샘플
buffer 5.7.1: Buffer
검증된 샘플 — npm buffer 5.7.1: Buffer. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Buffer.from creates Buffer from string with default utf8…
sha256:82a6b293fbe5f339c46db7e941f423b9ea17e4b66f0ffbe3633dfaf90c6271f0
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-28 |
케이스
HOW- 목표
- verify pkg:npm/buffer@5.7.1
- 패키지
- 심벌
-
- Buffer
- 생성일
- 2026-08-28T08:08:47Z
컨트랙트
- Buffer.from creates Buffer from string with default utf8 encoding
- Buffer.from creates Buffer from string with hex and base64 encodings
- Buffer.from creates Buffer from byte array
- Buffer.from creates Buffer copy from existing Buffer
- Buffer.from creates Buffer from ArrayBuffer with byteOffset and length
- Buffer.alloc creates zero-filled buffer of specified size
- Buffer.alloc creates filled buffer with custom fill value
- Buffer.allocUnsafe creates uninitialized buffer of specified size
- Buffer.isBuffer returns true for Buffer instances and false for non-buffers
- Buffer.isEncoding returns true for valid encodings and false for invalid encodings
- Buffer.concat joins multiple Buffer instances into a single Buffer
- Buffer.byteLength returns byte length of strings across different encodings
- Buffer.compare orders buffers lexicographically
- Buffer instance supports write, toString, toJSON, slice, and binary read/write methods
- Buffer.from throws TypeError when value is a number
- Buffer.from throws TypeError when encoding is unknown
- Buffer.alloc throws RangeError when size is negative
- Buffer.alloc throws TypeError when size is not a number
- Buffer.concat throws TypeError when list is not an Array
파일
- PROMPT.md
- csx.json
- 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/buffer@5.7.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/buffer@5.7.1
Demonstrate these symbols/APIs:
- Buffer
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:f3f44a1f94fef86bed3048696a554c8ffe9cbfc5c5e2a3db793015475a8eda25","contract":["Buffer.from creates Buffer from string with default utf8 encoding","Buffer.from creates Buffer from string with hex and base64 encodings","Buffer.from creates Buffer from byte array","Buffer.from creates Buffer copy from existing Buffer","Buffer.from creates Buffer from ArrayBuffer with byteOffset and length","Buffer.alloc creates zero-filled buffer of specified size","Buffer.alloc creates filled buffer with custom fill value","Buffer.allocUnsafe creates uninitialized buffer of specified size","Buffer.isBuffer returns true for Buffer instances and false for non-buffers","Buffer.isEncoding returns true for valid encodings and false for invalid encodings","Buffer.concat joins multiple Buffer instances into a single Buffer","Buffer.byteLength returns byte length of strings across different encodings","Buffer.compare orders buffers lexicographically","Buffer instance supports write, toString, toJSON, slice, and binary read/write methods","Buffer.from throws TypeError when value is a number","Buffer.from throws TypeError when encoding is unknown","Buffer.alloc throws RangeError when size is negative","Buffer.alloc throws TypeError when size is not a number","Buffer.concat throws TypeError when list is not an Array"],"goal":"verify pkg:npm/buffer@5.7.1","kind":"HOW","packages":["pkg:npm/buffer@5.7.1"],"schemaVersion":1,"symbols":["Buffer"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/buffer@5.7.1"],"schemaVersion":1,"subject":"pkg:npm/buffer@5.7.1","symbols":["Buffer"],"verifierAdapter":"node-typescript@1"}
{
"name": "buffer-verification",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "buffer-verification",
"version": "1.0.0",
"dependencies": {
"buffer": "5.7.1"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/buffer": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.1.13"
}
},
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "BSD-3-Clause"
}
}
}
{
"name": "buffer-verification",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for buffer",
"dependencies": {
"buffer": "5.7.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/buffer@5.7.1",
"kind": "HOW",
"packages": [
"pkg:npm/buffer@5.7.1"
],
"symbols": [
"Buffer"
]
}
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { Buffer } = require('buffer/');
// 1. Buffer.from creates Buffer from string with default utf8 encoding
const strBuf = Buffer.from('hello world');
assert.ok(Buffer.isBuffer(strBuf));
assert.strictEqual(strBuf.toString('utf8'), 'hello world');
assert.strictEqual(strBuf.length, 11);
// 2. Buffer.from creates Buffer from string with hex and base64 encodings
const hexBuf = Buffer.from('68656c6c6f', 'hex');
assert.strictEqual(hexBuf.toString('utf8'), 'hello');
const b64Buf = Buffer.from('aGVsbG8=', 'base64');
assert.strictEqual(b64Buf.toString('utf8'), 'hello');
// 3. Buffer.from creates Buffer from byte array
const arrBuf = Buffer.from([104, 101, 108, 108, 111]);
assert.ok(Buffer.isBuffer(arrBuf));
assert.strictEqual(arrBuf.toString('utf8'), 'hello');
assert.strictEqual(arrBuf.length, 5);
// 4. Buffer.from creates Buffer copy from existing Buffer
const original = Buffer.from('copy-test');
const copied = Buffer.from(original);
assert.ok(Buffer.isBuffer(copied));
assert.strictEqual(copied.toString('utf8'), 'copy-test');
original[0] = 0x78;
assert.strictEqual(copied.toString('utf8'), 'copy-test');
// 5. Buffer.from creates Buffer from ArrayBuffer with byteOffset and length
const ab = new Uint8Array([1, 2, 3, 4, 5, 6]).buffer;
const abBuf = Buffer.from(ab, 2, 3);
assert.ok(Buffer.isBuffer(abBuf));
assert.strictEqual(abBuf.length, 3);
assert.deepStrictEqual(Array.from(abBuf), [3, 4, 5]);
// 6. Buffer.alloc creates zero-filled buffer of specified size
const zeroBuf = Buffer.alloc(10);
assert.ok(Buffer.isBuffer(zeroBuf));
assert.strictEqual(zeroBuf.length, 10);
assert.deepStrictEqual(Array.from(zeroBuf), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
// 7. Buffer.alloc creates filled buffer with custom fill value
const filledBuf = Buffer.alloc(5, 'a');
assert.strictEqual(filledBuf.toString('utf8'), 'aaaaa');
// 8. Buffer.allocUnsafe creates uninitialized buffer of specified size
const unsafeBuf = Buffer.allocUnsafe(8);
assert.ok(Buffer.isBuffer(unsafeBuf));
assert.strictEqual(unsafeBuf.length, 8);
// 9. Buffer.isBuffer returns true for Buffer instances and false for non-buffers
assert.strictEqual(Buffer.isBuffer(Buffer.alloc(4)), true);
assert.strictEqual(Buffer.isBuffer(new Uint8Array(4)), false);
assert.strictEqual(Buffer.isBuffer('string'), false);
assert.strictEqual(Buffer.isBuffer(null), false);
// 10. Buffer.isEncoding returns true for valid encodings and false for invalid encodings
assert.strictEqual(Buffer.isEncoding('utf8'), true);
assert.strictEqual(Buffer.isEncoding('hex'), true);
assert.strictEqual(Buffer.isEncoding('base64'), true);
assert.strictEqual(Buffer.isEncoding('utf-8'), true);
assert.strictEqual(Buffer.isEncoding('invalid-enc'), false);
// 11. Buffer.concat joins multiple Buffer instances into a single Buffer
const c1 = Buffer.from('hello ');
const c2 = Buffer.from('world');
const concatenated = Buffer.concat([c1, c2]);
assert.strictEqual(concatenated.toString('utf8'), 'hello world');
assert.strictEqual(concatenated.length, 11);
// 12. Buffer.byteLength returns byte length of strings across different encodings
assert.strictEqual(Buffer.byteLength('hello', 'utf8'), 5);
assert.strictEqual(Buffer.byteLength('€', 'utf8'), 3);
assert.strictEqual(Buffer.byteLength('68656c6c6f', 'hex'), 5);
// 13. Buffer.compare orders buffers lexicographically
const cmpA = Buffer.from('abc');
const cmpB = Buffer.from('abd');
assert.strictEqual(Buffer.compare(cmpA, cmpB), -1);
assert.strictEqual(Buffer.compare(cmpB, cmpA), 1);
assert.strictEqual(Buffer.compare(cmpA, cmpA), 0);
assert.strictEqual(cmpA.compare(cmpB), -1);
// 14. Buffer instance supports write, toString, toJSON, slice, and binary read/write methods
const instanceBuf = Buffer.alloc(10);
instanceBuf.write('test', 0, 4, 'utf8');
assert.strictEqual(instanceBuf.toString('utf8', 0, 4), 'test');
const jsonRep = instanceBuf.toJSON();
assert.strictEqual(jsonRep.type, 'Buffer');
assert.ok(Array.isArray(jsonRep.data));
const sliced = instanceBuf.slice(0, 4);
assert.strictEqual(sliced.toString('utf8'), 'test');
const numBuf = Buffer.alloc(4);
numBuf.writeUInt16BE(0x1234, 0);
assert.strictEqual(numBuf.readUInt16BE(0), 0x1234);
// 15. Buffer.from throws TypeError when value is a number
assert.throws(
() => Buffer.from(123),
{
name: 'TypeError',
message: 'The "value" argument must not be of type number. Received type number'
}
);
// 16. Buffer.from throws TypeError when encoding is unknown
assert.throws(
() => Buffer.from('abc', 'invalid-encoding'),
{
name: 'TypeError',
message: 'Unknown encoding: invalid-encoding'
}
);
// 17. Buffer.alloc throws RangeError when size is negative
assert.throws(
() => Buffer.alloc(-1),
{
name: 'RangeError',
message: 'The value "-1" is invalid for option "size"'
}
);
// 18. Buffer.alloc throws TypeError when size is not a number
assert.throws(
() => Buffer.alloc('invalid'),
{
name: 'TypeError',
message: '"size" argument must be of type number'
}
);
// 19. Buffer.concat throws TypeError when list is not an Array
assert.throws(
() => Buffer.concat('not-an-array'),
{
name: 'TypeError',
message: '"list" argument must be an Array of Buffers'
}
);
console.log('Contract passed');
오리진 시더
익명