CodeSampleX

Sample

ip-address 10.7.3

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

sha256:c8304ae129269c8e05baf0d38db62a7213965958166f4830f35ddda1f74ada5b

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 linux 24 · ubuntu · glibc 2.39 x64 npm

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-03

Case

HOW
Goal
verify pkg:npm/ip-address@10.7.3
Packages
Created
2026-11-03T21:49:09Z

Contract

  1. Address4 parses IPv4 CIDR notation, computes startAddress and endAddress boundaries, and converts to/from BigInt
  2. Address4.prototype.isInSubnet and Address4.isValid check IPv4 subnet membership and syntax validity
  3. Address6 parses IPv6 CIDR notation, formats canonicalForm and correctForm strings, and computes subnet boundaries
  4. Address6.fromAddress4, to4in6, reverseForm, and fromArpa handle IPv4-mapped IPv6 and ip6.arpa reverse DNS
  5. Address4 and Address6 throw AddressError instances when instantiated with invalid address strings

Files

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

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.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/ip-address@10.7.3

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:635441be5c2821d4d61fd41c7126fd6c5196b8ff512d0708ecde863b0980e184","contract":["Address4 parses IPv4 CIDR notation, computes startAddress and endAddress boundaries, and converts to/from BigInt","Address4.prototype.isInSubnet and Address4.isValid check IPv4 subnet membership and syntax validity","Address6 parses IPv6 CIDR notation, formats canonicalForm and correctForm strings, and computes subnet boundaries","Address6.fromAddress4, to4in6, reverseForm, and fromArpa handle IPv4-mapped IPv6 and ip6.arpa reverse DNS","Address4 and Address6 throw AddressError instances when instantiated with invalid address strings"],"goal":"verify pkg:npm/ip-address@10.7.3","kind":"HOW","packages":["pkg:npm/ip-address@10.7.3"],"schemaVersion":1},"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/ip-address@10.7.3"],"schemaVersion":1,"subject":"pkg:npm/ip-address@10.7.3","verifierAdapter":"node-typescript@1"}
index.mjs
import { Address4, Address6, AddressError } from 'ip-address';

export function inspectIpv4Subnet(cidr) {
  const addr = new Address4(cidr);
  return {
    correctForm: addr.correctForm(),
    subnetMask: addr.subnetMask,
    startAddress: addr.startAddress().correctForm(),
    endAddress: addr.endAddress().correctForm(),
    bigInt: addr.bigInt()
  };
}

export function checkIpv4InSubnet(candidate, subnetCidr) {
  const host = new Address4(candidate);
  const net = new Address4(subnetCidr);
  return host.isInSubnet(net);
}

export function inspectIpv6Subnet(cidr) {
  const addr = new Address6(cidr);
  return {
    correctForm: addr.correctForm(),
    canonicalForm: addr.canonicalForm(),
    networkForm: addr.networkForm(),
    startAddress: addr.startAddress().correctForm(),
    endAddress: addr.endAddress().correctForm(),
    subnetMaskAddress: addr.subnetMaskAddress().correctForm(),
    bigInt: addr.bigInt()
  };
}

export function mapIpv4AndReverseIpv6(ipv4Str, ipv6Str) {
  const mapped = Address6.fromAddress4(ipv4Str);
  const v6 = new Address6(ipv6Str);
  const arpa = v6.reverseForm();
  const roundtripArpa = Address6.fromArpa(arpa);
  return {
    mappedCorrect: mapped.correctForm(),
    mapped4in6: mapped.to4in6(),
    arpa,
    roundtripArpa: roundtripArpa.correctForm()
  };
}

