CodeSampleX

Ejemplo

pac-resolver 7.0.1: sandbox

Muestra verificada para npm pac-resolver 7.0.1: sandbox. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.

sha256:3204a8245723a63fb325666dafef753006557618253dd27d7b9a888cdc725513

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

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 pac-resolver.sandbox in pkg:npm/pac-resolver@7.0.1
Paquetes
Símbolos
  • pac-resolver.sandbox
Entorno
node 22.23.2
Creado
2026-08-27T11:38:17Z

Contrato

  1. assert sandbox is a frozen object containing standard PAC utility functions
  2. assert isPlainHostName returns true for unqualified hostnames without dots and false for domain names
  3. assert dnsDomainIs returns true when host matches the specified domain suffix
  4. assert dnsDomainLevels returns the count of dots in the host string
  5. assert localHostOrDomainIs matches exact host or unqualified hostname prefix against target domain
  6. assert shExpMatch matches strings using shell wildcard expressions with question marks and asterisks
  7. assert isInNet evaluates whether an IP address belongs to the specified subnet and mask

Archivos

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

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 pac-resolver.sandbox in pkg:npm/pac-resolver@7.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/pac-resolver@7.0.1
Demonstrate these symbols/APIs:
  - pac-resolver.sandbox
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: esm
  - 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.
csx.json
{"case":{"caseId":"case:sha256:4066f1fce274210233d5ea7eb0d4ab79ad05aa4a26e2a46fa8fbeaa233f41e9d","constraints":{"executionContext":"node"},"contract":["assert sandbox is a frozen object containing standard PAC utility functions","assert isPlainHostName returns true for unqualified hostnames without dots and false for domain names","assert dnsDomainIs returns true when host matches the specified domain suffix","assert dnsDomainLevels returns the count of dots in the host string","assert localHostOrDomainIs matches exact host or unqualified hostname prefix against target domain","assert shExpMatch matches strings using shell wildcard expressions with question marks and asterisks","assert isInNet evaluates whether an IP address belongs to the specified subnet and mask"],"goal":"verify pac-resolver.sandbox in pkg:npm/pac-resolver@7.0.1","kind":"HOW","packages":["pkg:npm/pac-resolver@7.0.1"],"schemaVersion":1,"symbols":["pac-resolver.sandbox"]},"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/pac-resolver@7.0.1"],"schemaVersion":1,"subject":"pkg:npm/pac-resolver@7.0.1","symbols":["pac-resolver.sandbox"],"verifierAdapter":"node-typescript@1"}
index.js
import { sandbox } from 'pac-resolver';

export { sandbox };

export function checkPlainHost(host) {
  return sandbox.isPlainHostName(host);
}

export function checkDomainMatch(host, domain) {
  return sandbox.dnsDomainIs(host, domain);
}

export function getDomainLevels(host) {
  return sandbox.dnsDomainLevels(host);
}

export function checkLocalOrDomain(host, hostdom) {
  return sandbox.localHostOrDomainIs(host, hostdom);
}

export function matchPattern(str, pattern) {
  return sandbox.shExpMatch(str, pattern);
}

