Пример
electron-updater 6.8.9: autoUpdater
Проверенный пример — npm electron-updater 6.8.9: autoUpdater. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:7ebd4488fc03e2c3e7ed51b733b025c0076a88ff2d84416acaade86ad1b61b54
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-26 |
Кейс
HOW- Цель
- verify autoUpdater in pkg:npm/electron-updater@6.8.9
- Пакеты
- Символы
-
- autoUpdater
- Окружение
- node 22.23.2
- Создан
- 2026-08-26T10:54:51Z
Контракт
- autoUpdater singleton is exported by electron-updater and reports current application version
- autoUpdater configurable properties include channel, allowPrerelease, allowDowngrade, autoDownload, and autoInstallOnAppQuit
- autoUpdater setFeedURL and addAuthHeader configure update feed and authorization headers
- autoUpdater checkForUpdates detects new version and emits checking-for-update and update-available events
- autoUpdater downloadUpdate retrieves update package and emits download-progress and update-downloaded events
- autoUpdater checkForUpdates emits update-not-available when current version is up to date
- autoUpdater signals helper provides progress, updateDownloaded, and updateCancelled registration hooks
Файлы
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
Исходный код
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify autoUpdater in pkg:npm/electron-updater@6.8.9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/electron-updater@6.8.9
Demonstrate these symbols/APIs:
- autoUpdater
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:3cf5b885f224dffc838e6473143db93cb533a824dd8dca5e1cf50c3e1c9308e3","contract":["autoUpdater singleton is exported by electron-updater and reports current application version","autoUpdater configurable properties include channel, allowPrerelease, allowDowngrade, autoDownload, and autoInstallOnAppQuit","autoUpdater setFeedURL and addAuthHeader configure update feed and authorization headers","autoUpdater checkForUpdates detects new version and emits checking-for-update and update-available events","autoUpdater downloadUpdate retrieves update package and emits download-progress and update-downloaded events","autoUpdater checkForUpdates emits update-not-available when current version is up to date","autoUpdater signals helper provides progress, updateDownloaded, and updateCancelled registration hooks"],"goal":"verify autoUpdater in pkg:npm/electron-updater@6.8.9","kind":"HOW","packages":["pkg:npm/electron-updater@6.8.9"],"schemaVersion":1,"symbols":["autoUpdater"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/electron-updater@6.8.9"],"schemaVersion":1,"subject":"pkg:npm/electron-updater@6.8.9","symbols":["autoUpdater"],"verifierAdapter":"node-typescript@1"}
const http = require("http");
const Module = require("module");
if (!process.resourcesPath) {
process.resourcesPath = process.cwd();
}
function setupMockElectron(appOptions = {}) {
const version = appOptions.version || "1.0.0";
const name = appOptions.name || "contract-updater-app";
const isPackaged = appOptions.isPackaged !== undefined ? appOptions.isPackaged : true;
const appPath = appOptions.appPath || process.cwd();
const userDataPath = appOptions.userDataPath || appPath;
const mockApp = {
getVersion: () => version,
getName: () => name,
isPackaged,
getAppPath: () => appPath,
getPath: (prop) => (prop === "userData" ? userDataPath : appPath),
whenReady: async () => {},
quit: () => {},
relaunch: () => {},
once: () => {},
};
const originalResolve = Module._resolveFilename;
Module._resolveFilename = function (request, parent, isMain, options) {
if (request === "electron") return "electron";
return originalResolve.call(this, request, parent, isMain, options);
};
require.cache["electron"] = {
id: "electron",
filename: "electron",
loaded: true,
exports: { app: mockApp },
};
return mockApp;
}
if (!require.cache["electron"]) {
setupMockElectron();
}
const {
autoUpdater,
NoOpLogger,
CancellationToken,
DOWNLOAD_PROGRESS,
UPDATE_DOWNLOADED,
} = require("electron-updater");
const { HttpExecutor, configureRequestUrl, configureRequestOptions } = require("builder-util-runtime");
class NodeHttpExecutor extends HttpExecutor {
async download(url, destination, options) {
return await options.cancellationToken.createPromise((resolve, reject, onCancel) => {
const requestOptions = {
headers: options.headers || undefined,
redirect: "manual",
};
configureRequestUrl(url, requestOptions);
configureRequestOptions(requestOptions);
this.doDownload(
requestOptions,
{
destination,
options,
onCancel,
callback: (error) => {
if (error == null) {
resolve(destination);
} else {
reject(error);
}
},
responseHandler: null,
},
0
);
});
}
createRequest(options, callback) {
return http.request(options, callback);
}
}
module.exports = {
setupMockElectron,
NodeHttpExecutor,
autoUpdater,
NoOpLogger,
CancellationToken,
DOWNLOAD_PROGRESS,
UPDATE_DOWNLOADED,
};
{
"name": "electron-updater-contract",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "electron-updater-contract",
"version": "1.0.0",
"dependencies": {
"electron-updater": "6.8.9"
}
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"license": "Python-2.0"
},
"node_modules/builder-util-runtime": {
"version": "9.7.0",
"resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.7.0.tgz",
"integrity": "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw==",
"license": "MIT",
"dependencies": {
"debug": "^4.3.4",
"sax": "^1.2.4"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/electron-updater": {
"version": "6.8.9",
"resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.8.9.tgz",
"integrity": "sha512-ZhVxM9iGONUpZGI1FxdMRgJjUFXi7AYGVa5PwKlO1tV1/4zDxQmfKpXOHVztKrd6L9rLcFjERvi1Mf2vxyTkig==",
"license": "MIT",
"dependencies": {
"builder-util-runtime": "9.7.0",
"fs-extra": "^10.1.0",
"js-yaml": "^4.1.0",
"lazy-val": "^1.0.5",
"lodash.escaperegexp": "^4.1.2",
"lodash.isequal": "^4.5.0",
"semver": "~7.7.3",
"tiny-typed-emitter": "^2.1.0"
}
},
"node_modules/fs-extra": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
},
"engines": {
"node": ">=12"
}
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"license": "ISC"
},
"node_modules/js-yaml": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
"integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/jsonfile": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
"integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
"license": "MIT",
"dependencies": {
"universalify": "^2.0.0"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/lazy-val": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz",
"integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==",
"license": "MIT"
},
"node_modules/lodash.escaperegexp": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz",
"integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==",
"license": "MIT"
},
"node_modules/lodash.isequal": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
"integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
"deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.",
"license": "MIT"
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/sax": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz",
"integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=11.0.0"
}
},
"node_modules/semver": {
"version": "7.7.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/tiny-typed-emitter": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",
"integrity": "sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==",
"license": "MIT"
},
"node_modules/universalify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
"license": "MIT",
"engines": {
"node": ">= 10.0.0"
}
}
}
}
{
"name": "electron-updater-contract",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for electron-updater autoUpdater",
"main": "index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"electron-updater": "6.8.9"
}
}
{
"schemaVersion": 1,
"goal": "verify autoUpdater in pkg:npm/electron-updater@6.8.9",
"kind": "HOW",
"packages": [
"pkg:npm/electron-updater@6.8.9"
],
"symbols": [
"autoUpdater"
]
}
const assert = require("assert");
const http = require("http");
const path = require("path");
const os = require("os");
const fs = require("fs");
const crypto = require("crypto");
const {
setupMockElectron,
NodeHttpExecutor,
autoUpdater,
NoOpLogger,
CancellationToken,
DOWNLOAD_PROGRESS,
UPDATE_DOWNLOADED,
} = require("../index.js");
async function main() {
// 1. Setup isolated directories and mock electron app
const uniqueId = Math.random().toString(36).substring(2, 8);
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "electron-auto-updater-" + uniqueId + "-"));
const userDataDir = path.join(tempDir, "userData");
const cacheDir = path.join(tempDir, "cache");
const configPath = path.join(tempDir, "app-update.yml");
const mockAppImage = path.join(tempDir, "contract-app-1.0.0.AppImage");
fs.mkdirSync(userDataDir, { recursive: true });
fs.mkdirSync(cacheDir, { recursive: true });
fs.writeFileSync(configPath, "provider: generic\n");
fs.writeFileSync(mockAppImage, "contract-app-payload-v1.0.0");
process.resourcesPath = tempDir;
process.env["APPIMAGE"] = mockAppImage;
const appName = "contract-updater-" + uniqueId;
setupMockElectron({
version: "1.0.0",
name: appName,
isPackaged: true,
appPath: tempDir,
userDataPath: userDataDir,
});
// 2. Mock offline HTTP update server
const installerPayload = Buffer.from("contract-test-installer-binary-payload-v1.2.0");
const installerSha512 = crypto.createHash("sha512").update(installerPayload).digest("base64");
let serverMode = "available";
const server = http.createServer((req, res) => {
if (req.url.includes(".yml")) {
const version = serverMode === "available" ? "1.2.0" : "1.0.0";
const ymlContent = `version: ${version}
files:
- url: contract-app-${version}.AppImage
sha512: ${installerSha512}
size: ${installerPayload.length}
path: contract-app-${version}.AppImage
sha512: ${installerSha512}
releaseDate: 2026-01-01T00:00:00.000Z
`;
res.writeHead(200, { "Content-Type": "text/yaml" });
res.end(ymlContent);
} else if (req.url.includes(".AppImage") || req.url.includes("contract-app")) {
res.writeHead(200, {
"Content-Type": "application/octet-stream",
"Content-Length": installerPayload.length,
});
res.end(installerPayload);
} else {
res.writeHead(404);
res.end();
}
});
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
const serverPort = server.address().port;
const feedUrl = `http://127.0.0.1:${serverPort}`;
try {
// 3. Verify autoUpdater singleton export and current version
assert(autoUpdater, "autoUpdater singleton should be exported");
assert.strictEqual(typeof autoUpdater.checkForUpdates, "function", "checkForUpdates should be a function");
assert.strictEqual(typeof autoUpdater.downloadUpdate, "function", "downloadUpdate should be a function");
assert.strictEqual(autoUpdater.currentVersion.version, "1.0.0", "currentVersion should report 1.0.0");
// 4. Configure autoUpdater properties
autoUpdater.httpExecutor = new NodeHttpExecutor();
autoUpdater.logger = new NoOpLogger();
autoUpdater.autoDownload = false;
autoUpdater.allowPrerelease = true;
autoUpdater.allowDowngrade = false;
autoUpdater.channel = "beta";
autoUpdater.autoInstallOnAppQuit = true;
autoUpdater.disableDifferentialDownload = true;
// Clear download helper cache to ensure clean download test
const downloadHelper = await autoUpdater.getOrCreateDownloadHelper();
await downloadHelper.clear();
assert.strictEqual(autoUpdater.autoDownload, false, "autoDownload should be false");
assert.strictEqual(autoUpdater.allowPrerelease, true, "allowPrerelease should be true");
assert.strictEqual(autoUpdater.channel, "beta", "channel should be beta");
assert.strictEqual(autoUpdater.autoInstallOnAppQuit, true, "autoInstallOnAppQuit should be true");
// 5. Configure feed URL and authentication header
autoUpdater.setFeedURL({
provider: "generic",
url: feedUrl,
});
autoUpdater.addAuthHeader("Bearer contract-auth-token-xyz");
assert.strictEqual(
autoUpdater.requestHeaders.authorization,
"Bearer contract-auth-token-xyz",
"authorization header should be configured"
);
// 6. Check for updates (update available)
let checkingEmitted = false;
let availableInfo = null;
autoUpdater.on("checking-for-update", () => {
checkingEmitted = true;
});
autoUpdater.on("update-available", (info) => {
availableInfo = info;
});
const checkResult = await autoUpdater.checkForUpdates();
assert(checkResult, "checkForUpdates result should exist");
assert.strictEqual(checkResult.isUpdateAvailable, true, "isUpdateAvailable should be true");
assert.strictEqual(checkResult.updateInfo.version, "1.2.0", "update version should be 1.2.0");
assert.strictEqual(checkingEmitted, true, "checking-for-update event should have fired");
assert(availableInfo, "update-available event should have fired");
assert.strictEqual(availableInfo.version, "1.2.0", "availableInfo version should match");
// 7. Download update and verify progress + downloaded events and signals hooks
let progressFired = false;
let downloadedInfo = null;
let signalProgressFired = false;
let signalDownloadedFired = false;
autoUpdater.on(DOWNLOAD_PROGRESS, (progress) => {
progressFired = true;
assert(progress.percent >= 0 && progress.percent <= 100, "progress percent should be 0-100");
});
autoUpdater.on(UPDATE_DOWNLOADED, (info) => {
downloadedInfo = info;
});
assert(autoUpdater.signals, "autoUpdater.signals should exist");
autoUpdater.signals.progress((progress) => {
signalProgressFired = true;
});
autoUpdater.signals.updateDownloaded((info) => {
signalDownloadedFired = true;
});
const downloadedFiles = await autoUpdater.downloadUpdate();
assert(Array.isArray(downloadedFiles) && downloadedFiles.length > 0, "downloadedFiles should be a non-empty array");
assert.strictEqual(progressFired, true, "DOWNLOAD_PROGRESS event should have fired");
assert.strictEqual(signalProgressFired, true, "signals.progress hook should have fired");
assert(downloadedInfo, "UPDATE_DOWNLOADED event should have fired");
assert.strictEqual(signalDownloadedFired, true, "signals.updateDownloaded hook should have fired");
assert.strictEqual(downloadedInfo.version, "1.2.0", "downloadedInfo version should match 1.2.0");
const downloadedFilePath = downloadedFiles[0];
assert(fs.existsSync(downloadedFilePath), "downloaded file should exist on disk");
const downloadedContent = fs.readFileSync(downloadedFilePath);
assert.deepStrictEqual(downloadedContent, installerPayload, "downloaded content should match payload");
// 8. Check for updates (update not available)
serverMode = "not-available";
autoUpdater.downloadPromise = null;
autoUpdater.updateInfoAndProvider = null;
autoUpdater.allowDowngrade = false;
let notAvailableInfo = null;
autoUpdater.on("update-not-available", (info) => {
notAvailableInfo = info;
});
const notAvailableResult = await autoUpdater.checkForUpdates();
assert(notAvailableResult, "notAvailableResult should exist");
assert.strictEqual(notAvailableResult.isUpdateAvailable, false, "isUpdateAvailable should be false");
assert.strictEqual(notAvailableResult.updateInfo.version, "1.0.0", "version should be 1.0.0");
assert(notAvailableInfo, "update-not-available event should have fired");
assert.strictEqual(notAvailableInfo.version, "1.0.0", "notAvailableInfo version should match 1.0.0");
// 9. Signals helper contract
assert.strictEqual(typeof autoUpdater.signals.progress, "function", "signals.progress should be a function");
assert.strictEqual(
typeof autoUpdater.signals.updateDownloaded,
"function",
"signals.updateDownloaded should be a function"
);
assert.strictEqual(
typeof autoUpdater.signals.updateCancelled,
"function",
"signals.updateCancelled should be a function"
);
console.log("autoUpdater contract successfully verified.");
} finally {
server.close();
fs.rmSync(tempDir, { recursive: true, force: true });
delete process.env["APPIMAGE"];
}
}
main().catch((err) => {
console.error("Contract test failed:", err);
process.exit(1);
});
Исходный сидер
аноним