export { Address4, Address6, AddressError };
package-lock.json
{
  "name": "ip-address-verify-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "ip-address-verify-sample",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "ip-address": "10.7.3"
      }
    },
    "node_modules/ip-address": {
      "version": "10.7.3",
      "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.3.tgz",
      "integrity": "sha512-A1kdq/tSb5QjvKvAMgIoEvDBIgL7qaqVP/jkvSwYYRZ9iEzvPpopxp2wQfu3SuZRHtpHNxMn8Fs0bS+gf5Xmwg==",
      "license": "MIT",
      "engines": {
        "node": ">= 12"
      }
    }
  }
}
package.json
{
  "name": "ip-address-verify-sample",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "ip-address": "10.7.3"
  },
  "scripts": {
    "test": "node test/contract.mjs"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/ip-address@10.7.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ip-address@10.7.3"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  Address4,
  Address6,
  AddressError,
  inspectIpv4Subnet,
  checkIpv4InSubnet,
  inspectIpv6Subnet,
  mapIpv4AndReverseIpv6
} from '../index.mjs';

// 1. Address4 parses IPv4 CIDR notation, computes start/end boundaries, and converts to/from BigInt
{
  const info = inspectIpv4Subnet('192.168.10.42/24');
  assert.equal(info.correctForm, '192.168.10.42');
  assert.equal(info.subnetMask, 24);
  assert.equal(info.startAddress, '192.168.10.0');
  assert.equal(info.endAddress, '192.168.10.255');
  assert.equal(info.bigInt, 3232238122n);

  const restored4 = Address4.fromBigInt(info.bigInt);
  assert.equal(restored4.correctForm(), '192.168.10.42');

  const masked = Address4.fromAddressAndMask('10.20.30.40', '255.255.0.0');
  assert.equal(masked.correctForm(), '10.20.30.40');
  assert.equal(masked.subnetMask, 16);
}

// 2. Address4.prototype.isInSubnet and Address4.isValid check subnet membership and syntax validity
{
  assert.equal(checkIpv4InSubnet('192.168.10.99', '192.168.10.0/24'), true);
  assert.equal(checkIpv4InSubnet('192.168.11.1', '192.168.10.0/24'), false);
  assert.equal(Address4.isValid('127.0.0.1'), true);
  assert.equal(Address4.isValid('999.0.0.1'), false);
}

// 3. Address6 parses IPv6 CIDR notation, formats canonical/compressed strings, and computes subnet boundaries
{
  const v6 = inspectIpv6Subnet('2001:0db8:0000:0042::0001/64');
  assert.equal(v6.correctForm, '2001:db8:0:42::1');
  assert.equal(v6.canonicalForm, '2001:0db8:0000:0042:0000:0000:0000:0001');
  assert.equal(v6.networkForm, '2001:db8:0:42::/64');
  assert.equal(v6.startAddress, '2001:db8:0:42::');
  assert.equal(v6.endAddress, '2001:db8:0:42:ffff:ffff:ffff:ffff');
  assert.equal(v6.subnetMaskAddress, 'ffff:ffff:ffff:ffff::');

  const restored6 = Address6.fromBigInt(v6.bigInt);
  assert.equal(restored6.correctForm(), '2001:db8:0:42::1');
  assert.equal(new Address6('2001:db8:0:42::cafe').isInSubnet(new Address6('2001:db8:0:42::/64')), true);
  assert.equal(new Address6('2001:db8:0:43::1').isInSubnet(new Address6('2001:db8:0:42::/64')), false);
}

// 4. Address6.fromAddress4, to4in6, reverseForm, and fromArpa handle IPv4-mapped IPv6 and ip6.arpa reverse DNS
{
  const res = mapIpv4AndReverseIpv6('172.16.0.5', '2001:db8::abcd');
  assert.equal(res.mappedCorrect, '::ffff:ac10:5');
  assert.equal(res.mapped4in6, '::ffff:172.16.0.5');
  assert.equal(res.arpa, 'd.c.b.a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.');
  assert.equal(res.roundtripArpa, '2001:db8::abcd');
}

// 5. Address4 and Address6 throw AddressError on invalid address strings
{
  assert.throws(
    () => new Address4('256.300.1.1'),
    (err) => err instanceof AddressError && err.name === 'AddressError'
  );
  assert.throws(
    () => new Address6('2001:::1'),
    (err) => err instanceof AddressError && err.name === 'AddressError' && typeof err.parseMessage === 'string'
  );
}

Origin Seeder

anonymous