CodeSampleX

Beispiel

ipaddr.js 2.5.0

Verifiziertes Beispiel für npm ipaddr.js 2.5.0. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: ipaddr.isValid validates IPv4 and IPv6…

sha256:0f7933f1d1fd913f0a4ec87695dc763bb2f85e688557d6206330a944a86134b9

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-13

Fall

HOW
Ziel
verify pkg:npm/ipaddr.js@2.5.0
Pakete
Umgebung
node 22.23.2
Erstellt
2026-09-13T13:47:47Z

Contract

  1. ipaddr.isValid validates IPv4 and IPv6 string formats
  2. ipaddr.IPv4.isValid and ipaddr.IPv6.isValid validate specific IP versions
  3. ipaddr.parse parses IPv4 address into object with kind ipv4, octets array, and private range
  4. ipaddr.parse parses IPv6 address into object with kind ipv6 and normalized string representation
  5. ipaddr.parseCIDR and match evaluate CIDR subnet membership
  6. ipaddr.process correctly processes IPv4-mapped IPv6 addresses to IPv4
  7. ipaddr.parse throws error on invalid IP format

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/ipaddr.js@2.5.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/ipaddr.js@2.5.0

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:590c39798283d12328b46a133d3fd23c61af87c7d3a8b3f995f5bf9e2638592a","contract":["ipaddr.isValid validates IPv4 and IPv6 string formats","ipaddr.IPv4.isValid and ipaddr.IPv6.isValid validate specific IP versions","ipaddr.parse parses IPv4 address into object with kind ipv4, octets array, and private range","ipaddr.parse parses IPv6 address into object with kind ipv6 and normalized string representation","ipaddr.parseCIDR and match evaluate CIDR subnet membership","ipaddr.process correctly processes IPv4-mapped IPv6 addresses to IPv4","ipaddr.parse throws error on invalid IP format"],"goal":"verify pkg:npm/ipaddr.js@2.5.0","kind":"HOW","packages":["pkg:npm/ipaddr.js@2.5.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/ipaddr.js@2.5.0"],"schemaVersion":1,"subject":"pkg:npm/ipaddr.js@2.5.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "ipaddr-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "ipaddr-verification",
      "version": "1.0.0",
      "dependencies": {
        "ipaddr.js": "2.5.0"
      }
    },
    "node_modules/ipaddr.js": {
      "version": "2.5.0",
      "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.5.0.tgz",
      "integrity": "sha512-aq+t5NAc+cS6rZQQVWC2x98CPqGtKKTMDd4Gaodv0wShnItdKg/51djkGJ1hqH+Oy0ivDftCbSLCQob8zso01w==",
      "license": "MIT",
      "engines": {
        "node": ">= 10"
      }
    }
  }
}
package.json
{
  "name": "ipaddr-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for ipaddr.js",
  "dependencies": {
    "ipaddr.js": "2.5.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/ipaddr.js@2.5.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ipaddr.js@2.5.0"
  ]
}
test/contract.mjs
import assert from "node:assert";
import ipaddr from "ipaddr.js";

// 1. Validate IP address strings
assert.strictEqual(ipaddr.isValid("127.0.0.1"), true);
assert.strictEqual(ipaddr.isValid("2001:db8::1"), true);
assert.strictEqual(ipaddr.isValid("not-an-ip"), false);

// 2. Validate specific IP version strings
assert.strictEqual(ipaddr.IPv4.isValid("127.0.0.1"), true);
assert.strictEqual(ipaddr.IPv4.isValid("2001:db8::1"), false);
assert.strictEqual(ipaddr.IPv6.isValid("2001:db8::1"), true);
assert.strictEqual(ipaddr.IPv6.isValid("127.0.0.1"), false);

// 3. IPv4 address parsing and attributes
const v4 = ipaddr.parse("192.168.1.1");
assert.strictEqual(v4.kind(), "ipv4");
assert.strictEqual(v4.toString(), "192.168.1.1");
assert.deepStrictEqual(v4.octets, [192, 168, 1, 1]);
assert.strictEqual(v4.range(), "private");

// 4. IPv6 address parsing and attributes
const v6 = ipaddr.parse("2001:db8::1");
assert.strictEqual(v6.kind(), "ipv6");
assert.strictEqual(v6.toNormalizedString(), "2001:db8:0:0:0:0:0:1");
assert.strictEqual(v6.range(), "reserved");

// 5. CIDR parsing and matching
const cidr = ipaddr.parseCIDR("192.168.1.0/24");
assert.strictEqual(cidr[0].toString(), "192.168.1.0");
assert.strictEqual(cidr[1], 24);
assert.strictEqual(v4.match(cidr), true);
assert.strictEqual(v4.match(ipaddr.parseCIDR("10.0.0.0/8")), false);

// 6. IPv4-mapped IPv6 processing
const mapped = ipaddr.process("::ffff:192.168.1.1");
assert.strictEqual(mapped.kind(), "ipv4");
assert.strictEqual(mapped.toString(), "192.168.1.1");

// 7. Error handling for invalid inputs
assert.throws(() => ipaddr.parse("invalid-ip"), /neither IPv6 nor IPv4 format/);

console.log("Contract passed");

Ursprungs-Seeder

anonym