@dnsid-ai/sdk 0.20.1
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/LICENSE +201 -0
- package/README.md +121 -0
- package/dist/index.cjs +657 -0
- package/dist/index.d.cts +210 -0
- package/dist/index.d.ts +210 -0
- package/dist/index.js +625 -0
- package/dist/node.cjs +560 -0
- package/dist/node.d.cts +195 -0
- package/dist/node.d.ts +195 -0
- package/dist/node.js +518 -0
- package/package.json +61 -0
package/dist/node.d.cts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { KeyProvider, DnsIdJWK, DNSSECMode, DnsidConfig, IdentityConfig, IdentityManagerDependencies, IdentityManager } from '@dnsid-ai/protocol';
|
|
2
|
+
export { CreateIdentityManagerDependencies } from './index.cjs';
|
|
3
|
+
import '@dnsid-ai/jose';
|
|
4
|
+
import '@dnsid-ai/http-signatures';
|
|
5
|
+
import '@dnsid-ai/registry';
|
|
6
|
+
import '@dnsid-ai/web-bot-auth';
|
|
7
|
+
|
|
8
|
+
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
|
+
/**
|
|
18
|
+
* File-backed KeyProvider that stores Ed25519 or ECDSA P-256 keys as a JSON file.
|
|
19
|
+
*
|
|
20
|
+
* This concrete key-storage implementation is provided by `@dnsid-ai/sdk` as the default developer/runtime key provider.
|
|
21
|
+
* Use only one provider instance/process per file. Mutations within an instance are serialized.
|
|
22
|
+
* Writes require filesystem support for atomic rename, hard links, and directory fsync.
|
|
23
|
+
* Existing symlinks are resolved at load time; `<resolvedPath>.bak` holds the private previous generation.
|
|
24
|
+
* A failure after replacement may mean the new state is visible but not crash-durable;
|
|
25
|
+
* memory follows the visible file. Inspect the store before retrying a failed mutation.
|
|
26
|
+
*/
|
|
27
|
+
declare class LocalKeyProvider implements KeyProvider {
|
|
28
|
+
private store;
|
|
29
|
+
private readonly filePath;
|
|
30
|
+
private mutations;
|
|
31
|
+
private constructor();
|
|
32
|
+
static load(filePath: string, createIfMissing?: boolean, algorithm?: LocalKeyAlgorithm): Promise<LocalKeyProvider>;
|
|
33
|
+
static fromEnvironment(env?: Record<string, string | undefined>, options?: LocalKeyProviderEnvironmentOptions): Promise<LocalKeyProvider>;
|
|
34
|
+
static generate(algorithm?: LocalKeyAlgorithm): Promise<LocalKeyProvider>;
|
|
35
|
+
static fromDirectory(dir: string): Promise<LocalKeyProvider>;
|
|
36
|
+
/** Loads a single private JWK file, including DNSid CLI `entity_key_path` files. */
|
|
37
|
+
static fromFile(filePath: string): Promise<LocalKeyProvider>;
|
|
38
|
+
static fromDomain(domain: string, dnsidDir?: string): Promise<LocalKeyProvider>;
|
|
39
|
+
signingKey(): Promise<DnsIdJWK>;
|
|
40
|
+
jwk(kid: string): Promise<DnsIdJWK>;
|
|
41
|
+
listKeyIds(): Promise<string[]>;
|
|
42
|
+
sign(payload: Uint8Array): Promise<Uint8Array>;
|
|
43
|
+
signKey(kid: string, payload: Uint8Array): Promise<Uint8Array>;
|
|
44
|
+
generateKey(): Promise<string>;
|
|
45
|
+
activate(kid: string): Promise<void>;
|
|
46
|
+
supersede(kid: string): Promise<void>;
|
|
47
|
+
/** @deprecated Use supersede(). */
|
|
48
|
+
purge(kid: string): Promise<void>;
|
|
49
|
+
private mutate;
|
|
50
|
+
}
|
|
51
|
+
declare function keyStorePathFromEnvironment(env?: Record<string, string | undefined>, defaultPath?: string): string;
|
|
52
|
+
|
|
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 dnssecMode: "DNSID_DNSSEC_MODE";
|
|
65
|
+
readonly publicUrl: "DNSID_PUBLIC_URL";
|
|
66
|
+
readonly keyStorePath: "DNSID_KEY_STORE";
|
|
67
|
+
readonly agentPort: "DNSID_AGENT_PORT";
|
|
68
|
+
readonly agentName: "DNSID_AGENT_NAME";
|
|
69
|
+
};
|
|
70
|
+
type EnvironmentFieldName = keyof typeof dnsidEnvironmentVariables;
|
|
71
|
+
type EnvironmentVariableName = (typeof dnsidEnvironmentVariables)[EnvironmentFieldName];
|
|
72
|
+
type EnvironmentSource = Record<string, string | undefined>;
|
|
73
|
+
interface EnvironmentField<T> {
|
|
74
|
+
variable: EnvironmentVariableName;
|
|
75
|
+
parse(value: string, variable: EnvironmentVariableName): T;
|
|
76
|
+
}
|
|
77
|
+
declare const environmentSchema: {
|
|
78
|
+
domain: EnvironmentField<string>;
|
|
79
|
+
governanceId: EnvironmentField<string>;
|
|
80
|
+
registryUrl: EnvironmentField<string>;
|
|
81
|
+
apiKey: EnvironmentField<string>;
|
|
82
|
+
statusUrl: EnvironmentField<string>;
|
|
83
|
+
logRef: EnvironmentField<string>;
|
|
84
|
+
ekUrl: EnvironmentField<string>;
|
|
85
|
+
kuUrl: EnvironmentField<string>;
|
|
86
|
+
dnsServer: EnvironmentField<string>;
|
|
87
|
+
caBundlePath: EnvironmentField<string>;
|
|
88
|
+
dnssecMode: EnvironmentField<DNSSECMode>;
|
|
89
|
+
publicUrl: EnvironmentField<string>;
|
|
90
|
+
keyStorePath: EnvironmentField<string>;
|
|
91
|
+
agentPort: EnvironmentField<number>;
|
|
92
|
+
agentName: EnvironmentField<string>;
|
|
93
|
+
};
|
|
94
|
+
type EnvironmentValue<K extends EnvironmentFieldName> = typeof environmentSchema[K] extends EnvironmentField<infer T> ? T : never;
|
|
95
|
+
type DnsidEnvironment = {
|
|
96
|
+
[K in EnvironmentFieldName]?: EnvironmentValue<K>;
|
|
97
|
+
};
|
|
98
|
+
type ConfigForEnvironment<RequiredFields extends EnvironmentFieldName> = DnsidConfig & {
|
|
99
|
+
identity: IdentityConfig & Required<Pick<IdentityConfig, Extract<RequiredFields, keyof IdentityConfig>>>;
|
|
100
|
+
};
|
|
101
|
+
interface EnvironmentConfigResultBase<RequiredFields extends EnvironmentFieldName = never> {
|
|
102
|
+
/** Core configuration: `identity` publication fields, `verification.dnssecMode`, and `transport` from the environment. */
|
|
103
|
+
config: ConfigForEnvironment<RequiredFields>;
|
|
104
|
+
/** Base URL of the DNSid registry for control-plane workflows. Defaults to the local registry ({@link DEFAULT_REGISTRY_URL}). Not core config. */
|
|
105
|
+
registryUrl: string;
|
|
106
|
+
/** Owner API key for registry workflows (`DNSID_API_KEY`); `dnsid local env` exports one for the local registry. */
|
|
107
|
+
apiKey?: string;
|
|
108
|
+
/** Optional public base URL for the agent, e.g. https://alice.example.com. */
|
|
109
|
+
publicUrl?: string;
|
|
110
|
+
/** Optional local key-store path for LocalKeyProvider. */
|
|
111
|
+
keyStorePath?: string;
|
|
112
|
+
/** Optional example/server display name. */
|
|
113
|
+
agentName?: string;
|
|
114
|
+
/** Optional example/server port. */
|
|
115
|
+
agentPort?: number;
|
|
116
|
+
}
|
|
117
|
+
type EnvironmentConfigResult<RequiredFields extends EnvironmentFieldName = never> = EnvironmentConfigResultBase<RequiredFields> & Required<Pick<EnvironmentConfigResultBase<RequiredFields>, Extract<RequiredFields, keyof EnvironmentConfigResultBase<RequiredFields>>>>;
|
|
118
|
+
interface ConfigFromEnvironmentOptions<RequiredFields extends EnvironmentFieldName = never> {
|
|
119
|
+
require?: readonly RequiredFields[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Explicit loader mapping DNSID_* environment variables to a {@link DnsidConfig} plus
|
|
123
|
+
* registry/example settings. Constructors never read the environment themselves.
|
|
124
|
+
*/
|
|
125
|
+
declare function configFromEnvironment<const RequiredFields extends EnvironmentFieldName = never>(options?: ConfigFromEnvironmentOptions<RequiredFields>): EnvironmentConfigResult<RequiredFields>;
|
|
126
|
+
declare function configFromEnvironment<const RequiredFields extends EnvironmentFieldName = never>(env: EnvironmentSource | undefined, options?: ConfigFromEnvironmentOptions<RequiredFields>): EnvironmentConfigResult<RequiredFields>;
|
|
127
|
+
/**
|
|
128
|
+
* Registry client options from `DNSID_REGISTRY_URL` and `DNSID_API_KEY`, the
|
|
129
|
+
* variables `dnsid local env` exports. Unset means the local registry with no
|
|
130
|
+
* credential. Unlike {@link configFromEnvironment} this needs no identity
|
|
131
|
+
* variables, so it works before an agent exists:
|
|
132
|
+
* `new RegistryClient(registryClientOptionsFromEnvironment())`.
|
|
133
|
+
*/
|
|
134
|
+
declare function registryClientOptionsFromEnvironment(env?: EnvironmentSource): {
|
|
135
|
+
baseUrl: string;
|
|
136
|
+
token?: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/** Explicit inputs for {@link createNodeIdentityManagerFromDnsid}. */
|
|
140
|
+
interface CreateNodeIdentityManagerFromDnsidOptions {
|
|
141
|
+
/** Root DNSid directory containing config.json and <fqdn>/{private,public}.jwk. Defaults to `DNSID_CONFIG_DIR` or ~/.dnsid. */
|
|
142
|
+
dnsidDir?: string;
|
|
143
|
+
/** Environment used to discover DNSID_CONFIG_DIR. Defaults to process.env. */
|
|
144
|
+
env?: Record<string, string | undefined>;
|
|
145
|
+
/**
|
|
146
|
+
* Caller settings. `identity` fields overlay the persisted publication fields before any
|
|
147
|
+
* normalization or derivation; `verification` and `transport` are never read from the CLI files.
|
|
148
|
+
*/
|
|
149
|
+
config?: Omit<DnsidConfig, 'identity'> & {
|
|
150
|
+
identity?: Partial<IdentityConfig>;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Creates an IdentityManager with Node.js DNS and HTTPS defaults.
|
|
155
|
+
*
|
|
156
|
+
* `config.transport` configures only the SDK-managed defaults: `dnsServer` applies to whichever of
|
|
157
|
+
* `dnsResolver`/`fetchJson` is not injected and is rejected when both are; `caBundlePath` and
|
|
158
|
+
* `allowedUnsafeHosts` apply to the default fetcher and are rejected when `fetchJson` is injected. Injected dependencies are never
|
|
159
|
+
* inspected or modified. `@dnsid-ai/transport` is an optional peer; install it or inject both
|
|
160
|
+
* dependencies. The system resolver reports `UNKNOWN`; `validated`/`required` DNSSEC modes need a
|
|
161
|
+
* DNSSEC-aware resolver.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { configFromEnvironment, createNodeIdentityManager, LocalKeyProvider } from '@dnsid-ai/sdk/node';
|
|
166
|
+
*
|
|
167
|
+
* const { config, keyStorePath } = configFromEnvironment();
|
|
168
|
+
* const keyProvider = await LocalKeyProvider.load(keyStorePath ?? '.dnsid/keys.json', true);
|
|
169
|
+
* const idm = await createNodeIdentityManager(config, { keyProvider, entityKeyProvider });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
declare function createNodeIdentityManager(config: DnsidConfig, deps?: IdentityManagerDependencies): Promise<IdentityManager>;
|
|
173
|
+
/** Creates a verification-only IdentityManager with Node.js DNS and HTTPS defaults (`config.identity` omitted). */
|
|
174
|
+
declare function createNodeIdentityVerifier(config?: Omit<DnsidConfig, 'identity'>, deps?: Omit<IdentityManagerDependencies, 'keyProvider' | 'entityKeyProvider'>): Promise<IdentityManager>;
|
|
175
|
+
/**
|
|
176
|
+
* Creates an IdentityManager from a DNSid CLI directory layout (`~/.dnsid` by default).
|
|
177
|
+
*
|
|
178
|
+
* Reads `config.json` (following a `domain` pointer to a per-identity config when present) and
|
|
179
|
+
* maps its publication fields into `config.identity`; caller `options.config.identity` values win
|
|
180
|
+
* and are applied before normalization or `status_url` derivation. Key files are located by the
|
|
181
|
+
* effective domain. Verification and transport settings come only from `options.config`. Supplied
|
|
182
|
+
* `deps.keyProvider`/`deps.entityKeyProvider` win over loaded key files. The result is identical to
|
|
183
|
+
* calling {@link createNodeIdentityManager} with the assembled configuration.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { createNodeIdentityManagerFromDnsid } from '@dnsid-ai/sdk/node';
|
|
188
|
+
*
|
|
189
|
+
* // Reads ~/.dnsid (or DNSID_CONFIG_DIR) for config.json and key files.
|
|
190
|
+
* const idm = await createNodeIdentityManagerFromDnsid();
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare function createNodeIdentityManagerFromDnsid(options?: CreateNodeIdentityManagerFromDnsidOptions, deps?: IdentityManagerDependencies): Promise<IdentityManager>;
|
|
194
|
+
|
|
195
|
+
export { type ConfigFromEnvironmentOptions, type CreateNodeIdentityManagerFromDnsidOptions, type DnsidEnvironment, type EnvironmentConfigResult, type EnvironmentFieldName, type LocalKeyAlgorithm, LocalKeyProvider, type LocalKeyProviderEnvironmentOptions, configFromEnvironment, createNodeIdentityManager, createNodeIdentityManagerFromDnsid, createNodeIdentityVerifier, dnsidEnvironmentVariables, keyStorePathFromEnvironment, registryClientOptionsFromEnvironment };
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { KeyProvider, DnsIdJWK, DNSSECMode, DnsidConfig, IdentityConfig, IdentityManagerDependencies, IdentityManager } from '@dnsid-ai/protocol';
|
|
2
|
+
export { CreateIdentityManagerDependencies } from './index.js';
|
|
3
|
+
import '@dnsid-ai/jose';
|
|
4
|
+
import '@dnsid-ai/http-signatures';
|
|
5
|
+
import '@dnsid-ai/registry';
|
|
6
|
+
import '@dnsid-ai/web-bot-auth';
|
|
7
|
+
|
|
8
|
+
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
|
+
/**
|
|
18
|
+
* File-backed KeyProvider that stores Ed25519 or ECDSA P-256 keys as a JSON file.
|
|
19
|
+
*
|
|
20
|
+
* This concrete key-storage implementation is provided by `@dnsid-ai/sdk` as the default developer/runtime key provider.
|
|
21
|
+
* Use only one provider instance/process per file. Mutations within an instance are serialized.
|
|
22
|
+
* Writes require filesystem support for atomic rename, hard links, and directory fsync.
|
|
23
|
+
* Existing symlinks are resolved at load time; `<resolvedPath>.bak` holds the private previous generation.
|
|
24
|
+
* A failure after replacement may mean the new state is visible but not crash-durable;
|
|
25
|
+
* memory follows the visible file. Inspect the store before retrying a failed mutation.
|
|
26
|
+
*/
|
|
27
|
+
declare class LocalKeyProvider implements KeyProvider {
|
|
28
|
+
private store;
|
|
29
|
+
private readonly filePath;
|
|
30
|
+
private mutations;
|
|
31
|
+
private constructor();
|
|
32
|
+
static load(filePath: string, createIfMissing?: boolean, algorithm?: LocalKeyAlgorithm): Promise<LocalKeyProvider>;
|
|
33
|
+
static fromEnvironment(env?: Record<string, string | undefined>, options?: LocalKeyProviderEnvironmentOptions): Promise<LocalKeyProvider>;
|
|
34
|
+
static generate(algorithm?: LocalKeyAlgorithm): Promise<LocalKeyProvider>;
|
|
35
|
+
static fromDirectory(dir: string): Promise<LocalKeyProvider>;
|
|
36
|
+
/** Loads a single private JWK file, including DNSid CLI `entity_key_path` files. */
|
|
37
|
+
static fromFile(filePath: string): Promise<LocalKeyProvider>;
|
|
38
|
+
static fromDomain(domain: string, dnsidDir?: string): Promise<LocalKeyProvider>;
|
|
39
|
+
signingKey(): Promise<DnsIdJWK>;
|
|
40
|
+
jwk(kid: string): Promise<DnsIdJWK>;
|
|
41
|
+
listKeyIds(): Promise<string[]>;
|
|
42
|
+
sign(payload: Uint8Array): Promise<Uint8Array>;
|
|
43
|
+
signKey(kid: string, payload: Uint8Array): Promise<Uint8Array>;
|
|
44
|
+
generateKey(): Promise<string>;
|
|
45
|
+
activate(kid: string): Promise<void>;
|
|
46
|
+
supersede(kid: string): Promise<void>;
|
|
47
|
+
/** @deprecated Use supersede(). */
|
|
48
|
+
purge(kid: string): Promise<void>;
|
|
49
|
+
private mutate;
|
|
50
|
+
}
|
|
51
|
+
declare function keyStorePathFromEnvironment(env?: Record<string, string | undefined>, defaultPath?: string): string;
|
|
52
|
+
|
|
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 dnssecMode: "DNSID_DNSSEC_MODE";
|
|
65
|
+
readonly publicUrl: "DNSID_PUBLIC_URL";
|
|
66
|
+
readonly keyStorePath: "DNSID_KEY_STORE";
|
|
67
|
+
readonly agentPort: "DNSID_AGENT_PORT";
|
|
68
|
+
readonly agentName: "DNSID_AGENT_NAME";
|
|
69
|
+
};
|
|
70
|
+
type EnvironmentFieldName = keyof typeof dnsidEnvironmentVariables;
|
|
71
|
+
type EnvironmentVariableName = (typeof dnsidEnvironmentVariables)[EnvironmentFieldName];
|
|
72
|
+
type EnvironmentSource = Record<string, string | undefined>;
|
|
73
|
+
interface EnvironmentField<T> {
|
|
74
|
+
variable: EnvironmentVariableName;
|
|
75
|
+
parse(value: string, variable: EnvironmentVariableName): T;
|
|
76
|
+
}
|
|
77
|
+
declare const environmentSchema: {
|
|
78
|
+
domain: EnvironmentField<string>;
|
|
79
|
+
governanceId: EnvironmentField<string>;
|
|
80
|
+
registryUrl: EnvironmentField<string>;
|
|
81
|
+
apiKey: EnvironmentField<string>;
|
|
82
|
+
statusUrl: EnvironmentField<string>;
|
|
83
|
+
logRef: EnvironmentField<string>;
|
|
84
|
+
ekUrl: EnvironmentField<string>;
|
|
85
|
+
kuUrl: EnvironmentField<string>;
|
|
86
|
+
dnsServer: EnvironmentField<string>;
|
|
87
|
+
caBundlePath: EnvironmentField<string>;
|
|
88
|
+
dnssecMode: EnvironmentField<DNSSECMode>;
|
|
89
|
+
publicUrl: EnvironmentField<string>;
|
|
90
|
+
keyStorePath: EnvironmentField<string>;
|
|
91
|
+
agentPort: EnvironmentField<number>;
|
|
92
|
+
agentName: EnvironmentField<string>;
|
|
93
|
+
};
|
|
94
|
+
type EnvironmentValue<K extends EnvironmentFieldName> = typeof environmentSchema[K] extends EnvironmentField<infer T> ? T : never;
|
|
95
|
+
type DnsidEnvironment = {
|
|
96
|
+
[K in EnvironmentFieldName]?: EnvironmentValue<K>;
|
|
97
|
+
};
|
|
98
|
+
type ConfigForEnvironment<RequiredFields extends EnvironmentFieldName> = DnsidConfig & {
|
|
99
|
+
identity: IdentityConfig & Required<Pick<IdentityConfig, Extract<RequiredFields, keyof IdentityConfig>>>;
|
|
100
|
+
};
|
|
101
|
+
interface EnvironmentConfigResultBase<RequiredFields extends EnvironmentFieldName = never> {
|
|
102
|
+
/** Core configuration: `identity` publication fields, `verification.dnssecMode`, and `transport` from the environment. */
|
|
103
|
+
config: ConfigForEnvironment<RequiredFields>;
|
|
104
|
+
/** Base URL of the DNSid registry for control-plane workflows. Defaults to the local registry ({@link DEFAULT_REGISTRY_URL}). Not core config. */
|
|
105
|
+
registryUrl: string;
|
|
106
|
+
/** Owner API key for registry workflows (`DNSID_API_KEY`); `dnsid local env` exports one for the local registry. */
|
|
107
|
+
apiKey?: string;
|
|
108
|
+
/** Optional public base URL for the agent, e.g. https://alice.example.com. */
|
|
109
|
+
publicUrl?: string;
|
|
110
|
+
/** Optional local key-store path for LocalKeyProvider. */
|
|
111
|
+
keyStorePath?: string;
|
|
112
|
+
/** Optional example/server display name. */
|
|
113
|
+
agentName?: string;
|
|
114
|
+
/** Optional example/server port. */
|
|
115
|
+
agentPort?: number;
|
|
116
|
+
}
|
|
117
|
+
type EnvironmentConfigResult<RequiredFields extends EnvironmentFieldName = never> = EnvironmentConfigResultBase<RequiredFields> & Required<Pick<EnvironmentConfigResultBase<RequiredFields>, Extract<RequiredFields, keyof EnvironmentConfigResultBase<RequiredFields>>>>;
|
|
118
|
+
interface ConfigFromEnvironmentOptions<RequiredFields extends EnvironmentFieldName = never> {
|
|
119
|
+
require?: readonly RequiredFields[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Explicit loader mapping DNSID_* environment variables to a {@link DnsidConfig} plus
|
|
123
|
+
* registry/example settings. Constructors never read the environment themselves.
|
|
124
|
+
*/
|
|
125
|
+
declare function configFromEnvironment<const RequiredFields extends EnvironmentFieldName = never>(options?: ConfigFromEnvironmentOptions<RequiredFields>): EnvironmentConfigResult<RequiredFields>;
|
|
126
|
+
declare function configFromEnvironment<const RequiredFields extends EnvironmentFieldName = never>(env: EnvironmentSource | undefined, options?: ConfigFromEnvironmentOptions<RequiredFields>): EnvironmentConfigResult<RequiredFields>;
|
|
127
|
+
/**
|
|
128
|
+
* Registry client options from `DNSID_REGISTRY_URL` and `DNSID_API_KEY`, the
|
|
129
|
+
* variables `dnsid local env` exports. Unset means the local registry with no
|
|
130
|
+
* credential. Unlike {@link configFromEnvironment} this needs no identity
|
|
131
|
+
* variables, so it works before an agent exists:
|
|
132
|
+
* `new RegistryClient(registryClientOptionsFromEnvironment())`.
|
|
133
|
+
*/
|
|
134
|
+
declare function registryClientOptionsFromEnvironment(env?: EnvironmentSource): {
|
|
135
|
+
baseUrl: string;
|
|
136
|
+
token?: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/** Explicit inputs for {@link createNodeIdentityManagerFromDnsid}. */
|
|
140
|
+
interface CreateNodeIdentityManagerFromDnsidOptions {
|
|
141
|
+
/** Root DNSid directory containing config.json and <fqdn>/{private,public}.jwk. Defaults to `DNSID_CONFIG_DIR` or ~/.dnsid. */
|
|
142
|
+
dnsidDir?: string;
|
|
143
|
+
/** Environment used to discover DNSID_CONFIG_DIR. Defaults to process.env. */
|
|
144
|
+
env?: Record<string, string | undefined>;
|
|
145
|
+
/**
|
|
146
|
+
* Caller settings. `identity` fields overlay the persisted publication fields before any
|
|
147
|
+
* normalization or derivation; `verification` and `transport` are never read from the CLI files.
|
|
148
|
+
*/
|
|
149
|
+
config?: Omit<DnsidConfig, 'identity'> & {
|
|
150
|
+
identity?: Partial<IdentityConfig>;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Creates an IdentityManager with Node.js DNS and HTTPS defaults.
|
|
155
|
+
*
|
|
156
|
+
* `config.transport` configures only the SDK-managed defaults: `dnsServer` applies to whichever of
|
|
157
|
+
* `dnsResolver`/`fetchJson` is not injected and is rejected when both are; `caBundlePath` and
|
|
158
|
+
* `allowedUnsafeHosts` apply to the default fetcher and are rejected when `fetchJson` is injected. Injected dependencies are never
|
|
159
|
+
* inspected or modified. `@dnsid-ai/transport` is an optional peer; install it or inject both
|
|
160
|
+
* dependencies. The system resolver reports `UNKNOWN`; `validated`/`required` DNSSEC modes need a
|
|
161
|
+
* DNSSEC-aware resolver.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { configFromEnvironment, createNodeIdentityManager, LocalKeyProvider } from '@dnsid-ai/sdk/node';
|
|
166
|
+
*
|
|
167
|
+
* const { config, keyStorePath } = configFromEnvironment();
|
|
168
|
+
* const keyProvider = await LocalKeyProvider.load(keyStorePath ?? '.dnsid/keys.json', true);
|
|
169
|
+
* const idm = await createNodeIdentityManager(config, { keyProvider, entityKeyProvider });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
declare function createNodeIdentityManager(config: DnsidConfig, deps?: IdentityManagerDependencies): Promise<IdentityManager>;
|
|
173
|
+
/** Creates a verification-only IdentityManager with Node.js DNS and HTTPS defaults (`config.identity` omitted). */
|
|
174
|
+
declare function createNodeIdentityVerifier(config?: Omit<DnsidConfig, 'identity'>, deps?: Omit<IdentityManagerDependencies, 'keyProvider' | 'entityKeyProvider'>): Promise<IdentityManager>;
|
|
175
|
+
/**
|
|
176
|
+
* Creates an IdentityManager from a DNSid CLI directory layout (`~/.dnsid` by default).
|
|
177
|
+
*
|
|
178
|
+
* Reads `config.json` (following a `domain` pointer to a per-identity config when present) and
|
|
179
|
+
* maps its publication fields into `config.identity`; caller `options.config.identity` values win
|
|
180
|
+
* and are applied before normalization or `status_url` derivation. Key files are located by the
|
|
181
|
+
* effective domain. Verification and transport settings come only from `options.config`. Supplied
|
|
182
|
+
* `deps.keyProvider`/`deps.entityKeyProvider` win over loaded key files. The result is identical to
|
|
183
|
+
* calling {@link createNodeIdentityManager} with the assembled configuration.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { createNodeIdentityManagerFromDnsid } from '@dnsid-ai/sdk/node';
|
|
188
|
+
*
|
|
189
|
+
* // Reads ~/.dnsid (or DNSID_CONFIG_DIR) for config.json and key files.
|
|
190
|
+
* const idm = await createNodeIdentityManagerFromDnsid();
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare function createNodeIdentityManagerFromDnsid(options?: CreateNodeIdentityManagerFromDnsidOptions, deps?: IdentityManagerDependencies): Promise<IdentityManager>;
|
|
194
|
+
|
|
195
|
+
export { type ConfigFromEnvironmentOptions, type CreateNodeIdentityManagerFromDnsidOptions, type DnsidEnvironment, type EnvironmentConfigResult, type EnvironmentFieldName, type LocalKeyAlgorithm, LocalKeyProvider, type LocalKeyProviderEnvironmentOptions, configFromEnvironment, createNodeIdentityManager, createNodeIdentityManagerFromDnsid, createNodeIdentityVerifier, dnsidEnvironmentVariables, keyStorePathFromEnvironment, registryClientOptionsFromEnvironment };
|