@dnsid-ai/sdk 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.d.cts CHANGED
@@ -1,19 +1,12 @@
1
- import { KeyProvider, DnsIdJWK, DNSSECMode, DnsidConfig, IdentityConfig, IdentityManagerDependencies, IdentityManager } from '@dnsid-ai/protocol';
2
1
  export { CreateIdentityManagerDependencies } from './index.cjs';
2
+ import * as _dnsid_ai_protocol from '@dnsid-ai/protocol';
3
+ import { KeyProvider, DnsIdJWK, DnsidConfig, IdentityManagerDependencies, IdentityManager, IdentityConfig } from '@dnsid-ai/protocol';
4
+ import { RegistryClient } from '@dnsid-ai/registry';
3
5
  import '@dnsid-ai/jose';
4
6
  import '@dnsid-ai/http-signatures';
5
- import '@dnsid-ai/registry';
6
7
  import '@dnsid-ai/web-bot-auth';
7
8
 
8
9
  type LocalKeyAlgorithm = 'EdDSA' | 'ES256';
9
- interface LocalKeyProviderEnvironmentOptions {
10
- /** Default key-store path when the environment variable is absent. Default: .dnsid/keys.json. */
11
- defaultPath?: string;
12
- /** Create an initial key store if the file does not exist. Default: false. */
13
- createIfMissing?: boolean;
14
- /** Algorithm used when creating a missing key store. Default: EdDSA. */
15
- algorithm?: LocalKeyAlgorithm;
16
- }
17
10
  /**
18
11
  * File-backed KeyProvider that stores Ed25519 or ECDSA P-256 keys as a JSON file.
19
12
  *
@@ -30,7 +23,6 @@ declare class LocalKeyProvider implements KeyProvider {
30
23
  private mutations;
31
24
  private constructor();
32
25
  static load(filePath: string, createIfMissing?: boolean, algorithm?: LocalKeyAlgorithm): Promise<LocalKeyProvider>;
33
- static fromEnvironment(env?: Record<string, string | undefined>, options?: LocalKeyProviderEnvironmentOptions): Promise<LocalKeyProvider>;
34
26
  static generate(algorithm?: LocalKeyAlgorithm): Promise<LocalKeyProvider>;
35
27
  static fromDirectory(dir: string): Promise<LocalKeyProvider>;
36
28
  /** Loads a single private JWK file, including DNSid CLI `entity_key_path` files. */
@@ -48,110 +40,7 @@ declare class LocalKeyProvider implements KeyProvider {
48
40
  purge(kid: string): Promise<void>;
49
41
  private mutate;
50
42
  }
51
- declare function keyStorePathFromEnvironment(env?: Record<string, string | undefined>, defaultPath?: string): string;
52
43
 
