Sample
raw-body 2.5.2: getRawBody
Verified sample for npm raw-body 2.5.2: getRawBody. The contract ran on node 22 · linux debian/x64 · docker and passed: getRawBody(stream) resolves to a…
sha256:2fac624e35289fb9b45a678e167ac4d7ade22abcc7dc86b32c8ffdf31a7c5fd6
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-09-19 |
Case
HOW- Goal
- verify getRawBody in pkg:npm/raw-body@2.5.2
- Packages
- Symbols
-
- getRawBody
- Created
- 2026-09-18T12:30:35Z
Contract
- getRawBody(stream) resolves to a Buffer containing the complete stream data
- getRawBody(stream, callback) yields buffer to node-style callback function
- getRawBody(stream, { encoding: 'utf8' }) decodes stream contents into a string
- getRawBody(stream, { length: N }) verifies exact byte length and throws 400 request.size.invalid error on mismatch
- getRawBody(stream, { limit: N }) enforces maximum byte size and throws 413 entity.too.large error when exceeded
- getRawBody(stream, { limit: '1kb' }) parses string byte limits using bytes library formatting
- getRawBody(stream, { encoding: 'invalid' }) throws 415 encoding.unsupported error on unknown encodings
- getRawBody throws or rejects TypeError on invalid arguments or missing stream
Files
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Source
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 getRawBody in pkg:npm/raw-body@2.5.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/raw-body@2.5.2
Demonstrate these symbols/APIs:
- getRawBody
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:7a430548317d12b221fe80cc0380618fa0a91ce8732b1daae3664851f12fa272","contract":["getRawBody(stream) resolves to a Buffer containing the complete stream data","getRawBody(stream, callback) yields buffer to node-style callback function","getRawBody(stream, { encoding: 'utf8' }) decodes stream contents into a string","getRawBody(stream, { length: N }) verifies exact byte length and throws 400 request.size.invalid error on mismatch","getRawBody(stream, { limit: N }) enforces maximum byte size and throws 413 entity.too.large error when exceeded","getRawBody(stream, { limit: '1kb' }) parses string byte limits using bytes library formatting","getRawBody(stream, { encoding: 'invalid' }) throws 415 encoding.unsupported error on unknown encodings","getRawBody throws or rejects TypeError on invalid arguments or missing stream"],"goal":"verify getRawBody in pkg:npm/raw-body@2.5.2","kind":"HOW","packages":["pkg:npm/raw-body@2.5.2"],"schemaVersion":1,"symbols":["getRawBody"]},"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@2.5.2"],"schemaVersion":1,"subject":"pkg:npm/raw-body@2.5.2","symbols":["getRawBody"],"verifierAdapter":"node-typescript@1"}
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const getRawBody = require('raw-body');
export { getRawBody };
export default getRawBody;
{
"name": "sample-raw-body-getrawbody",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-raw-body-getrawbody",
"version": "1.0.0",
"dependencies": {
"raw-body": "2.5.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.0",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
"license": "MIT",
"dependencies": {
"depd": "2.0.0",
"inherits": "2.0.4",
"setprototypeof": "1.2.0",
"statuses": "2.0.1",
"toidentifier": "1.0.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"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": "2.5.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
"license": "MIT",
"dependencies": {
"bytes": "3.1.2",
"http-errors": "2.0.0",
"iconv-lite": "0.4.24",
"unpipe": "1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"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.1",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
"integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
"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-getrawbody",
"version": "1.0.0",
"type": "module",
"main": "index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"raw-body": "2.5.2"
}
}
{
"schemaVersion": 1,
"goal": "verify getRawBody in pkg:npm/raw-body@2.5.2",
"kind": "HOW",
"packages": [
"pkg:npm/raw-body@2.5.2"
],
"symbols": [
"getRawBody"
]
}
import assert from 'node:assert/strict';
import { Readable } from 'node:stream';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const rawBody = require('raw-body');
const { getRawBody } = await import('../index.mjs');
function createStream(chunks) {
return Readable.from(chunks);
}
// 1. getRawBody(stream) resolves to a Buffer containing the complete stream data
{
const stream = createStream([Buffer.from('hello '), Buffer.from('world')]);
const buf = await getRawBody(stream);
assert.ok(Buffer.isBuffer(buf));
assert.equal(buf.toString('utf8'), 'hello world');
assert.equal(buf.length, 11);
}
// 2. getRawBody(stream, callback) yields buffer to node-style callback function
{
await new Promise((resolve, reject) => {
const stream = createStream([Buffer.from('callback test')]);
rawBody(stream, (err, buf) => {
if (err) return reject(err);
try {
assert.ok(Buffer.isBuffer(buf));
assert.equal(buf.toString('utf8'), 'callback test');
resolve();
} catch (e) {
reject(e);
}
});
});
}
// 3. getRawBody(stream, { encoding: 'utf8' }) decodes stream contents into a string
{
const stream = createStream(['utf8 ', 'content']);
const str = await getRawBody(stream, { encoding: 'utf8' });
assert.equal(typeof str, 'string');
assert.equal(str, 'utf8 content');
}
// 4. getRawBody(stream, { length: N }) verifies exact byte length and throws 400 size.did.not.match error on mismatch
{
// Matching length succeeds
const matchStream = createStream([Buffer.from('exact length')]);
const matchBuf = await getRawBody(matchStream, { length: 12 });
assert.equal(matchBuf.toString('utf8'), 'exact length');
// Mismatched length rejects
const mismatchStream = createStream([Buffer.from('mismatch length')]);
await assert.rejects(
async () => {
await getRawBody(mismatchStream, { length: 5 });
},
(err) => {
assert.equal(err.status, 400);
assert.equal(err.statusCode, 400);
assert.equal(err.type, 'request.size.invalid');
assert.equal(err.expected, 5);
assert.equal(err.received, 15);
return true;
}
);
}
// 5. getRawBody(stream, { limit: N }) enforces maximum byte size and throws 413 entity.too.large error when exceeded
{
const stream = createStream([Buffer.from('data that exceeds the five byte limit')]);
await assert.rejects(
async () => {
await getRawBody(stream, { limit: 5 });
},
(err) => {
assert.equal(err.status, 413);
assert.equal(err.statusCode, 413);
assert.equal(err.type, 'entity.too.large');
assert.equal(err.limit, 5);
assert.equal(err.received, 37);
return true;
}
);
}
// 6. getRawBody(stream, { limit: '1kb' }) parses string byte limits using bytes library formatting
{
const stream = createStream([Buffer.from('within one kilobyte')]);
const buf = await getRawBody(stream, { limit: '1kb' });
assert.ok(Buffer.isBuffer(buf));
assert.equal(buf.toString('utf8'), 'within one kilobyte');
}
// 7. getRawBody(stream, { encoding: 'invalid' }) throws 415 encoding.unsupported error on unknown encodings
{
const stream = createStream([Buffer.from('some data')]);
await assert.rejects(
async () => {
await getRawBody(stream, { encoding: 'non-existent-charset-12345' });
},
(err) => {
assert.equal(err.status, 415);
assert.equal(err.statusCode, 415);
assert.equal(err.type, 'encoding.unsupported');
return true;
}
);
}
// 8. getRawBody throws or rejects TypeError on invalid arguments or missing stream
{
await assert.rejects(
async () => {
await getRawBody(null);
},
{
name: 'TypeError'
}
);
}
console.log('All getRawBody contract assertions passed.');
Origin Seeder
anonymous