Exemple
node-abi 3.96.0: supportedTargets
Échantillon vérifié pour npm node-abi 3.96.0: supportedTargets. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:3624ba51f6add76b6b82782a4640d73279cd4d86a6ad855b4f3644f7294974a1
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-14 |
Cas
HOW- Objectif
- verify node-abi.supportedTargets in pkg:npm/node-abi@3.96.0
- Paquets
- Symboles
-
- node-abi.supportedTargets
- Créé
- 2026-09-14T23:34:08Z
Contrat
- supportedTargets is exported as an array from node-abi
- supportedTargets contains target objects each having string properties runtime, target, abi, and boolean lts
- supportedTargets contains targets for both node and electron runtimes
- supportedTargets includes major Node.js releases such as 22.0.0 with ABI 127 and 20.0.0 with ABI 115
- supportedTargets includes Electron release targets such as 30.0.0-alpha.1 with ABI 123
- supportedTargets contains LTS targets marked with lts boolean true
- all targets in supportedTargets are consistent with getAbi mapping
- isTargetSupported correctly detects supported and unsupported versions for node and electron runtimes
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Code source
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 node-abi.supportedTargets in pkg:npm/node-abi@3.96.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/node-abi@3.96.0
Demonstrate these symbols/APIs:
- node-abi.supportedTargets
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:6c6d690ae4db3ae916b0af00f23700f90753cf6358d64d5ab4d0eee5afad8a21","contract":["supportedTargets is exported as an array from node-abi","supportedTargets contains target objects each having string properties runtime, target, abi, and boolean lts","supportedTargets contains targets for both node and electron runtimes","supportedTargets includes major Node.js releases such as 22.0.0 with ABI 127 and 20.0.0 with ABI 115","supportedTargets includes Electron release targets such as 30.0.0-alpha.1 with ABI 123","supportedTargets contains LTS targets marked with lts boolean true","all targets in supportedTargets are consistent with getAbi mapping","isTargetSupported correctly detects supported and unsupported versions for node and electron runtimes"],"goal":"verify node-abi.supportedTargets in pkg:npm/node-abi@3.96.0","kind":"HOW","packages":["pkg:npm/node-abi@3.96.0"],"schemaVersion":1,"symbols":["node-abi.supportedTargets"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/node-abi@3.96.0"],"schemaVersion":1,"subject":"pkg:npm/node-abi@3.96.0","symbols":["node-abi.supportedTargets"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-node-abi",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-node-abi",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"node-abi": "3.96.0"
}
},
"node_modules/node-abi": {
"version": "3.96.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.96.0.tgz",
"integrity": "sha512-rebQ/lz7i0EkoLzUVSrKRzA69zMkwLp95kKMWoMDkkM00Suxz0D7zEQPwRml5fQum24mj7bPvmlgLAmu2JCiYg==",
"license": "MIT",
"dependencies": {
"semver": "^7.3.5"
},
"engines": {
"node": ">=10"
}
},
"node_modules/semver": {
"version": "7.8.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
}
}
}
{
"name": "sample-node-abi",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for node-abi supportedTargets in node-abi@3.96.0",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"node-abi": "3.96.0"
}
}
{
"schemaVersion": 1,
"goal": "verify node-abi.supportedTargets in pkg:npm/node-abi@3.96.0",
"kind": "HOW",
"packages": [
"pkg:npm/node-abi@3.96.0"
],
"symbols": [
"node-abi.supportedTargets"
]
}
const nodeAbi = require('node-abi');
/**
* Returns the array of supported target descriptors.
*
* @returns {Array<object>} Supported targets array.
*/
function getSupportedTargets() {
return nodeAbi.supportedTargets;
}
/**
* Filters supported targets by runtime ('node' or 'electron').
*
* @param {string} runtime - Target runtime name ('node' or 'electron').
* @returns {Array<object>} Filtered supported target descriptors.
*/
function getSupportedTargetsByRuntime(runtime) {
return nodeAbi.supportedTargets.filter((target) => target.runtime === runtime);
}
/**
* Checks if a specific target version is present in supportedTargets for a given runtime.
*
* @param {string} targetVersion - Runtime target version string (e.g. '22.0.0').
* @param {string} [runtime='node'] - Target runtime ('node' or 'electron').
* @returns {boolean} True if target is in supportedTargets.
*/
function isTargetSupported(targetVersion, runtime = 'node') {
return nodeAbi.supportedTargets.some(
(t) => t.runtime === runtime && t.target === targetVersion
);
}
/**
* Finds target descriptor in supportedTargets for a given target version and runtime.
*
* @param {string} targetVersion - Runtime target version string.
* @param {string} [runtime='node'] - Target runtime ('node' or 'electron').
* @returns {object|undefined} The target object if found.
*/
function findSupportedTarget(targetVersion, runtime = 'node') {
return nodeAbi.supportedTargets.find(
(t) => t.runtime === runtime && t.target === targetVersion
);
}
module.exports = {
nodeAbi,
supportedTargets: nodeAbi.supportedTargets,
getSupportedTargets,
getSupportedTargetsByRuntime,
isTargetSupported,
findSupportedTarget
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
nodeAbi,
supportedTargets,
getSupportedTargets,
getSupportedTargetsByRuntime,
isTargetSupported,
findSupportedTarget
} = require('../src/index.js');
async function runTests() {
// 1. supportedTargets is exported as an array from node-abi
assert(Array.isArray(nodeAbi.supportedTargets), 'nodeAbi.supportedTargets must be an array');
assert(Array.isArray(supportedTargets), 'supportedTargets must be an array');
assert.equal(getSupportedTargets(), supportedTargets, 'getSupportedTargets should return supportedTargets');
assert(supportedTargets.length > 0, 'supportedTargets must not be empty');
// 2. supportedTargets contains target objects each having string properties runtime, target, abi, and boolean lts
for (const t of supportedTargets) {
assert.equal(typeof t.runtime, 'string', 'target.runtime must be a string');
assert.equal(typeof t.target, 'string', 'target.target must be a string');
assert.equal(typeof t.abi, 'string', 'target.abi must be a string');
assert.equal(typeof t.lts, 'boolean', 'target.lts must be a boolean');
}
// 3. supportedTargets contains targets for both node and electron runtimes
const runtimes = new Set(supportedTargets.map((t) => t.runtime));
assert(runtimes.has('node'), 'supportedTargets must contain node runtime targets');
assert(runtimes.has('electron'), 'supportedTargets must contain electron runtime targets');
const nodeTargets = getSupportedTargetsByRuntime('node');
const electronTargets = getSupportedTargetsByRuntime('electron');
assert(nodeTargets.length > 0, 'nodeTargets must not be empty');
assert(electronTargets.length > 0, 'electronTargets must not be empty');
assert.equal(nodeTargets.length + electronTargets.length, supportedTargets.length);
// 4. supportedTargets includes major Node.js releases such as 22.0.0 with ABI 127 and 20.0.0 with ABI 115
const node22 = findSupportedTarget('22.0.0', 'node');
assert(node22, 'node 22.0.0 must be present in supportedTargets');
assert.equal(node22.abi, '127', 'node 22.0.0 ABI should be 127');
const node20 = findSupportedTarget('20.0.0', 'node');
assert(node20, 'node 20.0.0 must be present in supportedTargets');
assert.equal(node20.abi, '115', 'node 20.0.0 ABI should be 115');
// 5. supportedTargets includes Electron release targets such as 30.0.0-alpha.1 with ABI 123
const electron30 = findSupportedTarget('30.0.0-alpha.1', 'electron');
assert(electron30, 'electron 30.0.0-alpha.1 must be present in supportedTargets');
assert.equal(electron30.abi, '123', 'electron 30.0.0-alpha.1 ABI should be 123');
// 6. supportedTargets contains LTS targets marked with lts boolean true
const ltsTargets = supportedTargets.filter((t) => t.lts === true);
assert(ltsTargets.length > 0, 'supportedTargets must have at least one LTS target');
for (const t of ltsTargets) {
assert.equal(t.runtime, 'node', 'LTS target runtime must be node');
}
// 7. all targets in supportedTargets are consistent with getAbi mapping
for (const t of supportedTargets) {
const resolvedAbi = nodeAbi.getAbi(t.target, t.runtime);
assert.equal(
resolvedAbi,
t.abi,
`getAbi(${t.target}, ${t.runtime}) should match target.abi ${t.abi}`
);
}
// 8. isTargetSupported correctly detects supported and unsupported versions for node and electron runtimes
assert.equal(isTargetSupported('22.0.0', 'node'), true);
assert.equal(isTargetSupported('999.0.0', 'node'), false);
assert.equal(isTargetSupported('30.0.0-alpha.1', 'electron'), true);
assert.equal(isTargetSupported('999.0.0', 'electron'), false);
console.log('All contract assertions for node-abi.supportedTargets passed successfully.');
}
runTests().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Seeder d'origine
anonyme