示例
adm-zip 0.6.1
已验证示例 — npm adm-zip 0.6.1. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: AdmZip creates an in-memory zip archive and adds file entries
sha256:03dd301bd633ef294815fa8e88247ec4d0489bce941cb14df11986713cedc4c2
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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-09-16 |
案例
HOW- 目标
- verify pkg:npm/adm-zip@0.6.1
- 环境
- node 22.23.2
- 创建时间
- 2026-09-16T11:04:16Z
契约
- AdmZip creates an in-memory zip archive and adds file entries
- readAsText retrieves decompressed file contents as string
- getEntry returns entry metadata and getData returns raw decompressed Buffer
- nested file entry preserves byte-for-byte binary content
- serialize archive to buffer and reload into new AdmZip instance
- deleteFile removes an entry from the archive
文件
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
源代码
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/adm-zip@0.6.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/adm-zip@0.6.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.
{"case":{"caseId":"case:sha256:db6f5c987450b115cc734dafcd8125568af3d52652fac5b7ba660c3029f15afa","contract":["AdmZip creates an in-memory zip archive and adds file entries","readAsText retrieves decompressed file contents as string","getEntry returns entry metadata and getData returns raw decompressed Buffer","nested file entry preserves byte-for-byte binary content","serialize archive to buffer and reload into new AdmZip instance","deleteFile removes an entry from the archive"],"goal":"verify pkg:npm/adm-zip@0.6.1","kind":"HOW","packages":["pkg:npm/adm-zip@0.6.1"],"schemaVersion":1},"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/adm-zip@0.6.1"],"schemaVersion":1,"subject":"pkg:npm/adm-zip@0.6.1","verifierAdapter":"node-typescript@1"}
const AdmZip = require('adm-zip');
/**
* Creates an in-memory zip archive with initial files.
* @param {Array<{path: string, content: Buffer|string, comment?: string}>} files
* @returns {AdmZip}
*/
function createArchive(files = []) {
const zip = new AdmZip();
for (const file of files) {
const data = Buffer.isBuffer(file.content)
? file.content
: Buffer.from(file.content, 'utf8');
zip.addFile(file.path, data, file.comment || '');
}
return zip;
}
/**
* Reads entry content as text.
* @param {AdmZip} zip
* @param {string} entryPath
* @returns {string}
*/
function readEntryText(zip, entryPath) {
return zip.readAsText(entryPath);
}
/**
* Serializes archive to a Buffer and reloads a fresh AdmZip instance.
* @param {AdmZip} zip
* @returns {AdmZip}
*/
function reloadArchive(zip) {
const buffer = zip.toBuffer();
return new AdmZip(buffer);
}
module.exports = {
AdmZip,
createArchive,
readEntryText,
reloadArchive
};
{
"name": "sample-adm-zip",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-adm-zip",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"adm-zip": "0.6.1"
}
},
"node_modules/adm-zip": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.6.1.tgz",
"integrity": "sha512-Xwrja8nx9e5o2N1my4DsKCeKpdrnACyr1wtbPxBDgGzKzKyE9kRtBFA8mWldI+RVlD7CBZNWY/wQ2+ydwOR6kQ==",
"license": "MIT",
"engines": {
"node": ">=14.0"
}
}
}
}
{
"name": "sample-adm-zip",
"version": "1.0.0",
"description": "Clean-room sample verifying pkg:npm/adm-zip@0.6.1 functionality",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"adm-zip": "0.6.1"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/adm-zip@0.6.1",
"kind": "HOW",
"packages": [
"pkg:npm/adm-zip@0.6.1"
]
}
import assert from 'node:assert';
import AdmZip from 'adm-zip';
import { createArchive, readEntryText, reloadArchive } from '../index.js';
// 1. AdmZip creates an in-memory zip archive and adds file entries
const testContent = 'Hello CodeSampleX adm-zip verification!';
const binaryData = Buffer.from([0x50, 0x4b, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04]);
const zip = createArchive([
{ path: 'test.txt', content: testContent, comment: 'test comment' },
{ path: 'nested/binary.bin', content: binaryData }
]);
assert.strictEqual(zip.getEntries().length, 2, 'zip should contain 2 entries');
// 2. readAsText retrieves decompressed file contents as string
const text = readEntryText(zip, 'test.txt');
assert.strictEqual(text, testContent, 'readAsText should return exact text content');
// 3. getEntry returns entry metadata and getData returns raw decompressed Buffer
const entry = zip.getEntry('test.txt');
assert.ok(entry, 'entry should exist');
assert.strictEqual(entry.entryName, 'test.txt', 'entryName should match');
assert.strictEqual(entry.comment, 'test comment', 'comment should match');
const buffer = entry.getData();
assert.ok(Buffer.isBuffer(buffer), 'getData should return a Buffer');
assert.strictEqual(buffer.toString('utf8'), testContent, 'buffer content should match testContent');
// 4. nested file entry preserves byte-for-byte binary content
const binEntry = zip.getEntry('nested/binary.bin');
assert.ok(binEntry, 'nested entry should exist');
assert.ok(binEntry.getData().equals(binaryData), 'binary data should be byte-identical');
// 5. serialize archive to buffer and reload into new AdmZip instance
const reloaded = reloadArchive(zip);
assert.strictEqual(reloaded.getEntries().length, 2, 'reloaded zip should contain 2 entries');
assert.strictEqual(reloaded.readAsText('test.txt'), testContent, 'reloaded readAsText should match');
assert.ok(reloaded.getEntry('nested/binary.bin').getData().equals(binaryData), 'reloaded binary data should match');
// 6. deleteFile removes an entry from the archive
reloaded.deleteFile('test.txt');
assert.strictEqual(reloaded.getEntries().length, 1, 'archive should have 1 entry after deletion');
assert.strictEqual(reloaded.getEntry('test.txt'), null, 'deleted entry should be null');
console.log('Contract assertions passed.');
原始种子者
匿名