@tern-secure/types 1.0.3 → 1.0.5
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/esm/index.js +0 -106
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +356 -41
- package/dist/index.d.ts +1054 -11
- package/dist/index.js +0 -110
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/dist/all.d.ts +0 -105
- package/dist/all.d.ts.map +0 -1
- package/dist/auth.d.ts +0 -37
- package/dist/auth.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -66
- package/dist/errors.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/instanceTree.d.ts +0 -121
- package/dist/instanceTree.d.ts.map +0 -1
- package/dist/redirect.d.ts +0 -8
- package/dist/redirect.d.ts.map +0 -1
- package/dist/session.d.ts +0 -87
- package/dist/session.d.ts.map +0 -1
- package/dist/signIn.d.ts +0 -56
- package/dist/signIn.d.ts.map +0 -1
- package/dist/signUp.d.ts +0 -20
- package/dist/signUp.d.ts.map +0 -1
- package/dist/ternsecure.d.ts +0 -123
- package/dist/ternsecure.d.ts.map +0 -1
- package/dist/theme.d.ts +0 -133
- package/dist/theme.d.ts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -53,6 +53,7 @@ interface TernSecureConfig {
|
|
|
53
53
|
appId: string;
|
|
54
54
|
measurementId?: string;
|
|
55
55
|
appName?: string;
|
|
56
|
+
tenantId?: string;
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* Configuration validation result
|
|
@@ -94,6 +95,12 @@ interface TernSecureAdminConfig {
|
|
|
94
95
|
clientEmail: string;
|
|
95
96
|
privateKey: string;
|
|
96
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Firebase Server configuration interface
|
|
100
|
+
*/
|
|
101
|
+
interface TernSecureServerConfig {
|
|
102
|
+
apiKey: string;
|
|
103
|
+
}
|
|
97
104
|
/**
|
|
98
105
|
* Firebase Admin configuration validation result
|
|
99
106
|
*/
|
|
@@ -102,24 +109,38 @@ interface AdminConfigValidationResult {
|
|
|
102
109
|
errors: string[];
|
|
103
110
|
config: TernSecureAdminConfig;
|
|
104
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Firebase Server configuration validation result
|
|
114
|
+
*/
|
|
115
|
+
interface ServerConfigValidationResult {
|
|
116
|
+
isValid: boolean;
|
|
117
|
+
errors: string[];
|
|
118
|
+
config: TernSecureServerConfig;
|
|
119
|
+
}
|
|
120
|
+
type InstanceType = 'production' | 'development';
|
|
105
121
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
success: false;
|
|
122
|
+
interface TernSecureAPIError {
|
|
123
|
+
code: string;
|
|
109
124
|
message: string;
|
|
110
|
-
code: ErrorCode;
|
|
111
125
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
|
|
127
|
+
interface CookieStore {
|
|
128
|
+
get(name: string): Promise<{
|
|
129
|
+
value: string | undefined;
|
|
130
|
+
}>;
|
|
131
|
+
set(name: string, value: string, options: CookieOptions): Promise<void>;
|
|
132
|
+
delete(name: string): Promise<void>;
|
|
116
133
|
}
|
|
117
|
-
interface
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
134
|
+
interface CookieOptions {
|
|
135
|
+
maxAge?: number;
|
|
136
|
+
httpOnly?: boolean;
|
|
137
|
+
secure?: boolean;
|
|
138
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
139
|
+
path?: string;
|
|
122
140
|
}
|
|
141
|
+
|
|
142
|
+
type AuthErrorCode = keyof typeof ERRORS;
|
|
143
|
+
type ErrorCode = keyof typeof ERRORS;
|
|
123
144
|
declare const ERRORS: {
|
|
124
145
|
readonly SERVER_SIDE_INITIALIZATION: "TernSecure must be initialized on the client side";
|
|
125
146
|
readonly REQUIRES_VERIFICATION: "AUTH_REQUIRES_VERIFICATION";
|
|
@@ -154,20 +175,6 @@ declare const ERRORS: {
|
|
|
154
175
|
readonly INVALID_ID_TOKEN: "Invalid ID token.";
|
|
155
176
|
readonly REDIRECT_LOOP: "Redirect loop detected.";
|
|
156
177
|
};
|
|
157
|
-
type AuthErrorCode = keyof typeof ERRORS;
|
|
158
|
-
declare class TernSecureError extends Error {
|
|
159
|
-
code: ErrorCode;
|
|
160
|
-
constructor(code: ErrorCode, message?: string);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Handles Firebase authentication errors with multiple fallback mechanisms
|
|
164
|
-
*/
|
|
165
|
-
declare function handleFirebaseAuthError(error: unknown): AuthErrorResponse;
|
|
166
|
-
/**
|
|
167
|
-
* Type guard to check if a response is an AuthErrorResponse
|
|
168
|
-
*/
|
|
169
|
-
declare function isAuthErrorResponse(response: unknown): response is AuthErrorResponse;
|
|
170
|
-
declare function getErrorAlertVariant(error: any | undefined): "destructive" | "default";
|
|
171
178
|
|
|
172
179
|
/**
|
|
173
180
|
* Defines the basic structure for color theming.
|
|
@@ -372,7 +379,7 @@ interface SignUpProps extends RedirectConfig {
|
|
|
372
379
|
* for managing the authentication lifecycle. It is designed to be used by
|
|
373
380
|
* UI packages like tern-ui, which act as "dumb" renderers.
|
|
374
381
|
*/
|
|
375
|
-
interface
|
|
382
|
+
interface TernSecureInstanceOld {
|
|
376
383
|
/** Indicates if the user is currently signed in. */
|
|
377
384
|
isSignedIn: () => boolean;
|
|
378
385
|
/** The current authenticated user object, or null if not signed in. */
|
|
@@ -426,7 +433,7 @@ type SessionStatus = 'active' | 'expired' | 'revoked' | 'pending';
|
|
|
426
433
|
/**
|
|
427
434
|
* parsed can be replaced with
|
|
428
435
|
*/
|
|
429
|
-
|
|
436
|
+
interface ParsedToken {
|
|
430
437
|
/** Expiration time of the token. */
|
|
431
438
|
'exp'?: string;
|
|
432
439
|
/** UID of the user. */
|
|
@@ -475,18 +482,21 @@ interface AuthenticatedSessionBase {
|
|
|
475
482
|
*/
|
|
476
483
|
interface ActiveSession extends AuthenticatedSessionBase {
|
|
477
484
|
status: 'active';
|
|
485
|
+
user?: TernSecureUser;
|
|
478
486
|
}
|
|
479
487
|
/**
|
|
480
488
|
* Represents a session when the user was authenticated, but the token has expired.
|
|
481
489
|
*/
|
|
482
490
|
interface ExpiredSession extends AuthenticatedSessionBase {
|
|
483
491
|
status: 'expired';
|
|
492
|
+
user?: TernSecureUser;
|
|
484
493
|
}
|
|
485
494
|
/**
|
|
486
495
|
* Represents a session that is awaiting some action.
|
|
487
496
|
*/
|
|
488
497
|
interface PendingSession extends AuthenticatedSessionBase {
|
|
489
498
|
status: 'pending';
|
|
499
|
+
user?: TernSecureUser;
|
|
490
500
|
}
|
|
491
501
|
/**
|
|
492
502
|
* Defines the possible states of a user's session within TernSecure.
|
|
@@ -514,6 +524,22 @@ type SignInFormValuesTree = {
|
|
|
514
524
|
password: string;
|
|
515
525
|
phoneNumber?: string;
|
|
516
526
|
};
|
|
527
|
+
interface AuthErrorResponse {
|
|
528
|
+
success: false;
|
|
529
|
+
message: string;
|
|
530
|
+
code: ErrorCode;
|
|
531
|
+
}
|
|
532
|
+
interface AuthErrorTree extends Error {
|
|
533
|
+
code?: any | string;
|
|
534
|
+
message: string;
|
|
535
|
+
response?: any | string;
|
|
536
|
+
}
|
|
537
|
+
interface SignInResponseTree {
|
|
538
|
+
success: boolean;
|
|
539
|
+
message?: string;
|
|
540
|
+
error?: any | undefined;
|
|
541
|
+
user?: any;
|
|
542
|
+
}
|
|
517
543
|
type SignInInitialValueTree = Partial<SignInFormValuesTree>;
|
|
518
544
|
interface ResendEmailVerification extends SignInResponseTree {
|
|
519
545
|
isVerified?: boolean;
|
|
@@ -582,6 +608,88 @@ interface SignUpResource {
|
|
|
582
608
|
}
|
|
583
609
|
type SignUpStatus = 'missing_requirements' | 'complete' | 'abandoned';
|
|
584
610
|
|
|
611
|
+
interface FirebaseClaims {
|
|
612
|
+
identities: {
|
|
613
|
+
[key: string]: unknown;
|
|
614
|
+
};
|
|
615
|
+
sign_in_provider: string;
|
|
616
|
+
sign_in_second_factor?: string;
|
|
617
|
+
second_factor_identifier?: string;
|
|
618
|
+
tenant?: string;
|
|
619
|
+
[key: string]: unknown;
|
|
620
|
+
}
|
|
621
|
+
interface DecodedIdToken {
|
|
622
|
+
aud: string;
|
|
623
|
+
auth_time: number;
|
|
624
|
+
email?: string;
|
|
625
|
+
email_verified?: boolean;
|
|
626
|
+
exp: number;
|
|
627
|
+
firebase: FirebaseClaims;
|
|
628
|
+
iat: number;
|
|
629
|
+
iss: string;
|
|
630
|
+
phone_number?: string;
|
|
631
|
+
picture?: string;
|
|
632
|
+
sub: string;
|
|
633
|
+
uid: string;
|
|
634
|
+
[key: string]: any;
|
|
635
|
+
}
|
|
636
|
+
interface VerifiedTokens {
|
|
637
|
+
IdToken: string;
|
|
638
|
+
DecodedIdToken: DecodedIdToken;
|
|
639
|
+
}
|
|
640
|
+
interface JWTProtectedHeader {
|
|
641
|
+
alg?: string;
|
|
642
|
+
kid?: string;
|
|
643
|
+
x5t?: string;
|
|
644
|
+
x5c?: string[];
|
|
645
|
+
x5u?: string;
|
|
646
|
+
jku?: string;
|
|
647
|
+
typ?: string;
|
|
648
|
+
cty?: string;
|
|
649
|
+
crit?: string[];
|
|
650
|
+
b64?: boolean;
|
|
651
|
+
enc?: string;
|
|
652
|
+
[propName: string]: unknown;
|
|
653
|
+
}
|
|
654
|
+
interface JWTPayload {
|
|
655
|
+
iss?: string;
|
|
656
|
+
sub?: string;
|
|
657
|
+
aud?: string | string[];
|
|
658
|
+
jti?: string;
|
|
659
|
+
nbf?: number;
|
|
660
|
+
exp?: number;
|
|
661
|
+
iat?: number;
|
|
662
|
+
[propName: string]: unknown;
|
|
663
|
+
}
|
|
664
|
+
type Jwt = {
|
|
665
|
+
header: JWTProtectedHeader;
|
|
666
|
+
payload: JWTPayload;
|
|
667
|
+
signature: Uint8Array;
|
|
668
|
+
raw: {
|
|
669
|
+
header: string;
|
|
670
|
+
payload: string;
|
|
671
|
+
signature: string;
|
|
672
|
+
text: string;
|
|
673
|
+
};
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
type SignInRedirectUrl = {
|
|
677
|
+
signInForceRedirectUrl?: string | null;
|
|
678
|
+
};
|
|
679
|
+
type SignUpRedirectUrl = {
|
|
680
|
+
signUpForceRedirectUrl?: string | null;
|
|
681
|
+
};
|
|
682
|
+
type AfterSignOutUrl = {
|
|
683
|
+
afterSignOutUrl?: string | null;
|
|
684
|
+
};
|
|
685
|
+
type RedirectOptions = SignInRedirectUrl | SignUpRedirectUrl;
|
|
686
|
+
|
|
687
|
+
interface InitialState {
|
|
688
|
+
userId: string | null;
|
|
689
|
+
token: any | null;
|
|
690
|
+
email: string | null;
|
|
691
|
+
user?: TernSecureUser | null;
|
|
692
|
+
}
|
|
585
693
|
interface TernSecureState {
|
|
586
694
|
userId: string | null;
|
|
587
695
|
isLoaded: boolean;
|
|
@@ -594,7 +702,7 @@ interface TernSecureState {
|
|
|
594
702
|
status: "loading" | "authenticated" | "unauthenticated" | "unverified";
|
|
595
703
|
user?: TernSecureUser | null;
|
|
596
704
|
}
|
|
597
|
-
type AuthProviderStatus =
|
|
705
|
+
type AuthProviderStatus = "idle" | "pending" | "error" | "success";
|
|
598
706
|
declare const DEFAULT_TERN_SECURE_STATE: TernSecureState;
|
|
599
707
|
interface TernSecureAuthProvider {
|
|
600
708
|
/** Current auth state */
|
|
@@ -606,25 +714,172 @@ interface TernSecureAuthProvider {
|
|
|
606
714
|
/** Current session */
|
|
607
715
|
currentSession: SignedInSession | null;
|
|
608
716
|
/** Sign in resource for authentication operations */
|
|
609
|
-
signIn: SignInResource;
|
|
717
|
+
signIn: SignInResource | undefined;
|
|
610
718
|
/** SignUp resource for authentication operations */
|
|
611
|
-
signUp: SignUpResource;
|
|
719
|
+
signUp: SignUpResource | undefined;
|
|
612
720
|
/** The Firebase configuration used by this TernAuth instance. */
|
|
613
721
|
ternSecureConfig?: TernSecureConfig;
|
|
614
722
|
/** Sign out the current user */
|
|
615
723
|
signOut(): Promise<void>;
|
|
616
724
|
}
|
|
617
|
-
|
|
618
|
-
type
|
|
619
|
-
|
|
725
|
+
type Persistence = "local" | "session" | "browserCookie" | "none";
|
|
726
|
+
type Mode$1 = "browser" | "server";
|
|
727
|
+
type TernAuthSDK = {
|
|
728
|
+
/** SDK package name (e.g., @tern-secure/auth) */
|
|
729
|
+
name: string;
|
|
730
|
+
/** SDK version (e.g., 1.2.3) */
|
|
731
|
+
version: string;
|
|
732
|
+
/** Build environment (development, production, test) */
|
|
733
|
+
environment?: string;
|
|
734
|
+
/** Build date as ISO string */
|
|
735
|
+
buildDate?: string;
|
|
736
|
+
/** Additional build metadata */
|
|
737
|
+
buildInfo?: {
|
|
738
|
+
name: string;
|
|
739
|
+
version: string;
|
|
740
|
+
buildDate: string;
|
|
741
|
+
buildEnv: string;
|
|
742
|
+
};
|
|
620
743
|
};
|
|
621
|
-
|
|
622
|
-
|
|
744
|
+
interface TernSecureResources {
|
|
745
|
+
user?: TernSecureUser | null;
|
|
746
|
+
session?: SignedInSession | null;
|
|
747
|
+
}
|
|
748
|
+
type TernSecureAuthOptions = {
|
|
749
|
+
apiUrl?: string;
|
|
750
|
+
sdkMetadata?: TernAuthSDK;
|
|
751
|
+
signInUrl?: string;
|
|
752
|
+
signUpUrl?: string;
|
|
753
|
+
mode?: Mode$1;
|
|
754
|
+
requiresVerification?: boolean;
|
|
755
|
+
isTernSecureDev?: boolean;
|
|
756
|
+
ternSecureConfig?: TernSecureConfig;
|
|
757
|
+
persistence?: Persistence;
|
|
758
|
+
enableServiceWorker?: boolean;
|
|
759
|
+
} & SignInRedirectUrl & SignUpRedirectUrl & AfterSignOutUrl;
|
|
760
|
+
type TernAuthListenerEventPayload = {
|
|
761
|
+
authStateChanged: TernSecureState;
|
|
762
|
+
userChanged: TernSecureUser;
|
|
763
|
+
sessionChanged: SignedInSession | null;
|
|
764
|
+
tokenRefreshed: string | null;
|
|
765
|
+
};
|
|
766
|
+
type TernAuthListenerEvent = keyof TernAuthListenerEventPayload;
|
|
767
|
+
type ListenerCallback = (emission: TernSecureResources) => void;
|
|
768
|
+
type UnsubscribeCallback = () => void;
|
|
769
|
+
type TernSecureEvent = keyof TernAuthEventPayload;
|
|
770
|
+
type EventHandler<Events extends TernSecureEvent> = (payload: TernAuthEventPayload[Events]) => void;
|
|
771
|
+
type TernAuthEventPayload = {
|
|
772
|
+
status: TernSecureAuthStatus;
|
|
773
|
+
};
|
|
774
|
+
type TernSecureAuthStatus = "error" | "loading" | "ready";
|
|
775
|
+
type onEventListener = <E extends TernSecureEvent>(event: E, handler: EventHandler<E>, opt?: {
|
|
776
|
+
notify?: boolean;
|
|
777
|
+
}) => void;
|
|
778
|
+
type OffEventListener = <E extends TernSecureEvent>(event: E, handler: EventHandler<E>) => void;
|
|
779
|
+
type SignOutOptions = {
|
|
780
|
+
/** URL to redirect to after sign out */
|
|
781
|
+
redirectUrl?: string;
|
|
782
|
+
/** Callback to perform consumer-specific cleanup (e.g., delete session cookies) */
|
|
783
|
+
onBeforeSignOut?: () => Promise<void> | void;
|
|
784
|
+
/** Callback executed after successful sign out */
|
|
785
|
+
onAfterSignOut?: () => Promise<void> | void;
|
|
786
|
+
};
|
|
787
|
+
interface SignOut {
|
|
788
|
+
(options?: SignOutOptions): Promise<void>;
|
|
789
|
+
}
|
|
790
|
+
interface TernSecureAuth {
|
|
791
|
+
/** TernSecureAuth SDK version number */
|
|
792
|
+
version: string | undefined;
|
|
793
|
+
/** Metadata about the SDK instance */
|
|
794
|
+
sdkMetadata: TernAuthSDK | undefined;
|
|
795
|
+
/** Indicates if the TernSecureAuth instance is currently loading */
|
|
796
|
+
isLoading: boolean;
|
|
797
|
+
/** The current status of the TernSecureAuth instance */
|
|
798
|
+
status: TernSecureAuthStatus;
|
|
799
|
+
/** TernSecure API URL */
|
|
800
|
+
apiUrl: string;
|
|
801
|
+
/** TernSecure domain for API string */
|
|
802
|
+
domain: string;
|
|
803
|
+
/** TernSecure Proxy url */
|
|
804
|
+
proxyUrl?: string;
|
|
805
|
+
/** TernSecure Instance type */
|
|
806
|
+
instanceType: InstanceType | undefined;
|
|
807
|
+
/** Indicates if the TernSecureAuth instance is ready for use */
|
|
808
|
+
isReady: boolean;
|
|
809
|
+
/** Requires Verification */
|
|
810
|
+
requiresVerification: boolean;
|
|
811
|
+
/** Initialize TernSecureAuth */
|
|
812
|
+
initialize(options?: TernSecureAuthOptions): Promise<void>;
|
|
813
|
+
/** Current user*/
|
|
814
|
+
user: TernSecureUser | null | undefined;
|
|
815
|
+
/** Current session */
|
|
816
|
+
currentSession: SignedInSession | null;
|
|
817
|
+
/** Sign in resource for authentication operations */
|
|
818
|
+
signIn: SignInResource | undefined | null;
|
|
819
|
+
/** SignUp resource for authentication operations */
|
|
820
|
+
signUp: SignUpResource | undefined | null;
|
|
821
|
+
/** The Firebase configuration used by this TernAuth instance. */
|
|
822
|
+
ternSecureConfig?: TernSecureConfig;
|
|
823
|
+
/** Subscribe to auth state changes */
|
|
824
|
+
onAuthStateChanged(callback: (cb: any) => void): () => void;
|
|
825
|
+
/** Sign out the current user */
|
|
826
|
+
signOut: SignOut;
|
|
827
|
+
/** Subscribe to a single event */
|
|
828
|
+
on: onEventListener;
|
|
829
|
+
/** Remove event listener */
|
|
830
|
+
off: OffEventListener;
|
|
831
|
+
addListener: (callback: ListenerCallback) => UnsubscribeCallback;
|
|
832
|
+
}
|
|
833
|
+
interface TernSecureAuthFactory {
|
|
834
|
+
create(options?: TernSecureAuthOptions): TernSecureAuth;
|
|
835
|
+
}
|
|
836
|
+
type SharedSignInAuthObjectProperties = {
|
|
837
|
+
session: DecodedIdToken;
|
|
838
|
+
userId: string;
|
|
839
|
+
};
|
|
840
|
+
type CheckCustomClaims = {
|
|
841
|
+
role?: string | string[];
|
|
842
|
+
permissions?: string | string[];
|
|
843
|
+
[key: string]: any;
|
|
844
|
+
};
|
|
845
|
+
type CheckAuthorizationFromSessionClaims = (isAuthorizedParams: CheckCustomClaims) => boolean;
|
|
846
|
+
type TernVerificationResult = (DecodedIdToken & {
|
|
847
|
+
valid: true;
|
|
848
|
+
token?: string;
|
|
849
|
+
error?: never;
|
|
850
|
+
}) | {
|
|
851
|
+
valid: false;
|
|
852
|
+
error: AuthErrorResponse;
|
|
623
853
|
};
|
|
624
|
-
type RedirectOptions = SignInRedirectUrl | SignUpRedirectUrl;
|
|
625
854
|
|
|
626
855
|
type Mode = 'browser' | 'server';
|
|
856
|
+
type TernSecureSDK = {
|
|
857
|
+
/** SDK package name (e.g., @tern-secure/ui) */
|
|
858
|
+
name: string;
|
|
859
|
+
/** SDK version (e.g., 1.2.3) */
|
|
860
|
+
version: string;
|
|
861
|
+
/** Build environment (development, production, test) */
|
|
862
|
+
environment?: string;
|
|
863
|
+
/** Build date as ISO string */
|
|
864
|
+
buildDate?: string;
|
|
865
|
+
/** Additional build metadata */
|
|
866
|
+
buildInfo?: {
|
|
867
|
+
name: string;
|
|
868
|
+
version: string;
|
|
869
|
+
buildDate: string;
|
|
870
|
+
buildEnv: string;
|
|
871
|
+
};
|
|
872
|
+
};
|
|
873
|
+
type SignOutOptionsTree = {
|
|
874
|
+
/** URL to redirect to after sign out */
|
|
875
|
+
redirectUrl?: string;
|
|
876
|
+
/** Callback to perform consumer-specific cleanup (e.g., delete session cookies) */
|
|
877
|
+
onBeforeSignOut?: () => Promise<void> | void;
|
|
878
|
+
/** Callback executed after successful sign out */
|
|
879
|
+
onAfterSignOut?: () => Promise<void> | void;
|
|
880
|
+
};
|
|
627
881
|
type TernSecureInstanceTreeOptions = {
|
|
882
|
+
sdkMetadata?: TernSecureSDK;
|
|
628
883
|
initialSession?: TernSecureSessionTree | null;
|
|
629
884
|
defaultAppearance?: Appearance;
|
|
630
885
|
signInUrl?: string;
|
|
@@ -632,17 +887,18 @@ type TernSecureInstanceTreeOptions = {
|
|
|
632
887
|
mode?: Mode;
|
|
633
888
|
onAuthStateChanged?: (user: TernSecureUser | null) => void;
|
|
634
889
|
onError?: (error: AuthErrorTree) => void;
|
|
635
|
-
environment?: string | undefined;
|
|
636
890
|
requiresVerification?: boolean;
|
|
637
891
|
isTernSecureDev?: boolean;
|
|
638
892
|
ternSecureConfig?: TernSecureConfig;
|
|
639
893
|
enableServiceWorker?: boolean;
|
|
640
|
-
} & SignInRedirectUrl & SignUpRedirectUrl;
|
|
894
|
+
} & SignInRedirectUrl & SignUpRedirectUrl & AfterSignOutUrl;
|
|
641
895
|
type TernSecureInstanceTreeStatus = 'error' | 'loading' | 'ready';
|
|
642
896
|
/**
|
|
643
897
|
* Instance interface for managing auth UI state
|
|
644
898
|
*/
|
|
645
899
|
interface TernSecureInstanceTree {
|
|
900
|
+
version: string | undefined;
|
|
901
|
+
sdkMetadata: TernSecureSDK | undefined;
|
|
646
902
|
customDomain?: string;
|
|
647
903
|
proxyUrl?: string;
|
|
648
904
|
apiKey?: string;
|
|
@@ -665,6 +921,8 @@ interface TernSecureInstanceTree {
|
|
|
665
921
|
};
|
|
666
922
|
/** Core Authentication Methods */
|
|
667
923
|
ternAuth: TernSecureAuthProvider | undefined;
|
|
924
|
+
/** Sign out current user with optional cleanup */
|
|
925
|
+
signOut: (options?: SignOutOptionsTree) => Promise<void>;
|
|
668
926
|
showSignIn: (targetNode: HTMLDivElement, config?: SignInPropsTree) => void;
|
|
669
927
|
hideSignIn: (targetNode: HTMLDivElement) => void;
|
|
670
928
|
showSignUp: (targetNode: HTMLDivElement, config?: SignUpPropsTree) => void;
|
|
@@ -695,6 +953,23 @@ interface TernSecureInstanceTree {
|
|
|
695
953
|
onStatusChanged: (callback: (status: TernSecureInstanceTreeStatus) => void) => () => void;
|
|
696
954
|
};
|
|
697
955
|
}
|
|
956
|
+
/**
|
|
957
|
+
* Instance interface for managing auth UI state
|
|
958
|
+
*/
|
|
959
|
+
interface TernSecureInstance {
|
|
960
|
+
customDomain?: string;
|
|
961
|
+
proxyUrl?: string;
|
|
962
|
+
apiKey?: string;
|
|
963
|
+
projectId?: string;
|
|
964
|
+
environment?: string | undefined;
|
|
965
|
+
mode?: Mode;
|
|
966
|
+
isReady: boolean;
|
|
967
|
+
isLoading: boolean;
|
|
968
|
+
error: Error | null;
|
|
969
|
+
requiresVerification: boolean;
|
|
970
|
+
/** Sign out current user with optional cleanup */
|
|
971
|
+
signOut: (options?: SignOutOptionsTree) => Promise<void>;
|
|
972
|
+
}
|
|
698
973
|
type SignUpFormValuesTree = {
|
|
699
974
|
email: string;
|
|
700
975
|
password: string;
|
|
@@ -736,4 +1011,44 @@ type SignUpPropsTree = {
|
|
|
736
1011
|
type SignInRedirectOptions = RedirectOptions;
|
|
737
1012
|
type SignUpRedirectOptions = RedirectOptions;
|
|
738
1013
|
|
|
739
|
-
|
|
1014
|
+
interface TernSecureApiErrorJSON {
|
|
1015
|
+
code: string;
|
|
1016
|
+
message: string;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
type UseAuthReturn = {
|
|
1020
|
+
userId: string | null | undefined;
|
|
1021
|
+
isLoaded: boolean;
|
|
1022
|
+
isValid: boolean;
|
|
1023
|
+
isVerified: boolean;
|
|
1024
|
+
isAuthenticated: boolean;
|
|
1025
|
+
token: any | null;
|
|
1026
|
+
email: string | null;
|
|
1027
|
+
status: "loading" | "authenticated" | "unauthenticated" | "unverified";
|
|
1028
|
+
user?: TernSecureUser | null;
|
|
1029
|
+
signOut: SignOut;
|
|
1030
|
+
};
|
|
1031
|
+
type UseSignInReturn = {
|
|
1032
|
+
isLoaded: false;
|
|
1033
|
+
signIn: undefined;
|
|
1034
|
+
} | {
|
|
1035
|
+
isLoaded: true;
|
|
1036
|
+
signIn: SignInResource;
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
type DomainOrProxyUrl = {
|
|
1040
|
+
proxyUrl?: never;
|
|
1041
|
+
domain?: string | ((url: URL) => string);
|
|
1042
|
+
} | {
|
|
1043
|
+
proxyUrl?: string | ((url: URL) => string);
|
|
1044
|
+
domain?: never;
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Enables autocompletion for a union type, while keeping the ability to use any string
|
|
1049
|
+
* or type of `T`
|
|
1050
|
+
* @internal
|
|
1051
|
+
*/
|
|
1052
|
+
type Autocomplete<U extends T, T = string> = U | (T & Record<never, never>);
|
|
1053
|
+
|
|
1054
|
+
export { type ActiveSession, type AdminConfigValidationResult, type AfterSignOutUrl, type Appearance, type AuthActions, type AuthError, type AuthErrorCode, type AuthErrorResponse, type AuthErrorTree, type AuthProviderStatus, type Autocomplete, type BaseAuthUIConfig, type CheckAuthorizationFromSessionClaims, type CheckCustomClaims, type ConfigValidationResult, type CookieOptions, type CookieStore, DEFAULT_TERN_SECURE_STATE, type DecodedIdToken, type DomainOrProxyUrl, ERRORS, 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 RedirectConfig, type RedirectOptions, type ResendEmailVerification, type ServerConfigValidationResult, type SessionParams, type SessionResult, type SessionStatus, 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 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 UnsubscribeCallback, type UseAuthReturn, type UseSignInReturn, type UserInfo, type VerifiedTokens, isSignInResponse, isSignInResponseTree };
|