Exemple
@tybys/wasm-util 0.10.2: Memory, extendMemory, loadSync
Échantillon vérifié pour npm @tybys/wasm-util 0.10.2: Memory, extendMemory, loadSync. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a…
sha256:b43c5794fc95268d5fe16156b8e587104fb7c0e70ed47ca4bf2c39599d54fee1
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 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 |
Cas
HOW- Objectif
- verify pkg:npm/%40tybys/wasm-util@0.10.2
- Paquets
- Symboles
-
- Memory
- extendMemory
- loadSync
- Environnement
- node 22.23.2
- Créé
- 2026-09-18T20:55:31Z
Contrat
- loadSync instantiates a WebAssembly binary synchronously from a Uint8Array buffer
- extendMemory upgrades a standard WebAssembly.Memory instance to provide typed array getters
- Memory instance provides HEAPU8 and DataView access reflecting underlying memory mutations
- instantiated WebAssembly module executes exported arithmetic functions correctly
- extendMemory is idempotent when called multiple times on the same memory instance
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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/%40tybys/wasm-util@0.10.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40tybys/wasm-util@0.10.2
Demonstrate these symbols/APIs:
- Memory
- extendMemory
- loadSync
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:7ae91db174fb232f64638d7ce8ac68d55a653617c89652dfbd8fb8dc21842e58","contract":["loadSync instantiates a WebAssembly binary synchronously from a Uint8Array buffer","extendMemory upgrades a standard WebAssembly.Memory instance to provide typed array getters","Memory instance provides HEAPU8 and DataView access reflecting underlying memory mutations","instantiated WebAssembly module executes exported arithmetic functions correctly","extendMemory is idempotent when called multiple times on the same memory instance"],"goal":"verify pkg:npm/%40tybys/wasm-util@0.10.2","kind":"HOW","packages":["pkg:npm/%40tybys/wasm-util@0.10.2"],"schemaVersion":1,"symbols":["Memory","extendMemory","loadSync"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40tybys/wasm-util@0.10.2"],"schemaVersion":1,"subject":"pkg:npm/%40tybys/wasm-util@0.10.2","symbols":["Memory","extendMemory","loadSync"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-tybys-wasm-util",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-tybys-wasm-util",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@tybys/wasm-util": "0.10.2"
}
},
"node_modules/@tybys/wasm-util": {
"version": "0.10.2",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.2.tgz",
"integrity": "sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==",
"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-tybys-wasm-util",
"version": "1.0.0",
"type": "module",
"private": true,
"description": "verify pkg:npm/%40tybys/wasm-util@0.10.2",
"main": "src/index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@tybys/wasm-util": "0.10.2"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40tybys/wasm-util@0.10.2",
"kind": "HOW",
"packages": [
"pkg:npm/%40tybys/wasm-util@0.10.2"
],
"symbols": [
"Memory",
"extendMemory",
"loadSync"
]
}
import { Memory, extendMemory, loadSync } from '@tybys/wasm-util';
export const ADD_WASM_BYTES = new Uint8Array([
0x00, 0x61, 0x73, 0x6d,
0x01, 0x00, 0x00, 0x00,
0x01, 0x07, 0x01, 0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f,
0x03, 0x02, 0x01, 0x00,
0x07, 0x07, 0x01, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00,
0x0a, 0x09, 0x01, 0x07, 0x00, 0x20, 0x00, 0x20, 0x01, 0x6a, 0x0b
]);
export function createExtendedMemory(descriptor = { initial: 1 }) {
const mem = new WebAssembly.Memory(descriptor);
return extendMemory(mem);
}
export function loadModuleSync(bufferSource, imports) {
return loadSync(bufferSource, imports);
}
export function createAddModule() {
return loadSync(ADD_WASM_BYTES);
}
export { Memory, extendMemory, loadSync };
import assert from 'node:assert';
import {
Memory,
extendMemory,
loadSync,
ADD_WASM_BYTES,
createExtendedMemory,
loadModuleSync,
createAddModule
} from '../src/index.mjs';
// 1. loadSync instantiates a WebAssembly binary synchronously from a Uint8Array buffer
const { instance, module } = loadSync(ADD_WASM_BYTES);
assert(instance instanceof WebAssembly.Instance, 'instance should be a WebAssembly.Instance');
assert(module instanceof WebAssembly.Module, 'module should be a WebAssembly.Module');
const helperLoaded = loadModuleSync(ADD_WASM_BYTES);
assert(helperLoaded.instance instanceof WebAssembly.Instance, 'helper loadModuleSync returns an instance');
// 2. extendMemory upgrades a standard WebAssembly.Memory instance to provide typed array getters
const rawMem = new WebAssembly.Memory({ initial: 1 });
const extended = extendMemory(rawMem);
assert.strictEqual(extended, rawMem, 'extendMemory modifies and returns the same memory instance');
assert(extended instanceof Memory, 'extended memory should inherit from Memory');
assert(extended.HEAPU8 instanceof Uint8Array, 'HEAPU8 should be a Uint8Array view');
assert(extended.HEAP32 instanceof Int32Array, 'HEAP32 should be an Int32Array view');
assert(extended.view instanceof DataView, 'view should be a DataView');
const helperMem = createExtendedMemory({ initial: 2 });
assert(helperMem instanceof Memory, 'createExtendedMemory returns Memory instance');
assert.strictEqual(helperMem.HEAPU8.length, 131072, '2 pages should equal 131072 bytes');
// 3. Memory instance provides HEAPU8 and DataView access reflecting underlying memory mutations
extended.HEAPU8[0] = 0xef;
extended.HEAPU8[1] = 0xbe;
extended.HEAPU8[2] = 0xad;
extended.HEAPU8[3] = 0xde;
assert.strictEqual(extended.view.getUint32(0, true), 0xdeadbeef, 'DataView should reflect byte mutations');
assert.strictEqual(extended.HEAP32[0], -559038737, 'HEAP32 should reflect 32-bit integer value');
// 4. instantiated WebAssembly module executes exported arithmetic functions correctly
assert.strictEqual(typeof instance.exports.add, 'function', 'add export should be a callable function');
assert.strictEqual(instance.exports.add(15, 27), 42, 'add(15, 27) should equal 42');
const addModule = createAddModule();
assert.strictEqual(addModule.instance.exports.add(100, 250), 350, 'createAddModule helper executes add correctly');
// 5. extendMemory is idempotent when called multiple times on the same memory instance
const reExtended = extendMemory(extended);
assert.strictEqual(reExtended, extended, 'Calling extendMemory again returns the same instance');
assert(reExtended instanceof Memory, 're-extended instance remains an instance of Memory');
console.log('Contract tests passed successfully.');
process.exit(0);
Seeder d'origine
anonyme