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

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,12 @@ 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
+ debugToken?: string | boolean;
183
+ }
178
184
 
179
185
  interface TernSecureAPIError {
180
186
  code: string;
@@ -247,9 +253,10 @@ declare const ERRORS: {
247
253
  readonly REDIRECT_LOOP: "Redirect loop detected.";
248
254
  };
249
255
 
250
- type AuthEndpoint = 'cookies' | 'sessions' | 'users';
256
+ type AuthEndpoint = 'cookies' | 'sessions' | 'users' | 'sign_ins';
251
257
  type CookieSubEndpoint = 'get' | 'set' | 'delete' | 'clear' | 'list';
252
258
  type SessionSubEndpoint = 'verify' | 'createsession' | 'refresh' | 'revoke';
259
+ type SignInSubEndpoint = 'create' | 'resetPasswordEmail';
253
260
  interface CorsOptions {
254
261
  allowedOrigins: string[] | '*';
255
262
  allowedMethods?: string[];
@@ -313,6 +320,11 @@ interface SessionEndpointConfig extends EndpointConfig {
313
320
  [K in SessionSubEndpoint]?: Partial<EndpointConfig>;
314
321
  };
315
322
  }
323
+ interface SignInEndpointConfig extends EndpointConfig {
324
+ subEndpoints?: {
325
+ [K in SignInSubEndpoint]?: Partial<EndpointConfig>;
326
+ };
327
+ }
316
328
  interface TernSecureHandlerOptions {
317
329
  cors?: CorsOptions;
318
330
  cookies?: CookieOpts;
@@ -321,6 +333,7 @@ interface TernSecureHandlerOptions {
321
333
  endpoints?: {
322
334
  cookies?: CookieEndpointConfig;
323
335
  sessions?: SessionEndpointConfig;
336
+ signIns?: SignInEndpointConfig;
324
337
  };
325
338
  tenantId?: string | null;
326
339
  revokeRefreshTokensOnSignOut?: boolean;
@@ -378,10 +391,32 @@ interface SessionResource extends IdTokenResult {
378
391
  getIdAndRefreshToken: (idToken: string, csrfToken: string) => Promise<void>;
379
392
  }
380
393
 
394
+ interface TernSecureApiErrorJSON {
395
+ code: string;
396
+ message: string;
397
+ }
398
+ interface TernSecureFireRestErrorJSON extends TernSecureApiErrorJSON {
399
+ domain: string;
400
+ reason: string;
401
+ }
402
+ interface SessionJson extends IdTokenResult {
403
+ status: SessionStatus;
404
+ user?: TernSecureUser;
405
+ }
406
+ /**
407
+ * Currently representing API DTOs in their JSON form.
408
+ */
409
+ interface TernSecureResourceJSON {
410
+ id: string;
411
+ object: string;
412
+ }
413
+
414
+ type UnverifiedField = 'email_address' | 'phone_number';
381
415
  interface BaseSignUpResponse {
382
416
  status?: SignUpStatus;
383
417
  message?: string;
384
- error?: any | undefined;
418
+ error?: any;
419
+ unverifiedFields?: UnverifiedField[];
385
420
  }
386
421
  interface SignUpSuccessResponse extends BaseSignUpResponse, UserCredential {
387
422
  status: 'complete';
@@ -389,24 +424,23 @@ interface SignUpSuccessResponse extends BaseSignUpResponse, UserCredential {
389
424
  interface SignUpErrorResponse extends BaseSignUpResponse {
390
425
  status: 'error';
391
426
  }
392
- type SignUpResponse = SignUpSuccessResponse | SignUpErrorResponse;
427
+ interface SignUpMissingRequirementsResponse extends BaseSignUpResponse, UserCredential {
428
+ status: 'missing_requirements';
429
+ unverifiedFields: UnverifiedField[];
430
+ }
431
+ type SignUpResponse = SignUpSuccessResponse | SignUpErrorResponse | SignUpMissingRequirementsResponse;
393
432
  type SignUpFormValues = {
394
433
  email: string;
395
434
  password: string;
396
435
  };
397
- type SignUpInitialValue = {
398
- email: string;
399
- password: string;
400
- };
436
+ type SignUpInitialValue = Partial<SignUpFormValues>;
401
437
  interface SignUpResource {
402
438
  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>;
439
+ user: TernSecureUser | null;
440
+ unverifiedFields?: UnverifiedField[];
441
+ message?: string;
442
+ error?: any;
443
+ withEmailAndPassword: (params: SignUpFormValues) => Promise<SignUpResource>;
410
444
  /**
411
445
  * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
412
446
  * @param options - Optional configuration for the social sign-in flow.
@@ -415,8 +449,22 @@ interface SignUpResource {
415
449
  withSocialProvider: (provider: string, options?: {
416
450
  mode?: 'popup' | 'redirect';
417
451
  }) => Promise<SignUpResponse | void>;
452
+ /**
453
+ * Sends an email verification link to the user's email address.
454
+ * @param options - Optional configuration for the verification email.
455
+ * @returns A promise that resolves with the updated SignUpResource.
456
+ */
457
+ attemptEmailVerification: (options?: {
458
+ url?: string;
459
+ handleCodeInApp?: boolean;
460
+ }) => Promise<SignUpResource>;
418
461
  }
419
462
  type SignUpStatus = 'missing_requirements' | 'complete' | 'abandoned' | 'error';
463
+ interface SignUpJson extends TernSecureResourceJSON {
464
+ object: 'sign_up';
465
+ id: string;
466
+ status: SignUpStatus;
467
+ }
420
468
 
421
469
  interface FirebaseClaims {
422
470
  identities: {
@@ -534,11 +582,129 @@ type AfterSignOutUrl = {
534
582
  afterSignOutUrl?: string | null;
535
583
  };
536
584
 
537
- type SignInStatus = 'idle' | 'pending_email_password' | 'pending_social' | 'pending_mfa' | 'redirecting' | 'success' | 'error';
585
+ type PasskeyStrategy = 'passkey';
586
+ type PasswordStrategy = 'password';
587
+ type PhoneCodeStrategy = 'phone_code';
588
+ type EmailCodeStrategy = 'email_code';
589
+ type EmailLinkStrategy = 'email_link';
590
+ type TOTPStrategy = 'totp';
591
+ type BackupCodeStrategy = 'backup_code';
592
+ type ResetPasswordPhoneCodeStrategy = 'reset_password_phone_code';
593
+ type ResetPasswordEmailCodeStrategy = 'reset_password_email_code';
594
+ type EnterpriseSSOStrategy = 'enterprise_sso';
595
+
596
+ type EmailCodeFactor = {
597
+ strategy: EmailCodeStrategy;
598
+ emailAddressId: string;
599
+ safeIdentifier: string;
600
+ primary?: boolean;
601
+ };
602
+ type EmailLinkFactor = {
603
+ strategy: EmailLinkStrategy;
604
+ emailAddressId: string;
605
+ safeIdentifier: string;
606
+ primary?: boolean;
607
+ };
608
+ type PhoneCodeFactor = {
609
+ strategy: PhoneCodeStrategy;
610
+ phoneNumberId: string;
611
+ safeIdentifier: string;
612
+ primary?: boolean;
613
+ default?: boolean;
614
+ };
615
+ type PasswordFactor = {
616
+ strategy: PasswordStrategy;
617
+ };
618
+ type PasskeyFactor = {
619
+ strategy: PasskeyStrategy;
620
+ };
621
+ type EnterpriseSSOFactor = {
622
+ strategy: EnterpriseSSOStrategy;
623
+ };
624
+ type TOTPFactor = {
625
+ strategy: TOTPStrategy;
626
+ };
627
+ type BackupCodeFactor = {
628
+ strategy: BackupCodeStrategy;
629
+ };
630
+ type ResetPasswordPhoneCodeFactor = {
631
+ strategy: ResetPasswordPhoneCodeStrategy;
632
+ phoneNumberId: string;
633
+ safeIdentifier: string;
634
+ primary?: boolean;
635
+ };
636
+ type ResetPasswordEmailCodeFactor = {
637
+ strategy: ResetPasswordEmailCodeStrategy;
638
+ emailAddressId: string;
639
+ safeIdentifier: string;
640
+ primary?: boolean;
641
+ };
642
+ type ResetPasswordCodeFactor = ResetPasswordEmailCodeFactor | ResetPasswordPhoneCodeFactor;
643
+ type ResetPasswordPhoneCodeFactorConfig = Omit<ResetPasswordPhoneCodeFactor, 'safeIdentifier'>;
644
+ type ResetPasswordEmailCodeFactorConfig = Omit<ResetPasswordEmailCodeFactor, 'safeIdentifier'>;
645
+ type EmailCodeConfig = Omit<EmailCodeFactor, 'safeIdentifier'>;
646
+ type EmailLinkConfig = Omit<EmailLinkFactor, 'safeIdentifier'> & {
647
+ redirectUrl: string;
648
+ };
649
+ type PhoneCodeConfig = Omit<PhoneCodeFactor, 'safeIdentifier'>;
650
+ type PassKeyConfig = PasskeyFactor;
651
+ type EnterpriseSSOConfig = EnterpriseSSOFactor & {
652
+ redirectUrl: string;
653
+ actionCompleteRedirectUrl: string;
654
+ oidcPrompt?: string;
655
+ };
656
+ type PhoneCodeSecondFactorConfig = {
657
+ strategy: PhoneCodeStrategy;
658
+ phoneNumberId?: string;
659
+ };
660
+ type EmailCodeAttempt = {
661
+ strategy: EmailCodeStrategy;
662
+ code: string;
663
+ };
664
+ type PhoneCodeAttempt = {
665
+ strategy: PhoneCodeStrategy;
666
+ code: string;
667
+ };
668
+ type PasswordAttempt = {
669
+ strategy: PasswordStrategy;
670
+ password: string;
671
+ };
672
+ type TOTPAttempt = {
673
+ strategy: TOTPStrategy;
674
+ code: string;
675
+ };
676
+ type BackupCodeAttempt = {
677
+ strategy: BackupCodeStrategy;
678
+ code: string;
679
+ };
680
+ type ResetPasswordPhoneCodeAttempt = {
681
+ strategy: ResetPasswordPhoneCodeStrategy;
682
+ code: string;
683
+ password?: string;
684
+ };
685
+ type ResetPasswordEmailCodeAttempt = {
686
+ strategy: ResetPasswordEmailCodeStrategy;
687
+ code: string;
688
+ password?: string;
689
+ };
690
+
691
+ 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
692
  type SignInFormValues = {
693
+ email?: string;
694
+ password?: string;
695
+ phoneNumber?: string;
696
+ };
697
+ /**
698
+ * @deprecated
699
+ */
700
+ type SignInInitialValue = Partial<SignInFormValues>;
701
+ type SignInPasswordParams = {
539
702
  email: string;
540
703
  password: string;
541
- phoneNumber?: string;
704
+ };
705
+ type SignInPhoneParams = {
706
+ phoneNumber: string;
707
+ appVerifier?: any;
542
708
  };
543
709
  interface AuthErrorResponse {
544
710
  success: false;
@@ -565,7 +731,6 @@ interface SignInPendingResponse extends BaseSignInResponse {
565
731
  status: 'redirecting' | 'pending_social' | 'pending_email_password';
566
732
  }
567
733
  type SignInResponse = SignInSuccessResponse | SignInErrorResponse | SignInPendingResponse;
568
- type SignInInitialValue = Partial<SignInFormValues>;
569
734
  interface ResendEmailVerification {
570
735
  isVerified?: boolean;
571
736
  }
@@ -581,46 +746,230 @@ interface SocialProviderOptions {
581
746
  /** OAuth scopes to request from the provider */
582
747
  scopes?: string[];
583
748
  }
749
+ interface SignInVerificationResponse {
750
+ status: SignInStatus;
751
+ message?: string;
752
+ error?: any;
753
+ }
584
754
  interface SignInResource {
755
+ status: SignInStatus | null;
756
+ supportedFirstFactors: SignInFirstFactor[] | null;
757
+ identifier: string | null;
758
+ user?: TernSecureUser | null;
585
759
  /**
586
- * The current status of the sign-in process.
760
+ * Create combine email and phone sign in method
587
761
  */
588
- status: SignInStatus | null;
762
+ create: (params: SignInCreateParams) => Promise<SignInResource>;
763
+ authenticateWithPassword: (params: SignInPasswordParams) => Promise<SignInResponse>;
764
+ createRecaptchaVerifier: (containerOrId: string | HTMLElement, parameters?: any) => any;
765
+ authenticateWithPhoneNumber: (params: SignInPhoneParams) => Promise<SignInResponse>;
766
+ authenticateWithSocialProvider: (provider: string, options: SocialProviderOptions) => Promise<SignInResponse>;
767
+ completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponse>;
768
+ sendPasswordResetEmail: (email: string) => Promise<{
769
+ response: {
770
+ email: string;
771
+ };
772
+ } | null>;
773
+ attemptEmailVerification: (options?: {
774
+ url?: string;
775
+ handleCodeInApp?: boolean;
776
+ }) => Promise<SignInVerificationResponse>;
777
+ attemptFirstFactor: (params: AttemptFirstFactorParams) => Promise<SignInResource>;
778
+ attemptPhoneNumberVerification: (params: {
779
+ code: string;
780
+ }) => Promise<SignInResponse>;
781
+ checkRedirectResult: () => Promise<SignInResponse | null>;
782
+ }
783
+ type SignInFirstFactor = EmailCodeFactor | PasswordFactor;
784
+ type SignInSecondFactor = PhoneCodeFactor | TOTPFactor | BackupCodeFactor;
785
+ type SignInFactor = SignInFirstFactor | SignInSecondFactor;
786
+ type SignInCreateParams = ({
787
+ strategy: PasswordStrategy;
788
+ password?: string;
789
+ identifier: string;
790
+ } | {
791
+ strategy: PhoneCodeStrategy | EmailCodeStrategy | ResetPasswordEmailCodeStrategy | ResetPasswordPhoneCodeStrategy;
792
+ identifier: string;
793
+ });
794
+ type AttemptFirstFactorParams = EmailCodeAttempt | PhoneCodeAttempt | PasswordAttempt | ResetPasswordPhoneCodeAttempt | ResetPasswordEmailCodeAttempt;
795
+ interface SignInJson extends TernSecureResourceJSON {
796
+ object: 'sign_in';
797
+ id: string;
798
+ status: SignInStatus;
799
+ supportedFirstFactors: SignInFirstFactor[];
800
+ firstFactorVerification?: SignInFirstFactor;
801
+ secondFactorVerification?: SignInSecondFactor;
802
+ identifier: string | null;
803
+ }
804
+
805
+ /**
806
+ * Defines the basic structure for color theming.
807
+ */
808
+ interface ThemeColors {
809
+ primary?: string;
810
+ secondary?: string;
811
+ accent?: string;
812
+ background?: string;
813
+ text?: string;
814
+ error?: string;
815
+ success?: string;
816
+ }
817
+ /**
818
+ * Defines the basic structure for font theming.
819
+ */
820
+ interface ThemeFonts {
821
+ primary?: string;
822
+ secondary?: string;
823
+ }
824
+ /**
825
+ * Defines the basic structure for spacing and layout theming.
826
+ */
827
+ interface ThemeSpacing {
828
+ small?: string | number;
829
+ medium?: string | number;
830
+ large?: string | number;
831
+ }
832
+ /**
833
+ * Defines the basic structure for border radius theming.
834
+ */
835
+ interface ThemeBorderRadius {
836
+ small?: string | number;
837
+ medium?: string | number;
838
+ large?: string | number;
839
+ }
840
+ /**
841
+ * Allows for overriding styles of specific UI components.
842
+ * Properties can be CSS-in-JS objects or class names, depending on implementation.
843
+ */
844
+ interface ThemeComponentStyles {
845
+ button?: Record<string, any> | string;
846
+ input?: Record<string, any> | string;
847
+ card?: Record<string, any> | string;
848
+ label?: Record<string, any> | string;
849
+ }
850
+ /**
851
+ * Defines the overall appearance/theme configuration.
852
+ * This allows for broad customization of the UI components.
853
+ */
854
+ interface Appearance {
855
+ colors?: ThemeColors;
856
+ fonts?: ThemeFonts;
857
+ spacing?: ThemeSpacing;
858
+ borderRadius?: ThemeBorderRadius;
859
+ componentStyles?: ThemeComponentStyles;
860
+ variables?: Record<string, string | number>;
861
+ }
862
+ type Layout = {
589
863
  /**
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.
864
+ * @default inside
593
865
  */
594
- withEmailAndPassword: (params: SignInFormValues) => Promise<SignInResponse>;
866
+ logoPlacement?: 'inside' | 'outside' | 'none';
595
867
  /**
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.
868
+ * @default undefined
599
869
  */
600
- withSocialProvider: (provider: string, options: SocialProviderOptions) => Promise<SignInResponse>;
870
+ logoImageUrl?: string;
601
871
  /**
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.
872
+ * @default undefined
606
873
  */
607
- completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponse>;
874
+ logoLinkUrl?: string;
608
875
  /**
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.
876
+ * @default auto
612
877
  */
613
- sendPasswordResetEmail: (email: string) => Promise<void>;
878
+ socialButtonsVariant?: 'auto' | 'iconButton' | 'blockButton';
614
879
  /**
615
- * Resends the email verification link to the user's email address.
616
- * @returns A promise that resolves with the sign-in response.
880
+ * @default bottom
617
881
  */
618
- resendEmailVerification: () => Promise<ResendEmailVerification>;
882
+ socialButtonsPlacement?: 'top' | 'bottom';
619
883
  /**
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.
884
+ * enables "Terms" link
622
885
  */
623
- checkRedirectResult: () => Promise<SignInResponse | null>;
886
+ termsPageUrl?: string;
887
+ /**
888
+ * enables "Help" link
889
+ */
890
+ helpPageUrl?: string;
891
+ /**
892
+ * enables "Privacy Policy" link
893
+ */
894
+ privacyPageUrl?: string;
895
+ };
896
+ type TernSecureTheme = {
897
+ appearance?: Appearance;
898
+ layout?: Layout;
899
+ };
900
+ type SignInTheme = TernSecureTheme;
901
+ type SignUpTheme = TernSecureTheme;
902
+ /**
903
+ * Base UI configuration shared between SignIn and SignUp
904
+ * @deprecated Use TernSecureTheme instead.
905
+ */
906
+ interface BaseAuthUIConfig {
907
+ /** Visual appearance configuration */
908
+ appearance?: Appearance;
909
+ /** Application logo URL or SVG string */
910
+ logo?: string;
911
+ /** Application name for display */
912
+ appName?: string;
913
+ /** Render mode for cross-platform support */
914
+ renderMode?: 'modal' | 'page' | 'embedded';
915
+ /** Layout direction */
916
+ layout?: 'vertical' | 'horizontal';
917
+ /** Custom loading message */
918
+ loadingMessage?: string;
919
+ /** Loading spinner variant */
920
+ loadingSpinnerVariant?: 'circular' | 'linear' | 'dots';
921
+ /** Accessibility configuration */
922
+ a11y?: {
923
+ /** ARIA labels and descriptions */
924
+ labels?: Record<string, string>;
925
+ /** Element to receive initial focus */
926
+ initialFocus?: string;
927
+ /** Whether to trap focus within the auth UI */
928
+ trapFocus?: boolean;
929
+ };
930
+ }
931
+ /**
932
+ * Sign-in specific UI configuration
933
+ * @deprecated Use SignInTheme instead.
934
+ */
935
+ interface SignInUIConfig extends BaseAuthUIConfig {
936
+ /** Social sign-in buttons configuration */
937
+ socialButtons?: {
938
+ google?: boolean;
939
+ microsoft?: boolean;
940
+ github?: boolean;
941
+ facebook?: boolean;
942
+ twitter?: boolean;
943
+ apple?: boolean;
944
+ linkedin?: boolean;
945
+ layout?: 'vertical' | 'horizontal';
946
+ size?: 'small' | 'medium' | 'large';
947
+ };
948
+ /** "Remember me" checkbox configuration */
949
+ rememberMe?: {
950
+ enabled?: boolean;
951
+ defaultChecked?: boolean;
952
+ };
953
+ }
954
+ /**
955
+ * Sign-up specific UI configuration
956
+ * @deprecated Use SignUpTheme instead.
957
+ */
958
+ interface SignUpUIConfig extends BaseAuthUIConfig {
959
+ /** Password requirements display configuration */
960
+ passwordRequirements?: {
961
+ show?: boolean;
962
+ rules?: Array<{
963
+ rule: string;
964
+ description: string;
965
+ }>;
966
+ };
967
+ /** Terms and conditions configuration */
968
+ terms?: {
969
+ enabled?: boolean;
970
+ text?: string;
971
+ link?: string;
972
+ };
624
973
  }
625
974
 
626
975
  /**
@@ -740,8 +1089,13 @@ type TernSecureAuthOptions = TernSecureOptionsNavigation & SignInForceRedirectUr
740
1089
  sdkMetadata?: TernAuthSDK;
741
1090
  signInUrl?: string;
742
1091
  signUpUrl?: string;
1092
+ signUpMode?: 'public' | 'restricted' | 'waitlist';
1093
+ passwordAuthentication?: boolean;
743
1094
  mode?: Mode$1;
744
1095
  requiresVerification?: boolean;
1096
+ /**
1097
+ * @deprecated will be removed in future releases. please use ternUIUrl
1098
+ */
745
1099
  isTernSecureDev?: boolean;
746
1100
  ternSecureConfig?: TernSecureConfig;
747
1101
  persistence?: Persistence;
@@ -758,6 +1112,10 @@ type TernSecureAuthOptions = TernSecureOptionsNavigation & SignInForceRedirectUr
758
1112
  /** rethrow network errors that occur while the offline */
759
1113
  rethrowOfflineNetworkErrors?: boolean;
760
1114
  };
1115
+ /**
1116
+ * ReCaptcha V3 Site Key for Firebase App Check
1117
+ */
1118
+ appCheck?: AppCheckConfig;
761
1119
  };
762
1120
  /**
763
1121
  * @deprecated will be removed in future releases.
@@ -808,10 +1166,16 @@ interface TernSecureAuth {
808
1166
  isLoading: boolean;
809
1167
  /** The current status of the TernSecureAuth instance */
810
1168
  status: TernSecureAuthStatus;
1169
+ /** The Firebase App instance */
1170
+ firebaseApp?: any;
1171
+ /** The Firebase App Check instance */
1172
+ appCheck?: any;
811
1173
  /** TernSecure API URL */
812
1174
  apiUrl: string;
813
1175
  /** TernSecure domain for API string */
814
- domain: string;
1176
+ authDomain: string;
1177
+ /** TernSecure Frontend domain for TernSecure UI */
1178
+ frontEndDomain?: string;
815
1179
  /** TernSecure Proxy url */
816
1180
  proxyUrl?: string;
817
1181
  /** TernSecure Instance type */
@@ -844,6 +1208,32 @@ interface TernSecureAuth {
844
1208
  onAuthStateChanged(callback: (cb: any) => void): () => void;
845
1209
  /** Sign out the current user */
846
1210
  signOut: SignOut;
1211
+ /** Mounts a sign-in component
1212
+ * @param targetNode HTMLDivElement where the component will be mounted
1213
+ * @param signInProps Configuration options for the sign-in component
1214
+ */
1215
+ showSignIn: (targetNode: HTMLDivElement, config?: SignInProps) => void;
1216
+ /** Unmount sign-in component
1217
+ * @param targetNode HTMLDivElement where the component is mounted
1218
+ */
1219
+ hideSignIn: (targetNode: HTMLDivElement) => void;
1220
+ /** Mounts a sign-up component
1221
+ * @param targetNode HTMLDivElement where the component will be mounted
1222
+ * @param signUpProps Configuration options for the sign-up component
1223
+ */
1224
+ showSignUp: (targetNode: HTMLDivElement, config?: SignUpProps) => void;
1225
+ /** Unmount sign-up component
1226
+ * @param targetNode HTMLDivElement where the component is mounted
1227
+ */
1228
+ hideSignUp: (targetNode: HTMLDivElement) => void;
1229
+ /** Mounts a user button component
1230
+ * @param targetNode HTMLDivElement where the component will be mounted
1231
+ */
1232
+ showUserButton: (targetNode: HTMLDivElement) => void;
1233
+ /** Unmount user button component
1234
+ * @param targetNode HTMLDivElement where the component is mounted
1235
+ */
1236
+ hideUserButton: (targetNode: HTMLDivElement) => void;
847
1237
  /** Subscribe to a single event */
848
1238
  on: onEventListener;
849
1239
  /** Remove event listener */
@@ -860,6 +1250,7 @@ interface TernSecureAuth {
860
1250
  * @param {string} to
861
1251
  */
862
1252
  constructUrlWithAuthRedirect(to: string): string;
1253
+ constructAfterSignOutUrl(): string;
863
1254
  /** Navigate to SignIn page */
864
1255
  redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
865
1256
  /** Navigate to SignUp page */
@@ -888,12 +1279,18 @@ type TernVerificationResult = (DecodedIdToken & {
888
1279
  valid: false;
889
1280
  error: AuthErrorResponse;
890
1281
  };
1282
+ type RoutingOptions = {
1283
+ path: string | undefined;
1284
+ routing?: Extract<RoutingStrategy, 'path'>;
1285
+ } | {
1286
+ path?: never;
1287
+ routing?: Extract<RoutingStrategy, 'hash' | 'virtual'>;
1288
+ };
1289
+ type WithoutRouting<T> = Omit<T, 'path' | 'routing'>;
891
1290
  /**
892
1291
  * Props for SignIn component focusing on UI concerns
893
1292
  */
894
- type SignInProps = {
895
- /** Routing Path */
896
- path?: string;
1293
+ type SignInProps = RoutingOptions & {
897
1294
  /** URL to navigate to after successfully sign-in
898
1295
  * Use this prop to override the redirect URL when needed.
899
1296
  * @default undefined
@@ -905,18 +1302,40 @@ type SignInProps = {
905
1302
  * @default undefined
906
1303
  */
907
1304
  fallbackRedirectUrl?: string | null;
1305
+ /**
1306
+ * Full URL or path to for the sign in process.
1307
+ * Used to fill the "Sign in" link in the SignUp component.
1308
+ */
1309
+ signInUrl?: string;
1310
+ /**
1311
+ * Full URL or path to for the sign up process.
1312
+ * Used to fill the "Sign up" link in the SignUp component.
1313
+ */
1314
+ signUpUrl?: string;
1315
+ /**
1316
+ * Preferred strategy for sign-in when using email identifier.
1317
+ * Options: 'password' | 'email_code'
1318
+ * @default 'password'
1319
+ */
1320
+ preferredEmailStrategy?: 'password' | 'email_code';
1321
+ /**
1322
+ * Customize UI
1323
+ */
1324
+ appearance?: SignInTheme;
908
1325
  /** Initial form values */
909
- initialValue?: SignInInitialValue;
1326
+ initialValues?: SignInInitialValues & SignUpInitialValues;
910
1327
  /**
911
- * @deprecated this prop will be removed in future releases. Use UI configuration options instead. use onSignInSuccess
912
- *
1328
+ * Whether to show the combined email and password form.
1329
+ * If true, the email and password fields will be shown together.
1330
+ * If false, the email field will be shown first, followed by the password field.
1331
+ * @default true
913
1332
  */
914
- onSuccess?: (user: TernSecureUser | null) => void;
1333
+ showCombinedForm?: boolean;
915
1334
  } & SignUpForceRedirectUrl & SignUpFallbackRedirectUrl & AfterSignOutUrl;
916
1335
  /**
917
1336
  * Props for SignUp component focusing on UI concerns
918
1337
  */
919
- type SignUpProps = {
1338
+ type SignUpProps = RoutingOptions & {
920
1339
  /** URL to navigate to after successfully sign-up
921
1340
  * Use this prop to override the redirect URL when needed.
922
1341
  * @default undefined
@@ -928,15 +1347,60 @@ type SignUpProps = {
928
1347
  * @default undefined
929
1348
  */
930
1349
  fallbackRedirectUrl?: string | null;
1350
+ /**
1351
+ * Full URL or path to for the sign in process.
1352
+ * Used to fill the "Sign in" link in the SignUp component.
1353
+ */
1354
+ signInUrl?: string;
1355
+ /**
1356
+ * Customize UI
1357
+ */
1358
+ appearance?: SignUpTheme;
1359
+ /**
1360
+ * Whether to show the sign up form.
1361
+ * @default true
1362
+ */
1363
+ shouldShowForm?: boolean;
931
1364
  /** Initial form values */
932
- initialValue?: SignUpInitialValue;
933
- /** Callbacks */
934
- onSubmit?: (values: SignUpFormValues) => Promise<void>;
935
- onSuccess?: (user: TernSecureUser | null) => void;
1365
+ initialValues?: SignUpInitialValues;
936
1366
  } & SignInFallbackRedirectUrl & SignInForceRedirectUrl & AfterSignOutUrl;
1367
+ type UserButtonProps = {
1368
+ /**
1369
+ * Controls if the username is displayed next to the trigger button
1370
+ */
1371
+ showName?: boolean;
1372
+ /**
1373
+ * Controls the default state of the UserButton
1374
+ */
1375
+ defaultOpen?: boolean;
1376
+ /**
1377
+ * Full URL or path to navigate to on "Add another account" action.
1378
+ * Multi-session mode only.
1379
+ */
1380
+ signInUrl?: string;
1381
+ };
1382
+ type SignInModalProps = WithoutRouting<SignInProps>;
1383
+ type SignUpModalProps = WithoutRouting<SignUpProps>;
937
1384
  type SignInRedirectOptions = RedirectOptions;
938
1385
  type SignUpRedirectOptions = RedirectOptions;
939
1386
  type RoutingStrategy = 'path' | 'hash' | 'virtual';
1387
+ type __internal_ComponentNavigationContext = {
1388
+ /**
1389
+ * The `navigate` reference within the component router context
1390
+ */
1391
+ navigate: (to: string, options?: {
1392
+ searchParams?: URLSearchParams;
1393
+ }) => Promise<unknown>;
1394
+ /**
1395
+ * This path represents the root route for a specific component type and is used
1396
+ * for internal routing and navigation.
1397
+ *
1398
+ * @example
1399
+ * indexPath: '/sign-in' // When <SignIn path='/sign-in' />
1400
+ * indexPath: '/sign-up' // When <SignUp path='/sign-up' />
1401
+ */
1402
+ indexPath: string;
1403
+ };
940
1404
  /**
941
1405
  * Internal is a navigation type that affects the component
942
1406
  *
@@ -986,139 +1450,19 @@ metadata?: {
986
1450
  */
987
1451
  windowNavigate: (to: URL | string) => void;
988
1452
  }) => 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
- }
1453
+ type SignInInitialValues = {
1454
+ emailAddress?: string;
1455
+ phoneNumber?: string;
1456
+ username?: string;
1457
+ };
1458
+ type SignUpInitialValues = {
1459
+ emailAddress?: string;
1460
+ phoneNumber?: string;
1461
+ firstName?: string;
1462
+ lastName?: string;
1463
+ displayName?: string;
1464
+ username?: string;
1465
+ };
1122
1466
 
1123
1467
  type Mode = 'browser' | 'server';
1124
1468
  type TernSecureSDK = {
@@ -1282,19 +1626,6 @@ type SignUpPropsTree = {
1282
1626
  type SignInRedirectOptionss = RedirectOptions;
1283
1627
  type SignUpRedirectOptionss = RedirectOptions;
1284
1628
 
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
1629
  type UseAuthReturn = {
1299
1630
  userId: string | null | undefined;
1300
1631
  isLoaded: boolean;
@@ -1335,5 +1666,13 @@ type DomainOrProxyUrl = {
1335
1666
  * @internal
1336
1667
  */
1337
1668
  type Autocomplete<U extends T, T = string> = U | (T & Record<never, never>);
1669
+ /**
1670
+ * Omit without union flattening
1671
+ * */
1672
+ type Without<T, W> = {
1673
+ [P in keyof T as Exclude<P, W>]: T[P];
1674
+ };
1675
+
1676
+ type Attribute = 'email_address' | 'phone_number' | 'username' | 'first_name' | 'last_name' | 'password' | 'web3_wallet' | 'authenticator_app' | 'backup_code' | 'passkey';
1338
1677
 
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 };
1678
+ 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 };