샘플
netmask 2.1.2: ip2long
검증된 샘플 — npm netmask 2.1.2: ip2long. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: ip2long converts dotted-quad IPv4 strings (0.0.0.0…
sha256:0999423696f12df1d2bf676045613ffb056f05acfcf94735bcc948efb1b29873
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-23 |
케이스
HOW- 목표
- verify netmask.ip2long in pkg:npm/netmask@2.1.2
- 패키지
- 심벌
-
- netmask.ip2long
- 환경
- node 22.23.2
- 생성일
- 2026-11-23T16:02:53Z
컨트랙트
- ip2long converts dotted-quad IPv4 strings (0.0.0.0, 127.0.0.1, 192.0.2.1, 255.255.255.255) into unsigned 32-bit integers (0 through 4294967295)
- ip2long supports shorthand 1-, 2-, and 3-part inet_aton IPv4 forms (2130706433, 127.1, 192.0.513)
- ip2long parses hexadecimal (0x/0X) and leading-zero octal octets (0xc0.0x00.0x02.0x01, 0x7F000001, 0177.0.0.1)
- ip2long throws Error('Invalid IP') for out-of-range octets (256.0.0.1), >4 parts (1.2.3.4.5), empty strings, CIDR suffixes (192.0.2.1/24), and trailing invalid octal digits (018.0.0.1)
- ip2long throws Error('empty octet') for invalid leading-zero octets (08.0.0.1), trailing dots (192.0.2.), and IPv6 strings (::1)
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
소스
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 netmask.ip2long in pkg:npm/netmask@2.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/netmask@2.1.2
Demonstrate these symbols/APIs:
- netmask.ip2long
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:bf9cedb3b07fb7830cd2fda6fd09a66fa11b4f68ccb0495423e921df5ad85052","constraints":{"executionContext":"node"},"contract":["ip2long converts dotted-quad IPv4 strings (0.0.0.0, 127.0.0.1, 192.0.2.1, 255.255.255.255) into unsigned 32-bit integers (0 through 4294967295)","ip2long supports shorthand 1-, 2-, and 3-part inet_aton IPv4 forms (2130706433, 127.1, 192.0.513)","ip2long parses hexadecimal (0x/0X) and leading-zero octal octets (0xc0.0x00.0x02.0x01, 0x7F000001, 0177.0.0.1)","ip2long throws Error('Invalid IP') for out-of-range octets (256.0.0.1), \u003e4 parts (1.2.3.4.5), empty strings, CIDR suffixes (192.0.2.1/24), and trailing invalid octal digits (018.0.0.1)","ip2long throws Error('empty octet') for invalid leading-zero octets (08.0.0.1), trailing dots (192.0.2.), and IPv6 strings (::1)"],"goal":"verify netmask.ip2long in pkg:npm/netmask@2.1.2","kind":"HOW","packages":["pkg:npm/netmask@2.1.2"],"schemaVersion":1,"symbols":["netmask.ip2long"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/netmask@2.1.2"],"schemaVersion":1,"subject":"pkg:npm/netmask@2.1.2","symbols":["netmask.ip2long"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-netmask-ip2long",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-netmask-ip2long",
"version": "1.0.0",
"dependencies": {
"netmask": "2.1.2"
}
},
"node_modules/netmask": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/netmask/-/netmask-2.1.2.tgz",
"integrity": "sha512-In/qjEgPWP3EEKRBrATKSHRCcempKN/gUl97rrB1mTreVQfvPGthTJVwNXwbQHtIzzLf1bYyh8M50xpeYk0r6Q==",
"license": "MIT",
"engines": {
"node": ">= 0.4.0"
}
}
}
}
{
"name": "sample-netmask-ip2long",
"version": "1.0.0",
"private": true,
"description": "Verify netmask.ip2long in netmask 2.1.2",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"netmask": "2.1.2"
}
}
{
"schemaVersion": 1,
"goal": "verify netmask.ip2long in pkg:npm/netmask@2.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/netmask@2.1.2"
],
"symbols": [
"netmask.ip2long"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict';
const { ip2long } = require('netmask');
/**
* Convert an IPv4 address string into an unsigned 32-bit integer using netmask.ip2long.
* @param {string} ip
* @returns {number}
*/
function parseIpv4(ip) {
return ip2long(ip);
}
/**
* Compare two IPv4 addresses by their unsigned 32-bit integer values.
* @param {string} a
* @param {string} b
* @returns {number}
*/
function compareIpv4(a, b) {
return ip2long(a) - ip2long(b);
}
module.exports = {
parseIpv4,
compareIpv4,
};
'use strict';
const assert = require('node:assert/strict');
const { ip2long } = require('netmask');
const { parseIpv4, compareIpv4 } = require('../src/index');
// 1. Standard dotted-quad IPv4 addresses convert to unsigned 32-bit integers
assert.equal(ip2long('0.0.0.0'), 0);
assert.equal(ip2long('127.0.0.1'), 2130706433);
assert.equal(ip2long('192.0.2.1'), 3221225985);
assert.equal(ip2long('255.255.255.255'), 4294967295);
assert.equal(parseIpv4('198.51.100.1'), 3325256705);
assert.ok(compareIpv4('192.0.2.1', '203.0.113.1') < 0);
// 2. Shorthand 1-, 2-, and 3-part IPv4 forms are parsed per inet_aton rules
assert.equal(ip2long('2130706433'), 2130706433);
assert.equal(ip2long('127.1'), 2130706433);
assert.equal(ip2long('192.0.513'), 3221225985);
// 3. Hexadecimal (0x/0X) and octal (leading 0) octet encodings are supported
assert.equal(ip2long('0xc0.0x00.0x02.0x01'), 3221225985);
assert.equal(ip2long('0x7F000001'), 2130706433);
assert.equal(ip2long('0177.0.0.1'), 2130706433);
// 4. Invalid inputs, out-of-range octets, CIDR suffixes, and IPv6 addresses throw Error
assert.throws(() => ip2long('256.0.0.1'), { message: 'Invalid IP' });
assert.throws(() => ip2long('1.2.3.4.5'), { message: 'Invalid IP' });
assert.throws(() => ip2long(''), { message: 'Invalid IP' });
assert.throws(() => ip2long('192.0.2.1/24'), { message: 'Invalid IP' });
assert.throws(() => ip2long('018.0.0.1'), { message: 'Invalid IP' });
assert.throws(() => ip2long('08.0.0.1'), { message: 'empty octet' });
assert.throws(() => ip2long('192.0.2.'), { message: 'empty octet' });
assert.throws(() => ip2long('::1'), { message: 'empty octet' });
console.log('PASS: netmask.ip2long contract verified');
오리진 시더
익명