@spine-event-engine/auth 2.0.0-snapshot.21 → 2.0.0-snapshot.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/oidc/index.d.ts.map +1 -1
- package/dist/oidc/index.js +241 -16
- package/dist/oidc/index.js.map +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +298 -108
- package/dist/providers/index.js.map +1 -1
- package/dist/sessions/opaque.d.ts +37 -0
- package/dist/sessions/opaque.d.ts.map +1 -1
- package/dist/sessions/opaque.js +70 -1
- package/dist/sessions/opaque.js.map +1 -1
- package/dist/sessions/signed.d.ts +1 -1
- package/dist/sessions/signed.d.ts.map +1 -1
- package/dist/sessions/signed.js +164 -15
- package/dist/sessions/signed.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -151,13 +151,50 @@ export declare class OpaqueSessions implements SessionResolver {
|
|
|
151
151
|
* @returns Completes after retained records are dropped.
|
|
152
152
|
*/
|
|
153
153
|
close(): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Checks whether the session store has been closed.
|
|
156
|
+
* @returns Whether further session operations must be rejected.
|
|
157
|
+
*/
|
|
154
158
|
private isClosed;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a bounded session record for an authenticated principal.
|
|
161
|
+
* @param principal The identity to store in the session.
|
|
162
|
+
* @param now The validated issuance time in milliseconds.
|
|
163
|
+
* @returns The record, or undefined if expiry cannot be represented.
|
|
164
|
+
*/
|
|
155
165
|
private record;
|
|
166
|
+
/**
|
|
167
|
+
* Creates an unused opaque credential identifier within the retry limit.
|
|
168
|
+
* @returns The identifier, or undefined after entropy failures or collisions.
|
|
169
|
+
*/
|
|
156
170
|
private nextId;
|
|
171
|
+
/**
|
|
172
|
+
* Returns a live session record and removes it when expired.
|
|
173
|
+
* @param id The opaque credential identifier.
|
|
174
|
+
* @param now The validated lookup time in milliseconds.
|
|
175
|
+
* @returns The live record, or undefined if absent or expired.
|
|
176
|
+
*/
|
|
157
177
|
private live;
|
|
178
|
+
/**
|
|
179
|
+
* Removes every session that has expired by the supplied time.
|
|
180
|
+
* @param now The validated sweep time in milliseconds.
|
|
181
|
+
*/
|
|
158
182
|
private sweepExpired;
|
|
183
|
+
/**
|
|
184
|
+
* Compares a session expiry with the current millisecond reading.
|
|
185
|
+
* @param record The session record to inspect.
|
|
186
|
+
* @param now The validated current time.
|
|
187
|
+
* @returns Whether the record has expired.
|
|
188
|
+
*/
|
|
159
189
|
private expired;
|
|
190
|
+
/**
|
|
191
|
+
* Reads a safe clock value and closes the store on clock failure.
|
|
192
|
+
* @returns Current epoch milliseconds, or undefined after failure.
|
|
193
|
+
*/
|
|
160
194
|
private now;
|
|
195
|
+
/**
|
|
196
|
+
* Closes the store and clears session records after a clock fault.
|
|
197
|
+
*/
|
|
161
198
|
private failClosed;
|
|
162
199
|
}
|
|
163
200
|
//# sourceMappingURL=opaque.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opaque.d.ts","sourceRoot":"","sources":["../../src/sessions/opaque.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opaque.d.ts","sourceRoot":"","sources":["../../src/sessions/opaque.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAGjC;;;OAGG;IACH,GAAG,IAAI,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,UAAU,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAGpC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAEpC;;;;OAIG;IACH,QAAQ,CAAC,WAA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AAC,QAAQ,CAAC,KAAK,CAAqB;IAE3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAE7C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IAEzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAE3C,OAAO,CAAC,MAAM,CAAS;IAEvB;;;OAGG;gBACS,OAAO,GAAE,qBAA0B;IAiB/C;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,sBAAsB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IA8B7E;;;;OAIG;IACH,OAAO,CAAC,eAAe,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAQjF;;;;OAIG;IACH,MAAM,CAAC,eAAe,EAAE,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAsC9E;;;;OAIG;IACH,MAAM,CAAC,eAAe,EAAE,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAM9E;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;OAKG;IACH,OAAO,CAAC,MAAM;IASd;;;OAGG;IACH,OAAO,CAAC,MAAM;IAmBd;;;;;OAKG;IACH,OAAO,CAAC,IAAI;IAQZ;;;OAGG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;OAKG;IACH,OAAO,CAAC,OAAO;IAIf;;;OAGG;IACH,OAAO,CAAC,GAAG;IAYX;;OAEG;IACH,OAAO,CAAC,UAAU;CAInB"}
|
package/dist/sessions/opaque.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
|
+
import { Time } from "@spine-event-engine/core/time";
|
|
14
15
|
import { create } from "@bufbuild/protobuf";
|
|
15
16
|
import { TimestampSchema } from "@bufbuild/protobuf/wkt";
|
|
16
17
|
import { randomBytes as nodeRandomBytes } from "node:crypto";
|
|
@@ -33,7 +34,7 @@ export class OpaqueSessions {
|
|
|
33
34
|
* @param options The optional clock, entropy, lifetime, and capacity settings.
|
|
34
35
|
*/
|
|
35
36
|
constructor(options = {}) {
|
|
36
|
-
this.clock = options.clock ?? { now:
|
|
37
|
+
this.clock = options.clock ?? { now: () => Time.currentTimeMillis() };
|
|
37
38
|
this.random = options.randomBytes ?? nodeRandomBytes;
|
|
38
39
|
this.ttlMilliseconds = OpaqueSessionValues.positiveSafeInteger(options.ttlMilliseconds ?? 8 * 60 * 60 * 1_000, "ttlMilliseconds");
|
|
39
40
|
this.maxSessions = OpaqueSessionValues.positiveSafeInteger(options.maxSessions ?? 10_000, "maxSessions");
|
|
@@ -162,9 +163,19 @@ export class OpaqueSessions {
|
|
|
162
163
|
this.records.clear();
|
|
163
164
|
return Promise.resolve();
|
|
164
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Checks whether the session store has been closed.
|
|
168
|
+
* @returns Whether further session operations must be rejected.
|
|
169
|
+
*/
|
|
165
170
|
isClosed() {
|
|
166
171
|
return this.closed;
|
|
167
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Creates a bounded session record for an authenticated principal.
|
|
175
|
+
* @param principal The identity to store in the session.
|
|
176
|
+
* @param now The validated issuance time in milliseconds.
|
|
177
|
+
* @returns The record, or undefined if expiry cannot be represented.
|
|
178
|
+
*/
|
|
168
179
|
record(principal, now) {
|
|
169
180
|
const expiresAt = now + this.ttlMilliseconds;
|
|
170
181
|
if (!Number.isSafeInteger(expiresAt) || !OpaqueSessionValues.timestampValid(expiresAt)) {
|
|
@@ -173,6 +184,10 @@ export class OpaqueSessions {
|
|
|
173
184
|
}
|
|
174
185
|
return { principal: OpaqueSessionValues.copyPrincipal(principal), expiresAt };
|
|
175
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Creates an unused opaque credential identifier within the retry limit.
|
|
189
|
+
* @returns The identifier, or undefined after entropy failures or collisions.
|
|
190
|
+
*/
|
|
176
191
|
nextId() {
|
|
177
192
|
for (let attempt = 0; attempt < this.collisionAttempts; attempt += 1) {
|
|
178
193
|
let bytes;
|
|
@@ -195,6 +210,12 @@ export class OpaqueSessions {
|
|
|
195
210
|
}
|
|
196
211
|
return undefined;
|
|
197
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Returns a live session record and removes it when expired.
|
|
215
|
+
* @param id The opaque credential identifier.
|
|
216
|
+
* @param now The validated lookup time in milliseconds.
|
|
217
|
+
* @returns The live record, or undefined if absent or expired.
|
|
218
|
+
*/
|
|
198
219
|
live(id, now) {
|
|
199
220
|
const record = this.records.get(id);
|
|
200
221
|
if (record === undefined)
|
|
@@ -204,14 +225,28 @@ export class OpaqueSessions {
|
|
|
204
225
|
this.records.delete(id);
|
|
205
226
|
return undefined;
|
|
206
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Removes every session that has expired by the supplied time.
|
|
230
|
+
* @param now The validated sweep time in milliseconds.
|
|
231
|
+
*/
|
|
207
232
|
sweepExpired(now) {
|
|
208
233
|
for (const [id, record] of this.records)
|
|
209
234
|
if (this.expired(record, now))
|
|
210
235
|
this.records.delete(id);
|
|
211
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Compares a session expiry with the current millisecond reading.
|
|
239
|
+
* @param record The session record to inspect.
|
|
240
|
+
* @param now The validated current time.
|
|
241
|
+
* @returns Whether the record has expired.
|
|
242
|
+
*/
|
|
212
243
|
expired(record, now) {
|
|
213
244
|
return now >= record.expiresAt;
|
|
214
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Reads a safe clock value and closes the store on clock failure.
|
|
248
|
+
* @returns Current epoch milliseconds, or undefined after failure.
|
|
249
|
+
*/
|
|
215
250
|
now() {
|
|
216
251
|
try {
|
|
217
252
|
const value = this.clock.now();
|
|
@@ -224,6 +259,9 @@ export class OpaqueSessions {
|
|
|
224
259
|
return undefined;
|
|
225
260
|
}
|
|
226
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Closes the store and clears session records after a clock fault.
|
|
264
|
+
*/
|
|
227
265
|
failClosed() {
|
|
228
266
|
this.closed = true;
|
|
229
267
|
this.records.clear();
|
|
@@ -233,26 +271,52 @@ export class OpaqueSessions {
|
|
|
233
271
|
* Validates opaque-session values and creates immutable credential data.
|
|
234
272
|
*/
|
|
235
273
|
const OpaqueSessionValues = Object.freeze({
|
|
274
|
+
/**
|
|
275
|
+
* Validates a positive safe integer for a session limit.
|
|
276
|
+
* @param value The candidate limit.
|
|
277
|
+
* @param name The option named in an error.
|
|
278
|
+
* @returns The accepted limit.
|
|
279
|
+
*/
|
|
236
280
|
positiveSafeInteger(value, name) {
|
|
237
281
|
if (!Number.isSafeInteger(value) || value <= 0)
|
|
238
282
|
throw new Error(`${name} must be a positive safe integer`);
|
|
239
283
|
return value;
|
|
240
284
|
},
|
|
285
|
+
/**
|
|
286
|
+
* Wraps an opaque identifier in an immutable cookie credential.
|
|
287
|
+
* @param value The opaque identifier.
|
|
288
|
+
* @returns The cookie credential.
|
|
289
|
+
*/
|
|
241
290
|
credential(value) {
|
|
242
291
|
return Object.freeze({ kind: "cookie", value });
|
|
243
292
|
},
|
|
293
|
+
/**
|
|
294
|
+
* Copies a principal and freezes its attributes before retention.
|
|
295
|
+
* @param principal The authenticated identity to copy.
|
|
296
|
+
* @returns An immutable principal snapshot.
|
|
297
|
+
*/
|
|
244
298
|
copyPrincipal(principal) {
|
|
245
299
|
if (typeof principal.id !== "string")
|
|
246
300
|
throw new Error("principal.id must be a string");
|
|
247
301
|
const attributes = principal.attributes === undefined ? undefined : Object.freeze({ ...principal.attributes });
|
|
248
302
|
return Object.freeze(attributes === undefined ? { id: principal.id } : { id: principal.id, attributes });
|
|
249
303
|
},
|
|
304
|
+
/**
|
|
305
|
+
* Builds a detached resolved session from a retained record.
|
|
306
|
+
* @param record The live session record.
|
|
307
|
+
* @returns The resolved principal and precise expiry.
|
|
308
|
+
*/
|
|
250
309
|
resolved(record) {
|
|
251
310
|
return Object.freeze({
|
|
252
311
|
principal: OpaqueSessionValues.copyPrincipal(record.principal),
|
|
253
312
|
expiresAt: OpaqueSessionValues.timestamp(record.expiresAt),
|
|
254
313
|
});
|
|
255
314
|
},
|
|
315
|
+
/**
|
|
316
|
+
* Converts epoch milliseconds to a Protobuf expiry timestamp.
|
|
317
|
+
* @param milliseconds The expiry time to encode.
|
|
318
|
+
* @returns The normalized Protobuf timestamp.
|
|
319
|
+
*/
|
|
256
320
|
timestamp(milliseconds) {
|
|
257
321
|
const seconds = Math.floor(milliseconds / 1_000);
|
|
258
322
|
return create(TimestampSchema, {
|
|
@@ -260,6 +324,11 @@ const OpaqueSessionValues = Object.freeze({
|
|
|
260
324
|
nanos: (milliseconds - seconds * 1_000) * 1_000_000,
|
|
261
325
|
});
|
|
262
326
|
},
|
|
327
|
+
/**
|
|
328
|
+
* Checks whether epoch milliseconds fit the Protobuf timestamp range.
|
|
329
|
+
* @param milliseconds The candidate expiry time.
|
|
330
|
+
* @returns Whether it fits the supported range.
|
|
331
|
+
*/
|
|
263
332
|
timestampValid(milliseconds) {
|
|
264
333
|
const seconds = Math.floor(milliseconds / 1_000);
|
|
265
334
|
return seconds >= -62_135_596_800 && seconds <= 253_402_300_799;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opaque.js","sourceRoot":"","sources":["../../src/sessions/opaque.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAkB,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,aAAa,CAAC;AA0J7D;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACR,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"opaque.js","sourceRo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AAG,KAAK,CAAC,CAAC;QACjD,OAAO,OAAO,IAAI,CAAC,cAAc,IAAI,OAAO,IAAI,eAAe,CAAC;IAClE,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -93,7 +93,7 @@ export interface SignedSessionsOptions {
|
|
|
93
93
|
*/
|
|
94
94
|
readonly revocation?: SignedTokenRevocation;
|
|
95
95
|
/**
|
|
96
|
-
* Unix-millisecond clock; defaults to `
|
|
96
|
+
* Unix-millisecond clock; defaults to `Time.currentTimeMillis`.
|
|
97
97
|
*/
|
|
98
98
|
readonly clock?: SignedSessionClock;
|
|
99
99
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signed.d.ts","sourceRoot":"","sources":["../../src/sessions/signed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signed.d.ts","sourceRoot":"","sources":["../../src/sessions/signed.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,SAAS,EAMV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAGjC;;;;OAIG;IACH,GAAG,IAAI,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,EAAE,KAAK,UAAU,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IAGtC;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAG3C;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,C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A2B,CAAC;IA0C3E;;;;;;;OAOG;IACG,MAAM,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAY/E;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAmIvB"}
|
package/dist/sessions/signed.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
12
|
* the License.
|
|
13
13
|
*/
|
|
14
|
+
import { Time } from "@spine-event-engine/core/time";
|
|
14
15
|
import { create } from "@bufbuild/protobuf";
|
|
15
16
|
import { KeyObject, createPrivateKey, createPublicKey, randomBytes as nodeRandomBytes, sign, verify, } from "node:crypto";
|
|
16
17
|
import { TimestampSchema } from "@bufbuild/protobuf/wkt";
|
|
@@ -40,23 +41,20 @@ export class SignedSessions {
|
|
|
40
41
|
* @param options The issuer, key ring, limits, clock, entropy, and revocation settings.
|
|
41
42
|
*/
|
|
42
43
|
constructor(options) {
|
|
43
|
-
|
|
44
|
-
this.#
|
|
45
|
-
this.#
|
|
46
|
-
this.#
|
|
47
|
-
this.#
|
|
48
|
-
this.#
|
|
49
|
-
this.#
|
|
50
|
-
this.#
|
|
51
|
-
this.#
|
|
52
|
-
this.#
|
|
44
|
+
const settings = SignedSessionValues.settings(options);
|
|
45
|
+
this.#issuer = settings.issuer;
|
|
46
|
+
this.#audience = settings.audience;
|
|
47
|
+
this.#ttl = settings.ttl;
|
|
48
|
+
this.#skew = settings.skew;
|
|
49
|
+
this.#maxToken = settings.maxToken;
|
|
50
|
+
this.#maxKeys = settings.maxKeys;
|
|
51
|
+
this.#maxId = settings.maxId;
|
|
52
|
+
this.#maxAttributes = settings.maxAttributes;
|
|
53
|
+
this.#maxAttributeChars = settings.maxAttributeChars;
|
|
54
|
+
this.#clock = options.clock ?? { now: () => Time.currentTimeMillis() };
|
|
53
55
|
this.#random = options.randomBytes ?? nodeRandomBytes;
|
|
54
56
|
this.#revocation = options.revocation;
|
|
55
|
-
|
|
56
|
-
throw new Error("maxKeys exceeded");
|
|
57
|
-
const retainedUntil = options.retiredKeys === undefined || options.retiredKeys.length === 0
|
|
58
|
-
? undefined
|
|
59
|
-
: SignedSessionValues.retentionDeadline(SignedSessionValues.clockValue(this.#clock), this.#ttl, this.#skew);
|
|
57
|
+
const retainedUntil = SignedSessionValues.retiredRetention(options, this.#maxKeys, this.#clock, this.#ttl, this.#skew);
|
|
60
58
|
this.#active = SignedSessionValues.signing(options.activeKey);
|
|
61
59
|
this.#keys.set(this.#active.kid, { publicKey: this.#active.publicKey });
|
|
62
60
|
for (const key of options.retiredKeys ?? []) {
|
|
@@ -360,12 +358,61 @@ export class SignedSessions {
|
|
|
360
358
|
* Validates, serializes, and constructs finite signed-session values.
|
|
361
359
|
*/
|
|
362
360
|
const SignedSessionValues = Object.freeze({
|
|
361
|
+
/**
|
|
362
|
+
* Validates the issuer, audience, and finite token limits before key installation.
|
|
363
|
+
* @param options The signed-session configuration.
|
|
364
|
+
* @returns Copied and bounded settings for a signed session.
|
|
365
|
+
*/
|
|
366
|
+
settings(options) {
|
|
367
|
+
return {
|
|
368
|
+
issuer: SignedSessionValues.boundedString(options.issuer, "issuer"),
|
|
369
|
+
audience: SignedSessionValues.boundedString(options.audience, "audience"),
|
|
370
|
+
ttl: SignedSessionValues.positive(options.ttlSeconds ?? 28_800, "ttlSeconds"),
|
|
371
|
+
skew: SignedSessionValues.nonnegative(options.clockSkewSeconds ?? 60, "clockSkewSeconds"),
|
|
372
|
+
maxToken: SignedSessionValues.positive(options.maxTokenCharacters ?? 8_192, "maxTokenCharacters"),
|
|
373
|
+
maxKeys: SignedSessionValues.positive(options.maxKeys ?? 16, "maxKeys"),
|
|
374
|
+
maxId: SignedSessionValues.positive(options.maxPrincipalIdCharacters ?? 256, "maxPrincipalIdCharacters"),
|
|
375
|
+
maxAttributes: SignedSessionValues.nonnegative(options.maxAttributes ?? 32, "maxAttributes"),
|
|
376
|
+
maxAttributeChars: SignedSessionValues.nonnegative(options.maxAttributeCharacters ?? 4_096, "maxAttributeCharacters"),
|
|
377
|
+
};
|
|
378
|
+
},
|
|
379
|
+
/**
|
|
380
|
+
* Checks retired-key capacity and computes their shared retention deadline.
|
|
381
|
+
* @param options The configured retired keys.
|
|
382
|
+
* @param maxKeys The maximum ring size including the active key.
|
|
383
|
+
* @param clock The effective session clock.
|
|
384
|
+
* @param ttl The token lifetime in seconds.
|
|
385
|
+
* @param skew The accepted clock skew in seconds.
|
|
386
|
+
* @returns The retention deadline, or no deadline when no retired keys exist.
|
|
387
|
+
*/
|
|
388
|
+
retiredRetention(options, maxKeys, clock, ttl, skew) {
|
|
389
|
+
if ((options.retiredKeys?.length ?? 0) + 1 > maxKeys)
|
|
390
|
+
throw new Error("maxKeys exceeded");
|
|
391
|
+
return options.retiredKeys === undefined || options.retiredKeys.length === 0
|
|
392
|
+
? undefined
|
|
393
|
+
: SignedSessionValues.retentionDeadline(SignedSessionValues.clockValue(clock), ttl, skew);
|
|
394
|
+
},
|
|
395
|
+
/**
|
|
396
|
+
* Creates a rejected token-issue result.
|
|
397
|
+
* @param reason The reason for rejecting the operation.
|
|
398
|
+
* @returns The rejected issue outcome.
|
|
399
|
+
*/
|
|
363
400
|
rejected(reason) {
|
|
364
401
|
return { kind: "rejected", reason };
|
|
365
402
|
},
|
|
403
|
+
/**
|
|
404
|
+
* Creates a rejected key-rotation result.
|
|
405
|
+
* @param reason The reason for rejecting the operation.
|
|
406
|
+
* @returns The rejected rotation outcome.
|
|
407
|
+
*/
|
|
366
408
|
rotation(reason) {
|
|
367
409
|
return { kind: "rejected", reason };
|
|
368
410
|
},
|
|
411
|
+
/**
|
|
412
|
+
* Copies and validates a P-256 private signing key.
|
|
413
|
+
* @param key The key material to copy and validate.
|
|
414
|
+
* @returns The copied private and public key pair.
|
|
415
|
+
*/
|
|
369
416
|
signing(key) {
|
|
370
417
|
const kid = SignedSessionValues.boundedString(key.kid, "kid");
|
|
371
418
|
if (key.privateKey.type !== "private" ||
|
|
@@ -383,6 +430,11 @@ const SignedSessionValues = Object.freeze({
|
|
|
383
430
|
const publicKey = createPublicKey(privateKey);
|
|
384
431
|
return { kid, privateKey, publicKey };
|
|
385
432
|
},
|
|
433
|
+
/**
|
|
434
|
+
* Copies and validates a P-256 public verification key.
|
|
435
|
+
* @param key The key material to copy and validate.
|
|
436
|
+
* @returns The copied public verification key.
|
|
437
|
+
*/
|
|
386
438
|
verification(key) {
|
|
387
439
|
const kid = SignedSessionValues.boundedString(key.kid, "kid");
|
|
388
440
|
if (key.publicKey.type !== "public" ||
|
|
@@ -397,41 +449,92 @@ const SignedSessionValues = Object.freeze({
|
|
|
397
449
|
der.fill(0);
|
|
398
450
|
}
|
|
399
451
|
},
|
|
452
|
+
/**
|
|
453
|
+
* Validates a positive safe integer limit.
|
|
454
|
+
* @param value The positive integer limit to validate.
|
|
455
|
+
* @param name The named setting in a validation error.
|
|
456
|
+
* @returns The validated positive limit.
|
|
457
|
+
*/
|
|
400
458
|
positive(value, name) {
|
|
401
459
|
if (!Number.isSafeInteger(value) || value <= 0)
|
|
402
460
|
throw new Error(`${name} must be a positive safe integer`);
|
|
403
461
|
return value;
|
|
404
462
|
},
|
|
463
|
+
/**
|
|
464
|
+
* Validates a non-negative safe integer limit.
|
|
465
|
+
* @param value The non-negative integer limit to validate.
|
|
466
|
+
* @param name The named setting in a validation error.
|
|
467
|
+
* @returns The validated non-negative limit.
|
|
468
|
+
*/
|
|
405
469
|
nonnegative(value, name) {
|
|
406
470
|
if (!Number.isSafeInteger(value) || value < 0)
|
|
407
471
|
throw new Error(`${name} must be a non-negative safe integer`);
|
|
408
472
|
return value;
|
|
409
473
|
},
|
|
474
|
+
/**
|
|
475
|
+
* Validates a non-empty bounded key or identity string.
|
|
476
|
+
* @param value The signing key or identity string to validate.
|
|
477
|
+
* @param name The named setting in a validation error.
|
|
478
|
+
* @returns The validated string.
|
|
479
|
+
*/
|
|
410
480
|
boundedString(value, name) {
|
|
411
481
|
if (typeof value !== "string" || value.length === 0 || value.length > 256)
|
|
412
482
|
throw new Error(`${name} must be a non-empty string of at most 256 characters`);
|
|
413
483
|
return value;
|
|
414
484
|
},
|
|
485
|
+
/**
|
|
486
|
+
* Checks the signing-key identifier length.
|
|
487
|
+
* @param value The signing-key identifier to check.
|
|
488
|
+
* @returns Whether the key identifier length is valid.
|
|
489
|
+
*/
|
|
415
490
|
validKid(value) {
|
|
416
491
|
return value.length > 0 && value.length <= 256;
|
|
417
492
|
},
|
|
493
|
+
/**
|
|
494
|
+
* Checks the URL-safe base64 alphabet and length.
|
|
495
|
+
* @param value The encoded string to check for URL-safe base64.
|
|
496
|
+
* @returns Whether the string is URL-safe base64.
|
|
497
|
+
*/
|
|
418
498
|
base64url(value) {
|
|
419
499
|
return value.length > 0 && /^[A-Za-z0-9_-]+$/.test(value) && value.length % 4 !== 1;
|
|
420
500
|
},
|
|
501
|
+
/**
|
|
502
|
+
* Encodes a JSON value as URL-safe base64.
|
|
503
|
+
* @param value The JSON value to encode.
|
|
504
|
+
* @returns The encoded JSON string.
|
|
505
|
+
*/
|
|
421
506
|
encode(value) {
|
|
422
507
|
return Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
423
508
|
},
|
|
509
|
+
/**
|
|
510
|
+
* Decodes bounded URL-safe base64 JSON.
|
|
511
|
+
* @param value The URL-safe base64 JSON string to decode.
|
|
512
|
+
* @returns The decoded JSON value.
|
|
513
|
+
*/
|
|
424
514
|
json(value) {
|
|
425
515
|
const decoded = Buffer.from(value, "base64url");
|
|
426
516
|
if (decoded.byteLength > 16_384)
|
|
427
517
|
throw new Error();
|
|
428
518
|
return JSON.parse(decoded.toString("utf8"));
|
|
429
519
|
},
|
|
520
|
+
/**
|
|
521
|
+
* Checks whether a value is a plain object.
|
|
522
|
+
* @param value The unknown value to test for plain-record shape.
|
|
523
|
+
* @returns Whether the value is a plain record.
|
|
524
|
+
*/
|
|
430
525
|
plain(value) {
|
|
431
526
|
return (typeof value === "object" &&
|
|
432
527
|
value !== null &&
|
|
433
528
|
Object.getPrototypeOf(value) === Object.prototype);
|
|
434
529
|
},
|
|
530
|
+
/**
|
|
531
|
+
* Copies a principal under identifier and attribute bounds.
|
|
532
|
+
* @param value The principal data to copy under configured bounds.
|
|
533
|
+
* @param maxId The maximum principal identifier length.
|
|
534
|
+
* @param maxAttributes The maximum attribute count.
|
|
535
|
+
* @param maxChars The maximum combined attribute characters.
|
|
536
|
+
* @returns The immutable principal, or undefined when bounds fail.
|
|
537
|
+
*/
|
|
435
538
|
principalCopy(value, maxId, maxAttributes, maxChars) {
|
|
436
539
|
if (typeof value.id !== "string" || value.id.length === 0 || value.id.length > maxId)
|
|
437
540
|
return undefined;
|
|
@@ -459,6 +562,19 @@ const SignedSessionValues = Object.freeze({
|
|
|
459
562
|
attributes: Object.freeze(Object.fromEntries(entries)),
|
|
460
563
|
});
|
|
461
564
|
},
|
|
565
|
+
/**
|
|
566
|
+
* Validates signed token claims, time limits, and principal bounds.
|
|
567
|
+
* @param value The decoded signed-token claims to validate.
|
|
568
|
+
* @param issuer The required token issuer.
|
|
569
|
+
* @param audience The required token audience.
|
|
570
|
+
* @param ttl The maximum token lifetime in seconds.
|
|
571
|
+
* @param skew The accepted clock skew in seconds.
|
|
572
|
+
* @param now The current epoch milliseconds.
|
|
573
|
+
* @param maxId The maximum principal identifier length.
|
|
574
|
+
* @param maxAttributes The maximum attribute count.
|
|
575
|
+
* @param maxChars The maximum combined attribute characters.
|
|
576
|
+
* @returns Validated claims, or undefined when verification fails.
|
|
577
|
+
*/
|
|
462
578
|
validClaims(value, issuer, audience, ttl, skew, now, maxId, maxAttributes, maxChars) {
|
|
463
579
|
if (!SignedSessionValues.plain(value) ||
|
|
464
580
|
Object.keys(value).some((key) => !["iss", "aud", "sub", "iat", "nbf", "exp", "jti", "attributes"].includes(key)))
|
|
@@ -495,9 +611,20 @@ const SignedSessionValues = Object.freeze({
|
|
|
495
611
|
...(principal.attributes === undefined ? {} : { attributes: principal.attributes }),
|
|
496
612
|
};
|
|
497
613
|
},
|
|
614
|
+
/**
|
|
615
|
+
* Creates a Protobuf timestamp from epoch seconds.
|
|
616
|
+
* @param seconds The timestamp seconds.
|
|
617
|
+
* @returns The Protobuf timestamp.
|
|
618
|
+
*/
|
|
498
619
|
timestamp(seconds) {
|
|
499
620
|
return create(TimestampSchema, { seconds: BigInt(seconds) });
|
|
500
621
|
},
|
|
622
|
+
/**
|
|
623
|
+
* Creates a resolved session with a detached principal.
|
|
624
|
+
* @param principal The principal to copy.
|
|
625
|
+
* @param seconds The timestamp seconds.
|
|
626
|
+
* @returns The detached resolved session.
|
|
627
|
+
*/
|
|
501
628
|
session(principal, seconds) {
|
|
502
629
|
const copied = SignedSessionValues.principalCopy(principal, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
|
|
503
630
|
if (copied === undefined)
|
|
@@ -507,19 +634,41 @@ const SignedSessionValues = Object.freeze({
|
|
|
507
634
|
expiresAt: SignedSessionValues.timestamp(seconds),
|
|
508
635
|
});
|
|
509
636
|
},
|
|
637
|
+
/**
|
|
638
|
+
* Checks whether epoch milliseconds fit a Protobuf timestamp.
|
|
639
|
+
* @param milliseconds The candidate epoch milliseconds.
|
|
640
|
+
* @returns Whether the instant is representable.
|
|
641
|
+
*/
|
|
510
642
|
timeValid(milliseconds) {
|
|
511
643
|
const seconds = Math.floor(milliseconds / 1000);
|
|
512
644
|
return seconds >= -62_135_596_800 && seconds <= 253_402_300_799;
|
|
513
645
|
},
|
|
646
|
+
/**
|
|
647
|
+
* Checks a token identifier against expected random encoding.
|
|
648
|
+
* @param value The token identifier to check.
|
|
649
|
+
* @returns Whether the token identifier has the expected shape.
|
|
650
|
+
*/
|
|
514
651
|
validJti(value) {
|
|
515
652
|
return value.length === 22 && SignedSessionValues.base64url(value);
|
|
516
653
|
},
|
|
654
|
+
/**
|
|
655
|
+
* Reads a safe signed-session clock value.
|
|
656
|
+
* @param clock The configured millisecond clock.
|
|
657
|
+
* @returns The validated epoch milliseconds.
|
|
658
|
+
*/
|
|
517
659
|
clockValue(clock) {
|
|
518
660
|
const value = clock.now();
|
|
519
661
|
if (!Number.isSafeInteger(value) || !SignedSessionValues.timeValid(value))
|
|
520
662
|
throw new Error("invalid clock");
|
|
521
663
|
return value;
|
|
522
664
|
},
|
|
665
|
+
/**
|
|
666
|
+
* Calculates when a retired signing key may be removed.
|
|
667
|
+
* @param now The current epoch milliseconds.
|
|
668
|
+
* @param ttl The maximum token lifetime in seconds.
|
|
669
|
+
* @param skew The accepted clock skew in seconds.
|
|
670
|
+
* @returns The safe retired-key deadline.
|
|
671
|
+
*/
|
|
523
672
|
retentionDeadline(now, ttl, skew) {
|
|
524
673
|
const seconds = ttl + skew;
|
|
525
674
|
const milliseconds = seconds * 1_000;
|