@julr/sesame 0.6.0 → 0.7.0

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 (70) hide show
  1. package/README.md +69 -6
  2. package/build/{authorize_controller-BiycO4be.js → authorize_controller-sCZIjnc-.js} +10 -10
  3. package/build/{client_info_controller-AcOG8lWu.js → client_info_controller-B5A3tpbk.js} +3 -4
  4. package/build/commands/sesame_key.d.ts +1 -1
  5. package/build/commands/sesame_purge.js +2 -5
  6. package/build/{configure-DkDkIlt8.js → configure-t9q3KonY.js} +7 -3
  7. package/build/configure.js +1 -2
  8. package/build/{consent_controller-Dsdhv6-f.js → consent_controller-ChBboaSd.js} +17 -29
  9. package/build/consent_retry-DMkfhmk9.js +41 -0
  10. package/build/decorate-RQD1h28J.js +9 -0
  11. package/build/{id_token_service-CpTzOUDe.js → id_token_service-BtBUiL_n.js} +1 -1
  12. package/build/index.d.ts +2 -8
  13. package/build/index.js +38 -9
  14. package/build/{introspect_controller-DvOp9scr.js → introspect_controller-LVYGWhMj.js} +13 -9
  15. package/build/{issue_authorization_code-B9ERu1uO.js → issue_authorization_code-Dr4-bbMp.js} +2 -3
  16. package/build/{jwks_controller-keo4kBZc.js → jwks_controller-4HUVS_HC.js} +1 -5
  17. package/build/{main-DGBJhq3E.js → main-Dx9kZv07.js} +14 -52
  18. package/build/{metadata_controller-BVsTo0Gp.js → metadata_controller-hwfmxlF7.js} +4 -6
  19. package/build/providers/sesame_provider.d.ts +1 -1
  20. package/build/providers/sesame_provider.js +8 -8
  21. package/build/{register_controller-gbq7p8a5.js → register_controller-Cdk3c32j.js} +3 -6
  22. package/build/{revoke_controller-z_ghrEB7.js → revoke_controller-Daz4Yqfs.js} +15 -21
  23. package/build/services/main.js +1 -5
  24. package/build/{sesame_manager-DYUSZ0NC.js → sesame_manager-CeEmlzba.js} +78 -256
  25. package/build/sesame_manager-DQxvsTEq.js +2 -0
  26. package/build/src/actions/exchange_authorization_code.d.ts +5 -5
  27. package/build/src/actions/exchange_client_credentials.d.ts +3 -3
  28. package/build/src/actions/exchange_refresh_token.d.ts +4 -4
  29. package/build/src/actions/issue_authorization_code.d.ts +2 -2
  30. package/build/src/controllers/authorize_controller.d.ts +11 -11
  31. package/build/src/controllers/metadata_controller.d.ts +7 -7
  32. package/build/src/controllers/register_controller.d.ts +30 -30
  33. package/build/src/guard/guard.d.ts +1 -1
  34. package/build/src/guard/lucid.d.ts +8 -0
  35. package/build/src/guard/lucid.js +46 -0
  36. package/build/src/guard/main.d.ts +2 -9
  37. package/build/src/guard/main.js +2 -6
  38. package/build/src/guard/types.d.ts +0 -9
  39. package/build/src/guard/user_provider.d.ts +9 -1
  40. package/build/src/middleware/any_scope_middleware.js +1 -2
  41. package/build/src/middleware/scope_middleware.js +1 -2
  42. package/build/src/oauth_error.d.ts +74 -74
  43. package/build/src/services/client_service.d.ts +5 -2
  44. package/build/src/sesame_manager.d.ts +6 -5
  45. package/build/src/storage/consent_retry.d.ts +4 -0
  46. package/build/src/storage/drivers/kysely.d.ts +166 -0
  47. package/build/src/storage/drivers/kysely.js +480 -0
  48. package/build/src/storage/drivers/lucid.d.ts +162 -0
  49. package/build/src/storage/drivers/lucid.js +549 -0
  50. package/build/src/storage/migrations/kysely.d.ts +6 -0
  51. package/build/src/storage/types.d.ts +197 -0
  52. package/build/src/storage/types.js +1 -0
  53. package/build/src/stores.d.ts +21 -0
  54. package/build/src/types.d.ts +9 -1
  55. package/build/src/types.js +2 -0
  56. package/build/stubs/config/sesame.stub +4 -1
  57. package/build/stubs/config/sesame_kysely.stub +35 -0
  58. package/build/stubs/migrations/kysely/create_oauth_tables.stub +151 -0
  59. package/build/taze.config.d.ts +2 -0
  60. package/build/{token_controller-DyI7oy-U.js → token_controller-DRatCQNT.js} +74 -63
  61. package/build/types-DEtn2Zdb.js +75 -0
  62. package/build/{userinfo_controller-RLk8cN_o.js → userinfo_controller-YwN26wK-.js} +5 -8
  63. package/build/vite.config.d.ts +1 -1
  64. package/package.json +33 -17
  65. package/build/chunk-DF48asd8.js +0 -9
  66. package/build/oauth_access_token-Cz_5gNBx.js +0 -29
  67. package/build/oauth_client-BSanvSql.js +0 -63
  68. package/build/sesame_manager-B1Jgq1v2.js +0 -6
  69. /package/build/{oauth_error-C7UhDb2q.js → oauth_error-CvxtZvjp.js} +0 -0
  70. /package/build/{token_service-DwnfAR9F.js → token_service-DDQ3Dxaj.js} +0 -0
