CodeSampleX

Sample

node-abi 4.33.0: supportedTargets

Verified sample for npm node-abi 4.33.0: supportedTargets. The contract ran on node 22 · linux debian/x64 · docker and passed.

sha256:0995083e3478743bd310f533765717359b88b42e6ccea6ecaf38a15f71d1a99a

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
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-04

Case

HOW
Goal
verify node-abi.supportedTargets in pkg:npm/node-abi@4.33.0
Packages
Symbols
  • node-abi.supportedTargets
Created
2026-09-04T12:51:50Z

Contract

  1. supportedTargets is exported as an array from node-abi
  2. supportedTargets contains target objects each having string properties runtime, target, abi, and boolean lts
  3. supportedTargets contains targets for both node and electron runtimes
  4. supportedTargets includes major Node.js releases such as 22.0.0 with ABI 127 and 20.0.0 with ABI 115
  5. supportedTargets includes Electron release targets such as 30.0.0-alpha.1 with ABI 123
  6. supportedTargets contains LTS targets marked with lts boolean true
  7. all targets in supportedTargets are consistent with getAbi mapping
  8. isTargetSupported correctly detects supported and unsupported versions for node and electron runtimes

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
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@4.33.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/node-abi@4.33.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.
csx.json
{"case":{"caseId":"case:sha256:31b7941fddc921f6805143bee74d59b6d43d0d3d7100bc280e69332fa6f3b490","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@4.33.0","kind":"HOW","packages":["pkg:npm/node-abi@4.33.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@4.33.0"],"schemaVersion":1,"subject":"pkg:npm/node-abi@4.33.0","symbols":["node-abi.supportedTargets"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "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": "4.33.0"
      }
    },
    "node_modules/node-abi": {
      "version": "4.33.0",
      "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.33.0.tgz",
      "integrity": "sha512-vLBWCKb+7LWsX+TbfzWOkw0W81m377tyx3hOweBTjO43CXZnRGS1/JPWs20fr0PgZyDXk6ROYrylsEycK8raDA==",
      "license": "MIT",
      "dependencies": {
        "semver": "^7.6.3"
      },
      "engines": {
        "node": ">=22.12.0"
      }
    },
    "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"
      }
    }
  }
}
package.json
{
  "name": "sample-node-abi",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for node-abi supportedTargets in node-abi@4.33.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "node-abi": "4.33.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify node-abi.supportedTargets in pkg:npm/node-abi@4.33.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-abi@4.33.0"
  ],
  "symbols": [
    "node-abi.supportedTargets"
  ]
}
src/index.js
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
};
test/contract.mjs
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);
});

Origin Seeder

anonymous