샘플
tar-stream 3.3.0: extract
검증된 샘플 — npm tar-stream 3.3.0: extract. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: extract emits entry events with header metadata…
sha256:5e52650f196f51f09a2d61450a25296c03e3b8cbc9ec4e8ff809698f7e8318d1
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-12-01 |
케이스
HOW- 목표
- verify tar-stream.extract in pkg:npm/tar-stream@3.3.0
- 패키지
- 심벌
-
- tar-stream.extract
- 환경
- node 22.23.2
- 생성일
- 2026-12-01T00:24:11Z
컨트랙트
- extract emits entry events with header metadata, byteOffset, and readable streams while serializing entries until next() is invoked
- extract emits zero-byte readable streams for directory entries and empty files and decodes PAX long path entries
- extract supports async iteration yielding readable entry streams with header metadata and byte offset
- extract propagates errors passed to the entry callback next(err) to the extract error event
- extract emits an error on corrupted tar header checksums and on truncated streams (Unexpected end of data)
- extract stops emitting further entries and closes when an entry stream is destroyed
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
소스
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.extract in pkg:npm/tar-stream@3.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/tar-stream@3.3.0
Demonstrate these symbols/APIs:
- tar-stream.extract
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:f33e7de1a50458b701fa28ec18a8b73cec4c69771add6151f96193a413e71dd7","constraints":{"executionContext":"node"},"contract":["extract emits entry events with header metadata, byteOffset, and readable streams while serializing entries until next() is invoked","extract emits zero-byte readable streams for directory entries and empty files and decodes PAX long path entries","extract supports async iteration yielding readable entry streams with header metadata and byte offset","extract propagates errors passed to the entry callback next(err) to the extract error event","extract emits an error on corrupted tar header checksums and on truncated streams (Unexpected end of data)","extract stops emitting further entries and closes when an entry stream is destroyed"],"goal":"verify tar-stream.extract in pkg:npm/tar-stream@3.3.0","kind":"HOW","packages":["pkg:npm/tar-stream@3.3.0"],"schemaVersion":1,"symbols":["tar-stream.extract"]},"contractCommand":["node","test/contract.cjs"],"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","symbols":["tar-stream.extract"],"verifierAdapter":"node-typescript@1"}
{
"name": "tar-stream-extract-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tar-stream-extract-sample",
"version": "1.0.0",
"license": "MIT-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.4",
"resolved": "https://registry.npmjs.org/bare-buffer/-/bare-buffer-3.7.4.tgz",
"integrity": "sha512-J7JAMtFcCrE9/5BtnexA+iyxoZB23YYmY0UHxtAyYMt531pex700+phkJ0ofqczoJAzBYVo10ZivEkKgq/7dSQ==",
"license": "Apache-2.0",
"engines": {
"bare": ">=1.20.0"
}
},
"node_modules/bare-events": {
"version": "2.10.2",
"resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.10.2.tgz",
"integrity": "sha512-0ztZmAVHMID0CDy0ubK19kSKm6SmCGkeQbefrl9EIKn/rU6RmbtSMRvxtGaq+1oWyRlZIsQPmLMpotluyOSazg==",
"license": "Apache-2.0",
"peerDependencies": {
"bare-abort-controller": "*"
},
"peerDependenciesMeta": {
"bare-abort-controller": {
"optional": true
}
}
},
"node_modules/bare-fs": {
"version": "4.8.8",
"resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.8.8.tgz",
"integrity": "sha512-T98Fau5GoDAgsg4nansBou+tJrDEb5Ros1x4IxEcfnYQqTk+mLA6GAh+lxfCcNo3mtGxIQ8eWPD4K/Wr6dIqmg==",
"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"
},
"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-extract-sample",
"version": "1.0.0",
"private": true,
"description": "Verify tar-stream.extract in tar-stream 3.3.0",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"tar-stream": "3.3.0"
}
}
{
"schemaVersion": 1,
"goal": "verify tar-stream.extract in pkg:npm/tar-stream@3.3.0",
"kind": "HOW",
"packages": [
"pkg:npm/tar-stream@3.3.0"
],
"symbols": [
"tar-stream.extract"
],
"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')
function collectStream (stream) {
return new Promise((resolve, reject) => {
const chunks = []
stream.on('data', (chunk) => chunks.push(chunk))
stream.on('error', reject)
stream.on('end', () => resolve(Buffer.concat(chunks)))
})
}
function packToBuffer (entries) {
return new Promise((resolve, reject) => {
const pack = tar.pack()
const chunks = []
pack.on('data', (chunk) => chunks.push(chunk))
pack.on('error', reject)
pack.on('end', () => resolve(Buffer.concat(chunks)))
for (const item of entries) {
if (item.body !== undefined) {
pack.entry(item.header, item.body)
} else {
pack.entry(item.header)
}
}
pack.finalize()
})
}
async function testSequentialEntriesAndBackpressure () {
const longName = `nested/${'segment_'.repeat(16)}data.bin`
const largePayload = Buffer.alloc(700, 0x42)
const archive = await packToBuffer([
{ header: { name: 'dir/', type: 'directory', mode: 0o755 } },
{ header: { name: 'dir/empty.txt', type: 'file' }, body: Buffer.alloc(0) },
{ header: { name: 'dir/hello.txt', mode: 0o644 }, body: Buffer.from('hello tar-stream') },
{ header: { name: longName }, body: largePayload }
])
const results = []
let activeEntries = 0
let maxConcurrentEntries = 0
await new Promise((resolve, reject) => {
const extract = tar.extract()
extract.on('entry', (header, stream, next) => {
activeEntries += 1
if (activeEntries > maxConcurrentEntries) {
maxConcurrentEntries = activeEntries
}
collectStream(stream).then((data) => {
results.push({
name: header.name,
type: header.type,
size: header.size,
mode: header.mode,
byteOffset: header.byteOffset,
data
})
activeEntries -= 1
next()
}, (err) => {
activeEntries -= 1
next(err)
})
})
extract.on('error', reject)
extract.on('finish', resolve)
extract.end(archive)
})
assert.equal(maxConcurrentEntries, 1, 'next() should serialize entry emission')
assert.equal(results.length, 4)
assert.equal(results[0].name, 'dir/')
assert.equal(results[0].type, 'directory')
assert.equal(results[0].size, 0)
assert.equal(results[0].data.length, 0)
assert.equal(results[1].name, 'dir/empty.txt')
assert.equal(results[1].type, 'file')
assert.equal(results[1].size, 0)
assert.equal(results[1].data.length, 0)
assert.equal(results[2].name, 'dir/hello.txt')
assert.equal(results[2].type, 'file')
assert.equal(results[2].size, 16)
assert.equal(results[2].mode, 0o644)
assert.equal(typeof results[2].byteOffset, 'number')
assert.equal(results[2].data.toString('utf8'), 'hello tar-stream')
assert.equal(results[3].name, longName)
assert.equal(results[3].type, 'file')
assert.equal(results[3].size, 700)
assert.ok(results[3].data.equals(largePayload))
}
async function testAsyncIteration () {
const archive = await packToBuffer([
{ header: { name: 'first.txt' }, body: Buffer.from('alpha') },
{ header: { name: 'second.txt' }, body: Buffer.from('beta') }
])
const extract = tar.extract()
// Feed in smaller chunks to exercise streaming across block boundaries
const midpoint = Math.floor(archive.length / 2)
extract.write(archive.subarray(0, midpoint))
extract.end(archive.subarray(midpoint))
const seen = []
for await (const entry of extract) {
const data = await collectStream(entry)
seen.push({
name: entry.header.name,
offset: entry.offset,
text: data.toString('utf8')
})
}
assert.equal(seen.length, 2)
assert.equal(seen[0].name, 'first.txt')
assert.equal(seen[0].offset, 0)
assert.equal(seen[0].text, 'alpha')
assert.equal(seen[1].name, 'second.txt')
assert.equal(seen[1].offset, 1024)
assert.equal(seen[1].text, 'beta')
}
async function testNextErrorPropagation () {
const archive = await packToBuffer([
{ header: { name: 'one.txt' }, body: Buffer.from('111') },
{ header: { name: 'two.txt' }, body: Buffer.from('222') }
])
const err = await new Promise((resolve, reject) => {
const extract = tar.extract()
let count = 0
extract.on('entry', (_header, stream, next) => {
count += 1
stream.resume()
next(new Error('stop extraction'))
})
extract.on('error', (e) => {
resolve({ err: e, count })
})
extract.on('finish', () => reject(new Error('expected error, got finish')))
extract.end(archive)
})
assert.equal(err.err.message, 'stop extraction')
assert.equal(err.count, 1)
}
async function testInvalidHeaderError () {
const invalid = Buffer.alloc(512, 0x58)
const err = await new Promise((resolve, reject) => {
const extract = tar.extract()
extract.on('error', resolve)
extract.on('finish', () => reject(new Error('expected invalid header error')))
extract.end(invalid)
})
assert.match(err.message, /Invalid tar header/)
}
async function testTruncatedStreamError () {
const archive = await packToBuffer([
{ header: { name: 'full.bin' }, body: Buffer.alloc(512, 0x33) }
])
const truncated = archive.subarray(0, 768)
const err = await new Promise((resolve, reject) => {
const extract = tar.extract()
extract.on('entry', (_header, stream, next) => {
stream.on('data', () => {})
stream.on('end', () => next())
})
extract.on('error', resolve)
extract.on('finish', () => reject(new Error('expected truncated stream error')))
extract.end(truncated)
})
assert.equal(err.message, 'Unexpected end of data')
}
async function testDestroyAbortsRemainingEntries () {
const archive = await packToBuffer([
{ header: { name: 'a.txt' }, body: Buffer.from('aaa') },
{ header: { name: 'b.txt' }, body: Buffer.from('bbb') }
])
const seen = []
await new Promise((resolve, reject) => {
const extract = tar.extract()
extract.on('entry', (header, stream) => {
seen.push(header.name)
stream.destroy()
})
extract.on('error', reject)
extract.on('close', resolve)
extract.end(archive)
})
assert.deepEqual(seen, ['a.txt'])
}
async function main () {
await testSequentialEntriesAndBackpressure()
await testAsyncIteration()
await testNextErrorPropagation()
await testInvalidHeaderError()
await testTruncatedStreamError()
await testDestroyAbortsRemainingEntries()
}
main().catch((err) => {
console.error(err)
process.exitCode = 1
})
오리진 시더
익명