Ejemplo
@img/sharp-wasm32 0.35.5: metadata
Muestra verificada para npm @img/sharp-wasm32 0.35.5: metadata. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:72e040670409ff01945a28a2fc332bab7e08b0cd010743c76ca209bc05047e3e
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 debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-11-27 |
Caso
HOW- Objetivo
- verify @img/sharp-wasm32.metadata in pkg:npm/%40img/sharp-wasm32@0.35.5
- Paquetes
- Símbolos
-
- @img/sharp-wasm32.metadata
- Entorno
- node 22.23.2
- Creado
- 2026-11-27T01:22:03Z
Contrato
- Requiring '@img/sharp-wasm32/sharp.node' in Node CommonJS exposes metadata as a function.
- Calling metadata({ input, debuglog }, cb) on a 4x3 8-bit RGBA PNG buffer yields format='png', mediaType='image/png', width=4, height=3, channels=4, space='srgb', depth='uchar', bitsPerSample=8, hasAlpha=true, size=buffer.length, and autoOrient={ width: 4, height: 3 }.
- Calling metadata on a 5x2 RGB PNG buffer yields format='png', width=5, height=2, channels=3, and hasAlpha=false.
- Calling metadata on a raw uchar buffer with rawWidth, rawHeight, rawChannels, rawDepth, rawPremultiplied, and rawPageHeight yields format='raw' with matching dimensions, channels, and byte size.
- Passing a non-image buffer reports an error matching /unsupported image format/i through the callback.
- Setting limitInputPixels below width*height reports an error matching /exceeds pixel limit/i through the callback.
- Setting limitInputChannels below the image channel count reports an error matching /exceeds channel limit/i through the callback.
- Omitting options.input or omitting numeric input.limitInputChannels throws a TypeError synchronously.
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: verify @img/sharp-wasm32.metadata in pkg:npm/%40img/sharp-wasm32@0.35.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40img/sharp-wasm32@0.35.5
Demonstrate these symbols/APIs:
- @img/sharp-wasm32.metadata
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.
{"case":{"caseId":"case:sha256:6f5b9c2a5b7ba62a4c8939a54ad8638a5cc093428dbaf26900aff6eee2717399","constraints":{"executionContext":"node"},"contract":["Requiring '@img/sharp-wasm32/sharp.node' in Node CommonJS exposes metadata as a function.","Calling metadata({ input, debuglog }, cb) on a 4x3 8-bit RGBA PNG buffer yields format='png', mediaType='image/png', width=4, height=3, channels=4, space='srgb', depth='uchar', bitsPerSample=8, hasAlpha=true, size=buffer.length, and autoOrient={ width: 4, height: 3 }.","Calling metadata on a 5x2 RGB PNG buffer yields format='png', width=5, height=2, channels=3, and hasAlpha=false.","Calling metadata on a raw uchar buffer with rawWidth, rawHeight, rawChannels, rawDepth, rawPremultiplied, and rawPageHeight yields format='raw' with matching dimensions, channels, and byte size.","Passing a non-image buffer reports an error matching /unsupported image format/i through the callback.","Setting limitInputPixels below width*height reports an error matching /exceeds pixel limit/i through the callback.","Setting limitInputChannels below the image channel count reports an error matching /exceeds channel limit/i through the callback.","Omitting options.input or omitting numeric input.limitInputChannels throws a TypeError synchronously."],"goal":"verify @img/sharp-wasm32.metadata in pkg:npm/%40img/sharp-wasm32@0.35.5","kind":"HOW","packages":["pkg:npm/%40img/sharp-wasm32@0.35.5"],"schemaVersion":1,"symbols":["@img/sharp-wasm32.metadata"]},"contractCommand":["node","test/contract.js"],"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/%40img/sharp-wasm32@0.35.5"],"schemaVersion":1,"subject":"pkg:npm/%40img/sharp-wasm32@0.35.5","symbols":["@img/sharp-wasm32.metadata"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-sharp-wasm32-metadata",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-sharp-wasm32-metadata",
"version": "1.0.0",
"dependencies": {
"@img/sharp-wasm32": "0.35.5"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.11.3",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
"integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
"license": "MIT",
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@img/sharp-wasm32": {
"version": "0.35.5",
"resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz",
"integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==",
"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
"dependencies": {
"@emnapi/runtime": "^1.11.3"
},
"engines": {
"node": ">=20.9.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/tslib": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz",
"integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==",
"license": "0BSD"
}
}
}
{
"name": "sample-sharp-wasm32-metadata",
"version": "1.0.0",
"private": true,
"type": "commonjs",
"dependencies": {
"@img/sharp-wasm32": "0.35.5"
},
"scripts": {
"test": "node test/contract.js"
}
}
{
"schemaVersion": 1,
"goal": "verify @img/sharp-wasm32.metadata in pkg:npm/%40img/sharp-wasm32@0.35.5",
"kind": "HOW",
"packages": [
"pkg:npm/%40img/sharp-wasm32@0.35.5"
],
"symbols": [
"@img/sharp-wasm32.metadata"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict';
const sharpWasm = require('@img/sharp-wasm32/sharp.node');
const DEFAULT_LIMIT_INPUT_PIXELS = Math.pow(0x3fff, 2);
function readMetadata(inputOptions) {
const input = {
failOn: 'warning',
limitInputPixels: DEFAULT_LIMIT_INPUT_PIXELS,
limitInputChannels: 0,
unlimited: false,
autoOrient: false,
...inputOptions
};
return new Promise((resolve, reject) => {
sharpWasm.metadata(
{
input,
debuglog: () => {}
},
(err, metadata) => {
if (err) {
reject(err);
return;
}
resolve(metadata);
}
);
});
}
module.exports = {
sharpWasm,
readMetadata
};
'use strict';
const assert = require('node:assert/strict');
const zlib = require('node:zlib');
const { sharpWasm, readMetadata } = require('../src/index.js');
function crc32(buffer) {
let crc = 0xffffffff;
for (let i = 0; i < buffer.length; i += 1) {
crc ^= buffer[i];
for (let bit = 0; bit < 8; bit += 1) {
crc = (crc >>> 1) ^ (0xedb88320 & -(crc & 1));
}
}
return (crc ^ 0xffffffff) >>> 0;
}
function pngChunk(type, data) {
const length = Buffer.alloc(4);
length.writeUInt32BE(data.length, 0);
const typeBuf = Buffer.from(type, 'ascii');
const crc = Buffer.alloc(4);
crc.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])), 0);
return Buffer.concat([length, typeBuf, data, crc]);
}
function createPngBuffer(width, height, colorType) {
const channels = colorType === 6 ? 4 : 3;
const signature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
const ihdr = Buffer.alloc(13);
ihdr.writeUInt32BE(width, 0);
ihdr.writeUInt32BE(height, 4);
ihdr[8] = 8;
ihdr[9] = colorType;
ihdr[10] = 0;
ihdr[11] = 0;
ihdr[12] = 0;
const rows = [];
for (let y = 0; y < height; y += 1) {
const row = Buffer.alloc(1 + width * channels);
row[0] = 0;
for (let x = 0; x < width; x += 1) {
row[1 + x * channels] = 200;
row[2 + x * channels] = 100;
row[3 + x * channels] = 50;
if (channels === 4) {
row[4 + x * channels] = 255;
}
}
rows.push(row);
}
const idat = zlib.deflateSync(Buffer.concat(rows));
return Buffer.concat([
signature,
pngChunk('IHDR', ihdr),
pngChunk('IDAT', idat),
pngChunk('IEND', Buffer.alloc(0))
]);
}
async function main() {
assert.equal(typeof sharpWasm.metadata, 'function');
// 1. RGBA PNG buffer metadata
const rgbaPng = createPngBuffer(4, 3, 6);
const rgbaMeta = await readMetadata({ buffer: rgbaPng });
assert.equal(rgbaMeta.format, 'png');
assert.equal(rgbaMeta.mediaType, 'image/png');
assert.equal(rgbaMeta.size, rgbaPng.length);
assert.equal(rgbaMeta.width, 4);
assert.equal(rgbaMeta.height, 3);
assert.equal(rgbaMeta.space, 'srgb');
assert.equal(rgbaMeta.channels, 4);
assert.equal(rgbaMeta.depth, 'uchar');
assert.equal(rgbaMeta.bitsPerSample, 8);
assert.equal(rgbaMeta.hasAlpha, true);
assert.deepEqual(rgbaMeta.autoOrient, { width: 4, height: 3 });
// 2. RGB PNG buffer metadata (no alpha)
const rgbPng = createPngBuffer(5, 2, 2);
const rgbMeta = await readMetadata({ buffer: rgbPng });
assert.equal(rgbMeta.format, 'png');
assert.equal(rgbMeta.width, 5);
assert.equal(rgbMeta.height, 2);
assert.equal(rgbMeta.channels, 3);
assert.equal(rgbMeta.hasAlpha, false);
// 3. Raw pixel buffer metadata
const rawBuffer = Buffer.alloc(2 * 3 * 3);
const rawMeta = await readMetadata({
buffer: rawBuffer,
rawWidth: 2,
rawHeight: 3,
rawChannels: 3,
rawDepth: 'uchar',
rawPremultiplied: false,
rawPageHeight: 0
});
assert.equal(rawMeta.format, 'raw');
assert.equal(rawMeta.size, rawBuffer.length);
assert.equal(rawMeta.width, 2);
assert.equal(rawMeta.height, 3);
assert.equal(rawMeta.channels, 3);
assert.equal(rawMeta.hasAlpha, false);
// 4. Unsupported image buffer fails via callback error
await assert.rejects(
readMetadata({ buffer: Buffer.from('not-an-image') }),
/unsupported image format/i
);
// 5. Pixel limit enforced via limitInputPixels
await assert.rejects(
readMetadata({ buffer: rgbaPng, limitInputPixels: 10 }),
/exceeds pixel limit/i
);
// 6. Channel limit enforced via limitInputChannels
await assert.rejects(
readMetadata({ buffer: rgbaPng, limitInputChannels: 3 }),
/exceeds channel limit/i
);
// 7. Missing required input descriptor throws TypeError synchronously
assert.throws(() => {
sharpWasm.metadata({}, () => {});
}, TypeError);
// 8. Missing numeric limitInputChannels throws TypeError synchronously
assert.throws(() => {
sharpWasm.metadata(
{
input: {
buffer: rgbaPng,
failOn: 'warning',
limitInputPixels: 1000,
unlimited: false,
autoOrient: false
},
debuglog: () => {}
},
() => {}
);
}, TypeError);
console.log('PASS: @img/sharp-wasm32.metadata contract verified');
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
Seeder de origen
anónimo