CodeSampleX

Ejemplo

crc32-stream 4.0.3: CRC32Stream

Muestra verificada para npm crc32-stream 4.0.3: CRC32Stream. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.

sha256:f9e8db1d0cc199e86c48d5f314e86e3c6dce3b41ad1ddb114808645cb67abe41

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify pkg:npm/crc32-stream@4.0.3
Paquetes
Símbolos
  • CRC32Stream
Creado
2026-08-28T08:20:56Z

Contrato

  1. assert CRC32Stream processes stream data without altering stream contents
  2. assert CRC32Stream calculates expected 32-bit CRC checksum across multiple stream chunks
  3. assert CRC32Stream size returns the total raw byte length processed
  4. assert CRC32Stream hex returns uppercase 8-character hex string of CRC32 checksum
  5. assert CRC32Stream digest returns 4-byte Buffer or hex string matching calculated checksum
  6. assert CRC32Stream handles empty input stream producing zero checksum and zero size

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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/crc32-stream@4.0.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/crc32-stream@4.0.3
Demonstrate these symbols/APIs:
  - CRC32Stream

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:2290126ce41866f7008551a09a1d7e4bb9c29582d8c6a8062ce23fa9901687cb","contract":["assert CRC32Stream processes stream data without altering stream contents","assert CRC32Stream calculates expected 32-bit CRC checksum across multiple stream chunks","assert CRC32Stream size returns the total raw byte length processed","assert CRC32Stream hex returns uppercase 8-character hex string of CRC32 checksum","assert CRC32Stream digest returns 4-byte Buffer or hex string matching calculated checksum","assert CRC32Stream handles empty input stream producing zero checksum and zero size"],"goal":"verify pkg:npm/crc32-stream@4.0.3","kind":"HOW","packages":["pkg:npm/crc32-stream@4.0.3"],"schemaVersion":1,"symbols":["CRC32Stream"]},"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/crc32-stream@4.0.3"],"schemaVersion":1,"subject":"pkg:npm/crc32-stream@4.0.3","symbols":["CRC32Stream"],"verifierAdapter":"node-typescript@1"}
index.mjs
import crc32Pkg from 'crc32-stream';

const { CRC32Stream, DeflateCRC32Stream } = crc32Pkg;

/**
 * Creates a new CRC32Stream instance.
 * @param {object} [options]
 * @returns {CRC32Stream}
 */
export function createCRC32Stream(options) {
  return new CRC32Stream(options);
}

