@vunexa/lixa 0.1.6-alpha.13 → 0.1.6-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +392 -674
- package/dist/credentials/credentials-manager.d.ts +14 -0
- package/dist/credentials/credentials-manager.d.ts.map +1 -1
- package/dist/credentials/types.d.ts +29 -6
- package/dist/credentials/types.d.ts.map +1 -1
- package/dist/dao/session-cache.d.ts.map +1 -1
- package/dist/dao/types.d.ts +24 -0
- package/dist/dao/types.d.ts.map +1 -1
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/export-types/index.d.ts +899 -88
- package/dist/identity/composite.d.ts +65 -0
- package/dist/identity/composite.d.ts.map +1 -0
- package/dist/identity/index.d.ts +4 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/self-managed.d.ts +66 -0
- package/dist/identity/self-managed.d.ts.map +1 -0
- package/dist/identity/types.d.ts +232 -0
- package/dist/identity/types.d.ts.map +1 -0
- package/dist/index.cjs +1543 -341
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +868 -80
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1461 -267
- package/dist/index.js.map +1 -1
- package/dist/lixa.d.ts +190 -35
- package/dist/lixa.d.ts.map +1 -1
- package/dist/models/session.d.ts +12 -6
- package/dist/models/session.d.ts.map +1 -1
- package/dist/providers/IProvider.d.ts +4 -0
- package/dist/providers/IProvider.d.ts.map +1 -1
- package/dist/types.d.ts +140 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/user-info.d.ts.map +1 -1
- package/package.json +3 -11
|
@@ -16,6 +16,40 @@
|
|
|
16
16
|
* @packageDocumentation
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Account handler configuration.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare interface AccountHandler {
|
|
25
|
+
accountStorage?: AccountStorage;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Thrown when a login attempt matches an existing user under another provider,
|
|
30
|
+
* requiring step-up verification (e.g. password or original provider login) before linking.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare class AccountLinkingChallengeRequiredError extends LixaError {
|
|
35
|
+
readonly challengeToken: string;
|
|
36
|
+
readonly email: string;
|
|
37
|
+
readonly incomingProvider: string;
|
|
38
|
+
readonly incomingProviderUserId?: string | undefined;
|
|
39
|
+
readonly existingUserId: string;
|
|
40
|
+
readonly existingProviders: string[];
|
|
41
|
+
readonly hasPassword: boolean;
|
|
42
|
+
constructor(message: string, details: {
|
|
43
|
+
challengeToken: string;
|
|
44
|
+
email: string;
|
|
45
|
+
incomingProvider: string;
|
|
46
|
+
incomingProviderUserId?: string | undefined;
|
|
47
|
+
existingUserId: string;
|
|
48
|
+
existingProviders: string[];
|
|
49
|
+
hasPassword: boolean;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
19
53
|
/**
|
|
20
54
|
* Account linking settings for Lixa.
|
|
21
55
|
*
|
|
@@ -43,7 +77,7 @@ export declare interface AccountLinkingConfig {
|
|
|
43
77
|
*
|
|
44
78
|
* @public
|
|
45
79
|
*/
|
|
46
|
-
export declare type AccountLinkingMode = AccountLinkingStrategy | "AUTO_LINK_BY_VERIFIED_EMAIL" | "ISOLATED" | "linkByEmail" | "separate";
|
|
80
|
+
export declare type AccountLinkingMode = AccountLinkingStrategy | "AUTO_LINK_BY_VERIFIED_EMAIL" | "ISOLATED" | "STEP_UP_VERIFICATION" | "linkByEmail" | "separate" | "stepUp";
|
|
47
81
|
|
|
48
82
|
/**
|
|
49
83
|
* Main configuration object for Lixa.
|
|
@@ -120,7 +154,35 @@ export declare enum AccountLinkingStrategy {
|
|
|
120
154
|
/** Automatically merge identities matching the same verified primary email address */
|
|
121
155
|
AUTO_LINK_BY_VERIFIED_EMAIL = "AUTO_LINK_BY_VERIFIED_EMAIL",
|
|
122
156
|
/** Keep identity profiles isolated per provider (no automatic account merging) */
|
|
123
|
-
ISOLATED = "ISOLATED"
|
|
157
|
+
ISOLATED = "ISOLATED",
|
|
158
|
+
/** Require password or original provider step-up verification before linking secondary accounts */
|
|
159
|
+
STEP_UP_VERIFICATION = "STEP_UP_VERIFICATION"
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Thrown when a user's account has not been verified/confirmed yet.
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
export declare class AccountNotVerifiedError extends LixaError {
|
|
168
|
+
constructor(identifier?: string, details?: Record<string, unknown>);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Interface for persistent linked account storage across user sessions.
|
|
173
|
+
*
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
export declare interface AccountStorage {
|
|
177
|
+
saveAccount(userId: string, provider: string, account: LinkedAccount): Promise<void>;
|
|
178
|
+
getAccount(userId: string, provider: string): Promise<LinkedAccount | null>;
|
|
179
|
+
getUserAccounts(userId: string): Promise<Record<string, LinkedAccount>>;
|
|
180
|
+
deleteAccount(userId: string, provider: string): Promise<void>;
|
|
181
|
+
findAccountsByEmail?(email: string): Promise<Array<{
|
|
182
|
+
userId: string;
|
|
183
|
+
provider: string;
|
|
184
|
+
account: LinkedAccount;
|
|
185
|
+
}>>;
|
|
124
186
|
}
|
|
125
187
|
|
|
126
188
|
/**
|
|
@@ -138,6 +200,8 @@ export declare class AccountUnlinkError extends LixaError {
|
|
|
138
200
|
* @public
|
|
139
201
|
*/
|
|
140
202
|
export declare interface ChangePasswordParams {
|
|
203
|
+
/** Target identity provider name when using CompositeIdentityProvider */
|
|
204
|
+
provider?: string | undefined;
|
|
141
205
|
/** Username (optional if identifier or userId is provided) */
|
|
142
206
|
username?: string | undefined;
|
|
143
207
|
/** Primary identifier (optional if username or userId is provided) */
|
|
@@ -176,10 +240,117 @@ export declare function clearSessionCookie(options?: CookieOptions): CookiePaylo
|
|
|
176
240
|
*/
|
|
177
241
|
export declare function clearStateCookie(options?: CookieOptions): CookiePayload;
|
|
178
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Composite Identity Provider that aggregates multiple child IIdentityProvider instances
|
|
245
|
+
* and OAuth 2.0 / OIDC provider configurations under a single unified identityProvider.
|
|
246
|
+
*
|
|
247
|
+
* @remarks
|
|
248
|
+
* Eliminates the need for separate `federatedOAuthProviders` configuration in Lixa.
|
|
249
|
+
* Provides compile-time autocompletion of configured provider names.
|
|
250
|
+
* Routing is strictly explicit: uses `params.provider` if provided, or `defaultProvider`.
|
|
251
|
+
* No silent fallbacks or guesswork.
|
|
252
|
+
*
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
export declare class CompositeIdentityProvider<TProviders extends Record<string, IIdentityProvider> = Record<string, IIdentityProvider>, TOAuthProviders extends Record<string, ProviderConfig> = Record<string, ProviderConfig>> implements IIdentityProvider {
|
|
256
|
+
readonly name: string;
|
|
257
|
+
readonly providers: TProviders;
|
|
258
|
+
readonly defaultProvider?: (keyof TProviders & string) | undefined;
|
|
259
|
+
readonly oauthProviders?: TOAuthProviders | undefined;
|
|
260
|
+
constructor(options: CompositeIdentityProviderOptions<TProviders, TOAuthProviders>);
|
|
261
|
+
/**
|
|
262
|
+
* Resolves the target child provider based on explicit parameter or defaultProvider.
|
|
263
|
+
* Throws an error immediately if the provider cannot be resolved or does not exist.
|
|
264
|
+
*/
|
|
265
|
+
selectProvider(providerName?: string): IIdentityProvider;
|
|
266
|
+
/**
|
|
267
|
+
* Returns all OAuth / OIDC provider configurations aggregated across this composite provider
|
|
268
|
+
* and any child providers exposing `getOAuthProviders()` or `getProviders()`.
|
|
269
|
+
*/
|
|
270
|
+
getProviders(): Record<string, ProviderConfig>;
|
|
271
|
+
signUp(params: SignUpParams): Promise<UserIdentity>;
|
|
272
|
+
signIn(params: SignInParams): Promise<IdentityAuthResult>;
|
|
273
|
+
verifyCredentials(params: VerifyCredentialsParams): Promise<UserIdentity | null>;
|
|
274
|
+
changePassword(params: ChangePasswordParams): Promise<boolean>;
|
|
275
|
+
forgotPassword(params: ForgotPasswordParams): Promise<ForgotPasswordResult>;
|
|
276
|
+
confirmPasswordReset(params: ConfirmPasswordResetParams): Promise<boolean>;
|
|
277
|
+
confirmSignUp(params: ConfirmSignUpParams): Promise<boolean>;
|
|
278
|
+
resendConfirmationCode(params: ResendConfirmationCodeParams): Promise<ResendConfirmationCodeResult>;
|
|
279
|
+
getUserById(id: string, providerName?: string): Promise<UserIdentity | null>;
|
|
280
|
+
getUserByIdentifier(identifier: string, providerName?: string): Promise<UserIdentity | null>;
|
|
281
|
+
deleteUser(id: string, providerName?: string): Promise<void>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Options for initializing a CompositeIdentityProvider.
|
|
286
|
+
*
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
289
|
+
export declare interface CompositeIdentityProviderOptions<TProviders extends Record<string, IIdentityProvider> = Record<string, IIdentityProvider>, TOAuthProviders extends Record<string, ProviderConfig> = Record<string, ProviderConfig>> {
|
|
290
|
+
/**
|
|
291
|
+
* Record of child identity providers keyed by unique provider names.
|
|
292
|
+
* e.g. `{ cognito: new CognitoIdentityProvider(...), okta: new OktaIdentityProvider(...) }`
|
|
293
|
+
*/
|
|
294
|
+
providers: TProviders;
|
|
295
|
+
/**
|
|
296
|
+
* Default provider key to use when a request does not explicitly pass a `provider` parameter.
|
|
297
|
+
*/
|
|
298
|
+
defaultProvider?: (keyof TProviders & string) | undefined;
|
|
299
|
+
/**
|
|
300
|
+
* Record of OAuth 2.0 / OIDC provider configurations (Google, GitHub, etc.)
|
|
301
|
+
* to register alongside these identity providers.
|
|
302
|
+
*/
|
|
303
|
+
oauthProviders?: TOAuthProviders | undefined;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Inferred key of identity providers configured in a CompositeIdentityProvider.
|
|
308
|
+
*
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
export declare type ConfiguredIdentityKey<TIdentity> = TIdentity extends CompositeIdentityProvider<infer TProviders, any> ? (keyof TProviders & string) : string;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Inferred key of OAuth / OIDC providers configured in a CompositeIdentityProvider or inline providers.
|
|
315
|
+
*
|
|
316
|
+
* @public
|
|
317
|
+
*/
|
|
318
|
+
export declare type ConfiguredOAuthKey<TIdentity = unknown, TProviders extends Record<string, ProviderConfig> = Record<string, ProviderConfig>> = TIdentity extends CompositeIdentityProvider<any, infer TOAuth> ? (keyof TOAuth & string) | (keyof TProviders & string) : keyof TProviders & string;
|
|
319
|
+
|
|
179
320
|
/**
|
|
180
321
|
* Type representing the keys of configured providers
|
|
181
322
|
*/
|
|
182
|
-
declare type ConfiguredProviderKey<
|
|
323
|
+
declare type ConfiguredProviderKey<TProviders extends Record<string, ProviderConfig>> = keyof TProviders & string;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Parameters for confirming a password reset with a confirmation code or token.
|
|
327
|
+
*
|
|
328
|
+
* @public
|
|
329
|
+
*/
|
|
330
|
+
export declare interface ConfirmPasswordResetParams {
|
|
331
|
+
/** Target identity provider name when using CompositeIdentityProvider */
|
|
332
|
+
provider?: string | undefined;
|
|
333
|
+
/** Username or email of the account */
|
|
334
|
+
identifier: string;
|
|
335
|
+
/** Verification code (e.g. 6-digit OTP from email/SMS) or reset token */
|
|
336
|
+
confirmationCode: string;
|
|
337
|
+
/** New plaintext password */
|
|
338
|
+
newPassword: string;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Parameters for confirming user registration with a verification code.
|
|
343
|
+
*
|
|
344
|
+
* @public
|
|
345
|
+
*/
|
|
346
|
+
export declare interface ConfirmSignUpParams {
|
|
347
|
+
/** Target identity provider name when using CompositeIdentityProvider */
|
|
348
|
+
provider?: string | undefined;
|
|
349
|
+
/** Username or email of the account to confirm */
|
|
350
|
+
identifier: string;
|
|
351
|
+
/** Verification code (e.g. 6-digit OTP from email/SMS) */
|
|
352
|
+
confirmationCode: string;
|
|
353
|
+
}
|
|
183
354
|
|
|
184
355
|
/**
|
|
185
356
|
* Represents a connected resource provider token (e.g. GitHub Repo access, Google Drive)
|
|
@@ -378,6 +549,13 @@ export declare interface CredentialsConfig {
|
|
|
378
549
|
* @default 86400 (24 hours)
|
|
379
550
|
*/
|
|
380
551
|
sessionTtlSeconds?: number | undefined;
|
|
552
|
+
/**
|
|
553
|
+
* Whether identity verification (e.g. email confirmation code) is required before persisting credentials to storage.
|
|
554
|
+
* When true, signUp creates a pending registration without writing to storage, requiring confirmSignUp() to activate.
|
|
555
|
+
*
|
|
556
|
+
* @default false
|
|
557
|
+
*/
|
|
558
|
+
requireVerification?: boolean | undefined;
|
|
381
559
|
}
|
|
382
560
|
|
|
383
561
|
/**
|
|
@@ -426,6 +604,20 @@ export declare class CredentialsManager {
|
|
|
426
604
|
* @returns True if password was successfully updated
|
|
427
605
|
*/
|
|
428
606
|
changePassword(params: ChangePasswordParams): Promise<boolean>;
|
|
607
|
+
/**
|
|
608
|
+
* Sets a password for a user who doesn't have one yet (e.g. SSO-first users),
|
|
609
|
+
* or updates an existing password without requiring the old one.
|
|
610
|
+
* This should only be called from an authenticated context (user already verified their identity via SSO).
|
|
611
|
+
*
|
|
612
|
+
* @param params - userId and newPassword
|
|
613
|
+
* @returns True if password was successfully set
|
|
614
|
+
*/
|
|
615
|
+
setPassword(params: {
|
|
616
|
+
userId: string;
|
|
617
|
+
newPassword: string;
|
|
618
|
+
identifier?: string;
|
|
619
|
+
email?: string;
|
|
620
|
+
}): Promise<boolean>;
|
|
429
621
|
/**
|
|
430
622
|
* Finds a user by ID and returns safe user data.
|
|
431
623
|
*/
|
|
@@ -504,6 +696,12 @@ export declare interface CredentialsStorage {
|
|
|
504
696
|
* @param username - Username string
|
|
505
697
|
*/
|
|
506
698
|
findUserByUsername?(username: string): Promise<UserCredentials | null>;
|
|
699
|
+
/**
|
|
700
|
+
* Optional helper to find user directly by email address.
|
|
701
|
+
*
|
|
702
|
+
* @param email - Verified email address
|
|
703
|
+
*/
|
|
704
|
+
findUserByEmail?(email: string): Promise<UserCredentials | null>;
|
|
507
705
|
}
|
|
508
706
|
|
|
509
707
|
/**
|
|
@@ -607,6 +805,204 @@ export declare function extractUserInfo(tokenData: OAuthTokenResponse, providerM
|
|
|
607
805
|
*/
|
|
608
806
|
export declare function fetchUserInfo(accessToken: string, userInfoEndpoint: string): Promise<UserInfo>;
|
|
609
807
|
|
|
808
|
+
/**
|
|
809
|
+
* Parameters for requesting a password reset (forgot password).
|
|
810
|
+
*
|
|
811
|
+
* @public
|
|
812
|
+
*/
|
|
813
|
+
export declare interface ForgotPasswordParams {
|
|
814
|
+
/** Target identity provider name when using CompositeIdentityProvider */
|
|
815
|
+
provider?: string | undefined;
|
|
816
|
+
/** Username or email of the account requesting a password reset */
|
|
817
|
+
identifier: string;
|
|
818
|
+
/** Optional custom client metadata or redirect URL */
|
|
819
|
+
metadata?: Record<string, unknown> | undefined;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Result of a password reset request.
|
|
824
|
+
*
|
|
825
|
+
* @public
|
|
826
|
+
*/
|
|
827
|
+
export declare interface ForgotPasswordResult {
|
|
828
|
+
/** Whether the password reset request was accepted */
|
|
829
|
+
success: boolean;
|
|
830
|
+
/** Delivery destination description (e.g. masked email: a***@example.com or phone) */
|
|
831
|
+
deliveryMedium?: string | undefined;
|
|
832
|
+
/** Optional message or status code from provider */
|
|
833
|
+
message?: string | undefined;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
export declare namespace identity {
|
|
837
|
+
export {
|
|
838
|
+
UserIdentity,
|
|
839
|
+
IdentityTokens,
|
|
840
|
+
IdentityAuthResult,
|
|
841
|
+
ForgotPasswordParams,
|
|
842
|
+
ForgotPasswordResult,
|
|
843
|
+
ConfirmPasswordResetParams,
|
|
844
|
+
ConfirmSignUpParams,
|
|
845
|
+
ResendConfirmationCodeParams,
|
|
846
|
+
ResendConfirmationCodeResult,
|
|
847
|
+
IIdentityProvider,
|
|
848
|
+
IdentityConfig,
|
|
849
|
+
SelfManagedIdentityProvider,
|
|
850
|
+
CompositeIdentityProviderOptions,
|
|
851
|
+
CompositeIdentityProvider
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* Result of user authentication through an identity provider.
|
|
857
|
+
*
|
|
858
|
+
* @public
|
|
859
|
+
*/
|
|
860
|
+
export declare interface IdentityAuthResult {
|
|
861
|
+
/** Authenticated user profile */
|
|
862
|
+
user: UserIdentity;
|
|
863
|
+
/** Optional tokens issued by the identity provider */
|
|
864
|
+
tokens?: IdentityTokens | undefined;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Configuration options for Identity Providers in LixaConfig.
|
|
869
|
+
*
|
|
870
|
+
* @public
|
|
871
|
+
*/
|
|
872
|
+
export declare type IdentityConfig = IIdentityProvider | ({
|
|
873
|
+
provider?: "self-managed";
|
|
874
|
+
} & CredentialsConfig);
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Thrown when identity operations (signUp, signIn, etc.) are invoked on a Lixa instance
|
|
878
|
+
* where neither identity nor credentials authentication is enabled.
|
|
879
|
+
*
|
|
880
|
+
* @public
|
|
881
|
+
*/
|
|
882
|
+
export declare class IdentityNotConfiguredError extends CredentialsNotConfiguredError {
|
|
883
|
+
constructor(message?: string, details?: Record<string, unknown>);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Thrown when an identity provider operation fails with an upstream provider error.
|
|
888
|
+
*
|
|
889
|
+
* @public
|
|
890
|
+
*/
|
|
891
|
+
export declare class IdentityProviderError extends LixaError {
|
|
892
|
+
readonly provider: string | undefined;
|
|
893
|
+
readonly statusCode: number | undefined;
|
|
894
|
+
constructor(message: string, provider?: string, statusCode?: number, details?: Record<string, unknown>);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Standardized token response from an identity provider.
|
|
899
|
+
*
|
|
900
|
+
* @public
|
|
901
|
+
*/
|
|
902
|
+
export declare interface IdentityTokens {
|
|
903
|
+
/** OAuth / IdP Access Token (JWT or opaque token) */
|
|
904
|
+
accessToken?: string | undefined;
|
|
905
|
+
/** OpenID Connect ID Token containing user claims */
|
|
906
|
+
idToken?: string | undefined;
|
|
907
|
+
/** Refresh token for renewing expired credentials */
|
|
908
|
+
refreshToken?: string | undefined;
|
|
909
|
+
/** Token type (usually "Bearer") */
|
|
910
|
+
tokenType?: string | undefined;
|
|
911
|
+
/** Token expiration time in seconds */
|
|
912
|
+
expiresIn?: number | undefined;
|
|
913
|
+
/** Raw response object returned directly by the provider */
|
|
914
|
+
raw?: Record<string, unknown> | undefined;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Unified interface for Identity Providers in Lixa.
|
|
919
|
+
*
|
|
920
|
+
* @remarks
|
|
921
|
+
* Implement this interface to create custom identity providers (e.g. Supabase Auth,
|
|
922
|
+
* Firebase Auth, Keycloak, or proprietary enterprise directories).
|
|
923
|
+
*
|
|
924
|
+
* Built-in extensions for AWS Cognito, Auth0, and Okta are available in `@vunexa/lixa-extensions`.
|
|
925
|
+
*
|
|
926
|
+
* @public
|
|
927
|
+
*/
|
|
928
|
+
export declare interface IIdentityProvider {
|
|
929
|
+
/**
|
|
930
|
+
* Unique name of the identity provider.
|
|
931
|
+
* Examples: 'self-managed', 'cognito', 'auth0', 'okta'
|
|
932
|
+
*/
|
|
933
|
+
readonly name: string;
|
|
934
|
+
/**
|
|
935
|
+
* Registers a new user with the identity provider.
|
|
936
|
+
*
|
|
937
|
+
* @param params - User registration details (identifier, password, email, username, metadata)
|
|
938
|
+
* @returns Created user identity
|
|
939
|
+
*/
|
|
940
|
+
signUp(params: SignUpParams): Promise<UserIdentity>;
|
|
941
|
+
/**
|
|
942
|
+
* Authenticates a user with credentials.
|
|
943
|
+
*
|
|
944
|
+
* @param params - Sign in credentials (identifier, password)
|
|
945
|
+
* @returns Authenticated user identity and optional provider tokens
|
|
946
|
+
*/
|
|
947
|
+
signIn(params: SignInParams): Promise<IdentityAuthResult>;
|
|
948
|
+
/**
|
|
949
|
+
* Verifies credentials without necessarily creating a full session.
|
|
950
|
+
*
|
|
951
|
+
* @param params - Verification parameters
|
|
952
|
+
* @returns User identity if credentials are valid, null otherwise
|
|
953
|
+
*/
|
|
954
|
+
verifyCredentials?(params: VerifyCredentialsParams): Promise<UserIdentity | null>;
|
|
955
|
+
/**
|
|
956
|
+
* Changes a user's password.
|
|
957
|
+
*
|
|
958
|
+
* @param params - Old password, new password, and user identifier
|
|
959
|
+
* @returns True if password was successfully updated
|
|
960
|
+
*/
|
|
961
|
+
changePassword?(params: ChangePasswordParams): Promise<boolean>;
|
|
962
|
+
/**
|
|
963
|
+
* Requests a password reset (forgot password flow).
|
|
964
|
+
*
|
|
965
|
+
* @param params - Forgot password parameters
|
|
966
|
+
*/
|
|
967
|
+
forgotPassword?(params: ForgotPasswordParams): Promise<ForgotPasswordResult>;
|
|
968
|
+
/**
|
|
969
|
+
* Confirms password reset with verification code and new password.
|
|
970
|
+
*
|
|
971
|
+
* @param params - Confirm password reset parameters
|
|
972
|
+
*/
|
|
973
|
+
confirmPasswordReset?(params: ConfirmPasswordResetParams): Promise<boolean>;
|
|
974
|
+
/**
|
|
975
|
+
* Confirms user registration using a verification code.
|
|
976
|
+
*
|
|
977
|
+
* @param params - Confirm sign up parameters
|
|
978
|
+
*/
|
|
979
|
+
confirmSignUp?(params: ConfirmSignUpParams): Promise<boolean>;
|
|
980
|
+
/**
|
|
981
|
+
* Resends the sign up confirmation code.
|
|
982
|
+
*
|
|
983
|
+
* @param params - Resend confirmation code parameters
|
|
984
|
+
*/
|
|
985
|
+
resendConfirmationCode?(params: ResendConfirmationCodeParams): Promise<ResendConfirmationCodeResult>;
|
|
986
|
+
/**
|
|
987
|
+
* Retrieves a user by their unique ID.
|
|
988
|
+
*
|
|
989
|
+
* @param id - Unique user ID
|
|
990
|
+
*/
|
|
991
|
+
getUserById?(id: string): Promise<UserIdentity | null>;
|
|
992
|
+
/**
|
|
993
|
+
* Retrieves a user by their identifier (email or username).
|
|
994
|
+
*
|
|
995
|
+
* @param identifier - Username or email string
|
|
996
|
+
*/
|
|
997
|
+
getUserByIdentifier?(identifier: string): Promise<UserIdentity | null>;
|
|
998
|
+
/**
|
|
999
|
+
* Deletes a user account.
|
|
1000
|
+
*
|
|
1001
|
+
* @param id - Unique user ID
|
|
1002
|
+
*/
|
|
1003
|
+
deleteUser?(id: string): Promise<void>;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
610
1006
|
/**
|
|
611
1007
|
* Thrown when user credentials (username/email and password) are invalid during authentication.
|
|
612
1008
|
*
|
|
@@ -809,6 +1205,10 @@ export declare interface IProvider {
|
|
|
809
1205
|
* @example ['openid', 'email', 'profile'] or ['read:user', 'user:email']
|
|
810
1206
|
*/
|
|
811
1207
|
authScopes?: string[];
|
|
1208
|
+
/**
|
|
1209
|
+
* Default OAuth scopes requested when not explicitly specified in ProviderConfig.
|
|
1210
|
+
*/
|
|
1211
|
+
defaultScopes?: string[];
|
|
812
1212
|
}
|
|
813
1213
|
|
|
814
1214
|
/**
|
|
@@ -822,17 +1222,23 @@ export declare function isProductionEnvironment(): boolean;
|
|
|
822
1222
|
*
|
|
823
1223
|
* @public
|
|
824
1224
|
*/
|
|
825
|
-
declare interface LinkedAccount {
|
|
1225
|
+
export declare interface LinkedAccount {
|
|
826
1226
|
/** The provider identifier (e.g. 'github', 'google') */
|
|
827
1227
|
provider: string;
|
|
828
1228
|
/** Provider user ID if available */
|
|
829
1229
|
providerUserId?: string | undefined;
|
|
830
1230
|
/** User email for this provider */
|
|
831
1231
|
email?: string | undefined;
|
|
832
|
-
/**
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1232
|
+
/**
|
|
1233
|
+
* Optional OAuth access token for this provider.
|
|
1234
|
+
* @deprecated Authentication tokens belong strictly to session.token / session.raw for that session alone. Resource tokens belong in ConnectedResource / user_resources.
|
|
1235
|
+
*/
|
|
1236
|
+
accessToken?: string | undefined;
|
|
1237
|
+
/**
|
|
1238
|
+
* Optional raw token response from provider.
|
|
1239
|
+
* @deprecated Authentication tokens belong strictly to session.token / session.raw for that session alone. Resource tokens belong in ConnectedResource / user_resources.
|
|
1240
|
+
*/
|
|
1241
|
+
raw?: OAuthTokenResponse | undefined;
|
|
836
1242
|
/** Unix timestamp in milliseconds when account was linked */
|
|
837
1243
|
linkedAt: number;
|
|
838
1244
|
}
|
|
@@ -889,20 +1295,25 @@ declare interface LinkedAccount {
|
|
|
889
1295
|
*
|
|
890
1296
|
* @public
|
|
891
1297
|
*/
|
|
892
|
-
export declare class Lixa<
|
|
1298
|
+
export declare class Lixa<TIdentity extends IIdentityProvider | IdentityConfig = IIdentityProvider | IdentityConfig, TProviders extends Record<string, ProviderConfig> = Record<string, ProviderConfig>> {
|
|
893
1299
|
private static DEFAULT_PROVIDERS;
|
|
894
1300
|
private static CONFIGURED_PROVIDERS;
|
|
895
1301
|
private localStateHandler;
|
|
896
1302
|
private localSessionHandler;
|
|
897
1303
|
private localResourceHandler;
|
|
1304
|
+
private localAccountHandler;
|
|
898
1305
|
private userResourceStore;
|
|
1306
|
+
private userAccountStore;
|
|
899
1307
|
private refreshMutexes;
|
|
1308
|
+
private identityProvider?;
|
|
900
1309
|
private credentialsManager?;
|
|
901
1310
|
private config;
|
|
902
1311
|
private stateHandler;
|
|
903
1312
|
private sessionHandler;
|
|
904
1313
|
private resourceHandler;
|
|
1314
|
+
private accountHandler;
|
|
905
1315
|
private debug;
|
|
1316
|
+
private sessionCookieResolver?;
|
|
906
1317
|
/**
|
|
907
1318
|
* Creates a new Lixa instance with the provided configuration.
|
|
908
1319
|
*
|
|
@@ -916,7 +1327,7 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
916
1327
|
* @throws Error when provider implementation is missing required properties
|
|
917
1328
|
* @throws Error when provider is not available and no inline implementation is provided
|
|
918
1329
|
*/
|
|
919
|
-
constructor(config:
|
|
1330
|
+
constructor(config: LixaConfig<TIdentity, TProviders>);
|
|
920
1331
|
/**
|
|
921
1332
|
* Validates that a provider configuration has all required credentials.
|
|
922
1333
|
*
|
|
@@ -957,7 +1368,7 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
957
1368
|
* }
|
|
958
1369
|
* ```
|
|
959
1370
|
*/
|
|
960
|
-
isProviderConfigured<T extends string>(provider: T): provider is T & ConfiguredProviderKey<
|
|
1371
|
+
isProviderConfigured<T extends string>(provider: T): provider is T & (ConfiguredOAuthKey<TIdentity, TProviders> | ConfiguredProviderKey<TProviders>);
|
|
961
1372
|
/**
|
|
962
1373
|
* Gets a provider implementation by name.
|
|
963
1374
|
* Resolution priority: inline custom provider \> default providers \> legacy registry
|
|
@@ -1138,7 +1549,7 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
1138
1549
|
* res.redirect(authUrl);
|
|
1139
1550
|
* ```
|
|
1140
1551
|
*/
|
|
1141
|
-
getAuthUrl(provider:
|
|
1552
|
+
getAuthUrl(provider: ConfiguredOAuthKey<TIdentity, TProviders> | string, state?: string): Promise<string>;
|
|
1142
1553
|
/**
|
|
1143
1554
|
* Restricts primary authentication scopes strictly to AuthN identity scopes unless allowNonAuthScopes is true.
|
|
1144
1555
|
*/
|
|
@@ -1162,10 +1573,11 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
1162
1573
|
* });
|
|
1163
1574
|
* ```
|
|
1164
1575
|
*/
|
|
1165
|
-
handleCallback({ provider, code, state, }: {
|
|
1166
|
-
provider:
|
|
1576
|
+
handleCallback({ provider, code, state, sessionId, }: {
|
|
1577
|
+
provider: ConfiguredOAuthKey<TIdentity, TProviders> | string;
|
|
1167
1578
|
code: string;
|
|
1168
1579
|
state?: string;
|
|
1580
|
+
sessionId?: string;
|
|
1169
1581
|
}): Promise<string>;
|
|
1170
1582
|
/**
|
|
1171
1583
|
* Explicitly link a new OAuth provider account to an active session.
|
|
@@ -1175,7 +1587,7 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
1175
1587
|
*/
|
|
1176
1588
|
linkAccount(params: {
|
|
1177
1589
|
sessionId: string;
|
|
1178
|
-
provider: ConfiguredProviderKey<
|
|
1590
|
+
provider: ConfiguredProviderKey<TProviders> | string;
|
|
1179
1591
|
code: string;
|
|
1180
1592
|
state?: string;
|
|
1181
1593
|
}): Promise<string>;
|
|
@@ -1187,6 +1599,38 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
1187
1599
|
* @returns Promise resolving to true on successful unlink
|
|
1188
1600
|
*/
|
|
1189
1601
|
unlinkAccount(sessionId: string, providerToUnlink: string): Promise<boolean>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Confirms a pending account linking step-up challenge using the user's password.
|
|
1604
|
+
* On successful verification, links the pending provider to the existing account and creates a session.
|
|
1605
|
+
*
|
|
1606
|
+
* @param params - challengeToken and password
|
|
1607
|
+
* @returns Session ID, Session, and User identity
|
|
1608
|
+
* @throws InvalidStateError if challenge is invalid or expired
|
|
1609
|
+
* @throws InvalidCredentialsError if password verification fails
|
|
1610
|
+
*/
|
|
1611
|
+
confirmLinkingWithPassword(params: {
|
|
1612
|
+
challengeToken: string;
|
|
1613
|
+
password: string;
|
|
1614
|
+
}): Promise<{
|
|
1615
|
+
sessionId: string;
|
|
1616
|
+
session: Session;
|
|
1617
|
+
user?: any;
|
|
1618
|
+
}>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Sets a password for an SSO-authenticated user who doesn't have one yet.
|
|
1621
|
+
* Must be called from an authenticated context (user has active session proving identity).
|
|
1622
|
+
*
|
|
1623
|
+
* @param params - userId, newPassword, optional identifier and email
|
|
1624
|
+
* @returns True if password was set successfully
|
|
1625
|
+
* @throws IdentityNotConfiguredError if no identity provider configured
|
|
1626
|
+
* @throws WeakPasswordError if password doesn't meet policy
|
|
1627
|
+
*/
|
|
1628
|
+
setPassword(params: {
|
|
1629
|
+
userId: string;
|
|
1630
|
+
newPassword: string;
|
|
1631
|
+
identifier?: string;
|
|
1632
|
+
email?: string;
|
|
1633
|
+
}): Promise<boolean>;
|
|
1190
1634
|
/**
|
|
1191
1635
|
* Generates an authorization URL for connecting a resource provider (AuthZ) post-login.
|
|
1192
1636
|
*
|
|
@@ -1200,23 +1644,46 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
1200
1644
|
*/
|
|
1201
1645
|
getResourceAuthUrl(params: {
|
|
1202
1646
|
sessionId: string;
|
|
1203
|
-
provider:
|
|
1204
|
-
scopes
|
|
1647
|
+
provider: ConfiguredOAuthKey<TIdentity, TProviders> | string;
|
|
1648
|
+
scopes?: string[];
|
|
1205
1649
|
state?: string;
|
|
1206
1650
|
prompt?: string;
|
|
1651
|
+
authorizationParams?: Record<string, string>;
|
|
1207
1652
|
extraConfig?: Record<string, string>;
|
|
1208
1653
|
}): Promise<string>;
|
|
1209
1654
|
private getUserKeyFromSession;
|
|
1655
|
+
private sanitizeIdentityForStorage;
|
|
1210
1656
|
/**
|
|
1211
1657
|
* Handles the OAuth callback for a connected resource provider and stores resource tokens bound to user account.
|
|
1212
1658
|
*/
|
|
1213
1659
|
handleResourceCallback(params: {
|
|
1214
1660
|
sessionId: string;
|
|
1215
|
-
provider:
|
|
1661
|
+
provider: ConfiguredOAuthKey<TIdentity, TProviders> | string;
|
|
1216
1662
|
code: string;
|
|
1217
1663
|
state?: string;
|
|
1218
1664
|
scopes?: string[];
|
|
1219
1665
|
}): Promise<Session>;
|
|
1666
|
+
/**
|
|
1667
|
+
* Retrieves configured default resource scopes for a provider.
|
|
1668
|
+
*
|
|
1669
|
+
* @param provider - Provider name (e.g. 'github', 'google')
|
|
1670
|
+
* @returns Array of configured resource scopes, or undefined if not configured
|
|
1671
|
+
*/
|
|
1672
|
+
getResourceScopes(provider: ConfiguredOAuthKey<TIdentity, TProviders> | string): string[] | undefined;
|
|
1673
|
+
/**
|
|
1674
|
+
* Returns the resolved session cookie name.
|
|
1675
|
+
* Dynamically reflects any changes to the active identity provider.
|
|
1676
|
+
*
|
|
1677
|
+
* @param req - Optional request object for multi-tenant request-scoped cookie resolution
|
|
1678
|
+
* @returns Resolved session cookie name
|
|
1679
|
+
*/
|
|
1680
|
+
getSessionCookieName(req?: unknown): string;
|
|
1681
|
+
/**
|
|
1682
|
+
* Sets or updates the session cookie name or dynamic resolver on this instance.
|
|
1683
|
+
*
|
|
1684
|
+
* @param resolver - Static cookie name or dynamic resolver function
|
|
1685
|
+
*/
|
|
1686
|
+
setSessionCookieName(resolver: SessionCookieResolver<Lixa<TProviders>>): void;
|
|
1220
1687
|
/**
|
|
1221
1688
|
* Retrieves a connected resource for a specific User ID / Email directly (independent of session IDs).
|
|
1222
1689
|
* Automatically refreshes expired access tokens if a refresh token is present.
|
|
@@ -1264,6 +1731,13 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
1264
1731
|
* Retrieves active session details from session storage.
|
|
1265
1732
|
*/
|
|
1266
1733
|
fetchSessionInfo(sessionId: string): Promise<Session | null>;
|
|
1734
|
+
/**
|
|
1735
|
+
* Retrieves all linked accounts for a user from account storage.
|
|
1736
|
+
*
|
|
1737
|
+
* @param userIdOrSessionId - User ID, email, or active session ID
|
|
1738
|
+
* @returns Record mapping provider name to linked account metadata
|
|
1739
|
+
*/
|
|
1740
|
+
getUserAccounts(userIdOrSessionId: string): Promise<Record<string, LinkedAccount>>;
|
|
1267
1741
|
/**
|
|
1268
1742
|
* Deletes a session from session storage (e.g. on logout).
|
|
1269
1743
|
*
|
|
@@ -1272,57 +1746,144 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
1272
1746
|
deleteSession(sessionId: string): Promise<void>;
|
|
1273
1747
|
private exchangeCodeForToken;
|
|
1274
1748
|
/**
|
|
1275
|
-
* Checks if
|
|
1749
|
+
* Checks if an identity provider (Self-Managed Database, AWS Cognito, Auth0, Okta, etc.) is configured.
|
|
1750
|
+
*
|
|
1751
|
+
* @returns True if identity provider is configured and available
|
|
1752
|
+
*/
|
|
1753
|
+
isIdentityEnabled(): boolean;
|
|
1754
|
+
/**
|
|
1755
|
+
* Checks if credentials / identity authentication is configured and enabled.
|
|
1276
1756
|
*
|
|
1277
|
-
* @returns True if credentials authentication is available
|
|
1757
|
+
* @returns True if credentials / identity authentication is available
|
|
1278
1758
|
*/
|
|
1279
1759
|
isCredentialsEnabled(): boolean;
|
|
1280
1760
|
/**
|
|
1281
|
-
* Returns the
|
|
1761
|
+
* Returns the configured IdentityProvider instance.
|
|
1762
|
+
*/
|
|
1763
|
+
getIdentityProvider(): IIdentityProvider | undefined;
|
|
1764
|
+
/**
|
|
1765
|
+
* Dynamically sets or updates the active identity provider (e.g. SelfManaged, Cognito, Auth0, Okta).
|
|
1766
|
+
*
|
|
1767
|
+
* @param provider - Identity provider instance or undefined to disable
|
|
1768
|
+
*/
|
|
1769
|
+
setIdentityProvider(provider?: IIdentityProvider): void;
|
|
1770
|
+
/**
|
|
1771
|
+
* Returns the underlying CredentialsManager instance if using Self-Managed identity.
|
|
1282
1772
|
*/
|
|
1283
1773
|
getCredentialsManager(): CredentialsManager | undefined;
|
|
1284
1774
|
/**
|
|
1285
|
-
* Registers a new user with
|
|
1286
|
-
* Automatically
|
|
1287
|
-
* stores credentials, and creates a session (unless autoCreateSessionOnSignUp is false).
|
|
1775
|
+
* Registers a new user with the configured identity provider (Self-Managed DB, Cognito, Auth0, Okta).
|
|
1776
|
+
* Automatically creates an active session unless autoCreateSessionOnSignUp is explicitly set to false.
|
|
1288
1777
|
*
|
|
1289
1778
|
* @param params - Registration parameters (identifier, password, email, username, metadata)
|
|
1290
|
-
* @returns Created user
|
|
1779
|
+
* @returns Created user identity and optional active session
|
|
1291
1780
|
* @throws WeakPasswordError if password does not meet policy requirements
|
|
1292
1781
|
* @throws UserAlreadyExistsError if identifier is already registered
|
|
1293
|
-
* @throws
|
|
1782
|
+
* @throws IdentityNotConfiguredError if identity authentication is not configured
|
|
1294
1783
|
*/
|
|
1295
|
-
signUp(params: SignUpParams
|
|
1784
|
+
signUp(params: SignUpParams & {
|
|
1785
|
+
provider?: ConfiguredIdentityKey<TIdentity>;
|
|
1786
|
+
}): Promise<SignUpResult>;
|
|
1296
1787
|
/**
|
|
1297
|
-
* Authenticates a user with
|
|
1298
|
-
*
|
|
1299
|
-
* If account linking is configured with AUTO_LINK_BY_VERIFIED_EMAIL, merges with existing session.
|
|
1788
|
+
* Authenticates a user with credentials via the configured identity provider (Self-Managed DB, Cognito, Auth0, Okta, or Composite).
|
|
1789
|
+
* Creates an active session and automatically links with existing sessions when AUTO_LINK_BY_VERIFIED_EMAIL is configured.
|
|
1300
1790
|
*
|
|
1301
|
-
* @param params - Sign-in parameters (identifier, password)
|
|
1791
|
+
* @param params - Sign-in parameters (identifier, password, optional provider)
|
|
1302
1792
|
* @returns Authenticated user, session ID, and session object
|
|
1303
1793
|
* @throws InvalidCredentialsError if authentication fails
|
|
1304
|
-
* @throws
|
|
1794
|
+
* @throws IdentityNotConfiguredError if identity authentication is not configured
|
|
1305
1795
|
*/
|
|
1306
|
-
signIn(params: SignInParams
|
|
1796
|
+
signIn(params: SignInParams & {
|
|
1797
|
+
provider?: ConfiguredIdentityKey<TIdentity>;
|
|
1798
|
+
}): Promise<SignInResult>;
|
|
1307
1799
|
/**
|
|
1308
1800
|
* Verifies username/email and password credentials without generating a session.
|
|
1309
1801
|
*
|
|
1310
|
-
* @param params - Verification parameters (identifier, password)
|
|
1311
|
-
* @returns User credentials
|
|
1312
|
-
* @throws
|
|
1802
|
+
* @param params - Verification parameters (identifier, password, optional provider)
|
|
1803
|
+
* @returns User credentials/identity or null if invalid
|
|
1804
|
+
* @throws IdentityNotConfiguredError if identity auth is not configured
|
|
1313
1805
|
*/
|
|
1314
|
-
verifyCredentials(params: VerifyCredentialsParams
|
|
1806
|
+
verifyCredentials(params: VerifyCredentialsParams & {
|
|
1807
|
+
provider?: ConfiguredIdentityKey<TIdentity>;
|
|
1808
|
+
}): Promise<UserIdentity | null>;
|
|
1315
1809
|
/**
|
|
1316
1810
|
* Updates a user's password after verifying the current password and enforcing policy on the new password.
|
|
1317
1811
|
*
|
|
1318
|
-
* @param params - Change password parameters (userId/identifier, oldPassword, newPassword)
|
|
1812
|
+
* @param params - Change password parameters (userId/identifier, oldPassword, newPassword, optional provider)
|
|
1319
1813
|
* @returns True if password was updated successfully
|
|
1320
1814
|
* @throws UserNotFoundError if user is not found
|
|
1321
1815
|
* @throws InvalidCredentialsError if current password is incorrect
|
|
1322
1816
|
* @throws WeakPasswordError if new password does not meet policy requirements
|
|
1323
|
-
* @throws
|
|
1817
|
+
* @throws IdentityNotConfiguredError if identity auth is not configured
|
|
1324
1818
|
*/
|
|
1325
|
-
changePassword(params: ChangePasswordParams
|
|
1819
|
+
changePassword(params: ChangePasswordParams & {
|
|
1820
|
+
provider?: ConfiguredIdentityKey<TIdentity>;
|
|
1821
|
+
}): Promise<boolean>;
|
|
1822
|
+
/**
|
|
1823
|
+
* Initiates a password reset (forgot password flow) through the configured identity provider.
|
|
1824
|
+
*
|
|
1825
|
+
* @param params - Forgot password parameters (identifier, optional metadata, optional provider)
|
|
1826
|
+
* @returns ForgotPasswordResult indicating status and delivery medium (email/SMS)
|
|
1827
|
+
* @throws IdentityNotConfiguredError if identity auth is not configured
|
|
1828
|
+
*/
|
|
1829
|
+
forgotPassword(params: ForgotPasswordParams & {
|
|
1830
|
+
provider?: ConfiguredIdentityKey<TIdentity>;
|
|
1831
|
+
}): Promise<ForgotPasswordResult>;
|
|
1832
|
+
/**
|
|
1833
|
+
* Confirms a password reset using a verification code / token and sets the new password.
|
|
1834
|
+
*
|
|
1835
|
+
* @param params - Verification code, identifier, new password, and optional provider
|
|
1836
|
+
* @returns True if password reset was successfully confirmed
|
|
1837
|
+
* @throws IdentityNotConfiguredError if identity auth is not configured
|
|
1838
|
+
*/
|
|
1839
|
+
confirmPasswordReset(params: ConfirmPasswordResetParams & {
|
|
1840
|
+
provider?: ConfiguredIdentityKey<TIdentity>;
|
|
1841
|
+
}): Promise<boolean>;
|
|
1842
|
+
/**
|
|
1843
|
+
* Confirms user account registration using a verification code.
|
|
1844
|
+
*
|
|
1845
|
+
* @param params - Verification parameters including identifier, confirmationCode, and optional provider
|
|
1846
|
+
* @returns True if confirmation was successful
|
|
1847
|
+
* @throws IdentityNotConfiguredError if identity auth is not configured
|
|
1848
|
+
* @throws IdentityProviderError if identity provider does not support confirmation
|
|
1849
|
+
*/
|
|
1850
|
+
confirmSignUp(params: ConfirmSignUpParams & {
|
|
1851
|
+
provider?: ConfiguredIdentityKey<TIdentity>;
|
|
1852
|
+
}): Promise<boolean>;
|
|
1853
|
+
/**
|
|
1854
|
+
* Resends the sign up confirmation code to the user.
|
|
1855
|
+
*
|
|
1856
|
+
* @param params - Resend parameters including user identifier and optional provider
|
|
1857
|
+
* @returns Details about the code delivery (medium, destination)
|
|
1858
|
+
* @throws IdentityNotConfiguredError if identity auth is not configured
|
|
1859
|
+
* @throws IdentityProviderError if identity provider does not support resending codes
|
|
1860
|
+
*/
|
|
1861
|
+
resendConfirmationCode(params: ResendConfirmationCodeParams & {
|
|
1862
|
+
provider?: ConfiguredIdentityKey<TIdentity>;
|
|
1863
|
+
}): Promise<ResendConfirmationCodeResult>;
|
|
1864
|
+
/**
|
|
1865
|
+
* Retrieves a user by their unique ID from the configured identity provider.
|
|
1866
|
+
*
|
|
1867
|
+
* @param id - Unique user ID
|
|
1868
|
+
* @param provider - Optional provider key when using CompositeIdentityProvider
|
|
1869
|
+
* @returns UserIdentity or null if not found
|
|
1870
|
+
*/
|
|
1871
|
+
getUserById(id: string, provider?: ConfiguredIdentityKey<TIdentity>): Promise<UserIdentity | null>;
|
|
1872
|
+
/**
|
|
1873
|
+
* Retrieves a user by their identifier (username or email) from the configured identity provider.
|
|
1874
|
+
*
|
|
1875
|
+
* @param identifier - Username or email string
|
|
1876
|
+
* @param provider - Optional provider key when using CompositeIdentityProvider
|
|
1877
|
+
* @returns UserIdentity or null if not found
|
|
1878
|
+
*/
|
|
1879
|
+
getUserByIdentifier(identifier: string, provider?: ConfiguredIdentityKey<TIdentity>): Promise<UserIdentity | null>;
|
|
1880
|
+
/**
|
|
1881
|
+
* Deletes a user account from the configured identity provider.
|
|
1882
|
+
*
|
|
1883
|
+
* @param id - Unique user ID
|
|
1884
|
+
* @param provider - Optional provider key when using CompositeIdentityProvider
|
|
1885
|
+
*/
|
|
1886
|
+
deleteUser(id: string, provider?: ConfiguredIdentityKey<TIdentity>): Promise<void>;
|
|
1326
1887
|
private findProviderByType;
|
|
1327
1888
|
}
|
|
1328
1889
|
|
|
@@ -1332,20 +1893,51 @@ export declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConf
|
|
|
1332
1893
|
*
|
|
1333
1894
|
* @public
|
|
1334
1895
|
*/
|
|
1335
|
-
export declare interface LixaConfig<TProviders extends Record<string, ProviderConfig> = Record<string, ProviderConfig>> {
|
|
1896
|
+
export declare interface LixaConfig<TIdentity extends IIdentityProvider | IdentityConfig = IIdentityProvider | IdentityConfig, TProviders extends Record<string, ProviderConfig> = Record<string, ProviderConfig>> {
|
|
1336
1897
|
/**
|
|
1337
|
-
*
|
|
1338
|
-
*
|
|
1898
|
+
* Primary Identity Provider configuration (Self-Managed Database, AWS Cognito, Auth0, Okta,
|
|
1899
|
+
* or a CompositeIdentityProvider combining multiple backends and OAuth providers).
|
|
1900
|
+
*
|
|
1901
|
+
* @example
|
|
1902
|
+
* Composite Identity Provider:
|
|
1903
|
+
* ```typescript
|
|
1904
|
+
* identityProvider: new CompositeIdentityProvider({
|
|
1905
|
+
* defaultProvider: 'cognito',
|
|
1906
|
+
* providers: {
|
|
1907
|
+
* cognito: new CognitoIdentityProvider(...),
|
|
1908
|
+
* 'self-managed': new SelfManagedIdentityProvider(...)
|
|
1909
|
+
* },
|
|
1910
|
+
* oauthProviders: {
|
|
1911
|
+
* google: { provider: new GoogleProvider(), ... }
|
|
1912
|
+
* }
|
|
1913
|
+
* })
|
|
1914
|
+
* ```
|
|
1915
|
+
*/
|
|
1916
|
+
identityProvider?: TIdentity;
|
|
1917
|
+
/**
|
|
1918
|
+
* Alias for {@link LixaConfig.identityProvider}.
|
|
1919
|
+
*/
|
|
1920
|
+
identity?: TIdentity;
|
|
1921
|
+
/**
|
|
1922
|
+
* Direct OAuth 2.0 / OIDC provider configurations (Google, GitHub, etc.).
|
|
1923
|
+
* When using CompositeIdentityProvider, OAuth providers can also be defined in its `oauthProviders` field.
|
|
1339
1924
|
*/
|
|
1340
1925
|
providers?: TProviders;
|
|
1341
1926
|
/**
|
|
1342
1927
|
* Credentials (username and password) authentication configuration.
|
|
1928
|
+
* Automatically maps to a SelfManagedIdentityProvider.
|
|
1343
1929
|
*/
|
|
1344
1930
|
credentials?: CredentialsConfig;
|
|
1931
|
+
/**
|
|
1932
|
+
* Unified database storage adapter (e.g. createPrismaAdapter or createDrizzleAdapter).
|
|
1933
|
+
* Automatically configures sessionHandler, stateHandler, and resourceHandler.
|
|
1934
|
+
*/
|
|
1935
|
+
storage?: StorageAdapter;
|
|
1345
1936
|
/**
|
|
1346
1937
|
* Account linking configuration for multi-SSO user linking.
|
|
1938
|
+
* Pass `true` or `"linkByEmail"` for automatic email-verified linking.
|
|
1347
1939
|
*/
|
|
1348
|
-
accountLinking?: AccountLinkingConfig;
|
|
1940
|
+
accountLinking?: boolean | AccountLinkingMode | AccountLinkingConfig;
|
|
1349
1941
|
/**
|
|
1350
1942
|
* Optional custom state handler.
|
|
1351
1943
|
* Handles state generation and storage during OAuth authorization flow.
|
|
@@ -1389,6 +1981,23 @@ export declare interface LixaConfig<TProviders extends Record<string, ProviderCo
|
|
|
1389
1981
|
* If provided, all Lixa logs will be routed through this logger.
|
|
1390
1982
|
*/
|
|
1391
1983
|
logger?: LixaLogger;
|
|
1984
|
+
/**
|
|
1985
|
+
* Session cookie name or dynamic resolution function.
|
|
1986
|
+
* Can accept a static string or `(lixa: Lixa, req?: unknown) => string`.
|
|
1987
|
+
* Automatically evaluated live against the instance when getSessionCookieName() is called.
|
|
1988
|
+
*/
|
|
1989
|
+
sessionCookieName?: SessionCookieResolver;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Interface exposing identity information for dynamic session cookie name resolution.
|
|
1994
|
+
* @public
|
|
1995
|
+
*/
|
|
1996
|
+
export declare interface LixaCookieContext {
|
|
1997
|
+
/**
|
|
1998
|
+
* Retrieves the currently active identity provider.
|
|
1999
|
+
*/
|
|
2000
|
+
getIdentityProvider(): IIdentityProvider | undefined;
|
|
1392
2001
|
}
|
|
1393
2002
|
|
|
1394
2003
|
/**
|
|
@@ -1439,7 +2048,7 @@ export declare class LocalCredentialsStorage implements CredentialsStorage {
|
|
|
1439
2048
|
* Log context for Lixa structured logging.
|
|
1440
2049
|
* @public
|
|
1441
2050
|
*/
|
|
1442
|
-
export declare type LogContext = "Init" | "Auth" | "Token" | "Session" | "State" | "AccountLinking" | "Resource" | "Credentials";
|
|
2051
|
+
export declare type LogContext = "Init" | "Auth" | "Token" | "Session" | "State" | "AccountLinking" | "Resource" | "Credentials" | "Identity";
|
|
1443
2052
|
|
|
1444
2053
|
/**
|
|
1445
2054
|
* Log level for Lixa structured logging.
|
|
@@ -1594,38 +2203,6 @@ export declare class Pbkdf2PasswordHasher implements IPasswordHasher {
|
|
|
1594
2203
|
|
|
1595
2204
|
/**
|
|
1596
2205
|
* Configuration for an OAuth provider instance.
|
|
1597
|
-
*
|
|
1598
|
-
* @remarks
|
|
1599
|
-
* For built-in providers (google, github), just provide credentials.
|
|
1600
|
-
* For custom providers, include the provider implementation.
|
|
1601
|
-
*
|
|
1602
|
-
* The provider field uses a discriminated union to ensure type safety:
|
|
1603
|
-
* - When omitted or undefined: assumes a built-in provider
|
|
1604
|
-
* - When provided: must be a valid IProvider implementation
|
|
1605
|
-
*
|
|
1606
|
-
* @example
|
|
1607
|
-
* Built-in provider configuration:
|
|
1608
|
-
* ```typescript
|
|
1609
|
-
* {
|
|
1610
|
-
* clientId: 'your-client-id',
|
|
1611
|
-
* clientSecret: 'your-client-secret',
|
|
1612
|
-
* redirectUri: 'https://app.com/callback',
|
|
1613
|
-
* scopes: ['openid', 'email']
|
|
1614
|
-
* }
|
|
1615
|
-
* ```
|
|
1616
|
-
*
|
|
1617
|
-
* @example
|
|
1618
|
-
* Custom provider configuration:
|
|
1619
|
-
* ```typescript
|
|
1620
|
-
* {
|
|
1621
|
-
* provider: new CustomProvider(),
|
|
1622
|
-
* clientId: 'your-client-id',
|
|
1623
|
-
* clientSecret: 'your-client-secret',
|
|
1624
|
-
* redirectUri: 'https://app.com/callback',
|
|
1625
|
-
* scopes: ['read:user']
|
|
1626
|
-
* }
|
|
1627
|
-
* ```
|
|
1628
|
-
*
|
|
1629
2206
|
* @public
|
|
1630
2207
|
*/
|
|
1631
2208
|
export declare type ProviderConfig = {
|
|
@@ -1635,15 +2212,38 @@ export declare type ProviderConfig = {
|
|
|
1635
2212
|
clientSecret: string;
|
|
1636
2213
|
/** The redirect URI registered with the provider */
|
|
1637
2214
|
redirectUri: string;
|
|
1638
|
-
/**
|
|
1639
|
-
|
|
2215
|
+
/**
|
|
2216
|
+
* Explicit scopes for authentication and post-login resource authorization.
|
|
2217
|
+
* Can be configured as `{ auth: [...], resource: [...] }` or a shorthand `string[]` for auth scopes.
|
|
2218
|
+
*
|
|
2219
|
+
* @example
|
|
2220
|
+
* ```typescript
|
|
2221
|
+
* scopes: {
|
|
2222
|
+
* auth: ["openid", "email", "profile"],
|
|
2223
|
+
* resource: ["https://www.googleapis.com/auth/drive.readonly"],
|
|
2224
|
+
* }
|
|
2225
|
+
* ```
|
|
2226
|
+
*/
|
|
2227
|
+
scopes?: ScopesConfig | string[];
|
|
2228
|
+
/**
|
|
2229
|
+
* Flat alias for authentication scopes (AuthN).
|
|
2230
|
+
*/
|
|
2231
|
+
authScopes?: string[];
|
|
2232
|
+
/**
|
|
2233
|
+
* Flat alias for post-authentication resource authorization scopes (AuthZ).
|
|
2234
|
+
*/
|
|
2235
|
+
resourceScopes?: string[];
|
|
1640
2236
|
/**
|
|
1641
2237
|
* Set to true to allow non-identity (resource) scopes during primary authentication flow.
|
|
1642
2238
|
* By default (false), Lixa restricts primary AuthN scopes to identity scopes to maintain
|
|
1643
2239
|
* clean AuthN vs AuthZ separation.
|
|
1644
2240
|
*/
|
|
1645
2241
|
allowNonAuthScopes?: boolean;
|
|
1646
|
-
/**
|
|
2242
|
+
/**
|
|
2243
|
+
* Custom query parameters passed to the OAuth authorization endpoint (e.g. `{ identity_provider: "Google" }`).
|
|
2244
|
+
*/
|
|
2245
|
+
authorizationParams?: Record<string, string>;
|
|
2246
|
+
/** Additional provider-specific configuration parameters (alias for authorizationParams) */
|
|
1647
2247
|
extraConfig?: Record<string, string>;
|
|
1648
2248
|
} & ({
|
|
1649
2249
|
provider?: never;
|
|
@@ -1689,6 +2289,32 @@ export declare class RefreshTokenError extends LixaError {
|
|
|
1689
2289
|
constructor(message: string, details?: Record<string, unknown>);
|
|
1690
2290
|
}
|
|
1691
2291
|
|
|
2292
|
+
/**
|
|
2293
|
+
* Parameters for resending a sign up confirmation code.
|
|
2294
|
+
*
|
|
2295
|
+
* @public
|
|
2296
|
+
*/
|
|
2297
|
+
export declare interface ResendConfirmationCodeParams {
|
|
2298
|
+
/** Target identity provider name when using CompositeIdentityProvider */
|
|
2299
|
+
provider?: string | undefined;
|
|
2300
|
+
/** Username or email of the account */
|
|
2301
|
+
identifier: string;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
/**
|
|
2305
|
+
* Result of resending a sign up confirmation code.
|
|
2306
|
+
*
|
|
2307
|
+
* @public
|
|
2308
|
+
*/
|
|
2309
|
+
export declare interface ResendConfirmationCodeResult {
|
|
2310
|
+
/** True if code was dispatched */
|
|
2311
|
+
success: boolean;
|
|
2312
|
+
/** Delivery medium (e.g. 'EMAIL' or 'SMS') */
|
|
2313
|
+
deliveryMedium?: string | undefined;
|
|
2314
|
+
/** Obscured destination */
|
|
2315
|
+
destination?: string | undefined;
|
|
2316
|
+
}
|
|
2317
|
+
|
|
1692
2318
|
/**
|
|
1693
2319
|
* Resource handler configuration.
|
|
1694
2320
|
*
|
|
@@ -1751,6 +2377,60 @@ export declare type SafeLixaConfig<TProviders extends Record<string, ProviderCon
|
|
|
1751
2377
|
providers: TProviders;
|
|
1752
2378
|
};
|
|
1753
2379
|
|
|
2380
|
+
/**
|
|
2381
|
+
* Configuration for an OAuth provider instance.
|
|
2382
|
+
*
|
|
2383
|
+
* @remarks
|
|
2384
|
+
* For built-in providers (google, github), just provide credentials.
|
|
2385
|
+
* For custom providers, include the provider implementation.
|
|
2386
|
+
*
|
|
2387
|
+
* The provider field uses a discriminated union to ensure type safety:
|
|
2388
|
+
* - When omitted or undefined: assumes a built-in provider
|
|
2389
|
+
* - When provided: must be a valid IProvider implementation
|
|
2390
|
+
*
|
|
2391
|
+
* @example
|
|
2392
|
+
* Built-in provider configuration:
|
|
2393
|
+
* ```typescript
|
|
2394
|
+
* {
|
|
2395
|
+
* clientId: 'your-client-id',
|
|
2396
|
+
* clientSecret: 'your-client-secret',
|
|
2397
|
+
* redirectUri: 'https://app.com/callback',
|
|
2398
|
+
* scopes: ['openid', 'email']
|
|
2399
|
+
* }
|
|
2400
|
+
* ```
|
|
2401
|
+
*
|
|
2402
|
+
* @example
|
|
2403
|
+
* Custom provider configuration:
|
|
2404
|
+
* ```typescript
|
|
2405
|
+
* {
|
|
2406
|
+
* provider: new CustomProvider(),
|
|
2407
|
+
* clientId: 'your-client-id',
|
|
2408
|
+
* clientSecret: 'your-client-secret',
|
|
2409
|
+
* redirectUri: 'https://app.com/callback',
|
|
2410
|
+
* scopes: ['read:user']
|
|
2411
|
+
* }
|
|
2412
|
+
* ```
|
|
2413
|
+
*
|
|
2414
|
+
* @public
|
|
2415
|
+
*/
|
|
2416
|
+
/**
|
|
2417
|
+
* Scopes configuration explicitly partitioned into authentication and resource authorization.
|
|
2418
|
+
*
|
|
2419
|
+
* @public
|
|
2420
|
+
*/
|
|
2421
|
+
export declare interface ScopesConfig {
|
|
2422
|
+
/**
|
|
2423
|
+
* Explicit identity scopes requested during primary authentication (AuthN) (e.g. ['openid', 'email', 'profile']).
|
|
2424
|
+
* If omitted, uses the provider's default identity scopes.
|
|
2425
|
+
*/
|
|
2426
|
+
auth?: string[];
|
|
2427
|
+
/**
|
|
2428
|
+
* Explicit permission scopes requested during post-authentication resource authorization (AuthZ)
|
|
2429
|
+
* (e.g. ['https://www.googleapis.com/auth/drive.readonly'] or ['repo']).
|
|
2430
|
+
*/
|
|
2431
|
+
resource?: string[];
|
|
2432
|
+
}
|
|
2433
|
+
|
|
1754
2434
|
/**
|
|
1755
2435
|
* Options for Scrypt password hashing.
|
|
1756
2436
|
*
|
|
@@ -1806,6 +2486,69 @@ export declare class ScryptPasswordHasher implements IPasswordHasher {
|
|
|
1806
2486
|
private deriveKey;
|
|
1807
2487
|
}
|
|
1808
2488
|
|
|
2489
|
+
/**
|
|
2490
|
+
* Self-Managed Identity Provider implementation for Lixa.
|
|
2491
|
+
*
|
|
2492
|
+
* @remarks
|
|
2493
|
+
* Backed by custom database storage (Prisma, Drizzle, PostgreSQL, SQLite, MongoDB)
|
|
2494
|
+
* or local in-memory storage, with cryptographic password hashing (Scrypt, Argon2, PBKDF2)
|
|
2495
|
+
* and configurable password policy enforcement.
|
|
2496
|
+
*
|
|
2497
|
+
* @public
|
|
2498
|
+
*/
|
|
2499
|
+
export declare class SelfManagedIdentityProvider implements IIdentityProvider {
|
|
2500
|
+
readonly name: string;
|
|
2501
|
+
private readonly manager;
|
|
2502
|
+
private readonly pendingSignups;
|
|
2503
|
+
private readonly requireVerification;
|
|
2504
|
+
private readonly config;
|
|
2505
|
+
constructor(configOrManager?: CredentialsConfig | CredentialsManager);
|
|
2506
|
+
private mapUser;
|
|
2507
|
+
private generateConfirmationCode;
|
|
2508
|
+
/**
|
|
2509
|
+
* Registers a new user with optional pending verification.
|
|
2510
|
+
* When requireVerification is true, credentials are NOT persisted to the database until confirmSignUp() is called.
|
|
2511
|
+
*/
|
|
2512
|
+
signUp(params: SignUpParams): Promise<UserIdentity>;
|
|
2513
|
+
/**
|
|
2514
|
+
* Confirms a pending signup registration using the verification code.
|
|
2515
|
+
* Only after successful confirmation is the user persisted to the database.
|
|
2516
|
+
*/
|
|
2517
|
+
confirmSignUp(params: ConfirmSignUpParams): Promise<boolean>;
|
|
2518
|
+
/**
|
|
2519
|
+
* Resends the verification code for a pending signup.
|
|
2520
|
+
*/
|
|
2521
|
+
resendConfirmationCode(params: ResendConfirmationCodeParams): Promise<ResendConfirmationCodeResult>;
|
|
2522
|
+
/**
|
|
2523
|
+
* Authenticates a user with password.
|
|
2524
|
+
*/
|
|
2525
|
+
signIn(params: SignInParams): Promise<IdentityAuthResult>;
|
|
2526
|
+
/**
|
|
2527
|
+
* Verifies credentials without throwing an error if invalid.
|
|
2528
|
+
*/
|
|
2529
|
+
verifyCredentials(params: VerifyCredentialsParams): Promise<UserIdentity | null>;
|
|
2530
|
+
/**
|
|
2531
|
+
* Changes a user's password.
|
|
2532
|
+
*/
|
|
2533
|
+
changePassword(params: ChangePasswordParams): Promise<boolean>;
|
|
2534
|
+
/**
|
|
2535
|
+
* Retrieves a user by their unique ID.
|
|
2536
|
+
*/
|
|
2537
|
+
getUserById(id: string): Promise<UserIdentity | null>;
|
|
2538
|
+
/**
|
|
2539
|
+
* Retrieves a user by their identifier (email or username).
|
|
2540
|
+
*/
|
|
2541
|
+
getUserByIdentifier(identifier: string): Promise<UserIdentity | null>;
|
|
2542
|
+
/**
|
|
2543
|
+
* Deletes a user from storage if supported by the storage adapter.
|
|
2544
|
+
*/
|
|
2545
|
+
deleteUser(id: string): Promise<void>;
|
|
2546
|
+
/**
|
|
2547
|
+
* Returns the underlying CredentialsManager instance.
|
|
2548
|
+
*/
|
|
2549
|
+
getCredentialsManager(): CredentialsManager;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
1809
2552
|
/**
|
|
1810
2553
|
* Serializes a cookie name, value, and options into a standard `Set-Cookie` header string.
|
|
1811
2554
|
*
|
|
@@ -1832,9 +2575,9 @@ export declare function serializeCookie(name: string, value: string, options?: C
|
|
|
1832
2575
|
*/
|
|
1833
2576
|
export declare interface Session<TRaw = OAuthTokenResponse> {
|
|
1834
2577
|
/**
|
|
1835
|
-
* Unique session ID generated by Lixa upon authentication.
|
|
2578
|
+
* Unique canonical session ID generated by Lixa upon authentication.
|
|
1836
2579
|
*/
|
|
1837
|
-
|
|
2580
|
+
sessionId?: string | undefined;
|
|
1838
2581
|
/**
|
|
1839
2582
|
* Linked identity provider accounts (AuthN) keyed by provider name.
|
|
1840
2583
|
* Single source of truth for all authenticated user SSO identities.
|
|
@@ -1861,6 +2604,14 @@ export declare interface Session<TRaw = OAuthTokenResponse> {
|
|
|
1861
2604
|
raw?: TRaw | undefined;
|
|
1862
2605
|
}
|
|
1863
2606
|
|
|
2607
|
+
/**
|
|
2608
|
+
* Dynamic resolver for session cookie name.
|
|
2609
|
+
* Can be a static string or a dynamic callback receiving the Lixa instance and an optional request context.
|
|
2610
|
+
*
|
|
2611
|
+
* @public
|
|
2612
|
+
*/
|
|
2613
|
+
export declare type SessionCookieResolver<TContext extends LixaCookieContext = LixaCookieContext> = string | ((lixa: TContext, req?: unknown) => string);
|
|
2614
|
+
|
|
1864
2615
|
/**
|
|
1865
2616
|
* Session handler for OAuth authentication.
|
|
1866
2617
|
*
|
|
@@ -2011,6 +2762,8 @@ export declare interface SessionStorage {
|
|
|
2011
2762
|
* @public
|
|
2012
2763
|
*/
|
|
2013
2764
|
export declare interface SignInParams {
|
|
2765
|
+
/** Target identity provider name when using CompositeIdentityProvider */
|
|
2766
|
+
provider?: string | undefined;
|
|
2014
2767
|
/** Username or email of the account */
|
|
2015
2768
|
username?: string | undefined;
|
|
2016
2769
|
/** Primary identifier (username or email) */
|
|
@@ -2024,9 +2777,9 @@ export declare interface SignInParams {
|
|
|
2024
2777
|
*
|
|
2025
2778
|
* @public
|
|
2026
2779
|
*/
|
|
2027
|
-
export declare interface SignInResult<TSession = Session> {
|
|
2028
|
-
/** Authenticated user credentials (with passwordHash omitted for safety) */
|
|
2029
|
-
user:
|
|
2780
|
+
export declare interface SignInResult<TSession = Session, TUser = UserIdentity> {
|
|
2781
|
+
/** Authenticated user profile / credentials (with passwordHash omitted for safety) */
|
|
2782
|
+
user: TUser;
|
|
2030
2783
|
/** Active session ID */
|
|
2031
2784
|
sessionId: string;
|
|
2032
2785
|
/** Active session object */
|
|
@@ -2039,6 +2792,8 @@ export declare interface SignInResult<TSession = Session> {
|
|
|
2039
2792
|
* @public
|
|
2040
2793
|
*/
|
|
2041
2794
|
export declare interface SignUpParams {
|
|
2795
|
+
/** Target identity provider name when using CompositeIdentityProvider */
|
|
2796
|
+
provider?: string | undefined;
|
|
2042
2797
|
/** Username for the user (can be used directly instead of identifier) */
|
|
2043
2798
|
username?: string | undefined;
|
|
2044
2799
|
/** Primary identifier (username or email) */
|
|
@@ -2056,13 +2811,27 @@ export declare interface SignUpParams {
|
|
|
2056
2811
|
*
|
|
2057
2812
|
* @public
|
|
2058
2813
|
*/
|
|
2059
|
-
export declare interface SignUpResult<TSession = Session> {
|
|
2060
|
-
/** Created user credentials (with passwordHash omitted for safety) */
|
|
2061
|
-
user:
|
|
2814
|
+
export declare interface SignUpResult<TSession = Session, TUser = UserIdentity> {
|
|
2815
|
+
/** Created user profile / credentials (with passwordHash omitted for safety) */
|
|
2816
|
+
user: TUser;
|
|
2062
2817
|
/** Created session ID if autoCreateSessionOnSignUp is enabled */
|
|
2063
2818
|
sessionId?: string | undefined;
|
|
2064
2819
|
/** Created session object if autoCreateSessionOnSignUp is enabled */
|
|
2065
2820
|
session?: TSession | undefined;
|
|
2821
|
+
requiresVerification?: boolean | undefined;
|
|
2822
|
+
devConfirmationCode?: string | undefined;
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
/**
|
|
2826
|
+
* Thrown when attempting to sign up with username+password for an email that already has an SSO account.
|
|
2827
|
+
* The user should sign in via their original SSO provider and set a password in Settings.
|
|
2828
|
+
*
|
|
2829
|
+
* @public
|
|
2830
|
+
*/
|
|
2831
|
+
export declare class SSOAccountAlreadyExistsError extends LixaError {
|
|
2832
|
+
readonly existingProviders: string[];
|
|
2833
|
+
readonly email: string;
|
|
2834
|
+
constructor(email: string, existingProviders: string[], details?: Record<string, unknown>);
|
|
2066
2835
|
}
|
|
2067
2836
|
|
|
2068
2837
|
/**
|
|
@@ -2258,6 +3027,19 @@ export declare interface StateStorage {
|
|
|
2258
3027
|
deleteState(state: string): Promise<void>;
|
|
2259
3028
|
}
|
|
2260
3029
|
|
|
3030
|
+
/**
|
|
3031
|
+
* Unified storage adapter interface (e.g. Prisma or Drizzle adapter).
|
|
3032
|
+
* When provided to Lixa via config.storage, automatically configures session, state, and resource storage.
|
|
3033
|
+
* @public
|
|
3034
|
+
*/
|
|
3035
|
+
export declare interface StorageAdapter {
|
|
3036
|
+
sessionStorage?: any;
|
|
3037
|
+
resourceStorage?: any;
|
|
3038
|
+
stateStorage?: any;
|
|
3039
|
+
credentialsStorage?: any;
|
|
3040
|
+
accountStorage?: any;
|
|
3041
|
+
}
|
|
3042
|
+
|
|
2261
3043
|
/**
|
|
2262
3044
|
* Thrown when exchanging an authorization code for OAuth tokens fails at the provider endpoint.
|
|
2263
3045
|
*
|
|
@@ -2301,6 +3083,33 @@ export declare interface UserCredentials {
|
|
|
2301
3083
|
metadata?: Record<string, unknown> | undefined;
|
|
2302
3084
|
}
|
|
2303
3085
|
|
|
3086
|
+
/**
|
|
3087
|
+
* Standardized user identity representation across all identity providers
|
|
3088
|
+
* (Self-Managed Database, AWS Cognito, Auth0, Okta, Firebase, etc.).
|
|
3089
|
+
*
|
|
3090
|
+
* @public
|
|
3091
|
+
*/
|
|
3092
|
+
export declare interface UserIdentity {
|
|
3093
|
+
/** Unique user identifier (UUID, Sub, Auth0 user_id, Okta id) */
|
|
3094
|
+
id: string;
|
|
3095
|
+
/** Primary unique lookup identifier (email or username) */
|
|
3096
|
+
identifier: string;
|
|
3097
|
+
/** Associated email address if available */
|
|
3098
|
+
email?: string | undefined;
|
|
3099
|
+
/** Username of the account if available */
|
|
3100
|
+
username?: string | undefined;
|
|
3101
|
+
/** Whether the email address has been verified by the identity provider */
|
|
3102
|
+
emailVerified?: boolean | undefined;
|
|
3103
|
+
/** Unix timestamp in milliseconds when user was created */
|
|
3104
|
+
createdAt?: number | undefined;
|
|
3105
|
+
/** Unix timestamp in milliseconds when user was last updated */
|
|
3106
|
+
updatedAt?: number | undefined;
|
|
3107
|
+
/** Custom user metadata or profile attributes */
|
|
3108
|
+
metadata?: Record<string, unknown> | undefined;
|
|
3109
|
+
/** Identity provider name (e.g. "self-managed", "cognito", "auth0", "okta") */
|
|
3110
|
+
provider?: string | undefined;
|
|
3111
|
+
}
|
|
3112
|
+
|
|
2304
3113
|
/**
|
|
2305
3114
|
* User information extracted from OAuth provider
|
|
2306
3115
|
*
|
|
@@ -2344,6 +3153,8 @@ export declare function validatePasswordPolicy(password: string, policy?: Passwo
|
|
|
2344
3153
|
* @public
|
|
2345
3154
|
*/
|
|
2346
3155
|
export declare interface VerifyCredentialsParams {
|
|
3156
|
+
/** Target identity provider name when using CompositeIdentityProvider */
|
|
3157
|
+
provider?: string | undefined;
|
|
2347
3158
|
/** Username or email of the account */
|
|
2348
3159
|
username?: string | undefined;
|
|
2349
3160
|
/** Primary identifier (username or email) */
|