@happyvertical/smrt-users 0.57.41 → 0.57.43
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/AGENTS.md +1 -0
- package/agents/family-invitations.md +62 -0
- package/dist/chunks/{PasswordCredentialService-bedKxkaa.js → PasswordCredentialService-DHJNKEeJ.js} +53 -7
- package/dist/chunks/PasswordCredentialService-DHJNKEeJ.js.map +1 -0
- package/dist/chunks/{TerminalAuthService-DU1uUFVC.js → TerminalAuthService-B1SqTDum.js} +3 -3
- package/dist/chunks/TerminalAuthService-B1SqTDum.js.map +1 -0
- package/dist/collections/UserCollection.d.ts +7 -0
- package/dist/collections/UserCollection.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +197 -17
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +20 -1
- package/dist/operator.js +1 -1
- package/dist/services/LoginAttemptLimiter.d.ts +2 -0
- package/dist/services/LoginAttemptLimiter.d.ts.map +1 -1
- package/dist/services/MailboxAuthenticationService.d.ts +40 -1
- package/dist/services/MailboxAuthenticationService.d.ts.map +1 -1
- package/dist/services/TenantInvitationService.d.ts +17 -3
- package/dist/services/TenantInvitationService.d.ts.map +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +29 -6
- package/dist/sveltekit/index.d.ts +8 -3
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit.js +2 -2
- package/dist/sveltekit.js.map +1 -1
- package/package.json +10 -10
- package/dist/chunks/PasswordCredentialService-bedKxkaa.js.map +0 -1
- package/dist/chunks/TerminalAuthService-DU1uUFVC.js.map +0 -1
package/dist/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": "1.0.0",
|
|
3
3
|
"timestamp": 0,
|
|
4
4
|
"packageName": "@happyvertical/smrt-users",
|
|
5
|
-
"packageVersion": "0.57.
|
|
5
|
+
"packageVersion": "0.57.43",
|
|
6
6
|
"objects": {
|
|
7
7
|
"@happyvertical/smrt-users:AccessRequestCollection": {
|
|
8
8
|
"name": "accessrequestcollection",
|
|
@@ -6344,6 +6344,25 @@
|
|
|
6344
6344
|
"packageName": "@happyvertical/smrt-users",
|
|
6345
6345
|
"fields": {},
|
|
6346
6346
|
"methods": {
|
|
6347
|
+
"requireOwnedPersonForTenant": {
|
|
6348
|
+
"name": "requireOwnedPersonForTenant",
|
|
6349
|
+
"async": true,
|
|
6350
|
+
"parameters": [
|
|
6351
|
+
{
|
|
6352
|
+
"name": "userId",
|
|
6353
|
+
"type": "string",
|
|
6354
|
+
"optional": false
|
|
6355
|
+
},
|
|
6356
|
+
{
|
|
6357
|
+
"name": "tenantId",
|
|
6358
|
+
"type": "string",
|
|
6359
|
+
"optional": false
|
|
6360
|
+
}
|
|
6361
|
+
],
|
|
6362
|
+
"returnType": "Promise<Profile>",
|
|
6363
|
+
"isStatic": false,
|
|
6364
|
+
"isPublic": true
|
|
6365
|
+
},
|
|
6347
6366
|
"findByEmail": {
|
|
6348
6367
|
"name": "findByEmail",
|
|
6349
6368
|
"async": true,
|
package/dist/operator.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dt as
|
|
1
|
+
import { Dt as normalizeEmail, Et as isValidEmail, I as UserCollection, Ot as normalizeUsername, P as verifySecretHash, U as TenantCollection, _ as PermissionResolver, f as PasswordCredentialService, lt as UsersPasswordCredentialCollection, pt as MembershipCollection, st as RoleCollection } from "./chunks/PasswordCredentialService-DHJNKEeJ.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";
|
|
@@ -181,6 +181,8 @@ export interface ReserveLoginAttemptOptions {
|
|
|
181
181
|
/** A granted reservation. Exactly one of the three methods must be awaited. */
|
|
182
182
|
export interface LoginAttemptLease {
|
|
183
183
|
readonly allowed: true;
|
|
184
|
+
/** Earliest reserved key window end, as Unix milliseconds (not a fresh TTL). */
|
|
185
|
+
readonly budgetExpiresAt: number;
|
|
184
186
|
readonly subjectKeyHash: string | null;
|
|
185
187
|
readonly sourceKeyHash: string | null;
|
|
186
188
|
/** The credential was wrong. Keeps the reservation; may lock the key. */
|
|
@@ -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;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,iBAAiB,CAAC;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C,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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Independent emailed mailbox authentication for existing active canonical users. */
|
|
2
2
|
import { type SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
3
|
+
import type { DatabaseInterface } from '@happyvertical/sql';
|
|
3
4
|
import { type LoginAttemptLimiter } from './LoginAttemptLimiter.js';
|
|
4
5
|
/** Server-only effect. Never return, log, preview, or expose the mailed proof. */
|
|
5
6
|
export type MailboxAuthenticationDelivery = (mail: {
|
|
@@ -18,12 +19,48 @@ export interface AuthenticatedMailbox {
|
|
|
18
19
|
profileId: string;
|
|
19
20
|
tenantId: string;
|
|
20
21
|
}
|
|
22
|
+
/** Immutable destination selected by the trusted server before its caller transaction. */
|
|
23
|
+
export type MailboxAuthenticationRequestScope = {
|
|
24
|
+
purpose: 'returning';
|
|
25
|
+
email: string;
|
|
26
|
+
} | {
|
|
27
|
+
purpose: 'invitation';
|
|
28
|
+
tenantId: string;
|
|
29
|
+
email: string;
|
|
30
|
+
};
|
|
31
|
+
declare const mailboxReservationBrand: unique symbol;
|
|
32
|
+
/** Opaque one-use budget capability; never serialize, copy, or return to a browser. */
|
|
33
|
+
export type MailboxRequestReservation = Readonly<{
|
|
34
|
+
[mailboxReservationBrand]: true;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Reserve AND settle retained send budget before entering the caller transaction.
|
|
38
|
+
* Malformed/unknown returning email deliberately consumes the same source budget.
|
|
39
|
+
* This capability carries no release/refund operation and expires no later than
|
|
40
|
+
* any reserved key's actual window end or thirty seconds, whichever comes first.
|
|
41
|
+
*/
|
|
42
|
+
export declare function reserveMailboxAuthenticationRequest(input: {
|
|
43
|
+
limiter: LoginAttemptLimiter;
|
|
44
|
+
scope: MailboxAuthenticationRequestScope;
|
|
45
|
+
sourceKey: string;
|
|
46
|
+
}): Promise<MailboxRequestReservation>;
|
|
47
|
+
/** Internal one-use claim: delete synchronously, before any request work can await. */
|
|
48
|
+
export declare function claimMailboxAuthenticationRequest(input: {
|
|
49
|
+
reservation?: MailboxRequestReservation;
|
|
50
|
+
limiter?: LoginAttemptLimiter;
|
|
51
|
+
sourceKey: string;
|
|
52
|
+
db: DatabaseInterface;
|
|
53
|
+
}): {
|
|
54
|
+
reserved: boolean;
|
|
55
|
+
assertFresh: () => void;
|
|
56
|
+
assertScope(scope: MailboxAuthenticationRequestScope): void;
|
|
57
|
+
};
|
|
21
58
|
/** Canonical shared request budget; keys are hashed/peppered by LoginAttemptLimiter. */
|
|
22
59
|
export declare function reserveMailboxRequest(input: {
|
|
23
60
|
subject: string;
|
|
24
61
|
sourceKey: string;
|
|
25
62
|
limiter?: LoginAttemptLimiter;
|
|
26
|
-
}): Promise<
|
|
63
|
+
}): Promise<number>;
|
|
27
64
|
/** Preserve existing signed-in identity and session ceilings during mailbox login. */
|
|
28
65
|
export declare function assertMailboxSessionCompatibility(options: SmrtClassOptions, input: {
|
|
29
66
|
userId: string;
|
|
@@ -47,6 +84,7 @@ export declare class MailboxAuthenticationService {
|
|
|
47
84
|
email: string;
|
|
48
85
|
sourceKey: string;
|
|
49
86
|
deliver: MailboxAuthenticationDelivery;
|
|
87
|
+
reservation?: MailboxRequestReservation;
|
|
50
88
|
}): Promise<{
|
|
51
89
|
requested: true;
|
|
52
90
|
}>;
|
|
@@ -58,4 +96,5 @@ export declare class MailboxAuthenticationService {
|
|
|
58
96
|
private links;
|
|
59
97
|
private eligible;
|
|
60
98
|
}
|
|
99
|
+
export {};
|
|
61
100
|
//# sourceMappingURL=MailboxAuthenticationService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MailboxAuthenticationService.d.ts","sourceRoot":"","sources":["../../src/services/MailboxAuthenticationService.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"MailboxAuthenticationService.d.ts","sourceRoot":"","sources":["../../src/services/MailboxAuthenticationService.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAO5D,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,0FAA0F;AAC1F,MAAM,MAAM,iCAAiC,GACzC;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,O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AmC;IAc1D,OAAO,CAAC,KAAK,EAAE;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,6BAA6B,CAAC;QACvC,WAAW,CAAC,EAAE,yBAAyB,CAAC;KACzC,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,CAAC;IA4C1B,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"}
|
|
@@ -2,13 +2,18 @@ import { type SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
|
2
2
|
import { type Profile } from '@happyvertical/smrt-profiles';
|
|
3
3
|
import { type OidcProfileOwnerAuthorizerContext } from '../collections/UserCollection.js';
|
|
4
4
|
import type { LoginAttemptLimiter } from './LoginAttemptLimiter.js';
|
|
5
|
-
import { type MailboxAuthenticationDelivery } from './MailboxAuthenticationService.js';
|
|
5
|
+
import { type MailboxAuthenticationDelivery, type MailboxRequestReservation } from './MailboxAuthenticationService.js';
|
|
6
6
|
/** Host-authorized invitation destination and least-privilege system role. */
|
|
7
|
-
export
|
|
7
|
+
export type PrepareTenantInvitationInput = {
|
|
8
8
|
tenantId: string;
|
|
9
9
|
email: string;
|
|
10
|
+
} & ({
|
|
10
11
|
roleSlug: string;
|
|
11
|
-
|
|
12
|
+
roleId?: never;
|
|
13
|
+
} | {
|
|
14
|
+
roleId: string;
|
|
15
|
+
roleSlug?: never;
|
|
16
|
+
});
|
|
12
17
|
/** Persisted pending access; active means the exact membership already existed. */
|
|
13
18
|
export interface PreparedTenantInvitation {
|
|
14
19
|
userId: string;
|
|
@@ -24,6 +29,8 @@ export declare class TenantInvitationError extends Error {
|
|
|
24
29
|
/** Signing is required only when issuing or accepting an invitation. */
|
|
25
30
|
export interface TenantInvitationServiceOptions extends SmrtClassOptions {
|
|
26
31
|
transaction: 'caller';
|
|
32
|
+
/** Explicitly preserve an existing active User's owned family Person. */
|
|
33
|
+
existingProfilePolicy?: 'canonical-global' | 'owned-person';
|
|
27
34
|
secret?: string;
|
|
28
35
|
tokenExpiry?: number;
|
|
29
36
|
/** Required for requestMailboxAuthentication(): supply a root-executor limiter independent of the caller transaction. Other operations may omit it. */
|
|
@@ -59,6 +66,11 @@ export declare class TenantInvitationService {
|
|
|
59
66
|
issue(input: {
|
|
60
67
|
membershipId: string;
|
|
61
68
|
}): Promise<IssuedTenantInvitation>;
|
|
69
|
+
/** Host-authorized cancellation of pending access; active memberships are never disabled. */
|
|
70
|
+
revoke(input: {
|
|
71
|
+
membershipId: string;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
private generation;
|
|
62
74
|
/**
|
|
63
75
|
* Request independent mailbox authentication, delivering only to the canonical
|
|
64
76
|
* invitee. The trusted server callback must send auth mail, never expose the
|
|
@@ -71,6 +83,7 @@ export declare class TenantInvitationService {
|
|
|
71
83
|
token: string;
|
|
72
84
|
sourceKey: string;
|
|
73
85
|
deliver: MailboxAuthenticationDelivery;
|
|
86
|
+
reservation?: MailboxRequestReservation;
|
|
74
87
|
}): Promise<{
|
|
75
88
|
expiresAt: Date;
|
|
76
89
|
}>;
|
|
@@ -114,6 +127,7 @@ export declare class TenantInvitationService {
|
|
|
114
127
|
private magicLinks;
|
|
115
128
|
/** Lock existing authority before verifying it; never authorize by email match. */
|
|
116
129
|
private invitationRecords;
|
|
130
|
+
private requireInvitationRole;
|
|
117
131
|
/** Prepare or replay a pending membership, preserving all existing authority. */
|
|
118
132
|
prepare(input: PrepareTenantInvitationInput): Promise<PreparedTenantInvitation>;
|
|
119
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TenantInvitationService.d.ts","sourceRoot":"","sources":["../../src/services/TenantInvitationService.ts"],"names":[],"mappings":"AAEA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C;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,CAAC;IA4ChC;;;;;OAKG;IACG,mBAAmB,CAAC,KAAK,EAAE;QAC/B,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,wBAAwB,CAAC;YA4CvB,YAAY;IAc1B,sFAAsF;IAChF,MAAM,CAAC,KAAK,EAAE;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA0CrC;;;;OAIG;IACG,kBAAkB,CACtB,OAAO,EAAE,iCAAiC,EAC1C,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf;;;;;;YAuCW,kBAAkB;YASlB,WAAW;YASX,UAAU;IAkBxB,mFAAmF;YACrE,iBAAiB;YA8FjB,qBAAqB;IAkBnC,iFAAiF;IAC3E,OAAO,CACX,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,wBAAwB,CAAC;CA2KrC"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { ANCESTOR_READ_ACTION, type AncestorReadPackageConfig, type AncestorRead
|
|
|
7
7
|
export { type ClearPinInput, DEFAULT_DEVICE_PERSON_IDLE_SECONDS, DEFAULT_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
|
+
export { type AuthenticatedMailbox, type MailboxAuthenticationDelivery, type MailboxAuthenticationRequestScope, MailboxAuthenticationService, type MailboxAuthenticationServiceOptions, type MailboxRequestReservation, reserveMailboxAuthenticationRequest, } from './MailboxAuthenticationService.js';
|
|
11
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';
|
|
12
12
|
export { SmrtOAuthAuthorizationService, type SmrtOAuthAuthorizationServiceOptions, type SmrtOAuthGrantSummary, } from './OAuthAuthorizationService.js';
|
|
13
13
|
export { SMRT_OAUTH_GRANT_CLAIM, SmrtOAuthAuthorizationStorage, type SmrtOAuthAuthorizationStorageOptions, } from './OAuthAuthorizationStorage.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,2BAA2B,EAC3B,KAAK,iCAAiC,EACtC,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,+BAA+B,EAC/B,+BAA+B,EAC/B,sBAAsB,EACtB,KAAK,4BAA4B,EACjC,2BAA2B,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,aAAa,EAClB,kCAAkC,EAClC,6BAA6B,EAC7B,qBAAqB,EACrB,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,8BAA8B,EAC9B,cAAc,EACd,0BAA0B,EAC1B,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,WAAW,GACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,oCAAoC,EACpC,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,0BAA0B,EAC1B,oCAAoC,EACpC,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAClC,4BAA4B,EAC5B,KAAK,mCAAmC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,2BAA2B,EAC3B,KAAK,iCAAiC,EACtC,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,oBAAoB,EACpB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,+BAA+B,EAC/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3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-users",
|
|
6
|
-
"packageVersion": "0.57.
|
|
6
|
+
"packageVersion": "0.57.43",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
10
|
+
"manifest": "5a9ce20f47185e61334fc1cc8fbfdfc72a6285d91d6dcc7931c5bf96482a10d7",
|
|
11
|
+
"packageJson": "75e18f0cd7d90d0b2325cb1214962fd139323c366a538971d937bc5ad53c8174",
|
|
12
|
+
"agents": "0dd40a4fc4386d603822766cdcff52a922577ab5cb2af81d466a209b7564214b",
|
|
13
13
|
"moduleDoc:agents/permissions.md": "02b2f03f0e057721369d9c693a624a6fdb3df4935401531a4373ff18229a64be",
|
|
14
14
|
"moduleDoc:agents/oidc-provisioning.md": "b73f3fdaf61136720132a614c7e14237b7bd35f7bf5d43eabb29f565485803b9",
|
|
15
15
|
"moduleDoc:agents/mobile-auth.md": "25e85e83f43e3a46383a92fa809f3a003b4545c3026e78dbe1bccbbc35161e18",
|
|
16
16
|
"moduleDoc:agents/terminal-auth-testing.md": "ca6bdf325fe4edc3c875e6da38e3f5b4ae287bc0e7035002d275cf15de36e906",
|
|
17
|
+
"moduleDoc:agents/family-invitations.md": "8598bfc3540b4c5ee2aef611db55dc2a8f6b6993fce9619f84a8ce32608a2954",
|
|
17
18
|
"moduleDoc:agents/retention.md": "fc6ed5443b154641bfe890a4de1213366d4b330ea1bb18ea9e0edfe605f45b02"
|
|
18
19
|
},
|
|
19
20
|
"exports": [
|
|
@@ -3329,7 +3330,8 @@
|
|
|
3329
3330
|
"findCanonicalByEmail",
|
|
3330
3331
|
"findPending",
|
|
3331
3332
|
"getOrCreateForProfile",
|
|
3332
|
-
"getOrCreateFromOidc"
|
|
3333
|
+
"getOrCreateFromOidc",
|
|
3334
|
+
"requireOwnedPersonForTenant"
|
|
3333
3335
|
],
|
|
3334
3336
|
"methodSignatures": [
|
|
3335
3337
|
{
|
|
@@ -3393,6 +3395,15 @@
|
|
|
3393
3395
|
"options?: GetOrCreateFromOidcOptions"
|
|
3394
3396
|
],
|
|
3395
3397
|
"returns": "Promise<OidcIdentityResult>"
|
|
3398
|
+
},
|
|
3399
|
+
{
|
|
3400
|
+
"name": "requireOwnedPersonForTenant",
|
|
3401
|
+
"async": true,
|
|
3402
|
+
"params": [
|
|
3403
|
+
"userId: string",
|
|
3404
|
+
"tenantId: string"
|
|
3405
|
+
],
|
|
3406
|
+
"returns": "Promise<Profile>"
|
|
3396
3407
|
}
|
|
3397
3408
|
],
|
|
3398
3409
|
"surfaces": [],
|
|
@@ -3452,6 +3463,13 @@
|
|
|
3452
3463
|
"code": "not-included",
|
|
3453
3464
|
"reason": "not listed in api.include",
|
|
3454
3465
|
"objectName": "@happyvertical/smrt-users:UserCollection"
|
|
3466
|
+
},
|
|
3467
|
+
{
|
|
3468
|
+
"kind": "api",
|
|
3469
|
+
"operation": "requireOwnedPersonForTenant",
|
|
3470
|
+
"code": "not-included",
|
|
3471
|
+
"reason": "not listed in api.include",
|
|
3472
|
+
"objectName": "@happyvertical/smrt-users:UserCollection"
|
|
3455
3473
|
}
|
|
3456
3474
|
],
|
|
3457
3475
|
"relationshipFeatures": [
|
|
@@ -8223,7 +8241,7 @@
|
|
|
8223
8241
|
"polymorphicAssociations": 0,
|
|
8224
8242
|
"uuidColumns": 162
|
|
8225
8243
|
},
|
|
8226
|
-
"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",
|
|
8244
|
+
"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/services/TenantInvitationService.ts`, `src/services/MailboxAuthenticationService.ts` | exact-role invitations, preserved identity, one-use generations and embedded transaction send budgets | [agents/family-invitations.md](agents/family-invitations.md) |\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",
|
|
8227
8245
|
"moduleDocs": [
|
|
8228
8246
|
{
|
|
8229
8247
|
"path": "agents/permissions.md",
|
|
@@ -8245,6 +8263,11 @@
|
|
|
8245
8263
|
"module": "terminal-auth-testing",
|
|
8246
8264
|
"content": "# Terminal approval storage and regression matrix — #3076\n\nThe failed-approval budget is shared storage, keyed by unique `user_id`.\nEach UPSERT candidate uses a unique private slug, so concurrent first inserts do\nnot also collide on the inherited `(slug, context)` index. Existing rows require\nno migration: their slug is not used for lookup or authorization. The guarded\nUPSERT continues to reserve at most the configured count across service instances\nand processes. Unknown database failures propagate; they are not authentication\nsuccesses or silently converted to a rate-limit response.\n\nRisk: high (terminal authentication and shared rate-limit authority). No public\nAPI, schema, session, tenant or approval contract changes.\n\n| Behavior / trigger | Positive | Negative / failure | Actor / executor | Runtime / edge | Validation |\n|---|---|---|---|---|---|\n| First reservation candidates | Distinct private insert slugs, one user budget | Third reservation denied at limit2; old code deterministically repeats slug | Same user, real SQL observed without replacing executor | SQLite; independent PostgreSQL service connections | users `test`, `test:postgres` |\n| Concurrent invalid approvals | Three attempts reach ordinary auth denial | Ten rejected, exactly seven typed rate limits; zero attacker sessions | One attacker/user+tenant, two instances, atomic UPSERT | SQLite and PostgreSQL18 | users `test`, `test:postgres` |\n| Concurrent approval/exchange | Eight approvals share one session, one of eight exchanges succeeds | Seven exchanges expired, consumed row clears session ID | UUID user/tenant, owning services | PostgreSQL; SQLite existing lifecycle coverage | users `test`, `test:postgres` |\n| Window/release | Successful attempts release their reservation | Old-window release cannot erase new-window failure; cleanup failure cannot reverse committed approval | Existing storage executor, no retry change | SQLite | users `test` |\n| Fixture retry/reseed | Two complete fixture cycles use the same emails | No duplicate email from prior committed fixture rows | Test-owned UUIDs, explicit cleanup through public database interface | PostgreSQL; intentionally independent connections outside rollback | users `test:postgres` |\n\nBefore the repair, the candidate regression fails (one slug instead of two),\nand the second PostgreSQL fixture cycle fails its fixed-email insert. Actual CI\nalso captured a PostgreSQL duplicate `(slug, context)` error during concurrent\nfirst reservations. The fixture cleans only its own IDs in FK order, then rolls\nback its isolated handle; it must not replace real connections with one shared\ntransaction, weaken count assertions, or disable retries.\n\nRun documented users build, typecheck (including Svelte), test, test:postgres and\nverify:pack gates. PostgreSQL runs use the canonical disposable-database wrapper.\nRoot knowledge checks follow all producers. No new dialect is introduced; the\nterminal auth regression suite declares SQLite and PostgreSQL coverage.\n\n## Mounted approval error projection (#4319)\n\n`mountTerminalLoginPage().approve` exposes only the explicitly public\n`TerminalAuthError` refusal message (400) and `TerminalAuthRateLimitError`\nmessage (429). Unexpected service initialization or approval failures return\n500 with `Unable to approve terminal login.`; never reflect their message or\nlog the raw exception, which can contain database connection credentials.\nAuthentication/input gates, the resolved user/tenant context, and successful\napproval remain unchanged. `terminal-approval-errors.test.ts` proves both\nservice failure points using synthetic private data, preserves typed refusals,\nand checks unauthenticated and missing-code denials before service access.\nThis projection changes no database or approval transaction behavior.\n"
|
|
8247
8265
|
},
|
|
8266
|
+
{
|
|
8267
|
+
"path": "agents/family-invitations.md",
|
|
8268
|
+
"module": "family-invitations",
|
|
8269
|
+
"content": "## Family invitations and preserved Person identity\n\nTrusted hosts may use `prepare({tenantId,email,roleId})` instead of `roleSlug`\nto select an exact destination-owned role (or genuine global system role). Both\nselectors together, foreign-tenant roles and missing roles fail closed. The\nlegacy `roleSlug` path remains system-only. `existingProfilePolicy:'owned-person'`\nis an explicit service option allowing an existing ACTIVE canonical User's\nalready-owned tenant Person; exact normalized email, Person discriminator, unique\nownership and active source-family membership/tenant are required. It never\nrebinds profiles or credentials. New pending identities stay canonical global;\nOIDC owner authorization still requires canonical global Person. Returning\n`MailboxAuthenticationService` retains its existing global-only contract.\n\n`UserCollection.requireOwnedPersonForTenant(userId,tenantId)` is a bounded\nread for the exact current tenant actor, with active destination membership; it\nvalidates the same preserved owned Person. System/bypass/different actors fail.\nConsumers must use their transaction executor and treat returned profile data as\nprivate identity data, never a cross-family directory.\n\nEach `issue` rotates a random generation in canonical membership context memory\n(`smrt/tenant-invitation`, `generation`) and signs it into grant bindings, so a\nresend invalidates every earlier grant and its mailbox proofs. `revoke` affects\nonly pending membership, rotates generation and marks it inactive. `prepare`\nmay reprepare only service-revoked inactive membership with the same role;\nmanual inactive memberships stay refused. Malformed generation fails closed.\nNever edit/forget this framework-owned state. Legacy grants without generation\nremain valid until a rotation, expiry or consumption. Host scope/relationship\nwrites must follow acceptance on the same caller executor: a failure rolls back\nnonces, activation, generation and host writes. Mint the canonical magic-link\nsession only after committed mailbox identity proof; the grant alone cannot mint.\n\n### Retained send budgets with embedded caller transactions\n\nBefore opening a caller transaction, use exported\n`reserveMailboxAuthenticationRequest({limiter,scope,sourceKey})`. Scope is\n`{purpose:'returning',email}` or `{purpose:'invitation',tenantId,email}`. Pass\nits opaque `MailboxRequestReservation` as `reservation` to the corresponding\nrequest method, with the same limiter instance configured on the service and\nthe same trusted source key. The capability is a frozen empty object branded\nonly in a private WeakMap: copying/serializing/forging/reusing it does not carry\nauthority. Claim is synchronous and consumes even mismatched attempts before\nany await. It has no release/refund method; budget is settled with\n`retainOnSuccess` before the host transaction, so transport/caller rollback\ncannot refund it. Reserve outside all caller transactions; SDK versions without\nroot transaction introspection cannot prove that the host followed this rule.\n\nSQLite/DuckDB requests without a pre-reservation fail before writes or delivery.\nPostgreSQL retains its independently supplied root-limiter implicit request path\nand its legacy subject keys; do not claim those counters are pooled with the new\ncapability keys. Each host should consistently use its selected request path.\nEach capability expires at the earlier of thirty seconds or the earliest actual\nreserved key window end; allowed `LoginAttemptLease.budgetExpiresAt` reports that\nUnix-millisecond deadline. Request rechecks expiry after awaited identity work,\nbefore proof generation and before delivery. Never retain capabilities for later\nwork or carry one across processes. Capability subject budgets use purpose-separated immutable\n`['returning',normalizedEmail]` and `['invitation',tenantId,normalizedEmail]`\ntuples, so malformed returning email cannot collide with invitation scope and preparing/reissuing membership\nor grant generations does not reset the send budget. Source budget namespace is\nshared across both purposes. Returning malformed/unknown email intentionally\nconsumes normal source budget and returns no proof: a host's unknown invitation\npreflight may reserve `{purpose:'returning',email:''}`, discard the capability\nand return its uniform failure response without a service/proof call.\n"
|
|
8270
|
+
},
|
|
8248
8271
|
{
|
|
8249
8272
|
"path": "agents/retention.md",
|
|
8250
8273
|
"module": "retention",
|
|
@@ -21,6 +21,7 @@ import type { OidcProfileOwnerAuthorizer, OidcProfileResolver } from '../collect
|
|
|
21
21
|
import { type SessionAuthMethod } from '../models/Session.js';
|
|
22
22
|
import { type OidcLoginResult, type OidcProviderResolutionOptions, type OidcTransaction } from '../services/OidcLoginService.js';
|
|
23
23
|
import { TerminalAuthError, TerminalAuthRateLimitError, TerminalAuthService, type TerminalAuthServiceOptions } from '../services/TerminalAuthService.js';
|
|
24
|
+
import type { SessionLocals } from './types.js';
|
|
24
25
|
export { type AppResultContract, type AppResultMetadata, type CommandRequirements, canonicalizeDiscoveryArtifact, createDiscoveryConformanceArtifact, type DeclaredActionField, type DiscoveryArtifactIntegrity, DiscoveryArtifactValidationError, type DiscoveryConformanceArtifact, type DiscoveryPayload, deriveCommandRequirements, type JsonValue, 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, validateDiscoveryConformanceArtifact, } from '../app-contract.js';
|
|
25
26
|
export type { NormalizedOidcClaims, OidcProfileOwnerAuthorization, OidcProfileOwnerAuthorizer, OidcProfileOwnerAuthorizerContext, OidcProfileResolver, OidcProfileResolverContext, } from '../collections/UserCollection.js';
|
|
26
27
|
export { MobileAuthError, type MobileAuthErrorCode, MobileAuthService, type MobileAuthServiceOptions, type MobileBootstrapContext, type MobileLoginContext, type MobileLogoutResult, type MobileRequestMeta, type MobileResolvedUser, type MobileTenantContext, readMobileBearerToken, validateMobileRedirectUri, } from '../services/MobileAuthService.js';
|
|
@@ -66,10 +67,14 @@ type HandleInput = {
|
|
|
66
67
|
event: {
|
|
67
68
|
cookies: {
|
|
68
69
|
get: (name: string) => string | undefined;
|
|
69
|
-
set: (name: string, value: string, options
|
|
70
|
-
|
|
70
|
+
set: (name: string, value: string, options: Record<string, unknown> & {
|
|
71
|
+
path: string;
|
|
72
|
+
}) => void;
|
|
73
|
+
delete: (name: string, options: Record<string, unknown> & {
|
|
74
|
+
path: string;
|
|
75
|
+
}) => void;
|
|
71
76
|
};
|
|
72
|
-
locals:
|
|
77
|
+
locals: Partial<SessionLocals>;
|
|
73
78
|
url: {
|
|
74
79
|
pathname: string;
|
|
75
80
|
protocol?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sveltekit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAKL,KAAK,eAAe,EAGpB,KAAK,6BAA6B,EAClC,KAAK,eAAe,EAGrB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAEL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,0BAA0B,EAChC,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sveltekit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAKL,KAAK,eAAe,EAGpB,KAAK,6BAA6B,EAClC,KAAK,eAAe,EAGrB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAEL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,0BAA0B,EAChC,MAAM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qBAAqB,CAAC,CAAC;IACvE,OAAO,EAAE,CACP,KAAK,EAAE,qBAAqB,KACzB,OAAO,CACR,2BAA2B,GAC3B;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,2BAA2B,CAAA;KAAE,CACzE,CAAC;CACH;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,6BAA6B,GACrC,wBAAwB,CAsF1B;AAuBD,OAAO,EACL,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,CAAC"}
|
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-
|
|
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-
|
|
1
|
+
import { M as LoginRateLimitError, d as PasswordCredentialForbiddenError, f as PasswordCredentialService, g as SessionService, p as PasswordPolicyError, u as PasswordCredentialError } from "./chunks/PasswordCredentialService-DHJNKEeJ.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-B1SqTDum.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";
|