@tern-secure/types 1.1.0-canary.v20251108045933 → 1.1.0-canary.v20251125170702

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/dist/index.d.ts CHANGED
@@ -175,6 +175,11 @@ interface ServerConfigValidationResult {
175
175
  config: TernSecureServerConfig;
176
176
  }
177
177
  type InstanceType = 'production' | 'development';
178
+ interface AppCheckConfig {
179
+ provider: 'reCaptchaV3' | 'reCaptchaEnterprise';
180
+ siteKey: string;
181
+ isTokenAutoRefreshEnabled?: boolean;
182
+ }
178
183
 
179
184
  interface TernSecureAPIError {
180
185
  code: string;
@@ -247,9 +252,10 @@ declare const ERRORS: {
247
252
  readonly REDIRECT_LOOP: "Redirect loop detected.";
248
253
  };
249
254
 
250
- type AuthEndpoint = 'cookies' | 'sessions' | 'users';
255
+ type AuthEndpoint = 'cookies' | 'sessions' | 'users' | 'sign_ins';
251
256
  type CookieSubEndpoint = 'get' | 'set' | 'delete' | 'clear' | 'list';
252
257
  type SessionSubEndpoint = 'verify' | 'createsession' | 'refresh' | 'revoke';
258
+ type SignInSubEndpoint = 'create' | 'resetPasswordEmail';
253
259
  interface CorsOptions {
254
260
  allowedOrigins: string[] | '*';
255
261
  allowedMethods?: string[];
@@ -313,6 +319,11 @@ interface SessionEndpointConfig extends EndpointConfig {
313
319
  [K in SessionSubEndpoint]?: Partial<EndpointConfig>;
314
320
  };
315
321
  }
322
+ interface SignInEndpointConfig extends EndpointConfig {
323
+ subEndpoints?: {
324
+ [K in SignInSubEndpoint]?: Partial<EndpointConfig>;
325
+ };
326
+ }
316
327
  interface TernSecureHandlerOptions {
317
328
  cors?: CorsOptions;
318
329
  cookies?: CookieOpts;
@@ -321,6 +332,7 @@ interface TernSecureHandlerOptions {
321
332
  endpoints?: {
322
333
  cookies?: CookieEndpointConfig;
323
334
  sessions?: SessionEndpointConfig;
335
+ signIns?: SignInEndpointConfig;
324
336
  };
325
337
  tenantId?: string | null;
326
338
  revokeRefreshTokensOnSignOut?: boolean;
@@ -378,10 +390,32 @@ interface SessionResource extends IdTokenResult {
378
390
  getIdAndRefreshToken: (idToken: string, csrfToken: string) => Promise<void>;
379
391
  }
380
392
 
393
+ interface TernSecureApiErrorJSON {
394
+ code: string;
395
+ message: string;
396
+ }
397
+ interface TernSecureFireRestErrorJSON extends TernSecureApiErrorJSON {
398
+ domain: string;
399
+ reason: string;
400
+ }
401
+ interface SessionJson extends IdTokenResult {
402
+ status: SessionStatus;
403
+ user?: TernSecureUser;
404
+ }
405
+ /**
406
+ * Currently representing API DTOs in their JSON form.
407
+ */
408
+ interface TernSecureResourceJSON {
409
+ id: string;
410
+ object: string;
411
+ }
412
+
413
+ type UnverifiedField = 'email_address' | 'phone_number';
381
414
  interface BaseSignUpResponse {
382
415
  status?: SignUpStatus;
383
416
  message?: string;
384
- error?: any | undefined;
417
+ error?: any;
418
+ unverifiedFields?: UnverifiedField[];
385
419
  }
386
420
  interface SignUpSuccessResponse extends BaseSignUpResponse, UserCredential {
387
421
  status: 'complete';
@@ -389,24 +423,23 @@ interface SignUpSuccessResponse extends BaseSignUpResponse, UserCredential {
389
423
  interface SignUpErrorResponse extends BaseSignUpResponse {
390
424
  status: 'error';
391
425
  }
392
- type SignUpResponse = SignUpSuccessResponse | SignUpErrorResponse;
426
+ interface SignUpMissingRequirementsResponse extends BaseSignUpResponse, UserCredential {
427
+ status: 'missing_requirements';
428
+ unverifiedFields: UnverifiedField[];
429
+ }
430
+ type SignUpResponse = SignUpSuccessResponse | SignUpErrorResponse | SignUpMissingRequirementsResponse;
393
431
  type SignUpFormValues = {
394
432
  email: string;
395
433
  password: string;
396
434
  };
397
- type SignUpInitialValue = {
398
- email: string;
399
- password: string;
400
- };
435
+ type SignUpInitialValue = Partial<SignUpFormValues>;
401
436
  interface SignUpResource {
402
437
  status: SignUpStatus | null;
403
- username: string | null;
404
- firstName: string | null;
405
- lastName: string | null;
406
- displayName: string | null;
407
- email: string | null;
408
- phoneNumber: string | null;
409
- withEmailAndPassword: (params: SignUpInitialValue) => Promise<SignUpResponse>;
438
+ user: TernSecureUser | null;
439
+ unverifiedFields?: UnverifiedField[];
440
+ message?: string;
441
+ error?: any;
442
+ withEmailAndPassword: (params: SignUpFormValues) => Promise<SignUpResource>;
410
443
  /**
411
444
  * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
412
445
  * @param options - Optional configuration for the social sign-in flow.
@@ -415,8 +448,22 @@ interface SignUpResource {
415
448
  withSocialProvider: (provider: string, options?: {
416
449
  mode?: 'popup' | 'redirect';
417
450
  }) => Promise<SignUpResponse | void>;
451
+ /**
452
+ * Sends an email verification link to the user's email address.
453
+ * @param options - Optional configuration for the verification email.
454
+ * @returns A promise that resolves with the updated SignUpResource.
455
+ */
456
+ attemptEmailVerification: (options?: {
457
+ url?: string;
458
+ handleCodeInApp?: boolean;
459
+ }) => Promise<SignUpResource>;
418
460
  }
419
461
  type SignUpStatus = 'missing_requirements' | 'complete' | 'abandoned' | 'error';
462
+ interface SignUpJson extends TernSecureResourceJSON {
463
+ object: 'sign_up';
464
+ id: string;
465
+ status: SignUpStatus;
466
+ }
420
467
 
421
468
  interface FirebaseClaims {
422
469
  identities: {
@@ -534,11 +581,129 @@ type AfterSignOutUrl = {
534
581
  afterSignOutUrl?: string | null;
535
582
  };
536
583
 
537
- type SignInStatus = 'idle' | 'pending_email_password' | 'pending_social' | 'pending_mfa' | 'redirecting' | 'success' | 'error';
584
+ type PasskeyStrategy = 'passkey';
585
+ type PasswordStrategy = 'password';
586
+ type PhoneCodeStrategy = 'phone_code';
587
+ type EmailCodeStrategy = 'email_code';
588
+ type EmailLinkStrategy = 'email_link';
589
+ type TOTPStrategy = 'totp';
590
+ type BackupCodeStrategy = 'backup_code';
591
+ type ResetPasswordPhoneCodeStrategy = 'reset_password_phone_code';
592
+ type ResetPasswordEmailCodeStrategy = 'reset_password_email_code';
593
+ type EnterpriseSSOStrategy = 'enterprise_sso';
594
+
595
+ type EmailCodeFactor = {
596
+ strategy: EmailCodeStrategy;
597
+ emailAddressId: string;
598
+ safeIdentifier: string;
599
+ primary?: boolean;
600
+ };
601
+ type EmailLinkFactor = {
602
+ strategy: EmailLinkStrategy;
603
+ emailAddressId: string;
604
+ safeIdentifier: string;
605
+ primary?: boolean;
606
+ };
607
+ type PhoneCodeFactor = {
608
+ strategy: PhoneCodeStrategy;
609
+ phoneNumberId: string;
610
+ safeIdentifier: string;
611
+ primary?: boolean;
612
+ default?: boolean;
613
+ };
614
+ type PasswordFactor = {
615
+ strategy: PasswordStrategy;
616
+ };
617
+ type PasskeyFactor = {
618
+ strategy: PasskeyStrategy;
619
+ };
620
+ type EnterpriseSSOFactor = {
621
+ strategy: EnterpriseSSOStrategy;
622
+ };
623
+ type TOTPFactor = {
624
+ strategy: TOTPStrategy;
625
+ };
626
+ type BackupCodeFactor = {
627
+ strategy: BackupCodeStrategy;
628
+ };
629
+ type ResetPasswordPhoneCodeFactor = {
630
+ strategy: ResetPasswordPhoneCodeStrategy;
631
+ phoneNumberId: string;
632
+ safeIdentifier: string;
633
+ primary?: boolean;
634
+ };
635
+ type ResetPasswordEmailCodeFactor = {
636
+ strategy: ResetPasswordEmailCodeStrategy;
637
+ emailAddressId: string;
638
+ safeIdentifier: string;
639
+ primary?: boolean;
640
+ };
641
+ type ResetPasswordCodeFactor = ResetPasswordEmailCodeFactor | ResetPasswordPhoneCodeFactor;
642
+ type ResetPasswordPhoneCodeFactorConfig = Omit<ResetPasswordPhoneCodeFactor, 'safeIdentifier'>;
643
+ type ResetPasswordEmailCodeFactorConfig = Omit<ResetPasswordEmailCodeFactor, 'safeIdentifier'>;
644
+ type EmailCodeConfig = Omit<EmailCodeFactor, 'safeIdentifier'>;
645
+ type EmailLinkConfig = Omit<EmailLinkFactor, 'safeIdentifier'> & {
646
+ redirectUrl: string;
647
+ };
648
+ type PhoneCodeConfig = Omit<PhoneCodeFactor, 'safeIdentifier'>;
649
+ type PassKeyConfig = PasskeyFactor;
650
+ type EnterpriseSSOConfig = EnterpriseSSOFactor & {
651
+ redirectUrl: string;
652
+ actionCompleteRedirectUrl: string;
653
+ oidcPrompt?: string;
654
+ };
655
+ type PhoneCodeSecondFactorConfig = {
656
+ strategy: PhoneCodeStrategy;
657
+ phoneNumberId?: string;
658
+ };
659
+ type EmailCodeAttempt = {
660
+ strategy: EmailCodeStrategy;
661
+ code: string;
662
+ };
663
+ type PhoneCodeAttempt = {
664
+ strategy: PhoneCodeStrategy;
665
+ code: string;
666
+ };
667
+ type PasswordAttempt = {
668
+ strategy: PasswordStrategy;
669
+ password: string;
670
+ };
671
+ type TOTPAttempt = {
672
+ strategy: TOTPStrategy;
673
+ code: string;
674
+ };
675
+ type BackupCodeAttempt = {
676
+ strategy: BackupCodeStrategy;
677
+ code: string;
678
+ };
679
+ type ResetPasswordPhoneCodeAttempt = {
680
+ strategy: ResetPasswordPhoneCodeStrategy;
681
+ code: string;
682
+ password?: string;
683
+ };
684
+ type ResetPasswordEmailCodeAttempt = {
685
+ strategy: ResetPasswordEmailCodeStrategy;
686
+ code: string;
687
+ password?: string;
688
+ };
689
+
690
+ type SignInStatus = 'needs_identifier' | 'needs_first_factor' | 'needs_second_factor' | 'needs_new_password' | 'needs_email_verification' | 'idle' | 'pending_email_password' | 'pending_social' | 'pending_mfa' | 'redirecting' | 'success' | 'error';
538
691
  type SignInFormValues = {
692
+ email?: string;
693
+ password?: string;
694
+ phoneNumber?: string;
695
+ };
696
+ /**
697
+ * @deprecated
698
+ */
699
+ type SignInInitialValue = Partial<SignInFormValues>;
700
+ type SignInPasswordParams = {
539
701
  email: string;
540
702
  password: string;
541
- phoneNumber?: string;
703
+ };
704
+ type SignInPhoneParams = {
705
+ phoneNumber: string;
706
+ appVerifier?: any;
542
707
  };
543
708
  interface AuthErrorResponse {
544
709
  success: false;
@@ -565,7 +730,6 @@ interface SignInPendingResponse extends BaseSignInResponse {
565
730
  status: 'redirecting' | 'pending_social' | 'pending_email_password';
566
731
  }
567
732
  type SignInResponse = SignInSuccessResponse | SignInErrorResponse | SignInPendingResponse;
568
- type SignInInitialValue = Partial<SignInFormValues>;
569
733
  interface ResendEmailVerification {
570
734
  isVerified?: boolean;
571
735
  }
@@ -581,46 +745,227 @@ interface SocialProviderOptions {
581
745
  /** OAuth scopes to request from the provider */
582
746
  scopes?: string[];
583
747
  }
748
+ interface SignInVerificationResponse {
749
+ status: SignInStatus;
750
+ message?: string;
751
+ error?: any;
752
+ }
584
753
  interface SignInResource {
754
+ status: SignInStatus | null;
755
+ supportedFirstFactors: SignInFirstFactor[] | null;
756
+ identifier: string | null;
757
+ user?: TernSecureUser | null;
585
758
  /**
586
- * The current status of the sign-in process.
759
+ * Create combine email and phone sign in method
587
760
  */
588
- status: SignInStatus | null;
761
+ create: (params: SignInCreateParams) => Promise<SignInResource>;
762
+ authenticateWithPassword: (params: SignInPasswordParams) => Promise<SignInResponse>;
763
+ createRecaptchaVerifier: (containerOrId: string | HTMLElement, parameters?: any) => any;
764
+ authenticateWithPhoneNumber: (params: SignInPhoneParams) => Promise<SignInResponse>;
765
+ authenticateWithSocialProvider: (provider: string, options: SocialProviderOptions) => Promise<SignInResponse>;
766
+ completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponse>;
767
+ sendPasswordResetEmail: (email: string) => Promise<{
768
+ response: {
769
+ email: string;
770
+ };
771
+ } | null>;
772
+ attemptEmailVerification: (options?: {
773
+ url?: string;
774
+ handleCodeInApp?: boolean;
775
+ }) => Promise<SignInVerificationResponse>;
776
+ attemptFirstFactor: (params: AttemptFirstFactorParams) => Promise<SignInResource>;
777
+ checkRedirectResult: () => Promise<SignInResponse | null>;
778
+ }
779
+ type SignInFirstFactor = EmailCodeFactor | PasswordFactor;
780
+ type SignInSecondFactor = PhoneCodeFactor | TOTPFactor | BackupCodeFactor;
781
+ type SignInFactor = SignInFirstFactor | SignInSecondFactor;
782
+ type SignInCreateParams = ({
783
+ strategy: PasswordStrategy;
784
+ password?: string;
785
+ identifier: string;
786
+ } | {
787
+ strategy: PhoneCodeStrategy | EmailCodeStrategy | ResetPasswordEmailCodeStrategy | ResetPasswordPhoneCodeStrategy;
788
+ identifier: string;
789
+ });
790
+ type AttemptFirstFactorParams = EmailCodeAttempt | PhoneCodeAttempt | PasswordAttempt | ResetPasswordPhoneCodeAttempt | ResetPasswordEmailCodeAttempt;
791
+ interface SignInJson extends TernSecureResourceJSON {
792
+ object: 'sign_in';
793
+ id: string;
794
+ status: SignInStatus;
795
+ supportedFirstFactors: SignInFirstFactor[];
796
+ firstFactorVerification?: SignInFirstFactor;
797
+ secondFactorVerification?: SignInSecondFactor;
798
+ identifier: string | null;
799
+ }
800
+
801
+ /**
802
+ * Defines the basic structure for color theming.
803
+ */
804
+ interface ThemeColors {
805
+ primary?: string;
806
+ secondary?: string;
807
+ accent?: string;
808
+ background?: string;
809
+ text?: string;
810
+ error?: string;
811
+ success?: string;
812
+ }
813
+ /**
814
+ * Defines the basic structure for font theming.
815
+ */
816
+ interface ThemeFonts {
817
+ primary?: string;
818
+ secondary?: string;
819
+ }
820
+ /**
821
+ * Defines the basic structure for spacing and layout theming.
822
+ */
823
+ interface ThemeSpacing {
824
+ small?: string | number;
825
+ medium?: string | number;
826
+ large?: string | number;
827
+ }
828
+ /**
829
+ * Defines the basic structure for border radius theming.
830
+ */
831
+ interface ThemeBorderRadius {
832
+ small?: string | number;
833
+ medium?: string | number;
834
+ large?: string | number;
835
+ }
836
+ /**
837
+ * Allows for overriding styles of specific UI components.
838
+ * Properties can be CSS-in-JS objects or class names, depending on implementation.
839
+ */
840
+ interface ThemeComponentStyles {
841
+ button?: Record<string, any> | string;
842
+ input?: Record<string, any> | string;
843
+ card?: Record<string, any> | string;
844
+ label?: Record<string, any> | string;
845
+ }
846
+ /**
847
+ * Defines the overall appearance/theme configuration.
848
+ * This allows for broad customization of the UI components.
849
+ */
850
+ interface Appearance {
851
+ colors?: ThemeColors;
852
+ fonts?: ThemeFonts;
853
+ spacing?: ThemeSpacing;
854
+ borderRadius?: ThemeBorderRadius;
855
+ componentStyles?: ThemeComponentStyles;
856
+ variables?: Record<string, string | number>;
857
+ }
858
+ type Layout = {
589
859
  /**
590
- * Signs in a user with their email and password.
591
- * @param params - The sign-in form values.
592
- * @returns A promise that resolves with the sign-in response.
860
+ * @default inside
593
861
  */
594
- withEmailAndPassword: (params: SignInFormValues) => Promise<SignInResponse>;
862
+ logoPlacement?: 'inside' | 'outside' | 'none';
595
863
  /**
596
- * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
597
- * @param options - Optional configuration for the social sign-in flow.
598
- * @returns A promise that resolves with the sign-in response.
864
+ * @default undefined
599
865
  */
600
- withSocialProvider: (provider: string, options: SocialProviderOptions) => Promise<SignInResponse>;
866
+ logoImageUrl?: string;
601
867
  /**
602
- * Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.
603
- * @param mfaToken - The MFA token or code submitted by the user.
604
- * @param mfaContext - Optional context or session data from the MFA initiation step.
605
- * @returns A promise that resolves with the sign-in response upon successful MFA verification.
868
+ * @default undefined
606
869
  */
607
- completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponse>;
870
+ logoLinkUrl?: string;
608
871
  /**
609
- * Sends a password reset email to the given email address.
610
- * @param email - The user's email address.
611
- * @returns A promise that resolves when the email is sent.
872
+ * @default auto
612
873
  */
613
- sendPasswordResetEmail: (email: string) => Promise<void>;
874
+ socialButtonsVariant?: 'auto' | 'iconButton' | 'blockButton';
614
875
  /**
615
- * Resends the email verification link to the user's email address.
616
- * @returns A promise that resolves with the sign-in response.
876
+ * @default bottom
617
877
  */
618
- resendEmailVerification: () => Promise<ResendEmailVerification>;
878
+ socialButtonsPlacement?: 'top' | 'bottom';
619
879
  /**
620
- * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.
621
- * @returns A promise that resolves with the sign-in response or null if no result is available.
880
+ * enables "Terms" link
622
881
  */
623
- checkRedirectResult: () => Promise<SignInResponse | null>;
882
+ termsPageUrl?: string;
883
+ /**
884
+ * enables "Help" link
885
+ */
886
+ helpPageUrl?: string;
887
+ /**
888
+ * enables "Privacy Policy" link
889
+ */
890
+ privacyPageUrl?: string;
891
+ };
892
+ type TernSecureTheme = {
893
+ appearance?: Appearance;
894
+ layout?: Layout;
895
+ };
896
+ type SignInTheme = TernSecureTheme;
897
+ type SignUpTheme = TernSecureTheme;
898
+ /**
899
+ * Base UI configuration shared between SignIn and SignUp
900
+ * @deprecated Use TernSecureTheme instead.
901
+ */
902
+ interface BaseAuthUIConfig {
903
+ /** Visual appearance configuration */
904
+ appearance?: Appearance;
905
+ /** Application logo URL or SVG string */
906
+ logo?: string;
907
+ /** Application name for display */
908
+ appName?: string;
909
+ /** Render mode for cross-platform support */
910
+ renderMode?: 'modal' | 'page' | 'embedded';
911
+ /** Layout direction */
912
+ layout?: 'vertical' | 'horizontal';
913
+ /** Custom loading message */
914
+ loadingMessage?: string;
915
+ /** Loading spinner variant */
916
+ loadingSpinnerVariant?: 'circular' | 'linear' | 'dots';
917
+ /** Accessibility configuration */
918
+ a11y?: {
919
+ /** ARIA labels and descriptions */
920
+ labels?: Record<string, string>;
921
+ /** Element to receive initial focus */
922
+ initialFocus?: string;
923
+ /** Whether to trap focus within the auth UI */
924
+ trapFocus?: boolean;
925
+ };
926
+ }
927
+ /**
928
+ * Sign-in specific UI configuration
929
+ * @deprecated Use SignInTheme instead.
930
+ */
931
+ interface SignInUIConfig extends BaseAuthUIConfig {
932
+ /** Social sign-in buttons configuration */
933
+ socialButtons?: {
934
+ google?: boolean;
935
+ microsoft?: boolean;
936
+ github?: boolean;
937
+ facebook?: boolean;
938
+ twitter?: boolean;
939
+ apple?: boolean;
940
+ linkedin?: boolean;
941
+ layout?: 'vertical' | 'horizontal';
942
+ size?: 'small' | 'medium' | 'large';
943
+ };
944
+ /** "Remember me" checkbox configuration */
945
+ rememberMe?: {
946
+ enabled?: boolean;
947
+ defaultChecked?: boolean;
948
+ };
949
+ }
950
+ /**
951
+ * Sign-up specific UI configuration
952
+ * @deprecated Use SignUpTheme instead.
953
+ */
954
+ interface SignUpUIConfig extends BaseAuthUIConfig {
955
+ /** Password requirements display configuration */
956
+ passwordRequirements?: {
957
+ show?: boolean;
958
+ rules?: Array<{
959
+ rule: string;
960
+ description: string;
961
+ }>;
962
+ };
963
+ /** Terms and conditions configuration */
964
+ terms?: {
965
+ enabled?: boolean;
966
+ text?: string;
967
+ link?: string;
968
+ };
624
969
  }
625
970
 
626
971
  /**
@@ -740,8 +1085,13 @@ type TernSecureAuthOptions = TernSecureOptionsNavigation & SignInForceRedirectUr
740
1085
  sdkMetadata?: TernAuthSDK;
741
1086
  signInUrl?: string;
742
1087
  signUpUrl?: string;
1088
+ signUpMode?: 'public' | 'restricted' | 'waitlist';
1089
+ passwordAuthentication?: boolean;
743
1090
  mode?: Mode$1;
744
1091
  requiresVerification?: boolean;
1092
+ /**
1093
+ * @deprecated will be removed in future releases. please use ternUIUrl
1094
+ */
745
1095
  isTernSecureDev?: boolean;
746
1096
  ternSecureConfig?: TernSecureConfig;
747
1097
  persistence?: Persistence;
@@ -758,6 +1108,10 @@ type TernSecureAuthOptions = TernSecureOptionsNavigation & SignInForceRedirectUr
758
1108
  /** rethrow network errors that occur while the offline */
759
1109
  rethrowOfflineNetworkErrors?: boolean;
760
1110
  };
1111
+ /**
1112
+ * ReCaptcha V3 Site Key for Firebase App Check
1113
+ */
1114
+ appCheck?: AppCheckConfig;
761
1115
  };
762
1116
  /**
763
1117
  * @deprecated will be removed in future releases.
@@ -811,7 +1165,9 @@ interface TernSecureAuth {
811
1165
  /** TernSecure API URL */
812
1166
  apiUrl: string;
813
1167
  /** TernSecure domain for API string */
814
- domain: string;
1168
+ authDomain: string;
1169
+ /** TernSecure Frontend domain for TernSecure UI */
1170
+ frontEndDomain?: string;
815
1171
  /** TernSecure Proxy url */
816
1172
  proxyUrl?: string;
817
1173
  /** TernSecure Instance type */
@@ -844,6 +1200,32 @@ interface TernSecureAuth {
844
1200
  onAuthStateChanged(callback: (cb: any) => void): () => void;
845
1201
  /** Sign out the current user */
846
1202
  signOut: SignOut;
1203
+ /** Mounts a sign-in component
1204
+ * @param targetNode HTMLDivElement where the component will be mounted
1205
+ * @param signInProps Configuration options for the sign-in component
1206
+ */
1207
+ showSignIn: (targetNode: HTMLDivElement, config?: SignInProps) => void;
1208
+ /** Unmount sign-in component
1209
+ * @param targetNode HTMLDivElement where the component is mounted
1210
+ */
1211
+ hideSignIn: (targetNode: HTMLDivElement) => void;
1212
+ /** Mounts a sign-up component
1213
+ * @param targetNode HTMLDivElement where the component will be mounted
1214
+ * @param signUpProps Configuration options for the sign-up component
1215
+ */
1216
+ showSignUp: (targetNode: HTMLDivElement, config?: SignUpProps) => void;
1217
+ /** Unmount sign-up component
1218
+ * @param targetNode HTMLDivElement where the component is mounted
1219
+ */
1220
+ hideSignUp: (targetNode: HTMLDivElement) => void;
1221
+ /** Mounts a user button component
1222
+ * @param targetNode HTMLDivElement where the component will be mounted
1223
+ */
1224
+ showUserButton: (targetNode: HTMLDivElement) => void;
1225
+ /** Unmount user button component
1226
+ * @param targetNode HTMLDivElement where the component is mounted
1227
+ */
1228
+ hideUserButton: (targetNode: HTMLDivElement) => void;
847
1229
  /** Subscribe to a single event */
848
1230
  on: onEventListener;
849
1231
  /** Remove event listener */
@@ -860,6 +1242,7 @@ interface TernSecureAuth {
860
1242
  * @param {string} to
861
1243
  */
862
1244
  constructUrlWithAuthRedirect(to: string): string;
1245
+ constructAfterSignOutUrl(): string;
863
1246
  /** Navigate to SignIn page */
864
1247
  redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
865
1248
  /** Navigate to SignUp page */
@@ -888,12 +1271,18 @@ type TernVerificationResult = (DecodedIdToken & {
888
1271
  valid: false;
889
1272
  error: AuthErrorResponse;
890
1273
  };
1274
+ type RoutingOptions = {
1275
+ path: string | undefined;
1276
+ routing?: Extract<RoutingStrategy, 'path'>;
1277
+ } | {
1278
+ path?: never;
1279
+ routing?: Extract<RoutingStrategy, 'hash' | 'virtual'>;
1280
+ };
1281
+ type WithoutRouting<T> = Omit<T, 'path' | 'routing'>;
891
1282
  /**
892
1283
  * Props for SignIn component focusing on UI concerns
893
1284
  */
894
- type SignInProps = {
895
- /** Routing Path */
896
- path?: string;
1285
+ type SignInProps = RoutingOptions & {
897
1286
  /** URL to navigate to after successfully sign-in
898
1287
  * Use this prop to override the redirect URL when needed.
899
1288
  * @default undefined
@@ -905,18 +1294,40 @@ type SignInProps = {
905
1294
  * @default undefined
906
1295
  */
907
1296
  fallbackRedirectUrl?: string | null;
1297
+ /**
1298
+ * Full URL or path to for the sign in process.
1299
+ * Used to fill the "Sign in" link in the SignUp component.
1300
+ */
1301
+ signInUrl?: string;
1302
+ /**
1303
+ * Full URL or path to for the sign up process.
1304
+ * Used to fill the "Sign up" link in the SignUp component.
1305
+ */
1306
+ signUpUrl?: string;
1307
+ /**
1308
+ * Preferred strategy for sign-in when using email identifier.
1309
+ * Options: 'password' | 'email_code'
1310
+ * @default 'password'
1311
+ */
1312
+ preferredEmailStrategy?: 'password' | 'email_code';
1313
+ /**
1314
+ * Customize UI
1315
+ */
1316
+ appearance?: SignInTheme;
908
1317
  /** Initial form values */
909
- initialValue?: SignInInitialValue;
1318
+ initialValues?: SignInInitialValues & SignUpInitialValues;
910
1319
  /**
911
- * @deprecated this prop will be removed in future releases. Use UI configuration options instead. use onSignInSuccess
912
- *
1320
+ * Whether to show the combined email and password form.
1321
+ * If true, the email and password fields will be shown together.
1322
+ * If false, the email field will be shown first, followed by the password field.
1323
+ * @default true
913
1324
  */
914
- onSuccess?: (user: TernSecureUser | null) => void;
1325
+ showCombinedForm?: boolean;
915
1326
  } & SignUpForceRedirectUrl & SignUpFallbackRedirectUrl & AfterSignOutUrl;
916
1327
  /**
917
1328
  * Props for SignUp component focusing on UI concerns
918
1329
  */
919
- type SignUpProps = {
1330
+ type SignUpProps = RoutingOptions & {
920
1331
  /** URL to navigate to after successfully sign-up
921
1332
  * Use this prop to override the redirect URL when needed.
922
1333
  * @default undefined
@@ -928,15 +1339,60 @@ type SignUpProps = {
928
1339
  * @default undefined
929
1340
  */
930
1341
  fallbackRedirectUrl?: string | null;
1342
+ /**
1343
+ * Full URL or path to for the sign in process.
1344
+ * Used to fill the "Sign in" link in the SignUp component.
1345
+ */
1346
+ signInUrl?: string;
1347
+ /**
1348
+ * Customize UI
1349
+ */
1350
+ appearance?: SignUpTheme;
1351
+ /**
1352
+ * Whether to show the sign up form.
1353
+ * @default true
1354
+ */
1355
+ shouldShowForm?: boolean;
931
1356
  /** Initial form values */
932
- initialValue?: SignUpInitialValue;
933
- /** Callbacks */
934
- onSubmit?: (values: SignUpFormValues) => Promise<void>;
935
- onSuccess?: (user: TernSecureUser | null) => void;
1357
+ initialValues?: SignUpInitialValues;
936
1358
  } & SignInFallbackRedirectUrl & SignInForceRedirectUrl & AfterSignOutUrl;
1359
+ type UserButtonProps = {
1360
+ /**
1361
+ * Controls if the username is displayed next to the trigger button
1362
+ */
1363
+ showName?: boolean;
1364
+ /**
1365
+ * Controls the default state of the UserButton
1366
+ */
1367
+ defaultOpen?: boolean;
1368
+ /**
1369
+ * Full URL or path to navigate to on "Add another account" action.
1370
+ * Multi-session mode only.
1371
+ */
1372
+ signInUrl?: string;
1373
+ };
1374
+ type SignInModalProps = WithoutRouting<SignInProps>;
1375
+ type SignUpModalProps = WithoutRouting<SignUpProps>;
937
1376
  type SignInRedirectOptions = RedirectOptions;
938
1377
  type SignUpRedirectOptions = RedirectOptions;
939
1378
  type RoutingStrategy = 'path' | 'hash' | 'virtual';
1379
+ type __internal_ComponentNavigationContext = {
1380
+ /**
1381
+ * The `navigate` reference within the component router context
1382
+ */
1383
+ navigate: (to: string, options?: {
1384
+ searchParams?: URLSearchParams;
1385
+ }) => Promise<unknown>;
1386
+ /**
1387
+ * This path represents the root route for a specific component type and is used
1388
+ * for internal routing and navigation.
1389
+ *
1390
+ * @example
1391
+ * indexPath: '/sign-in' // When <SignIn path='/sign-in' />
1392
+ * indexPath: '/sign-up' // When <SignUp path='/sign-up' />
1393
+ */
1394
+ indexPath: string;
1395
+ };
940
1396
  /**
941
1397
  * Internal is a navigation type that affects the component
942
1398
  *
@@ -986,139 +1442,19 @@ metadata?: {
986
1442
  */
987
1443
  windowNavigate: (to: URL | string) => void;
988
1444
  }) => Promise<unknown> | unknown;
989
-
990
- /**
991
- * Defines the basic structure for color theming.
992
- */
993
- interface ThemeColors {
994
- primary?: string;
995
- secondary?: string;
996
- accent?: string;
997
- background?: string;
998
- text?: string;
999
- error?: string;
1000
- success?: string;
1001
- }
1002
- /**
1003
- * Defines the basic structure for font theming.
1004
- */
1005
- interface ThemeFonts {
1006
- primary?: string;
1007
- secondary?: string;
1008
- }
1009
- /**
1010
- * Defines the basic structure for spacing and layout theming.
1011
- */
1012
- interface ThemeSpacing {
1013
- small?: string | number;
1014
- medium?: string | number;
1015
- large?: string | number;
1016
- }
1017
- /**
1018
- * Defines the basic structure for border radius theming.
1019
- */
1020
- interface ThemeBorderRadius {
1021
- small?: string | number;
1022
- medium?: string | number;
1023
- large?: string | number;
1024
- }
1025
- /**
1026
- * Allows for overriding styles of specific UI components.
1027
- * Properties can be CSS-in-JS objects or class names, depending on implementation.
1028
- */
1029
- interface ThemeComponentStyles {
1030
- button?: Record<string, any> | string;
1031
- input?: Record<string, any> | string;
1032
- card?: Record<string, any> | string;
1033
- label?: Record<string, any> | string;
1034
- }
1035
- /**
1036
- * Defines the overall appearance/theme configuration.
1037
- * This allows for broad customization of the UI components.
1038
- */
1039
- interface Appearance {
1040
- colors?: ThemeColors;
1041
- fonts?: ThemeFonts;
1042
- spacing?: ThemeSpacing;
1043
- borderRadius?: ThemeBorderRadius;
1044
- componentStyles?: ThemeComponentStyles;
1045
- variables?: Record<string, string | number>;
1046
- }
1047
- /**
1048
- * Base UI configuration shared between SignIn and SignUp
1049
- */
1050
- interface BaseAuthUIConfig {
1051
- /** Visual appearance configuration */
1052
- appearance?: Appearance;
1053
- /** Application logo URL or SVG string */
1054
- logo?: string;
1055
- /** Application name for display */
1056
- appName?: string;
1057
- /** Render mode for cross-platform support */
1058
- renderMode?: 'modal' | 'page' | 'embedded';
1059
- /** Layout direction */
1060
- layout?: 'vertical' | 'horizontal';
1061
- /** Custom loading message */
1062
- loadingMessage?: string;
1063
- /** Loading spinner variant */
1064
- loadingSpinnerVariant?: 'circular' | 'linear' | 'dots';
1065
- /** Accessibility configuration */
1066
- a11y?: {
1067
- /** ARIA labels and descriptions */
1068
- labels?: Record<string, string>;
1069
- /** Element to receive initial focus */
1070
- initialFocus?: string;
1071
- /** Whether to trap focus within the auth UI */
1072
- trapFocus?: boolean;
1073
- };
1074
- }
1075
- /**
1076
- * Sign-in specific UI configuration
1077
- */
1078
- interface SignInUIConfig extends BaseAuthUIConfig {
1079
- /** Social sign-in buttons configuration */
1080
- socialButtons?: {
1081
- google?: boolean;
1082
- microsoft?: boolean;
1083
- github?: boolean;
1084
- facebook?: boolean;
1085
- twitter?: boolean;
1086
- apple?: boolean;
1087
- linkedin?: boolean;
1088
- layout?: 'vertical' | 'horizontal';
1089
- size?: 'small' | 'medium' | 'large';
1090
- };
1091
- /** "Remember me" checkbox configuration */
1092
- rememberMe?: {
1093
- enabled?: boolean;
1094
- defaultChecked?: boolean;
1095
- };
1096
- /** Sign-up link configuration */
1097
- signUpLink?: {
1098
- enabled?: boolean;
1099
- text?: string;
1100
- href?: string;
1101
- };
1102
- }
1103
- /**
1104
- * Sign-up specific UI configuration
1105
- */
1106
- interface SignUpUIConfig extends BaseAuthUIConfig {
1107
- /** Password requirements display configuration */
1108
- passwordRequirements?: {
1109
- show?: boolean;
1110
- rules?: Array<{
1111
- rule: string;
1112
- description: string;
1113
- }>;
1114
- };
1115
- /** Terms and conditions configuration */
1116
- terms?: {
1117
- enabled?: boolean;
1118
- text?: string;
1119
- link?: string;
1120
- };
1121
- }
1445
+ type SignInInitialValues = {
1446
+ emailAddress?: string;
1447
+ phoneNumber?: string;
1448
+ username?: string;
1449
+ };
1450
+ type SignUpInitialValues = {
1451
+ emailAddress?: string;
1452
+ phoneNumber?: string;
1453
+ firstName?: string;
1454
+ lastName?: string;
1455
+ displayName?: string;
1456
+ username?: string;
1457
+ };
1122
1458
 
1123
1459
  type Mode = 'browser' | 'server';
1124
1460
  type TernSecureSDK = {
@@ -1282,19 +1618,6 @@ type SignUpPropsTree = {
1282
1618
  type SignInRedirectOptionss = RedirectOptions;
1283
1619
  type SignUpRedirectOptionss = RedirectOptions;
1284
1620
 
1285
- interface TernSecureApiErrorJSON {
1286
- code: string;
1287
- message: string;
1288
- }
1289
- interface TernSecureFireRestErrorJSON extends TernSecureApiErrorJSON {
1290
- domain: string;
1291
- reason: string;
1292
- }
1293
- interface SessionJson extends IdTokenResult {
1294
- status: SessionStatus;
1295
- user?: TernSecureUser;
1296
- }
1297
-
1298
1621
  type UseAuthReturn = {
1299
1622
  userId: string | null | undefined;
1300
1623
  isLoaded: boolean;
@@ -1335,5 +1658,13 @@ type DomainOrProxyUrl = {
1335
1658
  * @internal
1336
1659
  */
1337
1660
  type Autocomplete<U extends T, T = string> = U | (T & Record<never, never>);
1661
+ /**
1662
+ * Omit without union flattening
1663
+ * */
1664
+ type Without<T, W> = {
1665
+ [P in keyof T as Exclude<P, W>]: T[P];
1666
+ };
1667
+
1668
+ type Attribute = 'email_address' | 'phone_number' | 'username' | 'first_name' | 'last_name' | 'password' | 'web3_wallet' | 'authenticator_app' | 'backup_code' | 'passkey';
1338
1669
 
1339
- export { type ActiveSession, type AdminConfigValidationResult, type AfterSignOutUrl, type Appearance, type AuthEndpoint, type AuthErrorCode, type AuthErrorResponse, type AuthErrorTree, type AuthProviderStatus, type Autocomplete, type BaseAuthUIConfig, type CheckAuthorizationFromSessionClaims, type CheckCustomClaims, type ConfigValidationResult, type CookieEndpointConfig, type CookieOptions, type CookieOpts, type CookieResource, type CookieStore, type CookieSubEndpoint, type CorsOptions, type CreateActiveSession, type CreateActiveSessionParams, type CustomNavigation, DEFAULT_TERN_SECURE_STATE, type DecodedIdToken, type DomainOrProxyUrl, ERRORS, type EndpointConfig, type ErrorCode, type ExpiredSession, type FirebaseClaims, type FirebaseState, type IdTokenResult, type InitialState, type InstanceType, type JWTPayload, type JWTProtectedHeader, type Jwt, type LegacyRedirectProps, type ListenerCallback, type NavigateOptions, type ParsedToken, type PendingSession, type Persistence, type ProviderUserInfo, type RateLimitOptions, type RedirectOptions, type RedirectUrlProp, type ResendEmailVerification, type RoutingStrategy, type SecurityOptions, type ServerConfigValidationResult, type SessionCookieConfig, type SessionEndpointConfig, type SessionJson, type SessionParams, type SessionResource, type SessionResult, type SessionStatus, type SessionSubEndpoint, type SharedSignInAuthObjectProperties, type SignInErrorResponse, type SignInFallbackRedirectUrl, type SignInForceRedirectUrl, type SignInFormValues, type SignInInitialValue, type SignInPendingResponse, type SignInProps, type SignInPropsTree, type SignInRedirectOptions, type SignInRedirectOptionss, type SignInResource, type SignInResponse, type SignInStatus, type SignInSuccessResponse, type SignInUIConfig, type SignOut, type SignOutOptions, type SignOutOptionsTree, type SignUpErrorResponse, type SignUpFallbackRedirectUrl, type SignUpForceRedirectUrl, type SignUpFormValues, type SignUpFormValuesTree, type SignUpInitialValue, type SignUpInitialValueTree, type SignUpProps, type SignUpPropsTree, type SignUpRedirectOptions, type SignUpRedirectOptionss, type SignUpResource, type SignUpResponse, type SignUpStatus, type SignUpSuccessResponse, type SignUpUIConfig, type SignedInSession, type SocialProviderOptions, type TernAuthEventPayload, type TernAuthListenerEvent, type TernAuthListenerEventPayload, type TernAuthSDK, type TernSecureAPIError, type TernSecureAdminConfig, type TernSecureApiErrorJSON, type TernSecureAuth, type TernSecureAuthFactory, type TernSecureAuthOptions, type TernSecureAuthProvider, type TernSecureAuthStatus, type TernSecureConfig, type TernSecureFireRestError, type TernSecureFireRestErrorJSON, type TernSecureHandlerOptions, type TernSecureInitialState, type TernSecureInstance, type TernSecureInstanceTree, type TernSecureInstanceTreeOptions, type TernSecureInstanceTreeStatus, type TernSecureOptions, type TernSecureResources, type TernSecureSDK, type TernSecureServerConfig, type TernSecureSessionTree, type TernSecureState, type TernSecureStateExtended, type TernSecureUser, type TernSecureUserData, type TernVerificationResult, type ThemeBorderRadius, type ThemeColors, type ThemeComponentStyles, type ThemeFonts, type ThemeSpacing, type TokenCookieConfig, type UnsubscribeCallback, type UseAuthReturn, type UseSignInReturn, type UseSignUpReturn, type UserCredential, type UserInfo, type VerifiedTokens, isSignInResponseTree };
1670
+ export { type ActiveSession, type AdminConfigValidationResult, type AfterSignOutUrl, type AppCheckConfig, type Appearance, type AttemptFirstFactorParams, type Attribute, type AuthEndpoint, type AuthErrorCode, type AuthErrorResponse, type AuthErrorTree, type AuthProviderStatus, type Autocomplete, type BackupCodeAttempt, type BackupCodeFactor, type BaseAuthUIConfig, type CheckAuthorizationFromSessionClaims, type CheckCustomClaims, type ConfigValidationResult, type CookieEndpointConfig, type CookieOptions, type CookieOpts, type CookieResource, type CookieStore, type CookieSubEndpoint, type CorsOptions, type CreateActiveSession, type CreateActiveSessionParams, type CustomNavigation, DEFAULT_TERN_SECURE_STATE, type DecodedIdToken, type DomainOrProxyUrl, ERRORS, type EmailCodeAttempt, type EmailCodeConfig, type EmailCodeFactor, type EmailLinkConfig, type EmailLinkFactor, type EndpointConfig, type EnterpriseSSOConfig, type EnterpriseSSOFactor, type ErrorCode, type ExpiredSession, type FirebaseClaims, type FirebaseState, type IdTokenResult, type InitialState, type InstanceType, type JWTPayload, type JWTProtectedHeader, type Jwt, type Layout, type LegacyRedirectProps, type ListenerCallback, type NavigateOptions, type ParsedToken, type PassKeyConfig, type PasskeyFactor, type PasswordAttempt, type PasswordFactor, type PendingSession, type Persistence, type PhoneCodeAttempt, type PhoneCodeConfig, type PhoneCodeFactor, type PhoneCodeSecondFactorConfig, type ProviderUserInfo, type RateLimitOptions, type RedirectOptions, type RedirectUrlProp, type ResendEmailVerification, type ResetPasswordCodeFactor, type ResetPasswordEmailCodeAttempt, type ResetPasswordEmailCodeFactor, type ResetPasswordEmailCodeFactorConfig, type ResetPasswordPhoneCodeAttempt, type ResetPasswordPhoneCodeFactor, type ResetPasswordPhoneCodeFactorConfig, type RoutingOptions, type RoutingStrategy, type SecurityOptions, type ServerConfigValidationResult, type SessionCookieConfig, type SessionEndpointConfig, type SessionJson, type SessionParams, type SessionResource, type SessionResult, type SessionStatus, type SessionSubEndpoint, type SharedSignInAuthObjectProperties, type SignInCreateParams, type SignInEndpointConfig, type SignInErrorResponse, type SignInFactor, type SignInFallbackRedirectUrl, type SignInFirstFactor, type SignInForceRedirectUrl, type SignInInitialValue, type SignInInitialValues, type SignInJson, type SignInModalProps, type SignInPasswordParams, type SignInPendingResponse, type SignInPhoneParams, type SignInProps, type SignInPropsTree, type SignInRedirectOptions, type SignInRedirectOptionss, type SignInResource, type SignInResponse, type SignInSecondFactor, type SignInStatus, type SignInSubEndpoint, type SignInSuccessResponse, type SignInTheme, type SignInUIConfig, type SignInVerificationResponse, type SignOut, type SignOutOptions, type SignOutOptionsTree, type SignUpErrorResponse, type SignUpFallbackRedirectUrl, type SignUpForceRedirectUrl, type SignUpFormValues, type SignUpFormValuesTree, type SignUpInitialValue, type SignUpInitialValueTree, type SignUpInitialValues, type SignUpJson, type SignUpMissingRequirementsResponse, type SignUpModalProps, type SignUpProps, type SignUpPropsTree, type SignUpRedirectOptions, type SignUpRedirectOptionss, type SignUpResource, type SignUpResponse, type SignUpStatus, type SignUpSuccessResponse, type SignUpTheme, type SignUpUIConfig, type SignedInSession, type SocialProviderOptions, type TOTPAttempt, type TOTPFactor, type TernAuthEventPayload, type TernAuthListenerEvent, type TernAuthListenerEventPayload, type TernAuthSDK, type TernSecureAPIError, type TernSecureAdminConfig, type TernSecureApiErrorJSON, type TernSecureAuth, type TernSecureAuthFactory, type TernSecureAuthOptions, type TernSecureAuthProvider, type TernSecureAuthStatus, type TernSecureConfig, type TernSecureFireRestError, type TernSecureFireRestErrorJSON, type TernSecureHandlerOptions, type TernSecureInitialState, type TernSecureInstance, type TernSecureInstanceTree, type TernSecureInstanceTreeOptions, type TernSecureInstanceTreeStatus, type TernSecureOptions, type TernSecureResourceJSON, type TernSecureResources, type TernSecureSDK, type TernSecureServerConfig, type TernSecureSessionTree, type TernSecureState, type TernSecureStateExtended, type TernSecureTheme, type TernSecureUser, type TernSecureUserData, type TernVerificationResult, type ThemeBorderRadius, type ThemeColors, type ThemeComponentStyles, type ThemeFonts, type ThemeSpacing, type TokenCookieConfig, type UnsubscribeCallback, type UnverifiedField, type UseAuthReturn, type UseSignInReturn, type UseSignUpReturn, type UserButtonProps, type UserCredential, type UserInfo, type VerifiedTokens, type Without, type WithoutRouting, type __internal_ComponentNavigationContext, isSignInResponseTree };