@tern-secure/types 1.0.1 → 1.0.2

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/auth.d.ts CHANGED
@@ -12,7 +12,6 @@ export interface TernSecureState {
12
12
  token: any | null;
13
13
  email: string | null;
14
14
  status: "loading" | "authenticated" | "unauthenticated" | "unverified";
15
- requiresVerification?: boolean;
16
15
  user?: TernSecureUser | null;
17
16
  }
18
17
  export type AuthProviderStatus = 'idle' | 'pending' | 'error' | 'success';
@@ -22,6 +21,8 @@ export interface TernSecureAuthProvider {
22
21
  internalAuthState: TernSecureState;
23
22
  /** Current user*/
24
23
  ternSecureUser(): TernSecureUser | null;
24
+ /** AuthCookie Manager */
25
+ authCookieManager(): void;
25
26
  /** Current session */
26
27
  currentSession: SignedInSession | null;
27
28
  /** Sign in resource for authentication operations */
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EACjB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACR,cAAc,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,OAAO,CAAA;IACnB,eAAe,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,GAAG,GAAG,IAAI,CAAA;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,SAAS,GAAG,eAAe,GAAG,iBAAiB,GAAG,YAAY,CAAA;IACtE,oB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M,EAAE,SAAS,GAAG,eAAe,GAAG,iBAAiB,GAAG,YAAY,CAAA;IACtE,IAAI,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;CAC7B;AAGD,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE1E,eAAO,MAAM,yBAAyB,EAAE,eAWvC,CAAC;AAGF,MAAM,WAAW,sBAAsB;IACrC,yBAAyB;IACzB,iBAAiB,EAAE,eAAe,CAAC;IAEnC,kBAAkB;IAClB,cAAc,IAAI,cAAc,GAAG,IAAI,CAAC;IAExC,yBAAyB;IACzB,iBAAiB,IAAI,IAAI,CAAC;IAE1B,sBAAsB;IACtB,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;IAEvC,qDAAqD;IACrD,MAAM,EAAE,cAAc,CAAC;IAEvB,oDAAoD;IACpD,MAAM,EAAE,cAAc,CAAC;IAEvB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC,gCAAgC;IAChC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
package/dist/esm/index.js CHANGED
@@ -152,7 +152,6 @@ var DEFAULT_TERN_SECURE_STATE = {
152
152
  token: null,
153
153
  email: null,
154
154
  status: "loading",
155
- requiresVerification: false,
156
155
  user: null
157
156
  };
158
157
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/errors.ts","../../src/ternsecure.ts","../../src/auth.ts","../../src/signIn.ts"],"sourcesContent":["export type ErrorCode = keyof typeof ERRORS\r\n\r\nexport interface AuthErrorResponse {\r\n success: false\r\n message: string\r\n code: ErrorCode\r\n}\r\n\r\nexport interface AuthErrorTree extends Error {\r\n code?: any | string;\r\n message: string;\r\n response?: any | string;\r\n}\r\n\r\nexport interface SignInResponseTree {\r\n success: boolean;\r\n message?: string;\r\n error?: any | undefined;\r\n user?: any;\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\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\n// Firebase Auth Error Code patterns\r\nconst ERROR_PATTERNS = {\r\n INVALID_EMAIL: /auth.*invalid.*email|invalid.*email.*auth|Firebase:.*Error.*auth\\/invalid-email/i,\r\n INVALID_CREDENTIALS:\r\n /auth.*invalid.*credential|invalid.*password|wrong.*password|Firebase:.*Error.*auth\\/(invalid-credential|wrong-password|user-not-found)/i,\r\n USER_DISABLED: /user.*disabled|disabled.*user|Firebase:.*Error.*auth\\/user-disabled/i,\r\n TOO_MANY_ATTEMPTS: /too.*many.*attempts|too.*many.*requests|Firebase:.*Error.*auth\\/too-many-requests/i,\r\n NETWORK_ERROR: /network.*request.*failed|failed.*network|Firebase:.*Error.*auth\\/network-request-failed/i,\r\n OPERATION_NOT_ALLOWED: /operation.*not.*allowed|method.*not.*allowed|Firebase:.*Error.*auth\\/operation-not-allowed/i,\r\n POPUP_BLOCKED: /popup.*blocked|blocked.*popup|Firebase:.*Error.*auth\\/popup-blocked/i,\r\n EMAIL_EXISTS: /email.*exists|email.*already.*use|Firebase:.*Error.*auth\\/email-already-in-use/i,\r\n EXPIRED_TOKEN: /token.*expired|expired.*token|Firebase:.*Error.*auth\\/expired-token/i,\r\n INVALID_TOKEN: /invalid.*token|token.*invalid|Firebase:.*Error.*auth\\/invalid-token/i,\r\n SESSION_EXPIRED: /session.*expired|expired.*session|Firebase:.*Error.*auth\\/session-expired/i,\r\n WEAK_PASSWORD: /weak.*password|password.*weak|Firebase:.*Error.*auth\\/weak-password/i,\r\n} as const\r\n\r\nexport class TernSecureError extends Error {\r\n code: ErrorCode\r\n\r\n constructor(code: ErrorCode, message?: string) {\r\n super(message || code)\r\n this.name = \"TernSecureError\"\r\n this.code = code\r\n }\r\n}\r\n\r\ninterface SerializedFirebaseError {\r\n name?: string\r\n code?: string\r\n message?: string\r\n stack?: string\r\n}\r\n\r\n/**\r\n * Determines if an object matches the shape of a Firebase Error\r\n */\r\nfunction isFirebaseErrorLike(error: unknown): error is SerializedFirebaseError {\r\n if (!error || typeof error !== \"object\") return false\r\n\r\n const err = error as SerializedFirebaseError\r\n\r\n // Check for bundled Firebase error format: \"Firebase: Error (auth/error-code)\"\r\n if (typeof err.message === \"string\") {\r\n const bundledErrorMatch = err.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n // Add the extracted code to the error object\r\n err.code = `auth/${bundledErrorMatch[1]}`\r\n return true\r\n }\r\n }\r\n\r\n return (\r\n (typeof err.code === \"string\" && err.code.startsWith(\"auth/\")) ||\r\n (typeof err.name === \"string\" && err.name.includes(\"FirebaseError\"))\r\n )\r\n}\r\n\r\n/**\r\n * Extracts the error code from a Firebase-like error object\r\n */\r\nfunction extractFirebaseErrorCode(error: SerializedFirebaseError): string {\r\n // First try to extract from bundled error message format\r\n if (typeof error.message === \"string\") {\r\n const bundledErrorMatch = error.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n return bundledErrorMatch[1]\r\n }\r\n }\r\n\r\n // Then try the standard code property\r\n if (error.code) {\r\n return error.code.replace(\"auth/\", \"\")\r\n }\r\n\r\n // Finally try to extract from error message if it contains an error code\r\n if (typeof error.message === \"string\") {\r\n const messageCodeMatch = error.message.match(/auth\\/([a-z-]+)/)\r\n if (messageCodeMatch) {\r\n return messageCodeMatch[1]\r\n }\r\n }\r\n\r\n return \"\"\r\n}\r\n\r\n/**\r\n * Maps a Firebase error code to our internal error code\r\n */\r\nfunction mapFirebaseErrorCode(code: string): ErrorCode {\r\n // Direct mapping for known error codes\r\n const directMappings: Record<string, ErrorCode> = {\r\n \"invalid-email\": \"INVALID_EMAIL\",\r\n \"user-disabled\": \"USER_DISABLED\",\r\n \"too-many-requests\": \"TOO_MANY_ATTEMPTS\",\r\n \"network-request-failed\": \"NETWORK_ERROR\",\r\n \"operation-not-allowed\": \"OPERATION_NOT_ALLOWED\",\r\n \"popup-blocked\": \"POPUP_BLOCKED\",\r\n \"email-already-in-use\": \"EMAIL_EXISTS\",\r\n \"weak-password\": \"WEAK_PASSWORD\",\r\n \"invalid-credential\": \"INVALID_CREDENTIALS\",\r\n \"wrong-password\": \"INVALID_CREDENTIALS\",\r\n \"user-not-found\": \"INVALID_CREDENTIALS\",\r\n \"invalid-password\": \"INVALID_CREDENTIALS\",\r\n \"user-token-expired\": \"EXPIRED_TOKEN\",\r\n \"invalid-id-token\": \"INVALID_TOKEN\",\r\n }\r\n\r\n return directMappings[code] || \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Determines error type based on error message pattern matching\r\n */\r\nfunction determineErrorTypeFromMessage(message: string): ErrorCode {\r\n // First check for bundled Firebase error format\r\n const bundledErrorMatch = message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n const errorCode = bundledErrorMatch[1]\r\n const mappedCode = mapFirebaseErrorCode(errorCode)\r\n if (mappedCode) {\r\n return mappedCode\r\n }\r\n }\r\n\r\n // Then check standard patterns\r\n for (const [errorType, pattern] of Object.entries(ERROR_PATTERNS)) {\r\n if (pattern.test(message)) {\r\n return errorType as ErrorCode\r\n }\r\n }\r\n\r\n return \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Creates a standardized error response\r\n */\r\nfunction createErrorResponse(code: ErrorCode, message: string): AuthErrorResponse {\r\n const defaultMessages: Record<ErrorCode, string> = {\r\n INVALID_EMAIL: \"Invalid email format\",\r\n INVALID_CREDENTIALS: \"Invalid email or password\",\r\n USER_DISABLED: \"This account has been disabled\",\r\n TOO_MANY_ATTEMPTS: \"Too many attempts. Please try again later\",\r\n NETWORK_ERROR: \"Network error. Please check your connection\",\r\n OPERATION_NOT_ALLOWED: \"This login method is not enabled\",\r\n POPUP_BLOCKED: \"Login popup was blocked. Please enable popups\",\r\n EMAIL_EXISTS: \"This email is already in use\",\r\n EXPIRED_TOKEN: \"Your session has expired. Please login again\",\r\n INVALID_TOKEN: \"Invalid authentication token\",\r\n SESSION_EXPIRED: \"Your session has expired\",\r\n WEAK_PASSWORD: \"Password is too weak\",\r\n EMAIL_NOT_VERIFIED: \"Email verification required\",\r\n INTERNAL_ERROR: \"An internal error occurred. Please try again\",\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"Email verification required\",\r\n AUTHENTICATED: \"Already authenticated\",\r\n UNAUTHENTICATED: \"Authentication required\",\r\n UNVERIFIED: \"Email verification required\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"User not found.\",\r\n WRONG_PASSWORD: \"Wrong password.\",\r\n EMAIL_ALREADY_IN_USE: \"Email already in use.\",\r\n REQUIRES_RECENT_LOGIN: \"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 }\r\n\r\n return {\r\n success: false,\r\n message: message || defaultMessages[code],\r\n code,\r\n }\r\n}\r\n\r\n/**\r\n * Handles Firebase authentication errors with multiple fallback mechanisms\r\n */\r\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\r\n // Helper to extract clean error code from bundled format\r\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\r\n // Case 1: String input (direct Firebase error message)\r\n if (typeof input === 'string') {\r\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: input };\r\n }\r\n }\r\n\r\n // Case 2: Error object\r\n if (input && typeof input === 'object') {\r\n const err = input as { code?: string; message?: string };\r\n \r\n // Check for bundled message format first\r\n if (err.message) {\r\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: err.message };\r\n }\r\n }\r\n\r\n // Check for direct code\r\n if (err.code) {\r\n return {\r\n code: err.code.replace('auth/', ''),\r\n message: err.message || ''\r\n };\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n // Map error codes to user-friendly messages\r\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\r\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\r\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\r\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\r\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\r\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\r\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\r\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\r\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\r\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\r\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' }\r\n };\r\n\r\n try {\r\n // Extract error information\r\n const errorInfo = extractErrorInfo(error);\r\n \r\n if (errorInfo) {\r\n const mappedError = ERROR_MESSAGES[errorInfo.code];\r\n if (mappedError) {\r\n return {\r\n success: false,\r\n message: mappedError.message,\r\n code: mappedError.code\r\n };\r\n }\r\n }\r\n\r\n // If we couldn't extract or map the error, try one last time with string conversion\r\n const errorString = String(error);\r\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\r\n return {\r\n success: false,\r\n ...ERROR_MESSAGES[lastMatch[1]]\r\n };\r\n }\r\n\r\n } catch (e) {\r\n // Silent catch - we'll return the default error\r\n }\r\n\r\n // Default fallback\r\n return {\r\n success: false,\r\n message: 'An unexpected error occurred. Please try again later',\r\n code: 'INTERNAL_ERROR'\r\n };\r\n}\r\n\r\n/**\r\n * Type guard to check if a response is an AuthErrorResponse\r\n */\r\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\r\n return (\r\n typeof response === \"object\" &&\r\n response !== null &&\r\n \"success\" in response &&\r\n (response as { success: boolean }).success === false &&\r\n \"code\" in response &&\r\n \"message\" in response\r\n )\r\n}\r\n\r\nexport function getErrorAlertVariant(error: any | undefined) {\r\n if (!error) return \"destructive\"\r\n\r\n switch (error.error) {\r\n case \"AUTHENTICATED\":\r\n return \"default\"\r\n case \"EMAIL_EXISTS\":\r\n case \"UNAUTHENTICATED\":\r\n case \"UNVERIFIED\":\r\n case \"REQUIRES_VERIFICATION\":\r\n case \"INVALID_EMAIL\":\r\n case \"INVALID_TOKEN\":\r\n case \"INTERNAL_ERROR\":\r\n case \"USER_DISABLED\":\r\n case \"TOO_MANY_ATTEMPTS\":\r\n case \"NETWORK_ERROR\":\r\n case \"SESSION_EXPIRED\":\r\n case \"EXPIRED_TOKEN\":\r\n case \"INVALID_CREDENTIALS\":\r\n default:\r\n return \"destructive\"\r\n }\r\n}","import { \n TernSecureUser \n} from './all';\nimport { 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 TernSecureInstance {\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 { SignedInSession } from 'session';\nimport type { \n TernSecureUser,\n TernSecureConfig\n} from './all';\nimport type { \n SignInResource\n} from './signIn';\nimport { SignUpResource } from 'signUp';\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 requiresVerification?: boolean\n user?: TernSecureUser | null\n}\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 requiresVerification: false,\n user: null\n};\n\n\nexport interface TernSecureAuthProvider {\n /** Current auth state */\n internalAuthState: TernSecureState;\n\n /** Current user*/\n ternSecureUser(): TernSecureUser | null;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource;\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}","import type { \n SignInResponseTree\n} 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\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\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\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}"],"mappings":";AAqBO,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;AAqBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EAEA,YAAY,MAAiB,SAAkB;AAC7C,UAAM,WAAW,IAAI;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AA+JO,SAA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ACF;;;ACtUO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;;;ACjBO,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,sBAAsB;AAAA,EACtB,MAAM;AACR;;;ACVO,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":["export type ErrorCode = keyof typeof ERRORS\r\n\r\nexport interface AuthErrorResponse {\r\n success: false\r\n message: string\r\n code: ErrorCode\r\n}\r\n\r\nexport interface AuthErrorTree extends Error {\r\n code?: any | string;\r\n message: string;\r\n response?: any | string;\r\n}\r\n\r\nexport interface SignInResponseTree {\r\n success: boolean;\r\n message?: string;\r\n error?: any | undefined;\r\n user?: any;\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\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\n// Firebase Auth Error Code patterns\r\nconst ERROR_PATTERNS = {\r\n INVALID_EMAIL: /auth.*invalid.*email|invalid.*email.*auth|Firebase:.*Error.*auth\\/invalid-email/i,\r\n INVALID_CREDENTIALS:\r\n /auth.*invalid.*credential|invalid.*password|wrong.*password|Firebase:.*Error.*auth\\/(invalid-credential|wrong-password|user-not-found)/i,\r\n USER_DISABLED: /user.*disabled|disabled.*user|Firebase:.*Error.*auth\\/user-disabled/i,\r\n TOO_MANY_ATTEMPTS: /too.*many.*attempts|too.*many.*requests|Firebase:.*Error.*auth\\/too-many-requests/i,\r\n NETWORK_ERROR: /network.*request.*failed|failed.*network|Firebase:.*Error.*auth\\/network-request-failed/i,\r\n OPERATION_NOT_ALLOWED: /operation.*not.*allowed|method.*not.*allowed|Firebase:.*Error.*auth\\/operation-not-allowed/i,\r\n POPUP_BLOCKED: /popup.*blocked|blocked.*popup|Firebase:.*Error.*auth\\/popup-blocked/i,\r\n EMAIL_EXISTS: /email.*exists|email.*already.*use|Firebase:.*Error.*auth\\/email-already-in-use/i,\r\n EXPIRED_TOKEN: /token.*expired|expired.*token|Firebase:.*Error.*auth\\/expired-token/i,\r\n INVALID_TOKEN: /invalid.*token|token.*invalid|Firebase:.*Error.*auth\\/invalid-token/i,\r\n SESSION_EXPIRED: /session.*expired|expired.*session|Firebase:.*Error.*auth\\/session-expired/i,\r\n WEAK_PASSWORD: /weak.*password|password.*weak|Firebase:.*Error.*auth\\/weak-password/i,\r\n} as const\r\n\r\nexport class TernSecureError extends Error {\r\n code: ErrorCode\r\n\r\n constructor(code: ErrorCode, message?: string) {\r\n super(message || code)\r\n this.name = \"TernSecureError\"\r\n this.code = code\r\n }\r\n}\r\n\r\ninterface SerializedFirebaseError {\r\n name?: string\r\n code?: string\r\n message?: string\r\n stack?: string\r\n}\r\n\r\n/**\r\n * Determines if an object matches the shape of a Firebase Error\r\n */\r\nfunction isFirebaseErrorLike(error: unknown): error is SerializedFirebaseError {\r\n if (!error || typeof error !== \"object\") return false\r\n\r\n const err = error as SerializedFirebaseError\r\n\r\n // Check for bundled Firebase error format: \"Firebase: Error (auth/error-code)\"\r\n if (typeof err.message === \"string\") {\r\n const bundledErrorMatch = err.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n // Add the extracted code to the error object\r\n err.code = `auth/${bundledErrorMatch[1]}`\r\n return true\r\n }\r\n }\r\n\r\n return (\r\n (typeof err.code === \"string\" && err.code.startsWith(\"auth/\")) ||\r\n (typeof err.name === \"string\" && err.name.includes(\"FirebaseError\"))\r\n )\r\n}\r\n\r\n/**\r\n * Extracts the error code from a Firebase-like error object\r\n */\r\nfunction extractFirebaseErrorCode(error: SerializedFirebaseError): string {\r\n // First try to extract from bundled error message format\r\n if (typeof error.message === \"string\") {\r\n const bundledErrorMatch = error.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n return bundledErrorMatch[1]\r\n }\r\n }\r\n\r\n // Then try the standard code property\r\n if (error.code) {\r\n return error.code.replace(\"auth/\", \"\")\r\n }\r\n\r\n // Finally try to extract from error message if it contains an error code\r\n if (typeof error.message === \"string\") {\r\n const messageCodeMatch = error.message.match(/auth\\/([a-z-]+)/)\r\n if (messageCodeMatch) {\r\n return messageCodeMatch[1]\r\n }\r\n }\r\n\r\n return \"\"\r\n}\r\n\r\n/**\r\n * Maps a Firebase error code to our internal error code\r\n */\r\nfunction mapFirebaseErrorCode(code: string): ErrorCode {\r\n // Direct mapping for known error codes\r\n const directMappings: Record<string, ErrorCode> = {\r\n \"invalid-email\": \"INVALID_EMAIL\",\r\n \"user-disabled\": \"USER_DISABLED\",\r\n \"too-many-requests\": \"TOO_MANY_ATTEMPTS\",\r\n \"network-request-failed\": \"NETWORK_ERROR\",\r\n \"operation-not-allowed\": \"OPERATION_NOT_ALLOWED\",\r\n \"popup-blocked\": \"POPUP_BLOCKED\",\r\n \"email-already-in-use\": \"EMAIL_EXISTS\",\r\n \"weak-password\": \"WEAK_PASSWORD\",\r\n \"invalid-credential\": \"INVALID_CREDENTIALS\",\r\n \"wrong-password\": \"INVALID_CREDENTIALS\",\r\n \"user-not-found\": \"INVALID_CREDENTIALS\",\r\n \"invalid-password\": \"INVALID_CREDENTIALS\",\r\n \"user-token-expired\": \"EXPIRED_TOKEN\",\r\n \"invalid-id-token\": \"INVALID_TOKEN\",\r\n }\r\n\r\n return directMappings[code] || \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Determines error type based on error message pattern matching\r\n */\r\nfunction determineErrorTypeFromMessage(message: string): ErrorCode {\r\n // First check for bundled Firebase error format\r\n const bundledErrorMatch = message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n const errorCode = bundledErrorMatch[1]\r\n const mappedCode = mapFirebaseErrorCode(errorCode)\r\n if (mappedCode) {\r\n return mappedCode\r\n }\r\n }\r\n\r\n // Then check standard patterns\r\n for (const [errorType, pattern] of Object.entries(ERROR_PATTERNS)) {\r\n if (pattern.test(message)) {\r\n return errorType as ErrorCode\r\n }\r\n }\r\n\r\n return \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Creates a standardized error response\r\n */\r\nfunction createErrorResponse(code: ErrorCode, message: string): AuthErrorResponse {\r\n const defaultMessages: Record<ErrorCode, string> = {\r\n INVALID_EMAIL: \"Invalid email format\",\r\n INVALID_CREDENTIALS: \"Invalid email or password\",\r\n USER_DISABLED: \"This account has been disabled\",\r\n TOO_MANY_ATTEMPTS: \"Too many attempts. Please try again later\",\r\n NETWORK_ERROR: \"Network error. Please check your connection\",\r\n OPERATION_NOT_ALLOWED: \"This login method is not enabled\",\r\n POPUP_BLOCKED: \"Login popup was blocked. Please enable popups\",\r\n EMAIL_EXISTS: \"This email is already in use\",\r\n EXPIRED_TOKEN: \"Your session has expired. Please login again\",\r\n INVALID_TOKEN: \"Invalid authentication token\",\r\n SESSION_EXPIRED: \"Your session has expired\",\r\n WEAK_PASSWORD: \"Password is too weak\",\r\n EMAIL_NOT_VERIFIED: \"Email verification required\",\r\n INTERNAL_ERROR: \"An internal error occurred. Please try again\",\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"Email verification required\",\r\n AUTHENTICATED: \"Already authenticated\",\r\n UNAUTHENTICATED: \"Authentication required\",\r\n UNVERIFIED: \"Email verification required\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"User not found.\",\r\n WRONG_PASSWORD: \"Wrong password.\",\r\n EMAIL_ALREADY_IN_USE: \"Email already in use.\",\r\n REQUIRES_RECENT_LOGIN: \"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 }\r\n\r\n return {\r\n success: false,\r\n message: message || defaultMessages[code],\r\n code,\r\n }\r\n}\r\n\r\n/**\r\n * Handles Firebase authentication errors with multiple fallback mechanisms\r\n */\r\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\r\n // Helper to extract clean error code from bundled format\r\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\r\n // Case 1: String input (direct Firebase error message)\r\n if (typeof input === 'string') {\r\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: input };\r\n }\r\n }\r\n\r\n // Case 2: Error object\r\n if (input && typeof input === 'object') {\r\n const err = input as { code?: string; message?: string };\r\n \r\n // Check for bundled message format first\r\n if (err.message) {\r\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: err.message };\r\n }\r\n }\r\n\r\n // Check for direct code\r\n if (err.code) {\r\n return {\r\n code: err.code.replace('auth/', ''),\r\n message: err.message || ''\r\n };\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n // Map error codes to user-friendly messages\r\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\r\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\r\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\r\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\r\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\r\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\r\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\r\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\r\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\r\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\r\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' }\r\n };\r\n\r\n try {\r\n // Extract error information\r\n const errorInfo = extractErrorInfo(error);\r\n \r\n if (errorInfo) {\r\n const mappedError = ERROR_MESSAGES[errorInfo.code];\r\n if (mappedError) {\r\n return {\r\n success: false,\r\n message: mappedError.message,\r\n code: mappedError.code\r\n };\r\n }\r\n }\r\n\r\n // If we couldn't extract or map the error, try one last time with string conversion\r\n const errorString = String(error);\r\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\r\n return {\r\n success: false,\r\n ...ERROR_MESSAGES[lastMatch[1]]\r\n };\r\n }\r\n\r\n } catch (e) {\r\n // Silent catch - we'll return the default error\r\n }\r\n\r\n // Default fallback\r\n return {\r\n success: false,\r\n message: 'An unexpected error occurred. Please try again later',\r\n code: 'INTERNAL_ERROR'\r\n };\r\n}\r\n\r\n/**\r\n * Type guard to check if a response is an AuthErrorResponse\r\n */\r\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\r\n return (\r\n typeof response === \"object\" &&\r\n response !== null &&\r\n \"success\" in response &&\r\n (response as { success: boolean }).success === false &&\r\n \"code\" in response &&\r\n \"message\" in response\r\n )\r\n}\r\n\r\nexport function getErrorAlertVariant(error: any | undefined) {\r\n if (!error) return \"destructive\"\r\n\r\n switch (error.error) {\r\n case \"AUTHENTICATED\":\r\n return \"default\"\r\n case \"EMAIL_EXISTS\":\r\n case \"UNAUTHENTICATED\":\r\n case \"UNVERIFIED\":\r\n case \"REQUIRES_VERIFICATION\":\r\n case \"INVALID_EMAIL\":\r\n case \"INVALID_TOKEN\":\r\n case \"INTERNAL_ERROR\":\r\n case \"USER_DISABLED\":\r\n case \"TOO_MANY_ATTEMPTS\":\r\n case \"NETWORK_ERROR\":\r\n case \"SESSION_EXPIRED\":\r\n case \"EXPIRED_TOKEN\":\r\n case \"INVALID_CREDENTIALS\":\r\n default:\r\n return \"destructive\"\r\n }\r\n}","import { \n TernSecureUser \n} from './all';\nimport { 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 TernSecureInstance {\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 { SignedInSession } from 'session';\nimport type { \n TernSecureUser,\n TernSecureConfig\n} from './all';\nimport type { \n SignInResource\n} from './signIn';\nimport { SignUpResource } from 'signUp';\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\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\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;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource;\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}","import type { \n SignInResponseTree\n} 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\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\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\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":";AAqBO,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;AAqBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EAEA,YAAY,MAAiB,SAAkB;AAC7C,UAAM,WAAW,IAAI;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AA+JO,SAAS,wBAAwB,OAAmC;AAEzE,WAAS,iBAAiB,OAA0D;AAElF,QAAI,OAAO,UAAU,UAAU;AAC7B,YAAM,QAAQ,MAAM,MAAM,uCAAuC;AACjE,UAAI,OAAO;AACT,eAAO,EAAE,MAAM,MAAM,CAAC,GAAG,SAAS,MAAM;AAAA,MAC1C;AAAA,IACF;AAGA,QAAI,SAAS,OAAO,UAAU,UAAU;AACtC,YAAM,MAAM;AAGZ,UAAI,IAAI,SAAS;AACf,cA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;AACR;;;ACRO,SAAS,qBAAqB,OAAyC;AAC5E,SACE,OAAO,UAAU,YACjB,aAAa,SACb,OAAO,MAAM,YAAY;AAE7B;","names":[]}
package/dist/index.d.mts CHANGED
@@ -496,6 +496,17 @@ interface PendingSession extends AuthenticatedSessionBase {
496
496
  */
497
497
  type TernSecureSessionTree = ActiveSession | ExpiredSession;
498
498
  type SignedInSession = ActiveSession | PendingSession | ExpiredSession;
499
+ interface SessionParams {
500
+ idToken: string;
501
+ csrfToken?: string;
502
+ }
503
+ interface SessionResult {
504
+ success: boolean;
505
+ message: string;
506
+ expiresIn?: number;
507
+ error?: string;
508
+ cookieSet?: boolean;
509
+ }
499
510
 
500
511
  type SignInStatus = 'idle' | 'pending_email_password' | 'pending_social' | 'pending_mfa' | 'redirecting' | 'success' | 'error';
501
512
  type SignInFormValuesTree = {
@@ -545,6 +556,11 @@ interface SignInResource {
545
556
  * @returns A promise that resolves with the sign-in response.
546
557
  */
547
558
  resendEmailVerification: () => Promise<ResendEmailVerification>;
559
+ /**
560
+ * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.
561
+ * @returns A promise that resolves with the sign-in response or null if no result is available.
562
+ */
563
+ checkRedirectResult: () => Promise<SignInResponseTree | null>;
548
564
  }
549
565
 
550
566
  interface SignUpResource {
@@ -576,7 +592,6 @@ interface TernSecureState {
576
592
  token: any | null;
577
593
  email: string | null;
578
594
  status: "loading" | "authenticated" | "unauthenticated" | "unverified";
579
- requiresVerification?: boolean;
580
595
  user?: TernSecureUser | null;
581
596
  }
582
597
  type AuthProviderStatus = 'idle' | 'pending' | 'error' | 'success';
@@ -586,6 +601,8 @@ interface TernSecureAuthProvider {
586
601
  internalAuthState: TernSecureState;
587
602
  /** Current user*/
588
603
  ternSecureUser(): TernSecureUser | null;
604
+ /** AuthCookie Manager */
605
+ authCookieManager(): void;
589
606
  /** Current session */
590
607
  currentSession: SignedInSession | null;
591
608
  /** Sign in resource for authentication operations */
@@ -616,8 +633,10 @@ type TernSecureInstanceTreeOptions = {
616
633
  onAuthStateChanged?: (user: TernSecureUser | null) => void;
617
634
  onError?: (error: AuthErrorTree) => void;
618
635
  environment?: string | undefined;
619
- requireverification?: boolean;
636
+ requiresVerification?: boolean;
637
+ isTernSecureDev?: boolean;
620
638
  ternSecureConfig?: TernSecureConfig;
639
+ enableServiceWorker?: boolean;
621
640
  } & SignInRedirectUrl & SignUpRedirectUrl;
622
641
  type TernSecureInstanceTreeStatus = 'error' | 'loading' | 'ready';
623
642
  /**
@@ -636,6 +655,7 @@ interface TernSecureInstanceTree {
636
655
  currentView: 'signIn' | 'signUp' | 'verify' | null;
637
656
  isLoading: boolean;
638
657
  error: Error | null;
658
+ requiresVerification: boolean;
639
659
  /** Authentication State */
640
660
  auth: {
641
661
  /** Current authenticated user */
@@ -658,7 +678,7 @@ interface TernSecureInstanceTree {
658
678
  /** Check if redirect is needed */
659
679
  shouldRedirect: (currentPath: string) => boolean | string;
660
680
  /** Construct URL with redirect parameters */
661
- constructUrlWithRedirect: (to: string) => string;
681
+ constructUrlWithAuthRedirect: (to: string) => string;
662
682
  /** Navigate to SignIn page */
663
683
  redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
664
684
  /** Navigate to SignUp page */
@@ -686,6 +706,8 @@ type SignUpInitialValueTree = Partial<SignUpFormValuesTree>;
686
706
  * Props for SignIn component focusing on UI concerns
687
707
  */
688
708
  type SignInPropsTree = {
709
+ /** Routing Path */
710
+ path?: string;
689
711
  /** URL to navigate to after successfully sign-in */
690
712
  forceRedirectUrl?: string | null;
691
713
  /** Initial form values */
@@ -714,4 +736,4 @@ type SignUpPropsTree = {
714
736
  type SignInRedirectOptions = RedirectOptions;
715
737
  type SignUpRedirectOptions = RedirectOptions;
716
738
 
717
- export { type ActiveSession, type AdminConfigValidationResult, type Appearance, type AuthActions, type AuthError, type AuthErrorCode, type AuthErrorResponse, type AuthErrorTree, type AuthProviderStatus, type BaseAuthUIConfig, type ConfigValidationResult, DEFAULT_TERN_SECURE_STATE, ERRORS, type ErrorCode, type ExpiredSession, type FirebaseState, type IdTokenResult, type ParsedToken, type PendingSession, type RedirectConfig, type RedirectOptions, type ResendEmailVerification, type SessionStatus, 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 SignUpFormValuesTree, type SignUpInitialValue, type SignUpInitialValueTree, type SignUpProps, type SignUpPropsTree, type SignUpRedirectOptions, type SignUpRedirectUrl, type SignUpResource, type SignUpStatus, type SignUpUIConfig, type SignedInSession, type TernSecureAdminConfig, type TernSecureAuthProvider, type TernSecureConfig, TernSecureError, type TernSecureInstance, type TernSecureInstanceTree, type TernSecureInstanceTreeOptions, type TernSecureInstanceTreeStatus, type TernSecureOptions, type TernSecureSession, type TernSecureSessionTree, type TernSecureState, type TernSecureUser, type TernSecureUserData, type ThemeBorderRadius, type ThemeColors, type ThemeComponentStyles, type ThemeFonts, type ThemeSpacing, type UserInfo, getErrorAlertVariant, handleFirebaseAuthError, isAuthErrorResponse, isSignInResponse, isSignInResponseTree };
739
+ export { type ActiveSession, type AdminConfigValidationResult, type Appearance, type AuthActions, type AuthError, type AuthErrorCode, type AuthErrorResponse, type AuthErrorTree, type AuthProviderStatus, type BaseAuthUIConfig, type ConfigValidationResult, DEFAULT_TERN_SECURE_STATE, ERRORS, type ErrorCode, type ExpiredSession, type FirebaseState, type IdTokenResult, type ParsedToken, type PendingSession, type RedirectConfig, type RedirectOptions, type ResendEmailVerification, type SessionParams, type SessionResult, type SessionStatus, 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 SignUpFormValuesTree, type SignUpInitialValue, type SignUpInitialValueTree, type SignUpProps, type SignUpPropsTree, type SignUpRedirectOptions, type SignUpRedirectUrl, type SignUpResource, type SignUpStatus, type SignUpUIConfig, type SignedInSession, type TernSecureAdminConfig, type TernSecureAuthProvider, type TernSecureConfig, TernSecureError, type TernSecureInstance, type TernSecureInstanceTree, type TernSecureInstanceTreeOptions, type TernSecureInstanceTreeStatus, type TernSecureOptions, type TernSecureSession, type TernSecureSessionTree, type TernSecureState, type TernSecureUser, type TernSecureUserData, type ThemeBorderRadius, type ThemeColors, type ThemeComponentStyles, type ThemeFonts, type ThemeSpacing, type UserInfo, getErrorAlertVariant, handleFirebaseAuthError, isAuthErrorResponse, isSignInResponse, isSignInResponseTree };
package/dist/index.js CHANGED
@@ -185,7 +185,6 @@ var DEFAULT_TERN_SECURE_STATE = {
185
185
  token: null,
186
186
  email: null,
187
187
  status: "loading",
188
- requiresVerification: false,
189
188
  user: null
190
189
  };
191
190
 
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 './errors'\nexport * from './ternsecure'\nexport * from './theme'\nexport * from './instanceTree'\nexport * from './auth'\nexport * from './signIn'\nexport * from './signUp'\nexport * from './session'\nexport * from './redirect'","export type ErrorCode = keyof typeof ERRORS\r\n\r\nexport interface AuthErrorResponse {\r\n success: false\r\n message: string\r\n code: ErrorCode\r\n}\r\n\r\nexport interface AuthErrorTree extends Error {\r\n code?: any | string;\r\n message: string;\r\n response?: any | string;\r\n}\r\n\r\nexport interface SignInResponseTree {\r\n success: boolean;\r\n message?: string;\r\n error?: any | undefined;\r\n user?: any;\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\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\n// Firebase Auth Error Code patterns\r\nconst ERROR_PATTERNS = {\r\n INVALID_EMAIL: /auth.*invalid.*email|invalid.*email.*auth|Firebase:.*Error.*auth\\/invalid-email/i,\r\n INVALID_CREDENTIALS:\r\n /auth.*invalid.*credential|invalid.*password|wrong.*password|Firebase:.*Error.*auth\\/(invalid-credential|wrong-password|user-not-found)/i,\r\n USER_DISABLED: /user.*disabled|disabled.*user|Firebase:.*Error.*auth\\/user-disabled/i,\r\n TOO_MANY_ATTEMPTS: /too.*many.*attempts|too.*many.*requests|Firebase:.*Error.*auth\\/too-many-requests/i,\r\n NETWORK_ERROR: /network.*request.*failed|failed.*network|Firebase:.*Error.*auth\\/network-request-failed/i,\r\n OPERATION_NOT_ALLOWED: /operation.*not.*allowed|method.*not.*allowed|Firebase:.*Error.*auth\\/operation-not-allowed/i,\r\n POPUP_BLOCKED: /popup.*blocked|blocked.*popup|Firebase:.*Error.*auth\\/popup-blocked/i,\r\n EMAIL_EXISTS: /email.*exists|email.*already.*use|Firebase:.*Error.*auth\\/email-already-in-use/i,\r\n EXPIRED_TOKEN: /token.*expired|expired.*token|Firebase:.*Error.*auth\\/expired-token/i,\r\n INVALID_TOKEN: /invalid.*token|token.*invalid|Firebase:.*Error.*auth\\/invalid-token/i,\r\n SESSION_EXPIRED: /session.*expired|expired.*session|Firebase:.*Error.*auth\\/session-expired/i,\r\n WEAK_PASSWORD: /weak.*password|password.*weak|Firebase:.*Error.*auth\\/weak-password/i,\r\n} as const\r\n\r\nexport class TernSecureError extends Error {\r\n code: ErrorCode\r\n\r\n constructor(code: ErrorCode, message?: string) {\r\n super(message || code)\r\n this.name = \"TernSecureError\"\r\n this.code = code\r\n }\r\n}\r\n\r\ninterface SerializedFirebaseError {\r\n name?: string\r\n code?: string\r\n message?: string\r\n stack?: string\r\n}\r\n\r\n/**\r\n * Determines if an object matches the shape of a Firebase Error\r\n */\r\nfunction isFirebaseErrorLike(error: unknown): error is SerializedFirebaseError {\r\n if (!error || typeof error !== \"object\") return false\r\n\r\n const err = error as SerializedFirebaseError\r\n\r\n // Check for bundled Firebase error format: \"Firebase: Error (auth/error-code)\"\r\n if (typeof err.message === \"string\") {\r\n const bundledErrorMatch = err.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n // Add the extracted code to the error object\r\n err.code = `auth/${bundledErrorMatch[1]}`\r\n return true\r\n }\r\n }\r\n\r\n return (\r\n (typeof err.code === \"string\" && err.code.startsWith(\"auth/\")) ||\r\n (typeof err.name === \"string\" && err.name.includes(\"FirebaseError\"))\r\n )\r\n}\r\n\r\n/**\r\n * Extracts the error code from a Firebase-like error object\r\n */\r\nfunction extractFirebaseErrorCode(error: SerializedFirebaseError): string {\r\n // First try to extract from bundled error message format\r\n if (typeof error.message === \"string\") {\r\n const bundledErrorMatch = error.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n return bundledErrorMatch[1]\r\n }\r\n }\r\n\r\n // Then try the standard code property\r\n if (error.code) {\r\n return error.code.replace(\"auth/\", \"\")\r\n }\r\n\r\n // Finally try to extract from error message if it contains an error code\r\n if (typeof error.message === \"string\") {\r\n const messageCodeMatch = error.message.match(/auth\\/([a-z-]+)/)\r\n if (messageCodeMatch) {\r\n return messageCodeMatch[1]\r\n }\r\n }\r\n\r\n return \"\"\r\n}\r\n\r\n/**\r\n * Maps a Firebase error code to our internal error code\r\n */\r\nfunction mapFirebaseErrorCode(code: string): ErrorCode {\r\n // Direct mapping for known error codes\r\n const directMappings: Record<string, ErrorCode> = {\r\n \"invalid-email\": \"INVALID_EMAIL\",\r\n \"user-disabled\": \"USER_DISABLED\",\r\n \"too-many-requests\": \"TOO_MANY_ATTEMPTS\",\r\n \"network-request-failed\": \"NETWORK_ERROR\",\r\n \"operation-not-allowed\": \"OPERATION_NOT_ALLOWED\",\r\n \"popup-blocked\": \"POPUP_BLOCKED\",\r\n \"email-already-in-use\": \"EMAIL_EXISTS\",\r\n \"weak-password\": \"WEAK_PASSWORD\",\r\n \"invalid-credential\": \"INVALID_CREDENTIALS\",\r\n \"wrong-password\": \"INVALID_CREDENTIALS\",\r\n \"user-not-found\": \"INVALID_CREDENTIALS\",\r\n \"invalid-password\": \"INVALID_CREDENTIALS\",\r\n \"user-token-expired\": \"EXPIRED_TOKEN\",\r\n \"invalid-id-token\": \"INVALID_TOKEN\",\r\n }\r\n\r\n return directMappings[code] || \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Determines error type based on error message pattern matching\r\n */\r\nfunction determineErrorTypeFromMessage(message: string): ErrorCode {\r\n // First check for bundled Firebase error format\r\n const bundledErrorMatch = message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n const errorCode = bundledErrorMatch[1]\r\n const mappedCode = mapFirebaseErrorCode(errorCode)\r\n if (mappedCode) {\r\n return mappedCode\r\n }\r\n }\r\n\r\n // Then check standard patterns\r\n for (const [errorType, pattern] of Object.entries(ERROR_PATTERNS)) {\r\n if (pattern.test(message)) {\r\n return errorType as ErrorCode\r\n }\r\n }\r\n\r\n return \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Creates a standardized error response\r\n */\r\nfunction createErrorResponse(code: ErrorCode, message: string): AuthErrorResponse {\r\n const defaultMessages: Record<ErrorCode, string> = {\r\n INVALID_EMAIL: \"Invalid email format\",\r\n INVALID_CREDENTIALS: \"Invalid email or password\",\r\n USER_DISABLED: \"This account has been disabled\",\r\n TOO_MANY_ATTEMPTS: \"Too many attempts. Please try again later\",\r\n NETWORK_ERROR: \"Network error. Please check your connection\",\r\n OPERATION_NOT_ALLOWED: \"This login method is not enabled\",\r\n POPUP_BLOCKED: \"Login popup was blocked. Please enable popups\",\r\n EMAIL_EXISTS: \"This email is already in use\",\r\n EXPIRED_TOKEN: \"Your session has expired. Please login again\",\r\n INVALID_TOKEN: \"Invalid authentication token\",\r\n SESSION_EXPIRED: \"Your session has expired\",\r\n WEAK_PASSWORD: \"Password is too weak\",\r\n EMAIL_NOT_VERIFIED: \"Email verification required\",\r\n INTERNAL_ERROR: \"An internal error occurred. Please try again\",\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"Email verification required\",\r\n AUTHENTICATED: \"Already authenticated\",\r\n UNAUTHENTICATED: \"Authentication required\",\r\n UNVERIFIED: \"Email verification required\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"User not found.\",\r\n WRONG_PASSWORD: \"Wrong password.\",\r\n EMAIL_ALREADY_IN_USE: \"Email already in use.\",\r\n REQUIRES_RECENT_LOGIN: \"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 }\r\n\r\n return {\r\n success: false,\r\n message: message || defaultMessages[code],\r\n code,\r\n }\r\n}\r\n\r\n/**\r\n * Handles Firebase authentication errors with multiple fallback mechanisms\r\n */\r\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\r\n // Helper to extract clean error code from bundled format\r\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\r\n // Case 1: String input (direct Firebase error message)\r\n if (typeof input === 'string') {\r\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: input };\r\n }\r\n }\r\n\r\n // Case 2: Error object\r\n if (input && typeof input === 'object') {\r\n const err = input as { code?: string; message?: string };\r\n \r\n // Check for bundled message format first\r\n if (err.message) {\r\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: err.message };\r\n }\r\n }\r\n\r\n // Check for direct code\r\n if (err.code) {\r\n return {\r\n code: err.code.replace('auth/', ''),\r\n message: err.message || ''\r\n };\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n // Map error codes to user-friendly messages\r\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\r\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\r\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\r\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\r\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\r\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\r\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\r\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\r\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\r\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\r\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' }\r\n };\r\n\r\n try {\r\n // Extract error information\r\n const errorInfo = extractErrorInfo(error);\r\n \r\n if (errorInfo) {\r\n const mappedError = ERROR_MESSAGES[errorInfo.code];\r\n if (mappedError) {\r\n return {\r\n success: false,\r\n message: mappedError.message,\r\n code: mappedError.code\r\n };\r\n }\r\n }\r\n\r\n // If we couldn't extract or map the error, try one last time with string conversion\r\n const errorString = String(error);\r\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\r\n return {\r\n success: false,\r\n ...ERROR_MESSAGES[lastMatch[1]]\r\n };\r\n }\r\n\r\n } catch (e) {\r\n // Silent catch - we'll return the default error\r\n }\r\n\r\n // Default fallback\r\n return {\r\n success: false,\r\n message: 'An unexpected error occurred. Please try again later',\r\n code: 'INTERNAL_ERROR'\r\n };\r\n}\r\n\r\n/**\r\n * Type guard to check if a response is an AuthErrorResponse\r\n */\r\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\r\n return (\r\n typeof response === \"object\" &&\r\n response !== null &&\r\n \"success\" in response &&\r\n (response as { success: boolean }).success === false &&\r\n \"code\" in response &&\r\n \"message\" in response\r\n )\r\n}\r\n\r\nexport function getErrorAlertVariant(error: any | undefined) {\r\n if (!error) return \"destructive\"\r\n\r\n switch (error.error) {\r\n case \"AUTHENTICATED\":\r\n return \"default\"\r\n case \"EMAIL_EXISTS\":\r\n case \"UNAUTHENTICATED\":\r\n case \"UNVERIFIED\":\r\n case \"REQUIRES_VERIFICATION\":\r\n case \"INVALID_EMAIL\":\r\n case \"INVALID_TOKEN\":\r\n case \"INTERNAL_ERROR\":\r\n case \"USER_DISABLED\":\r\n case \"TOO_MANY_ATTEMPTS\":\r\n case \"NETWORK_ERROR\":\r\n case \"SESSION_EXPIRED\":\r\n case \"EXPIRED_TOKEN\":\r\n case \"INVALID_CREDENTIALS\":\r\n default:\r\n return \"destructive\"\r\n }\r\n}","import { \n TernSecureUser \n} from './all';\nimport { 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 TernSecureInstance {\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 { SignedInSession } from 'session';\nimport type { \n TernSecureUser,\n TernSecureConfig\n} from './all';\nimport type { \n SignInResource\n} from './signIn';\nimport { SignUpResource } from 'signUp';\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 requiresVerification?: boolean\n user?: TernSecureUser | null\n}\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 requiresVerification: false,\n user: null\n};\n\n\nexport interface TernSecureAuthProvider {\n /** Current auth state */\n internalAuthState: TernSecureState;\n\n /** Current user*/\n ternSecureUser(): TernSecureUser | null;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource;\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}","import type { \n SignInResponseTree\n} 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\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\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\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}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqBO,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;AAqBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EAEA,YAAY,MAAiB,SAAkB;AAC7C,UAAM,WAAW,IAAI;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AA+JO,SAAS,wBAAwB,OAAmC;AAEzE,WAAS,iBAAiB,OAA0D;AAElF,QAAI,O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AAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;;;ACjBO,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,sBAAsB;AAAA,EACtB,MAAM;AACR;;;ACVO,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 './errors'\nexport * from './ternsecure'\nexport * from './theme'\nexport * from './instanceTree'\nexport * from './auth'\nexport * from './signIn'\nexport * from './signUp'\nexport * from './session'\nexport * from './redirect'","export type ErrorCode = keyof typeof ERRORS\r\n\r\nexport interface AuthErrorResponse {\r\n success: false\r\n message: string\r\n code: ErrorCode\r\n}\r\n\r\nexport interface AuthErrorTree extends Error {\r\n code?: any | string;\r\n message: string;\r\n response?: any | string;\r\n}\r\n\r\nexport interface SignInResponseTree {\r\n success: boolean;\r\n message?: string;\r\n error?: any | undefined;\r\n user?: any;\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\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\n// Firebase Auth Error Code patterns\r\nconst ERROR_PATTERNS = {\r\n INVALID_EMAIL: /auth.*invalid.*email|invalid.*email.*auth|Firebase:.*Error.*auth\\/invalid-email/i,\r\n INVALID_CREDENTIALS:\r\n /auth.*invalid.*credential|invalid.*password|wrong.*password|Firebase:.*Error.*auth\\/(invalid-credential|wrong-password|user-not-found)/i,\r\n USER_DISABLED: /user.*disabled|disabled.*user|Firebase:.*Error.*auth\\/user-disabled/i,\r\n TOO_MANY_ATTEMPTS: /too.*many.*attempts|too.*many.*requests|Firebase:.*Error.*auth\\/too-many-requests/i,\r\n NETWORK_ERROR: /network.*request.*failed|failed.*network|Firebase:.*Error.*auth\\/network-request-failed/i,\r\n OPERATION_NOT_ALLOWED: /operation.*not.*allowed|method.*not.*allowed|Firebase:.*Error.*auth\\/operation-not-allowed/i,\r\n POPUP_BLOCKED: /popup.*blocked|blocked.*popup|Firebase:.*Error.*auth\\/popup-blocked/i,\r\n EMAIL_EXISTS: /email.*exists|email.*already.*use|Firebase:.*Error.*auth\\/email-already-in-use/i,\r\n EXPIRED_TOKEN: /token.*expired|expired.*token|Firebase:.*Error.*auth\\/expired-token/i,\r\n INVALID_TOKEN: /invalid.*token|token.*invalid|Firebase:.*Error.*auth\\/invalid-token/i,\r\n SESSION_EXPIRED: /session.*expired|expired.*session|Firebase:.*Error.*auth\\/session-expired/i,\r\n WEAK_PASSWORD: /weak.*password|password.*weak|Firebase:.*Error.*auth\\/weak-password/i,\r\n} as const\r\n\r\nexport class TernSecureError extends Error {\r\n code: ErrorCode\r\n\r\n constructor(code: ErrorCode, message?: string) {\r\n super(message || code)\r\n this.name = \"TernSecureError\"\r\n this.code = code\r\n }\r\n}\r\n\r\ninterface SerializedFirebaseError {\r\n name?: string\r\n code?: string\r\n message?: string\r\n stack?: string\r\n}\r\n\r\n/**\r\n * Determines if an object matches the shape of a Firebase Error\r\n */\r\nfunction isFirebaseErrorLike(error: unknown): error is SerializedFirebaseError {\r\n if (!error || typeof error !== \"object\") return false\r\n\r\n const err = error as SerializedFirebaseError\r\n\r\n // Check for bundled Firebase error format: \"Firebase: Error (auth/error-code)\"\r\n if (typeof err.message === \"string\") {\r\n const bundledErrorMatch = err.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n // Add the extracted code to the error object\r\n err.code = `auth/${bundledErrorMatch[1]}`\r\n return true\r\n }\r\n }\r\n\r\n return (\r\n (typeof err.code === \"string\" && err.code.startsWith(\"auth/\")) ||\r\n (typeof err.name === \"string\" && err.name.includes(\"FirebaseError\"))\r\n )\r\n}\r\n\r\n/**\r\n * Extracts the error code from a Firebase-like error object\r\n */\r\nfunction extractFirebaseErrorCode(error: SerializedFirebaseError): string {\r\n // First try to extract from bundled error message format\r\n if (typeof error.message === \"string\") {\r\n const bundledErrorMatch = error.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n return bundledErrorMatch[1]\r\n }\r\n }\r\n\r\n // Then try the standard code property\r\n if (error.code) {\r\n return error.code.replace(\"auth/\", \"\")\r\n }\r\n\r\n // Finally try to extract from error message if it contains an error code\r\n if (typeof error.message === \"string\") {\r\n const messageCodeMatch = error.message.match(/auth\\/([a-z-]+)/)\r\n if (messageCodeMatch) {\r\n return messageCodeMatch[1]\r\n }\r\n }\r\n\r\n return \"\"\r\n}\r\n\r\n/**\r\n * Maps a Firebase error code to our internal error code\r\n */\r\nfunction mapFirebaseErrorCode(code: string): ErrorCode {\r\n // Direct mapping for known error codes\r\n const directMappings: Record<string, ErrorCode> = {\r\n \"invalid-email\": \"INVALID_EMAIL\",\r\n \"user-disabled\": \"USER_DISABLED\",\r\n \"too-many-requests\": \"TOO_MANY_ATTEMPTS\",\r\n \"network-request-failed\": \"NETWORK_ERROR\",\r\n \"operation-not-allowed\": \"OPERATION_NOT_ALLOWED\",\r\n \"popup-blocked\": \"POPUP_BLOCKED\",\r\n \"email-already-in-use\": \"EMAIL_EXISTS\",\r\n \"weak-password\": \"WEAK_PASSWORD\",\r\n \"invalid-credential\": \"INVALID_CREDENTIALS\",\r\n \"wrong-password\": \"INVALID_CREDENTIALS\",\r\n \"user-not-found\": \"INVALID_CREDENTIALS\",\r\n \"invalid-password\": \"INVALID_CREDENTIALS\",\r\n \"user-token-expired\": \"EXPIRED_TOKEN\",\r\n \"invalid-id-token\": \"INVALID_TOKEN\",\r\n }\r\n\r\n return directMappings[code] || \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Determines error type based on error message pattern matching\r\n */\r\nfunction determineErrorTypeFromMessage(message: string): ErrorCode {\r\n // First check for bundled Firebase error format\r\n const bundledErrorMatch = message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n const errorCode = bundledErrorMatch[1]\r\n const mappedCode = mapFirebaseErrorCode(errorCode)\r\n if (mappedCode) {\r\n return mappedCode\r\n }\r\n }\r\n\r\n // Then check standard patterns\r\n for (const [errorType, pattern] of Object.entries(ERROR_PATTERNS)) {\r\n if (pattern.test(message)) {\r\n return errorType as ErrorCode\r\n }\r\n }\r\n\r\n return \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Creates a standardized error response\r\n */\r\nfunction createErrorResponse(code: ErrorCode, message: string): AuthErrorResponse {\r\n const defaultMessages: Record<ErrorCode, string> = {\r\n INVALID_EMAIL: \"Invalid email format\",\r\n INVALID_CREDENTIALS: \"Invalid email or password\",\r\n USER_DISABLED: \"This account has been disabled\",\r\n TOO_MANY_ATTEMPTS: \"Too many attempts. Please try again later\",\r\n NETWORK_ERROR: \"Network error. Please check your connection\",\r\n OPERATION_NOT_ALLOWED: \"This login method is not enabled\",\r\n POPUP_BLOCKED: \"Login popup was blocked. Please enable popups\",\r\n EMAIL_EXISTS: \"This email is already in use\",\r\n EXPIRED_TOKEN: \"Your session has expired. Please login again\",\r\n INVALID_TOKEN: \"Invalid authentication token\",\r\n SESSION_EXPIRED: \"Your session has expired\",\r\n WEAK_PASSWORD: \"Password is too weak\",\r\n EMAIL_NOT_VERIFIED: \"Email verification required\",\r\n INTERNAL_ERROR: \"An internal error occurred. Please try again\",\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"Email verification required\",\r\n AUTHENTICATED: \"Already authenticated\",\r\n UNAUTHENTICATED: \"Authentication required\",\r\n UNVERIFIED: \"Email verification required\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"User not found.\",\r\n WRONG_PASSWORD: \"Wrong password.\",\r\n EMAIL_ALREADY_IN_USE: \"Email already in use.\",\r\n REQUIRES_RECENT_LOGIN: \"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 }\r\n\r\n return {\r\n success: false,\r\n message: message || defaultMessages[code],\r\n code,\r\n }\r\n}\r\n\r\n/**\r\n * Handles Firebase authentication errors with multiple fallback mechanisms\r\n */\r\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\r\n // Helper to extract clean error code from bundled format\r\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\r\n // Case 1: String input (direct Firebase error message)\r\n if (typeof input === 'string') {\r\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: input };\r\n }\r\n }\r\n\r\n // Case 2: Error object\r\n if (input && typeof input === 'object') {\r\n const err = input as { code?: string; message?: string };\r\n \r\n // Check for bundled message format first\r\n if (err.message) {\r\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: err.message };\r\n }\r\n }\r\n\r\n // Check for direct code\r\n if (err.code) {\r\n return {\r\n code: err.code.replace('auth/', ''),\r\n message: err.message || ''\r\n };\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n // Map error codes to user-friendly messages\r\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\r\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\r\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\r\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\r\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\r\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\r\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\r\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\r\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\r\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\r\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' }\r\n };\r\n\r\n try {\r\n // Extract error information\r\n const errorInfo = extractErrorInfo(error);\r\n \r\n if (errorInfo) {\r\n const mappedError = ERROR_MESSAGES[errorInfo.code];\r\n if (mappedError) {\r\n return {\r\n success: false,\r\n message: mappedError.message,\r\n code: mappedError.code\r\n };\r\n }\r\n }\r\n\r\n // If we couldn't extract or map the error, try one last time with string conversion\r\n const errorString = String(error);\r\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\r\n return {\r\n success: false,\r\n ...ERROR_MESSAGES[lastMatch[1]]\r\n };\r\n }\r\n\r\n } catch (e) {\r\n // Silent catch - we'll return the default error\r\n }\r\n\r\n // Default fallback\r\n return {\r\n success: false,\r\n message: 'An unexpected error occurred. Please try again later',\r\n code: 'INTERNAL_ERROR'\r\n };\r\n}\r\n\r\n/**\r\n * Type guard to check if a response is an AuthErrorResponse\r\n */\r\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\r\n return (\r\n typeof response === \"object\" &&\r\n response !== null &&\r\n \"success\" in response &&\r\n (response as { success: boolean }).success === false &&\r\n \"code\" in response &&\r\n \"message\" in response\r\n )\r\n}\r\n\r\nexport function getErrorAlertVariant(error: any | undefined) {\r\n if (!error) return \"destructive\"\r\n\r\n switch (error.error) {\r\n case \"AUTHENTICATED\":\r\n return \"default\"\r\n case \"EMAIL_EXISTS\":\r\n case \"UNAUTHENTICATED\":\r\n case \"UNVERIFIED\":\r\n case \"REQUIRES_VERIFICATION\":\r\n case \"INVALID_EMAIL\":\r\n case \"INVALID_TOKEN\":\r\n case \"INTERNAL_ERROR\":\r\n case \"USER_DISABLED\":\r\n case \"TOO_MANY_ATTEMPTS\":\r\n case \"NETWORK_ERROR\":\r\n case \"SESSION_EXPIRED\":\r\n case \"EXPIRED_TOKEN\":\r\n case \"INVALID_CREDENTIALS\":\r\n default:\r\n return \"destructive\"\r\n }\r\n}","import { \n TernSecureUser \n} from './all';\nimport { 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 TernSecureInstance {\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 { SignedInSession } from 'session';\nimport type { \n TernSecureUser,\n TernSecureConfig\n} from './all';\nimport type { \n SignInResource\n} from './signIn';\nimport { SignUpResource } from 'signUp';\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\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\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;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource;\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}","import type { \n SignInResponseTree\n} 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\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\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\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;AAAA;AAAA;AAAA;AAAA;;;ACqBO,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;AAqBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EAEA,YAAY,MAAiB,SAAkB;AAC7C,UAAM,WAAW,IAAI;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AA+JO,SAAS,wBAAwB,OAAmC;AAEzE,WAAS,iBAAiB,OAA0D;AAElF,QAAI,OAAO,UAAU,UAAU;AAC7B,YAAM,QAAQ,MAAM,MAAM,uCAAuC;AACjE,UAAI,O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ACxD,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;;;ACRO,SAAS,qBAAqB,OAAyC;AAC5E,SACE,OAAO,UAAU,YACjB,aAAa,SACb,OAAO,MAAM,YAAY;AAE7B;","names":[]}
@@ -15,8 +15,10 @@ export type TernSecureInstanceTreeOptions = {
15
15
  onAuthStateChanged?: (user: TernSecureUser | null) => void;
16
16
  onError?: (error: AuthErrorTree) => void;
17
17
  environment?: string | undefined;
18
- requireverification?: boolean;
18
+ requiresVerification?: boolean;
19
+ isTernSecureDev?: boolean;
19
20
  ternSecureConfig?: TernSecureConfig;
21
+ enableServiceWorker?: boolean;
20
22
  } & SignInRedirectUrl & SignUpRedirectUrl;
21
23
  export type TernSecureInstanceTreeStatus = 'error' | 'loading' | 'ready';
22
24
  /**
@@ -35,6 +37,7 @@ export interface TernSecureInstanceTree {
35
37
  currentView: 'signIn' | 'signUp' | 'verify' | null;
36
38
  isLoading: boolean;
37
39
  error: Error | null;
40
+ requiresVerification: boolean;
38
41
  /** Authentication State */
39
42
  auth: {
40
43
  /** Current authenticated user */
@@ -57,7 +60,7 @@ export interface TernSecureInstanceTree {
57
60
  /** Check if redirect is needed */
58
61
  shouldRedirect: (currentPath: string) => boolean | string;
59
62
  /** Construct URL with redirect parameters */
60
- constructUrlWithRedirect: (to: string) => string;
63
+ constructUrlWithAuthRedirect: (to: string) => string;
61
64
  /** Navigate to SignIn page */
62
65
  redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
63
66
  /** Navigate to SignUp page */
@@ -85,6 +88,8 @@ export type SignUpInitialValueTree = Partial<SignUpFormValuesTree>;
85
88
  * Props for SignIn component focusing on UI concerns
86
89
  */
87
90
  export type SignInPropsTree = {
91
+ /** Routing Path */
92
+ path?: string;
88
93
  /** URL to navigate to after successfully sign-in */
89
94
  forceRedirectUrl?: string | null;
90
95
  /** Initial form values */
@@ -1 +1 @@
1
- {"version":3,"file":"instanceTree.d.ts","sourceRoot":"","sources":["../src/instanceTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,MAAM,SAAS,CAAC;AAClB,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAIlB,KAAK,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC;AAGjC,MAAM,MAAM,6BAA6B,GAAG;IAC1C,cAAc,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC9C,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAE1C,MAAM,MAAM,4BAA4B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BAAgB;IAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD,GAAG,iBAAiB,CAAA;AAGrB;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,0BAA0B;IAC1B,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,uBAAuB;IACvB,EAAE,CAAC,EAAE,cAAc,CAAC;IACpB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;CACnD,GAAG,iBAAiB,CAAA;AAErB,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAA;AACnD,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC"}
package/dist/session.d.ts CHANGED
@@ -72,5 +72,16 @@ export interface PendingSession extends AuthenticatedSessionBase {
72
72
  */
73
73
  export type TernSecureSessionTree = ActiveSession | ExpiredSession;
74
74
  export type SignedInSession = ActiveSession | PendingSession | ExpiredSession;
75
+ export interface SessionParams {
76
+ idToken: string;
77
+ csrfToken?: string;
78
+ }
79
+ export interface SessionResult {
80
+ success: boolean;
81
+ message: string;
82
+ expiresIn?: number;
83
+ error?: string;
84
+ cookieSet?: boolean;
85
+ }
75
86
  export {};
76
87
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,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wB;IAC9D,MAAM,EAAE,SAAS,CAAC;CACnB;AAGD;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,wBAAwB;IAC9D,MAAM,EAAE,SAAS,CAAC;CACnB;AAGD;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG,cAAc,CAAC;AAGnE,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,cAAc,GAAG,cAAc,CAAC;AAG9E,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
package/dist/signIn.d.ts CHANGED
@@ -47,5 +47,10 @@ export interface SignInResource {
47
47
  * @returns A promise that resolves with the sign-in response.
48
48
  */
49
49
  resendEmailVerification: () => Promise<ResendEmailVerification>;
50
+ /**
51
+ * Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.
52
+ * @returns A promise that resolves with the sign-in response or null if no result is available.
53
+ */
54
+ checkRedirectResult: () => Promise<SignInResponseTree | null>;
50
55
  }
51
56
  //# sourceMappingURL=signIn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signIn.d.ts","sourceRoot":"","sources":["../src/signIn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,wBAAwB,GACxB,gBAAgB,GAChB,aAAa,GACb,aAAa,GACb,SAAS,GACT,OAAO,CAAC;AAIZ,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACj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MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAGnE,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,kBAAkB,CAM5E;AAID,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;OAIG;IACH,oBAAoB,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpF;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAAA;KAAE,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;IACxH;;;;;OAKG;IACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvF;;;;OAIG;IACH,sBAAsB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD;;;OAGG;IACH,uBAAuB,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAChE;;;OAGG;IACH,mBAAmB,EAAE,MAAM,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;CAC/D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tern-secure/types",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Type definitions for TernSecure packages",
5
5
  "repository": {
6
6
  "type": "git",