サンプル
ip-address 10.7.0: Address4
検証済みサンプル — npm ip-address 10.7.0: Address4. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: Address4.isValid validates valid IPv4 addresses and…
sha256:80e1525638ded483657815d2a62cb59f67daf2bf33b82c4dbb6ed7612508c74f
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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-07 |
ケース
HOW- ゴール
- verify ip-address.Address4 in pkg:npm/ip-address@10.7.0
- パッケージ
- シンボル
-
- ip-address.Address4
- 環境
- node 22.23.2
- 作成日
- 2026-09-07T00:54:40Z
コントラクト
- Address4.isValid validates valid IPv4 addresses and rejects invalid strings
- Address4 constructor parses IPv4 address and CIDR subnet mask correctly
- Address4 calculates startAddress and endAddress for a given subnet
- Address4.isInSubnet determines whether an address belongs to a specified subnet
- Address4.fromAddressAndMask parses dotted-decimal subnet masks into CIDR prefix length
- Address4 bigInt and fromBigInt convert IPv4 addresses to and from BigInt representations
- Address4 correctForm returns the normalized dotted-decimal IP address string
- Address4 throws AddressError when instantiated with an invalid IP address string
ファイル
- 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 ip-address.Address4 in pkg:npm/ip-address@10.7.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/ip-address@10.7.0
Demonstrate these symbols/APIs:
- ip-address.Address4
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:6ae76167af7bb9e72e4060f1cc21ed1eb81281092aafc9a0edee5bc85b4cc2a7","constraints":{"executionContext":"node"},"contract":["Address4.isValid validates valid IPv4 addresses and rejects invalid strings","Address4 constructor parses IPv4 address and CIDR subnet mask correctly","Address4 calculates startAddress and endAddress for a given subnet","Address4.isInSubnet determines whether an address belongs to a specified subnet","Address4.fromAddressAndMask parses dotted-decimal subnet masks into CIDR prefix length","Address4 bigInt and fromBigInt convert IPv4 addresses to and from BigInt representations","Address4 correctForm returns the normalized dotted-decimal IP address string","Address4 throws AddressError when instantiated with an invalid IP address string"],"goal":"verify ip-address.Address4 in pkg:npm/ip-address@10.7.0","kind":"HOW","packages":["pkg:npm/ip-address@10.7.0"],"schemaVersion":1,"symbols":["ip-address.Address4"]},"contractCommand":["node","test/contract.cjs"],"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/ip-address@10.7.0"],"schemaVersion":1,"subject":"pkg:npm/ip-address@10.7.0","symbols":["ip-address.Address4"],"verifierAdapter":"node-typescript@1"}
{
"name": "ip-address-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ip-address-sample",
"version": "1.0.0",
"dependencies": {
"ip-address": "10.7.0"
}
},
"node_modules/ip-address": {
"version": "10.7.0",
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.0.tgz",
"integrity": "sha512-BGFsyJd5mpXp3rK6jIdADLNgpJUK1jnjzvYF8lK+VyDab9JAmqN0YOKDdP17HlgKb2+ehPgDc8EtnRLbGCAMhA==",
"license": "MIT",
"engines": {
"node": ">= 12"
}
}
}
}
{
"name": "ip-address-sample",
"version": "1.0.0",
"private": true,
"description": "Verification sample for ip-address 10.7.0",
"dependencies": {
"ip-address": "10.7.0"
}
}
{
"schemaVersion": 1,
"goal": "verify ip-address.Address4 in pkg:npm/ip-address@10.7.0",
"kind": "HOW",
"packages": [
"pkg:npm/ip-address@10.7.0"
],
"symbols": [
"ip-address.Address4"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const assert = require("node:assert/strict");
const { Address4, AddressError } = require("ip-address");
// 1. Address4.isValid validates valid IPv4 addresses and rejects invalid strings
assert.equal(Address4.isValid("192.168.1.100"), true);
assert.equal(Address4.isValid("10.0.0.1"), true);
assert.equal(Address4.isValid("127.0.0.1"), true);
assert.equal(Address4.isValid("999.1.1.1"), false);
assert.equal(Address4.isValid("256.0.0.1"), false);
assert.equal(Address4.isValid("invalid-ip"), false);
assert.equal(Address4.isValid(""), false);
// 2. Address4 constructor parses IPv4 address and CIDR subnet mask correctly
const ipv4 = new Address4("192.168.1.100/24");
assert.equal(ipv4.address, "192.168.1.100/24");
assert.equal(ipv4.subnet, "/24");
assert.equal(ipv4.subnetMask, 24);
assert.deepEqual(ipv4.parsedAddress, ["192", "168", "1", "100"]);
// 3. Address4 calculates startAddress and endAddress for a given subnet
assert.equal(ipv4.startAddress().correctForm(), "192.168.1.0");
assert.equal(ipv4.endAddress().correctForm(), "192.168.1.255");
// 4. Address4.isInSubnet determines whether an address belongs to a specified subnet
const member4 = new Address4("192.168.1.50");
const nonMember4 = new Address4("192.168.2.1");
assert.equal(member4.isInSubnet(ipv4), true);
assert.equal(nonMember4.isInSubnet(ipv4), false);
// 5. Address4.fromAddressAndMask parses dotted-decimal subnet masks into CIDR prefix length
const v4FromMask = Address4.fromAddressAndMask("10.0.0.1", "255.255.0.0");
assert.equal(v4FromMask.subnetMask, 16);
assert.equal(v4FromMask.startAddress().correctForm(), "10.0.0.0");
assert.equal(v4FromMask.endAddress().correctForm(), "10.0.255.255");
// 6. Address4 bigInt and fromBigInt convert IPv4 addresses to and from BigInt representations
const v4BigInt = ipv4.bigInt();
assert.equal(typeof v4BigInt, "bigint");
assert.equal(Address4.fromBigInt(v4BigInt).correctForm(), "192.168.1.100");
// 7. Address4 correctForm returns the normalized dotted-decimal IP address string
const addrWithSubnet = new Address4("192.168.1.1/24");
assert.equal(addrWithSubnet.correctForm(), "192.168.1.1");
assert.equal(addrWithSubnet.isCorrect(), true);
const plainAddr = new Address4("10.0.0.1");
assert.equal(plainAddr.correctForm(), "10.0.0.1");
// 8. Address4 throws AddressError when instantiated with an invalid IP address string
assert.throws(
() => new Address4("not-an-ip"),
(err) => {
return err instanceof AddressError || err.name === "AddressError" || /Invalid/i.test(err.message);
}
);
assert.throws(
() => new Address4("300.1.1.1"),
(err) => {
return err instanceof AddressError || err.name === "AddressError" || /Invalid/i.test(err.message);
}
);
assert.throws(
() => new Address4("192.168.001.001"),
(err) => {
return err instanceof AddressError || err.name === "AddressError" || /zeroes/i.test(err.message);
}
);
console.log("Contract verified successfully.");
オリジンシーダー
匿名