CodeSampleX

サンプル

ip-address 10.1.0: Address6

検証済みサンプル — npm ip-address 10.1.0: Address6. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: Address6.isValid validates valid IPv6 addresses and…

sha256:98cd6e828e7b405a3e3c762c296d11e51fe7e79d3806e9c461474e16a3862d85

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。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-21

ケース

HOW
ゴール
verify ip-address.Address6 in pkg:npm/ip-address@10.1.0
パッケージ
シンボル
  • ip-address.Address6
環境
node 22.23.2
作成日
2026-09-21T05:15:09Z

コントラクト

  1. Address6.isValid validates valid IPv6 addresses and rejects invalid strings
  2. Address6 constructor parses IPv6 address and CIDR subnet mask correctly
  3. Address6 formats canonical and correct compressed representations
  4. Address6 calculates startAddress, endAddress, and subnet membership for IPv6 subnets
  5. Address6 bigInt and fromBigInt convert IPv6 addresses to and from BigInt representations
  6. Address6 identifies special address types including loopback, link-local, multicast, and unspecified
  7. Address6.fromAddress4 creates IPv4-mapped IPv6 address and converts back via to4
  8. Address6 throws AddressError when instantiated with an invalid IP address string

ファイル

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

ソースアーティファクトをダウンロード (tar.gz)

ソース

PROMPT.md
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.Address6 in pkg:npm/ip-address@10.1.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/ip-address@10.1.0
Demonstrate these symbols/APIs:
  - ip-address.Address6

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.
csx.json
{"case":{"caseId":"case:sha256:da206a013a29064efd2ff86e1b8f2e5c1a0f5405fa89cf7eec8f210d33cebe2d","contract":["Address6.isValid validates valid IPv6 addresses and rejects invalid strings","Address6 constructor parses IPv6 address and CIDR subnet mask correctly","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 BigInt representations","Address6 identifies special address types including loopback, link-local, multicast, and unspecified","Address6.fromAddress4 creates IPv4-mapped IPv6 address and converts back via to4","Address6 throws AddressError when instantiated with an invalid IP address string"],"goal":"verify ip-address.Address6 in pkg:npm/ip-address@10.1.0","kind":"HOW","packages":["pkg:npm/ip-address@10.1.0"],"schemaVersion":1,"symbols":["ip-address.Address6"]},"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.1.0"],"schemaVersion":1,"subject":"pkg:npm/ip-address@10.1.0","symbols":["ip-address.Address6"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "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.1.0"
      }
    },
    "node_modules/ip-address": {
      "version": "10.1.0",
      "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz",
      "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==",
      "license": "MIT",
      "engines": {
        "node": ">= 12"
      }
    }
  }
}
package.json
{
  "name": "ip-address-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Verification sample for ip-address 10.1.0",
  "dependencies": {
    "ip-address": "10.1.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify ip-address.Address6 in pkg:npm/ip-address@10.1.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ip-address@10.1.0"
  ],
  "symbols": [
    "ip-address.Address6"
  ]
}
test/contract.cjs
const assert = require("node:assert/strict");
const { Address6, AddressError } = require("ip-address");

// 1. Address6.isValid validates valid IPv6 addresses and rejects invalid strings
assert.equal(Address6.isValid("2001:db8::1"), true);
assert.equal(Address6.isValid("::1"), true);
assert.equal(Address6.isValid("fe80::1"), true);
assert.equal(Address6.isValid("2001:0db8:85a3:0000:0000:8a2e:0370:7334"), true);
assert.equal(Address6.isValid("2001:::1"), false);
assert.equal(Address6.isValid("invalid-ipv6"), false);
assert.equal(Address6.isValid(""), false);

// 2. Address6 constructor parses IPv6 address and CIDR subnet mask correctly
const ipv6 = new Address6("2001:0db8:85a3:0000:0000:8a2e:0370:7334/64");
assert.equal(ipv6.address, "2001:0db8:85a3:0000:0000:8a2e:0370:7334/64");
assert.equal(ipv6.subnet, "/64");
assert.equal(ipv6.subnetMask, 64);
assert.deepEqual(ipv6.parsedAddress, ["2001", "db8", "85a3", "0", "0", "8a2e", "370", "7334"]);

// 3. Address6 formats canonical and correct compressed representations
assert.equal(ipv6.canonicalForm(), "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
assert.equal(ipv6.correctForm(), "2001:db8:85a3::8a2e:370:7334");
assert.equal(new Address6("2001:db8:85a3::8a2e:370:7334").isCorrect(), true);

// 4. Address6 calculates startAddress, endAddress, and subnet membership for IPv6 subnets
assert.equal(ipv6.startAddress().correctForm(), "2001:db8:85a3::");
assert.equal(ipv6.endAddress().correctForm(), "2001:db8:85a3:0:ffff:ffff:ffff:ffff");
const member = new Address6("2001:db8:85a3::1");
const nonMember = new Address6("2001:db8:85a4::1");
assert.equal(member.isInSubnet(ipv6), true);
assert.equal(nonMember.isInSubnet(ipv6), false);

// 5. Address6 bigInt and fromBigInt convert IPv6 addresses to and from BigInt representations
const bi = ipv6.bigInt();
assert.equal(typeof bi, "bigint");
assert.equal(Address6.fromBigInt(bi).correctForm(), "2001:db8:85a3::8a2e:370:7334");

// 6. Address6 identifies special address types including loopback, link-local, multicast, and unspecified
assert.equal(new Address6("::1").isLoopback(), true);
assert.equal(new Address6("fe80::1").isLinkLocal(), true);
assert.equal(new Address6("ff00::1").isMulticast(), true);
assert.equal(new Address6("::").getType(), "Unspecified");
assert.equal(new Address6("2001::1").isTeredo(), true);
assert.equal(new Address6("2002::1").is6to4(), true);

// 7. Address6.fromAddress4 creates IPv4-mapped IPv6 address and converts back via to4
const v4Mapped = Address6.fromAddress4("192.168.1.1");
assert.equal(v4Mapped.is4(), true);
assert.equal(v4Mapped.correctForm(), "::ffff:c0a8:101");
assert.equal(v4Mapped.to4in6(), "::ffff:192.168.1.1");
const backTo4 = v4Mapped.to4();
assert.equal(backTo4.correctForm(), "192.168.1.1");

// 8. Address6 throws AddressError when instantiated with an invalid IP address string
assert.throws(
  () => new Address6("invalid-ipv6"),
  (err) => err instanceof AddressError || err.name === "AddressError" || /Invalid/i.test(err.message)
);
assert.throws(
  () => new Address6("2001:::1"),
  (err) => err instanceof AddressError || err.name === "AddressError" || /Invalid/i.test(err.message)
);

console.log("Contract verified successfully.");

オリジンシーダー

匿名