示例
chromium-pickle-js 0.2.0: createEmpty, createFromBuffer
已验证示例 — npm chromium-pickle-js 0.2.0: createEmpty, createFromBuffer. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: createEmpty returns a new Pickle…
sha256:258c307b68344ed1f201fa4a1d3acd6c6b0dd7ddfdfbafca4e3bbfb2ca0e8951
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 2
- 构建过它的签名密钥
- 1
声明的环境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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-26 |
| 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-08 |
案例
HOW- 目标
- verify pkg:npm/chromium-pickle-js@0.2.0
- 符号
-
- createEmpty
- createFromBuffer
- 环境
- node 22.23.2
- 创建时间
- 2026-08-26T09:11:46Z
契约
- createEmpty returns a new Pickle instance that can write bool, int, uint32, float, double, and string primitives
- Pickle.toBuffer returns a Buffer containing the 4-byte payload size header followed by 4-byte aligned payload data
- createFromBuffer initializes a Pickle instance from an existing Buffer for reading with PickleIterator
- PickleIterator sequentially reads bool, int, uint32, float, double, and string values in matching write order
- Pickle.writeInt64 and Pickle.writeUInt64 throw TypeError in Node.js because 64-bit buffer write methods are undefined on Buffer.prototype
- PickleIterator throws an Error when attempting to read past the payload buffer end
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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/chromium-pickle-js@0.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/chromium-pickle-js@0.2.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:2a8593e5836b43efa8f92fa1b859ef2940f790b35ad5147c877cd3218bee6c31","constraints":{"executionContext":"node"},"contract":["createEmpty returns a new Pickle instance that can write bool, int, uint32, float, double, and string primitives","Pickle.toBuffer returns a Buffer containing the 4-byte payload size header followed by 4-byte aligned payload data","createFromBuffer initializes a Pickle instance from an existing Buffer for reading with PickleIterator","PickleIterator sequentially reads bool, int, uint32, float, double, and string values in matching write order","Pickle.writeInt64 and Pickle.writeUInt64 throw TypeError in Node.js because 64-bit buffer write methods are undefined on Buffer.prototype","PickleIterator throws an Error when attempting to read past the payload buffer end"],"goal":"verify pkg:npm/chromium-pickle-js@0.2.0","kind":"HOW","packages":["pkg:npm/chromium-pickle-js@0.2.0"],"schemaVersion":1,"symbols":["createEmpty","createFromBuffer"]},"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/chromium-pickle-js@0.2.0"],"schemaVersion":1,"subject":"pkg:npm/chromium-pickle-js@0.2.0","symbols":["createEmpty","createFromBuffer"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-chromium-pickle-js",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-chromium-pickle-js",
"version": "1.0.0",
"dependencies": {
"chromium-pickle-js": "0.2.0"
}
},
"node_modules/chromium-pickle-js": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
"integrity": "sha512-1R5Fho+jBq0DDydt+/vHWj5KJNJCKdARKOCwZUen84I5BreWoLqRLANH1U87eJy1tiASPtMnGqJJq0ZsLoRPOw==",
"license": "MIT"
}
}
}
{
"name": "sample-chromium-pickle-js",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"chromium-pickle-js": "0.2.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/chromium-pickle-js@0.2.0",
"kind": "HOW",
"packages": [
"pkg:npm/chromium-pickle-js@0.2.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import pickle from 'chromium-pickle-js';
const { createEmpty, createFromBuffer } = pickle;
/**
* Creates an empty Pickle instance for writing binary data.
* @returns {object}
*/
export function createEmptyPickle() {
return createEmpty();
}
/**
* Creates a Pickle instance from an existing Buffer for reading.
* @param {Buffer} buffer
* @returns {object}
*/
export function createPickleFromBuffer(buffer) {
return createFromBuffer(buffer);
}
export { createEmpty, createFromBuffer };
import assert from 'node:assert/strict';
import {
createEmpty,
createFromBuffer,
createEmptyPickle,
createPickleFromBuffer,
} from '../src/index.mjs';
// 1. createEmpty returns a new Pickle instance that can write bool, int, uint32, float, double, and string primitives
{
const p = createEmptyPickle();
assert.equal(p.writeBool(true), true);
assert.equal(p.writeBool(false), true);
assert.equal(p.writeInt(-12345), true);
assert.equal(p.writeUInt32(54321), true);
assert.equal(p.writeFloat(1.5), true);
assert.equal(p.writeDouble(3.141592653589793), true);
assert.equal(p.writeString('chromium-pickle-sample'), true);
}
// 2. Pickle.toBuffer returns a Buffer containing the 4-byte payload size header followed by 4-byte aligned payload data
{
const p = createEmpty();
assert.equal(p.writeInt(42), true);
const buf = p.toBuffer();
assert.ok(Buffer.isBuffer(buf));
const payloadSize = buf.readUInt32LE(0);
assert.equal(payloadSize, 4);
assert.equal(buf.length, 8);
assert.equal(buf.readInt32LE(4), 42);
}
// 3. createFromBuffer initializes a Pickle instance from an existing Buffer for reading with PickleIterator
{
const pWrite = createEmpty();
assert.equal(pWrite.writeString('read-test'), true);
const buf = pWrite.toBuffer();
const pRead = createPickleFromBuffer(buf);
const it = pRead.createIterator();
assert.equal(it.readString(), 'read-test');
}
// 4. PickleIterator sequentially reads bool, int, uint32, float, double, and string values in matching write order
{
const p = createEmpty();
assert.equal(p.writeBool(true), true);
assert.equal(p.writeBool(false), true);
assert.equal(p.writeInt(-9876), true);
assert.equal(p.writeUInt32(65432), true);
assert.equal(p.writeFloat(2.5), true);
assert.equal(p.writeDouble(2.718281828459045), true);
assert.equal(p.writeString('sequential-test'), true);
const buf = p.toBuffer();
const pRead = createFromBuffer(buf);
const it = pRead.createIterator();
assert.equal(it.readBool(), true);
assert.equal(it.readBool(), false);
assert.equal(it.readInt(), -9876);
assert.equal(it.readUInt32(), 65432);
assert.equal(it.readFloat(), 2.5);
assert.equal(it.readDouble(), 2.718281828459045);
assert.equal(it.readString(), 'sequential-test');
}
// 5. Pickle.writeInt64 and Pickle.writeUInt64 throw TypeError in Node.js because 64-bit buffer write methods are undefined on Buffer.prototype
{
const p = createEmpty();
assert.throws(
() => {
p.writeInt64(100);
},
{
name: 'TypeError',
}
);
assert.throws(
() => {
p.writeUInt64(100);
},
{
name: 'TypeError',
}
);
}
// 6. PickleIterator throws an Error when attempting to read past the payload buffer end
{
const p = createEmpty();
assert.equal(p.writeInt(100), true);
const buf = p.toBuffer();
const pRead = createFromBuffer(buf);
const it = pRead.createIterator();
assert.equal(it.readInt(), 100);
assert.throws(
() => {
it.readInt();
},
{
name: 'Error',
message: /Failed to read data with length of/,
}
);
}
console.log('Contract assertions passed.');
原始种子者
匿名