Exemple
json-buffer 3.0.1: serialize and deserialize Buffer objects with JSON using json-buffer
Échantillon vérifié pour npm json-buffer 3.0.1: serialize and deserialize Buffer objects with JSON using json-buffer. Le contrat s'est exécuté sur node 22 …
sha256:441b61e50fa3fc504caaedc3fd2188513fd4fa8dbe4a7ef9794dcc083d866438
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é
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-28 |
Cas
HOW- Objectif
- serialize and deserialize Buffer objects with JSON using json-buffer
- Paquets
- Symboles
-
- parse
- stringify
- Créé
- 2026-08-28T03:19:07Z
Contrat
- stringify encodes Buffer as base64 string prefixed with colon
- parse decodes colon base64 prefixed string back to Buffer
- stringify and parse round-trip nested objects containing Buffer instances
- stringify and parse round-trip arrays containing Buffer instances
- stringify escapes strings starting with colon by prepending an extra colon
- stringify returns undefined for undefined input and omits undefined object properties
- stringify serializes undefined elements in arrays as null
- parse throws SyntaxError on invalid JSON input
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- 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: serialize and deserialize Buffer objects with JSON using json-buffer
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/json-buffer@3.0.1
Demonstrate these symbols/APIs:
- parse
- stringify
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:65bc682cfd3a132b0f0bc5522f7a41c9492fbef768383b77dc5b3b077727c199","contract":["stringify encodes Buffer as base64 string prefixed with colon","parse decodes colon base64 prefixed string back to Buffer","stringify and parse round-trip nested objects containing Buffer instances","stringify and parse round-trip arrays containing Buffer instances","stringify escapes strings starting with colon by prepending an extra colon","stringify returns undefined for undefined input and omits undefined object properties","stringify serializes undefined elements in arrays as null","parse throws SyntaxError on invalid JSON input"],"goal":"serialize and deserialize Buffer objects with JSON using json-buffer","kind":"HOW","packages":["pkg:npm/json-buffer@3.0.1"],"schemaVersion":1,"symbols":["parse","stringify"]},"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/json-buffer@3.0.1"],"schemaVersion":1,"subject":"pkg:npm/json-buffer@3.0.1","symbols":["parse","stringify"],"verifierAdapter":"node-typescript@1"}
{
"name": "json-buffer-verification",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "json-buffer-verification",
"version": "1.0.0",
"dependencies": {
"json-buffer": "3.0.1"
}
},
"node_modules/json-buffer": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
"integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==",
"license": "MIT"
}
}
}
{
"name": "json-buffer-verification",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for json-buffer",
"dependencies": {
"json-buffer": "3.0.1"
}
}
{
"schemaVersion": 1,
"goal": "serialize and deserialize Buffer objects with JSON using json-buffer",
"kind": "HOW",
"packages": [
"pkg:npm/json-buffer@3.0.1"
],
"symbols": [
"parse",
"stringify"
]
}
import assert from 'node:assert';
import { parse, stringify } from 'json-buffer';
// 1. stringify encodes Buffer as base64 string prefixed with colon
const buf = Buffer.from('hello', 'utf8');
const json = stringify(buf);
assert.strictEqual(json, JSON.stringify(':base64:' + buf.toString('base64')));
// 2. parse decodes colon base64 prefixed string back to Buffer
const parsed = parse(json);
assert.ok(Buffer.isBuffer(parsed));
assert.strictEqual(parsed.toString('utf8'), 'hello');
// 3. stringify and parse round-trip nested objects containing Buffer instances
const obj = { id: 42, buf: Buffer.from([0xde, 0xad, 0xbe, 0xef]), text: 'sample' };
const encoded = stringify(obj);
const decoded = parse(encoded);
assert.strictEqual(decoded.id, 42);
assert.strictEqual(decoded.text, 'sample');
assert.ok(Buffer.isBuffer(decoded.buf));
assert.deepStrictEqual(Array.from(decoded.buf), [0xde, 0xad, 0xbe, 0xef]);
// 4. stringify and parse round-trip arrays containing Buffer instances
const arr = [Buffer.from('first'), 123, Buffer.from('second')];
const encodedArr = stringify(arr);
const decodedArr = parse(encodedArr);
assert.strictEqual(decodedArr.length, 3);
assert.ok(Buffer.isBuffer(decodedArr[0]));
assert.strictEqual(decodedArr[0].toString('utf8'), 'first');
assert.strictEqual(decodedArr[1], 123);
assert.ok(Buffer.isBuffer(decodedArr[2]));
assert.strictEqual(decodedArr[2].toString('utf8'), 'second');
// 5. stringify escapes strings starting with colon by prepending an extra colon
const colonStr = ':my-colon-string';
const encodedStr = stringify(colonStr);
assert.strictEqual(encodedStr, JSON.stringify('::my-colon-string'));
assert.strictEqual(parse(encodedStr), colonStr);
// 6. stringify returns undefined for undefined input and omits undefined object properties
assert.strictEqual(stringify(undefined), undefined);
const objWithUndef = { keep: 1, remove: undefined };
assert.strictEqual(stringify(objWithUndef), '{"keep":1}');
// 7. stringify serializes undefined elements in arrays as null
const arrWithUndef = [1, undefined, 3];
const encUndef = stringify(arrWithUndef);
assert.strictEqual(encUndef, '[1,null,3]');
assert.deepStrictEqual(parse(encUndef), [1, null, 3]);
// 8. parse throws SyntaxError on invalid JSON input
assert.throws(
() => parse('{ malformed json }'),
{ name: 'SyntaxError' }
);
console.log('Contract passed');
Seeder d'origine
anonyme