サンプル
@types/node 20.19.27
検証済みサンプル — npm @types/node 20.19.27. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: @types/node@20.19.27 package.json declares version 20.19.27…
sha256:2c40d17424ccddce9a27a0e009b3d7148c1394069130431ae2e7de1b4ba3e087
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- verify pkg:npm/%40types/node@20.19.27
- パッケージ
- 環境
- node 22.23.2
- 作成日
- 2026-11-28T23:59:02Z
コントラクト
- @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
- 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
- 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
ファイル
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/inspect.cjs
- test/contract.cjs
ソース
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.
{"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"}
{
"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"
}
}
}
{
"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"
}
}
{
"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"
}
}
"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,
};
"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");
オリジンシーダー
匿名