@aooth/auth 0.2.0 → 0.2.2
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/atscript-db.cjs +5 -7
- package/dist/atscript-db.d.cts +21 -25
- package/dist/atscript-db.d.mts +21 -25
- package/dist/atscript-db.mjs +5 -7
- package/dist/{auth-credential-BsH0E8hG.d.mts → auth-credential-46_eOF3c.d.cts} +34 -3
- package/dist/{auth-credential-D1V5-2uy.d.cts → auth-credential-Co-0pqcD.d.mts} +34 -3
- package/dist/authz.cjs +21 -33
- package/dist/authz.d.cts +23 -45
- package/dist/authz.d.mts +23 -45
- package/dist/authz.mjs +21 -33
- package/dist/client.cjs +1 -2
- package/dist/client.d.cts +7 -10
- package/dist/client.d.mts +7 -10
- package/dist/client.mjs +1 -2
- package/dist/{clock-Bl-H3eqE.cjs → clock-BcBMqB9g.cjs} +1 -2
- package/dist/{clock-Bdsep_1j.mjs → clock-DzAK2bWR.mjs} +1 -2
- package/dist/{clock-CzAaCoZ5.d.cts → clock-hTHoZ2vA.d.cts} +0 -6
- package/dist/{clock-CzAaCoZ5.d.mts → clock-hTHoZ2vA.d.mts} +0 -6
- package/dist/{dynamic-client-store-DykM9QOT.cjs → dynamic-client-store-CC4qr_kz.cjs} +5 -8
- package/dist/{dynamic-client-store-CUGQiS08.d.mts → dynamic-client-store-CTt1B6Gj.d.cts} +2 -10
- package/dist/{dynamic-client-store-B1JwFHdP.mjs → dynamic-client-store-DrMBcFtG.mjs} +5 -8
- package/dist/{dynamic-client-store-D0RDGSSJ.d.cts → dynamic-client-store-mYg0nRJU.d.mts} +2 -10
- package/dist/index.cjs +92 -42
- package/dist/index.d.cts +18 -40
- package/dist/index.d.mts +18 -40
- package/dist/index.mjs +92 -42
- package/dist/{opaque-token-BaMOrC1A.mjs → opaque-token-BLoQKkZ3.mjs} +1 -2
- package/dist/{opaque-token-CaZgD2i6.cjs → opaque-token-BLuVHSVJ.cjs} +1 -2
- package/dist/{payload-C1cQW7p_.cjs → payload-CqQH88C6.cjs} +2 -4
- package/dist/{payload-DDlf38B-.mjs → payload-DizkKbzh.mjs} +2 -4
- package/dist/redis.cjs +8 -7
- package/dist/redis.d.cts +21 -11
- package/dist/redis.d.mts +21 -11
- package/dist/redis.mjs +8 -7
- package/dist/{store-BaFYDHxn.d.cts → store-BXxX8sUP.d.mts} +1 -3
- package/dist/{store-h-bLOAaS.d.mts → store-D9CcbcBp.d.cts} +1 -3
- package/package.json +9 -9
- package/src/atscript-db/auth-code.as.d.ts +1 -1
- package/src/atscript-db/auth-credential.as.d.ts +1 -1
- package/src/atscript-db/dynamic-client.as.d.ts +1 -1
- package/src/atscript-db/pending-authorization.as.d.ts +1 -1
package/dist/authz.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_clock = require("./clock-
|
|
3
|
-
const require_opaque_token = require("./opaque-token-
|
|
4
|
-
const require_dynamic_client_store = require("./dynamic-client-store-
|
|
2
|
+
const require_clock = require("./clock-BcBMqB9g.cjs");
|
|
3
|
+
const require_opaque_token = require("./opaque-token-BLuVHSVJ.cjs");
|
|
4
|
+
const require_dynamic_client_store = require("./dynamic-client-store-CC4qr_kz.cjs");
|
|
5
5
|
let node_crypto = require("node:crypto");
|
|
6
6
|
let jose = require("jose");
|
|
7
|
-
|
|
7
|
+
// src/authz/token-policy.ts
|
|
8
8
|
/**
|
|
9
9
|
* Default refresh-token (grant) lifetime for {@link TokenPolicy.refresh} when
|
|
10
10
|
* no `ttl` is given: 30 days. Deliberately independent of the session tier's
|
|
11
11
|
* `AuthCredentialOptions.refresh.ttl` — an authz grant's lifetime is the
|
|
12
12
|
* policy's decision, never inherited from browser-session posture.
|
|
13
13
|
*/
|
|
14
|
-
const DEFAULT_AUTHZ_REFRESH_TTL_MS =
|
|
14
|
+
const DEFAULT_AUTHZ_REFRESH_TTL_MS = 2592e6;
|
|
15
15
|
/**
|
|
16
16
|
* Flatten a {@link TokenPolicy} into the `AuthCredential.issue()` options a
|
|
17
17
|
* token endpoint forwards. The refresh dimension applies only to client-bound
|
|
@@ -35,8 +35,7 @@ function tokenPolicyToIssueOptions(policy, clientId) {
|
|
|
35
35
|
...withRefresh && { metadata: { authzClientId: clientId } }
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
//#region src/authz/authz-errors.ts
|
|
38
|
+
// src/authz/authz-errors.ts
|
|
40
39
|
/** A typed authorization-server failure. */
|
|
41
40
|
var AuthorizeError = class extends Error {
|
|
42
41
|
code;
|
|
@@ -46,8 +45,7 @@ var AuthorizeError = class extends Error {
|
|
|
46
45
|
this.code = code;
|
|
47
46
|
}
|
|
48
47
|
};
|
|
49
|
-
|
|
50
|
-
//#region src/authz/client-policy.ts
|
|
48
|
+
// src/authz/client-policy.ts
|
|
51
49
|
/**
|
|
52
50
|
* `true` when `uri` is a syntactically valid http(s) URL whose host is a
|
|
53
51
|
* **loopback literal** — `127.0.0.1`, `::1`, or `localhost` — on any port (RFC
|
|
@@ -71,7 +69,7 @@ function isLoopbackRedirectUri(uri) {
|
|
|
71
69
|
}
|
|
72
70
|
const DEFAULT_CLI_TOKEN_POLICY = {
|
|
73
71
|
kind: "cli-session",
|
|
74
|
-
ttl:
|
|
72
|
+
ttl: 2592e6
|
|
75
73
|
};
|
|
76
74
|
/**
|
|
77
75
|
* Tier-1 policy: accept any **loopback** `redirect_uri`, treat the client as a
|
|
@@ -92,8 +90,7 @@ var LoopbackClientPolicy = class {
|
|
|
92
90
|
};
|
|
93
91
|
}
|
|
94
92
|
};
|
|
95
|
-
|
|
96
|
-
//#region src/utils/timing-safe.ts
|
|
93
|
+
// src/utils/timing-safe.ts
|
|
97
94
|
/** Constant-time string compare that also fails closed on a length mismatch. */
|
|
98
95
|
function timingSafeEqualStr(a, b) {
|
|
99
96
|
const ab = Buffer.from(a, "utf8");
|
|
@@ -101,8 +98,7 @@ function timingSafeEqualStr(a, b) {
|
|
|
101
98
|
if (ab.length !== bb.length) return false;
|
|
102
99
|
return (0, node_crypto.timingSafeEqual)(ab, bb);
|
|
103
100
|
}
|
|
104
|
-
|
|
105
|
-
//#region src/authz/oidc-claims-resolver.ts
|
|
101
|
+
// src/authz/oidc-claims-resolver.ts
|
|
106
102
|
/**
|
|
107
103
|
* Resolves the OIDC profile claims to embed in an `id_token` for a given user +
|
|
108
104
|
* granted scope (AUTH-SERVER.md §4.9). The authorization server already controls
|
|
@@ -131,8 +127,7 @@ function scopeGrants(scope, claim) {
|
|
|
131
127
|
if (!scope) return false;
|
|
132
128
|
return scope.split(/\s+/u).includes(claim);
|
|
133
129
|
}
|
|
134
|
-
|
|
135
|
-
//#region src/authz/registered-client-policy.ts
|
|
130
|
+
// src/authz/registered-client-policy.ts
|
|
136
131
|
/**
|
|
137
132
|
* Tier-2 policy: a static registry of first-party clients. `resolveClient`
|
|
138
133
|
* authorizes the client + `redirect_uri` (against the registered allowlist) and
|
|
@@ -199,8 +194,7 @@ var RegisteredClientPolicy = class {
|
|
|
199
194
|
return granted.length > 0 ? granted.join(" ") : void 0;
|
|
200
195
|
}
|
|
201
196
|
};
|
|
202
|
-
|
|
203
|
-
//#region src/authz/composite-client-policy.ts
|
|
197
|
+
// src/authz/composite-client-policy.ts
|
|
204
198
|
/**
|
|
205
199
|
* Runs the tiers side by side, dispatching on the **presence and ownership of
|
|
206
200
|
* `client_id`** (AUTH-SERVER.md §10, OAUTH.md R2): a request without a
|
|
@@ -247,8 +241,7 @@ var CompositeClientPolicy = class {
|
|
|
247
241
|
return known instanceof Promise ? known.then((k) => k ? this.registered : this.dynamic) : known ? this.registered : this.dynamic;
|
|
248
242
|
}
|
|
249
243
|
};
|
|
250
|
-
|
|
251
|
-
//#region src/authz/client-secret.ts
|
|
244
|
+
// src/authz/client-secret.ts
|
|
252
245
|
/**
|
|
253
246
|
* Mint a confidential dynamic client's secret (RFC 7591 `client_secret`) — a
|
|
254
247
|
* plain {@link generateOpaqueToken} mint. Returned to the registrant ONCE in
|
|
@@ -271,8 +264,7 @@ function hashClientSecret(secret) {
|
|
|
271
264
|
function verifyClientSecret(secret, hash) {
|
|
272
265
|
return timingSafeEqualStr(hashClientSecret(secret), hash);
|
|
273
266
|
}
|
|
274
|
-
|
|
275
|
-
//#region src/authz/client-registration.ts
|
|
267
|
+
// src/authz/client-registration.ts
|
|
276
268
|
/** A typed RFC 7591 registration failure; `message` becomes `error_description`. */
|
|
277
269
|
var ClientRegistrationError = class extends Error {
|
|
278
270
|
code;
|
|
@@ -432,11 +424,10 @@ var DynamicClientRegistration = class {
|
|
|
432
424
|
return this.store.create(metadata);
|
|
433
425
|
}
|
|
434
426
|
};
|
|
435
|
-
|
|
436
|
-
//#region src/authz/dynamic-client-policy.ts
|
|
427
|
+
// src/authz/dynamic-client-policy.ts
|
|
437
428
|
const DEFAULT_DYNAMIC_TOKEN_POLICY = {
|
|
438
429
|
kind: "dynamic-session",
|
|
439
|
-
ttl:
|
|
430
|
+
ttl: 2592e6
|
|
440
431
|
};
|
|
441
432
|
/**
|
|
442
433
|
* Policy for RFC 7591 dynamically-registered clients (OAUTH.md R2) on the
|
|
@@ -536,8 +527,7 @@ function redirectAllowed(client, uri) {
|
|
|
536
527
|
return reg.protocol === presented.protocol && reg.hostname === presented.hostname && reg.pathname === presented.pathname && reg.search === presented.search;
|
|
537
528
|
});
|
|
538
529
|
}
|
|
539
|
-
|
|
540
|
-
//#region src/authz/id-token-signer.ts
|
|
530
|
+
// src/authz/id-token-signer.ts
|
|
541
531
|
/**
|
|
542
532
|
* Signs OIDC `id_token`s and publishes the matching JWKS (AUTH-SERVER.md §4.9).
|
|
543
533
|
* Holds one asymmetric keypair; mints short-lived RS256/ES256 tokens with the
|
|
@@ -590,7 +580,8 @@ var IdTokenSigner = class {
|
|
|
590
580
|
*/
|
|
591
581
|
async jwks() {
|
|
592
582
|
this.jwksPromise ??= (async () => {
|
|
593
|
-
const
|
|
583
|
+
const pub = await (0, jose.importSPKI)(this.publicKeyPem, this.alg, { extractable: true });
|
|
584
|
+
const jwk = await (0, jose.exportJWK)(pub);
|
|
594
585
|
jwk.kid = this.kid;
|
|
595
586
|
jwk.alg = this.alg;
|
|
596
587
|
jwk.use = "sig";
|
|
@@ -603,8 +594,7 @@ var IdTokenSigner = class {
|
|
|
603
594
|
return this.privateKeyPromise;
|
|
604
595
|
}
|
|
605
596
|
};
|
|
606
|
-
|
|
607
|
-
//#region src/authz/server-metadata.ts
|
|
597
|
+
// src/authz/server-metadata.ts
|
|
608
598
|
/**
|
|
609
599
|
* Strip a trailing slash from an issuer identifier. RFC 8414 mandates EXACT
|
|
610
600
|
* (byte-identical) string comparison of issuer values, so every document that
|
|
@@ -645,8 +635,7 @@ function buildAuthorizationServerMetadata(opts) {
|
|
|
645
635
|
...opts.scopesSupported !== void 0 && { scopes_supported: opts.scopesSupported }
|
|
646
636
|
};
|
|
647
637
|
}
|
|
648
|
-
|
|
649
|
-
//#region src/authz/resource-metadata.ts
|
|
638
|
+
// src/authz/resource-metadata.ts
|
|
650
639
|
/**
|
|
651
640
|
* Build the RFC 9728 protected-resource document. Pure — no I/O, no framework;
|
|
652
641
|
* mount it on any HTTP stack. Optional fields are omitted entirely (no
|
|
@@ -693,7 +682,6 @@ function buildWwwAuthenticateBearerChallenge(opts) {
|
|
|
693
682
|
push("scope", opts?.scope);
|
|
694
683
|
return params.length === 0 ? "Bearer" : `Bearer ${params.join(", ")}`;
|
|
695
684
|
}
|
|
696
|
-
//#endregion
|
|
697
685
|
exports.AuthCodeStore = require_dynamic_client_store.AuthCodeStore;
|
|
698
686
|
exports.AuthCodeStoreMemory = require_dynamic_client_store.AuthCodeStoreMemory;
|
|
699
687
|
exports.AuthorizeError = AuthorizeError;
|
package/dist/authz.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as Clock } from "./clock-
|
|
2
|
-
import { _ as PendingAuthorizationStoreMemoryOptions, a as DynamicClientStoreMemoryOptions, b as tokenPolicyToIssueOptions, c as AuthCodeStore, d as NewAuthCode, f as DEFAULT_PENDING_TTL_MS, g as PendingAuthorizationStoreMemory, h as PendingAuthorizationStore, i as DynamicClientStoreMemory, l as AuthCodeStoreMemory, m as PendingAuthorization, n as DynamicClientAuthMethod, o as NewDynamicClient, p as NewPendingAuthorization, r as DynamicClientStore, s as AuthCode, t as DynamicClient, u as AuthCodeStoreMemoryOptions, v as DEFAULT_AUTHZ_REFRESH_TTL_MS, y as TokenPolicy } from "./dynamic-client-store-
|
|
1
|
+
import { t as Clock } from "./clock-hTHoZ2vA.cjs";
|
|
2
|
+
import { _ as PendingAuthorizationStoreMemoryOptions, a as DynamicClientStoreMemoryOptions, b as tokenPolicyToIssueOptions, c as AuthCodeStore, d as NewAuthCode, f as DEFAULT_PENDING_TTL_MS, g as PendingAuthorizationStoreMemory, h as PendingAuthorizationStore, i as DynamicClientStoreMemory, l as AuthCodeStoreMemory, m as PendingAuthorization, n as DynamicClientAuthMethod, o as NewDynamicClient, p as NewPendingAuthorization, r as DynamicClientStore, s as AuthCode, t as DynamicClient, u as AuthCodeStoreMemoryOptions, v as DEFAULT_AUTHZ_REFRESH_TTL_MS, y as TokenPolicy } from "./dynamic-client-store-CTt1B6Gj.cjs";
|
|
3
3
|
import { JWK } from "jose";
|
|
4
|
-
//#region src/authz/authz-errors.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Failure taxonomy for the authorization-server endpoints (AUTH-SERVER.md §7).
|
|
7
6
|
* The `/authorize` side fails SOFT (302 → an app error/login route, never a
|
|
@@ -30,12 +29,10 @@ type AuthorizeErrorCode =
|
|
|
30
29
|
/** An unexpected server-side failure. */
|
|
31
30
|
"server_error";
|
|
32
31
|
/** A typed authorization-server failure. */
|
|
33
|
-
declare class AuthorizeError extends Error {
|
|
32
|
+
export declare class AuthorizeError extends Error {
|
|
34
33
|
readonly code: AuthorizeErrorCode;
|
|
35
34
|
constructor(code: AuthorizeErrorCode, message: string);
|
|
36
35
|
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/authz/client-policy.d.ts
|
|
39
36
|
/**
|
|
40
37
|
* The client + redirect resolved at `GET /auth/authorize` — what the grant is
|
|
41
38
|
* allowed to deliver and where.
|
|
@@ -118,7 +115,7 @@ interface ClientRedirectPolicy {
|
|
|
118
115
|
* `0.0.0.0`. Only a local process can receive a loopback redirect, which is why
|
|
119
116
|
* an arbitrary port is safe — the binding is the loopback host + PKCE.
|
|
120
117
|
*/
|
|
121
|
-
declare function isLoopbackRedirectUri(uri: string): boolean;
|
|
118
|
+
export declare function isLoopbackRedirectUri(uri: string): boolean;
|
|
122
119
|
interface LoopbackClientPolicyOptions {
|
|
123
120
|
/**
|
|
124
121
|
* What a loopback grant mints. Default: a full-authority `cli-session` with a
|
|
@@ -132,7 +129,7 @@ interface LoopbackClientPolicyOptions {
|
|
|
132
129
|
* public client (no `client_id` / secret — PKCE is the binding), and mint the
|
|
133
130
|
* configured CLI token policy. Rejects every non-loopback redirect.
|
|
134
131
|
*/
|
|
135
|
-
declare class LoopbackClientPolicy implements ClientRedirectPolicy {
|
|
132
|
+
export declare class LoopbackClientPolicy implements ClientRedirectPolicy {
|
|
136
133
|
private readonly tokenPolicy;
|
|
137
134
|
constructor(opts?: LoopbackClientPolicyOptions);
|
|
138
135
|
resolveClient(args: {
|
|
@@ -141,8 +138,6 @@ declare class LoopbackClientPolicy implements ClientRedirectPolicy {
|
|
|
141
138
|
scope?: string;
|
|
142
139
|
}): ResolvedClient;
|
|
143
140
|
}
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/authz/registered-client-policy.d.ts
|
|
146
141
|
/**
|
|
147
142
|
* One registered first-party client (AUTH-SERVER.md §4.5). The registry is the
|
|
148
143
|
* open-redirect / token-theft boundary, so a client's `redirect_uri` allowlist
|
|
@@ -185,7 +180,7 @@ interface RegisteredClientPolicyOptions {
|
|
|
185
180
|
* (`client_secret` for confidential clients; PKCE is the binding for public ones).
|
|
186
181
|
* An unregistered client or an unlisted redirect is rejected.
|
|
187
182
|
*/
|
|
188
|
-
declare class RegisteredClientPolicy implements ClientRedirectPolicy {
|
|
183
|
+
export declare class RegisteredClientPolicy implements ClientRedirectPolicy {
|
|
189
184
|
private readonly clients;
|
|
190
185
|
constructor(opts: RegisteredClientPolicyOptions);
|
|
191
186
|
resolveClient(args: {
|
|
@@ -203,8 +198,6 @@ declare class RegisteredClientPolicy implements ClientRedirectPolicy {
|
|
|
203
198
|
private redirectAllowed;
|
|
204
199
|
private grantScope;
|
|
205
200
|
}
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/authz/composite-client-policy.d.ts
|
|
208
201
|
interface CompositeClientPolicyOptions {
|
|
209
202
|
/** Used when the request carries NO `client_id` (Tier-1 public/loopback CLI). */
|
|
210
203
|
loopback: ClientRedirectPolicy;
|
|
@@ -231,7 +224,7 @@ interface CompositeClientPolicyOptions {
|
|
|
231
224
|
* `client_id` must be authenticated by the dynamic policy (existence check,
|
|
232
225
|
* PKCE binds), never rejected by the static registry that doesn't know it.
|
|
233
226
|
*/
|
|
234
|
-
declare class CompositeClientPolicy implements ClientRedirectPolicy {
|
|
227
|
+
export declare class CompositeClientPolicy implements ClientRedirectPolicy {
|
|
235
228
|
private readonly loopback;
|
|
236
229
|
private readonly registered?;
|
|
237
230
|
private readonly dynamic?;
|
|
@@ -252,8 +245,6 @@ declare class CompositeClientPolicy implements ClientRedirectPolicy {
|
|
|
252
245
|
*/
|
|
253
246
|
private pickForClientId;
|
|
254
247
|
}
|
|
255
|
-
//#endregion
|
|
256
|
-
//#region src/authz/client-registration.d.ts
|
|
257
248
|
/**
|
|
258
249
|
* RFC 7591 §3.2.2 error vocabulary — deliberately separate from
|
|
259
250
|
* `AuthorizeErrorCode`: registration errors are a different wire contract
|
|
@@ -261,7 +252,7 @@ declare class CompositeClientPolicy implements ClientRedirectPolicy {
|
|
|
261
252
|
*/
|
|
262
253
|
type ClientRegistrationErrorCode = "invalid_redirect_uri" | "invalid_client_metadata";
|
|
263
254
|
/** A typed RFC 7591 registration failure; `message` becomes `error_description`. */
|
|
264
|
-
declare class ClientRegistrationError extends Error {
|
|
255
|
+
export declare class ClientRegistrationError extends Error {
|
|
265
256
|
readonly code: ClientRegistrationErrorCode;
|
|
266
257
|
constructor(code: ClientRegistrationErrorCode, message: string);
|
|
267
258
|
}
|
|
@@ -308,7 +299,7 @@ interface ClientRegistrationValidationOptions {
|
|
|
308
299
|
* the allowed set is rejected — never silently downgrade a client that asked
|
|
309
300
|
* for a secret. Unknown fields are ignored and never echoed.
|
|
310
301
|
*/
|
|
311
|
-
declare function validateClientRegistration(body: unknown, opts?: ClientRegistrationValidationOptions): NewDynamicClient;
|
|
302
|
+
export declare function validateClientRegistration(body: unknown, opts?: ClientRegistrationValidationOptions): NewDynamicClient;
|
|
312
303
|
interface DynamicClientRegistrationOptions {
|
|
313
304
|
store: DynamicClientStore;
|
|
314
305
|
/**
|
|
@@ -359,7 +350,7 @@ type RegisteredDynamicClient = DynamicClient & {
|
|
|
359
350
|
* controller endpoint is a thin HTTP adapter over `register()`, and non-moost
|
|
360
351
|
* servers can call it directly.
|
|
361
352
|
*/
|
|
362
|
-
declare class DynamicClientRegistration {
|
|
353
|
+
export declare class DynamicClientRegistration {
|
|
363
354
|
private readonly store;
|
|
364
355
|
private readonly maxClients;
|
|
365
356
|
private readonly unusedClientTtlMs?;
|
|
@@ -375,26 +366,22 @@ declare class DynamicClientRegistration {
|
|
|
375
366
|
*/
|
|
376
367
|
register(body: unknown): Promise<RegisteredDynamicClient>;
|
|
377
368
|
}
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/authz/client-secret.d.ts
|
|
380
369
|
/**
|
|
381
370
|
* Mint a confidential dynamic client's secret (RFC 7591 `client_secret`) — a
|
|
382
371
|
* plain {@link generateOpaqueToken} mint. Returned to the registrant ONCE in
|
|
383
372
|
* the registration response; only its {@link hashClientSecret} digest is
|
|
384
373
|
* stored.
|
|
385
374
|
*/
|
|
386
|
-
declare function mintClientSecret(): string;
|
|
375
|
+
export declare function mintClientSecret(): string;
|
|
387
376
|
/**
|
|
388
377
|
* Storage digest for a client secret — plain SHA-256 (hex). No KDF/salt on
|
|
389
378
|
* purpose: the secret is high-entropy server-minted material (never a human
|
|
390
379
|
* password), so brute-forcing the digest is infeasible and a per-row salt
|
|
391
380
|
* buys nothing.
|
|
392
381
|
*/
|
|
393
|
-
declare function hashClientSecret(secret: string): string;
|
|
382
|
+
export declare function hashClientSecret(secret: string): string;
|
|
394
383
|
/** Constant-time check of a presented secret against a stored digest. */
|
|
395
|
-
declare function verifyClientSecret(secret: string, hash: string): boolean;
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region src/authz/dynamic-client-policy.d.ts
|
|
384
|
+
export declare function verifyClientSecret(secret: string, hash: string): boolean;
|
|
398
385
|
interface DynamicClientPolicyOptions {
|
|
399
386
|
store: DynamicClientStore;
|
|
400
387
|
/**
|
|
@@ -429,7 +416,7 @@ interface DynamicClientPolicyOptions {
|
|
|
429
416
|
* applies — a dynamic code redeemed without (or with another) `client_id` is
|
|
430
417
|
* rejected exactly like a Tier-2 code.
|
|
431
418
|
*/
|
|
432
|
-
declare class DynamicClientPolicy implements ClientRedirectPolicy {
|
|
419
|
+
export declare class DynamicClientPolicy implements ClientRedirectPolicy {
|
|
433
420
|
private readonly store;
|
|
434
421
|
private readonly tokenPolicy;
|
|
435
422
|
private readonly allowedScopes?;
|
|
@@ -457,8 +444,6 @@ declare class DynamicClientPolicy implements ClientRedirectPolicy {
|
|
|
457
444
|
private requireClient;
|
|
458
445
|
private grantScope;
|
|
459
446
|
}
|
|
460
|
-
//#endregion
|
|
461
|
-
//#region src/authz/id-token-signer.d.ts
|
|
462
447
|
/** Asymmetric signing algorithms an OIDC `id_token` may use (AUTH-SERVER.md §4.9). */
|
|
463
448
|
type IdTokenAlg = "RS256" | "ES256";
|
|
464
449
|
interface IdTokenSignerOptions {
|
|
@@ -504,7 +489,7 @@ interface IdTokenClaims {
|
|
|
504
489
|
* Never used for the access token (that stays in `AuthCredential`'s store) — the
|
|
505
490
|
* `id_token` is a separate, audience-bound identity assertion.
|
|
506
491
|
*/
|
|
507
|
-
declare class IdTokenSigner {
|
|
492
|
+
export declare class IdTokenSigner {
|
|
508
493
|
/** The `iss` claim + discovery `issuer` (read by `/.well-known/openid-configuration`). */
|
|
509
494
|
readonly issuer: string;
|
|
510
495
|
/** Signature algorithm — published in discovery's `id_token_signing_alg_values_supported`. */
|
|
@@ -530,8 +515,6 @@ declare class IdTokenSigner {
|
|
|
530
515
|
}>;
|
|
531
516
|
private importPrivateKey;
|
|
532
517
|
}
|
|
533
|
-
//#endregion
|
|
534
|
-
//#region src/authz/oidc-claims-resolver.d.ts
|
|
535
518
|
/**
|
|
536
519
|
* Resolves the OIDC profile claims to embed in an `id_token` for a given user +
|
|
537
520
|
* granted scope (AUTH-SERVER.md §4.9). The authorization server already controls
|
|
@@ -548,7 +531,7 @@ declare class IdTokenSigner {
|
|
|
548
531
|
* `name`/`picture`/etc. under `profile`, so a client receives only what it asked
|
|
549
532
|
* for (and was allowed).
|
|
550
533
|
*/
|
|
551
|
-
declare abstract class OidcClaimsResolver {
|
|
534
|
+
export declare abstract class OidcClaimsResolver {
|
|
552
535
|
/**
|
|
553
536
|
* @param userId the authenticated subject (the `id_token` `sub`).
|
|
554
537
|
* @param scope the granted scope, space-joined (e.g. `"openid email profile"`), or undefined.
|
|
@@ -557,20 +540,18 @@ declare abstract class OidcClaimsResolver {
|
|
|
557
540
|
abstract resolveClaims(userId: string, scope: string | undefined): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
558
541
|
}
|
|
559
542
|
/** Default resolver: emits no profile claims, so the `id_token` carries only `sub` + the registered claims. */
|
|
560
|
-
declare class NoopOidcClaimsResolver extends OidcClaimsResolver {
|
|
543
|
+
export declare class NoopOidcClaimsResolver extends OidcClaimsResolver {
|
|
561
544
|
resolveClaims(): Record<string, unknown>;
|
|
562
545
|
}
|
|
563
546
|
/** `true` when `scope` (space-joined) grants `claim` — `"email"`/`"profile"` etc. */
|
|
564
|
-
declare function scopeGrants(scope: string | undefined, claim: string): boolean;
|
|
565
|
-
//#endregion
|
|
566
|
-
//#region src/authz/server-metadata.d.ts
|
|
547
|
+
export declare function scopeGrants(scope: string | undefined, claim: string): boolean;
|
|
567
548
|
/**
|
|
568
549
|
* Strip a trailing slash from an issuer identifier. RFC 8414 mandates EXACT
|
|
569
550
|
* (byte-identical) string comparison of issuer values, so every document that
|
|
570
551
|
* spells the issuer must canonicalize it the same way — same rule as
|
|
571
552
|
* `IdTokenSigner`. Shared by the AS metadata and protected-resource builders.
|
|
572
553
|
*/
|
|
573
|
-
declare function canonicalizeIssuer(issuer: string): string;
|
|
554
|
+
export declare function canonicalizeIssuer(issuer: string): string;
|
|
574
555
|
/**
|
|
575
556
|
* RFC 8414 Authorization Server Metadata — the discovery document MCP connector
|
|
576
557
|
* clients fetch from `/.well-known/oauth-authorization-server` to locate the
|
|
@@ -630,9 +611,7 @@ interface BuildAuthorizationServerMetadataOptions {
|
|
|
630
611
|
* are omitted entirely (no `undefined` keys) so the serialized JSON carries
|
|
631
612
|
* only what was configured.
|
|
632
613
|
*/
|
|
633
|
-
declare function buildAuthorizationServerMetadata(opts: BuildAuthorizationServerMetadataOptions): AuthorizationServerMetadata;
|
|
634
|
-
//#endregion
|
|
635
|
-
//#region src/authz/resource-metadata.d.ts
|
|
614
|
+
export declare function buildAuthorizationServerMetadata(opts: BuildAuthorizationServerMetadataOptions): AuthorizationServerMetadata;
|
|
636
615
|
/**
|
|
637
616
|
* RFC 9728 Protected Resource Metadata — the document a resource server (an
|
|
638
617
|
* MCP server, an API) publishes at `/.well-known/oauth-protected-resource` so
|
|
@@ -667,7 +646,7 @@ interface BuildProtectedResourceMetadataOptions {
|
|
|
667
646
|
* mount it on any HTTP stack. Optional fields are omitted entirely (no
|
|
668
647
|
* `undefined` keys) so the serialized JSON carries only what was configured.
|
|
669
648
|
*/
|
|
670
|
-
declare function buildProtectedResourceMetadata(opts: BuildProtectedResourceMetadataOptions): ProtectedResourceMetadata;
|
|
649
|
+
export declare function buildProtectedResourceMetadata(opts: BuildProtectedResourceMetadataOptions): ProtectedResourceMetadata;
|
|
671
650
|
interface WwwAuthenticateBearerChallengeOptions {
|
|
672
651
|
/**
|
|
673
652
|
* URL of the protected-resource document (RFC 9728 §5.1) — emitted as
|
|
@@ -692,6 +671,5 @@ interface WwwAuthenticateBearerChallengeOptions {
|
|
|
692
671
|
* `realm`, `error`, `error_description`, `resource_metadata`, `scope`. All
|
|
693
672
|
* values pass through {@link sanitizeQuotedStringValue} — see its security note.
|
|
694
673
|
*/
|
|
695
|
-
declare function buildWwwAuthenticateBearerChallenge(opts?: WwwAuthenticateBearerChallengeOptions): string;
|
|
696
|
-
|
|
697
|
-
export { type AuthCode, AuthCodeStore, AuthCodeStoreMemory, type AuthCodeStoreMemoryOptions, type AuthorizationServerMetadata, AuthorizeError, type AuthorizeErrorCode, type BuildAuthorizationServerMetadataOptions, type BuildProtectedResourceMetadataOptions, type ClientRedirectPolicy, ClientRegistrationError, type ClientRegistrationErrorCode, type ClientRegistrationValidationOptions, CompositeClientPolicy, type CompositeClientPolicyOptions, DEFAULT_AUTHZ_REFRESH_TTL_MS, DEFAULT_PENDING_TTL_MS, type DynamicClient, type DynamicClientAuthMethod, DynamicClientPolicy, type DynamicClientPolicyOptions, DynamicClientRegistration, type DynamicClientRegistrationOptions, DynamicClientStore, DynamicClientStoreMemory, type DynamicClientStoreMemoryOptions, type IdTokenAlg, type IdTokenClaims, IdTokenSigner, type IdTokenSignerOptions, LoopbackClientPolicy, type LoopbackClientPolicyOptions, type NewAuthCode, type NewDynamicClient, type NewPendingAuthorization, NoopOidcClaimsResolver, OidcClaimsResolver, type PendingAuthorization, PendingAuthorizationStore, PendingAuthorizationStoreMemory, type PendingAuthorizationStoreMemoryOptions, type ProtectedResourceMetadata, type RegisteredClient, RegisteredClientPolicy, type RegisteredClientPolicyOptions, type RegisteredDynamicClient, type ResolvedClient, type TokenPolicy, type WwwAuthenticateBearerChallengeOptions, buildAuthorizationServerMetadata, buildProtectedResourceMetadata, buildWwwAuthenticateBearerChallenge, canonicalizeIssuer, hashClientSecret, isLoopbackRedirectUri, mintClientSecret, scopeGrants, tokenPolicyToIssueOptions, validateClientRegistration, verifyClientSecret };
|
|
674
|
+
export declare function buildWwwAuthenticateBearerChallenge(opts?: WwwAuthenticateBearerChallengeOptions): string;
|
|
675
|
+
export { type AuthCode, AuthCodeStore, AuthCodeStoreMemory, type AuthCodeStoreMemoryOptions, type AuthorizationServerMetadata, type AuthorizeErrorCode, type BuildAuthorizationServerMetadataOptions, type BuildProtectedResourceMetadataOptions, type ClientRedirectPolicy, type ClientRegistrationErrorCode, type ClientRegistrationValidationOptions, type CompositeClientPolicyOptions, DEFAULT_AUTHZ_REFRESH_TTL_MS, DEFAULT_PENDING_TTL_MS, type DynamicClient, type DynamicClientAuthMethod, type DynamicClientPolicyOptions, type DynamicClientRegistrationOptions, DynamicClientStore, DynamicClientStoreMemory, type DynamicClientStoreMemoryOptions, type IdTokenAlg, type IdTokenClaims, type IdTokenSignerOptions, type LoopbackClientPolicyOptions, type NewAuthCode, type NewDynamicClient, type NewPendingAuthorization, type PendingAuthorization, PendingAuthorizationStore, PendingAuthorizationStoreMemory, type PendingAuthorizationStoreMemoryOptions, type ProtectedResourceMetadata, type RegisteredClient, type RegisteredClientPolicyOptions, type RegisteredDynamicClient, type ResolvedClient, type TokenPolicy, type WwwAuthenticateBearerChallengeOptions, tokenPolicyToIssueOptions };
|
package/dist/authz.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as Clock } from "./clock-
|
|
2
|
-
import { _ as PendingAuthorizationStoreMemoryOptions, a as DynamicClientStoreMemoryOptions, b as tokenPolicyToIssueOptions, c as AuthCodeStore, d as NewAuthCode, f as DEFAULT_PENDING_TTL_MS, g as PendingAuthorizationStoreMemory, h as PendingAuthorizationStore, i as DynamicClientStoreMemory, l as AuthCodeStoreMemory, m as PendingAuthorization, n as DynamicClientAuthMethod, o as NewDynamicClient, p as NewPendingAuthorization, r as DynamicClientStore, s as AuthCode, t as DynamicClient, u as AuthCodeStoreMemoryOptions, v as DEFAULT_AUTHZ_REFRESH_TTL_MS, y as TokenPolicy } from "./dynamic-client-store-
|
|
1
|
+
import { t as Clock } from "./clock-hTHoZ2vA.mjs";
|
|
2
|
+
import { _ as PendingAuthorizationStoreMemoryOptions, a as DynamicClientStoreMemoryOptions, b as tokenPolicyToIssueOptions, c as AuthCodeStore, d as NewAuthCode, f as DEFAULT_PENDING_TTL_MS, g as PendingAuthorizationStoreMemory, h as PendingAuthorizationStore, i as DynamicClientStoreMemory, l as AuthCodeStoreMemory, m as PendingAuthorization, n as DynamicClientAuthMethod, o as NewDynamicClient, p as NewPendingAuthorization, r as DynamicClientStore, s as AuthCode, t as DynamicClient, u as AuthCodeStoreMemoryOptions, v as DEFAULT_AUTHZ_REFRESH_TTL_MS, y as TokenPolicy } from "./dynamic-client-store-mYg0nRJU.mjs";
|
|
3
3
|
import { JWK } from "jose";
|
|
4
|
-
//#region src/authz/authz-errors.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Failure taxonomy for the authorization-server endpoints (AUTH-SERVER.md §7).
|
|
7
6
|
* The `/authorize` side fails SOFT (302 → an app error/login route, never a
|
|
@@ -30,12 +29,10 @@ type AuthorizeErrorCode =
|
|
|
30
29
|
/** An unexpected server-side failure. */
|
|
31
30
|
"server_error";
|
|
32
31
|
/** A typed authorization-server failure. */
|
|
33
|
-
declare class AuthorizeError extends Error {
|
|
32
|
+
export declare class AuthorizeError extends Error {
|
|
34
33
|
readonly code: AuthorizeErrorCode;
|
|
35
34
|
constructor(code: AuthorizeErrorCode, message: string);
|
|
36
35
|
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/authz/client-policy.d.ts
|
|
39
36
|
/**
|
|
40
37
|
* The client + redirect resolved at `GET /auth/authorize` — what the grant is
|
|
41
38
|
* allowed to deliver and where.
|
|
@@ -118,7 +115,7 @@ interface ClientRedirectPolicy {
|
|
|
118
115
|
* `0.0.0.0`. Only a local process can receive a loopback redirect, which is why
|
|
119
116
|
* an arbitrary port is safe — the binding is the loopback host + PKCE.
|
|
120
117
|
*/
|
|
121
|
-
declare function isLoopbackRedirectUri(uri: string): boolean;
|
|
118
|
+
export declare function isLoopbackRedirectUri(uri: string): boolean;
|
|
122
119
|
interface LoopbackClientPolicyOptions {
|
|
123
120
|
/**
|
|
124
121
|
* What a loopback grant mints. Default: a full-authority `cli-session` with a
|
|
@@ -132,7 +129,7 @@ interface LoopbackClientPolicyOptions {
|
|
|
132
129
|
* public client (no `client_id` / secret — PKCE is the binding), and mint the
|
|
133
130
|
* configured CLI token policy. Rejects every non-loopback redirect.
|
|
134
131
|
*/
|
|
135
|
-
declare class LoopbackClientPolicy implements ClientRedirectPolicy {
|
|
132
|
+
export declare class LoopbackClientPolicy implements ClientRedirectPolicy {
|
|
136
133
|
private readonly tokenPolicy;
|
|
137
134
|
constructor(opts?: LoopbackClientPolicyOptions);
|
|
138
135
|
resolveClient(args: {
|
|
@@ -141,8 +138,6 @@ declare class LoopbackClientPolicy implements ClientRedirectPolicy {
|
|
|
141
138
|
scope?: string;
|
|
142
139
|
}): ResolvedClient;
|
|
143
140
|
}
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/authz/registered-client-policy.d.ts
|
|
146
141
|
/**
|
|
147
142
|
* One registered first-party client (AUTH-SERVER.md §4.5). The registry is the
|
|
148
143
|
* open-redirect / token-theft boundary, so a client's `redirect_uri` allowlist
|
|
@@ -185,7 +180,7 @@ interface RegisteredClientPolicyOptions {
|
|
|
185
180
|
* (`client_secret` for confidential clients; PKCE is the binding for public ones).
|
|
186
181
|
* An unregistered client or an unlisted redirect is rejected.
|
|
187
182
|
*/
|
|
188
|
-
declare class RegisteredClientPolicy implements ClientRedirectPolicy {
|
|
183
|
+
export declare class RegisteredClientPolicy implements ClientRedirectPolicy {
|
|
189
184
|
private readonly clients;
|
|
190
185
|
constructor(opts: RegisteredClientPolicyOptions);
|
|
191
186
|
resolveClient(args: {
|
|
@@ -203,8 +198,6 @@ declare class RegisteredClientPolicy implements ClientRedirectPolicy {
|
|
|
203
198
|
private redirectAllowed;
|
|
204
199
|
private grantScope;
|
|
205
200
|
}
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/authz/composite-client-policy.d.ts
|
|
208
201
|
interface CompositeClientPolicyOptions {
|
|
209
202
|
/** Used when the request carries NO `client_id` (Tier-1 public/loopback CLI). */
|
|
210
203
|
loopback: ClientRedirectPolicy;
|
|
@@ -231,7 +224,7 @@ interface CompositeClientPolicyOptions {
|
|
|
231
224
|
* `client_id` must be authenticated by the dynamic policy (existence check,
|
|
232
225
|
* PKCE binds), never rejected by the static registry that doesn't know it.
|
|
233
226
|
*/
|
|
234
|
-
declare class CompositeClientPolicy implements ClientRedirectPolicy {
|
|
227
|
+
export declare class CompositeClientPolicy implements ClientRedirectPolicy {
|
|
235
228
|
private readonly loopback;
|
|
236
229
|
private readonly registered?;
|
|
237
230
|
private readonly dynamic?;
|
|
@@ -252,8 +245,6 @@ declare class CompositeClientPolicy implements ClientRedirectPolicy {
|
|
|
252
245
|
*/
|
|
253
246
|
private pickForClientId;
|
|
254
247
|
}
|
|
255
|
-
//#endregion
|
|
256
|
-
//#region src/authz/client-registration.d.ts
|
|
257
248
|
/**
|
|
258
249
|
* RFC 7591 §3.2.2 error vocabulary — deliberately separate from
|
|
259
250
|
* `AuthorizeErrorCode`: registration errors are a different wire contract
|
|
@@ -261,7 +252,7 @@ declare class CompositeClientPolicy implements ClientRedirectPolicy {
|
|
|
261
252
|
*/
|
|
262
253
|
type ClientRegistrationErrorCode = "invalid_redirect_uri" | "invalid_client_metadata";
|
|
263
254
|
/** A typed RFC 7591 registration failure; `message` becomes `error_description`. */
|
|
264
|
-
declare class ClientRegistrationError extends Error {
|
|
255
|
+
export declare class ClientRegistrationError extends Error {
|
|
265
256
|
readonly code: ClientRegistrationErrorCode;
|
|
266
257
|
constructor(code: ClientRegistrationErrorCode, message: string);
|
|
267
258
|
}
|
|
@@ -308,7 +299,7 @@ interface ClientRegistrationValidationOptions {
|
|
|
308
299
|
* the allowed set is rejected — never silently downgrade a client that asked
|
|
309
300
|
* for a secret. Unknown fields are ignored and never echoed.
|
|
310
301
|
*/
|
|
311
|
-
declare function validateClientRegistration(body: unknown, opts?: ClientRegistrationValidationOptions): NewDynamicClient;
|
|
302
|
+
export declare function validateClientRegistration(body: unknown, opts?: ClientRegistrationValidationOptions): NewDynamicClient;
|
|
312
303
|
interface DynamicClientRegistrationOptions {
|
|
313
304
|
store: DynamicClientStore;
|
|
314
305
|
/**
|
|
@@ -359,7 +350,7 @@ type RegisteredDynamicClient = DynamicClient & {
|
|
|
359
350
|
* controller endpoint is a thin HTTP adapter over `register()`, and non-moost
|
|
360
351
|
* servers can call it directly.
|
|
361
352
|
*/
|
|
362
|
-
declare class DynamicClientRegistration {
|
|
353
|
+
export declare class DynamicClientRegistration {
|
|
363
354
|
private readonly store;
|
|
364
355
|
private readonly maxClients;
|
|
365
356
|
private readonly unusedClientTtlMs?;
|
|
@@ -375,26 +366,22 @@ declare class DynamicClientRegistration {
|
|
|
375
366
|
*/
|
|
376
367
|
register(body: unknown): Promise<RegisteredDynamicClient>;
|
|
377
368
|
}
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/authz/client-secret.d.ts
|
|
380
369
|
/**
|
|
381
370
|
* Mint a confidential dynamic client's secret (RFC 7591 `client_secret`) — a
|
|
382
371
|
* plain {@link generateOpaqueToken} mint. Returned to the registrant ONCE in
|
|
383
372
|
* the registration response; only its {@link hashClientSecret} digest is
|
|
384
373
|
* stored.
|
|
385
374
|
*/
|
|
386
|
-
declare function mintClientSecret(): string;
|
|
375
|
+
export declare function mintClientSecret(): string;
|
|
387
376
|
/**
|
|
388
377
|
* Storage digest for a client secret — plain SHA-256 (hex). No KDF/salt on
|
|
389
378
|
* purpose: the secret is high-entropy server-minted material (never a human
|
|
390
379
|
* password), so brute-forcing the digest is infeasible and a per-row salt
|
|
391
380
|
* buys nothing.
|
|
392
381
|
*/
|
|
393
|
-
declare function hashClientSecret(secret: string): string;
|
|
382
|
+
export declare function hashClientSecret(secret: string): string;
|
|
394
383
|
/** Constant-time check of a presented secret against a stored digest. */
|
|
395
|
-
declare function verifyClientSecret(secret: string, hash: string): boolean;
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region src/authz/dynamic-client-policy.d.ts
|
|
384
|
+
export declare function verifyClientSecret(secret: string, hash: string): boolean;
|
|
398
385
|
interface DynamicClientPolicyOptions {
|
|
399
386
|
store: DynamicClientStore;
|
|
400
387
|
/**
|
|
@@ -429,7 +416,7 @@ interface DynamicClientPolicyOptions {
|
|
|
429
416
|
* applies — a dynamic code redeemed without (or with another) `client_id` is
|
|
430
417
|
* rejected exactly like a Tier-2 code.
|
|
431
418
|
*/
|
|
432
|
-
declare class DynamicClientPolicy implements ClientRedirectPolicy {
|
|
419
|
+
export declare class DynamicClientPolicy implements ClientRedirectPolicy {
|
|
433
420
|
private readonly store;
|
|
434
421
|
private readonly tokenPolicy;
|
|
435
422
|
private readonly allowedScopes?;
|
|
@@ -457,8 +444,6 @@ declare class DynamicClientPolicy implements ClientRedirectPolicy {
|
|
|
457
444
|
private requireClient;
|
|
458
445
|
private grantScope;
|
|
459
446
|
}
|
|
460
|
-
//#endregion
|
|
461
|
-
//#region src/authz/id-token-signer.d.ts
|
|
462
447
|
/** Asymmetric signing algorithms an OIDC `id_token` may use (AUTH-SERVER.md §4.9). */
|
|
463
448
|
type IdTokenAlg = "RS256" | "ES256";
|
|
464
449
|
interface IdTokenSignerOptions {
|
|
@@ -504,7 +489,7 @@ interface IdTokenClaims {
|
|
|
504
489
|
* Never used for the access token (that stays in `AuthCredential`'s store) — the
|
|
505
490
|
* `id_token` is a separate, audience-bound identity assertion.
|
|
506
491
|
*/
|
|
507
|
-
declare class IdTokenSigner {
|
|
492
|
+
export declare class IdTokenSigner {
|
|
508
493
|
/** The `iss` claim + discovery `issuer` (read by `/.well-known/openid-configuration`). */
|
|
509
494
|
readonly issuer: string;
|
|
510
495
|
/** Signature algorithm — published in discovery's `id_token_signing_alg_values_supported`. */
|
|
@@ -530,8 +515,6 @@ declare class IdTokenSigner {
|
|
|
530
515
|
}>;
|
|
531
516
|
private importPrivateKey;
|
|
532
517
|
}
|
|
533
|
-
//#endregion
|
|
534
|
-
//#region src/authz/oidc-claims-resolver.d.ts
|
|
535
518
|
/**
|
|
536
519
|
* Resolves the OIDC profile claims to embed in an `id_token` for a given user +
|
|
537
520
|
* granted scope (AUTH-SERVER.md §4.9). The authorization server already controls
|
|
@@ -548,7 +531,7 @@ declare class IdTokenSigner {
|
|
|
548
531
|
* `name`/`picture`/etc. under `profile`, so a client receives only what it asked
|
|
549
532
|
* for (and was allowed).
|
|
550
533
|
*/
|
|
551
|
-
declare abstract class OidcClaimsResolver {
|
|
534
|
+
export declare abstract class OidcClaimsResolver {
|
|
552
535
|
/**
|
|
553
536
|
* @param userId the authenticated subject (the `id_token` `sub`).
|
|
554
537
|
* @param scope the granted scope, space-joined (e.g. `"openid email profile"`), or undefined.
|
|
@@ -557,20 +540,18 @@ declare abstract class OidcClaimsResolver {
|
|
|
557
540
|
abstract resolveClaims(userId: string, scope: string | undefined): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
558
541
|
}
|
|
559
542
|
/** Default resolver: emits no profile claims, so the `id_token` carries only `sub` + the registered claims. */
|
|
560
|
-
declare class NoopOidcClaimsResolver extends OidcClaimsResolver {
|
|
543
|
+
export declare class NoopOidcClaimsResolver extends OidcClaimsResolver {
|
|
561
544
|
resolveClaims(): Record<string, unknown>;
|
|
562
545
|
}
|
|
563
546
|
/** `true` when `scope` (space-joined) grants `claim` — `"email"`/`"profile"` etc. */
|
|
564
|
-
declare function scopeGrants(scope: string | undefined, claim: string): boolean;
|
|
565
|
-
//#endregion
|
|
566
|
-
//#region src/authz/server-metadata.d.ts
|
|
547
|
+
export declare function scopeGrants(scope: string | undefined, claim: string): boolean;
|
|
567
548
|
/**
|
|
568
549
|
* Strip a trailing slash from an issuer identifier. RFC 8414 mandates EXACT
|
|
569
550
|
* (byte-identical) string comparison of issuer values, so every document that
|
|
570
551
|
* spells the issuer must canonicalize it the same way — same rule as
|
|
571
552
|
* `IdTokenSigner`. Shared by the AS metadata and protected-resource builders.
|
|
572
553
|
*/
|
|
573
|
-
declare function canonicalizeIssuer(issuer: string): string;
|
|
554
|
+
export declare function canonicalizeIssuer(issuer: string): string;
|
|
574
555
|
/**
|
|
575
556
|
* RFC 8414 Authorization Server Metadata — the discovery document MCP connector
|
|
576
557
|
* clients fetch from `/.well-known/oauth-authorization-server` to locate the
|
|
@@ -630,9 +611,7 @@ interface BuildAuthorizationServerMetadataOptions {
|
|
|
630
611
|
* are omitted entirely (no `undefined` keys) so the serialized JSON carries
|
|
631
612
|
* only what was configured.
|
|
632
613
|
*/
|
|
633
|
-
declare function buildAuthorizationServerMetadata(opts: BuildAuthorizationServerMetadataOptions): AuthorizationServerMetadata;
|
|
634
|
-
//#endregion
|
|
635
|
-
//#region src/authz/resource-metadata.d.ts
|
|
614
|
+
export declare function buildAuthorizationServerMetadata(opts: BuildAuthorizationServerMetadataOptions): AuthorizationServerMetadata;
|
|
636
615
|
/**
|
|
637
616
|
* RFC 9728 Protected Resource Metadata — the document a resource server (an
|
|
638
617
|
* MCP server, an API) publishes at `/.well-known/oauth-protected-resource` so
|
|
@@ -667,7 +646,7 @@ interface BuildProtectedResourceMetadataOptions {
|
|
|
667
646
|
* mount it on any HTTP stack. Optional fields are omitted entirely (no
|
|
668
647
|
* `undefined` keys) so the serialized JSON carries only what was configured.
|
|
669
648
|
*/
|
|
670
|
-
declare function buildProtectedResourceMetadata(opts: BuildProtectedResourceMetadataOptions): ProtectedResourceMetadata;
|
|
649
|
+
export declare function buildProtectedResourceMetadata(opts: BuildProtectedResourceMetadataOptions): ProtectedResourceMetadata;
|
|
671
650
|
interface WwwAuthenticateBearerChallengeOptions {
|
|
672
651
|
/**
|
|
673
652
|
* URL of the protected-resource document (RFC 9728 §5.1) — emitted as
|
|
@@ -692,6 +671,5 @@ interface WwwAuthenticateBearerChallengeOptions {
|
|
|
692
671
|
* `realm`, `error`, `error_description`, `resource_metadata`, `scope`. All
|
|
693
672
|
* values pass through {@link sanitizeQuotedStringValue} — see its security note.
|
|
694
673
|
*/
|
|
695
|
-
declare function buildWwwAuthenticateBearerChallenge(opts?: WwwAuthenticateBearerChallengeOptions): string;
|
|
696
|
-
|
|
697
|
-
export { type AuthCode, AuthCodeStore, AuthCodeStoreMemory, type AuthCodeStoreMemoryOptions, type AuthorizationServerMetadata, AuthorizeError, type AuthorizeErrorCode, type BuildAuthorizationServerMetadataOptions, type BuildProtectedResourceMetadataOptions, type ClientRedirectPolicy, ClientRegistrationError, type ClientRegistrationErrorCode, type ClientRegistrationValidationOptions, CompositeClientPolicy, type CompositeClientPolicyOptions, DEFAULT_AUTHZ_REFRESH_TTL_MS, DEFAULT_PENDING_TTL_MS, type DynamicClient, type DynamicClientAuthMethod, DynamicClientPolicy, type DynamicClientPolicyOptions, DynamicClientRegistration, type DynamicClientRegistrationOptions, DynamicClientStore, DynamicClientStoreMemory, type DynamicClientStoreMemoryOptions, type IdTokenAlg, type IdTokenClaims, IdTokenSigner, type IdTokenSignerOptions, LoopbackClientPolicy, type LoopbackClientPolicyOptions, type NewAuthCode, type NewDynamicClient, type NewPendingAuthorization, NoopOidcClaimsResolver, OidcClaimsResolver, type PendingAuthorization, PendingAuthorizationStore, PendingAuthorizationStoreMemory, type PendingAuthorizationStoreMemoryOptions, type ProtectedResourceMetadata, type RegisteredClient, RegisteredClientPolicy, type RegisteredClientPolicyOptions, type RegisteredDynamicClient, type ResolvedClient, type TokenPolicy, type WwwAuthenticateBearerChallengeOptions, buildAuthorizationServerMetadata, buildProtectedResourceMetadata, buildWwwAuthenticateBearerChallenge, canonicalizeIssuer, hashClientSecret, isLoopbackRedirectUri, mintClientSecret, scopeGrants, tokenPolicyToIssueOptions, validateClientRegistration, verifyClientSecret };
|
|
674
|
+
export declare function buildWwwAuthenticateBearerChallenge(opts?: WwwAuthenticateBearerChallengeOptions): string;
|
|
675
|
+
export { type AuthCode, AuthCodeStore, AuthCodeStoreMemory, type AuthCodeStoreMemoryOptions, type AuthorizationServerMetadata, type AuthorizeErrorCode, type BuildAuthorizationServerMetadataOptions, type BuildProtectedResourceMetadataOptions, type ClientRedirectPolicy, type ClientRegistrationErrorCode, type ClientRegistrationValidationOptions, type CompositeClientPolicyOptions, DEFAULT_AUTHZ_REFRESH_TTL_MS, DEFAULT_PENDING_TTL_MS, type DynamicClient, type DynamicClientAuthMethod, type DynamicClientPolicyOptions, type DynamicClientRegistrationOptions, DynamicClientStore, DynamicClientStoreMemory, type DynamicClientStoreMemoryOptions, type IdTokenAlg, type IdTokenClaims, type IdTokenSignerOptions, type LoopbackClientPolicyOptions, type NewAuthCode, type NewDynamicClient, type NewPendingAuthorization, type PendingAuthorization, PendingAuthorizationStore, PendingAuthorizationStoreMemory, type PendingAuthorizationStoreMemoryOptions, type ProtectedResourceMetadata, type RegisteredClient, type RegisteredClientPolicyOptions, type RegisteredDynamicClient, type ResolvedClient, type TokenPolicy, type WwwAuthenticateBearerChallengeOptions, tokenPolicyToIssueOptions };
|