@dnsid-ai/protocol

中文文档
0.37.0发布于 2026/11/12Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 8094

DNSid protocol core contracts, TXT record parsing, JWKS validation, and identity verification engine.

原始使用文档
文档目录5 节
  1. Responsibilities
  2. Install
  3. Example
  4. Verification context and limits
  5. High-value operation log checks

@dnsid-ai/protocol

Protocol core for DNSid TypeScript packages.

Use this package when you want the DNSid protocol engine and contracts without runtime-specific defaults.

Responsibilities

  • IdentityManager
  • DNSid TXT record parsing, validation, serialization, and canonicalization
  • JWKS validation and JWK thumbprints
  • Protocol data types and strict protocol status validation
  • DNS, fetch, cache, key-provider, and log contracts
  • Common DNSid errors and verification primitives

This package intentionally does not include Node DNS/HTTPS transport, local filesystem key storage, environment-variable loading, registry-specific lifecycle behavior, or profile-specific conveniences.

Install

npm install @dnsid-ai/protocol

Example

import { IdentityManager } from '@dnsid-ai/protocol';

// config is data only; runtime objects are injected as dependencies.
const idm = new IdentityManager(
  {
    identity,                                  // omit for a verification-only manager
    verification: { dnssecMode: 'required', trustedEntities: [{ governanceId: 'agent.example' }] },
  },
  { keyProvider, entityKeyProvider, logRegistry, dnsResolver, cache, fetchJson },
);

verification.trustedEntities is an optional counterparty allowlist checked on every verifyDomain return (including cache hits) after protocol verification. Entries match the verified record's governance ID exactly; optional entityKeyThumbprints pin the current record-signing key. Omit it to make no acceptance decision; [] denies all. A denial raises VerificationError with code CounterpartyNotAccepted carrying only the observed verifiedGovernanceId/verifiedEntityKeyThumbprint.

The core has no default DNS or HTTPS implementation, so config.transport settings are rejected here; use @dnsid-ai/sdk/node, which consumes them for its defaults.

For ergonomic Node.js defaults, use @dnsid-ai/sdk/node with @dnsid-ai/transport.

Verification context and limits

verifyDomain(domain, peerCert?, { timeoutMs?, signal? }) has a 30-second whole-operation default. Each coalesced caller retains its deadline; shared identity work also has a 30-second cap and is canceled when its last caller leaves. DNS, HTTPS redirects, and lifecycle evidence share the remaining budget. Injected resolvers, fetchers, and log factories must honor the supplied signal, keep trust configuration immutable, and bound their responses before allocation. Native system DNS work may finish in the background under the platform's finite resolver retry limits; canceled verification does not proceed or populate caches. TXT input is limited to 65,535 characters/1,024 chunks; JWKS and status fetches request 256 KiB and 16 KiB limits respectively.

Injected caches are namespaced per manager, never shared by domain alone. Configuration and log-method selection are snapshotted at construction; use a new manager for changed trust policy. DNS expiry starts at lookup acquisition, not verification completion. Status refresh never extends it, zero-TTL answers are never reused, and DNS/TLS/key-age bounds are checked before returning.

refreshDomain(domain, peerCert?, options?) performs complete verification without reusing the cached identity or falling back after failure. Concurrent refreshes share acquisition, but each caller still passes peer and acceptance checks. Injected JSON fetchers and log factories must honor revalidate: true by bypassing local caches and revalidating upstream evidence. DNS answers retain their normal TTL. Older in-flight lookups cannot overwrite a successful refresh.

High-value operation log checks

verifyDomain() validates the bilateral ISSUANCE binding for every identity. If the verified record advertises fl=logchk, the application must additionally perform a current non-revocation check before relying on the identity for an operation it classifies as high value or irreversible:

const verified = await idm.verifyDomain('agent.example');
if (verified.requiresLogCheck()) {
  const evidence = await verified.verifyNonRevocation();
  console.log(evidence.logReference, evidence.freshnessTime);
}

Operation classification remains application policy. Call verifyNonRevocation() regardless of the advertised flag when local policy requires it. The returned evidence identifies the verified history bounds, completeness mechanism, checkpoint, and freshness boundary; it does not contain the events. Log unavailability or stale evidence fails the check closed.

版本与发布记录

@dnsid-ai/protocol 共发布 22 个版本,首次发布于 2026/09/22;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.37.0latest2026/11/121 天前
0.36.02026/11/112 天前
0.35.02026/11/067 天前
0.34.02026/10/3014 天前
0.33.02026/10/2815 天前
0.32.02026/10/2716 天前

关于 @dnsid-ai/protocol 的常见问题

@dnsid-ai/protocol 是什么?

DNSid protocol core contracts, TXT record parsing, JWKS validation, and identity verification engine.

如何安装 @dnsid-ai/protocol?

在项目目录运行 npm install @dnsid-ai/protocol,或使用 pnpm add / yarn add / bun add。

@dnsid-ai/protocol 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dnsid-ai/protocol 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dnsid-ai/protocol 可以商用吗?

@dnsid-ai/protocol 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dnsid-ai/protocol 的下载量有多少?

根据 npm 官方下载统计,@dnsid-ai/protocol 在 2026/10/13 – 2026/11/11 这 30 天内被下载 8,094 次,日均约 270 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dnsid-ai/protocol 还在维护吗?

最新版本 0.37.0 发布于 2026/11/12(1 天前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/09/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。