@softistx/janus 0.77.0 → 0.78.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/README.md +8 -3
- package/dist/auth/api-keys/authenticate-key.d.ts +3 -2
- package/dist/auth/api-keys/authenticate-key.d.ts.map +1 -1
- package/dist/auth/api-keys/count.d.ts.map +1 -1
- package/dist/auth/api-keys/create/after-insert.d.ts +11 -0
- package/dist/auth/api-keys/create/after-insert.d.ts.map +1 -0
- package/dist/auth/api-keys/create/checks.d.ts +17 -0
- package/dist/auth/api-keys/create/checks.d.ts.map +1 -1
- package/dist/auth/api-keys/create/index.d.ts.map +1 -1
- package/dist/auth/api-keys/create/service-checks.d.ts +25 -0
- package/dist/auth/api-keys/create/service-checks.d.ts.map +1 -0
- package/dist/auth/api-keys/create/service.d.ts +12 -0
- package/dist/auth/api-keys/create/service.d.ts.map +1 -0
- package/dist/auth/api-keys/expiry.d.ts.map +1 -1
- package/dist/auth/api-keys/flows.d.ts +6 -2
- package/dist/auth/api-keys/flows.d.ts.map +1 -1
- package/dist/auth/api-keys/owned.d.ts +12 -0
- package/dist/auth/api-keys/owned.d.ts.map +1 -0
- package/dist/auth/api-keys/read.d.ts.map +1 -1
- package/dist/auth/api-keys/service-flows.d.ts +13 -0
- package/dist/auth/api-keys/service-flows.d.ts.map +1 -0
- package/dist/auth/api-keys/to-api-key.d.ts.map +1 -1
- package/dist/auth/config/api-keys-config.d.ts +29 -2
- package/dist/auth/config/api-keys-config.d.ts.map +1 -1
- package/dist/auth/config/index.d.ts +1 -1
- package/dist/auth/config/index.d.ts.map +1 -1
- package/dist/auth/config/resolve-api-keys.d.ts.map +1 -1
- package/dist/auth/config/resolved-config.d.ts +8 -0
- package/dist/auth/config/resolved-config.d.ts.map +1 -1
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/port/memory/api-keys/capabilities.d.ts.map +1 -1
- package/dist/auth/port/memory/api-keys/index.d.ts.map +1 -1
- package/dist/auth/port/types/api-keys.d.ts +25 -5
- package/dist/auth/port/types/api-keys.d.ts.map +1 -1
- package/dist/auth/sessions/authenticate.d.ts +3 -2
- package/dist/auth/sessions/authenticate.d.ts.map +1 -1
- package/dist/auth/sessions/fresh.d.ts +2 -2
- package/dist/auth/sessions/fresh.d.ts.map +1 -1
- package/dist/auth/sessions/shared-api.d.ts +3 -2
- package/dist/auth/sessions/shared-api.d.ts.map +1 -1
- package/dist/auth/shared-api.d.ts +11 -3
- package/dist/auth/shared-api.d.ts.map +1 -1
- package/dist/auth/signed-token.d.ts +41 -0
- package/dist/auth/signed-token.d.ts.map +1 -0
- package/dist/auth/types/api-keys-of.d.ts +6 -1
- package/dist/auth/types/api-keys-of.d.ts.map +1 -1
- package/dist/auth/types/api-keys.d.ts +18 -6
- package/dist/auth/types/api-keys.d.ts.map +1 -1
- package/dist/auth/types/checks.d.ts +17 -1
- package/dist/auth/types/checks.d.ts.map +1 -1
- package/dist/auth/types/index.d.ts +3 -2
- package/dist/auth/types/index.d.ts.map +1 -1
- package/dist/auth/types/service-keys.d.ts +58 -0
- package/dist/auth/types/service-keys.d.ts.map +1 -0
- package/dist/auth/types/session.d.ts +21 -2
- package/dist/auth/types/session.d.ts.map +1 -1
- package/dist/auth/types/shared-api.d.ts +15 -1
- package/dist/auth/types/shared-api.d.ts.map +1 -1
- package/dist/chunks/{index-7h34nqrm.js → index-5hcajrrx.js} +5 -5
- package/dist/chunks/{index-7h34nqrm.js.map → index-5hcajrrx.js.map} +4 -4
- package/dist/chunks/{index-n8jxmxeg.js → index-gzc472ar.js} +2 -2
- package/dist/chunks/{index-ftz0ne6j.js → index-r8fcessc.js} +2 -2
- package/dist/chunks/{index-2ttdcz7n.js → index-vx9a5cpy.js} +9 -3
- package/dist/chunks/{index-2ttdcz7n.js.map → index-vx9a5cpy.js.map} +4 -4
- package/dist/conformance/api-keys/cases/index.d.ts.map +1 -1
- package/dist/conformance/api-keys/cases/outage.d.ts.map +1 -1
- package/dist/conformance/api-keys/cases/service.d.ts +3 -0
- package/dist/conformance/api-keys/cases/service.d.ts.map +1 -0
- package/dist/conformance/index.js +407 -302
- package/dist/conformance/index.js.map +6 -5
- package/dist/errors/janus-error/codes.invitations.d.ts +6 -0
- package/dist/errors/janus-error/codes.invitations.d.ts.map +1 -1
- package/dist/errors/janus-error/index.d.ts +1 -1
- package/dist/errors/janus-error/index.d.ts.map +1 -1
- package/dist/errors/janus-error/options.d.ts +1 -1
- package/dist/errors/janus-error/options.d.ts.map +1 -1
- package/dist/errors/janus-error/refusals.d.ts +5 -0
- package/dist/errors/janus-error/refusals.d.ts.map +1 -1
- package/dist/errors/janus-error/status.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +427 -99
- package/dist/index.js.map +21 -15
- package/dist/permissions/index.js +3 -3
- package/docs/README.md +1 -0
- package/docs/guide/api-keys.md +78 -1
- package/docs/guide/errors.md +1 -0
- package/docs/guide/signed-tokens.md +46 -0
- package/docs/roadmap.md +2 -0
- package/docs/troubleshooting.md +12 -0
- package/package.json +1 -1
- /package/dist/chunks/{index-n8jxmxeg.js.map → index-gzc472ar.js.map} +0 -0
- /package/dist/chunks/{index-ftz0ne6j.js.map → index-r8fcessc.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createMemoryApiKeys2,
|
|
4
4
|
createMemoryInvitations2,
|
|
5
5
|
createMemoryStores2
|
|
6
|
-
} from "../chunks/index-
|
|
6
|
+
} from "../chunks/index-5hcajrrx.js";
|
|
7
7
|
import {
|
|
8
8
|
JanusError2,
|
|
9
9
|
InvalidCursorError2,
|
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
StoreConflict2,
|
|
12
12
|
NotFoundError2,
|
|
13
13
|
formatSubject2
|
|
14
|
-
} from "../chunks/index-
|
|
14
|
+
} from "../chunks/index-vx9a5cpy.js";
|
|
15
15
|
import {
|
|
16
16
|
holderCursor2,
|
|
17
17
|
createMemoryRelations2
|
|
18
|
-
} from "../chunks/index-
|
|
18
|
+
} from "../chunks/index-r8fcessc.js";
|
|
19
19
|
|
|
20
20
|
// src/conformance/assert.ts
|
|
21
21
|
function equal(actual, expected, what) {
|
|
@@ -465,67 +465,169 @@ var apiKeyRevokeCases = [
|
|
|
465
465
|
}
|
|
466
466
|
];
|
|
467
467
|
|
|
468
|
-
// src/conformance/api-keys/cases/
|
|
468
|
+
// src/conformance/api-keys/cases/service.ts
|
|
469
469
|
var group5 = "apiKeys";
|
|
470
470
|
var at5 = (iso) => new Date(iso);
|
|
471
|
+
var owner = { type: "account", id: "a1" };
|
|
472
|
+
var service = (overrides = {}) => apiKey({
|
|
473
|
+
userId: null,
|
|
474
|
+
expiresAt: null,
|
|
475
|
+
scopes: ["mail:send"],
|
|
476
|
+
bound: owner,
|
|
477
|
+
details: { domains: ["example.org"] },
|
|
478
|
+
...overrides
|
|
479
|
+
});
|
|
480
|
+
var bound2 = (store) => store;
|
|
481
|
+
var apiKeyServiceCases = [
|
|
482
|
+
{
|
|
483
|
+
id: "apiKeys.service.insert",
|
|
484
|
+
group: group5,
|
|
485
|
+
needs: "bound",
|
|
486
|
+
name: "a service key (no user, no expiry, scopes, owner and details) is answered verbatim",
|
|
487
|
+
async run({ store }) {
|
|
488
|
+
const key = service();
|
|
489
|
+
await store.insertApiKey(key);
|
|
490
|
+
equal(await store.findApiKey(key.id), key, "findApiKey: userId and expiresAt are null, details as written");
|
|
491
|
+
const lapsing = service({ expiresAt: at5("2027-01-01T00:00:00.000Z") });
|
|
492
|
+
await store.insertApiKey(lapsing);
|
|
493
|
+
equal(await store.findApiKey(lapsing.id), lapsing, "findApiKey: a service key with an expiry keeps it");
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
id: "apiKeys.service.list",
|
|
498
|
+
group: group5,
|
|
499
|
+
needs: "bound",
|
|
500
|
+
name: "a service key is listed with its owner, and in no user listing",
|
|
501
|
+
async run({ store }) {
|
|
502
|
+
const s = bound2(store);
|
|
503
|
+
const user = mintId2();
|
|
504
|
+
const held = apiKey({ userId: user, bound: owner });
|
|
505
|
+
const key = service();
|
|
506
|
+
await store.insertApiKey(held);
|
|
507
|
+
await store.insertApiKey(key);
|
|
508
|
+
const page = await s.listBoundApiKeys(owner, { first: 10, after: null });
|
|
509
|
+
equal(page.items.map((item) => item.id).sort(), [held.id, key.id].sort(), "listBoundApiKeys: the user key and the service key of the object");
|
|
510
|
+
const listed = await store.listUserApiKeys(user, {
|
|
511
|
+
first: 10,
|
|
512
|
+
after: null
|
|
513
|
+
});
|
|
514
|
+
equal(listed.items.map((item) => item.id), [held.id], "listUserApiKeys: only the user key");
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
id: "apiKeys.service.untouched",
|
|
519
|
+
group: group5,
|
|
520
|
+
needs: "bound",
|
|
521
|
+
name: "revoking or deleting a user’s keys, or the expired ones, leaves a service key standing",
|
|
522
|
+
async run({ store }) {
|
|
523
|
+
const user = mintId2();
|
|
524
|
+
const key = service();
|
|
525
|
+
await store.insertApiKey(key);
|
|
526
|
+
await store.insertApiKey(apiKey({ userId: user, bound: owner }));
|
|
527
|
+
const when = at5("2026-06-01T00:00:00.000Z");
|
|
528
|
+
await store.revokeUserApiKeys(user, when);
|
|
529
|
+
await bound2(store).revokeBoundApiKeys(user, owner, when);
|
|
530
|
+
await store.deleteUserApiKeys(user);
|
|
531
|
+
if (store.deleteExpiredApiKeys !== undefined) {
|
|
532
|
+
await store.deleteExpiredApiKeys(at5("2099-01-01T00:00:00.000Z"));
|
|
533
|
+
}
|
|
534
|
+
equal(await store.findApiKey(key.id), key, "findApiKey: the service key is as inserted, never revoked nor deleted");
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
id: "apiKeys.service.never-expiring",
|
|
539
|
+
group: group5,
|
|
540
|
+
needs: ["bound", "expiryNotice"],
|
|
541
|
+
name: "a never-expiring service key is never listed as expiring",
|
|
542
|
+
async run({ store }) {
|
|
543
|
+
const key = service();
|
|
544
|
+
await store.insertApiKey(key);
|
|
545
|
+
const s = store;
|
|
546
|
+
const page = await s.listExpiringApiKeys({
|
|
547
|
+
now: at5("2026-06-01T00:00:00.000Z"),
|
|
548
|
+
before: at5("2099-01-01T00:00:00.000Z"),
|
|
549
|
+
first: 10,
|
|
550
|
+
after: null
|
|
551
|
+
});
|
|
552
|
+
equal(page.items.length, 0, "listExpiringApiKeys: nothing");
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
id: "apiKeys.service.revoke",
|
|
557
|
+
group: group5,
|
|
558
|
+
needs: "bound",
|
|
559
|
+
name: "a service key is revoked by id, keeping its first revokedAt",
|
|
560
|
+
async run({ store }) {
|
|
561
|
+
const key = service();
|
|
562
|
+
await store.insertApiKey(key);
|
|
563
|
+
equal(await store.revokeApiKey(key.id, at5("2026-03-01T00:00:00.000Z")), true, "revokeApiKey: true");
|
|
564
|
+
await store.revokeApiKey(key.id, at5("2026-04-01T00:00:00.000Z"));
|
|
565
|
+
equal((await store.findApiKey(key.id))?.revokedAt, at5("2026-03-01T00:00:00.000Z"), "findApiKey: the first revokedAt");
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
];
|
|
569
|
+
|
|
570
|
+
// src/conformance/api-keys/cases/touch.ts
|
|
571
|
+
var group6 = "apiKeys";
|
|
572
|
+
var at6 = (iso) => new Date(iso);
|
|
471
573
|
var apiKeyTouchCases = [
|
|
472
574
|
{
|
|
473
575
|
id: "apiKeys.touch",
|
|
474
|
-
group:
|
|
576
|
+
group: group6,
|
|
475
577
|
name: "touchApiKey writes lastUsedAt only for a key never used or used before staleBefore, and answers whether it wrote",
|
|
476
578
|
async run({ store }) {
|
|
477
579
|
const key = apiKey();
|
|
478
580
|
await store.insertApiKey(key);
|
|
479
|
-
const t1 =
|
|
480
|
-
const t2 =
|
|
481
|
-
const t3 =
|
|
482
|
-
equal(await store.touchApiKey(key.id, t1,
|
|
581
|
+
const t1 = at6("2026-04-01T12:00:00.000Z");
|
|
582
|
+
const t2 = at6("2026-04-01T12:30:00.000Z");
|
|
583
|
+
const t3 = at6("2026-04-01T13:30:00.000Z");
|
|
584
|
+
equal(await store.touchApiKey(key.id, t1, at6("2026-04-01T11:00:00.000Z")), true, "touchApiKey: a key never used is written");
|
|
483
585
|
equal((await store.findApiKey(key.id))?.lastUsedAt, t1, "touchApiKey: lastUsedAt is the instant given");
|
|
484
|
-
equal(await store.touchApiKey(key.id, t2,
|
|
586
|
+
equal(await store.touchApiKey(key.id, t2, at6("2026-04-01T11:30:00.000Z")), false, "touchApiKey: a key used at or after staleBefore is left alone");
|
|
485
587
|
equal((await store.findApiKey(key.id))?.lastUsedAt, t1, "touchApiKey: a refused touch changes nothing");
|
|
486
|
-
equal(await store.touchApiKey(key.id, t3,
|
|
487
|
-
equal(await store.touchApiKey(key.id,
|
|
588
|
+
equal(await store.touchApiKey(key.id, t3, at6("2026-04-01T12:30:00.000Z")), true, "touchApiKey: a key last used before staleBefore is written");
|
|
589
|
+
equal(await store.touchApiKey(key.id, at6("2026-04-01T14:00:00.000Z"), t3), false, "touchApiKey: a key last used exactly at staleBefore is left alone");
|
|
488
590
|
equal((await store.findApiKey(key.id))?.lastUsedAt, t3, "touchApiKey: a key used exactly at staleBefore keeps its lastUsedAt");
|
|
489
591
|
equal(await store.touchApiKey(mintId2(), t3, t3), false, "touchApiKey: an unknown key is false, not a failure");
|
|
490
592
|
}
|
|
491
593
|
},
|
|
492
594
|
{
|
|
493
595
|
id: "apiKeys.touch.concurrent",
|
|
494
|
-
group:
|
|
596
|
+
group: group6,
|
|
495
597
|
name: "touchApiKey: of concurrent calls on a stale key exactly one answers true",
|
|
496
598
|
async run({ store }) {
|
|
497
599
|
const key = apiKey();
|
|
498
600
|
await store.insertApiKey(key);
|
|
499
|
-
const at1 =
|
|
500
|
-
const stale =
|
|
601
|
+
const at1 = at6("2026-04-01T12:00:00.000Z");
|
|
602
|
+
const stale = at6("2026-04-01T11:00:00.000Z");
|
|
501
603
|
const results = await Promise.all(Array.from({ length: 10 }, () => store.touchApiKey(key.id, at1, stale)));
|
|
502
604
|
equal(results.filter(Boolean).length, 1, "touchApiKey: exactly one of ten concurrent calls should have written");
|
|
503
605
|
}
|
|
504
606
|
},
|
|
505
607
|
{
|
|
506
608
|
id: "apiKeys.touch.revoked",
|
|
507
|
-
group:
|
|
609
|
+
group: group6,
|
|
508
610
|
name: "touchApiKey never writes a revoked key",
|
|
509
611
|
async run({ store }) {
|
|
510
612
|
const key = apiKey();
|
|
511
613
|
await store.insertApiKey(key);
|
|
512
|
-
await store.revokeApiKey(key.id,
|
|
513
|
-
equal(await store.touchApiKey(key.id,
|
|
614
|
+
await store.revokeApiKey(key.id, at6("2026-04-01T00:00:00.000Z"));
|
|
615
|
+
equal(await store.touchApiKey(key.id, at6("2026-04-02T00:00:00.000Z"), at6("2026-04-03T00:00:00.000Z")), false, "touchApiKey: a revoked key is false");
|
|
514
616
|
equal((await store.findApiKey(key.id))?.lastUsedAt, null, "touchApiKey: a revoked key stays unused");
|
|
515
617
|
}
|
|
516
618
|
}
|
|
517
619
|
];
|
|
518
620
|
|
|
519
621
|
// src/conformance/api-keys/cases/user-bound.ts
|
|
520
|
-
var
|
|
622
|
+
var group7 = "apiKeys";
|
|
521
623
|
var needs3 = ["bound", "userBound"];
|
|
522
|
-
var
|
|
624
|
+
var at7 = (iso) => new Date(iso);
|
|
523
625
|
var userBound = (store) => store;
|
|
524
626
|
var workspace2 = (id) => ({ type: "workspace", id });
|
|
525
627
|
var apiKeyUserBoundCases = [
|
|
526
628
|
{
|
|
527
629
|
id: "apiKeys.userBound.list",
|
|
528
|
-
group:
|
|
630
|
+
group: group7,
|
|
529
631
|
needs: needs3,
|
|
530
632
|
name: "listUserBoundApiKeys pages one user’s keys bound to one object in id order, whatever their state",
|
|
531
633
|
async run({ store }) {
|
|
@@ -537,10 +639,10 @@ var apiKeyUserBoundCases = [
|
|
|
537
639
|
id: a,
|
|
538
640
|
userId,
|
|
539
641
|
bound: workspace2("w1"),
|
|
540
|
-
expiresAt:
|
|
642
|
+
expiresAt: at7("2020-01-01T00:00:00.000Z")
|
|
541
643
|
}));
|
|
542
644
|
await store.insertApiKey(apiKey({ id: b, userId, bound: workspace2("w1") }));
|
|
543
|
-
await store.revokeApiKey(b,
|
|
645
|
+
await store.revokeApiKey(b, at7("2026-03-01T00:00:00.000Z"));
|
|
544
646
|
await store.insertApiKey(apiKey({ userId, bound: workspace2("w2") }));
|
|
545
647
|
await store.insertApiKey(apiKey({ userId, bound: { type: "account", id: "w1" } }));
|
|
546
648
|
await store.insertApiKey(apiKey({ userId }));
|
|
@@ -561,7 +663,7 @@ var apiKeyUserBoundCases = [
|
|
|
561
663
|
},
|
|
562
664
|
{
|
|
563
665
|
id: "apiKeys.userBound.unbound",
|
|
564
|
-
group:
|
|
666
|
+
group: group7,
|
|
565
667
|
needs: needs3,
|
|
566
668
|
name: "listUserBoundApiKeys with null pages only the user’s unbound keys",
|
|
567
669
|
async run({ store }) {
|
|
@@ -588,7 +690,7 @@ var apiKeyUserBoundCases = [
|
|
|
588
690
|
},
|
|
589
691
|
{
|
|
590
692
|
id: "apiKeys.userBound.none",
|
|
591
|
-
group:
|
|
693
|
+
group: group7,
|
|
592
694
|
needs: needs3,
|
|
593
695
|
name: "listUserBoundApiKeys answers an empty page, never null, for nothing bound and for an unknown cursor",
|
|
594
696
|
async run({ store }) {
|
|
@@ -625,10 +727,13 @@ var apiKeyStoreCases = [
|
|
|
625
727
|
...apiKeyRevokeCases,
|
|
626
728
|
...apiKeyBoundCases,
|
|
627
729
|
...apiKeyUserBoundCases,
|
|
730
|
+
...apiKeyServiceCases,
|
|
628
731
|
...apiKeyExpiryCases
|
|
629
732
|
];
|
|
630
733
|
// src/conformance/api-keys/cases/outage.ts
|
|
631
|
-
var seeded = apiKey({
|
|
734
|
+
var seeded = apiKey({
|
|
735
|
+
id: "00000000-0000-7000-8000-000000000001"
|
|
736
|
+
});
|
|
632
737
|
var boundTo = { type: "workspace", id: "w1" };
|
|
633
738
|
var seededBound = { ...seeded, bound: boundTo };
|
|
634
739
|
var when = new Date("2026-09-01T00:00:00.000Z");
|
|
@@ -690,7 +795,7 @@ function present(method) {
|
|
|
690
795
|
return method;
|
|
691
796
|
}
|
|
692
797
|
// src/conformance/fixtures.ts
|
|
693
|
-
var
|
|
798
|
+
var at8 = (iso) => new Date(iso);
|
|
694
799
|
var fresh = () => `user-${mintId2()}@example.test`;
|
|
695
800
|
function userRecord(overrides = {}) {
|
|
696
801
|
const email = fresh();
|
|
@@ -703,14 +808,14 @@ function userRecord(overrides = {}) {
|
|
|
703
808
|
logins: [email],
|
|
704
809
|
password: {
|
|
705
810
|
hash: "$scrypt$ln=17,r=8,p=1$c2FsdA==$a2V5",
|
|
706
|
-
updatedAt:
|
|
811
|
+
updatedAt: at8("2026-01-01T00:00:00.000Z")
|
|
707
812
|
},
|
|
708
813
|
secondFactor: null,
|
|
709
814
|
avatar: null,
|
|
710
815
|
emailVerifiedAt: null,
|
|
711
816
|
version: 0,
|
|
712
|
-
createdAt:
|
|
713
|
-
updatedAt:
|
|
817
|
+
createdAt: at8("2026-01-01T00:00:00.000Z"),
|
|
818
|
+
updatedAt: at8("2026-01-01T00:00:00.000Z"),
|
|
714
819
|
...overrides
|
|
715
820
|
};
|
|
716
821
|
}
|
|
@@ -719,10 +824,10 @@ function sessionRecord(overrides = {}) {
|
|
|
719
824
|
id: mintId2(),
|
|
720
825
|
tokenHash: hexOf(mintId2()),
|
|
721
826
|
userId: mintId2(),
|
|
722
|
-
authenticatedAt:
|
|
723
|
-
expiresAt:
|
|
827
|
+
authenticatedAt: at8("2026-01-01T00:00:00.000Z"),
|
|
828
|
+
expiresAt: at8("2099-01-01T00:00:00.000Z"),
|
|
724
829
|
revokedAt: null,
|
|
725
|
-
createdAt:
|
|
830
|
+
createdAt: at8("2026-01-01T00:00:00.000Z"),
|
|
726
831
|
...overrides
|
|
727
832
|
};
|
|
728
833
|
}
|
|
@@ -734,9 +839,9 @@ function tokenRecord(overrides = {}) {
|
|
|
734
839
|
address: fresh(),
|
|
735
840
|
codeHash: null,
|
|
736
841
|
attempts: 0,
|
|
737
|
-
expiresAt:
|
|
842
|
+
expiresAt: at8("2099-01-01T00:00:00.000Z"),
|
|
738
843
|
spentAt: null,
|
|
739
|
-
createdAt:
|
|
844
|
+
createdAt: at8("2026-01-01T00:00:00.000Z"),
|
|
740
845
|
...overrides
|
|
741
846
|
};
|
|
742
847
|
}
|
|
@@ -746,7 +851,7 @@ function socialLinkRecord(overrides = {}) {
|
|
|
746
851
|
accountId: `acct-${mintId2()}`,
|
|
747
852
|
userId: mintId2(),
|
|
748
853
|
email: fresh(),
|
|
749
|
-
createdAt:
|
|
854
|
+
createdAt: at8("2026-01-01T00:00:00.000Z"),
|
|
750
855
|
...overrides
|
|
751
856
|
};
|
|
752
857
|
}
|
|
@@ -767,7 +872,7 @@ function passkeyRecord(overrides = {}) {
|
|
|
767
872
|
backupEligible: true,
|
|
768
873
|
backedUp: false,
|
|
769
874
|
name: "Laptop",
|
|
770
|
-
createdAt:
|
|
875
|
+
createdAt: at8("2026-01-01T00:00:00.000Z"),
|
|
771
876
|
lastUsedAt: null,
|
|
772
877
|
...overrides
|
|
773
878
|
};
|
|
@@ -825,7 +930,7 @@ var user = userRecord();
|
|
|
825
930
|
var session = sessionRecord({ userId: user.id });
|
|
826
931
|
var token = tokenRecord({ userId: user.id });
|
|
827
932
|
var link = socialLinkRecord({ userId: user.id });
|
|
828
|
-
var now2 =
|
|
933
|
+
var now2 = at8("2026-02-01T00:00:00.000Z");
|
|
829
934
|
var seed = async ({ stores }) => {
|
|
830
935
|
await stores.users.insertUser(user);
|
|
831
936
|
await stores.sessions.insertSession(session);
|
|
@@ -848,7 +953,7 @@ var outageCases = [
|
|
|
848
953
|
outage2("users", "listUsers", ({ stores }) => stores.users.listUsers({ type: user.type, after: null, limit: 10 }), seed),
|
|
849
954
|
outage2("users", "countUsers", ({ stores }) => stores.users.countUsers({ type: user.type }), seed),
|
|
850
955
|
outage2("sessions", "findSessionByTokenHash", ({ stores }) => stores.sessions.findSessionByTokenHash(session.tokenHash), seed),
|
|
851
|
-
outage2("sessions", "extendSession", ({ stores }) => stores.sessions.extendSession(session.id,
|
|
956
|
+
outage2("sessions", "extendSession", ({ stores }) => stores.sessions.extendSession(session.id, at8("2099-06-01T00:00:00.000Z")), seed),
|
|
852
957
|
outage2("sessions", "reauthenticateSession", ({ stores }) => stores.sessions.reauthenticateSession(session.id, now2), seed),
|
|
853
958
|
outage2("sessions", "revokeSession", ({ stores }) => stores.sessions.revokeSession(session.id, now2), seed),
|
|
854
959
|
outage2("sessions", "revokeUserSessions", ({ stores }) => stores.sessions.revokeUserSessions(user.id, now2), seed),
|
|
@@ -871,12 +976,12 @@ var outageCases = [
|
|
|
871
976
|
];
|
|
872
977
|
|
|
873
978
|
// src/conformance/cases/passkeys/deletion.ts
|
|
874
|
-
var
|
|
979
|
+
var group8 = "passkeys";
|
|
875
980
|
var needs4 = "passkeys";
|
|
876
981
|
var passkeyDeletionCases = [
|
|
877
982
|
{
|
|
878
983
|
id: "passkeys.renameOwner",
|
|
879
|
-
group:
|
|
984
|
+
group: group8,
|
|
880
985
|
needs: needs4,
|
|
881
986
|
name: "renames a passkey only for its owner: true and the name changed, false for another user or an unknown credential",
|
|
882
987
|
async run({ stores }) {
|
|
@@ -893,7 +998,7 @@ var passkeyDeletionCases = [
|
|
|
893
998
|
},
|
|
894
999
|
{
|
|
895
1000
|
id: "passkeys.deleteOwner",
|
|
896
|
-
group:
|
|
1001
|
+
group: group8,
|
|
897
1002
|
needs: needs4,
|
|
898
1003
|
name: "deletes a passkey only for its owner: a wrong owner is false and keeps it, a repeat is false",
|
|
899
1004
|
async run({ stores }) {
|
|
@@ -911,7 +1016,7 @@ var passkeyDeletionCases = [
|
|
|
911
1016
|
},
|
|
912
1017
|
{
|
|
913
1018
|
id: "passkeys.deleteUser",
|
|
914
|
-
group:
|
|
1019
|
+
group: group8,
|
|
915
1020
|
needs: needs4,
|
|
916
1021
|
name: "deletes every passkey of one user and counts them, 0 for a user with none, and leaves other users’ passkeys",
|
|
917
1022
|
async run({ stores }) {
|
|
@@ -937,12 +1042,12 @@ var passkeyDeletionCases = [
|
|
|
937
1042
|
];
|
|
938
1043
|
|
|
939
1044
|
// src/conformance/cases/passkeys/inserts.ts
|
|
940
|
-
var
|
|
1045
|
+
var group9 = "passkeys";
|
|
941
1046
|
var needs5 = "passkeys";
|
|
942
1047
|
var passkeyInsertCases = [
|
|
943
1048
|
{
|
|
944
1049
|
id: "passkeys.insertIdempotent",
|
|
945
|
-
group:
|
|
1050
|
+
group: group9,
|
|
946
1051
|
needs: needs5,
|
|
947
1052
|
name: "answers the stored record when the same user inserts the same credential again, and writes nothing",
|
|
948
1053
|
async run({ stores }) {
|
|
@@ -956,7 +1061,7 @@ var passkeyInsertCases = [
|
|
|
956
1061
|
},
|
|
957
1062
|
{
|
|
958
1063
|
id: "passkeys.insertTaken",
|
|
959
|
-
group:
|
|
1064
|
+
group: group9,
|
|
960
1065
|
needs: needs5,
|
|
961
1066
|
name: "answers the holder’s record, and writes nothing, when another user inserts a held credential",
|
|
962
1067
|
async run({ stores }) {
|
|
@@ -974,7 +1079,7 @@ var passkeyInsertCases = [
|
|
|
974
1079
|
},
|
|
975
1080
|
{
|
|
976
1081
|
id: "passkeys.insertConcurrent",
|
|
977
|
-
group:
|
|
1082
|
+
group: group9,
|
|
978
1083
|
needs: needs5,
|
|
979
1084
|
name: "stores one record when twenty users insert one credential at once, and answers all of them that record",
|
|
980
1085
|
async run({ stores }) {
|
|
@@ -1000,12 +1105,12 @@ var passkeyInsertCases = [
|
|
|
1000
1105
|
];
|
|
1001
1106
|
|
|
1002
1107
|
// src/conformance/cases/passkeys/reads.ts
|
|
1003
|
-
var
|
|
1108
|
+
var group10 = "passkeys";
|
|
1004
1109
|
var needs6 = "passkeys";
|
|
1005
1110
|
var passkeyReadCases = [
|
|
1006
1111
|
{
|
|
1007
1112
|
id: "passkeys.findVerbatim",
|
|
1008
|
-
group:
|
|
1113
|
+
group: group10,
|
|
1009
1114
|
needs: needs6,
|
|
1010
1115
|
name: "answers a stored passkey verbatim by its credential id, and null for an unknown one",
|
|
1011
1116
|
async run({ stores }) {
|
|
@@ -1022,7 +1127,7 @@ var passkeyReadCases = [
|
|
|
1022
1127
|
},
|
|
1023
1128
|
{
|
|
1024
1129
|
id: "passkeys.bytesRoundTrip",
|
|
1025
|
-
group:
|
|
1130
|
+
group: group10,
|
|
1026
1131
|
needs: needs6,
|
|
1027
1132
|
name: "round-trips the public key byte for byte, and compares credential ids case-sensitively",
|
|
1028
1133
|
async run({ stores }) {
|
|
@@ -1052,7 +1157,7 @@ var passkeyReadCases = [
|
|
|
1052
1157
|
},
|
|
1053
1158
|
{
|
|
1054
1159
|
id: "passkeys.listIsolation",
|
|
1055
|
-
group:
|
|
1160
|
+
group: group10,
|
|
1056
1161
|
needs: needs6,
|
|
1057
1162
|
name: "lists one user’s passkeys and only theirs, and an empty list — never null — for a user with none",
|
|
1058
1163
|
async run({ stores }) {
|
|
@@ -1074,13 +1179,13 @@ var passkeyReadCases = [
|
|
|
1074
1179
|
];
|
|
1075
1180
|
|
|
1076
1181
|
// src/conformance/cases/passkeys/uses.ts
|
|
1077
|
-
var
|
|
1182
|
+
var group11 = "passkeys";
|
|
1078
1183
|
var needs7 = "passkeys";
|
|
1079
1184
|
var usedAt = new Date("2026-03-01T08:09:10.111Z");
|
|
1080
1185
|
var passkeyUseCases = [
|
|
1081
1186
|
{
|
|
1082
1187
|
id: "passkeys.useConditional",
|
|
1083
|
-
group:
|
|
1188
|
+
group: group11,
|
|
1084
1189
|
needs: needs7,
|
|
1085
1190
|
name: "records a use only if the counter is still ifCounter: the updated record is answered, a stale counter is null and writes nothing",
|
|
1086
1191
|
async run({ stores }) {
|
|
@@ -1103,7 +1208,7 @@ var passkeyUseCases = [
|
|
|
1103
1208
|
},
|
|
1104
1209
|
{
|
|
1105
1210
|
id: "passkeys.useOwnerAndUnknown",
|
|
1106
|
-
group:
|
|
1211
|
+
group: group11,
|
|
1107
1212
|
needs: needs7,
|
|
1108
1213
|
name: "answers null, and writes nothing, for a use by another user or of an unknown credential",
|
|
1109
1214
|
async run({ stores }) {
|
|
@@ -1118,7 +1223,7 @@ var passkeyUseCases = [
|
|
|
1118
1223
|
},
|
|
1119
1224
|
{
|
|
1120
1225
|
id: "passkeys.useConcurrent",
|
|
1121
|
-
group:
|
|
1226
|
+
group: group11,
|
|
1122
1227
|
needs: needs7,
|
|
1123
1228
|
name: "lets one of twenty concurrent uses that read the same counter pass, and answers null to the others",
|
|
1124
1229
|
async run({ stores }) {
|
|
@@ -1147,21 +1252,21 @@ var passkeyStoreCases = [
|
|
|
1147
1252
|
];
|
|
1148
1253
|
|
|
1149
1254
|
// src/conformance/cases/sessions/deletion.ts
|
|
1150
|
-
var
|
|
1255
|
+
var group12 = "sessions";
|
|
1151
1256
|
var sessionDeletionCases = [
|
|
1152
1257
|
{
|
|
1153
1258
|
id: "sessions.deleteUser",
|
|
1154
|
-
group:
|
|
1259
|
+
group: group12,
|
|
1155
1260
|
name: "deletes every session of one user — standing, revoked or lapsed — and counts them",
|
|
1156
1261
|
async run({ stores }) {
|
|
1157
1262
|
const userId = mintId2();
|
|
1158
1263
|
const lapsed = sessionRecord({
|
|
1159
1264
|
userId,
|
|
1160
|
-
expiresAt:
|
|
1265
|
+
expiresAt: at8("2026-01-02T00:00:00.000Z")
|
|
1161
1266
|
});
|
|
1162
1267
|
const records = [
|
|
1163
1268
|
sessionRecord({ userId }),
|
|
1164
|
-
sessionRecord({ userId, revokedAt:
|
|
1269
|
+
sessionRecord({ userId, revokedAt: at8("2026-01-02T00:00:00.000Z") }),
|
|
1165
1270
|
lapsed
|
|
1166
1271
|
];
|
|
1167
1272
|
const stranger = sessionRecord();
|
|
@@ -1181,21 +1286,21 @@ var sessionDeletionCases = [
|
|
|
1181
1286
|
},
|
|
1182
1287
|
{
|
|
1183
1288
|
id: "sessions.deleteExpired",
|
|
1184
|
-
group:
|
|
1289
|
+
group: group12,
|
|
1185
1290
|
name: "deletes sessions whose expiry is at or before the instant, and only those",
|
|
1186
1291
|
needs: "deleteExpiredSessions",
|
|
1187
1292
|
async run({ stores }) {
|
|
1188
1293
|
const collect = stores.sessions.deleteExpiredSessions;
|
|
1189
1294
|
ok(collect !== undefined, "deleteExpiredSessions should be present");
|
|
1190
1295
|
const lapsed = sessionRecord({
|
|
1191
|
-
expiresAt:
|
|
1296
|
+
expiresAt: at8("2026-01-10T00:00:00.000Z")
|
|
1192
1297
|
});
|
|
1193
1298
|
const living = sessionRecord({
|
|
1194
|
-
expiresAt:
|
|
1299
|
+
expiresAt: at8("2026-01-10T00:00:00.001Z")
|
|
1195
1300
|
});
|
|
1196
1301
|
await stores.sessions.insertSession(lapsed);
|
|
1197
1302
|
await stores.sessions.insertSession(living);
|
|
1198
|
-
equal(await collect?.call(stores.sessions,
|
|
1303
|
+
equal(await collect?.call(stores.sessions, at8("2026-01-10T00:00:00.000Z")), 1, "deleteExpiredSessions: how many it deleted");
|
|
1199
1304
|
isNull(await stores.sessions.findSessionByTokenHash(lapsed.tokenHash), "findSessionByTokenHash after deleteExpiredSessions");
|
|
1200
1305
|
equal(await stores.sessions.findSessionByTokenHash(living.tokenHash), living, "deleteExpiredSessions should keep a session one millisecond short of lapsing");
|
|
1201
1306
|
}
|
|
@@ -1203,20 +1308,20 @@ var sessionDeletionCases = [
|
|
|
1203
1308
|
];
|
|
1204
1309
|
|
|
1205
1310
|
// src/conformance/cases/sessions/extension.ts
|
|
1206
|
-
var
|
|
1311
|
+
var group13 = "sessions";
|
|
1207
1312
|
var sessionExtensionCases = [
|
|
1208
1313
|
{
|
|
1209
1314
|
id: "sessions.extend",
|
|
1210
|
-
group:
|
|
1315
|
+
group: group13,
|
|
1211
1316
|
name: "extends a standing session, and never brings back a revoked one",
|
|
1212
1317
|
async run({ stores }) {
|
|
1213
1318
|
const standing = sessionRecord();
|
|
1214
1319
|
const revoked = sessionRecord({
|
|
1215
|
-
revokedAt:
|
|
1320
|
+
revokedAt: at8("2026-01-02T00:00:00.000Z")
|
|
1216
1321
|
});
|
|
1217
1322
|
await stores.sessions.insertSession(standing);
|
|
1218
1323
|
await stores.sessions.insertSession(revoked);
|
|
1219
|
-
const later =
|
|
1324
|
+
const later = at8("2099-06-01T00:00:00.000Z");
|
|
1220
1325
|
equal(await stores.sessions.extendSession(standing.id, later), { ...standing, expiresAt: later }, "extendSession should answer the session with its new expiresAt");
|
|
1221
1326
|
isNull(await stores.sessions.extendSession(revoked.id, later), "extendSession on a revoked session — an extension racing a revocation must never bring it back");
|
|
1222
1327
|
equal(await stores.sessions.findSessionByTokenHash(revoked.tokenHash), revoked, "extendSession refused on a revoked session should have written nothing");
|
|
@@ -1225,10 +1330,10 @@ var sessionExtensionCases = [
|
|
|
1225
1330
|
},
|
|
1226
1331
|
{
|
|
1227
1332
|
id: "sessions.extendLastUsed",
|
|
1228
|
-
group:
|
|
1333
|
+
group: group13,
|
|
1229
1334
|
name: "writes lastUsedAt with the extension when given, and keeps device and lastUsedAt otherwise",
|
|
1230
1335
|
async run({ stores }) {
|
|
1231
|
-
const first =
|
|
1336
|
+
const first = at8("2026-01-01T00:00:00.000Z");
|
|
1232
1337
|
const record = sessionRecord({
|
|
1233
1338
|
device: "Firefox on Linux",
|
|
1234
1339
|
lastUsedAt: first
|
|
@@ -1236,8 +1341,8 @@ var sessionExtensionCases = [
|
|
|
1236
1341
|
const old = sessionRecord();
|
|
1237
1342
|
await stores.sessions.insertSession(record);
|
|
1238
1343
|
await stores.sessions.insertSession(old);
|
|
1239
|
-
const later =
|
|
1240
|
-
const used =
|
|
1344
|
+
const later = at8("2099-06-01T00:00:00.000Z");
|
|
1345
|
+
const used = at8("2026-02-01T00:00:00.000Z");
|
|
1241
1346
|
equal(await stores.sessions.findSessionByTokenHash(record.tokenHash), record, "device and lastUsedAt should be stored and read back");
|
|
1242
1347
|
equal(await stores.sessions.extendSession(record.id, later), { ...record, expiresAt: later }, "extendSession without lastUsedAt should leave device and lastUsedAt as they were");
|
|
1243
1348
|
equal(await stores.sessions.extendSession(record.id, later, used), { ...record, expiresAt: later, lastUsedAt: used }, "extendSession with lastUsedAt should write it and keep device");
|
|
@@ -1247,11 +1352,11 @@ var sessionExtensionCases = [
|
|
|
1247
1352
|
];
|
|
1248
1353
|
|
|
1249
1354
|
// src/conformance/cases/sessions/inserts.ts
|
|
1250
|
-
var
|
|
1355
|
+
var group14 = "sessions";
|
|
1251
1356
|
var sessionInsertCases = [
|
|
1252
1357
|
{
|
|
1253
1358
|
id: "sessions.idempotentInsert",
|
|
1254
|
-
group:
|
|
1359
|
+
group: group14,
|
|
1255
1360
|
name: "is idempotent under retry: inserting an existing session id writes nothing",
|
|
1256
1361
|
async run({ stores }) {
|
|
1257
1362
|
const record = sessionRecord();
|
|
@@ -1266,11 +1371,11 @@ var sessionInsertCases = [
|
|
|
1266
1371
|
];
|
|
1267
1372
|
|
|
1268
1373
|
// src/conformance/cases/sessions/list.ts
|
|
1269
|
-
var
|
|
1374
|
+
var group15 = "sessions";
|
|
1270
1375
|
var sessionListCases = [
|
|
1271
1376
|
{
|
|
1272
1377
|
id: "sessions.listUser",
|
|
1273
|
-
group:
|
|
1378
|
+
group: group15,
|
|
1274
1379
|
name: "lists the standing sessions of one user: not revoked, not lapsed at the instant, not another user",
|
|
1275
1380
|
needs: "listUserSessions",
|
|
1276
1381
|
async run({ stores }) {
|
|
@@ -1282,46 +1387,46 @@ var sessionListCases = [
|
|
|
1282
1387
|
const standing = sessionRecord({
|
|
1283
1388
|
userId,
|
|
1284
1389
|
device: "Safari on iOS",
|
|
1285
|
-
lastUsedAt:
|
|
1390
|
+
lastUsedAt: at8("2026-01-05T00:00:00.000Z")
|
|
1286
1391
|
});
|
|
1287
1392
|
const plain = sessionRecord({ userId });
|
|
1288
1393
|
const revoked = sessionRecord({
|
|
1289
1394
|
userId,
|
|
1290
|
-
revokedAt:
|
|
1395
|
+
revokedAt: at8("2026-01-02T00:00:00.000Z")
|
|
1291
1396
|
});
|
|
1292
1397
|
const lapsed = sessionRecord({
|
|
1293
1398
|
userId,
|
|
1294
|
-
expiresAt:
|
|
1399
|
+
expiresAt: at8("2026-01-10T00:00:00.000Z")
|
|
1295
1400
|
});
|
|
1296
1401
|
const edge = sessionRecord({
|
|
1297
1402
|
userId,
|
|
1298
|
-
expiresAt:
|
|
1403
|
+
expiresAt: at8("2026-01-15T00:00:00.000Z")
|
|
1299
1404
|
});
|
|
1300
1405
|
const stranger = sessionRecord();
|
|
1301
1406
|
for (const record of [standing, plain, revoked, lapsed, edge, stranger]) {
|
|
1302
1407
|
await stores.sessions.insertSession(record);
|
|
1303
1408
|
}
|
|
1304
|
-
const listed = await list(userId,
|
|
1409
|
+
const listed = await list(userId, at8("2026-01-15T00:00:00.000Z"));
|
|
1305
1410
|
equal([...listed].sort((a, b) => a.id.localeCompare(b.id)), [standing, plain].sort((a, b) => a.id.localeCompare(b.id)), "listUserSessions: only the standing sessions of the user, records verbatim (an expiresAt equal to now has lapsed)");
|
|
1306
|
-
equal(await list(mintId2(),
|
|
1411
|
+
equal(await list(mintId2(), at8("2026-01-15T00:00:00.000Z")), [], "listUserSessions for a user with none answers [], not a failure");
|
|
1307
1412
|
}
|
|
1308
1413
|
}
|
|
1309
1414
|
];
|
|
1310
1415
|
|
|
1311
1416
|
// src/conformance/cases/sessions/reads.ts
|
|
1312
|
-
var
|
|
1417
|
+
var group16 = "sessions";
|
|
1313
1418
|
var sessionReadCases = [
|
|
1314
1419
|
{
|
|
1315
1420
|
id: "sessions.verbatim",
|
|
1316
|
-
group:
|
|
1421
|
+
group: group16,
|
|
1317
1422
|
name: "answers a stored session verbatim — revoked or lapsed — or null once lapsed, and never a changed record",
|
|
1318
1423
|
async run({ stores }) {
|
|
1319
1424
|
const standing = sessionRecord();
|
|
1320
1425
|
const revoked = sessionRecord({
|
|
1321
|
-
revokedAt:
|
|
1426
|
+
revokedAt: at8("2026-01-02T00:00:00.000Z")
|
|
1322
1427
|
});
|
|
1323
1428
|
const lapsed = sessionRecord({
|
|
1324
|
-
expiresAt:
|
|
1429
|
+
expiresAt: at8("2020-01-01T00:00:00.000Z")
|
|
1325
1430
|
});
|
|
1326
1431
|
for (const record of [standing, revoked, lapsed]) {
|
|
1327
1432
|
await stores.sessions.insertSession(record);
|
|
@@ -1338,20 +1443,20 @@ var sessionReadCases = [
|
|
|
1338
1443
|
];
|
|
1339
1444
|
|
|
1340
1445
|
// src/conformance/cases/sessions/reauthentication.ts
|
|
1341
|
-
var
|
|
1446
|
+
var group17 = "sessions";
|
|
1342
1447
|
var sessionReauthenticationCases = [
|
|
1343
1448
|
{
|
|
1344
1449
|
id: "sessions.reauthenticate",
|
|
1345
|
-
group:
|
|
1450
|
+
group: group17,
|
|
1346
1451
|
name: "moves authenticatedAt on a standing session, and never brings back a revoked one",
|
|
1347
1452
|
async run({ stores }) {
|
|
1348
1453
|
const standing = sessionRecord();
|
|
1349
1454
|
const revoked = sessionRecord({
|
|
1350
|
-
revokedAt:
|
|
1455
|
+
revokedAt: at8("2026-01-02T00:00:00.000Z")
|
|
1351
1456
|
});
|
|
1352
1457
|
await stores.sessions.insertSession(standing);
|
|
1353
1458
|
await stores.sessions.insertSession(revoked);
|
|
1354
|
-
const now =
|
|
1459
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1355
1460
|
equal(await stores.sessions.reauthenticateSession(standing.id, now), { ...standing, authenticatedAt: now }, "reauthenticateSession should answer the session with its new authenticatedAt, and every other field as it was");
|
|
1356
1461
|
equal(await stores.sessions.findSessionByTokenHash(standing.tokenHash), { ...standing, authenticatedAt: now }, "reauthenticateSession should have written authenticatedAt, and read back the same");
|
|
1357
1462
|
isNull(await stores.sessions.reauthenticateSession(revoked.id, now), "reauthenticateSession on a revoked session — a confirmation racing a revocation must never bring it back");
|
|
@@ -1361,13 +1466,13 @@ var sessionReauthenticationCases = [
|
|
|
1361
1466
|
},
|
|
1362
1467
|
{
|
|
1363
1468
|
id: "sessions.amr",
|
|
1364
|
-
group:
|
|
1469
|
+
group: group17,
|
|
1365
1470
|
name: "keeps the methods a session proved, and replaces them only when a step-up gives them",
|
|
1366
1471
|
async run({ stores }) {
|
|
1367
1472
|
const record = sessionRecord({ amr: ["hwk", "user"] });
|
|
1368
1473
|
await stores.sessions.insertSession(record);
|
|
1369
1474
|
equal((await stores.sessions.findSessionByTokenHash(record.tokenHash))?.amr, ["hwk", "user"], "insertSession should have written amr, and read it back in order");
|
|
1370
|
-
const now =
|
|
1475
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1371
1476
|
equal((await stores.sessions.reauthenticateSession(record.id, now))?.amr, ["hwk", "user"], "reauthenticateSession without amr should leave amr as it was");
|
|
1372
1477
|
equal((await stores.sessions.reauthenticateSession(record.id, now, [
|
|
1373
1478
|
"hwk",
|
|
@@ -1383,10 +1488,10 @@ var sessionReauthenticationCases = [
|
|
|
1383
1488
|
},
|
|
1384
1489
|
{
|
|
1385
1490
|
id: "sessions.reauthenticateRace",
|
|
1386
|
-
group:
|
|
1491
|
+
group: group17,
|
|
1387
1492
|
name: "never brings back a session whose revocation races its confirmation",
|
|
1388
1493
|
async run({ stores }) {
|
|
1389
|
-
const now =
|
|
1494
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1390
1495
|
for (let round = 0;round < 10; round += 1) {
|
|
1391
1496
|
const record = sessionRecord();
|
|
1392
1497
|
await stores.sessions.insertSession(record);
|
|
@@ -1401,25 +1506,25 @@ var sessionReauthenticationCases = [
|
|
|
1401
1506
|
];
|
|
1402
1507
|
|
|
1403
1508
|
// src/conformance/cases/sessions/revocation.ts
|
|
1404
|
-
var
|
|
1509
|
+
var group18 = "sessions";
|
|
1405
1510
|
var sessionRevocationCases = [
|
|
1406
1511
|
{
|
|
1407
1512
|
id: "sessions.revoke",
|
|
1408
|
-
group:
|
|
1513
|
+
group: group18,
|
|
1409
1514
|
name: "revokes once and keeps the first revokedAt; answers false only when there is no session",
|
|
1410
1515
|
async run({ stores }) {
|
|
1411
1516
|
const record = sessionRecord();
|
|
1412
1517
|
await stores.sessions.insertSession(record);
|
|
1413
|
-
const first =
|
|
1518
|
+
const first = at8("2026-02-01T00:00:00.000Z");
|
|
1414
1519
|
equal(await stores.sessions.revokeSession(record.id, first), true, "revokeSession on a standing session");
|
|
1415
|
-
equal(await stores.sessions.revokeSession(record.id,
|
|
1520
|
+
equal(await stores.sessions.revokeSession(record.id, at8("2026-03-01T00:00:00.000Z")), true, "revokeSession on a revoked session still answers true: the session exists");
|
|
1416
1521
|
equal((await stores.sessions.findSessionByTokenHash(record.tokenHash))?.revokedAt, first, "revokeSession twice should keep the first revokedAt");
|
|
1417
1522
|
equal(await stores.sessions.revokeSession(mintId2(), first), false, "revokeSession on an unknown session");
|
|
1418
1523
|
}
|
|
1419
1524
|
},
|
|
1420
1525
|
{
|
|
1421
1526
|
id: "sessions.revokeUser",
|
|
1422
|
-
group:
|
|
1527
|
+
group: group18,
|
|
1423
1528
|
name: "revokes every standing session of one user but the one excepted, and counts only what it revoked",
|
|
1424
1529
|
async run({ stores }) {
|
|
1425
1530
|
const userId = mintId2();
|
|
@@ -1427,13 +1532,13 @@ var sessionRevocationCases = [
|
|
|
1427
1532
|
const other = sessionRecord({ userId });
|
|
1428
1533
|
const already = sessionRecord({
|
|
1429
1534
|
userId,
|
|
1430
|
-
revokedAt:
|
|
1535
|
+
revokedAt: at8("2026-01-02T00:00:00.000Z")
|
|
1431
1536
|
});
|
|
1432
1537
|
const stranger = sessionRecord();
|
|
1433
1538
|
for (const record of [current, other, already, stranger]) {
|
|
1434
1539
|
await stores.sessions.insertSession(record);
|
|
1435
1540
|
}
|
|
1436
|
-
const now =
|
|
1541
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1437
1542
|
equal(await stores.sessions.revokeUserSessions(userId, now, current.id), 1, "revokeUserSessions with except: how many this call revoked");
|
|
1438
1543
|
isNull((await stores.sessions.findSessionByTokenHash(current.tokenHash))?.revokedAt ?? null, "revokeUserSessions should spare the excepted session");
|
|
1439
1544
|
equal((await stores.sessions.findSessionByTokenHash(already.tokenHash))?.revokedAt, already.revokedAt, "revokeUserSessions should keep an earlier revokedAt");
|
|
@@ -1444,28 +1549,28 @@ var sessionRevocationCases = [
|
|
|
1444
1549
|
},
|
|
1445
1550
|
{
|
|
1446
1551
|
id: "sessions.revokeUserIssuedBefore",
|
|
1447
|
-
group:
|
|
1552
|
+
group: group18,
|
|
1448
1553
|
name: "revokes only the sessions created strictly before issuedBefore, and still spares the one excepted",
|
|
1449
1554
|
async run({ stores }) {
|
|
1450
1555
|
const userId = mintId2();
|
|
1451
|
-
const cutoff =
|
|
1556
|
+
const cutoff = at8("2026-01-10T00:00:00.000Z");
|
|
1452
1557
|
const older = sessionRecord({
|
|
1453
1558
|
userId,
|
|
1454
|
-
createdAt:
|
|
1559
|
+
createdAt: at8("2026-01-09T23:59:59.999Z")
|
|
1455
1560
|
});
|
|
1456
1561
|
const olderSpared = sessionRecord({
|
|
1457
1562
|
userId,
|
|
1458
|
-
createdAt:
|
|
1563
|
+
createdAt: at8("2026-01-05T00:00:00.000Z")
|
|
1459
1564
|
});
|
|
1460
1565
|
const atCutoff = sessionRecord({ userId, createdAt: cutoff });
|
|
1461
1566
|
const newer = sessionRecord({
|
|
1462
1567
|
userId,
|
|
1463
|
-
createdAt:
|
|
1568
|
+
createdAt: at8("2026-01-11T00:00:00.000Z")
|
|
1464
1569
|
});
|
|
1465
1570
|
for (const record of [older, olderSpared, atCutoff, newer]) {
|
|
1466
1571
|
await stores.sessions.insertSession(record);
|
|
1467
1572
|
}
|
|
1468
|
-
const now =
|
|
1573
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1469
1574
|
equal(await stores.sessions.revokeUserSessions(userId, now, olderSpared.id, cutoff), 1, "revokeUserSessions with issuedBefore and except: how many this call revoked");
|
|
1470
1575
|
const revokedAt = async (record) => (await stores.sessions.findSessionByTokenHash(record.tokenHash))?.revokedAt ?? null;
|
|
1471
1576
|
equal(await revokedAt(older), now, "a session created before the cut-off goes");
|
|
@@ -1491,12 +1596,12 @@ var sessionStoreCases = [
|
|
|
1491
1596
|
];
|
|
1492
1597
|
|
|
1493
1598
|
// src/conformance/cases/social-links/deletion.ts
|
|
1494
|
-
var
|
|
1599
|
+
var group19 = "socialLinks";
|
|
1495
1600
|
var needs8 = "socialLinks";
|
|
1496
1601
|
var socialLinkDeletionCases = [
|
|
1497
1602
|
{
|
|
1498
1603
|
id: "socialLinks.deleteOwner",
|
|
1499
|
-
group:
|
|
1604
|
+
group: group19,
|
|
1500
1605
|
needs: needs8,
|
|
1501
1606
|
name: "deletes a link only for its owner: a wrong owner is false and keeps it, a repeat is false",
|
|
1502
1607
|
async run({ stores }) {
|
|
@@ -1514,7 +1619,7 @@ var socialLinkDeletionCases = [
|
|
|
1514
1619
|
},
|
|
1515
1620
|
{
|
|
1516
1621
|
id: "socialLinks.deleteUser",
|
|
1517
|
-
group:
|
|
1622
|
+
group: group19,
|
|
1518
1623
|
needs: needs8,
|
|
1519
1624
|
name: "deletes every link of one user and counts them, 0 for a user with none, and leaves other users’ links",
|
|
1520
1625
|
async run({ stores }) {
|
|
@@ -1540,12 +1645,12 @@ var socialLinkDeletionCases = [
|
|
|
1540
1645
|
];
|
|
1541
1646
|
|
|
1542
1647
|
// src/conformance/cases/social-links/inserts.ts
|
|
1543
|
-
var
|
|
1648
|
+
var group20 = "socialLinks";
|
|
1544
1649
|
var needs9 = "socialLinks";
|
|
1545
1650
|
var socialLinkInsertCases = [
|
|
1546
1651
|
{
|
|
1547
1652
|
id: "socialLinks.insertIdempotent",
|
|
1548
|
-
group:
|
|
1653
|
+
group: group20,
|
|
1549
1654
|
needs: needs9,
|
|
1550
1655
|
name: "answers the stored record when the same user inserts the same pair again, and writes nothing",
|
|
1551
1656
|
async run({ stores }) {
|
|
@@ -1563,7 +1668,7 @@ var socialLinkInsertCases = [
|
|
|
1563
1668
|
},
|
|
1564
1669
|
{
|
|
1565
1670
|
id: "socialLinks.insertTaken",
|
|
1566
|
-
group:
|
|
1671
|
+
group: group20,
|
|
1567
1672
|
needs: needs9,
|
|
1568
1673
|
name: "answers the holder’s record, and writes nothing, when another user inserts a linked pair",
|
|
1569
1674
|
async run({ stores }) {
|
|
@@ -1582,7 +1687,7 @@ var socialLinkInsertCases = [
|
|
|
1582
1687
|
},
|
|
1583
1688
|
{
|
|
1584
1689
|
id: "socialLinks.insertConcurrent",
|
|
1585
|
-
group:
|
|
1690
|
+
group: group20,
|
|
1586
1691
|
needs: needs9,
|
|
1587
1692
|
name: "stores one record when twenty users insert one pair at once, and answers all of them that record",
|
|
1588
1693
|
async run({ stores }) {
|
|
@@ -1608,12 +1713,12 @@ var socialLinkInsertCases = [
|
|
|
1608
1713
|
];
|
|
1609
1714
|
|
|
1610
1715
|
// src/conformance/cases/social-links/reads.ts
|
|
1611
|
-
var
|
|
1716
|
+
var group21 = "socialLinks";
|
|
1612
1717
|
var needs10 = "socialLinks";
|
|
1613
1718
|
var socialLinkReadCases = [
|
|
1614
1719
|
{
|
|
1615
1720
|
id: "socialLinks.findVerbatim",
|
|
1616
|
-
group:
|
|
1721
|
+
group: group21,
|
|
1617
1722
|
needs: needs10,
|
|
1618
1723
|
name: "answers a stored link verbatim by its pair, and null for an unknown pair",
|
|
1619
1724
|
async run({ stores }) {
|
|
@@ -1630,7 +1735,7 @@ var socialLinkReadCases = [
|
|
|
1630
1735
|
},
|
|
1631
1736
|
{
|
|
1632
1737
|
id: "socialLinks.countByProvider",
|
|
1633
|
-
group:
|
|
1738
|
+
group: group21,
|
|
1634
1739
|
needs: needs10,
|
|
1635
1740
|
name: "counts the links of one provider (when the store counts), 0 for none, and follows a delete",
|
|
1636
1741
|
async run({ stores }) {
|
|
@@ -1661,7 +1766,7 @@ var socialLinkReadCases = [
|
|
|
1661
1766
|
},
|
|
1662
1767
|
{
|
|
1663
1768
|
id: "socialLinks.bytesRoundTrip",
|
|
1664
|
-
group:
|
|
1769
|
+
group: group21,
|
|
1665
1770
|
needs: needs10,
|
|
1666
1771
|
name: "round-trips unicode, and compares provider and accountId case-sensitively",
|
|
1667
1772
|
async run({ stores }) {
|
|
@@ -1691,7 +1796,7 @@ var socialLinkReadCases = [
|
|
|
1691
1796
|
},
|
|
1692
1797
|
{
|
|
1693
1798
|
id: "socialLinks.listIsolation",
|
|
1694
|
-
group:
|
|
1799
|
+
group: group21,
|
|
1695
1800
|
needs: needs10,
|
|
1696
1801
|
name: "lists one user’s links and only theirs, and an empty list — never null — for a user with none",
|
|
1697
1802
|
async run({ stores }) {
|
|
@@ -1720,11 +1825,11 @@ var socialLinkStoreCases = [
|
|
|
1720
1825
|
];
|
|
1721
1826
|
|
|
1722
1827
|
// src/conformance/cases/tokens/attempts.ts
|
|
1723
|
-
var
|
|
1828
|
+
var group22 = "tokens";
|
|
1724
1829
|
var tokenAttemptCases = [
|
|
1725
1830
|
{
|
|
1726
1831
|
id: "tokens.countAttempt",
|
|
1727
|
-
group:
|
|
1832
|
+
group: group22,
|
|
1728
1833
|
name: "counts an attempt at a code, and answers the token as it is after the call",
|
|
1729
1834
|
async run({ stores }) {
|
|
1730
1835
|
const record = tokenRecord({
|
|
@@ -1734,12 +1839,12 @@ var tokenAttemptCases = [
|
|
|
1734
1839
|
await stores.tokens.insertToken(record);
|
|
1735
1840
|
equal(await stores.tokens.countAttempt(record.tokenHash, "signInCode"), { ...record, attempts: 1 }, "countAttempt the first time should answer the token with attempts 1, codeHash as written");
|
|
1736
1841
|
equal(await stores.tokens.countAttempt(record.tokenHash, "signInCode"), { ...record, attempts: 2 }, "countAttempt the second time should answer attempts 2");
|
|
1737
|
-
equal(await stores.tokens.consumeToken(record.tokenHash, "signInCode",
|
|
1842
|
+
equal(await stores.tokens.consumeToken(record.tokenHash, "signInCode", at8("2026-02-01T00:00:00.000Z")), { ...record, attempts: 2 }, "consumeToken should answer the attempts counted, and spend the token");
|
|
1738
1843
|
}
|
|
1739
1844
|
},
|
|
1740
1845
|
{
|
|
1741
1846
|
id: "tokens.countAttemptConcurrency",
|
|
1742
|
-
group:
|
|
1847
|
+
group: group22,
|
|
1743
1848
|
name: "gives twenty concurrent attempts twenty distinct counts — one conditional write, never a read then a write",
|
|
1744
1849
|
async run({ stores }) {
|
|
1745
1850
|
const record = tokenRecord({ kind: "secondFactor" });
|
|
@@ -1750,12 +1855,12 @@ var tokenAttemptCases = [
|
|
|
1750
1855
|
},
|
|
1751
1856
|
{
|
|
1752
1857
|
id: "tokens.countAttemptRace",
|
|
1753
|
-
group:
|
|
1858
|
+
group: group22,
|
|
1754
1859
|
name: "never counts an attempt once the token is spent, when attempts and a redemption race",
|
|
1755
1860
|
async run({ stores }) {
|
|
1756
1861
|
const record = tokenRecord({ kind: "signInCode" });
|
|
1757
1862
|
await stores.tokens.insertToken(record);
|
|
1758
|
-
const now =
|
|
1863
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1759
1864
|
const count = () => stores.tokens.countAttempt(record.tokenHash, "signInCode");
|
|
1760
1865
|
const answers = await Promise.all([
|
|
1761
1866
|
...Array.from({ length: 10 }, count),
|
|
@@ -1773,13 +1878,13 @@ var tokenAttemptCases = [
|
|
|
1773
1878
|
},
|
|
1774
1879
|
{
|
|
1775
1880
|
id: "tokens.countAttemptSpent",
|
|
1776
|
-
group:
|
|
1881
|
+
group: group22,
|
|
1777
1882
|
name: "does not count an attempt at a spent token, nor at a token of another kind, nor at none",
|
|
1778
1883
|
async run({ stores }) {
|
|
1779
1884
|
const spent = tokenRecord({
|
|
1780
1885
|
kind: "signInCode",
|
|
1781
1886
|
attempts: 3,
|
|
1782
|
-
spentAt:
|
|
1887
|
+
spentAt: at8("2026-01-02T00:00:00.000Z")
|
|
1783
1888
|
});
|
|
1784
1889
|
const other = tokenRecord({ kind: "resetPassword" });
|
|
1785
1890
|
await stores.tokens.insertToken(spent);
|
|
@@ -1788,18 +1893,18 @@ var tokenAttemptCases = [
|
|
|
1788
1893
|
equal(await stores.tokens.countAttempt(spent.tokenHash, "signInCode"), spent, `countAttempt on a spent token, the ${call} time, should answer it as it is: attempts still 3, nothing written`);
|
|
1789
1894
|
}
|
|
1790
1895
|
isNull(await stores.tokens.countAttempt(other.tokenHash, "signInCode"), "countAttempt for a resetPassword token counted as signInCode");
|
|
1791
|
-
equal(await stores.tokens.consumeToken(other.tokenHash, "resetPassword",
|
|
1896
|
+
equal(await stores.tokens.consumeToken(other.tokenHash, "resetPassword", at8("2026-02-01T00:00:00.000Z")), other, "countAttempt of the other kind should not have counted: attempts still 0");
|
|
1792
1897
|
isNull(await stores.tokens.countAttempt("0".repeat(64), "signInCode"), "countAttempt for an unknown hash");
|
|
1793
1898
|
}
|
|
1794
1899
|
}
|
|
1795
1900
|
];
|
|
1796
1901
|
|
|
1797
1902
|
// src/conformance/cases/tokens/change-email.ts
|
|
1798
|
-
var
|
|
1903
|
+
var group23 = "tokens";
|
|
1799
1904
|
var tokenChangeEmailCases = [
|
|
1800
1905
|
{
|
|
1801
1906
|
id: "tokens.changeEmailKind",
|
|
1802
|
-
group:
|
|
1907
|
+
group: group23,
|
|
1803
1908
|
name: "keeps an e-mail change apart from a verification, and keeps the address it replaces in codeHash",
|
|
1804
1909
|
async run({ stores }) {
|
|
1805
1910
|
const userId = mintId2();
|
|
@@ -1817,7 +1922,7 @@ var tokenChangeEmailCases = [
|
|
|
1817
1922
|
});
|
|
1818
1923
|
await stores.tokens.insertToken(change);
|
|
1819
1924
|
await stores.tokens.insertToken(verification);
|
|
1820
|
-
const now =
|
|
1925
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1821
1926
|
isNull(await stores.tokens.consumeToken(verification.tokenHash, "changeEmail", now), "consumeToken for a verifyEmail token redeemed as changeEmail");
|
|
1822
1927
|
isNull(await stores.tokens.consumeToken(change.tokenHash, "verifyEmail", now), "consumeToken for a changeEmail token redeemed as verifyEmail");
|
|
1823
1928
|
isNull(await stores.tokens.countAttempt(change.tokenHash, "verifyEmail"), "countAttempt for a changeEmail token counted as verifyEmail");
|
|
@@ -1828,24 +1933,24 @@ var tokenChangeEmailCases = [
|
|
|
1828
1933
|
];
|
|
1829
1934
|
|
|
1830
1935
|
// src/conformance/cases/tokens/deletion.ts
|
|
1831
|
-
var
|
|
1936
|
+
var group24 = "tokens";
|
|
1832
1937
|
var tokenDeletionCases = [
|
|
1833
1938
|
{
|
|
1834
1939
|
id: "tokens.deleteUser",
|
|
1835
|
-
group:
|
|
1940
|
+
group: group24,
|
|
1836
1941
|
name: "deletes every token of one user, spent or not, of either kind, and counts them",
|
|
1837
1942
|
async run({ stores }) {
|
|
1838
1943
|
const userId = mintId2();
|
|
1839
1944
|
const records = [
|
|
1840
1945
|
tokenRecord({ userId }),
|
|
1841
1946
|
tokenRecord({ userId, kind: "verifyEmail" }),
|
|
1842
|
-
tokenRecord({ userId, spentAt:
|
|
1947
|
+
tokenRecord({ userId, spentAt: at8("2026-01-02T00:00:00.000Z") })
|
|
1843
1948
|
];
|
|
1844
1949
|
const stranger = tokenRecord();
|
|
1845
1950
|
for (const record of [...records, stranger]) {
|
|
1846
1951
|
await stores.tokens.insertToken(record);
|
|
1847
1952
|
}
|
|
1848
|
-
const now =
|
|
1953
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1849
1954
|
equal(await stores.tokens.deleteUserTokens(userId), 3, "deleteUserTokens: how many it deleted");
|
|
1850
1955
|
for (const record of records) {
|
|
1851
1956
|
isNull(await stores.tokens.consumeToken(record.tokenHash, record.kind, now), "consumeToken after deleteUserTokens");
|
|
@@ -1856,15 +1961,15 @@ var tokenDeletionCases = [
|
|
|
1856
1961
|
},
|
|
1857
1962
|
{
|
|
1858
1963
|
id: "tokens.deleteExpired",
|
|
1859
|
-
group:
|
|
1964
|
+
group: group24,
|
|
1860
1965
|
name: "deletes tokens whose expiry is at or before the instant, spent or not, and only those",
|
|
1861
1966
|
needs: "deleteExpiredTokens",
|
|
1862
1967
|
async run({ stores }) {
|
|
1863
1968
|
const collect = stores.tokens.deleteExpiredTokens;
|
|
1864
1969
|
ok(collect !== undefined, "deleteExpiredTokens should be present");
|
|
1865
|
-
const lapsedAt =
|
|
1866
|
-
const laterAt =
|
|
1867
|
-
const spentAt =
|
|
1970
|
+
const lapsedAt = at8("2026-01-10T00:00:00.000Z");
|
|
1971
|
+
const laterAt = at8("2026-01-10T00:00:00.001Z");
|
|
1972
|
+
const spentAt = at8("2026-01-05T00:00:00.000Z");
|
|
1868
1973
|
const lapsed = tokenRecord({ expiresAt: lapsedAt });
|
|
1869
1974
|
const lapsedSpent = tokenRecord({ expiresAt: lapsedAt, spentAt });
|
|
1870
1975
|
const living = tokenRecord({ expiresAt: laterAt });
|
|
@@ -1884,27 +1989,27 @@ var tokenDeletionCases = [
|
|
|
1884
1989
|
];
|
|
1885
1990
|
|
|
1886
1991
|
// src/conformance/cases/tokens/inserts.ts
|
|
1887
|
-
var
|
|
1992
|
+
var group25 = "tokens";
|
|
1888
1993
|
var tokenInsertCases = [
|
|
1889
1994
|
{
|
|
1890
1995
|
id: "tokens.challenge",
|
|
1891
|
-
group:
|
|
1996
|
+
group: group25,
|
|
1892
1997
|
name: "keeps a second-factor challenge, whose address is '' — nothing was sent for it",
|
|
1893
1998
|
async run({ stores }) {
|
|
1894
1999
|
const record = tokenRecord({ kind: "secondFactor", address: "" });
|
|
1895
2000
|
await stores.tokens.insertToken(record);
|
|
1896
2001
|
equal(await stores.tokens.countAttempt(record.tokenHash, "secondFactor"), { ...record, attempts: 1 }, "countAttempt should answer a challenge with its empty address kept — a store that refuses '' refuses every sign-in with a second factor");
|
|
1897
|
-
equal(await stores.tokens.consumeToken(record.tokenHash, "secondFactor",
|
|
2002
|
+
equal(await stores.tokens.consumeToken(record.tokenHash, "secondFactor", at8("2026-02-01T00:00:00.000Z")), { ...record, attempts: 1 }, "consumeToken should spend the challenge and answer it as it was");
|
|
1898
2003
|
}
|
|
1899
2004
|
},
|
|
1900
2005
|
{
|
|
1901
2006
|
id: "tokens.lapsed",
|
|
1902
|
-
group:
|
|
2007
|
+
group: group25,
|
|
1903
2008
|
name: "spends a lapsed token all the same: expiry is compared by the core, after the call",
|
|
1904
2009
|
async run({ stores }) {
|
|
1905
|
-
const record = tokenRecord({ expiresAt:
|
|
2010
|
+
const record = tokenRecord({ expiresAt: at8("2020-01-01T00:00:00.000Z") });
|
|
1906
2011
|
await stores.tokens.insertToken(record);
|
|
1907
|
-
const now =
|
|
2012
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1908
2013
|
const first = await stores.tokens.consumeToken(record.tokenHash, "resetPassword", now);
|
|
1909
2014
|
if (first !== null) {
|
|
1910
2015
|
equal(first, record, "consumeToken on a lapsed token should answer it as it was");
|
|
@@ -1914,7 +2019,7 @@ var tokenInsertCases = [
|
|
|
1914
2019
|
},
|
|
1915
2020
|
{
|
|
1916
2021
|
id: "tokens.idempotentInsert",
|
|
1917
|
-
group:
|
|
2022
|
+
group: group25,
|
|
1918
2023
|
name: "is idempotent under retry: inserting an existing token hash writes nothing",
|
|
1919
2024
|
async run({ stores }) {
|
|
1920
2025
|
const record = tokenRecord();
|
|
@@ -1923,13 +2028,13 @@ var tokenInsertCases = [
|
|
|
1923
2028
|
...record,
|
|
1924
2029
|
address: "other@example.test"
|
|
1925
2030
|
});
|
|
1926
|
-
equal(await stores.tokens.consumeToken(record.tokenHash, "resetPassword",
|
|
2031
|
+
equal(await stores.tokens.consumeToken(record.tokenHash, "resetPassword", at8("2026-02-01T00:00:00.000Z")), record, "insertToken retried with the same hash should write nothing");
|
|
1927
2032
|
}
|
|
1928
2033
|
}
|
|
1929
2034
|
];
|
|
1930
2035
|
|
|
1931
2036
|
// src/conformance/cases/tokens/kinds.ts
|
|
1932
|
-
var
|
|
2037
|
+
var group26 = "tokens";
|
|
1933
2038
|
var KINDS = Object.keys({
|
|
1934
2039
|
verifyEmail: true,
|
|
1935
2040
|
resetPassword: true,
|
|
@@ -1944,10 +2049,10 @@ var KINDS = Object.keys({
|
|
|
1944
2049
|
var tokenKindCases = [
|
|
1945
2050
|
{
|
|
1946
2051
|
id: "tokens.everyKind",
|
|
1947
|
-
group:
|
|
2052
|
+
group: group26,
|
|
1948
2053
|
name: "stores, counts and spends a token of every kind the port names",
|
|
1949
2054
|
async run({ stores }) {
|
|
1950
|
-
const now =
|
|
2055
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1951
2056
|
for (const kind of KINDS) {
|
|
1952
2057
|
const record = tokenRecord({ kind, codeHash: "c".repeat(64) });
|
|
1953
2058
|
await stores.tokens.insertToken(record);
|
|
@@ -1958,7 +2063,7 @@ var tokenKindCases = [
|
|
|
1958
2063
|
},
|
|
1959
2064
|
{
|
|
1960
2065
|
id: "tokens.stepUpKind",
|
|
1961
|
-
group:
|
|
2066
|
+
group: group26,
|
|
1962
2067
|
name: "keeps a step-up apart from a sign-in code: neither is counted, spent nor answered as the other",
|
|
1963
2068
|
async run({ stores }) {
|
|
1964
2069
|
const userId = mintId2();
|
|
@@ -1966,7 +2071,7 @@ var tokenKindCases = [
|
|
|
1966
2071
|
const signInCode = tokenRecord({ userId, kind: "signInCode" });
|
|
1967
2072
|
await stores.tokens.insertToken(stepUp);
|
|
1968
2073
|
await stores.tokens.insertToken(signInCode);
|
|
1969
|
-
const now =
|
|
2074
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1970
2075
|
isNull(await stores.tokens.countAttempt(stepUp.tokenHash, "signInCode"), "countAttempt for a stepUp token counted as signInCode");
|
|
1971
2076
|
isNull(await stores.tokens.consumeToken(signInCode.tokenHash, "stepUp", now), "consumeToken for a signInCode token redeemed as stepUp");
|
|
1972
2077
|
equal(await stores.tokens.spendUserTokens(userId, "stepUp", now), 1, "spendUserTokens of stepUp: the step-up only");
|
|
@@ -1975,7 +2080,7 @@ var tokenKindCases = [
|
|
|
1975
2080
|
},
|
|
1976
2081
|
{
|
|
1977
2082
|
id: "tokens.magicLinkKind",
|
|
1978
|
-
group:
|
|
2083
|
+
group: group26,
|
|
1979
2084
|
name: "keeps a sign-in link apart from a sign-in code: neither is counted, spent nor answered as the other",
|
|
1980
2085
|
async run({ stores }) {
|
|
1981
2086
|
const userId = mintId2();
|
|
@@ -1987,7 +2092,7 @@ var tokenKindCases = [
|
|
|
1987
2092
|
});
|
|
1988
2093
|
await stores.tokens.insertToken(link);
|
|
1989
2094
|
await stores.tokens.insertToken(code);
|
|
1990
|
-
const now =
|
|
2095
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
1991
2096
|
isNull(await stores.tokens.consumeToken(code.tokenHash, "magicLink", now), "consumeToken for a signInCode token redeemed as magicLink");
|
|
1992
2097
|
isNull(await stores.tokens.countAttempt(link.tokenHash, "signInCode"), "countAttempt for a magicLink token counted as signInCode");
|
|
1993
2098
|
equal(await stores.tokens.spendUserTokens(userId, "magicLink", now), 1, "spendUserTokens of magicLink: the link only");
|
|
@@ -1996,10 +2101,10 @@ var tokenKindCases = [
|
|
|
1996
2101
|
},
|
|
1997
2102
|
{
|
|
1998
2103
|
id: "tokens.amr",
|
|
1999
|
-
group:
|
|
2104
|
+
group: group26,
|
|
2000
2105
|
name: "keeps the methods a second-factor challenge carries, and answers none when none were given",
|
|
2001
2106
|
async run({ stores }) {
|
|
2002
|
-
const now =
|
|
2107
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
2003
2108
|
const carrying = tokenRecord({
|
|
2004
2109
|
kind: "secondFactor",
|
|
2005
2110
|
amr: ["hwk", "user"]
|
|
@@ -2014,65 +2119,65 @@ var tokenKindCases = [
|
|
|
2014
2119
|
];
|
|
2015
2120
|
|
|
2016
2121
|
// src/conformance/cases/tokens/redemption.ts
|
|
2017
|
-
var
|
|
2122
|
+
var group27 = "tokens";
|
|
2018
2123
|
var tokenRedemptionCases = [
|
|
2019
2124
|
{
|
|
2020
2125
|
id: "tokens.consume",
|
|
2021
|
-
group:
|
|
2126
|
+
group: group27,
|
|
2022
2127
|
name: "answers the token as it was before the call: spentAt null means this call spent it",
|
|
2023
2128
|
async run({ stores }) {
|
|
2024
2129
|
const record = tokenRecord();
|
|
2025
2130
|
await stores.tokens.insertToken(record);
|
|
2026
|
-
const first =
|
|
2131
|
+
const first = at8("2026-02-01T00:00:00.000Z");
|
|
2027
2132
|
equal(await stores.tokens.consumeToken(record.tokenHash, "resetPassword", first), record, "consumeToken the first time should answer the token as it was — spentAt null");
|
|
2028
|
-
equal(await stores.tokens.consumeToken(record.tokenHash, "resetPassword",
|
|
2133
|
+
equal(await stores.tokens.consumeToken(record.tokenHash, "resetPassword", at8("2026-02-02T00:00:00.000Z")), { ...record, spentAt: first }, "consumeToken the second time should answer it spent at the first call’s instant, and change nothing");
|
|
2029
2134
|
}
|
|
2030
2135
|
},
|
|
2031
2136
|
{
|
|
2032
2137
|
id: "tokens.concurrency",
|
|
2033
|
-
group:
|
|
2138
|
+
group: group27,
|
|
2034
2139
|
name: "lets exactly one of twenty concurrent redemptions spend a token — one conditional write, never a read then a write",
|
|
2035
2140
|
async run({ stores }) {
|
|
2036
2141
|
const record = tokenRecord();
|
|
2037
2142
|
await stores.tokens.insertToken(record);
|
|
2038
|
-
const now =
|
|
2143
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
2039
2144
|
const answers = await Promise.all(Array.from({ length: 20 }, () => stores.tokens.consumeToken(record.tokenHash, "resetPassword", now)));
|
|
2040
2145
|
equal(answers.filter((answer) => answer !== null && answer.spentAt === null).length, 1, "consumeToken: of twenty concurrent calls, exactly one should see spentAt null — a reset token redeemed twice is an account takeover");
|
|
2041
2146
|
}
|
|
2042
2147
|
},
|
|
2043
2148
|
{
|
|
2044
2149
|
id: "tokens.kind",
|
|
2045
|
-
group:
|
|
2150
|
+
group: group27,
|
|
2046
2151
|
name: "does not know, and does not spend, a token of the other kind",
|
|
2047
2152
|
async run({ stores }) {
|
|
2048
2153
|
const record = tokenRecord({ kind: "verifyEmail" });
|
|
2049
2154
|
await stores.tokens.insertToken(record);
|
|
2050
|
-
isNull(await stores.tokens.consumeToken(record.tokenHash, "resetPassword",
|
|
2051
|
-
const own = await stores.tokens.consumeToken(record.tokenHash, "verifyEmail",
|
|
2155
|
+
isNull(await stores.tokens.consumeToken(record.tokenHash, "resetPassword", at8("2026-02-01T00:00:00.000Z")), "consumeToken for a verifyEmail token redeemed as resetPassword");
|
|
2156
|
+
const own = await stores.tokens.consumeToken(record.tokenHash, "verifyEmail", at8("2026-02-02T00:00:00.000Z"));
|
|
2052
2157
|
equal(own, record, "consumeToken of the other kind should not have spent the token: redeemed as its own kind, it is still unspent");
|
|
2053
|
-
isNull(await stores.tokens.consumeToken("0".repeat(64), "resetPassword",
|
|
2158
|
+
isNull(await stores.tokens.consumeToken("0".repeat(64), "resetPassword", at8("2026-02-01T00:00:00.000Z")), "consumeToken for an unknown hash");
|
|
2054
2159
|
}
|
|
2055
2160
|
},
|
|
2056
2161
|
{
|
|
2057
2162
|
id: "tokens.consumeBound",
|
|
2058
|
-
group:
|
|
2163
|
+
group: group27,
|
|
2059
2164
|
name: "given a userId, answers null and does not spend a token of another user",
|
|
2060
2165
|
async run({ stores }) {
|
|
2061
2166
|
const record = tokenRecord({ kind: "verifyEmail" });
|
|
2062
2167
|
await stores.tokens.insertToken(record);
|
|
2063
|
-
isNull(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail",
|
|
2064
|
-
isNull(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail",
|
|
2065
|
-
equal(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail",
|
|
2168
|
+
isNull(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail", at8("2026-02-01T00:00:00.000Z"), mintId2()), "consumeToken bound to another user");
|
|
2169
|
+
isNull(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail", at8("2026-02-01T00:00:00.000Z"), ""), "consumeToken bound to an empty id should match no token, not any");
|
|
2170
|
+
equal(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail", at8("2026-02-02T00:00:00.000Z"), record.userId), record, "consumeToken bound to the token’s own user should answer it unspent: the other user’s call spent nothing");
|
|
2066
2171
|
}
|
|
2067
2172
|
}
|
|
2068
2173
|
];
|
|
2069
2174
|
|
|
2070
2175
|
// src/conformance/cases/tokens/social-flow.ts
|
|
2071
|
-
var
|
|
2176
|
+
var group28 = "tokens";
|
|
2072
2177
|
var tokenSocialFlowCases = [
|
|
2073
2178
|
{
|
|
2074
2179
|
id: "tokens.socialFlowKind",
|
|
2075
|
-
group:
|
|
2180
|
+
group: group28,
|
|
2076
2181
|
name: "keeps a social flow apart from a verification, and keeps its binding hash in codeHash",
|
|
2077
2182
|
async run({ stores }) {
|
|
2078
2183
|
const userId = mintId2();
|
|
@@ -2085,7 +2190,7 @@ var tokenSocialFlowCases = [
|
|
|
2085
2190
|
const verification = tokenRecord({ userId, kind: "verifyEmail" });
|
|
2086
2191
|
await stores.tokens.insertToken(flow);
|
|
2087
2192
|
await stores.tokens.insertToken(verification);
|
|
2088
|
-
const now =
|
|
2193
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
2089
2194
|
isNull(await stores.tokens.consumeToken(verification.tokenHash, "socialFlow", now), "consumeToken for a verifyEmail token redeemed as socialFlow");
|
|
2090
2195
|
isNull(await stores.tokens.consumeToken(flow.tokenHash, "verifyEmail", now), "consumeToken for a socialFlow token redeemed as verifyEmail");
|
|
2091
2196
|
isNull(await stores.tokens.countAttempt(flow.tokenHash, "magicLink"), "countAttempt for a socialFlow token counted as magicLink");
|
|
@@ -2096,17 +2201,17 @@ var tokenSocialFlowCases = [
|
|
|
2096
2201
|
];
|
|
2097
2202
|
|
|
2098
2203
|
// src/conformance/cases/tokens/spending.ts
|
|
2099
|
-
var
|
|
2204
|
+
var group29 = "tokens";
|
|
2100
2205
|
var tokenSpendingCases = [
|
|
2101
2206
|
{
|
|
2102
2207
|
id: "tokens.spendUserTokens",
|
|
2103
|
-
group:
|
|
2208
|
+
group: group29,
|
|
2104
2209
|
name: "spends every unspent token of one user and one kind, and counts them, leaving the rest as they were",
|
|
2105
2210
|
async run({ stores }) {
|
|
2106
2211
|
const userId = mintId2();
|
|
2107
2212
|
const first = tokenRecord({ userId, kind: "signInCode" });
|
|
2108
2213
|
const second = tokenRecord({ userId, kind: "signInCode", attempts: 2 });
|
|
2109
|
-
const spentBefore =
|
|
2214
|
+
const spentBefore = at8("2026-01-02T00:00:00.000Z");
|
|
2110
2215
|
const spent = tokenRecord({
|
|
2111
2216
|
userId,
|
|
2112
2217
|
kind: "signInCode",
|
|
@@ -2117,7 +2222,7 @@ var tokenSpendingCases = [
|
|
|
2117
2222
|
for (const record of [first, second, spent, otherKind, otherUser]) {
|
|
2118
2223
|
await stores.tokens.insertToken(record);
|
|
2119
2224
|
}
|
|
2120
|
-
const now =
|
|
2225
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
2121
2226
|
equal(await stores.tokens.spendUserTokens(userId, "signInCode", now), 2, "spendUserTokens: how many it spent — the two unspent signInCode tokens, not the one already spent");
|
|
2122
2227
|
for (const record of [first, second]) {
|
|
2123
2228
|
equal(await stores.tokens.consumeToken(record.tokenHash, "signInCode", now), { ...record, spentAt: now }, "spendUserTokens should have spent it at `at`, keeping its attempts");
|
|
@@ -2131,7 +2236,7 @@ var tokenSpendingCases = [
|
|
|
2131
2236
|
},
|
|
2132
2237
|
{
|
|
2133
2238
|
id: "tokens.spendUserTokensExcept",
|
|
2134
|
-
group:
|
|
2239
|
+
group: group29,
|
|
2135
2240
|
name: "spares the token named by except, and spends the rest",
|
|
2136
2241
|
async run({ stores }) {
|
|
2137
2242
|
const userId = mintId2();
|
|
@@ -2143,7 +2248,7 @@ var tokenSpendingCases = [
|
|
|
2143
2248
|
for (const record of [kept, ...others]) {
|
|
2144
2249
|
await stores.tokens.insertToken(record);
|
|
2145
2250
|
}
|
|
2146
|
-
const now =
|
|
2251
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
2147
2252
|
equal(await stores.tokens.spendUserTokens(userId, "signInCode", now, kept.tokenHash), 2, "spendUserTokens with except: how many it spent — every token but the one named");
|
|
2148
2253
|
equal(await stores.tokens.consumeToken(kept.tokenHash, "signInCode", now), kept, "spendUserTokens should not spend the token named by except");
|
|
2149
2254
|
for (const record of others) {
|
|
@@ -2153,10 +2258,10 @@ var tokenSpendingCases = [
|
|
|
2153
2258
|
},
|
|
2154
2259
|
{
|
|
2155
2260
|
id: "tokens.spendUserTokensRace",
|
|
2156
|
-
group:
|
|
2261
|
+
group: group29,
|
|
2157
2262
|
name: "spends a token once, when spending a user's tokens races a redemption",
|
|
2158
2263
|
async run({ stores }) {
|
|
2159
|
-
const now =
|
|
2264
|
+
const now = at8("2026-02-01T00:00:00.000Z");
|
|
2160
2265
|
for (let round = 0;round < 10; round += 1) {
|
|
2161
2266
|
const record = tokenRecord({ kind: "signInCode" });
|
|
2162
2267
|
await stores.tokens.insertToken(record);
|
|
@@ -2183,12 +2288,12 @@ var tokenStoreCases = [
|
|
|
2183
2288
|
];
|
|
2184
2289
|
|
|
2185
2290
|
// src/conformance/cases/users/batch.ts
|
|
2186
|
-
var
|
|
2291
|
+
var group30 = "users";
|
|
2187
2292
|
var byId = (a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
|
2188
2293
|
var userBatchCases = [
|
|
2189
2294
|
{
|
|
2190
2295
|
id: "users.findUsers",
|
|
2191
|
-
group:
|
|
2296
|
+
group: group30,
|
|
2192
2297
|
name: "findUsers answers each stored user once, byte for byte and whatever its type, and leaves out an id nobody holds",
|
|
2193
2298
|
needs: "findUsers",
|
|
2194
2299
|
async run({ stores }) {
|
|
@@ -2211,7 +2316,7 @@ var userBatchCases = [
|
|
|
2211
2316
|
},
|
|
2212
2317
|
{
|
|
2213
2318
|
id: "users.findUsersNone",
|
|
2214
|
-
group:
|
|
2319
|
+
group: group30,
|
|
2215
2320
|
name: "findUsers answers an empty list, not null, when no id is held",
|
|
2216
2321
|
needs: "findUsers",
|
|
2217
2322
|
async run({ stores }) {
|
|
@@ -2222,11 +2327,11 @@ var userBatchCases = [
|
|
|
2222
2327
|
];
|
|
2223
2328
|
|
|
2224
2329
|
// src/conformance/cases/users/deletion.ts
|
|
2225
|
-
var
|
|
2330
|
+
var group31 = "users";
|
|
2226
2331
|
var userDeletionCases = [
|
|
2227
2332
|
{
|
|
2228
2333
|
id: "users.delete",
|
|
2229
|
-
group:
|
|
2334
|
+
group: group31,
|
|
2230
2335
|
name: "deletes a user and frees their logins, answers false for nobody, and touches no other user",
|
|
2231
2336
|
async run({ stores }) {
|
|
2232
2337
|
const record = userRecord();
|
|
@@ -2246,11 +2351,11 @@ var userDeletionCases = [
|
|
|
2246
2351
|
];
|
|
2247
2352
|
|
|
2248
2353
|
// src/conformance/cases/users/inserts.ts
|
|
2249
|
-
var
|
|
2354
|
+
var group32 = "users";
|
|
2250
2355
|
var userInsertCases = [
|
|
2251
2356
|
{
|
|
2252
2357
|
id: "users.idempotentInsert",
|
|
2253
|
-
group:
|
|
2358
|
+
group: group32,
|
|
2254
2359
|
name: "is idempotent under retry: inserting an existing id answers the stored record and writes nothing",
|
|
2255
2360
|
async run({ stores }) {
|
|
2256
2361
|
const record = userRecord();
|
|
@@ -2265,7 +2370,7 @@ var userInsertCases = [
|
|
|
2265
2370
|
},
|
|
2266
2371
|
{
|
|
2267
2372
|
id: "users.uniqueness",
|
|
2268
|
-
group:
|
|
2373
|
+
group: group32,
|
|
2269
2374
|
name: "lets exactly one of twenty concurrent inserts hold a login: uniqueness is a constraint, not a read",
|
|
2270
2375
|
async run({ stores }) {
|
|
2271
2376
|
const records = Array.from({ length: 20 }, () => userRecord({ logins: ["contested@example.test"] }));
|
|
@@ -2290,11 +2395,11 @@ var userInsertCases = [
|
|
|
2290
2395
|
];
|
|
2291
2396
|
|
|
2292
2397
|
// src/conformance/cases/users/listing.ts
|
|
2293
|
-
var
|
|
2398
|
+
var group33 = "users";
|
|
2294
2399
|
var userListingCases = [
|
|
2295
2400
|
{
|
|
2296
2401
|
id: "users.pagination",
|
|
2297
|
-
group:
|
|
2402
|
+
group: group33,
|
|
2298
2403
|
name: "pages 25 users of one type by 10 in ascending id order, with no gap, no repeat and no other type, and ends on a null cursor",
|
|
2299
2404
|
async run({ stores }) {
|
|
2300
2405
|
const records = Array.from({ length: 25 }, () => userRecord());
|
|
@@ -2333,7 +2438,7 @@ var userListingCases = [
|
|
|
2333
2438
|
},
|
|
2334
2439
|
{
|
|
2335
2440
|
id: "users.loginPrefix",
|
|
2336
|
-
group:
|
|
2441
|
+
group: group33,
|
|
2337
2442
|
name: "lists and counts only the users of the type holding a login that starts with the prefix, byte for byte, with no gap or repeat across pages",
|
|
2338
2443
|
async run({ stores }) {
|
|
2339
2444
|
const stamp = mintId2();
|
|
@@ -2389,7 +2494,7 @@ var userListingCases = [
|
|
|
2389
2494
|
},
|
|
2390
2495
|
{
|
|
2391
2496
|
id: "users.loginPrefix.literal",
|
|
2392
|
-
group:
|
|
2497
|
+
group: group33,
|
|
2393
2498
|
name: 'treats the prefix as text: ".", "+", "%", "_", "\\" and "*" match themselves and nothing else',
|
|
2394
2499
|
async run({ stores }) {
|
|
2395
2500
|
const stamp = mintId2();
|
|
@@ -2438,7 +2543,7 @@ var userListingCases = [
|
|
|
2438
2543
|
},
|
|
2439
2544
|
{
|
|
2440
2545
|
id: "users.namePrefix",
|
|
2441
|
-
group:
|
|
2546
|
+
group: group33,
|
|
2442
2547
|
name: "lists and counts only the users of the type whose name key starts with the prefix, byte for byte, combined with a loginPrefix, with no gap or repeat across pages",
|
|
2443
2548
|
async run({ stores }) {
|
|
2444
2549
|
const stamp = mintId2();
|
|
@@ -2504,7 +2609,7 @@ var userListingCases = [
|
|
|
2504
2609
|
},
|
|
2505
2610
|
{
|
|
2506
2611
|
id: "users.namePrefix.literal",
|
|
2507
|
-
group:
|
|
2612
|
+
group: group33,
|
|
2508
2613
|
name: 'treats the name prefix as text: ".", "+", "%", "_", "\\" and "*" match themselves and nothing else',
|
|
2509
2614
|
async run({ stores }) {
|
|
2510
2615
|
const base = `ln-${mintId2()}`;
|
|
@@ -2544,7 +2649,7 @@ var userListingCases = [
|
|
|
2544
2649
|
// src/conformance/cases/users/avatar.ts
|
|
2545
2650
|
var avatar = {
|
|
2546
2651
|
id: "avatars/ada.3f9c1d",
|
|
2547
|
-
updatedAt:
|
|
2652
|
+
updatedAt: at8("2026-01-05T10:20:30.456Z")
|
|
2548
2653
|
};
|
|
2549
2654
|
var writtenAt = (version) => new Date(Date.UTC(2026, 1, 2 + version));
|
|
2550
2655
|
var avatarSlotCase = {
|
|
@@ -2559,7 +2664,7 @@ var avatarSlotCase = {
|
|
|
2559
2664
|
equal(kept.avatar, avatar, "updateUser not naming avatar should keep it");
|
|
2560
2665
|
const replacement = {
|
|
2561
2666
|
id: "avatars/ada.b7e204",
|
|
2562
|
-
updatedAt:
|
|
2667
|
+
updatedAt: at8("2026-02-03T04:05:06.789Z")
|
|
2563
2668
|
};
|
|
2564
2669
|
const replaced = await stores.users.updateUser(record.id, { updatedAt: writtenAt(1), avatar: replacement }, 1);
|
|
2565
2670
|
equal(replaced.avatar, replacement, "updateUser naming avatar should replace it whole");
|
|
@@ -2594,7 +2699,7 @@ var secondFactorSlotCase = {
|
|
|
2594
2699
|
await noCodesIsNotNoFactor(stores, record.id);
|
|
2595
2700
|
const confirmed = {
|
|
2596
2701
|
...secondFactor,
|
|
2597
|
-
confirmedAt:
|
|
2702
|
+
confirmedAt: at8("2026-02-01T00:00:00.000Z"),
|
|
2598
2703
|
lastStep: 59000000,
|
|
2599
2704
|
recoveryCodes
|
|
2600
2705
|
};
|
|
@@ -2633,60 +2738,60 @@ async function nullClearsCodes(stores, id) {
|
|
|
2633
2738
|
}
|
|
2634
2739
|
|
|
2635
2740
|
// src/conformance/cases/users/patches.ts
|
|
2636
|
-
var
|
|
2741
|
+
var group34 = "users";
|
|
2637
2742
|
var userPatchCases = [
|
|
2638
2743
|
{
|
|
2639
2744
|
id: "users.omission",
|
|
2640
|
-
group:
|
|
2745
|
+
group: group34,
|
|
2641
2746
|
name: "omission — the Kratos PUT trap: an update leaves every field it does not name exactly as it was",
|
|
2642
2747
|
async run({ stores }) {
|
|
2643
2748
|
const record = userRecord({
|
|
2644
2749
|
fields: { email: "kept@example.test", plan: "pro" },
|
|
2645
2750
|
secondFactor: {
|
|
2646
2751
|
...secondFactor,
|
|
2647
|
-
confirmedAt:
|
|
2752
|
+
confirmedAt: at8("2026-01-03T00:00:00.000Z"),
|
|
2648
2753
|
lastStep: 59000000,
|
|
2649
2754
|
recoveryCodes: recoveryCodes.slice(0, 2)
|
|
2650
2755
|
},
|
|
2651
|
-
emailVerifiedAt:
|
|
2756
|
+
emailVerifiedAt: at8("2026-01-02T00:00:00.000Z")
|
|
2652
2757
|
});
|
|
2653
2758
|
await stores.users.insertUser(record);
|
|
2654
|
-
const written = await stores.users.updateUser(record.id, { updatedAt:
|
|
2759
|
+
const written = await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-01T00:00:00.000Z"), schemaVersion: "2" }, 0);
|
|
2655
2760
|
equal(written, {
|
|
2656
2761
|
...record,
|
|
2657
2762
|
schemaVersion: "2",
|
|
2658
2763
|
version: 1,
|
|
2659
|
-
updatedAt:
|
|
2764
|
+
updatedAt: at8("2026-02-01T00:00:00.000Z")
|
|
2660
2765
|
}, "updateUser naming only schemaVersion should leave active, fields, logins, password, secondFactor and emailVerifiedAt untouched");
|
|
2661
2766
|
}
|
|
2662
2767
|
},
|
|
2663
2768
|
{
|
|
2664
2769
|
id: "users.nameKeySlot",
|
|
2665
|
-
group:
|
|
2770
|
+
group: group34,
|
|
2666
2771
|
name: "keeps a name key the patch does not name, replaces one it names, and removes one it names null",
|
|
2667
2772
|
async run({ stores }) {
|
|
2668
2773
|
const record = userRecord({ nameKey: "ada lovelace" });
|
|
2669
2774
|
await stores.users.insertUser(record);
|
|
2670
|
-
const kept = await stores.users.updateUser(record.id, { updatedAt:
|
|
2775
|
+
const kept = await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-01T00:00:00.000Z"), schemaVersion: "2" }, 0);
|
|
2671
2776
|
equal(kept.nameKey, "ada lovelace", "updateUser not naming nameKey should keep it");
|
|
2672
|
-
const replaced = await stores.users.updateUser(record.id, { updatedAt:
|
|
2777
|
+
const replaced = await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-02T00:00:00.000Z"), nameKey: "grace hopper" }, 1);
|
|
2673
2778
|
equal(replaced.nameKey, "grace hopper", "updateUser naming nameKey should replace it");
|
|
2674
2779
|
equal(await stores.users.countUsers({ type: "user", namePrefix: "grace" }), 1, "countUsers: the replaced name key should be the one searched");
|
|
2675
|
-
const removed = await stores.users.updateUser(record.id, { updatedAt:
|
|
2780
|
+
const removed = await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-03T00:00:00.000Z"), nameKey: null }, 2);
|
|
2676
2781
|
equal("nameKey" in removed, false, "updateUser naming nameKey null should leave the record with no nameKey");
|
|
2677
2782
|
equal(await stores.users.countUsers({ type: "user", namePrefix: "grace" }), 0, "countUsers: a removed name key should match no prefix");
|
|
2678
2783
|
}
|
|
2679
2784
|
},
|
|
2680
2785
|
{
|
|
2681
2786
|
id: "users.passwordSlot",
|
|
2682
|
-
group:
|
|
2787
|
+
group: group34,
|
|
2683
2788
|
name: "keeps a password the patch does not name, and removes one the patch names null",
|
|
2684
2789
|
async run({ stores }) {
|
|
2685
2790
|
const record = userRecord();
|
|
2686
2791
|
await stores.users.insertUser(record);
|
|
2687
|
-
const kept = await stores.users.updateUser(record.id, { updatedAt:
|
|
2792
|
+
const kept = await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-01T00:00:00.000Z") }, 0);
|
|
2688
2793
|
equal(kept.password, record.password, "updateUser not naming password should keep it");
|
|
2689
|
-
const removed = await stores.users.updateUser(record.id, { updatedAt:
|
|
2794
|
+
const removed = await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-02T00:00:00.000Z"), password: null }, 1);
|
|
2690
2795
|
isNull(removed.password, "updateUser with password: null should remove the password");
|
|
2691
2796
|
}
|
|
2692
2797
|
},
|
|
@@ -2694,7 +2799,7 @@ var userPatchCases = [
|
|
|
2694
2799
|
avatarSlotCase,
|
|
2695
2800
|
{
|
|
2696
2801
|
id: "users.loginsMove",
|
|
2697
|
-
group:
|
|
2802
|
+
group: group34,
|
|
2698
2803
|
name: "moves logins on update: the old one is free, the new one found, one held elsewhere refused",
|
|
2699
2804
|
async run({ stores }) {
|
|
2700
2805
|
const record = userRecord();
|
|
@@ -2703,10 +2808,10 @@ var userPatchCases = [
|
|
|
2703
2808
|
await stores.users.insertUser(other);
|
|
2704
2809
|
const [old] = record.logins;
|
|
2705
2810
|
const moved = "moved@example.test";
|
|
2706
|
-
await stores.users.updateUser(record.id, { updatedAt:
|
|
2811
|
+
await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-01T00:00:00.000Z"), logins: [moved] }, 0);
|
|
2707
2812
|
isNull(await stores.users.findUserByLogin("user", old ?? ""), "findUserByLogin for a login the update replaced");
|
|
2708
2813
|
equal((await stores.users.findUserByLogin("user", moved))?.id, record.id, "findUserByLogin for the login the update wrote");
|
|
2709
|
-
const error = await rejects(stores.users.updateUser(other.id, { updatedAt:
|
|
2814
|
+
const error = await rejects(stores.users.updateUser(other.id, { updatedAt: at8("2026-02-02T00:00:00.000Z"), logins: [moved] }, 0), "updateUser onto a login another user holds should reject");
|
|
2710
2815
|
isOurs(error, StoreConflict2, "StoreConflict", "updateUser onto a held login should reject with StoreConflict");
|
|
2711
2816
|
equal(error.code, "LOGIN_TAKEN", "updateUser: the conflict code");
|
|
2712
2817
|
equal(await stores.users.findUser(other.id), other, "updateUser refused for a login should have written nothing");
|
|
@@ -2715,11 +2820,11 @@ var userPatchCases = [
|
|
|
2715
2820
|
];
|
|
2716
2821
|
|
|
2717
2822
|
// src/conformance/cases/users/reads.ts
|
|
2718
|
-
var
|
|
2823
|
+
var group35 = "users";
|
|
2719
2824
|
var userReadCases = [
|
|
2720
2825
|
{
|
|
2721
2826
|
id: "users.roundTrip",
|
|
2722
|
-
group:
|
|
2827
|
+
group: group35,
|
|
2723
2828
|
name: 'round-trips a record byte for byte: nested fields, a 1 that stays a number, a "1" that stays a string',
|
|
2724
2829
|
async run({ stores }) {
|
|
2725
2830
|
const record = userRecord({
|
|
@@ -2735,7 +2840,7 @@ var userReadCases = [
|
|
|
2735
2840
|
nested: { deep: { deeper: [1, { two: 2 }] } },
|
|
2736
2841
|
tags: ["a", "b"]
|
|
2737
2842
|
},
|
|
2738
|
-
emailVerifiedAt:
|
|
2843
|
+
emailVerifiedAt: at8("2026-01-02T00:00:00.000Z")
|
|
2739
2844
|
});
|
|
2740
2845
|
equal(await stores.users.insertUser(record), record, "insertUser should answer the record as stored");
|
|
2741
2846
|
equal(await stores.users.findUser(record.id), record, "findUser should answer the record exactly as it was written");
|
|
@@ -2743,7 +2848,7 @@ var userReadCases = [
|
|
|
2743
2848
|
},
|
|
2744
2849
|
{
|
|
2745
2850
|
id: "users.edgeCharacters",
|
|
2746
|
-
group:
|
|
2851
|
+
group: group35,
|
|
2747
2852
|
name: "round-trips every character the core lets through: control characters, U+FFFF and a surrogate pair",
|
|
2748
2853
|
async run({ stores }) {
|
|
2749
2854
|
const edge = "a\x01\x1F \uD83D\uDE00 z";
|
|
@@ -2758,7 +2863,7 @@ var userReadCases = [
|
|
|
2758
2863
|
},
|
|
2759
2864
|
{
|
|
2760
2865
|
id: "users.absence",
|
|
2761
|
-
group:
|
|
2866
|
+
group: group35,
|
|
2762
2867
|
name: "answers null for an absence, never undefined, and an empty page for an empty store",
|
|
2763
2868
|
async run({ stores }) {
|
|
2764
2869
|
isNull(await stores.users.findUser(mintId2()), "findUser for an unknown id");
|
|
@@ -2768,7 +2873,7 @@ var userReadCases = [
|
|
|
2768
2873
|
},
|
|
2769
2874
|
{
|
|
2770
2875
|
id: "users.loginBytes",
|
|
2771
|
-
group:
|
|
2876
|
+
group: group35,
|
|
2772
2877
|
name: "compares logins as bytes, within one type: no case folding, no trimming, no collation",
|
|
2773
2878
|
async run({ stores }) {
|
|
2774
2879
|
const upper = userRecord({ logins: ["Ada@Example.test"] });
|
|
@@ -2785,21 +2890,21 @@ var userReadCases = [
|
|
|
2785
2890
|
];
|
|
2786
2891
|
|
|
2787
2892
|
// src/conformance/cases/users/versions.ts
|
|
2788
|
-
var
|
|
2893
|
+
var group36 = "users";
|
|
2789
2894
|
var userVersionCases = [
|
|
2790
2895
|
{
|
|
2791
2896
|
id: "users.versionIncrements",
|
|
2792
|
-
group:
|
|
2897
|
+
group: group36,
|
|
2793
2898
|
name: "applies an update at the expected version, and answers the record written with its version one higher",
|
|
2794
2899
|
async run({ stores }) {
|
|
2795
2900
|
const record = userRecord();
|
|
2796
2901
|
await stores.users.insertUser(record);
|
|
2797
|
-
const written = await stores.users.updateUser(record.id, { updatedAt:
|
|
2902
|
+
const written = await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-01T00:00:00.000Z"), active: false }, 0);
|
|
2798
2903
|
const expected = {
|
|
2799
2904
|
...record,
|
|
2800
2905
|
active: false,
|
|
2801
2906
|
version: 1,
|
|
2802
|
-
updatedAt:
|
|
2907
|
+
updatedAt: at8("2026-02-01T00:00:00.000Z")
|
|
2803
2908
|
};
|
|
2804
2909
|
equal(written, expected, "updateUser should answer the record as written");
|
|
2805
2910
|
equal(await stores.users.findUser(record.id), expected, "findUser after updateUser");
|
|
@@ -2807,15 +2912,15 @@ var userVersionCases = [
|
|
|
2807
2912
|
},
|
|
2808
2913
|
{
|
|
2809
2914
|
id: "users.versionConflict",
|
|
2810
|
-
group:
|
|
2915
|
+
group: group36,
|
|
2811
2916
|
name: "refuses a stale version with both versions, and leaves the record identical byte for byte",
|
|
2812
2917
|
async run({ stores }) {
|
|
2813
2918
|
const record = userRecord();
|
|
2814
2919
|
await stores.users.insertUser(record);
|
|
2815
|
-
await stores.users.updateUser(record.id, { updatedAt:
|
|
2920
|
+
await stores.users.updateUser(record.id, { updatedAt: at8("2026-02-01T00:00:00.000Z"), active: false }, 0);
|
|
2816
2921
|
const before = await stores.users.findUser(record.id);
|
|
2817
2922
|
const error = await rejects(stores.users.updateUser(record.id, {
|
|
2818
|
-
updatedAt:
|
|
2923
|
+
updatedAt: at8("2026-03-01T00:00:00.000Z"),
|
|
2819
2924
|
active: true,
|
|
2820
2925
|
fields: { email: "overwritten@example.test" }
|
|
2821
2926
|
}, 0), "updateUser at a stale version should reject");
|
|
@@ -2828,10 +2933,10 @@ var userVersionCases = [
|
|
|
2828
2933
|
},
|
|
2829
2934
|
{
|
|
2830
2935
|
id: "users.unknownUpdate",
|
|
2831
|
-
group:
|
|
2936
|
+
group: group36,
|
|
2832
2937
|
name: "refuses an update to an unknown id with NotFoundError, told apart from a version conflict",
|
|
2833
2938
|
async run({ stores }) {
|
|
2834
|
-
const error = await rejects(stores.users.updateUser(mintId2(), { updatedAt:
|
|
2939
|
+
const error = await rejects(stores.users.updateUser(mintId2(), { updatedAt: at8("2026-02-01T00:00:00.000Z") }, 0), "updateUser on an unknown id should reject");
|
|
2835
2940
|
isOurs(error, NotFoundError2, "NotFoundError", "updateUser on an unknown id should reject with NotFoundError, not a version conflict");
|
|
2836
2941
|
}
|
|
2837
2942
|
}
|
|
@@ -3054,12 +3159,12 @@ function invitation(overrides = {}) {
|
|
|
3054
3159
|
}
|
|
3055
3160
|
|
|
3056
3161
|
// src/conformance/invitations/cases/actors.ts
|
|
3057
|
-
var
|
|
3162
|
+
var group37 = "invitations";
|
|
3058
3163
|
var t = new Date("2026-03-01T00:00:00.000Z");
|
|
3059
3164
|
var invitationActorCases = [
|
|
3060
3165
|
{
|
|
3061
3166
|
id: "invitations.update.actors",
|
|
3062
|
-
group:
|
|
3167
|
+
group: group37,
|
|
3063
3168
|
name: "updateInvitation stores revokedBy and resentBy, a record without them reads as absent or null, and null erases a resender",
|
|
3064
3169
|
async run({ store }) {
|
|
3065
3170
|
const { revokedBy: _r, resentBy: _s, ...bare } = invitation();
|
|
@@ -3092,13 +3197,13 @@ var invitationActorCases = [
|
|
|
3092
3197
|
];
|
|
3093
3198
|
|
|
3094
3199
|
// src/conformance/invitations/cases/find-pending.ts
|
|
3095
|
-
var
|
|
3200
|
+
var group38 = "invitations";
|
|
3096
3201
|
var lapsedAt = new Date("2026-05-01T00:00:00.000Z");
|
|
3097
3202
|
var t2 = new Date("2026-03-01T00:00:00.000Z");
|
|
3098
3203
|
var invitationFindPendingCases = [
|
|
3099
3204
|
{
|
|
3100
3205
|
id: "invitations.find-pending",
|
|
3101
|
-
group:
|
|
3206
|
+
group: group38,
|
|
3102
3207
|
name: "findPendingInvitation answers the pending invitation of an address in a scope, lapsed or not, and null for none",
|
|
3103
3208
|
async run({ store }) {
|
|
3104
3209
|
if (store.findPendingInvitation === undefined)
|
|
@@ -3141,11 +3246,11 @@ var invitationFindPendingCases = [
|
|
|
3141
3246
|
];
|
|
3142
3247
|
|
|
3143
3248
|
// src/conformance/invitations/cases/imported.ts
|
|
3144
|
-
var
|
|
3249
|
+
var group39 = "invitations";
|
|
3145
3250
|
var invitationImportedCases = [
|
|
3146
3251
|
{
|
|
3147
3252
|
id: "invitations.insert.imported",
|
|
3148
|
-
group:
|
|
3253
|
+
group: group39,
|
|
3149
3254
|
name: 'insertInvitation stores an imported accepted record and a revoked one with a codeHash that is not hex ("import:…") verbatim, and findInvitationByCodeHash finds each by it',
|
|
3150
3255
|
async run({ store }) {
|
|
3151
3256
|
const accepted = invitation({
|
|
@@ -3174,20 +3279,20 @@ var invitationImportedCases = [
|
|
|
3174
3279
|
];
|
|
3175
3280
|
|
|
3176
3281
|
// src/conformance/invitations/cases/insert.ts
|
|
3177
|
-
var
|
|
3178
|
-
var
|
|
3282
|
+
var group40 = "invitations";
|
|
3283
|
+
var at9 = (iso) => new Date(iso);
|
|
3179
3284
|
var invitationInsertCases = [
|
|
3180
3285
|
{
|
|
3181
3286
|
id: "invitations.insert",
|
|
3182
|
-
group:
|
|
3287
|
+
group: group40,
|
|
3183
3288
|
name: "insertInvitation stores an invitation that findInvitation and findInvitationByCodeHash answer verbatim, and null for an unknown id or hash",
|
|
3184
3289
|
async run({ store }) {
|
|
3185
3290
|
const record = invitation({
|
|
3186
3291
|
locale: "fr",
|
|
3187
3292
|
name: "Zoë “Z” Ünal",
|
|
3188
3293
|
acceptedBy: mintId2(),
|
|
3189
|
-
acceptedAt:
|
|
3190
|
-
revokedAt:
|
|
3294
|
+
acceptedAt: at9("2026-02-01T00:00:00.000Z"),
|
|
3295
|
+
revokedAt: at9("2026-02-02T00:00:00.000Z"),
|
|
3191
3296
|
status: "revoked"
|
|
3192
3297
|
});
|
|
3193
3298
|
equal(await store.insertInvitation(record), true, "insertInvitation: a new invitation answers true");
|
|
@@ -3199,7 +3304,7 @@ var invitationInsertCases = [
|
|
|
3199
3304
|
},
|
|
3200
3305
|
{
|
|
3201
3306
|
id: "invitations.insert.system",
|
|
3202
|
-
group:
|
|
3307
|
+
group: group40,
|
|
3203
3308
|
name: "insertInvitation stores an invitation issued by the system (invitedBy: null) and reads it back as null, not as a missing field or a placeholder",
|
|
3204
3309
|
async run({ store }) {
|
|
3205
3310
|
const record = invitation({ invitedBy: null });
|
|
@@ -3216,7 +3321,7 @@ var invitationInsertCases = [
|
|
|
3216
3321
|
},
|
|
3217
3322
|
{
|
|
3218
3323
|
id: "invitations.insert.type",
|
|
3219
|
-
group:
|
|
3324
|
+
group: group40,
|
|
3220
3325
|
name: "insertInvitation keeps the user type as stored: a name stays that name and null stays null",
|
|
3221
3326
|
async run({ store }) {
|
|
3222
3327
|
const named = invitation({ type: "guardian" });
|
|
@@ -3230,15 +3335,15 @@ var invitationInsertCases = [
|
|
|
3230
3335
|
},
|
|
3231
3336
|
{
|
|
3232
3337
|
id: "invitations.insert.idempotent",
|
|
3233
|
-
group:
|
|
3338
|
+
group: group40,
|
|
3234
3339
|
name: "insertInvitation is idempotent by id: a retry writes nothing, answers true and does not throw",
|
|
3235
3340
|
async run({ store }) {
|
|
3236
3341
|
const record = invitation();
|
|
3237
3342
|
await store.insertInvitation(record);
|
|
3238
3343
|
await store.updateInvitation(record.id, 0, {
|
|
3239
|
-
updatedAt:
|
|
3344
|
+
updatedAt: at9("2026-03-01T00:00:00.000Z"),
|
|
3240
3345
|
status: "revoked",
|
|
3241
|
-
revokedAt:
|
|
3346
|
+
revokedAt: at9("2026-03-01T00:00:00.000Z")
|
|
3242
3347
|
});
|
|
3243
3348
|
equal(await store.insertInvitation({ ...record, name: "replayed" }), true, "insertInvitation: a replay of a stored id answers true");
|
|
3244
3349
|
equal((await store.findInvitation(record.id))?.name, record.name, "insertInvitation replayed should leave the stored invitation untouched");
|
|
@@ -3247,7 +3352,7 @@ var invitationInsertCases = [
|
|
|
3247
3352
|
},
|
|
3248
3353
|
{
|
|
3249
3354
|
id: "invitations.insert.one-pending",
|
|
3250
|
-
group:
|
|
3355
|
+
group: group40,
|
|
3251
3356
|
name: "insertInvitation answers false when the scope and address already hold a pending invitation, and writes nothing",
|
|
3252
3357
|
async run({ store }) {
|
|
3253
3358
|
const first = invitation({ email: "ada@example.com" });
|
|
@@ -3261,7 +3366,7 @@ var invitationInsertCases = [
|
|
|
3261
3366
|
},
|
|
3262
3367
|
{
|
|
3263
3368
|
id: "invitations.insert.one-pending.concurrent",
|
|
3264
|
-
group:
|
|
3369
|
+
group: group40,
|
|
3265
3370
|
name: "of 20 concurrent insertInvitation calls for one scope and address exactly one answers true and the others false, leaving one pending invitation",
|
|
3266
3371
|
async run({ store }) {
|
|
3267
3372
|
const records = Array.from({ length: 20 }, () => invitation({ email: "race@example.com" }));
|
|
@@ -3272,15 +3377,15 @@ var invitationInsertCases = [
|
|
|
3272
3377
|
},
|
|
3273
3378
|
{
|
|
3274
3379
|
id: "invitations.insert.after-final",
|
|
3275
|
-
group:
|
|
3380
|
+
group: group40,
|
|
3276
3381
|
name: "a revoked or accepted invitation frees its scope and address for a new pending one",
|
|
3277
3382
|
async run({ store }) {
|
|
3278
3383
|
const old = invitation({ email: "ada@example.com" });
|
|
3279
3384
|
await store.insertInvitation(old);
|
|
3280
3385
|
await store.updateInvitation(old.id, 0, {
|
|
3281
|
-
updatedAt:
|
|
3386
|
+
updatedAt: at9("2026-03-01T00:00:00.000Z"),
|
|
3282
3387
|
status: "revoked",
|
|
3283
|
-
revokedAt:
|
|
3388
|
+
revokedAt: at9("2026-03-01T00:00:00.000Z")
|
|
3284
3389
|
});
|
|
3285
3390
|
const fresh = invitation({ email: "ada@example.com" });
|
|
3286
3391
|
equal(await store.insertInvitation(fresh), true, "insertInvitation: a revoked invitation no longer holds the address");
|
|
@@ -3290,11 +3395,11 @@ var invitationInsertCases = [
|
|
|
3290
3395
|
];
|
|
3291
3396
|
|
|
3292
3397
|
// src/conformance/invitations/cases/list.ts
|
|
3293
|
-
var
|
|
3398
|
+
var group41 = "invitations";
|
|
3294
3399
|
var invitationListCases = [
|
|
3295
3400
|
{
|
|
3296
3401
|
id: "invitations.list",
|
|
3297
|
-
group:
|
|
3402
|
+
group: group41,
|
|
3298
3403
|
name: "listScopeInvitations pages one scope’s invitations in id order with a cursor, and leaves other scopes out",
|
|
3299
3404
|
async run({ store }) {
|
|
3300
3405
|
const scope = `org-${mintId2()}`;
|
|
@@ -3336,7 +3441,7 @@ var invitationListCases = [
|
|
|
3336
3441
|
},
|
|
3337
3442
|
{
|
|
3338
3443
|
id: "invitations.list-filters",
|
|
3339
|
-
group:
|
|
3444
|
+
group: group41,
|
|
3340
3445
|
name: "listScopeInvitations filters by role and ref, pages newest first with order desc, and stores the ref verbatim",
|
|
3341
3446
|
async run({ store }) {
|
|
3342
3447
|
const scope = `org-${mintId2()}`;
|
|
@@ -3376,7 +3481,7 @@ var invitationListCases = [
|
|
|
3376
3481
|
},
|
|
3377
3482
|
{
|
|
3378
3483
|
id: "invitations.count",
|
|
3379
|
-
group:
|
|
3484
|
+
group: group41,
|
|
3380
3485
|
name: "countScopeInvitations counts one scope by status, role and ref, whatever the page",
|
|
3381
3486
|
async run({ store }) {
|
|
3382
3487
|
if (store.countScopeInvitations === undefined)
|
|
@@ -3407,7 +3512,7 @@ var invitationListCases = [
|
|
|
3407
3512
|
];
|
|
3408
3513
|
|
|
3409
3514
|
// src/conformance/invitations/cases/list-lapsed.ts
|
|
3410
|
-
var
|
|
3515
|
+
var group42 = "invitations";
|
|
3411
3516
|
var now3 = new Date("2026-06-01T00:00:00.000Z");
|
|
3412
3517
|
var before2 = new Date("2026-05-01T00:00:00.000Z");
|
|
3413
3518
|
var after = new Date("2026-07-01T00:00:00.000Z");
|
|
@@ -3434,7 +3539,7 @@ async function seed2(store) {
|
|
|
3434
3539
|
var invitationListLapsedCases = [
|
|
3435
3540
|
{
|
|
3436
3541
|
id: "invitations.list.lapsed",
|
|
3437
|
-
group:
|
|
3542
|
+
group: group42,
|
|
3438
3543
|
name: "listScopeInvitations leaves lapsed pending invitations out or keeps only them, the boundary lapsed, accepted and revoked never",
|
|
3439
3544
|
async run({ store }) {
|
|
3440
3545
|
const { scope, ids } = await seed2(store);
|
|
@@ -3462,7 +3567,7 @@ var invitationListLapsedCases = [
|
|
|
3462
3567
|
},
|
|
3463
3568
|
{
|
|
3464
3569
|
id: "invitations.count.lapsed",
|
|
3465
|
-
group:
|
|
3570
|
+
group: group42,
|
|
3466
3571
|
name: "countScopeInvitations follows the lapsed filter, alone and with a status",
|
|
3467
3572
|
async run({ store }) {
|
|
3468
3573
|
if (store.countScopeInvitations === undefined)
|
|
@@ -3485,13 +3590,13 @@ var invitationListLapsedCases = [
|
|
|
3485
3590
|
];
|
|
3486
3591
|
|
|
3487
3592
|
// src/conformance/invitations/cases/list-status.ts
|
|
3488
|
-
var
|
|
3489
|
-
var
|
|
3490
|
-
var t3 =
|
|
3593
|
+
var group43 = "invitations";
|
|
3594
|
+
var at10 = (iso) => new Date(iso);
|
|
3595
|
+
var t3 = at10("2026-03-01T00:00:00.000Z");
|
|
3491
3596
|
var invitationListStatusCases = [
|
|
3492
3597
|
{
|
|
3493
3598
|
id: "invitations.list.status",
|
|
3494
|
-
group:
|
|
3599
|
+
group: group43,
|
|
3495
3600
|
name: "listScopeInvitations filters by status, and the cursor pages within the filter",
|
|
3496
3601
|
async run({ store }) {
|
|
3497
3602
|
const scope = `org-${mintId2()}`;
|
|
@@ -3533,13 +3638,13 @@ var invitationListStatusCases = [
|
|
|
3533
3638
|
];
|
|
3534
3639
|
|
|
3535
3640
|
// src/conformance/invitations/cases/scope.ts
|
|
3536
|
-
var
|
|
3537
|
-
var
|
|
3538
|
-
var t4 =
|
|
3641
|
+
var group44 = "invitations";
|
|
3642
|
+
var at11 = (iso) => new Date(iso);
|
|
3643
|
+
var t4 = at11("2026-03-01T00:00:00.000Z");
|
|
3539
3644
|
var invitationScopeCases = [
|
|
3540
3645
|
{
|
|
3541
3646
|
id: "invitations.get",
|
|
3542
|
-
group:
|
|
3647
|
+
group: group44,
|
|
3543
3648
|
name: "findInvitation answers the invitation with the scope it was stored in, and null for an id nobody stored",
|
|
3544
3649
|
async run({ store }) {
|
|
3545
3650
|
const scope = `org-${mintId2()}`;
|
|
@@ -3556,15 +3661,15 @@ var invitationScopeCases = [
|
|
|
3556
3661
|
},
|
|
3557
3662
|
{
|
|
3558
3663
|
id: "invitations.count-pending",
|
|
3559
|
-
group:
|
|
3664
|
+
group: group44,
|
|
3560
3665
|
name: "countPendingInvitations counts one scope’s pending invitations that have not lapsed, and 0 for none",
|
|
3561
3666
|
async run({ store }) {
|
|
3562
3667
|
const scope = `org-${mintId2()}`;
|
|
3563
|
-
const now =
|
|
3668
|
+
const now = at11("2026-06-01T00:00:00.000Z");
|
|
3564
3669
|
const standing = invitation({ scope });
|
|
3565
3670
|
const lapsed = invitation({
|
|
3566
3671
|
scope,
|
|
3567
|
-
expiresAt:
|
|
3672
|
+
expiresAt: at11("2026-05-01T00:00:00.000Z")
|
|
3568
3673
|
});
|
|
3569
3674
|
const atNow = invitation({ scope, expiresAt: now });
|
|
3570
3675
|
const revoked = invitation({ scope });
|
|
@@ -3584,7 +3689,7 @@ var invitationScopeCases = [
|
|
|
3584
3689
|
},
|
|
3585
3690
|
{
|
|
3586
3691
|
id: "invitations.delete-scope",
|
|
3587
|
-
group:
|
|
3692
|
+
group: group44,
|
|
3588
3693
|
name: "deleteScopeInvitations deletes every invitation of one scope, whatever its status, and answers how many",
|
|
3589
3694
|
async run({ store }) {
|
|
3590
3695
|
const scope = `org-${mintId2()}`;
|
|
@@ -3605,31 +3710,31 @@ var invitationScopeCases = [
|
|
|
3605
3710
|
},
|
|
3606
3711
|
{
|
|
3607
3712
|
id: "invitations.delete-expired",
|
|
3608
|
-
group:
|
|
3713
|
+
group: group44,
|
|
3609
3714
|
name: "deleteExpiredInvitations, when implemented, deletes invitations expiring at or before the instant and answers how many",
|
|
3610
3715
|
async run({ store }) {
|
|
3611
3716
|
if (store.deleteExpiredInvitations === undefined)
|
|
3612
3717
|
return;
|
|
3613
|
-
const old = invitation({ expiresAt:
|
|
3614
|
-
const edge = invitation({ expiresAt:
|
|
3615
|
-
const live = invitation({ expiresAt:
|
|
3718
|
+
const old = invitation({ expiresAt: at11("2026-01-10T00:00:00.000Z") });
|
|
3719
|
+
const edge = invitation({ expiresAt: at11("2026-02-01T00:00:00.000Z") });
|
|
3720
|
+
const live = invitation({ expiresAt: at11("2026-03-01T00:00:00.000Z") });
|
|
3616
3721
|
await store.insertInvitation(old);
|
|
3617
3722
|
await store.insertInvitation(edge);
|
|
3618
3723
|
await store.insertInvitation(live);
|
|
3619
|
-
equal(await store.deleteExpiredInvitations(
|
|
3724
|
+
equal(await store.deleteExpiredInvitations(at11("2026-02-01T00:00:00.000Z")), 2, "deleteExpiredInvitations: at or before the instant");
|
|
3620
3725
|
equal(await store.findInvitation(live.id), live, "deleteExpiredInvitations: a later one is kept");
|
|
3621
3726
|
}
|
|
3622
3727
|
}
|
|
3623
3728
|
];
|
|
3624
3729
|
|
|
3625
3730
|
// src/conformance/invitations/cases/update.ts
|
|
3626
|
-
var
|
|
3627
|
-
var
|
|
3628
|
-
var t5 =
|
|
3731
|
+
var group45 = "invitations";
|
|
3732
|
+
var at12 = (iso) => new Date(iso);
|
|
3733
|
+
var t5 = at12("2026-03-01T00:00:00.000Z");
|
|
3629
3734
|
var invitationUpdateCases = [
|
|
3630
3735
|
{
|
|
3631
3736
|
id: "invitations.update",
|
|
3632
|
-
group:
|
|
3737
|
+
group: group45,
|
|
3633
3738
|
name: "updateInvitation applies a patch under ifVersion, answers the record as written with version + 1, and leaves unnamed fields alone",
|
|
3634
3739
|
async run({ store }) {
|
|
3635
3740
|
const record = invitation({ locale: "fr" });
|
|
@@ -3656,13 +3761,13 @@ var invitationUpdateCases = [
|
|
|
3656
3761
|
},
|
|
3657
3762
|
{
|
|
3658
3763
|
id: "invitations.update.fields",
|
|
3659
|
-
group:
|
|
3764
|
+
group: group45,
|
|
3660
3765
|
name: "updateInvitation replaces codeHash, expiresAt and locale whole, and a null locale erases it",
|
|
3661
3766
|
async run({ store }) {
|
|
3662
3767
|
const record = invitation({ locale: "fr" });
|
|
3663
3768
|
await store.insertInvitation(record);
|
|
3664
3769
|
const codeHash = "c".repeat(64);
|
|
3665
|
-
const expiresAt =
|
|
3770
|
+
const expiresAt = at12("2028-01-01T00:00:00.000Z");
|
|
3666
3771
|
await store.updateInvitation(record.id, 0, {
|
|
3667
3772
|
updatedAt: t5,
|
|
3668
3773
|
codeHash,
|
|
@@ -3682,7 +3787,7 @@ var invitationUpdateCases = [
|
|
|
3682
3787
|
},
|
|
3683
3788
|
{
|
|
3684
3789
|
id: "invitations.update.absent",
|
|
3685
|
-
group:
|
|
3790
|
+
group: group45,
|
|
3686
3791
|
name: "updateInvitation answers null, writing nothing, for an id that is not stored",
|
|
3687
3792
|
async run({ store }) {
|
|
3688
3793
|
isNull(await store.updateInvitation(mintId2(), 0, {
|
|
@@ -3694,7 +3799,7 @@ var invitationUpdateCases = [
|
|
|
3694
3799
|
},
|
|
3695
3800
|
{
|
|
3696
3801
|
id: "invitations.update.version",
|
|
3697
|
-
group:
|
|
3802
|
+
group: group45,
|
|
3698
3803
|
name: "updateInvitation throws StoreConflict on a version that moved, writing nothing",
|
|
3699
3804
|
async run({ store }) {
|
|
3700
3805
|
const record = invitation();
|
|
@@ -3712,7 +3817,7 @@ var invitationUpdateCases = [
|
|
|
3712
3817
|
},
|
|
3713
3818
|
{
|
|
3714
3819
|
id: "invitations.update.concurrent",
|
|
3715
|
-
group:
|
|
3820
|
+
group: group45,
|
|
3716
3821
|
name: "updateInvitation: of 20 concurrent claims on one version exactly one wins and the others throw StoreConflict",
|
|
3717
3822
|
async run({ store }) {
|
|
3718
3823
|
const record = invitation();
|
|
@@ -3734,7 +3839,7 @@ var invitationUpdateCases = [
|
|
|
3734
3839
|
},
|
|
3735
3840
|
{
|
|
3736
3841
|
id: "invitations.update.release",
|
|
3737
|
-
group:
|
|
3842
|
+
group: group45,
|
|
3738
3843
|
name: "updateInvitation can release a claim to pending, but throws StoreConflict when another pending invitation holds the address",
|
|
3739
3844
|
async run({ store }) {
|
|
3740
3845
|
const record = invitation({ email: "ada@example.com" });
|
|
@@ -3941,11 +4046,11 @@ var tuple = (object, relation, subject) => ({ object, relation, subject });
|
|
|
3941
4046
|
var sorted = (subjects) => subjects.map(formatSubject2).sort();
|
|
3942
4047
|
|
|
3943
4048
|
// src/conformance/relations/cases/deletion.ts
|
|
3944
|
-
var
|
|
4049
|
+
var group46 = "relations";
|
|
3945
4050
|
var relationDeletionCases = [
|
|
3946
4051
|
{
|
|
3947
4052
|
id: "relations.deleteEntity",
|
|
3948
|
-
group:
|
|
4053
|
+
group: group46,
|
|
3949
4054
|
name: "deletes every tuple naming an entity — as object, as subject, as a set’s entity — and counts them",
|
|
3950
4055
|
async run({ store }) {
|
|
3951
4056
|
const team = entity("team");
|
|
@@ -3972,11 +4077,11 @@ var relationDeletionCases = [
|
|
|
3972
4077
|
];
|
|
3973
4078
|
|
|
3974
4079
|
// src/conformance/relations/cases/holders.ts
|
|
3975
|
-
var
|
|
4080
|
+
var group47 = "relations";
|
|
3976
4081
|
var relationHolderCases = [
|
|
3977
4082
|
{
|
|
3978
4083
|
id: "relations.findHolders",
|
|
3979
|
-
group:
|
|
4084
|
+
group: group47,
|
|
3980
4085
|
name: "findHolders pages the single entities of one object and relation in type then id order, with a cursor, and leaves out subject sets and other relations",
|
|
3981
4086
|
async run({ store }) {
|
|
3982
4087
|
if (store.findHolders === undefined)
|
|
@@ -4013,7 +4118,7 @@ var relationHolderCases = [
|
|
|
4013
4118
|
},
|
|
4014
4119
|
{
|
|
4015
4120
|
id: "relations.findHolders.search",
|
|
4016
|
-
group:
|
|
4121
|
+
group: group47,
|
|
4017
4122
|
name: "findHolders search keeps the holders whose id contains the text, ignoring case, and takes % _ . and \\ literally",
|
|
4018
4123
|
async run({ store }) {
|
|
4019
4124
|
if (store.findHolders === undefined)
|
|
@@ -4050,7 +4155,7 @@ var relationHolderCases = [
|
|
|
4050
4155
|
},
|
|
4051
4156
|
{
|
|
4052
4157
|
id: "relations.findHolders.cursor",
|
|
4053
|
-
group:
|
|
4158
|
+
group: group47,
|
|
4054
4159
|
name: "findHolders refuses a cursor it did not mint with InvalidCursorError, never the first page",
|
|
4055
4160
|
async run({ store }) {
|
|
4056
4161
|
if (store.findHolders === undefined)
|
|
@@ -4073,11 +4178,11 @@ var relationHolderCases = [
|
|
|
4073
4178
|
];
|
|
4074
4179
|
|
|
4075
4180
|
// src/conformance/relations/cases/reads.ts
|
|
4076
|
-
var
|
|
4181
|
+
var group48 = "relations";
|
|
4077
4182
|
var relationReadCases = [
|
|
4078
4183
|
{
|
|
4079
4184
|
id: "relations.roundTrip",
|
|
4080
|
-
group:
|
|
4185
|
+
group: group48,
|
|
4081
4186
|
name: "holds exactly the tuples written, byte for byte: staff:u1 is not patient:u1, and a set is not its entity",
|
|
4082
4187
|
async run({ store }) {
|
|
4083
4188
|
const record = entity("record", "R:1 — ÿ");
|
|
@@ -4093,7 +4198,7 @@ var relationReadCases = [
|
|
|
4093
4198
|
},
|
|
4094
4199
|
{
|
|
4095
4200
|
id: "relations.edgeCharacters",
|
|
4096
|
-
group:
|
|
4201
|
+
group: group48,
|
|
4097
4202
|
name: "round-trips every character the core lets through in an id: control characters, U+FFFF and a surrogate pair",
|
|
4098
4203
|
async run({ store }) {
|
|
4099
4204
|
const edge = "a\x01\x1F \uD83D\uDE00 z";
|
|
@@ -4116,7 +4221,7 @@ var relationReadCases = [
|
|
|
4116
4221
|
},
|
|
4117
4222
|
{
|
|
4118
4223
|
id: "relations.undefinedRelation",
|
|
4119
|
-
group:
|
|
4224
|
+
group: group48,
|
|
4120
4225
|
name: "reads a subject whose relation is undefined as its entity, not as a set",
|
|
4121
4226
|
async run({ store }) {
|
|
4122
4227
|
const record = entity("record");
|
|
@@ -4146,7 +4251,7 @@ var relationReadCases = [
|
|
|
4146
4251
|
},
|
|
4147
4252
|
{
|
|
4148
4253
|
id: "relations.absence",
|
|
4149
|
-
group:
|
|
4254
|
+
group: group48,
|
|
4150
4255
|
name: "answers false, [], an empty page and 0 for an empty store — never null or undefined",
|
|
4151
4256
|
async run({ store }) {
|
|
4152
4257
|
const record = entity("record");
|
|
@@ -4167,11 +4272,11 @@ var relationReadCases = [
|
|
|
4167
4272
|
];
|
|
4168
4273
|
|
|
4169
4274
|
// src/conformance/relations/cases/traversal.ts
|
|
4170
|
-
var
|
|
4275
|
+
var group49 = "relations";
|
|
4171
4276
|
var relationTraversalCases = [
|
|
4172
4277
|
{
|
|
4173
4278
|
id: "relations.oneHop",
|
|
4174
|
-
group:
|
|
4279
|
+
group: group49,
|
|
4175
4280
|
name: "answers one hop: the subject sets and the entities holding one relation on one object, and nothing else",
|
|
4176
4281
|
async run({ store }) {
|
|
4177
4282
|
const record = entity("record");
|
|
@@ -4195,7 +4300,7 @@ var relationTraversalCases = [
|
|
|
4195
4300
|
},
|
|
4196
4301
|
{
|
|
4197
4302
|
id: "relations.objects",
|
|
4198
|
-
group:
|
|
4303
|
+
group: group49,
|
|
4199
4304
|
name: "pages 25 objects by 10 in ascending id order, for one type, relation and exact subject, and ends on a null cursor",
|
|
4200
4305
|
async run({ store }) {
|
|
4201
4306
|
const staff = entity("staff");
|
|
@@ -4242,11 +4347,11 @@ var relationTraversalCases = [
|
|
|
4242
4347
|
];
|
|
4243
4348
|
|
|
4244
4349
|
// src/conformance/relations/cases/writes.ts
|
|
4245
|
-
var
|
|
4350
|
+
var group50 = "relations";
|
|
4246
4351
|
var relationWriteCases = [
|
|
4247
4352
|
{
|
|
4248
4353
|
id: "relations.idempotentWrite",
|
|
4249
|
-
group:
|
|
4354
|
+
group: group50,
|
|
4250
4355
|
name: "is idempotent under retry: adding a stored tuple and removing an absent one write nothing",
|
|
4251
4356
|
async run({ store }) {
|
|
4252
4357
|
const record = entity("record");
|
|
@@ -4259,7 +4364,7 @@ var relationWriteCases = [
|
|
|
4259
4364
|
},
|
|
4260
4365
|
{
|
|
4261
4366
|
id: "relations.uniqueness",
|
|
4262
|
-
group:
|
|
4367
|
+
group: group50,
|
|
4263
4368
|
name: "keeps one tuple when twenty concurrent writes add it: uniqueness is a constraint, not a read",
|
|
4264
4369
|
async run({ store }) {
|
|
4265
4370
|
const record = entity("record");
|
|
@@ -4270,7 +4375,7 @@ var relationWriteCases = [
|
|
|
4270
4375
|
},
|
|
4271
4376
|
{
|
|
4272
4377
|
id: "relations.removeThenAdd",
|
|
4273
|
-
group:
|
|
4378
|
+
group: group50,
|
|
4274
4379
|
name: "applies one write’s removals and additions together",
|
|
4275
4380
|
async run({ store }) {
|
|
4276
4381
|
const record = entity("record");
|
|
@@ -4438,5 +4543,5 @@ export {
|
|
|
4438
4543
|
userStoreCases
|
|
4439
4544
|
};
|
|
4440
4545
|
|
|
4441
|
-
//# debugId=
|
|
4546
|
+
//# debugId=88D1585A4D4695DA64756E2164756E21
|
|
4442
4547
|
//# sourceMappingURL=index.js.map
|