@dnsid-ai/transport

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

Node.js DNS and HTTPS transport implementations for DNSid.

原始使用文档
文档目录4 节
  1. Responsibilities
  2. Install
  3. Example
  4. Single-send signed-response transport

@dnsid-ai/transport

Node.js transport implementation for DNSid TypeScript packages.

Use this package when you want default Node DNS and HTTPS/TLS plumbing for @dnsid-ai/protocol or @dnsid-ai/sdk/node.

Responsibilities

  • DNS TXT resolution through system DNS or a configured DNS server
  • DNS server parsing and lookup helpers
  • HTTPS JSON fetching
  • SSRF-safe fetch for profile packages that need connection-time DNS checks
  • TLS certificate capture
  • custom CA bundle support
  • custom DNS server support

This package is Node-only and intentionally separate from @dnsid-ai/protocol.

Install

npm install @dnsid-ai/transport

Example

import { createDefaultDnsResolver, createSsrfSafeFetch, fetchJson } from '@dnsid-ai/transport';

const dnsResolver = createDefaultDnsResolver({ dnsServer: process.env.DNSID_DNS_SERVER });
const result = await fetchJson('https://agent.example/.well-known/dnsid-status.json', {
  allowedHost: 'agent.example',
  dnsServer: process.env.DNSID_DNS_SERVER,
  caBundlePath: process.env.DNSID_CA_BUNDLE,
});

const safeFetch = createSsrfSafeFetch({ dnsServer: process.env.DNSID_DNS_SERVER });

Single-send signed-response transport

createResponseSignatureTransport(config?) returns the responseTransport function required by HttpSignaturesProfile.createSignedFetch when signing.responseSignature is present. It accepts a prepared Request and returns { response, peerCert }. It performs one HTTPS request per call, reuses keep-alive connections across calls, never follows redirects or retries, never caches, and preserves encoded content bytes without transparent decompression. Request bodies are sent with Content-Length. The certificate comes from the connection that carried the response, so it can satisfy fl=mtls; the profile still validates its SAN against the expected DNSid agent.

The transport honors the request abort signal and has a 30-second ceiling. The signed client supplies a shared finite send/read/verification budget and bounded content reads (8 MiB). Standalone transport consumers must also bound body reads, cancel rejected responses, and not expose unverified content. Protocol upgrades and tunnel establishment reject. HTTP errors and ordinary redirect responses are returned to the profile for signature verification.

Custom DNS and CA settings follow createDnsidFetch. Like that function, this transport does not filter private addresses: callers must select a trusted target or inject a transport with their required network-address policy. It is separate from WBA's SSRF-safe discovery transport and does not change that profile.

Most Node applications should use this through @dnsid-ai/sdk/node or profile defaults.

The default resolver queries the DNS servers returned by Node's dns.getServers() in order, using UDP with TCP fallback to capture the recursive server's remaining TXT TTL (capped at one day). dnsServer can override this list. On failures or empty answers it falls back to Node's native TXT lookup with TTL 0, disabling identity caching for that result. Node's server list may omit macOS scoped/split-DNS routing, so even positive wire answers are not guaranteed to match the platform resolver in those setups. Neither path validates DNSSEC (UNKNOWN); SERVFAIL is a resolution error. validated/required DNSSEC modes still need an injected validating resolver. Cached verification still re-fetches status unless verification.statusCheckInterval is set.

createSsrfSafeFetch() enforces unsafe-address rejection in the lookup used by the outgoing socket and returns redirects without following them automatically. Trusted test/private deployments may pass privateAddressHosts: exact hostnames or leading-dot suffixes such as .test (label-bounded, case-insensitive); only RFC 1918/ULA private and loopback results are then accepted for matching hosts, while link-local, mixed public/private, and IP-literal URLs remain blocked. Nothing is allowed by default, not even .test; a local dnsid stack needs privateAddressHosts: ['.test'] (or DNSID_PRIVATE_HOSTS=.test through loadEnvironment). Profile packages that accept a custom fetch cannot force equivalent behavior on arbitrary implementations, so custom fetch injection remains trusted infrastructure.

版本与发布记录

@dnsid-ai/transport 共发布 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/transport 的常见问题

@dnsid-ai/transport 是什么?

Node.js DNS and HTTPS transport implementations for DNSid.

如何安装 @dnsid-ai/transport?

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

@dnsid-ai/transport 支持 TypeScript 吗?

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

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

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

@dnsid-ai/transport 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.23.4 || ^24.22.1 || >=26.12.1。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

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

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

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

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

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

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