Exemple
bare-url 2.5.2
Échantillon vérifié pour npm bare-url 2.5.2. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : package manifest specifies Bare…
sha256:d0b51bfd1aae9188136b48f9947c886d9634889d29ebe82f273d34642c4a8c7c
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é
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-23 |
Cas
HOW- Objectif
- verify pkg:npm/bare-url@2.5.2
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-08-23T16:01:41Z
Contrat
- package manifest specifies Bare addon configuration and exports for root, global, and package subpaths
- declares URL interface, URL namespace helper functions, and ambient global types in index.d.ts and global.d.ts
- URLSearchParams parses query strings, supports get, getAll, has, append, delete, set, size, serialization, and iteration
- URLError defines error hierarchy with specific static constructors including INVALID_URL and INVALID_FILE_URL_PATH
- ships native Bare C addon binding and CMakeLists build configuration
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- 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 pkg:npm/bare-url@2.5.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/bare-url@2.5.2
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:41f8fa80ae399b3457bae2a21d100289b10f53c295361f52db739b9961c0b187","constraints":{"executionContext":"node"},"contract":["package manifest specifies Bare addon configuration and exports for root, global, and package subpaths","declares URL interface, URL namespace helper functions, and ambient global types in index.d.ts and global.d.ts","URLSearchParams parses query strings, supports get, getAll, has, append, delete, set, size, serialization, and iteration","URLError defines error hierarchy with specific static constructors including INVALID_URL and INVALID_FILE_URL_PATH","ships native Bare C addon binding and CMakeLists build configuration"],"goal":"verify pkg:npm/bare-url@2.5.2","kind":"HOW","packages":["pkg:npm/bare-url@2.5.2"],"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/bare-url@2.5.2"],"schemaVersion":1,"subject":"pkg:npm/bare-url@2.5.2","verifierAdapter":"node-typescript@1"}
{
"name": "sample-bare-url",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-url",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"bare-url": "2.5.2"
}
},
"node_modules/bare-path": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.1.tgz",
"integrity": "sha512-JprUlveX3QjApC1cTpsUOiscADftCGVWkzitbHsRqv84hzYwYHw2mbluddsq5TvI8mH/8Ov1f4BiMAdcB0oYnQ==",
"license": "Apache-2.0"
},
"node_modules/bare-url": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.5.2.tgz",
"integrity": "sha512-L13PCJzKG8RGvx8V1/DdMi12ERhC3tprr7/8a94BxpmnRsFqxh5XZNdhtMxu5HPkRshYOOWRGY8lDP7ZhpG9Cg==",
"license": "Apache-2.0",
"dependencies": {
"bare-path": "^3.0.0"
}
}
}
}
{
"name": "sample-bare-url",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"bare-url": "2.5.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/bare-url@2.5.2",
"kind": "HOW",
"packages": [
"pkg:npm/bare-url@2.5.2"
],
"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 bare-url package manifest and verify exports and metadata
const pkgPath = require.resolve('bare-url/package');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
assert.equal(pkg.name, 'bare-url', 'Package name must be bare-url');
assert.equal(pkg.version, '2.5.2', 'Package version must be 2.5.2');
assert.equal(pkg.license, 'Apache-2.0', 'Package license must be Apache-2.0');
assert.equal(pkg.addon, true, 'Package must be marked as addon');
assert.ok(pkg.exports, 'Package must define exports');
assert.equal(pkg.exports['.'].types, './index.d.ts', 'Root export must specify index.d.ts types');
assert.equal(pkg.exports['.'].default, './index.js', 'Root export must specify index.js default');
assert.equal(pkg.exports['./global'].types, './global.d.ts', 'Global export must specify global.d.ts types');
assert.equal(pkg.exports['./global'].default, './global.js', 'Global export must specify global.js default');
assert.equal(pkg.exports['./package'], './package.json', 'Package export must point to package.json');
const pkgDir = path.dirname(pkgPath);
const indexDts = fs.readFileSync(path.join(pkgDir, 'index.d.ts'), 'utf8');
const globalDts = fs.readFileSync(path.join(pkgDir, 'global.d.ts'), 'utf8');
// 2. Verify index.d.ts and global.d.ts type definitions and API declarations
assert.ok(indexDts.includes('interface URL {'), 'index.d.ts must declare URL interface');
assert.ok(indexDts.includes('searchParams: URLSearchParams'), 'index.d.ts must declare searchParams property');
assert.ok(indexDts.includes('declare class URL {'), 'index.d.ts must declare URL class constructor');
assert.ok(indexDts.includes('export function isURL(value: unknown): value is URL'), 'index.d.ts must declare isURL guard');
assert.ok(indexDts.includes('export function isURLSearchParams(value: unknown): value is URLSearchParams'), 'index.d.ts must declare isURLSearchParams guard');
assert.ok(indexDts.includes('export function parse(input: string, base?: string | URL): URL | null'), 'index.d.ts must declare parse function');
assert.ok(indexDts.includes('export function canParse(input: string, base?: string | URL): boolean'), 'index.d.ts must declare canParse function');
assert.ok(indexDts.includes('export function fileURLToPath(url: URL | string): string'), 'index.d.ts must declare fileURLToPath');
assert.ok(indexDts.includes('export function pathToFileURL(pathname: string): URL'), 'index.d.ts must declare pathToFileURL');
assert.ok(globalDts.includes('declare global {'), 'global.d.ts must declare global augmentations');
assert.ok(globalDts.includes('type URL = url.URL'), 'global.d.ts must define URL global type');
assert.ok(globalDts.includes('type URLSearchParams = url.URLSearchParams'), 'global.d.ts must define URLSearchParams global type');
// 3. Verify URLSearchParams query parsing, manipulation, serialization, and iteration
const URLSearchParams = require(path.join(pkgDir, 'lib', 'url-search-params.js'));
const params = new URLSearchParams('topic=api&tag=v1&tag=v2&filter=active');
assert.equal(params.size, 4, 'size should count all parameters');
assert.equal(params.get('topic'), 'api', 'get should return first match');
assert.deepEqual(params.getAll('tag'), ['v1', 'v2'], 'getAll should return all matching values');
assert.equal(params.has('topic'), true, 'has should return true for existing key');
assert.equal(params.has('topic', 'api'), true, 'has should verify key and value');
assert.equal(params.has('topic', 'other'), false, 'has should return false for mismatched value');
params.append('tag', 'v3');
assert.deepEqual(params.getAll('tag'), ['v1', 'v2', 'v3']);
params.delete('tag', 'v1');
assert.deepEqual(params.getAll('tag'), ['v2', 'v3']);
params.set('filter', 'all');
assert.equal(params.get('filter'), 'all');
assert.equal(params.toString(), 'topic=api&tag=v2&tag=v3&filter=all');
assert.deepEqual(params.toJSON(), [
['topic', 'api'],
['tag', 'v2'],
['tag', 'v3'],
['filter', 'all']
]);
// Test iterator
const entries = Array.from(params);
assert.equal(entries.length, 4);
assert.deepEqual(entries[0], ['topic', 'api']);
// 4. Verify URLError error hierarchy and static error constructors
const URLError = require(path.join(pkgDir, 'lib', 'errors.js'));
const invalidUrlErr = URLError.INVALID_URL('bad input', 'ht!tp');
assert.equal(invalidUrlErr.name, 'URLError');
assert.equal(invalidUrlErr.code, 'INVALID_URL');
assert.equal(invalidUrlErr.input, 'ht!tp');
const schemeErr = URLError.INVALID_URL_SCHEME();
assert.equal(schemeErr.code, 'INVALID_URL_SCHEME');
const hostErr = URLError.INVALID_FILE_URL_HOST();
assert.equal(hostErr.code, 'INVALID_FILE_URL_HOST');
const pathErr = URLError.INVALID_FILE_URL_PATH();
assert.equal(pathErr.code, 'INVALID_FILE_URL_PATH');
// 5. Verify C binding and CMake native build files exist
assert.ok(fs.existsSync(path.join(pkgDir, 'binding.c')), 'binding.c must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'binding.js')), 'binding.js must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'CMakeLists.txt')), 'CMakeLists.txt must exist');
assert.ok(fs.existsSync(path.join(pkgDir, 'prebuilds')), 'prebuilds directory must exist');
console.log('Contract tests passed successfully.');
Seeder d'origine
anonyme