CodeSampleX

샘플

minizlib 2.1.2

검증된 샘플 — npm minizlib 2.1.2. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: Gzip compresses input buffer and Gunzip decompresses back to…

sha256:39ed08176da92665cf4e7d5942ee056ad6ce93b6ce59a7c6d93aac84153b9685

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

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
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-28

케이스

HOW
목표
verify pkg:npm/minizlib@2.1.2
패키지
환경
node 22.23.2
생성일
2026-08-28T07:55:59Z

컨트랙트

  1. Gzip compresses input buffer and Gunzip decompresses back to original buffer
  2. Deflate and Inflate perform standard zlib compression and decompression
  3. DeflateRaw and InflateRaw handle raw deflate streams without zlib headers
  4. BrotliCompress compresses payload and BrotliDecompress restores original content
  5. Gunzip emits error event on malformed compressed payload
  6. Gzip respects compression level options from constants

파일

  • 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/minizlib@2.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/minizlib@2.1.2
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.
csx.json
{"case":{"caseId":"case:sha256:192d7df0884e76c7019aad5aeda1414c60becab860ea9e35dd33e2f694b1f06a","constraints":{"executionContext":"node"},"contract":["Gzip compresses input buffer and Gunzip decompresses back to original buffer","Deflate and Inflate perform standard zlib compression and decompression","DeflateRaw and InflateRaw handle raw deflate streams without zlib headers","BrotliCompress compresses payload and BrotliDecompress restores original content","Gunzip emits error event on malformed compressed payload","Gzip respects compression level options from constants"],"goal":"verify pkg:npm/minizlib@2.1.2","kind":"HOW","packages":["pkg:npm/minizlib@2.1.2"],"schemaVersion":1},"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/minizlib@2.1.2"],"schemaVersion":1,"subject":"pkg:npm/minizlib@2.1.2","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-minizlib-verify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-minizlib-verify",
      "version": "1.0.0",
      "dependencies": {
        "minizlib": "2.1.2"
      }
    },
    "node_modules/minipass": {
      "version": "3.3.6",
      "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz",
      "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==",
      "license": "ISC",
      "dependencies": {
        "yallist": "^4.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/minizlib": {
      "version": "2.1.2",
      "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz",
      "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==",
      "license": "MIT",
      "dependencies": {
        "minipass": "^3.0.0",
        "yallist": "^4.0.0"
      },
      "engines": {
        "node": ">= 8"
      }
    },
    "node_modules/yallist": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
      "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-minizlib-verify",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "minizlib": "2.1.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/minizlib@2.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/minizlib@2.1.2"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  Gzip,
  Gunzip,
  Deflate,
  Inflate,
  DeflateRaw,
  InflateRaw,
  BrotliCompress,
  BrotliDecompress,
  constants
} = require('minizlib');

// 1. Gzip compresses input and Gunzip decompresses back to original buffer
{
  const input = Buffer.from('Hello CodeSampleX with minizlib gzip compression!');
  const gzip = new Gzip();
  gzip.end(input);
  const compressed = gzip.read();

  assert.ok(Buffer.isBuffer(compressed), 'Gzip output should be a Buffer');
  assert.ok(compressed.length > 0, 'Gzip output should not be empty');
  assert.strictEqual(compressed[0], 0x1f, 'First gzip magic byte should be 0x1f');
  assert.strictEqual(compressed[1], 0x8b, 'Second gzip magic byte should be 0x8b');

  const gunzip = new Gunzip();
  gunzip.end(compressed);
  const decompressed = gunzip.read();

  assert.ok(Buffer.isBuffer(decompressed), 'Gunzip output should be a Buffer');
  assert.strictEqual(decompressed.toString('utf8'), input.toString('utf8'), 'Decompressed content must match original input');
}

// 2. Deflate and Inflate perform standard zlib compression and decompression
{
  const input = Buffer.from('Testing Deflate and Inflate with structured text payload 1234567890');
  const deflate = new Deflate();
  deflate.end(input);
  const compressed = deflate.read();

  assert.ok(Buffer.isBuffer(compressed), 'Deflate output should be a Buffer');

  const inflate = new Inflate();
  inflate.end(compressed);
  const decompressed = inflate.read();

  assert.strictEqual(decompressed.toString('utf8'), input.toString('utf8'), 'Inflate output must match deflate input');
}

// 3. DeflateRaw and InflateRaw handle raw deflate streams without zlib headers
{
  const input = Buffer.from('Testing DeflateRaw and InflateRaw without headers');
  const rawDeflate = new DeflateRaw();
  rawDeflate.end(input);
  const rawCompressed = rawDeflate.read();

  assert.ok(Buffer.isBuffer(rawCompressed), 'DeflateRaw output should be a Buffer');

  const rawInflate = new InflateRaw();
  rawInflate.end(rawCompressed);
  const decompressed = rawInflate.read();

  assert.strictEqual(decompressed.toString('utf8'), input.toString('utf8'), 'InflateRaw output must match raw deflate input');
}

// 4. BrotliCompress compresses payload and BrotliDecompress restores original content
{
  const input = Buffer.from('Testing BrotliCompress and BrotliDecompress in minizlib');
  const brotliCompress = new BrotliCompress();
  brotliCompress.end(input);
  const compressed = brotliCompress.read();

  assert.ok(Buffer.isBuffer(compressed), 'BrotliCompress output should be a Buffer');

  const brotliDecompress = new BrotliDecompress();
  brotliDecompress.end(compressed);
  const decompressed = brotliDecompress.read();

  assert.strictEqual(decompressed.toString('utf8'), input.toString('utf8'), 'BrotliDecompress must match original content');
}

// 5. Gunzip emits error event on malformed compressed payload
{
  const gunzip = new Gunzip();
  let errorCaught = null;
  gunzip.on('error', (err) => {
    errorCaught = err;
  });

  gunzip.end(Buffer.from('not valid gzip compressed data'));

  assert.ok(errorCaught !== null, 'Gunzip should emit error on corrupt payload');
  assert.strictEqual(errorCaught.code, 'Z_DATA_ERROR', 'Error code should be Z_DATA_ERROR');
}

// 6. Gzip respects compression level options from constants
{
  const input = Buffer.from('Repeated payload '.repeat(100));

  const fastZip = new Gzip({ level: constants.Z_BEST_SPEED });
  fastZip.end(input);
  const fastOut = fastZip.read();

  const bestZip = new Gzip({ level: constants.Z_BEST_COMPRESSION });
  bestZip.end(input);
  const bestOut = bestZip.read();

  const noCompZip = new Gzip({ level: constants.Z_NO_COMPRESSION });
  noCompZip.end(input);
  const noCompOut = noCompZip.read();

  assert.ok(fastOut.length < noCompOut.length, 'Best speed compression should be smaller than no compression');
  assert.ok(bestOut.length <= fastOut.length, 'Best compression should be smaller or equal to best speed');
}

console.log('All minizlib contract assertions passed.');

오리진 시더

익명