53
- declare const dnsidEnvironmentVariables: {
54
- readonly domain: "DNSID_DOMAIN";
55
- readonly governanceId: "DNSID_GOVERNANCE_ID";
56
- readonly registryUrl: "DNSID_REGISTRY_URL";
57
- readonly apiKey: "DNSID_API_KEY";
58
- readonly statusUrl: "DNSID_STATUS_URL";
59
- readonly logRef: "DNSID_LOG_REF";
60
- readonly ekUrl: "DNSID_EK_URL";
61
- readonly kuUrl: "DNSID_KU_URL";
62
- readonly dnsServer: "DNSID_DNS_SERVER";
63
- readonly caBundlePath: "DNSID_CA_BUNDLE";
64
- readonly privateAddressHosts: "DNSID_PRIVATE_HOSTS";
65
- readonly dnssecMode: "DNSID_DNSSEC_MODE";
66
- readonly publicUrl: "DNSID_PUBLIC_URL";
67
- readonly keyStorePath: "DNSID_KEY_STORE";
68
- readonly agentPort: "DNSID_AGENT_PORT";
69
- readonly agentName: "DNSID_AGENT_NAME";
70
- };
71
- type EnvironmentFieldName = keyof typeof dnsidEnvironmentVariables;
72
- type EnvironmentVariableName = (typeof dnsidEnvironmentVariables)[EnvironmentFieldName];
73
- type EnvironmentSource = Record<string, string | undefined>;
74
- interface EnvironmentField<T> {
75
- variable: EnvironmentVariableName;
76
- parse(value: string, variable: EnvironmentVariableName): T;
77
- }
78
- declare const environmentSchema: {
79
- domain: EnvironmentField<string>;
80
- governanceId: EnvironmentField<string>;
81
- registryUrl: EnvironmentField<string>;
82
- apiKey: EnvironmentField<string>;
83
- statusUrl: EnvironmentField<string>;
84
- logRef: EnvironmentField<string>;
85
- ekUrl: EnvironmentField<string>;
86
- kuUrl: EnvironmentField<string>;
87
- dnsServer: EnvironmentField<string>;
88
- caBundlePath: EnvironmentField<string>;
89
- privateAddressHosts: EnvironmentField<string[] | undefined>;
90
- dnssecMode: EnvironmentField<DNSSECMode>;
91
- publicUrl: EnvironmentField<string>;
92
- keyStorePath: EnvironmentField<string>;
93
- agentPort: EnvironmentField<number>;
94
- agentName: EnvironmentField<string>;
95
- };
96
- type EnvironmentValue<K extends EnvironmentFieldName> = typeof environmentSchema[K] extends EnvironmentField<infer T> ? T : never;
97
- type DnsidEnvironment = {
98
- [K in EnvironmentFieldName]?: EnvironmentValue<K>;
99
- };
100
- type ConfigForEnvironment<RequiredFields extends EnvironmentFieldName> = DnsidConfig & {
101
- identity: IdentityConfig & Required<Pick<IdentityConfig, Extract<RequiredFields, keyof IdentityConfig>>>;
102
- };
103
- interface EnvironmentConfigResultBase<RequiredFields extends EnvironmentFieldName = never> {
104
- /** Core configuration: `identity` publication fields, `verification.dnssecMode`, and `transport` from the environment. */
105
- config: ConfigForEnvironment<RequiredFields>;
106
- /** Base URL of the DNSid registry for control-plane workflows. Defaults to the local registry ({@link DEFAULT_REGISTRY_URL}). Not core config. */
107
- registryUrl: string;
108
- /** Owner API key for registry workflows (`DNSID_API_KEY`); `dnsid local env` exports one for the local registry. */
109
- apiKey?: string;
110
- /** Optional public base URL for the agent, e.g. https://alice.example.com. */
111
- publicUrl?: string;
112
- /** Optional local key-store path for LocalKeyProvider. */
113
- keyStorePath?: string;
114
- /** Optional example/server display name. */
115
- agentName?: string;
116
- /** Optional example/server port. */
117
- agentPort?: number;
118
- }
119
- type EnvironmentConfigResult<RequiredFields extends EnvironmentFieldName = never> = EnvironmentConfigResultBase<RequiredFields> & Required<Pick<EnvironmentConfigResultBase<RequiredFields>, Extract<RequiredFields, keyof EnvironmentConfigResultBase<RequiredFields>>>>;
120
- interface ConfigFromEnvironmentOptions<RequiredFields extends EnvironmentFieldName = never> {
121
- require?: readonly RequiredFields[];
122
- }
123
- /**
124
- * Explicit loader mapping DNSID_* environment variables to a {@link DnsidConfig} plus
125
- * registry/example settings. Constructors never read the environment themselves.
126
- */
127
- declare function configFromEnvironment<const RequiredFields extends EnvironmentFieldName = never>(options?: ConfigFromEnvironmentOptions<RequiredFields>): EnvironmentConfigResult<RequiredFields>;
128
- declare function configFromEnvironment<const RequiredFields extends EnvironmentFieldName = never>(env: EnvironmentSource | undefined, options?: ConfigFromEnvironmentOptions<RequiredFields>): EnvironmentConfigResult<RequiredFields>;
129
- /**
130
- * Registry client options from `DNSID_REGISTRY_URL` and `DNSID_API_KEY`, the
131
- * variables `dnsid local env` exports. Unset means the local registry with no
132
- * credential. Unlike {@link configFromEnvironment} this needs no identity
133
- * variables, so it works before an agent exists:
134
- * `new RegistryClient(registryClientOptionsFromEnvironment())`.
135
- */
136
- declare function registryClientOptionsFromEnvironment(env?: EnvironmentSource): {
137
- baseUrl: string;
138
- token?: string;
139
- };
140
-
141
- /** Explicit inputs for {@link createNodeIdentityManagerFromDnsid}. */
142
- interface CreateNodeIdentityManagerFromDnsidOptions {
143
- /** Root DNSid directory containing config.json and <fqdn>/{private,public}.jwk. Defaults to `DNSID_CONFIG_DIR` or ~/.dnsid. */
144
- dnsidDir?: string;
145
- /** Environment used to discover DNSID_CONFIG_DIR. Defaults to process.env. */
146
- env?: Record<string, string | undefined>;
147
- /**
148
- * Caller settings. `identity` fields overlay the persisted publication fields before any
149
- * normalization or derivation; `verification` and `transport` are never read from the CLI files.
150
- */
151
- config?: Omit<DnsidConfig, 'identity'> & {
152
- identity?: Partial<IdentityConfig>;
153
- };
154
- }
155
44
  /**
156
45
  * Creates an IdentityManager with Node.js DNS and HTTPS defaults.
157
46
  *
@@ -164,34 +53,78 @@ interface CreateNodeIdentityManagerFromDnsidOptions {
164
53
  *
165
54
  * @example
166
55
  * ```ts
167
- * import { configFromEnvironment, createNodeIdentityManager, LocalKeyProvider } from '@dnsid-ai/sdk/node';
56
+ * import { createNodeIdentityManager, LocalKeyProvider } from '@dnsid-ai/sdk/node';
168
57
  *
169
- * const { config, keyStorePath } = configFromEnvironment();
170
- * const keyProvider = await LocalKeyProvider.load(keyStorePath ?? '.dnsid/keys.json', true);
171
- * const idm = await createNodeIdentityManager(config, { keyProvider, entityKeyProvider });
58
+ * const keyProvider = await LocalKeyProvider.load('.dnsid/keys.json', true);
59
+ * const idm = await createNodeIdentityManager({ identity, verification }, { keyProvider, entityKeyProvider });
172
60
  * ```
173
61
  */
