샘플
@hono/node-server 2.1.1: getConnInfo
검증된 샘플 — npm @hono/node-server 2.1.1: getConnInfo. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: getConnInfo is an exported function from…
sha256:1628291b7e7ae82eca717952f3d6d95dbc5f28406b2c5df1667a25b232eebe9f
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify @hono/node-server.getConnInfo in pkg:npm/%40hono/node-server@2.1.1
- 심벌
-
- @hono/node-server.getConnInfo
- 생성일
- 2026-09-06T01:24:19Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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.');
오리진 시더
익명