@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.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { t as defaultClock } from "./clock-
|
|
2
|
-
import { t as generateOpaqueToken } from "./opaque-token-
|
|
3
|
-
import { c as PendingAuthorizationStoreMemory, i as AuthCodeStoreMemory, n as DynamicClientStoreMemory, o as DEFAULT_PENDING_TTL_MS, r as AuthCodeStore, s as PendingAuthorizationStore, t as DynamicClientStore } from "./dynamic-client-store-
|
|
1
|
+
import { t as defaultClock } from "./clock-DzAK2bWR.mjs";
|
|
2
|
+
import { t as generateOpaqueToken } from "./opaque-token-BLoQKkZ3.mjs";
|
|
3
|
+
import { c as PendingAuthorizationStoreMemory, i as AuthCodeStoreMemory, n as DynamicClientStoreMemory, o as DEFAULT_PENDING_TTL_MS, r as AuthCodeStore, s as PendingAuthorizationStore, t as DynamicClientStore } from "./dynamic-client-store-DrMBcFtG.mjs";
|
|
4
4
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
5
5
|
import { SignJWT, exportJWK, importPKCS8, importSPKI } from "jose";
|
|
6
|
-
|
|
6
|
+
// src/authz/token-policy.ts
|
|
7
7
|
/**
|
|
8
8
|
* Default refresh-token (grant) lifetime for {@link TokenPolicy.refresh} when
|
|
9
9
|
* no `ttl` is given: 30 days. Deliberately independent of the session tier's
|
|
10
10
|
* `AuthCredentialOptions.refresh.ttl` — an authz grant's lifetime is the
|
|
11
11
|
* policy's decision, never inherited from browser-session posture.
|
|
12
12
|
*/
|
|
13
|
-
const DEFAULT_AUTHZ_REFRESH_TTL_MS =
|
|
13
|
+
const DEFAULT_AUTHZ_REFRESH_TTL_MS = 2592e6;
|
|
14
14
|
/**
|
|
15
15
|
* Flatten a {@link TokenPolicy} into the `AuthCredential.issue()` options a
|
|
16
16
|
* token endpoint forwards. The refresh dimension applies only to client-bound
|
|
@@ -34,8 +34,7 @@ function tokenPolicyToIssueOptions(policy, clientId) {
|
|
|
34
34
|
...withRefresh && { metadata: { authzClientId: clientId } }
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
//#region src/authz/authz-errors.ts
|
|
37
|
+
// src/authz/authz-errors.ts
|
|
39
38
|
/** A typed authorization-server failure. */
|
|
40
39
|
var AuthorizeError = class extends Error {
|
|
41
40
|
code;
|
|
@@ -45,8 +44,7 @@ var AuthorizeError = class extends Error {
|
|
|
45
44
|
this.code = code;
|
|
46
45
|
}
|
|
47
46
|
};
|
|
48
|
-
|
|
49
|
-
//#region src/authz/client-policy.ts
|
|
47
|
+
// src/authz/client-policy.ts
|
|
50
48
|
/**
|
|
51
49
|
* `true` when `uri` is a syntactically valid http(s) URL whose host is a
|
|
52
50
|
* **loopback literal** — `127.0.0.1`, `::1`, or `localhost` — on any port (RFC
|
|
@@ -70,7 +68,7 @@ function isLoopbackRedirectUri(uri) {
|
|
|
70
68
|
}
|
|
71
69
|
const DEFAULT_CLI_TOKEN_POLICY = {
|
|
72
70
|
kind: "cli-session",
|
|
73
|
-
ttl:
|
|
71
|
+
ttl: 2592e6
|
|
74
72
|
};
|
|
75
73
|
/**
|
|
76
74
|
* Tier-1 policy: accept any **loopback** `redirect_uri`, treat the client as a
|
|
@@ -91,8 +89,7 @@ var LoopbackClientPolicy = class {
|
|
|
91
89
|
};
|
|
92
90
|
}
|
|
93
91
|
};
|
|
94
|
-
|
|
95
|
-
//#region src/utils/timing-safe.ts
|
|
92
|
+
// src/utils/timing-safe.ts
|
|
96
93
|
/** Constant-time string compare that also fails closed on a length mismatch. */
|
|
97
94
|
function timingSafeEqualStr(a, b) {
|
|
98
95
|
const ab = Buffer.from(a, "utf8");
|
|
@@ -100,8 +97,7 @@ function timingSafeEqualStr(a, b) {
|
|
|
100
97
|
if (ab.length !== bb.length) return false;
|
|
101
98
|
return timingSafeEqual(ab, bb);
|
|
102
99
|
}
|
|
103
|
-
|
|
104
|
-
//#region src/authz/oidc-claims-resolver.ts
|
|
100
|
+
// src/authz/oidc-claims-resolver.ts
|
|
105
101
|
/**
|
|
106
102
|
* Resolves the OIDC profile claims to embed in an `id_token` for a given user +
|
|
107
103
|
* granted scope (AUTH-SERVER.md §4.9). The authorization server already controls
|
|
@@ -130,8 +126,7 @@ function scopeGrants(scope, claim) {
|
|
|
130
126
|
if (!scope) return false;
|
|
131
127
|
return scope.split(/\s+/u).includes(claim);
|
|
132
128
|
}
|
|
133
|
-
|
|
134
|
-
//#region src/authz/registered-client-policy.ts
|
|
129
|
+
// src/authz/registered-client-policy.ts
|
|
135
130
|
/**
|
|
136
131
|
* Tier-2 policy: a static registry of first-party clients. `resolveClient`
|
|
137
132
|
* authorizes the client + `redirect_uri` (against the registered allowlist) and
|
|
@@ -198,8 +193,7 @@ var RegisteredClientPolicy = class {
|
|
|
198
193
|
return granted.length > 0 ? granted.join(" ") : void 0;
|
|
199
194
|
}
|
|
200
195
|
};
|
|
201
|
-
|
|
202
|
-
//#region src/authz/composite-client-policy.ts
|
|
196
|
+
// src/authz/composite-client-policy.ts
|
|
203
197
|
/**
|
|
204
198
|
* Runs the tiers side by side, dispatching on the **presence and ownership of
|
|
205
199
|
* `client_id`** (AUTH-SERVER.md §10, OAUTH.md R2): a request without a
|
|
@@ -246,8 +240,7 @@ var CompositeClientPolicy = class {
|
|
|
246
240
|
return known instanceof Promise ? known.then((k) => k ? this.registered : this.dynamic) : known ? this.registered : this.dynamic;
|
|
247
241
|
}
|
|
248
242
|
};
|
|
249
|
-
|
|
250
|
-
//#region src/authz/client-secret.ts
|
|
243
|
+
// src/authz/client-secret.ts
|
|
251
244
|
/**
|
|
252
245
|
* Mint a confidential dynamic client's secret (RFC 7591 `client_secret`) — a
|
|
253
246
|
* plain {@link generateOpaqueToken} mint. Returned to the registrant ONCE in
|
|
@@ -270,8 +263,7 @@ function hashClientSecret(secret) {
|
|
|
270
263
|
function verifyClientSecret(secret, hash) {
|
|
271
264
|
return timingSafeEqualStr(hashClientSecret(secret), hash);
|
|
272
265
|
}
|
|
273
|
-
|
|
274
|
-
//#region src/authz/client-registration.ts
|
|
266
|
+
// src/authz/client-registration.ts
|
|
275
267
|
/** A typed RFC 7591 registration failure; `message` becomes `error_description`. */
|
|
276
268
|
var ClientRegistrationError = class extends Error {
|
|
277
269
|
code;
|
|
@@ -431,11 +423,10 @@ var DynamicClientRegistration = class {
|
|
|
431
423
|
return this.store.create(metadata);
|
|
432
424
|
}
|
|
433
425
|
};
|
|
434
|
-
|
|
435
|
-
//#region src/authz/dynamic-client-policy.ts
|
|
426
|
+
// src/authz/dynamic-client-policy.ts
|
|
436
427
|
const DEFAULT_DYNAMIC_TOKEN_POLICY = {
|
|
437
428
|
kind: "dynamic-session",
|
|
438
|
-
ttl:
|
|
429
|
+
ttl: 2592e6
|
|
439
430
|
};
|
|
440
431
|
/**
|
|
441
432
|
* Policy for RFC 7591 dynamically-registered clients (OAUTH.md R2) on the
|
|
@@ -535,8 +526,7 @@ function redirectAllowed(client, uri) {
|
|
|
535
526
|
return reg.protocol === presented.protocol && reg.hostname === presented.hostname && reg.pathname === presented.pathname && reg.search === presented.search;
|
|
536
527
|
});
|
|
537
528
|
}
|
|
538
|
-
|
|
539
|
-
//#region src/authz/id-token-signer.ts
|
|
529
|
+
// src/authz/id-token-signer.ts
|
|
540
530
|
/**
|
|
541
531
|
* Signs OIDC `id_token`s and publishes the matching JWKS (AUTH-SERVER.md §4.9).
|
|
542
532
|
* Holds one asymmetric keypair; mints short-lived RS256/ES256 tokens with the
|
|
@@ -589,7 +579,8 @@ var IdTokenSigner = class {
|
|
|
589
579
|
*/
|
|
590
580
|
async jwks() {
|
|
591
581
|
this.jwksPromise ??= (async () => {
|
|
592
|
-
const
|
|
582
|
+
const pub = await importSPKI(this.publicKeyPem, this.alg, { extractable: true });
|
|
583
|
+
const jwk = await exportJWK(pub);
|
|
593
584
|
jwk.kid = this.kid;
|
|
594
585
|
jwk.alg = this.alg;
|
|
595
586
|
jwk.use = "sig";
|
|
@@ -602,8 +593,7 @@ var IdTokenSigner = class {
|
|
|
602
593
|
return this.privateKeyPromise;
|
|
603
594
|
}
|
|
604
595
|
};
|
|
605
|
-
|
|
606
|
-
//#region src/authz/server-metadata.ts
|
|
596
|
+
// src/authz/server-metadata.ts
|
|
607
597
|
/**
|
|
608
598
|
* Strip a trailing slash from an issuer identifier. RFC 8414 mandates EXACT
|
|
609
599
|
* (byte-identical) string comparison of issuer values, so every document that
|
|
@@ -644,8 +634,7 @@ function buildAuthorizationServerMetadata(opts) {
|
|
|
644
634
|
...opts.scopesSupported !== void 0 && { scopes_supported: opts.scopesSupported }
|
|
645
635
|
};
|
|
646
636
|
}
|
|
647
|
-
|
|
648
|
-
//#region src/authz/resource-metadata.ts
|
|
637
|
+
// src/authz/resource-metadata.ts
|
|
649
638
|
/**
|
|
650
639
|
* Build the RFC 9728 protected-resource document. Pure — no I/O, no framework;
|
|
651
640
|
* mount it on any HTTP stack. Optional fields are omitted entirely (no
|
|
@@ -692,5 +681,4 @@ function buildWwwAuthenticateBearerChallenge(opts) {
|
|
|
692
681
|
push("scope", opts?.scope);
|
|
693
682
|
return params.length === 0 ? "Bearer" : `Bearer ${params.join(", ")}`;
|
|
694
683
|
}
|
|
695
|
-
//#endregion
|
|
696
684
|
export { AuthCodeStore, AuthCodeStoreMemory, AuthorizeError, ClientRegistrationError, CompositeClientPolicy, DEFAULT_AUTHZ_REFRESH_TTL_MS, DEFAULT_PENDING_TTL_MS, DynamicClientPolicy, DynamicClientRegistration, DynamicClientStore, DynamicClientStoreMemory, IdTokenSigner, LoopbackClientPolicy, NoopOidcClaimsResolver, OidcClaimsResolver, PendingAuthorizationStore, PendingAuthorizationStoreMemory, RegisteredClientPolicy, buildAuthorizationServerMetadata, buildProtectedResourceMetadata, buildWwwAuthenticateBearerChallenge, canonicalizeIssuer, hashClientSecret, isLoopbackRedirectUri, mintClientSecret, scopeGrants, tokenPolicyToIssueOptions, validateClientRegistration, verifyClientSecret };
|
package/dist/client.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// src/client/index.ts
|
|
3
3
|
/**
|
|
4
4
|
* Wraps `fetch` with cookie-session silent refresh. Every call forwards
|
|
5
5
|
* credentials; a response whose status is in `refreshOn` (401 by default)
|
|
@@ -68,5 +68,4 @@ function createAuthedFetch(options = {}) {
|
|
|
68
68
|
};
|
|
69
69
|
return authedFetch;
|
|
70
70
|
}
|
|
71
|
-
//#endregion
|
|
72
71
|
exports.createAuthedFetch = createAuthedFetch;
|
package/dist/client.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
//#region src/client/index.d.ts
|
|
2
1
|
/** Minimal structural view of a fetch `Response` this helper reads. The DOM `Response` satisfies it. */
|
|
3
|
-
interface MinimalResponse {
|
|
2
|
+
export interface MinimalResponse {
|
|
4
3
|
readonly ok: boolean;
|
|
5
4
|
readonly status: number;
|
|
6
5
|
}
|
|
@@ -9,7 +8,7 @@ interface MinimalResponse {
|
|
|
9
8
|
* (and Node's) is assignable to it: fields the helper never inspects are typed
|
|
10
9
|
* `unknown` so `Headers` instances, `AbortSignal`s and any body type pass through.
|
|
11
10
|
*/
|
|
12
|
-
interface MinimalRequestInit {
|
|
11
|
+
export interface MinimalRequestInit {
|
|
13
12
|
method?: string;
|
|
14
13
|
headers?: unknown;
|
|
15
14
|
body?: unknown;
|
|
@@ -32,7 +31,7 @@ interface MinimalRequestInit {
|
|
|
32
31
|
* Declared method-style so its parameters are compared bivariantly — the DOM
|
|
33
32
|
* `fetch`'s wider `RequestInfo` / `RequestInit` parameters still match.
|
|
34
33
|
*/
|
|
35
|
-
type FetchFn = {
|
|
34
|
+
export type FetchFn = {
|
|
36
35
|
fetch(input: string | URL, init?: MinimalRequestInit): Promise<MinimalResponse>;
|
|
37
36
|
}["fetch"];
|
|
38
37
|
/**
|
|
@@ -42,7 +41,7 @@ type FetchFn = {
|
|
|
42
41
|
* `@aooth/auth/client` free of a hard DOM-lib dependency while preserving great
|
|
43
42
|
* DX in browser projects.
|
|
44
43
|
*/
|
|
45
|
-
type DefaultFetch = typeof globalThis extends {
|
|
44
|
+
export type DefaultFetch = typeof globalThis extends {
|
|
46
45
|
fetch: infer F extends FetchFn;
|
|
47
46
|
} ? F : FetchFn;
|
|
48
47
|
/**
|
|
@@ -50,11 +49,11 @@ type DefaultFetch = typeof globalThis extends {
|
|
|
50
49
|
* answered; `error` is the thrown value when the request itself failed
|
|
51
50
|
* (offline, aborted, DNS, CORS).
|
|
52
51
|
*/
|
|
53
|
-
interface AuthedFetchRefreshFailure {
|
|
52
|
+
export interface AuthedFetchRefreshFailure {
|
|
54
53
|
status?: number;
|
|
55
54
|
error?: unknown;
|
|
56
55
|
}
|
|
57
|
-
interface CreateAuthedFetchOptions<TFetch extends FetchFn = DefaultFetch> {
|
|
56
|
+
export interface CreateAuthedFetchOptions<TFetch extends FetchFn = DefaultFetch> {
|
|
58
57
|
/** Refresh endpoint path or URL. Default `'/auth/refresh'`. Match your `AuthController` mount. */
|
|
59
58
|
refreshPath?: string;
|
|
60
59
|
/**
|
|
@@ -105,6 +104,4 @@ interface CreateAuthedFetchOptions<TFetch extends FetchFn = DefaultFetch> {
|
|
|
105
104
|
* const res = await api('/api/me') // 401 → silent refresh → retried once
|
|
106
105
|
* ```
|
|
107
106
|
*/
|
|
108
|
-
declare function createAuthedFetch<TFetch extends FetchFn = DefaultFetch>(options?: CreateAuthedFetchOptions<TFetch>): TFetch;
|
|
109
|
-
//#endregion
|
|
110
|
-
export { AuthedFetchRefreshFailure, CreateAuthedFetchOptions, DefaultFetch, FetchFn, MinimalRequestInit, MinimalResponse, createAuthedFetch };
|
|
107
|
+
export declare function createAuthedFetch<TFetch extends FetchFn = DefaultFetch>(options?: CreateAuthedFetchOptions<TFetch>): TFetch;
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
//#region src/client/index.d.ts
|
|
2
1
|
/** Minimal structural view of a fetch `Response` this helper reads. The DOM `Response` satisfies it. */
|
|
3
|
-
interface MinimalResponse {
|
|
2
|
+
export interface MinimalResponse {
|
|
4
3
|
readonly ok: boolean;
|
|
5
4
|
readonly status: number;
|
|
6
5
|
}
|
|
@@ -9,7 +8,7 @@ interface MinimalResponse {
|
|
|
9
8
|
* (and Node's) is assignable to it: fields the helper never inspects are typed
|
|
10
9
|
* `unknown` so `Headers` instances, `AbortSignal`s and any body type pass through.
|
|
11
10
|
*/
|
|
12
|
-
interface MinimalRequestInit {
|
|
11
|
+
export interface MinimalRequestInit {
|
|
13
12
|
method?: string;
|
|
14
13
|
headers?: unknown;
|
|
15
14
|
body?: unknown;
|
|
@@ -32,7 +31,7 @@ interface MinimalRequestInit {
|
|
|
32
31
|
* Declared method-style so its parameters are compared bivariantly — the DOM
|
|
33
32
|
* `fetch`'s wider `RequestInfo` / `RequestInit` parameters still match.
|
|
34
33
|
*/
|
|
35
|
-
type FetchFn = {
|
|
34
|
+
export type FetchFn = {
|
|
36
35
|
fetch(input: string | URL, init?: MinimalRequestInit): Promise<MinimalResponse>;
|
|
37
36
|
}["fetch"];
|
|
38
37
|
/**
|
|
@@ -42,7 +41,7 @@ type FetchFn = {
|
|
|
42
41
|
* `@aooth/auth/client` free of a hard DOM-lib dependency while preserving great
|
|
43
42
|
* DX in browser projects.
|
|
44
43
|
*/
|
|
45
|
-
type DefaultFetch = typeof globalThis extends {
|
|
44
|
+
export type DefaultFetch = typeof globalThis extends {
|
|
46
45
|
fetch: infer F extends FetchFn;
|
|
47
46
|
} ? F : FetchFn;
|
|
48
47
|
/**
|
|
@@ -50,11 +49,11 @@ type DefaultFetch = typeof globalThis extends {
|
|
|
50
49
|
* answered; `error` is the thrown value when the request itself failed
|
|
51
50
|
* (offline, aborted, DNS, CORS).
|
|
52
51
|
*/
|
|
53
|
-
interface AuthedFetchRefreshFailure {
|
|
52
|
+
export interface AuthedFetchRefreshFailure {
|
|
54
53
|
status?: number;
|
|
55
54
|
error?: unknown;
|
|
56
55
|
}
|
|
57
|
-
interface CreateAuthedFetchOptions<TFetch extends FetchFn = DefaultFetch> {
|
|
56
|
+
export interface CreateAuthedFetchOptions<TFetch extends FetchFn = DefaultFetch> {
|
|
58
57
|
/** Refresh endpoint path or URL. Default `'/auth/refresh'`. Match your `AuthController` mount. */
|
|
59
58
|
refreshPath?: string;
|
|
60
59
|
/**
|
|
@@ -105,6 +104,4 @@ interface CreateAuthedFetchOptions<TFetch extends FetchFn = DefaultFetch> {
|
|
|
105
104
|
* const res = await api('/api/me') // 401 → silent refresh → retried once
|
|
106
105
|
* ```
|
|
107
106
|
*/
|
|
108
|
-
declare function createAuthedFetch<TFetch extends FetchFn = DefaultFetch>(options?: CreateAuthedFetchOptions<TFetch>): TFetch;
|
|
109
|
-
//#endregion
|
|
110
|
-
export { AuthedFetchRefreshFailure, CreateAuthedFetchOptions, DefaultFetch, FetchFn, MinimalRequestInit, MinimalResponse, createAuthedFetch };
|
|
107
|
+
export declare function createAuthedFetch<TFetch extends FetchFn = DefaultFetch>(options?: CreateAuthedFetchOptions<TFetch>): TFetch;
|
package/dist/client.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/client/index.ts
|
|
2
2
|
/**
|
|
3
3
|
* Wraps `fetch` with cookie-session silent refresh. Every call forwards
|
|
4
4
|
* credentials; a response whose status is in `refreshOn` (401 by default)
|
|
@@ -67,5 +67,4 @@ function createAuthedFetch(options = {}) {
|
|
|
67
67
|
};
|
|
68
68
|
return authedFetch;
|
|
69
69
|
}
|
|
70
|
-
//#endregion
|
|
71
70
|
export { createAuthedFetch };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/credential/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The read-time envelope a successful auth check always produces — the fixed
|
|
4
3
|
* fields, before the credential's typed payload is merged in. See
|
|
@@ -284,8 +283,6 @@ interface RefreshConfig {
|
|
|
284
283
|
*/
|
|
285
284
|
onRotationGraceHit?: (state: CredentialState) => void;
|
|
286
285
|
}
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region src/stores/store.d.ts
|
|
289
286
|
/**
|
|
290
287
|
* Pluggable credential storage. Implementations: Memory, JWT, Encapsulated.
|
|
291
288
|
* Same shape works for stateful and stateless stores. Stateless stores treat
|
|
@@ -358,8 +355,6 @@ interface DenylistStore {
|
|
|
358
355
|
has(jti: string): Promise<boolean>;
|
|
359
356
|
cleanup(): Promise<number>;
|
|
360
357
|
}
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/utils/clock.d.ts
|
|
363
358
|
/**
|
|
364
359
|
* Minimal time abstraction shared across stores and orchestrators.
|
|
365
360
|
*
|
|
@@ -371,5 +366,4 @@ interface Clock {
|
|
|
371
366
|
now(): number;
|
|
372
367
|
}
|
|
373
368
|
declare const defaultClock: Clock;
|
|
374
|
-
//#endregion
|
|
375
369
|
export { AuthContext as a, CredentialSuccessorRef as c, RefreshConfig as d, RefreshResult as f, DenylistStore as i, EnrichedSession as l, SessionInfo as m, defaultClock as n, CredentialMetadata as o, SessionEnricher as p, CredentialStore as r, CredentialState as s, Clock as t, IssueResult as u };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/credential/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The read-time envelope a successful auth check always produces — the fixed
|
|
4
3
|
* fields, before the credential's typed payload is merged in. See
|
|
@@ -284,8 +283,6 @@ interface RefreshConfig {
|
|
|
284
283
|
*/
|
|
285
284
|
onRotationGraceHit?: (state: CredentialState) => void;
|
|
286
285
|
}
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region src/stores/store.d.ts
|
|
289
286
|
/**
|
|
290
287
|
* Pluggable credential storage. Implementations: Memory, JWT, Encapsulated.
|
|
291
288
|
* Same shape works for stateful and stateless stores. Stateless stores treat
|
|
@@ -358,8 +355,6 @@ interface DenylistStore {
|
|
|
358
355
|
has(jti: string): Promise<boolean>;
|
|
359
356
|
cleanup(): Promise<number>;
|
|
360
357
|
}
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/utils/clock.d.ts
|
|
363
358
|
/**
|
|
364
359
|
* Minimal time abstraction shared across stores and orchestrators.
|
|
365
360
|
*
|
|
@@ -371,5 +366,4 @@ interface Clock {
|
|
|
371
366
|
now(): number;
|
|
372
367
|
}
|
|
373
368
|
declare const defaultClock: Clock;
|
|
374
|
-
//#endregion
|
|
375
369
|
export { AuthContext as a, CredentialSuccessorRef as c, RefreshConfig as d, RefreshResult as f, DenylistStore as i, EnrichedSession as l, SessionInfo as m, defaultClock as n, CredentialMetadata as o, SessionEnricher as p, CredentialStore as r, CredentialState as s, Clock as t, IssueResult as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_clock = require("./clock-
|
|
1
|
+
const require_clock = require("./clock-BcBMqB9g.cjs");
|
|
2
2
|
let node_crypto = require("node:crypto");
|
|
3
|
-
|
|
3
|
+
// src/authz/pending-authorization-store.ts
|
|
4
4
|
/**
|
|
5
5
|
* Storage seam for in-flight authorizations (AUTH-SERVER.md §4.3). Short-lived
|
|
6
6
|
* (≈ the login-session ceiling): created at `/authorize`, read+deleted at the
|
|
@@ -10,7 +10,7 @@ let node_crypto = require("node:crypto");
|
|
|
10
10
|
*/
|
|
11
11
|
var PendingAuthorizationStore = class {};
|
|
12
12
|
/** Default pending-authorization lifetime (15 min). Shared by the memory + atscript-db stores. */
|
|
13
|
-
const DEFAULT_PENDING_TTL_MS =
|
|
13
|
+
const DEFAULT_PENDING_TTL_MS = 9e5;
|
|
14
14
|
/**
|
|
15
15
|
* In-memory {@link PendingAuthorizationStore} — the reference impl for a
|
|
16
16
|
* single-process app + tests. `structuredClone` on read/write isolates callers.
|
|
@@ -63,8 +63,7 @@ var PendingAuthorizationStoreMemory = class extends PendingAuthorizationStore {
|
|
|
63
63
|
return this.store.delete(handle);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
//#region src/authz/auth-code-store.ts
|
|
66
|
+
// src/authz/auth-code-store.ts
|
|
68
67
|
/**
|
|
69
68
|
* Storage seam for issued authorization codes (AUTH-SERVER.md §4.3). Very
|
|
70
69
|
* short-lived (≈ 30–60 s) and **single-use**: {@link consume} returns the row
|
|
@@ -119,8 +118,7 @@ var AuthCodeStoreMemory = class extends AuthCodeStore {
|
|
|
119
118
|
return structuredClone(row);
|
|
120
119
|
}
|
|
121
120
|
};
|
|
122
|
-
|
|
123
|
-
//#region src/authz/dynamic-client-store.ts
|
|
121
|
+
// src/authz/dynamic-client-store.ts
|
|
124
122
|
/**
|
|
125
123
|
* Storage seam for dynamically-registered clients (OAUTH.md R2). Long-lived
|
|
126
124
|
* (unlike the pending-auth / auth-code stores): a connector caches its
|
|
@@ -179,7 +177,6 @@ var DynamicClientStoreMemory = class extends DynamicClientStore {
|
|
|
179
177
|
return removed;
|
|
180
178
|
}
|
|
181
179
|
};
|
|
182
|
-
//#endregion
|
|
183
180
|
Object.defineProperty(exports, "AuthCodeStore", {
|
|
184
181
|
enumerable: true,
|
|
185
182
|
get: function() {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { t as Clock } from "./clock-
|
|
2
|
-
import { r as IssueOptions } from "./auth-credential-
|
|
3
|
-
//#region src/authz/token-policy.d.ts
|
|
1
|
+
import { t as Clock } from "./clock-hTHoZ2vA.cjs";
|
|
2
|
+
import { r as IssueOptions } from "./auth-credential-46_eOF3c.cjs";
|
|
4
3
|
/**
|
|
5
4
|
* What the authorization server mints for a completed grant — forwarded verbatim
|
|
6
5
|
* into `AuthCredential.issue(userId, …)` at the token endpoint. Decided by the
|
|
@@ -69,8 +68,6 @@ declare const DEFAULT_AUTHZ_REFRESH_TTL_MS: number;
|
|
|
69
68
|
* its default ttl, so every HTTP adapter applies the same semantics.
|
|
70
69
|
*/
|
|
71
70
|
declare function tokenPolicyToIssueOptions(policy: TokenPolicy, clientId: string | undefined): IssueOptions;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/authz/pending-authorization-store.d.ts
|
|
74
71
|
/**
|
|
75
72
|
* One in-flight authorization request, recorded at `GET /auth/authorize` and
|
|
76
73
|
* read once at the login-workflow terminal that mints the auth code. Keyed by an
|
|
@@ -190,8 +187,6 @@ declare class PendingAuthorizationStoreMemory extends PendingAuthorizationStore
|
|
|
190
187
|
get(handle: string): Promise<PendingAuthorization | null>;
|
|
191
188
|
delete(handle: string): Promise<boolean>;
|
|
192
189
|
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/authz/auth-code-store.d.ts
|
|
195
190
|
/**
|
|
196
191
|
* A minted, single-use authorization code, bound to the user the login resolved
|
|
197
192
|
* plus the PKCE challenge / redirect / token policy recorded at `/authorize`.
|
|
@@ -281,8 +276,6 @@ declare class AuthCodeStoreMemory extends AuthCodeStore {
|
|
|
281
276
|
}>;
|
|
282
277
|
consume(code: string): Promise<AuthCode | null>;
|
|
283
278
|
}
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/authz/dynamic-client-store.d.ts
|
|
286
279
|
/** Token-endpoint auth methods a dynamic client may register with. */
|
|
287
280
|
type DynamicClientAuthMethod = "none" | "client_secret_post";
|
|
288
281
|
/**
|
|
@@ -384,5 +377,4 @@ declare class DynamicClientStoreMemory extends DynamicClientStore {
|
|
|
384
377
|
touch(clientId: string, at: number): Promise<void>;
|
|
385
378
|
deleteUnusedBefore(cutoff: number): Promise<number>;
|
|
386
379
|
}
|
|
387
|
-
//#endregion
|
|
388
380
|
export { PendingAuthorizationStoreMemoryOptions as _, DynamicClientStoreMemoryOptions as a, tokenPolicyToIssueOptions as b, AuthCodeStore as c, NewAuthCode as d, DEFAULT_PENDING_TTL_MS as f, PendingAuthorizationStoreMemory as g, PendingAuthorizationStore as h, DynamicClientStoreMemory as i, AuthCodeStoreMemory as l, PendingAuthorization as m, DynamicClientAuthMethod as n, NewDynamicClient as o, NewPendingAuthorization as p, DynamicClientStore as r, AuthCode as s, DynamicClient as t, AuthCodeStoreMemoryOptions as u, DEFAULT_AUTHZ_REFRESH_TTL_MS as v, TokenPolicy as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as defaultClock } from "./clock-
|
|
1
|
+
import { t as defaultClock } from "./clock-DzAK2bWR.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
|
|
3
|
+
// src/authz/pending-authorization-store.ts
|
|
4
4
|
/**
|
|
5
5
|
* Storage seam for in-flight authorizations (AUTH-SERVER.md §4.3). Short-lived
|
|
6
6
|
* (≈ the login-session ceiling): created at `/authorize`, read+deleted at the
|
|
@@ -10,7 +10,7 @@ import { randomUUID } from "node:crypto";
|
|
|
10
10
|
*/
|
|
11
11
|
var PendingAuthorizationStore = class {};
|
|
12
12
|
/** Default pending-authorization lifetime (15 min). Shared by the memory + atscript-db stores. */
|
|
13
|
-
const DEFAULT_PENDING_TTL_MS =
|
|
13
|
+
const DEFAULT_PENDING_TTL_MS = 9e5;
|
|
14
14
|
/**
|
|
15
15
|
* In-memory {@link PendingAuthorizationStore} — the reference impl for a
|
|
16
16
|
* single-process app + tests. `structuredClone` on read/write isolates callers.
|
|
@@ -63,8 +63,7 @@ var PendingAuthorizationStoreMemory = class extends PendingAuthorizationStore {
|
|
|
63
63
|
return this.store.delete(handle);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
//#region src/authz/auth-code-store.ts
|
|
66
|
+
// src/authz/auth-code-store.ts
|
|
68
67
|
/**
|
|
69
68
|
* Storage seam for issued authorization codes (AUTH-SERVER.md §4.3). Very
|
|
70
69
|
* short-lived (≈ 30–60 s) and **single-use**: {@link consume} returns the row
|
|
@@ -119,8 +118,7 @@ var AuthCodeStoreMemory = class extends AuthCodeStore {
|
|
|
119
118
|
return structuredClone(row);
|
|
120
119
|
}
|
|
121
120
|
};
|
|
122
|
-
|
|
123
|
-
//#region src/authz/dynamic-client-store.ts
|
|
121
|
+
// src/authz/dynamic-client-store.ts
|
|
124
122
|
/**
|
|
125
123
|
* Storage seam for dynamically-registered clients (OAUTH.md R2). Long-lived
|
|
126
124
|
* (unlike the pending-auth / auth-code stores): a connector caches its
|
|
@@ -179,5 +177,4 @@ var DynamicClientStoreMemory = class extends DynamicClientStore {
|
|
|
179
177
|
return removed;
|
|
180
178
|
}
|
|
181
179
|
};
|
|
182
|
-
//#endregion
|
|
183
180
|
export { DEFAULT_CODE_TTL_MS as a, PendingAuthorizationStoreMemory as c, AuthCodeStoreMemory as i, DynamicClientStoreMemory as n, DEFAULT_PENDING_TTL_MS as o, AuthCodeStore as r, PendingAuthorizationStore as s, DynamicClientStore as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { t as Clock } from "./clock-
|
|
2
|
-
import { r as IssueOptions } from "./auth-credential-
|
|
3
|
-
//#region src/authz/token-policy.d.ts
|
|
1
|
+
import { t as Clock } from "./clock-hTHoZ2vA.mjs";
|
|
2
|
+
import { r as IssueOptions } from "./auth-credential-Co-0pqcD.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* What the authorization server mints for a completed grant — forwarded verbatim
|
|
6
5
|
* into `AuthCredential.issue(userId, …)` at the token endpoint. Decided by the
|
|
@@ -69,8 +68,6 @@ declare const DEFAULT_AUTHZ_REFRESH_TTL_MS: number;
|
|
|
69
68
|
* its default ttl, so every HTTP adapter applies the same semantics.
|
|
70
69
|
*/
|
|
71
70
|
declare function tokenPolicyToIssueOptions(policy: TokenPolicy, clientId: string | undefined): IssueOptions;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/authz/pending-authorization-store.d.ts
|
|
74
71
|
/**
|
|
75
72
|
* One in-flight authorization request, recorded at `GET /auth/authorize` and
|
|
76
73
|
* read once at the login-workflow terminal that mints the auth code. Keyed by an
|
|
@@ -190,8 +187,6 @@ declare class PendingAuthorizationStoreMemory extends PendingAuthorizationStore
|
|
|
190
187
|
get(handle: string): Promise<PendingAuthorization | null>;
|
|
191
188
|
delete(handle: string): Promise<boolean>;
|
|
192
189
|
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/authz/auth-code-store.d.ts
|
|
195
190
|
/**
|
|
196
191
|
* A minted, single-use authorization code, bound to the user the login resolved
|
|
197
192
|
* plus the PKCE challenge / redirect / token policy recorded at `/authorize`.
|
|
@@ -281,8 +276,6 @@ declare class AuthCodeStoreMemory extends AuthCodeStore {
|
|
|
281
276
|
}>;
|
|
282
277
|
consume(code: string): Promise<AuthCode | null>;
|
|
283
278
|
}
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region src/authz/dynamic-client-store.d.ts
|
|
286
279
|
/** Token-endpoint auth methods a dynamic client may register with. */
|
|
287
280
|
type DynamicClientAuthMethod = "none" | "client_secret_post";
|
|
288
281
|
/**
|
|
@@ -384,5 +377,4 @@ declare class DynamicClientStoreMemory extends DynamicClientStore {
|
|
|
384
377
|
touch(clientId: string, at: number): Promise<void>;
|
|
385
378
|
deleteUnusedBefore(cutoff: number): Promise<number>;
|
|
386
379
|
}
|
|
387
|
-
//#endregion
|
|
388
380
|
export { PendingAuthorizationStoreMemoryOptions as _, DynamicClientStoreMemoryOptions as a, tokenPolicyToIssueOptions as b, AuthCodeStore as c, NewAuthCode as d, DEFAULT_PENDING_TTL_MS as f, PendingAuthorizationStoreMemory as g, PendingAuthorizationStore as h, DynamicClientStoreMemory as i, AuthCodeStoreMemory as l, PendingAuthorization as m, DynamicClientAuthMethod as n, NewDynamicClient as o, NewPendingAuthorization as p, DynamicClientStore as r, AuthCode as s, DynamicClient as t, AuthCodeStoreMemoryOptions as u, DEFAULT_AUTHZ_REFRESH_TTL_MS as v, TokenPolicy as y };
|