CodeSampleX

샘플

@peculiar/asn1-schema 2.9.4

검증된 샘플 — npm @peculiar/asn1-schema 2.9.4. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: assert AsnSerializer.serialize and AsnParser.parse…

sha256:1ffa550956831143dd9bc1ad1293dcb1aae3c2ef524ce642ce13d2b2f822d6d3

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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.9.4
패키지
생성일
2026-08-21T07:17:22Z

컨트랙트

  1. assert AsnSerializer.serialize and AsnParser.parse encode and decode typed class instances with primitive and nested ASN.1 schemas
  2. assert AsnConvert.serialize, AsnConvert.parse, and AsnConvert.toString provide high-level DER conversion and string visualization
  3. assert AsnChoiceType supports CHOICE schemas with contextual tags
  4. assert OctetString and BitString represent binary and bitstring ASN.1 values
  5. assert AsnParser.parse throws an error when parsing malformed ASN.1 buffers

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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.9.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40peculiar/asn1-schema@2.9.4

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.
csx.json
{"case":{"caseId":"case:sha256:daba7510c3b1107fedd7e8b2204fd0bc69a079801615b85d192d24aa9b6de0d1","contract":["assert AsnSerializer.serialize and AsnParser.parse encode and decode typed class instances with primitive and nested ASN.1 schemas","assert AsnConvert.serialize, AsnConvert.parse, and AsnConvert.toString provide high-level DER conversion and string visualization","assert AsnChoiceType supports CHOICE schemas with contextual tags","assert OctetString and BitString represent binary and bitstring ASN.1 values","assert AsnParser.parse throws an error when parsing malformed ASN.1 buffers"],"goal":"verify pkg:npm/%40peculiar/asn1-schema@2.9.4","kind":"HOW","packages":["pkg:npm/%40peculiar/asn1-schema@2.9.4"],"schemaVersion":1,"symbols":["AsnChoiceType","AsnConvert.parse","AsnConvert.serialize","AsnConvert.toString","AsnParser.parse","AsnProp","AsnPropTypes","AsnSerializer.serialize","AsnType","AsnTypeTypes","BitString","OctetString"]},"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/%40peculiar/asn1-schema@2.9.4"],"schemaVersion":1,"subject":"pkg:npm/%40peculiar/asn1-schema@2.9.4","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-peculiar-asn1-schema",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-peculiar-asn1-schema",
      "version": "1.0.0",
      "dependencies": {
        "@peculiar/asn1-schema": "2.9.4"
      }
    },
    "node_modules/@peculiar/asn1-schema": {
      "version": "2.9.4",
      "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.9.4.tgz",
      "integrity": "sha512-GjzePcT9Iw8NzeOPf73iNS9xM+TBhd/FilAfP+RQGkTMQJTVWtytN3JHJACCjf/ABNau5S7mS3g+DcuxmRgYEg==",
      "license": "MIT",
      "dependencies": {
        "@peculiar/utils": "^2.0.2",
        "asn1js": "^3.0.10",
        "tslib": "^2.8.1"
      },
      "engines": {
        "node": ">=14"
      }
    },
    "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"
    }
  }
}
package.json
{
  "name": "sample-peculiar-asn1-schema",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "@peculiar/asn1-schema": "2.9.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40peculiar/asn1-schema@2.9.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40peculiar/asn1-schema@2.9.4"
  ]
}
test/contract.mjs
import assert from "node:assert/strict";
import {
  AsnProp,
  AsnPropTypes,
  AsnType,
  AsnTypeTypes,
  AsnChoiceType,
  AsnParser,
  AsnSerializer,
  AsnConvert,
  OctetString,
  BitString,
} from "@peculiar/asn1-schema";

// 1. Nested Sequence Schema Definition
class NestedPayload {
  constructor() {
    this.label = "";
  }
}
AsnType({ type: AsnTypeTypes.Sequence })(NestedPayload);
AsnProp({ type: AsnPropTypes.Utf8String })(NestedPayload.prototype, "label");

// Root Sequence Schema Definition
class ContainerRecord {
  constructor() {
    this.id = 0;
    this.name = "";
    this.active = false;
    this.payload = new NestedPayload();
    this.data = new OctetString();
    this.optionalComment = undefined;
    this.tags = [];
  }
}
AsnType({ type: AsnTypeTypes.Sequence })(ContainerRecord);
AsnProp({ type: AsnPropTypes.Integer })(ContainerRecord.prototype, "id");
AsnProp({ type: AsnPropTypes.Utf8String })(ContainerRecord.prototype, "name");
AsnProp({ type: AsnPropTypes.Boolean })(ContainerRecord.prototype, "active");
AsnProp({ type: NestedPayload })(ContainerRecord.prototype, "payload");
AsnProp({ type: OctetString })(ContainerRecord.prototype, "data");
AsnProp({ type: AsnPropTypes.Utf8String, optional: true, context: 0, implicit: true })(ContainerRecord.prototype, "optionalComment");
AsnProp({ type: AsnPropTypes.Utf8String, repeated: "sequence", context: 1 })(ContainerRecord.prototype, "tags");