@@ -32,24 +32,24 @@ export declare const E_INVALID_REQUEST: {
32
32
  code?: string;
33
33
  status?: number;
34
34
  }): {
35
- get oauthCode(): string;
36
- handle(error: /*elided*/ any, ctx: HttpContext): void;
35
+ message: string;
36
+ stack?: string;
37
+ cause?: unknown;
37
38
  name: string;
38
39
  help?: string;
39
40
  code?: string;
40
41
  status: number;
41
- toString(): string;
42
42
  get [Symbol.toStringTag](): string;
43
- message: string;
44
- stack?: string;
45
- cause?: unknown;
43
+ toString(): string;
44
+ get oauthCode(): string;
45
+ handle(error: /*elided*/ any, ctx: HttpContext): void;
46
46
  };
47
47
  readonly status: number;
48
48
  readonly code: string;
49
49
  readonly message: string;
50
50
  readonly oauthCode: string;
51
- help?: string;
52
51
  isError(error: unknown): error is Error;
52
+ help?: string;
53
53
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
54
54
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
55
55
  stackTraceLimit: number;
@@ -72,23 +72,23 @@ export declare const E_INVALID_CLIENT: {
72
72
  * @see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-3.2.4
73
73
  */
74
74
  handle(error: /*elided*/ any, ctx: HttpContext): void;
75
- get oauthCode(): string;
75
+ message: string;
76
+ stack?: string;
77
+ cause?: unknown;
76
78
  name: string;
77
79
  help?: string;
78
80
  code?: string;
79
81
  status: number;
80
- toString(): string;
81
82
  get [Symbol.toStringTag](): string;
82
- message: string;
83
- stack?: string;
84
- cause?: unknown;
83
+ toString(): string;
84
+ get oauthCode(): string;
85
85
  };
86
86
  readonly status: number;
87
87
  readonly code: string;
88
88
  readonly message: string;
89
89
  readonly oauthCode: string;
90
- help?: string;
91
90
  isError(error: unknown): error is Error;
91
+ help?: string;
92
92
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
93
93
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
94
94
  stackTraceLimit: number;
