Пример
mimic-response 3.1.0
Проверенный пример — npm mimic-response 3.1.0. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: mimicResponse(fromStream, toStream) copies…
sha256:3006b9956f4ebda3b8bbac54dc067cf7307117ca79ec8b97d342b993f399222a
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
Кейс
HOW- Цель
- verify pkg:npm/mimic-response@3.1.0
- Пакеты
- Окружение
- node 22.23.2
- Создан
- 2026-08-21T17:59:08Z
Контракт
- mimicResponse(fromStream, toStream) copies HTTP response properties including statusCode, statusMessage, headers, and url from fromStream to toStream
- mimicResponse(fromStream, toStream) returns the destination toStream instance
- mimicResponse(fromStream, toStream) does not overwrite properties already existing on toStream
- mimicResponse(fromStream, toStream) throws an Error if toStream has autoDestroy enabled
- mimicResponse(fromStream, toStream) forwards getters and setters between fromStream and toStream
- mimicResponse(fromStream, toStream) propagates aborted event from fromStream to destroy toStream
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.js
Исходный код
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/mimic-response@3.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/mimic-response@3.1.0
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:9494774e3352fab876617a927d6de6d38871d5f3bdf9016c1ddc3a68a578aa8b","constraints":{"executionContext":"node"},"contract":["mimicResponse(fromStream, toStream) copies HTTP response properties including statusCode, statusMessage, headers, and url from fromStream to toStream","mimicResponse(fromStream, toStream) returns the destination toStream instance","mimicResponse(fromStream, toStream) does not overwrite properties already existing on toStream","mimicResponse(fromStream, toStream) throws an Error if toStream has autoDestroy enabled","mimicResponse(fromStream, toStream) forwards getters and setters between fromStream and toStream","mimicResponse(fromStream, toStream) propagates aborted event from fromStream to destroy toStream"],"goal":"verify pkg:npm/mimic-response@3.1.0","kind":"HOW","packages":["pkg:npm/mimic-response@3.1.0"],"schemaVersion":1},"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/mimic-response@3.1.0"],"schemaVersion":1,"subject":"pkg:npm/mimic-response@3.1.0","verifierAdapter":"node-typescript@1"}
{
"name": "csx-sample-mimic-response",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "csx-sample-mimic-response",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"mimic-response": "3.1.0"
}
},
"node_modules/mimic-response": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
"integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==",
"license": "MIT",
"engines": {
"node": ">=10"
}
}
}
}
{
"name": "csx-sample-mimic-response",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for mimic-response",
"main": "test/contract.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"mimic-response": "3.1.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/mimic-response@3.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/mimic-response@3.1.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const assert = require('assert');
const { PassThrough } = require('stream');
const mimicResponse = require('mimic-response');
async function runTests() {
// Test 1: Copies HTTP response properties and returns toStream
{
const fromStream = new PassThrough();
fromStream.statusCode = 200;
fromStream.statusMessage = 'OK';
fromStream.headers = { 'content-type': 'application/json' };
fromStream.httpVersion = '1.1';
fromStream.url = '/api/resource';
fromStream.method = 'GET';
const toStream = new PassThrough({ autoDestroy: false });
const result = mimicResponse(fromStream, toStream);
assert.strictEqual(result, toStream, 'mimicResponse should return toStream');
assert.strictEqual(toStream.statusCode, 200, 'statusCode should match');
assert.strictEqual(toStream.statusMessage, 'OK', 'statusMessage should match');
assert.deepStrictEqual(toStream.headers, { 'content-type': 'application/json' }, 'headers should match');
assert.strictEqual(toStream.httpVersion, '1.1', 'httpVersion should match');
assert.strictEqual(toStream.url, '/api/resource', 'url should match');
assert.strictEqual(toStream.method, 'GET', 'method should match');
}
// Test 2: Does not overwrite existing properties on toStream
{
const fromStream = new PassThrough();
fromStream.statusCode = 200;
fromStream.customProperty = 'from-source';
const toStream = new PassThrough({ autoDestroy: false });
toStream.customProperty = 'original-destination';
mimicResponse(fromStream, toStream);
assert.strictEqual(toStream.customProperty, 'original-destination', 'existing property should not be overwritten');
assert.strictEqual(toStream.statusCode, 200, 'new property should be copied');
}
// Test 3: Throws an Error if toStream has autoDestroy enabled
{
const fromStream = new PassThrough();
const toStream = new PassThrough({ autoDestroy: true });
assert.throws(
() => mimicResponse(fromStream, toStream),
/The second stream must have the `autoDestroy` option set to `false`/,
'should throw error when autoDestroy is true'
);
}
// Test 4: Forwards getters and setters between fromStream and toStream
{
const fromStream = new PassThrough();
fromStream.statusCode = 200;
const toStream = new PassThrough({ autoDestroy: false });
mimicResponse(fromStream, toStream);
toStream.statusCode = 404;
assert.strictEqual(fromStream.statusCode, 404, 'setting property on toStream should update fromStream');
fromStream.statusMessage = 'Not Found';
assert.strictEqual(toStream.statusMessage, 'Not Found', 'updating property on fromStream should reflect on toStream');
}
// Test 5: Propagates aborted event from fromStream to destroy toStream
await new Promise((resolve, reject) => {
const fromStream = new PassThrough();
const toStream = new PassThrough({ autoDestroy: false });
mimicResponse(fromStream, toStream);
let abortedEmitted = false;
toStream.on('aborted', () => {
abortedEmitted = true;
});
toStream.on('close', () => {
try {
assert.strictEqual(abortedEmitted, true, 'aborted event should have been emitted on toStream');
assert.strictEqual(toStream.destroyed, true, 'toStream should be destroyed');
resolve();
} catch (err) {
reject(err);
}
});
fromStream.emit('aborted');
});
console.log('All mimic-response contract assertions passed successfully.');
}
runTests().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Исходный сидер
аноним