Exemplo
@webassemblyjs/helper-buffer 1.14.1
Amostra verificada para npm @webassemblyjs/helper-buffer 1.14.1. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.
sha256:7b01f30bd733fa15233169801a39bf67cd23d3b4ae03578f644a3d7887752962
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
linux 24 · ubuntu · glibc 2.39 x64 npm
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-buffer@1.14.1
- Criado
- 2026-08-27T23:21:05Z
Contrato
- overrideBytesInBuffer replaces a slice of Uint8Array at specified start and end offsets with replacement bytes
- overrideBytesInBuffer supports inserting bytes without removing any when startLoc equals endLoc
- overrideBytesInBuffer supports deleting bytes when replacement byte array is empty
- overrideBytesInBuffer throws TypeError or Error if input buffer is not Uint8Array
- makeBuffer flattens nested byte arrays and returns an ArrayBuffer
- fromHexdump parses multi-line formatted hex dump strings omitting offset column into a Uint8Array
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-buffer@1.14.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40webassemblyjs/helper-buffer@1.14.1
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:c07324f428955ebac8b330afd49912287b3aa788a51ccdbbeb223ca40dfc7956","contract":["overrideBytesInBuffer replaces a slice of Uint8Array at specified start and end offsets with replacement bytes","overrideBytesInBuffer supports inserting bytes without removing any when startLoc equals endLoc","overrideBytesInBuffer supports deleting bytes when replacement byte array is empty","overrideBytesInBuffer throws TypeError or Error if input buffer is not Uint8Array","makeBuffer flattens nested byte arrays and returns an ArrayBuffer","fromHexdump parses multi-line formatted hex dump strings omitting offset column into a Uint8Array"],"goal":"verify pkg:npm/%40webassemblyjs/helper-buffer@1.14.1","kind":"HOW","packages":["pkg:npm/%40webassemblyjs/helper-buffer@1.14.1"],"schemaVersion":1},"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/%40webassemblyjs/helper-buffer@1.14.1"],"schemaVersion":1,"subject":"pkg:npm/%40webassemblyjs/helper-buffer@1.14.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-webassemblyjs-helper-buffer",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-webassemblyjs-helper-buffer",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@webassemblyjs/helper-buffer": "1.14.1"
}
},
"node_modules/@webassemblyjs/helper-buffer": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.14.1.tgz",
"integrity": "sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA==",
"license": "MIT"
}
}
}
{
"name": "sample-webassemblyjs-helper-buffer",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for @webassemblyjs/helper-buffer@1.14.1",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"@webassemblyjs/helper-buffer": "1.14.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40webassemblyjs/helper-buffer@1.14.1",
"kind": "HOW",
"packages": [
"pkg:npm/%40webassemblyjs/helper-buffer@1.14.1"
]
}
const {
overrideBytesInBuffer,
makeBuffer,
fromHexdump
} = require('@webassemblyjs/helper-buffer');
/**
* Replace a range of bytes in a Uint8Array buffer with new bytes.
*
* @param {Uint8Array} buffer - Source Uint8Array buffer.
* @param {number} startLoc - Zero-based index at which to start replacing.
* @param {number} endLoc - Zero-based index at which to stop replacing.
* @param {Array<number>|Uint8Array} newBytes - Bytes to splice in.
* @returns {Uint8Array} New Uint8Array containing modified buffer.
*/
function replaceBytes(buffer, startLoc, endLoc, newBytes) {
return overrideBytesInBuffer(buffer, startLoc, endLoc, newBytes);
}
/**
* Construct an ArrayBuffer from byte numbers or byte arrays.
*
* @param {...(number|Array<number>)} byteArrays - Byte lists to concatenate into an ArrayBuffer.
* @returns {ArrayBuffer} Newly created ArrayBuffer.
*/
function createArrayBuffer(...byteArrays) {
return makeBuffer(...byteArrays);
}
/**
* Parse formatted hexdump text into a Uint8Array byte sequence.
*
* @param {string} dump - Multi-line string in standard hexdump format.
* @returns {Uint8Array} Parsed binary byte sequence.
*/
function parseHexdump(dump) {
return fromHexdump(dump);
}
module.exports = {
overrideBytesInBuffer,
makeBuffer,
fromHexdump,
replaceBytes,
createArrayBuffer,
parseHexdump
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
overrideBytesInBuffer,
makeBuffer,
fromHexdump,
replaceBytes,
createArrayBuffer,
parseHexdump
} = require('../src/index.js');
async function runTests() {
// 1. overrideBytesInBuffer replaces a slice of Uint8Array at specified start and end offsets with replacement bytes
const initial = new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05]);
const replaced = replaceBytes(initial, 1, 3, [0xAA, 0xBB]);
assert.equal(replaced instanceof Uint8Array, true, 'Result must be a Uint8Array');
assert.deepEqual(
Array.from(replaced),
[0x01, 0xAA, 0xBB, 0x04, 0x05],
'overrideBytesInBuffer should replace indices [1, 3) with [0xAA, 0xBB]'
);
// 2. overrideBytesInBuffer supports inserting bytes without removing any when startLoc equals endLoc
const inserted = overrideBytesInBuffer(initial, 2, 2, [0xFF, 0xEE]);
assert.deepEqual(
Array.from(inserted),
[0x01, 0x02, 0xFF, 0xEE, 0x03, 0x04, 0x05],
'Inserting at startLoc == endLoc should not remove existing elements'
);
// 3. overrideBytesInBuffer supports deleting bytes when replacement byte array is empty
const deleted = overrideBytesInBuffer(initial, 1, 4, []);
assert.deepEqual(
Array.from(deleted),
[0x01, 0x05],
'Empty replacement should delete the slice [1, 4)'
);
// 4. overrideBytesInBuffer throws TypeError or Error if input buffer is not Uint8Array
assert.throws(
() => {
overrideBytesInBuffer('not-a-buffer', 0, 1, [0x00]);
},
(err) => err instanceof Error,
'Passing invalid buffer type must throw an Error'
);
// 5. makeBuffer flattens nested byte arrays and returns an ArrayBuffer
const arrayBuffer = createArrayBuffer([0x00, 0x61], [0x73, 0x6d, 0x01]);
assert.equal(arrayBuffer instanceof ArrayBuffer, true, 'makeBuffer must return an ArrayBuffer');
assert.equal(arrayBuffer.byteLength, 5, 'ArrayBuffer byteLength must match total number of bytes');
assert.deepEqual(
Array.from(new Uint8Array(arrayBuffer)),
[0x00, 0x61, 0x73, 0x6d, 0x01],
'makeBuffer must assemble bytes in order'
);
// 6. fromHexdump parses multi-line formatted hex dump strings omitting offset column into a Uint8Array
const hexdumpText = `
0000000 00 61 73 6d
0000004 01 00 00 00
`;
const parsed = parseHexdump(hexdumpText);
assert.equal(parsed instanceof Uint8Array, true, 'fromHexdump must return a Uint8Array');
assert.deepEqual(
Array.from(parsed),
[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00],
'fromHexdump must strip offsets and parse hexadecimal byte pairs into Uint8Array'
);
console.log('All contract assertions for @webassemblyjs/helper-buffer passed successfully.');
}
runTests().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Seeder de origem
anônimo