@spine-event-engine/auth 2.0.0-snapshot.26 → 2.0.0-snapshot.28

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 (65) hide show
  1. package/README.md +102 -11
  2. package/REFERENCE.md +125 -3
  3. package/dist/index.d.ts +15 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +4 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/oidc/contracts.d.ts +18 -4
  8. package/dist/oidc/contracts.d.ts.map +1 -1
  9. package/dist/oidc/flow-store.d.ts +143 -0
  10. package/dist/oidc/flow-store.d.ts.map +1 -0
  11. package/dist/oidc/flow-store.js +184 -0
  12. package/dist/oidc/flow-store.js.map +1 -0
  13. package/dist/oidc/index.d.ts +29 -9
  14. package/dist/oidc/index.d.ts.map +1 -1
  15. package/dist/oidc/index.js +611 -152
  16. package/dist/oidc/index.js.map +1 -1
  17. package/dist/oidc/persistent-flow-store.d.ts +117 -0
  18. package/dist/oidc/persistent-flow-store.d.ts.map +1 -0
  19. package/dist/oidc/persistent-flow-store.js +413 -0
  20. package/dist/oidc/persistent-flow-store.js.map +1 -0
  21. package/dist/oidc/records.d.ts +15 -0
  22. package/dist/oidc/records.d.ts.map +1 -0
  23. package/dist/oidc/records.js +91 -0
  24. package/dist/oidc/records.js.map +1 -0
  25. package/dist/providers/index.d.ts +10 -5
  26. package/dist/providers/index.d.ts.map +1 -1
  27. package/dist/providers/index.js +103 -30
  28. package/dist/providers/index.js.map +1 -1
  29. package/dist/sessions/cookies.d.ts +46 -8
  30. package/dist/sessions/cookies.d.ts.map +1 -1
  31. package/dist/sessions/cookies.js +269 -47
  32. package/dist/sessions/cookies.js.map +1 -1
  33. package/dist/sessions/opaque-session-store.d.ts +143 -0
  34. package/dist/sessions/opaque-session-store.d.ts.map +1 -0
  35. package/dist/sessions/opaque-session-store.js +185 -0
  36. package/dist/sessions/opaque-session-store.js.map +1 -0
  37. package/dist/sessions/opaque.d.ts +93 -106
  38. package/dist/sessions/opaque.d.ts.map +1 -1
  39. package/dist/sessions/opaque.js +501 -232
  40. package/dist/sessions/opaque.js.map +1 -1
  41. package/dist/sessions/persistent-opaque-session-store.d.ts +105 -0
  42. package/dist/sessions/persistent-opaque-session-store.d.ts.map +1 -0
  43. package/dist/sessions/persistent-opaque-session-store.js +333 -0
  44. package/dist/sessions/persistent-opaque-session-store.js.map +1 -0
  45. package/dist/sessions/persistent-token-revocations.d.ts +90 -0
  46. package/dist/sessions/persistent-token-revocations.d.ts.map +1 -0
  47. package/dist/sessions/persistent-token-revocations.js +422 -0
  48. package/dist/sessions/persistent-token-revocations.js.map +1 -0
  49. package/dist/sessions/session-lifetime.d.ts +67 -0
  50. package/dist/sessions/session-lifetime.d.ts.map +1 -0
  51. package/dist/sessions/session-lifetime.js +165 -0
  52. package/dist/sessions/session-lifetime.js.map +1 -0
  53. package/dist/sessions/session-record.d.ts +15 -0
  54. package/dist/sessions/session-record.d.ts.map +1 -0
  55. package/dist/sessions/session-record.js +109 -0
  56. package/dist/sessions/session-record.js.map +1 -0
  57. package/dist/sessions/signed.d.ts +5 -4
  58. package/dist/sessions/signed.d.ts.map +1 -1
  59. package/dist/sessions/signed.js +212 -74
  60. package/dist/sessions/signed.js.map +1 -1
  61. package/dist/subscriptions/index.d.ts.map +1 -1
  62. package/dist/subscriptions/index.js +260 -26
  63. package/dist/subscriptions/index.js.map +1 -1
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +20 -6
@@ -0,0 +1,413 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ var _a;
15
+ import { Time } from "@spine-event-engine/core/time";
16
+ import { OidcLoginGrantSchema, OidcLoginTransactionSchema, } from "@spine-event-engine/proto/auth";
17
+ import { ColumnTypes, defaultQueryCandidateLimit, RecordColumn, RecordSpec, } from "@spine-event-engine/storage";
18
+ import { StoragePreparations } from "@spine-event-engine/storage/provider";
19
+ import { OidcFlowKeys } from "./records.js";
20
+ import { SessionRecords } from "../sessions/session-record.js";
21
+ /**
22
+ * Durable atomic transaction and grant transitions for one component login flow.
23
+ */
24
+ export class PersistentOidcFlowStore {
25
+ /**
26
+ * Flow identity used to qualify persisted records and indexed expiry ranges.
27
+ */
28
+ flowId;
29
+ #transactions;
30
+ #grants;
31
+ #clock;
32
+ #closed = false;
33
+ #active = 0;
34
+ #drained;
35
+ #closing;
36
+ /**
37
+ * Binds both independent handles and their trusted maintenance clock.
38
+ *
39
+ * @param flowId Application-selected flow identity.
40
+ * @param transactions Transaction record handle.
41
+ * @param grants Grant record handle.
42
+ * @param clock Latest allowed maintenance cutoff.
43
+ */
44
+ constructor(flowId, transactions, grants, clock) {
45
+ this.flowId = flowId;
46
+ this.#transactions = transactions;
47
+ this.#grants = grants;
48
+ this.#clock = clock;
49
+ }
50
+ /**
51
+ * Acquires two handles and completes selected physical preparation.
52
+ *
53
+ * @param options Flow placement and preparation policy.
54
+ * @returns Ready persistent store, or an explicit non-preparing store.
55
+ */
56
+ static async create(options) {
57
+ if (typeof options.flowId !== "string" || options.flowId.trim().length === 0)
58
+ throw new TypeError("flowId must be a nonempty string.");
59
+ const handles = [];
60
+ try {
61
+ const transactions = options.storageFactory.createRecordStorage(context, transactionSpec, options.group, { prepareOnAccess: false });
62
+ handles.push(transactions);
63
+ const grants = options.storageFactory.createRecordStorage(context, grantSpec, options.group, {
64
+ prepareOnAccess: false,
65
+ });
66
+ handles.push(grants);
67
+ if (!transactions.atomicCompareAndSet || !grants.atomicCompareAndSet)
68
+ throw new Error("OIDC flow storage requires atomic compare-and-set.");
69
+ if (options.createMissingStructures !== false)
70
+ await _a.prepare(options);
71
+ return new _a(options.flowId, transactions, grants, options.clock ?? Time.currentTime);
72
+ }
73
+ catch (error) {
74
+ _a.releaseAfterFailure(handles, error);
75
+ }
76
+ }
77
+ /**
78
+ * Closes acquired handles while preserving the original construction failure.
79
+ *
80
+ * @param handles Handles acquired before failure.
81
+ * @param error Original acquisition or preparation failure.
82
+ * @returns Never returns; throws the original failure or an aggregate with close failures.
83
+ */
84
+ static releaseAfterFailure(handles, error) {
85
+ const failures = [error];
86
+ for (const handle of handles) {
87
+ try {
88
+ handle.close();
89
+ }
90
+ catch (closeError) {
91
+ failures.push(closeError);
92
+ }
93
+ }
94
+ if (failures.length > 1)
95
+ throw new AggregateError(failures, "OIDC flow preparation and handle cleanup failed.");
96
+ throw error;
97
+ }
98
+ /**
99
+ * Prepares both selected record families before factory completion.
100
+ *
101
+ * @param options Factory and group to prepare.
102
+ * @returns Completion after both structures pass compatibility checks.
103
+ */
104
+ static async prepare(options) {
105
+ const provider = StoragePreparations.for(options.storageFactory);
106
+ await provider.prepareRecord(context, transactionSpec, options.group, "create");
107
+ await provider.prepareRecord(context, grantSpec, options.group, "create");
108
+ }
109
+ /**
110
+ * @inheritdoc
111
+ */
112
+ insertTransaction(record, signal) {
113
+ return this.#run(async () => {
114
+ this.#validate(record);
115
+ signal?.throwIfAborted();
116
+ const inserted = await this.#transactions.compareAndSet(record.lookupDigest, undefined, record);
117
+ if (!inserted)
118
+ signal?.throwIfAborted();
119
+ return inserted;
120
+ });
121
+ }
122
+ /**
123
+ * @inheritdoc
124
+ */
125
+ readTransaction(digest, signal) {
126
+ return this.#read(this.#transactions, digest, signal);
127
+ }
128
+ /**
129
+ * @inheritdoc
130
+ */
131
+ consumeTransaction(expected, signal) {
132
+ return this.#consume(this.#transactions, expected, signal);
133
+ }
134
+ /**
135
+ * @inheritdoc
136
+ */
137
+ insertGrant(record, signal) {
138
+ return this.#run(async () => {
139
+ this.#validate(record);
140
+ signal?.throwIfAborted();
141
+ const inserted = await this.#grants.compareAndSet(record.lookupDigest, undefined, record);
142
+ if (!inserted)
143
+ signal?.throwIfAborted();
144
+ return inserted;
145
+ });
146
+ }
147
+ /**
148
+ * @inheritdoc
149
+ */
150
+ readGrant(digest, signal) {
151
+ return this.#read(this.#grants, digest, signal);
152
+ }
153
+ /**
154
+ * @inheritdoc
155
+ */
156
+ consumeGrant(expected, signal) {
157
+ return this.#consume(this.#grants, expected, signal);
158
+ }
159
+ /**
160
+ * @inheritdoc
161
+ */
162
+ purgeExpired(cutoff, signal) {
163
+ return this.#run(async () => {
164
+ const valid = SessionRecords.deadline(cutoff);
165
+ signal?.throwIfAborted();
166
+ if (SessionRecords.compare(valid, SessionRecords.deadline(this.#clock())) > 0)
167
+ throw new RangeError("Purge cutoff cannot be later than the trusted clock.");
168
+ const transactions = await this.#purgeFamily(this.#transactions, valid, signal);
169
+ const grants = await this.#purgeFamily(this.#grants, valid, signal);
170
+ return { transactions, grants };
171
+ });
172
+ }
173
+ /**
174
+ * @inheritdoc
175
+ */
176
+ close() {
177
+ if (this.#closing !== undefined)
178
+ return this.#closing;
179
+ this.#closed = true;
180
+ this.#closing = this.#finishClose();
181
+ return this.#closing;
182
+ }
183
+ /**
184
+ * Closes both acquired handles after admitted work settles.
185
+ *
186
+ * @returns Completion after both close attempts.
187
+ */
188
+ async #finishClose() {
189
+ if (this.#active > 0)
190
+ await new Promise((resolve) => (this.#drained = resolve));
191
+ const errors = [];
192
+ for (const handle of [this.#transactions, this.#grants]) {
193
+ try {
194
+ handle.close();
195
+ }
196
+ catch (error) {
197
+ errors.push(error);
198
+ }
199
+ }
200
+ if (errors.length > 0)
201
+ throw new AggregateError(errors, "OIDC flow handle close failed.");
202
+ }
203
+ /**
204
+ * Admits work until closure and drains it before handle release.
205
+ *
206
+ * @typeParam T Operation result.
207
+ * @param work Admitted asynchronous operation.
208
+ * @returns Operation result.
209
+ */
210
+ async #run(work) {
211
+ if (this.#closed)
212
+ throw new Error("OIDC flow store is closed.");
213
+ this.#active += 1;
214
+ try {
215
+ return await work();
216
+ }
217
+ finally {
218
+ this.#active -= 1;
219
+ if (this.#active === 0)
220
+ this.#drained?.();
221
+ }
222
+ }
223
+ /**
224
+ * Checks flow binding, digest shape and deadline before mutation.
225
+ *
226
+ * @param record Complete flow record.
227
+ */
228
+ #validate(record) {
229
+ if (record.flowId !== this.flowId || !/^[0-9a-f]{64}$/.test(record.lookupDigest))
230
+ throw new TypeError("OIDC flow record has an invalid identity.");
231
+ OidcFlowKeys.expiry(record);
232
+ }
233
+ /**
234
+ * Reads only a record belonging to this configured flow.
235
+ *
236
+ * @typeParam R Transaction or grant record.
237
+ * @param storage Selected family handle.
238
+ * @param digest Flow-qualified lookup digest.
239
+ * @param signal Optional cancellation.
240
+ * @returns Current record for this flow, if present.
241
+ */
242
+ #read(storage, digest, signal) {
243
+ return this.#run(async () => {
244
+ signal?.throwIfAborted();
245
+ const record = await storage.read(digest);
246
+ signal?.throwIfAborted();
247
+ return record?.flowId === this.flowId ? record : undefined;
248
+ });
249
+ }
250
+ /**
251
+ * Deletes only one expected complete record.
252
+ *
253
+ * @typeParam R Transaction or grant record.
254
+ * @param storage Selected family handle.
255
+ * @param expected Validated snapshot.
256
+ * @param signal Optional cancellation.
257
+ * @returns Whether this call consumed the record.
258
+ */
259
+ #consume(storage, expected, signal) {
260
+ return this.#run(async () => {
261
+ this.#validate(expected);
262
+ signal?.throwIfAborted();
263
+ const consumed = await storage.compareAndSet(expected.lookupDigest, expected, undefined);
264
+ if (!consumed)
265
+ signal?.throwIfAborted();
266
+ return consumed;
267
+ });
268
+ }
269
+ /**
270
+ * Drains indexed expiry groups until no candidate remains or a CAS race occurs.
271
+ *
272
+ * @typeParam R Transaction or grant record.
273
+ * @param storage Selected family handle.
274
+ * @param cutoff Trusted maximum eligible deadline.
275
+ * @param signal Optional cancellation.
276
+ * @returns Count removed by this pass.
277
+ */
278
+ async #purgeFamily(storage, cutoff, signal) {
279
+ let completed;
280
+ let removed = 0;
281
+ const cutoffKey = OidcFlowKeys.upperBound(this.flowId, cutoff);
282
+ const lowerKey = OidcFlowKeys.lowerBound(this.flowId);
283
+ for (;;) {
284
+ signal?.throwIfAborted();
285
+ const key = await this.#nextExpiry(storage, lowerKey, cutoffKey, completed);
286
+ signal?.throwIfAborted();
287
+ if (key === undefined)
288
+ return removed;
289
+ const [count, raced] = await this.#purgeTie(storage, key, cutoff, signal);
290
+ removed += count;
291
+ if (raced)
292
+ return removed;
293
+ completed = key;
294
+ }
295
+ }
296
+ /**
297
+ * Finds the next indexed exact expiry group.
298
+ *
299
+ * @typeParam R Transaction or grant record.
300
+ * @param storage Selected family handle.
301
+ * @param lowerKey First key in this flow's indexed range.
302
+ * @param cutoffKey Encoded maximum deadline.
303
+ * @param completed Last drained expiry group.
304
+ * @returns Next expiry group, if present.
305
+ */
306
+ async #nextExpiry(storage, lowerKey, cutoffKey, completed) {
307
+ const entries = await storage.queryPlanEntries({
308
+ predicate: _a.expiryPredicate(lowerKey, cutoffKey, completed),
309
+ order: [{ column: "expires_order", direction: "asc" }],
310
+ limit: 1,
311
+ });
312
+ return entries[0] === undefined ? undefined : OidcFlowKeys.orderKey(entries[0].record);
313
+ }
314
+ /**
315
+ * Pages one exact expiry group by immutable digest.
316
+ *
317
+ * @typeParam R Transaction or grant record.
318
+ * @param storage Selected family handle.
319
+ * @param key Encoded exact deadline.
320
+ * @param cutoff Trusted maximum deadline.
321
+ * @param signal Optional cancellation.
322
+ * @returns Removed count and a concurrent-change marker.
323
+ */
324
+ async #purgeTie(storage, key, cutoff, signal) {
325
+ let after;
326
+ let removed = 0;
327
+ let raced = false;
328
+ for (;;) {
329
+ signal?.throwIfAborted();
330
+ const entries = await storage.queryEntries({
331
+ filters: [{ column: "expires_order", value: key }],
332
+ sort: [{ field: "id" }],
333
+ limit: defaultQueryCandidateLimit,
334
+ ...(after === undefined ? {} : { after }),
335
+ });
336
+ signal?.throwIfAborted();
337
+ if (entries.length === 0)
338
+ return [removed, raced];
339
+ for (const entry of entries) {
340
+ const result = await this.#removeExpired(storage, entry.record, cutoff, signal);
341
+ if (result === true)
342
+ removed += 1;
343
+ if (result === false)
344
+ raced = true;
345
+ }
346
+ const last = entries.at(-1);
347
+ if (last === undefined)
348
+ return [removed, raced];
349
+ after = { id: last.id, values: [{ field: "id", value: last.id }] };
350
+ }
351
+ }
352
+ /**
353
+ * Attempts one conditional deletion without retrying a concurrent change.
354
+ * @typeParam R Transaction or grant record.
355
+ * @param storage Selected family handle.
356
+ * @param record Candidate snapshot from the indexed page.
357
+ * @param cutoff Trusted maximum eligible deadline.
358
+ * @param signal Optional cancellation.
359
+ * @returns True when removed, false after a race, or undefined if ineligible.
360
+ */
361
+ async #removeExpired(storage, record, cutoff, signal) {
362
+ if (record.flowId !== this.flowId ||
363
+ SessionRecords.compare(OidcFlowKeys.expiry(record), cutoff) > 0)
364
+ return undefined;
365
+ const removed = await storage.compareAndSet(record.lookupDigest, record, undefined);
366
+ signal?.throwIfAborted();
367
+ return removed;
368
+ }
369
+ /**
370
+ * Builds the indexed range for one flow and cutoff without scanning other flows.
371
+ *
372
+ * @param lowerKey Start of this flow's range.
373
+ * @param cutoffKey Last eligible exact expiry key.
374
+ * @param completed Previously drained expiry key, if any.
375
+ * @returns Provider-supported comparison predicate.
376
+ */
377
+ static expiryPredicate(lowerKey, cutoffKey, completed) {
378
+ return {
379
+ kind: "all",
380
+ predicates: [
381
+ {
382
+ kind: "comparison",
383
+ column: "expires_order",
384
+ operator: "lessOrEqual",
385
+ value: cutoffKey,
386
+ },
387
+ {
388
+ kind: "comparison",
389
+ column: "expires_order",
390
+ operator: completed === undefined ? "greaterOrEqual" : "greaterThan",
391
+ value: completed ?? lowerKey,
392
+ },
393
+ ],
394
+ };
395
+ }
396
+ }
397
+ _a = PersistentOidcFlowStore;
398
+ const context = { name: "__AUTH_OIDC_FLOW__", multitenant: false };
399
+ const transactionSpec = new RecordSpec({
400
+ recordType: OidcLoginTransactionSchema,
401
+ idKind: "string",
402
+ extractId: (record) => record.lookupDigest,
403
+ columns: [new RecordColumn("expires_order", ColumnTypes.fixedBytes(44), OidcFlowKeys.orderKey)],
404
+ indexes: [{ name: "expiry", columns: ["expires_order", "id"] }],
405
+ });
406
+ const grantSpec = new RecordSpec({
407
+ recordType: OidcLoginGrantSchema,
408
+ idKind: "string",
409
+ extractId: (record) => record.lookupDigest,
410
+ columns: [new RecordColumn("expires_order", ColumnTypes.fixedBytes(44), OidcFlowKeys.orderKey)],
411
+ indexes: [{ name: "expiry", columns: ["expires_order", "id"] }],
412
+ });
413
+ //# sourceMappingURL=persistent-flow-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistent-flow-store.js","sourceRoot":"","sources":["../../src/oidc/persistent-flow-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAG3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,WAAW,EACX,0BAA0B,EAC1B,YAAY,EACZ,UAAU,GAMX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAG3E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAyC/D;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAClC;;OAEG;IACM,MAAM,CAAS;IAEf,aAAa,CAA8C;IAE3D,OAAO,CAAwC;IAE/C,MAAM,CAAkB;IAEjC,OAAO,GAAG,KAAK,CAAC;IAEhB,OAAO,GAAG,CAAC,CAAC;IAEZ,QAAQ,CAA2B;IAEnC,QAAQ,CAA4B;IAEpC;;;;;;;OAOG;IACH,YACE,MAAc,EACd,YAAyD,EACzD,MAA6C,EAC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M,CAAC,YAAY;IAC1C,OAAO,EAAE,CAAC,IAAI,YAAY,CAAC,eAAe,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC/F,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC;CAChE,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Timestamp } from "@bufbuild/protobuf/wkt";
2
+ import type { OidcLoginGrant, OidcLoginTransaction } from "@spine-event-engine/proto/auth";
3
+ import type { AuthenticatedPrincipal } from "../index.js";
4
+ /**
5
+ * Exact identity and expiry helpers for component login records.
6
+ */
7
+ export declare const OidcFlowKeys: Readonly<{
8
+ digest(flowId: string, value: string): string;
9
+ lowerBound(flowId: string): Uint8Array;
10
+ upperBound(flowId: string, cutoff: Timestamp): Uint8Array;
11
+ expiry(record: OidcLoginTransaction | OidcLoginGrant): Timestamp;
12
+ orderKey(record: OidcLoginTransaction | OidcLoginGrant): Uint8Array;
13
+ principal(record: OidcLoginGrant): AuthenticatedPrincipal;
14
+ }>;
15
+ //# sourceMappingURL=records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/oidc/records.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAG3F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC;IAClC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9C,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IACvC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;IAC1D,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,GAAG,SAAS,CAAC;IACjE,QAAQ,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,GAAG,UAAU,CAAC;IACpE,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,sBAAsB,CAAC;CAC3D,CA2EC,CAAC"}
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Copyright 2026, CodeMatters. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
+ * in compliance with the License. You may obtain a copy of the License at
6
+ *
7
+ * https://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
10
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
+ * or implied. See the License for the specific language governing permissions and limitations under
12
+ * the License.
13
+ */
14
+ import { createHash } from "node:crypto";
15
+ import { SessionRecords } from "../sessions/session-record.js";
16
+ /**
17
+ * Exact identity and expiry helpers for component login records.
18
+ */
19
+ export const OidcFlowKeys = Object.freeze({
20
+ /**
21
+ * Qualifies a one-use browser value by its configured flow before hashing.
22
+ *
23
+ * @param flowId Application-selected flow identity.
24
+ * @param value Random state or grant value.
25
+ * @returns SHA-256 digest used only as the record slot.
26
+ */
27
+ digest(flowId, value) {
28
+ if (!flowId || !value)
29
+ throw new TypeError("OIDC flow and lookup value must be nonempty.");
30
+ return createHash("sha256")
31
+ .update(JSON.stringify([flowId, value]))
32
+ .digest("hex");
33
+ },
34
+ /**
35
+ * Starts the indexed expiry range for one flow.
36
+ *
37
+ * @param flowId Application-selected flow identity.
38
+ * @returns Digest prefix followed by the least twelve-byte deadline.
39
+ */
40
+ lowerBound(flowId) {
41
+ return Buffer.concat([createHash("sha256").update(flowId).digest(), Buffer.alloc(12)]);
42
+ },
43
+ /**
44
+ * Ends the indexed expiry range at one exact deadline.
45
+ *
46
+ * @param flowId Application-selected flow identity.
47
+ * @param cutoff Trusted maximum deadline.
48
+ * @returns Digest prefix followed by the encoded cutoff.
49
+ */
50
+ upperBound(flowId, cutoff) {
51
+ return Buffer.concat([
52
+ createHash("sha256").update(flowId).digest(),
53
+ SessionRecords.orderKey(cutoff),
54
+ ]);
55
+ },
56
+ /**
57
+ * Reads the required exact application deadline.
58
+ *
59
+ * @param record Complete transaction or grant.
60
+ * @returns Detached validated deadline.
61
+ */
62
+ expiry(record) {
63
+ if (record.whenExpires === undefined)
64
+ throw new Error("OIDC flow record has no expiry.");
65
+ return SessionRecords.deadline(record.whenExpires);
66
+ },
67
+ /**
68
+ * Encodes an exact deadline for provider index ordering.
69
+ *
70
+ * @param record Complete transaction or grant.
71
+ * @returns Flow digest and twelve ordered deadline bytes.
72
+ */
73
+ orderKey(record) {
74
+ return OidcFlowKeys.upperBound(record.flowId, OidcFlowKeys.expiry(record));
75
+ },
76
+ /**
77
+ * Restores the complete mapped principal without losing empty attributes.
78
+ *
79
+ * @param record Consumed application grant.
80
+ * @returns Detached public principal.
81
+ */
82
+ principal(record) {
83
+ const principal = record.principal;
84
+ if (principal === undefined)
85
+ throw new Error("OIDC grant has no mapped principal.");
86
+ return Object.freeze(principal.attributes === undefined
87
+ ? { id: principal.id }
88
+ : { id: principal.id, attributes: Object.freeze({ ...principal.attributes.values }) });
89
+ },
90
+ });
91
+ //# sourceMappingURL=records.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/oidc/records.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAOpB,MAAM,CAAC,MAAM,CAAC;IACjB;;;;;;OAMG;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ACnC,IAAI,SAAS,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACpF,OAAO,MAAM,CAAC,MAAM,CAClB,SAAS,CAAC,UAAU,KAAK,SAAS;YAChC,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE;YACtB,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,CACxF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -123,16 +123,20 @@ export interface GitHubProviderOptions {
123
123
  readonly includeVerifiedPrimaryEmail?: boolean;