// Contract 1: AsnSerializer.serialize and AsnParser.parse encode and decode typed class instances with primitive and nested ASN.1 schemas
const record = new ContainerRecord();
record.id = 101;
record.name = "sample-record";
record.active = true;
record.payload.label = "nested-content";
record.data = new OctetString([0xde, 0xad, 0xbe, 0xef]);
record.optionalComment = "optional-info";
record.tags = ["tag-alpha", "tag-beta"];

const serializedDer = AsnSerializer.serialize(record);
assert.ok(serializedDer instanceof ArrayBuffer);
assert.ok(serializedDer.byteLength > 0);

const parsedRecord = AsnParser.parse(serializedDer, ContainerRecord);
assert.ok(parsedRecord instanceof ContainerRecord);
assert.equal(parsedRecord.id, 101);
assert.equal(parsedRecord.name, "sample-record");
assert.equal(parsedRecord.active, true);
assert.ok(parsedRecord.payload instanceof NestedPayload);
assert.equal(parsedRecord.payload.label, "nested-content");
assert.deepEqual(new Uint8Array(parsedRecord.data.buffer), new Uint8Array([0xde, 0xad, 0xbe, 0xef]));
assert.equal(parsedRecord.optionalComment, "optional-info");
assert.deepEqual(parsedRecord.tags, ["tag-alpha", "tag-beta"]);

// Contract 2: AsnConvert.serialize, AsnConvert.parse, and AsnConvert.toString provide high-level DER conversion and string visualization
const convertDer = AsnConvert.serialize(record);
assert.ok(convertDer instanceof ArrayBuffer);

const convertDecoded = AsnConvert.parse(convertDer, ContainerRecord);
assert.equal(convertDecoded.id, 101);
assert.equal(convertDecoded.name, "sample-record");
assert.equal(convertDecoded.active, true);

const derString = AsnConvert.toString(convertDer);
assert.ok(typeof derString === "string");
assert.ok(derString.length > 0);

// Contract 3: AsnChoiceType supports CHOICE schemas with contextual tags
class ChoicePayload {
  constructor() {
    this.textValue = undefined;
    this.numericValue = undefined;
  }
}
AsnChoiceType()(ChoicePayload);
AsnProp({ type: AsnPropTypes.Utf8String, context: 0 })(ChoicePayload.prototype, "textValue");
AsnProp({ type: AsnPropTypes.Integer, context: 1 })(ChoicePayload.prototype, "numericValue");

const choiceItem = new ChoicePayload();
choiceItem.textValue = "selected-text-branch";

const choiceDer = AsnConvert.serialize(choiceItem);
const decodedChoice = AsnConvert.parse(choiceDer, ChoicePayload);
assert.equal(decodedChoice.textValue, "selected-text-branch");
assert.equal(decodedChoice.numericValue, undefined);

// Contract 4: OctetString and BitString represent binary and bitstring ASN.1 values
class BinaryContainer {
  constructor() {
    this.octets = new OctetString();
    this.bits = new BitString();
  }
}
AsnType({ type: AsnTypeTypes.Sequence })(BinaryContainer);
AsnProp({ type: OctetString })(BinaryContainer.prototype, "octets");
AsnProp({ type: BitString })(BinaryContainer.prototype, "bits");

const binaryObj = new BinaryContainer();
binaryObj.octets = new OctetString(new Uint8Array([0x01, 0x02, 0x03, 0x04]));
binaryObj.bits = new BitString(new Uint8Array([0b11000000]).buffer, 2);

const binaryDer = AsnConvert.serialize(binaryObj);
const decodedBinary = AsnConvert.parse(binaryDer, BinaryContainer);
assert.deepEqual(new Uint8Array(decodedBinary.octets.buffer), new Uint8Array([0x01, 0x02, 0x03, 0x04]));
assert.equal(decodedBinary.bits.unusedBits, 2);

// Contract 5: AsnParser.parse throws an error when parsing malformed ASN.1 buffers
assert.throws(() => {
  AsnParser.parse(new Uint8Array([0xff, 0xff, 0xff]), ContainerRecord);
});

console.log("Contract verified: all assertions passed.");

오리진 시더

익명