export { CRC32Stream, DeflateCRC32Stream };
export default CRC32Stream;
package-lock.json
{
  "name": "sample-crc32-stream-verify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-crc32-stream-verify",
      "version": "1.0.0",
      "dependencies": {
        "crc32-stream": "4.0.3"
      }
    },
    "node_modules/crc-32": {
      "version": "1.2.2",
      "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz",
      "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
      "license": "Apache-2.0",
      "bin": {
        "crc32": "bin/crc32.njs"
      },
      "engines": {
        "node": ">=0.8"
      }
    },
    "node_modules/crc32-stream": {
      "version": "4.0.3",
      "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-4.0.3.tgz",
      "integrity": "sha512-NT7w2JVU7DFroFdYkeq8cywxrgjPHWkdX1wjpRQXPX5Asews3tA+Ght6lddQO5Mkumffp3X7GEqku3epj2toIw==",
      "license": "MIT",
      "dependencies": {
        "crc-32": "^1.2.0",
        "readable-stream": "^3.4.0"
      },
      "engines": {
        "node": ">= 10"
      }
    },
    "node_modules/inherits": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
      "license": "ISC"
    },
    "node_modules/readable-stream": {
      "version": "3.6.2",
      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
      "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
      "license": "MIT",
      "dependencies": {
        "inherits": "^2.0.3",
        "string_decoder": "^1.1.1",
        "util-deprecate": "^1.0.1"
      },
      "engines": {
        "node": ">= 6"
      }
    },
    "node_modules/safe-buffer": {
      "version": "5.2.1",
      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
      "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
      "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/string_decoder": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
      "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
      "license": "MIT",
      "dependencies": {
        "safe-buffer": "~5.2.0"
      }
    },
    "node_modules/util-deprecate": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
      "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-crc32-stream-verify",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "crc32-stream": "4.0.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/crc32-stream@4.0.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/crc32-stream@4.0.3"
  ],
  "symbols": [
    "CRC32Stream"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { Readable } from 'node:stream';
import CRC32Stream, { createCRC32Stream } from '../index.mjs';

// 1. assert CRC32Stream processes stream data without altering stream contents
{
  const inputBuffer = Buffer.from('The quick brown fox jumps over the lazy dog');
  const stream = Readable.from([inputBuffer]);
  const crcStream = createCRC32Stream();

  const chunks = [];
  crcStream.on('data', chunk => chunks.push(chunk));

  await new Promise((resolve, reject) => {
    crcStream.on('end', resolve);
    crcStream.on('error', reject);
    stream.pipe(crcStream);
  });

  const outputBuffer = Buffer.concat(chunks);
  assert.strictEqual(outputBuffer.toString('utf8'), 'The quick brown fox jumps over the lazy dog');
}

// 2. assert CRC32Stream calculates expected 32-bit CRC checksum across multiple stream chunks
{
  const chunks = ['123', '456', '789'];
  const stream = Readable.from(chunks);
  const crcStream = new CRC32Stream();

  crcStream.resume();

  await new Promise((resolve, reject) => {
    crcStream.on('end', resolve);
    crcStream.on('error', reject);
    stream.pipe(crcStream);
  });

  assert.strictEqual(crcStream.hex(), 'CBF43926');
  assert.strictEqual(crcStream.digest('hex'), 'cbf43926');
}

// 3. assert CRC32Stream size returns the total raw byte length processed
{
  const part1 = Buffer.from('hello ');
  const part2 = Buffer.from('world!');
  const stream = Readable.from([part1, part2]);
  const crcStream = new CRC32Stream();

  crcStream.resume();

  await new Promise((resolve, reject) => {
    crcStream.on('end', resolve);
    crcStream.on('error', reject);
    stream.pipe(crcStream);
  });

  assert.strictEqual(crcStream.size(), 12);
  assert.strictEqual(crcStream.rawSize, 12);
}

// 4. assert CRC32Stream hex returns uppercase 8-character hex string of CRC32 checksum
{
  const input = Buffer.from('hello world');
  const stream = Readable.from([input]);
  const crcStream = new CRC32Stream();

  crcStream.resume();

  await new Promise((resolve, reject) => {
    crcStream.on('end', resolve);
    crcStream.on('error', reject);
    stream.pipe(crcStream);
  });

  const hexValue = crcStream.hex();
  assert.strictEqual(typeof hexValue, 'string');
  assert.strictEqual(hexValue.length, 8);
  assert.strictEqual(hexValue, '0D4A1185');
}

// 5. assert CRC32Stream digest returns 4-byte Buffer or hex string matching calculated checksum
{
  const input = Buffer.from('node-crc32-stream verification');
  const stream = Readable.from([input]);
  const crcStream = new CRC32Stream();

  crcStream.resume();

  await new Promise((resolve, reject) => {
    crcStream.on('end', resolve);
    crcStream.on('error', reject);
    stream.pipe(crcStream);
  });

  const bufferDigest = crcStream.digest();
  assert.ok(Buffer.isBuffer(bufferDigest));
  assert.strictEqual(bufferDigest.length, 4);

  const hexDigest = crcStream.digest('hex');
  assert.strictEqual(hexDigest, bufferDigest.toString('hex'));
}

// 6. assert CRC32Stream handles empty input stream producing zero checksum and zero size
{
  const stream = Readable.from([]);
  const crcStream = new CRC32Stream();

  crcStream.resume();

  await new Promise((resolve, reject) => {
    crcStream.on('end', resolve);
    crcStream.on('error', reject);
    stream.pipe(crcStream);
  });

  assert.strictEqual(crcStream.size(), 0);
  assert.strictEqual(crcStream.hex(), '00000000');
  assert.strictEqual(crcStream.digest('hex'), '00000000');
}

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

Seeder de origen

anónimo