124
124
  }
125
125
  /**
126
- * Fetches and validates OpenID Connect discovery metadata before constructing an adapter.
127
- * @param options The trusted issuer and bounded discovery settings.
128
- * @returns The configured provider, or undefined when discovery cannot be trusted.
126
+ * Trusted issuer and optional exact metadata URL for provider discovery.
129
127
  */
130
- export declare function discoverOidcProvider(options: Omit<OidcProviderOptions, "authorizationEndpoint" | "tokenEndpoint" | "jwksEndpoint"> & {
128
+ type DiscoveryOptions = Omit<OidcProviderOptions, "authorizationEndpoint" | "tokenEndpoint" | "jwksEndpoint"> & {
131
129
  /**
132
130
  * Trusted HTTPS discovery URL; defaults under the configured issuer.
133
131
  */
134
132
  readonly discoveryEndpoint?: string;
135
- }): Promise<ConfiguredOidcProvider | undefined>;
133
+ };
134
+ /**
135
+ * Fetches and validates OpenID Connect discovery metadata before constructing an adapter.
136
+ * @param options The trusted issuer and bounded discovery settings.
137
+ * @returns The configured provider, or undefined when discovery cannot be trusted.
138
+ */
139
+ export declare function discoverOidcProvider(options: DiscoveryOptions): Promise<ConfiguredOidcProvider | undefined>;
136
140
  /**
137
141
  * Creates an OIDC authorization-code verifier from explicitly trusted metadata.
138
142
  * @param options The trusted OIDC endpoints, client credentials, and bounds.
@@ -151,4 +155,5 @@ export declare function createGoogleProvider(options: Omit<OidcProviderOptions,
151
155
  * @returns The configured GitHub provider.
152
156
  */
153
157
  export declare function createGitHubProvider(options: GitHubProviderOptions): ConfiguredOidcProvider;
158
+ export {};
154
159
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAGV,4BAA4B,EAC7B,MAAM,sBAAsB,CAAC;AAqB9B;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,GAAG,oBAAoB,GAAG,MAAM,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAGlC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,wBAAwB,CAAC;IAEzD;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,E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