Exemplo
raw-body 3.0.2
Amostra verificada para npm raw-body 3.0.2. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: assert getRawBody reads a readable stream and…
sha256:f6a659e9ea8bcabf8f6dd8f498d170843f3fbf34304e55edae84852f09c31481
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
Caso
HOW- Objetivo
- verify pkg:npm/raw-body@3.0.2
- Pacotes
- Criado
- 2026-08-20T14:06:05Z
Contrato
- assert getRawBody reads a readable stream and resolves to a Buffer when no encoding is specified
- assert getRawBody decodes stream contents to a string when encoding option is provided
- assert getRawBody rejects with 413 entity.too.large when stream size exceeds numeric or string limit
- assert getRawBody rejects with 400 request.size.invalid when stream length does not match expected length option
- assert getRawBody supports Node.js error-first callback convention when callback function is supplied
Arquivos
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
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/raw-body@3.0.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/raw-body@3.0.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:d25d9c32edf1c4a150ea00283e18a21eee4f095a61329aba9450b033ea4c7ac4","contract":["assert getRawBody reads a readable stream and resolves to a Buffer when no encoding is specified","assert getRawBody decodes stream contents to a string when encoding option is provided","assert getRawBody rejects with 413 entity.too.large when stream size exceeds numeric or string limit","assert getRawBody rejects with 400 request.size.invalid when stream length does not match expected length option","assert getRawBody supports Node.js error-first callback convention when callback function is supplied"],"goal":"verify pkg:npm/raw-body@3.0.2","kind":"HOW","packages":["pkg:npm/raw-body@3.0.2"],"schemaVersion":1},"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/raw-body@3.0.2"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
import getRawBody from 'raw-body';
/**
* Read and parse raw body from a readable stream.
* @param {import('stream').Readable} stream
* @param {object} [options]
* @returns {Promise<Buffer|string>}
*/
export async function readBody(stream, options = {}) {
return getRawBody(stream, options);
}
export default getRawBody;
{
"name": "sample-raw-body-verify",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-raw-body-verify",
"version": "1.0.0",
"dependencies": {
"raw-body": "3.0.2"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
"integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"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/raw-body": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz",
"integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.7.0",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}
{
"name": "sample-raw-body-verify",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"raw-body": "3.0.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/raw-body@3.0.2",
"kind": "HOW",
"packages": [
"pkg:npm/raw-body@3.0.2"
]
}
import assert from 'node:assert/strict';
import { Readable } from 'node:stream';
import getRawBody, { readBody } from '../index.mjs';
// 1. assert getRawBody reads a readable stream and resolves to a Buffer when no encoding is specified
{
const stream = Readable.from([Buffer.from('hello '), Buffer.from('world')]);
const result = await getRawBody(stream);
assert.ok(Buffer.isBuffer(result), 'Result should be a Buffer');
assert.strictEqual(result.toString('utf8'), 'hello world');
}
// 2. assert getRawBody decodes stream contents to a string when encoding option is provided
{
const stream = Readable.from(['hello ', 'world']);
const result = await getRawBody(stream, { encoding: 'utf8' });
assert.strictEqual(typeof result, 'string', 'Result should be a string');
assert.strictEqual(result, 'hello world');
const streamViaHelper = Readable.from(['helper ', 'test']);
const helperResult = await readBody(streamViaHelper, { encoding: 'utf8' });
assert.strictEqual(helperResult, 'helper test');
}
// 3. assert getRawBody rejects with 413 entity.too.large when stream size exceeds numeric or string limit
{
const streamNumeric = Readable.from(['1234567890']);
let numLimitErr = null;
try {
await getRawBody(streamNumeric, { limit: 5 });
} catch (err) {
numLimitErr = err;
}
assert.ok(numLimitErr !== null, 'Should have thrown limit error');
assert.strictEqual(numLimitErr.status, 413);
assert.strictEqual(numLimitErr.statusCode, 413);
assert.strictEqual(numLimitErr.type, 'entity.too.large');
assert.strictEqual(numLimitErr.limit, 5);
assert.strictEqual(numLimitErr.received, 10);
const streamString = Readable.from(['a'.repeat(1500)]);
let strLimitErr = null;
try {
await getRawBody(streamString, { limit: '1kb' });
} catch (err) {
strLimitErr = err;
}
assert.ok(strLimitErr !== null, 'Should have thrown string limit error');
assert.strictEqual(strLimitErr.status, 413);
assert.strictEqual(strLimitErr.type, 'entity.too.large');
assert.strictEqual(strLimitErr.limit, 1024);
assert.strictEqual(strLimitErr.received, 1500);
}
// 4. assert getRawBody rejects with 400 request.size.invalid when stream length does not match expected length option
{
const stream = Readable.from(['hello']);
let lenErr = null;
try {
await getRawBody(stream, { length: 10 });
} catch (err) {
lenErr = err;
}
assert.ok(lenErr !== null, 'Should have thrown length mismatch error');
assert.strictEqual(lenErr.status, 400);
assert.strictEqual(lenErr.statusCode, 400);
assert.strictEqual(lenErr.type, 'request.size.invalid');
assert.strictEqual(lenErr.length, 10);
assert.strictEqual(lenErr.expected, 10);
assert.strictEqual(lenErr.received, 5);
}
// 5. assert getRawBody supports Node.js error-first callback convention when callback function is supplied
{
const stream = Readable.from(['callback ', 'data']);
const result = await new Promise((resolve, reject) => {
getRawBody(stream, { encoding: 'utf8' }, (err, data) => {
if (err) return reject(err);
resolve(data);
});
});
assert.strictEqual(result, 'callback data');
}
console.log('All contracts passed successfully.');
Seeder de origem
anônimo