샘플
@webassemblyjs/helper-buffer 1.14.1
검증된 샘플 — npm @webassemblyjs/helper-buffer 1.14.1. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: overrideBytesInBuffer replaces a slice of…
sha256:7b01f30bd733fa15233169801a39bf67cd23d3b4ae03578f644a3d7887752962
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:npm/%40webassemblyjs/helper-buffer@1.14.1
- 생성일
- 2026-08-27T23:21:05Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
소스
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);
});
오리진 시더
익명