174
62
  declare function createNodeIdentityManager(config: DnsidConfig, deps?: IdentityManagerDependencies): Promise<IdentityManager>;
175
63
  /** Creates a verification-only IdentityManager with Node.js DNS and HTTPS defaults (`config.identity` omitted). */
176
64
  declare function createNodeIdentityVerifier(config?: Omit<DnsidConfig, 'identity'>, deps?: Omit<IdentityManagerDependencies, 'keyProvider' | 'entityKeyProvider'>): Promise<IdentityManager>;
65
+
66
+ type EnvironmentSource = Readonly<Record<string, string | undefined>>;
67
+ /** Log trust for `deps.logRegistry`; exactly one variant is required at construction. */
68
+ interface LogTrust {
69
+ /** `true` selects the embedded DNSid-managed catalog. */
70
+ managed?: boolean;
71
+ /** `dnsid-c2sp-tlog-trust-profile@v1` document (parsed JSON). */
72
+ profile?: Record<string, unknown>;
73
+ /** Trusted C2SP `tlog-policy` bytes. */
74
+ policyDocument?: Uint8Array;
75
+ /** Trusted C2SP `tlog-policy` HTTPS URL. */
76
+ policyUrl?: string;
77
+ }
78
+ interface KeySource {
79
+ /** DNSid CLI identity directory; key files are located under the effective identity domain. */
80
+ cliDirectory?: string;
81
+ /** Accountable-entity private JWK file. */
82
+ entityKeyPath?: string;
83
+ /** `LocalKeyProvider` key-store file; used only when `cliDirectory` is absent. */
84
+ keyStorePath?: string;
85
+ }
86
+ interface LoadedRegistryConfig {
87
+ registryUrl?: string;
88
+ }
89
+ /** `DnsidConfig` with a partial `identity`: sources may supply some publication fields and leave the rest to an overlay. */
90
+ interface LoadedDnsidConfig extends Omit<DnsidConfig, 'identity'> {
91
+ identity?: Partial<IdentityConfig>;
92
+ }
93
+ /** Partial configuration from one source. Every field is present only when sourced. */
94
+ interface LoadedConfig {
95
+ dnsid?: LoadedDnsidConfig;
96
+ logTrust?: LogTrust;
97
+ registry?: LoadedRegistryConfig;
98
+ keySource?: KeySource;
99
+ }
100
+ /** Reads configuration from `DNSID_*`. Secrets such as `DNSID_API_KEY` stay out of `LoadedConfig`. */
101
+ declare function loadEnvironment(env?: EnvironmentSource): Promise<LoadedConfig>;
177
102
  /**
178
- * Creates an IdentityManager from a DNSid CLI directory layout (`~/.dnsid` by default).
179
- *
180
- * Reads `config.json` (following a `domain` pointer to a per-identity config when present) and
181
- * maps its publication fields into `config.identity`; caller `options.config.identity` values win
182
- * and are applied before normalization or `status_url` derivation. Key files are located by the
183
- * effective domain. Verification and transport settings come only from `options.config`. Supplied
184
- * `deps.keyProvider`/`deps.entityKeyProvider` win over loaded key files. The result is identical to
185
- * calling {@link createNodeIdentityManager} with the assembled configuration.
186
- *
187
- * @example
188
- * ```ts
189
- * import { createNodeIdentityManagerFromDnsid } from '@dnsid-ai/sdk/node';
190
- *
191
- * // Reads ~/.dnsid (or DNSID_CONFIG_DIR) for config.json and key files.
192
- * const idm = await createNodeIdentityManagerFromDnsid();
193
- * ```
103
+ * Reads a JSON deployment file: `{ dnsid?, logTrust?, registry? }`. Unknown members, mistyped
104
+ * values, and duplicate members are rejected; semantic `dnsid` validation stays with the constructor.
105
+ */
106
+ declare function loadFile(filePath: string): Promise<LoadedConfig>;
107
+ /**
108
+ * Reads a DNSid CLI directory (`~/.dnsid` by default): `config.json`, following a root `domain`
109
+ * pointer to `<domain>/config.json` when that file exists. Maps the snake_case publication fields
110
+ * into `dnsid.identity` and records the directory (and resolved `entity_key_path`) as `keySource`.
111
+ * Never consults `DNSID_CONFIG_DIR`.
112
+ */
113
+ declare function loadCliDirectory(dnsidDir?: string): Promise<LoadedConfig>;
114
+ /**
115
+ * Field-wise merge; presence wins, not truthiness. Lists replace. `logTrust` is replaced as a
116
+ * whole section when `overlay` sets any variant.
117
+ */
118
+ declare function mergeLoadedConfig(base: LoadedConfig, overlay: LoadedConfig): LoadedConfig;
119
+ /**
120
+ * Fills `deps.logRegistry` from `logTrust` and key providers from `keySource` only when the caller
121
+ * did not supply them, then calls {@link createNodeIdentityManager}. Adds no configuration values.
194
122
  */
