Ejemplo
minizlib 3.1.0: compress and decompress data using minizlib Gzip and Gunzip streams
Muestra verificada para npm minizlib 3.1.0: compress and decompress data using minizlib Gzip and Gunzip streams. El contrato se ejecutó en node 22 · linux…
sha256:867f0794653070fe38765517c2734750f5bea7d73308b69390c4ffc9efe03ffa
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
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
- compress and decompress data using minizlib Gzip and Gunzip streams
- Paquetes
- Símbolos
-
- minizlib.Gunzip
- minizlib.Gzip
- Entorno
- node 22.23.2
- Creado
- 2026-08-28T05:35:31Z
Contrato
- Gzip and Gunzip classes are exported and instantiate stream instances extending Zlib
- Gzip synchronously compresses string or buffer into gzip formatted buffer with magic bytes 0x1f 0x8b
- Gunzip synchronously decompresses gzip buffer back to the original content
- Gzip piped into Gunzip processes data through stream pipeline asynchronously
- Gunzip raises ZlibError when consuming invalid or corrupted compressed input
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Código fuente
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: compress and decompress data using minizlib Gzip and Gunzip streams
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/minizlib@3.1.0
Demonstrate these symbols/APIs:
- minizlib.Gunzip
- minizlib.Gzip
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:ce021948e986b7e97843d5d9ab7d32dbd600772ddd521e7e2365da2fff5656e7","contract":["Gzip and Gunzip classes are exported and instantiate stream instances extending Zlib","Gzip synchronously compresses string or buffer into gzip formatted buffer with magic bytes 0x1f 0x8b","Gunzip synchronously decompresses gzip buffer back to the original content","Gzip piped into Gunzip processes data through stream pipeline asynchronously","Gunzip raises ZlibError when consuming invalid or corrupted compressed input"],"goal":"compress and decompress data using minizlib Gzip and Gunzip streams","kind":"HOW","packages":["pkg:npm/minizlib@3.1.0"],"schemaVersion":1,"symbols":["minizlib.Gunzip","minizlib.Gzip"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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@3.1.0"],"schemaVersion":1,"subject":"pkg:npm/minizlib@3.1.0","symbols":["minizlib.Gunzip","minizlib.Gzip"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-minizlib-gzip-gunzip",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-minizlib-gzip-gunzip",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"minizlib": "3.1.0"
}
},
"node_modules/minipass": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
"integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=16 || 14 >=14.17"
}
},
"node_modules/minizlib": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz",
"integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==",
"license": "MIT",
"dependencies": {
"minipass": "^7.1.2"
},
"engines": {
"node": ">= 18"
}
}
}
}
{
"name": "sample-minizlib-gzip-gunzip",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "Clean-room verification for minizlib Gzip and Gunzip streams",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"minizlib": "3.1.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "compress and decompress data using minizlib Gzip and Gunzip streams",
"kind": "HOW",
"packages": [
"pkg:npm/minizlib@3.1.0"
],
"symbols": [
"minizlib.Gunzip",
"minizlib.Gzip"
]
}
import { Gzip, Gunzip, Zlib, ZlibError } from 'minizlib';
/**
* Compresses data synchronously using minizlib Gzip.
* @param {string | Buffer} data
* @param {import('zlib').ZlibOptions} [options]
* @returns {Buffer}
*/
export function gzipSync(data, options) {
const zip = new Gzip(options);
zip.end(data);
return zip.read();
}
/**
* Decompresses gzip data synchronously using minizlib Gunzip.
* @param {Buffer} data
* @param {import('zlib').ZlibOptions} [options]
* @returns {Buffer}
*/
export function gunzipSync(data, options) {
const unzip = new Gunzip(options);
unzip.end(data);
return unzip.read();
}
/**
* Creates a configured Gzip compression stream.
* @param {import('zlib').ZlibOptions} [options]
* @returns {Gzip}
*/
export function createGzipStream(options) {
return new Gzip(options);
}
/**
* Creates a configured Gunzip decompression stream.
* @param {import('zlib').ZlibOptions} [options]
* @returns {Gunzip}
*/
export function createGunzipStream(options) {
return new Gunzip(options);
}
export { Gzip, Gunzip, Zlib, ZlibError };
import assert from 'node:assert/strict';
import {
Gzip,
Gunzip,
Zlib,
ZlibError,
gzipSync,
gunzipSync,
createGzipStream,
createGunzipStream,
} from '../src/index.js';
// 1. Gzip and Gunzip classes are exported and instantiate stream instances extending Zlib
assert.equal(typeof Gzip, 'function', 'Gzip must be a constructor function');
assert.equal(typeof Gunzip, 'function', 'Gunzip must be a constructor function');
const gzipInstance = new Gzip();
const gunzipInstance = new Gunzip();
assert.ok(gzipInstance instanceof Zlib, 'Gzip must inherit from Zlib');
assert.ok(gunzipInstance instanceof Zlib, 'Gunzip must inherit from Zlib');
// 2. Gzip synchronously compresses string or buffer into gzip formatted buffer with magic bytes 0x1f 0x8b
const sampleText = 'CodeSampleX minizlib stream contract verification payload 12345';
const compressedBuffer = gzipSync(sampleText);
assert.ok(Buffer.isBuffer(compressedBuffer), 'Compressed output must be a Buffer');
assert.ok(compressedBuffer.length > 0, 'Compressed output must not be empty');
assert.equal(compressedBuffer[0], 0x1f, 'Gzip magic byte 0 must be 0x1f');
assert.equal(compressedBuffer[1], 0x8b, 'Gzip magic byte 1 must be 0x8b');
// 3. Gunzip synchronously decompresses gzip buffer back to the original content
const decompressedBuffer = gunzipSync(compressedBuffer);
assert.ok(Buffer.isBuffer(decompressedBuffer), 'Decompressed output must be a Buffer');
assert.equal(decompressedBuffer.toString('utf8'), sampleText, 'Decompressed text must match original');
// 4. Gzip piped into Gunzip processes data through stream pipeline asynchronously
const zipStream = createGzipStream();
const unzipStream = createGunzipStream();
zipStream.pipe(unzipStream);
const receivedChunks = [];
unzipStream.on('data', chunk => receivedChunks.push(chunk));
await new Promise((resolve, reject) => {
unzipStream.on('end', () => {
const pipedResult = Buffer.concat(receivedChunks).toString('utf8');
assert.equal(pipedResult, sampleText, 'Stream piped result must match original payload');
resolve();
});
zipStream.on('error', reject);
unzipStream.on('error', reject);
zipStream.end(sampleText);
});
// 5. Gunzip raises ZlibError when consuming invalid or corrupted compressed input
let caughtError = null;
try {
gunzipSync(Buffer.from('not valid compressed gzip payload'));
} catch (err) {
caughtError = err;
}
assert.ok(caughtError !== null, 'Gunzip must throw an error on invalid compressed input');
assert.ok(caughtError instanceof Error, 'Thrown error must be an instance of Error');
assert.ok(
caughtError instanceof ZlibError || caughtError.code !== undefined || caughtError.message.length > 0,
'Error must have diagnostic details'
);
console.log('All minizlib contract assertions passed successfully.');
Seeder de origen
anónimo