CodeSampleX

Sample

ip-address 10.7.6

Verified sample for npm ip-address 10.7.6. The contract ran on node 22 · linux debian/x64 · docker and passed: Address4 parses IPv4 CIDR notation, computes…

sha256:462f2641f38ec635f06e89bddc077b7c1fdbbd40cf9ba192be120d620ca5e944

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
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-11-21

Case

HOW
Goal
verify pkg:npm/ip-address@10.7.6
Packages
Environment
node 22.23.2
Created
2026-11-21T17:37:17Z

Contract

  1. Address4 parses IPv4 CIDR notation, computes networkForm, startAddress, endAddress, subnetMaskAddress, wildcardMask, offset, nextNetwork, and round-trips BigInt and in-addr.arpa forms
  2. Address4.fromAddressAndMask and Address4.fromAddressAndWildcardMask derive CIDR prefix lengths from dotted-decimal and wildcard masks
  3. Address4.isInSubnet and Address4.isHostInSubnet distinguish subnet-aware containment from host-only containment
  4. Address6 parses IPv6 CIDR notation, formats RFC 5952 correctForm and expanded canonicalForm, computes subnet boundaries and nextNetwork, and round-trips BigInt and ip6.arpa forms
  5. Address6.fromAddress4, to4in6, isMapped4, embeddedIPv4, fromAddress4Nat64, and toAddress4Nat64 handle IPv4-mapped IPv6 and RFC 6052 NAT64 conversions
  6. Address4 and Address6 classifiers (isPrivate, isLoopback, isDocumentation, isGlobal) classify native and embedded IPv4-mapped addresses
  7. Address4, Address6, and Address4.fromAddressAndMask throw AddressError on malformed addresses or non-contiguous masks

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

Download the source artifact (tar.gz)

