Ejemplo
require-asset 1.2.2: require-asset
Muestra verificada para npm require-asset 1.2.2: require-asset. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.
sha256:3c0eb33df1bd80671e4f284d2f8ca472ab6118f219fc87897852d8ceb5548737
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-27 |
Caso
HOW- Objetivo
- verify pkg:npm/require-asset@1.2.2
- Paquetes
- Símbolos
-
- require-asset
- Creado
- 2026-08-27T13:00:53Z
Contrato
- package manifest specifies exports, Apache-2.0 license, and bare-module-resolve dependency
- exports asset resolution function accepting specifier and parent module path string or URL instance
- resolves relative asset paths using filesystem path string or URL instance as parentURL
- reads package metadata and evaluates resolution conditions for assets
- throws ASSET_NOT_FOUND error with specifier, referrer, and candidates properties when asset is missing
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
- test/fixtures/data.txt
- test/fixtures/info.json
Código fuente
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/require-asset@1.2.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/require-asset@1.2.2
Demonstrate these symbols/APIs:
- require-asset
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:f2750ecbba990cb46153ab52326518f045a8dad0ae0af2736135dfbca76ee884","contract":["package manifest specifies exports, Apache-2.0 license, and bare-module-resolve dependency","exports asset resolution function accepting specifier and parent module path string or URL instance","resolves relative asset paths using filesystem path string or URL instance as parentURL","reads package metadata and evaluates resolution conditions for assets","throws ASSET_NOT_FOUND error with specifier, referrer, and candidates properties when asset is missing"],"goal":"verify pkg:npm/require-asset@1.2.2","kind":"HOW","packages":["pkg:npm/require-asset@1.2.2"],"schemaVersion":1,"symbols":["require-asset"]},"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/require-asset@1.2.2"],"schemaVersion":1,"subject":"pkg:npm/require-asset@1.2.2","symbols":["require-asset"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-require-asset",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-require-asset",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"require-asset": "1.2.2"
}
},
"node_modules/bare-module-resolve": {
"version": "1.12.4",
"resolved": "https://registry.npmjs.org/bare-module-resolve/-/bare-module-resolve-1.12.4.tgz",
"integrity": "sha512-xcfgg2u7HqgJiBmah71O9vvdFAgHCvkqC/WSC2O7Bbgosoc1eC/BWe/6IDJ4OsfKlkxuvC/TDWXC+oH5yeW8mA==",
"license": "Apache-2.0",
"dependencies": {
"bare-semver": "^1.0.0"
},
"peerDependencies": {
"bare-url": "*"
},
"peerDependenciesMeta": {
"bare-url": {
"optional": true
}
}
},
"node_modules/bare-semver": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/bare-semver/-/bare-semver-1.1.0.tgz",
"integrity": "sha512-1Hw5qJ7hXdVt3uPUqjeFTuxyvBUJauvz5A1I2jk8gzjZMHp04n//6nV9MDbG9CMw78JHY2lGV0w6s//LrASm2w==",
"license": "Apache-2.0"
},
"node_modules/require-asset": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/require-asset/-/require-asset-1.2.2.tgz",
"integrity": "sha512-uc8nWKhqAxVD9Z4rST2b4yaemrC9Xb5vA1wlCz5AiCYnBYdwGRWNqFjneA5zRILzlo1MNrB63ry9+pc8wNR26w==",
"license": "Apache-2.0",
"dependencies": {
"bare-module-resolve": "^1.6.2"
},
"engines": {
"bare": ">=1.10.0",
"node": ">=18"
}
}
}
}
{
"name": "sample-require-asset",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"require-asset": "1.2.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/require-asset@1.2.2",
"kind": "HOW",
"packages": [
"pkg:npm/require-asset@1.2.2"
],
"symbols": [
"require-asset"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
const require = createRequire(import.meta.url);
// 1. Verify package manifest and metadata
const pkgPath = require.resolve('require-asset/package');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
assert.equal(pkg.name, 'require-asset', 'Package name must be require-asset');
assert.equal(pkg.version, '1.2.2', 'Package version must be 1.2.2');
assert.equal(pkg.license, 'Apache-2.0', 'Package license must be Apache-2.0');
assert.ok(pkg.exports, 'Package must define exports');
assert.equal(pkg.exports['./package'], './package.json', 'Package export must point to ./package.json');
assert.equal(pkg.exports['.'].node, './lib/node.js', 'Root node export must point to ./lib/node.js');
assert.equal(pkg.exports['.'].bare, './lib/bare.js', 'Root bare export must point to ./lib/bare.js');
assert.equal(pkg.exports['.'].default, './lib/default.js', 'Root default export must point to ./lib/default.js');
assert.ok(pkg.dependencies['bare-module-resolve'], 'Package must depend on bare-module-resolve');
// 2. Verify imported module function
const asset = require('require-asset');
assert.equal(typeof asset, 'function', 'require-asset must export a function');
// 3. Verify asset resolution with filesystem path string and URL object
const currentFilePath = fileURLToPath(import.meta.url);
const fixtureTxtPath = path.resolve(path.dirname(currentFilePath), 'fixtures', 'data.txt');
const fixtureJsonPath = path.resolve(path.dirname(currentFilePath), 'fixtures', 'info.json');
// Resolving with filesystem path string (as in CommonJS __filename or fileURLToPath)
const resolvedTxtFromPath = asset('./fixtures/data.txt', currentFilePath);
assert.equal(resolvedTxtFromPath, fixtureTxtPath, 'Resolved text path must match expected fixture path');
assert.equal(fs.readFileSync(resolvedTxtFromPath, 'utf8').trim(), 'hello require-asset');
const resolvedJsonFromPath = asset('./fixtures/info.json', currentFilePath);
assert.equal(resolvedJsonFromPath, fixtureJsonPath, 'Resolved JSON path must match expected fixture path');
const jsonContent = JSON.parse(fs.readFileSync(resolvedJsonFromPath, 'utf8'));
assert.equal(jsonContent.type, 'sample');
assert.equal(jsonContent.value, 42);
// Resolving with URL object (new URL(import.meta.url) or pathToFileURL(filePath))
const currentUrlObj = new URL(import.meta.url);
const resolvedTxtFromUrlObj = asset('./fixtures/data.txt', currentUrlObj);
assert.equal(resolvedTxtFromUrlObj, fixtureTxtPath, 'Resolved path using URL object must match');
const currentPathToFileUrl = pathToFileURL(currentFilePath);
const resolvedJsonFromPathUrl = asset('./fixtures/info.json', currentPathToFileUrl);
assert.equal(resolvedJsonFromPathUrl, fixtureJsonPath, 'Resolved path using pathToFileURL must match');
// 4. Verify ASSET_NOT_FOUND error when asset cannot be resolved
let threw = false;
try {
asset('./fixtures/nonexistent_asset.bin', currentFilePath);
} catch (err) {
threw = true;
assert.equal(err.code, 'ASSET_NOT_FOUND', 'Error code must be ASSET_NOT_FOUND');
assert.equal(err.specifier, './fixtures/nonexistent_asset.bin', 'Error must contain specifier');
assert.ok(err.referrer instanceof URL || typeof err.referrer === 'object', 'Error must contain referrer URL');
assert.ok(Array.isArray(err.candidates), 'Error must contain candidates array');
assert.ok(err.message.includes("Cannot find asset './fixtures/nonexistent_asset.bin'"), 'Error message must describe missing asset');
}
assert.equal(threw, true, 'Calling asset with non-existent file must throw');
console.log('Contract tests passed successfully.');
hello require-asset
{"type":"sample","value":42}
Seeder de origen
anónimo