示例
undici-types 6.21.0
已验证示例 — npm undici-types 6.21.0. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: package manifest specifies index.d.ts type declarations and files…
sha256:1d8d83e2a9dfa46e0ec9221025b5252233942fd9cea5b6594b3728bb338c90fd
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 2
- 构建过它的签名密钥
- 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@1 |
2026-08-21 |
| 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-08 |
案例
HOW- 目标
- verify pkg:npm/undici-types@6.21.0
- 环境
- node 22.23.2
- 创建时间
- 2026-08-21T03:24:42Z
契约
- package manifest specifies index.d.ts type declarations and files field
- declares Dispatcher base class with dispatch, request, stream, pipeline, connect, and compose methods
- declares Client, Pool, BalancedPool, and Agent classes extending Dispatcher
- declares high-level request, stream, pipeline, connect, and upgrade API functions
- declares fetch, Headers, Request, Response, FormData, File, and FileReader web standards declarations
- declares Errors namespace with UndiciError base class and specific error subtypes
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
源代码
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/undici-types@6.21.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/undici-types@6.21.0
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:5ed3b4c413573333bbd9e39b61c8daae0204abf84e56bc3c9c4e6d00602b55b0","constraints":{"executionContext":"node"},"contract":["package manifest specifies index.d.ts type declarations and files field","declares Dispatcher base class with dispatch, request, stream, pipeline, connect, and compose methods","declares Client, Pool, BalancedPool, and Agent classes extending Dispatcher","declares high-level request, stream, pipeline, connect, and upgrade API functions","declares fetch, Headers, Request, Response, FormData, File, and FileReader web standards declarations","declares Errors namespace with UndiciError base class and specific error subtypes"],"goal":"verify pkg:npm/undici-types@6.21.0","kind":"HOW","packages":["pkg:npm/undici-types@6.21.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/undici-types@6.21.0"],"schemaVersion":1,"subject":"pkg:npm/undici-types@6.21.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-undici-types",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-undici-types",
"version": "1.0.0",
"license": "MIT-0",
"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": "sample-undici-types",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"undici-types": "6.21.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/undici-types@6.21.0",
"kind": "HOW",
"packages": [
"pkg:npm/undici-types@6.21.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';
const require = createRequire(import.meta.url);
// 1. Resolve undici-types package manifest and verify type declaration entry points
const pkgPath = require.resolve('undici-types/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
assert.equal(pkg.name, 'undici-types', 'Package name must be undici-types');
assert.equal(pkg.version, '6.21.0', 'Package version must be 6.21.0');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.ok(Array.isArray(pkg.files) && pkg.files.includes('*.d.ts'), 'Package files must include *.d.ts');
const typesDir = path.dirname(pkgPath);
const indexDts = fs.readFileSync(path.join(typesDir, 'index.d.ts'), 'utf8');
const dispatcherDts = fs.readFileSync(path.join(typesDir, 'dispatcher.d.ts'), 'utf8');
const clientDts = fs.readFileSync(path.join(typesDir, 'client.d.ts'), 'utf8');
const poolDts = fs.readFileSync(path.join(typesDir, 'pool.d.ts'), 'utf8');
const agentDts = fs.readFileSync(path.join(typesDir, 'agent.d.ts'), 'utf8');
const apiDts = fs.readFileSync(path.join(typesDir, 'api.d.ts'), 'utf8');
const fetchDts = fs.readFileSync(path.join(typesDir, 'fetch.d.ts'), 'utf8');
const errorsDts = fs.readFileSync(path.join(typesDir, 'errors.d.ts'), 'utf8');
// 2. Verify Dispatcher base class declaration and methods
assert.ok(
dispatcherDts.includes('declare class Dispatcher extends EventEmitter'),
'Dispatcher class must extend EventEmitter'
);
assert.ok(
dispatcherDts.includes('dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandlers): boolean;') &&
dispatcherDts.includes('request(options: Dispatcher.RequestOptions): Promise<Dispatcher.ResponseData>;') &&
dispatcherDts.includes('stream(options: Dispatcher.RequestOptions, factory: Dispatcher.StreamFactory): Promise<Dispatcher.StreamData>;') &&
dispatcherDts.includes('pipeline(options: Dispatcher.PipelineOptions, handler: Dispatcher.PipelineHandler): Duplex;') &&
dispatcherDts.includes('connect(options: Dispatcher.ConnectOptions): Promise<Dispatcher.ConnectData>;') &&
dispatcherDts.includes('compose(dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;'),
'Dispatcher must declare dispatch, request, stream, pipeline, connect, and compose methods'
);
// 3. Verify Client, Pool, BalancedPool, and Agent classes extending Dispatcher
assert.ok(
clientDts.includes('export class Client extends Dispatcher') &&
clientDts.includes('constructor(url: string | URL, options?: Client.Options);'),
'Client class must extend Dispatcher'
);
assert.ok(
poolDts.includes('declare class Pool extends Dispatcher') &&
poolDts.includes('constructor(url: string | URL, options?: Pool.Options)'),
'Pool class must extend Dispatcher'
);
assert.ok(
agentDts.includes('declare class Agent extends Dispatcher') &&
agentDts.includes('constructor(opts?: Agent.Options)'),
'Agent class must extend Dispatcher'
);
assert.ok(
indexDts.includes('export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent'),
'index.d.ts must export Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, and Agent'
);
// 4. Verify high-level request, stream, pipeline, connect, and upgrade API functions
assert.ok(
apiDts.includes('declare function request(') &&
apiDts.includes('declare function stream(') &&
apiDts.includes('declare function pipeline(') &&
apiDts.includes('declare function connect(') &&
apiDts.includes('declare function upgrade('),
'api.d.ts must declare request, stream, pipeline, connect, and upgrade functions'
);
// 5. Verify fetch, Headers, Request, Response, FormData, File, and FileReader web standards declarations
assert.ok(
fetchDts.includes('export declare function fetch (') &&
fetchDts.includes('export type RequestInfo = string | URL | Request') &&
fetchDts.includes('export class BodyMixin'),
'fetch.d.ts must declare fetch function, RequestInfo, and BodyMixin'
);
assert.ok(
indexDts.includes("export * from './fetch'") &&
indexDts.includes("export * from './formdata'") &&
indexDts.includes("export * from './file'") &&
indexDts.includes("export * from './filereader'"),
'index.d.ts must re-export fetch, formdata, file, and filereader types'
);
// 6. Verify Errors namespace with UndiciError and error subtypes
assert.ok(
errorsDts.includes('export class UndiciError extends Error') &&
errorsDts.includes('export class ConnectTimeoutError extends UndiciError') &&
errorsDts.includes('export class HeadersTimeoutError extends UndiciError') &&
errorsDts.includes('export class BodyTimeoutError extends UndiciError') &&
errorsDts.includes('export class ResponseStatusCodeError extends UndiciError'),
'errors.d.ts must declare UndiciError and specific error subtypes'
);
console.log('Contract tests passed successfully.');
原始种子者
匿名