@@ -105,24 +105,24 @@ export declare const E_INVALID_GRANT: {
105
105
  code?: string;
106
106
  status?: number;
107
107
  }): {
108
- get oauthCode(): string;
109
- handle(error: /*elided*/ any, ctx: HttpContext): void;
108
+ message: string;
109
+ stack?: string;
110
+ cause?: unknown;
110
111
  name: string;
111
112
  help?: string;
112
113
  code?: string;
113
114
  status: number;
114
- toString(): string;
115
115
  get [Symbol.toStringTag](): string;
116
- message: string;
117
- stack?: string;
118
- cause?: unknown;
116
+ toString(): string;
117
+ get oauthCode(): string;
118
+ handle(error: /*elided*/ any, ctx: HttpContext): void;
119
119
  };
120
120
  readonly status: number;
121
121
  readonly code: string;
122
122
  readonly message: string;
123
123
  readonly oauthCode: string;
124
- help?: string;
125
124
  isError(error: unknown): error is Error;
125
+ help?: string;
126
126
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
127
127
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
128
128
  stackTraceLimit: number;
@@ -138,24 +138,24 @@ export declare const E_INVALID_SCOPE: {
138
138
  code?: string;
139
139
  status?: number;
140
140
  }): {
141
- get oauthCode(): string;
142
- handle(error: /*elided*/ any, ctx: HttpContext): void;
141
+ message: string;
142
+ stack?: string;
143
+ cause?: unknown;
143
144
  name: string;
144
145
  help?: string;
145
146
  code?: string;
146
147
  status: number;
147
- toString(): string;
148
148
  get [Symbol.toStringTag](): string;
149
- message: string;
150
- stack?: string;
151
- cause?: unknown;
149
+ toString(): string;
150
+ get oauthCode(): string;
151
+ handle(error: /*elided*/ any, ctx: HttpContext): void;
152
152
  };
153
153
  readonly status: number;
154
154
  readonly code: string;
155
155
  readonly message: string;
156
156
  readonly oauthCode: string;
157
- help?: string;
158
157
  isError(error: unknown): error is Error;
158
+ help?: string;
159
159
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
160
160
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
161
161
  stackTraceLimit: number;
@@ -172,23 +172,23 @@ export declare const E_INVALID_TOKEN: {
172
172
  status?: number;
173
173
  }): {
174
174
  handle(error: /*elided*/ any, ctx: HttpContext): void;
175
- get oauthCode(): string;
175
+ message: string;
176
+ stack?: string;
177
+ cause?: unknown;
176
178
  name: string;
177
179
  help?: string;
178
180
  code?: string;
179
181
  status: number;
180
- toString(): string;
181
182
  get [Symbol.toStringTag](): string;
182
- message: string;
183
- stack?: string;
184
- cause?: unknown;
183
+ toString(): string;
184
+ get oauthCode(): string;
185
185
  };
186
186
  readonly status: number;
187
187
  readonly code: string;
188
188
  readonly message: string;
189
189
  readonly oauthCode: string;
190
- help?: string;
191
190
  isError(error: unknown): error is Error;
191
+ help?: string;
192
192
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
193
193
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
194
194
  stackTraceLimit: number;
@@ -204,24 +204,24 @@ export declare const E_UNSUPPORTED_GRANT_TYPE: {
204
204
  code?: string;
205
205
  status?: number;
206
206
  }): {
207
- get oauthCode(): string;
208
- handle(error: /*elided*/ any, ctx: HttpContext): void;
207
+ message: string;
208
+ stack?: string;
209
+ cause?: unknown;
209
210
  name: string;
210
211
  help?: string;
211
212
  code?: string;
212
213
  status: number;
213
- toString(): string;
214
214
  get [Symbol.toStringTag](): string;
215
- message: string;
216
- stack?: string;
217
- cause?: unknown;
215
+ toString(): string;
216
+ get oauthCode(): string;
217
+ handle(error: /*elided*/ any, ctx: HttpContext): void;
218
218
  };
219
219
  readonly status: number;
220
220
  readonly code: string;
221
221
  readonly message: string;
222
222
  readonly oauthCode: string;
223
- help?: string;
224
223
  isError(error: unknown): error is Error;
224
+ help?: string;
225
225
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
226
226
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
227
227
  stackTraceLimit: number;
