示例
ip-address 10.3.1
已验证示例 — npm ip-address 10.3.1. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: Address4.isValid validates valid IPv4 addresses and rejects invalid…
sha256:f90ef8b5d23eb0c70e57a21d25884410cf964976e9d8ab195c339f746d6388c0
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
案例
HOW- 目标
- verify pkg:npm/ip-address@10.3.1
- 创建时间
- 2026-08-27T22:12:58Z
契约
- Address4.isValid validates valid IPv4 addresses and rejects invalid strings
- Address4 parses IPv4 address and CIDR subnet mask correctly
- Address4 calculates startAddress, endAddress, and host boundaries for a given subnet
- Address4.isInSubnet determines whether an address belongs to the subnet
- Address4.fromAddressAndMask parses dotted-decimal subnet masks into CIDR prefix length
- Address4 bigInt and fromBigInt convert IPv4 addresses to and from 32-bit integers
- Address4 fromHex and toHex convert between hex string and Address4
- Address6.isValid validates valid IPv6 addresses and rejects invalid formats
- Address6 formats canonical and correct compressed representations
- Address6 calculates startAddress, endAddress, and subnet membership for IPv6 subnets
- Address6 bigInt and fromBigInt convert IPv6 addresses to and from 128-bit integers
- Address6 identifies special address types including loopback, link-local, and multicast
- Address6 converts IPv4-mapped IPv6 address to Address4 instance via to4 and isMapped4
- AddressError creates error instances with proper name and prototype inheritance
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
源代码
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/ip-address@10.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/ip-address@10.3.1
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:b12fa58266655818789c8fae6a59d452c6b9fbf231b9cfd21a8223ea61c01706","contract":["Address4.isValid validates valid IPv4 addresses and rejects invalid strings","Address4 parses IPv4 address and CIDR subnet mask correctly","Address4 calculates startAddress, endAddress, and host boundaries for a given subnet","Address4.isInSubnet determines whether an address belongs to the subnet","Address4.fromAddressAndMask parses dotted-decimal subnet masks into CIDR prefix length","Address4 bigInt and fromBigInt convert IPv4 addresses to and from 32-bit integers","Address4 fromHex and toHex convert between hex string and Address4","Address6.isValid validates valid IPv6 addresses and rejects invalid formats","Address6 formats canonical and correct compressed representations","Address6 calculates startAddress, endAddress, and subnet membership for IPv6 subnets","Address6 bigInt and fromBigInt convert IPv6 addresses to and from 128-bit integers","Address6 identifies special address types including loopback, link-local, and multicast","Address6 converts IPv4-mapped IPv6 address to Address4 instance via to4 and isMapped4","AddressError creates error instances with proper name and prototype inheritance"],"goal":"verify pkg:npm/ip-address@10.3.1","kind":"HOW","packages":["pkg:npm/ip-address@10.3.1"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"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/ip-address@10.3.1"],"schemaVersion":1,"subject":"pkg:npm/ip-address@10.3.1","verifierAdapter":"node-typescript@1"}
{
"name": "ip-address-verification",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ip-address-verification",
"version": "1.0.0",
"dependencies": {
"ip-address": "10.3.1"
}
},
"node_modules/ip-address": {
"version": "10.3.1",
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.3.1.tgz",
"integrity": "sha512-1e9d3kb97NHJTIJDZW9rKqW2h6+dFa50Dy0fpPSMQp2ADje5gvKsXmdiK6dwY5t76TaTt5+P5N1Y/LoToIxP6g==",
"license": "MIT",
"engines": {
"node": ">= 12"
}
}
}
}
{
"name": "ip-address-verification",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for ip-address",
"dependencies": {
"ip-address": "10.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/ip-address@10.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/ip-address@10.3.1"
]
}
const assert = require('node:assert');
const { Address4, Address6, AddressError } = require('ip-address');
// 1. Address4.isValid validates valid IPv4 addresses and rejects invalid strings
assert.strictEqual(Address4.isValid('192.168.1.1'), true);
assert.strictEqual(Address4.isValid('10.0.0.1/24'), true);
assert.strictEqual(Address4.isValid('256.0.0.1'), false);
assert.strictEqual(Address4.isValid('invalid-ip'), false);
assert.strictEqual(Address4.isValid(''), false);
// 2. Address4 parses IPv4 address and CIDR subnet mask correctly
const v4 = new Address4('192.168.1.50/24');
assert.strictEqual(v4.correctForm(), '192.168.1.50');
assert.strictEqual(v4.subnet, '/24');
assert.strictEqual(v4.subnetMask, 24);
assert.strictEqual(v4.address, '192.168.1.50/24');
// 3. Address4 calculates startAddress, endAddress, and host boundaries for a given subnet
assert.strictEqual(v4.startAddress().correctForm(), '192.168.1.0');
assert.strictEqual(v4.endAddress().correctForm(), '192.168.1.255');
assert.strictEqual(v4.startAddressExclusive().correctForm(), '192.168.1.1');
assert.strictEqual(v4.endAddressExclusive().correctForm(), '192.168.1.254');
// 4. Address4.isInSubnet determines whether an address belongs to the subnet
const inSubnet4 = new Address4('192.168.1.200/24');
const outSubnet4 = new Address4('192.168.2.1/24');
assert.strictEqual(inSubnet4.isInSubnet(v4), true);
assert.strictEqual(outSubnet4.isInSubnet(v4), false);
// 5. Address4.fromAddressAndMask parses dotted-decimal subnet masks into CIDR prefix length
const fromMask = Address4.fromAddressAndMask('10.0.0.1', '255.255.255.0');
assert.strictEqual(fromMask.subnetMask, 24);
assert.strictEqual(fromMask.correctForm(), '10.0.0.1');
// 6. Address4 bigInt and fromBigInt convert IPv4 addresses to and from 32-bit integers
const bigInt4 = v4.bigInt();
assert.strictEqual(typeof bigInt4, 'bigint');
const restored4 = Address4.fromBigInt(bigInt4);
assert.strictEqual(restored4.correctForm(), '192.168.1.50');
// 7. Address4 fromHex and toHex convert between hex string and Address4
const hex4 = v4.toHex();
const fromHex4 = Address4.fromHex(hex4);
assert.strictEqual(fromHex4.correctForm(), '192.168.1.50');
// 8. Address6.isValid validates valid IPv6 addresses and rejects invalid formats
assert.strictEqual(Address6.isValid('2001:db8::1'), true);
assert.strictEqual(Address6.isValid('::1'), true);
assert.strictEqual(Address6.isValid('2001:db8:::1'), false);
assert.strictEqual(Address6.isValid('invalid-ipv6'), false);
assert.strictEqual(Address6.isValid(''), false);
// 9. Address6 formats canonical and correct compressed representations
const v6 = new Address6('2001:0db8:0000:0000:0000:0000:0000:0001/64');
assert.strictEqual(v6.canonicalForm(), '2001:0db8:0000:0000:0000:0000:0000:0001');
assert.strictEqual(v6.correctForm(), '2001:db8::1');
assert.strictEqual(v6.subnet, '/64');
assert.strictEqual(v6.subnetMask, 64);
// 10. Address6 calculates startAddress, endAddress, and subnet membership for IPv6 subnets
assert.strictEqual(v6.startAddress().correctForm(), '2001:db8::');
assert.strictEqual(v6.endAddress().correctForm(), '2001:db8::ffff:ffff:ffff:ffff');
const inSubnet6 = new Address6('2001:db8::abcd');
const outSubnet6 = new Address6('2001:db9::1');
assert.strictEqual(inSubnet6.isInSubnet(v6), true);
assert.strictEqual(outSubnet6.isInSubnet(v6), false);
// 11. Address6 bigInt and fromBigInt convert IPv6 addresses to and from 128-bit integers
const bigInt6 = v6.bigInt();
assert.strictEqual(typeof bigInt6, 'bigint');
const restored6 = Address6.fromBigInt(bigInt6);
assert.strictEqual(restored6.correctForm(), '2001:db8::1');
// 12. Address6 identifies special address types including loopback, link-local, and multicast
const loopback = new Address6('::1');
const linkLocal = new Address6('fe80::1');
const multicast = new Address6('ff02::1');
assert.strictEqual(loopback.isLoopback(), true);
assert.strictEqual(linkLocal.isLinkLocal(), true);
assert.strictEqual(multicast.isMulticast(), true);
assert.strictEqual(v6.isLoopback(), false);
// 13. Address6 converts IPv4-mapped IPv6 address to Address4 instance via to4 and isMapped4
const v4Mapped = new Address6('::ffff:192.168.1.1');
assert.strictEqual(v4Mapped.is4(), true);
assert.strictEqual(v4Mapped.isMapped4(), true);
const convertedV4 = v4Mapped.to4();
assert.strictEqual(convertedV4 instanceof Address4, true);
assert.strictEqual(convertedV4.correctForm(), '192.168.1.1');
// 14. AddressError creates error instances with proper name and prototype inheritance
const err = new AddressError('Invalid IP format');
assert.strictEqual(err instanceof Error, true);
assert.strictEqual(err instanceof AddressError, true);
assert.strictEqual(err.name, 'AddressError');
assert.strictEqual(err.message, 'Invalid IP format');
console.log('Contract passed');
原始种子者
匿名