195
- declare function createNodeIdentityManagerFromDnsid(options?: CreateNodeIdentityManagerFromDnsidOptions, deps?: IdentityManagerDependencies): Promise<IdentityManager>;
123
+ declare function constructIdentityManager(loaded: LoadedConfig, deps?: IdentityManagerDependencies): Promise<_dnsid_ai_protocol.IdentityManager>;
124
+ declare function createNodeIdentityManagerFromEnvironment(env?: EnvironmentSource, overlay?: LoadedDnsidConfig, deps?: IdentityManagerDependencies): Promise<_dnsid_ai_protocol.IdentityManager>;
125
+ declare function createNodeIdentityManagerFromDnsid(dnsidDir?: string, overlay?: LoadedDnsidConfig, deps?: IdentityManagerDependencies): Promise<_dnsid_ai_protocol.IdentityManager>;
126
+ declare function createNodeIdentityManagerFromFile(filePath: string, overlay?: LoadedDnsidConfig, deps?: IdentityManagerDependencies): Promise<_dnsid_ai_protocol.IdentityManager>;
127
+ /** `RegistryClient` from `DNSID_REGISTRY_URL` and `DNSID_API_KEY`; the constructor defaults to the local registry. */
128
+ declare function createRegistryClientFromEnvironment(env?: EnvironmentSource): Promise<RegistryClient>;
196
129
 
197
- export { type ConfigFromEnvironmentOptions, type CreateNodeIdentityManagerFromDnsidOptions, type DnsidEnvironment, type EnvironmentConfigResult, type EnvironmentFieldName, type LocalKeyAlgorithm, LocalKeyProvider, type LocalKeyProviderEnvironmentOptions, configFromEnvironment, createNodeIdentityManager, createNodeIdentityManagerFromDnsid, createNodeIdentityVerifier, dnsidEnvironmentVariables, keyStorePathFromEnvironment, registryClientOptionsFromEnvironment };
130
+ export { type EnvironmentSource, type KeySource, type LoadedConfig, type LoadedDnsidConfig, type LoadedRegistryConfig, type LocalKeyAlgorithm, LocalKeyProvider, type LogTrust, constructIdentityManager, createNodeIdentityManager, createNodeIdentityManagerFromDnsid, createNodeIdentityManagerFromEnvironment, createNodeIdentityManagerFromFile, createNodeIdentityVerifier, createRegistryClientFromEnvironment, loadCliDirectory, loadEnvironment, loadFile, mergeLoadedConfig };
package/dist/node.d.ts CHANGED
@@ -1,19 +1,12 @@
1
- import { KeyProvider, DnsIdJWK, DNSSECMode, DnsidConfig, IdentityConfig, IdentityManagerDependencies, IdentityManager } from '@dnsid-ai/protocol';
2
1
  export { CreateIdentityManagerDependencies } from './index.js';
