CodeSampleX

Ejemplo

ip-address 10.3.1

Muestra verificada para npm ip-address 10.3.1. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: Address4.isValid validates valid IPv4…

sha256:f90ef8b5d23eb0c70e57a21d25884410cf964976e9d8ab195c339f746d6388c0

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify pkg:npm/ip-address@10.3.1
Paquetes
Creado
2026-08-27T22:12:58Z

Contrato

  1. Address4.isValid validates valid IPv4 addresses and rejects invalid strings
  2. Address4 parses IPv4 address and CIDR subnet mask correctly
  3. Address4 calculates startAddress, endAddress, and host boundaries for a given subnet
  4. Address4.isInSubnet determines whether an address belongs to the subnet
  5. Address4.fromAddressAndMask parses dotted-decimal subnet masks into CIDR prefix length
  6. Address4 bigInt and fromBigInt convert IPv4 addresses to and from 32-bit integers
  7. Address4 fromHex and toHex convert between hex string and Address4
  8. Address6.isValid validates valid IPv6 addresses and rejects invalid formats
  9. Address6 formats canonical and correct compressed representations
  10. Address6 calculates startAddress, endAddress, and subnet membership for IPv6 subnets
  11. Address6 bigInt and fromBigInt convert IPv6 addresses to and from 128-bit integers
  12. Address6 identifies special address types including loopback, link-local, and multicast
  13. Address6 converts IPv4-mapped IPv6 address to Address4 instance via to4 and isMapped4
  14. AddressError creates error instances with proper name and prototype inheritance

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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.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.
csx.json
{"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"}
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "name": "ip-address-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for ip-address",
  "dependencies": {
    "ip-address": "10.3.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/ip-address@10.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ip-address@10.3.1"
  ]
}
test/contract.cjs
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');

Seeder de origen

anónimo