Exemple
ip-address 10.7.0: Address6.endAddress, Address6.isInSubnet, Address6.startAddress
Échantillon vérifié pour npm ip-address 10.7.0: Address6.endAddress, Address6.isInSubnet, Address6.startAddress. Le contrat s'est exécuté sur node 22 · linux…
sha256:1f009eb2cee31c0a7e169da15e9fd101907bf7ef4e9da354f8262d0c79916144
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-07 |
Cas
HOW- Objectif
- verify pkg:npm/ip-address@10.7.0
- Paquets
- Symboles
-
- Address6.endAddress
- Address6.isInSubnet
- Address6.startAddress
- Créé
- 2026-09-07T00:35:57Z
Contrat
- Address6.startAddress calculates the first IPv6 network address of a CIDR block and returns an Address6 instance
- Address6.endAddress calculates the final broadcast IPv6 address of a CIDR block and returns an Address6 instance
- Address6.isInSubnet verifies membership of host addresses and nested subnets within a target IPv6 prefix
- Address6 calculates exclusive host boundaries using startAddressExclusive and endAddressExclusive
Fichiers
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/ip-address@10.7.0
Demonstrate these symbols/APIs:
- Address6.endAddress
- Address6.isInSubnet
- Address6.startAddress
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.
{"case":{"caseId":"case:sha256:b500847079c2c3ad227b414a714d157719371dd01e78948589b3afa619ce4f52","contract":["Address6.startAddress calculates the first IPv6 network address of a CIDR block and returns an Address6 instance","Address6.endAddress calculates the final broadcast IPv6 address of a CIDR block and returns an Address6 instance","Address6.isInSubnet verifies membership of host addresses and nested subnets within a target IPv6 prefix","Address6 calculates exclusive host boundaries using startAddressExclusive and endAddressExclusive"],"goal":"verify pkg:npm/ip-address@10.7.0","kind":"HOW","packages":["pkg:npm/ip-address@10.7.0"],"schemaVersion":1,"symbols":["Address6.endAddress","Address6.isInSubnet","Address6.startAddress"]},"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.0"],"schemaVersion":1,"subject":"pkg:npm/ip-address@10.7.0","symbols":["Address6.endAddress","Address6.isInSubnet","Address6.startAddress"],"verifierAdapter":"node-typescript@1"}
import { Address6 } from 'ip-address';
/**
* Calculates the network boundary (start and end addresses) of an IPv6 CIDR block.
* @param {string} cidrString
* @returns {{ startAddress: string, endAddress: string }}
*/
export function getSubnetRange(cidrString) {
const addr = new Address6(cidrString);
return {
startAddress: addr.startAddress().correctForm(),
endAddress: addr.endAddress().correctForm()
};
}
/**
* Calculates the exclusive usable host boundaries of an IPv6 CIDR block.
* @param {string} cidrString
* @returns {{ exclusiveStart: string, exclusiveEnd: string }}
*/
export function getExclusiveSubnetRange(cidrString) {
const addr = new Address6(cidrString);
return {
exclusiveStart: addr.startAddressExclusive().correctForm(),
exclusiveEnd: addr.endAddressExclusive().correctForm()
};
}
/**
* Checks whether an IPv6 candidate (host or subnet) is contained within a target subnet.
* @param {string} candidateString
* @param {string} targetSubnetString
* @returns {boolean}
*/
export function isAddressInSubnet(candidateString, targetSubnetString) {
const candidate = new Address6(candidateString);
const targetSubnet = new Address6(targetSubnetString);
return candidate.isInSubnet(targetSubnet);
}
{
"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.0"
}
},
"node_modules/ip-address": {
"version": "10.7.0",
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.0.tgz",
"integrity": "sha512-BGFsyJd5mpXp3rK6jIdADLNgpJUK1jnjzvYF8lK+VyDab9JAmqN0YOKDdP17HlgKb2+ehPgDc8EtnRLbGCAMhA==",
"license": "MIT",
"engines": {
"node": ">= 12"
}
}
}
}
{
"name": "ip-address-sample",
"version": "1.0.0",
"type": "module",
"license": "MIT-0",
"dependencies": {
"ip-address": "10.7.0"
},
"scripts": {
"test": "node test/contract.mjs"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/ip-address@10.7.0",
"kind": "HOW",
"packages": [
"pkg:npm/ip-address@10.7.0"
],
"symbols": [
"Address6.endAddress",
"Address6.isInSubnet",
"Address6.startAddress"
]
}
import assert from 'node:assert/strict';
import { Address6 } from 'ip-address';
import {
getSubnetRange,
getExclusiveSubnetRange,
isAddressInSubnet
} from '../index.mjs';
// Contract 1: Address6.startAddress calculates the first IPv6 network address of a CIDR block and returns an Address6 instance
{
const subnet64 = new Address6('2001:db8:abcd:0012::1/64');
const start = subnet64.startAddress();
assert.equal(start instanceof Address6, true);
assert.equal(start.correctForm(), '2001:db8:abcd:12::');
assert.equal(start.subnet, '/128');
// Single host (/128)
const host128 = new Address6('2001:db8::1/128');
assert.equal(host128.startAddress().correctForm(), '2001:db8::1');
// Helper function verification
const range = getSubnetRange('2001:db8:ffff::5/48');
assert.equal(range.startAddress, '2001:db8:ffff::');
}
// Contract 2: Address6.endAddress calculates the final broadcast IPv6 address of a CIDR block and returns an Address6 instance
{
const subnet64 = new Address6('2001:db8:abcd:0012::1/64');
const end = subnet64.endAddress();
assert.equal(end instanceof Address6, true);
assert.equal(end.correctForm(), '2001:db8:abcd:12:ffff:ffff:ffff:ffff');
assert.equal(end.subnet, '/128');
// Single host (/128)
const host128 = new Address6('2001:db8::1/128');
assert.equal(host128.endAddress().correctForm(), '2001:db8::1');
// Helper function verification
const range = getSubnetRange('2001:db8:ffff::5/48');
assert.equal(range.endAddress, '2001:db8:ffff:ffff:ffff:ffff:ffff:ffff');
}
// Contract 3: Address6.isInSubnet verifies membership of host addresses and nested subnets within a target IPv6 prefix
{
const parent = new Address6('2001:db8::/32');
const childSubnet = new Address6('2001:db8:1234::/48');
const insideHost = new Address6('2001:db8:ffff:ffff::1/128');
const insideHostWithoutMask = new Address6('2001:db8::42');
const outsideHost = new Address6('2001:db9::1/128');
// Direct Address6 API
assert.equal(childSubnet.isInSubnet(parent), true);
assert.equal(insideHost.isInSubnet(parent), true);
assert.equal(insideHostWithoutMask.isInSubnet(parent), true);
assert.equal(outsideHost.isInSubnet(parent), false);
assert.equal(parent.isInSubnet(childSubnet), false);
// Helper function verification
assert.equal(isAddressInSubnet('2001:db8:abcd::1', '2001:db8::/32'), true);
assert.equal(isAddressInSubnet('fe80::1', '2001:db8::/32'), false);
}
// Contract 4: Address6 calculates exclusive host boundaries using startAddressExclusive and endAddressExclusive
{
const subnet64 = new Address6('2001:db8:abcd:0012::1/64');
const exclusiveStart = subnet64.startAddressExclusive();
const exclusiveEnd = subnet64.endAddressExclusive();
assert.equal(exclusiveStart.correctForm(), '2001:db8:abcd:12::1');
assert.equal(exclusiveEnd.correctForm(), '2001:db8:abcd:12:ffff:ffff:ffff:fffe');
// Helper function verification
const exclusive = getExclusiveSubnetRange('2001:db8:abcd:0012::1/64');
assert.equal(exclusive.exclusiveStart, '2001:db8:abcd:12::1');
assert.equal(exclusive.exclusiveEnd, '2001:db8:abcd:12:ffff:ffff:ffff:fffe');
}
console.log('All contract assertions verified successfully.');
Seeder d'origine
anonyme