샘플
@peculiar/asn1-schema 2.8.0
검증된 샘플 — npm @peculiar/asn1-schema 2.8.0. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: AsnSerializer.serialize serializes a decorated Sequence…
sha256:cb70a5b57e58dcb552182661c9fc843be7604e004420ece9a16fb762cba59af8
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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@1 |
2026-08-21 |
케이스
HOW- 목표
- verify pkg:npm/%40peculiar/asn1-schema@2.8.0
- 생성일
- 2026-08-21T07:04:50Z
컨트랙트
- AsnSerializer.serialize serializes a decorated Sequence class with integer, string, and optional boolean fields to DER ArrayBuffer
- AsnParser.parse deserializes ASN.1 DER buffer into class instances restoring typed property values
- AsnSerializer.serialize and AsnParser.parse support nested sequence schemas and repeated sequence elements
- AsnSerializer.toASN converts decorated class instances to asn1js objects and AsnParser.fromASN reconstructs instances from asn1js objects
- AsnChoiceType defines schemas with context-tagged variant choices and serialize/parse roundtrips selected variants
파일
- PROMPT.md
- csx.json
- index.js
- 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 pkg:npm/%40peculiar/asn1-schema@2.8.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40peculiar/asn1-schema@2.8.0
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:069d799c238c4b4cf853da54b8155210dd52a7c83d2a7cd39f9696eb2808e2b6","contract":["AsnSerializer.serialize serializes a decorated Sequence class with integer, string, and optional boolean fields to DER ArrayBuffer","AsnParser.parse deserializes ASN.1 DER buffer into class instances restoring typed property values","AsnSerializer.serialize and AsnParser.parse support nested sequence schemas and repeated sequence elements","AsnSerializer.toASN converts decorated class instances to asn1js objects and AsnParser.fromASN reconstructs instances from asn1js objects","AsnChoiceType defines schemas with context-tagged variant choices and serialize/parse roundtrips selected variants"],"goal":"verify pkg:npm/%40peculiar/asn1-schema@2.8.0","kind":"HOW","packages":["pkg:npm/%40peculiar/asn1-schema@2.8.0"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"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/%40peculiar/asn1-schema@2.8.0"],"schemaVersion":1,"subject":"pkg:npm/%40peculiar/asn1-schema@2.8.0","verifierAdapter":"node-typescript@1"}
'use strict';
const {
AsnSerializer,
AsnParser,
AsnProp,
AsnPropTypes,
AsnType,
AsnTypeTypes,
AsnChoiceType
} = require("@peculiar/asn1-schema");
// Schema 1: Simple Sequence
class UserProfile {
constructor(id, name, active) {
this.id = id;
this.name = name;
this.active = active;
}
}
AsnProp({ type: AsnPropTypes.Integer })(UserProfile.prototype, "id");
AsnProp({ type: AsnPropTypes.Utf8String })(UserProfile.prototype, "name");
AsnProp({ type: AsnPropTypes.Boolean, optional: true })(UserProfile.prototype, "active");
AsnType({ type: AsnTypeTypes.Sequence })(UserProfile);
// Schema 2: Nested Item in Sequence
class LogEntry {
constructor(code, message) {
this.code = code;
this.message = message;
}
}
AsnProp({ type: AsnPropTypes.Integer })(LogEntry.prototype, "code");
AsnProp({ type: AsnPropTypes.Utf8String })(LogEntry.prototype, "message");
AsnType({ type: AsnTypeTypes.Sequence })(LogEntry);
class LogBatch {
constructor(serviceName, entries, tags) {
this.serviceName = serviceName;
this.entries = entries || [];
this.tags = tags || [];
}
}
AsnProp({ type: AsnPropTypes.Utf8String })(LogBatch.prototype, "serviceName");
AsnProp({ type: LogEntry, repeated: "sequence" })(LogBatch.prototype, "entries");
AsnProp({ type: AsnPropTypes.Utf8String, repeated: "sequence", optional: true })(LogBatch.prototype, "tags");
AsnType({ type: AsnTypeTypes.Sequence })(LogBatch);
// Schema 3: Choice Type
class TargetIdentifier {
constructor(name, id) {
if (name !== undefined) this.name = name;
if (id !== undefined) this.id = id;
}
}
AsnProp({ type: AsnPropTypes.Utf8String, context: 0, implicit: true })(TargetIdentifier.prototype, "name");
AsnProp({ type: AsnPropTypes.Integer, context: 1, implicit: true })(TargetIdentifier.prototype, "id");
AsnChoiceType()(TargetIdentifier);
module.exports = {
UserProfile,
LogEntry,
LogBatch,
TargetIdentifier,
AsnSerializer,
AsnParser,
AsnProp,
AsnPropTypes,
AsnType,
AsnTypeTypes,
AsnChoiceType
};
{
"name": "sample-peculiar-asn1-schema",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-peculiar-asn1-schema",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@peculiar/asn1-schema": "2.8.0"
}
},
"node_modules/@peculiar/asn1-schema": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.8.0.tgz",
"integrity": "sha512-7YT0U/ze0tF2QOBbE15gKZwy5tvgGyLRiRHLzhlbOpf7BT032oBSd0haZqXn5W6l26WLlu3dyxzjM+2638/z2Q==",
"license": "MIT",
"dependencies": {
"@peculiar/utils": "^2.0.2",
"asn1js": "^3.0.10",
"tslib": "^2.8.1"
}
},
"node_modules/@peculiar/utils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz",
"integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==",
"license": "MIT",
"dependencies": {
"tslib": "^2.8.1"
}
},
"node_modules/asn1js": {
"version": "3.0.10",
"resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.10.tgz",
"integrity": "sha512-S2s3aOytiKdFRdulw2qPE51MzjzVOisppcVv7jVFR+Kw0kxwvFrDcYA0h7Ndqbmj0HkMIXYWaoj7fli8kgx1eg==",
"license": "BSD-3-Clause",
"dependencies": {
"pvtsutils": "^1.3.6",
"pvutils": "^1.1.5",
"tslib": "^2.8.1"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/pvtsutils": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz",
"integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==",
"license": "MIT",
"dependencies": {
"tslib": "^2.8.1"
}
},
"node_modules/pvutils": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.2.0.tgz",
"integrity": "sha512-BbubeCEyTuQjVMakvJQ/Sxbc93F2pwmbsxONT/ZRrwU7Ua38d8unYTwXpTVLAKJ4BDuH9IGztCjQcd/N/39Dvg==",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/tslib": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
}
}
}
{
"name": "sample-peculiar-asn1-schema",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for @peculiar/asn1-schema",
"main": "index.js",
"scripts": {
"test": "node test/contract.cjs"
},
"license": "MIT-0",
"dependencies": {
"@peculiar/asn1-schema": "2.8.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40peculiar/asn1-schema@2.8.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40peculiar/asn1-schema@2.8.0"
]
}
'use strict';
const assert = require("node:assert/strict");
const {
UserProfile,
LogEntry,
LogBatch,
TargetIdentifier,
AsnSerializer,
AsnParser
} = require("../index.js");
// 1. AsnSerializer.serialize serializes a decorated Sequence class with integer, string, and optional boolean fields to DER ArrayBuffer
{
const profile = new UserProfile(101, "Alice", true);
const der = AsnSerializer.serialize(profile);
assert.ok(der instanceof ArrayBuffer, "serialize must return an ArrayBuffer");
assert.ok(der.byteLength > 0, "ArrayBuffer must not be empty");
const hex = Buffer.from(der).toString("hex");
// Sequence tag is 0x30
assert.equal(hex.startsWith("30"), true, "DER serialization should start with SEQUENCE tag 0x30");
}
// 2. AsnParser.parse deserializes ASN.1 DER buffer into class instances restoring typed property values
{
const original = new UserProfile(202, "Bob", false);
const der = AsnSerializer.serialize(original);
const parsed = AsnParser.parse(der, UserProfile);
assert.ok(parsed instanceof UserProfile, "parsed object must be an instance of UserProfile");
assert.equal(parsed.id, 202, "id must match integer value 202");
assert.equal(parsed.name, "Bob", "name must match string 'Bob'");
assert.equal(parsed.active, false, "active must match boolean false");
// Optional field omitted
const originalWithoutOptional = new UserProfile(303, "Charlie", undefined);
const der2 = AsnSerializer.serialize(originalWithoutOptional);
const parsed2 = AsnParser.parse(der2, UserProfile);
assert.equal(parsed2.id, 303, "id must match");
assert.equal(parsed2.name, "Charlie", "name must match");
assert.equal(parsed2.active, undefined, "optional active property should remain undefined");
}
// 3. AsnSerializer.serialize and AsnParser.parse support nested sequence schemas and repeated sequence elements
{
const entries = [
new LogEntry(200, "OK"),
new LogEntry(404, "Not Found"),
new LogEntry(500, "Internal Server Error")
];
const tags = ["production", "api-gateway"];
const batch = new LogBatch("auth-service", entries, tags);
const der = AsnSerializer.serialize(batch);
const parsed = AsnParser.parse(der, LogBatch);
assert.ok(parsed instanceof LogBatch, "parsed object must be an instance of LogBatch");
assert.equal(parsed.serviceName, "auth-service", "serviceName must match");
assert.equal(parsed.entries.length, 3, "entries count must be 3");
assert.ok(parsed.entries[0] instanceof LogEntry, "nested items must be LogEntry instances");
assert.equal(parsed.entries[0].code, 200, "first entry code must be 200");
assert.equal(parsed.entries[0].message, "OK", "first entry message must be OK");
assert.equal(parsed.entries[1].code, 404, "second entry code must be 404");
assert.equal(parsed.entries[1].message, "Not Found", "second entry message must be Not Found");
assert.equal(parsed.entries[2].code, 500, "third entry code must be 500");
assert.equal(parsed.entries[2].message, "Internal Server Error", "third entry message must be Internal Server Error");
assert.deepEqual(parsed.tags, ["production", "api-gateway"], "repeated string tags must match");
}
// 4. AsnSerializer.toASN converts decorated class instances to asn1js objects and AsnParser.fromASN reconstructs instances from asn1js objects
{
const profile = new UserProfile(555, "David", true);
const asn1Obj = AsnSerializer.toASN(profile);
assert.ok(asn1Obj, "toASN must return an ASN.1 schema object");
const parsed = AsnParser.fromASN(asn1Obj, UserProfile);
assert.ok(parsed instanceof UserProfile, "fromASN must return a UserProfile instance");
assert.equal(parsed.id, 555, "id must match");
assert.equal(parsed.name, "David", "name must match");
assert.equal(parsed.active, true, "active must match");
}
// 5. AsnChoiceType defines schemas with context-tagged variant choices and serialize/parse roundtrips selected variants
{
const choiceName = new TargetIdentifier("target-node-1", undefined);
const derName = AsnSerializer.serialize(choiceName);
const parsedName = AsnParser.parse(derName, TargetIdentifier);
assert.equal(parsedName.name, "target-node-1", "choice variant name should be restored");
assert.equal(parsedName.id, undefined, "choice variant id should be undefined");
const choiceId = new TargetIdentifier(undefined, 9999);
const derId = AsnSerializer.serialize(choiceId);
const parsedId = AsnParser.parse(derId, TargetIdentifier);
assert.equal(parsedId.name, undefined, "choice variant name should be undefined");
assert.equal(parsedId.id, 9999, "choice variant id should be restored");
}
console.log("All @peculiar/asn1-schema contract assertions passed successfully.");
오리진 시더
익명