Ejemplo
http2-wrapper 1.0.3: get
Muestra verificada para npm http2-wrapper 1.0.3: get. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó: http2-wrapper exports get…
sha256:7fe0082c4d63e3c1f09b1d45aea94351ce43bd6d03001ae2c16bad23fd2adb9f
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
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-09-03 |
Caso
HOW- Objetivo
- verify http2-wrapper.get in pkg:npm/http2-wrapper@1.0.3
- Paquetes
- Símbolos
-
- http2-wrapper.get
- Entorno
- node 22.23.2
- Creado
- 2026-09-03T15:59:47Z
Contrato
- http2-wrapper exports get function and ClientRequest constructor
- get rejects unsupported protocols with ERR_INVALID_PROTOCOL
- get executes HTTP/2 GET request over TLS and returns ClientRequest instance with method GET
- get automatically terminates request stream without requiring manual req.end() call
- get invokes response callback with IncomingMessage delivering status code, headers, and body chunks
- get accepts URL string or request options object and supports custom Agent
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
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 http2-wrapper.get in pkg:npm/http2-wrapper@1.0.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/http2-wrapper@1.0.3
Demonstrate these symbols/APIs:
- http2-wrapper.get
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- 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:2313c9d4207423d20208b3e4cfcf4b7be6f240c028a86b06893125f317214dc4","constraints":{"executionContext":"node"},"contract":["http2-wrapper exports get function and ClientRequest constructor","get rejects unsupported protocols with ERR_INVALID_PROTOCOL","get executes HTTP/2 GET request over TLS and returns ClientRequest instance with method GET","get automatically terminates request stream without requiring manual req.end() call","get invokes response callback with IncomingMessage delivering status code, headers, and body chunks","get accepts URL string or request options object and supports custom Agent"],"goal":"verify http2-wrapper.get in pkg:npm/http2-wrapper@1.0.3","kind":"HOW","packages":["pkg:npm/http2-wrapper@1.0.3"],"schemaVersion":1,"symbols":["http2-wrapper.get"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/http2-wrapper@1.0.3"],"schemaVersion":1,"subject":"pkg:npm/http2-wrapper@1.0.3","symbols":["http2-wrapper.get"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-http2-wrapper-get",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-http2-wrapper-get",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"http2-wrapper": "1.0.3"
}
},
"node_modules/http2-wrapper": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz",
"integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==",
"license": "MIT",
"dependencies": {
"quick-lru": "^5.1.1",
"resolve-alpn": "^1.0.0"
},
"engines": {
"node": ">=10.19.0"
}
},
"node_modules/quick-lru": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
"integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==",
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/resolve-alpn": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz",
"integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==",
"license": "MIT"
}
}
}
{
"name": "sample-http2-wrapper-get",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for http2-wrapper.get in http2-wrapper@1.0.3",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"http2-wrapper": "1.0.3"
}
}
{
"schemaVersion": 1,
"goal": "verify http2-wrapper.get in pkg:npm/http2-wrapper@1.0.3",
"kind": "HOW",
"packages": [
"pkg:npm/http2-wrapper@1.0.3"
],
"symbols": [
"http2-wrapper.get"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
'use strict';
const http2Wrapper = require('http2-wrapper');
/**
* Executes an HTTP/2 GET request with automatic request termination.
*
* @param {string | URL | object} url - Target URL or request options.
* @param {object | Function} [options] - Request options or response callback.
* @param {Function} [callback] - Response callback receiving IncomingMessage.
* @returns {http2Wrapper.ClientRequest} ClientRequest instance.
*/
function get(url, options, callback) {
return http2Wrapper.get(url, options, callback);
}
/**
* Creates an HTTP/2 Agent instance for managing HTTP/2 sessions and connection pooling.
*
* @param {object} [options] - Agent options.
* @returns {http2Wrapper.Agent} Configured Agent instance.
*/
function createAgent(options) {
return new http2Wrapper.Agent(options);
}
module.exports = {
http2Wrapper,
get,
createAgent
};
import assert from 'node:assert';
import http2 from 'node:http2';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { http2Wrapper, get, createAgent } = require('../src/index.js');
const TEST_KEY_B64 = 'LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2Z0lCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktnd2dnU2tBZ0VBQW9JQkFRQzJSdGwwdDZGZUlWUGoKY2Z6K3NuK1FUeU9zNFNHNHRndkhWVUw4djFqbmZsK3plUEwvVGlyWG1BZ0k3eVVsbXZWSlh6OWk0Z21kdDFvQwo0UFNjTjB5K3RsV0UwbUk5UXltVGN4UXVadjlZdHBDNW8xdlhhZDY2ekNDdEtKdmJwaW10M2ZnMWx3YzVQd2Z5Cmx5L1pLNFF6Uy9UbENiUmZOb2kzSEo0V2JqVSt6amQ5N1JxWWJzNnAyUG1LS2c5K0RrYlNvbVFldXNiQzg3M1AKeURXd1dTYk9qMjl2L1BHcXJyMUdSNmlRV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G8va3Vsa1MxRFJNelM0TXp6ZnpaRTFabmg3ClJaVlY1cGJIZHNRWnNMOEt3T1Y5NWtsREp4YTlPUGFkQnNJS0lFNHVtd1dYak1DSFpiMWpORzUxQWsrY0MxemYKdnVEYnlkVlhsR1VleWtBak1RPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=';
async function testAll() {
// 1. Export verification
assert.strictEqual(typeof http2Wrapper.get, 'function', 'http2Wrapper.get must be exported as a function');
assert.strictEqual(typeof http2Wrapper.ClientRequest, 'function', 'http2Wrapper.ClientRequest must be exported as a constructor');
assert.strictEqual(typeof get, 'function', 'get helper must be exported as a function');
// 2. ClientRequest protocol validation throws synchronously
assert.throws(
() => get({ protocol: 'ftp:', hostname: 'localhost' }),
{ code: 'ERR_INVALID_PROTOCOL' },
'get should throw ERR_INVALID_PROTOCOL on unsupported protocol'
);
// 3. Offline HTTP/2 secure server integration
const key = Buffer.from(TEST_KEY_B64, 'base64').toString('utf8');
const cert = Buffer.from(TEST_CERT_B64, 'base64').toString('utf8');
const server = http2.createSecureServer({
key,
cert,
allowHTTP1: true
});
server.on('request', (req, res) => {
if (req.url === '/test-get' && req.method === 'GET') {
res.writeHead(200, {
'content-type': 'application/json',
'x-sample-header': 'get-verified'
});
res.end(JSON.stringify({ method: 'GET', path: '/test-get', ok: true }));
} else if (req.url === '/not-found') {
res.writeHead(404, { 'content-type': 'text/plain' });
res.end('Resource not found');
} else {
res.writeHead(400);
res.end('Unexpected request');
}
});
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
const port = server.address().port;
const testAgent = createAgent({
rejectUnauthorized: false
});
try {
// 4. Test get with options object and callback
await new Promise((resolve, reject) => {
const req = get({
hostname: 'localhost',
port,
path: '/test-get',
agent: testAgent,
rejectUnauthorized: false
}, (res) => {
assert.strictEqual(res.statusCode, 200, 'response status code must be 200');
assert.strictEqual(res.headers['x-sample-header'], 'get-verified', 'custom header must be present in response');
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => {
const body = JSON.parse(data);
assert.strictEqual(body.ok, true, 'response body ok flag must be true');
assert.strictEqual(body.method, 'GET', 'response method must be GET');
resolve();
});
});
assert(req instanceof http2Wrapper.ClientRequest, 'req must be an instance of ClientRequest');
assert.strictEqual(req.method, 'GET', 'request method must default to GET');
req.on('error', reject);
});
// 5. Test get with URL string and options
await new Promise((resolve, reject) => {
const targetUrl = `https://localhost:${port}/not-found`;
const req = get(targetUrl, {
agent: testAgent,
rejectUnauthorized: false
}, (res) => {
assert.strictEqual(res.statusCode, 404, 'not-found status code must be 404');
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => {
assert.strictEqual(data, 'Resource not found', 'response body must match 404 text');
resolve();
});
});
assert(req instanceof http2Wrapper.ClientRequest, 'req must be an instance of ClientRequest');
req.on('error', reject);
});
} finally {
testAgent.destroy();
await new Promise((resolve) => server.close(resolve));
}
console.log('Contract passed: all assertions verified');
}
testAll().catch((err) => {
console.error('Contract failed:', err);
process.exit(1);
});
Seeder de origen
anónimo