Exemple
@hono/node-server 2.1.1: getConnInfo
Échantillon vérifié pour npm @hono/node-server 2.1.1: getConnInfo. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:1628291b7e7ae82eca717952f3d6d95dbc5f28406b2c5df1667a25b232eebe9f
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-06 |
Cas
HOW- Objectif
- verify @hono/node-server.getConnInfo in pkg:npm/%40hono/node-server@2.1.1
- Paquets
- Symboles
-
- @hono/node-server.getConnInfo
- Créé
- 2026-09-06T01:24:19Z
Contrat
- getConnInfo is an exported function from @hono/node-server/conninfo
- getConnInfo extracts remote address, port, and IPv4 addressType from c.env.incoming.socket
- getConnInfo extracts remote connection details when incoming socket is under c.env.server.incoming
- getConnInfo detects IPv6 addressType when remoteFamily is IPv6
- getConnInfo sets addressType to undefined when remoteFamily is neither IPv4 nor IPv6
- getConnInfo extracts live connection information from a running HTTP server request socket
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code 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 @hono/node-server.getConnInfo in pkg:npm/%40hono/node-server@2.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40hono/node-server@2.1.1
Demonstrate these symbols/APIs:
- @hono/node-server.getConnInfo
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:43ab6114a17ab044f150e20fb8fb52570f37247b9ba0b2a923e8399d9c8b3036","contract":["getConnInfo is an exported function from @hono/node-server/conninfo","getConnInfo extracts remote address, port, and IPv4 addressType from c.env.incoming.socket","getConnInfo extracts remote connection details when incoming socket is under c.env.server.incoming","getConnInfo detects IPv6 addressType when remoteFamily is IPv6","getConnInfo sets addressType to undefined when remoteFamily is neither IPv4 nor IPv6","getConnInfo extracts live connection information from a running HTTP server request socket"],"goal":"verify @hono/node-server.getConnInfo in pkg:npm/%40hono/node-server@2.1.1","kind":"HOW","packages":["pkg:npm/%40hono/node-server@2.1.1"],"schemaVersion":1,"symbols":["@hono/node-server.getConnInfo"]},"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/%40hono/node-server@2.1.1"],"schemaVersion":1,"subject":"pkg:npm/%40hono/node-server@2.1.1","symbols":["@hono/node-server.getConnInfo"],"verifierAdapter":"node-typescript@1"}
export { getConnInfo } from '@hono/node-server/conninfo';
{
"name": "sample-hono-node-server-getconninfo",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-hono-node-server-getconninfo",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@hono/node-server": "2.1.1"
}
},
"node_modules/@hono/node-server": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.1.tgz",
"integrity": "sha512-ELuehkj5VCBdgEw9zs+ivkKwyzzUCSQuE96YmiPvn1ECBoZCczbFXJLeEGMTYjphP6gydh4pHMqEYPVMYUVgQg==",
"license": "MIT",
"engines": {
"node": ">=20"
},
"peerDependencies": {
"hono": "^4"
}
},
"node_modules/hono": {
"version": "4.13.7",
"resolved": "https://registry.npmjs.org/hono/-/hono-4.13.7.tgz",
"integrity": "sha512-c8/gF9ac8Y78/agExVocyLevgR+JlpNB444Py0FSX8pJoPdYUfUzRcXtYEYGwt6l19qIlVZPN5Mfsw9jFShmQQ==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=16.9.0"
}
}
}
}
{
"name": "sample-hono-node-server-getconninfo",
"version": "1.0.0",
"private": true,
"description": "verify @hono/node-server.getConnInfo in pkg:npm/%40hono/node-server@2.1.1",
"type": "module",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@hono/node-server": "2.1.1"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify @hono/node-server.getConnInfo in pkg:npm/%40hono/node-server@2.1.1",
"kind": "HOW",
"packages": [
"pkg:npm/%40hono/node-server@2.1.1"
],
"symbols": [
"@hono/node-server.getConnInfo"
]
}
import assert from 'node:assert';
import http from 'node:http';
import { getConnInfo } from '../index.js';
// 1. getConnInfo is an exported function from @hono/node-server/conninfo
assert.strictEqual(typeof getConnInfo, 'function', 'getConnInfo must be an exported function');
// 2. getConnInfo extracts remote address, port, and IPv4 addressType from c.env.incoming.socket
const ctxDirect = {
env: {
incoming: {
socket: {
remoteAddress: '127.0.0.1',
remotePort: 54321,
remoteFamily: 'IPv4'
}
}
}
};
const directInfo = getConnInfo(ctxDirect);
assert.deepStrictEqual(directInfo, {
remote: {
address: '127.0.0.1',
port: 54321,
addressType: 'IPv4'
}
});
// 3. getConnInfo extracts remote connection details when incoming socket is under c.env.server.incoming
const ctxNested = {
env: {
server: {
incoming: {
socket: {
remoteAddress: '192.168.1.100',
remotePort: 8080,
remoteFamily: 'IPv4'
}
}
}
}
};
const nestedInfo = getConnInfo(ctxNested);
assert.deepStrictEqual(nestedInfo, {
remote: {
address: '192.168.1.100',
port: 8080,
addressType: 'IPv4'
}
});
// 4. getConnInfo detects IPv6 addressType when remoteFamily is IPv6
const ctxIPv6 = {
env: {
incoming: {
socket: {
remoteAddress: '::1',
remotePort: 9000,
remoteFamily: 'IPv6'
}
}
}
};
const ipv6Info = getConnInfo(ctxIPv6);
assert.deepStrictEqual(ipv6Info, {
remote: {
address: '::1',
port: 9000,
addressType: 'IPv6'
}
});
// 5. getConnInfo sets addressType to undefined when remoteFamily is neither IPv4 nor IPv6
const ctxUnknownFamily = {
env: {
incoming: {
socket: {
remoteAddress: 'custom-pipe',
remotePort: undefined,
remoteFamily: 'UnknownFamily'
}
}
}
};
const unknownInfo = getConnInfo(ctxUnknownFamily);
assert.deepStrictEqual(unknownInfo, {
remote: {
address: 'custom-pipe',
port: undefined,
addressType: undefined
}
});
// 6. getConnInfo extracts live connection information from a running HTTP server request socket
const server = http.createServer((req, res) => {
const liveContext = {
env: {
incoming: req
}
};
const liveInfo = getConnInfo(liveContext);
assert(liveInfo && liveInfo.remote, 'remote property must exist');
assert(typeof liveInfo.remote.address === 'string', 'address must be string');
assert(typeof liveInfo.remote.port === 'number' && liveInfo.remote.port > 0, 'port must be positive number');
assert(['IPv4', 'IPv6'].includes(liveInfo.remote.addressType), 'addressType must be IPv4 or IPv6');
res.statusCode = 200;
res.end('ok');
});
await new Promise((resolve, reject) => {
server.listen(0, '127.0.0.1', () => {
const addressInfo = server.address();
const port = addressInfo.port;
const clientReq = http.get(`http://127.0.0.1:${port}`, (res) => {
res.resume();
res.on('end', () => {
server.close((err) => {
if (err) reject(err);
else resolve();
});
});
});
clientReq.on('error', reject);
});
});
console.log('Contract tests passed successfully.');
Seeder d'origine
anonyme