@civic/auth 0.11.4 โ 0.11.5-beta.1
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/CHANGELOG.md +4 -0
- package/dist/lib/oauth2/OAuth2Client.d.ts +69 -0
- package/dist/lib/oauth2/OAuth2Client.d.ts.map +1 -0
- package/dist/lib/oauth2/OAuth2Client.js +171 -0
- package/dist/lib/oauth2/OAuth2Client.js.map +1 -0
- package/dist/server/ServerAuthenticationResolver.js +1 -1
- package/dist/server/ServerAuthenticationResolver.js.map +1 -1
- package/dist/services/AuthenticationService.js +1 -1
- package/dist/services/AuthenticationService.js.map +1 -1
- package/dist/services/PKCE.js +1 -1
- package/dist/services/PKCE.js.map +1 -1
- package/dist/shared/lib/AuthenticationRefresherImpl.js +1 -1
- package/dist/shared/lib/AuthenticationRefresherImpl.js.map +1 -1
- package/dist/shared/lib/util.d.ts +1 -1
- package/dist/shared/lib/util.d.ts.map +1 -1
- package/dist/shared/lib/util.js +1 -1
- package/dist/shared/lib/util.js.map +1 -1
- package/dist/shared/version.d.ts +1 -1
- package/dist/shared/version.d.ts.map +1 -1
- package/dist/shared/version.js +1 -1
- package/dist/shared/version.js.map +1 -1
- package/dist/vanillajs/auth/CivicAuth.js +1 -0
- package/dist/vanillajs/auth/CivicAuth.js.map +1 -1
- package/dist/vanillajs/auth/SessionManager.d.ts.map +1 -1
- package/dist/vanillajs/auth/SessionManager.js +1 -0
- package/dist/vanillajs/auth/SessionManager.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CivicAuth.js","sourceRoot":"","sources":["../../../src/vanillajs/auth/CivicAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGhF,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB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CAAC;gBACpD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAE1D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE;oBACnD,QAAQ;iBACT,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gDAAgD,EAAE;oBACjE,QAAQ,EAAE,KAAK;oBACf,iBAAiB;iBAClB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACpE,sDAAsD;QACxD,CAAC;IACH,CAAC;CACF;AAID,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["import { AuthEvent } from \"../types/index.js\";\nimport type { Endpoints, AuthStorage } from \"../../types.js\";\nimport { buildAuthUrl, extractTokensFromSession } from \"../utils/auth-utils.js\";\nimport type { AuthResult, Session } from \"../types/index.js\";\nimport type { createLogger } from \"../utils/logger.js\";\nimport {\n createMainLogger,\n configureLogging,\n setCurrentLogger,\n} from \"../utils/logger.js\";\nimport { GenericPublicClientPKCEProducer } from \"../../services/PKCE.js\";\nimport { generateState } from \"../../lib/oauth.js\";\nimport { SessionManager } from \"./SessionManager.js\";\nimport { AuthenticationEvents } from \"./AuthenticationEvents.js\";\nimport { PopupError } from \"../../services/types.js\";\nimport { getVersion } from \"../../shared/index.js\";\nimport { handleOAuthRedirectPage } from \"./handlers/OAuthCallbackHandler.js\";\nimport {\n generateOauthLogoutUrl,\n clearTokens,\n retrieveTokens,\n getBackendEndpoints,\n resolveEndpointUrl,\n} from \"../../shared/lib/util.js\";\nimport { LOGOUT_STATE } from \"../../constants.js\";\nimport { getOauthEndpoints } from \"../../lib/oauth.js\";\nimport { collectAndSendSDKAnalytics } from \"../../lib/analytics.js\";\nimport type { AuthConfig } from \"../../server/config.js\";\n\n// Import new modular components\nimport type {\n CivicAuthClientConfig,\n ProcessedCivicAuthConfig,\n} from \"./types/AuthTypes.js\";\nimport {\n CivicAuthError,\n CivicAuthErrorCode,\n CIVIC_AUTH_CONSTANTS,\n} from \"./types/AuthTypes.js\";\nimport { processConfigWithDefaults } from \"./config/ConfigProcessor.js\";\nimport { MessageHandler } from \"./handlers/MessageHandler.js\";\nimport { PopupHandler } from \"./handlers/PopupHandler.js\";\nimport { IframeAuthHandler } from \"./handlers/IframeAuthHandler.js\";\nimport { IframeManager } from \"../iframe/IframeManager.js\";\n\n// Authentication session timeout in seconds (30 minutes)\nconst AUTH_SESSION_TIMEOUT_SECONDS = 30 * 60;\nconst AUTH_SESSION_TIMESTAMP_KEY =\n \"civic_auth_authentication_started_at_seconds\";\n\n// In-memory fallback store for environments without localStorage\nconst inMemoryStore: Map<string, string> = new Map();\n\n/**\n * CivicAuth client for handling OAuth authentication\n *\n * This is a refactored version that uses a modular architecture for better maintainability.\n */\nexport class CivicAuth {\n private config: ProcessedCivicAuthConfig;\n private storage: AuthStorage;\n private endpoints?: Endpoints;\n private logger: ReturnType<typeof createLogger>;\n private sessionManager: SessionManager;\n private events: AuthenticationEvents;\n private initialDisplayMode:\n | \"iframe\"\n | \"modal\"\n | \"redirect\"\n | \"new_tab\"\n | \"custom_tab\";\n\n // Authentication state\n private authPromise?: Promise<AuthResult>;\n private authPromiseResolve?: (value: AuthResult) => void;\n private authPromiseReject?: (reason?: Error) => void;\n private authProcessTimeoutHandle?: number;\n private popupFailureTimeoutHandle?: number;\n private hasPopupFailed: boolean = false;\n private hasSignInStarted: boolean = false;\n\n // Backend integration - custom login URL\n private loginUrl?: string;\n\n // Handlers\n private messageHandler?: MessageHandler;\n private popupHandler?: PopupHandler;\n private iframeAuthHandler?: IframeAuthHandler;\n\n /**\n * Private constructor - initializes configuration and handlers.\n * Use {@link CivicAuth.create} to create a new instance.\n */\n private constructor(config: CivicAuthClientConfig) {\n // Process config with defaults and validation\n this.config = processConfigWithDefaults(config);\n this.initialDisplayMode = this.config.displayMode;\n\n // Set loginUrl from config if provided\n this.loginUrl = this.config.loginUrl;\n\n // Configure logging\n configureLogging(this.config.logging);\n\n // Initialize logger - always use \"vanillajs\" as base namespace\n if (this.config.logging?.enabled) {\n this.logger = createMainLogger(\"vanillajs\"); // Always use \"vanillajs\"\n } else {\n this.logger = {\n debug: () => {},\n info: () => {},\n warn: () => {},\n error: () => {},\n };\n }\n\n setCurrentLogger(this.logger);\n this.storage = this.config.storageAdapter;\n\n // Always initialize events - use provided events or create default instance\n this.events = config.events || new AuthenticationEvents();\n\n // Always initialize SessionManager\n this.sessionManager = new SessionManager(\n this.storage,\n this.events,\n this.config,\n this.config.initialUser,\n );\n\n // Initialize handlers\n this.initializeHandlers();\n }\n\n /**\n * Creates and initializes a new instance of CivicAuth.\n * This is the recommended way to create a CivicAuth instance.\n *\n * @param config - Configuration options for the auth client\n * @returns A promise that resolves with the initialized CivicAuth instance\n * @throws {CivicAuthError} If initialization fails or required configuration is missing\n *\n * @example\n * ```typescript\n * // Standard SPA authentication\n * const auth = await CivicAuth.create({\n * clientId: \"your-client-id\",\n * // redirectUrl is optional - defaults to current page (window.location.origin + window.location.pathname)\n * redirectUrl: \"https://your-app.com/callback\", // optional\n * // logoutRedirectUrl is optional - defaults to redirectUrl if not provided\n * logoutRedirectUrl: \"https://your-app.com/logout\", // optional\n * // oauthServerBaseUrl is optional - defaults to \"https://auth.civic.com/oauth\"\n * oauthServerBaseUrl: \"https://auth-server.com/\", // optional\n * // scopes is optional - defaults to ['openid', 'profile', 'email', 'offline_access']\n * scopes: [\"openid\", \"profile\"], // optional\n * targetContainerElement: \"auth-container\",\n * textSignals: {\n * success: \"Authentication successful!\"\n * }\n * });\n *\n * // Backend integration authentication\n * const authWithBackend = await CivicAuth.create({\n * clientId: \"your-client-id\",\n * loginUrl: \"http://example.com/custom-backendurl\" // Automatically uses BrowserCookieStorage\n * });\n * ```\n */\n public static async create(\n config: CivicAuthClientConfig,\n ): Promise<CivicAuth> {\n const instance = new CivicAuth(config);\n await instance.init();\n return instance;\n }\n\n /**\n * Initializes the auth client and checks for callback handling\n */\n private async init(): Promise<void> {\n this.logger.info(\"๐ Initializing CivicAuth\", {\n currentUrl: window.location.href,\n redirectUrl: this.config.redirectUrl,\n oauthServerBaseUrl: this.config.oauthServerBaseUrl,\n isCallbackUrl: window.location.href.startsWith(this.config.redirectUrl),\n });\n\n try {\n // Get OAuth endpoints using shared function (handles trailing slash automatically)\n this.endpoints = await getOauthEndpoints(this.config.oauthServerBaseUrl);\n\n this.logger.info(\"๐ OAuth endpoints configured\", {\n endpoints: this.endpoints,\n });\n\n // Initialize SessionManager with auth config\n if (this.sessionManager) {\n const loginUrl = this.config.loginUrl || this.loginUrl;\n\n // Construct authConfig based on our discriminated union pattern\n const authConfig: AuthConfig =\n loginUrl && !this.config.clientId\n ? {\n ...this.config,\n // Backend integration mode: loginUrl required, clientId optional\n loginUrl,\n redirectUrl: this.config.redirectUrl,\n oauthServer: this.config.oauthServerBaseUrl,\n backendEndpoints: this.config.backendEndpoints,\n }\n : {\n ...this.config,\n // Standard OAuth mode: clientId required, loginUrl optional\n clientId: this.config.clientId!,\n loginUrl,\n redirectUrl: this.config.redirectUrl,\n oauthServer: this.config.oauthServerBaseUrl,\n backendEndpoints: this.config.backendEndpoints,\n };\n\n this.logger.info(\"๐ง Initializing SessionManager\", { authConfig });\n await this.sessionManager.initializeWithAuthConfig(authConfig);\n }\n\n // Check if we're on the callback page\n const isCallbackPage = window.location.href.startsWith(\n this.config.redirectUrl,\n );\n this.logger.info(\"๐ Callback page check\", {\n isCallbackPage,\n currentUrl: window.location.href,\n redirectUrl: this.config.redirectUrl,\n });\n\n // Handle logout state cleanup first (before processing auth callbacks)\n await this.handleLogoutStateCleanup();\n\n if (isCallbackPage) {\n this.logger.info(\"๐ Processing callback page\");\n await this.handleCallback();\n } else {\n this.logger.info(\"๐ Not a callback page, initialization complete\");\n }\n\n // Check if we're in embedded mode - we need to show the iframe\n // Note: After config processing, \"embedded\" displayMode becomes \"iframe\" + iframeDisplayMode: \"embedded\"\n const isEmbeddedMode =\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"embedded\";\n\n this.logger.info(\"๐ Checking display mode conditions\", {\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n isEmbeddedMode,\n preloadIframe: this.config.preloadIframe,\n });\n\n if (isEmbeddedMode) {\n // For embedded mode, we need to start authentication to show the iframe\n try {\n this.logger.info(\n \"๐ผ๏ธ Starting authentication for embedded mode to show iframe...\",\n );\n await this.startAuthentication();\n this.logger.info(\n \"โ
Embedded iframe authentication started successfully\",\n );\n } catch (error) {\n // Don't fail initialization if embedded authentication fails - graceful degradation\n this.logger.warn(\n \"โ ๏ธ Embedded authentication failed (graceful degradation):\",\n {\n error: error instanceof Error ? error.message : String(error),\n },\n );\n }\n } else if (\n this.config.preloadIframe &&\n this.config.displayMode === \"iframe\"\n ) {\n // Regular iframe preloading logic for modal mode\n try {\n const isAuthenticated = await this.isAuthenticated();\n this.logger.info(\"๐ Authentication check for preload\", {\n isAuthenticated,\n });\n\n if (!isAuthenticated) {\n this.logger.info(\n \"๐ Auto-preloading iframe for instant sign-in...\",\n );\n await this.preloadAuthentication();\n this.logger.info(\"โ
Iframe auto-preloaded successfully\");\n } else {\n this.logger.debug(\n \"โน๏ธ User already authenticated, skipping preload\",\n );\n }\n } catch (error) {\n // Don't fail initialization if preloading fails - graceful degradation\n this.logger.warn(\n \"โ ๏ธ Auto-preloading failed (graceful degradation):\",\n {\n error: error instanceof Error ? error.message : String(error),\n },\n );\n }\n } else {\n this.logger.info(\"โน๏ธ Auto-preload conditions not met\", {\n preloadIframe: this.config.preloadIframe,\n displayMode: this.config.displayMode,\n isEmbeddedMode,\n reason: isEmbeddedMode\n ? \"embedded mode uses startAuthentication instead\"\n : !this.config.preloadIframe\n ? \"preloadIframe is disabled\"\n : \"displayMode is not iframe\",\n });\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to initialize authentication\";\n this.logger.error(\"โ CivicAuth initialization failed\", {\n error: errorMessage,\n stack: error instanceof Error ? error.stack : undefined,\n });\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: errorMessage,\n });\n throw new CivicAuthError(errorMessage, CivicAuthErrorCode.INIT_FAILED);\n }\n }\n\n /**\n * Initialize all handlers with proper configuration\n */\n private initializeHandlers(): void {\n const handlerConfig = {\n config: this.config,\n logger: this.logger,\n onAuthSuccess: this.handleAuthSuccess.bind(this),\n onAuthError: this.handleAuthError.bind(this),\n cleanup: this.cleanup.bind(this),\n };\n\n this.messageHandler = new MessageHandler({\n ...handlerConfig,\n onPopupFailure: this.handlePopupFailure.bind(this),\n onBrowserCorsFailsSilently: async () => {\n if (this.hasSignInStarted) {\n await this.handleBrowserCorsFailsSilently();\n }\n },\n });\n\n this.popupHandler = new PopupHandler(handlerConfig);\n\n this.iframeAuthHandler = new IframeAuthHandler({\n ...handlerConfig,\n messageHandler: this.messageHandler.handleMessage,\n });\n\n // Set up automatic re-preloading when authentication is cancelled\n this.setupAutoRepreload();\n }\n\n /**\n * Set up automatic re-preloading when authentication is cancelled by user\n * This maintains instant sign-in experience for subsequent attempts\n */\n private setupAutoRepreload(): void {\n this.events.on(AuthEvent.SIGN_IN_STARTED, () => {\n this.hasSignInStarted = true;\n });\n this.events.on(AuthEvent.SIGN_IN_ERROR, (event?: { detail?: string }) => {\n // Only re-preload for iframe mode with user cancellation and preload enabled\n if (\n this.config.displayMode === \"iframe\" &&\n this.config.preloadIframe &&\n event?.detail === \"Authentication cancelled by user\"\n ) {\n this.logger.debug(\n \"๐ Authentication cancelled, scheduling re-preload for instant subsequent sign-in\",\n );\n\n // Small delay to ensure cleanup is complete\n setTimeout(async () => {\n try {\n await this.preloadAuthentication();\n this.logger.debug(\n \"โ
Re-preloaded iframe after cancellation for instant sign-in\",\n );\n } catch (error) {\n // Don't fail silently, but don't crash either - just log the issue\n this.logger.warn(\n \"โ ๏ธ Failed to re-preload iframe after cancellation:\",\n {\n error: error instanceof Error ? error.message : String(error),\n },\n );\n }\n }, 200); // Small delay to ensure cleanup completion\n }\n });\n }\n\n /**\n * Builds the authentication URL with PKCE challenge\n */\n private async buildAuthUrl(isStale?: boolean): Promise<string> {\n // If a login URL is set (for backend integration), use that instead\n if (this.loginUrl) {\n this.logger.info(\"๐ Using login URL for backend integration\", {\n loginUrl: this.loginUrl,\n });\n\n // Generate state with display mode information for backend integration\n const state =\n this.config.initialState ||\n generateState({\n displayMode: this.config.displayMode || \"iframe\",\n iframeDisplayMode: this.config.iframeDisplayMode,\n framework: this.config.framework || \"vanillajs\",\n sdkVersion: getVersion(),\n loginSuccessUrl: this.config.loginSuccessUrl,\n previousSessionStale: isStale,\n });\n\n // Append state as query parameter to loginUrl\n const url = new URL(this.loginUrl, window.location.origin);\n url.searchParams.set(\"state\", state);\n url.searchParams.set(\"appUrl\", window.location.origin);\n\n this.logger.info(\"๐ Built login URL with display mode state\", {\n loginUrl: url.toString(),\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n });\n\n return url.toString();\n }\n\n if (!this.endpoints) {\n throw new CivicAuthError(\n \"OAuth endpoints not initialized. Please wait for initialization to complete.\",\n CivicAuthErrorCode.ENDPOINTS_NOT_INITIALIZED,\n );\n }\n\n // Ensure clientId is present for OAuth flow (it should be according to our discriminated union)\n if (!this.config.clientId) {\n throw new CivicAuthError(\n \"ClientId is required for OAuth flow when loginUrl is not provided.\",\n CivicAuthErrorCode.CONFIG_REQUIRED,\n );\n }\n\n const pkceProducer = new GenericPublicClientPKCEProducer(this.storage);\n const codeChallenge = await pkceProducer.getCodeChallenge();\n const state =\n this.config.initialState ||\n generateState({\n displayMode: this.config.displayMode || \"iframe\",\n iframeDisplayMode: this.config.iframeDisplayMode,\n framework: this.config.framework || \"vanillajs\",\n sdkVersion: getVersion(),\n loginSuccessUrl: this.config.loginSuccessUrl,\n });\n\n return buildAuthUrl({\n endpoints: this.endpoints,\n clientId: this.config.clientId,\n redirectUrl: this.config.redirectUrl,\n scopes: this.config.scopes,\n codeChallenge,\n state,\n prompt: this.config.prompt,\n nonce: this.config.nonce,\n });\n }\n\n /**\n * Preloads the authentication iframe for instant sign-in\n * This creates the iframe in the background but keeps it hidden until startAuthentication() is called\n * @throws {CivicAuthError} If preloading fails or is not supported\n * @private - This method is used internally for automatic preloading\n */\n private async preloadAuthentication(): Promise<void> {\n this.logger.info(\"๐ฌ Preloading authentication for instant sign-in\", {\n displayMode: this.config.displayMode,\n userAgent: navigator.userAgent,\n currentUrl: window.location.href,\n });\n\n if (!this.endpoints) {\n const error = new CivicAuthError(\n \"OAuth endpoints not initialized. Please wait for initialization to complete.\",\n CivicAuthErrorCode.ENDPOINTS_NOT_INITIALIZED,\n );\n this.logger.error(\"โ Endpoints not initialized for preload\", {\n error: error.message,\n });\n throw error;\n }\n\n // Only support preloading for iframe mode\n if (this.config.displayMode !== \"iframe\") {\n this.logger.warn(\n \"โ ๏ธ Iframe preloading only supported for iframe display mode\",\n {\n displayMode: this.config.displayMode,\n },\n );\n return;\n }\n\n if (!this.iframeAuthHandler) {\n const error = new CivicAuthError(\n \"Iframe handler not initialized for preloading\",\n CivicAuthErrorCode.INIT_FAILED,\n );\n this.logger.error(\"โ Iframe handler not initialized\", {\n error: error.message,\n });\n throw error;\n }\n\n const fullAuthUrl = await this.buildAuthUrl();\n this.logger.info(\"๐ Built authentication URL for preload\", {\n url: fullAuthUrl,\n displayMode: this.config.displayMode,\n });\n\n try {\n // Set authentication timestamp when preloading starts\n // This ensures stale detection works even for preloaded iframes\n this.setAuthenticationStartedAtSeconds();\n\n await this.iframeAuthHandler.preloadIframe(fullAuthUrl);\n const iframeElement = this.iframeAuthHandler.getIframeElement();\n if (iframeElement) {\n this.messageHandler?.updateIframeElement(iframeElement);\n }\n\n this.logger.info(\"โ
Authentication iframe preloaded successfully\");\n } catch (error) {\n // Clear timestamp if preloading fails\n this.clearAuthenticationStartedAtSeconds();\n\n const errorMessage =\n error instanceof Error ? error.message : \"Failed to preload iframe\";\n this.logger.error(\"โ Failed to preload authentication iframe\", {\n error: errorMessage,\n });\n throw new CivicAuthError(\n errorMessage,\n CivicAuthErrorCode.IFRAME_PRELOAD_FAILED,\n );\n }\n }\n\n /**\n * Check if authentication is preloaded and ready for instant sign-in\n * @returns True if an iframe is preloaded and ready\n */\n isAuthenticationPreloaded(): boolean {\n if (this.config.displayMode !== \"iframe\" || !this.iframeAuthHandler) {\n return false;\n }\n return this.iframeAuthHandler.hasPreloadedIframe();\n }\n\n /**\n * Enable or disable iframe preloading\n * @param enabled Whether to enable iframe preloading\n */\n setPreloadEnabled(enabled: boolean): void {\n // Preloading only makes sense for iframe mode\n if (this.config.displayMode !== \"iframe\") {\n this.logger.debug(\n \"๐ฏ Iframe preloading not applicable for non-iframe mode\",\n {\n displayMode: this.config.displayMode,\n enabled,\n },\n );\n return;\n }\n\n if (this.iframeAuthHandler) {\n this.iframeAuthHandler.setPreloadEnabled(enabled);\n this.logger.info(\"๐ฏ Iframe preloading\", { enabled });\n } else {\n this.logger.warn(\n \"โ ๏ธ Cannot set preload enabled: iframe handler not initialized\",\n );\n }\n }\n\n /**\n * Check if iframe preloading is enabled\n * @returns True if iframe preloading is enabled\n */\n getPreloadEnabled(): boolean {\n // Preloading only makes sense for iframe mode\n if (this.config.displayMode !== \"iframe\") {\n return false;\n }\n return this.iframeAuthHandler?.getPreloadEnabled() ?? false;\n }\n\n /**\n * Check if the authentication session is stale (older than timeout)\n * @returns True if session is stale and needs re-initialization\n */\n private isAuthenticationSessionStale(): boolean {\n const timestampSeconds = this.getAuthenticationStartedAtSeconds();\n if (!timestampSeconds) {\n return false; // No timestamp means no stale session\n }\n\n const currentTimeSeconds = Math.floor(Date.now() / 1000);\n const elapsedSeconds = currentTimeSeconds - timestampSeconds;\n\n return elapsedSeconds > AUTH_SESSION_TIMEOUT_SECONDS;\n }\n\n /**\n * Get the authentication started timestamp from storage\n * @returns The timestamp in seconds or null if not set\n */\n private getAuthenticationStartedAtSeconds(): number | null {\n try {\n let value: string | null = null;\n\n // Try localStorage first\n if (typeof window !== \"undefined\" && window.localStorage) {\n value = window.localStorage.getItem(AUTH_SESSION_TIMESTAMP_KEY);\n } else {\n // Fall back to in-memory store\n value = inMemoryStore.get(AUTH_SESSION_TIMESTAMP_KEY) || null;\n }\n\n if (value) {\n const timestamp = parseInt(value, 10);\n return isNaN(timestamp) ? null : timestamp;\n }\n return null;\n } catch (error) {\n // localStorage might throw in private browsing mode\n this.logger.warn(\n \"Failed to get authentication timestamp, using in-memory fallback\",\n { error },\n );\n const value = inMemoryStore.get(AUTH_SESSION_TIMESTAMP_KEY);\n if (value) {\n const timestamp = parseInt(value, 10);\n return isNaN(timestamp) ? null : timestamp;\n }\n return null;\n }\n }\n\n /**\n * Set the authentication started timestamp in storage\n */\n private setAuthenticationStartedAtSeconds(): void {\n try {\n const currentTimeSeconds = Math.floor(Date.now() / 1000);\n const value = currentTimeSeconds.toString();\n\n // Try localStorage first\n if (typeof window !== \"undefined\" && window.localStorage) {\n window.localStorage.setItem(AUTH_SESSION_TIMESTAMP_KEY, value);\n } else {\n // Fall back to in-memory store\n inMemoryStore.set(AUTH_SESSION_TIMESTAMP_KEY, value);\n }\n\n this.logger.debug(\"Authentication timestamp set\", {\n timestamp: currentTimeSeconds,\n });\n } catch (error) {\n // localStorage might throw in private browsing mode\n this.logger.warn(\n \"Failed to set authentication timestamp in localStorage, using in-memory fallback\",\n { error },\n );\n const currentTimeSeconds = Math.floor(Date.now() / 1000);\n inMemoryStore.set(\n AUTH_SESSION_TIMESTAMP_KEY,\n currentTimeSeconds.toString(),\n );\n }\n }\n\n /**\n * Clear the authentication started timestamp from storage\n */\n private clearAuthenticationStartedAtSeconds(): void {\n try {\n // Try localStorage first\n if (typeof window !== \"undefined\" && window.localStorage) {\n window.localStorage.removeItem(AUTH_SESSION_TIMESTAMP_KEY);\n }\n // Also clear from in-memory store\n inMemoryStore.delete(AUTH_SESSION_TIMESTAMP_KEY);\n\n this.logger.debug(\"Authentication timestamp cleared\");\n } catch (error) {\n // localStorage might throw in private browsing mode\n this.logger.warn(\n \"Failed to clear authentication timestamp from localStorage\",\n { error },\n );\n inMemoryStore.delete(AUTH_SESSION_TIMESTAMP_KEY);\n }\n }\n\n /**\n * Re-initialize the auth client when session is stale\n * Preserves configuration but resets authentication state\n */\n private async reinitializeForStaleSession(): Promise<void> {\n this.logger.info(\"๐ Re-initializing due to stale authentication session\");\n\n // Clear any existing auth promise to ensure fresh start\n if (this.authPromise) {\n this.logger.info(\"๐งน Clearing existing auth promise for fresh start\");\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n }\n\n // Clean up any existing handlers before re-initialization\n if (this.messageHandler || this.popupHandler || this.iframeAuthHandler) {\n this.logger.info(\n \"๐งน Cleaning up existing handlers before re-initialization\",\n );\n this.cleanup();\n }\n\n // Clear the stale authentication timestamp\n this.clearAuthenticationStartedAtSeconds();\n\n try {\n // Ensure OAuth endpoints are available\n if (!this.endpoints) {\n this.logger.info(\"๐ Getting OAuth endpoints for re-initialization\");\n this.endpoints = await getOauthEndpoints(\n this.config.oauthServerBaseUrl,\n );\n }\n\n // Re-initialize all handlers with preserved config\n this.logger.info(\n \"๐ Re-initializing handlers with preserved configuration\",\n );\n this.initializeHandlers();\n\n this.logger.info(\"โ
Re-initialization completed successfully\");\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Failed to re-initialize\";\n this.logger.error(\"โ Failed to re-initialize for stale session\", {\n error: errorMessage,\n stack: error instanceof Error ? error.stack : undefined,\n });\n throw new CivicAuthError(\n `Failed to re-initialize authentication: ${errorMessage}`,\n CivicAuthErrorCode.INIT_FAILED,\n );\n }\n }\n\n /**\n * Starts the authentication process\n * @returns A promise that resolves with the authentication result\n * @throws {CivicAuthError} If authentication fails or times out\n */\n async startAuthentication(): Promise<AuthResult> {\n this.logger.info(\"๐ฌ Starting authentication process\", {\n displayMode: this.config.displayMode,\n userAgent: navigator.userAgent,\n currentUrl: window.location.href,\n });\n\n // Check if authentication session is stale and needs re-initialization\n const isStale = this.isAuthenticationSessionStale();\n if (isStale) {\n this.logger.info(\n \"โ ๏ธ Authentication session is stale, re-initializing...\",\n );\n await this.reinitializeForStaleSession();\n }\n\n const currentUser = await this.getCurrentUser();\n if (currentUser) {\n return { user: currentUser };\n }\n\n // Send SDK analytics when authentication starts\n // Fire and forget - don't block authentication if analytics fails\n collectAndSendSDKAnalytics(\n this.config.clientId,\n this.config.oauthServerBaseUrl,\n this.config.framework || \"vanillajs\",\n );\n\n if (!this.endpoints) {\n const error = new CivicAuthError(\n \"OAuth endpoints not initialized. Please wait for initialization to complete.\",\n CivicAuthErrorCode.ENDPOINTS_NOT_INITIALIZED,\n );\n this.logger.error(\"โ Endpoints not initialized\", {\n error: error.message,\n });\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: error.message,\n });\n throw error;\n }\n\n if (this.authPromise) {\n this.logger.info(\n \"โณ Authentication already in progress, returning existing promise\",\n );\n return this.authPromise;\n }\n\n // Set authentication started timestamp for fresh authentication\n this.setAuthenticationStartedAtSeconds();\n\n const fullAuthUrl = await this.buildAuthUrl(isStale);\n this.logger.info(\"๐ Built authentication URL\", {\n url: fullAuthUrl,\n displayMode: this.config.displayMode,\n authProcessTimeout: this.config.authProcessTimeout,\n });\n\n this.authPromise = new Promise<AuthResult>((resolve, reject) => {\n this.authPromiseResolve = resolve;\n this.authPromiseReject = reject;\n\n this.handleAuthenticationByDisplayMode(fullAuthUrl);\n this.setupAuthenticationTimeout();\n });\n\n return this.authPromise;\n }\n\n /**\n * Reloads embedded authentication interface\n *\n * This method is specifically designed for embedded mode scenarios where the iframe\n * needs to be recreated after navigation or DOM changes. It performs a complete\n * re-initialization by calling the full init() method.\n *\n * @returns Promise that resolves when the embedded iframe is created\n * @throws {CivicAuthError} If not in embedded mode or if iframe creation fails\n *\n * @example\n * ```typescript\n * // After navigation in a SPA\n * await civicAuth.reloadEmbedded();\n * ```\n */\n async reloadEmbedded(): Promise<void> {\n this.logger.info(\"๐ Reloading embedded authentication interface\", {\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n authPromise: !!this.authPromise,\n });\n\n this.config.displayMode = \"iframe\";\n this.config.iframeDisplayMode = \"embedded\";\n\n // Check if container element exists\n const container = this.getContainerElement();\n this.logger.info(\"๐ฏ Container element check\", {\n containerFound: !!container,\n containerId: container?.id,\n containerClass: container?.className,\n });\n\n if (!container) {\n const error = new CivicAuthError(\n \"Container element for embedded iframe not found. Ensure an element with id 'civic-login-container' exists or provide targetContainerElement in config.\",\n CivicAuthErrorCode.CONTAINER_NOT_FOUND,\n );\n this.logger.error(error.message);\n throw error;\n }\n\n // Clear any existing auth promise to ensure fresh start\n if (this.authPromise) {\n this.logger.info(\"๐งน Clearing existing auth promise for fresh start\");\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n }\n\n // Clean up any existing handlers before re-initialization\n if (this.messageHandler || this.popupHandler || this.iframeAuthHandler) {\n this.logger.info(\n \"๐งน Cleaning up existing handlers before re-initialization\",\n );\n this.cleanup();\n }\n\n this.logger.info(\"๐ Re-initializing handlers and starting embedded auth\");\n\n try {\n // Don't call init() - that would re-process config based on current page\n // Instead, do minimal re-initialization with original config\n\n // Ensure OAuth endpoints are available (they should be from original init)\n if (!this.endpoints) {\n this.logger.info(\"๐ Getting OAuth endpoints\");\n this.endpoints = await getOauthEndpoints(\n this.config.oauthServerBaseUrl,\n );\n }\n\n // Re-initialize all handlers (creates new instances)\n this.logger.info(\"๐ Re-initializing handlers\");\n this.initializeHandlers();\n\n // Start authentication to create the embedded iframe\n this.logger.info(\"๐ฌ Starting embedded authentication\");\n await this.startAuthentication();\n this.logger.info(\"โ
Embedded iframe reloaded successfully\");\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to reload embedded iframe\";\n this.logger.error(\"โ Failed to reload embedded iframe\", {\n error: errorMessage,\n stack: error instanceof Error ? error.stack : undefined,\n });\n throw error;\n }\n }\n\n private async handleBrowserCorsFailsSilently(): Promise<Promise<void>> {\n this.logger.warn(\n \"๐จ Browser CORS fails silently - switching to redirect mode\",\n {\n displayMode: this.config.displayMode,\n iframeAuthHandler: !!this.iframeAuthHandler,\n messageHandler: !!this.messageHandler,\n },\n );\n if (!this.iframeAuthHandler || !this.messageHandler) {\n throw new Error(\"Iframe handler not initialized\");\n }\n this.config.displayMode = \"redirect\";\n this.iframeAuthHandler.forceHideIframe();\n const rebuiltUrl = await this.buildAuthUrl();\n this.config.events?.emit(AuthEvent.SIGN_IN_ERROR, {\n detail:\n \"Browser doesn't support popups and passkey with CORS in iframe - switching to redirect mode\",\n error: {\n type: \"browser_cors_fails_silently\",\n failedUrl: IframeManager.browserCorsFailsSilentlyUrl,\n suggestion:\n \"Browser doesn't support popups and passkey with CORS in iframe - switching to redirect mode\",\n },\n });\n // use a small delay to ensure the loader is shown\n setTimeout(() => {\n window.location.href = rebuiltUrl;\n }, 100);\n }\n\n /**\n * Handle authentication based on display mode\n */\n private async handleAuthenticationByDisplayMode(\n fullAuthUrl: string,\n ): Promise<void> {\n this.logger.info(\"๐ฏ Handling authentication with display mode\", {\n displayMode: this.config.displayMode,\n });\n\n try {\n switch (this.config.displayMode) {\n case \"redirect\":\n this.logger.info(\"๐ Using redirect mode\");\n this.events.locationChange(\n fullAuthUrl,\n \"Redirecting to auth URL\",\n \"login\",\n );\n break;\n\n case \"new_tab\":\n this.logger.info(\"๐ฑ Using new_tab mode\");\n if (!this.popupHandler) {\n throw new Error(\"Popup handler not initialized\");\n }\n await this.popupHandler.handleNewTabAuth(fullAuthUrl);\n break;\n\n case \"iframe\":\n default: {\n this.logger.info(\"๐ผ๏ธ Using iframe mode\");\n if (!this.iframeAuthHandler || !this.messageHandler) {\n throw new Error(\"Iframe handler not initialized\");\n }\n if (IframeManager.browserCorsFailsSilentlyUrl) {\n return this.handleBrowserCorsFailsSilently();\n }\n\n const iframeElement =\n await this.iframeAuthHandler.handleIframeAuth(fullAuthUrl);\n this.messageHandler.updateIframeElement(iframeElement);\n break;\n }\n }\n } catch (error) {\n if (error instanceof PopupError) {\n await this.handlePopupErrorWithFallback(fullAuthUrl, error);\n } else {\n this.handleAuthError(\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n }\n }\n\n /**\n * Handle popup error with redirect fallback\n */\n private async handlePopupErrorWithFallback(\n fullAuthUrl: string,\n error: PopupError,\n ): Promise<void> {\n this.logger.warn(\"๐ซ Popup failed, falling back to redirect mode\", {\n originalDisplayMode: this.config.displayMode,\n error: error.message,\n });\n\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: \"Popup blocked, falling back to redirect mode\",\n });\n\n try {\n this.logger.info(\"๐ Attempting redirect fallback\");\n\n // Clean up current authentication attempt\n this.cleanup();\n\n // Always switch to redirect mode for Safari compatibility\n this.config.displayMode = \"redirect\";\n\n // Regenerate the auth URL with updated display mode in state\n const fallbackAuthUrl = await this.buildAuthUrl();\n\n this.logger.info(\"๐ Redirecting to auth URL\", { url: fallbackAuthUrl });\n window.location.href = fallbackAuthUrl;\n this.logger.info(\"โ
Redirect initiated successfully\");\n } catch (redirectError) {\n this.logger.error(\"โ Redirect fallback failed\", {\n error: redirectError,\n redirectUrl: fullAuthUrl,\n });\n\n const fallbackError = new CivicAuthError(\n \"Failed to open popup window and redirect fallback failed. Please check your browser's popup settings.\",\n CivicAuthErrorCode.INIT_FAILED,\n );\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: fallbackError.message,\n });\n this.handleAuthError(fallbackError);\n }\n }\n\n /**\n * Setup authentication timeout\n */\n private setupAuthenticationTimeout(): void {\n // Skip timeout for embedded iframe mode - embedded iframes should stay persistent\n if (\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"embedded\"\n ) {\n this.logger.debug(\n \"โฐ Skipping authentication timeout for embedded iframe mode\",\n {\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n },\n );\n return;\n }\n\n // Set up timeout for other modes\n if (this.config.authProcessTimeout && this.config.authProcessTimeout > 0) {\n this.logger.debug(\"โฐ Setting up authentication timeout\", {\n timeout: this.config.authProcessTimeout,\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n });\n\n this.authProcessTimeoutHandle = window.setTimeout(() => {\n this.logger.info(\"โฐ Authentication timeout reached\");\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: \"Authentication timed out\",\n });\n\n const error = new CivicAuthError(\n \"Authentication timed out\",\n CivicAuthErrorCode.AUTH_PROCESS_TIMEOUT,\n );\n this.handleAuthError(error);\n }, this.config.authProcessTimeout);\n }\n }\n\n /**\n * Handle successful authentication\n */\n private handleAuthSuccess(result: AuthResult): void {\n this.logger.info(\"โ
Authentication successful\");\n\n // Clear authentication timestamp on successful completion\n this.clearAuthenticationStartedAtSeconds();\n\n this.authPromiseResolve?.(result);\n\n // For embedded mode, preserve the iframe completely - don't cleanup\n // The iframe should stay visible showing the successful authentication state\n const isEmbeddedMode =\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"embedded\";\n\n if (isEmbeddedMode) {\n this.logger.info(\n \"๐ง Embedded mode - preserving iframe, skipping cleanup\",\n );\n // Only clean up timeouts and reset promises, but keep iframe visible\n this.cleanupTimeoutsAndState();\n } else {\n // For modal/redirect modes, do full cleanup as before\n this.cleanup();\n }\n }\n\n /**\n * Handle authentication error\n */\n private handleAuthError(error: Error): void {\n this.logger.error(\"โ Authentication failed\", { error: error.message });\n\n // Clear authentication timestamp on error/cancellation\n this.clearAuthenticationStartedAtSeconds();\n\n this.authPromiseReject?.(error);\n\n // For embedded mode, preserve the iframe to show error state\n // For other modes, do full cleanup as before\n const isEmbeddedMode =\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"embedded\";\n\n if (isEmbeddedMode) {\n this.logger.info(\n \"๐ง Embedded mode - preserving iframe to show error state\",\n );\n // Only clean up timeouts and reset promises, but keep iframe visible\n this.cleanupTimeoutsAndState();\n } else {\n // For modal/redirect modes, do full cleanup as before\n this.cleanup();\n }\n }\n\n /**\n * Handle popup failure - simplified like React implementation\n */\n private handlePopupFailure(failedUrl?: string): void {\n this.hasPopupFailed = true;\n\n this.logger.warn(\"Popup failed, using redirect mode instead...\", {\n failedUrl,\n });\n\n // Clean up iframe if it exists\n if (this.iframeAuthHandler) {\n this.iframeAuthHandler.cleanupIframe();\n }\n\n // Always redirect to the failed URL or build a new one\n if (failedUrl) {\n // this.config.displayMode = \"redirect\";\n\n // Use centralized location change handler\n this.events.locationChange(\n failedUrl,\n \"Popup blocked, falling back to redirect mode\",\n \"login\",\n );\n\n return;\n }\n\n this.buildAuthUrl()\n .then((authUrl) => {\n this.events.locationChange(authUrl, \"Redirecting to auth URL\", \"login\");\n })\n .catch((error) => {\n this.logger.error(\"Failed to build auth URL for redirect fallback\", {\n error,\n });\n const fallbackError = new CivicAuthError(\n \"Failed to redirect for authentication\",\n CivicAuthErrorCode.INIT_FAILED,\n );\n this.handleAuthError(fallbackError);\n });\n }\n\n /**\n * Show popup failure message to user\n */\n private showPopupFailureMessage(\n customMessage: string = \"Authentication will continue in this window. Please wait...\",\n ): void {\n const container = this.getContainerElement();\n if (!container) {\n this.logger.warn(\n \"Cannot show popup failure message - container not found\",\n );\n return;\n }\n const existingMessage = document.getElementById(\n \"civic-auth-popup-failure-message\",\n );\n if (existingMessage && existingMessage.parentNode) {\n existingMessage.parentNode.removeChild(existingMessage);\n }\n const messageOverlay = document.createElement(\"div\");\n messageOverlay.id = \"civic-auth-popup-failure-message\";\n messageOverlay.style.cssText =\n \"position:absolute;top:0;left:0;right:0;background:rgba(255,249,196,.95);border:1px solid #f59e0b;border-radius:6px;padding:12px;margin:8px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;font-size:14px;color:#92400e;z-index:1000;box-shadow:0 2px 4px rgba(0,0,0,.1);\";\n messageOverlay.innerHTML =\n '<div style=\"display:flex;align-items:center;gap:8px;\">' +\n '<span style=\"font-size:16px;\">โ ๏ธ</span>' +\n \"<div>\" +\n \"<strong>Popup blocked</strong><br>\" +\n '<span style=\"font-size:12px;\">' +\n customMessage +\n \"</span>\" +\n \"</div>\" +\n \"</div>\";\n\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n container.appendChild(messageOverlay);\n\n setTimeout(() => {\n if (messageOverlay.parentNode) {\n messageOverlay.parentNode.removeChild(messageOverlay);\n }\n }, 10000);\n this.logger.info(\"Popup failure message displayed to user\");\n }\n\n /**\n * Setup popup failure timeout\n */\n private setupPopupFailureTimeout(): void {\n this.popupFailureTimeoutHandle = window.setTimeout(() => {\n this.logger.info(\"โฐ Popup failure timeout reached\");\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: \"Authentication timeout - popup failure scenario\",\n });\n\n const error = new CivicAuthError(\n \"Authentication timeout - popup failure scenario\",\n CivicAuthErrorCode.AUTH_PROCESS_TIMEOUT,\n );\n this.handleAuthError(error);\n }, 20000); // 20 seconds\n }\n\n /**\n * Gets the container element for the auth iframe\n */\n private getContainerElement(): HTMLElement | null {\n if (typeof this.config.targetContainerElement === \"string\") {\n const element = document.getElementById(\n this.config.targetContainerElement,\n );\n if (!element) {\n this.logger.warn(\n `Container element with ID \"${this.config.targetContainerElement}\" not found`,\n );\n }\n return element;\n }\n\n if (this.config.targetContainerElement) {\n return this.config.targetContainerElement;\n }\n\n // Fallback: Look for element with id \"civic-login-container\"\n const fallbackContainer = document.getElementById(\n \"civic-login-container\",\n ) as HTMLElement;\n if (fallbackContainer) {\n this.logger.debug(\n 'Using fallback container with id \"civic-login-container\"',\n );\n return fallbackContainer;\n }\n\n return null;\n }\n\n /**\n * Handle OAuth callback\n */\n private async handleCallback(): Promise<void> {\n this.logger.info(\"๐ Handling OAuth callback\", {\n currentUrl: window.location.href,\n redirectUrl: this.config.redirectUrl,\n });\n\n try {\n // Only handle OAuth callback if not using backend integration\n if (!this.config.clientId && this.config.loginUrl) {\n this.logger.info(\n \"๐ Backend integration mode - skipping OAuth callback handling\",\n );\n return;\n }\n\n // Ensure clientId is available for OAuth callback\n if (!this.config.clientId) {\n throw new Error(\"ClientId is required for OAuth callback handling\");\n }\n\n const callbackHandled = await handleOAuthRedirectPage({\n clientId: this.config.clientId,\n oauthServer: this.config.oauthServerBaseUrl,\n redirectUrl: this.config.redirectUrl,\n textSignals: {\n success: this.config.textSignals.success,\n error: this.config.textSignals.error || \"Authentication failed\",\n },\n storageAdapter: this.storage,\n });\n\n this.logger.info(\"๐ Callback processing result\", { callbackHandled });\n\n if (callbackHandled) {\n const successSignal = document.getElementById(\n CIVIC_AUTH_CONSTANTS.SUCCESS_SIGNAL_ID,\n );\n const errorSignal = document.getElementById(\n CIVIC_AUTH_CONSTANTS.ERROR_SIGNAL_ID,\n );\n\n if (successSignal) {\n this.logger.info(\"โ
Success signal found\");\n let userInfo = null;\n const userInfoAttr = successSignal.getAttribute(\"data-user-info\");\n if (userInfoAttr) {\n try {\n userInfo = JSON.parse(userInfoAttr);\n } catch (error) {\n this.logger.error(\"โ Failed to parse user info\", { error });\n }\n }\n this.events.emit(AuthEvent.SIGN_IN_COMPLETE, {\n detail: \"Callback processed successfully\",\n user: userInfo,\n });\n } else if (errorSignal) {\n this.logger.error(\"โ Error signal found\");\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: errorSignal.textContent || \"Unknown error during callback\",\n });\n }\n }\n } catch (error) {\n this.logger.error(\"โ Callback handling failed\", { error });\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail:\n error instanceof Error\n ? error.message\n : \"Unknown error during callback\",\n });\n }\n }\n\n /**\n * Cleans up resources and event listeners\n */\n public cleanup(): void {\n this.logger.info(\"Cleaning up authentication client\");\n\n // Clean up handlers\n this.iframeAuthHandler?.cleanupIframe();\n\n // Clean up timeouts\n if (this.authProcessTimeoutHandle) {\n window.clearTimeout(this.authProcessTimeoutHandle);\n this.authProcessTimeoutHandle = undefined;\n }\n\n if (this.popupFailureTimeoutHandle) {\n window.clearTimeout(this.popupFailureTimeoutHandle);\n this.popupFailureTimeoutHandle = undefined;\n }\n\n // Reset state\n this.hasPopupFailed = false;\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n\n // Remove message event listener\n if (this.messageHandler) {\n window.removeEventListener(\"message\", this.messageHandler.handleMessage);\n }\n }\n\n /**\n * Clean up only timeouts and state without touching iframe (for embedded mode)\n */\n private cleanupTimeoutsAndState(): void {\n this.logger.info(\n \"Cleaning up timeouts and state (preserving iframe for embedded mode)\",\n );\n\n // Clean up timeouts\n if (this.authProcessTimeoutHandle) {\n window.clearTimeout(this.authProcessTimeoutHandle);\n this.authProcessTimeoutHandle = undefined;\n }\n\n if (this.popupFailureTimeoutHandle) {\n window.clearTimeout(this.popupFailureTimeoutHandle);\n this.popupFailureTimeoutHandle = undefined;\n }\n\n // Reset state\n this.hasPopupFailed = false;\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n\n // Keep message handler and iframe for embedded mode\n }\n\n /**\n * Get the current session\n */\n public async getCurrentSession(): Promise<Session | null> {\n return this.sessionManager.getCurrentSession() || null;\n }\n\n /**\n * Get current session tokens including decoded forwarded tokens\n * This method extracts and decodes forwarded tokens from the ID token JWT\n */\n public async getTokensWithForwardedTokens() {\n const session = await this.getCurrentSession();\n return extractTokensFromSession(session);\n }\n\n /**\n * Check if user is authenticated\n */\n public async isAuthenticated(): Promise<boolean> {\n return this.sessionManager.isAuthenticated() || false;\n }\n\n /**\n * Get the current user\n */\n public async getCurrentUser() {\n return this.sessionManager.getCurrentUser() || null;\n }\n\n /**\n * Clear the current session\n */\n public async clearSession(): Promise<void> {\n return this.sessionManager.clearSession();\n }\n\n /**\n * Manually refresh tokens\n */\n public async refreshTokens(): Promise<void> {\n return this.sessionManager.refreshTokens();\n }\n\n /**\n * Get token refresher state for debugging\n */\n public getTokenRefresherState() {\n return this.sessionManager.getTokenRefresherState() || null;\n }\n\n /**\n * Set a custom login URL for backend integration.\n * This is useful when integrating with a backend that handles the OAuth flow.\n * Alternatively, you can configure this directly in CivicAuth.create().\n *\n * @param loginUrl - The custom login URL to use (e.g., \"http://localhost:3020/auth/login\")\n *\n * @example\n * ```typescript\n * // Option 1: Configure in create()\n * const authClient = await CivicAuth.create({\n * clientId: \"YOUR_CLIENT_ID\",\n * loginUrl: \"http://example.com/custom-backendurl\"\n * });\n *\n * // Option 2: Set after creation\n * civicAuth.setLoginUrl(\"http://localhost:3020/auth/login\");\n * await civicAuth.startAuthentication();\n * ```\n */\n public setLoginUrl(loginUrl: string): void {\n this.loginUrl = loginUrl;\n\n // Update MessageHandler to expect messages from the custom origin\n if (this.messageHandler) {\n this.messageHandler.setCustomExpectedOrigin(loginUrl);\n }\n\n this.logger.info(\"๐ Custom login URL set for backend integration\", {\n loginUrl: this.loginUrl,\n });\n }\n\n /**\n * Clear the login URL and return to standard OAuth flow\n */\n public clearLoginUrl(): void {\n this.loginUrl = undefined;\n\n // Clear custom expected origin from MessageHandler\n if (this.messageHandler) {\n this.messageHandler.clearCustomExpectedOrigin();\n }\n\n this.logger.info(\"๐ Login URL cleared, returning to standard OAuth flow\");\n }\n\n /**\n * Get the current login URL\n * @returns The current login URL or undefined if not set\n */\n public getLoginUrl(): string | undefined {\n return this.loginUrl;\n }\n\n /**\n * Update the iframe display mode\n * @param mode - The display mode to use for the iframe\n */\n public setIframeDisplayMode(mode: \"modal\" | \"embedded\"): void {\n this.config.iframeDisplayMode = mode;\n this.logger.debug(`Iframe display mode updated to: ${mode}`);\n }\n\n /**\n * Get the current iframe display mode\n * @returns The current iframe display mode\n */\n public getIframeDisplayMode(): \"modal\" | \"embedded\" | undefined {\n return this.config.iframeDisplayMode;\n }\n\n /**\n * Reset authentication state when page is restored from back-forward cache (bfcache)\n * This clears any pending authentication promises that may have been interrupted\n * by the browser caching the page, allowing fresh authentication attempts\n */\n public resetOnBfcache(): void {\n this.logger.info(\n \"๐ Resetting authentication state due to bfcache restore\",\n );\n\n // Clear pending authentication promise and related state\n if (this.authPromise) {\n this.logger.debug(\"Clearing stale authentication promise from bfcache\");\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n }\n\n // Clear timeouts that may no longer be valid\n if (this.authProcessTimeoutHandle) {\n window.clearTimeout(this.authProcessTimeoutHandle);\n this.authProcessTimeoutHandle = undefined;\n }\n\n if (this.popupFailureTimeoutHandle) {\n window.clearTimeout(this.popupFailureTimeoutHandle);\n this.popupFailureTimeoutHandle = undefined;\n }\n\n // Reset auth flags\n this.hasPopupFailed = false;\n this.hasSignInStarted = false;\n\n // Reset iframe handler state if needed\n if (this.iframeAuthHandler) {\n this.iframeAuthHandler.cleanupIframe();\n }\n }\n\n /**\n * Destroy the auth client and clean up all resources\n */\n public async destroy(): Promise<void> {\n this.cleanup();\n await this.sessionManager.destroy();\n this.logger.info(\"CivicAuth destroyed\");\n }\n\n /**\n * Handle logout\n */\n public async logout(): Promise<void> {\n try {\n this.logger.info(\"๐ Starting logout process\");\n this.events.emit(AuthEvent.SIGN_OUT_STARTED, {\n detail: \"Logout process started\",\n });\n\n // If a loginUrl is configured, redirect to the backend's logout endpoint.\n // The backend will then handle redirecting to the OIDC provider.\n if (this.loginUrl) {\n this.logger.info(\n \"๐ช Redirecting to backend for logout in backend-integrated flow\",\n );\n const backendUrl = new URL(this.loginUrl).origin;\n const endpoints = getBackendEndpoints(this.config.backendEndpoints);\n const backendLogoutUrl = resolveEndpointUrl(\n backendUrl,\n endpoints.logout,\n );\n\n this.events.emit(AuthEvent.SIGN_OUT_COMPLETE, {\n detail: \"Local session cleared, redirecting to backend for logout.\",\n });\n\n // Generate state for backend integration to enable iframe mode detection\n const state = generateState({\n displayMode: this.config.displayMode || \"iframe\",\n framework: this.config.framework || \"vanillajs\",\n sdkVersion: getVersion(),\n });\n\n // Perform top-level redirect to the backend logout endpoint\n // Include logoutRedirectUrl and state as query parameters\n const logoutUrl = new URL(backendLogoutUrl);\n if (this.config.logoutRedirectUrl) {\n logoutUrl.searchParams.set(\n \"logoutRedirectUrl\",\n this.config.logoutRedirectUrl,\n );\n }\n\n // Include state for iframe mode detection on server\n logoutUrl.searchParams.set(\"state\", state);\n\n this.logger.info(\"๐ Loading backend logout endpoint in iframe\", {\n url: logoutUrl.toString(),\n path: logoutUrl.pathname,\n logoutRedirectUrl: this.config.logoutRedirectUrl,\n displayMode: this.config.displayMode,\n });\n\n // Use iframe for SPA logout to avoid full page reload\n this.loadLogoutInIframe(logoutUrl);\n\n return;\n }\n\n // --- Existing SPA redirect-based logout flow ---\n this.logger.info(\"๐ช Using redirect-based logout for SPA flow\");\n const tokens = await retrieveTokens(this.storage);\n\n if (!tokens?.id_token) {\n this.logger.warn(\"โ ๏ธ No ID token found, clearing local session only\");\n await clearTokens(this.storage);\n await this.sessionManager.clearSession();\n this.events.emit(AuthEvent.SIGN_OUT_COMPLETE, {\n detail: \"Local session cleared\",\n });\n return;\n }\n\n if (!this.endpoints) {\n throw new Error(\"OAuth endpoints not initialized\");\n }\n\n // Generate a state for logout (for OAuth provider tracking only)\n const state = generateState({\n displayMode: this.config.displayMode || \"iframe\",\n framework: this.config.framework || \"vanillajs\",\n sdkVersion: getVersion(),\n });\n\n this.logger.info(\"๐ Generated logout state for OAuth provider\", {\n generatedState: state,\n displayMode: this.config.displayMode,\n });\n\n // Note: No need to store logout_state in localStorage since iframe flows\n // don't receive redirect callbacks that need state coordination\n\n // Ensure clientId is available for OAuth logout\n if (!this.config.clientId) {\n throw new Error(\"ClientId is required for OAuth logout flow\");\n }\n\n // Generate logout URL\n const logoutUrl = await generateOauthLogoutUrl({\n clientId: this.config.clientId,\n redirectUrl: this.config.logoutRedirectUrl,\n idToken: tokens.id_token,\n state: state,\n oauthServer: this.config.oauthServerBaseUrl,\n });\n\n this.logger.info(\"๐ Generated logout URL\", {\n logoutUrl: logoutUrl.toString(),\n });\n\n // Clear local tokens and session completely (no need to preserve logout_state)\n await this.sessionManager.clearSession(false);\n\n // Emit logout complete event before iframe request\n this.events.emit(AuthEvent.SIGN_OUT_COMPLETE, {\n detail: \"Logout successful\",\n });\n\n // Use hidden iframe instead of redirect to avoid full page reload in SPA mode\n this.loadLogoutInIframe(logoutUrl);\n } catch (error) {\n this.logger.error(\"โ Logout failed\", { error });\n this.events.emit(AuthEvent.SIGN_OUT_ERROR, {\n detail: error instanceof Error ? error.message : String(error),\n });\n throw new CivicAuthError(\n \"Logout failed\",\n CivicAuthErrorCode.LOGOUT_FAILED,\n );\n }\n }\n\n /**\n * Load logout URL in a hidden iframe to avoid full page reload\n * @param logoutUrl The URL to load in the iframe\n */\n private loadLogoutInIframe(logoutUrl: URL): void {\n this.logger.info(\"๐ Loading logout URL in hidden iframe\");\n\n const logoutIframe = document.createElement(\"iframe\");\n logoutIframe.style.display = \"none\";\n\n // Clean up iframe when logout completes (or errors)\n const cleanupIframe = () => {\n this.logger.info(\"๐งน Cleaning up logout iframe\");\n\n if (!logoutIframe.parentNode) {\n this.logger.warn(\"๐งน Logout iframe not found, skipping iframe cleanup\");\n return;\n }\n\n logoutIframe.parentNode.removeChild(logoutIframe);\n\n if (this.config.logoutRedirectUrl) {\n this.logger.info(\n \"๐ Redirecting to logoutRedirectUrl after logout iframe cleanup\",\n {\n logoutRedirectUrl: this.config.logoutRedirectUrl,\n },\n );\n // Use direct redirect for logout to ensure frontend state is cleared\n // This bypasses any URL_CHANGE event listeners that might interfere\n // we should only redirect if we're not already on the logoutRedirectUrl\n const currentPathAndQuery =\n window.location.pathname + window.location.search;\n\n // Parse the logout redirect URL to get its path and query\n const logoutUrl = new URL(\n this.config.logoutRedirectUrl,\n window.location.origin,\n );\n const logoutPathAndQuery = logoutUrl.pathname + logoutUrl.search;\n\n // Only redirect if current path + query is different from logout redirect URL\n if (currentPathAndQuery !== logoutPathAndQuery) {\n window.location.href = this.config.logoutRedirectUrl;\n }\n }\n };\n\n logoutIframe.onload = () => {\n cleanupIframe();\n };\n logoutIframe.onerror = (error) => {\n this.logger.error(\"โ Logout iframe failed to load\", { error });\n cleanupIframe();\n };\n\n logoutIframe.src = logoutUrl.toString();\n document.body.appendChild(logoutIframe);\n }\n\n /**\n * Handle logout state cleanup\n * This mirrors the logic from useSignIn.ts to properly clean up after logout\n */\n private async handleLogoutStateCleanup(): Promise<void> {\n try {\n const params = new URLSearchParams(window.location.search);\n const state = params.get(\"state\");\n\n this.logger.info(\"๐ Checking for logout state cleanup\", {\n currentUrl: window.location.href,\n hasStateParam: !!state,\n stateValue: state,\n rawSearch: window.location.search,\n });\n\n if (!state) {\n this.logger.info(\n \"๐ No state parameter found, skipping logout cleanup\",\n );\n return; // No state parameter, nothing to cleanup\n }\n\n // Check if we have a stored logout state that matches\n const storedLogoutState = await this.storage.get(LOGOUT_STATE);\n\n // The state might be URL-decoded by URLSearchParams, but stored as plain\n // Let's try both the decoded and encoded versions\n const decodedState = decodeURIComponent(state);\n\n this.logger.info(\"๐ Comparing logout states\", {\n urlState: state,\n decodedState,\n storedLogoutState,\n directMatch: state === storedLogoutState,\n decodedMatch: decodedState === storedLogoutState,\n });\n\n if (state === storedLogoutState || decodedState === storedLogoutState) {\n this.logger.info(\"๐งน Cleaning up logout state\", {\n state,\n storedLogoutState,\n });\n\n // Clear tokens and user data from storage\n await clearTokens(this.storage);\n await this.sessionManager.clearSession();\n\n // Clean up the logout state from storage\n await this.storage.delete(LOGOUT_STATE);\n\n // Emit logout complete event\n this.events.emit(AuthEvent.SIGN_OUT_COMPLETE, {\n detail: \"Logout cleanup completed\",\n });\n\n // Clean up URL by removing query parameters\n const cleanUrl = window.location.href.split(\"?\")[0];\n window.history.replaceState({}, document.title, cleanUrl);\n\n this.logger.info(\"โ
Logout state cleanup completed\", {\n cleanUrl,\n });\n } else {\n this.logger.info(\"๐ Logout states don't match, skipping cleanup\", {\n urlState: state,\n storedLogoutState,\n });\n }\n } catch (error) {\n this.logger.warn(\"โ ๏ธ Error during logout state cleanup\", { error });\n // Don't throw error to prevent initialization failure\n }\n }\n}\n\n// Export types for external use\nexport type { CivicAuthClientConfig } from \"./types/AuthTypes.js\";\nexport { CivicAuthErrorCode } from \"./types/AuthTypes.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"CivicAuth.js","sourceRoot":"","sources":["../../../src/vanillajs/auth/CivicAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGhF,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAQpE,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,oB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,CAAC;gBACtE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,EAAE;oBAC9C,KAAK;oBACL,iBAAiB;iBAClB,CAAC,CAAC;gBAEH,0CAA0C;gBAC1C,MAAM,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChC,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;gBAEzC,yCAAyC;gBACzC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBAExC,6BAA6B;gBAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE;oBAC5C,MAAM,EAAE,0BAA0B;iBACnC,CAAC,CAAC;gBAEH,4CAA4C;gBAC5C,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBACpD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAE1D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE;oBACnD,QAAQ;iBACT,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gDAAgD,EAAE;oBACjE,QAAQ,EAAE,KAAK;oBACf,iBAAiB;iBAClB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACpE,sDAAsD;QACxD,CAAC;IACH,CAAC;CACF;AAID,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["import { AuthEvent } from \"../types/index.js\";\nimport type { Endpoints, AuthStorage } from \"../../types.js\";\nimport { buildAuthUrl, extractTokensFromSession } from \"../utils/auth-utils.js\";\nimport type { AuthResult, Session } from \"../types/index.js\";\nimport type { createLogger } from \"../utils/logger.js\";\nimport {\n createMainLogger,\n configureLogging,\n setCurrentLogger,\n} from \"../utils/logger.js\";\nimport { GenericPublicClientPKCEProducer } from \"../../services/PKCE.js\";\nimport { generateState } from \"../../lib/oauth.js\";\nimport { SessionManager } from \"./SessionManager.js\";\nimport { AuthenticationEvents } from \"./AuthenticationEvents.js\";\nimport { PopupError } from \"../../services/types.js\";\nimport { getVersion } from \"../../shared/index.js\";\nimport { handleOAuthRedirectPage } from \"./handlers/OAuthCallbackHandler.js\";\nimport {\n generateOauthLogoutUrl,\n clearTokens,\n retrieveTokens,\n getBackendEndpoints,\n resolveEndpointUrl,\n} from \"../../shared/lib/util.js\";\nimport { LOGOUT_STATE } from \"../../constants.js\";\nimport { getOauthEndpoints } from \"../../lib/oauth.js\";\nimport { collectAndSendSDKAnalytics } from \"../../lib/analytics.js\";\nimport type { AuthConfig } from \"../../server/config.js\";\n\n// Import new modular components\nimport type {\n CivicAuthClientConfig,\n ProcessedCivicAuthConfig,\n} from \"./types/AuthTypes.js\";\nimport {\n CivicAuthError,\n CivicAuthErrorCode,\n CIVIC_AUTH_CONSTANTS,\n} from \"./types/AuthTypes.js\";\nimport { processConfigWithDefaults } from \"./config/ConfigProcessor.js\";\nimport { MessageHandler } from \"./handlers/MessageHandler.js\";\nimport { PopupHandler } from \"./handlers/PopupHandler.js\";\nimport { IframeAuthHandler } from \"./handlers/IframeAuthHandler.js\";\nimport { IframeManager } from \"../iframe/IframeManager.js\";\n\n// Authentication session timeout in seconds (30 minutes)\nconst AUTH_SESSION_TIMEOUT_SECONDS = 30 * 60;\nconst AUTH_SESSION_TIMESTAMP_KEY =\n \"civic_auth_authentication_started_at_seconds\";\n\n// In-memory fallback store for environments without localStorage\nconst inMemoryStore: Map<string, string> = new Map();\n\n/**\n * CivicAuth client for handling OAuth authentication\n *\n * This is a refactored version that uses a modular architecture for better maintainability.\n */\nexport class CivicAuth {\n private config: ProcessedCivicAuthConfig;\n private storage: AuthStorage;\n private endpoints?: Endpoints;\n private logger: ReturnType<typeof createLogger>;\n private sessionManager: SessionManager;\n private events: AuthenticationEvents;\n private initialDisplayMode:\n | \"iframe\"\n | \"modal\"\n | \"redirect\"\n | \"new_tab\"\n | \"custom_tab\";\n\n // Authentication state\n private authPromise?: Promise<AuthResult>;\n private authPromiseResolve?: (value: AuthResult) => void;\n private authPromiseReject?: (reason?: Error) => void;\n private authProcessTimeoutHandle?: number;\n private popupFailureTimeoutHandle?: number;\n private hasPopupFailed: boolean = false;\n private hasSignInStarted: boolean = false;\n\n // Backend integration - custom login URL\n private loginUrl?: string;\n\n // Handlers\n private messageHandler?: MessageHandler;\n private popupHandler?: PopupHandler;\n private iframeAuthHandler?: IframeAuthHandler;\n\n /**\n * Private constructor - initializes configuration and handlers.\n * Use {@link CivicAuth.create} to create a new instance.\n */\n private constructor(config: CivicAuthClientConfig) {\n // Process config with defaults and validation\n this.config = processConfigWithDefaults(config);\n this.initialDisplayMode = this.config.displayMode;\n\n // Set loginUrl from config if provided\n this.loginUrl = this.config.loginUrl;\n\n // Configure logging\n configureLogging(this.config.logging);\n\n // Initialize logger - always use \"vanillajs\" as base namespace\n if (this.config.logging?.enabled) {\n this.logger = createMainLogger(\"vanillajs\"); // Always use \"vanillajs\"\n } else {\n this.logger = {\n debug: () => {},\n info: () => {},\n warn: () => {},\n error: () => {},\n };\n }\n\n setCurrentLogger(this.logger);\n this.storage = this.config.storageAdapter;\n\n // Always initialize events - use provided events or create default instance\n this.events = config.events || new AuthenticationEvents();\n\n // Always initialize SessionManager\n this.sessionManager = new SessionManager(\n this.storage,\n this.events,\n this.config,\n this.config.initialUser,\n );\n\n // Initialize handlers\n this.initializeHandlers();\n }\n\n /**\n * Creates and initializes a new instance of CivicAuth.\n * This is the recommended way to create a CivicAuth instance.\n *\n * @param config - Configuration options for the auth client\n * @returns A promise that resolves with the initialized CivicAuth instance\n * @throws {CivicAuthError} If initialization fails or required configuration is missing\n *\n * @example\n * ```typescript\n * // Standard SPA authentication\n * const auth = await CivicAuth.create({\n * clientId: \"your-client-id\",\n * // redirectUrl is optional - defaults to current page (window.location.origin + window.location.pathname)\n * redirectUrl: \"https://your-app.com/callback\", // optional\n * // logoutRedirectUrl is optional - defaults to redirectUrl if not provided\n * logoutRedirectUrl: \"https://your-app.com/logout\", // optional\n * // oauthServerBaseUrl is optional - defaults to \"https://auth.civic.com/oauth\"\n * oauthServerBaseUrl: \"https://auth-server.com/\", // optional\n * // scopes is optional - defaults to ['openid', 'profile', 'email', 'offline_access']\n * scopes: [\"openid\", \"profile\"], // optional\n * targetContainerElement: \"auth-container\",\n * textSignals: {\n * success: \"Authentication successful!\"\n * }\n * });\n *\n * // Backend integration authentication\n * const authWithBackend = await CivicAuth.create({\n * clientId: \"your-client-id\",\n * loginUrl: \"http://example.com/custom-backendurl\" // Automatically uses BrowserCookieStorage\n * });\n * ```\n */\n public static async create(\n config: CivicAuthClientConfig,\n ): Promise<CivicAuth> {\n const instance = new CivicAuth(config);\n await instance.init();\n return instance;\n }\n\n /**\n * Initializes the auth client and checks for callback handling\n */\n private async init(): Promise<void> {\n this.logger.info(\"๐ Initializing CivicAuth\", {\n currentUrl: window.location.href,\n redirectUrl: this.config.redirectUrl,\n oauthServerBaseUrl: this.config.oauthServerBaseUrl,\n isCallbackUrl: window.location.href.startsWith(this.config.redirectUrl),\n });\n\n try {\n // Get OAuth endpoints using shared function (handles trailing slash automatically)\n this.endpoints = await getOauthEndpoints(this.config.oauthServerBaseUrl);\n\n this.logger.info(\"๐ OAuth endpoints configured\", {\n endpoints: this.endpoints,\n });\n\n // Initialize SessionManager with auth config\n if (this.sessionManager) {\n const loginUrl = this.config.loginUrl || this.loginUrl;\n\n // Construct authConfig based on our discriminated union pattern\n const authConfig: AuthConfig =\n loginUrl && !this.config.clientId\n ? {\n ...this.config,\n // Backend integration mode: loginUrl required, clientId optional\n loginUrl,\n redirectUrl: this.config.redirectUrl,\n oauthServer: this.config.oauthServerBaseUrl,\n backendEndpoints: this.config.backendEndpoints,\n }\n : {\n ...this.config,\n // Standard OAuth mode: clientId required, loginUrl optional\n clientId: this.config.clientId!,\n loginUrl,\n redirectUrl: this.config.redirectUrl,\n oauthServer: this.config.oauthServerBaseUrl,\n backendEndpoints: this.config.backendEndpoints,\n };\n\n this.logger.info(\"๐ง Initializing SessionManager\", { authConfig });\n await this.sessionManager.initializeWithAuthConfig(authConfig);\n }\n\n // Check if we're on the callback page\n const isCallbackPage = window.location.href.startsWith(\n this.config.redirectUrl,\n );\n this.logger.info(\"๐ Callback page check\", {\n isCallbackPage,\n currentUrl: window.location.href,\n redirectUrl: this.config.redirectUrl,\n });\n\n // Handle logout state cleanup first (before processing auth callbacks)\n await this.handleLogoutStateCleanup();\n\n if (isCallbackPage) {\n this.logger.info(\"๐ Processing callback page\");\n await this.handleCallback();\n } else {\n this.logger.info(\"๐ Not a callback page, initialization complete\");\n }\n\n // Check if we're in embedded mode - we need to show the iframe\n // Note: After config processing, \"embedded\" displayMode becomes \"iframe\" + iframeDisplayMode: \"embedded\"\n const isEmbeddedMode =\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"embedded\";\n\n this.logger.info(\"๐ Checking display mode conditions\", {\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n isEmbeddedMode,\n preloadIframe: this.config.preloadIframe,\n });\n\n if (isEmbeddedMode) {\n // For embedded mode, we need to start authentication to show the iframe\n try {\n this.logger.info(\n \"๐ผ๏ธ Starting authentication for embedded mode to show iframe...\",\n );\n await this.startAuthentication();\n this.logger.info(\n \"โ
Embedded iframe authentication started successfully\",\n );\n } catch (error) {\n // Don't fail initialization if embedded authentication fails - graceful degradation\n this.logger.warn(\n \"โ ๏ธ Embedded authentication failed (graceful degradation):\",\n {\n error: error instanceof Error ? error.message : String(error),\n },\n );\n }\n } else if (\n this.config.preloadIframe &&\n this.config.displayMode === \"iframe\"\n ) {\n // Regular iframe preloading logic for modal mode\n try {\n const isAuthenticated = await this.isAuthenticated();\n this.logger.info(\"๐ Authentication check for preload\", {\n isAuthenticated,\n });\n\n if (!isAuthenticated) {\n this.logger.info(\n \"๐ Auto-preloading iframe for instant sign-in...\",\n );\n await this.preloadAuthentication();\n this.logger.info(\"โ
Iframe auto-preloaded successfully\");\n } else {\n this.logger.debug(\n \"โน๏ธ User already authenticated, skipping preload\",\n );\n }\n } catch (error) {\n // Don't fail initialization if preloading fails - graceful degradation\n this.logger.warn(\n \"โ ๏ธ Auto-preloading failed (graceful degradation):\",\n {\n error: error instanceof Error ? error.message : String(error),\n },\n );\n }\n } else {\n this.logger.info(\"โน๏ธ Auto-preload conditions not met\", {\n preloadIframe: this.config.preloadIframe,\n displayMode: this.config.displayMode,\n isEmbeddedMode,\n reason: isEmbeddedMode\n ? \"embedded mode uses startAuthentication instead\"\n : !this.config.preloadIframe\n ? \"preloadIframe is disabled\"\n : \"displayMode is not iframe\",\n });\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to initialize authentication\";\n this.logger.error(\"โ CivicAuth initialization failed\", {\n error: errorMessage,\n stack: error instanceof Error ? error.stack : undefined,\n });\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: errorMessage,\n });\n throw new CivicAuthError(errorMessage, CivicAuthErrorCode.INIT_FAILED);\n }\n }\n\n /**\n * Initialize all handlers with proper configuration\n */\n private initializeHandlers(): void {\n const handlerConfig = {\n config: this.config,\n logger: this.logger,\n onAuthSuccess: this.handleAuthSuccess.bind(this),\n onAuthError: this.handleAuthError.bind(this),\n cleanup: this.cleanup.bind(this),\n };\n\n this.messageHandler = new MessageHandler({\n ...handlerConfig,\n onPopupFailure: this.handlePopupFailure.bind(this),\n onBrowserCorsFailsSilently: async () => {\n if (this.hasSignInStarted) {\n await this.handleBrowserCorsFailsSilently();\n }\n },\n });\n\n this.popupHandler = new PopupHandler(handlerConfig);\n\n this.iframeAuthHandler = new IframeAuthHandler({\n ...handlerConfig,\n messageHandler: this.messageHandler.handleMessage,\n });\n\n // Set up automatic re-preloading when authentication is cancelled\n this.setupAutoRepreload();\n }\n\n /**\n * Set up automatic re-preloading when authentication is cancelled by user\n * This maintains instant sign-in experience for subsequent attempts\n */\n private setupAutoRepreload(): void {\n this.events.on(AuthEvent.SIGN_IN_STARTED, () => {\n this.hasSignInStarted = true;\n });\n this.events.on(AuthEvent.SIGN_IN_ERROR, (event?: { detail?: string }) => {\n // Only re-preload for iframe mode with user cancellation and preload enabled\n if (\n this.config.displayMode === \"iframe\" &&\n this.config.preloadIframe &&\n event?.detail === \"Authentication cancelled by user\"\n ) {\n this.logger.debug(\n \"๐ Authentication cancelled, scheduling re-preload for instant subsequent sign-in\",\n );\n\n // Small delay to ensure cleanup is complete\n setTimeout(async () => {\n try {\n await this.preloadAuthentication();\n this.logger.debug(\n \"โ
Re-preloaded iframe after cancellation for instant sign-in\",\n );\n } catch (error) {\n // Don't fail silently, but don't crash either - just log the issue\n this.logger.warn(\n \"โ ๏ธ Failed to re-preload iframe after cancellation:\",\n {\n error: error instanceof Error ? error.message : String(error),\n },\n );\n }\n }, 200); // Small delay to ensure cleanup completion\n }\n });\n }\n\n /**\n * Builds the authentication URL with PKCE challenge\n */\n private async buildAuthUrl(isStale?: boolean): Promise<string> {\n // If a login URL is set (for backend integration), use that instead\n if (this.loginUrl) {\n this.logger.info(\"๐ Using login URL for backend integration\", {\n loginUrl: this.loginUrl,\n });\n\n // Generate state with display mode information for backend integration\n const state =\n this.config.initialState ||\n generateState({\n displayMode: this.config.displayMode || \"iframe\",\n iframeDisplayMode: this.config.iframeDisplayMode,\n framework: this.config.framework || \"vanillajs\",\n sdkVersion: getVersion(),\n loginSuccessUrl: this.config.loginSuccessUrl,\n previousSessionStale: isStale,\n });\n\n // Append state as query parameter to loginUrl\n const url = new URL(this.loginUrl, window.location.origin);\n url.searchParams.set(\"state\", state);\n url.searchParams.set(\"appUrl\", window.location.origin);\n\n this.logger.info(\"๐ Built login URL with display mode state\", {\n loginUrl: url.toString(),\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n });\n\n return url.toString();\n }\n\n if (!this.endpoints) {\n throw new CivicAuthError(\n \"OAuth endpoints not initialized. Please wait for initialization to complete.\",\n CivicAuthErrorCode.ENDPOINTS_NOT_INITIALIZED,\n );\n }\n\n // Ensure clientId is present for OAuth flow (it should be according to our discriminated union)\n if (!this.config.clientId) {\n throw new CivicAuthError(\n \"ClientId is required for OAuth flow when loginUrl is not provided.\",\n CivicAuthErrorCode.CONFIG_REQUIRED,\n );\n }\n\n const pkceProducer = new GenericPublicClientPKCEProducer(this.storage);\n const codeChallenge = await pkceProducer.getCodeChallenge();\n const state =\n this.config.initialState ||\n generateState({\n displayMode: this.config.displayMode || \"iframe\",\n iframeDisplayMode: this.config.iframeDisplayMode,\n framework: this.config.framework || \"vanillajs\",\n sdkVersion: getVersion(),\n loginSuccessUrl: this.config.loginSuccessUrl,\n });\n\n return buildAuthUrl({\n endpoints: this.endpoints,\n clientId: this.config.clientId,\n redirectUrl: this.config.redirectUrl,\n scopes: this.config.scopes,\n codeChallenge,\n state,\n prompt: this.config.prompt,\n nonce: this.config.nonce,\n });\n }\n\n /**\n * Preloads the authentication iframe for instant sign-in\n * This creates the iframe in the background but keeps it hidden until startAuthentication() is called\n * @throws {CivicAuthError} If preloading fails or is not supported\n * @private - This method is used internally for automatic preloading\n */\n private async preloadAuthentication(): Promise<void> {\n this.logger.info(\"๐ฌ Preloading authentication for instant sign-in\", {\n displayMode: this.config.displayMode,\n userAgent: navigator.userAgent,\n currentUrl: window.location.href,\n });\n\n if (!this.endpoints) {\n const error = new CivicAuthError(\n \"OAuth endpoints not initialized. Please wait for initialization to complete.\",\n CivicAuthErrorCode.ENDPOINTS_NOT_INITIALIZED,\n );\n this.logger.error(\"โ Endpoints not initialized for preload\", {\n error: error.message,\n });\n throw error;\n }\n\n // Only support preloading for iframe mode\n if (this.config.displayMode !== \"iframe\") {\n this.logger.warn(\n \"โ ๏ธ Iframe preloading only supported for iframe display mode\",\n {\n displayMode: this.config.displayMode,\n },\n );\n return;\n }\n\n if (!this.iframeAuthHandler) {\n const error = new CivicAuthError(\n \"Iframe handler not initialized for preloading\",\n CivicAuthErrorCode.INIT_FAILED,\n );\n this.logger.error(\"โ Iframe handler not initialized\", {\n error: error.message,\n });\n throw error;\n }\n\n const fullAuthUrl = await this.buildAuthUrl();\n this.logger.info(\"๐ Built authentication URL for preload\", {\n url: fullAuthUrl,\n displayMode: this.config.displayMode,\n });\n\n try {\n // Set authentication timestamp when preloading starts\n // This ensures stale detection works even for preloaded iframes\n this.setAuthenticationStartedAtSeconds();\n\n await this.iframeAuthHandler.preloadIframe(fullAuthUrl);\n const iframeElement = this.iframeAuthHandler.getIframeElement();\n if (iframeElement) {\n this.messageHandler?.updateIframeElement(iframeElement);\n }\n\n this.logger.info(\"โ
Authentication iframe preloaded successfully\");\n } catch (error) {\n // Clear timestamp if preloading fails\n this.clearAuthenticationStartedAtSeconds();\n\n const errorMessage =\n error instanceof Error ? error.message : \"Failed to preload iframe\";\n this.logger.error(\"โ Failed to preload authentication iframe\", {\n error: errorMessage,\n });\n throw new CivicAuthError(\n errorMessage,\n CivicAuthErrorCode.IFRAME_PRELOAD_FAILED,\n );\n }\n }\n\n /**\n * Check if authentication is preloaded and ready for instant sign-in\n * @returns True if an iframe is preloaded and ready\n */\n isAuthenticationPreloaded(): boolean {\n if (this.config.displayMode !== \"iframe\" || !this.iframeAuthHandler) {\n return false;\n }\n return this.iframeAuthHandler.hasPreloadedIframe();\n }\n\n /**\n * Enable or disable iframe preloading\n * @param enabled Whether to enable iframe preloading\n */\n setPreloadEnabled(enabled: boolean): void {\n // Preloading only makes sense for iframe mode\n if (this.config.displayMode !== \"iframe\") {\n this.logger.debug(\n \"๐ฏ Iframe preloading not applicable for non-iframe mode\",\n {\n displayMode: this.config.displayMode,\n enabled,\n },\n );\n return;\n }\n\n if (this.iframeAuthHandler) {\n this.iframeAuthHandler.setPreloadEnabled(enabled);\n this.logger.info(\"๐ฏ Iframe preloading\", { enabled });\n } else {\n this.logger.warn(\n \"โ ๏ธ Cannot set preload enabled: iframe handler not initialized\",\n );\n }\n }\n\n /**\n * Check if iframe preloading is enabled\n * @returns True if iframe preloading is enabled\n */\n getPreloadEnabled(): boolean {\n // Preloading only makes sense for iframe mode\n if (this.config.displayMode !== \"iframe\") {\n return false;\n }\n return this.iframeAuthHandler?.getPreloadEnabled() ?? false;\n }\n\n /**\n * Check if the authentication session is stale (older than timeout)\n * @returns True if session is stale and needs re-initialization\n */\n private isAuthenticationSessionStale(): boolean {\n const timestampSeconds = this.getAuthenticationStartedAtSeconds();\n if (!timestampSeconds) {\n return false; // No timestamp means no stale session\n }\n\n const currentTimeSeconds = Math.floor(Date.now() / 1000);\n const elapsedSeconds = currentTimeSeconds - timestampSeconds;\n\n return elapsedSeconds > AUTH_SESSION_TIMEOUT_SECONDS;\n }\n\n /**\n * Get the authentication started timestamp from storage\n * @returns The timestamp in seconds or null if not set\n */\n private getAuthenticationStartedAtSeconds(): number | null {\n try {\n let value: string | null = null;\n\n // Try localStorage first\n if (typeof window !== \"undefined\" && window.localStorage) {\n value = window.localStorage.getItem(AUTH_SESSION_TIMESTAMP_KEY);\n } else {\n // Fall back to in-memory store\n value = inMemoryStore.get(AUTH_SESSION_TIMESTAMP_KEY) || null;\n }\n\n if (value) {\n const timestamp = parseInt(value, 10);\n return isNaN(timestamp) ? null : timestamp;\n }\n return null;\n } catch (error) {\n // localStorage might throw in private browsing mode\n this.logger.warn(\n \"Failed to get authentication timestamp, using in-memory fallback\",\n { error },\n );\n const value = inMemoryStore.get(AUTH_SESSION_TIMESTAMP_KEY);\n if (value) {\n const timestamp = parseInt(value, 10);\n return isNaN(timestamp) ? null : timestamp;\n }\n return null;\n }\n }\n\n /**\n * Set the authentication started timestamp in storage\n */\n private setAuthenticationStartedAtSeconds(): void {\n try {\n const currentTimeSeconds = Math.floor(Date.now() / 1000);\n const value = currentTimeSeconds.toString();\n\n // Try localStorage first\n if (typeof window !== \"undefined\" && window.localStorage) {\n window.localStorage.setItem(AUTH_SESSION_TIMESTAMP_KEY, value);\n } else {\n // Fall back to in-memory store\n inMemoryStore.set(AUTH_SESSION_TIMESTAMP_KEY, value);\n }\n\n this.logger.debug(\"Authentication timestamp set\", {\n timestamp: currentTimeSeconds,\n });\n } catch (error) {\n // localStorage might throw in private browsing mode\n this.logger.warn(\n \"Failed to set authentication timestamp in localStorage, using in-memory fallback\",\n { error },\n );\n const currentTimeSeconds = Math.floor(Date.now() / 1000);\n inMemoryStore.set(\n AUTH_SESSION_TIMESTAMP_KEY,\n currentTimeSeconds.toString(),\n );\n }\n }\n\n /**\n * Clear the authentication started timestamp from storage\n */\n private clearAuthenticationStartedAtSeconds(): void {\n try {\n // Try localStorage first\n if (typeof window !== \"undefined\" && window.localStorage) {\n window.localStorage.removeItem(AUTH_SESSION_TIMESTAMP_KEY);\n }\n // Also clear from in-memory store\n inMemoryStore.delete(AUTH_SESSION_TIMESTAMP_KEY);\n\n this.logger.debug(\"Authentication timestamp cleared\");\n } catch (error) {\n // localStorage might throw in private browsing mode\n this.logger.warn(\n \"Failed to clear authentication timestamp from localStorage\",\n { error },\n );\n inMemoryStore.delete(AUTH_SESSION_TIMESTAMP_KEY);\n }\n }\n\n /**\n * Re-initialize the auth client when session is stale\n * Preserves configuration but resets authentication state\n */\n private async reinitializeForStaleSession(): Promise<void> {\n this.logger.info(\"๐ Re-initializing due to stale authentication session\");\n\n // Clear any existing auth promise to ensure fresh start\n if (this.authPromise) {\n this.logger.info(\"๐งน Clearing existing auth promise for fresh start\");\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n }\n\n // Clean up any existing handlers before re-initialization\n if (this.messageHandler || this.popupHandler || this.iframeAuthHandler) {\n this.logger.info(\n \"๐งน Cleaning up existing handlers before re-initialization\",\n );\n this.cleanup();\n }\n\n // Clear the stale authentication timestamp\n this.clearAuthenticationStartedAtSeconds();\n\n try {\n // Ensure OAuth endpoints are available\n if (!this.endpoints) {\n this.logger.info(\"๐ Getting OAuth endpoints for re-initialization\");\n this.endpoints = await getOauthEndpoints(\n this.config.oauthServerBaseUrl,\n );\n }\n\n // Re-initialize all handlers with preserved config\n this.logger.info(\n \"๐ Re-initializing handlers with preserved configuration\",\n );\n this.initializeHandlers();\n\n this.logger.info(\"โ
Re-initialization completed successfully\");\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Failed to re-initialize\";\n this.logger.error(\"โ Failed to re-initialize for stale session\", {\n error: errorMessage,\n stack: error instanceof Error ? error.stack : undefined,\n });\n throw new CivicAuthError(\n `Failed to re-initialize authentication: ${errorMessage}`,\n CivicAuthErrorCode.INIT_FAILED,\n );\n }\n }\n\n /**\n * Starts the authentication process\n * @returns A promise that resolves with the authentication result\n * @throws {CivicAuthError} If authentication fails or times out\n */\n async startAuthentication(): Promise<AuthResult> {\n this.logger.info(\"๐ฌ Starting authentication process\", {\n displayMode: this.config.displayMode,\n userAgent: navigator.userAgent,\n currentUrl: window.location.href,\n });\n\n // Check if authentication session is stale and needs re-initialization\n const isStale = this.isAuthenticationSessionStale();\n if (isStale) {\n this.logger.info(\n \"โ ๏ธ Authentication session is stale, re-initializing...\",\n );\n await this.reinitializeForStaleSession();\n }\n\n const currentUser = await this.getCurrentUser();\n if (currentUser) {\n return { user: currentUser };\n }\n\n // Send SDK analytics when authentication starts\n // Fire and forget - don't block authentication if analytics fails\n collectAndSendSDKAnalytics(\n this.config.clientId,\n this.config.oauthServerBaseUrl,\n this.config.framework || \"vanillajs\",\n );\n\n if (!this.endpoints) {\n const error = new CivicAuthError(\n \"OAuth endpoints not initialized. Please wait for initialization to complete.\",\n CivicAuthErrorCode.ENDPOINTS_NOT_INITIALIZED,\n );\n this.logger.error(\"โ Endpoints not initialized\", {\n error: error.message,\n });\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: error.message,\n });\n throw error;\n }\n\n if (this.authPromise) {\n this.logger.info(\n \"โณ Authentication already in progress, returning existing promise\",\n );\n return this.authPromise;\n }\n\n // Set authentication started timestamp for fresh authentication\n this.setAuthenticationStartedAtSeconds();\n\n const fullAuthUrl = await this.buildAuthUrl(isStale);\n this.logger.info(\"๐ Built authentication URL\", {\n url: fullAuthUrl,\n displayMode: this.config.displayMode,\n authProcessTimeout: this.config.authProcessTimeout,\n });\n\n this.authPromise = new Promise<AuthResult>((resolve, reject) => {\n this.authPromiseResolve = resolve;\n this.authPromiseReject = reject;\n\n this.handleAuthenticationByDisplayMode(fullAuthUrl);\n this.setupAuthenticationTimeout();\n });\n\n return this.authPromise;\n }\n\n /**\n * Reloads embedded authentication interface\n *\n * This method is specifically designed for embedded mode scenarios where the iframe\n * needs to be recreated after navigation or DOM changes. It performs a complete\n * re-initialization by calling the full init() method.\n *\n * @returns Promise that resolves when the embedded iframe is created\n * @throws {CivicAuthError} If not in embedded mode or if iframe creation fails\n *\n * @example\n * ```typescript\n * // After navigation in a SPA\n * await civicAuth.reloadEmbedded();\n * ```\n */\n async reloadEmbedded(): Promise<void> {\n this.logger.info(\"๐ Reloading embedded authentication interface\", {\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n authPromise: !!this.authPromise,\n });\n\n this.config.displayMode = \"iframe\";\n this.config.iframeDisplayMode = \"embedded\";\n\n // Check if container element exists\n const container = this.getContainerElement();\n this.logger.info(\"๐ฏ Container element check\", {\n containerFound: !!container,\n containerId: container?.id,\n containerClass: container?.className,\n });\n\n if (!container) {\n const error = new CivicAuthError(\n \"Container element for embedded iframe not found. Ensure an element with id 'civic-login-container' exists or provide targetContainerElement in config.\",\n CivicAuthErrorCode.CONTAINER_NOT_FOUND,\n );\n this.logger.error(error.message);\n throw error;\n }\n\n // Clear any existing auth promise to ensure fresh start\n if (this.authPromise) {\n this.logger.info(\"๐งน Clearing existing auth promise for fresh start\");\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n }\n\n // Clean up any existing handlers before re-initialization\n if (this.messageHandler || this.popupHandler || this.iframeAuthHandler) {\n this.logger.info(\n \"๐งน Cleaning up existing handlers before re-initialization\",\n );\n this.cleanup();\n }\n\n this.logger.info(\"๐ Re-initializing handlers and starting embedded auth\");\n\n try {\n // Don't call init() - that would re-process config based on current page\n // Instead, do minimal re-initialization with original config\n\n // Ensure OAuth endpoints are available (they should be from original init)\n if (!this.endpoints) {\n this.logger.info(\"๐ Getting OAuth endpoints\");\n this.endpoints = await getOauthEndpoints(\n this.config.oauthServerBaseUrl,\n );\n }\n\n // Re-initialize all handlers (creates new instances)\n this.logger.info(\"๐ Re-initializing handlers\");\n this.initializeHandlers();\n\n // Start authentication to create the embedded iframe\n this.logger.info(\"๐ฌ Starting embedded authentication\");\n await this.startAuthentication();\n this.logger.info(\"โ
Embedded iframe reloaded successfully\");\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : \"Failed to reload embedded iframe\";\n this.logger.error(\"โ Failed to reload embedded iframe\", {\n error: errorMessage,\n stack: error instanceof Error ? error.stack : undefined,\n });\n throw error;\n }\n }\n\n private async handleBrowserCorsFailsSilently(): Promise<Promise<void>> {\n this.logger.warn(\n \"๐จ Browser CORS fails silently - switching to redirect mode\",\n {\n displayMode: this.config.displayMode,\n iframeAuthHandler: !!this.iframeAuthHandler,\n messageHandler: !!this.messageHandler,\n },\n );\n if (!this.iframeAuthHandler || !this.messageHandler) {\n throw new Error(\"Iframe handler not initialized\");\n }\n this.config.displayMode = \"redirect\";\n this.iframeAuthHandler.forceHideIframe();\n const rebuiltUrl = await this.buildAuthUrl();\n this.config.events?.emit(AuthEvent.SIGN_IN_ERROR, {\n detail:\n \"Browser doesn't support popups and passkey with CORS in iframe - switching to redirect mode\",\n error: {\n type: \"browser_cors_fails_silently\",\n failedUrl: IframeManager.browserCorsFailsSilentlyUrl,\n suggestion:\n \"Browser doesn't support popups and passkey with CORS in iframe - switching to redirect mode\",\n },\n });\n // use a small delay to ensure the loader is shown\n setTimeout(() => {\n window.location.href = rebuiltUrl;\n }, 100);\n }\n\n /**\n * Handle authentication based on display mode\n */\n private async handleAuthenticationByDisplayMode(\n fullAuthUrl: string,\n ): Promise<void> {\n this.logger.info(\"๐ฏ Handling authentication with display mode\", {\n displayMode: this.config.displayMode,\n });\n\n try {\n switch (this.config.displayMode) {\n case \"redirect\":\n this.logger.info(\"๐ Using redirect mode\");\n this.events.locationChange(\n fullAuthUrl,\n \"Redirecting to auth URL\",\n \"login\",\n );\n break;\n\n case \"new_tab\":\n this.logger.info(\"๐ฑ Using new_tab mode\");\n if (!this.popupHandler) {\n throw new Error(\"Popup handler not initialized\");\n }\n await this.popupHandler.handleNewTabAuth(fullAuthUrl);\n break;\n\n case \"iframe\":\n default: {\n this.logger.info(\"๐ผ๏ธ Using iframe mode\");\n if (!this.iframeAuthHandler || !this.messageHandler) {\n throw new Error(\"Iframe handler not initialized\");\n }\n if (IframeManager.browserCorsFailsSilentlyUrl) {\n return this.handleBrowserCorsFailsSilently();\n }\n\n const iframeElement =\n await this.iframeAuthHandler.handleIframeAuth(fullAuthUrl);\n this.messageHandler.updateIframeElement(iframeElement);\n break;\n }\n }\n } catch (error) {\n if (error instanceof PopupError) {\n await this.handlePopupErrorWithFallback(fullAuthUrl, error);\n } else {\n this.handleAuthError(\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n }\n }\n\n /**\n * Handle popup error with redirect fallback\n */\n private async handlePopupErrorWithFallback(\n fullAuthUrl: string,\n error: PopupError,\n ): Promise<void> {\n this.logger.warn(\"๐ซ Popup failed, falling back to redirect mode\", {\n originalDisplayMode: this.config.displayMode,\n error: error.message,\n });\n\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: \"Popup blocked, falling back to redirect mode\",\n });\n\n try {\n this.logger.info(\"๐ Attempting redirect fallback\");\n\n // Clean up current authentication attempt\n this.cleanup();\n\n // Always switch to redirect mode for Safari compatibility\n this.config.displayMode = \"redirect\";\n\n // Regenerate the auth URL with updated display mode in state\n const fallbackAuthUrl = await this.buildAuthUrl();\n\n this.logger.info(\"๐ Redirecting to auth URL\", { url: fallbackAuthUrl });\n window.location.href = fallbackAuthUrl;\n this.logger.info(\"โ
Redirect initiated successfully\");\n } catch (redirectError) {\n this.logger.error(\"โ Redirect fallback failed\", {\n error: redirectError,\n redirectUrl: fullAuthUrl,\n });\n\n const fallbackError = new CivicAuthError(\n \"Failed to open popup window and redirect fallback failed. Please check your browser's popup settings.\",\n CivicAuthErrorCode.INIT_FAILED,\n );\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: fallbackError.message,\n });\n this.handleAuthError(fallbackError);\n }\n }\n\n /**\n * Setup authentication timeout\n */\n private setupAuthenticationTimeout(): void {\n // Skip timeout for embedded iframe mode - embedded iframes should stay persistent\n if (\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"embedded\"\n ) {\n this.logger.debug(\n \"โฐ Skipping authentication timeout for embedded iframe mode\",\n {\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n },\n );\n return;\n }\n\n // Set up timeout for other modes\n if (this.config.authProcessTimeout && this.config.authProcessTimeout > 0) {\n this.logger.debug(\"โฐ Setting up authentication timeout\", {\n timeout: this.config.authProcessTimeout,\n displayMode: this.config.displayMode,\n iframeDisplayMode: this.config.iframeDisplayMode,\n });\n\n this.authProcessTimeoutHandle = window.setTimeout(() => {\n this.logger.info(\"โฐ Authentication timeout reached\");\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: \"Authentication timed out\",\n });\n\n const error = new CivicAuthError(\n \"Authentication timed out\",\n CivicAuthErrorCode.AUTH_PROCESS_TIMEOUT,\n );\n this.handleAuthError(error);\n }, this.config.authProcessTimeout);\n }\n }\n\n /**\n * Handle successful authentication\n */\n private handleAuthSuccess(result: AuthResult): void {\n this.logger.info(\"โ
Authentication successful\");\n\n // Clear authentication timestamp on successful completion\n this.clearAuthenticationStartedAtSeconds();\n\n this.authPromiseResolve?.(result);\n\n // For embedded mode, preserve the iframe completely - don't cleanup\n // The iframe should stay visible showing the successful authentication state\n const isEmbeddedMode =\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"embedded\";\n\n if (isEmbeddedMode) {\n this.logger.info(\n \"๐ง Embedded mode - preserving iframe, skipping cleanup\",\n );\n // Only clean up timeouts and reset promises, but keep iframe visible\n this.cleanupTimeoutsAndState();\n } else {\n // For modal/redirect modes, do full cleanup as before\n this.cleanup();\n }\n }\n\n /**\n * Handle authentication error\n */\n private handleAuthError(error: Error): void {\n this.logger.error(\"โ Authentication failed\", { error: error.message });\n\n // Clear authentication timestamp on error/cancellation\n this.clearAuthenticationStartedAtSeconds();\n\n this.authPromiseReject?.(error);\n\n // For embedded mode, preserve the iframe to show error state\n // For other modes, do full cleanup as before\n const isEmbeddedMode =\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"embedded\";\n\n if (isEmbeddedMode) {\n this.logger.info(\n \"๐ง Embedded mode - preserving iframe to show error state\",\n );\n // Only clean up timeouts and reset promises, but keep iframe visible\n this.cleanupTimeoutsAndState();\n } else {\n // For modal/redirect modes, do full cleanup as before\n this.cleanup();\n }\n }\n\n /**\n * Handle popup failure - simplified like React implementation\n */\n private handlePopupFailure(failedUrl?: string): void {\n this.hasPopupFailed = true;\n\n this.logger.warn(\"Popup failed, using redirect mode instead...\", {\n failedUrl,\n });\n\n // Clean up iframe if it exists\n if (this.iframeAuthHandler) {\n this.iframeAuthHandler.cleanupIframe();\n }\n\n // Always redirect to the failed URL or build a new one\n if (failedUrl) {\n // this.config.displayMode = \"redirect\";\n\n // Use centralized location change handler\n this.events.locationChange(\n failedUrl,\n \"Popup blocked, falling back to redirect mode\",\n \"login\",\n );\n\n return;\n }\n\n this.buildAuthUrl()\n .then((authUrl) => {\n this.events.locationChange(authUrl, \"Redirecting to auth URL\", \"login\");\n })\n .catch((error) => {\n this.logger.error(\"Failed to build auth URL for redirect fallback\", {\n error,\n });\n const fallbackError = new CivicAuthError(\n \"Failed to redirect for authentication\",\n CivicAuthErrorCode.INIT_FAILED,\n );\n this.handleAuthError(fallbackError);\n });\n }\n\n /**\n * Show popup failure message to user\n */\n private showPopupFailureMessage(\n customMessage: string = \"Authentication will continue in this window. Please wait...\",\n ): void {\n const container = this.getContainerElement();\n if (!container) {\n this.logger.warn(\n \"Cannot show popup failure message - container not found\",\n );\n return;\n }\n const existingMessage = document.getElementById(\n \"civic-auth-popup-failure-message\",\n );\n if (existingMessage && existingMessage.parentNode) {\n existingMessage.parentNode.removeChild(existingMessage);\n }\n const messageOverlay = document.createElement(\"div\");\n messageOverlay.id = \"civic-auth-popup-failure-message\";\n messageOverlay.style.cssText =\n \"position:absolute;top:0;left:0;right:0;background:rgba(255,249,196,.95);border:1px solid #f59e0b;border-radius:6px;padding:12px;margin:8px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;font-size:14px;color:#92400e;z-index:1000;box-shadow:0 2px 4px rgba(0,0,0,.1);\";\n messageOverlay.innerHTML =\n '<div style=\"display:flex;align-items:center;gap:8px;\">' +\n '<span style=\"font-size:16px;\">โ ๏ธ</span>' +\n \"<div>\" +\n \"<strong>Popup blocked</strong><br>\" +\n '<span style=\"font-size:12px;\">' +\n customMessage +\n \"</span>\" +\n \"</div>\" +\n \"</div>\";\n\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n container.appendChild(messageOverlay);\n\n setTimeout(() => {\n if (messageOverlay.parentNode) {\n messageOverlay.parentNode.removeChild(messageOverlay);\n }\n }, 10000);\n this.logger.info(\"Popup failure message displayed to user\");\n }\n\n /**\n * Setup popup failure timeout\n */\n private setupPopupFailureTimeout(): void {\n this.popupFailureTimeoutHandle = window.setTimeout(() => {\n this.logger.info(\"โฐ Popup failure timeout reached\");\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: \"Authentication timeout - popup failure scenario\",\n });\n\n const error = new CivicAuthError(\n \"Authentication timeout - popup failure scenario\",\n CivicAuthErrorCode.AUTH_PROCESS_TIMEOUT,\n );\n this.handleAuthError(error);\n }, 20000); // 20 seconds\n }\n\n /**\n * Gets the container element for the auth iframe\n */\n private getContainerElement(): HTMLElement | null {\n if (typeof this.config.targetContainerElement === \"string\") {\n const element = document.getElementById(\n this.config.targetContainerElement,\n );\n if (!element) {\n this.logger.warn(\n `Container element with ID \"${this.config.targetContainerElement}\" not found`,\n );\n }\n return element;\n }\n\n if (this.config.targetContainerElement) {\n return this.config.targetContainerElement;\n }\n\n // Fallback: Look for element with id \"civic-login-container\"\n const fallbackContainer = document.getElementById(\n \"civic-login-container\",\n ) as HTMLElement;\n if (fallbackContainer) {\n this.logger.debug(\n 'Using fallback container with id \"civic-login-container\"',\n );\n return fallbackContainer;\n }\n\n return null;\n }\n\n /**\n * Handle OAuth callback\n */\n private async handleCallback(): Promise<void> {\n this.logger.info(\"๐ Handling OAuth callback\", {\n currentUrl: window.location.href,\n redirectUrl: this.config.redirectUrl,\n });\n\n try {\n // Only handle OAuth callback if not using backend integration\n if (!this.config.clientId && this.config.loginUrl) {\n this.logger.info(\n \"๐ Backend integration mode - skipping OAuth callback handling\",\n );\n return;\n }\n\n // Ensure clientId is available for OAuth callback\n if (!this.config.clientId) {\n throw new Error(\"ClientId is required for OAuth callback handling\");\n }\n\n const callbackHandled = await handleOAuthRedirectPage({\n clientId: this.config.clientId,\n oauthServer: this.config.oauthServerBaseUrl,\n redirectUrl: this.config.redirectUrl,\n textSignals: {\n success: this.config.textSignals.success,\n error: this.config.textSignals.error || \"Authentication failed\",\n },\n storageAdapter: this.storage,\n });\n\n this.logger.info(\"๐ Callback processing result\", { callbackHandled });\n\n if (callbackHandled) {\n const successSignal = document.getElementById(\n CIVIC_AUTH_CONSTANTS.SUCCESS_SIGNAL_ID,\n );\n const errorSignal = document.getElementById(\n CIVIC_AUTH_CONSTANTS.ERROR_SIGNAL_ID,\n );\n\n if (successSignal) {\n this.logger.info(\"โ
Success signal found\");\n let userInfo = null;\n const userInfoAttr = successSignal.getAttribute(\"data-user-info\");\n if (userInfoAttr) {\n try {\n userInfo = JSON.parse(userInfoAttr);\n } catch (error) {\n this.logger.error(\"โ Failed to parse user info\", { error });\n }\n }\n this.events.emit(AuthEvent.SIGN_IN_COMPLETE, {\n detail: \"Callback processed successfully\",\n user: userInfo,\n });\n } else if (errorSignal) {\n this.logger.error(\"โ Error signal found\");\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: errorSignal.textContent || \"Unknown error during callback\",\n });\n }\n }\n } catch (error) {\n this.logger.error(\"โ Callback handling failed\", { error });\n this.events.emit(AuthEvent.SIGN_IN_ERROR, {\n detail:\n error instanceof Error\n ? error.message\n : \"Unknown error during callback\",\n });\n }\n }\n\n /**\n * Cleans up resources and event listeners\n */\n public cleanup(): void {\n this.logger.info(\"Cleaning up authentication client\");\n\n // Clean up handlers\n this.iframeAuthHandler?.cleanupIframe();\n\n // Clean up timeouts\n if (this.authProcessTimeoutHandle) {\n window.clearTimeout(this.authProcessTimeoutHandle);\n this.authProcessTimeoutHandle = undefined;\n }\n\n if (this.popupFailureTimeoutHandle) {\n window.clearTimeout(this.popupFailureTimeoutHandle);\n this.popupFailureTimeoutHandle = undefined;\n }\n\n // Reset state\n this.hasPopupFailed = false;\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n\n // Remove message event listener\n if (this.messageHandler) {\n window.removeEventListener(\"message\", this.messageHandler.handleMessage);\n }\n }\n\n /**\n * Clean up only timeouts and state without touching iframe (for embedded mode)\n */\n private cleanupTimeoutsAndState(): void {\n this.logger.info(\n \"Cleaning up timeouts and state (preserving iframe for embedded mode)\",\n );\n\n // Clean up timeouts\n if (this.authProcessTimeoutHandle) {\n window.clearTimeout(this.authProcessTimeoutHandle);\n this.authProcessTimeoutHandle = undefined;\n }\n\n if (this.popupFailureTimeoutHandle) {\n window.clearTimeout(this.popupFailureTimeoutHandle);\n this.popupFailureTimeoutHandle = undefined;\n }\n\n // Reset state\n this.hasPopupFailed = false;\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n\n // Keep message handler and iframe for embedded mode\n }\n\n /**\n * Get the current session\n */\n public async getCurrentSession(): Promise<Session | null> {\n return this.sessionManager.getCurrentSession() || null;\n }\n\n /**\n * Get current session tokens including decoded forwarded tokens\n * This method extracts and decodes forwarded tokens from the ID token JWT\n */\n public async getTokensWithForwardedTokens() {\n const session = await this.getCurrentSession();\n return extractTokensFromSession(session);\n }\n\n /**\n * Check if user is authenticated\n */\n public async isAuthenticated(): Promise<boolean> {\n return this.sessionManager.isAuthenticated() || false;\n }\n\n /**\n * Get the current user\n */\n public async getCurrentUser() {\n return this.sessionManager.getCurrentUser() || null;\n }\n\n /**\n * Clear the current session\n */\n public async clearSession(): Promise<void> {\n return this.sessionManager.clearSession();\n }\n\n /**\n * Manually refresh tokens\n */\n public async refreshTokens(): Promise<void> {\n return this.sessionManager.refreshTokens();\n }\n\n /**\n * Get token refresher state for debugging\n */\n public getTokenRefresherState() {\n return this.sessionManager.getTokenRefresherState() || null;\n }\n\n /**\n * Set a custom login URL for backend integration.\n * This is useful when integrating with a backend that handles the OAuth flow.\n * Alternatively, you can configure this directly in CivicAuth.create().\n *\n * @param loginUrl - The custom login URL to use (e.g., \"http://localhost:3020/auth/login\")\n *\n * @example\n * ```typescript\n * // Option 1: Configure in create()\n * const authClient = await CivicAuth.create({\n * clientId: \"YOUR_CLIENT_ID\",\n * loginUrl: \"http://example.com/custom-backendurl\"\n * });\n *\n * // Option 2: Set after creation\n * civicAuth.setLoginUrl(\"http://localhost:3020/auth/login\");\n * await civicAuth.startAuthentication();\n * ```\n */\n public setLoginUrl(loginUrl: string): void {\n this.loginUrl = loginUrl;\n\n // Update MessageHandler to expect messages from the custom origin\n if (this.messageHandler) {\n this.messageHandler.setCustomExpectedOrigin(loginUrl);\n }\n\n this.logger.info(\"๐ Custom login URL set for backend integration\", {\n loginUrl: this.loginUrl,\n });\n }\n\n /**\n * Clear the login URL and return to standard OAuth flow\n */\n public clearLoginUrl(): void {\n this.loginUrl = undefined;\n\n // Clear custom expected origin from MessageHandler\n if (this.messageHandler) {\n this.messageHandler.clearCustomExpectedOrigin();\n }\n\n this.logger.info(\"๐ Login URL cleared, returning to standard OAuth flow\");\n }\n\n /**\n * Get the current login URL\n * @returns The current login URL or undefined if not set\n */\n public getLoginUrl(): string | undefined {\n return this.loginUrl;\n }\n\n /**\n * Update the iframe display mode\n * @param mode - The display mode to use for the iframe\n */\n public setIframeDisplayMode(mode: \"modal\" | \"embedded\"): void {\n this.config.iframeDisplayMode = mode;\n this.logger.debug(`Iframe display mode updated to: ${mode}`);\n }\n\n /**\n * Get the current iframe display mode\n * @returns The current iframe display mode\n */\n public getIframeDisplayMode(): \"modal\" | \"embedded\" | undefined {\n return this.config.iframeDisplayMode;\n }\n\n /**\n * Reset authentication state when page is restored from back-forward cache (bfcache)\n * This clears any pending authentication promises that may have been interrupted\n * by the browser caching the page, allowing fresh authentication attempts\n */\n public resetOnBfcache(): void {\n this.logger.info(\n \"๐ Resetting authentication state due to bfcache restore\",\n );\n\n // Clear pending authentication promise and related state\n if (this.authPromise) {\n this.logger.debug(\"Clearing stale authentication promise from bfcache\");\n this.authPromise = undefined;\n this.authPromiseResolve = undefined;\n this.authPromiseReject = undefined;\n }\n\n // Clear timeouts that may no longer be valid\n if (this.authProcessTimeoutHandle) {\n window.clearTimeout(this.authProcessTimeoutHandle);\n this.authProcessTimeoutHandle = undefined;\n }\n\n if (this.popupFailureTimeoutHandle) {\n window.clearTimeout(this.popupFailureTimeoutHandle);\n this.popupFailureTimeoutHandle = undefined;\n }\n\n // Reset auth flags\n this.hasPopupFailed = false;\n this.hasSignInStarted = false;\n\n // Reset iframe handler state if needed\n if (this.iframeAuthHandler) {\n this.iframeAuthHandler.cleanupIframe();\n }\n }\n\n /**\n * Destroy the auth client and clean up all resources\n */\n public async destroy(): Promise<void> {\n this.cleanup();\n await this.sessionManager.destroy();\n this.logger.info(\"CivicAuth destroyed\");\n }\n\n /**\n * Handle logout\n */\n public async logout(): Promise<void> {\n try {\n this.logger.info(\"๐ Starting logout process\");\n this.events.emit(AuthEvent.SIGN_OUT_STARTED, {\n detail: \"Logout process started\",\n });\n\n // If a loginUrl is configured, redirect to the backend's logout endpoint.\n // The backend will then handle redirecting to the OIDC provider.\n if (this.loginUrl) {\n this.logger.info(\n \"๐ช Redirecting to backend for logout in backend-integrated flow\",\n );\n const backendUrl = new URL(this.loginUrl).origin;\n const endpoints = getBackendEndpoints(this.config.backendEndpoints);\n const backendLogoutUrl = resolveEndpointUrl(\n backendUrl,\n endpoints.logout,\n );\n\n this.events.emit(AuthEvent.SIGN_OUT_COMPLETE, {\n detail: \"Local session cleared, redirecting to backend for logout.\",\n });\n\n // Generate state for backend integration to enable iframe mode detection\n const state = generateState({\n displayMode: this.config.displayMode || \"iframe\",\n framework: this.config.framework || \"vanillajs\",\n sdkVersion: getVersion(),\n });\n\n // Perform top-level redirect to the backend logout endpoint\n // Include logoutRedirectUrl and state as query parameters\n const logoutUrl = new URL(backendLogoutUrl);\n if (this.config.logoutRedirectUrl) {\n logoutUrl.searchParams.set(\n \"logoutRedirectUrl\",\n this.config.logoutRedirectUrl,\n );\n }\n\n // Include state for iframe mode detection on server\n logoutUrl.searchParams.set(\"state\", state);\n\n this.logger.info(\"๐ Loading backend logout endpoint in iframe\", {\n url: logoutUrl.toString(),\n path: logoutUrl.pathname,\n logoutRedirectUrl: this.config.logoutRedirectUrl,\n displayMode: this.config.displayMode,\n });\n\n // Use iframe for SPA logout to avoid full page reload\n this.loadLogoutInIframe(logoutUrl);\n await this.sessionManager.clearSession();\n return;\n }\n\n // --- Existing SPA redirect-based logout flow ---\n this.logger.info(\"๐ช Using redirect-based logout for SPA flow\");\n const tokens = await retrieveTokens(this.storage);\n\n if (!tokens?.id_token) {\n this.logger.warn(\"โ ๏ธ No ID token found, clearing local session only\");\n await clearTokens(this.storage);\n await this.sessionManager.clearSession();\n this.events.emit(AuthEvent.SIGN_OUT_COMPLETE, {\n detail: \"Local session cleared\",\n });\n return;\n }\n\n if (!this.endpoints) {\n throw new Error(\"OAuth endpoints not initialized\");\n }\n\n // Generate a state for logout (for OAuth provider tracking only)\n const state = generateState({\n displayMode: this.config.displayMode || \"iframe\",\n framework: this.config.framework || \"vanillajs\",\n sdkVersion: getVersion(),\n });\n\n this.logger.info(\"๐ Generated logout state for OAuth provider\", {\n generatedState: state,\n displayMode: this.config.displayMode,\n });\n\n // Note: No need to store logout_state in localStorage since iframe flows\n // don't receive redirect callbacks that need state coordination\n\n // Ensure clientId is available for OAuth logout\n if (!this.config.clientId) {\n throw new Error(\"ClientId is required for OAuth logout flow\");\n }\n\n // Generate logout URL\n const logoutUrl = await generateOauthLogoutUrl({\n clientId: this.config.clientId,\n redirectUrl: this.config.logoutRedirectUrl,\n idToken: tokens.id_token,\n state: state,\n oauthServer: this.config.oauthServerBaseUrl,\n });\n\n this.logger.info(\"๐ Generated logout URL\", {\n logoutUrl: logoutUrl.toString(),\n });\n\n // Clear local tokens and session completely (no need to preserve logout_state)\n await this.sessionManager.clearSession(false);\n\n // Emit logout complete event before iframe request\n this.events.emit(AuthEvent.SIGN_OUT_COMPLETE, {\n detail: \"Logout successful\",\n });\n\n // Use hidden iframe instead of redirect to avoid full page reload in SPA mode\n this.loadLogoutInIframe(logoutUrl);\n } catch (error) {\n this.logger.error(\"โ Logout failed\", { error });\n this.events.emit(AuthEvent.SIGN_OUT_ERROR, {\n detail: error instanceof Error ? error.message : String(error),\n });\n throw new CivicAuthError(\n \"Logout failed\",\n CivicAuthErrorCode.LOGOUT_FAILED,\n );\n }\n }\n\n /**\n * Load logout URL in a hidden iframe to avoid full page reload\n * @param logoutUrl The URL to load in the iframe\n */\n private loadLogoutInIframe(logoutUrl: URL): void {\n this.logger.info(\"๐ Loading logout URL in hidden iframe\");\n\n const logoutIframe = document.createElement(\"iframe\");\n logoutIframe.style.display = \"none\";\n\n // Clean up iframe when logout completes (or errors)\n const cleanupIframe = () => {\n this.logger.info(\"๐งน Cleaning up logout iframe\");\n\n if (!logoutIframe.parentNode) {\n this.logger.warn(\"๐งน Logout iframe not found, skipping iframe cleanup\");\n return;\n }\n\n logoutIframe.parentNode.removeChild(logoutIframe);\n\n if (this.config.logoutRedirectUrl) {\n this.logger.info(\n \"๐ Redirecting to logoutRedirectUrl after logout iframe cleanup\",\n {\n logoutRedirectUrl: this.config.logoutRedirectUrl,\n },\n );\n // Use direct redirect for logout to ensure frontend state is cleared\n // This bypasses any URL_CHANGE event listeners that might interfere\n // we should only redirect if we're not already on the logoutRedirectUrl\n const currentPathAndQuery =\n window.location.pathname + window.location.search;\n\n // Parse the logout redirect URL to get its path and query\n const logoutUrl = new URL(\n this.config.logoutRedirectUrl,\n window.location.origin,\n );\n const logoutPathAndQuery = logoutUrl.pathname + logoutUrl.search;\n\n // Only redirect if current path + query is different from logout redirect URL\n if (currentPathAndQuery !== logoutPathAndQuery) {\n window.location.href = this.config.logoutRedirectUrl;\n }\n }\n };\n\n logoutIframe.onload = () => {\n cleanupIframe();\n };\n logoutIframe.onerror = (error) => {\n this.logger.error(\"โ Logout iframe failed to load\", { error });\n cleanupIframe();\n };\n\n logoutIframe.src = logoutUrl.toString();\n document.body.appendChild(logoutIframe);\n }\n\n /**\n * Handle logout state cleanup\n * This mirrors the logic from useSignIn.ts to properly clean up after logout\n */\n private async handleLogoutStateCleanup(): Promise<void> {\n try {\n const params = new URLSearchParams(window.location.search);\n const state = params.get(\"state\");\n\n this.logger.info(\"๐ Checking for logout state cleanup\", {\n currentUrl: window.location.href,\n hasStateParam: !!state,\n stateValue: state,\n rawSearch: window.location.search,\n });\n\n if (!state) {\n this.logger.info(\n \"๐ No state parameter found, skipping logout cleanup\",\n );\n return; // No state parameter, nothing to cleanup\n }\n\n // Check if we have a stored logout state that matches\n const storedLogoutState = await this.storage.get(LOGOUT_STATE);\n\n // The state might be URL-decoded by URLSearchParams, but stored as plain\n // Let's try both the decoded and encoded versions\n const decodedState = decodeURIComponent(state);\n\n this.logger.info(\"๐ Comparing logout states\", {\n urlState: state,\n decodedState,\n storedLogoutState,\n directMatch: state === storedLogoutState,\n decodedMatch: decodedState === storedLogoutState,\n });\n\n if (state === storedLogoutState || decodedState === storedLogoutState) {\n this.logger.info(\"๐งน Cleaning up logout state\", {\n state,\n storedLogoutState,\n });\n\n // Clear tokens and user data from storage\n await clearTokens(this.storage);\n await this.sessionManager.clearSession();\n\n // Clean up the logout state from storage\n await this.storage.delete(LOGOUT_STATE);\n\n // Emit logout complete event\n this.events.emit(AuthEvent.SIGN_OUT_COMPLETE, {\n detail: \"Logout cleanup completed\",\n });\n\n // Clean up URL by removing query parameters\n const cleanUrl = window.location.href.split(\"?\")[0];\n window.history.replaceState({}, document.title, cleanUrl);\n\n this.logger.info(\"โ
Logout state cleanup completed\", {\n cleanUrl,\n });\n } else {\n this.logger.info(\"๐ Logout states don't match, skipping cleanup\", {\n urlState: state,\n storedLogoutState,\n });\n }\n } catch (error) {\n this.logger.warn(\"โ ๏ธ Error during logout state cleanup\", { error });\n // Don't throw error to prevent initialization failure\n }\n }\n}\n\n// Export types for external use\nexport type { CivicAuthClientConfig } from \"./types/AuthTypes.js\";\nexport { CivicAuthErrorCode } from \"./types/AuthTypes.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionManager.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/auth/SessionManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA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IR;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAK/B"}
|
|
@@ -400,6 +400,7 @@ export class SessionManager {
|
|
|
400
400
|
*/
|
|
401
401
|
async clearSession(preserveLogoutState = false) {
|
|
402
402
|
try {
|
|
403
|
+
this.initialUser = undefined;
|
|
403
404
|
// Stop token refresher so that in-flight refreshes are cancelled
|
|
404
405
|
this.tokenRefresher?.setAuthenticationState(false);
|
|
405
406
|
if (preserveLogoutState) {
|