@tern-secure/types 1.1.0-canary.v20251030165007 → 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[];
@@ -278,7 +284,6 @@ interface TokenCookieConfig {
278
284
  interface CookieOpts extends CookieOptions {
279
285
  domain?: string;
280
286
  namePrefix?: string;
281
- session?: SessionCookieConfig;
282
287
  }
283
288
  interface RateLimitOptions {
284
289
  windowMs?: number;
@@ -314,6 +319,11 @@ interface SessionEndpointConfig extends EndpointConfig {
314
319
  [K in SessionSubEndpoint]?: Partial<EndpointConfig>;
315
320
  };
316
321
  }
322
+ interface SignInEndpointConfig extends EndpointConfig {
323
+ subEndpoints?: {
324
+ [K in SignInSubEndpoint]?: Partial<EndpointConfig>;
325
+ };
326
+ }
317
327
  interface TernSecureHandlerOptions {
318
328
  cors?: CorsOptions;
319
329
  cookies?: CookieOpts;
@@ -322,6 +332,7 @@ interface TernSecureHandlerOptions {
322
332
  endpoints?: {
323
333
  cookies?: CookieEndpointConfig;
324
334
  sessions?: SessionEndpointConfig;
335
+ signIns?: SignInEndpointConfig;
325
336
  };
326
337
  tenantId?: string | null;
327
338
  revokeRefreshTokensOnSignOut?: boolean;
@@ -379,10 +390,32 @@ interface SessionResource extends IdTokenResult {
379
390
  getIdAndRefreshToken: (idToken: string, csrfToken: string) => Promise<void>;
380
391
  }
381
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';
382
414
  interface BaseSignUpResponse {
383
415
  status?: SignUpStatus;
384
416
  message?: string;
385
- error?: any | undefined;
417
+ error?: any;
418
+ unverifiedFields?: UnverifiedField[];
386
419
  }
387
420
  interface SignUpSuccessResponse extends BaseSignUpResponse, UserCredential {
388
421
  status: 'complete';
@@ -390,24 +423,23 @@ interface SignUpSuccessResponse extends BaseSignUpResponse, UserCredential {
390
423
  interface SignUpErrorResponse extends BaseSignUpResponse {
391
424
  status: 'error';
392
425
  }
393
- type SignUpResponse = SignUpSuccessResponse | SignUpErrorResponse;
426
+ interface SignUpMissingRequirementsResponse extends BaseSignUpResponse, UserCredential {
427
+ status: 'missing_requirements';
428
+ unverifiedFields: UnverifiedField[];
429
+ }
430
+ type SignUpResponse = SignUpSuccessResponse | SignUpErrorResponse | SignUpMissingRequirementsResponse;
394
431
  type SignUpFormValues = {
395
432
  email: string;
396
433
  password: string;
397
434
  };
398
- type SignUpInitialValue = {
399
- email: string;
400
- password: string;
401
- };
435
+ type SignUpInitialValue = Partial<SignUpFormValues>;
402
436
  interface SignUpResource {
403
437
  status: SignUpStatus | null;
404
- username: string | null;
405
- firstName: string | null;
406
- lastName: string | null;
407
- displayName: string | null;
408
- email: string | null;
409
- phoneNumber: string | null;
410
- withEmailAndPassword: (params: SignUpInitialValue) => Promise<SignUpResponse>;
438
+ user: TernSecureUser | null;
439
+ unverifiedFields?: UnverifiedField[];
440
+ message?: string;
441
+ error?: any;
442
+ withEmailAndPassword: (params: SignUpFormValues) => Promise<SignUpResource>;
411
443
  /**
412
444
  * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
413
445
  * @param options - Optional configuration for the social sign-in flow.
@@ -416,8 +448,22 @@ interface SignUpResource {
416
448
  withSocialProvider: (provider: string, options?: {
417
449
  mode?: 'popup' | 'redirect';
418
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>;
419
460
  }
420
461
  type SignUpStatus = 'missing_requirements' | 'complete' | 'abandoned' | 'error';
462
+ interface SignUpJson extends TernSecureResourceJSON {
463
+ object: 'sign_up';
464
+ id: string;
465
+ status: SignUpStatus;
466
+ }
421
467
 
422
468
  interface FirebaseClaims {
423
469
  identities: {
@@ -535,11 +581,129 @@ type AfterSignOutUrl = {
535
581
  afterSignOutUrl?: string | null;
536
582
  };
537
583
 
538
- 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';
539
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 = {
540
701
  email: string;
541
702
  password: string;
542
- phoneNumber?: string;
703
+ };
704
+ type SignInPhoneParams = {
705
+ phoneNumber: string;
706
+ appVerifier?: any;
543
707
  };
544
708
  interface AuthErrorResponse {
545
709
  success: false;
@@ -566,7 +730,6 @@ interface SignInPendingResponse extends BaseSignInResponse {
566
730
  status: 'redirecting' | 'pending_social' | 'pending_email_password';
567
731
  }
568
732
  type SignInResponse = SignInSuccessResponse | SignInErrorResponse | SignInPendingResponse;
569
- type SignInInitialValue = Partial<SignInFormValues>;
570
733
  interface ResendEmailVerification {
571
734
  isVerified?: boolean;
572
735
  }
@@ -582,46 +745,227 @@ interface SocialProviderOptions {
582
745
  /** OAuth scopes to request from the provider */
583
746
  scopes?: string[];
584
747
  }
748
+ interface SignInVerificationResponse {
749
+ status: SignInStatus;
750
+ message?: string;
751
+ error?: any;
752
+ }
585
753
  interface SignInResource {
754
+ status: SignInStatus | null;
755
+ supportedFirstFactors: SignInFirstFactor[] | null;
756
+ identifier: string | null;
757
+ user?: TernSecureUser | null;
586
758
  /**
587
- * The current status of the sign-in process.
759
+ * Create combine email and phone sign in method
588
760
  */
589
- 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 = {
590
859
  /**
591
- * Signs in a user with their email and password.
592
- * @param params - The sign-in form values.
593
- * @returns A promise that resolves with the sign-in response.
860
+ * @default inside
594
861
  */
595
- withEmailAndPassword: (params: SignInFormValues) => Promise<SignInResponse>;
862
+ logoPlacement?: 'inside' | 'outside' | 'none';
596
863
  /**
597
- * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
598
- * @param options - Optional configuration for the social sign-in flow.
599
- * @returns A promise that resolves with the sign-in response.
864
+ * @default undefined
600
865
  */
601
- withSocialProvider: (provider: string, options: SocialProviderOptions) => Promise<SignInResponse>;
866
+ logoImageUrl?: string;
602
867
  /**
603
- * Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.
604
- * @param mfaToken - The MFA token or code submitted by the user.
605
- * @param mfaContext - Optional context or session data from the MFA initiation step.
606
- * @returns A promise that resolves with the sign-in response upon successful MFA verification.
868
+ * @default undefined
607
869
  */
608
- completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponse>;
870
+ logoLinkUrl?: string;
609
871
  /**
610
- * Sends a password reset email to the given email address.
611
- * @param email - The user's email address.
612
- * @returns A promise that resolves when the email is sent.
872
+ * @default auto
613
873
  */
614
- sendPasswordResetEmail: (email: string) => Promise<void>;
874
+ socialButtonsVariant?: 'auto' | 'iconButton' | 'blockButton';
615
875
  /**
616
- * Resends the email verification link to the user's email address.
617
- * @returns A promise that resolves with the sign-in response.
876
+ * @default bottom
618
877
  */
619
- resendEmailVerification: () => Promise<ResendEmailVerification>;
878
+ socialButtonsPlacement?: 'top' | 'bottom';
620
879
  /**
621
- * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.
622
- * @returns A promise that resolves with the sign-in response or null if no result is available.
880
+ * enables "Terms" link
623
881
  */
624
- 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
+ };
625
969
  }
626
970
 
627
971
  /**
@@ -741,8 +1085,13 @@ type TernSecureAuthOptions = TernSecureOptionsNavigation & SignInForceRedirectUr
741
1085
  sdkMetadata?: TernAuthSDK;
742
1086
  signInUrl?: string;
743
1087
  signUpUrl?: string;
1088
+ signUpMode?: 'public' | 'restricted' | 'waitlist';
1089
+ passwordAuthentication?: boolean;
744
1090
  mode?: Mode$1;
745
1091
  requiresVerification?: boolean;
1092
+ /**
1093
+ * @deprecated will be removed in future releases. please use ternUIUrl
1094
+ */
746
1095
  isTernSecureDev?: boolean;
747
1096
  ternSecureConfig?: TernSecureConfig;
748
1097
  persistence?: Persistence;
@@ -759,6 +1108,10 @@ type TernSecureAuthOptions = TernSecureOptionsNavigation & SignInForceRedirectUr
759
1108
  /** rethrow network errors that occur while the offline */
760
1109
  rethrowOfflineNetworkErrors?: boolean;
761
1110
  };
1111
+ /**
1112
+ * ReCaptcha V3 Site Key for Firebase App Check
1113
+ */
1114
+ appCheck?: AppCheckConfig;
762
1115
  };
763
1116
  /**
764
1117
  * @deprecated will be removed in future releases.
@@ -812,7 +1165,9 @@ interface TernSecureAuth {
812
1165
  /** TernSecure API URL */
813
1166
  apiUrl: string;
814
1167
  /** TernSecure domain for API string */
815
- domain: string;
1168
+ authDomain: string;
1169
+ /** TernSecure Frontend domain for TernSecure UI */
1170
+ frontEndDomain?: string;
816
1171
  /** TernSecure Proxy url */
817
1172
  proxyUrl?: string;
818
1173
  /** TernSecure Instance type */
@@ -845,6 +1200,32 @@ interface TernSecureAuth {
845
1200
  onAuthStateChanged(callback: (cb: any) => void): () => void;
846
1201
  /** Sign out the current user */
847
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;
848
1229
  /** Subscribe to a single event */
849
1230
  on: onEventListener;
850
1231
  /** Remove event listener */
@@ -861,6 +1242,7 @@ interface TernSecureAuth {
861
1242
  * @param {string} to
862
1243
  */
863
1244
  constructUrlWithAuthRedirect(to: string): string;
1245
+ constructAfterSignOutUrl(): string;
864
1246
  /** Navigate to SignIn page */
865
1247
  redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
866
1248
  /** Navigate to SignUp page */
@@ -889,12 +1271,18 @@ type TernVerificationResult = (DecodedIdToken & {
889
1271
  valid: false;
890
1272
  error: AuthErrorResponse;
891
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'>;
892
1282
  /**
893
1283
  * Props for SignIn component focusing on UI concerns
894
1284
  */
895
- type SignInProps = {
896
- /** Routing Path */
897
- path?: string;
1285
+ type SignInProps = RoutingOptions & {
898
1286
  /** URL to navigate to after successfully sign-in
899
1287
  * Use this prop to override the redirect URL when needed.
900
1288
  * @default undefined
@@ -906,18 +1294,40 @@ type SignInProps = {
906
1294
  * @default undefined
907
1295
  */
908
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;
909
1317
  /** Initial form values */
910
- initialValue?: SignInInitialValue;
1318
+ initialValues?: SignInInitialValues & SignUpInitialValues;
911
1319
  /**
912
- * @deprecated this prop will be removed in future releases. Use UI configuration options instead. use onSignInSuccess
913
- *
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
914
1324
  */
915
- onSuccess?: (user: TernSecureUser | null) => void;
1325
+ showCombinedForm?: boolean;
916
1326
  } & SignUpForceRedirectUrl & SignUpFallbackRedirectUrl & AfterSignOutUrl;
917
1327
  /**
918
1328
  * Props for SignUp component focusing on UI concerns
919
1329
  */
920
- type SignUpProps = {
1330
+ type SignUpProps = RoutingOptions & {
921
1331
  /** URL to navigate to after successfully sign-up
922
1332
  * Use this prop to override the redirect URL when needed.
923
1333
  * @default undefined
@@ -929,15 +1339,60 @@ type SignUpProps = {
929
1339
  * @default undefined
930
1340
  */
931
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;
932
1356
  /** Initial form values */
933
- initialValue?: SignUpInitialValue;
934
- /** Callbacks */
935
- onSubmit?: (values: SignUpFormValues) => Promise<void>;
936
- onSuccess?: (user: TernSecureUser | null) => void;
1357
+ initialValues?: SignUpInitialValues;
937
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>;
938
1376
  type SignInRedirectOptions = RedirectOptions;
939
1377
  type SignUpRedirectOptions = RedirectOptions;
940
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
+ };
941
1396
  /**
942
1397
  * Internal is a navigation type that affects the component
943
1398
  *
@@ -987,139 +1442,19 @@ metadata?: {
987
1442
  */
988
1443
  windowNavigate: (to: URL | string) => void;
989
1444
  }) => Promise<unknown> | unknown;
990
-
991
- /**
992
- * Defines the basic structure for color theming.
993
- */
994
- interface ThemeColors {
995
- primary?: string;
996
- secondary?: string;
997
- accent?: string;
998
- background?: string;
999
- text?: string;
1000
- error?: string;
1001
- success?: string;
1002
- }
1003
- /**
1004
- * Defines the basic structure for font theming.
1005
- */
1006
- interface ThemeFonts {
1007
- primary?: string;
1008
- secondary?: string;
1009
- }
1010
- /**
1011
- * Defines the basic structure for spacing and layout theming.
1012
- */
1013
- interface ThemeSpacing {
1014
- small?: string | number;
1015
- medium?: string | number;
1016
- large?: string | number;
1017
- }
1018
- /**
1019
- * Defines the basic structure for border radius theming.
1020
- */
1021
- interface ThemeBorderRadius {
1022
- small?: string | number;
1023
- medium?: string | number;
1024
- large?: string | number;
1025
- }
1026
- /**
1027
- * Allows for overriding styles of specific UI components.
1028
- * Properties can be CSS-in-JS objects or class names, depending on implementation.
1029
- */
1030
- interface ThemeComponentStyles {
1031
- button?: Record<string, any> | string;
1032
- input?: Record<string, any> | string;
1033
- card?: Record<string, any> | string;
1034
- label?: Record<string, any> | string;
1035
- }
1036
- /**
1037
- * Defines the overall appearance/theme configuration.
1038
- * This allows for broad customization of the UI components.
1039
- */
1040
- interface Appearance {
1041
- colors?: ThemeColors;
1042
- fonts?: ThemeFonts;
1043
- spacing?: ThemeSpacing;
1044
- borderRadius?: ThemeBorderRadius;
1045
- componentStyles?: ThemeComponentStyles;
1046
- variables?: Record<string, string | number>;
1047
- }
1048
- /**
1049
- * Base UI configuration shared between SignIn and SignUp
1050
- */
1051
- interface BaseAuthUIConfig {
1052
- /** Visual appearance configuration */
1053
- appearance?: Appearance;
1054
- /** Application logo URL or SVG string */
1055
- logo?: string;
1056
- /** Application name for display */
1057
- appName?: string;
1058
- /** Render mode for cross-platform support */
1059
- renderMode?: 'modal' | 'page' | 'embedded';
1060
- /** Layout direction */
1061
- layout?: 'vertical' | 'horizontal';
1062
- /** Custom loading message */
1063
- loadingMessage?: string;
1064
- /** Loading spinner variant */
1065
- loadingSpinnerVariant?: 'circular' | 'linear' | 'dots';
1066
- /** Accessibility configuration */
1067
- a11y?: {
1068
- /** ARIA labels and descriptions */
1069
- labels?: Record<string, string>;
1070
- /** Element to receive initial focus */
1071
- initialFocus?: string;
1072
- /** Whether to trap focus within the auth UI */
1073
- trapFocus?: boolean;
1074
- };
1075
- }
1076
- /**
1077
- * Sign-in specific UI configuration
1078
- */
1079
- interface SignInUIConfig extends BaseAuthUIConfig {
1080
- /** Social sign-in buttons configuration */
1081
- socialButtons?: {
1082
- google?: boolean;
1083
- microsoft?: boolean;
1084
- github?: boolean;
1085
- facebook?: boolean;
1086
- twitter?: boolean;
1087
- apple?: boolean;
1088
- linkedin?: boolean;
1089
- layout?: 'vertical' | 'horizontal';
1090
- size?: 'small' | 'medium' | 'large';
1091
- };
1092
- /** "Remember me" checkbox configuration */
1093
- rememberMe?: {
1094
- enabled?: boolean;
1095
- defaultChecked?: boolean;
1096
- };
1097
- /** Sign-up link configuration */
1098
- signUpLink?: {
1099
- enabled?: boolean;
1100
- text?: string;
1101
- href?: string;
1102
- };
1103
- }
1104
- /**
1105
- * Sign-up specific UI configuration
1106
- */
1107
- interface SignUpUIConfig extends BaseAuthUIConfig {
1108
- /** Password requirements display configuration */
1109
- passwordRequirements?: {
1110
- show?: boolean;
1111
- rules?: Array<{
1112
- rule: string;
1113
- description: string;
1114
- }>;
1115
- };
1116
- /** Terms and conditions configuration */
1117
- terms?: {
1118
- enabled?: boolean;
1119
- text?: string;
1120
- link?: string;
1121
- };
1122
- }
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
+ };
1123
1458
 
1124
1459
  type Mode = 'browser' | 'server';
1125
1460
  type TernSecureSDK = {
@@ -1283,19 +1618,6 @@ type SignUpPropsTree = {
1283
1618
  type SignInRedirectOptionss = RedirectOptions;
1284
1619
  type SignUpRedirectOptionss = RedirectOptions;
1285
1620
 
1286
- interface TernSecureApiErrorJSON {
1287
- code: string;
1288
- message: string;
1289
- }
1290
- interface TernSecureFireRestErrorJSON extends TernSecureApiErrorJSON {
1291
- domain: string;
1292
- reason: string;
1293
- }
1294
- interface SessionJson extends IdTokenResult {
1295
- status: SessionStatus;
1296
- user?: TernSecureUser;
1297
- }
1298
-
1299
1621
  type UseAuthReturn = {
1300
1622
  userId: string | null | undefined;
1301
1623
  isLoaded: boolean;
@@ -1336,5 +1658,13 @@ type DomainOrProxyUrl = {
1336
1658
  * @internal
1337
1659
  */
1338
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';
1339
1669
 
1340
- 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 };