@dnsid-ai/oidc 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 +94 -0
- package/dist/index.cjs +911 -0
- package/dist/index.d.cts +386 -0
- package/dist/index.d.ts +386 -0
- package/dist/index.js +884 -0
- package/package.json +48 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { JWTPayload } from 'jose';
|
|
2
|
+
import { KeyProvider, DnsIdJWK, SigningIdentityManager, IdentityResolver, VerificationOptions, TLSCertificate, VerifiedDomain } from '@dnsid-ai/protocol';
|
|
3
|
+
|
|
4
|
+
/** Tunable OIDC policy for an {@link OIDCProfile}. All members are optional; defaults noted per member. */
|
|
5
|
+
interface OIDCProfileConfig {
|
|
6
|
+
/** Scope requested when a token exchange does not specify one. Defaults to 'openid'. */
|
|
7
|
+
defaultScope?: string;
|
|
8
|
+
/** Lifetime of minted client assertions, in seconds. Defaults to 300. */
|
|
9
|
+
assertionLifetime?: number;
|
|
10
|
+
/** Upper bound on any requested assertion lifetime, in seconds. Defaults to 900. */
|
|
11
|
+
maxAssertionLifetime?: number;
|
|
12
|
+
/** Clock skew tolerated when validating token timestamps, in seconds. Defaults to 30. */
|
|
13
|
+
clockSkew?: number;
|
|
14
|
+
/** Timeout for discovery, JWKS, and token-endpoint requests, in milliseconds. Defaults to 10000. */
|
|
15
|
+
fetchTimeoutMs?: number;
|
|
16
|
+
/** Exact issuer URLs `verifyOIDCToken()` accepts. When absent or empty, verification always fails. */
|
|
17
|
+
allowedIssuers?: string[];
|
|
18
|
+
/** JWS algorithms accepted on inbound OIDC tokens. Defaults to ['RS256']. */
|
|
19
|
+
allowedTokenAlgorithms?: string[];
|
|
20
|
+
/** Permit plain-HTTP loopback issuers (localhost, 127.x, ::1) for local testing. Defaults to false. */
|
|
21
|
+
allowHttpLoopbackIssuer?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Constructor options for {@link OIDCProfile}. */
|
|
24
|
+
interface OIDCProfileOptions {
|
|
25
|
+
/** Agent FQDN; becomes the iss/sub/fqdn claims of minted assertions. */
|
|
26
|
+
domain: string;
|
|
27
|
+
/** Provider used to sign client assertions. Omit for a verification-only profile. */
|
|
28
|
+
keyProvider?: KeyProvider;
|
|
29
|
+
/** Resolver used by `verifyOIDCToken()` to verify token subjects as DNSid identity records. */
|
|
30
|
+
identityResolver?: IdentityResolver;
|
|
31
|
+
/** Custom fetch replaces the SSRF-safe Node default; inject only trusted/test transports with equivalent DNS safety. */
|
|
32
|
+
fetch?: typeof globalThis.fetch;
|
|
33
|
+
/** OIDC policy overrides; see {@link OIDCProfileConfig}. */
|
|
34
|
+
oidc?: OIDCProfileConfig;
|
|
35
|
+
}
|
|
36
|
+
/** Options for minting a JWT bearer client assertion. */
|
|
37
|
+
interface OIDCAssertionOptions {
|
|
38
|
+
/** OIDC issuer the assertion is addressed to; becomes the aud claim. */
|
|
39
|
+
issuer: string;
|
|
40
|
+
/** Assertion lifetime in seconds; overrides the configured default, capped by maxAssertionLifetime. */
|
|
41
|
+
expiry?: number;
|
|
42
|
+
/** Extra claims to embed. Must not override reserved claims (iss, sub, aud, iat, exp, jti, fqdn). */
|
|
43
|
+
additionalClaims?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The subset of an OIDC discovery document (`.well-known/openid-configuration`)
|
|
47
|
+
* this package relies on. Additional members are preserved as-is.
|
|
48
|
+
*/
|
|
49
|
+
interface OIDCDiscoveryDocument {
|
|
50
|
+
issuer: string;
|
|
51
|
+
token_endpoint: string;
|
|
52
|
+
jwks_uri: string;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
/** Options for `OIDCProfile.exchangeOIDCToken()` and `getOIDCToken()`. */
|
|
56
|
+
interface OIDCTokenExchangeOptions {
|
|
57
|
+
/** Exact OIDC issuer URL to exchange against. */
|
|
58
|
+
issuer: string;
|
|
59
|
+
/** Audience (aud) requested for the access token. */
|
|
60
|
+
audience: string;
|
|
61
|
+
/** Space-delimited scope; defaults to the configured defaultScope, then 'openid'. */
|
|
62
|
+
scope?: string;
|
|
63
|
+
/** Pre-minted client assertion to present; its aud must exactly match the issuer. Minted fresh when absent. */
|
|
64
|
+
assertion?: string;
|
|
65
|
+
}
|
|
66
|
+
/** A successful token-endpoint response, normalized to camelCase members. */
|
|
67
|
+
interface OIDCTokenResponse {
|
|
68
|
+
/** The issued access token. */
|
|
69
|
+
accessToken: string;
|
|
70
|
+
/** ID token, when the issuer returned one. */
|
|
71
|
+
idToken?: string;
|
|
72
|
+
/** Token type as reported by the issuer; always Bearer (case preserved). */
|
|
73
|
+
tokenType: string;
|
|
74
|
+
/** Token lifetime in seconds, when the issuer provided one. */
|
|
75
|
+
expiresIn?: number;
|
|
76
|
+
/** Scope actually granted, when the issuer reported it. */
|
|
77
|
+
scope?: string;
|
|
78
|
+
/** Issuer the token was obtained from. */
|
|
79
|
+
issuer?: string;
|
|
80
|
+
/** Token endpoint the exchange was performed against. */
|
|
81
|
+
tokenEndpoint?: string;
|
|
82
|
+
/** Raw JSON body of the token response. */
|
|
83
|
+
raw: unknown;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A private JWK used to sign client assertions without a full key provider.
|
|
87
|
+
* Must carry the private `d` member; keep it server-side only.
|
|
88
|
+
*/
|
|
89
|
+
interface OIDCPrivateJWK extends Omit<DnsIdJWK, 'kid'> {
|
|
90
|
+
kty: string;
|
|
91
|
+
/** Private key material (base64url). */
|
|
92
|
+
d: string;
|
|
93
|
+
/** Key id published on the derived public key; defaults to the RFC 7638 thumbprint. */
|
|
94
|
+
kid?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Selects how the token endpoint is located. Exactly one mode applies:
|
|
98
|
+
* `issuer` (discovery at the issuer root), `serverUrl` (discovery relative to a
|
|
99
|
+
* base URL, token endpoint at `serverUrl` + '/token'), or `tokenEndpoint`
|
|
100
|
+
* (explicit endpoint; requires `issuer`, must share its origin, skips discovery).
|
|
101
|
+
*/
|
|
102
|
+
interface OIDCTokenEndpointOptions {
|
|
103
|
+
/** Exact HTTPS issuer root URL — no path, query, fragment, or trailing slash. Mutually exclusive with serverUrl. */
|
|
104
|
+
issuer?: string;
|
|
105
|
+
/** Base server URL used to derive the discovery document and token endpoint. Mutually exclusive with issuer. */
|
|
106
|
+
serverUrl?: string;
|
|
107
|
+
/** Explicit discovery document URL; only valid alongside issuer or serverUrl. */
|
|
108
|
+
discoveryUrl?: string;
|
|
109
|
+
/** Explicit token endpoint URL; requires issuer, must share its origin, and bypasses discovery. */
|
|
110
|
+
tokenEndpoint?: string;
|
|
111
|
+
}
|
|
112
|
+
/** Constructor options for {@link OIDCTokenMinter}. */
|
|
113
|
+
interface OIDCTokenMinterOptions extends OIDCTokenEndpointOptions {
|
|
114
|
+
/** Agent FQDN; becomes the iss/sub/fqdn claims of minted assertions. */
|
|
115
|
+
domain: string;
|
|
116
|
+
/** Provider of the agent's operational key, used to sign client assertions. */
|
|
117
|
+
keyProvider: KeyProvider;
|
|
118
|
+
/** Custom fetch replaces the SSRF-safe Node default; inject only trusted/test transports with equivalent DNS safety. */
|
|
119
|
+
fetch?: typeof globalThis.fetch;
|
|
120
|
+
/** Scope used when a mint call does not specify one. Defaults to 'openid'. */
|
|
121
|
+
defaultScope?: string;
|
|
122
|
+
/** Lifetime of minted client assertions, in seconds. Defaults to 300. */
|
|
123
|
+
assertionLifetime?: number;
|
|
124
|
+
/** Upper bound on any requested assertion lifetime, in seconds. Defaults to 900. */
|
|
125
|
+
maxAssertionLifetime?: number;
|
|
126
|
+
/** Timeout for discovery and token-endpoint requests, in milliseconds. Defaults to 10000. */
|
|
127
|
+
timeoutMs?: number;
|
|
128
|
+
/** Permit plain-HTTP loopback issuers (localhost, 127.x, ::1) for local testing. Defaults to false. */
|
|
129
|
+
allowHttpLoopbackIssuer?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/** Options for {@link createOIDCTokenMinter}: provide exactly one of keyProvider or privateJwk. */
|
|
132
|
+
interface CreateOIDCTokenMinterOptions extends Omit<OIDCTokenMinterOptions, 'keyProvider'> {
|
|
133
|
+
/** Provider of the agent's operational key. Mutually exclusive with privateJwk. */
|
|
134
|
+
keyProvider?: KeyProvider;
|
|
135
|
+
/** Raw private JWK to sign with, wrapped in an in-memory provider. Mutually exclusive with keyProvider. */
|
|
136
|
+
privateJwk?: OIDCPrivateJWK;
|
|
137
|
+
}
|
|
138
|
+
/** Per-call options for `OIDCTokenMinter.mintToken()`. Endpoint members override the minter's defaults. */
|
|
139
|
+
interface OIDCTokenMintOptions extends OIDCTokenEndpointOptions {
|
|
140
|
+
/** Audience (aud) requested for the access token. */
|
|
141
|
+
audience: string;
|
|
142
|
+
/** Space-delimited scope string. Mutually exclusive with scopes. */
|
|
143
|
+
scope?: string;
|
|
144
|
+
/** Individual scope values, joined with spaces. Mutually exclusive with scope. */
|
|
145
|
+
scopes?: readonly string[];
|
|
146
|
+
/** Extra claims for the client assertion. Must not override reserved claims (iss, sub, aud, iat, exp, jti, fqdn). */
|
|
147
|
+
additionalAssertionClaims?: Record<string, unknown>;
|
|
148
|
+
}
|
|
149
|
+
/** Combined options for the one-shot {@link mintOIDCToken}. */
|
|
150
|
+
type MintOIDCTokenOptions = CreateOIDCTokenMinterOptions & OIDCTokenMintOptions;
|
|
151
|
+
/** Options for `OIDCProfile.verifyOIDCToken()`. */
|
|
152
|
+
interface VerifyOIDCTokenOptions extends VerificationOptions {
|
|
153
|
+
/** Exact issuer URL the token must have been issued by; must appear in the profile's allowedIssuers. */
|
|
154
|
+
issuer: string;
|
|
155
|
+
/** Audience the token must be addressed to (exact match). */
|
|
156
|
+
audience: string;
|
|
157
|
+
/** Set false to skip verifying the token subject as a DNSid identity record. Defaults to true. */
|
|
158
|
+
verifyDnsidSubject?: boolean;
|
|
159
|
+
peerCert?: TLSCertificate;
|
|
160
|
+
}
|
|
161
|
+
/** Result of a successful `OIDCProfile.verifyOIDCToken()` call. */
|
|
162
|
+
interface VerifiedOIDCSubject {
|
|
163
|
+
/** Issuer that signed the token. */
|
|
164
|
+
issuer: string;
|
|
165
|
+
/** Token subject — the agent FQDN for DNSid-federated tokens. */
|
|
166
|
+
subject: string;
|
|
167
|
+
/** Audience the token was verified against. */
|
|
168
|
+
audience: string;
|
|
169
|
+
/** DNSid verification result for the subject; absent when verifyDnsidSubject is false. */
|
|
170
|
+
verifiedDomain?: VerifiedDomain;
|
|
171
|
+
/** The signature-verified JWT claims. */
|
|
172
|
+
claims: JWTPayload;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* OAuth 2.0 error returned by a token endpoint (e.g. invalid_grant), carrying
|
|
176
|
+
* the raw `error` and `error_description` members from the response body.
|
|
177
|
+
*/
|
|
178
|
+
declare class OAuthError extends Error {
|
|
179
|
+
/** The RFC 6749 error code, when the endpoint provided one. */
|
|
180
|
+
readonly error?: string;
|
|
181
|
+
/** Human-readable error description, when the endpoint provided one. */
|
|
182
|
+
readonly errorDescription?: string;
|
|
183
|
+
constructor(error?: string, errorDescription?: string);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Mints OIDC access tokens for a DNSid agent via the RFC 7523 JWT bearer
|
|
187
|
+
* grant: signs a client assertion with the agent's operational key, then
|
|
188
|
+
* exchanges it at the issuer's token endpoint.
|
|
189
|
+
*
|
|
190
|
+
* Server-side only — requires the agent's private operational key. Prefer a
|
|
191
|
+
* long-lived minter over repeated {@link mintOIDCToken} calls when minting
|
|
192
|
+
* more than once against the same issuer.
|
|
193
|
+
*/
|
|
194
|
+
declare class OIDCTokenMinter {
|
|
195
|
+
private readonly domain;
|
|
196
|
+
private readonly keyProvider;
|
|
197
|
+
private readonly fetch;
|
|
198
|
+
private readonly defaultEndpointOptions;
|
|
199
|
+
private readonly defaultScope?;
|
|
200
|
+
private readonly assertionLifetime?;
|
|
201
|
+
private readonly maxAssertionLifetime?;
|
|
202
|
+
private readonly timeoutMs;
|
|
203
|
+
private readonly allowHttpLoopbackIssuer;
|
|
204
|
+
/**
|
|
205
|
+
* @throws ArgumentError if domain is not a valid agent FQDN, the endpoint
|
|
206
|
+
* options mix modes (see {@link OIDCTokenEndpointOptions}), or timeoutMs
|
|
207
|
+
* is not a positive number.
|
|
208
|
+
*/
|
|
209
|
+
constructor(opts: OIDCTokenMinterOptions);
|
|
210
|
+
/**
|
|
211
|
+
* Mints a signed JWT bearer client assertion for the given issuer
|
|
212
|
+
* (iss/sub/fqdn = agent domain, aud = issuer, fresh jti).
|
|
213
|
+
*
|
|
214
|
+
* @throws ArgumentError if the issuer URL is invalid, the expiry is not
|
|
215
|
+
* positive or exceeds the maximum lifetime, or additionalClaims override
|
|
216
|
+
* a reserved claim.
|
|
217
|
+
* @throws ValidationError if the operational signing key is unsupported for JWS.
|
|
218
|
+
* @throws VerificationError (SignatureInvalid) if the produced signature does
|
|
219
|
+
* not verify against the active operational key.
|
|
220
|
+
*/
|
|
221
|
+
createAssertion(opts: OIDCAssertionOptions): Promise<string>;
|
|
222
|
+
/**
|
|
223
|
+
* Resolves the token endpoint (per the configured or per-call endpoint mode),
|
|
224
|
+
* mints a fresh assertion, and performs the JWT bearer token exchange.
|
|
225
|
+
*
|
|
226
|
+
* @returns The normalized token response.
|
|
227
|
+
* @throws ArgumentError if audience is missing or the options are inconsistent.
|
|
228
|
+
* @throws VerificationError if discovery or transport fails, the target
|
|
229
|
+
* resolves to an unsafe address, or the response is malformed.
|
|
230
|
+
* @throws OAuthError if the token endpoint returns an OAuth error response.
|
|
231
|
+
*/
|
|
232
|
+
mintToken(opts: OIDCTokenMintOptions): Promise<OIDCTokenResponse>;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Creates an {@link OIDCTokenMinter}, resolving the signing key from either a
|
|
236
|
+
* KeyProvider or a raw private JWK.
|
|
237
|
+
*
|
|
238
|
+
* @throws ArgumentError if neither or both of keyProvider/privateJwk are
|
|
239
|
+
* given, the private JWK is invalid, or the minter options are invalid.
|
|
240
|
+
*/
|
|
241
|
+
declare function createOIDCTokenMinter(opts: CreateOIDCTokenMinterOptions): Promise<OIDCTokenMinter>;
|
|
242
|
+
/**
|
|
243
|
+
* One-shot convenience: creates a minter and mints a single OIDC access token
|
|
244
|
+
* via the JWT bearer grant. Server-side only — never mint tokens in
|
|
245
|
+
* browser/client code. See `OIDCTokenMinter.mintToken()` for thrown errors.
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* import { LocalKeyProvider } from '@dnsid-ai/sdk/node';
|
|
250
|
+
* import { mintOIDCToken } from '@dnsid-ai/oidc';
|
|
251
|
+
*
|
|
252
|
+
* const keyProvider = await LocalKeyProvider.load('.dnsid/keys.json', true);
|
|
253
|
+
* const token = await mintOIDCToken({
|
|
254
|
+
* domain: 'agent.example.com',
|
|
255
|
+
* keyProvider,
|
|
256
|
+
* issuer: 'https://issuer.example.com',
|
|
257
|
+
* audience: 'https://api.example.com',
|
|
258
|
+
* scopes: ['openid', 'dnsid'],
|
|
259
|
+
* });
|
|
260
|
+
* console.log(token.accessToken);
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
declare function mintOIDCToken(opts: MintOIDCTokenOptions): Promise<OIDCTokenResponse>;
|
|
264
|
+
/**
|
|
265
|
+
* Wraps a raw private JWK in an in-memory KeyProvider suitable for signing
|
|
266
|
+
* OIDC assertions. Derives the public key, kid (RFC 7638 thumbprint), and alg
|
|
267
|
+
* when absent. The provider is signing-only: key generation, activation, and
|
|
268
|
+
* supersession are not supported.
|
|
269
|
+
*
|
|
270
|
+
* @throws ArgumentError if the JWK is not an object with a non-empty d member.
|
|
271
|
+
* @throws ValidationError if the key type/curve is unsupported for signing.
|
|
272
|
+
*/
|
|
273
|
+
declare function createOIDCKeyProviderFromJWK(privateJwk: OIDCPrivateJWK): Promise<KeyProvider>;
|
|
274
|
+
/**
|
|
275
|
+
* DNSid OIDC federation profile for a single agent: mints client assertions,
|
|
276
|
+
* exchanges them for access tokens, and verifies inbound OIDC tokens back to
|
|
277
|
+
* DNSid identity records.
|
|
278
|
+
*
|
|
279
|
+
* Token minting requires the agent's private operational key — keep it
|
|
280
|
+
* server-side; never construct a profile in browser/client code.
|
|
281
|
+
*/
|
|
282
|
+
declare class OIDCProfile {
|
|
283
|
+
/** Builds a profile sharing an identity manager's domain, operational key provider, and identity resolver. */
|
|
284
|
+
static fromIdentityManager(identityManager: SigningIdentityManager, oidc?: OIDCProfileConfig): OIDCProfile;
|
|
285
|
+
private readonly domain;
|
|
286
|
+
private readonly keyProvider;
|
|
287
|
+
private readonly identityResolver?;
|
|
288
|
+
private readonly fetch;
|
|
289
|
+
private readonly config;
|
|
290
|
+
/** @throws ArgumentError if domain is not a valid agent FQDN. */
|
|
291
|
+
constructor(opts: OIDCProfileOptions);
|
|
292
|
+
/**
|
|
293
|
+
* Mints a signed JWT bearer client assertion for the given issuer
|
|
294
|
+
* (iss/sub/fqdn = agent domain, aud = issuer, fresh jti).
|
|
295
|
+
*
|
|
296
|
+
* @throws ArgumentError if the issuer URL is invalid, the expiry is not
|
|
297
|
+
* positive or exceeds the maximum lifetime, or additionalClaims override
|
|
298
|
+
* a reserved claim.
|
|
299
|
+
* @throws ValidationError if the operational signing key is unsupported for JWS.
|
|
300
|
+
* @throws VerificationError (SignatureInvalid) if the produced signature does
|
|
301
|
+
* not verify against the active operational key.
|
|
302
|
+
*/
|
|
303
|
+
createOIDCAssertion(opts: OIDCAssertionOptions): Promise<string>;
|
|
304
|
+
/**
|
|
305
|
+
* Fetches and validates the issuer's discovery document. The document's
|
|
306
|
+
* issuer must match exactly, and token_endpoint/jwks_uri must share the
|
|
307
|
+
* issuer's origin.
|
|
308
|
+
*
|
|
309
|
+
* @throws ArgumentError if the issuer is not an exact HTTPS URL.
|
|
310
|
+
* @throws VerificationError if the fetch fails, redirects, or the document is invalid.
|
|
311
|
+
*/
|
|
312
|
+
discoverOIDCIssuer(issuer: string, options?: VerificationOptions): Promise<OIDCDiscoveryDocument>;
|
|
313
|
+
/**
|
|
314
|
+
* Discovers the issuer and performs the RFC 7523 JWT bearer exchange. When
|
|
315
|
+
* `assertion` is supplied it is presented as-is (its aud must exactly match
|
|
316
|
+
* the discovered issuer); otherwise a fresh assertion is minted.
|
|
317
|
+
*
|
|
318
|
+
* @returns The normalized token response.
|
|
319
|
+
* @throws ArgumentError if audience is missing or a supplied assertion is
|
|
320
|
+
* not a valid JWT addressed to the issuer.
|
|
321
|
+
* @throws VerificationError if discovery or transport fails, or the response is malformed.
|
|
322
|
+
* @throws OAuthError if the token endpoint returns an OAuth error response.
|
|
323
|
+
*/
|
|
324
|
+
exchangeOIDCToken(opts: OIDCTokenExchangeOptions): Promise<OIDCTokenResponse>;
|
|
325
|
+
/** Like {@link OIDCProfile.exchangeOIDCToken} but always mints a fresh assertion, ignoring any supplied one. */
|
|
326
|
+
getOIDCToken(opts: OIDCTokenExchangeOptions): Promise<OIDCTokenResponse>;
|
|
327
|
+
/**
|
|
328
|
+
* Verifies an OIDC token end-to-end: issuer allow-list, exact audience
|
|
329
|
+
* match, header and claim hygiene, signature against the issuer's published
|
|
330
|
+
* JWKS (restricted to allowedTokenAlgorithms), and timestamp checks with the
|
|
331
|
+
* configured clock skew. Unless `verifyDnsidSubject` is false, the token
|
|
332
|
+
* subject is then verified as a DNSid identity record via the profile's
|
|
333
|
+
* identityResolver.
|
|
334
|
+
*
|
|
335
|
+
* @returns The verified subject, claims, and (unless skipped) the DNSid
|
|
336
|
+
* verification result for the subject domain.
|
|
337
|
+
* @throws ArgumentError if the issuer URL is invalid or audience is missing.
|
|
338
|
+
* @throws VerificationError with a VerificationCode (RecordInvalid,
|
|
339
|
+
* SignatureInvalid, or TLSError) identifying the first check that failed —
|
|
340
|
+
* including when the issuer is not in allowedIssuers, or when subject
|
|
341
|
+
* verification is requested without an identityResolver.
|
|
342
|
+
*/
|
|
343
|
+
verifyOIDCToken(token: string, opts: VerifyOIDCTokenOptions): Promise<VerifiedOIDCSubject>;
|
|
344
|
+
private verifyTokenWithinBudget;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Creates an {@link OIDCProfile}.
|
|
348
|
+
*
|
|
349
|
+
* @throws ArgumentError if domain is not a valid agent FQDN.
|
|
350
|
+
* @example
|
|
351
|
+
* ```ts
|
|
352
|
+
* import { LocalKeyProvider } from '@dnsid-ai/sdk/node';
|
|
353
|
+
* import { createOIDCProfile } from '@dnsid-ai/oidc';
|
|
354
|
+
*
|
|
355
|
+
* const profile = createOIDCProfile({
|
|
356
|
+
* domain: 'agent.example.com',
|
|
357
|
+
* keyProvider: await LocalKeyProvider.load('.dnsid/keys.json', true),
|
|
358
|
+
* oidc: { allowedIssuers: ['https://issuer.example.com'] },
|
|
359
|
+
* });
|
|
360
|
+
* const token = await profile.getOIDCToken({
|
|
361
|
+
* issuer: 'https://issuer.example.com',
|
|
362
|
+
* audience: 'https://api.example.com',
|
|
363
|
+
* });
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
declare function createOIDCProfile(opts: OIDCProfileOptions): OIDCProfile;
|
|
367
|
+
/**
|
|
368
|
+
* Validates that an issuer is an exact absolute URL — no query, fragment, or
|
|
369
|
+
* trailing slash — using HTTPS (or plain-HTTP loopback when explicitly allowed).
|
|
370
|
+
*
|
|
371
|
+
* @returns The validated issuer string, unchanged.
|
|
372
|
+
* @throws ArgumentError if the issuer does not meet these requirements.
|
|
373
|
+
*/
|
|
374
|
+
declare function validateExactOIDCIssuer(issuer: string, allowHttpLoopbackIssuer?: boolean): string;
|
|
375
|
+
/**
|
|
376
|
+
* Decodes a JWT's claims WITHOUT verifying its signature. Use only for
|
|
377
|
+
* inspection or logging — never for authorization decisions; use
|
|
378
|
+
* `OIDCProfile.verifyOIDCToken()` for those.
|
|
379
|
+
*
|
|
380
|
+
* @returns The decoded claims object.
|
|
381
|
+
* @throws VerificationError (RecordInvalid) if the token is not a decodable
|
|
382
|
+
* JWT whose payload is a JSON object.
|
|
383
|
+
*/
|
|
384
|
+
declare function decodeOIDCClaims(token: string): Record<string, unknown>;
|
|
385
|
+
|
|
386
|
+
export { type CreateOIDCTokenMinterOptions, type MintOIDCTokenOptions, OAuthError, type OIDCAssertionOptions, type OIDCDiscoveryDocument, type OIDCPrivateJWK, OIDCProfile, type OIDCProfileConfig, type OIDCProfileOptions, type OIDCTokenEndpointOptions, type OIDCTokenExchangeOptions, type OIDCTokenMintOptions, OIDCTokenMinter, type OIDCTokenMinterOptions, type OIDCTokenResponse, type VerifiedOIDCSubject, type VerifyOIDCTokenOptions, createOIDCKeyProviderFromJWK, createOIDCProfile, createOIDCTokenMinter, decodeOIDCClaims, mintOIDCToken, validateExactOIDCIssuer };
|