Source

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 pkg:npm/ip-address@10.7.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/ip-address@10.7.6
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.
csx.json
{"case":{"caseId":"case:sha256:59600bd2296e671b372ea98b92607e5db86b8ad736e94e2d7d651eaf5a17229b","constraints":{"executionContext":"node"},"contract":["Address4 parses IPv4 CIDR notation, computes networkForm, startAddress, endAddress, subnetMaskAddress, wildcardMask, offset, nextNetwork, and round-trips BigInt and in-addr.arpa forms","Address4.fromAddressAndMask and Address4.fromAddressAndWildcardMask derive CIDR prefix lengths from dotted-decimal and wildcard masks","Address4.isInSubnet and Address4.isHostInSubnet distinguish subnet-aware containment from host-only containment","Address6 parses IPv6 CIDR notation, formats RFC 5952 correctForm and expanded canonicalForm, computes subnet boundaries and nextNetwork, and round-trips BigInt and ip6.arpa forms","Address6.fromAddress4, to4in6, isMapped4, embeddedIPv4, fromAddress4Nat64, and toAddress4Nat64 handle IPv4-mapped IPv6 and RFC 6052 NAT64 conversions","Address4 and Address6 classifiers (isPrivate, isLoopback, isDocumentation, isGlobal) classify native and embedded IPv4-mapped addresses","Address4, Address6, and Address4.fromAddressAndMask throw AddressError on malformed addresses or non-contiguous masks"],"goal":"verify pkg:npm/ip-address@10.7.6","kind":"HOW","packages":["pkg:npm/ip-address@10.7.6"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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.6"],"schemaVersion":1,"subject":"pkg:npm/ip-address@10.7.6","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",
      "license": "MIT-0",
      "dependencies": {
        "ip-address": "10.7.6"
      }
    },
    "node_modules/ip-address": {
      "version": "10.7.6",
      "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.6.tgz",
      "integrity": "sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg==",
      "license": "MIT",
      "engines": {
        "node": ">= 12"
      }
    }
  }
}
package.json
{
  "name": "ip-address-sample",
  "version": "1.0.0",
  "private": true,
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "ip-address": "10.7.6"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/ip-address@10.7.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ip-address@10.7.6"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const { Address4, Address6, AddressError } = require('ip-address');

function inspectIPv4(cidr) {
  const addr = new Address4(cidr);
  return {
    correct: addr.correctForm(),
    network: addr.networkForm(),
    subnetMask: addr.subnetMask,
    maskAddress: addr.subnetMaskAddress().correctForm(),
    wildcardMask: addr.wildcardMask().correctForm(),
    start: addr.startAddress().correctForm(),
    end: addr.endAddress().correctForm(),
    nextNetwork: addr.nextNetwork().networkForm(),
    reverse: addr.reverseForm(),
    value: addr.bigInt(),
  };
}

function inspectIPv6(cidr) {
  const addr = new Address6(cidr);
  return {
    correct: addr.correctForm(),
    canonical: addr.canonicalForm(),
    network: addr.networkForm(),
    subnetMask: addr.subnetMask,
    start: addr.startAddress().correctForm(),
    end: addr.endAddress().correctForm(),
    nextNetwork: addr.nextNetwork().networkForm(),
    reverse: addr.reverseForm(),
    value: addr.bigInt(),
  };
}

function classifyAddress(input) {
  const addr = Address4.isValid(input) ? new Address4(input) : new Address6(input);
  return {
    isPrivate: addr.isPrivate(),
    isLoopback: addr.isLoopback(),
    isDocumentation: addr.isDocumentation(),
    isGlobal: addr.isGlobal(),
  };
}

module.exports = {
  Address4,
  Address6,
  AddressError,
  inspectIPv4,
  inspectIPv6,
  classifyAddress,
};
test/contract.js
'use strict';

const assert = require('node:assert/strict');
const {
  Address4,
  Address6,
  AddressError,
  inspectIPv4,
  inspectIPv6,
  classifyAddress,
} = require('../src/index.js');

// 1. IPv4 CIDR parsing, boundaries, masks, stepping, reverse ARPA, and BigInt round-trip
assert.equal(Address4.isValid('192.0.2.42/24'), true);
assert.equal(Address4.isValid('999.0.0.1'), false);

const v4 = inspectIPv4('192.0.2.42/24');
assert.equal(v4.correct, '192.0.2.42');
assert.equal(v4.network, '192.0.2.0/24');
assert.equal(v4.subnetMask, 24);
assert.equal(v4.maskAddress, '255.255.255.0');
assert.equal(v4.wildcardMask, '0.0.0.255');
assert.equal(v4.start, '192.0.2.0');
assert.equal(v4.end, '192.0.2.255');
assert.equal(v4.nextNetwork, '192.0.3.0/24');
assert.equal(v4.reverse, '42.2.0.192.in-addr.arpa.');
assert.equal(Address4.fromBigInt(v4.value).correctForm(), '192.0.2.42');
assert.equal(Address4.fromArpa(v4.reverse).correctForm(), '192.0.2.42');
assert.equal(Address4.fromAddressAndMask('192.0.2.42', '255.255.255.0').subnetMask, 24);
assert.equal(Address4.fromAddressAndWildcardMask('192.0.2.42', '0.0.0.255').subnetMask, 24);
assert.equal(new Address4('192.0.2.42/24').offset(1).correctForm(), '192.0.2.43');

// 2. IPv4 subnet containment: isInSubnet vs isHostInSubnet
const v4Subnet = new Address4('192.0.2.0/24');
assert.equal(new Address4('192.0.2.42/28').isInSubnet(v4Subnet), true);
assert.equal(new Address4('192.0.2.42/16').isInSubnet(v4Subnet), false);
assert.equal(new Address4('192.0.2.42/16').isHostInSubnet(v4Subnet), true);
assert.equal(new Address4('198.51.100.1').isHostInSubnet(v4Subnet), false);

// 3. IPv6 CIDR parsing, RFC 5952 formatting, boundaries, reverse ARPA, and BigInt round-trip
assert.equal(Address6.isValid('2001:0db8::1/64'), true);
assert.equal(Address6.isValid('2001:db8:::1'), false);

const v6 = inspectIPv6('2001:0db8::1/64');
assert.equal(v6.correct, '2001:db8::1');
assert.equal(v6.canonical, '2001:0db8:0000:0000:0000:0000:0000:0001');
assert.equal(v6.network, '2001:db8::/64');
assert.equal(v6.subnetMask, 64);
assert.equal(v6.start, '2001:db8::');
assert.equal(v6.end, '2001:db8::ffff:ffff:ffff:ffff');
assert.equal(v6.nextNetwork, '2001:db8:0:1::/64');
assert.equal(Address6.fromBigInt(v6.value).correctForm(), '2001:db8::1');
assert.equal(Address6.fromArpa('8.b.d.0.1.0.0.2.ip6.arpa.').networkForm(), '2001:db8::/32');
assert.equal(new Address6('2001:db8::1').isHostInSubnet(new Address6('2001:db8::/32')), true);

// 4. IPv4-mapped IPv6 and RFC 6052 NAT64 round-trips plus embedded IPv4 classification
const mapped = Address6.fromAddress4('192.0.2.33');
assert.equal(mapped.correctForm(), '::ffff:c000:221');
assert.equal(mapped.to4in6(), '::ffff:192.0.2.33');
assert.equal(mapped.isMapped4(), true);
assert.equal(mapped.embeddedIPv4().correctForm(), '192.0.2.33');

const nat64 = Address6.fromAddress4Nat64('192.0.2.33');
assert.equal(nat64.correctForm(), '64:ff9b::c000:221');
assert.equal(nat64.toAddress4Nat64().correctForm(), '192.0.2.33');

const mappedPrivate = new Address6('::ffff:10.0.0.1');
assert.equal(mappedPrivate.isPrivate(), true);
assert.equal(mappedPrivate.isGlobal(), false);

// 5. Special-purpose address classifiers
assert.deepEqual(classifyAddress('192.0.2.1'), {
  isPrivate: false,
  isLoopback: false,
  isDocumentation: true,
  isGlobal: false,
});
assert.deepEqual(classifyAddress('10.0.0.1'), {
  isPrivate: true,
  isLoopback: false,
  isDocumentation: false,
  isGlobal: false,
});
assert.deepEqual(classifyAddress('127.0.0.1'), {
  isPrivate: false,
  isLoopback: true,
  isDocumentation: false,
  isGlobal: false,
});
assert.deepEqual(classifyAddress('2001:db8::1'), {
  isPrivate: false,
  isLoopback: false,
  isDocumentation: true,
  isGlobal: false,
});

// 6. Invalid inputs and non-contiguous masks throw AddressError
assert.throws(() => new Address4('999.0.0.1'), AddressError);
assert.throws(() => new Address6('2001:db8:::1'), AddressError);
assert.throws(
  () => Address4.fromAddressAndMask('192.0.2.1', '255.0.255.0'),
  AddressError
);

console.log('contract passed');

Origin Seeder

anonymous