CodeSampleX

Beispiel

@webassemblyjs/helper-buffer 1.14.1

Verifiziertes Beispiel für npm @webassemblyjs/helper-buffer 1.14.1. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:7b01f30bd733fa15233169801a39bf67cd23d3b4ae03578f644a3d7887752962

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify pkg:npm/%40webassemblyjs/helper-buffer@1.14.1
Pakete
Erstellt
2026-08-27T23:21:05Z

Contract

  1. overrideBytesInBuffer replaces a slice of Uint8Array at specified start and end offsets with replacement bytes
  2. overrideBytesInBuffer supports inserting bytes without removing any when startLoc equals endLoc
  3. overrideBytesInBuffer supports deleting bytes when replacement byte array is empty
  4. overrideBytesInBuffer throws TypeError or Error if input buffer is not Uint8Array
  5. makeBuffer flattens nested byte arrays and returns an ArrayBuffer
  6. fromHexdump parses multi-line formatted hex dump strings omitting offset column into a Uint8Array

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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.
csx.json
{"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"}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40webassemblyjs/helper-buffer@1.14.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40webassemblyjs/helper-buffer@1.14.1"
  ]
}
src/index.js
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
};
test/contract.mjs
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);
});

Ursprungs-Seeder

anonym