샘플
compact-encoding 3.3.2: c.decode
검증된 샘플 — npm compact-encoding 3.3.2: c.decode. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: c.decode is exported as a function
sha256:030633ff9dd643d7b4695e7a30029f83ed272e85a4fac49547f58c2f3c2ce32b
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-02 |
케이스
HOW- 목표
- verify c.decode in pkg:npm/compact-encoding@3.3.2
- 심벌
-
- c.decode
- 환경
- node 22.23.2
- 생성일
- 2026-09-02T15:21:41Z
컨트랙트
- c.decode is exported as a function
- c.decode decodes UTF-8 strings from binary buffers
- c.decode decodes compact variable-length unsigned integers
- c.decode decodes fixed-size integers and signed integers
- c.decode decodes boolean values
- c.decode decodes arrays using composite array codecs
- c.decode decodes JSON objects from binary buffers
- c.decode decodes prefixed and raw binary buffers
- c.decode decodes structured custom records with multi-field codecs
- c.decode decodes from Uint8Array instances
- c.decode throws an out of bounds error when buffer length is insufficient
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 c.decode in pkg:npm/compact-encoding@3.3.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/compact-encoding@3.3.2
Demonstrate these symbols/APIs:
- c.decode
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:59a97621c25985b0ca1eb0fe44e0c174e83b1da6227cb53f28769f9a2082a93e","contract":["c.decode is exported as a function","c.decode decodes UTF-8 strings from binary buffers","c.decode decodes compact variable-length unsigned integers","c.decode decodes fixed-size integers and signed integers","c.decode decodes boolean values","c.decode decodes arrays using composite array codecs","c.decode decodes JSON objects from binary buffers","c.decode decodes prefixed and raw binary buffers","c.decode decodes structured custom records with multi-field codecs","c.decode decodes from Uint8Array instances","c.decode throws an out of bounds error when buffer length is insufficient"],"goal":"verify c.decode in pkg:npm/compact-encoding@3.3.2","kind":"HOW","packages":["pkg:npm/compact-encoding@3.3.2"],"schemaVersion":1,"symbols":["c.decode"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/compact-encoding@3.3.2"],"schemaVersion":1,"subject":"pkg:npm/compact-encoding@3.3.2","symbols":["c.decode"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-compact-encoding",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-compact-encoding",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"compact-encoding": "3.3.2"
}
},
"node_modules/b4a": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.1.tgz",
"integrity": "sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==",
"license": "Apache-2.0",
"peerDependencies": {
"react-native-b4a": "*"
},
"peerDependenciesMeta": {
"react-native-b4a": {
"optional": true
}
}
},
"node_modules/compact-encoding": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/compact-encoding/-/compact-encoding-3.3.2.tgz",
"integrity": "sha512-bgZ84oVSzjQmVHXBYWON+wQUkdVflrr8fM5+0X6UwQHZyzolsGIkdsjNK3vLLn22dhdASGFz5mS6Lf7rfrPdlg==",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.3.0"
}
}
}
}
{
"name": "sample-compact-encoding",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of compact-encoding",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"compact-encoding": "3.3.2"
}
}
{
"schemaVersion": 1,
"goal": "verify c.decode in pkg:npm/compact-encoding@3.3.2",
"kind": "HOW",
"packages": [
"pkg:npm/compact-encoding@3.3.2"
],
"symbols": [
"c.decode"
]
}
'use strict';
const c = require('compact-encoding');
/**
* Decode a binary buffer using compact-encoding.
* @param {object} encoding - compact-encoding codec
* @param {Buffer|Uint8Array} buffer - binary buffer to decode
* @returns {*} decoded value
*/
function decode(encoding, buffer) {
return c.decode(encoding, buffer);
}
/**
* Encode a value into a binary buffer using compact-encoding.
* @param {object} encoding - compact-encoding codec
* @param {*} value - value to encode
* @returns {Buffer|Uint8Array} encoded buffer
*/
function encode(encoding, value) {
return c.encode(encoding, value);
}
module.exports = {
c,
compactEncoding: c,
decode,
encode,
state: c.state,
string: c.string,
uint: c.uint,
uint8: c.uint8,
uint16: c.uint16,
uint32: c.uint32,
int: c.int,
int8: c.int8,
bool: c.bool,
buffer: c.buffer,
raw: c.raw,
json: c.json,
array: c.array,
frame: c.frame
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
c,
decode,
encode,
state,
string,
uint,
uint8,
uint16,
uint32,
int,
int8,
bool,
buffer,
raw,
json,
array,
frame
} = require('../src/index.js');
// 1. Export verification
assert.equal(typeof c.decode, 'function', 'c.decode must be exported as a function');
assert.equal(typeof decode, 'function', 'decode wrapper must be exported as a function');
assert.equal(typeof encode, 'function', 'encode wrapper must be exported as a function');
assert.equal(typeof state, 'function', 'state helper must be exported as a function');
// 2. c.decode decodes UTF-8 strings from binary buffers
{
const expected = 'compact encoding verification';
const encoded = encode(string, expected);
const result = decode(string, encoded);
assert.equal(result, expected);
}
// 3. c.decode decodes compact variable-length unsigned integers
{
const testValues = [0, 42, 252, 253, 65535, 65536, 4294967295];
for (const val of testValues) {
const encoded = encode(uint, val);
const result = decode(uint, encoded);
assert.equal(result, val);
}
}
// 4. c.decode decodes fixed-size integers and signed integers
{
assert.equal(decode(uint8, encode(uint8, 255)), 255);
assert.equal(decode(uint16, encode(uint16, 60000)), 60000);
assert.equal(decode(uint32, encode(uint32, 3000000000)), 3000000000);
assert.equal(decode(int8, encode(int8, -128)), -128);
assert.equal(decode(int, encode(int, -50000)), -50000);
}
// 5. c.decode decodes boolean values
{
assert.equal(decode(bool, encode(bool, true)), true);
assert.equal(decode(bool, encode(bool, false)), false);
}
// 6. c.decode decodes arrays using composite array codecs
{
const list = ['first', 'second', 'third'];
const listCodec = array(string);
const encoded = encode(listCodec, list);
const result = decode(listCodec, encoded);
assert.deepEqual(result, list);
}
// 7. c.decode decodes JSON objects from binary buffers
{
const payload = { id: 101, tags: ['alpha', 'beta'], active: true };
const encoded = encode(json, payload);
const result = decode(json, encoded);
assert.deepEqual(result, payload);
}
// 8. c.decode decodes prefixed and raw binary buffers
{
const sampleData = Buffer.from([0xaa, 0xbb, 0xcc, 0xdd]);
const encodedPrefixed = encode(buffer, sampleData);
const decodedPrefixed = decode(buffer, encodedPrefixed);
assert.deepEqual(decodedPrefixed, sampleData);
const encodedRaw = encode(raw, sampleData);
const decodedRaw = decode(raw, encodedRaw);
assert.deepEqual(decodedRaw, sampleData);
}
// 9. c.decode decodes structured custom records with multi-field codecs
{
const recordCodec = {
preencode(stateObj, rec) {
string.preencode(stateObj, rec.title);
uint.preencode(stateObj, rec.count);
bool.preencode(stateObj, rec.verified);
},
encode(stateObj, rec) {
string.encode(stateObj, rec.title);
uint.encode(stateObj, rec.count);
bool.encode(stateObj, rec.verified);
},
decode(stateObj) {
return {
title: string.decode(stateObj),
count: uint.decode(stateObj),
verified: bool.decode(stateObj)
};
}
};
const record = { title: 'Sample Spec', count: 42, verified: true };
const encoded = encode(recordCodec, record);
const result = decode(recordCodec, encoded);
assert.deepEqual(result, record);
}
// 10. c.decode decodes from Uint8Array instances
{
const text = 'typed array payload';
const encodedBuf = encode(string, text);
const uint8View = new Uint8Array(encodedBuf.buffer, encodedBuf.byteOffset, encodedBuf.byteLength);
const result = decode(string, uint8View);
assert.equal(result, text);
}
// 11. c.decode throws an out of bounds error when buffer length is insufficient
{
const truncatedBuffer = Buffer.alloc(1);
assert.throws(
() => decode(uint32, truncatedBuffer),
/Out of bounds/
);
}
console.log('Contract assertions passed.');
오리진 시더
익명