Skip to content

TypeScript: @dnsid-ai/sdk/node

Node.js conveniences for DNSid — the @dnsid-ai/sdk/node subpath.

Provides LocalKeyProvider (filesystem-backed key storage), the configuration loaders (loadEnvironment, loadFile, loadCliDirectory → mergeLoadedConfig → constructIdentityManager), the one-call createNodeIdentityManagerFromEnvironment / createNodeIdentityManagerFromDnsid / createNodeIdentityManagerFromFile constructors, and createNodeIdentityManager, which defaults DNS resolution and HTTPS JSON fetching to the optional @dnsid-ai/transport peer. Loaders parse; constructors default. No constructor reads the environment or files. The system resolver reports DNSSEC state UNKNOWN; the default auto policy accepts and preserves that state, while stricter policies require a DNSSEC-aware resolver.

Defined in: packages/sdk/src/local-key-provider.ts:38

File-backed KeyProvider that stores Ed25519 or ECDSA P-256 keys as a JSON file.

This concrete key-storage implementation is provided by @dnsid-ai/sdk as the default developer/runtime key provider. Use only one provider instance/process per file. Mutations within an instance are serialized. Writes require filesystem support for atomic rename, hard links, and directory fsync. Existing symlinks are resolved at load time; <resolvedPath>.bak holds the private previous generation. A failure after replacement may mean the new state is visible but not crash-durable; memory follows the visible file. Inspect the store before retrying a failed mutation.

activate(kid): Promise<void>;

Defined in: packages/sdk/src/local-key-provider.ts:161

Blocks new signing and drains in-flight signatures before promoting a pending key. The previously active key transitions to retained.

string

Promise<void>

KeyProvider.activate

generateKey(algorithm?): Promise<string>;

Defined in: packages/sdk/src/local-key-provider.ts:151

Generates a new key pair in the pending state. Returns the new key’s kid.

string

Promise<string>

KeyProvider.generateKey

jwk(kid): Promise<DnsIdJWK>;

Defined in: packages/sdk/src/local-key-provider.ts:114

Returns the JWK representation of a key by ID (active, pending, or retained). Raises if not found.

string

Promise<DnsIdJWK>

KeyProvider.jwk

listKeyIds(): Promise<string[]>;

Defined in: packages/sdk/src/local-key-provider.ts:123

Returns the IDs of all active and retained keys (pending keys excluded). The active key ID MUST appear first; retained keys follow in any order.

Promise<string[]>

KeyProvider.listKeyIds

purge(kid): Promise<void>;

Defined in: packages/sdk/src/local-key-provider.ts:188

string

Promise<void>

Use supersede().

KeyProvider.purge

sign(payload): Promise<Uint8Array<ArrayBufferLike>>;

Defined in: packages/sdk/src/local-key-provider.ts:127

Signs the given payload with the current active signing key. Returns raw signature bytes.

Uint8Array

Promise<Uint8Array<ArrayBufferLike>>

KeyProvider.sign

signingKey(): Promise<DnsIdJWK>;

Defined in: packages/sdk/src/local-key-provider.ts:110

Returns the JWK representation of the current active public signing key. The returned kid MUST NOT contain ’#’.

Promise<DnsIdJWK>

KeyProvider.signingKey

signKey(kid, payload): Promise<Uint8Array<ArrayBufferLike>>;

Defined in: packages/sdk/src/local-key-provider.ts:131

Signs with a specified active or pending key.

string

Uint8Array

Promise<Uint8Array<ArrayBufferLike>>

KeyProvider.signKey

supersede(kid): Promise<void>;

Defined in: packages/sdk/src/local-key-provider.ts:176

Supersedes and removes a retained key from this provider’s published key set.

string

Promise<void>

KeyProvider.supersede

validateKeyGeneration(algorithm): Promise<void>;

Defined in: packages/sdk/src/local-key-provider.ts:147

Validates generation settings and algorithm support without creating a key.

