CodeSampleX

Beispiel

@types/node 20.19.27

Verifiziertes Beispiel für npm @types/node 20.19.27. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: @types/node@20.19.27 package.json…

sha256:2c40d17424ccddce9a27a0e009b3d7148c1394069130431ae2e7de1b4ba3e087

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-11-28

Fall

HOW
Ziel
verify pkg:npm/%40types/node@20.19.27
Pakete
Umgebung
node 22.23.2
Erstellt
2026-11-28T23:59:02Z

Contract

  1. @types/node@20.19.27 package.json declares version 20.19.27, types index.d.ts, empty main (so require('@types/node') throws MODULE_NOT_FOUND), typeScriptVersion 5.2, typesVersions <=5.6 mapping to ts5.6/*, and undici-types ~6.21.0
  2. Every /// <reference path="..." /> directive in both root index.d.ts (TypeScript 5.7+) and ts5.6/index.d.ts (TypeScript <=5.6) resolves to an existing non-empty .d.ts file
  3. Transitive dependency undici-types@6.21.x resolves from @types/node and backs global fetch, Headers, Request, and Response declarations in web-globals/fetch.d.ts
  4. Core declaration files (fs.d.ts, crypto.d.ts, path.d.ts, util.d.ts, process.d.ts) declare both bare and node:-prefixed modules, and test.d.ts declares node:test
  5. Node 20.19 API declarations (crypto.hash, process.getBuiltinModule, URL.canParse, util.parseArgs) are present in the installed .d.ts files and match callable Node runtime built-ins

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/inspect.cjs
  • test/contract.cjs

Quellartefakt herunterladen (tar.gz)

Quelltext

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 pkg:npm/%40types/node@20.19.27
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/node@20.19.27
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:17c8ef38ae21a4e9927a6fc92f0df75a479e5aea8e131bd1952a5f56bc6ef024","constraints":{"executionContext":"node"},"contract":["@types/node@20.19.27 package.json declares version 20.19.27, types index.d.ts, empty main (so require('@types/node') throws MODULE_NOT_FOUND), typeScriptVersion 5.2, typesVersions \u003c=5.6 mapping to ts5.6/*, and undici-types ~6.21.0","Every /// \u003creference path=\"...\" /\u003e directive in both root index.d.ts (TypeScript 5.7+) and ts5.6/index.d.ts (TypeScript \u003c=5.6) resolves to an existing non-empty .d.ts file","Transitive dependency undici-types@6.21.x resolves from @types/node and backs global fetch, Headers, Request, and Response declarations in web-globals/fetch.d.ts","Core declaration files (fs.d.ts, crypto.d.ts, path.d.ts, util.d.ts, process.d.ts) declare both bare and node:-prefixed modules, and test.d.ts declares node:test","Node 20.19 API declarations (crypto.hash, process.getBuiltinModule, URL.canParse, util.parseArgs) are present in the installed .d.ts files and match callable Node runtime built-ins"],"goal":"verify pkg:npm/%40types/node@20.19.27","kind":"HOW","packages":["pkg:npm/%40types/node@20.19.27"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","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/%40types/node@20.19.27"],"schemaVersion":1,"subject":"pkg:npm/%40types/node@20.19.27","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-types-node",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-types-node",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/node": "20.19.27"
      }
    },
    "node_modules/@types/node": {
      "version": "20.19.27",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.27.tgz",
      "integrity": "sha512-N2clP5pJhB2YnZJ3PIHFk5RkygRX5WO/5f0WC08tp0wd+sv0rsJk3MqWn3CbNmT2J505a5336jaQj4ph1AdMug==",
      "license": "MIT",
      "dependencies": {
        "undici-types": "~6.21.0"
      }
    },
    "node_modules/undici-types": {
      "version": "6.21.0",
      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
      "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "verify-types-node",
  "version": "1.0.0",
  "private": true,
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@types/node": "20.19.27"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/node@20.19.27",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/node@20.19.27"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/inspect.cjs
"use strict";

const fs = require("node:fs");
const path = require("node:path");

function resolveTypesNodeRoot() {
  const pkgJsonPath = require.resolve("@types/node/package.json");
  const pkgDir = path.dirname(pkgJsonPath);
  const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
  return { pkgJsonPath, pkgDir, pkg };
}

function collectReferencePaths(dtsFilePath) {
  const content = fs.readFileSync(dtsFilePath, "utf8");
  const matches = [];
  const pattern = /^\/\/\/\s*<reference\s+path="([^"]+)"\s*\/>/gm;
  let match;
  while ((match = pattern.exec(content)) !== null) {
    matches.push(match[1]);
  }
  return matches;
}

function verifyReferenceTree(entryDtsPath) {
  const refs = collectReferencePaths(entryDtsPath);
  const entryDir = path.dirname(entryDtsPath);
  const resolved = refs.map((rel) => {
    const abs = path.resolve(entryDir, rel);
    const stat = fs.statSync(abs);
    return { rel, exists: stat.isFile(), size: stat.size };
  });
  return { entryDtsPath, count: refs.length, resolved };
}

function readDeclaration(pkgDir, relativePath) {
  return fs.readFileSync(path.join(pkgDir, relativePath), "utf8");
}

module.exports = {
  resolveTypesNodeRoot,
  collectReferencePaths,
  verifyReferenceTree,
  readDeclaration,
};
test/contract.cjs
"use strict";

const assert = require("node:assert/strict");
const crypto = require("node:crypto");
const fs = require("node:fs");
const path = require("node:path");
const util = require("node:util");
const {
  resolveTypesNodeRoot,
  verifyReferenceTree,
  readDeclaration,
} = require("../src/inspect.cjs");

// 1. Package metadata and type-only entry point behavior
const { pkgDir, pkg } = resolveTypesNodeRoot();
assert.equal(pkg.name, "@types/node");
assert.equal(pkg.version, "20.19.27");
assert.equal(pkg.types, "index.d.ts");
assert.equal(pkg.main, "");
assert.equal(pkg.typeScriptVersion, "5.2");
assert.deepEqual(pkg.typesVersions["<=5.6"]["*"], ["ts5.6/*"]);
assert.equal(pkg.dependencies["undici-types"], "~6.21.0");

assert.throws(
  () => {
    require("@types/node");
  },
  (err) => err && err.code === "MODULE_NOT_FOUND",
);

// 2. Both TS 5.7+ root index.d.ts and TS <=5.6 ts5.6/index.d.ts resolve all reference paths
const rootIndexPath = path.join(pkgDir, pkg.types);
const rootTree = verifyReferenceTree(rootIndexPath);
assert.ok(rootTree.count >= 50, `expected >= 50 reference directives, got ${rootTree.count}`);
for (const entry of rootTree.resolved) {
  assert.equal(entry.exists, true, `missing referenced declaration: ${entry.rel}`);
  assert.ok(entry.size > 0, `empty referenced declaration: ${entry.rel}`);
}

const ts56IndexPath = path.join(pkgDir, "ts5.6", "index.d.ts");
const ts56Tree = verifyReferenceTree(ts56IndexPath);
assert.equal(ts56Tree.count, rootTree.count);
for (const entry of ts56Tree.resolved) {
  assert.equal(entry.exists, true, `missing ts5.6 referenced declaration: ${entry.rel}`);
  assert.ok(entry.size > 0, `empty ts5.6 referenced declaration: ${entry.rel}`);
}

// 3. Transitive undici-types dependency resolves and backs web-globals/fetch.d.ts
const undiciPkgPath = require.resolve("undici-types/package.json", { paths: [pkgDir] });
const undiciPkg = JSON.parse(fs.readFileSync(undiciPkgPath, "utf8"));
assert.equal(undiciPkg.name, "undici-types");
assert.match(undiciPkg.version, /^6\.21\./);

const fetchDts = readDeclaration(pkgDir, "web-globals/fetch.d.ts");
assert.match(fetchDts, /import \* as undici from "undici-types";/);
assert.match(fetchDts, /function fetch\(/);
assert.match(fetchDts, /interface Headers extends _Headers/);
assert.match(fetchDts, /interface Request extends _Request/);
assert.match(fetchDts, /interface Response extends _Response/);

// 4. Core built-in modules declare both unprefixed and node:-prefixed modules (and node:test)
const dualModules = [
  ["fs.d.ts", "fs"],
  ["crypto.d.ts", "crypto"],
  ["path.d.ts", "path"],
  ["util.d.ts", "util"],
  ["process.d.ts", "process"],
];
for (const [file, modName] of dualModules) {
  const text = readDeclaration(pkgDir, file);
  assert.ok(text.includes(`declare module "${modName}"`), `${file} missing declare module "${modName}"`);
  assert.ok(text.includes(`declare module "node:${modName}"`), `${file} missing declare module "node:${modName}"`);
}
const testDts = readDeclaration(pkgDir, "test.d.ts");
assert.ok(testDts.includes('declare module "node:test"'));

// 5. Node 20.19 API declarations exist and match live Node built-ins
const cryptoDts = readDeclaration(pkgDir, "crypto.d.ts");
assert.match(cryptoDts, /function hash\(algorithm: string, data: BinaryLike, outputEncoding\?: BinaryToTextEncoding\): string;/);
assert.equal(
  crypto.hash("sha256", "hello", "hex"),
  "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
);

const processDts = readDeclaration(pkgDir, "process.d.ts");
assert.match(processDts, /getBuiltinModule\(id: string\): object \| undefined;/);
assert.equal(process.getBuiltinModule("node:path"), path);

const urlDts = readDeclaration(pkgDir, "url.d.ts");
assert.match(urlDts, /static canParse\(input: string, base\?: string\): boolean;/);
assert.equal(URL.canParse("/items", "https://example.com"), true);
assert.equal(URL.canParse("not a url"), false);

const utilDts = readDeclaration(pkgDir, "util.d.ts");
assert.match(utilDts, /export function parseArgs<T extends ParseArgsConfig>\(config\?: T\): ParsedResults<T>;/);
const parsed = util.parseArgs({
  args: ["--flag", "--name", "demo"],
  options: {
    flag: { type: "boolean" },
    name: { type: "string" },
  },
});
assert.equal(Object.getPrototypeOf(parsed.values), null);
assert.deepEqual({ ...parsed.values }, { flag: true, name: "demo" });

console.log("OK: @types/node@20.19.27 contract verified");

Ursprungs-Seeder

anonym