@happyvertical/smrt-users 0.57.20 → 0.57.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/AGENTS.md +101 -0
  2. package/dist/chunks/{PasswordCredentialService-DezdsV_v.js → PasswordCredentialService-DA2Y6H2X.js} +8 -2
  3. package/dist/chunks/PasswordCredentialService-DA2Y6H2X.js.map +1 -0
  4. package/dist/chunks/{TerminalAuthService-_IB-tAgS.js → TerminalAuthService-pHNqf5o3.js} +3 -3
  5. package/dist/chunks/TerminalAuthService-pHNqf5o3.js.map +1 -0
  6. package/dist/collections/MagicLinkTokenCollection.d.ts +2 -0
  7. package/dist/collections/MagicLinkTokenCollection.d.ts.map +1 -1
  8. package/dist/collections/UserCollection.d.ts +2 -0
  9. package/dist/collections/UserCollection.d.ts.map +1 -1
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +477 -14
  13. package/dist/index.js.map +1 -1
  14. package/dist/manifest.json +34 -1
  15. package/dist/operator.js +1 -1
  16. package/dist/services/LoginAttemptLimiter.d.ts +2 -0
  17. package/dist/services/LoginAttemptLimiter.d.ts.map +1 -1
  18. package/dist/services/MagicLinkService.d.ts +11 -1
  19. package/dist/services/MagicLinkService.d.ts.map +1 -1
  20. package/dist/services/MailboxAuthenticationService.d.ts +61 -0
  21. package/dist/services/MailboxAuthenticationService.d.ts.map +1 -0
  22. package/dist/services/TenantInvitationService.d.ts +120 -0
  23. package/dist/services/TenantInvitationService.d.ts.map +1 -0
  24. package/dist/services/index.d.ts +2 -0
  25. package/dist/services/index.d.ts.map +1 -1
  26. package/dist/smrt-knowledge.json +38 -5
  27. package/dist/sveltekit.js +2 -2
  28. package/package.json +10 -10
  29. package/dist/chunks/PasswordCredentialService-DezdsV_v.js.map +0 -1
  30. package/dist/chunks/TerminalAuthService-_IB-tAgS.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-users",
5
- "packageVersion": "0.57.20",
5
+ "packageVersion": "0.57.22",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-users:AccessRequestCollection": {
8
8
  "name": "accessrequestcollection",
@@ -1544,6 +1544,25 @@
1544
1544
  "isStatic": false,
1545
1545
  "isPublic": true
1546
1546
  },
1547
+ "isAvailable": {
1548
+ "name": "isAvailable",
1549
+ "async": true,
1550
+ "parameters": [
1551
+ {
1552
+ "name": "nonce",
1553
+ "type": "string",
1554
+ "optional": false
1555
+ },
1556
+ {
1557
+ "name": "email",
1558
+ "type": "string",
1559
+ "optional": false
1560
+ }
1561
+ ],
1562
+ "returnType": "Promise<boolean>",
1563
+ "isStatic": false,
1564
+ "isPublic": true
1565
+ },
1547
1566
  "markUsed": {
1548
1567
  "name": "markUsed",
1549
1568
  "async": true,
@@ -6339,6 +6358,20 @@
6339
6358
  "isStatic": false,
6340
6359
  "isPublic": true
6341
6360
  },
6361
+ "findCanonicalByEmail": {
6362
+ "name": "findCanonicalByEmail",
6363
+ "async": true,
6364
+ "parameters": [
6365
+ {
6366
+ "name": "email",
6367
+ "type": "string",
6368
+ "optional": false
6369
+ }
6370
+ ],
6371
+ "returnType": "Promise<User | null>",
6372
+ "isStatic": false,
6373
+ "isPublic": true
6374
+ },
6342
6375
  "findByProfile": {
6343
6376
  "name": "findByProfile",
6344
6377
  "async": true,
package/dist/operator.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Dt as normalizeUsername, Et as normalizeEmail, L as UserCollection, P as verifySecretHash, Tt as isValidEmail, U as TenantCollection, _ as PermissionResolver, ct as UsersPasswordCredentialCollection, f as PasswordCredentialService, ft as MembershipCollection, ot as RoleCollection } from "./chunks/PasswordCredentialService-DezdsV_v.js";
1
+ import { Dt as normalizeUsername, Et as normalizeEmail, L as UserCollection, P as verifySecretHash, Tt as isValidEmail, U as TenantCollection, _ as PermissionResolver, ct as UsersPasswordCredentialCollection, f as PasswordCredentialService, ft as MembershipCollection, ot as RoleCollection } from "./chunks/PasswordCredentialService-DA2Y6H2X.js";
2
2
  import { a as MembershipStatus, l as TenantStatus, u as UserStatus } from "./chunks/types-DFqeph0R.js";
3
3
  import { isPostgresDatabase, withEmbeddedWriteTransaction } from "@happyvertical/smrt-core";
4
4
  import { withSystemContext } from "@happyvertical/smrt-tenancy";