string

Promise<void>

KeyProvider.validateKeyGeneration

static fromDirectory(dir): Promise<LocalKeyProvider>;

Defined in: packages/sdk/src/local-key-provider.ts:83

string

Promise<LocalKeyProvider>

static fromDomain(domain, dnsidDir?): Promise<LocalKeyProvider>;

Defined in: packages/sdk/src/local-key-provider.ts:106

string

string = ...

Promise<LocalKeyProvider>

static fromFile(filePath): Promise<LocalKeyProvider>;

Defined in: packages/sdk/src/local-key-provider.ts:100

Loads a single private JWK file, including DNSid CLI entity_key_path files.

string

Promise<LocalKeyProvider>

static generate(algorithm?): Promise<LocalKeyProvider>;

Defined in: packages/sdk/src/local-key-provider.ts:79

LocalKeyAlgorithm = 'EdDSA'

Promise<LocalKeyProvider>

static load(
filePath,
createIfMissing?,
algorithm?
): Promise<LocalKeyProvider>;

Defined in: packages/sdk/src/local-key-provider.ts:51

string

boolean = false

LocalKeyAlgorithm = 'EdDSA'

Promise<LocalKeyProvider>

Defined in: packages/sdk/src/config-loading.ts:67

Optional Known Foundry account expectations, not identity selectors or acceptance policy.

optional governanceId?: string;

Defined in: packages/sdk/src/config-loading.ts:69

optional organizationId?: string;

Defined in: packages/sdk/src/config-loading.ts:68


Defined in: packages/sdk/src/config-loading.ts:51

optional cliDirectory?: string;

Defined in: packages/sdk/src/config-loading.ts:59

DNSid CLI identity directory; key files are located under the effective identity domain.

optional entityKeyPath?: string;

Defined in: packages/sdk/src/config-loading.ts:61

Accountable-entity private JWK file.

optional generation?: object;

Defined in: packages/sdk/src/config-loading.ts:56

File generation locator; cloud factories without atomic discovery require keyRef.

algorithm: string;
locator: string;

optional keyRef?: string;

Defined in: packages/sdk/src/config-loading.ts:54

Existing stable key reference; never combined with generation.

optional keyStorePath?: string;

Defined in: packages/sdk/src/config-loading.ts:63

LocalKeyProvider key-store file; used only when cliDirectory is absent.

optional provider?: "file" | "aws-kms" | "google-kms" | "azure-key-vault";

Defined in: packages/sdk/src/config-loading.ts:52

optional settings?: Record<string, unknown>;

Defined in: packages/sdk/src/config-loading.ts:57


Defined in: packages/sdk/src/config-loading.ts:88

Partial configuration from one source. Every field is present only when sourced.

optional dnsid?: LoadedDnsidConfig;

Defined in: packages/sdk/src/config-loading.ts:89

optional foundry?: FoundryConfig;

Defined in: packages/sdk/src/config-loading.ts:92

optional keySource?: KeySource;

Defined in: packages/sdk/src/config-loading.ts:95

optional logTrust?: LogTrust;

Defined in: packages/sdk/src/config-loading.ts:90

optional registration?: Partial<ManagedRegistrationConfig>;

Defined in: packages/sdk/src/config-loading.ts:94

Setup expectations only; never identity or counterparty acceptance defaults.

optional registry?: LoadedRegistryConfig;

Defined in: packages/sdk/src/config-loading.ts:91


Defined in: packages/sdk/src/config-loading.ts:83

DnsidConfig with a partial identity: sources may supply some publication fields and leave the rest to an overlay.

optional identity?: Partial<IdentityConfig>;

Defined in: packages/sdk/src/config-loading.ts:84

optional transport?: TransportConfig;

Defined in: packages/protocol/src/types.ts:128

DnsidConfig.transport

optional verification?: VerificationConfig;

Defined in: packages/protocol/src/types.ts:127

DnsidConfig.verification


