@tern-secure/types 1.1.0-canary.v20250919134427 → 1.1.0-canary.v20250926170202
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.map +1 -1
- package/dist/index.d.mts +78 -1
- package/dist/index.d.ts +78 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors.ts","../../src/ternsecure.ts","../../src/auth.ts","../../src/signIn.ts"],"sourcesContent":["\r\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\nexport type ErrorCode = keyof typeof ERRORS\r\n\r\n\r\nexport const ERRORS = {\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"AUTH_REQUIRES_VERIFICATION\",\r\n AUTHENTICATED: \"AUTHENTICATED\",\r\n UNAUTHENTICATED: \"UNAUTHENTICATED\",\r\n UNVERIFIED: \"UNVERIFIED\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized. Call initializeTernSecure() first\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n EMAIL_NOT_VERIFIED: \"EMAIL_NOT_VERIFIED\",\r\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\r\n USER_DISABLED: \"USER_DISABLED\",\r\n TOO_MANY_ATTEMPTS: \"TOO_MANY_ATTEMPTS\",\r\n NETWORK_ERROR: \"NETWORK_ERROR\",\r\n INVALID_EMAIL: \"INVALID_EMAIL\",\r\n WEAK_PASSWORD: \"WEAK_PASSWORD\",\r\n EMAIL_EXISTS: \"EMAIL_EXISTS\",\r\n POPUP_BLOCKED: \"POPUP_BLOCKED\",\r\n OPERATION_NOT_ALLOWED: \"OPERATION_NOT_ALLOWED\",\r\n EXPIRED_TOKEN: \"EXPIRED_TOKEN\",\r\n INVALID_TOKEN: \"INVALID_TOKEN\",\r\n SESSION_EXPIRED: \"SESSION_EXPIRED\",\r\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"auth/user-not-found\",\r\n WRONG_PASSWORD: \"auth/wrong-password\",\r\n EMAIL_ALREADY_IN_USE: \"auth/email-already-in-use\",\r\n REQUIRES_RECENT_LOGIN: \"auth/requires-recent-login\",\r\n NO_SESSION_COOKIE: \"No session cookie found.\",\r\n INVALID_SESSION_COOKIE: \"Invalid session cookie.\",\r\n NO_ID_TOKEN: \"No ID token found.\",\r\n INVALID_ID_TOKEN: \"Invalid ID token.\",\r\n REDIRECT_LOOP: \"Redirect loop detected.\",\r\n} as const\r\n\r\n","import type { \n TernSecureUser \n} from './all';\nimport type { Appearance } from './theme';\n\nexport interface TernSecureSession {\n token: string | null;\n expiresAt?: number;\n}\n\ntype SignInFormValues = {\n email: string;\n password: string;\n phoneNumber?: string;\n}\n\nexport type SignInInitialValue = Partial<SignInFormValues>;\n\n\ntype SignUpFormValues = {\n email: string;\n password: string;\n confirmPassword?: string;\n displayName?: string;\n};\n\n\nexport type SignUpInitialValue = Partial<SignUpFormValues>;\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\nexport interface AuthError extends Error {\n code?: any | string \n message: string\n response?: SignInResponse\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return typeof value === \"object\" && \"success\" in value && typeof value.success === \"boolean\"\n}\n\nexport interface AuthActions {\n signInWithEmail: (email: string, password: string) => Promise<SignInResponse>;\n signInWithGoogle: () => Promise<void>;\n signInWithMicrosoft: () => Promise<void>;\n signOut: () => Promise<void>;\n getRedirectResult: () => Promise<any>;\n getIdToken: () => Promise<string | null>;\n createUserWithEmailAndPassword?: (email: string, password: string) => Promise<SignInResponse>;\n sendEmailVerification?: (user: TernSecureUser) => Promise<void>;\n}\n\nexport interface RedirectConfig {\n // URL to redirect to after successful authentication\n redirectUrl?: string\n // Whether this is a return visit (e.g. after sign out)\n isReturn?: boolean\n // Priority of the redirect (higher number = higher priority)\n priority?: number\n}\n\n\nexport interface SignInProps extends RedirectConfig {\n initialValue?: SignInInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n\n/**\n * SignUpProps interface defines the properties for the sign-up component.\n * It extends RedirectConfig to include redirect-related properties.\n */\nexport interface SignUpProps extends RedirectConfig {\n initialValue?: SignUpInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n/**\n * Defines the contract for a TernSecure instance.\n * This instance provides authentication state, user information, and methods\n * for managing the authentication lifecycle. It is designed to be used by\n * UI packages like tern-ui, which act as \"dumb\" renderers.\n */\nexport interface TernSecureInstanceOld {\n /** Indicates if the user is currently signed in. */\n isSignedIn: () => boolean;\n\n /** The current authenticated user object, or null if not signed in. */\n user: TernSecureUser | null;\n\n /** The current user session information, or null if not signed in. */\n session: TernSecureSession | null;\n\n /** Initiates the sign-out process for the current user. */\n signOut: () => Promise<void>;\n\n /**\n * Prepares or signals to mount the sign-in interface.\n * @param options Optional configuration or initial state for the sign-in UI, conforming to SignInProps.\n */\n mountSignIn: (options?: SignInProps) => void;\n\n /** Cleans up or signals to unmount the sign-in interface. */\n unmountSignIn: () => void;\n\n /**\n * Prepares or signals to mount the sign-up interface.\n * @param options Optional configuration or initial state for the sign-up UI, conforming to SignUpProps.\n */\n mountSignUp: (options?: SignUpProps) => void;\n\n /** Cleans up or signals to unmount the sign-up interface. */\n unmountSignUp: () => void;\n\n /**\n * Determines if a redirect is necessary based on the current authentication\n * state and the given path.\n * @param currentPath The current URL path.\n * @returns True if a redirect is needed, false otherwise, or a string path to redirect to.\n */\n shouldRedirect: (currentPath: string) => boolean | string;\n\n /**\n * Constructs a URL, appending necessary redirect parameters.\n * Useful for redirecting back to the original page after authentication.\n * @param baseUrl The base URL to which redirect parameters should be added.\n * @returns The new URL string with redirect parameters.\n */\n constructUrlWithRedirect: (baseUrl: string) => string;\n\n /**\n * Redirects the user to the configured login page.\n * @param redirectUrl Optional URL to redirect to after successful login.\n */\n redirectToLogin: (redirectUrl?: string) => void;\n\n /** Indicates if an authentication operation is currently in progress. */\n isLoading: boolean;\n\n /** Holds any error that occurred during an authentication operation, or null otherwise. */\n error: Error | null;\n \n /** Indicates if the user has verified their email address. */\n sendVerificationEmail: () => Promise<void>;\n}","import type { SignedInSession } from \"session\";\nimport type { SignUpResource } from \"signUp\";\n\nimport type { InstanceType,TernSecureConfig, TernSecureUser } from \"./all\";\nimport type { DecodedIdToken } from \"./jwt\";\nimport type {\n AfterSignOutUrl,\n SignInRedirectUrl,\n SignUpRedirectUrl,\n} from \"./redirect\";\nimport type { AuthErrorResponse,SignInResource } from \"./signIn\";\n\nexport interface InitialState {\n userId: string | null;\n token: any | null;\n email: string | null;\n user?: TernSecureUser | null;\n}\n\nexport interface TernSecureState {\n userId: string | null;\n isLoaded: boolean;\n error: Error | null;\n isValid: boolean;\n isVerified: boolean;\n isAuthenticated: boolean;\n token: any | null;\n email: string | null;\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\";\n user?: TernSecureUser | null;\n}\n\nexport type AuthProviderStatus = \"idle\" | \"pending\" | \"error\" | \"success\";\n\nexport const DEFAULT_TERN_SECURE_STATE: TernSecureState = {\n userId: null,\n isLoaded: false,\n error: null,\n isValid: false,\n isVerified: false,\n isAuthenticated: false,\n token: null,\n email: null,\n status: \"loading\",\n user: null,\n};\n\nexport interface TernSecureAuthProvider {\n /** Current auth state */\n internalAuthState: TernSecureState;\n\n /** Current user*/\n ternSecureUser(): TernSecureUser | null;\n\n /** AuthCookie Manager */\n authCookieManager(): void;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource | undefined;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource | undefined;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Sign out the current user */\n signOut(): Promise<void>;\n}\n\nexport type Persistence = \"local\" | \"session\" | \"browserCookie\" | \"none\";\n\ntype Mode = \"browser\" | \"server\";\n\nexport type TernAuthSDK = {\n /** SDK package name (e.g., @tern-secure/auth) */\n name: string;\n /** SDK version (e.g., 1.2.3) */\n version: string;\n /** Build environment (development, production, test) */\n environment?: string;\n /** Build date as ISO string */\n buildDate?: string;\n /** Additional build metadata */\n buildInfo?: {\n name: string;\n version: string;\n buildDate: string;\n buildEnv: string;\n };\n};\n\nexport interface TernSecureResources {\n user?: TernSecureUser | null;\n session?: SignedInSession | null;\n}\n\nexport type TernSecureAuthOptions = {\n apiUrl?: string;\n sdkMetadata?: TernAuthSDK;\n signInUrl?: string;\n signUpUrl?: string;\n mode?: Mode;\n requiresVerification?: boolean;\n isTernSecureDev?: boolean;\n ternSecureConfig?: TernSecureConfig;\n persistence?: Persistence;\n enableServiceWorker?: boolean;\n} & SignInRedirectUrl &\n SignUpRedirectUrl &\n AfterSignOutUrl;\n\nexport type TernAuthListenerEventPayload = {\n authStateChanged: TernSecureState;\n userChanged: TernSecureUser;\n sessionChanged: SignedInSession | null;\n tokenRefreshed: string | null;\n};\n\nexport type TernAuthListenerEvent = keyof TernAuthListenerEventPayload;\n\nexport type ListenerCallback = (emission: TernSecureResources) => void;\nexport type UnsubscribeCallback = () => void;\ntype TernSecureEvent = keyof TernAuthEventPayload;\ntype EventHandler<Events extends TernSecureEvent> = (\n payload: TernAuthEventPayload[Events]\n) => void;\nexport type TernAuthEventPayload = {\n status: TernSecureAuthStatus;\n};\n\nexport type TernSecureAuthStatus = \"error\" | \"loading\" | \"ready\";\n\ntype onEventListener = <E extends TernSecureEvent>(\n event: E,\n handler: EventHandler<E>, opt?: { notify?: boolean }\n) => void;\ntype OffEventListener = <E extends TernSecureEvent>(\n event: E,\n handler: EventHandler<E>\n) => void;\n\nexport type SignOutOptions = {\n /** URL to redirect to after sign out */\n redirectUrl?: string;\n /** Callback to perform consumer-specific cleanup (e.g., delete session cookies) */\n onBeforeSignOut?: () => Promise<void> | void;\n /** Callback executed after successful sign out */\n onAfterSignOut?: () => Promise<void> | void;\n};\n\nexport interface SignOut {\n (options?: SignOutOptions): Promise<void>;\n}\n\nexport interface TernSecureAuth {\n /** TernSecureAuth SDK version number */\n version: string | undefined;\n\n /** Metadata about the SDK instance */\n sdkMetadata: TernAuthSDK | undefined;\n\n /** Indicates if the TernSecureAuth instance is currently loading */\n isLoading: boolean;\n\n /** The current status of the TernSecureAuth instance */\n status: TernSecureAuthStatus;\n\n /** TernSecure API URL */\n apiUrl: string;\n\n /** TernSecure domain for API string */\n domain: string;\n\n /** TernSecure Proxy url */\n proxyUrl?: string;\n\n /** TernSecure Instance type */\n instanceType: InstanceType | undefined;\n\n /** Indicates if the TernSecureAuth instance is ready for use */\n isReady: boolean;\n\n /** Requires Verification */\n requiresVerification: boolean;\n\n /** Initialize TernSecureAuth */\n initialize(options?: TernSecureAuthOptions): Promise<void>;\n\n /** Current user*/\n user: TernSecureUser | null | undefined;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource | undefined | null;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource | undefined | null;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Subscribe to auth state changes */\n onAuthStateChanged(callback: (cb: any) => void): () => void;\n\n /** Sign out the current user */\n signOut: SignOut;\n\n /** Subscribe to a single event */\n on: onEventListener;\n\n /** Remove event listener */\n off: OffEventListener;\n\n addListener: (callback: ListenerCallback) => UnsubscribeCallback;\n}\n\nexport interface TernSecureAuthFactory {\n create(options?: TernSecureAuthOptions): TernSecureAuth;\n}\n\nexport type SharedSignInAuthObjectProperties = {\n session: DecodedIdToken;\n userId: string;\n};\n\nexport type CheckCustomClaims = {\n role?: string | string[];\n permissions?: string | string[];\n [key: string]: any;\n};\n\nexport type CheckAuthorizationFromSessionClaims = (\n isAuthorizedParams: CheckCustomClaims,\n) => boolean;\n\nexport type TernVerificationResult =\n | (DecodedIdToken & {\n valid: true;\n token?: string;\n error?: never;\n })\n | {\n valid: false;\n error: AuthErrorResponse;\n };\n","import type { ErrorCode} from \"./errors\";\n\nexport type SignInStatus =\n | 'idle'\n | 'pending_email_password'\n | 'pending_social'\n | 'pending_mfa'\n | 'redirecting'\n | 'success'\n | 'error';\n\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\n};\n\nexport interface AuthErrorResponse {\n success: false\n message: string\n code: ErrorCode\n}\n\nexport interface AuthErrorTree extends Error {\n code?: any | string;\n message: string;\n response?: any | string;\n}\n\n\nexport interface SignInResponseTree {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\n\nexport type SignInInitialValueTree = Partial<SignInFormValuesTree>;\n\n\nexport interface ResendEmailVerification extends SignInResponseTree {\n isVerified?: boolean;\n}\n\nexport function isSignInResponseTree(value: any): value is SignInResponseTree {\n return (\n typeof value === 'object' &&\n 'success' in value &&\n typeof value.success === 'boolean'\n );\n}\n\n\nexport interface SignInResource {\n /**\n * The current status of the sign-in process.\n */\n status?: SignInStatus;\n /**\n * Signs in a user with their email and password.\n * @param params - The sign-in form values.\n * @returns A promise that resolves with the sign-in response.\n */\n withEmailAndPassword: (params: SignInFormValuesTree) => Promise<SignInResponseTree>;\n /**\n * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').\n * @param options - Optional configuration for the social sign-in flow.\n * @returns A promise that resolves with the sign-in response or void if redirecting.\n */\n withSocialProvider: (provider: string, options?: { mode?: 'popup' | 'redirect' }) => Promise<SignInResponseTree | void>;\n /**\n * Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.\n * @param mfaToken - The MFA token or code submitted by the user.\n * @param mfaContext - Optional context or session data from the MFA initiation step.\n * @returns A promise that resolves with the sign-in response upon successful MFA verification.\n */\n completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponseTree>;\n /**\n * Sends a password reset email to the given email address.\n * @param email - The user's email address.\n * @returns A promise that resolves when the email is sent.\n */\n sendPasswordResetEmail: (email: string) => Promise<void>;\n /**\n * Resends the email verification link to the user's email address.\n * @returns A promise that resolves with the sign-in response.\n */\n resendEmailVerification: () => Promise<ResendEmailVerification>;\n /**\n * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.\n * @returns A promise that resolves with the sign-in response or null if no result is available.\n */\n checkRedirectResult: () => Promise<SignInResponseTree | null>;\n}"],"mappings":";AAMO,IAAM,SAAS;AAAA,EACpB,4BAA4B;AAAA,EAC5B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,eAAe;AACjB;;;ACGO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;;;ACVO,IAAM,4BAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;;;ACCO,SAAS,qBAAqB,OAAyC;AAC5E,SACE,OAAO,UAAU,YACjB,aAAa,SACb,OAAO,MAAM,YAAY;AAE7B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/errors.ts","../../src/ternsecure.ts","../../src/auth.ts","../../src/signIn.ts"],"sourcesContent":["\r\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\nexport type ErrorCode = keyof typeof ERRORS\r\n\r\n\r\nexport const ERRORS = {\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"AUTH_REQUIRES_VERIFICATION\",\r\n AUTHENTICATED: \"AUTHENTICATED\",\r\n UNAUTHENTICATED: \"UNAUTHENTICATED\",\r\n UNVERIFIED: \"UNVERIFIED\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized. Call initializeTernSecure() first\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n EMAIL_NOT_VERIFIED: \"EMAIL_NOT_VERIFIED\",\r\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\r\n USER_DISABLED: \"USER_DISABLED\",\r\n TOO_MANY_ATTEMPTS: \"TOO_MANY_ATTEMPTS\",\r\n NETWORK_ERROR: \"NETWORK_ERROR\",\r\n INVALID_EMAIL: \"INVALID_EMAIL\",\r\n WEAK_PASSWORD: \"WEAK_PASSWORD\",\r\n EMAIL_EXISTS: \"EMAIL_EXISTS\",\r\n POPUP_BLOCKED: \"POPUP_BLOCKED\",\r\n OPERATION_NOT_ALLOWED: \"OPERATION_NOT_ALLOWED\",\r\n EXPIRED_TOKEN: \"EXPIRED_TOKEN\",\r\n INVALID_TOKEN: \"INVALID_TOKEN\",\r\n SESSION_EXPIRED: \"SESSION_EXPIRED\",\r\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"auth/user-not-found\",\r\n WRONG_PASSWORD: \"auth/wrong-password\",\r\n EMAIL_ALREADY_IN_USE: \"auth/email-already-in-use\",\r\n REQUIRES_RECENT_LOGIN: \"auth/requires-recent-login\",\r\n NO_SESSION_COOKIE: \"No session cookie found.\",\r\n INVALID_SESSION_COOKIE: \"Invalid session cookie.\",\r\n NO_ID_TOKEN: \"No ID token found.\",\r\n INVALID_ID_TOKEN: \"Invalid ID token.\",\r\n REDIRECT_LOOP: \"Redirect loop detected.\",\r\n} as const\r\n\r\n","import type { \n TernSecureUser \n} from './all';\nimport type { Appearance } from './theme';\n\nexport interface TernSecureSession {\n token: string | null;\n expiresAt?: number;\n}\n\ntype SignInFormValues = {\n email: string;\n password: string;\n phoneNumber?: string;\n}\n\nexport type SignInInitialValue = Partial<SignInFormValues>;\n\n\ntype SignUpFormValues = {\n email: string;\n password: string;\n confirmPassword?: string;\n displayName?: string;\n};\n\n\nexport type SignUpInitialValue = Partial<SignUpFormValues>;\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\nexport interface AuthError extends Error {\n code?: any | string \n message: string\n response?: SignInResponse\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return typeof value === \"object\" && \"success\" in value && typeof value.success === \"boolean\"\n}\n\nexport interface AuthActions {\n signInWithEmail: (email: string, password: string) => Promise<SignInResponse>;\n signInWithGoogle: () => Promise<void>;\n signInWithMicrosoft: () => Promise<void>;\n signOut: () => Promise<void>;\n getRedirectResult: () => Promise<any>;\n getIdToken: () => Promise<string | null>;\n createUserWithEmailAndPassword?: (email: string, password: string) => Promise<SignInResponse>;\n sendEmailVerification?: (user: TernSecureUser) => Promise<void>;\n}\n\nexport interface RedirectConfig {\n // URL to redirect to after successful authentication\n redirectUrl?: string\n // Whether this is a return visit (e.g. after sign out)\n isReturn?: boolean\n // Priority of the redirect (higher number = higher priority)\n priority?: number\n}\n\n\nexport interface SignInProps extends RedirectConfig {\n initialValue?: SignInInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n\n/**\n * SignUpProps interface defines the properties for the sign-up component.\n * It extends RedirectConfig to include redirect-related properties.\n */\nexport interface SignUpProps extends RedirectConfig {\n initialValue?: SignUpInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n/**\n * Defines the contract for a TernSecure instance.\n * This instance provides authentication state, user information, and methods\n * for managing the authentication lifecycle. It is designed to be used by\n * UI packages like tern-ui, which act as \"dumb\" renderers.\n */\nexport interface TernSecureInstanceOld {\n /** Indicates if the user is currently signed in. */\n isSignedIn: () => boolean;\n\n /** The current authenticated user object, or null if not signed in. */\n user: TernSecureUser | null;\n\n /** The current user session information, or null if not signed in. */\n session: TernSecureSession | null;\n\n /** Initiates the sign-out process for the current user. */\n signOut: () => Promise<void>;\n\n /**\n * Prepares or signals to mount the sign-in interface.\n * @param options Optional configuration or initial state for the sign-in UI, conforming to SignInProps.\n */\n mountSignIn: (options?: SignInProps) => void;\n\n /** Cleans up or signals to unmount the sign-in interface. */\n unmountSignIn: () => void;\n\n /**\n * Prepares or signals to mount the sign-up interface.\n * @param options Optional configuration or initial state for the sign-up UI, conforming to SignUpProps.\n */\n mountSignUp: (options?: SignUpProps) => void;\n\n /** Cleans up or signals to unmount the sign-up interface. */\n unmountSignUp: () => void;\n\n /**\n * Determines if a redirect is necessary based on the current authentication\n * state and the given path.\n * @param currentPath The current URL path.\n * @returns True if a redirect is needed, false otherwise, or a string path to redirect to.\n */\n shouldRedirect: (currentPath: string) => boolean | string;\n\n /**\n * Constructs a URL, appending necessary redirect parameters.\n * Useful for redirecting back to the original page after authentication.\n * @param baseUrl The base URL to which redirect parameters should be added.\n * @returns The new URL string with redirect parameters.\n */\n constructUrlWithRedirect: (baseUrl: string) => string;\n\n /**\n * Redirects the user to the configured login page.\n * @param redirectUrl Optional URL to redirect to after successful login.\n */\n redirectToLogin: (redirectUrl?: string) => void;\n\n /** Indicates if an authentication operation is currently in progress. */\n isLoading: boolean;\n\n /** Holds any error that occurred during an authentication operation, or null otherwise. */\n error: Error | null;\n \n /** Indicates if the user has verified their email address. */\n sendVerificationEmail: () => Promise<void>;\n}","import type { SignedInSession } from \"session\";\nimport type { SignUpResource } from \"signUp\";\n\nimport type { InstanceType,TernSecureConfig, TernSecureUser } from \"./all\";\nimport type { DecodedIdToken } from \"./jwt\";\nimport type {\n AfterSignOutUrl,\n SignInRedirectUrl,\n SignUpRedirectUrl,\n} from \"./redirect\";\nimport type { AuthErrorResponse,SignInResource } from \"./signIn\";\n\nexport interface InitialState {\n userId: string | null;\n token: any | null;\n email: string | null;\n user?: TernSecureUser | null;\n}\n\nexport interface TernSecureState {\n userId: string | null;\n isLoaded: boolean;\n error: Error | null;\n isValid: boolean;\n isVerified: boolean;\n isAuthenticated: boolean;\n token: any | null;\n email: string | null;\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\";\n user?: TernSecureUser | null;\n}\n\nexport type AuthProviderStatus = \"idle\" | \"pending\" | \"error\" | \"success\";\n\nexport const DEFAULT_TERN_SECURE_STATE: TernSecureState = {\n userId: null,\n isLoaded: false,\n error: null,\n isValid: false,\n isVerified: false,\n isAuthenticated: false,\n token: null,\n email: null,\n status: \"loading\",\n user: null,\n};\n\nexport interface TernSecureAuthProvider {\n /** Current auth state */\n internalAuthState: TernSecureState;\n\n /** Current user*/\n ternSecureUser(): TernSecureUser | null;\n\n /** AuthCookie Manager */\n authCookieManager(): void;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource | undefined;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource | undefined;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Sign out the current user */\n signOut(): Promise<void>;\n}\n\nexport type Persistence = \"local\" | \"session\" | \"browserCookie\" | \"none\";\n\ntype Mode = \"browser\" | \"server\";\n\nexport type TernAuthSDK = {\n /** SDK package name (e.g., @tern-secure/auth) */\n name: string;\n /** SDK version (e.g., 1.2.3) */\n version: string;\n /** Build environment (development, production, test) */\n environment?: string;\n /** Build date as ISO string */\n buildDate?: string;\n /** Additional build metadata */\n buildInfo?: {\n name: string;\n version: string;\n buildDate: string;\n buildEnv: string;\n };\n};\n\nexport interface TernSecureResources {\n user?: TernSecureUser | null;\n session?: SignedInSession | null;\n}\n\nexport type TernSecureAuthOptions = {\n apiUrl?: string;\n sdkMetadata?: TernAuthSDK;\n signInUrl?: string;\n signUpUrl?: string;\n mode?: Mode;\n requiresVerification?: boolean;\n isTernSecureDev?: boolean;\n ternSecureConfig?: TernSecureConfig;\n persistence?: Persistence;\n enableServiceWorker?: boolean;\n experimental?: {\n /** rethrow network errors that occur while the offline */\n rethrowOfflineNetworkErrors?: boolean;\n };\n} & SignInRedirectUrl &\n SignUpRedirectUrl &\n AfterSignOutUrl;\n\nexport type TernAuthListenerEventPayload = {\n authStateChanged: TernSecureState;\n userChanged: TernSecureUser;\n sessionChanged: SignedInSession | null;\n tokenRefreshed: string | null;\n};\n\nexport type TernAuthListenerEvent = keyof TernAuthListenerEventPayload;\n\nexport type ListenerCallback = (emission: TernSecureResources) => void;\nexport type UnsubscribeCallback = () => void;\ntype TernSecureEvent = keyof TernAuthEventPayload;\ntype EventHandler<Events extends TernSecureEvent> = (\n payload: TernAuthEventPayload[Events]\n) => void;\nexport type TernAuthEventPayload = {\n status: TernSecureAuthStatus;\n};\n\nexport type TernSecureAuthStatus = \"error\" | \"loading\" | \"ready\";\n\ntype onEventListener = <E extends TernSecureEvent>(\n event: E,\n handler: EventHandler<E>, opt?: { notify?: boolean }\n) => void;\ntype OffEventListener = <E extends TernSecureEvent>(\n event: E,\n handler: EventHandler<E>\n) => void;\n\nexport type SignOutOptions = {\n /** URL to redirect to after sign out */\n redirectUrl?: string;\n /** Callback to perform consumer-specific cleanup (e.g., delete session cookies) */\n onBeforeSignOut?: () => Promise<void> | void;\n /** Callback executed after successful sign out */\n onAfterSignOut?: () => Promise<void> | void;\n};\n\nexport interface SignOut {\n (options?: SignOutOptions): Promise<void>;\n}\n\nexport interface TernSecureAuth {\n /** TernSecureAuth SDK version number */\n version: string | undefined;\n\n /** Metadata about the SDK instance */\n sdkMetadata: TernAuthSDK | undefined;\n\n /** Indicates if the TernSecureAuth instance is currently loading */\n isLoading: boolean;\n\n /** The current status of the TernSecureAuth instance */\n status: TernSecureAuthStatus;\n\n /** TernSecure API URL */\n apiUrl: string;\n\n /** TernSecure domain for API string */\n domain: string;\n\n /** TernSecure Proxy url */\n proxyUrl?: string;\n\n /** TernSecure Instance type */\n instanceType: InstanceType | undefined;\n\n /** Indicates if the TernSecureAuth instance is ready for use */\n isReady: boolean;\n\n /** Requires Verification */\n requiresVerification: boolean;\n\n /** Initialize TernSecureAuth */\n initialize(options?: TernSecureAuthOptions): Promise<void>;\n\n /** Current user*/\n user: TernSecureUser | null | undefined;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource | undefined | null;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource | undefined | null;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Subscribe to auth state changes */\n onAuthStateChanged(callback: (cb: any) => void): () => void;\n\n /** Sign out the current user */\n signOut: SignOut;\n\n /** Subscribe to a single event */\n on: onEventListener;\n\n /** Remove event listener */\n off: OffEventListener;\n\n addListener: (callback: ListenerCallback) => UnsubscribeCallback;\n}\n\nexport interface TernSecureAuthFactory {\n create(options?: TernSecureAuthOptions): TernSecureAuth;\n}\n\nexport type SharedSignInAuthObjectProperties = {\n session: DecodedIdToken;\n userId: string;\n};\n\nexport type CheckCustomClaims = {\n role?: string | string[];\n permissions?: string | string[];\n [key: string]: any;\n};\n\nexport type CheckAuthorizationFromSessionClaims = (\n isAuthorizedParams: CheckCustomClaims,\n) => boolean;\n\nexport type TernVerificationResult =\n | (DecodedIdToken & {\n valid: true;\n token?: string;\n error?: never;\n })\n | {\n valid: false;\n error: AuthErrorResponse;\n };\n","import type { ErrorCode} from \"./errors\";\n\nexport type SignInStatus =\n | 'idle'\n | 'pending_email_password'\n | 'pending_social'\n | 'pending_mfa'\n | 'redirecting'\n | 'success'\n | 'error';\n\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\n};\n\nexport interface AuthErrorResponse {\n success: false\n message: string\n code: ErrorCode\n}\n\nexport interface AuthErrorTree extends Error {\n code?: any | string;\n message: string;\n response?: any | string;\n}\n\n\nexport interface SignInResponseTree {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\n\nexport type SignInInitialValueTree = Partial<SignInFormValuesTree>;\n\n\nexport interface ResendEmailVerification extends SignInResponseTree {\n isVerified?: boolean;\n}\n\nexport function isSignInResponseTree(value: any): value is SignInResponseTree {\n return (\n typeof value === 'object' &&\n 'success' in value &&\n typeof value.success === 'boolean'\n );\n}\n\n\nexport interface SignInResource {\n /**\n * The current status of the sign-in process.\n */\n status?: SignInStatus;\n /**\n * Signs in a user with their email and password.\n * @param params - The sign-in form values.\n * @returns A promise that resolves with the sign-in response.\n */\n withEmailAndPassword: (params: SignInFormValuesTree) => Promise<SignInResponseTree>;\n /**\n * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').\n * @param options - Optional configuration for the social sign-in flow.\n * @returns A promise that resolves with the sign-in response or void if redirecting.\n */\n withSocialProvider: (provider: string, options?: { mode?: 'popup' | 'redirect' }) => Promise<SignInResponseTree | void>;\n /**\n * Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.\n * @param mfaToken - The MFA token or code submitted by the user.\n * @param mfaContext - Optional context or session data from the MFA initiation step.\n * @returns A promise that resolves with the sign-in response upon successful MFA verification.\n */\n completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponseTree>;\n /**\n * Sends a password reset email to the given email address.\n * @param email - The user's email address.\n * @returns A promise that resolves when the email is sent.\n */\n sendPasswordResetEmail: (email: string) => Promise<void>;\n /**\n * Resends the email verification link to the user's email address.\n * @returns A promise that resolves with the sign-in response.\n */\n resendEmailVerification: () => Promise<ResendEmailVerification>;\n /**\n * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.\n * @returns A promise that resolves with the sign-in response or null if no result is available.\n */\n checkRedirectResult: () => Promise<SignInResponseTree | null>;\n}"],"mappings":";AAMO,IAAM,SAAS;AAAA,EACpB,4BAA4B;AAAA,EAC5B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,eAAe;AACjB;;;ACGO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;;;ACVO,IAAM,4BAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;;;ACCO,SAAS,qBAAqB,OAAyC;AAC5E,SACE,OAAO,UAAU,YACjB,aAAa,SACb,OAAO,MAAM,YAAY;AAE7B;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -176,6 +176,79 @@ declare const ERRORS: {
|
|
|
176
176
|
readonly REDIRECT_LOOP: "Redirect loop detected.";
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
type AuthEndpoint = 'sessions' | 'users';
|
|
180
|
+
type SessionSubEndpoint = 'verify' | 'createsession' | 'refresh' | 'revoke';
|
|
181
|
+
interface CorsOptions {
|
|
182
|
+
allowedOrigins: string[] | '*';
|
|
183
|
+
allowedMethods?: string[];
|
|
184
|
+
allowedHeaders?: string[];
|
|
185
|
+
allowCredentials?: boolean;
|
|
186
|
+
maxAge?: number;
|
|
187
|
+
skipSameOrigin?: boolean;
|
|
188
|
+
}
|
|
189
|
+
interface SessionCookieConfig {
|
|
190
|
+
domain?: string;
|
|
191
|
+
path?: string;
|
|
192
|
+
httpOnly?: boolean;
|
|
193
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
194
|
+
maxAge?: number;
|
|
195
|
+
}
|
|
196
|
+
interface TokenCookieConfig {
|
|
197
|
+
domain?: string;
|
|
198
|
+
path: string;
|
|
199
|
+
httpOnly: boolean;
|
|
200
|
+
sameSite: 'strict' | 'lax' | 'none';
|
|
201
|
+
maxAge: number;
|
|
202
|
+
}
|
|
203
|
+
interface CookieOpts extends CookieOptions {
|
|
204
|
+
namePrefix?: string;
|
|
205
|
+
domain?: string;
|
|
206
|
+
session?: SessionCookieConfig;
|
|
207
|
+
}
|
|
208
|
+
interface RateLimitOptions {
|
|
209
|
+
windowMs?: number;
|
|
210
|
+
maxRequests?: number;
|
|
211
|
+
skipSuccessful?: boolean;
|
|
212
|
+
skipFailedRequests?: boolean;
|
|
213
|
+
}
|
|
214
|
+
interface SecurityOptions {
|
|
215
|
+
requireCSRF?: boolean;
|
|
216
|
+
allowedReferers?: string[];
|
|
217
|
+
requiredHeaders?: Record<string, string>;
|
|
218
|
+
ipWhitelist?: string[];
|
|
219
|
+
userAgent?: {
|
|
220
|
+
block?: string[];
|
|
221
|
+
allow?: string[];
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
interface EndpointConfig {
|
|
225
|
+
enabled: boolean;
|
|
226
|
+
methods: ('GET' | 'POST' | 'PUT' | 'DELETE')[];
|
|
227
|
+
requireAuth?: boolean;
|
|
228
|
+
rateLimit?: RateLimitOptions;
|
|
229
|
+
security?: SecurityOptions;
|
|
230
|
+
cors?: Partial<CorsOptions>;
|
|
231
|
+
}
|
|
232
|
+
interface SessionEndpointConfig extends EndpointConfig {
|
|
233
|
+
subEndpoints?: {
|
|
234
|
+
[K in SessionSubEndpoint]?: Partial<EndpointConfig>;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
interface TernSecureHandlerOptions {
|
|
238
|
+
cors?: CorsOptions;
|
|
239
|
+
cookies?: CookieOpts;
|
|
240
|
+
rateLimit?: RateLimitOptions;
|
|
241
|
+
security?: SecurityOptions;
|
|
242
|
+
endpoints?: {
|
|
243
|
+
sessions?: SessionEndpointConfig;
|
|
244
|
+
};
|
|
245
|
+
tenantId?: string | null;
|
|
246
|
+
enableCustomToken?: boolean;
|
|
247
|
+
debug?: boolean;
|
|
248
|
+
environment?: 'development' | 'production' | 'test';
|
|
249
|
+
basePath?: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
179
252
|
/**
|
|
180
253
|
* Defines the basic structure for color theming.
|
|
181
254
|
*/
|
|
@@ -756,6 +829,10 @@ type TernSecureAuthOptions = {
|
|
|
756
829
|
ternSecureConfig?: TernSecureConfig;
|
|
757
830
|
persistence?: Persistence;
|
|
758
831
|
enableServiceWorker?: boolean;
|
|
832
|
+
experimental?: {
|
|
833
|
+
/** rethrow network errors that occur while the offline */
|
|
834
|
+
rethrowOfflineNetworkErrors?: boolean;
|
|
835
|
+
};
|
|
759
836
|
} & SignInRedirectUrl & SignUpRedirectUrl & AfterSignOutUrl;
|
|
760
837
|
type TernAuthListenerEventPayload = {
|
|
761
838
|
authStateChanged: TernSecureState;
|
|
@@ -1051,4 +1128,4 @@ type DomainOrProxyUrl = {
|
|
|
1051
1128
|
*/
|
|
1052
1129
|
type Autocomplete<U extends T, T = string> = U | (T & Record<never, never>);
|
|
1053
1130
|
|
|
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 };
|
|
1131
|
+
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 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -176,6 +176,79 @@ declare const ERRORS: {
|
|
|
176
176
|
readonly REDIRECT_LOOP: "Redirect loop detected.";
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
type AuthEndpoint = 'sessions' | 'users';
|
|
180
|
+
type SessionSubEndpoint = 'verify' | 'createsession' | 'refresh' | 'revoke';
|
|
181
|
+
interface CorsOptions {
|
|
182
|
+
allowedOrigins: string[] | '*';
|
|
183
|
+
allowedMethods?: string[];
|
|
184
|
+
allowedHeaders?: string[];
|
|
185
|
+
allowCredentials?: boolean;
|
|
186
|
+
maxAge?: number;
|
|
187
|
+
skipSameOrigin?: boolean;
|
|
188
|
+
}
|
|
189
|
+
interface SessionCookieConfig {
|
|
190
|
+
domain?: string;
|
|
191
|
+
path?: string;
|
|
192
|
+
httpOnly?: boolean;
|
|
193
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
194
|
+
maxAge?: number;
|
|
195
|
+
}
|
|
196
|
+
interface TokenCookieConfig {
|
|
197
|
+
domain?: string;
|
|
198
|
+
path: string;
|
|
199
|
+
httpOnly: boolean;
|
|
200
|
+
sameSite: 'strict' | 'lax' | 'none';
|
|
201
|
+
maxAge: number;
|
|
202
|
+
}
|
|
203
|
+
interface CookieOpts extends CookieOptions {
|
|
204
|
+
namePrefix?: string;
|
|
205
|
+
domain?: string;
|
|
206
|
+
session?: SessionCookieConfig;
|
|
207
|
+
}
|
|
208
|
+
interface RateLimitOptions {
|
|
209
|
+
windowMs?: number;
|
|
210
|
+
maxRequests?: number;
|
|
211
|
+
skipSuccessful?: boolean;
|
|
212
|
+
skipFailedRequests?: boolean;
|
|
213
|
+
}
|
|
214
|
+
interface SecurityOptions {
|
|
215
|
+
requireCSRF?: boolean;
|
|
216
|
+
allowedReferers?: string[];
|
|
217
|
+
requiredHeaders?: Record<string, string>;
|
|
218
|
+
ipWhitelist?: string[];
|
|
219
|
+
userAgent?: {
|
|
220
|
+
block?: string[];
|
|
221
|
+
allow?: string[];
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
interface EndpointConfig {
|
|
225
|
+
enabled: boolean;
|
|
226
|
+
methods: ('GET' | 'POST' | 'PUT' | 'DELETE')[];
|
|
227
|
+
requireAuth?: boolean;
|
|
228
|
+
rateLimit?: RateLimitOptions;
|
|
229
|
+
security?: SecurityOptions;
|
|
230
|
+
cors?: Partial<CorsOptions>;
|
|
231
|
+
}
|
|
232
|
+
interface SessionEndpointConfig extends EndpointConfig {
|
|
233
|
+
subEndpoints?: {
|
|
234
|
+
[K in SessionSubEndpoint]?: Partial<EndpointConfig>;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
interface TernSecureHandlerOptions {
|
|
238
|
+
cors?: CorsOptions;
|
|
239
|
+
cookies?: CookieOpts;
|
|
240
|
+
rateLimit?: RateLimitOptions;
|
|
241
|
+
security?: SecurityOptions;
|
|
242
|
+
endpoints?: {
|
|
243
|
+
sessions?: SessionEndpointConfig;
|
|
244
|
+
};
|
|
245
|
+
tenantId?: string | null;
|
|
246
|
+
enableCustomToken?: boolean;
|
|
247
|
+
debug?: boolean;
|
|
248
|
+
environment?: 'development' | 'production' | 'test';
|
|
249
|
+
basePath?: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
179
252
|
/**
|
|
180
253
|
* Defines the basic structure for color theming.
|
|
181
254
|
*/
|
|
@@ -756,6 +829,10 @@ type TernSecureAuthOptions = {
|
|
|
756
829
|
ternSecureConfig?: TernSecureConfig;
|
|
757
830
|
persistence?: Persistence;
|
|
758
831
|
enableServiceWorker?: boolean;
|
|
832
|
+
experimental?: {
|
|
833
|
+
/** rethrow network errors that occur while the offline */
|
|
834
|
+
rethrowOfflineNetworkErrors?: boolean;
|
|
835
|
+
};
|
|
759
836
|
} & SignInRedirectUrl & SignUpRedirectUrl & AfterSignOutUrl;
|
|
760
837
|
type TernAuthListenerEventPayload = {
|
|
761
838
|
authStateChanged: TernSecureState;
|
|
@@ -1051,4 +1128,4 @@ type DomainOrProxyUrl = {
|
|
|
1051
1128
|
*/
|
|
1052
1129
|
type Autocomplete<U extends T, T = string> = U | (T & Record<never, never>);
|
|
1053
1130
|
|
|
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 };
|
|
1131
|
+
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 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 };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/ternsecure.ts","../src/auth.ts","../src/signIn.ts"],"sourcesContent":["export * from './all'\nexport * from './api'\nexport * from './cookie'\nexport * from './errors'\nexport * from './ternsecure'\nexport * from './theme'\nexport * from './instanceTree'\nexport * from './json'\nexport * from './jwt'\nexport * from './auth'\nexport * from './signIn'\nexport * from './signUp'\nexport * from './session'\nexport * from './redirect'\nexport * from './hooks'\nexport * from './multiDomain'\nexport * from './utils'","\r\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\nexport type ErrorCode = keyof typeof ERRORS\r\n\r\n\r\nexport const ERRORS = {\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"AUTH_REQUIRES_VERIFICATION\",\r\n AUTHENTICATED: \"AUTHENTICATED\",\r\n UNAUTHENTICATED: \"UNAUTHENTICATED\",\r\n UNVERIFIED: \"UNVERIFIED\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized. Call initializeTernSecure() first\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n EMAIL_NOT_VERIFIED: \"EMAIL_NOT_VERIFIED\",\r\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\r\n USER_DISABLED: \"USER_DISABLED\",\r\n TOO_MANY_ATTEMPTS: \"TOO_MANY_ATTEMPTS\",\r\n NETWORK_ERROR: \"NETWORK_ERROR\",\r\n INVALID_EMAIL: \"INVALID_EMAIL\",\r\n WEAK_PASSWORD: \"WEAK_PASSWORD\",\r\n EMAIL_EXISTS: \"EMAIL_EXISTS\",\r\n POPUP_BLOCKED: \"POPUP_BLOCKED\",\r\n OPERATION_NOT_ALLOWED: \"OPERATION_NOT_ALLOWED\",\r\n EXPIRED_TOKEN: \"EXPIRED_TOKEN\",\r\n INVALID_TOKEN: \"INVALID_TOKEN\",\r\n SESSION_EXPIRED: \"SESSION_EXPIRED\",\r\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"auth/user-not-found\",\r\n WRONG_PASSWORD: \"auth/wrong-password\",\r\n EMAIL_ALREADY_IN_USE: \"auth/email-already-in-use\",\r\n REQUIRES_RECENT_LOGIN: \"auth/requires-recent-login\",\r\n NO_SESSION_COOKIE: \"No session cookie found.\",\r\n INVALID_SESSION_COOKIE: \"Invalid session cookie.\",\r\n NO_ID_TOKEN: \"No ID token found.\",\r\n INVALID_ID_TOKEN: \"Invalid ID token.\",\r\n REDIRECT_LOOP: \"Redirect loop detected.\",\r\n} as const\r\n\r\n","import type { \n TernSecureUser \n} from './all';\nimport type { Appearance } from './theme';\n\nexport interface TernSecureSession {\n token: string | null;\n expiresAt?: number;\n}\n\ntype SignInFormValues = {\n email: string;\n password: string;\n phoneNumber?: string;\n}\n\nexport type SignInInitialValue = Partial<SignInFormValues>;\n\n\ntype SignUpFormValues = {\n email: string;\n password: string;\n confirmPassword?: string;\n displayName?: string;\n};\n\n\nexport type SignUpInitialValue = Partial<SignUpFormValues>;\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\nexport interface AuthError extends Error {\n code?: any | string \n message: string\n response?: SignInResponse\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return typeof value === \"object\" && \"success\" in value && typeof value.success === \"boolean\"\n}\n\nexport interface AuthActions {\n signInWithEmail: (email: string, password: string) => Promise<SignInResponse>;\n signInWithGoogle: () => Promise<void>;\n signInWithMicrosoft: () => Promise<void>;\n signOut: () => Promise<void>;\n getRedirectResult: () => Promise<any>;\n getIdToken: () => Promise<string | null>;\n createUserWithEmailAndPassword?: (email: string, password: string) => Promise<SignInResponse>;\n sendEmailVerification?: (user: TernSecureUser) => Promise<void>;\n}\n\nexport interface RedirectConfig {\n // URL to redirect to after successful authentication\n redirectUrl?: string\n // Whether this is a return visit (e.g. after sign out)\n isReturn?: boolean\n // Priority of the redirect (higher number = higher priority)\n priority?: number\n}\n\n\nexport interface SignInProps extends RedirectConfig {\n initialValue?: SignInInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n\n/**\n * SignUpProps interface defines the properties for the sign-up component.\n * It extends RedirectConfig to include redirect-related properties.\n */\nexport interface SignUpProps extends RedirectConfig {\n initialValue?: SignUpInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n/**\n * Defines the contract for a TernSecure instance.\n * This instance provides authentication state, user information, and methods\n * for managing the authentication lifecycle. It is designed to be used by\n * UI packages like tern-ui, which act as \"dumb\" renderers.\n */\nexport interface TernSecureInstanceOld {\n /** Indicates if the user is currently signed in. */\n isSignedIn: () => boolean;\n\n /** The current authenticated user object, or null if not signed in. */\n user: TernSecureUser | null;\n\n /** The current user session information, or null if not signed in. */\n session: TernSecureSession | null;\n\n /** Initiates the sign-out process for the current user. */\n signOut: () => Promise<void>;\n\n /**\n * Prepares or signals to mount the sign-in interface.\n * @param options Optional configuration or initial state for the sign-in UI, conforming to SignInProps.\n */\n mountSignIn: (options?: SignInProps) => void;\n\n /** Cleans up or signals to unmount the sign-in interface. */\n unmountSignIn: () => void;\n\n /**\n * Prepares or signals to mount the sign-up interface.\n * @param options Optional configuration or initial state for the sign-up UI, conforming to SignUpProps.\n */\n mountSignUp: (options?: SignUpProps) => void;\n\n /** Cleans up or signals to unmount the sign-up interface. */\n unmountSignUp: () => void;\n\n /**\n * Determines if a redirect is necessary based on the current authentication\n * state and the given path.\n * @param currentPath The current URL path.\n * @returns True if a redirect is needed, false otherwise, or a string path to redirect to.\n */\n shouldRedirect: (currentPath: string) => boolean | string;\n\n /**\n * Constructs a URL, appending necessary redirect parameters.\n * Useful for redirecting back to the original page after authentication.\n * @param baseUrl The base URL to which redirect parameters should be added.\n * @returns The new URL string with redirect parameters.\n */\n constructUrlWithRedirect: (baseUrl: string) => string;\n\n /**\n * Redirects the user to the configured login page.\n * @param redirectUrl Optional URL to redirect to after successful login.\n */\n redirectToLogin: (redirectUrl?: string) => void;\n\n /** Indicates if an authentication operation is currently in progress. */\n isLoading: boolean;\n\n /** Holds any error that occurred during an authentication operation, or null otherwise. */\n error: Error | null;\n \n /** Indicates if the user has verified their email address. */\n sendVerificationEmail: () => Promise<void>;\n}","import type { SignedInSession } from \"session\";\nimport type { SignUpResource } from \"signUp\";\n\nimport type { InstanceType,TernSecureConfig, TernSecureUser } from \"./all\";\nimport type { DecodedIdToken } from \"./jwt\";\nimport type {\n AfterSignOutUrl,\n SignInRedirectUrl,\n SignUpRedirectUrl,\n} from \"./redirect\";\nimport type { AuthErrorResponse,SignInResource } from \"./signIn\";\n\nexport interface InitialState {\n userId: string | null;\n token: any | null;\n email: string | null;\n user?: TernSecureUser | null;\n}\n\nexport interface TernSecureState {\n userId: string | null;\n isLoaded: boolean;\n error: Error | null;\n isValid: boolean;\n isVerified: boolean;\n isAuthenticated: boolean;\n token: any | null;\n email: string | null;\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\";\n user?: TernSecureUser | null;\n}\n\nexport type AuthProviderStatus = \"idle\" | \"pending\" | \"error\" | \"success\";\n\nexport const DEFAULT_TERN_SECURE_STATE: TernSecureState = {\n userId: null,\n isLoaded: false,\n error: null,\n isValid: false,\n isVerified: false,\n isAuthenticated: false,\n token: null,\n email: null,\n status: \"loading\",\n user: null,\n};\n\nexport interface TernSecureAuthProvider {\n /** Current auth state */\n internalAuthState: TernSecureState;\n\n /** Current user*/\n ternSecureUser(): TernSecureUser | null;\n\n /** AuthCookie Manager */\n authCookieManager(): void;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource | undefined;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource | undefined;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Sign out the current user */\n signOut(): Promise<void>;\n}\n\nexport type Persistence = \"local\" | \"session\" | \"browserCookie\" | \"none\";\n\ntype Mode = \"browser\" | \"server\";\n\nexport type TernAuthSDK = {\n /** SDK package name (e.g., @tern-secure/auth) */\n name: string;\n /** SDK version (e.g., 1.2.3) */\n version: string;\n /** Build environment (development, production, test) */\n environment?: string;\n /** Build date as ISO string */\n buildDate?: string;\n /** Additional build metadata */\n buildInfo?: {\n name: string;\n version: string;\n buildDate: string;\n buildEnv: string;\n };\n};\n\nexport interface TernSecureResources {\n user?: TernSecureUser | null;\n session?: SignedInSession | null;\n}\n\nexport type TernSecureAuthOptions = {\n apiUrl?: string;\n sdkMetadata?: TernAuthSDK;\n signInUrl?: string;\n signUpUrl?: string;\n mode?: Mode;\n requiresVerification?: boolean;\n isTernSecureDev?: boolean;\n ternSecureConfig?: TernSecureConfig;\n persistence?: Persistence;\n enableServiceWorker?: boolean;\n} & SignInRedirectUrl &\n SignUpRedirectUrl &\n AfterSignOutUrl;\n\nexport type TernAuthListenerEventPayload = {\n authStateChanged: TernSecureState;\n userChanged: TernSecureUser;\n sessionChanged: SignedInSession | null;\n tokenRefreshed: string | null;\n};\n\nexport type TernAuthListenerEvent = keyof TernAuthListenerEventPayload;\n\nexport type ListenerCallback = (emission: TernSecureResources) => void;\nexport type UnsubscribeCallback = () => void;\ntype TernSecureEvent = keyof TernAuthEventPayload;\ntype EventHandler<Events extends TernSecureEvent> = (\n payload: TernAuthEventPayload[Events]\n) => void;\nexport type TernAuthEventPayload = {\n status: TernSecureAuthStatus;\n};\n\nexport type TernSecureAuthStatus = \"error\" | \"loading\" | \"ready\";\n\ntype onEventListener = <E extends TernSecureEvent>(\n event: E,\n handler: EventHandler<E>, opt?: { notify?: boolean }\n) => void;\ntype OffEventListener = <E extends TernSecureEvent>(\n event: E,\n handler: EventHandler<E>\n) => void;\n\nexport type SignOutOptions = {\n /** URL to redirect to after sign out */\n redirectUrl?: string;\n /** Callback to perform consumer-specific cleanup (e.g., delete session cookies) */\n onBeforeSignOut?: () => Promise<void> | void;\n /** Callback executed after successful sign out */\n onAfterSignOut?: () => Promise<void> | void;\n};\n\nexport interface SignOut {\n (options?: SignOutOptions): Promise<void>;\n}\n\nexport interface TernSecureAuth {\n /** TernSecureAuth SDK version number */\n version: string | undefined;\n\n /** Metadata about the SDK instance */\n sdkMetadata: TernAuthSDK | undefined;\n\n /** Indicates if the TernSecureAuth instance is currently loading */\n isLoading: boolean;\n\n /** The current status of the TernSecureAuth instance */\n status: TernSecureAuthStatus;\n\n /** TernSecure API URL */\n apiUrl: string;\n\n /** TernSecure domain for API string */\n domain: string;\n\n /** TernSecure Proxy url */\n proxyUrl?: string;\n\n /** TernSecure Instance type */\n instanceType: InstanceType | undefined;\n\n /** Indicates if the TernSecureAuth instance is ready for use */\n isReady: boolean;\n\n /** Requires Verification */\n requiresVerification: boolean;\n\n /** Initialize TernSecureAuth */\n initialize(options?: TernSecureAuthOptions): Promise<void>;\n\n /** Current user*/\n user: TernSecureUser | null | undefined;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource | undefined | null;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource | undefined | null;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Subscribe to auth state changes */\n onAuthStateChanged(callback: (cb: any) => void): () => void;\n\n /** Sign out the current user */\n signOut: SignOut;\n\n /** Subscribe to a single event */\n on: onEventListener;\n\n /** Remove event listener */\n off: OffEventListener;\n\n addListener: (callback: ListenerCallback) => UnsubscribeCallback;\n}\n\nexport interface TernSecureAuthFactory {\n create(options?: TernSecureAuthOptions): TernSecureAuth;\n}\n\nexport type SharedSignInAuthObjectProperties = {\n session: DecodedIdToken;\n userId: string;\n};\n\nexport type CheckCustomClaims = {\n role?: string | string[];\n permissions?: string | string[];\n [key: string]: any;\n};\n\nexport type CheckAuthorizationFromSessionClaims = (\n isAuthorizedParams: CheckCustomClaims,\n) => boolean;\n\nexport type TernVerificationResult =\n | (DecodedIdToken & {\n valid: true;\n token?: string;\n error?: never;\n })\n | {\n valid: false;\n error: AuthErrorResponse;\n };\n","import type { ErrorCode} from \"./errors\";\n\nexport type SignInStatus =\n | 'idle'\n | 'pending_email_password'\n | 'pending_social'\n | 'pending_mfa'\n | 'redirecting'\n | 'success'\n | 'error';\n\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\n};\n\nexport interface AuthErrorResponse {\n success: false\n message: string\n code: ErrorCode\n}\n\nexport interface AuthErrorTree extends Error {\n code?: any | string;\n message: string;\n response?: any | string;\n}\n\n\nexport interface SignInResponseTree {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\n\nexport type SignInInitialValueTree = Partial<SignInFormValuesTree>;\n\n\nexport interface ResendEmailVerification extends SignInResponseTree {\n isVerified?: boolean;\n}\n\nexport function isSignInResponseTree(value: any): value is SignInResponseTree {\n return (\n typeof value === 'object' &&\n 'success' in value &&\n typeof value.success === 'boolean'\n );\n}\n\n\nexport interface SignInResource {\n /**\n * The current status of the sign-in process.\n */\n status?: SignInStatus;\n /**\n * Signs in a user with their email and password.\n * @param params - The sign-in form values.\n * @returns A promise that resolves with the sign-in response.\n */\n withEmailAndPassword: (params: SignInFormValuesTree) => Promise<SignInResponseTree>;\n /**\n * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').\n * @param options - Optional configuration for the social sign-in flow.\n * @returns A promise that resolves with the sign-in response or void if redirecting.\n */\n withSocialProvider: (provider: string, options?: { mode?: 'popup' | 'redirect' }) => Promise<SignInResponseTree | void>;\n /**\n * Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.\n * @param mfaToken - The MFA token or code submitted by the user.\n * @param mfaContext - Optional context or session data from the MFA initiation step.\n * @returns A promise that resolves with the sign-in response upon successful MFA verification.\n */\n completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponseTree>;\n /**\n * Sends a password reset email to the given email address.\n * @param email - The user's email address.\n * @returns A promise that resolves when the email is sent.\n */\n sendPasswordResetEmail: (email: string) => Promise<void>;\n /**\n * Resends the email verification link to the user's email address.\n * @returns A promise that resolves with the sign-in response.\n */\n resendEmailVerification: () => Promise<ResendEmailVerification>;\n /**\n * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.\n * @returns A promise that resolves with the sign-in response or null if no result is available.\n */\n checkRedirectResult: () => Promise<SignInResponseTree | null>;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,SAAS;AAAA,EACpB,4BAA4B;AAAA,EAC5B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,eAAe;AACjB;;;ACGO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;;;ACVO,IAAM,4BAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;;;ACCO,SAAS,qBAAqB,OAAyC;AAC5E,SACE,OAAO,UAAU,YACjB,aAAa,SACb,OAAO,MAAM,YAAY;AAE7B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/ternsecure.ts","../src/auth.ts","../src/signIn.ts"],"sourcesContent":["export * from './all'\nexport * from './api'\nexport * from './cookie'\nexport * from './errors'\nexport * from './handler'\nexport * from './ternsecure'\nexport * from './theme'\nexport * from './instanceTree'\nexport * from './json'\nexport * from './jwt'\nexport * from './auth'\nexport * from './signIn'\nexport * from './signUp'\nexport * from './session'\nexport * from './redirect'\nexport * from './hooks'\nexport * from './multiDomain'\nexport * from './utils'","\r\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\nexport type ErrorCode = keyof typeof ERRORS\r\n\r\n\r\nexport const ERRORS = {\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"AUTH_REQUIRES_VERIFICATION\",\r\n AUTHENTICATED: \"AUTHENTICATED\",\r\n UNAUTHENTICATED: \"UNAUTHENTICATED\",\r\n UNVERIFIED: \"UNVERIFIED\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized. Call initializeTernSecure() first\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n EMAIL_NOT_VERIFIED: \"EMAIL_NOT_VERIFIED\",\r\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\r\n USER_DISABLED: \"USER_DISABLED\",\r\n TOO_MANY_ATTEMPTS: \"TOO_MANY_ATTEMPTS\",\r\n NETWORK_ERROR: \"NETWORK_ERROR\",\r\n INVALID_EMAIL: \"INVALID_EMAIL\",\r\n WEAK_PASSWORD: \"WEAK_PASSWORD\",\r\n EMAIL_EXISTS: \"EMAIL_EXISTS\",\r\n POPUP_BLOCKED: \"POPUP_BLOCKED\",\r\n OPERATION_NOT_ALLOWED: \"OPERATION_NOT_ALLOWED\",\r\n EXPIRED_TOKEN: \"EXPIRED_TOKEN\",\r\n INVALID_TOKEN: \"INVALID_TOKEN\",\r\n SESSION_EXPIRED: \"SESSION_EXPIRED\",\r\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"auth/user-not-found\",\r\n WRONG_PASSWORD: \"auth/wrong-password\",\r\n EMAIL_ALREADY_IN_USE: \"auth/email-already-in-use\",\r\n REQUIRES_RECENT_LOGIN: \"auth/requires-recent-login\",\r\n NO_SESSION_COOKIE: \"No session cookie found.\",\r\n INVALID_SESSION_COOKIE: \"Invalid session cookie.\",\r\n NO_ID_TOKEN: \"No ID token found.\",\r\n INVALID_ID_TOKEN: \"Invalid ID token.\",\r\n REDIRECT_LOOP: \"Redirect loop detected.\",\r\n} as const\r\n\r\n","import type { \n TernSecureUser \n} from './all';\nimport type { Appearance } from './theme';\n\nexport interface TernSecureSession {\n token: string | null;\n expiresAt?: number;\n}\n\ntype SignInFormValues = {\n email: string;\n password: string;\n phoneNumber?: string;\n}\n\nexport type SignInInitialValue = Partial<SignInFormValues>;\n\n\ntype SignUpFormValues = {\n email: string;\n password: string;\n confirmPassword?: string;\n displayName?: string;\n};\n\n\nexport type SignUpInitialValue = Partial<SignUpFormValues>;\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\nexport interface AuthError extends Error {\n code?: any | string \n message: string\n response?: SignInResponse\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return typeof value === \"object\" && \"success\" in value && typeof value.success === \"boolean\"\n}\n\nexport interface AuthActions {\n signInWithEmail: (email: string, password: string) => Promise<SignInResponse>;\n signInWithGoogle: () => Promise<void>;\n signInWithMicrosoft: () => Promise<void>;\n signOut: () => Promise<void>;\n getRedirectResult: () => Promise<any>;\n getIdToken: () => Promise<string | null>;\n createUserWithEmailAndPassword?: (email: string, password: string) => Promise<SignInResponse>;\n sendEmailVerification?: (user: TernSecureUser) => Promise<void>;\n}\n\nexport interface RedirectConfig {\n // URL to redirect to after successful authentication\n redirectUrl?: string\n // Whether this is a return visit (e.g. after sign out)\n isReturn?: boolean\n // Priority of the redirect (higher number = higher priority)\n priority?: number\n}\n\n\nexport interface SignInProps extends RedirectConfig {\n initialValue?: SignInInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n\n/**\n * SignUpProps interface defines the properties for the sign-up component.\n * It extends RedirectConfig to include redirect-related properties.\n */\nexport interface SignUpProps extends RedirectConfig {\n initialValue?: SignUpInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n/**\n * Defines the contract for a TernSecure instance.\n * This instance provides authentication state, user information, and methods\n * for managing the authentication lifecycle. It is designed to be used by\n * UI packages like tern-ui, which act as \"dumb\" renderers.\n */\nexport interface TernSecureInstanceOld {\n /** Indicates if the user is currently signed in. */\n isSignedIn: () => boolean;\n\n /** The current authenticated user object, or null if not signed in. */\n user: TernSecureUser | null;\n\n /** The current user session information, or null if not signed in. */\n session: TernSecureSession | null;\n\n /** Initiates the sign-out process for the current user. */\n signOut: () => Promise<void>;\n\n /**\n * Prepares or signals to mount the sign-in interface.\n * @param options Optional configuration or initial state for the sign-in UI, conforming to SignInProps.\n */\n mountSignIn: (options?: SignInProps) => void;\n\n /** Cleans up or signals to unmount the sign-in interface. */\n unmountSignIn: () => void;\n\n /**\n * Prepares or signals to mount the sign-up interface.\n * @param options Optional configuration or initial state for the sign-up UI, conforming to SignUpProps.\n */\n mountSignUp: (options?: SignUpProps) => void;\n\n /** Cleans up or signals to unmount the sign-up interface. */\n unmountSignUp: () => void;\n\n /**\n * Determines if a redirect is necessary based on the current authentication\n * state and the given path.\n * @param currentPath The current URL path.\n * @returns True if a redirect is needed, false otherwise, or a string path to redirect to.\n */\n shouldRedirect: (currentPath: string) => boolean | string;\n\n /**\n * Constructs a URL, appending necessary redirect parameters.\n * Useful for redirecting back to the original page after authentication.\n * @param baseUrl The base URL to which redirect parameters should be added.\n * @returns The new URL string with redirect parameters.\n */\n constructUrlWithRedirect: (baseUrl: string) => string;\n\n /**\n * Redirects the user to the configured login page.\n * @param redirectUrl Optional URL to redirect to after successful login.\n */\n redirectToLogin: (redirectUrl?: string) => void;\n\n /** Indicates if an authentication operation is currently in progress. */\n isLoading: boolean;\n\n /** Holds any error that occurred during an authentication operation, or null otherwise. */\n error: Error | null;\n \n /** Indicates if the user has verified their email address. */\n sendVerificationEmail: () => Promise<void>;\n}","import type { SignedInSession } from \"session\";\nimport type { SignUpResource } from \"signUp\";\n\nimport type { InstanceType,TernSecureConfig, TernSecureUser } from \"./all\";\nimport type { DecodedIdToken } from \"./jwt\";\nimport type {\n AfterSignOutUrl,\n SignInRedirectUrl,\n SignUpRedirectUrl,\n} from \"./redirect\";\nimport type { AuthErrorResponse,SignInResource } from \"./signIn\";\n\nexport interface InitialState {\n userId: string | null;\n token: any | null;\n email: string | null;\n user?: TernSecureUser | null;\n}\n\nexport interface TernSecureState {\n userId: string | null;\n isLoaded: boolean;\n error: Error | null;\n isValid: boolean;\n isVerified: boolean;\n isAuthenticated: boolean;\n token: any | null;\n email: string | null;\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\";\n user?: TernSecureUser | null;\n}\n\nexport type AuthProviderStatus = \"idle\" | \"pending\" | \"error\" | \"success\";\n\nexport const DEFAULT_TERN_SECURE_STATE: TernSecureState = {\n userId: null,\n isLoaded: false,\n error: null,\n isValid: false,\n isVerified: false,\n isAuthenticated: false,\n token: null,\n email: null,\n status: \"loading\",\n user: null,\n};\n\nexport interface TernSecureAuthProvider {\n /** Current auth state */\n internalAuthState: TernSecureState;\n\n /** Current user*/\n ternSecureUser(): TernSecureUser | null;\n\n /** AuthCookie Manager */\n authCookieManager(): void;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource | undefined;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource | undefined;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Sign out the current user */\n signOut(): Promise<void>;\n}\n\nexport type Persistence = \"local\" | \"session\" | \"browserCookie\" | \"none\";\n\ntype Mode = \"browser\" | \"server\";\n\nexport type TernAuthSDK = {\n /** SDK package name (e.g., @tern-secure/auth) */\n name: string;\n /** SDK version (e.g., 1.2.3) */\n version: string;\n /** Build environment (development, production, test) */\n environment?: string;\n /** Build date as ISO string */\n buildDate?: string;\n /** Additional build metadata */\n buildInfo?: {\n name: string;\n version: string;\n buildDate: string;\n buildEnv: string;\n };\n};\n\nexport interface TernSecureResources {\n user?: TernSecureUser | null;\n session?: SignedInSession | null;\n}\n\nexport type TernSecureAuthOptions = {\n apiUrl?: string;\n sdkMetadata?: TernAuthSDK;\n signInUrl?: string;\n signUpUrl?: string;\n mode?: Mode;\n requiresVerification?: boolean;\n isTernSecureDev?: boolean;\n ternSecureConfig?: TernSecureConfig;\n persistence?: Persistence;\n enableServiceWorker?: boolean;\n experimental?: {\n /** rethrow network errors that occur while the offline */\n rethrowOfflineNetworkErrors?: boolean;\n };\n} & SignInRedirectUrl &\n SignUpRedirectUrl &\n AfterSignOutUrl;\n\nexport type TernAuthListenerEventPayload = {\n authStateChanged: TernSecureState;\n userChanged: TernSecureUser;\n sessionChanged: SignedInSession | null;\n tokenRefreshed: string | null;\n};\n\nexport type TernAuthListenerEvent = keyof TernAuthListenerEventPayload;\n\nexport type ListenerCallback = (emission: TernSecureResources) => void;\nexport type UnsubscribeCallback = () => void;\ntype TernSecureEvent = keyof TernAuthEventPayload;\ntype EventHandler<Events extends TernSecureEvent> = (\n payload: TernAuthEventPayload[Events]\n) => void;\nexport type TernAuthEventPayload = {\n status: TernSecureAuthStatus;\n};\n\nexport type TernSecureAuthStatus = \"error\" | \"loading\" | \"ready\";\n\ntype onEventListener = <E extends TernSecureEvent>(\n event: E,\n handler: EventHandler<E>, opt?: { notify?: boolean }\n) => void;\ntype OffEventListener = <E extends TernSecureEvent>(\n event: E,\n handler: EventHandler<E>\n) => void;\n\nexport type SignOutOptions = {\n /** URL to redirect to after sign out */\n redirectUrl?: string;\n /** Callback to perform consumer-specific cleanup (e.g., delete session cookies) */\n onBeforeSignOut?: () => Promise<void> | void;\n /** Callback executed after successful sign out */\n onAfterSignOut?: () => Promise<void> | void;\n};\n\nexport interface SignOut {\n (options?: SignOutOptions): Promise<void>;\n}\n\nexport interface TernSecureAuth {\n /** TernSecureAuth SDK version number */\n version: string | undefined;\n\n /** Metadata about the SDK instance */\n sdkMetadata: TernAuthSDK | undefined;\n\n /** Indicates if the TernSecureAuth instance is currently loading */\n isLoading: boolean;\n\n /** The current status of the TernSecureAuth instance */\n status: TernSecureAuthStatus;\n\n /** TernSecure API URL */\n apiUrl: string;\n\n /** TernSecure domain for API string */\n domain: string;\n\n /** TernSecure Proxy url */\n proxyUrl?: string;\n\n /** TernSecure Instance type */\n instanceType: InstanceType | undefined;\n\n /** Indicates if the TernSecureAuth instance is ready for use */\n isReady: boolean;\n\n /** Requires Verification */\n requiresVerification: boolean;\n\n /** Initialize TernSecureAuth */\n initialize(options?: TernSecureAuthOptions): Promise<void>;\n\n /** Current user*/\n user: TernSecureUser | null | undefined;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource | undefined | null;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource | undefined | null;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Subscribe to auth state changes */\n onAuthStateChanged(callback: (cb: any) => void): () => void;\n\n /** Sign out the current user */\n signOut: SignOut;\n\n /** Subscribe to a single event */\n on: onEventListener;\n\n /** Remove event listener */\n off: OffEventListener;\n\n addListener: (callback: ListenerCallback) => UnsubscribeCallback;\n}\n\nexport interface TernSecureAuthFactory {\n create(options?: TernSecureAuthOptions): TernSecureAuth;\n}\n\nexport type SharedSignInAuthObjectProperties = {\n session: DecodedIdToken;\n userId: string;\n};\n\nexport type CheckCustomClaims = {\n role?: string | string[];\n permissions?: string | string[];\n [key: string]: any;\n};\n\nexport type CheckAuthorizationFromSessionClaims = (\n isAuthorizedParams: CheckCustomClaims,\n) => boolean;\n\nexport type TernVerificationResult =\n | (DecodedIdToken & {\n valid: true;\n token?: string;\n error?: never;\n })\n | {\n valid: false;\n error: AuthErrorResponse;\n };\n","import type { ErrorCode} from \"./errors\";\n\nexport type SignInStatus =\n | 'idle'\n | 'pending_email_password'\n | 'pending_social'\n | 'pending_mfa'\n | 'redirecting'\n | 'success'\n | 'error';\n\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\n};\n\nexport interface AuthErrorResponse {\n success: false\n message: string\n code: ErrorCode\n}\n\nexport interface AuthErrorTree extends Error {\n code?: any | string;\n message: string;\n response?: any | string;\n}\n\n\nexport interface SignInResponseTree {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\n\nexport type SignInInitialValueTree = Partial<SignInFormValuesTree>;\n\n\nexport interface ResendEmailVerification extends SignInResponseTree {\n isVerified?: boolean;\n}\n\nexport function isSignInResponseTree(value: any): value is SignInResponseTree {\n return (\n typeof value === 'object' &&\n 'success' in value &&\n typeof value.success === 'boolean'\n );\n}\n\n\nexport interface SignInResource {\n /**\n * The current status of the sign-in process.\n */\n status?: SignInStatus;\n /**\n * Signs in a user with their email and password.\n * @param params - The sign-in form values.\n * @returns A promise that resolves with the sign-in response.\n */\n withEmailAndPassword: (params: SignInFormValuesTree) => Promise<SignInResponseTree>;\n /**\n * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').\n * @param options - Optional configuration for the social sign-in flow.\n * @returns A promise that resolves with the sign-in response or void if redirecting.\n */\n withSocialProvider: (provider: string, options?: { mode?: 'popup' | 'redirect' }) => Promise<SignInResponseTree | void>;\n /**\n * Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.\n * @param mfaToken - The MFA token or code submitted by the user.\n * @param mfaContext - Optional context or session data from the MFA initiation step.\n * @returns A promise that resolves with the sign-in response upon successful MFA verification.\n */\n completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponseTree>;\n /**\n * Sends a password reset email to the given email address.\n * @param email - The user's email address.\n * @returns A promise that resolves when the email is sent.\n */\n sendPasswordResetEmail: (email: string) => Promise<void>;\n /**\n * Resends the email verification link to the user's email address.\n * @returns A promise that resolves with the sign-in response.\n */\n resendEmailVerification: () => Promise<ResendEmailVerification>;\n /**\n * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.\n * @returns A promise that resolves with the sign-in response or null if no result is available.\n */\n checkRedirectResult: () => Promise<SignInResponseTree | null>;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,SAAS;AAAA,EACpB,4BAA4B;AAAA,EAC5B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,eAAe;AACjB;;;ACGO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;;;ACVO,IAAM,4BAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AACR;;;ACCO,SAAS,qBAAqB,OAAyC;AAC5E,SACE,OAAO,UAAU,YACjB,aAAa,SACb,OAAO,MAAM,YAAY;AAE7B;","names":[]}
|