CodeSampleX

샘플

bare-dns 2.1.4

검증된 샘플 — npm bare-dns 2.1.4. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: package manifest specifies Bare native addon configuration…

sha256:17170efe4104817bc48707db11c58217e163fbae1a0a00bce4ca2fbc2aeedde7

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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-26
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/bare-dns@2.1.4
패키지
환경
node 22.23.2
생성일
2026-08-26T14:00:23Z

컨트랙트

  1. package manifest specifies Bare native addon configuration, Apache-2.0 license, and exports for root and package subpaths
  2. declares complete TypeScript definitions for DNS lookup, resolveTxt, and DNSResolver class in index.d.ts
  3. implements DNS lookup parameter normalization and resolver delegation in index.js
  4. implements native c-ares DNS resolver and lookup binding in binding.c with CMakeLists.txt build configuration
  5. provides multi-platform precompiled .bare addon binaries across Linux, Darwin, Windows, iOS, and Android targets

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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/bare-dns@2.1.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/bare-dns@2.1.4
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.
csx.json
{"case":{"caseId":"case:sha256:35d7e6e7c4c165cadfad589ef2c27d77d338a8736bb81f0c0e07d49ce580d9e1","constraints":{"executionContext":"node"},"contract":["package manifest specifies Bare native addon configuration, Apache-2.0 license, and exports for root and package subpaths","declares complete TypeScript definitions for DNS lookup, resolveTxt, and DNSResolver class in index.d.ts","implements DNS lookup parameter normalization and resolver delegation in index.js","implements native c-ares DNS resolver and lookup binding in binding.c with CMakeLists.txt build configuration","provides multi-platform precompiled .bare addon binaries across Linux, Darwin, Windows, iOS, and Android targets"],"goal":"verify pkg:npm/bare-dns@2.1.4","kind":"HOW","packages":["pkg:npm/bare-dns@2.1.4"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/bare-dns@2.1.4"],"schemaVersion":1,"subject":"pkg:npm/bare-dns@2.1.4","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-bare-dns",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-bare-dns",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "bare-dns": "2.1.4"
      }
    },
    "node_modules/bare-dns": {
      "version": "2.1.4",
      "resolved": "https://registry.npmjs.org/bare-dns/-/bare-dns-2.1.4.tgz",
      "integrity": "sha512-abwjHmpWqSRNB7V5615QxPH92L71AVzFm/kKTs8VYiNTAi2xVdonpv0BjJ0hwXLwomoW+xsSOPjW6PZPO14asg==",
      "license": "Apache-2.0",
      "engines": {
        "bare": ">=1.7.0"
      }
    }
  }
}
package.json
{
  "name": "sample-bare-dns",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "bare-dns": "2.1.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/bare-dns@2.1.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/bare-dns@2.1.4"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';

const require = createRequire(import.meta.url);

// 1. Resolve bare-dns package manifest and verify exports and metadata
const pkgPath = require.resolve('bare-dns/package');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, 'bare-dns', 'Package name must be bare-dns');
assert.equal(pkg.version, '2.1.4', 'Package version must be 2.1.4');
assert.equal(pkg.license, 'Apache-2.0', 'Package license must be Apache-2.0');
assert.equal(pkg.addon, true, 'Package must be marked as addon');
assert.equal(pkg.engines?.bare, '>=1.7.0', 'Package must specify Bare engine >=1.7.0');

assert.ok(pkg.exports, 'Package must define exports');
assert.equal(pkg.exports['.'].types, './index.d.ts', 'Root export must specify index.d.ts types');
assert.equal(pkg.exports['.'].default, './index.js', 'Root export must specify index.js default');
assert.equal(pkg.exports['./package'], './package.json', 'Package export must point to package.json');

assert.deepEqual(
  pkg.files,
  ['index.js', 'index.d.ts', 'binding.c', 'binding.js', 'CMakeLists.txt', 'lib', 'prebuilds'],
  'Package files array must match expected files'
);

const pkgDir = path.dirname(pkgPath);

// 2. Verify complete TypeScript definitions in index.d.ts
const indexDtsPath = path.join(pkgDir, 'index.d.ts');
assert.ok(fs.existsSync(indexDtsPath), 'index.d.ts must exist');
const indexDts = fs.readFileSync(indexDtsPath, 'utf8');