2
+ import * as _dnsid_ai_protocol from '@dnsid-ai/protocol';
3
+ import { KeyProvider, DnsIdJWK, DnsidConfig, IdentityManagerDependencies, IdentityManager, IdentityConfig } from '@dnsid-ai/protocol';
4
+ import { RegistryClient } from '@dnsid-ai/registry';
3
5
  import '@dnsid-ai/jose';
4
6
  import '@dnsid-ai/http-signatures';
5
- import '@dnsid-ai/registry';
6
7
  import '@dnsid-ai/web-bot-auth';
7
8
 
8
9
  type LocalKeyAlgorithm = 'EdDSA' | 'ES256';
9
- interface LocalKeyProviderEnvironmentOptions {
10
- /** Default key-store path when the environment variable is absent. Default: .dnsid/keys.json. */
11
- defaultPath?: string;
12
- /** Create an initial key store if the file does not exist. Default: false. */
13
- createIfMissing?: boolean;
14
- /** Algorithm used when creating a missing key store. Default: EdDSA. */
15
- algorithm?: LocalKeyAlgorithm;
16
- }
17
10
  /**
18
11
  * File-backed KeyProvider that stores Ed25519 or ECDSA P-256 keys as a JSON file.
19
12
  *
@@ -30,7 +23,6 @@ declare class LocalKeyProvider implements KeyProvider {
30
23
  private mutations;
31
24
  private constructor();
32
25
  static load(filePath: string, createIfMissing?: boolean, algorithm?: LocalKeyAlgorithm): Promise<LocalKeyProvider>;
33
- static fromEnvironment(env?: Record<string, string | undefined>, options?: LocalKeyProviderEnvironmentOptions): Promise<LocalKeyProvider>;
34
26
  static generate(algorithm?: LocalKeyAlgorithm): Promise<LocalKeyProvider>;
35
27
  static fromDirectory(dir: string): Promise<LocalKeyProvider>;
36
28
  /** Loads a single private JWK file, including DNSid CLI `entity_key_path` files. */
@@ -48,110 +40,7 @@ declare class LocalKeyProvider implements KeyProvider {
48
40
  purge(kid: string): Promise<void>;
49
41
  private mutate;
50
42
  }
51
- declare function keyStorePathFromEnvironment(env?: Record<string, string | undefined>, defaultPath?: string): string;
52
43
 