@@ -237,24 +237,24 @@ export declare const E_UNSUPPORTED_RESPONSE_TYPE: {
237
237
  code?: string;
238
238
  status?: number;
239
239
  }): {
240
- get oauthCode(): string;
241
- handle(error: /*elided*/ any, ctx: HttpContext): void;
240
+ message: string;
241
+ stack?: string;
242
+ cause?: unknown;
242
243
  name: string;
243
244
  help?: string;
244
245
  code?: string;
245
246
  status: number;
246
- toString(): string;
247
247
  get [Symbol.toStringTag](): string;
248
- message: string;
249
- stack?: string;
250
- cause?: unknown;
248
+ toString(): string;
249
+ get oauthCode(): string;
250
+ handle(error: /*elided*/ any, ctx: HttpContext): void;
251
251
  };
252
252
  readonly status: number;
253
253
  readonly code: string;
254
254
  readonly message: string;
255
255
  readonly oauthCode: string;
256
- help?: string;
257
256
  isError(error: unknown): error is Error;
257
+ help?: string;
258
258
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
259
259
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
260
260
  stackTraceLimit: number;
@@ -269,24 +269,24 @@ export declare const E_ACCESS_DENIED: {
269
269
  code?: string;
270
270
  status?: number;
271
271
  }): {
272
- get oauthCode(): string;
273
- handle(error: /*elided*/ any, ctx: HttpContext): void;
272
+ message: string;
273
+ stack?: string;
274
+ cause?: unknown;
274
275
  name: string;
275
276
  help?: string;
276
277
  code?: string;
277
278
  status: number;
278
- toString(): string;
279
279
  get [Symbol.toStringTag](): string;
280
- message: string;
281
- stack?: string;
282
- cause?: unknown;
280
+ toString(): string;
281
+ get oauthCode(): string;
282
+ handle(error: /*elided*/ any, ctx: HttpContext): void;
283
283
  };
284
284
  readonly status: number;
285
285
  readonly code: string;
286
286
  readonly message: string;
287
287
  readonly oauthCode: string;
288
- help?: string;
289
288
  isError(error: unknown): error is Error;
289
+ help?: string;
290
290
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
291
291
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
292
292
  stackTraceLimit: number;
@@ -302,24 +302,24 @@ export declare const E_INVALID_CLIENT_METADATA: {
302
302
  code?: string;
303
303
  status?: number;
304
304
  }): {
305
- get oauthCode(): string;
306
- handle(error: /*elided*/ any, ctx: HttpContext): void;
305
+ message: string;
306
+ stack?: string;
307
+ cause?: unknown;
307
308
  name: string;
308
309
  help?: string;
309
310
  code?: string;
310
311
  status: number;
311
- toString(): string;
312
312
  get [Symbol.toStringTag](): string;
313
- message: string;
314
- stack?: string;
315
- cause?: unknown;
313
+ toString(): string;
314
+ get oauthCode(): string;
315
+ handle(error: /*elided*/ any, ctx: HttpContext): void;
316
316
  };
317
317
  readonly status: number;
318
318
  readonly code: string;
319
319
  readonly message: string;
320
320
  readonly oauthCode: string;
321
- help?: string;
322
321
  isError(error: unknown): error is Error;
322
+ help?: string;
323
323
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
324
324
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
325
325
  stackTraceLimit: number;
@@ -335,24 +335,24 @@ export declare const E_SERVER_ERROR: {
335
335
  code?: string;
336
336
  status?: number;
337
337
  }): {
338
- get oauthCode(): string;
339
- handle(error: /*elided*/ any, ctx: HttpContext): void;
338
+ message: string;
339
+ stack?: string;
340
+ cause?: unknown;
340
341
  name: string;
341
342
  help?: string;
342
343
  code?: string;
343
344
  status: number;
344
- toString(): string;
345
345
  get [Symbol.toStringTag](): string;
346
- message: string;
347
- stack?: string;
348
- cause?: unknown;
346
+ toString(): string;
347
+ get oauthCode(): string;
348
+ handle(error: /*elided*/ any, ctx: HttpContext): void;
349
349
  };
350
350
  readonly status: number;