export async function checkInSubnet(ip, pattern, mask) {
  return await sandbox.isInNet(ip, pattern, mask);
}
package-lock.json
{
  "name": "sample-pac-resolver-sandbox",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-pac-resolver-sandbox",
      "version": "1.0.0",
      "dependencies": {
        "pac-resolver": "7.0.1"
      }
    },
    "node_modules/ast-types": {
      "version": "0.13.4",
      "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz",
      "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==",
      "license": "MIT",
      "dependencies": {
        "tslib": "^2.0.1"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/degenerator": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz",
      "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==",
      "license": "MIT",
      "dependencies": {
        "ast-types": "^0.13.4",
        "escodegen": "^2.1.0",
        "esprima": "^4.0.1"
      },
      "engines": {
        "node": ">= 14"
      }
    },
    "node_modules/escodegen": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz",
      "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==",
      "license": "BSD-2-Clause",
      "dependencies": {
        "esprima": "^4.0.1",
        "estraverse": "^5.2.0",
        "esutils": "^2.0.2"
      },
      "bin": {
        "escodegen": "bin/escodegen.js",
        "esgenerate": "bin/esgenerate.js"
      },
      "engines": {
        "node": ">=6.0"
      },
      "optionalDependencies": {
        "source-map": "~0.6.1"
      }
    },
    "node_modules/esprima": {
      "version": "4.0.1",
      "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
      "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
      "license": "BSD-2-Clause",
      "bin": {
        "esparse": "bin/esparse.js",
        "esvalidate": "bin/esvalidate.js"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/estraverse": {
      "version": "5.3.0",
      "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
      "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=4.0"
      }
    },
    "node_modules/esutils": {
      "version": "2.0.3",
      "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
      "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/netmask": {
      "version": "2.1.1",
      "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.1.1.tgz",
      "integrity": "sha512-eonl3sLUha+S1GzTPxychyhnUzKyeQkZ7jLjKrBagJgPla13F+uQ71HgpFefyHgqrjEbCPkDArxYsjY8/+gLKA==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4.0"
      }
    },
    "node_modules/pac-resolver": {
      "version": "7.0.1",
      "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz",
      "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==",
      "license": "MIT",
      "dependencies": {
        "degenerator": "^5.0.0",
        "netmask": "^2.0.2"
      },
      "engines": {
        "node": ">= 14"
      }
    },
    "node_modules/source-map": {
      "version": "0.6.1",
      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
      "license": "BSD-3-Clause",
      "optional": true,
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/tslib": {
      "version": "2.8.1",
      "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
      "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
      "license": "0BSD"
    }
  }
}
package.json
{
  "name": "sample-pac-resolver-sandbox",
  "version": "1.0.0",
  "description": "Minimal clean-room sample verifying pac-resolver sandbox functions",
  "type": "module",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "pac-resolver": "7.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pac-resolver.sandbox in pkg:npm/pac-resolver@7.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/pac-resolver@7.0.1"
  ],
  "symbols": [
    "pac-resolver.sandbox"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "esm",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert';
import {
  sandbox,
  checkPlainHost,
  checkDomainMatch,
  getDomainLevels,
  checkLocalOrDomain,
  matchPattern,
  checkInSubnet,
} from '../index.js';

// 1. Sandbox structure and immutability
assert.strictEqual(Object.isFrozen(sandbox), true, 'sandbox must be a frozen object');
assert.strictEqual(typeof sandbox.alert, 'function', 'sandbox.alert must be a function');
assert.strictEqual(typeof sandbox.isPlainHostName, 'function', 'sandbox.isPlainHostName must be a function');
assert.strictEqual(typeof sandbox.dnsDomainIs, 'function', 'sandbox.dnsDomainIs must be a function');
assert.strictEqual(typeof sandbox.dnsDomainLevels, 'function', 'sandbox.dnsDomainLevels must be a function');
assert.strictEqual(typeof sandbox.localHostOrDomainIs, 'function', 'sandbox.localHostOrDomainIs must be a function');
assert.strictEqual(typeof sandbox.shExpMatch, 'function', 'sandbox.shExpMatch must be a function');
assert.strictEqual(typeof sandbox.isInNet, 'function', 'sandbox.isInNet must be a function');

// 2. isPlainHostName
assert.strictEqual(checkPlainHost('localhost'), true, 'localhost is a plain hostname');
assert.strictEqual(checkPlainHost('example'), true, 'example without dot is a plain hostname');
assert.strictEqual(checkPlainHost('example.com'), false, 'example.com is not a plain hostname');
assert.strictEqual(checkPlainHost('sub.example.com'), false, 'sub.example.com is not a plain hostname');

// 3. dnsDomainIs
assert.strictEqual(checkDomainMatch('app.example.com', '.example.com'), true, 'app.example.com ends with .example.com');
assert.strictEqual(checkDomainMatch('example.com', '.example.com'), false, 'example.com does not have leading dot in match');
assert.strictEqual(checkDomainMatch('app.example.org', '.example.com'), false, 'mismatched domain must return false');

// 4. dnsDomainLevels
assert.strictEqual(getDomainLevels('localhost'), 0, 'localhost has 0 domain levels');
assert.strictEqual(getDomainLevels('example.com'), 1, 'example.com has 1 domain level');
assert.strictEqual(getDomainLevels('a.b.c.example.com'), 4, 'a.b.c.example.com has 4 domain levels');

// 5. localHostOrDomainIs
assert.strictEqual(checkLocalOrDomain('app.example.com', 'app.example.com'), true, 'exact match returns true');
assert.strictEqual(checkLocalOrDomain('app', 'app.example.com'), true, 'unqualified hostname prefix returns true');
assert.strictEqual(checkLocalOrDomain('other.example.com', 'app.example.com'), false, 'different host returns false');

// 6. shExpMatch
assert.strictEqual(matchPattern('http://example.com/api/v1', '*api*'), true, 'wildcard pattern matches');
assert.strictEqual(matchPattern('http://example.com/img/icon.png', '*.png'), true, 'suffix wildcard matches');
assert.strictEqual(matchPattern('http://example.com/api/v1', '*.html'), false, 'non-matching pattern returns false');

// 7. isInNet
const inNet1 = await checkInSubnet('192.168.1.42', '192.168.1.0', '255.255.255.0');
assert.strictEqual(inNet1, true, '192.168.1.42 is in subnet 192.168.1.0/24');
const inNet2 = await checkInSubnet('10.0.0.1', '192.168.1.0', '255.255.255.0');
assert.strictEqual(inNet2, false, '10.0.0.1 is not in subnet 192.168.1.0/24');

console.log('All pac-resolver.sandbox contract assertions passed.');

Seeder de origen

anónimo