@tern-secure/types 1.1.0-canary.v20251008131428 → 1.1.0-canary.v20251019190011

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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * TernSecure User
3
3
  */
4
- interface IdTokenResult {
4
+ interface IdTokenResult_DEPRECATED {
5
5
  authTime: string;
6
6
  expirationTime: string;
7
7
  issuedAtTime: string;
@@ -10,6 +10,55 @@ interface IdTokenResult {
10
10
  token: string;
11
11
  claims: Record<string, any>;
12
12
  }
13
+ /**
14
+ * parsed can be replaced with
15
+ */
16
+ interface ParsedToken {
17
+ /** Expiration time of the token. */
18
+ exp?: string;
19
+ /** UID of the user. */
20
+ sub?: string;
21
+ /** Time at which authentication was performed. */
22
+ auth_time?: string;
23
+ /** Issuance time of the token. */
24
+ iat?: string;
25
+ /** Firebase specific claims, containing the provider(s) used to authenticate the user. */
26
+ firebase?: {
27
+ sign_in_provider?: string;
28
+ sign_in_second_factor?: string;
29
+ identities?: Record<string, string>;
30
+ };
31
+ /** Map of any additional custom claims. */
32
+ [key: string]: unknown;
33
+ }
34
+ /**
35
+ * Core properties for any session that is or was authenticated.
36
+ * These properties are guaranteed to exist for active, expired, or revoked sessions.
37
+ */
38
+ interface IdTokenResult {
39
+ /** Time at which authentication was performed (from token claims). */
40
+ authTime: string;
41
+ /** The ID token expiration time (e.g., UTC string or Unix timestamp). */
42
+ expirationTime: string;
43
+ /** The ID token issuance time. */
44
+ issuedAtTime: string;
45
+ /** signInProvider */
46
+ signInProvider: string | null;
47
+ /** signInSecondFactor */
48
+ signInSecondFactor: string | null;
49
+ /** The Firebase Auth ID token JWT string. */
50
+ token: string;
51
+ /**
52
+ * The entire payload claims of the ID token including the standard reserved claims
53
+ * as well as custom claims.
54
+ */
55
+ claims: ParsedToken;
56
+ }
57
+ declare const OperationType: {
58
+ readonly SIGN_IN: "signIn";
59
+ readonly LINK: "link";
60
+ readonly REAUTHENTICATE: "reauthenticate";
61
+ };
13
62
  interface UserInfo {
14
63
  displayName: string | null;
15
64
  email: string | null;
@@ -34,11 +83,32 @@ interface TernSecureUser extends UserInfo {
34
83
  reload(): Promise<void>;
35
84
  toJSON(): object;
36
85
  }
37
- type TernSecureUserData = {
38
- uid: string;
39
- email: string | null;
40
- emailVerified?: boolean;
41
- displayName?: string | null;
86
+ interface ProviderUserInfo {
87
+ rawId: string;
88
+ displayName?: string;
89
+ email?: string;
90
+ photoUrl?: string;
91
+ phoneNumber?: string;
92
+ providerId: string;
93
+ federatedId?: string;
94
+ }
95
+ interface TernSecureUserData {
96
+ localId: string;
97
+ email: string;
98
+ emailVerified: boolean;
99
+ displayName: string;
100
+ providerUserInfo: ProviderUserInfo[];
101
+ photoUrl: string;
102
+ validSince: string;
103
+ disabled: boolean;
104
+ lastLoginAt: string;
105
+ createdAt: string;
106
+ customAuth: boolean;
107
+ }
108
+ type UserCredential = {
109
+ user?: any;
110
+ providerId?: string | null;
111
+ operationType?: (typeof OperationType)[keyof typeof OperationType] | null;
42
112
  };
43
113
  /**
44
114
  * TernSecure Firebase configuration interface
@@ -145,6 +215,12 @@ interface CookieOptions {
145
215
  sameSite?: 'strict' | 'lax' | 'none' | undefined;
146
216
  secure?: boolean | undefined;
147
217
  }
218
+ interface CookieResource {
219
+ idToken?: string;
220
+ sessionToken?: string;
221
+ refreshToken?: string;
222
+ customToken?: string;
223
+ }
148
224
 
149
225
  type AuthErrorCode = keyof typeof ERRORS;
150
226
  type ErrorCode = keyof typeof ERRORS;
@@ -183,7 +259,8 @@ declare const ERRORS: {
183
259
  readonly REDIRECT_LOOP: "Redirect loop detected.";
184
260
  };
185
261
 
186
- type AuthEndpoint = 'sessions' | 'users';
262
+ type AuthEndpoint = 'cookies' | 'sessions' | 'users';
263
+ type CookieSubEndpoint = 'get' | 'set' | 'delete' | 'clear' | 'list';
187
264
  type SessionSubEndpoint = 'verify' | 'createsession' | 'refresh' | 'revoke';
188
265
  interface CorsOptions {
189
266
  allowedOrigins: string[] | '*';
@@ -239,6 +316,11 @@ interface EndpointConfig {
239
316
  security?: SecurityOptions;
240
317
  cors?: Partial<CorsOptions>;
241
318
  }
319
+ interface CookieEndpointConfig extends EndpointConfig {
320
+ subEndpoints?: {
321
+ [K in CookieSubEndpoint]?: Partial<EndpointConfig>;
322
+ };
323
+ }
242
324
  interface SessionEndpointConfig extends EndpointConfig {
243
325
  subEndpoints?: {
244
326
  [K in SessionSubEndpoint]?: Partial<EndpointConfig>;
@@ -250,6 +332,7 @@ interface TernSecureHandlerOptions {
250
332
  rateLimit?: RateLimitOptions;
251
333
  security?: SecurityOptions;
252
334
  endpoints?: {
335
+ cookies?: CookieEndpointConfig;
253
336
  sessions?: SessionEndpointConfig;
254
337
  };
255
338
  tenantId?: string | null;
@@ -259,325 +342,25 @@ interface TernSecureHandlerOptions {
259
342
  basePath?: string;
260
343
  }
261
344
 
262
- /**
263
- * Defines the basic structure for color theming.
264
- */
265
- interface ThemeColors {
266
- primary?: string;
267
- secondary?: string;
268
- accent?: string;
269
- background?: string;
270
- text?: string;
271
- error?: string;
272
- success?: string;
273
- }
274
- /**
275
- * Defines the basic structure for font theming.
276
- */
277
- interface ThemeFonts {
278
- primary?: string;
279
- secondary?: string;
280
- }
281
- /**
282
- * Defines the basic structure for spacing and layout theming.
283
- */
284
- interface ThemeSpacing {
285
- small?: string | number;
286
- medium?: string | number;
287
- large?: string | number;
288
- }
289
- /**
290
- * Defines the basic structure for border radius theming.
291
- */
292
- interface ThemeBorderRadius {
293
- small?: string | number;
294
- medium?: string | number;
295
- large?: string | number;
296
- }
297
- /**
298
- * Allows for overriding styles of specific UI components.
299
- * Properties can be CSS-in-JS objects or class names, depending on implementation.
300
- */
301
- interface ThemeComponentStyles {
302
- button?: Record<string, any> | string;
303
- input?: Record<string, any> | string;
304
- card?: Record<string, any> | string;
305
- label?: Record<string, any> | string;
306
- }
307
- /**
308
- * Defines the overall appearance/theme configuration.
309
- * This allows for broad customization of the UI components.
310
- */
311
- interface Appearance {
312
- colors?: ThemeColors;
313
- fonts?: ThemeFonts;
314
- spacing?: ThemeSpacing;
315
- borderRadius?: ThemeBorderRadius;
316
- componentStyles?: ThemeComponentStyles;
317
- variables?: Record<string, string | number>;
318
- }
319
- /**
320
- * Base UI configuration shared between SignIn and SignUp
321
- */
322
- interface BaseAuthUIConfig {
323
- /** Visual appearance configuration */
324
- appearance?: Appearance;
325
- /** Application logo URL or SVG string */
326
- logo?: string;
327
- /** Application name for display */
328
- appName?: string;
329
- /** Render mode for cross-platform support */
330
- renderMode?: 'modal' | 'page' | 'embedded';
331
- /** Layout direction */
332
- layout?: 'vertical' | 'horizontal';
333
- /** Custom loading message */
334
- loadingMessage?: string;
335
- /** Loading spinner variant */
336
- loadingSpinnerVariant?: 'circular' | 'linear' | 'dots';
337
- /** Accessibility configuration */
338
- a11y?: {
339
- /** ARIA labels and descriptions */
340
- labels?: Record<string, string>;
341
- /** Element to receive initial focus */
342
- initialFocus?: string;
343
- /** Whether to trap focus within the auth UI */
344
- trapFocus?: boolean;
345
- };
346
- }
347
- /**
348
- * Sign-in specific UI configuration
349
- */
350
- interface SignInUIConfig extends BaseAuthUIConfig {
351
- /** Social sign-in buttons configuration */
352
- socialButtons?: {
353
- google?: boolean;
354
- microsoft?: boolean;
355
- github?: boolean;
356
- facebook?: boolean;
357
- twitter?: boolean;
358
- apple?: boolean;
359
- linkedin?: boolean;
360
- layout?: 'vertical' | 'horizontal';
361
- size?: 'small' | 'medium' | 'large';
362
- };
363
- /** "Remember me" checkbox configuration */
364
- rememberMe?: {
365
- enabled?: boolean;
366
- defaultChecked?: boolean;
367
- };
368
- /** Sign-up link configuration */
369
- signUpLink?: {
370
- enabled?: boolean;
371
- text?: string;
372
- href?: string;
373
- };
374
- }
375
- /**
376
- * Sign-up specific UI configuration
377
- */
378
- interface SignUpUIConfig extends BaseAuthUIConfig {
379
- /** Password requirements display configuration */
380
- passwordRequirements?: {
381
- show?: boolean;
382
- rules?: Array<{
383
- rule: string;
384
- description: string;
385
- }>;
386
- };
387
- /** Terms and conditions configuration */
388
- terms?: {
389
- enabled?: boolean;
390
- text?: string;
391
- link?: string;
392
- };
393
- }
394
-
395
- interface TernSecureSession {
396
- token: string | null;
397
- expiresAt?: number;
398
- }
399
- type SignInFormValues = {
400
- email: string;
401
- password: string;
402
- phoneNumber?: string;
403
- };
404
- type SignInInitialValue = Partial<SignInFormValues>;
405
- type SignUpFormValues = {
406
- email: string;
407
- password: string;
408
- confirmPassword?: string;
409
- displayName?: string;
410
- };
411
- type SignUpInitialValue = Partial<SignUpFormValues>;
412
- interface SignInResponse {
413
- success: boolean;
414
- message?: string;
415
- error?: any | undefined;
416
- user?: any;
417
- }
418
- interface AuthError extends Error {
419
- code?: any | string;
420
- message: string;
421
- response?: SignInResponse;
422
- }
423
- declare function isSignInResponse(value: any): value is SignInResponse;
424
- interface AuthActions {
425
- signInWithEmail: (email: string, password: string) => Promise<SignInResponse>;
426
- signInWithGoogle: () => Promise<void>;
427
- signInWithMicrosoft: () => Promise<void>;
428
- signOut: () => Promise<void>;
429
- getRedirectResult: () => Promise<any>;
430
- getIdToken: () => Promise<string | null>;
431
- createUserWithEmailAndPassword?: (email: string, password: string) => Promise<SignInResponse>;
432
- sendEmailVerification?: (user: TernSecureUser) => Promise<void>;
433
- }
434
- interface RedirectConfig {
435
- redirectUrl?: string;
436
- isReturn?: boolean;
437
- priority?: number;
438
- }
439
- interface SignInProps extends RedirectConfig {
440
- initialValue?: SignInInitialValue;
441
- logo?: string;
442
- appName?: string;
443
- appearance?: Appearance;
444
- onError?: (error: AuthError) => void;
445
- onSuccess?: (user: TernSecureUser | null) => void;
446
- }
447
- /**
448
- * SignUpProps interface defines the properties for the sign-up component.
449
- * It extends RedirectConfig to include redirect-related properties.
450
- */
451
- interface SignUpProps extends RedirectConfig {
452
- initialValue?: SignUpInitialValue;
453
- logo?: string;
454
- appName?: string;
455
- appearance?: Appearance;
456
- onError?: (error: AuthError) => void;
457
- onSuccess?: (user: TernSecureUser | null) => void;
458
- }
459
- /**
460
- * Defines the contract for a TernSecure instance.
461
- * This instance provides authentication state, user information, and methods
462
- * for managing the authentication lifecycle. It is designed to be used by
463
- * UI packages like tern-ui, which act as "dumb" renderers.
464
- */
465
- interface TernSecureInstanceOld {
466
- /** Indicates if the user is currently signed in. */
467
- isSignedIn: () => boolean;
468
- /** The current authenticated user object, or null if not signed in. */
469
- user: TernSecureUser | null;
470
- /** The current user session information, or null if not signed in. */
471
- session: TernSecureSession | null;
472
- /** Initiates the sign-out process for the current user. */
473
- signOut: () => Promise<void>;
474
- /**
475
- * Prepares or signals to mount the sign-in interface.
476
- * @param options Optional configuration or initial state for the sign-in UI, conforming to SignInProps.
477
- */
478
- mountSignIn: (options?: SignInProps) => void;
479
- /** Cleans up or signals to unmount the sign-in interface. */
480
- unmountSignIn: () => void;
481
- /**
482
- * Prepares or signals to mount the sign-up interface.
483
- * @param options Optional configuration or initial state for the sign-up UI, conforming to SignUpProps.
484
- */
485
- mountSignUp: (options?: SignUpProps) => void;
486
- /** Cleans up or signals to unmount the sign-up interface. */
487
- unmountSignUp: () => void;
488
- /**
489
- * Determines if a redirect is necessary based on the current authentication
490
- * state and the given path.
491
- * @param currentPath The current URL path.
492
- * @returns True if a redirect is needed, false otherwise, or a string path to redirect to.
493
- */
494
- shouldRedirect: (currentPath: string) => boolean | string;
495
- /**
496
- * Constructs a URL, appending necessary redirect parameters.
497
- * Useful for redirecting back to the original page after authentication.
498
- * @param baseUrl The base URL to which redirect parameters should be added.
499
- * @returns The new URL string with redirect parameters.
500
- */
501
- constructUrlWithRedirect: (baseUrl: string) => string;
502
- /**
503
- * Redirects the user to the configured login page.
504
- * @param redirectUrl Optional URL to redirect to after successful login.
505
- */
506
- redirectToLogin: (redirectUrl?: string) => void;
507
- /** Indicates if an authentication operation is currently in progress. */
508
- isLoading: boolean;
509
- /** Holds any error that occurred during an authentication operation, or null otherwise. */
510
- error: Error | null;
511
- /** Indicates if the user has verified their email address. */
512
- sendVerificationEmail: () => Promise<void>;
513
- }
514
-
515
345
  type SessionStatus = 'active' | 'expired' | 'revoked' | 'pending';
516
- /**
517
- * parsed can be replaced with
518
- */
519
- interface ParsedToken {
520
- /** Expiration time of the token. */
521
- 'exp'?: string;
522
- /** UID of the user. */
523
- 'sub'?: string;
524
- /** Time at which authentication was performed. */
525
- 'auth_time'?: string;
526
- /** Issuance time of the token. */
527
- 'iat'?: string;
528
- /** Firebase specific claims, containing the provider(s) used to authenticate the user. */
529
- 'firebase'?: {
530
- 'sign_in_provider'?: string;
531
- 'sign_in_second_factor'?: string;
532
- 'identities'?: Record<string, string>;
533
- };
534
- /** Map of any additional custom claims. */
535
- [key: string]: unknown;
536
- }
537
- /**
538
- * Core properties for any session that is or was authenticated.
539
- * These properties are guaranteed to exist for active, expired, or revoked sessions.
540
- */
541
- interface AuthenticatedSessionBase {
542
- /** The Firebase Auth ID token JWT string. */
543
- token: string;
544
- /** The ID token expiration time (e.g., UTC string or Unix timestamp). */
545
- expirationTime: string;
546
- /** The ID token issuance time. */
547
- issuedAtTime: string;
548
- /** Time at which authentication was performed (from token claims). */
549
- authTime: string;
550
- /**
551
- * The entire payload claims of the ID token including the standard reserved claims
552
- * as well as custom claims.
553
- */
554
- claims: ParsedToken;
555
- /**
556
- * Time the user last signed in.
557
- * This could be from Firebase User metadata or persisted by TernSecure.
558
- */
559
- lastSignedAt?: number;
560
- /** signInProvider */
561
- signInProvider: string;
562
- }
563
346
  /**
564
347
  * Represents a session when the user is authenticated and the token is considered active.
565
348
  */
566
- interface ActiveSession extends AuthenticatedSessionBase {
349
+ interface ActiveSession extends IdTokenResult {
567
350
  status: 'active';
568
351
  user?: TernSecureUser;
569
352
  }
570
353
  /**
571
354
  * Represents a session when the user was authenticated, but the token has expired.
572
355
  */
573
- interface ExpiredSession extends AuthenticatedSessionBase {
356
+ interface ExpiredSession extends IdTokenResult {
574
357
  status: 'expired';
575
358
  user?: TernSecureUser;
576
359
  }
577
360
  /**
578
361
  * Represents a session that is awaiting some action.
579
362
  */
580
- interface PendingSession extends AuthenticatedSessionBase {
363
+ interface PendingSession extends IdTokenResult {
581
364
  status: 'pending';
582
365
  user?: TernSecureUser;
583
366
  }
@@ -600,9 +383,15 @@ interface SessionResult {
600
383
  error?: string;
601
384
  cookieSet?: boolean;
602
385
  }
386
+ interface SessionResource extends IdTokenResult {
387
+ status: SessionStatus;
388
+ user?: TernSecureUser;
389
+ create: (csrfToken: string) => Promise<void>;
390
+ getIdAndRefreshToken: (idToken: string, csrfToken: string) => Promise<void>;
391
+ }
603
392
 
604
393
  type SignInStatus = 'idle' | 'pending_email_password' | 'pending_social' | 'pending_mfa' | 'redirecting' | 'success' | 'error';
605
- type SignInFormValuesTree = {
394
+ type SignInFormValues = {
606
395
  email: string;
607
396
  password: string;
608
397
  phoneNumber?: string;
@@ -617,17 +406,26 @@ interface AuthErrorTree extends Error {
617
406
  message: string;
618
407
  response?: any | string;
619
408
  }
620
- interface SignInResponseTree {
621
- success: boolean;
409
+ interface BaseSignInResponse {
410
+ status?: SignInStatus;
622
411
  message?: string;
623
412
  error?: any | undefined;
624
- user?: any;
625
413
  }
626
- type SignInInitialValueTree = Partial<SignInFormValuesTree>;
627
- interface ResendEmailVerification extends SignInResponseTree {
414
+ interface SignInSuccessResponse extends BaseSignInResponse, UserCredential {
415
+ status: 'success';
416
+ }
417
+ interface SignInErrorResponse extends BaseSignInResponse {
418
+ status: 'error';
419
+ }
420
+ interface SignInPendingResponse extends BaseSignInResponse {
421
+ status: 'redirecting' | 'pending_social' | 'pending_email_password';
422
+ }
423
+ type SignInResponse = SignInSuccessResponse | SignInErrorResponse | SignInPendingResponse;
424
+ type SignInInitialValue = Partial<SignInFormValues>;
425
+ interface ResendEmailVerification {
628
426
  isVerified?: boolean;
629
427
  }
630
- declare function isSignInResponseTree(value: any): value is SignInResponseTree;
428
+ declare function isSignInResponseTree(value: any): value is SignInResponse;
631
429
  interface SignInResource {
632
430
  /**
633
431
  * The current status of the sign-in process.
@@ -638,7 +436,7 @@ interface SignInResource {
638
436
  * @param params - The sign-in form values.
639
437
  * @returns A promise that resolves with the sign-in response.
640
438
  */
641
- withEmailAndPassword: (params: SignInFormValuesTree) => Promise<SignInResponseTree>;
439
+ withEmailAndPassword: (params: SignInFormValues) => Promise<SignInResponse>;
642
440
  /**
643
441
  * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
644
442
  * @param options - Optional configuration for the social sign-in flow.
@@ -646,14 +444,14 @@ interface SignInResource {
646
444
  */
647
445
  withSocialProvider: (provider: string, options?: {
648
446
  mode?: 'popup' | 'redirect';
649
- }) => Promise<SignInResponseTree | void>;
447
+ }) => Promise<SignInResponse | void>;
650
448
  /**
651
449
  * Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.
652
450
  * @param mfaToken - The MFA token or code submitted by the user.
653
451
  * @param mfaContext - Optional context or session data from the MFA initiation step.
654
452
  * @returns A promise that resolves with the sign-in response upon successful MFA verification.
655
453
  */
656
- completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponseTree>;
454
+ completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponse>;
657
455
  /**
658
456
  * Sends a password reset email to the given email address.
659
457
  * @param email - The user's email address.
@@ -669,7 +467,7 @@ interface SignInResource {
669
467
  * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.
670
468
  * @returns A promise that resolves with the sign-in response or null if no result is available.
671
469
  */
672
- checkRedirectResult: () => Promise<SignInResponseTree | null>;
470
+ checkRedirectResult: () => Promise<SignInResponse | null>;
673
471
  }
674
472
 
675
473
  interface SignUpResource {
@@ -687,7 +485,7 @@ interface SignUpResource {
687
485
  */
688
486
  withSocialProvider: (provider: string, options?: {
689
487
  mode?: 'popup' | 'redirect';
690
- }) => Promise<SignInResponseTree | void>;
488
+ }) => Promise<SignInResponse | void>;
691
489
  }
692
490
  type SignUpStatus = 'missing_requirements' | 'complete' | 'abandoned';
693
491
 
@@ -782,10 +580,16 @@ interface TernSecureState {
782
580
  isAuthenticated: boolean;
783
581
  token: any | null;
784
582
  email: string | null;
785
- status: "loading" | "authenticated" | "unauthenticated" | "unverified";
583
+ status: 'loading' | 'authenticated' | 'unauthenticated' | 'unverified';
786
584
  user?: TernSecureUser | null;
787
585
  }
788
- type AuthProviderStatus = "idle" | "pending" | "error" | "success";
586
+ type TernSecureStateExtended = {
587
+ sessionClaims: DecodedIdToken | null;
588
+ userId: string | null;
589
+ token: string | null;
590
+ user?: TernSecureUser | null;
591
+ };
592
+ type AuthProviderStatus = 'idle' | 'pending' | 'error' | 'success';
789
593
  declare const DEFAULT_TERN_SECURE_STATE: TernSecureState;
790
594
  interface TernSecureAuthProvider {
791
595
  /** Current auth state */
@@ -805,8 +609,8 @@ interface TernSecureAuthProvider {
805
609
  /** Sign out the current user */
806
610
  signOut(): Promise<void>;
807
611
  }
808
- type Persistence = "local" | "session" | "browserCookie" | "none";
809
- type Mode$1 = "browser" | "server";
612
+ type Persistence = 'local' | 'session' | 'browserCookie' | 'none';
613
+ type Mode$1 = 'browser' | 'server';
810
614
  type TernAuthSDK = {
811
615
  /** SDK package name (e.g., @tern-secure/auth) */
812
616
  name: string;
@@ -828,6 +632,11 @@ interface TernSecureResources {
828
632
  user?: TernSecureUser | null;
829
633
  session?: SignedInSession | null;
830
634
  }
635
+ type CreateActiveSessionParams = {
636
+ session?: TernSecureUser | null;
637
+ redirectUrl?: string;
638
+ };
639
+ type CreateActiveSession = (params: CreateActiveSessionParams) => Promise<void>;
831
640
  type TernSecureAuthOptions = {
832
641
  apiUrl?: string;
833
642
  sdkMetadata?: TernAuthSDK;
@@ -858,7 +667,7 @@ type EventHandler<Events extends TernSecureEvent> = (payload: TernAuthEventPaylo
858
667
  type TernAuthEventPayload = {
859
668
  status: TernSecureAuthStatus;
860
669
  };
861
- type TernSecureAuthStatus = "error" | "loading" | "ready";
670
+ type TernSecureAuthStatus = 'error' | 'loading' | 'ready';
862
671
  type onEventListener = <E extends TernSecureEvent>(event: E, handler: EventHandler<E>, opt?: {
863
672
  notify?: boolean;
864
673
  }) => void;
@@ -897,6 +706,14 @@ interface TernSecureAuth {
897
706
  requiresVerification: boolean;
898
707
  /** Initialize TernSecureAuth */
899
708
  initialize(options?: TernSecureAuthOptions): Promise<void>;
709
+ /**
710
+ * @internal
711
+ */
712
+ _internal_getOption<K extends keyof TernSecureAuthOptions>(key: K): TernSecureAuthOptions[K];
713
+ /**
714
+ * @internal
715
+ */
716
+ _internal_getAllOptions(): Readonly<TernSecureAuthOptions>;
900
717
  /** Current user*/
901
718
  user: TernSecureUser | null | undefined;
902
719
  /** Current session */
@@ -915,8 +732,26 @@ interface TernSecureAuth {
915
732
  on: onEventListener;
916
733
  /** Remove event listener */
917
734
  off: OffEventListener;
735
+ /** Subscribe to all auth state changes */
918
736
  addListener: (callback: ListenerCallback) => UnsubscribeCallback;
737
+ /** Get redirect result from OAuth flows */
738
+ getRedirectResult: () => Promise<any>;
739
+ /** Create an active session */
740
+ createActiveSession: CreateActiveSession;
741
+ /** Navigate to SignIn page */
742
+ redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
743
+ /** Navigate to SignUp page */
744
+ redirectToSignUp(options?: SignUpRedirectOptions): Promise<unknown>;
745
+ redirectAfterSignIn: () => void;
746
+ redirectAfterSignUp: () => void;
919
747
  }
748
+ type SignUpFormValues = {
749
+ email: string;
750
+ password: string;
751
+ confirmPassword?: string;
752
+ displayName?: string;
753
+ };
754
+ type SignUpInitialValue = Partial<SignUpFormValues>;
920
755
  interface TernSecureAuthFactory {
921
756
  create(options?: TernSecureAuthOptions): TernSecureAuth;
922
757
  }
@@ -938,6 +773,166 @@ type TernVerificationResult = (DecodedIdToken & {
938
773
  valid: false;
939
774
  error: AuthErrorResponse;
940
775
  };
776
+ /**
777
+ * Props for SignIn component focusing on UI concerns
778
+ */
779
+ type SignInProps = {
780
+ /** Routing Path */
781
+ path?: string;
782
+ /** URL to navigate to after successfully sign-in */
783
+ forceRedirectUrl?: string | null;
784
+ /** Initial form values */
785
+ initialValue?: SignInInitialValue;
786
+ /** Callbacks */
787
+ onSuccess?: (user: TernSecureUser | null) => void;
788
+ } & SignUpRedirectUrl;
789
+ /**
790
+ * Props for SignUp component focusing on UI concerns
791
+ */
792
+ type SignUpProps = {
793
+ /** URL to navigate to after successfully sign-up */
794
+ forceRedirectUrl?: string | null;
795
+ /** Initial form values */
796
+ initialValue?: SignUpInitialValue;
797
+ /** Callbacks */
798
+ onSubmit?: (values: SignUpFormValues) => Promise<void>;
799
+ onSuccess?: (user: TernSecureUser | null) => void;
800
+ } & SignInRedirectUrl;
801
+ type SignInRedirectOptions = RedirectOptions;
802
+ type SignUpRedirectOptions = RedirectOptions;
803
+
804
+ /**
805
+ * Defines the basic structure for color theming.
806
+ */
807
+ interface ThemeColors {
808
+ primary?: string;
809
+ secondary?: string;
810
+ accent?: string;
811
+ background?: string;
812
+ text?: string;
813
+ error?: string;
814
+ success?: string;
815
+ }
816
+ /**
817
+ * Defines the basic structure for font theming.
818
+ */
819
+ interface ThemeFonts {
820
+ primary?: string;
821
+ secondary?: string;
822
+ }
823
+ /**
824
+ * Defines the basic structure for spacing and layout theming.
825
+ */
826
+ interface ThemeSpacing {
827
+ small?: string | number;
828
+ medium?: string | number;
829
+ large?: string | number;
830
+ }
831
+ /**
832
+ * Defines the basic structure for border radius theming.
833
+ */
834
+ interface ThemeBorderRadius {
835
+ small?: string | number;
836
+ medium?: string | number;
837
+ large?: string | number;
838
+ }
839
+ /**
840
+ * Allows for overriding styles of specific UI components.
841
+ * Properties can be CSS-in-JS objects or class names, depending on implementation.
842
+ */
843
+ interface ThemeComponentStyles {
844
+ button?: Record<string, any> | string;
845
+ input?: Record<string, any> | string;
846
+ card?: Record<string, any> | string;
847
+ label?: Record<string, any> | string;
848
+ }
849
+ /**
850
+ * Defines the overall appearance/theme configuration.
851
+ * This allows for broad customization of the UI components.
852
+ */
853
+ interface Appearance {
854
+ colors?: ThemeColors;
855
+ fonts?: ThemeFonts;
856
+ spacing?: ThemeSpacing;
857
+ borderRadius?: ThemeBorderRadius;
858
+ componentStyles?: ThemeComponentStyles;
859
+ variables?: Record<string, string | number>;
860
+ }
861
+ /**
862
+ * Base UI configuration shared between SignIn and SignUp
863
+ */
864
+ interface BaseAuthUIConfig {
865
+ /** Visual appearance configuration */
866
+ appearance?: Appearance;
867
+ /** Application logo URL or SVG string */
868
+ logo?: string;
869
+ /** Application name for display */
870
+ appName?: string;
871
+ /** Render mode for cross-platform support */
872
+ renderMode?: 'modal' | 'page' | 'embedded';
873
+ /** Layout direction */
874
+ layout?: 'vertical' | 'horizontal';
875
+ /** Custom loading message */
876
+ loadingMessage?: string;
877
+ /** Loading spinner variant */
878
+ loadingSpinnerVariant?: 'circular' | 'linear' | 'dots';
879
+ /** Accessibility configuration */
880
+ a11y?: {
881
+ /** ARIA labels and descriptions */
882
+ labels?: Record<string, string>;
883
+ /** Element to receive initial focus */
884
+ initialFocus?: string;
885
+ /** Whether to trap focus within the auth UI */
886
+ trapFocus?: boolean;
887
+ };
888
+ }
889
+ /**
890
+ * Sign-in specific UI configuration
891
+ */
892
+ interface SignInUIConfig extends BaseAuthUIConfig {
893
+ /** Social sign-in buttons configuration */
894
+ socialButtons?: {
895
+ google?: boolean;
896
+ microsoft?: boolean;
897
+ github?: boolean;
898
+ facebook?: boolean;
899
+ twitter?: boolean;
900
+ apple?: boolean;
901
+ linkedin?: boolean;
902
+ layout?: 'vertical' | 'horizontal';
903
+ size?: 'small' | 'medium' | 'large';
904
+ };
905
+ /** "Remember me" checkbox configuration */
906
+ rememberMe?: {
907
+ enabled?: boolean;
908
+ defaultChecked?: boolean;
909
+ };
910
+ /** Sign-up link configuration */
911
+ signUpLink?: {
912
+ enabled?: boolean;
913
+ text?: string;
914
+ href?: string;
915
+ };
916
+ }
917
+ /**
918
+ * Sign-up specific UI configuration
919
+ */
920
+ interface SignUpUIConfig extends BaseAuthUIConfig {
921
+ /** Password requirements display configuration */
922
+ passwordRequirements?: {
923
+ show?: boolean;
924
+ rules?: Array<{
925
+ rule: string;
926
+ description: string;
927
+ }>;
928
+ };
929
+ /** Terms and conditions configuration */
930
+ terms?: {
931
+ enabled?: boolean;
932
+ text?: string;
933
+ link?: string;
934
+ };
935
+ }
941
936
 
942
937
  type Mode = 'browser' | 'server';
943
938
  type TernSecureSDK = {
@@ -1025,9 +1020,9 @@ interface TernSecureInstanceTree {
1025
1020
  /** Construct URL with redirect parameters */
1026
1021
  constructUrlWithAuthRedirect: (to: string) => string;
1027
1022
  /** Navigate to SignIn page */
1028
- redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
1023
+ redirectToSignIn(options?: SignInRedirectOptionss): Promise<unknown>;
1029
1024
  /** Navigate to SignUp page */
1030
- redirectToSignUp(options?: SignUpRedirectOptions): Promise<unknown>;
1025
+ redirectToSignUp(options?: SignUpRedirectOptionss): Promise<unknown>;
1031
1026
  redirectAfterSignIn: () => void;
1032
1027
  redirectAfterSignUp: () => void;
1033
1028
  /** Error and Event Handling */
@@ -1073,7 +1068,7 @@ type SignInPropsTree = {
1073
1068
  /** URL to navigate to after successfully sign-in */
1074
1069
  forceRedirectUrl?: string | null;
1075
1070
  /** Initial form values */
1076
- initialValue?: SignInInitialValueTree;
1071
+ initialValue?: SignInInitialValue;
1077
1072
  /** UI configuration */
1078
1073
  ui?: SignInUIConfig;
1079
1074
  /** Callbacks */
@@ -1095,8 +1090,8 @@ type SignUpPropsTree = {
1095
1090
  onError?: (error: AuthErrorTree) => void;
1096
1091
  onSuccess?: (user: TernSecureUser | null) => void;
1097
1092
  } & SignInRedirectUrl;
1098
- type SignInRedirectOptions = RedirectOptions;
1099
- type SignUpRedirectOptions = RedirectOptions;
1093
+ type SignInRedirectOptionss = RedirectOptions;
1094
+ type SignUpRedirectOptionss = RedirectOptions;
1100
1095
 
1101
1096
  interface TernSecureApiErrorJSON {
1102
1097
  code: string;
@@ -1106,6 +1101,10 @@ interface TernSecureFireRestErrorJSON extends TernSecureApiErrorJSON {
1106
1101
  domain: string;
1107
1102
  reason: string;
1108
1103
  }
1104
+ interface SessionJson extends IdTokenResult {
1105
+ status: SessionStatus;
1106
+ user?: TernSecureUser;
1107
+ }
1109
1108
 
1110
1109
  type UseAuthReturn = {
1111
1110
  userId: string | null | undefined;
@@ -1113,10 +1112,9 @@ type UseAuthReturn = {
1113
1112
  isValid: boolean;
1114
1113
  isVerified: boolean;
1115
1114
  isAuthenticated: boolean;
1116
- token: any | null;
1117
- email: string | null;
1118
1115
  status: "loading" | "authenticated" | "unauthenticated" | "unverified";
1119
1116
  user?: TernSecureUser | null;
1117
+ sessionClaims?: DecodedIdToken | null | undefined;
1120
1118
  signOut: SignOut;
1121
1119
  };
1122
1120
  type UseSignInReturn = {
@@ -1142,4 +1140,4 @@ type DomainOrProxyUrl = {
1142
1140
  */
1143
1141
  type Autocomplete<U extends T, T = string> = U | (T & Record<never, never>);
1144
1142
 
1145
- export { type ActiveSession, type AdminConfigValidationResult, type AfterSignOutUrl, type Appearance, type AuthActions, type AuthEndpoint, type AuthError, type AuthErrorCode, type AuthErrorResponse, type AuthErrorTree, type AuthProviderStatus, type Autocomplete, type BaseAuthUIConfig, type CheckAuthorizationFromSessionClaims, type CheckCustomClaims, type ConfigValidationResult, type CookieOptions, type CookieOpts, type CookieStore, type CorsOptions, 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 ListenerCallback, type ParsedToken, type PendingSession, type Persistence, type RateLimitOptions, type RedirectConfig, type RedirectOptions, type ResendEmailVerification, type SecurityOptions, type ServerConfigValidationResult, type SessionCookieConfig, type SessionEndpointConfig, type SessionParams, type SessionResult, type SessionStatus, type SessionSubEndpoint, type SharedSignInAuthObjectProperties, type SignInFormValuesTree, type SignInInitialValue, type SignInInitialValueTree, type SignInProps, type SignInPropsTree, type SignInRedirectOptions, type SignInRedirectUrl, type SignInResource, type SignInResponse, type SignInResponseTree, type SignInStatus, type SignInUIConfig, type SignOut, type SignOutOptions, type SignOutOptionsTree, type SignUpFormValuesTree, type SignUpInitialValue, type SignUpInitialValueTree, type SignUpProps, type SignUpPropsTree, type SignUpRedirectOptions, type SignUpRedirectUrl, type SignUpResource, type SignUpStatus, type SignUpUIConfig, type SignedInSession, 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 TernSecureInstance, type TernSecureInstanceOld, type TernSecureInstanceTree, type TernSecureInstanceTreeOptions, type TernSecureInstanceTreeStatus, type TernSecureOptions, type TernSecureResources, type TernSecureSDK, type TernSecureServerConfig, type TernSecureSession, type TernSecureSessionTree, type TernSecureState, 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 UserInfo, type VerifiedTokens, isSignInResponse, isSignInResponseTree };
1143
+ 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, DEFAULT_TERN_SECURE_STATE, type DecodedIdToken, type DomainOrProxyUrl, ERRORS, type EndpointConfig, type ErrorCode, type ExpiredSession, type FirebaseClaims, type FirebaseState, type IdTokenResult, type IdTokenResult_DEPRECATED, type InitialState, type InstanceType, type JWTPayload, type JWTProtectedHeader, type Jwt, type ListenerCallback, type ParsedToken, type PendingSession, type Persistence, type ProviderUserInfo, type RateLimitOptions, type RedirectOptions, type ResendEmailVerification, 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 SignInFormValues, type SignInInitialValue, type SignInPendingResponse, type SignInProps, type SignInPropsTree, type SignInRedirectOptions, type SignInRedirectOptionss, type SignInRedirectUrl, type SignInResource, type SignInResponse, type SignInStatus, type SignInSuccessResponse, type SignInUIConfig, type SignOut, type SignOutOptions, type SignOutOptionsTree, type SignUpFormValues, type SignUpFormValuesTree, type SignUpInitialValue, type SignUpInitialValueTree, type SignUpProps, type SignUpPropsTree, type SignUpRedirectOptions, type SignUpRedirectOptionss, type SignUpRedirectUrl, type SignUpResource, type SignUpStatus, type SignUpUIConfig, type SignedInSession, 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 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 UserCredential, type UserInfo, type VerifiedTokens, isSignInResponseTree };