@aooth/auth 0.2.1 → 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.
Files changed (37) hide show
  1. package/dist/atscript-db.cjs +5 -7
  2. package/dist/atscript-db.d.cts +21 -25
  3. package/dist/atscript-db.d.mts +21 -25
  4. package/dist/atscript-db.mjs +5 -7
  5. package/dist/{auth-credential-CjCgZv7n.d.mts → auth-credential-46_eOF3c.d.cts} +1 -3
  6. package/dist/{auth-credential-UV3sJ-lt.d.cts → auth-credential-Co-0pqcD.d.mts} +1 -3
  7. package/dist/authz.cjs +21 -33
  8. package/dist/authz.d.cts +23 -45
  9. package/dist/authz.d.mts +23 -45
  10. package/dist/authz.mjs +21 -33
  11. package/dist/client.cjs +1 -2
  12. package/dist/client.d.cts +7 -10
  13. package/dist/client.d.mts +7 -10
  14. package/dist/client.mjs +1 -2
  15. package/dist/{clock-Bl-H3eqE.cjs → clock-BcBMqB9g.cjs} +1 -2
  16. package/dist/{clock-Bdsep_1j.mjs → clock-DzAK2bWR.mjs} +1 -2
  17. package/dist/{clock-CzAaCoZ5.d.cts → clock-hTHoZ2vA.d.cts} +0 -6
  18. package/dist/{clock-CzAaCoZ5.d.mts → clock-hTHoZ2vA.d.mts} +0 -6
  19. package/dist/{dynamic-client-store-DykM9QOT.cjs → dynamic-client-store-CC4qr_kz.cjs} +5 -8
  20. package/dist/{dynamic-client-store-B7EnHuRp.d.cts → dynamic-client-store-CTt1B6Gj.d.cts} +2 -10
  21. package/dist/{dynamic-client-store-B1JwFHdP.mjs → dynamic-client-store-DrMBcFtG.mjs} +5 -8
  22. package/dist/{dynamic-client-store-BifZLGkT.d.mts → dynamic-client-store-mYg0nRJU.d.mts} +2 -10
  23. package/dist/index.cjs +14 -24
  24. package/dist/index.d.cts +18 -40
  25. package/dist/index.d.mts +18 -40
  26. package/dist/index.mjs +14 -24
  27. package/dist/{opaque-token-BaMOrC1A.mjs → opaque-token-BLoQKkZ3.mjs} +1 -2
  28. package/dist/{opaque-token-CaZgD2i6.cjs → opaque-token-BLuVHSVJ.cjs} +1 -2
  29. package/dist/{payload-C1cQW7p_.cjs → payload-CqQH88C6.cjs} +2 -4
  30. package/dist/{payload-DDlf38B-.mjs → payload-DizkKbzh.mjs} +2 -4
  31. package/dist/redis.cjs +1 -2
  32. package/dist/redis.d.cts +7 -9
  33. package/dist/redis.d.mts +7 -9
  34. package/dist/redis.mjs +1 -2
  35. package/dist/{store-BaFYDHxn.d.cts → store-BXxX8sUP.d.mts} +1 -3
  36. package/dist/{store-h-bLOAaS.d.mts → store-D9CcbcBp.d.cts} +1 -3
  37. package/package.json +9 -9
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_payload = require("./payload-C1cQW7p_.cjs");
3
- const require_clock = require("./clock-Bl-H3eqE.cjs");
4
- const require_dynamic_client_store = require("./dynamic-client-store-DykM9QOT.cjs");
2
+ const require_payload = require("./payload-CqQH88C6.cjs");
3
+ const require_clock = require("./clock-BcBMqB9g.cjs");
4
+ const require_dynamic_client_store = require("./dynamic-client-store-CC4qr_kz.cjs");
5
5
  let node_crypto = require("node:crypto");