Defined in: packages/sdk/src/config-loading.ts:78

optional registryUrl?: string;

Defined in: packages/sdk/src/config-loading.ts:79


Defined in: packages/sdk/src/config-loading.ts:40

Log trust for deps.logRegistry; exactly one variant is required at construction.

optional managed?: boolean;

Defined in: packages/sdk/src/config-loading.ts:42

true selects the embedded DNSid-managed catalog.

optional policyDocument?: Uint8Array<ArrayBufferLike>;

Defined in: packages/sdk/src/config-loading.ts:46

Trusted C2SP tlog-policy bytes.

optional policyUrl?: string;

Defined in: packages/sdk/src/config-loading.ts:48

Trusted C2SP tlog-policy HTTPS URL.

optional profile?: Record<string, unknown>;

Defined in: packages/sdk/src/config-loading.ts:44

dnsid-c2sp-tlog-trust-profile@v1 document (parsed JSON).


Defined in: packages/sdk/src/config-loading.ts:72

entityKeyUrl: string;

Defined in: packages/sdk/src/config-loading.ts:75

optional governanceId?: string;

Defined in: packages/sdk/src/config-loading.ts:74

optional organizationId?: string;

Defined in: packages/sdk/src/config-loading.ts:73


Defined in: packages/sdk/src/node-response-signing.ts:9

Options for createResponseSigningMiddleware.

optional origin?: string;

Defined in: packages/sdk/src/node-response-signing.ts:14

Public origin the client used, such as https://bob.test. Set it behind a TLS-terminating proxy. Default: the socket’s scheme and the Host header.

type EnvironmentSource = Readonly<Record<string, string | undefined>>;

Defined in: packages/sdk/src/config-loading.ts:37


type LocalKeyAlgorithm = "EdDSA" | "ES256";

Defined in: packages/sdk/src/local-key-provider.ts:16


type NodeMiddleware = (req, res, next) => void;

Defined in: packages/sdk/src/node-response-signing.ts:18

Connect-style middleware, usable with Express, Connect, or a plain node:http handler.

IncomingMessage

ServerResponse

(err?) => void

void

function constructIdentityManager(loaded, deps?): Promise<IdentityManager>;

Defined in: packages/sdk/src/config-loading.ts:367

Fills deps.logRegistry from logTrust and key providers from keySource only when the caller did not supply them, then calls createNodeIdentityManager. Adds no configuration values. Configuration-selected operational keys must match verified local publication before return. Initial setup injects its provider and owns its binding checks; missing publication fails closed.

LoadedConfig

IdentityManagerDependencies = {}

Promise<IdentityManager>


function createNodeIdentityManager(config, deps?): Promise<IdentityManager>;

Defined in: packages/sdk/src/node-identity-manager.ts:32

Creates an IdentityManager with Node.js DNS and HTTPS defaults.

config.transport configures only the SDK-managed defaults: dnsServer applies to whichever of dnsResolver/fetchJson is not injected and is rejected when both are; caBundlePath and privateAddressHosts apply to the default fetcher and are rejected when fetchJson is injected. Injected dependencies are never inspected or modified. @dnsid-ai/transport is an optional peer; install it or inject both dependencies. The system resolver reports UNKNOWN; validated/required DNSSEC modes need a DNSSEC-aware resolver.

DnsidConfig

IdentityManagerDependencies = {}

Promise<IdentityManager>

import { createNodeIdentityManager, LocalKeyProvider } from '@dnsid-ai/sdk/node';
const keyProvider = await LocalKeyProvider.load('.dnsid/keys.json', true);
const idm = await createNodeIdentityManager({ identity, verification }, { keyProvider, entityKeyProvider });

function createNodeIdentityManagerFromDnsid(
dnsidDir?,
overlay?,
deps?
): Promise<IdentityManager>;

Defined in: packages/sdk/src/config-loading.ts:516

string

LoadedDnsidConfig

IdentityManagerDependencies