53
- declare const dnsidEnvironmentVariables: {
54
- readonly domain: "DNSID_DOMAIN";
55
- readonly governanceId: "DNSID_GOVERNANCE_ID";
56
- readonly registryUrl: "DNSID_REGISTRY_URL";
57
- readonly apiKey: "DNSID_API_KEY";
58
- readonly statusUrl: "DNSID_STATUS_URL";
59
- readonly logRef: "DNSID_LOG_REF";
60
- readonly ekUrl: "DNSID_EK_URL";
61
- readonly kuUrl: "DNSID_KU_URL";
62
- readonly dnsServer: "DNSID_DNS_SERVER";
63
- readonly caBundlePath: "DNSID_CA_BUNDLE";
64
- readonly privateAddressHosts: "DNSID_PRIVATE_HOSTS";
65
- readonly dnssecMode: "DNSID_DNSSEC_MODE";
66
- readonly publicUrl: "DNSID_PUBLIC_URL";
67
- readonly keyStorePath: "DNSID_KEY_STORE";
68
- readonly agentPort: "DNSID_AGENT_PORT";
69
- readonly agentName: "DNSID_AGENT_NAME";
70
- };
71
- type EnvironmentFieldName = keyof typeof dnsidEnvironmentVariables;
72
- type EnvironmentVariableName = (typeof dnsidEnvironmentVariables)[EnvironmentFieldName];
73
- type EnvironmentSource = Record<string, string | undefined>;
74
- interface EnvironmentField<T> {
75
- variable: EnvironmentVariableName;
76
- parse(value: string, variable: EnvironmentVariableName): T;
77
- }
78
- declare const environmentSchema: {
79
- domain: EnvironmentField<string>;
80
- governanceId: EnvironmentField<string>;
81
- registryUrl: EnvironmentField<string>;
82
- apiKey: EnvironmentField<string>;
83
- statusUrl: EnvironmentField<string>;
84
- logRef: EnvironmentField<string>;
85
- ekUrl: EnvironmentField<string>;
86
- kuUrl: EnvironmentField<string>;
87
- dnsServer: EnvironmentField<string>;
88
- caBundlePath: EnvironmentField<string>;
89
- privateAddressHosts: EnvironmentField<string[] | undefined>;
90
- dnssecMode: EnvironmentField<DNSSECMode>;
91
- publicUrl: EnvironmentField<string>;
92
- keyStorePath: EnvironmentField<string>;
93
- agentPort: EnvironmentField<number>;
94
- agentName: EnvironmentField<string>;
95
- };
96
- type EnvironmentValue<K extends EnvironmentFieldName> = typeof environmentSchema[K] extends EnvironmentField<infer T> ? T : never;
97
- type DnsidEnvironment = {
98
- [K in EnvironmentFieldName]?: EnvironmentValue<K>;
99
- };
100
- type ConfigForEnvironment<RequiredFields extends EnvironmentFieldName> = DnsidConfig & {
101
- identity: IdentityConfig & Required<Pick<IdentityConfig, Extract<RequiredFields, keyof IdentityConfig>>>;
102
- };
103
- interface EnvironmentConfigResultBase<RequiredFields extends EnvironmentFieldName = never> {
104
- /** Core configuration: `identity` publication fields, `verification.dnssecMode`, and `transport` from the environment. */
105
- config: ConfigForEnvironment<RequiredFields>;
106
- /** Base URL of the DNSid registry for control-plane workflows. Defaults to the local registry ({@link DEFAULT_REGISTRY_URL}). Not core config. */
107
- registryUrl: string;
108
- /** Owner API key for registry workflows (`DNSID_API_KEY`); `dnsid local env` exports one for the local registry. */
109
- apiKey?: string;
110
- /** Optional public base URL for the agent, e.g. https://alice.example.com. */
111
- publicUrl?: string;
112
- /** Optional local key-store path for LocalKeyProvider. */
113
- keyStorePath?: string;
114
- /** Optional example/server display name. */
115
- agentName?: string;
116
- /** Optional example/server port. */
117
- agentPort?: number;
118
- }
119
- type EnvironmentConfigResult<RequiredFields extends EnvironmentFieldName = never> = EnvironmentConfigResultBase<RequiredFields> & Required<Pick<EnvironmentConfigResultBase<RequiredFields>, Extract<RequiredFields, keyof EnvironmentConfigResultBase<RequiredFields>>>>;
120
- interface ConfigFromEnvironmentOptions<RequiredFields extends EnvironmentFieldName = never> {
121
- require?: readonly RequiredFields[];
122
- }
123
- /**
124
- * Explicit loader mapping DNSID_* environment variables to a {@link DnsidConfig} plus
125
- * registry/example settings. Constructors never read the environment themselves.
126
- */
127
- declare function configFromEnvironment<const RequiredFields extends EnvironmentFieldName = never>(options?: ConfigFromEnvironmentOptions<RequiredFields>): EnvironmentConfigResult<RequiredFields>;
128
- declare function configFromEnvironment<const RequiredFields extends EnvironmentFieldName = never>(env: EnvironmentSource | undefined, options?: ConfigFromEnvironmentOptions<RequiredFields>): EnvironmentConfigResult<RequiredFields>;
129
- /**
130
- * Registry client options from `DNSID_REGISTRY_URL` and `DNSID_API_KEY`, the
131
- * variables `dnsid local env` exports. Unset means the local registry with no
132
- * credential. Unlike {@link configFromEnvironment} this needs no identity
133
- * variables, so it works before an agent exists:
134
- * `new RegistryClient(registryClientOptionsFromEnvironment())`.
135
- */
136
- declare function registryClientOptionsFromEnvironment(env?: EnvironmentSource): {
137
- baseUrl: string;
138
- token?: string;
139
- };
140
-
141
- /** Explicit inputs for {@link createNodeIdentityManagerFromDnsid}. */
142
- interface CreateNodeIdentityManagerFromDnsidOptions {
143
- /** Root DNSid directory containing config.json and <fqdn>/{private,public}.jwk. Defaults to `DNSID_CONFIG_DIR` or ~/.dnsid. */
144
- dnsidDir?: string;
145
- /** Environment used to discover DNSID_CONFIG_DIR. Defaults to process.env. */
146
- env?: Record<string, string | undefined>;
147
- /**
148
- * Caller settings. `identity` fields overlay the persisted publication fields before any
149
- * normalization or derivation; `verification` and `transport` are never read from the CLI files.
150
- */
151
- config?: Omit<DnsidConfig, 'identity'> & {
152
- identity?: Partial<IdentityConfig>;
153
- };
154
- }
155
44
  /**
156
45
  * Creates an IdentityManager with Node.js DNS and HTTPS defaults.
157
46
  *
@@ -164,34 +53,78 @@ interface CreateNodeIdentityManagerFromDnsidOptions {
164
53
  *
165
54
  * @example
166
55
  * ```ts
167
- * import { configFromEnvironment, createNodeIdentityManager, LocalKeyProvider } from '@dnsid-ai/sdk/node';
56
+ * import { createNodeIdentityManager, LocalKeyProvider } from '@dnsid-ai/sdk/node';
168
57
  *
169
- * const { config, keyStorePath } = configFromEnvironment();
170
- * const keyProvider = await LocalKeyProvider.load(keyStorePath ?? '.dnsid/keys.json', true);
171
- * const idm = await createNodeIdentityManager(config, { keyProvider, entityKeyProvider });
58
+ * const keyProvider = await LocalKeyProvider.load('.dnsid/keys.json', true);
59
+ * const idm = await createNodeIdentityManager({ identity, verification }, { keyProvider, entityKeyProvider });
172
60
  * ```
173
61
  */