@@ -169,6 +169,8 @@ export interface ReserveLoginAttemptOptions {
169
169
  * must not pool with the others prefixes its own subject.
170
170
  */
171
171
  kind: string;
172
+ /** Keep a successful request reservation until window expiry (e.g. auth mail sends). */
173
+ retainOnSuccess?: boolean;
172
174
  /** Identifier the client submitted (email key, user id, tag hash). */
173
175
  subject?: string | null;
174
176
  /** Client IP, or device/station id. */
@@ -1 +1 @@
1
- {"version":3,"file":"LoginAttemptLimiter.d.ts","sourceRoot":"","sources":["../../src/services/LoginAttemptLimiter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,+CAA+C;AAC/C,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAC5C,0CAA0C;AAC1C,eAAO,MAAM,oCAAoC,QAAS,CAAC;AAC3D,wCAAwC;AACxC,eAAO,MAAM,kCAAkC,KAAK,CAAC;AACrD,mEAAmE;AACnE,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,wCAAwC;AACxC,eAAO,MAAM,iCAAiC,QAAU,CAAC;AACzD,uFAAuF;AACvF,eAAO,MAAM,oCAAoC,QAAS,CAAC;AAI3D,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;I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IAC/C,OAAO,CAAC,KAAK,CAA+B;gBAEhC,OAAO,EAAE,0BAA0B;IAmB/C,mEAAmE;IACnE,IAAI,YAAY,IAAI,OAAO,CAE1B;WAEY,MAAM,CACjB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,mBAAmB,CAAC;IAMzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAWjC,kFAAkF;IAClF,OAAO,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAQtD;;;OAGG;IACH,YAAY,CACV,gBAAgB,EAAE,MAAM,EACxB,KAAK,GAAE,iBAA6B,GACnC,MAAM;IAUT,OAAO,CAAC,SAAS;IAIjB;;;;OAIG;IACG,OAAO,CACX,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,oBAAoB,CAAC;IA0IhC,uEAAuE;IACjE,gBAAgB,CAAC,KAAK,EAAE;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,IAAI,CAAC;IAajB,iDAAiD;IAC3C,WAAW,CAAC,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,MAAM,CAAC;YAIxD,UAAU;IAsBxB;;;;;OAKG;YACW,mBAAmB;YAoCnB,MAAM;CASrB"}
@@ -56,6 +56,8 @@ export interface MagicLinkVerifyResult {
56
56
  email: string;
57
57
  /** The nonce (for correlation/logging) */
58
58
  nonce: string;
59
+ /** Optional signed immutable identity binding supplied by a trusted host. */
60
+ subject?: string;
59
61
  }
60
62
  /**
61
63
  * Error class for magic link authentication failures
@@ -91,7 +93,9 @@ export declare class MagicLinkService {
91
93
  * Stores a nonce in the database for replay protection.
92
94
  * The caller is responsible for emailing the token to the user.
93
95
  */
94
- generate(email: string): Promise<MagicLinkResult>;
96
+ generate(email: string, options?: {
97
+ subject?: string;
98
+ }): Promise<MagicLinkResult>;
95
99
  /**
96
100
  * Verify a magic link token.
97
101
  *
@@ -101,6 +105,12 @@ export declare class MagicLinkService {
101
105
  * @throws {MagicLinkError} If the token is invalid, expired, or already used
102
106
  */
103
107
  verify(token: string): Promise<MagicLinkVerifyResult>;
108
+ /**
109
+ * Validate a signed live nonce without consuming it. This is preparation only,
110
+ * never authentication: a final verify() must atomically claim the token.
111
+ */
112
+ inspect(token: string): Promise<MagicLinkVerifyResult>;
113
+ private verifySignature;
104
114
  /**
105
115
  * Clean up expired tokens (run periodically)
106
116
  */
@@ -1 +1 @@
1
- {"version":3,"file":"MagicLinkService.d.ts","sourceRoot":"","sources":["../../src/services/MagicLinkService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAKjE;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,qBA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,MAAM,WAAW,qBAAqB;IACpC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,eAAe,CAAiC;IACxD,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;gBAEtC,OAAO,EAAE,uBAAuB;IAU5C;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjC;;OAEG;YACW,aAAa;IAW3B;;;;;OAKG;IACG,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAO,GACjC,OAAO,CAAC,eAAe,CAAC;IAqC3B;;;;;;;OAOG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAO3D;;;OAGG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAO9C,eAAe;IAkC7B;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7C;;OAEG;WACU,MAAM,CACjB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,gBAAgB,CAAC;CAK7B"}
@@ -0,0 +1,61 @@
1
+ /** Independent emailed mailbox authentication for existing active canonical users. */
2
+ import { type SmrtClassOptions } from '@happyvertical/smrt-core';
3
+ import { type LoginAttemptLimiter } from './LoginAttemptLimiter.js';
4
+ /** Server-only effect. Never return, log, preview, or expose the mailed proof. */
5
+ export type MailboxAuthenticationDelivery = (mail: {
6
+ email: string;
7
+ token: string;
8
+ expiresAt: Date;
9
+ }) => Promise<void>;
10
+ export interface MailboxAuthenticationServiceOptions extends SmrtClassOptions {
11
+ transaction: 'caller';
12
+ secret: string;
13
+ /** Required for request(): supply a root-executor limiter independent of the caller transaction. Completion-only use may omit it. */
14
+ loginLimiter?: LoginAttemptLimiter;
15
+ }
16
+ export interface AuthenticatedMailbox {
17
+ userId: string;
18
+ profileId: string;
19
+ tenantId: string;
20
+ }
21
+ /** Canonical shared request budget; keys are hashed/peppered by LoginAttemptLimiter. */
22
+ export declare function reserveMailboxRequest(input: {
23
+ subject: string;
24
+ sourceKey: string;
25
+ limiter?: LoginAttemptLimiter;
26
+ }): Promise<void>;
27
+ /** Preserve existing signed-in identity and session ceilings during mailbox login. */
28
+ export declare function assertMailboxSessionCompatibility(options: SmrtClassOptions, input: {
29
+ userId: string;
30
+ expectedUserId?: string;
31
+ sessionId?: string;
32
+ }): Promise<void>;
33
+ /**
34
+ * Caller owns transaction and trusted email transport. No sessions are minted.
35
+ * Request response is uniform for unknown/ineligible email; mail goes only to
36
+ * canonical active accounts. A delivered proof can authenticate only after the
37
+ * request transaction commits. Transport failure must reject and roll it back.
38
+ * The host should return a uniform HTTP response and run transport off the
39
+ * response timing path where supported; transport latency is not identity proof.
40
+ */
41
+ export declare class MailboxAuthenticationService {
42
+ private readonly options;
43
+ private readonly auth;
44
+ private constructor();
45
+ static create(options: MailboxAuthenticationServiceOptions): Promise<MailboxAuthenticationService>;
46
+ request(input: {
47
+ email: string;
48
+ sourceKey: string;
49
+ deliver: MailboxAuthenticationDelivery;
50
+ }): Promise<{
51
+ requested: true;
52
+ }>;
53
+ authenticate(input: {
54
+ token: string;
55
+ expectedUserId?: string;
56
+ sessionId?: string;
57
+ }): Promise<AuthenticatedMailbox>;
58
+ private links;
59
+ private eligible;
60
+ }
61
+ //# sourceMappingURL=MailboxAuthenticationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MailboxAuthenticationService.d.ts","sourceRoot":"","sources":["../../src/services/MailboxAuthenticationService.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAclC,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,0BAA0B,CAAC;AAIlC,kFAAkF;AAClF,MAAM,MAAM,6BAA6B,GAAG,CAAC,IAAI,EAAE;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;CACjB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACpB,MAAM,WAAW,mCAAoC,SAAQ,gBAAgB;IAC3E,WAAW,EAAE,QAAQ,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,qIAAqI;IACrI,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC;AACD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wFAAwF;AACxF,wBAAsB,qBAAqB,CAAC,KAAK,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B,iBAgBA;AAED,sFAAsF;AACtF,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE;IACL,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,iBA4BF;AAED;;;;;;;GAOG;AACH,qBAAa,4BAA4B;IAErC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFvB,OAAO;WAOM,MAAM,CAAC,OAAO,EAAE,mCAAmC;IAc1D,OAAO,CAAC,KAAK,EAAE;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,6BAA6B,CAAC;KACxC,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,CAAC;IAmC1B,YAAY,CAAC,KAAK,EAAE;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,oBAAoB,CAAC;YA0BnB,KAAK;YAQL,QAAQ;CAuEvB"}
@@ -0,0 +1,120 @@
1
+ import { type SmrtClassOptions } from '@happyvertical/smrt-core';
2
+ import { type Profile } from '@happyvertical/smrt-profiles';
3
+ import { type OidcProfileOwnerAuthorizerContext } from '../collections/UserCollection.js';
4
+ import type { LoginAttemptLimiter } from './LoginAttemptLimiter.js';
5
+ import { type MailboxAuthenticationDelivery } from './MailboxAuthenticationService.js';
6
+ /** Host-authorized invitation destination and least-privilege system role. */
7
+ export interface PrepareTenantInvitationInput {
8
+ tenantId: string;
9
+ email: string;
10
+ roleSlug: string;
11
+ }
12
+ /** Persisted pending access; active means the exact membership already existed. */
13
+ export interface PreparedTenantInvitation {
14
+ userId: string;
15
+ profileId: string;
16
+ membershipId: string;
17
+ status: 'pending' | 'active';
18
+ }
19
+ /** Expected, safe invitation refusal; adapter/database failures remain distinct. */
20
+ export declare class TenantInvitationError extends Error {
21
+ readonly status: 400 | 403;
22
+ constructor(message: string, status?: 400 | 403);
23
+ }
24
+ /** Signing is required only when issuing or accepting an invitation. */
25
+ export interface TenantInvitationServiceOptions extends SmrtClassOptions {
26
+ transaction: 'caller';
27
+ secret?: string;
28
+ tokenExpiry?: number;
29
+ /** Required for requestMailboxAuthentication(): supply a root-executor limiter independent of the caller transaction. Other operations may omit it. */
30
+ loginLimiter?: LoginAttemptLimiter;
31
+ }
32
+ /** Copyable tenant grant, never identity proof; the host must not log it. */
33
+ export interface IssuedTenantInvitation {
34
+ membershipId: string;
35
+ token: string;
36
+ expiresAt: Date;
37
+ }
38
+ /** Accepted identity and destination; no session is minted by this service. */
39
+ export interface AcceptedTenantInvitation extends Omit<PreparedTenantInvitation, 'status'> {
40
+ tenantId: string;
41
+ status: 'active';
42
+ }
43
+ /**
44
+ * Trusted host integration seam, never a public unauthenticated endpoint.
45
+ * The host authorizes the destination tenant/role and owns the transaction.
46
+ * prepare() creates pending records only. issue() returns a signed bearer proof
47
+ * for host-controlled delivery. accept() requires independent identity login;
48
+ * only the protocol-verified OIDC owner callback may activate a pending User. No email or session is created.
49
+ * Concurrent identity conflicts fail and roll back the caller transaction;
50
+ * the host may retry the entire transaction after that rollback.
51
+ */
52
+ export declare class TenantInvitationService {
53
+ private readonly options;
54
+ private readonly signing;
55
+ private constructor();
56
+ /** Bind an already-initialized transaction executor; never nest transactions. */
57
+ static create(options: TenantInvitationServiceOptions): Promise<TenantInvitationService>;
58
+ /** Host-authorized issue/reissue; never sends or logs the bearer token. */
59
+ issue(input: {
60
+ membershipId: string;
61
+ }): Promise<IssuedTenantInvitation>;
62
+ /**
63
+ * Request independent mailbox authentication, delivering only to the canonical
64
+ * invitee. The trusted server callback must send auth mail, never expose the
65
+ * proof to a requester/operator, and reject on transport failure. No grant is
66
+ * consumed here, so failed delivery/retries do not burn invitation access.
67
+ * Delivery precedes caller commit: a rolled-back challenge cannot authenticate.
68
+ */
69
+ requestMailboxAuthentication(input: {
70
+ membershipId: string;
71
+ token: string;
72
+ sourceKey: string;
73
+ deliver: MailboxAuthenticationDelivery;
74
+ }): Promise<{
75
+ expiresAt: Date;
76
+ }>;
77
+ /**
78
+ * Authenticate ONLY independent proof delivered to the canonical mailbox plus
79
+ * the exact project grant. Claim both nonces and activate atomically in the
80
+ * caller transaction. The host may then establish a magic-link session from
81
+ * committed returned IDs; a copied project grant alone never proves identity.
82
+ */
83
+ authenticateMailbox(input: {
84
+ membershipId: string;
85
+ invitationToken: string;
86
+ token: string;
87
+ expectedUserId?: string;
88
+ sessionId?: string;
89
+ }): Promise<AcceptedTenantInvitation>;
90
+ private mailboxLinks;
91
+ /** Accept a tenant grant using an independently authenticated first-class session. */
92
+ accept(input: {
93
+ membershipId: string;
94
+ token: string;
95
+ sessionId: string;
96
+ expectedUserId?: string;
97
+ }): Promise<AcceptedTenantInvitation>;
98
+ /**
99
+ * Authorize a pre-provisioned owner ONLY inside the canonical protocol-verified
100
+ * OIDC callback. A tenant grant alone never proves global identity. The host
101
+ * must not expose this trusted callback seam to arbitrary claims.
102
+ */
103
+ authorizeOidcOwner(context: OidcProfileOwnerAuthorizerContext, input: {
104
+ membershipId: string;
105
+ token: string;
106
+ }): Promise<{
107
+ profile: Profile;
108
+ user: import("../index.js").User;
109
+ tenantId: string;
110
+ membershipId: string;
111
+ }>;
112
+ private activateMembership;
113
+ private verifyProof;
114
+ private magicLinks;
115
+ /** Lock existing authority before verifying it; never authorize by email match. */
116
+ private invitationRecords;
117
+ /** Prepare or replay a pending membership, preserving all existing authority. */
118
+ prepare(input: PrepareTenantInvitationInput): Promise<PreparedTenantInvitation>;
119
+ }
120
+ //# sourceMappingURL=TenantInvitationService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TenantInvitationService.d.ts","sourceRoot":"","sources":["../../src/services/TenantInvitationService.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAIL,KAAK,OAAO,EAGb,MAAM,8BAA8B,CAAC;AAOtC,OAAO,EACL,KAAK,iCAAiC,EAEvC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAEL,KAAK,6BAA6B,EAEnC,MAAM,mCAAmC,CAAC;AAG3C,8EAA8E;AAC9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AULT_PIN_MANAGE_PERMISSION, DeviceCredentialError, DeviceCredentialForbiddenError, DeviceCredentialPolicyError, DeviceCredentialService, type DeviceCredentialServiceOptions, type DeviceCredentialVerification, type DeviceCredentialVerifier, type DeviceSignInContext, type DeviceSignInInput, type DeviceSignInResult, ensurePinPermissionsRegistered, PIN_LOGIN_KIND, PIN_PERMISSION_DEFINITIONS, type PinPolicyOptions, type PinSignInInput, PinVerifier, type ResetPinInput, type SetPinInput, } from './DeviceCredentialService.js';
8
8
  export { DEFAULT_LOGIN_ATTEMPT_WINDOW_SECONDS, DEFAULT_LOGIN_LOCKOUT_BASE_SECONDS, DEFAULT_LOGIN_LOCKOUT_FACTOR, DEFAULT_LOGIN_LOCKOUT_MAX_SECONDS, DEFAULT_LOGIN_MAX_ATTEMPTS, DEFAULT_SOURCE_LOCKOUT_AUDIT_SECONDS, DurableLoginAuditSink, InvalidCredentialsError, type LoginAttemptDecision, type LoginAttemptDenied, type LoginAttemptLease, LoginAttemptLimiter, type LoginAttemptLimiterOptions, type LoginAuditEntry, type LoginAuditSink, type LoginBudgetOptions, type LoginFailureOutcome, type LoginLockoutOptions, LoginRateLimitError, type ReserveLoginAttemptOptions, } from './LoginAttemptLimiter.js';
9
9
  export { MagicLinkError, type MagicLinkResult, MagicLinkService, type MagicLinkServiceOptions, type MagicLinkVerifyResult, } from './MagicLinkService.js';
10
+ export { type AuthenticatedMailbox, type MailboxAuthenticationDelivery, MailboxAuthenticationService, type MailboxAuthenticationServiceOptions, } from './MailboxAuthenticationService.js';
10
11
  export { MobileAuthError, type MobileAuthErrorCode, MobileAuthService, type MobileAuthServiceOptions, type MobileBootstrapContext, type MobileLoginContext, type MobileLogoutResult, type MobileRequestMeta, type MobileResolvedUser, type MobileTenantContext, readMobileBearerToken, validateMobileRedirectUri, } from './MobileAuthService.js';
11
12
  export { SmrtOAuthAuthorizationService, type SmrtOAuthAuthorizationServiceOptions, type SmrtOAuthGrantSummary, } from './OAuthAuthorizationService.js';
12
13
  export { SMRT_OAUTH_GRANT_CLAIM, SmrtOAuthAuthorizationStorage, type SmrtOAuthAuthorizationStorageOptions, } from './OAuthAuthorizationStorage.js';
@@ -20,6 +21,7 @@ export { applyPostgresPermissionPolicies, type GeneratePostgresPermissionSqlResu
20
21
  export { type CreateResourceGrantOptions, checkResourceOperationPermission, MAX_RESOURCE_GRANT_DELEGATION_DEPTH, type ResourceGrantDecision, ResourceGrantService, type ResourceIdentity, type ResourceIdentityVerifier, type ResourceOperationPermissionOptions, type RevokeResourceGrantOptions, } from './ResourceGrantService.js';
21
22
  export { getCurrentSessionPermissionContext, getRequestScopedDatabase, type PrincipalPermissionRuntimeOptions, type SessionPermissionRuntimeContext, type SessionPermissionRuntimeOptions, withPrincipalPermissionContext, withSessionPermissionContext, } from './SessionPermissionContext.js';
22
23
  export { type SessionContext, type SessionParentContext, SessionService, type SessionServiceOptions, type SwitchTenantResult, } from './SessionService.js';
24
+ export { type AcceptedTenantInvitation, type IssuedTenantInvitation, type PreparedTenantInvitation, type PrepareTenantInvitationInput, TenantInvitationError, TenantInvitationService, type TenantInvitationServiceOptions, } from './TenantInvitationService.js';
23
25
  export { type EnsureTenantResult, TenantService, type TenantWithOwnershipResult, } from './TenantService.js';
24
26
  export { type ApproveCliAuthRequestInput, type CliAuthStartResult, type CliAuthTokenResult, DEFAULT_CLI_AUTH_APPROVE_ATTEMPT_WINDOW_SECONDS, DEFAULT_CLI_AUTH_MAX_APPROVE_ATTEMPTS, DEFAULT_CLI_AUTH_POLL_INTERVAL_SECONDS, DEFAULT_CLI_AUTH_REQUEST_TTL_SECONDS, DEFAULT_CLI_SESSION_TTL_SECONDS, TERMINAL_APPROVE_LOGIN_KIND, TerminalAuthError, TerminalAuthRateLimitError, TerminalAuthService, type TerminalAuthServiceOptions, } from './TerminalAuthService.js';
25
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"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C7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,8BAA8B,GACpC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,kBAAkB,EACvB,aAAa,EACb,KAAK,yBAAyB,GAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,+CAA+C,EAC/C,qCAAqC,EACrC,sCAAsC,EACtC,oCAAoC,EACpC,+BAA+B,EAC/B,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,0BAA0B,CAAC"}
@@ -3,13 +3,13 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-users",
6
- "packageVersion": "0.57.20",
6
+ "packageVersion": "0.57.22",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "12bd3999dc3aaa068a90288525b9d484f7497cc7e85d8a6163a2aae293913c62",
11
- "packageJson": "6166d2c1f2364a375242c8a3306c20053e8ed884912d71216f14cb0a5ac51a87",
12
- "agents": "a78e98bccfdde674b905ee03295dcbb2f70a0532881ab88ecd18855da0feaa8f",
10
+ "manifest": "6402ef4f766d6622ddec9fff67144ee597df12ee58c2c22a6f2aac4781190e82",
11
+ "packageJson": "c522f1fb1676e2b45a8728c1815fbe46cf1a5ecbb64fd361fb96a447c40776e0",
12
+ "agents": "ae136a560a90c372f9edbd099acf9834be51fb3397a823761d7c1da5de57c691",
13
13
  "moduleDoc:agents/permissions.md": "02b2f03f0e057721369d9c693a624a6fdb3df4935401531a4373ff18229a64be",
14
14
  "moduleDoc:agents/oidc-provisioning.md": "b73f3fdaf61136720132a614c7e14237b7bd35f7bf5d43eabb29f565485803b9",
15
15
  "moduleDoc:agents/mobile-auth.md": "25e85e83f43e3a46383a92fa809f3a003b4545c3026e78dbe1bccbbc35161e18",
@@ -796,6 +796,7 @@
796
796
  "methods": [
797
797
  "deleteExpired",
798
798
  "findByNonce",
799
+ "isAvailable",
799
800
  "markUsed"
800
801
  ],
801
802
  "methodSignatures": [
@@ -815,6 +816,15 @@
815
816
  ],
816
817
  "returns": "Promise<UsersMagicLinkToken | null>"
817
818
  },
819
+ {
820
+ "name": "isAvailable",
821
+ "async": true,
822
+ "params": [
823
+ "nonce: string",
824
+ "email: string"
825
+ ],
826
+ "returns": "Promise<boolean>"
827
+ },
818
828
  {
819
829
  "name": "markUsed",
820
830
  "async": true,
@@ -840,6 +850,13 @@
840
850
  "reason": "not listed in api.include",
841
851
  "objectName": "@happyvertical/smrt-users:UsersMagicLinkTokenCollection"
842
852
  },
853
+ {
854
+ "kind": "api",
855
+ "operation": "isAvailable",
856
+ "code": "not-included",
857
+ "reason": "not listed in api.include",
858
+ "objectName": "@happyvertical/smrt-users:UsersMagicLinkTokenCollection"
859
+ },
843
860
  {
844
861
  "kind": "api",
845
862
  "operation": "markUsed",
@@ -3310,6 +3327,7 @@
3310
3327
  "findByEmail",
3311
3328
  "findByProfile",
3312
3329
  "findByStatus",
3330
+ "findCanonicalByEmail",
3313
3331
  "findPending",
3314
3332
  "getOrCreateForProfile",
3315
3333
  "getOrCreateFromOidc"
@@ -3344,6 +3362,14 @@
3344
3362
  ],
3345
3363
  "returns": "Promise<User[]>"
3346
3364
  },
3365
+ {
3366
+ "name": "findCanonicalByEmail",
3367
+ "async": true,
3368
+ "params": [
3369
+ "email: string"
3370
+ ],
3371
+ "returns": "Promise<User | null>"
3372
+ },
3347
3373
  {
3348
3374
  "name": "findPending",
3349
3375
  "async": true,
@@ -3400,6 +3426,13 @@
3400
3426
  "reason": "not listed in api.include",
3401
3427
  "objectName": "@happyvertical/smrt-users:UserCollection"
3402
3428
  },
3429
+ {
3430
+ "kind": "api",
3431
+ "operation": "findCanonicalByEmail",
3432
+ "code": "not-included",
3433
+ "reason": "not listed in api.include",
3434
+ "objectName": "@happyvertical/smrt-users:UserCollection"
3435
+ },
3403
3436
  {
3404
3437
  "kind": "api",
3405
3438
  "operation": "findPending",
@@ -8179,7 +8212,7 @@
8179
8212
  "polymorphicAssociations": 0,
8180
8213
  "uuidColumns": 162
8181
8214
  },
8182
- "agentDoc": "# @happyvertical/smrt-users\n\nMulti-tenant identity, RBAC, hierarchical tenants, sessions, and SvelteKit auth.\n\n## Modules\n\nRead only the module relevant to the change; protocol and provisioning details\nare not prerequisites for unrelated user-package work.\n\n| Module | Scope | Module doc |\n|---|---|---|\n| `src/services/PermissionResolver.ts` | permission precedence, inherited memberships, guards, RLS, role seeding | [agents/permissions.md](agents/permissions.md) |\n| `src/services/OidcLoginService.ts`, collections and OIDC handlers | identity reconciliation, transaction boundaries, migration readiness | [agents/oidc-provisioning.md](agents/oidc-provisioning.md) |\n| `src/services/MobileAuthService.ts` | mobile handshake, bearer sessions, bootstrap extension boundary | [agents/mobile-auth.md](agents/mobile-auth.md) |\n| `src/services/TerminalAuthService.ts`, `src/services/LoginAttemptLimiter.ts`, `src/collections/LoginAttemptCollection.ts` | terminal approval concurrency, shared login budget and lockout (#3273), retry-safe database fixtures | [agents/terminal-auth-testing.md](agents/terminal-auth-testing.md) |\n| `src/services/DeviceCredentialService.ts` | per-person PIN layered on a device session (#3276), verifier seam for other credential kinds | this file, \"Security boundaries\" |\n| `src/services/PasswordCredentialService.ts`, `src/sveltekit/password-handlers.ts` | email + password sign-in and password lifecycle (#3274); shared scrypt in `credential-hash.ts` | this file, \"Security boundaries\"; README \"Password sign-in\" |\n| `src/services/PasskeyCredentialService.ts`, `src/sveltekit/passkey-handlers.ts`, `src/svelte/passkey.ts` | passkey (WebAuthn) sign-in and passkey lifecycle (#3275); library does all verification | this file, \"Security boundaries\"; README \"Passkey sign-in\" |\n| `src/retention.ts` | expired session/token/CLI-auth reaping and retention sweep wiring | [agents/retention.md](agents/retention.md) |\n\n## Models and authority\n\n- Users are global; tenant access comes through Membership (unique user/tenant).\n User email is normalized and globally unique through readonly nullable\n `emailKey`. `profileId` is a unique cross-package reference: at most one User\n owns each non-null Profile.\n- Tenant uses STI and a materialized hierarchy, maximum depth 10.\n `hierarchyPath`/`hierarchyLevel` are derived from `parentTenantId` by\n `Tenant.save()` on every save (any caller-supplied value is recomputed) and\n descendants are re-materialized when they change; never hand-maintain them.\n Legacy rows are backfilled with `smrt db:materialize-tenant-hierarchy`\n (`materializeTenantHierarchy()`). Tests that need a corrupt path must write it\n with raw SQL (#3036).\n- Role with `tenantId = null` is available to all tenants; `isSystem` prevents\n deletion. `inheritsToDescendants` is opt-in. Seed owner/admin/member/viewer\n through `RoleCollection.seedSystemRoles()` at application initialization.\n- Group roles apply only in their own tenant. Use `getGroupIdsForTenant()`,\n never cross-tenant `getGroupIds()`, for authorization.\n- Upward visibility is opt-in and read-only: `permissions.ancestorRead`\n ({ roles, collections, maxDepth? }) lets a DESCENDANT membership contribute\n declared `<collection>.read` at an ancestor, only when no membership resolved\n there, intersected with BOTH the role's own catalog grants and the\n principal's effective permissions in that descendant, and only for SYSTEM\n roles (a tenant-scoped role sharing a declared slug is ignored). Off by default, never\n write, never lateral, and never row visibility — sibling rows stay scoped by\n tenancy/RLS. Read the permissions module before changing it.\n- Membership DENY always wins. Direct inactive membership blocks inherited\n authority; a direct active membership pins resolution instead of unioning it\n with ancestors. Read the permissions module before changing these rules.\n- AccessRequest has no generated API/MCP/CLI operations; access it through\n `AccessRequestService`. Its JSON field is `requestContext`, not reserved\n slug-scoping `context`.\n\n## Security boundaries\n\n- Generated REST/MCP operations on identity/RBAC models are list/get only.\n Route authentication does not authorize authority mutations, and these models\n are not tenant-scoped. Use permission-gated services or explicitly checked\n consumer handlers. Generated CLI is list/get or closed (`cli: false` for\n credential/grant models) because agents shell out to it; a `cli` without\n `include` is full CRUD (#3742). Their catalog slugs stay full via\n `USERS_AUTHORITY_CATALOG_MODELS`. Preserve the registry assertions in\n `security-audit-1400.test.ts` and `issue-3742-cli-surface-lockdown.test.ts`.\n- Resource guards take the resource tenant, not the session tenant. Omit a\n session membership when targeting a different tenant; mismatches fail closed.\n `loadSessionContext().tenantAuthorization` must be checked by required-tenant\n consumers: null membership can represent inherited authority.\n- Sessions use secure UUIDs; TTL is seconds (default seven days). Access marks\n expired sessions EXPIRED. Magic-link tokens are single use.\n- `Session.authMethod` is server-set at mint time and never read from the\n client; every mint site in this package sets it. A session with\n `parentSessionId` is valid only while its parent validates\n (`loadSessionContext` enforces this; there is no FK cascade by design), may\n not switch to a tenant other than the parent's, and is revoked with its\n parent by `destroySession`.\n- Credential sign-ins reserve through `LoginAttemptLimiter` BEFORE credential\n work and key the subject on the submitted identifier, never a resolved user,\n so unknown and wrong take the same path. Reservations are fail-closed: keep\n them on failure, release on success or abort, never skip the reserve.\n Limiter writes are raw SQL and bypass the change feed; the audit sink is the\n observability seam, and it must never throw into the sign-in path.\n Subject and source budgets are sized independently (#3531); `source: false`\n ignores the source key, so a reservation then needs a subject (fail closed).\n The `source-locked` audit entry never carries a subject or caller metadata.\n- `DeviceCredentialService` accepts a person credential only from a\n first-class session whose `authMethod` is a device-enrollment method\n (`terminal` by default) and that the host's `assertEnrolledDevice` confirms.\n A layered or PIN session can never administer PINs regardless of\n permissions. PIN hashes carry a per-row salt and the configured pepper;\n treat an unset pepper as a production misconfiguration.\n- A person session carries the PERSON's authority (resolved from their own\n membership on every load), never the device account's. `Session.data` keys\n in `SESSION_DATA_KEYS` are server-set controls enforced by the model:\n `permissionCeiling` only ever intersects (malformed fails closed to none)\n and suppresses `superAdminBypass`/`systemContext`; `absoluteExpiresAt`\n bounds `extend()` and `isValid()`; `idleSeconds` overrides the resolving\n service's TTL policy. Never write them from client input. The ceiling is a\n sign-in snapshot; `singleOccupant` revokes other children only AFTER a\n successful mint. A `mustReset` sign-in mints with an empty ceiling and\n `setPin` ends that session; do not grant it authority another way.\n- `UsersPasswordCredential` is one row per person, sensitive, with no\n generated surface; `PasswordCredentialService` and its handlers are its only\n session-authorized read/write paths. The separate Node `./operator` entrypoint\n provisions new PostgreSQL owners from trusted database custody, atomically;\n never mount it in a browser/REST/MCP handler. Exact retries verify existing\n credentials without writes; partial/conflicting identities fail closed.\n See README \"Trusted deployment owner provisioning\".\n Sign-in normalizes the email like `emailKey`, reserves\n before work, always runs one scrypt verify (dummy hash when absent), never\n creates a user, and maps every non-rate-limit refusal to one\n `PasswordCredentialError`. It re-checks the credential after the mint (a\n rehash that keeps row and version is confirmed by re-verifying); the\n parameter-upgrade write is a guarded UPDATE that must never replace a\n rotated password, and verification against a weaker stored hash is padded\n to the policy's scrypt cost. Self-service writes are guarded on the proven\n credential (first set insert-only); session sweeps run before and after\n each write. Self-service needs the current password except for a first\n set; `users.password.manage` follows the PIN's single-tenant target\n rule and never resets the actor's own. Layered sessions never manage\n passwords; a `mustChange` sign-in mints an empty ceiling.\n `replaceForgottenPassword` (#3905, opt-in `recovery`) is the only\n self-service write without the current password: it decides on the stored\n session row (owner, first-class, no ceiling, listed non-password/pin\n `authMethod`, fresh `outOfBandProofAt` stamp) and ends every session,\n its own included. Never set that stamp from client input.\n- `UsersPasskeyCredential` (many per person) and `UsersPasskeyChallenge` (consumed\n challenge ledger) are sensitive with no generated surface;\n `PasskeyCredentialService` and its handlers are the only paths. Verification is\n `@simplewebauthn/server`, loaded on first use (its `reflect-metadata` polyfill is process-wide) and external in the build; never hand-roll COSE/CBOR. Sign-in reserves on\n the submitted credential id before any work, requires user verification, checks\n user handle and a strictly advancing counter (`reason: 'counter'`), mints, then\n re-checks with a guarded counter UPDATE; a ceremony is an HMAC-signed\n `ceremonyId` consumed into the unique ledger (replay = refuse; set\n `challengeSecret` for multi-process). Unique arbiters are\n `INSERT … ON CONFLICT DO NOTHING`, never a caught constraint error. Register and\n self-remove need a session authenticated within `freshSessionSeconds`, decided\n on the stored row (`Session.getAuthenticatedAt()`: server-set\n `data.authenticatedAt`, which tenant-switch rotation carries forward, else\n `created_at`; malformed fails closed; `setSessionData` refuses the key),\n first-class, no ceiling, and its STORED `authMethod` in `freshAuthMethods` (default password/passkey/oidc/magic-link; never `terminal`, whose approval mints a fresh session for any holder of a stale one, nor `pin`); self list/rename also refuse a ceiling; `users.passkey.manage` follows the PIN's\n single-tenant rule, and `removeAllPasskeys` is admin-only, never self. Sessions\n end before and after every removal; `SESSION_DATA_KEYS.passkeyCredentialId` is\n server-set (`setSessionData` refuses it). State-changing handlers require\n `application/json` (415). Challenge rows are reaped only 10 minutes past expiry\n (clock skew).\n- A layered session whose tenant differs from its parent's never loads (null\n is allowed: narrower). Limiter rows carry `retain_until`; retention must\n not fall back to a process-wide horizon.\n- `Session.parentSessionId` is the parent's bearer: sensitive, never a\n `list()` filter (raw-SQL id reads, which also keep revocation sweeps free of\n caller list bounds), never serialized to clients. `users.pin.manage` reaches\n only people whose every active membership is in the actor's tenant (the PIN\n is global per person). A sign-in re-checks the verified\n credential generation AFTER the mint (`stillValid`); keep that ordering.\n Operation guards deny outside a session's ceiling; `loadPersonSession`\n re-checks device enrollment.\n- Tenant switching verifies active membership before writing and rotates the\n session ID for non-null targets, revoking the old session. Persist the returned\n `SwitchTenantResult.sessionId`; `switchSessionTenant()` updates the cookie and\n preserves its security settings. Failed switches mutate nothing; null clears\n do not rotate, and layered sessions never rotate (a replacement would escape\n the revocation sweeps they depend on). Layers do not nest. `SessionCollection.setSessionTenant()` is unguarded and must\n never receive an untrusted tenant ID.\n- OIDC provisioning is atomic and fail-closed. Preserve exact issuer/subject\n identifiers, claim-source email verification, unique global Person ownership,\n and transaction-bound reconciliation. Read the OIDC module and canonical\n scenario matrix before changing any provisioning path.\n\n## Entry points and validation\n\n`src/sveltekit/` owns `createSessionHandler`, `createSessionCookie`,\n`destroySessionCookie`, and `switchSessionTenant`. Use README integration examples\nrather than copying application setup into these instructions.\n\nFrom the repository root:\n\n```bash\npnpm --filter @happyvertical/smrt-users test\npnpm --filter @happyvertical/smrt-users typecheck\npnpm --filter @happyvertical/smrt-users test:postgres\n```\n\nStart with the relevant test file via `test -- src/__tests__/<file>.test.ts`.\nRun `test:postgres` for RLS, principal context, OIDC, or terminal-auth database\nchanges. `typecheck` includes Svelte accessibility checks; plain `tsc` is\ninsufficient. Follow root knowledge freshness checks before shipping.\n",
8215
+ "agentDoc": "# @happyvertical/smrt-users\n\nMulti-tenant identity, RBAC, hierarchical tenants, sessions, and SvelteKit auth.\n\n## Modules\n\nRead only the module relevant to the change; protocol and provisioning details\nare not prerequisites for unrelated user-package work.\n\n| Module | Scope | Module doc |\n|---|---|---|\n| `src/services/PermissionResolver.ts` | permission precedence, inherited memberships, guards, RLS, role seeding | [agents/permissions.md](agents/permissions.md) |\n| `src/services/OidcLoginService.ts`, collections and OIDC handlers | identity reconciliation, transaction boundaries, migration readiness | [agents/oidc-provisioning.md](agents/oidc-provisioning.md) |\n| `src/services/MobileAuthService.ts` | mobile handshake, bearer sessions, bootstrap extension boundary | [agents/mobile-auth.md](agents/mobile-auth.md) |\n| `src/services/TerminalAuthService.ts`, `src/services/LoginAttemptLimiter.ts`, `src/collections/LoginAttemptCollection.ts` | terminal approval concurrency, shared login budget and lockout (#3273), retry-safe database fixtures | [agents/terminal-auth-testing.md](agents/terminal-auth-testing.md) |\n| `src/services/DeviceCredentialService.ts` | per-person PIN layered on a device session (#3276), verifier seam for other credential kinds | this file, \"Security boundaries\" |\n| `src/services/PasswordCredentialService.ts`, `src/sveltekit/password-handlers.ts` | email + password sign-in and password lifecycle (#3274); shared scrypt in `credential-hash.ts` | this file, \"Security boundaries\"; README \"Password sign-in\" |\n| `src/services/PasskeyCredentialService.ts`, `src/sveltekit/passkey-handlers.ts`, `src/svelte/passkey.ts` | passkey (WebAuthn) sign-in and passkey lifecycle (#3275); library does all verification | this file, \"Security boundaries\"; README \"Passkey sign-in\" |\n| `src/retention.ts` | expired session/token/CLI-auth reaping and retention sweep wiring | [agents/retention.md](agents/retention.md) |\n\n## Models and authority\n\n- Users are global; tenant access comes through Membership (unique user/tenant).\n User email is normalized and globally unique through readonly nullable\n `emailKey`. `profileId` is a unique cross-package reference: at most one User\n owns each non-null Profile.\n- Tenant uses STI and a materialized hierarchy, maximum depth 10.\n `hierarchyPath`/`hierarchyLevel` are derived from `parentTenantId` by\n `Tenant.save()` on every save (any caller-supplied value is recomputed) and\n descendants are re-materialized when they change; never hand-maintain them.\n Legacy rows are backfilled with `smrt db:materialize-tenant-hierarchy`\n (`materializeTenantHierarchy()`). Tests that need a corrupt path must write it\n with raw SQL (#3036).\n- Role with `tenantId = null` is available to all tenants; `isSystem` prevents\n deletion. `inheritsToDescendants` is opt-in. Seed owner/admin/member/viewer\n through `RoleCollection.seedSystemRoles()` at application initialization.\n- Group roles apply only in their own tenant. Use `getGroupIdsForTenant()`,\n never cross-tenant `getGroupIds()`, for authorization.\n- Upward visibility is opt-in and read-only: `permissions.ancestorRead`\n ({ roles, collections, maxDepth? }) lets a DESCENDANT membership contribute\n declared `<collection>.read` at an ancestor, only when no membership resolved\n there, intersected with BOTH the role's own catalog grants and the\n principal's effective permissions in that descendant, and only for SYSTEM\n roles (a tenant-scoped role sharing a declared slug is ignored). Off by default, never\n write, never lateral, and never row visibility — sibling rows stay scoped by\n tenancy/RLS. Read the permissions module before changing it.\n- Membership DENY always wins. Direct inactive membership blocks inherited\n authority; a direct active membership pins resolution instead of unioning it\n with ancestors. Read the permissions module before changing these rules.\n- AccessRequest has no generated API/MCP/CLI operations; access it through\n `AccessRequestService`. Its JSON field is `requestContext`, not reserved\n slug-scoping `context`.\n\n## Security boundaries\n\n- Generated REST/MCP operations on identity/RBAC models are list/get only.\n Route authentication does not authorize authority mutations, and these models\n are not tenant-scoped. Use permission-gated services or explicitly checked\n consumer handlers. Generated CLI is list/get or closed (`cli: false` for\n credential/grant models) because agents shell out to it; a `cli` without\n `include` is full CRUD (#3742). Their catalog slugs stay full via\n `USERS_AUTHORITY_CATALOG_MODELS`. Preserve the registry assertions in\n `security-audit-1400.test.ts` and `issue-3742-cli-surface-lockdown.test.ts`.\n- Resource guards take the resource tenant, not the session tenant. Omit a\n session membership when targeting a different tenant; mismatches fail closed.\n `loadSessionContext().tenantAuthorization` must be checked by required-tenant\n consumers: null membership can represent inherited authority.\n- Sessions use secure UUIDs; TTL is seconds (default seven days). Access marks\n expired sessions EXPIRED. Magic-link tokens are single use.\n- `Session.authMethod` is server-set at mint time and never read from the\n client; every mint site in this package sets it. A session with\n `parentSessionId` is valid only while its parent validates\n (`loadSessionContext` enforces this; there is no FK cascade by design), may\n not switch to a tenant other than the parent's, and is revoked with its\n parent by `destroySession`.\n- Credential sign-ins reserve through `LoginAttemptLimiter` BEFORE credential\n work and key the subject on the submitted identifier, never a resolved user,\n so unknown and wrong take the same path. Reservations are fail-closed: keep\n them on failure, release on success or abort, never skip the reserve.\n Limiter writes are raw SQL and bypass the change feed; the audit sink is the\n observability seam, and it must never throw into the sign-in path.\n Subject and source budgets are sized independently (#3531); `source: false`\n ignores the source key, so a reservation then needs a subject (fail closed).\n The `source-locked` audit entry never carries a subject or caller metadata.\n- `DeviceCredentialService` accepts a person credential only from a\n first-class session whose `authMethod` is a device-enrollment method\n (`terminal` by default) and that the host's `assertEnrolledDevice` confirms.\n A layered or PIN session can never administer PINs regardless of\n permissions. PIN hashes carry a per-row salt and the configured pepper;\n treat an unset pepper as a production misconfiguration.\n- A person session carries the PERSON's authority (resolved from their own\n membership on every load), never the device account's. `Session.data` keys\n in `SESSION_DATA_KEYS` are server-set controls enforced by the model:\n `permissionCeiling` only ever intersects (malformed fails closed to none)\n and suppresses `superAdminBypass`/`systemContext`; `absoluteExpiresAt`\n bounds `extend()` and `isValid()`; `idleSeconds` overrides the resolving\n service's TTL policy. Never write them from client input. The ceiling is a\n sign-in snapshot; `singleOccupant` revokes other children only AFTER a\n successful mint. A `mustReset` sign-in mints with an empty ceiling and\n `setPin` ends that session; do not grant it authority another way.\n- `UsersPasswordCredential` is one row per person, sensitive, with no\n generated surface; `PasswordCredentialService` and its handlers are its only\n session-authorized read/write paths. The separate Node `./operator` entrypoint\n provisions new PostgreSQL owners from trusted database custody, atomically;\n never mount it in a browser/REST/MCP handler. Exact retries verify existing\n credentials without writes; partial/conflicting identities fail closed.\n See README \"Trusted deployment owner provisioning\".\n Sign-in normalizes the email like `emailKey`, reserves\n before work, always runs one scrypt verify (dummy hash when absent), never\n creates a user, and maps every non-rate-limit refusal to one\n `PasswordCredentialError`. It re-checks the credential after the mint (a\n rehash that keeps row and version is confirmed by re-verifying); the\n parameter-upgrade write is a guarded UPDATE that must never replace a\n rotated password, and verification against a weaker stored hash is padded\n to the policy's scrypt cost. Self-service writes are guarded on the proven\n credential (first set insert-only); session sweeps run before and after\n each write. Self-service needs the current password except for a first\n set; `users.password.manage` follows the PIN's single-tenant target\n rule and never resets the actor's own. Layered sessions never manage\n passwords; a `mustChange` sign-in mints an empty ceiling.\n `replaceForgottenPassword` (#3905, opt-in `recovery`) is the only\n self-service write without the current password: it decides on the stored\n session row (owner, first-class, no ceiling, listed non-password/pin\n `authMethod`, fresh `outOfBandProofAt` stamp) and ends every session,\n its own included. Never set that stamp from client input.\n- `UsersPasskeyCredential` (many per person) and `UsersPasskeyChallenge` (consumed\n challenge ledger) are sensitive with no generated surface;\n `PasskeyCredentialService` and its handlers are the only paths. Verification is\n `@simplewebauthn/server`, loaded on first use (its `reflect-metadata` polyfill is process-wide) and external in the build; never hand-roll COSE/CBOR. Sign-in reserves on\n the submitted credential id before any work, requires user verification, checks\n user handle and a strictly advancing counter (`reason: 'counter'`), mints, then\n re-checks with a guarded counter UPDATE; a ceremony is an HMAC-signed\n `ceremonyId` consumed into the unique ledger (replay = refuse; set\n `challengeSecret` for multi-process). Unique arbiters are\n `INSERT … ON CONFLICT DO NOTHING`, never a caught constraint error. Register and\n self-remove need a session authenticated within `freshSessionSeconds`, decided\n on the stored row (`Session.getAuthenticatedAt()`: server-set\n `data.authenticatedAt`, which tenant-switch rotation carries forward, else\n `created_at`; malformed fails closed; `setSessionData` refuses the key),\n first-class, no ceiling, and its STORED `authMethod` in `freshAuthMethods` (default password/passkey/oidc/magic-link; never `terminal`, whose approval mints a fresh session for any holder of a stale one, nor `pin`); self list/rename also refuse a ceiling; `users.passkey.manage` follows the PIN's\n single-tenant rule, and `removeAllPasskeys` is admin-only, never self. Sessions\n end before and after every removal; `SESSION_DATA_KEYS.passkeyCredentialId` is\n server-set (`setSessionData` refuses it). State-changing handlers require\n `application/json` (415). Challenge rows are reaped only 10 minutes past expiry\n (clock skew).\n- A layered session whose tenant differs from its parent's never loads (null\n is allowed: narrower). Limiter rows carry `retain_until`; retention must\n not fall back to a process-wide horizon.\n- `Session.parentSessionId` is the parent's bearer: sensitive, never a\n `list()` filter (raw-SQL id reads, which also keep revocation sweeps free of\n caller list bounds), never serialized to clients. `users.pin.manage` reaches\n only people whose every active membership is in the actor's tenant (the PIN\n is global per person). A sign-in re-checks the verified\n credential generation AFTER the mint (`stillValid`); keep that ordering.\n Operation guards deny outside a session's ceiling; `loadPersonSession`\n re-checks device enrollment.\n- Tenant switching verifies active membership before writing and rotates the\n session ID for non-null targets, revoking the old session. Persist the returned\n `SwitchTenantResult.sessionId`; `switchSessionTenant()` updates the cookie and\n preserves its security settings. Failed switches mutate nothing; null clears\n do not rotate, and layered sessions never rotate (a replacement would escape\n the revocation sweeps they depend on). Layers do not nest. `SessionCollection.setSessionTenant()` is unguarded and must\n never receive an untrusted tenant ID.\n- OIDC provisioning is atomic and fail-closed. Preserve exact issuer/subject\n identifiers, claim-source email verification, unique global Person ownership,\n and transaction-bound reconciliation. Read the OIDC module and canonical\n scenario matrix before changing any provisioning path.\n\n## Entry points and validation\n\n`src/sveltekit/` owns `createSessionHandler`, `createSessionCookie`,\n`destroySessionCookie`, and `switchSessionTenant`. Use README integration examples\nrather than copying application setup into these instructions.\n\nFrom the repository root:\n\n```bash\npnpm --filter @happyvertical/smrt-users test\npnpm --filter @happyvertical/smrt-users typecheck\npnpm --filter @happyvertical/smrt-users test:postgres\n```\n\nStart with the relevant test file via `test -- src/__tests__/<file>.test.ts`.\nRun `test:postgres` for RLS, principal context, OIDC, or terminal-auth database\nchanges. `typecheck` includes Svelte accessibility checks; plain `tsc` is\ninsufficient. Follow root knowledge freshness checks before shipping.\n\n## Pending invitations\n\n`TenantInvitationService.create({ db: tx, transaction: 'caller' }).prepare({\ntenantId, email, roleSlug })` is a trusted host integration seam. The caller\nmust authorize the destination tenant and system role, serialize its invitation\nscope, and own the entire transaction. It prepares only pending User and\nMembership records, with a canonical global Person and email reservation;\nit never proves email ownership, activates access, sends email, or mints login\ncredentials. Existing canonical User/Profile links remain unchanged; unowned\nsame-email Profiles require explicit reconciliation. Pending retries reuse rows,\nactive memberships remain active with their existing role, and inactive or\nconflicting memberships fail closed. Caller failures must roll back the whole\ntransaction; retry identity uniqueness conflicts only after rollback. Run the\nprofile/user email-key backfills before using this service.\n\n`issue({ membershipId })` requires the host to authorize that exact destination\nand returns a signed single-use `{ membershipId, token, expiresAt }`; secure\ndelivery is the host’s responsibility (no email is sent). Configure `secret` and\noptional `tokenExpiry` (1–604800 seconds, default one day) at service creation.\n`accept({ membershipId, token, sessionId, expectedUserId? })` consumes the tenant\ngrant only after validating an independently authenticated, active exact User's\nstored first-class OIDC, magic-link, password or passkey session. Layered,\npermission-ceiling, terminal and unknown sessions fail closed. It activates only\nthe Membership; reuse/switch that session through canonical session APIs.\nNever mint global identity sessions from an operator-copyable invitation.\n\nFor a new pending User, wire `authorizeOidcOwner(context, { membershipId, token })`\nonly into the canonical protocol-verified OIDC `authorizeProfileOwner` callback.\nIt requires the exact caller transaction, strict `email_verified: true` and the\nexact canonical invitee email, consumes the grant and activates pending User\nand Membership atomically before returning `{ profile, user, tenantId, membershipId }`.\nArbitrary claims must never reach this trusted callback seam. The canonical\nbinder still verifies ownership and issuer/subject authority before commit.\nThe signed scope fixes user, profile, tenant, membership and role; expiration,\nreplay, changed bindings, inactive membership and suspended users fail closed.\nNonce consumption and activation roll back together. `TenantInvitationError`\nis an expected 400/403 refusal;\n`MagicLinkError` represents invalid, expired or replayed proof. Database failures\nremain distinct. Treat tokens as secrets, prefer URL fragments and POST bodies,\nand never log or persist a copy outside the canonical token ledger.\n\n\n## Independent emailed mailbox authentication\n\n`MailboxAuthenticationService.create({db:tx,transaction:'caller',secret,loginLimiter})`\nrequests and verifies returning-client login without creating identities/sessions.\n`request({email,sourceKey,deliver})` returns only `{requested:true}` for known,\nunknown, malformed, pending, inactive or unauthorized accounts. The trusted server\n`deliver({email,token,expiresAt})` callback sends only to the eligible canonical\nactive User's email; never expose a proof in HTTP responses/operator UI/logs,\nincluding development. Ten-minute one-use proofs bind immutable User/Profile ids.\n`authenticate({token,expectedUserId?,sessionId?})` rechecks canonical identity and\nactive tenant membership before consuming proof; returns only verified\n`{userId,profileId,tenantId}` for the host's canonical magic-link session mint.\nExisting signed-in identity must match; supplied sessions cannot have a parent,\npermission ceiling, terminal/PIN/unknown method, or inactive principal.\n\nFor pending invitation onboarding, `requestMailboxAuthentication({membershipId,\ntoken:projectGrant,sourceKey,deliver})` inspects but never consumes the signed\nproject grant, then delivers a DIFFERENT mailbox proof to the fixed invitee.\nOnly `{expiresAt}` is returned. `authenticateMailbox({membershipId,\ninvitationToken:projectGrant,token:mailedProof,expectedUserId?,sessionId?})` claims\nBOTH proof nonces and activates pending canonical User/exact Membership in the\nsame caller transaction. Mailbox proof issuer binds all invitation ids, role and\nSHA256 of the exact grant. A copied operator-visible grant cannot authenticate\nidentity. Repeated email requests do not burn the grant; only the first completed\nauthentication can claim it. Existing active-session/OIDC paths remain supported.\n\nAll refusals/caller failures must roll back the whole caller transaction. Mail\ntransport must reject on failure. Delivery is an external effect before commit:\na successfully delivered but rolled-back proof is unusable; retry may send another\nmail. No session/authentication is valid without committed proof claims. The host\nmust set a bounded transport timeout and never return transport payloads/secrets.\nNo generic outbox/provider is required; compose the existing SDK email transport.\n\nBoth mail request operations REQUIRE a root-executor canonical\n`LoginAttemptLimiter` passed as `loginLimiter`; missing limiters fail before\nnonce/budget writes or delivery. Completion-only operations may omit it. Supply\nthe limiter independently from the caller transaction so\ncaller rollbacks cannot release send budgets (SQLite single-connection fixtures\ncannot prove that production-pool separation). `sourceKey` is a trusted server\nclient-address key, never request-controlled forwarded headers; limiter hashes\nand peppers it, never stores raw addresses/email. Each request retains its budget\nthrough window expiry via `retainOnSuccess`, regardless of account eligibility.\nHandle `LoginRateLimitError` with the same generic request response plus retry\npolicy. Returning request has a 250ms response floor; delivery latency remains\ntransport-dependent, so do not claim constant timing. Malformed/expired/replayed\nproofs raise `MagicLinkError`; invitation binding/status refusals also use\n`TenantInvitationError`. Database/transport faults remain distinguishable server\nfailures. Never swallow an error and commit a partially consumed transaction.\n\n`MagicLinkService.inspect()` validates signed live nonce without claiming it;\nit is preparation, never authentication. `verify()` remains the atomic claim.\nOptional generated signed `subject` binds immutable identity; legacy callers\nwithout a subject retain their existing result shape.\n\nFocused matrix: `mailbox-authentication.test.ts` runs in memory SQLite by default;\n`TEST_DB_ADAPTER=postgres` plus an explicit isolated `DATABASE_URL` creates a unique\nschema per scenario and also exercises concurrent invitation/login proof claims.\nIt is registered in `test:postgres`; no shared local service fallback is used.\n",
8183
8216
  "moduleDocs": [
8184
8217
  {
8185
8218
  "path": "agents/permissions.md",
package/dist/sveltekit.js CHANGED
@@ -1,5 +1,5 @@
1
- import { M as LoginRateLimitError, d as PasswordCredentialForbiddenError, f as PasswordCredentialService, g as SessionService, p as PasswordPolicyError, u as PasswordCredentialError } from "./chunks/PasswordCredentialService-DezdsV_v.js";
2
- import { B as OidcLoginService, C as PasskeyCredentialService, D as OperationPermissionError, F as MobileAuthError, H as encodeOidcTransaction, I as MobileAuthService, J as DeviceCredentialError, L as readMobileBearerToken, P as withSessionPermissionContext, R as validateMobileRedirectUri, S as PasskeyCredentialForbiddenError, T as PasskeyRegistrationError, U as getUsersOidcConfig, V as decodeOidcTransaction, W as resolveOidcProviderConfig, X as DeviceCredentialPolicyError, Y as DeviceCredentialForbiddenError, Z as DeviceCredentialService, a as TerminalAuthError, o as TerminalAuthRateLimitError, s as TerminalAuthService, w as PasskeyReauthenticationRequiredError, x as PasskeyCredentialError, z as OidcLoginError } from "./chunks/TerminalAuthService-_IB-tAgS.js";
1
+ import { M as LoginRateLimitError, d as PasswordCredentialForbiddenError, f as PasswordCredentialService, g as SessionService, p as PasswordPolicyError, u as PasswordCredentialError } from "./chunks/PasswordCredentialService-DA2Y6H2X.js";
2
+ import { B as OidcLoginService, C as PasskeyCredentialService, D as OperationPermissionError, F as MobileAuthError, H as encodeOidcTransaction, I as MobileAuthService, J as DeviceCredentialError, L as readMobileBearerToken, P as withSessionPermissionContext, R as validateMobileRedirectUri, S as PasskeyCredentialForbiddenError, T as PasskeyRegistrationError, U as getUsersOidcConfig, V as decodeOidcTransaction, W as resolveOidcProviderConfig, X as DeviceCredentialPolicyError, Y as DeviceCredentialForbiddenError, Z as DeviceCredentialService, a as TerminalAuthError, o as TerminalAuthRateLimitError, s as TerminalAuthService, w as PasskeyReauthenticationRequiredError, x as PasskeyCredentialError, z as OidcLoginError } from "./chunks/TerminalAuthService-pHNqf5o3.js";
3
3
  import { DiscoveryArtifactValidationError, SMRT_APP_RESULT_CONTRACT, SMRT_APP_RESULT_SCHEMA, SMRT_APP_RESULT_VERSION, SMRT_DISCOVERY_CONFORMANCE_ARTIFACT_SCHEMA, SMRT_DISCOVERY_CONFORMANCE_SCHEMA, SMRT_DISCOVERY_CONFORMANCE_VERSION, SMRT_MCP_RESULT_METADATA_KEY, canonicalizeDiscoveryArtifact, createDiscoveryConformanceArtifact, deriveCommandRequirements, validateDiscoveryConformanceArtifact } from "./app-contract.js";
4
4
  import { ObjectRegistry, createClassNamePredicate, resolveCustomActionMetadata, resolveEffectiveActionMetadata } from "@happyvertical/smrt-core";
5
5
  import { createLogger } from "@happyvertical/logger";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-users",
3
- "version": "0.57.20",
3
+ "version": "0.57.22",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Multi-tenant user management for the SMRT framework - users, tenants, roles, permissions, groups",
6
6
  "type": "module",
@@ -53,20 +53,20 @@
53
53
  "dependencies": {
54
54
  "@happyvertical/auth": "^0.106.0",
55
55
  "@happyvertical/logger": "^0.106.0",
56
- "@happyvertical/smrt-config": "0.57.20",
57
- "@happyvertical/smrt-core": "0.57.20",
58
- "@happyvertical/smrt-mobile-contract": "0.57.20",
59
- "@happyvertical/smrt-profiles": "0.57.20",
60
- "@happyvertical/smrt-tenancy": "0.57.20",
61
- "@happyvertical/smrt-types": "0.57.20",
62
- "@happyvertical/smrt-ui": "0.57.20",
56
+ "@happyvertical/smrt-config": "0.57.22",
57
+ "@happyvertical/smrt-core": "0.57.22",
58
+ "@happyvertical/smrt-mobile-contract": "0.57.22",
59
+ "@happyvertical/smrt-profiles": "0.57.22",
60
+ "@happyvertical/smrt-tenancy": "0.57.22",
61
+ "@happyvertical/smrt-types": "0.57.22",
62
+ "@happyvertical/smrt-ui": "0.57.22",
63
63
  "@happyvertical/sql": "^0.106.0",
64
64
  "@simplewebauthn/browser": "^14.0.0",
65
65
  "@simplewebauthn/server": "^14.0.3",
66
66
  "jose": "^6.2.12"
67
67
  },
68
68
  "devDependencies": {
69
- "@happyvertical/smrt-vitest": "0.57.20",
69
+ "@happyvertical/smrt-vitest": "0.57.22",
70
70
  "@sveltejs/package": "^2.5.8",
71
71
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
72
72
  "@types/node": "24.13.6",
@@ -104,7 +104,7 @@
104
104
  "clean": "rm -rf dist",
105
105
  "dev": "npm run build:watch",
106
106
  "test": "vitest run",
107
- "test:postgres": "node ../../scripts/run-with-ci-postgres.mjs -- pnpm exec vitest run src/__tests__/operator-provisioning-postgres.test.ts src/__tests__/member-register-postgres.test.ts src/__tests__/permission-action-alias-postgres.test.ts src/__tests__/permission-postgres-rls.test.ts src/__tests__/principal-permission-context-postgres.test.ts src/__tests__/oidc-provisioning-postgres.test.ts src/__tests__/legacy-user-profile-backfill-postgres.test.ts src/__tests__/terminal-auth-postgres.test.ts src/__tests__/device-credential-postgres.test.ts src/__tests__/password-credential-postgres.test.ts src/__tests__/passkey-credential-postgres.test.ts src/__tests__/username-identity.test.ts src/__tests__/resource-grant-postgres.test.ts src/__tests__/issue-3036-hierarchy-resolution-postgres.test.ts src/__tests__/issue-3047-permission-resolution-cost-postgres.test.ts src/__tests__/issue-3048-authorization-list-bounds-postgres.test.ts src/__tests__/issue-3329-concurrent-seeding-postgres.test.ts src/__tests__/issue-3329-grant-dedup.test.ts src/__tests__/issue-3375-authority-pair-dedup.test.ts src/__tests__/issue-3375-authority-pair-identity.test.ts src/__tests__/oauth-authorization.test.ts",
107
+ "test:postgres": "node ../../scripts/run-with-ci-postgres.mjs -- pnpm exec vitest run src/__tests__/operator-provisioning-postgres.test.ts src/__tests__/member-register-postgres.test.ts src/__tests__/permission-action-alias-postgres.test.ts src/__tests__/permission-postgres-rls.test.ts src/__tests__/principal-permission-context-postgres.test.ts src/__tests__/oidc-provisioning-postgres.test.ts src/__tests__/legacy-user-profile-backfill-postgres.test.ts src/__tests__/terminal-auth-postgres.test.ts src/__tests__/device-credential-postgres.test.ts src/__tests__/password-credential-postgres.test.ts src/__tests__/passkey-credential-postgres.test.ts src/__tests__/username-identity.test.ts src/__tests__/resource-grant-postgres.test.ts src/__tests__/issue-3036-hierarchy-resolution-postgres.test.ts src/__tests__/issue-3047-permission-resolution-cost-postgres.test.ts src/__tests__/issue-3048-authorization-list-bounds-postgres.test.ts src/__tests__/issue-3329-concurrent-seeding-postgres.test.ts src/__tests__/issue-3329-grant-dedup.test.ts src/__tests__/issue-3375-authority-pair-dedup.test.ts src/__tests__/issue-3375-authority-pair-identity.test.ts src/__tests__/oauth-authorization.test.ts src/__tests__/mailbox-authentication.test.ts",
108
108
  "typecheck": "tsc --noEmit && node ../../scripts/svelte-check-a11y.mjs --tsconfig ./tsconfig.svelte.json",
109
109
  "check": "pnpm exec svelte-check --tsconfig ./tsconfig.svelte.json",
110
110
  "verify:pack": "node ../../scripts/verify-package-types-exports.js ."