Exemple
tar-stream 3.2.0: pack
Échantillon vérifié pour npm tar-stream 3.2.0: pack. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:41b744f97d6816127c0a95d674d5269b3ca065f30561a62f7e03fc46f934f857
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-17 |
Cas
HOW- Objectif
- verify tar-stream.pack in pkg:npm/tar-stream@3.2.0
- Paquets
- Symboles
-
- tar-stream.pack
- Environnement
- node 22.23.2
- Créé
- 2026-09-17T01:40:07Z
Contrat
- tar.pack returns a readable stream that yields 512-byte aligned blocks and terminates with a 1024-byte zero block after finalize
- pack.entry buffers string or Buffer payload with custom header metadata and writes padded tar blocks
- pack.entry returns a writable sink stream when payload is omitted and finalizes after streaming exactly header.size bytes
- pack.entry destroys the pack stream and reports size mismatch when streamed bytes do not match header.size
- pack.entry queues concurrent entry streams and processes them sequentially
- pack.entry throws an error when called on an already finalized pack stream
- pack.entry writes directory entries with type directory, default 0755 mode, and zero size
- writing payload to a void directory entry emits an error rejecting bodies for that entry
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: verify tar-stream.pack in pkg:npm/tar-stream@3.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/tar-stream@3.2.0
Demonstrate these symbols/APIs:
- tar-stream.pack
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:0c3a8ba94805b0d00598e9cde542bcf86e9c3ae43f279f34b0d77c890d428264","contract":["tar.pack returns a readable stream that yields 512-byte aligned blocks and terminates with a 1024-byte zero block after finalize","pack.entry buffers string or Buffer payload with custom header metadata and writes padded tar blocks","pack.entry returns a writable sink stream when payload is omitted and finalizes after streaming exactly header.size bytes","pack.entry destroys the pack stream and reports size mismatch when streamed bytes do not match header.size","pack.entry queues concurrent entry streams and processes them sequentially","pack.entry throws an error when called on an already finalized pack stream","pack.entry writes directory entries with type directory, default 0755 mode, and zero size","writing payload to a void directory entry emits an error rejecting bodies for that entry"],"goal":"verify tar-stream.pack in pkg:npm/tar-stream@3.2.0","kind":"HOW","packages":["pkg:npm/tar-stream@3.2.0"],"schemaVersion":1,"symbols":["tar-stream.pack"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/tar-stream@3.2.0"],"schemaVersion":1,"subject":"pkg:npm/tar-stream@3.2.0","symbols":["tar-stream.pack"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-tar-stream-pack",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-tar-stream-pack",
"version": "1.0.0",
"dependencies": {
"tar-stream": "3.2.0"
}
},
"node_modules/b4a": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.9.0.tgz",
"integrity": "sha512-dpfcF9fDNR6++cthXR67iyhgqWy9CBouAvIWhIntzBG6cvK/cnIPiZQjBwi/ZqjjBEDGfoNDtmB0kTjroOJ3pQ==",
"license": "Apache-2.0",
"peerDependencies": {
"react-native-b4a": "*"
},
"peerDependenciesMeta": {
"react-native-b4a": {
"optional": true
}
}
},
"node_modules/bare-events": {
"version": "2.9.2",
"resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.2.tgz",
"integrity": "sha512-AIPKioV7/Y/8KfZ3AAhjPJxLLbY49S64Ym5DakZlUg75qQiTgUq9hEJoEwa4eUezPUlXRy/i5NpsKvo9jgKmoA==",
"license": "Apache-2.0",
"peerDependencies": {
"bare-abort-controller": "*"
},
"peerDependenciesMeta": {
"bare-abort-controller": {
"optional": true
}
}
},
"node_modules/bare-fs": {
"version": "4.8.1",
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.8.1.tgz",
"integrity": "sha512-N1nnXdHZAOSstz0XiHikGS4HGMH4CnSwhqWdGQQMqqdvp4Jybm9sE3R1WVnpWVd4SFkc8ryPDBLViNLwiEqECg==",
"license": "Apache-2.0",
"dependencies": {
"bare-events": "^2.5.4",
"bare-path": "^3.0.0",
"bare-stream": "^2.6.4",
"bare-url": "^2.2.2",
"fast-fifo": "^1.3.2"
},
"engines": {
"bare": ">=1.28.0"
},
"peerDependencies": {
"bare-buffer": "*"
},
"peerDependenciesMeta": {
"bare-buffer": {
"optional": true
}
}
},
"node_modules/bare-path": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.2.tgz",
"integrity": "sha512-ZyKbsuuqK6Ag0K8pX6V5Txq6XeJRvY+wXucnFGRjiyVYP9YWDpIQugk/b+enRYrEYBJaqLzghRQpXPMR7341Nw==",
"license": "Apache-2.0"
},
"node_modules/bare-stream": {
"version": "2.13.4",
"resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.4.tgz",
"integrity": "sha512-PcrQ8lVLbiJscNm1Kez+Yp4Gy4AHGcN1lzwjvf5NybWen7VvEgUfyfnXYJ2zNqWnzOfCb1Abq6lH8ti0syQszA==",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.8.1",
"streamx": "^2.25.0",
"teex": "^1.0.1"
},
"peerDependencies": {
"bare-abort-controller": "*",
"bare-buffer": "*",
"bare-events": "*"
},
"peerDependenciesMeta": {
"bare-abort-controller": {
"optional": true
},
"bare-buffer": {
"optional": true
},
"bare-events": {
"optional": true
}
}
},
"node_modules/bare-url": {
"version": "2.5.4",
"resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.5.4.tgz",
"integrity": "sha512-Gxa7UVWBr0/edU1b+TJhn/AZvMQUj9OGspvYsaTYQrAbZA4BOTZGL3LiZxvD+CeMlDH4juwD84+eTAp/bLYW5g==",
"license": "Apache-2.0",
"dependencies": {
"bare-path": "^3.0.0"
}
},
"node_modules/events-universal": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz",
"integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==",
"license": "Apache-2.0",
"dependencies": {
"bare-events": "^2.7.0"
}
},
"node_modules/fast-fifo": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
"integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==",
"license": "MIT"
},
"node_modules/streamx": {
"version": "2.28.1",
"resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.1.tgz",
"integrity": "sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==",
"license": "MIT",
"dependencies": {
"events-universal": "^1.0.0",
"fast-fifo": "^1.3.2",
"text-decoder": "^1.1.0"
}
},
"node_modules/tar-stream": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.2.0.tgz",
"integrity": "sha512-ojzvCvVaNp6aOTFmG7jaRD0meowIAuPc3cMMhSgKiVWws1GyHbGd/xvnyuRKcKlMpt3qvxx6r0hreCNITP9hIg==",
"license": "MIT",
"dependencies": {
"b4a": "^1.6.4",
"bare-fs": "^4.5.5",
"fast-fifo": "^1.2.0",
"streamx": "^2.15.0"
}
},
"node_modules/teex": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/teex/-/teex-1.0.1.tgz",
"integrity": "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==",
"license": "MIT",
"dependencies": {
"streamx": "^2.12.5"
}
},
"node_modules/text-decoder": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz",
"integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.6.4"
}
}
}
}
{
"name": "sample-tar-stream-pack",
"version": "1.0.0",
"private": true,
"dependencies": {
"tar-stream": "3.2.0"
}
}
{
"schemaVersion": 1,
"goal": "verify tar-stream.pack in pkg:npm/tar-stream@3.2.0",
"kind": "HOW",
"packages": [
"pkg:npm/tar-stream@3.2.0"
],
"symbols": [
"tar-stream.pack"
]
}
import assert from 'node:assert/strict';
import { Buffer } from 'node:buffer';
import tar from 'tar-stream';
// 1. tar.pack returns a readable stream that yields 512-byte aligned blocks and terminates with a 1024-byte zero block after finalize
await new Promise((resolve, reject) => {
const pack = tar.pack();
const chunks = [];
pack.on('data', (chunk) => chunks.push(chunk));
pack.on('end', () => {
try {
const tarBuf = Buffer.concat(chunks);
assert.ok(tarBuf.length >= 1024);
assert.equal(tarBuf.length % 512, 0);
const trailer = tarBuf.subarray(tarBuf.length - 1024);
assert.deepEqual(trailer, Buffer.alloc(1024, 0));
resolve();
} catch (err) {
reject(err);
}
});
pack.on('error', reject);
pack.finalize();
});
// 2. pack.entry buffers string or Buffer payload with custom header metadata and writes padded tar blocks
await new Promise((resolve, reject) => {
const pack = tar.pack();
const chunks = [];
pack.on('data', (chunk) => chunks.push(chunk));
pack.on('end', () => {
try {
const tarBuf = Buffer.concat(chunks);
assert.equal(tarBuf.length % 512, 0);
// Inspect header at offset 0
const name = tarBuf
.subarray(0, 100)
.toString('utf8')
.replace(/\0.*$/, '');
assert.equal(name, 'test-file.txt');
const sizeOctal = tarBuf
.subarray(124, 136)
.toString('utf8')
.replace(/\0.*$/, '')
.trim();
assert.equal(parseInt(sizeOctal, 8), 14);
const magic = tarBuf.subarray(257, 263).toString('utf8');
assert.ok(magic.startsWith('ustar'));
// Check content at offset 512
const content = tarBuf.subarray(512, 512 + 14).toString('utf8');
assert.equal(content, 'hello tar pack');
// Check padding between 512+14 and 1024
const padding = tarBuf.subarray(512 + 14, 1024);
assert.deepEqual(padding, Buffer.alloc(512 - 14, 0));
resolve();
} catch (err) {
reject(err);
}
});
pack.on('error', reject);
pack.entry(
{ name: 'test-file.txt', mode: 0o644, mtime: new Date(1700000000000) },
'hello tar pack',
(err) => {
if (err) return reject(err);
pack.finalize();
},
);
});
// 3. pack.entry returns a writable sink stream when payload is omitted and finalizes after streaming exactly header.size bytes
await new Promise((resolve, reject) => {
const pack = tar.pack();
const chunks = [];
pack.on('data', (chunk) => chunks.push(chunk));
pack.on('end', () => {
try {
const tarBuf = Buffer.concat(chunks);
assert.equal(tarBuf.length % 512, 0);
const name = tarBuf
.subarray(0, 100)
.toString('utf8')
.replace(/\0.*$/, '');
assert.equal(name, 'streamed.txt');
const content = tarBuf.subarray(512, 512 + 11).toString('utf8');
assert.equal(content, 'stream-data');
resolve();
} catch (err) {
reject(err);
}
});
pack.on('error', reject);
const entryStream = pack.entry({ name: 'streamed.txt', size: 11 }, (err) => {
if (err) return reject(err);
pack.finalize();
});
assert.equal(typeof entryStream.write, 'function');
entryStream.write(Buffer.from('stream-'));
entryStream.end(Buffer.from('data'));
});
// 4. pack.entry destroys the pack stream and reports size mismatch when streamed bytes do not match header.size
await new Promise((resolve, reject) => {
const pack = tar.pack();
let packError = null;
let entryError = null;
function check() {
try {
assert.ok(packError instanceof Error);
assert.match(packError.message, /size mismatch/i);
assert.ok(entryError instanceof Error);
assert.match(entryError.message, /size mismatch/i);
resolve();
} catch (e) {
reject(e);
}
}
pack.on('error', (err) => {
packError = err;
if (entryError) check();
});
const entryStream = pack.entry({ name: 'mismatch.txt', size: 20 }, () => {});
entryStream.on('error', (err) => {
entryError = err;
if (packError) check();
});
entryStream.write(Buffer.from('short'));
entryStream.end();
});
// 5. pack.entry queues concurrent entry streams and processes them sequentially
await new Promise((resolve, reject) => {
const pack = tar.pack();
const chunks = [];
pack.on('data', (chunk) => chunks.push(chunk));
pack.on('end', () => {
try {
const tarBuf = Buffer.concat(chunks);
assert.equal(tarBuf.length % 512, 0);
const name1 = tarBuf.subarray(0, 100).toString('utf8').replace(/\0.*$/, '');
assert.equal(name1, 'first.txt');
const name2 = tarBuf.subarray(1024, 1124).toString('utf8').replace(/\0.*$/, '');
assert.equal(name2, 'second.txt');
resolve();
} catch (err) {
reject(err);
}
});
pack.on('error', reject);
const s1 = pack.entry({ name: 'first.txt', size: 5 }, (err) => {
if (err) reject(err);
});
const s2 = pack.entry({ name: 'second.txt', size: 6 }, (err) => {
if (err) reject(err);
pack.finalize();
});
s1.write(Buffer.from('hello'));
s1.end();
s2.write(Buffer.from('world!'));
s2.end();
});
// 6. pack.entry throws an error when called on an already finalized pack stream
{
const pack = tar.pack();
pack.finalize();
assert.throws(
() => {
pack.entry({ name: 'late.txt' });
},
{
name: 'Error',
message: /already finalized or destroyed/,
},
);
}
// 7. pack.entry writes directory entries with type directory, default 0755 mode, and zero size
await new Promise((resolve, reject) => {
const pack = tar.pack();
const chunks = [];
pack.on('data', (chunk) => chunks.push(chunk));
pack.on('end', () => {
try {
const tarBuf = Buffer.concat(chunks);
const name = tarBuf
.subarray(0, 100)
.toString('utf8')
.replace(/\0.*$/, '');
assert.equal(name, 'some-dir/');
const modeOctal = tarBuf
.subarray(100, 108)
.toString('utf8')
.replace(/\0.*$/, '')
.trim();
assert.equal(parseInt(modeOctal, 8), 0o755);
const typeflag = String.fromCharCode(tarBuf[156]);
assert.equal(typeflag, '5');
const sizeOctal = tarBuf
.subarray(124, 136)
.toString('utf8')
.replace(/\0.*$/, '')
.trim();
assert.equal(parseInt(sizeOctal, 8), 0);
resolve();
} catch (err) {
reject(err);
}
});
pack.on('error', reject);
pack.entry({ name: 'some-dir/', type: 'directory' }, (err) => {
if (err) return reject(err);
pack.finalize();
});
});
// 8. writing payload to a void directory entry emits an error rejecting bodies for that entry
await new Promise((resolve, reject) => {
const pack = tar.pack();
let packError = null;
let sinkError = null;
function check() {
try {
assert.ok(packError instanceof Error);
assert.match(packError.message, /No body allowed for this entry/);
assert.ok(sinkError instanceof Error);
assert.match(sinkError.message, /No body allowed for this entry/);
resolve();
} catch (e) {
reject(e);
}
}
pack.on('error', (err) => {
packError = err;
if (sinkError) check();
});
const voidSink = pack.entry({ name: 'some-dir/', type: 'directory' });
voidSink.on('error', (err) => {
sinkError = err;
if (packError) check();
});
voidSink.write(Buffer.from('unexpected'));
});
Seeder d'origine
anonyme