174
62
  declare function createNodeIdentityManager(config: DnsidConfig, deps?: IdentityManagerDependencies): Promise<IdentityManager>;
175
63
  /** Creates a verification-only IdentityManager with Node.js DNS and HTTPS defaults (`config.identity` omitted). */
176
64
  declare function createNodeIdentityVerifier(config?: Omit<DnsidConfig, 'identity'>, deps?: Omit<IdentityManagerDependencies, 'keyProvider' | 'entityKeyProvider'>): Promise<IdentityManager>;
65
+
66
+ type EnvironmentSource = Readonly<Record<string, string | undefined>>;
67
+ /** Log trust for `deps.logRegistry`; exactly one variant is required at construction. */
68
+ interface LogTrust {
69
+ /** `true` selects the embedded DNSid-managed catalog. */
70
+ managed?: boolean;
71
+ /** `dnsid-c2sp-tlog-trust-profile@v1` document (parsed JSON). */
72
+ profile?: Record<string, unknown>;
73
+ /** Trusted C2SP `tlog-policy` bytes. */
74
+ policyDocument?: Uint8Array;
75
+ /** Trusted C2SP `tlog-policy` HTTPS URL. */
76
+ policyUrl?: string;
77
+ }
78
+ interface KeySource {
79
+ /** DNSid CLI identity directory; key files are located under the effective identity domain. */
80
+ cliDirectory?: string;
81
+ /** Accountable-entity private JWK file. */
82
+ entityKeyPath?: string;
83
+ /** `LocalKeyProvider` key-store file; used only when `cliDirectory` is absent. */
84
+ keyStorePath?: string;
85
+ }
86
+ interface LoadedRegistryConfig {
87
+ registryUrl?: string;
88
+ }
89
+ /** `DnsidConfig` with a partial `identity`: sources may supply some publication fields and leave the rest to an overlay. */
90
+ interface LoadedDnsidConfig extends Omit<DnsidConfig, 'identity'> {
91
+ identity?: Partial<IdentityConfig>;
92
+ }
93
+ /** Partial configuration from one source. Every field is present only when sourced. */
94
+ interface LoadedConfig {
95
+ dnsid?: LoadedDnsidConfig;
96
+ logTrust?: LogTrust;
97
+ registry?: LoadedRegistryConfig;
98
+ keySource?: KeySource;
99
+ }
100
+ /** Reads configuration from `DNSID_*`. Secrets such as `DNSID_API_KEY` stay out of `LoadedConfig`. */
101
+ declare function loadEnvironment(env?: EnvironmentSource): Promise<LoadedConfig>;
177
102
  /**
178
- * Creates an IdentityManager from a DNSid CLI directory layout (`~/.dnsid` by default).
179
- *
180
- * Reads `config.json` (following a `domain` pointer to a per-identity config when present) and
181
- * maps its publication fields into `config.identity`; caller `options.config.identity` values win
182
- * and are applied before normalization or `status_url` derivation. Key files are located by the
183
- * effective domain. Verification and transport settings come only from `options.config`. Supplied
184
- * `deps.keyProvider`/`deps.entityKeyProvider` win over loaded key files. The result is identical to
185
- * calling {@link createNodeIdentityManager} with the assembled configuration.
186
- *
187
- * @example
188
- * ```ts
189
- * import { createNodeIdentityManagerFromDnsid } from '@dnsid-ai/sdk/node';
190
- *
191
- * // Reads ~/.dnsid (or DNSID_CONFIG_DIR) for config.json and key files.
192
- * const idm = await createNodeIdentityManagerFromDnsid();
193
- * ```
103
+ * Reads a JSON deployment file: `{ dnsid?, logTrust?, registry? }`. Unknown members, mistyped
104
+ * values, and duplicate members are rejected; semantic `dnsid` validation stays with the constructor.
105
+ */
106
+ declare function loadFile(filePath: string): Promise<LoadedConfig>;
107
+ /**
108
+ * Reads a DNSid CLI directory (`~/.dnsid` by default): `config.json`, following a root `domain`
109
+ * pointer to `<domain>/config.json` when that file exists. Maps the snake_case publication fields
110
+ * into `dnsid.identity` and records the directory (and resolved `entity_key_path`) as `keySource`.
111
+ * Never consults `DNSID_CONFIG_DIR`.
112
+ */
113
+ declare function loadCliDirectory(dnsidDir?: string): Promise<LoadedConfig>;
114
+ /**
115
+ * Field-wise merge; presence wins, not truthiness. Lists replace. `logTrust` is replaced as a
116
+ * whole section when `overlay` sets any variant.
117
+ */
118
+ declare function mergeLoadedConfig(base: LoadedConfig, overlay: LoadedConfig): LoadedConfig;
119
+ /**
120
+ * Fills `deps.logRegistry` from `logTrust` and key providers from `keySource` only when the caller
121
+ * did not supply them, then calls {@link createNodeIdentityManager}. Adds no configuration values.
194
122
  */
