@happyvertical/smrt-users 0.38.10 → 0.38.11
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 +41 -0
- package/dist/chunks/{TerminalAuthService-BuZe5vEm.js → TerminalAuthService-DGp_Wsil.js} +610 -16
- package/dist/chunks/TerminalAuthService-DGp_Wsil.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -89
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +3 -2
- package/dist/services/MobileAuthService.d.ts +242 -0
- package/dist/services/MobileAuthService.d.ts.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +8 -6
- package/dist/sveltekit/index.d.ts +2 -0
- package/dist/sveltekit/index.d.ts.map +1 -1
- package/dist/sveltekit/mobile-handlers.d.ts +66 -0
- package/dist/sveltekit/mobile-handlers.d.ts.map +1 -0
- package/dist/sveltekit.js +178 -2
- package/dist/sveltekit.js.map +1 -1
- package/package.json +11 -10
- package/dist/chunks/TerminalAuthService-BuZe5vEm.js.map +0 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
2
|
+
import { MobileAuthCompleteRequest, MobileAuthSession, MobileAuthStartRequest, MobileAuthStartResponse, MobileSessionBootstrap, MobileTenantOption } from '@happyvertical/smrt-mobile-contract';
|
|
3
|
+
import { OidcClaims } from '../collections/UserCollection.js';
|
|
4
|
+
import { OidcProviderResolutionOptions, OidcTokenSet } from './OidcLoginService.js';
|
|
5
|
+
import { SessionContext, SessionService } from './SessionService.js';
|
|
6
|
+
/**
|
|
7
|
+
* Machine-readable error codes carried on {@link MobileAuthError} and in the
|
|
8
|
+
* JSON error body (`{ error, code }`) the SvelteKit handlers emit.
|
|
9
|
+
*/
|
|
10
|
+
export type MobileAuthErrorCode = 'invalid_request' | 'unknown_provider' | 'invalid_redirect_uri' | 'missing_code_verifier' | 'invalid_state' | 'expired_transaction' | 'exchange_failed' | 'signin_not_permitted' | 'missing_bearer_token' | 'invalid_bearer_token' | 'provider_unavailable' | 'server_misconfigured';
|
|
11
|
+
/**
|
|
12
|
+
* HTTP-mapped mobile-auth failure. `status` drives the response code; `code`
|
|
13
|
+
* gives clients a stable discriminator (messages may change).
|
|
14
|
+
*/
|
|
15
|
+
export declare class MobileAuthError extends Error {
|
|
16
|
+
readonly status: number;
|
|
17
|
+
readonly code: MobileAuthErrorCode;
|
|
18
|
+
constructor(status: number, code: MobileAuthErrorCode, message: string);
|
|
19
|
+
}
|
|
20
|
+
/** Context handed to the {@link MobileAuthServiceOptions.resolveUser} hook. */
|
|
21
|
+
export interface MobileLoginContext {
|
|
22
|
+
claims: OidcClaims;
|
|
23
|
+
tokens: OidcTokenSet;
|
|
24
|
+
providerName: string;
|
|
25
|
+
}
|
|
26
|
+
/** Minimal user identity a {@link MobileAuthServiceOptions.resolveUser} hook returns. */
|
|
27
|
+
export interface MobileResolvedUser {
|
|
28
|
+
id: string;
|
|
29
|
+
email?: string | null;
|
|
30
|
+
}
|
|
31
|
+
/** Context handed to the {@link MobileAuthServiceOptions.resolveTenantId} hook. */
|
|
32
|
+
export interface MobileTenantContext {
|
|
33
|
+
userId: string;
|
|
34
|
+
claims: OidcClaims;
|
|
35
|
+
providerName: string;
|
|
36
|
+
}
|
|
37
|
+
/** Context handed to the {@link MobileAuthServiceOptions.buildExtras} hook. */
|
|
38
|
+
export interface MobileBootstrapContext {
|
|
39
|
+
/** Full session context (user, membership, tenantId, sessionId). */
|
|
40
|
+
session: SessionContext;
|
|
41
|
+
/**
|
|
42
|
+
* The session's resolved permission slugs. Any MODEL JSON placed into
|
|
43
|
+
* `extras` must be projected with `toPublicJSON({ permissions })` using
|
|
44
|
+
* THIS set, or the response leaks fields the generated routes redact
|
|
45
|
+
* (`@field({ readPermission })`, #1822). Fail closed.
|
|
46
|
+
*/
|
|
47
|
+
permissions: string[];
|
|
48
|
+
tenants: MobileTenantOption[];
|
|
49
|
+
activeTenant: MobileTenantOption | null;
|
|
50
|
+
}
|
|
51
|
+
/** Request metadata recorded onto the minted session. */
|
|
52
|
+
export interface MobileRequestMeta {
|
|
53
|
+
userAgent?: string;
|
|
54
|
+
ipAddress?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface MobileAuthServiceOptions extends SmrtClassOptions, OidcProviderResolutionOptions {
|
|
57
|
+
/** Optional fetch override for tests or custom runtimes. */
|
|
58
|
+
fetch?: typeof fetch;
|
|
59
|
+
/** JWT clock tolerance passed to jose. */
|
|
60
|
+
clockTolerance?: number | string;
|
|
61
|
+
/**
|
|
62
|
+
* Allowed mobile redirect URIs. Entries are exact matches, except entries
|
|
63
|
+
* ending in `/` which allow any sub-path of that prefix. When omitted or
|
|
64
|
+
* empty, any structurally valid mobile redirect URI is accepted (https,
|
|
65
|
+
* loopback http, or a private app scheme — RFC 8252); configure this in
|
|
66
|
+
* production so authorization responses cannot be pointed at an
|
|
67
|
+
* attacker-controlled URI.
|
|
68
|
+
*/
|
|
69
|
+
redirectUris?: string[];
|
|
70
|
+
/** Mobile bearer session TTL in seconds. Default: 30 days. */
|
|
71
|
+
sessionTtl?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Auth handshake (start → complete) TTL in seconds. Default: 10 minutes,
|
|
74
|
+
* matching the web flow's transaction cookie.
|
|
75
|
+
*/
|
|
76
|
+
transactionTtl?: number;
|
|
77
|
+
/**
|
|
78
|
+
* HMAC secret for state-token integrity. Defaults to the resolved
|
|
79
|
+
* provider's `clientSecret`.
|
|
80
|
+
*
|
|
81
|
+
* State signing binds the `nonce`/provider/createdAt in the OAuth `state`
|
|
82
|
+
* so they cannot be forged, so it is REQUIRED by default: if neither
|
|
83
|
+
* `stateSecret` nor the provider's `clientSecret` is available, sign-in
|
|
84
|
+
* fails closed (500 `server_misconfigured`). A public OIDC client (no
|
|
85
|
+
* client secret — the PKCE case) just supplies a `stateSecret`; it is a
|
|
86
|
+
* server-side HMAC key unrelated to OAuth client authentication, so any
|
|
87
|
+
* deployment can set one. Set {@link allowUnsignedState} to opt into
|
|
88
|
+
* unsigned tokens (NOT recommended — then `redirectUris` is the only
|
|
89
|
+
* defense against state forgery).
|
|
90
|
+
*/
|
|
91
|
+
stateSecret?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Permit unsigned state tokens when no `stateSecret`/`clientSecret` is
|
|
94
|
+
* configured. Default false (fail closed). Only enable for local
|
|
95
|
+
* development or a deployment that accepts the state-forgery risk;
|
|
96
|
+
* production should configure a `stateSecret` instead.
|
|
97
|
+
*/
|
|
98
|
+
allowUnsignedState?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Include descendant tenants reachable through ACTIVE memberships whose
|
|
101
|
+
* role has `inheritsToDescendants: true` (#1867) in the bootstrap tenant
|
|
102
|
+
* list. Default true.
|
|
103
|
+
*/
|
|
104
|
+
includeInheritedTenants?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Provision a user even when the IdP explicitly reported the email as
|
|
107
|
+
* unverified. Passed through to `UserCollection.getOrCreateFromOidc`.
|
|
108
|
+
*/
|
|
109
|
+
allowUnverifiedEmail?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Map verified IdP claims to a SMRT user. The default provisions (or
|
|
112
|
+
* resolves) the user via `UserCollection.getOrCreateFromOidc`. Return
|
|
113
|
+
* `null`/`undefined` to REFUSE sign-in (403 `signin_not_permitted`) —
|
|
114
|
+
* invite-gated apps resolve against their own membership rules here
|
|
115
|
+
* without any user row being created. THROWING (vs returning null) is
|
|
116
|
+
* treated as an unexpected server error and surfaces as a generic 500;
|
|
117
|
+
* translate expected denials into a `null` return or a thrown
|
|
118
|
+
* {@link MobileAuthError}.
|
|
119
|
+
*/
|
|
120
|
+
resolveUser?: (context: MobileLoginContext) => Promise<MobileResolvedUser | null | undefined>;
|
|
121
|
+
/**
|
|
122
|
+
* Choose the tenant the minted session is bound to. Return a tenant id,
|
|
123
|
+
* `null` for an explicitly tenant-less session, or `undefined` to fall
|
|
124
|
+
* back to the default (the first direct ACTIVE membership's tenant,
|
|
125
|
+
* sorted by tenant name). The session's tenant is the isolation key for
|
|
126
|
+
* every `@TenantScoped` query, so only return tenants the user can
|
|
127
|
+
* actually resolve permissions in.
|
|
128
|
+
*/
|
|
129
|
+
resolveTenantId?: (context: MobileTenantContext) => Promise<string | null | undefined>;
|
|
130
|
+
/**
|
|
131
|
+
* App-defined `extras` object for the session bootstrap. Must be a plain
|
|
132
|
+
* JSON object (the Kotlin client decodes it as `JsonObject`). See
|
|
133
|
+
* {@link MobileBootstrapContext.permissions} for the read-permission
|
|
134
|
+
* redaction requirement on model JSON.
|
|
135
|
+
*/
|
|
136
|
+
buildExtras?: (context: MobileBootstrapContext) => Promise<Record<string, unknown> | null | undefined>;
|
|
137
|
+
}
|
|
138
|
+
/** Result of {@link MobileAuthService.logout}. */
|
|
139
|
+
export interface MobileLogoutResult {
|
|
140
|
+
ok: true;
|
|
141
|
+
/** Whether a live session was actually revoked. */
|
|
142
|
+
destroyed: boolean;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Pull the token out of an `Authorization: Bearer <token>` header. Returns
|
|
146
|
+
* `null` when the header is missing or malformed.
|
|
147
|
+
*/
|
|
148
|
+
export declare function readMobileBearerToken(authorizationHeader: string | null | undefined): string | null;
|
|
149
|
+
/**
|
|
150
|
+
* Validate a mobile redirect URI: absolute, a safe scheme (https, loopback
|
|
151
|
+
* http, or a private app scheme per RFC 8252), and — when an allow list is
|
|
152
|
+
* configured — present on it. Returns the normalized URI.
|
|
153
|
+
*/
|
|
154
|
+
export declare function validateMobileRedirectUri(value: unknown, allowList?: string[]): string;
|
|
155
|
+
/**
|
|
156
|
+
* Server implementation of the `/api/mobile` auth + session contract.
|
|
157
|
+
*
|
|
158
|
+
* Framework-agnostic: methods take plain wire DTOs and header strings and
|
|
159
|
+
* return wire DTOs or throw {@link MobileAuthError}. The SvelteKit adapters
|
|
160
|
+
* live in `@happyvertical/smrt-users/sveltekit`
|
|
161
|
+
* (`createMobileAuthHandlers`).
|
|
162
|
+
*/
|
|
163
|
+
export declare class MobileAuthService {
|
|
164
|
+
private readonly options;
|
|
165
|
+
private readonly classOptions;
|
|
166
|
+
private readonly sessionTtl;
|
|
167
|
+
private readonly transactionTtl;
|
|
168
|
+
private sessionService;
|
|
169
|
+
private userCollection;
|
|
170
|
+
private membershipCollection;
|
|
171
|
+
private roleCollection;
|
|
172
|
+
private tenantCollection;
|
|
173
|
+
/** Per-(provider, redirectUri) service cache preserving metadata caches. */
|
|
174
|
+
private readonly oidcServices;
|
|
175
|
+
constructor(options: MobileAuthServiceOptions);
|
|
176
|
+
private initialize;
|
|
177
|
+
static create(options: MobileAuthServiceOptions): Promise<MobileAuthService>;
|
|
178
|
+
/**
|
|
179
|
+
* The underlying {@link SessionService}. Exposed so route guards can share
|
|
180
|
+
* it with `withSessionPermissionContext` instead of minting a second one.
|
|
181
|
+
*/
|
|
182
|
+
getSessionService(): SessionService;
|
|
183
|
+
private resolveProvider;
|
|
184
|
+
private getOidcService;
|
|
185
|
+
/**
|
|
186
|
+
* The HMAC secret for state signing, or `undefined` when unsigned tokens
|
|
187
|
+
* are explicitly permitted via {@link MobileAuthServiceOptions.allowUnsignedState}.
|
|
188
|
+
* Fails closed (throws → 500 `server_misconfigured`) when no secret is
|
|
189
|
+
* available and unsigned tokens are not opted in, so a deployment can never
|
|
190
|
+
* silently fall back to forgeable state tokens.
|
|
191
|
+
*/
|
|
192
|
+
private stateSecretFor;
|
|
193
|
+
/**
|
|
194
|
+
* `POST /api/mobile/auth/start` — begin the server-brokered PKCE
|
|
195
|
+
* handshake. Returns the authorization URL plus the `state` and
|
|
196
|
+
* `codeVerifier` the client must persist and echo back on complete.
|
|
197
|
+
*/
|
|
198
|
+
start(input: MobileAuthStartRequest): Promise<MobileAuthStartResponse>;
|
|
199
|
+
/**
|
|
200
|
+
* `POST /api/mobile/auth/complete` — exchange the authorization code (with
|
|
201
|
+
* the echoed `state` + `codeVerifier`) for a mobile bearer session.
|
|
202
|
+
*/
|
|
203
|
+
complete(input: MobileAuthCompleteRequest, meta?: MobileRequestMeta): Promise<MobileAuthSession>;
|
|
204
|
+
private resolveUserFromLogin;
|
|
205
|
+
private resolveSessionTenantId;
|
|
206
|
+
/**
|
|
207
|
+
* `GET /api/mobile/session` — bootstrap the app from a bearer token.
|
|
208
|
+
* Throws 401 when the token is missing, unknown, expired, or revoked.
|
|
209
|
+
*/
|
|
210
|
+
bootstrap(authorizationHeader: string | null | undefined): Promise<MobileSessionBootstrap>;
|
|
211
|
+
/**
|
|
212
|
+
* Resolve a bearer header into a full {@link SessionContext} (user,
|
|
213
|
+
* membership, resolved permissions, tenant). Throws {@link MobileAuthError}
|
|
214
|
+
* with the 401 semantics the mobile client's re-auth flow expects.
|
|
215
|
+
*/
|
|
216
|
+
resolveSessionContext(authorizationHeader: string | null | undefined): Promise<SessionContext>;
|
|
217
|
+
/**
|
|
218
|
+
* `DELETE /api/mobile/session` — revoke the bearer session. Idempotent:
|
|
219
|
+
* a missing or unknown token reports `destroyed: false` with 200.
|
|
220
|
+
*/
|
|
221
|
+
logout(authorizationHeader: string | null | undefined): Promise<MobileLogoutResult>;
|
|
222
|
+
/**
|
|
223
|
+
* The user's selectable tenants: direct ACTIVE memberships plus — when
|
|
224
|
+
* `includeInheritedTenants` is on (default) — descendant tenants reachable
|
|
225
|
+
* through an ACTIVE membership whose role has `inheritsToDescendants:
|
|
226
|
+
* true` (#1867). Selection mirrors the permission resolver: the NEAREST
|
|
227
|
+
* flagged ancestor membership labels an inherited option, unflagged or
|
|
228
|
+
* inactive ancestors neither confer nor block, and ANY direct membership
|
|
229
|
+
* row on a tenant pins it (active → its own role; inactive → excluded,
|
|
230
|
+
* since a pinned inactive row resolves to the empty permission set).
|
|
231
|
+
*
|
|
232
|
+
* This list is informational — per-request authorization always re-runs
|
|
233
|
+
* through `PermissionResolver`, which additionally fail-closes on
|
|
234
|
+
* malformed hierarchy paths.
|
|
235
|
+
*/
|
|
236
|
+
listTenantOptions(userId: string): Promise<MobileTenantOption[]>;
|
|
237
|
+
private buildTenantOptions;
|
|
238
|
+
private loadTenantOptionSources;
|
|
239
|
+
private toTenantOption;
|
|
240
|
+
private toUserSummary;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=MobileAuthService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileAuthService.d.ts","sourceRoot":"","sources":["../../src/services/MobileAuthService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAEnB,MAAM,qCAAqC,CAAC;AAI7C,OAAO,EACL,KAAK,UAAU,EAEhB,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EAGL,KAAK,6BAA6B,EAClC,KAAK,YAAY,EAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAerD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC3B,iBAAiB,GACjB,kBAAkB,GAClB,sBAAsB,GACtB,uBAAuB,GACvB,eAAe,GACf,qBAAqB,GACrB,iBAAiB,GACjB,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,CAAC;AAE3B;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;gBAEvB,MAA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PABILITIES, type AccessRequestAuthorizationContext, type AccessRequestAuthorizer, type AccessRequestCapability, AccessRequestError, type AccessRequestErrorCode, type AccessRequestEvent, type AccessRequestEventHandler, type AccessRequestEventType, AccessRequestService, type AccessRequestServiceOptions, type ApproveAccessRequestOptions, type CancelAccessRequestOptions, type CreateAccessRequestInput, type DeclineAccessRequestOptions, type GraduateAccessRequestOptions, type GraduateAccessRequestResult, type GraduateExistingTenantOption, type GraduateNewTenantOption, type GraduateTenantOption, type ListAccessRequestsFilter, } from './AccessRequestService.js';
|
|
6
6
|
export { MagicLinkError, type MagicLinkResult, MagicLinkService, type MagicLinkServiceOptions, type MagicLinkVerifyResult, } from './MagicLinkService.js';
|
|
7
|
+
export { MobileAuthError, type MobileAuthErrorCode, MobileAuthService, type MobileAuthServiceOptions, type MobileBootstrapContext, type MobileLoginContext, type MobileLogoutResult, type MobileRequestMeta, type MobileResolvedUser, type MobileTenantContext, readMobileBearerToken, validateMobileRedirectUri, } from './MobileAuthService.js';
|
|
7
8
|
export { type CreateAuthorizationUrlOptions, decodeOidcTransaction, encodeOidcTransaction, getUsersOidcConfig, type OidcCallbackResult, OidcLoginError, type OidcLoginResult, OidcLoginService, type OidcLoginServiceOptions, type OidcProviderConfig, type OidcProviderKind, type OidcProviderMetadata, type OidcProviderResolution, type OidcProviderResolutionOptions, type OidcTokenEndpointAuthMethod, type OidcTokenSet, type OidcTransaction, type ResolvedOidcProviderConfig, resolveOidcProviderConfig, type UsersOidcConfig, } from './OidcLoginService.js';
|
|
8
9
|
export { assertOperationPermission, checkOperationPermission, hasOperationPermission, type OperationPermissionAllowReason, type OperationPermissionDecision, type OperationPermissionDenyReason, OperationPermissionError, type OperationPermissionOptions, } from './OperationPermissionService.js';
|
|
9
10
|
export { deriveOperationPermissionCollectionName, deriveOperationPermissionSlug, normalizeOperationPermissionAction, type OperationPermissionCollectionInput, type PermissionCatalog, PermissionCatalogService, type PermissionCatalogSource, type PermissionCatalogSyncResult, type PermissionDefinition, type PostgresPermissionAction, type PostgresPermissionBinding, registerPermissionDefinitions, syncPermissionCatalog, type UsersConfig, } from './PermissionCatalogService.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,cAAc,EACd,KAAK,eAAe,EACpB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,6BAA6B,EAClC,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,cAAc,EACd,KAAK,eAAe,EACpB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,yBAAyB,EACzB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,sBAA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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,cAAc,EACd,KAAK,eAAe,EACpB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,6BAA6B,EAClC,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,cAAc,EACd,KAAK,eAAe,EACpB,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,YAAY,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CAAqC,EACrC,sCAAsC,EACtC,oCAAoC,EACpC,+BAA+B,EAC/B,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,0BAA0B,CAAC"}
|
package/dist/smrt-knowledge.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-07-
|
|
3
|
+
"generatedAt": "2026-07-08T00:21:09.415Z",
|
|
4
4
|
"packageName": "@happyvertical/smrt-users",
|
|
5
|
-
"packageVersion": "0.38.
|
|
5
|
+
"packageVersion": "0.38.11",
|
|
6
6
|
"sourceManifestPath": "dist/manifest.json",
|
|
7
7
|
"agentDocPath": "AGENTS.md",
|
|
8
8
|
"sourceHashes": {
|
|
9
|
-
"manifest": "
|
|
10
|
-
"packageJson": "
|
|
11
|
-
"agents": "
|
|
9
|
+
"manifest": "2d4ae908f7171842d7e6d525021426db6c46d33333b79181df1352f2f7b25032",
|
|
10
|
+
"packageJson": "4ee9276cb7075b5a01efde3b1e30b5564ab54e27be2ce5eefb4f019ab1d37c43",
|
|
11
|
+
"agents": "168f57b55a92c1fa53760f1c09e8eb7d4e51c6cc1db55dd541aec0a224cd3a41"
|
|
12
12
|
},
|
|
13
13
|
"exports": [
|
|
14
14
|
".",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@happyvertical/logger": "catalog:",
|
|
23
23
|
"@happyvertical/smrt-config": "workspace:*",
|
|
24
24
|
"@happyvertical/smrt-core": "workspace:*",
|
|
25
|
+
"@happyvertical/smrt-mobile-contract": "workspace:*",
|
|
25
26
|
"@happyvertical/smrt-profiles": "workspace:*",
|
|
26
27
|
"@happyvertical/smrt-tenancy": "workspace:*",
|
|
27
28
|
"@happyvertical/smrt-types": "workspace:*",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"smrtDependencies": [
|
|
43
44
|
"@happyvertical/smrt-config",
|
|
44
45
|
"@happyvertical/smrt-core",
|
|
46
|
+
"@happyvertical/smrt-mobile-contract",
|
|
45
47
|
"@happyvertical/smrt-profiles",
|
|
46
48
|
"@happyvertical/smrt-tenancy",
|
|
47
49
|
"@happyvertical/smrt-types",
|
|
@@ -2863,5 +2865,5 @@
|
|
|
2863
2865
|
"polymorphicAssociations": 0,
|
|
2864
2866
|
"uuidColumns": 49
|
|
2865
2867
|
},
|
|
2866
|
-
"agentDoc": "# @happyvertical/smrt-users\n\nMulti-tenant user management with RBAC, hierarchical tenants, session handling, and SvelteKit integration.\n\n## Models (14)\n\n| Model | Key Pattern |\n|-------|-------------|\n| User | Auth identity. `profileId` is plain string (not FK) to smrt-profiles. Email auto-lowercased. |\n| AccessRequest | \"Request access / waitlist\" record captured before a `User` exists. CLOSED generated surface (`api`/`mcp`/`cli` = `[]`) — all access via `AccessRequestService`. Email normalized + indexed; JSON `requestContext` (NOT `context` — reserved for slug scoping). |\n| Tenant | **STI** + hierarchical parent-child. `hierarchyPath` (materialized path), `hierarchyLevel`. Max depth 10. |\n| Session | Server-side. Secure UUID. TTL in **seconds** (not ms). Status auto-updates to EXPIRED on access. |\n| MagicLinkToken | Single-use email login token. Backed by `MagicLinkService`. |\n| Role | `tenantId = null` → system role (available to all tenants). `isSystem: true` blocks deletion. `inheritsToDescendants: true` (default false) opts the role's membership authority into descendant tenants. |\n| Permission | Slug format: `resource.action`. Parsed by PermissionResolver. |\n| Membership | User + Tenant + Role junction. UNIQUE(userId, tenantId). |\n| Group | Team within a tenant. Multiple roles via GroupRole. |\n| GroupMember, GroupRole, RolePermission | Join tables. |\n| MembershipOverride | Per-user permission grant/deny. **DENY always wins.** |\n| TenantPermissionOverride | Tenant-level cascade overrides. Effect: INHERIT/GRANT/DENY. |\n\n## Permission Resolution — Precedence (broad → specific, most-specific wins)\n\n`PermissionResolver.resolvePermissions` builds the effective set in this order;\neach later layer overrides earlier ones:\n\n1. **Tenant-inherited** — walk ancestors, apply each `TenantPermissionOverride`\n down the cascade (GRANT adds, DENY removes within the hierarchy)\n2. **Membership role** — base permissions from the user's role in the tenant\n3. **Group roles** — permissions from all groups the user belongs to **in that tenant**\n4. **Tenant-level DENY** *(removes; overrides role/group grants, tenant-wide)* — a\n `TenantPermissionOverride` with effect `DENY` is a HARD, tenant-wide block: it\n subtracts the DENY'd slug even if a role or group granted it (steps 2–3). It\n sits just **above** the per-user membership overrides and **below** role/group.\n5. **Membership GRANT override** *(re-adds; most specific)* — a per-user GRANT can\n re-add a slug a tenant DENY'd in step 4, because it is more specific.\n6. **Membership DENY override** *(absolute; always wins)* — a per-user DENY removes\n the slug last and is never overridden.\n\nSo a permission a role grants but the tenant DENYs is **removed**, unless that\nexact user also has a membership-GRANT override for it. A membership-DENY always\nwins. Tenant-DENY of an inherited/cascade grant still blocks it (unchanged).\nThe hard block reflects the tenant cascade's **net** resolution, not an\nunconditional union of every DENY in the chain — so a more-specific tenant GRANT\n(e.g. a child sub-tenant re-granting a permission its parent DENYs) still wins.\n\n### Membership selection — hierarchical inheritance (opt-in, #1866)\n\nWhich membership feeds step 2 above:\n\n1. **A direct membership row in the target tenant always pins resolution to\n itself** — active rows resolve normally; an inactive (pending/suspended)\n row resolves to the **empty set**. A direct row therefore *attenuates*\n rather than unions: \"viewer here, despite being network admin\" gives\n viewer, and a suspension in the child is effective even for users holding\n inheritable authority on an ancestor.\n2. **No direct row** → the resolver walks the tenant's ancestors (nearest\n first, from `hierarchyPath`) and resolves through the **nearest ACTIVE\n ancestor membership whose role has `inheritsToDescendants: true`**.\n Unflagged or inactive ancestor memberships are skipped (they neither confer\n nor block); there is **no union across the chain** — the nearest flagged\n membership alone is used. To attenuate a specific descendant, create a\n direct membership there or use a tenant-level DENY.\n3. **No qualifying ancestor** → empty set (byte-identical to the\n pre-inheritance resolver; with no role flagged, nothing changes).\n\nAll later layers run unchanged against the **target** tenant: the tenant\ncascade and tenant-DENY hard block come from the target tenant (a child can\ncarve authority out of an inherited role), group roles stay exact-tenant (only\ntarget-tenant groups contribute; ancestor groups never flow down), and\nmembership GRANT/DENY overrides travel with the ancestor membership used.\n`PermissionResolutionResult.inheritedFromTenantId` reports the ancestor tenant\nwhen inheritance was used (`null` for direct resolution).\n\nSafety: resolution is bounded by `MAX_TENANT_HIERARCHY_DEPTH`; malformed\n`hierarchyPath` values fail closed to the empty set — too deep,\nself-referential, duplicate ancestors, or inconsistent with the actual\n`parentTenantId` chain (the path is verified link-by-link against the loaded\nancestor rows before it is trusted as an authorization source). Tenant `status` is not consulted (parity with direct\nresolution). Caching: a long-lived `(user, tenant)` permission cache must also\ninvalidate on ancestor-membership changes and on `Role.inheritsToDescendants`\nflips — request-scoped caches (the common pattern) are unaffected.\n\nFlag roles at seed time with\n`seedSystemRoles({ inheritsToDescendants: ['owner', 'admin'] })` (additive:\nlisted slugs are flagged, omitted slugs are never unflagged; unknown slugs\nthrow). The default seed leaves every role exact-tenant.\n\n## Operation Permission Guards\n\n- Use `assertOperationPermission()` for hand-written mutations in SvelteKit form\n actions, custom endpoints, CLI scripts, and jobs. It derives the same\n `<collection>.<action>` slugs as `PermissionCatalogService` (`list`/`get` →\n `read`), requires the slug to exist in the catalog, then resolves permissions\n through `PermissionResolver`.\n- `assertOperationPermission()` throws fail-closed by default. Use\n `{ onDeny: 'return' }`, `checkOperationPermission()`, or\n `hasOperationPermission()` when a structured/boolean result is needed.\n- **Resource-tenant calling convention**: for resource-anchored authorization,\n pass the **resource's** tenant id — `tenantId: resourceTenantId` — not the\n session's current tenant. With `Role.inheritsToDescendants` flagged, a\n root-tenant admin then passes for any descendant resource with no app-side\n authority logic (and no membership fan-out), while per-child delegation and\n DENY precedence keep working. Do NOT pass a session-scoped `membership`\n alongside a different resource `tenantId` — a membership/tenant mismatch\n fails closed by design; omit `membership` and let the resolver look it up.\n- System context and super-admin bypass context are honored for parity with\n Postgres RLS. Pass `{ allowSuperAdminBypass: false }` on money-class or\n separation-of-duties operations that must require an explicit permission grant.\n- **Postgres RLS and membership inheritance**: RLS policies check the\n session-injected `smrt.permissions` list (resolved app-side by\n `PermissionResolver`), so a session whose `smrt.tenant_id` IS the child\n tenant gets inherited authority in RLS automatically. But RLS row filtering\n stays bound to the session's tenant setting — a root-tenant session acting\n on child-tenant rows is authorized by the app-level guard (resource-tenant\n convention above), not by RLS. This is a documented divergence, mirroring\n how #1829 handled bypass parity.\n- Seed role mappings with `RolePermissionCollection.seedRolePermissions()` or\n `RoleCollection.seedSystemRoles({ seedPermissions: true })`. The default\n matrix maps owner/admin to all catalog permissions, member to read/create for\n ordinary app resources, and viewer to read-only. Member create grants\n intentionally exclude users/RBAC authority and security resources (`users`,\n `tenants`, `roles`, `permissions`, memberships, groups, sessions, magic-link\n tokens, and related join/override tables). Re-seeding is additive and\n idempotent; pruning stale mappings requires `{ prune: true }`.\n\n**Critical**: `getGroupIdsForTenant(userId, tenantId)` (joins with groups table to scope by tenant). Never use `getGroupIds()` — it's cross-tenant.\n\n## Hierarchical Tenants\n\n- `TenantCollection.createChild()` auto-calculates hierarchy fields, enforces depth limit\n- `moveToParent()` updates tenant + ALL descendants' paths/levels\n- `cascadePermissions` (parent pushes down) + `inheritPermissions` (child accepts) — both must be true\n- `getTree(rootId?)` returns nested structure for UI\n- Two independent downward flows: the `TenantPermissionOverride` **cascade**\n (tenant-level permission config, flags above) and **membership-role\n inheritance** (`Role.inheritsToDescendants`, per-role opt-in — see\n \"Membership selection\" above). The cascade flags do not gate membership\n inheritance.\n\n## SvelteKit Integration\n\n```typescript\n// hooks.server.ts\nexport const handle = createSessionHandler({ db, ttl: 604800, skipPaths: ['/api/public'] });\n// Populates event.locals: { user, membership, permissions: string[], tenantId, sessionId }\n\n// +page.server.ts\nawait createSessionCookie(event, userId, tenantId, { db });\nawait destroySessionCookie(event, { db });\nawait switchSessionTenant(event, tenantId, { db });\n```\n\n## Security (S5 #1400)\n\n- **Generated REST/MCP surface is READ-ONLY for every RBAC/identity model.**\n User, Tenant, Group, Membership, MembershipOverride, Role, Permission,\n RolePermission, GroupRole, GroupMember, and TenantPermissionOverride generate\n `list`/`get` only — `create`/`update`/`delete` are intentionally NOT\n generated. The merged `requireRouteAuth` gate (#1540) enforces *authentication*,\n not *authorization*, and these models are not `@TenantScoped`, so an\n auto-generated mutating route would let any authenticated user self-grant a\n role/permission, flip a tenant's cascade flags, or change another user's auth\n identity. Mutate them through the permission-gated services (`TenantService`,\n collection helpers) or consumer-owned, permission-checked handlers. A\n structural regression test (`security-audit-1400.test.ts`) enumerates the\n registry to assert no authority model exposes a mutating op. (`cli` stays\n enabled — local-operator surface, outside the network/agent threat model.)\n- **`switchTenant` is fail-closed AND rotates the session id.**\n `SessionService.switchTenant` / `switchSessionTenant` verify the session's user\n has an ACTIVE membership in the target tenant before any write (the tenant id\n is the isolation key for every `@TenantScoped` query). A non-member/unknown-\n session switch returns `{ switched: false, sessionId: null, ... }` and mutates\n nothing. On a successful switch into a NON-null tenant the session id is\n ROTATED: a fresh `Session` (new secure id, fresh TTL, same user, new tenant,\n device context carried over) is minted and the old session is REVOKED — so a\n captured pre-switch id immediately stops validating, shrinking the blast radius\n of a leaked id across a tenant boundary. `switchTenant` returns a\n `SwitchTenantResult` (`{ switched, sessionId, session, rotated }`); callers MUST\n persist the returned `sessionId`. `switchSessionTenant` does this for you by\n re-setting the session cookie (preserving httpOnly/secure/sameSite) to the new\n id. A `null` clear stays in place (no rotation, no cookie change). The\n low-level `SessionCollection.setSessionTenant` is the UNGUARDED primitive (used\n for the null-clear path) — never call it with an untrusted tenant id.\n- **OIDC `email_verified` is enforced.** `UserCollection.getOrCreateFromOidc`\n refuses to provision a user when the IdP explicitly returns\n `email_verified: false` (opt out with `{ allowUnverifiedEmail: true }`). An\n absent claim makes no assertion and is not enforced.\n\n## Gotchas\n\n- **seedSystemRoles() required**: call `RoleCollection.seedSystemRoles()` at app init (creates owner/admin/member/viewer)\n- **PermissionResolver casts `as any`**: collections have protected constructors — known framework limitation\n- **Session TTL in seconds**: `DEFAULT_SESSION_TTL = 7 * 24 * 60 * 60` (not milliseconds)\n- **Users are cross-tenant**: one user, many tenants via Membership. Email globally unique.\n- **Batch permission queries**: resolver fetches all permission IDs in one query, then maps to slugs (avoids N+1)\n"
|
|
2868
|
+
"agentDoc": "# @happyvertical/smrt-users\n\nMulti-tenant user management with RBAC, hierarchical tenants, session handling, and SvelteKit integration.\n\n## Models (14)\n\n| Model | Key Pattern |\n|-------|-------------|\n| User | Auth identity. `profileId` is plain string (not FK) to smrt-profiles. Email auto-lowercased. |\n| AccessRequest | \"Request access / waitlist\" record captured before a `User` exists. CLOSED generated surface (`api`/`mcp`/`cli` = `[]`) — all access via `AccessRequestService`. Email normalized + indexed; JSON `requestContext` (NOT `context` — reserved for slug scoping). |\n| Tenant | **STI** + hierarchical parent-child. `hierarchyPath` (materialized path), `hierarchyLevel`. Max depth 10. |\n| Session | Server-side. Secure UUID. TTL in **seconds** (not ms). Status auto-updates to EXPIRED on access. |\n| MagicLinkToken | Single-use email login token. Backed by `MagicLinkService`. |\n| Role | `tenantId = null` → system role (available to all tenants). `isSystem: true` blocks deletion. `inheritsToDescendants: true` (default false) opts the role's membership authority into descendant tenants. |\n| Permission | Slug format: `resource.action`. Parsed by PermissionResolver. |\n| Membership | User + Tenant + Role junction. UNIQUE(userId, tenantId). |\n| Group | Team within a tenant. Multiple roles via GroupRole. |\n| GroupMember, GroupRole, RolePermission | Join tables. |\n| MembershipOverride | Per-user permission grant/deny. **DENY always wins.** |\n| TenantPermissionOverride | Tenant-level cascade overrides. Effect: INHERIT/GRANT/DENY. |\n\n## Permission Resolution — Precedence (broad → specific, most-specific wins)\n\n`PermissionResolver.resolvePermissions` builds the effective set in this order;\neach later layer overrides earlier ones:\n\n1. **Tenant-inherited** — walk ancestors, apply each `TenantPermissionOverride`\n down the cascade (GRANT adds, DENY removes within the hierarchy)\n2. **Membership role** — base permissions from the user's role in the tenant\n3. **Group roles** — permissions from all groups the user belongs to **in that tenant**\n4. **Tenant-level DENY** *(removes; overrides role/group grants, tenant-wide)* — a\n `TenantPermissionOverride` with effect `DENY` is a HARD, tenant-wide block: it\n subtracts the DENY'd slug even if a role or group granted it (steps 2–3). It\n sits just **above** the per-user membership overrides and **below** role/group.\n5. **Membership GRANT override** *(re-adds; most specific)* — a per-user GRANT can\n re-add a slug a tenant DENY'd in step 4, because it is more specific.\n6. **Membership DENY override** *(absolute; always wins)* — a per-user DENY removes\n the slug last and is never overridden.\n\nSo a permission a role grants but the tenant DENYs is **removed**, unless that\nexact user also has a membership-GRANT override for it. A membership-DENY always\nwins. Tenant-DENY of an inherited/cascade grant still blocks it (unchanged).\nThe hard block reflects the tenant cascade's **net** resolution, not an\nunconditional union of every DENY in the chain — so a more-specific tenant GRANT\n(e.g. a child sub-tenant re-granting a permission its parent DENYs) still wins.\n\n### Membership selection — hierarchical inheritance (opt-in, #1866)\n\nWhich membership feeds step 2 above:\n\n1. **A direct membership row in the target tenant always pins resolution to\n itself** — active rows resolve normally; an inactive (pending/suspended)\n row resolves to the **empty set**. A direct row therefore *attenuates*\n rather than unions: \"viewer here, despite being network admin\" gives\n viewer, and a suspension in the child is effective even for users holding\n inheritable authority on an ancestor.\n2. **No direct row** → the resolver walks the tenant's ancestors (nearest\n first, from `hierarchyPath`) and resolves through the **nearest ACTIVE\n ancestor membership whose role has `inheritsToDescendants: true`**.\n Unflagged or inactive ancestor memberships are skipped (they neither confer\n nor block); there is **no union across the chain** — the nearest flagged\n membership alone is used. To attenuate a specific descendant, create a\n direct membership there or use a tenant-level DENY.\n3. **No qualifying ancestor** → empty set (byte-identical to the\n pre-inheritance resolver; with no role flagged, nothing changes).\n\nAll later layers run unchanged against the **target** tenant: the tenant\ncascade and tenant-DENY hard block come from the target tenant (a child can\ncarve authority out of an inherited role), group roles stay exact-tenant (only\ntarget-tenant groups contribute; ancestor groups never flow down), and\nmembership GRANT/DENY overrides travel with the ancestor membership used.\n`PermissionResolutionResult.inheritedFromTenantId` reports the ancestor tenant\nwhen inheritance was used (`null` for direct resolution).\n\nSafety: resolution is bounded by `MAX_TENANT_HIERARCHY_DEPTH`; malformed\n`hierarchyPath` values fail closed to the empty set — too deep,\nself-referential, duplicate ancestors, or inconsistent with the actual\n`parentTenantId` chain (the path is verified link-by-link against the loaded\nancestor rows before it is trusted as an authorization source). Tenant `status` is not consulted (parity with direct\nresolution). Caching: a long-lived `(user, tenant)` permission cache must also\ninvalidate on ancestor-membership changes and on `Role.inheritsToDescendants`\nflips — request-scoped caches (the common pattern) are unaffected.\n\nFlag roles at seed time with\n`seedSystemRoles({ inheritsToDescendants: ['owner', 'admin'] })` (additive:\nlisted slugs are flagged, omitted slugs are never unflagged; unknown slugs\nthrow). The default seed leaves every role exact-tenant.\n\n## Operation Permission Guards\n\n- Use `assertOperationPermission()` for hand-written mutations in SvelteKit form\n actions, custom endpoints, CLI scripts, and jobs. It derives the same\n `<collection>.<action>` slugs as `PermissionCatalogService` (`list`/`get` →\n `read`), requires the slug to exist in the catalog, then resolves permissions\n through `PermissionResolver`.\n- `assertOperationPermission()` throws fail-closed by default. Use\n `{ onDeny: 'return' }`, `checkOperationPermission()`, or\n `hasOperationPermission()` when a structured/boolean result is needed.\n- **Resource-tenant calling convention**: for resource-anchored authorization,\n pass the **resource's** tenant id — `tenantId: resourceTenantId` — not the\n session's current tenant. With `Role.inheritsToDescendants` flagged, a\n root-tenant admin then passes for any descendant resource with no app-side\n authority logic (and no membership fan-out), while per-child delegation and\n DENY precedence keep working. Do NOT pass a session-scoped `membership`\n alongside a different resource `tenantId` — a membership/tenant mismatch\n fails closed by design; omit `membership` and let the resolver look it up.\n- System context and super-admin bypass context are honored for parity with\n Postgres RLS. Pass `{ allowSuperAdminBypass: false }` on money-class or\n separation-of-duties operations that must require an explicit permission grant.\n- **Postgres RLS and membership inheritance**: RLS policies check the\n session-injected `smrt.permissions` list (resolved app-side by\n `PermissionResolver`), so a session whose `smrt.tenant_id` IS the child\n tenant gets inherited authority in RLS automatically. But RLS row filtering\n stays bound to the session's tenant setting — a root-tenant session acting\n on child-tenant rows is authorized by the app-level guard (resource-tenant\n convention above), not by RLS. This is a documented divergence, mirroring\n how #1829 handled bypass parity.\n- Seed role mappings with `RolePermissionCollection.seedRolePermissions()` or\n `RoleCollection.seedSystemRoles({ seedPermissions: true })`. The default\n matrix maps owner/admin to all catalog permissions, member to read/create for\n ordinary app resources, and viewer to read-only. Member create grants\n intentionally exclude users/RBAC authority and security resources (`users`,\n `tenants`, `roles`, `permissions`, memberships, groups, sessions, magic-link\n tokens, and related join/override tables). Re-seeding is additive and\n idempotent; pruning stale mappings requires `{ prune: true }`.\n\n**Critical**: `getGroupIdsForTenant(userId, tenantId)` (joins with groups table to scope by tenant). Never use `getGroupIds()` — it's cross-tenant.\n\n## Hierarchical Tenants\n\n- `TenantCollection.createChild()` auto-calculates hierarchy fields, enforces depth limit\n- `moveToParent()` updates tenant + ALL descendants' paths/levels\n- `cascadePermissions` (parent pushes down) + `inheritPermissions` (child accepts) — both must be true\n- `getTree(rootId?)` returns nested structure for UI\n- Two independent downward flows: the `TenantPermissionOverride` **cascade**\n (tenant-level permission config, flags above) and **membership-role\n inheritance** (`Role.inheritsToDescendants`, per-role opt-in — see\n \"Membership selection\" above). The cascade flags do not gate membership\n inheritance.\n\n## SvelteKit Integration\n\n```typescript\n// hooks.server.ts\nexport const handle = createSessionHandler({ db, ttl: 604800, skipPaths: ['/api/public'] });\n// Populates event.locals: { user, membership, permissions: string[], tenantId, sessionId }\n\n// +page.server.ts\nawait createSessionCookie(event, userId, tenantId, { db });\nawait destroySessionCookie(event, { db });\nawait switchSessionTenant(event, tenantId, { db });\n```\n\n## Mobile `/api/mobile` Handlers (ADR 0001 Phase 3.5, #1748)\n\n`createMobileAuthHandlers(options)` (from `/sveltekit`) returns the mountable\nserver side of the KMP mobile contract: `authStart` (`POST auth/start`,\nserver-brokered PKCE via `OidcLoginService`), `authComplete`\n(`POST auth/complete`, code + echoed `state`/`codeVerifier` → bearer\nsession), `session.GET`/`session.DELETE` (bootstrap/logout), and\n`guard`/`withSession` — the bearer middleware for app-owned mobile routes.\nCore logic lives in `MobileAuthService` (framework-agnostic; exported from\nthe package root).\n\n- **Bearer = session id** (same convention as `TerminalAuthService`); 401\n bodies are `{ error, code }` and drive the mobile client's re-auth flow.\n- **Stateless handshake**: the OAuth `state` is an HMAC-signed token\n (secret: `stateSecret` ?? provider `clientSecret`) carrying\n nonce/provider/createdAt — full ID-token nonce verification with no\n server-side pending state. The `codeVerifier` never enters a URL: it is\n client-held per the frozen contract.\n- **Wire DTOs** come from `@happyvertical/smrt-mobile-contract`\n (`MobileAuthStartRequest` etc.) — one owning package for the Kotlin,\n Swift, and TypeScript shapes (compile-checked descriptors + parity test).\n- **Tenant options** honor `Role.inheritsToDescendants` (#1867): direct\n ACTIVE memberships plus descendants of flagged memberships (nearest\n flagged ancestor labels the option; any direct row pins; inactive direct\n rows exclude). Session binding defaults to the first DIRECT tenant —\n override with `resolveTenantId`.\n- **Hooks**: `resolveUser` (invite-gating; default provisions via\n `getOrCreateFromOidc`), `resolveTenantId`, `buildExtras` (bootstrap\n `extras`; model JSON must use `toPublicJSON({ permissions })` — #1822).\n- **Guard** wraps `withSessionPermissionContext`, so\n `assertOperationPermission`, tenancy context, and Postgres RLS all see the\n bearer caller; `OperationPermissionError` maps to 403 with a\n machine-readable `reason`.\n- **Uploads**: `resolveMobileUploadDedupKey` + the documented contract in\n `docs/content/architecture/mobile-upload-contract.md` (`clientCaptureId`\n field, `Idempotency-Key` header fallback); domain ingestion stays\n app-side. Framework-model writes ride `sync/apply`, not this path.\n- Configure `redirectUris` in production — RFC 8252 scheme rules always\n apply, but the allow list is the defense against redirecting authorization\n responses to attacker-controlled URIs.\n\n## Security (S5 #1400)\n\n- **Generated REST/MCP surface is READ-ONLY for every RBAC/identity model.**\n User, Tenant, Group, Membership, MembershipOverride, Role, Permission,\n RolePermission, GroupRole, GroupMember, and TenantPermissionOverride generate\n `list`/`get` only — `create`/`update`/`delete` are intentionally NOT\n generated. The merged `requireRouteAuth` gate (#1540) enforces *authentication*,\n not *authorization*, and these models are not `@TenantScoped`, so an\n auto-generated mutating route would let any authenticated user self-grant a\n role/permission, flip a tenant's cascade flags, or change another user's auth\n identity. Mutate them through the permission-gated services (`TenantService`,\n collection helpers) or consumer-owned, permission-checked handlers. A\n structural regression test (`security-audit-1400.test.ts`) enumerates the\n registry to assert no authority model exposes a mutating op. (`cli` stays\n enabled — local-operator surface, outside the network/agent threat model.)\n- **`switchTenant` is fail-closed AND rotates the session id.**\n `SessionService.switchTenant` / `switchSessionTenant` verify the session's user\n has an ACTIVE membership in the target tenant before any write (the tenant id\n is the isolation key for every `@TenantScoped` query). A non-member/unknown-\n session switch returns `{ switched: false, sessionId: null, ... }` and mutates\n nothing. On a successful switch into a NON-null tenant the session id is\n ROTATED: a fresh `Session` (new secure id, fresh TTL, same user, new tenant,\n device context carried over) is minted and the old session is REVOKED — so a\n captured pre-switch id immediately stops validating, shrinking the blast radius\n of a leaked id across a tenant boundary. `switchTenant` returns a\n `SwitchTenantResult` (`{ switched, sessionId, session, rotated }`); callers MUST\n persist the returned `sessionId`. `switchSessionTenant` does this for you by\n re-setting the session cookie (preserving httpOnly/secure/sameSite) to the new\n id. A `null` clear stays in place (no rotation, no cookie change). The\n low-level `SessionCollection.setSessionTenant` is the UNGUARDED primitive (used\n for the null-clear path) — never call it with an untrusted tenant id.\n- **OIDC `email_verified` is enforced.** `UserCollection.getOrCreateFromOidc`\n refuses to provision a user when the IdP explicitly returns\n `email_verified: false` (opt out with `{ allowUnverifiedEmail: true }`). An\n absent claim makes no assertion and is not enforced.\n\n## Gotchas\n\n- **seedSystemRoles() required**: call `RoleCollection.seedSystemRoles()` at app init (creates owner/admin/member/viewer)\n- **PermissionResolver casts `as any`**: collections have protected constructors — known framework limitation\n- **Session TTL in seconds**: `DEFAULT_SESSION_TTL = 7 * 24 * 60 * 60` (not milliseconds)\n- **Users are cross-tenant**: one user, many tenants via Membership. Email globally unique.\n- **Batch permission queries**: resolver fetches all permission IDs in one query, then maps to slugs (avoids N+1)\n"
|
|
2867
2869
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
2
2
|
import { OidcLoginResult, OidcProviderResolutionOptions, OidcTransaction } from '../services/OidcLoginService.js';
|
|
3
3
|
import { TerminalAuthError, TerminalAuthRateLimitError, TerminalAuthService, TerminalAuthServiceOptions } from '../services/TerminalAuthService.js';
|
|
4
|
+
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';
|
|
5
|
+
export { type CreateMobileAuthHandlersOptions, createMobileAuthHandlers, type MobileAuthHandlers, type MobileRequestEvent, type MobileRequestHandler, resolveMobileUploadDedupKey, } from './mobile-handlers.js';
|
|
4
6
|
export { type CliResource, type CommandDefinition, type CommandKind, type CommandPolicyContext, type CommandScope, type CreateResourceListHandlerOptions, createResourceListHandler, InvalidBearerError, type ResolvedSession, type ResourceListResponseBody, } from './resource-list-handler.js';
|
|
5
7
|
export { defaultSessionLocals, type SessionLocals } from './types.js';
|
|
6
8
|
/**
|
|
@@ -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;AAEjE,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;AAE5C,OAAO,EACL,KAAK,WAAW,EAChB,KAA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AClB;AAED,kEAAkE;AAClE,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,6BACf,SAAQ,0BAA0B;IAClC,0DAA0D;IAC1D,WAAW,EAAE,CACX,KAAK,EAAE,qBAAqB,KACzB;QAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACtE,iDAAiD;IACjD,eAAe,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7E,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,OAAO,CAAC,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,CAuF1B;AAuBD,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MobileAuthService, MobileAuthServiceOptions } from '../services/MobileAuthService.js';
|
|
2
|
+
import { SessionPermissionRuntimeContext } from '../services/SessionPermissionContext.js';
|
|
3
|
+
/**
|
|
4
|
+
* Minimal structural slice of SvelteKit's `RequestEvent` these handlers
|
|
5
|
+
* touch (kept structural so `@sveltejs/kit` stays out of the dependency
|
|
6
|
+
* tree, like the rest of this package's SvelteKit integration).
|
|
7
|
+
*/
|
|
8
|
+
export interface MobileRequestEvent {
|
|
9
|
+
request: Request;
|
|
10
|
+
getClientAddress?: () => string;
|
|
11
|
+
locals?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export type MobileRequestHandler = (event: MobileRequestEvent) => Promise<Response>;
|
|
14
|
+
export interface CreateMobileAuthHandlersOptions extends MobileAuthServiceOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Enter smrt-tenancy request context for guarded routes when the session
|
|
17
|
+
* carries a tenant (default true — mobile domain routes are expected to
|
|
18
|
+
* hit `@TenantScoped` models).
|
|
19
|
+
*/
|
|
20
|
+
enterTenantContext?: boolean;
|
|
21
|
+
/** Enforce Postgres RLS via request-scoped transactions in guarded routes. */
|
|
22
|
+
postgresRls?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** The mounted `/api/mobile` handler set. */
|
|
25
|
+
export interface MobileAuthHandlers {
|
|
26
|
+
/** `POST /api/mobile/auth/start` */
|
|
27
|
+
authStart: MobileRequestHandler;
|
|
28
|
+
/** `POST /api/mobile/auth/complete` */
|
|
29
|
+
authComplete: MobileRequestHandler;
|
|
30
|
+
/** `GET /api/mobile/session` + `DELETE /api/mobile/session` */
|
|
31
|
+
session: {
|
|
32
|
+
GET: MobileRequestHandler;
|
|
33
|
+
DELETE: MobileRequestHandler;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Bearer-auth middleware for app-owned mobile routes: resolves the
|
|
37
|
+
* `Authorization: Bearer` session, establishes the request permission
|
|
38
|
+
* context ({@link withSessionPermissionContext} — so
|
|
39
|
+
* `assertOperationPermission`, tenancy interceptors, and Postgres RLS all
|
|
40
|
+
* see the caller), populates `event.locals` like the cookie session
|
|
41
|
+
* handler does, and maps auth/permission failures to the JSON + status
|
|
42
|
+
* semantics the mobile client expects (401 → client clears its session
|
|
43
|
+
* and re-authenticates; 403 carries a machine-readable `reason`).
|
|
44
|
+
*/
|
|
45
|
+
withSession: (event: MobileRequestEvent, fn: (event: MobileRequestEvent, context: SessionPermissionRuntimeContext) => Promise<Response>) => Promise<Response>;
|
|
46
|
+
/** Route-wrapper form of {@link MobileAuthHandlers.withSession}. */
|
|
47
|
+
guard: (fn: (event: MobileRequestEvent, context: SessionPermissionRuntimeContext) => Promise<Response>) => MobileRequestHandler;
|
|
48
|
+
/** The lazily-created underlying service (shared by all handlers). */
|
|
49
|
+
getService: () => Promise<MobileAuthService>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build the mountable `/api/mobile` handler set. Call ONCE per app (module
|
|
53
|
+
* scope) and export the members from the route files — the returned handlers
|
|
54
|
+
* share one lazily-initialized {@link MobileAuthService}.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createMobileAuthHandlers(options: CreateMobileAuthHandlersOptions): MobileAuthHandlers;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the dedup key for a mobile multipart upload per the documented
|
|
59
|
+
* contract (`docs/content/architecture/mobile-upload-contract.md`): the
|
|
60
|
+
* `clientCaptureId` form field wins; the `Idempotency-Key` header — which
|
|
61
|
+
* the shared mobile client sets to the durable queue entry's id — is the
|
|
62
|
+
* fallback. Returns `null` when neither is present (the upload then has no
|
|
63
|
+
* dedup guarantee).
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveMobileUploadDedupKey(formData: FormData | null, headers: Headers, fieldName?: string): string | null;
|
|
66
|
+
//# sourceMappingURL=mobile-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mobile-handlers.d.ts","sourceRoot":"","sources":["../../src/sveltekit/mobile-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,yBAAyB,CAAC;AAOjC,OAAO,EAEL,iBAAiB,EACjB,KAAK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