@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.
Files changed (41) 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-BsH0E8hG.d.mts → auth-credential-46_eOF3c.d.cts} +34 -3
  6. package/dist/{auth-credential-D1V5-2uy.d.cts → auth-credential-Co-0pqcD.d.mts} +34 -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-CUGQiS08.d.mts → 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-D0RDGSSJ.d.cts → dynamic-client-store-mYg0nRJU.d.mts} +2 -10
  23. package/dist/index.cjs +92 -42
  24. package/dist/index.d.cts +18 -40
  25. package/dist/index.d.mts +18 -40
  26. package/dist/index.mjs +92 -42
  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 +8 -7
  32. package/dist/redis.d.cts +21 -11
  33. package/dist/redis.d.mts +21 -11
  34. package/dist/redis.mjs +8 -7
  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
  38. package/src/atscript-db/auth-code.as.d.ts +1 -1
  39. package/src/atscript-db/auth-credential.as.d.ts +1 -1
  40. package/src/atscript-db/dynamic-client.as.d.ts +1 -1
  41. package/src/atscript-db/pending-authorization.as.d.ts +1 -1
@@ -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-D0RDGSSJ.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-CUGQiS08.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>;
@@ -291,6 +290,13 @@ declare class AuthCredential<TPayload extends object = object> {
291
290
  enrich?: SessionEnricher;
292
291
  kind?: string | string[];
293
292
  }): Promise<SessionInfo[] | EnrichedSession[]>;
293
+ /**
294
+ * Whether the store can enumerate a user's credentials — i.e. whether
295
+ * {@link listSessions}, {@link revokeSession} and {@link revokeOtherSessions}
296
+ * act at all. `false` for stateless stores (JWT, encapsulated), where those
297
+ * are no-ops and {@link revokeAllForUser} is the only bulk revocation.
298
+ */
299
+ get canEnumerateSessions(): boolean;
294
300
  /**
295
301
  * Revoke a single session — every token in its family (access + refresh +
296
302
  * rotations). No-op for stores that can't enumerate. Other sessions keep
@@ -303,6 +309,22 @@ declare class AuthCredential<TPayload extends object = object> {
303
309
  * (returns 0) for stores that can't enumerate.
304
310
  */
305
311
  revokeOtherSessions(userId: string, keepSessionId: string): Promise<number>;
312
+ /**
313
+ * Revoke every credential of `userId` whose session key matches, repeating
314
+ * list-then-delete until a listing finds no match; returns the distinct
315
+ * session keys revoked. No-op on stores that can't enumerate.
316
+ *
317
+ * Paired with the post-mint re-check in {@link assertStillLive}, this closes
318
+ * the race with refreshes in flight. A refresh re-reads the row it was
319
+ * minted from AFTER persisting its new rows, and revokes them if that row is
320
+ * gone. So a row surviving the final (empty) listing would have to be minted
321
+ * after that listing off a parent still alive after it — a parent that, not
322
+ * being listed, was itself minted after it, and so on down a chain that
323
+ * must start at a row that existed before the listing: a contradiction.
324
+ * Typically two passes (the second finds nothing); capped, failing loudly
325
+ * rather than spinning against a refresh loop.
326
+ */
327
+ private sweepUntilEmpty;
306
328
  /**
307
329
  * Derive a stable 32-byte key from this credential's underlying store secret,
308
330
  * domain-separated by `label`. Lets adjacent subsystems (e.g. workflow-state
@@ -321,6 +343,16 @@ declare class AuthCredential<TPayload extends object = object> {
321
343
  * rotated (keeping it valid through the grace window) instead of consuming it.
322
344
  */
323
345
  private issueRotatedPair;