assert.ok(indexDts.includes('type IPFamily = 4 | 6'), 'index.d.ts must define IPFamily');
assert.ok(indexDts.includes('interface LookupOptions'), 'index.d.ts must define LookupOptions');
assert.ok(indexDts.includes('declare class DNSResolver'), 'index.d.ts must declare DNSResolver class');
assert.ok(indexDts.includes('resolveTxt('), 'DNSResolver must declare resolveTxt');
assert.ok(indexDts.includes('destroy(): void'), 'DNSResolver must declare destroy');
assert.ok(indexDts.includes('export function lookup('), 'index.d.ts must declare lookup function');
assert.ok(indexDts.includes('export function resolveTxt('), 'index.d.ts must declare resolveTxt function');
assert.ok(indexDts.includes('DNSResolver as Resolver'), 'index.d.ts must export DNSResolver as Resolver');
assert.ok(indexDts.includes('export = dns'), 'index.d.ts must export namespace dns');

// 3. Verify JavaScript module implementation in index.js and binding.js
const indexJsPath = path.join(pkgDir, 'index.js');
assert.ok(fs.existsSync(indexJsPath), 'index.js must exist');
const indexJs = fs.readFileSync(indexJsPath, 'utf8');

assert.ok(indexJs.includes("require('./binding')"), 'index.js must require binding');
assert.ok(indexJs.includes('exports.Resolver = class DNSResolver'), 'index.js must define Resolver class');
assert.ok(indexJs.includes('exports.lookup = function lookup'), 'index.js must define lookup function');
assert.ok(indexJs.includes('exports.resolveTxt = function resolveTxt'), 'index.js must define resolveTxt function');
assert.ok(indexJs.includes('static global = new this()'), 'DNSResolver must initialize static global instance');

const bindingJsPath = path.join(pkgDir, 'binding.js');
assert.ok(fs.existsSync(bindingJsPath), 'binding.js must exist');
const bindingJs = fs.readFileSync(bindingJsPath, 'utf8');
assert.ok(bindingJs.includes('require.addon()'), 'binding.js must call require.addon()');

// 4. Verify C binding implementation and CMake build configuration
const bindingCPath = path.join(pkgDir, 'binding.c');
assert.ok(fs.existsSync(bindingCPath), 'binding.c must exist');
const bindingC = fs.readFileSync(bindingCPath, 'utf8');

assert.ok(bindingC.includes('#include <ares.h>'), 'binding.c must include <ares.h>');
assert.ok(bindingC.includes('#include <bare.h>'), 'binding.c must include <bare.h>');
assert.ok(bindingC.includes('#include <js.h>'), 'binding.c must include <js.h>');
assert.ok(bindingC.includes('#include <uv.h>'), 'binding.c must include <uv.h>');
assert.ok(bindingC.includes('bare_dns_lookup'), 'binding.c must define lookup implementation');
assert.ok(bindingC.includes('bare_dns_init_resolver'), 'binding.c must define initResolver implementation');
assert.ok(bindingC.includes('bare_dns_destroy_resolver'), 'binding.c must define destroyResolver implementation');
assert.ok(bindingC.includes('bare_dns_resolve_txt'), 'binding.c must define resolveTxt implementation');
assert.ok(bindingC.includes('BARE_MODULE(bare_dns, bare_dns_exports)'), 'binding.c must export BARE_MODULE bare_dns');

const cmakePath = path.join(pkgDir, 'CMakeLists.txt');
assert.ok(fs.existsSync(cmakePath), 'CMakeLists.txt must exist');
const cmake = fs.readFileSync(cmakePath, 'utf8');
assert.ok(cmake.includes('project(bare_dns C)'), 'CMakeLists.txt must define project bare_dns');
assert.ok(cmake.includes('add_bare_module(bare_dns)'), 'CMakeLists.txt must declare bare module');
assert.ok(cmake.includes('github:c-ares/c-ares'), 'CMakeLists.txt must fetch c-ares dependency');

// 5. Verify prebuilt native binaries across architectures
const prebuildsDir = path.join(pkgDir, 'prebuilds');
assert.ok(fs.existsSync(prebuildsDir), 'prebuilds directory must exist');

const expectedTargets = [
  'android-arm',
  'android-arm64',
  'android-ia32',
  'android-x64',
  'darwin-arm64',
  'darwin-x64',
  'ios-arm64-simulator',
  'ios-arm64',
  'ios-x64-simulator',
  'linux-arm64',
  'linux-x64',
  'win32-arm64',
  'win32-x64'
];

for (const target of expectedTargets) {
  const binaryPath = path.join(prebuildsDir, target, 'bare-dns.bare');
  assert.ok(fs.existsSync(binaryPath), `Prebuild binary must exist for target: ${target}`);
  const stat = fs.statSync(binaryPath);
  assert.ok(stat.size > 0, `Prebuild binary for ${target} must not be empty`);
}

const linuxX64Binary = fs.readFileSync(path.join(prebuildsDir, 'linux-x64', 'bare-dns.bare'));
assert.ok(linuxX64Binary.length > 1000, 'linux-x64 prebuild binary size must exceed 1000 bytes');

console.log('Contract tests passed successfully.');

오리진 시더

익명