Ejemplo
@napi-rs/wasm-runtime 1.1.4
Muestra verificada para npm @napi-rs/wasm-runtime 1.1.4. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:ab2c90f1828fbdb6d06246c9788f4c5a0f9db26d9e343a5525acc0549f0a862b
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-19 |
Caso
HOW- Objetivo
- verify pkg:npm/%40napi-rs/wasm-runtime@1.1.4
- Paquetes
- Entorno
- node 22.23.2
- Creado
- 2026-09-18T20:38:58Z
Contrato
- @napi-rs/wasm-runtime exports getDefaultContext, instantiateNapiModule, instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy, createOnMessage, Asyncify, and Memory
- getDefaultContext returns the default emnapi Context instance with active handle and scope stores
- WASI can be instantiated with custom args and environment variables
- MessageHandler can be instantiated with onLoad and postMessage handlers
- @napi-rs/wasm-runtime/fs exports memfs, Volume, fs, and createFsFromVolume
- createOnMessage processes readFileSync requests over SharedArrayBuffer messaging protocol
- createOnMessage handles errors and reports status 1 with serialized error payload over SharedArrayBuffer
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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/%40napi-rs/wasm-runtime@1.1.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40napi-rs/wasm-runtime@1.1.4
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:8a73fb8afa37b45e7171edca5179e024445e8efd9e701faa8cf75a3378d5ab5b","constraints":{"executionContext":"node"},"contract":["@napi-rs/wasm-runtime exports getDefaultContext, instantiateNapiModule, instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy, createOnMessage, Asyncify, and Memory","getDefaultContext returns the default emnapi Context instance with active handle and scope stores","WASI can be instantiated with custom args and environment variables","MessageHandler can be instantiated with onLoad and postMessage handlers","@napi-rs/wasm-runtime/fs exports memfs, Volume, fs, and createFsFromVolume","createOnMessage processes readFileSync requests over SharedArrayBuffer messaging protocol","createOnMessage handles errors and reports status 1 with serialized error payload over SharedArrayBuffer"],"goal":"verify pkg:npm/%40napi-rs/wasm-runtime@1.1.4","kind":"HOW","packages":["pkg:npm/%40napi-rs/wasm-runtime@1.1.4"],"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/%40napi-rs/wasm-runtime@1.1.4"],"schemaVersion":1,"subject":"pkg:npm/%40napi-rs/wasm-runtime@1.1.4","verifierAdapter":"node-typescript@1"}
{
"name": "sample-napi-rs-wasm-runtime",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-napi-rs-wasm-runtime",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@napi-rs/wasm-runtime": "1.1.4"
}
},
"node_modules/@emnapi/core": {
"version": "1.11.3",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.3.tgz",
"integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==",
"license": "MIT",
"peer": true,
"dependencies": {
"@emnapi/wasi-threads": "1.2.3",
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.11.3",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
"integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
"license": "MIT",
"peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/wasi-threads": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz",
"integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==",
"license": "MIT",
"peer": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@napi-rs/wasm-runtime": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz",
"integrity": "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==",
"license": "MIT",
"dependencies": {
"@tybys/wasm-util": "^0.10.1"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
},
"peerDependencies": {
"@emnapi/core": "^1.7.1",
"@emnapi/runtime": "^1.7.1"
}
},
"node_modules/@tybys/wasm-util": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.4.tgz",
"integrity": "sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==",
"license": "MIT",
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
}
}
}
{
"name": "sample-napi-rs-wasm-runtime",
"version": "1.0.0",
"type": "module",
"license": "MIT-0",
"dependencies": {
"@napi-rs/wasm-runtime": "1.1.4"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40napi-rs/wasm-runtime@1.1.4",
"kind": "HOW",
"packages": [
"pkg:npm/%40napi-rs/wasm-runtime@1.1.4"
]
}
import assert from 'node:assert/strict';
import {
getDefaultContext,
instantiateNapiModule,
instantiateNapiModuleSync,
MessageHandler,
WASI,
createFsProxy,
createOnMessage,
Asyncify,
Memory
} from '@napi-rs/wasm-runtime';
import { memfs, Volume, createFsFromVolume, fs as defaultFs } from '@napi-rs/wasm-runtime/fs';
// 1. Export verification
assert.equal(typeof getDefaultContext, 'function', 'getDefaultContext must be exported as a function');
assert.equal(typeof instantiateNapiModule, 'function', 'instantiateNapiModule must be exported as a function');
assert.equal(typeof instantiateNapiModuleSync, 'function', 'instantiateNapiModuleSync must be exported as a function');
assert.equal(typeof MessageHandler, 'function', 'MessageHandler must be exported as a constructor/function');
assert.equal(typeof WASI, 'function', 'WASI must be exported as a constructor/function');
assert.equal(typeof createFsProxy, 'function', 'createFsProxy must be exported as a function');
assert.equal(typeof createOnMessage, 'function', 'createOnMessage must be exported as a function');
assert.equal(typeof Asyncify, 'function', 'Asyncify must be exported as a constructor/function');
assert.equal(typeof Memory, 'function', 'Memory must be exported as a constructor/function');
// 2. Default context
const defaultCtx = getDefaultContext();
assert.ok(defaultCtx && typeof defaultCtx === 'object', 'getDefaultContext must return a context object');
assert.ok(defaultCtx.scopeStore, 'default context must have a scopeStore');
assert.ok(defaultCtx.handleStore, 'default context must have a handleStore');
// 3. WASI instantiation
const wasi = new WASI({
args: ['node', 'app.wasm'],
env: { NODE_ENV: 'test' }
});
assert.equal(typeof wasi.start, 'function', 'WASI instance must provide start method');
assert.equal(typeof wasi.initialize, 'function', 'WASI instance must provide initialize method');
// 4. MessageHandler instantiation
let messageReceived = false;
const handler = new MessageHandler({
onLoad: () => {},
postMessage: () => { messageReceived = true; }
});
assert.ok(handler && typeof handler === 'object', 'MessageHandler instance should be created');
// 5. FS subpath export verification
assert.equal(typeof memfs, 'function', 'memfs must be a function');
assert.equal(typeof Volume, 'function', 'Volume must be a constructor');
assert.equal(typeof createFsFromVolume, 'function', 'createFsFromVolume must be a function');
assert.ok(defaultFs && typeof defaultFs === 'object', 'fs must be a filesystem object');
// 6. createOnMessage with SharedArrayBuffer success
const { fs: inMemoryFs } = memfs({ '/sample.txt': 'napi-rs wasm runtime test' });
const onMsg = createOnMessage(inMemoryFs);
const sabSuccess = new SharedArrayBuffer(16 + 10240);
const i32Success = new Int32Array(sabSuccess);
Atomics.store(i32Success, 0, 21);
onMsg({
data: {
__fs__: {
sab: i32Success,
type: 'readFileSync',
payload: ['/sample.txt', 'utf8']
}
}
});
const statusSuccess = Atomics.load(i32Success, 0);
const typeSuccess = Atomics.load(i32Success, 1);
const sizeSuccess = Atomics.load(i32Success, 2);
const payloadSuccess = new Uint8Array(sabSuccess, 16, sizeSuccess);
const decodedText = new TextDecoder().decode(payloadSuccess);
assert.equal(statusSuccess, 0, 'Status must be 0 for successful filesystem execution');
assert.equal(typeSuccess, 4, 'Type 4 indicates string return value');
assert.equal(decodedText, 'napi-rs wasm runtime test', 'Decoded text must match written file content');
// 7. createOnMessage error handling over SharedArrayBuffer
const sabError = new SharedArrayBuffer(16 + 10240);
const i32Error = new Int32Array(sabError);
Atomics.store(i32Error, 0, 21);
onMsg({
data: {
__fs__: {
sab: i32Error,
type: 'readFileSync',
payload: ['/nonexistent.txt', 'utf8']
}
}
});
const statusError = Atomics.load(i32Error, 0);
assert.equal(statusError, 1, 'Status must be 1 for filesystem errors');
console.log('Contract tests passed successfully.');
Seeder de origen
anónimo