6
- //#region src/atscript-db/authz-stores.ts
6
+ // src/atscript-db/authz-stores.ts
7
7
  /**
8
8
  * Durable {@link PendingAuthorizationStore}. `create` inserts a row keyed by a
9
9
  * fresh opaque `handle`; `get` rejects (and lazily evicts) a past-expiry row;
@@ -218,8 +218,7 @@ function rowToDynamicClient(row) {
218
218
  if (row.lastUsedAt != null) out.lastUsedAt = row.lastUsedAt;
219
219
  return out;
220
220
  }
221
- //#endregion
222
- //#region src/atscript-db/index.ts
221
+ // src/atscript-db/index.ts
223
222
  /**
224
223
  * Metadata keys that carry per-token authority — losing them on a store
225
224
  * without a metadata column would silently widen what the token can do.
@@ -439,7 +438,6 @@ function rowToState(row, metadataField) {
439
438
  if (row.lastSeenAt !== void 0) state.lastSeenAt = row.lastSeenAt;
440
439
  return state;
441
440
  }
442
- //#endregion
443
441
  exports.AUTHORITY_METADATA_KEYS = AUTHORITY_METADATA_KEYS;
444
442
  exports.AuthCodeStoreAtscriptDb = AuthCodeStoreAtscriptDb;
445
443
  exports.CredentialStoreAtscriptDb = CredentialStoreAtscriptDb;
@@ -1,6 +1,5 @@
1
- import { c as CredentialSuccessorRef, r as CredentialStore, s as CredentialState, t as Clock } from "./clock-CzAaCoZ5.cjs";
2
- import { c as AuthCodeStore, d as NewAuthCode, h as PendingAuthorizationStore, m as PendingAuthorization, o as NewDynamicClient, p as NewPendingAuthorization, r as DynamicClientStore, s as AuthCode, t as DynamicClient } from "./dynamic-client-store-B7EnHuRp.cjs";
3
- //#region src/atscript-db/authz-stores.d.ts
1
+ import { c as CredentialSuccessorRef, r as CredentialStore, s as CredentialState, t as Clock } from "./clock-hTHoZ2vA.cjs";
2
+ import { c as AuthCodeStore, d as NewAuthCode, h as PendingAuthorizationStore, m as PendingAuthorization, o as NewDynamicClient, p as NewPendingAuthorization, r as DynamicClientStore, s as AuthCode, t as DynamicClient } from "./dynamic-client-store-CTt1B6Gj.cjs";
4
3
  /**
5
4
  * atscript-db-backed durable implementations of the two short-lived
6
5
  * authorization-server stores (AUTH-SERVER.md §4.3) — the multi-pod replacement
@@ -15,7 +14,7 @@ import { c as AuthCodeStore, d as NewAuthCode, h as PendingAuthorizationStore, m
15
14
  * `@db.json` schema would reject — and (de)serialized at this boundary.
16
15
  */
17
16
  /** Persisted row — mirrors `AoothPendingAuthorization` (`pending-authorization.as`). */