346
+ /**
347
+ * Post-mint half of the revocation protocol (see {@link sweepUntilEmpty}): after
348
+ * a refresh persisted new credentials, the refresh row it was minted from
349
+ * must still exist. If a revocation deleted it meanwhile, the new
350
+ * credentials belong to a revoked session — revoke them and refuse.
351
+ * Stateful stores only: a stateless refresh consumed (or keeps) a
352
+ * self-contained token, and its revocation epoch already rejects a mint
353
+ * stamped before the revocation.
354
+ */
355
+ private assertStillLive;
324
356
  /**
325
357
  * Under `hashAtRest` the successor pair is stored encrypted with a key
326
358
  * derived from the old refresh token — only a holder of that token (the
@@ -343,5 +375,4 @@ declare class AuthCredential<TPayload extends object = object> {
343
375
  */
344
376
  private respondToRefreshReuse;
345
377
  }
346
- //#endregion
347
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>;
@@ -291,6 +290,13 @@ declare class AuthCredential<TPayload extends object = object> {
291
290
  enrich?: SessionEnricher;
292
291
  kind?: string | string[];
293
292
  }): Promise<SessionInfo[] | EnrichedSession[]>;
293
+ /**
294
+ * Whether the store can enumerate a user's credentials — i.e. whether
295
+ * {@link listSessions}, {@link revokeSession} and {@link revokeOtherSessions}
296
+ * act at all. `false` for stateless stores (JWT, encapsulated), where those
297
+ * are no-ops and {@link revokeAllForUser} is the only bulk revocation.
298
+ */
299
+ get canEnumerateSessions(): boolean;
294
300
  /**
295
301
  * Revoke a single session — every token in its family (access + refresh +
296
302
  * rotations). No-op for stores that can't enumerate. Other sessions keep
@@ -303,6 +309,22 @@ declare class AuthCredential<TPayload extends object = object> {
303
309
  * (returns 0) for stores that can't enumerate.
304
310
  */
305
311
  revokeOtherSessions(userId: string, keepSessionId: string): Promise<number>;
312
+ /**
313
+ * Revoke every credential of `userId` whose session key matches, repeating
314
+ * list-then-delete until a listing finds no match; returns the distinct
315
+ * session keys revoked. No-op on stores that can't enumerate.
316
+ *
317
+ * Paired with the post-mint re-check in {@link assertStillLive}, this closes
318
+ * the race with refreshes in flight. A refresh re-reads the row it was
319
+ * minted from AFTER persisting its new rows, and revokes them if that row is
320
+ * gone. So a row surviving the final (empty) listing would have to be minted
321
+ * after that listing off a parent still alive after it — a parent that, not
322
+ * being listed, was itself minted after it, and so on down a chain that
323
+ * must start at a row that existed before the listing: a contradiction.
324
+ * Typically two passes (the second finds nothing); capped, failing loudly
325
+ * rather than spinning against a refresh loop.
326
+ */
327
+ private sweepUntilEmpty;
306
328
  /**
307
329
  * Derive a stable 32-byte key from this credential's underlying store secret,
308
330
  * domain-separated by `label`. Lets adjacent subsystems (e.g. workflow-state
@@ -321,6 +343,16 @@ declare class AuthCredential<TPayload extends object = object> {
321
343
  * rotated (keeping it valid through the grace window) instead of consuming it.
322
344
  */
323
345
  private issueRotatedPair;
346
+ /**
347
+ * Post-mint half of the revocation protocol (see {@link sweepUntilEmpty}): after
348
+ * a refresh persisted new credentials, the refresh row it was minted from
349
+ * must still exist. If a revocation deleted it meanwhile, the new
350
+ * credentials belong to a revoked session — revoke them and refuse.
351
+ * Stateful stores only: a stateless refresh consumed (or keeps) a
352
+ * self-contained token, and its revocation epoch already rejects a mint
353
+ * stamped before the revocation.
354
+ */
355
+ private assertStillLive;
324
356
  /**
325
357
  * Under `hashAtRest` the successor pair is stored encrypted with a key
326
358
  * derived from the old refresh token — only a holder of that token (the
@@ -343,5 +375,4 @@ declare class AuthCredential<TPayload extends object = object> {
343
375
  */
344
376
  private respondToRefreshReuse;
345
377
  }
346
- //#endregion
347
378
  export { RefreshCallOptions as i, AuthCredentialOptions as n, IssueOptions as r, AuthCredential as t };