195
- declare function createNodeIdentityManagerFromDnsid(options?: CreateNodeIdentityManagerFromDnsidOptions, deps?: IdentityManagerDependencies): Promise<IdentityManager>;
123
+ declare function constructIdentityManager(loaded: LoadedConfig, deps?: IdentityManagerDependencies): Promise<_dnsid_ai_protocol.IdentityManager>;
124
+ declare function createNodeIdentityManagerFromEnvironment(env?: EnvironmentSource, overlay?: LoadedDnsidConfig, deps?: IdentityManagerDependencies): Promise<_dnsid_ai_protocol.IdentityManager>;
125
+ declare function createNodeIdentityManagerFromDnsid(dnsidDir?: string, overlay?: LoadedDnsidConfig, deps?: IdentityManagerDependencies): Promise<_dnsid_ai_protocol.IdentityManager>;
126
+ declare function createNodeIdentityManagerFromFile(filePath: string, overlay?: LoadedDnsidConfig, deps?: IdentityManagerDependencies): Promise<_dnsid_ai_protocol.IdentityManager>;
127
+ /** `RegistryClient` from `DNSID_REGISTRY_URL` and `DNSID_API_KEY`; the constructor defaults to the local registry. */
128
+ declare function createRegistryClientFromEnvironment(env?: EnvironmentSource): Promise<RegistryClient>;
196
129
 
197
- export { type ConfigFromEnvironmentOptions, type CreateNodeIdentityManagerFromDnsidOptions, type DnsidEnvironment, type EnvironmentConfigResult, type EnvironmentFieldName, type LocalKeyAlgorithm, LocalKeyProvider, type LocalKeyProviderEnvironmentOptions, configFromEnvironment, createNodeIdentityManager, createNodeIdentityManagerFromDnsid, createNodeIdentityVerifier, dnsidEnvironmentVariables, keyStorePathFromEnvironment, registryClientOptionsFromEnvironment };
130
+ export { type EnvironmentSource, type KeySource, type LoadedConfig, type LoadedDnsidConfig, type LoadedRegistryConfig, type LocalKeyAlgorithm, LocalKeyProvider, type LogTrust, constructIdentityManager, createNodeIdentityManager, createNodeIdentityManagerFromDnsid, createNodeIdentityManagerFromEnvironment, createNodeIdentityManagerFromFile, createNodeIdentityVerifier, createRegistryClientFromEnvironment, loadCliDirectory, loadEnvironment, loadFile, mergeLoadedConfig };