18
- interface PendingAuthorizationRow {
17
+ export interface PendingAuthorizationRow {
19
18
  handle: string;
20
19
  redirectUri: string;
21
20
  codeChallenge: string;
@@ -41,7 +40,7 @@ interface PendingAuthorizationRow {
41
40
  * surface (consumers pass `db.getTable(AoothPendingAuthorization)` and TS matches
42
41
  * by-shape, same seam as `AuthCredentialTable`).
43
42
  */
44
- interface PendingAuthorizationTable {
43
+ export interface PendingAuthorizationTable {
45
44
  insertOne(row: PendingAuthorizationRow): Promise<{
46
45
  insertedId: unknown;
47
46
  }>;
@@ -52,7 +51,7 @@ interface PendingAuthorizationTable {
52
51
  deletedCount: number;
53
52
  }>;
54
53
  }
55
- interface PendingAuthorizationStoreAtscriptDbOptions {
54
+ export interface PendingAuthorizationStoreAtscriptDbOptions {
56
55
  table: PendingAuthorizationTable;
57
56
  /** Injectable clock for deterministic expiry. Defaults to {@link defaultClock}. */
58
57
  clock?: Clock;
@@ -64,7 +63,7 @@ interface PendingAuthorizationStoreAtscriptDbOptions {
64
63
  * fresh opaque `handle`; `get` rejects (and lazily evicts) a past-expiry row;
65
64
  * `delete` drops it once consumed. PK is `handle`, so reads/deletes are O(1).
66
65
  */
67
- declare class PendingAuthorizationStoreAtscriptDb extends PendingAuthorizationStore {
66
+ export declare class PendingAuthorizationStoreAtscriptDb extends PendingAuthorizationStore {
68
67
  private readonly table;
69
68
  private readonly clock;
70
69
  private readonly ttlMs;
@@ -77,7 +76,7 @@ declare class PendingAuthorizationStoreAtscriptDb extends PendingAuthorizationSt
77
76
  delete(handle: string): Promise<boolean>;
78
77
  }
79
78
  /** Persisted row — mirrors `AoothAuthCode` (`auth-code.as`). */
80
- interface AuthCodeRow {
79
+ export interface AuthCodeRow {
81
80
  code: string;
82
81
  userId: string;
83
82
  codeChallenge: string;
@@ -94,7 +93,7 @@ interface AuthCodeRow {
94
93
  expiresAt: number;
95
94
  }
96
95
  /** Structural surface of `AtscriptDbTable` for the auth-code adapter. */
97
- interface AuthCodeTable {
96
+ export interface AuthCodeTable {
98
97
  insertOne(row: AuthCodeRow): Promise<{
99
98
  insertedId: unknown;
100
99
  }>;
@@ -105,7 +104,7 @@ interface AuthCodeTable {
105
104
  deletedCount: number;
106
105
  }>;
107
106
  }
108
- interface AuthCodeStoreAtscriptDbOptions {
107
+ export interface AuthCodeStoreAtscriptDbOptions {
109
108
  table: AuthCodeTable;
110
109
  /** Injectable clock for deterministic expiry. Defaults to {@link defaultClock}. */
111
110
  clock?: Clock;
@@ -121,7 +120,7 @@ interface AuthCodeStoreAtscriptDbOptions {
121
120
  * back-button replay loses the race and gets `null`. (The delete is the claim,
122
121
  * so no version column is needed — `deleteOne(PK)` is atomic per the DB engine.)
123
122
  */
124
- declare class AuthCodeStoreAtscriptDb extends AuthCodeStore {
123
+ export declare class AuthCodeStoreAtscriptDb extends AuthCodeStore {
125
124
  private readonly table;
126
125
  private readonly clock;
127
126
  private readonly ttlMs;
@@ -137,7 +136,7 @@ declare class AuthCodeStoreAtscriptDb extends AuthCodeStore {
137
136
  * `tokenPolicy` above): a `string[]` column would need engine-specific array
138
137
  * support, and all matching happens in `DynamicClientPolicy` after parse.
139
138
  */
140
- interface DynamicClientRow {
139
+ export interface DynamicClientRow {
141
140
  clientId: string;
142
141
  clientName?: string;
143
142
  /** `JSON.stringify(string[])`. */
@@ -154,7 +153,7 @@ interface DynamicClientRow {
154
153
  lastUsedAt?: number;
155
154
  }
156
155
  /** Structural surface of `AtscriptDbTable` for the dynamic-client adapter. */
157
- interface DynamicClientTable {
156
+ export interface DynamicClientTable {
158
157
  insertOne(row: DynamicClientRow): Promise<{
159
158
  insertedId: unknown;
160
159
  }>;
@@ -175,7 +174,7 @@ interface DynamicClientTable {
175
174
  deletedCount: number;
176
175
  }>;
177
176
  }
178
- interface DynamicClientStoreAtscriptDbOptions {
177
+ export interface DynamicClientStoreAtscriptDbOptions {
179
178
  table: DynamicClientTable;
180
179
  /** Injectable clock for deterministic `createdAt`. Defaults to {@link defaultClock}. */
181
180
  clock?: Clock;
@@ -187,7 +186,7 @@ interface DynamicClientStoreAtscriptDbOptions {
187
186
  * op); `deleteUnusedBefore` is one mass `deleteMany` over
188
187
  * `createdAt < cutoff && lastUsedAt unset` — the never-used GC.
189
188
  */
190
- declare class DynamicClientStoreAtscriptDb extends DynamicClientStore {
189
+ export declare class DynamicClientStoreAtscriptDb extends DynamicClientStore {
191
190
  private readonly table;
192
191
  private readonly clock;
193
192
  constructor(opts: DynamicClientStoreAtscriptDbOptions);
@@ -198,8 +197,6 @@ declare class DynamicClientStoreAtscriptDb extends DynamicClientStore {
198
197
  touch(clientId: string, at: number): Promise<void>;
199
198
  deleteUnusedBefore(cutoff: number): Promise<number>;
200
199
  }
201
- //#endregion
202
- //#region src/atscript-db/index.d.ts
203
200
  /**
204
201
  * Persisted row shape — mirrors `AoothAuthCredential` from
205
202
  * `./auth-credential.as`. Re-declared here as a plain TS type so consumers can
@@ -216,7 +213,7 @@ declare class DynamicClientStoreAtscriptDb extends DynamicClientStore {
216
213
  * marked `@aooth.auth.metadata`) and mapped dynamically through the
217
214
  * `metadataField` option below.
218
215
  */
219
- type AuthCredentialRow<TPayload extends object = object> = {
216
+ export type AuthCredentialRow<TPayload extends object = object> = {
220
217
  token: string;
221
218
  userId: string;
222
219
  issuedAt: number;
@@ -234,7 +231,7 @@ type AuthCredentialRow<TPayload extends object = object> = {
234
231
  * `@aooth/auth` public surface — consumers pass `db.getTable(AoothAuthCredential)`
235
232
  * directly and TypeScript matches by-shape.
236
233
  */
237
- interface AuthCredentialTable<TPayload extends object = object> {
234
+ export interface AuthCredentialTable<TPayload extends object = object> {
238
235
  insertOne(row: AuthCredentialRow<TPayload>): Promise<{
239
236
  insertedId: unknown;
240
237
  }>;
@@ -292,9 +289,9 @@ interface CredentialStoreAtscriptDbOptions<TPayload extends object> {
292
289
  * Metadata keys that carry per-token authority — losing them on a store
293
290
  * without a metadata column would silently widen what the token can do.
294
291
  */
295
- declare const AUTHORITY_METADATA_KEYS: readonly ["accessTtl", "refreshRotation", "rotationGraceMs", "credentialKind", "authzClientId"];
292
+ export declare const AUTHORITY_METADATA_KEYS: readonly ["accessTtl", "refreshRotation", "rotationGraceMs", "credentialKind", "authzClientId"];
296
293
  /** Resolved credential-metadata column of a credential model (see {@link getAoothCredentialMetadataSpec}). */
297
- interface AoothCredentialMetadataSpec {
294
+ export interface AoothCredentialMetadataSpec {
298
295
  /** The `@aooth.auth.metadata` + `@db.json` field, or `undefined`. */
299
296
  metadataField: string | undefined;
300
297
  /** Non-fatal misconfiguration notes (an annotated field without `@db.json`). */
@@ -307,7 +304,7 @@ interface AoothCredentialMetadataSpec {
307
304
  * `undefined` with a warning; more than one annotated field throws. Cached
308
305
  * per model.
309
306
  */
310
- declare function getAoothCredentialMetadataSpec(credentialType: unknown): AoothCredentialMetadataSpec;
307
+ export declare function getAoothCredentialMetadataSpec(credentialType: unknown): AoothCredentialMetadataSpec;
311
308
  /**
312
309
  * atscript-db-backed `CredentialStore`.
313
310
  *
@@ -321,7 +318,7 @@ declare function getAoothCredentialMetadataSpec(credentialType: unknown): AoothC
321
318
  * `.as` model). Custom tables must keep `token` as PK or override the
322
319
  * adapter.
323
320
  */
324
- declare class CredentialStoreAtscriptDb<TPayload extends object = object> implements CredentialStore<TPayload> {
321
+ export declare class CredentialStoreAtscriptDb<TPayload extends object = object> implements CredentialStore<TPayload> {
325
322
  private readonly table;
326
323
  private readonly metadataField;
327
324
  private readonly optedOut;
@@ -345,5 +342,4 @@ declare class CredentialStoreAtscriptDb<TPayload extends object = object> implem
345
342
  token: string;
346
343
  }>>;
347
344
  }
348
- //#endregion
349
- export { AUTHORITY_METADATA_KEYS, AoothCredentialMetadataSpec, AuthCodeRow, AuthCodeStoreAtscriptDb, AuthCodeStoreAtscriptDbOptions, AuthCodeTable, AuthCredentialRow, AuthCredentialTable, CredentialStoreAtscriptDb, DynamicClientRow, DynamicClientStoreAtscriptDb, DynamicClientStoreAtscriptDbOptions, DynamicClientTable, PendingAuthorizationRow, PendingAuthorizationStoreAtscriptDb, PendingAuthorizationStoreAtscriptDbOptions, PendingAuthorizationTable, getAoothCredentialMetadataSpec };
345
+ export {};
@@ -1,6 +1,5 @@
1
- import { c as CredentialSuccessorRef, r as CredentialStore, s as CredentialState, t as Clock } from "./clock-CzAaCoZ5.mjs";
2
- import { c as AuthCodeStore, d as NewAuthCode, h as PendingAuthorizationStore, m as PendingAuthorization, o as NewDynamicClient, p as NewPendingAuthorization, r as DynamicClientStore, s as AuthCode, t as DynamicClient } from "./dynamic-client-store-BifZLGkT.mjs";
3
- //#region src/atscript-db/authz-stores.d.ts
1
+ import { c as CredentialSuccessorRef, r as CredentialStore, s as CredentialState, t as Clock } from "./clock-hTHoZ2vA.mjs";
2
+ import { c as AuthCodeStore, d as NewAuthCode, h as PendingAuthorizationStore, m as PendingAuthorization, o as NewDynamicClient, p as NewPendingAuthorization, r as DynamicClientStore, s as AuthCode, t as DynamicClient } from "./dynamic-client-store-mYg0nRJU.mjs";
4
3
  /**
5
4
  * atscript-db-backed durable implementations of the two short-lived
6
5
  * authorization-server stores (AUTH-SERVER.md §4.3) — the multi-pod replacement
@@ -15,7 +14,7 @@ import { c as AuthCodeStore, d as NewAuthCode, h as PendingAuthorizationStore, m
15
14
  * `@db.json` schema would reject — and (de)serialized at this boundary.
16
15
  */
17
16
  /** Persisted row — mirrors `AoothPendingAuthorization` (`pending-authorization.as`). */
18
- interface PendingAuthorizationRow {
17
+ export interface PendingAuthorizationRow {
19
18
  handle: string;
20
19
  redirectUri: string;
21
20
  codeChallenge: string;
@@ -41,7 +40,7 @@ interface PendingAuthorizationRow {
41
40
  * surface (consumers pass `db.getTable(AoothPendingAuthorization)` and TS matches
42
41
  * by-shape, same seam as `AuthCredentialTable`).
43
42
  */
44
- interface PendingAuthorizationTable {
43
+ export interface PendingAuthorizationTable {
45
44
  insertOne(row: PendingAuthorizationRow): Promise<{
46
45
  insertedId: unknown;
47
46
  }>;
@@ -52,7 +51,7 @@ interface PendingAuthorizationTable {
52
51
  deletedCount: number;
53
52
  }>;
54
53
  }
55
- interface PendingAuthorizationStoreAtscriptDbOptions {
54
+ export interface PendingAuthorizationStoreAtscriptDbOptions {
56
55
  table: PendingAuthorizationTable;
57
56
  /** Injectable clock for deterministic expiry. Defaults to {@link defaultClock}. */
58
57
  clock?: Clock;
@@ -64,7 +63,7 @@ interface PendingAuthorizationStoreAtscriptDbOptions {
64
63
  * fresh opaque `handle`; `get` rejects (and lazily evicts) a past-expiry row;
65
64
  * `delete` drops it once consumed. PK is `handle`, so reads/deletes are O(1).
66
65
  */
67
- declare class PendingAuthorizationStoreAtscriptDb extends PendingAuthorizationStore {
66
+ export declare class PendingAuthorizationStoreAtscriptDb extends PendingAuthorizationStore {
68
67
  private readonly table;
69
68
  private readonly clock;
70
69
  private readonly ttlMs;
@@ -77,7 +76,7 @@ declare class PendingAuthorizationStoreAtscriptDb extends PendingAuthorizationSt
77
76
  delete(handle: string): Promise<boolean>;
78
77
  }
79
78
  /** Persisted row — mirrors `AoothAuthCode` (`auth-code.as`). */
80
- interface AuthCodeRow {
79
+ export interface AuthCodeRow {
81
80
  code: string;
82
81
  userId: string;
83
82
  codeChallenge: string;
@@ -94,7 +93,7 @@ interface AuthCodeRow {
94
93
  expiresAt: number;
95
94
  }
96
95
  /** Structural surface of `AtscriptDbTable` for the auth-code adapter. */
97
- interface AuthCodeTable {
96
+ export interface AuthCodeTable {
98
97
  insertOne(row: AuthCodeRow): Promise<{
99
98
  insertedId: unknown;
100
99
  }>;
@@ -105,7 +104,7 @@ interface AuthCodeTable {
105
104
  deletedCount: number;
106
105
  }>;
107
106
  }
108
- interface AuthCodeStoreAtscriptDbOptions {
107
+ export interface AuthCodeStoreAtscriptDbOptions {
109
108
  table: AuthCodeTable;
110
109
  /** Injectable clock for deterministic expiry. Defaults to {@link defaultClock}. */
111
110
  clock?: Clock;
@@ -121,7 +120,7 @@ interface AuthCodeStoreAtscriptDbOptions {
121
120
  * back-button replay loses the race and gets `null`. (The delete is the claim,
122
121
  * so no version column is needed — `deleteOne(PK)` is atomic per the DB engine.)
123
122
  */
124
- declare class AuthCodeStoreAtscriptDb extends AuthCodeStore {
123
+ export declare class AuthCodeStoreAtscriptDb extends AuthCodeStore {
125
124
  private readonly table;
126
125
  private readonly clock;
127
126
  private readonly ttlMs;
@@ -137,7 +136,7 @@ declare class AuthCodeStoreAtscriptDb extends AuthCodeStore {
137
136
  * `tokenPolicy` above): a `string[]` column would need engine-specific array
138
137
  * support, and all matching happens in `DynamicClientPolicy` after parse.
139
138
  */
140
- interface DynamicClientRow {
139
+ export interface DynamicClientRow {
141
140
  clientId: string;
142
141
  clientName?: string;
143
142
  /** `JSON.stringify(string[])`. */
@@ -154,7 +153,7 @@ interface DynamicClientRow {
154
153
  lastUsedAt?: number;
155
154
  }
156
155
  /** Structural surface of `AtscriptDbTable` for the dynamic-client adapter. */
157
- interface DynamicClientTable {
156
+ export interface DynamicClientTable {
158
157
  insertOne(row: DynamicClientRow): Promise<{
159
158
  insertedId: unknown;
160
159
  }>;
@@ -175,7 +174,7 @@ interface DynamicClientTable {
175
174
  deletedCount: number;
176
175
  }>;
177
176
  }
178
- interface DynamicClientStoreAtscriptDbOptions {
177
+ export interface DynamicClientStoreAtscriptDbOptions {
179
178
  table: DynamicClientTable;
180
179
  /** Injectable clock for deterministic `createdAt`. Defaults to {@link defaultClock}. */
181
180
  clock?: Clock;
@@ -187,7 +186,7 @@ interface DynamicClientStoreAtscriptDbOptions {
187
186
  * op); `deleteUnusedBefore` is one mass `deleteMany` over
188
187
  * `createdAt < cutoff && lastUsedAt unset` — the never-used GC.
189
188
  */
190
- declare class DynamicClientStoreAtscriptDb extends DynamicClientStore {
189
+ export declare class DynamicClientStoreAtscriptDb extends DynamicClientStore {
191
190
  private readonly table;
192
191
  private readonly clock;
193
192
  constructor(opts: DynamicClientStoreAtscriptDbOptions);
@@ -198,8 +197,6 @@ declare class DynamicClientStoreAtscriptDb extends DynamicClientStore {
198
197
  touch(clientId: string, at: number): Promise<void>;
199
198
  deleteUnusedBefore(cutoff: number): Promise<number>;
200
199
  }
201
- //#endregion
202
- //#region src/atscript-db/index.d.ts
203
200
  /**
204
201
  * Persisted row shape — mirrors `AoothAuthCredential` from
205
202
  * `./auth-credential.as`. Re-declared here as a plain TS type so consumers can
@@ -216,7 +213,7 @@ declare class DynamicClientStoreAtscriptDb extends DynamicClientStore {
216
213
  * marked `@aooth.auth.metadata`) and mapped dynamically through the
217
214
  * `metadataField` option below.
218
215
  */
219
- type AuthCredentialRow<TPayload extends object = object> = {
216
+ export type AuthCredentialRow<TPayload extends object = object> = {
220
217
  token: string;
221
218
  userId: string;
222
219
  issuedAt: number;
@@ -234,7 +231,7 @@ type AuthCredentialRow<TPayload extends object = object> = {
234
231
  * `@aooth/auth` public surface — consumers pass `db.getTable(AoothAuthCredential)`
235
232
  * directly and TypeScript matches by-shape.
236
233
  */
237
- interface AuthCredentialTable<TPayload extends object = object> {
234
+ export interface AuthCredentialTable<TPayload extends object = object> {
238
235
  insertOne(row: AuthCredentialRow<TPayload>): Promise<{
239
236
  insertedId: unknown;
240
237
  }>;
@@ -292,9 +289,9 @@ interface CredentialStoreAtscriptDbOptions<TPayload extends object> {
292
289
  * Metadata keys that carry per-token authority — losing them on a store
293
290
  * without a metadata column would silently widen what the token can do.
294
291
  */
295
- declare const AUTHORITY_METADATA_KEYS: readonly ["accessTtl", "refreshRotation", "rotationGraceMs", "credentialKind", "authzClientId"];
292
+ export declare const AUTHORITY_METADATA_KEYS: readonly ["accessTtl", "refreshRotation", "rotationGraceMs", "credentialKind", "authzClientId"];
296
293
  /** Resolved credential-metadata column of a credential model (see {@link getAoothCredentialMetadataSpec}). */
297
- interface AoothCredentialMetadataSpec {
294
+ export interface AoothCredentialMetadataSpec {
298
295
  /** The `@aooth.auth.metadata` + `@db.json` field, or `undefined`. */
299
296
  metadataField: string | undefined;
300
297
  /** Non-fatal misconfiguration notes (an annotated field without `@db.json`). */
@@ -307,7 +304,7 @@ interface AoothCredentialMetadataSpec {
307
304
  * `undefined` with a warning; more than one annotated field throws. Cached
308
305
  * per model.
309
306
  */
310
- declare function getAoothCredentialMetadataSpec(credentialType: unknown): AoothCredentialMetadataSpec;
307
+ export declare function getAoothCredentialMetadataSpec(credentialType: unknown): AoothCredentialMetadataSpec;
311
308
  /**
312
309
  * atscript-db-backed `CredentialStore`.
313
310
  *
@@ -321,7 +318,7 @@ declare function getAoothCredentialMetadataSpec(credentialType: unknown): AoothC
321
318
  * `.as` model). Custom tables must keep `token` as PK or override the
322
319
  * adapter.
323
320
  */
324
- declare class CredentialStoreAtscriptDb<TPayload extends object = object> implements CredentialStore<TPayload> {
321
+ export declare class CredentialStoreAtscriptDb<TPayload extends object = object> implements CredentialStore<TPayload> {
325
322
  private readonly table;
326
323
  private readonly metadataField;
327
324
  private readonly optedOut;
@@ -345,5 +342,4 @@ declare class CredentialStoreAtscriptDb<TPayload extends object = object> implem
345
342
  token: string;
346
343
  }>>;
347
344
  }
348
- //#endregion
349
- export { AUTHORITY_METADATA_KEYS, AoothCredentialMetadataSpec, AuthCodeRow, AuthCodeStoreAtscriptDb, AuthCodeStoreAtscriptDbOptions, AuthCodeTable, AuthCredentialRow, AuthCredentialTable, CredentialStoreAtscriptDb, DynamicClientRow, DynamicClientStoreAtscriptDb, DynamicClientStoreAtscriptDbOptions, DynamicClientTable, PendingAuthorizationRow, PendingAuthorizationStoreAtscriptDb, PendingAuthorizationStoreAtscriptDbOptions, PendingAuthorizationTable, getAoothCredentialMetadataSpec };
345
+ export {};
@@ -1,8 +1,8 @@
1
- import { n as AuthError, t as credentialPayloadOf } from "./payload-DDlf38B-.mjs";
2
- import { t as defaultClock } from "./clock-Bdsep_1j.mjs";
3
- import { r as AuthCodeStore, s as PendingAuthorizationStore, t as DynamicClientStore } from "./dynamic-client-store-B1JwFHdP.mjs";
1
+ import { n as AuthError, t as credentialPayloadOf } from "./payload-DizkKbzh.mjs";
2
+ import { t as defaultClock } from "./clock-DzAK2bWR.mjs";
3
+ import { r as AuthCodeStore, s as PendingAuthorizationStore, t as DynamicClientStore } from "./dynamic-client-store-DrMBcFtG.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
- //#region src/atscript-db/authz-stores.ts
5
+ // src/atscript-db/authz-stores.ts
6
6
  /**
7
7
  * Durable {@link PendingAuthorizationStore}. `create` inserts a row keyed by a
8
8
  * fresh opaque `handle`; `get` rejects (and lazily evicts) a past-expiry row;
@@ -217,8 +217,7 @@ function rowToDynamicClient(row) {
217
217
  if (row.lastUsedAt != null) out.lastUsedAt = row.lastUsedAt;
218
218
  return out;
219
219
  }
220
- //#endregion
221
- //#region src/atscript-db/index.ts
220
+ // src/atscript-db/index.ts
222
221
  /**
223
222
  * Metadata keys that carry per-token authority — losing them on a store
224
223
  * without a metadata column would silently widen what the token can do.
@@ -438,5 +437,4 @@ function rowToState(row, metadataField) {
438
437
  if (row.lastSeenAt !== void 0) state.lastSeenAt = row.lastSeenAt;
439
438
  return state;
440
439
  }
441
- //#endregion
442
440
  export { AUTHORITY_METADATA_KEYS, AuthCodeStoreAtscriptDb, CredentialStoreAtscriptDb, DynamicClientStoreAtscriptDb, PendingAuthorizationStoreAtscriptDb, getAoothCredentialMetadataSpec };
@@ -1,5 +1,4 @@
1
- import { a as AuthContext, d as RefreshConfig, f as RefreshResult, i as DenylistStore, l as EnrichedSession, m as SessionInfo, o as CredentialMetadata, p as SessionEnricher, r as CredentialStore, s as CredentialState, t as Clock, u as IssueResult } from "./clock-CzAaCoZ5.mjs";
2
- //#region src/credential/auth-credential.d.ts
1
+ import { a as AuthContext, d as RefreshConfig, f as RefreshResult, i as DenylistStore, l as EnrichedSession, m as SessionInfo, o as CredentialMetadata, p as SessionEnricher, r as CredentialStore, s as CredentialState, t as Clock, u as IssueResult } from "./clock-hTHoZ2vA.cjs";
3
2
  interface AuthCredentialOptions<TPayload extends object = object> {
4
3
  /** Pluggable credential store (Memory, JWT, Encapsulated, ...). */
5
4
  store: CredentialStore<TPayload>;
@@ -376,5 +375,4 @@ declare class AuthCredential<TPayload extends object = object> {
376
375
  */
377
376
  private respondToRefreshReuse;
378
377
  }
379
- //#endregion
380
378
  export { RefreshCallOptions as i, AuthCredentialOptions as n, IssueOptions as r, AuthCredential as t };
@@ -1,5 +1,4 @@
1
- import { a as AuthContext, d as RefreshConfig, f as RefreshResult, i as DenylistStore, l as EnrichedSession, m as SessionInfo, o as CredentialMetadata, p as SessionEnricher, r as CredentialStore, s as CredentialState, t as Clock, u as IssueResult } from "./clock-CzAaCoZ5.cjs";
2
- //#region src/credential/auth-credential.d.ts
1
+ import { a as AuthContext, d as RefreshConfig, f as RefreshResult, i as DenylistStore, l as EnrichedSession, m as SessionInfo, o as CredentialMetadata, p as SessionEnricher, r as CredentialStore, s as CredentialState, t as Clock, u as IssueResult } from "./clock-hTHoZ2vA.mjs";
3
2
  interface AuthCredentialOptions<TPayload extends object = object> {
4
3
  /** Pluggable credential store (Memory, JWT, Encapsulated, ...). */
5
4
  store: CredentialStore<TPayload>;
@@ -376,5 +375,4 @@ declare class AuthCredential<TPayload extends object = object> {
376
375
  */
377
376
  private respondToRefreshReuse;
378
377
  }
379
- //#endregion
380
378
  export { RefreshCallOptions as i, AuthCredentialOptions as n, IssueOptions as r, AuthCredential as t };
package/dist/authz.cjs CHANGED
@@ -1,17 +1,17 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_clock = require("./clock-Bl-H3eqE.cjs");
3
- const require_opaque_token = require("./opaque-token-CaZgD2i6.cjs");
4
- const require_dynamic_client_store = require("./dynamic-client-store-DykM9QOT.cjs");
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
- //#region src/authz/token-policy.ts
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 = 720 * 60 * 6e4;
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
- //#endregion
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
- //#endregion
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: 720 * 60 * 6e4
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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
- //#endregion
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: 720 * 60 * 6e4
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
- //#endregion
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 jwk = await (0, jose.exportJWK)(await (0, jose.importSPKI)(this.publicKeyPem, this.alg, { extractable: true }));
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
- //#endregion
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
- //#endregion
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;