Promise<IdentityManager>


createNodeIdentityManagerFromEnvironment()

Section titled “createNodeIdentityManagerFromEnvironment()”
function createNodeIdentityManagerFromEnvironment(
env?,
overlay?,
deps?
): Promise<IdentityManager>;

Defined in: packages/sdk/src/config-loading.ts:512

Readonly<Record<string, string | undefined>>

LoadedDnsidConfig

IdentityManagerDependencies

Promise<IdentityManager>


function createNodeIdentityManagerFromFile(
filePath,
overlay?,
deps?
): Promise<IdentityManager>;

Defined in: packages/sdk/src/config-loading.ts:520

string

LoadedDnsidConfig

IdentityManagerDependencies

Promise<IdentityManager>


function createNodeIdentityVerifier(config?, deps?): Promise<IdentityManager>;

Defined in: packages/sdk/src/node-identity-manager.ts:58

Creates a verification-only IdentityManager with Node.js DNS and HTTPS defaults (config.identity omitted).

Omit<DnsidConfig, "identity"> = {}

Omit<IdentityManagerDependencies, "keyProvider" | "entityKeyProvider"> = {}

Promise<IdentityManager>


function createRegistryClientFromEnvironment(env?, options?): Promise<RegistryClient>;

Defined in: packages/sdk/src/config-loading.ts:525

RegistryClient from DNSID_REGISTRY_URL and DNSID_API_KEY; explicit options win, including transport overrides. The constructor defaults to the local registry.

Readonly<Record<string, string | undefined>>

RegistryClientOptions = {}

Promise<RegistryClient>


function createResponseSigningMiddleware(profile, options?): NodeMiddleware;

Defined in: packages/sdk/src/node-response-signing.ts:31

Signs responses to requests that carry Accept-Signature, for node:http servers. Requests without negotiation pass through unbuffered. Negotiated responses are buffered up to 8 MiB and signed with signRequestedHttpResponse before any header is sent. On a signing failure, an exceeded bound, or a flushHeaders() call (streaming, such as SSE) it sends an empty 500; it never sends the unsigned response. Register it before request verification, compression, and handlers so that it sees their final status, headers, and content coding. Informational responses written with writeContinue or writeEarlyHints are sent directly and are not signed.

HttpSignaturesProfile

ResponseSigningMiddlewareOptions = {}

NodeMiddleware


function loadCliDirectory(dnsidDir?): Promise<LoadedConfig>;

Defined in: packages/sdk/src/config-loading.ts:284

Reads a DNSid CLI directory (~/.dnsid by default): config.json, following a root domain pointer to <domain>/config.json when that file exists. Maps the snake_case publication fields into dnsid.identity and records the directory (and resolved entity_key_path) as keySource. Never consults DNSID_CONFIG_DIR.

string = ...

Promise<LoadedConfig>


function loadEnvironment(env?): Promise<LoadedConfig>;

Defined in: packages/sdk/src/config-loading.ts:113

Reads configuration from DNSID_*. Secrets such as DNSID_API_KEY stay out of LoadedConfig.

EnvironmentSource = process.env

Promise<LoadedConfig>


function loadFile(filePath): Promise<LoadedConfig>;

Defined in: packages/sdk/src/config-loading.ts:160

Reads a JSON deployment file: { dnsid?, logTrust?, registry?, foundry?, registration?, keySource? }. Unknown members, mistyped values, and duplicate members are rejected; semantic dnsid validation stays with the constructor.

string

Promise<LoadedConfig>


function mergeLoadedConfig(base, overlay): LoadedConfig;

Defined in: packages/sdk/src/config-loading.ts:324

Field-wise merge; presence wins, not truthiness. Lists replace. logTrust is replaced as a whole section when overlay sets any variant. Operational key-source fields replace together; entityKeyPath merges independently.

LoadedConfig

LoadedConfig

LoadedConfig

Re-exports CreateIdentityManagerDependencies