@wtfalch/auth 0.13.0 → 0.14.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.
- package/dist/namespace-session.js +49 -10
- package/package.json +1 -1
|
@@ -248,11 +248,30 @@ export function namespaceSessions(deps) {
|
|
|
248
248
|
.catch(() => { });
|
|
249
249
|
return stillValid ? leased : null;
|
|
250
250
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
251
|
+
let committed;
|
|
252
|
+
try {
|
|
253
|
+
committed = await store().advance(key, generation, {
|
|
254
|
+
payload: await seal(key, fresh),
|
|
255
|
+
expiresAt: now() + options().sessionMaxAge,
|
|
256
|
+
leaseUntil: null,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
// The commit itself threw (a store outage): the lease is still held.
|
|
261
|
+
// Best-effort release it, as the still-valid path above already does,
|
|
262
|
+
// so the session does not stay locked out for up to LEASE_SECONDS, and
|
|
263
|
+
// revoke a rotated refresh token that was never stored.
|
|
264
|
+
await store()
|
|
265
|
+
.advance(key, generation, {
|
|
266
|
+
payload: record.payload,
|
|
267
|
+
expiresAt: record.expiresAt,
|
|
268
|
+
leaseUntil: null,
|
|
269
|
+
})
|
|
270
|
+
.catch(() => { });
|
|
271
|
+
if (fresh.refreshToken !== tokens.rt)
|
|
272
|
+
revokeToken(fresh.refreshToken);
|
|
273
|
+
throw error;
|
|
274
|
+
}
|
|
256
275
|
if (!committed) {
|
|
257
276
|
// Revoked while we asked, or our lease ran out and another request took
|
|
258
277
|
// over. These tokens are kept nowhere, so they are not left live.
|
|
@@ -351,11 +370,31 @@ export function namespaceSessions(deps) {
|
|
|
351
370
|
// does for the same case.
|
|
352
371
|
throw error;
|
|
353
372
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
373
|
+
let committed;
|
|
374
|
+
try {
|
|
375
|
+
committed = await store().advance(key, generation, {
|
|
376
|
+
payload: await seal(key, fresh),
|
|
377
|
+
expiresAt: now() + options().sessionMaxAge,
|
|
378
|
+
leaseUntil: null,
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
// The commit itself threw (a store outage): the lease is still held.
|
|
383
|
+
// Best-effort release it, as the still-valid path in `refreshLeased`
|
|
384
|
+
// does, so the session does not stay locked out for up to
|
|
385
|
+
// LEASE_SECONDS, and revoke a rotated refresh token that was never
|
|
386
|
+
// stored.
|
|
387
|
+
await store()
|
|
388
|
+
.advance(key, generation, {
|
|
389
|
+
payload: record.payload,
|
|
390
|
+
expiresAt: record.expiresAt,
|
|
391
|
+
leaseUntil: null,
|
|
392
|
+
})
|
|
393
|
+
.catch(() => { });
|
|
394
|
+
if (fresh.refreshToken !== tokens.rt)
|
|
395
|
+
revokeToken(fresh.refreshToken);
|
|
396
|
+
throw error;
|
|
397
|
+
}
|
|
359
398
|
if (!committed) {
|
|
360
399
|
// Revoked while the grant was in flight, or the lease ran out and
|
|
361
400
|
// another request took over. The fresh tokens are kept nowhere, so
|
package/package.json
CHANGED