351
351
  readonly code: string;
352
352
  readonly message: string;
353
353
  readonly oauthCode: string;
354
- help?: string;
355
354
  isError(error: unknown): error is Error;
355
+ help?: string;
356
356
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
357
357
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
358
358
  stackTraceLimit: number;
@@ -368,23 +368,23 @@ export declare const E_INSUFFICIENT_SCOPE: {
368
368
  new (missingScopes: string[], message?: string): {
369
369
  missingScopes: string[];
370
370
  handle(error: /*elided*/ any, ctx: HttpContext): void;
371
- get oauthCode(): string;
371
+ message: string;
372
+ stack?: string;
373
+ cause?: unknown;
372
374
  name: string;
373
375
  help?: string;
374
376
  code?: string;
375
377
  status: number;
376
- toString(): string;
377
378
  get [Symbol.toStringTag](): string;
378
- message: string;
379
- stack?: string;
380
- cause?: unknown;
379
+ toString(): string;
380
+ get oauthCode(): string;
381
381
  };
382
382
  readonly status: number;
383
383
  readonly code: string;
384
384
  readonly message: string;
385
385
  readonly oauthCode: string;
386
- help?: string;
387
386
  isError(error: unknown): error is Error;
387
+ help?: string;
388
388
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
389
389
  prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
390
390
  stackTraceLimit: number;
@@ -1,4 +1,5 @@
1
- import { OAuthClient } from '../models/oauth_client.ts';
1
+ import type { SesameManager } from '../sesame_manager.ts';
2
+ import type { OAuthClientRecord } from '../storage/types.ts';
2
3
  /**
3
4
  * Extracted client credentials from a request.
4
5
  */
@@ -20,6 +21,8 @@ export interface ClientCredentials {
20
21
  * @see https://datatracker.ietf.org/doc/html/rfc6749#section-2.3
21
22
  */
22
23
  export declare class ClientService {
24
+ #private;
25
+ constructor(manager?: SesameManager);
23
26
  /**
24
27
  * Parse an HTTP Basic Authorization header into client credentials.
25
28
  * Follows RFC 6749 §2.3.1 — the client_id and client_secret are
@@ -47,7 +50,7 @@ export declare class ClientService {
47
50
  authorizationHeader?: string;
48
51
  bodyClientId?: string;
49
52
  bodyClientSecret?: string;
50
- }): Promise<OAuthClient>;
53
+ }): Promise<OAuthClientRecord>;
51
54
  /**
52
55
  * Validate that requested scopes are within the client's
53
56
  * allowed scopes. Throws `E_INVALID_SCOPE` if any scope
@@ -1,7 +1,7 @@
1
1
  import type { Router } from '@adonisjs/core/http';
2
2
  import { type CreateClientOptions, type CreateClientResult, type ResolvedSesameConfig, type Scope, type UpdateClientOptions } from './types.ts';
3
3
  import { KeyService } from './services/key_service.ts';
4
- import { OAuthClient } from './models/oauth_client.ts';
4
+ import type { OAuthClientRecord, SesameStore } from './storage/types.ts';
5
5
  export interface PurgeResult {
6
6
  accessTokens: number;
7
7
  refreshTokens: number;
@@ -16,8 +16,9 @@ export interface PurgeResult {
16
16
  */
17
17
  export declare class SesameManager {
18
18
  #private;
19
- constructor(config: ResolvedSesameConfig, router: Router);
19
+ constructor(config: ResolvedSesameConfig, router: Router, store: SesameStore);
20
20
  get config(): ResolvedSesameConfig;
21
+ get store(): SesameStore;
21
22
  get keyService(): KeyService;
22
23
  get isOidcEnabled(): boolean;
23
24
  /**
@@ -79,18 +80,18 @@ export declare class SesameManager {
79
80
  /**
80
81
  * Find a client by its public client_id.
81
82
  */
82
- findClient(clientId: string): Promise<OAuthClient | null>;
83
+ findClient(clientId: string): Promise<OAuthClientRecord | null>;
83
84
  /**
84
85
  * List all clients, optionally filtered by userId.
85
86
  */
86
87
  listClients(options?: {
87
88
  userId?: string;
88
- }): Promise<OAuthClient[]>;
89
+ }): Promise<OAuthClientRecord[]>;
89
90
  /**
90
91
  * Update an existing client by its public client_id.
91
92
  * Returns the updated client, or null if not found.
92
93
  */
93
- updateClient(clientId: string, options: UpdateClientOptions): Promise<OAuthClient | null>;
94
+ updateClient(clientId: string, options: UpdateClientOptions): Promise<OAuthClientRecord | null>;
94
95
  /**
95
96
  * Delete a client and all its associated tokens, codes, and consents.
96
97
  * Returns true if the client was found and deleted.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Retry consent writes after uniqueness, serialization, or lock conflicts.
3
+ */
4
+ export declare function retryConsentConflict<T>(operation: () => Promise<T>): Promise<T>;
@@ -0,0 +1,166 @@
1
+ import { type Kysely, type Transaction } from 'kysely';
2
+ import { DateTime } from 'luxon';
3
+ import type { CreateAccessTokenRecord, CreateAuthorizationCodeRecord, CreateClientRecord, CreatePendingAuthorizationRequestRecord, ExchangeAuthorizationCodeOptions, IssueTokenPairOptions, OAuthAccessTokenRecord, OAuthAuthorizationCodeRecord, OAuthClientRecord, OAuthConsentRecord, OAuthPendingAuthorizationRequestRecord, OAuthRefreshTokenRecord, PurgeTokensOptions, RotateRefreshTokenOptions, SesamePurgeResult, SesameStore, UpdateClientRecord } from '../types.js';
4
+ export type KyselyDialect = 'sqlite' | 'postgres' | 'mysql';
5
+ export interface KyselyStoreOptions<DB> {
6
+ db: Kysely<DB>;
7
+ /**
8
+ * Required only when a custom Kysely adapter cannot be identified.
9
+ */
10
+ dialect?: KyselyDialect;
11
+ }
12
+ type DatabaseConnection = Kysely<any> | Transaction<any>;
13
+ /**
14
+ * OAuth persistence backed by a Kysely connection.
15
+ */
16
+ export declare class KyselyStore implements SesameStore {
17
+ #private;
18
+ /**
19
+ * Bind the store to a Kysely connection or an active transaction.
20
+ */
21
+ constructor(db: DatabaseConnection, dialect: KyselyDialect, inTransaction?: boolean);
22
+ /**
23
+ * Return the client registered under a public client ID.
24
+ */
25
+ findClient(clientId: string): Promise<OAuthClientRecord | null>;
26
+ /**
27
+ * List clients in descending creation order, optionally for one user.
28
+ */
29
+ listClients(options?: {
30
+ userId?: string;
31
+ }): Promise<OAuthClientRecord[]>;
32
+ /**
33
+ * Insert a new OAuth client and return its persisted representation.
34
+ */
35
+ createClient(data: CreateClientRecord): Promise<OAuthClientRecord>;
36
+ /**
37
+ * Update the mutable metadata of one OAuth client.
38
+ */
39
+ updateClient(options: {
40
+ id: string;
41
+ data: UpdateClientRecord;
42
+ }): Promise<void>;
43
+ /**
44
+ * Replace a confidential client's hashed secret.
45
+ */
46
+ updateClientSecret(options: {
47
+ id: string;
48
+ secret: string;
49
+ }): Promise<void>;
50
+ /**
51
+ * Delete a client and all OAuth records that refer to it.
52
+ */
53
+ deleteClient(clientId: string): Promise<boolean>;
54
+ /**
55
+ * Find an access token by its hash, optionally restricted to a client.
56
+ */
57
+ findAccessToken(options: {
58
+ hash: string;
59
+ clientId?: string;
60
+ }): Promise<OAuthAccessTokenRecord | null>;
61
+ /**
62
+ * Persist a hashed access token.
63
+ */
64
+ createAccessToken(data: CreateAccessTokenRecord): Promise<void>;
65
+ /**
66
+ * Conditionally revoke an active access token owned by a client.
67
+ */
68
+ revokeAccessToken(options: {
69
+ hash: string;
70
+ clientId: string;
71
+ now: DateTime;
72
+ }): Promise<boolean>;
73
+ /**
74
+ * Find a refresh token by its hash and owning client.
75
+ */
76
+ findRefreshToken(options: {
77
+ hash: string;
78
+ clientId: string;
79
+ }): Promise<OAuthRefreshTokenRecord | null>;
80
+ /**
81
+ * Revoke a refresh token and the access token paired with it atomically.
82
+ */
83
+ revokeRefreshToken(options: {
84
+ hash: string;
85
+ clientId: string;
86
+ now: DateTime;
87
+ }): Promise<void>;
88
+ /**
89
+ * Delete refresh tokens and revoke access tokens after replay detection.
90
+ */
91
+ revokeTokenFamily(options: {
92
+ clientId: string;
93
+ userId: string;
94
+ now: DateTime;
95
+ }): Promise<void>;
96
+ /**
97
+ * Find an authorization code by its hash and owning client.
98
+ */
99
+ findAuthorizationCode(options: {
100
+ code: string;
101
+ clientId: string;
102
+ }): Promise<OAuthAuthorizationCodeRecord | null>;
103
+ /**
104
+ * Persist a hashed, short-lived authorization code.
105
+ */
106
+ createAuthorizationCode(data: CreateAuthorizationCodeRecord): Promise<void>;
107
+ /**
108
+ * Remove an invalid or expired authorization code.
109
+ */
110
+ deleteAuthorizationCode(id: string): Promise<void>;
111
+ /**
112
+ * Consume a code once and issue its token pair in one transaction.
113
+ */
114
+ exchangeAuthorizationCode(options: ExchangeAuthorizationCodeOptions): Promise<boolean>;
115
+ /**
116
+ * Find scopes consented to by a user for a client.
117
+ */
118
+ findConsent(options: {
119
+ clientId: string;
120
+ userId: string;
121
+ }): Promise<OAuthConsentRecord | null>;
122
+ /**
123
+ * Merge newly granted scopes into the user's existing consent.
124
+ */
125
+ grantConsent(options: {
126
+ clientId: string;
127
+ userId: string;
128
+ scopes: string[];
129
+ }): Promise<void>;
130
+ /**
131
+ * Persist the authorization context for the consent redirect.
132
+ */
133
+ createPendingAuthorizationRequest(data: CreatePendingAuthorizationRequestRecord): Promise<void>;
134
+ /**
135
+ * Delete and return an unexpired pending request exactly once.
136
+ */
137
+ consumePendingAuthorizationRequest(options: {
138
+ token: string;
139
+ userId: string;
140
+ now: DateTime;
141
+ }): Promise<OAuthPendingAuthorizationRequestRecord | null>;
142
+ /**
143
+ * Issue an access and refresh token together for grace-period reuse.
144
+ */
145
+ issueTokenPair(options: IssueTokenPairOptions): Promise<void>;
146
+ /**
147
+ * Conditionally rotate a refresh token and replace its access token.
148
+ */
149
+ rotateRefreshToken(options: RotateRefreshTokenOptions): Promise<boolean>;
150
+ /**
151
+ * Revoke tokens and discard codes and consents for a deleted user.
152
+ */
153
+ revokeAllForUser(options: {
154
+ userId: string;
155
+ now: DateTime;
156
+ }): Promise<void>;
157
+ /**
158
+ * Purge revoked and expired records, returning deleted row counts.
159
+ */
160
+ purgeTokens(options: PurgeTokensOptions): Promise<SesamePurgeResult>;
161
+ }
162
+ /**
163
+ * Create a Sesame persistence store backed by an existing Kysely connection.
164
+ */
165
+ export declare function kyselyStore<DB>(options: KyselyStoreOptions<DB>): SesameStore;
166
+ export {};