Exemplo
@webassemblyjs/helper-wasm-bytecode 1.13.2
Amostra verificada para npm @webassemblyjs/helper-wasm-bytecode 1.13.2. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.
sha256:eec6e3bd2d359748a53518f1dc9d280edcab39f588e68ad1625c20adcb683eb5
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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/%40webassemblyjs/helper-wasm-bytecode@1.13.2
- Ambiente
- node 22.23.2
- Criado
- 2026-08-27T23:23:52Z
Contrato
- magicModuleHeader and moduleVersion define standard WebAssembly binary header constants
- sections maps WebAssembly section names to their standard binary section IDs
- getSectionForNode resolves WebAssembly AST node types to their corresponding section names
- valtypes and valtypesByString provide bidirectional mapping for WebAssembly value type bytecode encodings
- symbolsByByte and symbolsByName provide bidirectional instruction opcode lookup and argument metadata
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Código-fonte
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/%40webassemblyjs/helper-wasm-bytecode@1.13.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40webassemblyjs/helper-wasm-bytecode@1.13.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:ffe64f7c296cebef072faafe667e740b89bb86721355c5cab665cf5f2985587b","constraints":{"executionContext":"node"},"contract":["magicModuleHeader and moduleVersion define standard WebAssembly binary header constants","sections maps WebAssembly section names to their standard binary section IDs","getSectionForNode resolves WebAssembly AST node types to their corresponding section names","valtypes and valtypesByString provide bidirectional mapping for WebAssembly value type bytecode encodings","symbolsByByte and symbolsByName provide bidirectional instruction opcode lookup and argument metadata"],"goal":"verify pkg:npm/%40webassemblyjs/helper-wasm-bytecode@1.13.2","kind":"HOW","packages":["pkg:npm/%40webassemblyjs/helper-wasm-bytecode@1.13.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/%40webassemblyjs/helper-wasm-bytecode@1.13.2"],"schemaVersion":1,"subject":"pkg:npm/%40webassemblyjs/helper-wasm-bytecode@1.13.2","verifierAdapter":"node-typescript@1"}
{
"name": "sample-webassemblyjs-helper-wasm-bytecode",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-webassemblyjs-helper-wasm-bytecode",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@webassemblyjs/helper-wasm-bytecode": "1.13.2"
}
},
"node_modules/@webassemblyjs/helper-wasm-bytecode": {
"version": "1.13.2",
"resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.13.2.tgz",
"integrity": "sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==",
"license": "MIT"
}
}
}
{
"name": "sample-webassemblyjs-helper-wasm-bytecode",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for @webassemblyjs/helper-wasm-bytecode@1.13.2",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"@webassemblyjs/helper-wasm-bytecode": "1.13.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40webassemblyjs/helper-wasm-bytecode@1.13.2",
"kind": "HOW",
"packages": [
"pkg:npm/%40webassemblyjs/helper-wasm-bytecode@1.13.2"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict';
const wasmBytecodeModule = require('@webassemblyjs/helper-wasm-bytecode');
const bytecode = wasmBytecodeModule.default || wasmBytecodeModule;
const getSectionForNode = wasmBytecodeModule.getSectionForNode || bytecode.getSectionForNode;
/**
* Validates whether the given binary buffer begins with the standard WASM magic header and version.
*
* @param {Uint8Array|Array<number>} headerBytes
* @returns {boolean}
*/
function isValidWasmHeader(headerBytes) {
if (!headerBytes || headerBytes.length < 8) {
return false;
}
const magic = bytecode.magicModuleHeader;
const version = bytecode.moduleVersion;
for (let i = 0; i < 4; i++) {
if (headerBytes[i] !== magic[i]) return false;
}
for (let i = 0; i < 4; i++) {
if (headerBytes[4 + i] !== version[i]) return false;
}
return true;
}
/**
* Returns the numeric section ID for a given section name.
*
* @param {string} sectionName
* @returns {number|undefined}
*/
function getSectionId(sectionName) {
return bytecode.sections[sectionName];
}
/**
* Resolves the section name for an AST node using getSectionForNode.
*
* @param {object} astNode
* @returns {string|undefined}
*/
function resolveSectionForNode(astNode) {
return getSectionForNode(astNode);
}
/**
* Look up opcode bytecode number for an instruction name (e.g. 'i32.add' or 'nop').
*
* @param {string} instructionName
* @returns {number|undefined}
*/
function getOpcodeByte(instructionName) {
const byteStr = bytecode.symbolsByName[instructionName];
return byteStr !== undefined ? Number(byteStr) : undefined;
}
/**
* Look up instruction symbol information for an opcode byte (e.g. 0x6a -> { name: 'add', object: 'i32', numberOfArgs: 0 }).
*
* @param {number} opcodeByte
* @returns {object|undefined}
*/
function getInstructionSymbol(opcodeByte) {
return bytecode.symbolsByByte[opcodeByte];
}
/**
* Look up value type string by its binary bytecode byte (e.g. 0x7f -> 'i32').
*
* @param {number} typeByte
* @returns {string|undefined}
*/
function getValtypeName(typeByte) {
return bytecode.valtypes[typeByte];
}
/**
* Look up value type byte number by its type name (e.g. 'i32' -> 0x7f).
*
* @param {string} typeName
* @returns {number|undefined}
*/
function getValtypeByte(typeName) {
const byteStr = bytecode.valtypesByString[typeName];
return byteStr !== undefined ? Number(byteStr) : undefined;
}
module.exports = {
bytecode,
getSectionForNode,
isValidWasmHeader,
getSectionId,
resolveSectionForNode,
getOpcodeByte,
getInstructionSymbol,
getValtypeName,
getValtypeByte
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
bytecode,
getSectionForNode,
isValidWasmHeader,
getSectionId,
resolveSectionForNode,
getOpcodeByte,
getInstructionSymbol,
getValtypeName,
getValtypeByte
} = require('../src/index.js');
async function testAll() {
// 1. magicModuleHeader and moduleVersion define standard WebAssembly binary header constants
assert.deepEqual(bytecode.magicModuleHeader, [0x00, 0x61, 0x73, 0x6d]);
assert.deepEqual(bytecode.moduleVersion, [0x01, 0x00, 0x00, 0x00]);
const validHeader = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]);
assert.equal(isValidWasmHeader(validHeader), true);
const invalidMagic = new Uint8Array([0x7f, 0x45, 0x4c, 0x46, 0x01, 0x00, 0x00, 0x00]);
assert.equal(isValidWasmHeader(invalidMagic), false);
const invalidVersion = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x02, 0x00, 0x00, 0x00]);
assert.equal(isValidWasmHeader(invalidVersion), false);
assert.equal(isValidWasmHeader(new Uint8Array([0x00, 0x61, 0x73])), false);
// 2. sections maps WebAssembly section names to their standard binary section IDs
assert.equal(getSectionId('custom'), 0);
assert.equal(getSectionId('type'), 1);
assert.equal(getSectionId('import'), 2);
assert.equal(getSectionId('func'), 3);
assert.equal(getSectionId('table'), 4);
assert.equal(getSectionId('memory'), 5);
assert.equal(getSectionId('global'), 6);
assert.equal(getSectionId('export'), 7);
assert.equal(getSectionId('start'), 8);
assert.equal(getSectionId('element'), 9);
assert.equal(getSectionId('code'), 10);
assert.equal(getSectionId('data'), 11);
assert.equal(getSectionId('nonexistent'), undefined);
assert.equal(bytecode.sections.custom, 0);
assert.equal(bytecode.sections.type, 1);
assert.equal(bytecode.sections.import, 2);
assert.equal(bytecode.sections.func, 3);
assert.equal(bytecode.sections.table, 4);
assert.equal(bytecode.sections.memory, 5);
assert.equal(bytecode.sections.global, 6);
assert.equal(bytecode.sections.export, 7);
assert.equal(bytecode.sections.start, 8);
assert.equal(bytecode.sections.element, 9);
assert.equal(bytecode.sections.code, 10);
assert.equal(bytecode.sections.data, 11);
// 3. getSectionForNode resolves WebAssembly AST node types to their corresponding section names
assert.equal(resolveSectionForNode({ type: 'ModuleImport' }), 'import');
assert.equal(resolveSectionForNode({ type: 'Func' }), 'code');
assert.equal(resolveSectionForNode({ type: 'Instr' }), 'code');
assert.equal(resolveSectionForNode({ type: 'CallInstruction' }), 'code');
assert.equal(resolveSectionForNode({ type: 'CallIndirectInstruction' }), 'code');
assert.equal(resolveSectionForNode({ type: 'ModuleExport' }), 'export');
assert.equal(resolveSectionForNode({ type: 'Start' }), 'start');
assert.equal(resolveSectionForNode({ type: 'TypeInstruction' }), 'type');
assert.equal(resolveSectionForNode({ type: 'IndexInFuncSection' }), 'func');
assert.equal(resolveSectionForNode({ type: 'Global' }), 'global');
assert.equal(resolveSectionForNode({ type: 'Program' }), undefined);
assert.equal(resolveSectionForNode({ type: 'Unknown' }), undefined);
assert.equal(getSectionForNode({ type: 'ModuleImport' }), 'import');
assert.equal(getSectionForNode({ type: 'Func' }), 'code');
// 4. valtypes and valtypesByString provide bidirectional mapping for WebAssembly value type bytecode encodings
assert.equal(getValtypeName(0x7f), 'i32');
assert.equal(getValtypeName(0x7e), 'i64');
assert.equal(getValtypeName(0x7d), 'f32');
assert.equal(getValtypeName(0x7c), 'f64');
assert.equal(getValtypeName(0x7b), 'v128');
assert.equal(getValtypeName(0x70), 'anyfunc');
assert.equal(getValtypeName(0x6f), 'externref');
assert.equal(getValtypeByte('i32'), 0x7f);
assert.equal(getValtypeByte('i64'), 0x7e);
assert.equal(getValtypeByte('f32'), 0x7d);
assert.equal(getValtypeByte('f64'), 0x7c);
assert.equal(getValtypeByte('v128'), 0x7b);
assert.equal(getValtypeByte('anyfunc'), 0x70);
assert.equal(getValtypeByte('externref'), 0x6f);
assert.equal(bytecode.types.func, 0x60);
assert.equal(bytecode.types.result, 0x40);
assert.equal(bytecode.exportTypes[0x00], 'Func');
assert.equal(bytecode.exportTypes[0x01], 'Table');
assert.equal(bytecode.exportTypes[0x02], 'Memory');
assert.equal(bytecode.exportTypes[0x03], 'Global');
assert.equal(bytecode.globalTypes[0], 'const');
assert.equal(bytecode.globalTypes[1], 'var');
// 5. symbolsByByte and symbolsByName provide bidirectional instruction opcode lookup and argument metadata
assert.equal(getOpcodeByte('i32.const'), 0x41);
assert.equal(bytecode.symbolsByName['i32.const'], '65');
assert.deepEqual(getInstructionSymbol(0x41), { name: 'const', object: 'i32', numberOfArgs: 1 });
assert.equal(getOpcodeByte('i32.add'), 0x6a);
assert.equal(bytecode.symbolsByName['i32.add'], '106');
assert.deepEqual(getInstructionSymbol(0x6a), { name: 'add', object: 'i32', numberOfArgs: 0 });
assert.equal(getOpcodeByte('end'), 0x0b);
assert.equal(bytecode.symbolsByName['end'], '11');
assert.deepEqual(getInstructionSymbol(0x0b), { name: 'end', numberOfArgs: 0 });
assert.equal(getOpcodeByte('unreachable'), 0x00);
assert.equal(bytecode.symbolsByName['unreachable'], '0');
assert.deepEqual(getInstructionSymbol(0x00), { name: 'unreachable', numberOfArgs: 0 });
assert.equal(getOpcodeByte('nop'), 0x01);
assert.equal(bytecode.symbolsByName['nop'], '1');
assert.deepEqual(getInstructionSymbol(0x01), { name: 'nop', numberOfArgs: 0 });
assert.equal(getOpcodeByte('block'), 0x02);
assert.equal(bytecode.symbolsByName['block'], '2');
assert.deepEqual(getInstructionSymbol(0x02), { name: 'block', numberOfArgs: 0 });
assert.equal(getOpcodeByte('loop'), 0x03);
assert.equal(bytecode.symbolsByName['loop'], '3');
assert.deepEqual(getInstructionSymbol(0x03), { name: 'loop', numberOfArgs: 0 });
assert.equal(getOpcodeByte('if'), 0x04);
assert.equal(bytecode.symbolsByName['if'], '4');
assert.deepEqual(getInstructionSymbol(0x04), { name: 'if', numberOfArgs: 0 });
assert.equal(getOpcodeByte('call'), 0x10);
assert.equal(bytecode.symbolsByName['call'], '16');
assert.deepEqual(getInstructionSymbol(0x10), { name: 'call', numberOfArgs: 1 });
assert.equal(getOpcodeByte('drop'), 0x1a);
assert.equal(bytecode.symbolsByName['drop'], '26');
assert.deepEqual(getInstructionSymbol(0x1a), { name: 'drop', numberOfArgs: 0 });
assert.equal(getOpcodeByte('get_local'), 0x20);
assert.equal(bytecode.symbolsByName['get_local'], '32');
assert.deepEqual(getInstructionSymbol(0x20), { name: 'get_local', numberOfArgs: 1 });
assert.equal(getOpcodeByte('set_local'), 0x21);
assert.equal(bytecode.symbolsByName['set_local'], '33');
assert.deepEqual(getInstructionSymbol(0x21), { name: 'set_local', numberOfArgs: 1 });
}
testAll()
.then(() => {
console.log('All contract assertions passed successfully.');
process.exit(0);
})
.catch((err) => {
console.error('Contract assertion failed:', err);
process.exit(1);
});
Seeder de origem
anônimo