Пример
ip-address 10.7.0: Address6.endAddress, Address6.isInSubnet, Address6.startAddress
Проверенный пример — npm ip-address 10.7.0: Address6.endAddress, Address6.isInSubnet, Address6.startAddress. Контракт выполнен на node 22 · linux debian/x64…
sha256:1f009eb2cee31c0a7e169da15e9fd101907bf7ef4e9da354f8262d0c79916144
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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 |
Кейс
HOW- Цель
- verify pkg:npm/ip-address@10.7.0
- Пакеты
- Символы
-
- Address6.endAddress
- Address6.isInSubnet
- Address6.startAddress
- Создан
- 2026-09-07T00:35:57Z
Контракт
- 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
Файлы
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Исходный код
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.');
Исходный сидер
аноним