Exemple
tar-stream 3.3.0
Échantillon vérifié pour npm tar-stream 3.3.0. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi : tar.pack writes 512-byte…
sha256:a60cb58a45fd52357b41f6a75f100ecd02556bfbff6c6272114bba334bef53bc
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-11-29 |
Cas
HOW- Objectif
- verify pkg:npm/tar-stream@3.3.0
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-11-29T23:52:40Z
Contrat
- tar.pack writes 512-byte aligned tar blocks terminated by a 1024-byte zero trailer
- tar.pack entry supports buffered payloads, streaming sink entries, directories with default 0o755 mode, symlinks, and PAX long-path headers
- tar.pack queues concurrent entry streams sequentially and throws when entry is called after finalize
- tar.pack rejects streamed entries with a size mismatch and rejects writing a body to directory entries
- tar.extract parses entries via the entry event preserving order, metadata, byteOffset, and payload bytes
- tar.extract supports async iteration yielding readable entry streams with header metadata and offset
- tar.extract rejects invalid tar headers, truncated streams, entry callback errors, and PAX paths containing a null byte
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
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 pkg:npm/tar-stream@3.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/tar-stream@3.3.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:121a3121a56ca9f166b20311042871523cbdd1267fe41e7bde52c9d98659c9ba","constraints":{"executionContext":"node"},"contract":["tar.pack writes 512-byte aligned tar blocks terminated by a 1024-byte zero trailer","tar.pack entry supports buffered payloads, streaming sink entries, directories with default 0o755 mode, symlinks, and PAX long-path headers","tar.pack queues concurrent entry streams sequentially and throws when entry is called after finalize","tar.pack rejects streamed entries with a size mismatch and rejects writing a body to directory entries","tar.extract parses entries via the entry event preserving order, metadata, byteOffset, and payload bytes","tar.extract supports async iteration yielding readable entry streams with header metadata and offset","tar.extract rejects invalid tar headers, truncated streams, entry callback errors, and PAX paths containing a null byte"],"goal":"verify pkg:npm/tar-stream@3.3.0","kind":"HOW","packages":["pkg:npm/tar-stream@3.3.0"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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.3.0"],"schemaVersion":1,"subject":"pkg:npm/tar-stream@3.3.0","verifierAdapter":"node-typescript@1"}
'use strict'
const tar = require('tar-stream')
function collectStream (readable) {
return new Promise((resolve, reject) => {
const chunks = []
readable.on('data', (chunk) => chunks.push(Buffer.from(chunk)))
readable.on('error', reject)
readable.on('end', () => resolve(Buffer.concat(chunks)))
})
}
async function packEntries (entries) {
const pack = tar.pack()
const outputPromise = collectStream(pack)
for (const item of entries) {
if (item.chunks) {
const entryStream = pack.entry(item.header)
for (const chunk of item.chunks) {
entryStream.write(chunk)
}
entryStream.end()
} else if (item.body !== undefined) {
pack.entry(item.header, item.body)
} else {
pack.entry(item.header)
}
}
pack.finalize()
return outputPromise
}
function extractEntries (archiveBuffer) {
return new Promise((resolve, reject) => {
const extract = tar.extract()
const results = []
extract.on('entry', async (header, stream, next) => {
try {
const body = await collectStream(stream)
results.push({ header, body })
next()
} catch (err) {
next(err)
}
})
extract.on('error', reject)
extract.on('finish', () => resolve(results))
extract.end(archiveBuffer)
})
}
async function extractEntriesAsync (archiveBuffer) {
const extract = tar.extract()
const results = []
extract.end(archiveBuffer)
for await (const entry of extract) {
const body = await collectStream(entry)
results.push({
header: entry.header,
offset: entry.offset,
body
})
}
return results
}
module.exports = {
collectStream,
packEntries,
extractEntries,
extractEntriesAsync
}
{
"name": "tar-stream-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tar-stream-sample",
"version": "1.0.0",
"dependencies": {
"tar-stream": "3.3.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-buffer": {
"version": "3.7.3",
"resolved": "https://registry.npmjs.org/bare-buffer/-/bare-buffer-3.7.3.tgz",
"integrity": "sha512-77owW16RX6YgdOzddHtM0oGz8wsd0/F9k/0coz6TPmjUHnr/9FwWODVMNKwyYWM/a/ESdTum855nfQxnsKUygA==",
"license": "Apache-2.0",
"engines": {
"bare": ">=1.20.0"
}
},
"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.7",
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.8.7.tgz",
"integrity": "sha512-bNBjq+x9Wezp3risJs7TaPH3jjVnyFmmSSxfpES8tp9xjvL4t6Bk9v2nC+xm5lfxJeDzChK7NBryK+JciM/pfQ==",
"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.3",
"resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.3.tgz",
"integrity": "sha512-8r+FVU/o4zcFmpCDqbqAYhHHbtXPP+cyZKo7DRGRWc7OLlNs4TMaSQEpXL/sIdzyEG0M7RHw4B7xYMGrTc+qrg==",
"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.8",
"resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.5.8.tgz",
"integrity": "sha512-G5KTe5Bj6z5pqIxcn3lWlIFIv0rkXbccx0T0Xuf7t4RapfSWvFlcVbrwYXxFZ00PC4lp57OCIk6uXP/r3GbpDw==",
"license": "Apache-2.0",
"dependencies": {
"bare-buffer": "^3.0.0",
"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.3.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.3.0.tgz",
"integrity": "sha512-rQZZfW2Q4YDCFJyP8KFDG+gfMzcOHaMYq0gb9jzH2gsK0P5qXVpu+UoKE1qaZcs3/R6QVkJr2228nlZoM1V5PA==",
"license": "MIT",
"dependencies": {
"b4a": "^1.9.0",
"bare-fs": "^4.8.2",
"fast-fifo": "^1.3.2",
"streamx": "^2.28.1"
}
},
"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": "tar-stream-sample",
"version": "1.0.0",
"private": true,
"description": "Minimal verification sample for tar-stream 3.3.0",
"main": "index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"tar-stream": "3.3.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/tar-stream@3.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/tar-stream@3.3.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict'
const assert = require('node:assert/strict')
const tar = require('tar-stream')
const {
collectStream,
packEntries,
extractEntries,
extractEntriesAsync
} = require('../index')
async function testPackAndExtractRoundTrip () {
const fixedTime = new Date(1700000000 * 1000)
const longName = 'nested/' + 'segment/'.repeat(16) + 'long-file-name.txt'
const binaryBody = Buffer.from([0x00, 0x01, 0x02, 0xfe, 0xff])
const archive = await packEntries([
{
header: {
name: 'dir/',
type: 'directory',
mtime: fixedTime
}
},
{
header: {
name: 'dir/hello.txt',
mode: 0o640,
uid: 1000,
gid: 1000,
uname: 'user',
gname: 'group',
mtime: fixedTime
},
body: 'hello tar-stream'
},
{
header: {
name: 'dir/binary.bin',
size: binaryBody.length,
mtime: fixedTime
},
chunks: [binaryBody.subarray(0, 2), binaryBody.subarray(2)]
},
{
header: {
name: 'dir/link.txt',
type: 'symlink',
linkname: 'hello.txt',
mtime: fixedTime
}
},
{
header: {
name: longName,
mtime: fixedTime,
pax: { comment: 'pax-metadata' }
},
body: Buffer.from('long-path-content')
}
])
assert.equal(archive.length % 512, 0)
assert.ok(archive.length >= 1024)
assert.deepEqual(archive.subarray(archive.length - 1024), Buffer.alloc(1024))
const entries = await extractEntries(archive)
assert.equal(entries.length, 5)
assert.equal(entries[0].header.name, 'dir/')
assert.equal(entries[0].header.type, 'directory')
assert.equal(entries[0].header.mode, 0o755)
assert.equal(entries[0].header.size, 0)
assert.equal(entries[0].body.length, 0)
assert.equal(entries[1].header.name, 'dir/hello.txt')
assert.equal(entries[1].header.type, 'file')
assert.equal(entries[1].header.mode, 0o640)
assert.equal(entries[1].header.uid, 1000)
assert.equal(entries[1].header.gid, 1000)
assert.equal(entries[1].header.uname, 'user')
assert.equal(entries[1].header.gname, 'group')
assert.equal(entries[1].header.mtime.getTime(), fixedTime.getTime())
assert.equal(typeof entries[1].header.byteOffset, 'number')
assert.ok(entries[1].header.byteOffset > 0)
assert.equal(entries[1].body.toString('utf8'), 'hello tar-stream')
assert.equal(entries[2].header.name, 'dir/binary.bin')
assert.equal(entries[2].header.size, binaryBody.length)
assert.deepEqual(entries[2].body, binaryBody)
assert.equal(entries[3].header.name, 'dir/link.txt')
assert.equal(entries[3].header.type, 'symlink')
assert.equal(entries[3].header.linkname, 'hello.txt')
assert.equal(entries[3].header.size, 0)
assert.equal(entries[4].header.name, longName)
assert.equal(entries[4].header.pax.comment, 'pax-metadata')
assert.equal(entries[4].body.toString('utf8'), 'long-path-content')
const iterated = await extractEntriesAsync(archive)
assert.equal(iterated.length, 5)
assert.equal(iterated[0].offset, 0)
assert.equal(iterated[1].header.name, 'dir/hello.txt')
assert.equal(iterated[1].body.toString('utf8'), 'hello tar-stream')
assert.equal(iterated[4].header.name, longName)
assert.equal(iterated[4].body.toString('utf8'), 'long-path-content')
}
async function testQueuedEntriesAndFinalizeGuard () {
const pack = tar.pack()
const archivePromise = collectStream(pack)
const first = pack.entry({ name: 'first.txt', size: 5 })
const second = pack.entry({ name: 'second.txt', size: 6 })
second.end('second')
first.end('first')
pack.finalize()
const archive = await archivePromise
assert.throws(
() => pack.entry({ name: 'after.txt' }, 'nope'),
/already finalized or destroyed/
)
const extracted = await extractEntries(archive)
assert.deepEqual(
extracted.map((e) => [e.header.name, e.body.toString('utf8')]),
[
['first.txt', 'first'],
['second.txt', 'second']
]
)
}
async function testPackErrorCases () {
await assert.rejects(async () => {
const pack = tar.pack()
const promise = collectStream(pack)
const sink = pack.entry({ name: 'mismatch.txt', size: 10 })
sink.on('error', () => {})
sink.end('short')
await promise
}, /Size mismatch/)
await assert.rejects(async () => {
const pack = tar.pack()
const promise = collectStream(pack)
const dirSink = pack.entry({ name: 'bad-dir/', type: 'directory' })
dirSink.on('error', () => {})
dirSink.write('unexpected-body')
dirSink.end()
await promise
}, /No body allowed for this entry/)
}
async function testExtractErrorCases () {
await assert.rejects(
() => extractEntries(Buffer.alloc(512, 0x41)),
/Invalid tar header/
)
const valid = await packEntries([
{ header: { name: 'cut.txt' }, body: 'complete payload data' }
])
await assert.rejects(
() => extractEntries(valid.subarray(0, 520)),
/Unexpected end of data/
)
await assert.rejects(async () => {
const extract = tar.extract()
await new Promise((resolve, reject) => {
extract.on('entry', (_header, stream, next) => {
stream.resume()
next(new Error('consumer abort'))
})
extract.on('error', reject)
extract.on('finish', resolve)
extract.end(valid)
})
}, /consumer abort/)
const paxNullArchive = await packEntries([
{
header: {
name: 'safe.txt',
pax: { path: 'bad\0name.txt' }
},
body: 'data'
}
])
await assert.rejects(
() => extractEntries(paxNullArchive),
/pax path contains a null byte/
)
}
async function main () {
await testPackAndExtractRoundTrip()
await testQueuedEntriesAndFinalizeGuard()
await testPackErrorCases()
await testExtractErrorCases()
console.log('tar-stream@3.3.0 contract passed')
}
main().catch((err) => {
console.error(err)
process.exit(1)
})
Seeder d'origine
anonyme