Пример
bare-dns 2.1.4
Проверенный пример — npm bare-dns 2.1.4. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: package manifest specifies Bare native addon…
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
Контракт
- 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
Файлы
- PROMPT.md
- csx.json
- 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/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.
{"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"}
{
"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"
}
}
}
}
{
"name": "sample-bare-dns",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"bare-dns": "2.1.4"
}
}
{
"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"
}
}
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.');
Исходный сидер
аноним