@civic/auth 0.9.0-beta.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactjs/core/GlobalAuthManager.d.ts.map +1 -1
- package/dist/reactjs/core/GlobalAuthManager.js +2 -1
- package/dist/reactjs/core/GlobalAuthManager.js.map +1 -1
- package/dist/reactjs/providers/CivicAuthContext.d.ts.map +1 -1
- package/dist/reactjs/providers/CivicAuthContext.js +2 -1
- package/dist/reactjs/providers/CivicAuthContext.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/types/AuthTypes.d.ts +2 -1
- package/dist/vanillajs/auth/types/AuthTypes.d.ts.map +1 -1
- package/dist/vanillajs/auth/types/AuthTypes.js +2 -1
- package/dist/vanillajs/auth/types/AuthTypes.js.map +1 -1
- package/dist/vanillajs/iframe/IframeManager.d.ts +4 -0
- package/dist/vanillajs/iframe/IframeManager.d.ts.map +1 -1
- package/dist/vanillajs/iframe/IframeManager.js +20 -7
- package/dist/vanillajs/iframe/IframeManager.js.map +1 -1
- package/dist/vanillajs/iframe/IframeResizer.d.ts +4 -1
- package/dist/vanillajs/iframe/IframeResizer.d.ts.map +1 -1
- package/dist/vanillajs/iframe/IframeResizer.js +30 -1
- package/dist/vanillajs/iframe/IframeResizer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalAuthManager.d.ts","sourceRoot":"","sources":["../../../src/reactjs/core/GlobalAuthManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAOH,OAAO,KAAK,EACV,IAAI,EACJ,OAAO,EAER,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;A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;IAwD3B;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,QAAQ;IAKhB;;OAEG;YACW,OAAO;CAStB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* - Server-side rendering scenarios where providers might be problematic
|
|
28
28
|
*/
|
|
29
29
|
import { CivicAuth, AuthenticationEvents, AuthEvent, } from "../../vanillajs/index.js";
|
|
30
|
+
import { DEFAULT_AUTH_PROCESS_TIMEOUT } from "../../vanillajs/auth/types/AuthTypes.js";
|
|
30
31
|
/**
|
|
31
32
|
* Global singleton that manages CivicAuth instance for React hooks
|
|
32
33
|
* Eliminates the need for React providers
|
|
@@ -103,7 +104,7 @@ class GlobalAuthManager {
|
|
|
103
104
|
displayMode: config.displayMode || "iframe",
|
|
104
105
|
iframeDisplayMode: config.iframeMode || "modal",
|
|
105
106
|
nonce: config.nonce,
|
|
106
|
-
authProcessTimeout: config.authProcessTimeout ||
|
|
107
|
+
authProcessTimeout: config.authProcessTimeout || DEFAULT_AUTH_PROCESS_TIMEOUT,
|
|
107
108
|
preloadIframe: config.preloadIframe,
|
|
108
109
|
autoRedirect: config.autoRedirect,
|
|
109
110
|
events: this.events,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalAuthManager.js","sourceRoot":"","sources":["../../../src/reactjs/core/GlobalAuthManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,SAAS,GACV,MAAM,0BAA0B,CAAC;AAsDlC;;;GAGG;AACH,MAAM,iBAAiB;IACb,MAAM,CAAC,QAAQ,GAA6B,IAAI,CAAC;IACjD,IAAI,GAAqB,IAAI,CAAC;IAC9B,MAAM,GAAgC,IAAI,CAAC;IAC3C,MAAM,GAA4B,IAAI,CAAC;IACvC,SAAS,GAAG,IAAI,GAAG,EAAiB,CAAC;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I,CAAC,iBAAiB,EAAE;gBAC7B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;aAC3B,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACtE,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED;;OAEG;IACK,QAAQ,CAAC,OAAiC;QAChD,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,OAAO;QACnB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC,4CAA4C;IACjF,CAAC;;AAGH,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["/**\n * GlobalAuthManager - Singleton Authentication State Manager\n *\n * This module provides a global singleton that manages authentication state across a React application\n * without requiring React Context providers or prop drilling. It acts as a centralized authentication\n * manager that wraps the CivicAuth vanilla JavaScript library and provides a React-friendly interface.\n *\n * Key Features:\n * - Singleton pattern ensures single auth instance across the entire app\n * - Eliminates need for React Context providers and reduces bundle size\n * - Manages authentication state (user, session, loading, errors)\n * - Handles sign-in/sign-out flows with event-driven updates\n * - Provides idempotent initialization (safe to call multiple times)\n * - Supports multiple React hooks subscribing to the same auth state\n * - Automatic session refresh and user data synchronization\n *\n * Usage:\n * - Initialize once in your app with authentication configuration\n * - Use React hooks (useCivicAuth, useAuth, etc.) to access auth state\n * - The manager handles all underlying CivicAuth SDK interactions\n * - State updates are automatically propagated to all subscribed components\n *\n * This design pattern is particularly useful for:\n * - Large applications with many components needing auth state\n * - Avoiding provider wrapper hell in React component trees\n * - Ensuring consistent auth state across disconnected component hierarchies\n * - Server-side rendering scenarios where providers might be problematic\n */\n\nimport {\n CivicAuth,\n AuthenticationEvents,\n AuthEvent,\n} from \"../../vanillajs/index.js\";\nimport type {\n User,\n Session,\n CivicAuthClientConfig,\n} from \"../../vanillajs/index.js\";\nimport type { DisplayMode, FrameworkType } from \"../../types.js\";\nimport type { LoggingConfig } from \"@/vanillajs/auth/types/AuthTypes.js\";\n\n// Event payload interfaces\ninterface SignInErrorEvent {\n detail: string;\n}\n\nexport interface GlobalAuthConfig {\n clientId: string;\n redirectUrl?: string;\n config?: {\n oauthServer?: string;\n };\n displayMode?: DisplayMode;\n iframeMode?: \"modal\" | \"embedded\";\n nonce?: string;\n logoutRedirectUrl?: string;\n scopes?: string[];\n authProcessTimeout?: number;\n onSignIn?: (error?: Error) => void;\n onSignOut?: () => void;\n logging?: LoggingConfig;\n preloadIframe?: boolean;\n autoRedirect?: boolean;\n /** Framework being used (for analytics) - internal use only */\n framework?: FrameworkType;\n}\n\nexport type AuthStatus =\n | \"authenticated\"\n | \"unauthenticated\"\n | \"authenticating\"\n | \"error\"\n | \"signing_out\";\n\nexport interface GlobalAuthState {\n user: User | null;\n session: Session | null;\n isLoading: boolean;\n authStatus: AuthStatus;\n error: Error | null;\n displayMode?: DisplayMode;\n isPreloaded?: boolean;\n}\n\ntype StateListener = (state: GlobalAuthState) => void;\n\n/**\n * Global singleton that manages CivicAuth instance for React hooks\n * Eliminates the need for React providers\n */\nclass GlobalAuthManager {\n private static instance: GlobalAuthManager | null = null;\n private auth: CivicAuth | null = null;\n private events: AuthenticationEvents | null = null;\n private config: GlobalAuthConfig | null = null;\n private listeners = new Set<StateListener>();\n private callbacks: {\n onSignIn?: (error?: Error) => void;\n onSignOut?: () => void;\n } = {};\n private initializationPromise: Promise<void> | null = null;\n\n private state: GlobalAuthState = {\n user: null,\n session: null,\n isLoading: false,\n authStatus: \"unauthenticated\",\n error: null,\n displayMode: undefined,\n };\n\n private constructor() {\n // Private constructor for singleton\n }\n\n static getInstance(): GlobalAuthManager {\n if (!GlobalAuthManager.instance) {\n GlobalAuthManager.instance = new GlobalAuthManager();\n }\n return GlobalAuthManager.instance;\n }\n\n /**\n * Initialize auth with config (idempotent)\n * Returns the same promise for concurrent calls with same config\n */\n async initialize(config: GlobalAuthConfig): Promise<void> {\n // If we have a promise and same config, return existing promise\n if (\n this.initializationPromise &&\n this.config &&\n this.isSameConfig(config)\n ) {\n return this.initializationPromise;\n }\n\n // If different config, reset everything\n if (this.config && !this.isSameConfig(config)) {\n this.initializationPromise = null;\n await this.cleanup();\n }\n\n // Create new initialization promise if needed\n if (!this.initializationPromise) {\n this.initializationPromise = this._doInitialize(config);\n }\n\n return this.initializationPromise;\n }\n\n /**\n * Private method that does the actual initialization work\n */\n private async _doInitialize(config: GlobalAuthConfig): Promise<void> {\n this.config = config;\n this.callbacks = {\n onSignIn: config.onSignIn,\n onSignOut: config.onSignOut,\n };\n this.setState({ isLoading: true, error: null });\n\n try {\n this.events = new AuthenticationEvents();\n this.setupEventListeners();\n\n const authConfig: CivicAuthClientConfig = {\n clientId: config.clientId,\n oauthServerBaseUrl: config.config?.oauthServer,\n scopes: config.scopes || [\n \"openid\",\n \"profile\",\n \"email\",\n \"offline_access\",\n ],\n displayMode: config.displayMode || \"iframe\",\n iframeDisplayMode: config.iframeMode || \"modal\",\n nonce: config.nonce,\n authProcessTimeout: config.authProcessTimeout || 120000,\n preloadIframe: config.preloadIframe,\n autoRedirect: config.autoRedirect,\n events: this.events,\n logging: {\n enabled: true,\n level: \"debug\" as const,\n },\n framework: config.framework,\n };\n\n // Only add redirectUrl if provided\n if (config.redirectUrl) {\n authConfig.redirectUrl = config.redirectUrl;\n }\n\n // Only add logoutRedirectUrl if provided\n if (config.logoutRedirectUrl) {\n authConfig.logoutRedirectUrl = config.logoutRedirectUrl;\n }\n\n this.auth = await CivicAuth.create(authConfig);\n\n // Check initial auth state\n const isAuthenticated = await this.auth.isAuthenticated();\n if (isAuthenticated) {\n await this.refreshUserAndSession();\n this.setState({ authStatus: \"authenticated\" });\n } else {\n this.setState({ authStatus: \"unauthenticated\" });\n\n // Note: Preloading is now handled automatically by CivicAuth based on config.preloadIframe\n }\n\n this.setState({\n isLoading: false,\n displayMode: config.displayMode,\n });\n } catch (error) {\n // Reset promise on error so it can be retried\n this.initializationPromise = null;\n\n const authError =\n error instanceof Error\n ? error\n : new Error(\"Auth initialization failed\");\n this.setState({\n error: authError,\n authStatus: \"error\",\n isLoading: false,\n });\n throw authError;\n }\n }\n\n /**\n * Subscribe to state changes\n */\n subscribe(listener: StateListener): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n /**\n * Get current state\n */\n getState(): GlobalAuthState {\n return { ...this.state };\n }\n\n /**\n * Sign in\n */\n async signIn(): Promise<{ user: User }> {\n if (!this.auth) {\n throw new Error(\"Auth not initialized\");\n }\n\n const { user } = await this.auth.startAuthentication();\n await this.refreshUserAndSession();\n\n // Ensure we have a user to return\n if (!user) {\n throw new Error(\"Authentication succeeded but no user was returned\");\n }\n\n // Return the user object\n return { user };\n }\n\n /**\n * Sign out\n */\n async signOut(): Promise<void> {\n if (!this.auth) {\n throw new Error(\"Auth not initialized\");\n }\n\n await this.auth.logout();\n this.setState({\n user: null,\n session: null,\n authStatus: \"unauthenticated\",\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 return this.auth?.isAuthenticationPreloaded() ?? false;\n }\n\n /**\n * Enable or disable iframe preloading\n */\n setPreloadEnabled(enabled: boolean): void {\n if (!this.auth) {\n throw new Error(\"Auth not initialized\");\n }\n this.auth.setPreloadEnabled(enabled);\n }\n\n /**\n * Check if iframe preloading is enabled\n */\n getPreloadEnabled(): boolean {\n return this.auth?.getPreloadEnabled() ?? true;\n }\n\n /**\n * Check if config is the same (for idempotent initialization)\n */\n private isSameConfig(newConfig: GlobalAuthConfig): boolean {\n if (!this.config) return false;\n return (\n this.config.clientId === newConfig.clientId &&\n this.config.config?.oauthServer === newConfig.config?.oauthServer &&\n this.config.displayMode === newConfig.displayMode &&\n this.config.nonce === newConfig.nonce &&\n this.config.preloadIframe === newConfig.preloadIframe &&\n this.config.autoRedirect === newConfig.autoRedirect\n );\n }\n\n /**\n * Setup event listeners for auth state changes\n */\n private setupEventListeners(): void {\n if (!this.events) return;\n\n this.events.on(AuthEvent.SIGN_IN_STARTED, () => {\n this.setState({\n isLoading: true,\n authStatus: \"authenticating\",\n error: null,\n });\n });\n\n this.events.on(AuthEvent.SIGN_IN_COMPLETE, () => {\n this.setState({\n isLoading: false,\n authStatus: \"authenticated\",\n error: null,\n });\n this.refreshUserAndSession();\n this.callbacks.onSignIn?.();\n });\n\n this.events.on(AuthEvent.SIGN_IN_ERROR, (event?: SignInErrorEvent) => {\n const errorDetail = event?.detail || \"Authentication failed\";\n const authError = new Error(errorDetail);\n this.setState({\n isLoading: false,\n authStatus: \"error\",\n error: authError,\n });\n this.callbacks.onSignIn?.(authError);\n });\n\n this.events.on(AuthEvent.SIGN_OUT_STARTED, () => {\n this.setState({\n isLoading: true,\n authStatus: \"signing_out\",\n error: null,\n });\n });\n\n this.events.on(AuthEvent.SIGN_OUT_COMPLETE, () => {\n this.setState({\n isLoading: false,\n authStatus: \"unauthenticated\",\n user: null,\n session: null,\n error: null,\n });\n this.callbacks.onSignOut?.();\n });\n\n this.events.on(AuthEvent.USER_SESSION_CHANGED, () => {\n this.refreshUserAndSession();\n });\n }\n\n /**\n * Refresh user and session data\n */\n private async refreshUserAndSession(): Promise<void> {\n if (!this.auth) return;\n\n try {\n const [session, user] = await Promise.all([\n this.auth.getCurrentSession(),\n this.auth.getCurrentUser(),\n ]);\n\n this.setState({ session, user });\n } catch (error) {\n const sessionError =\n error instanceof Error ? error : new Error(\"Failed to get session\");\n this.setState({ error: sessionError });\n }\n }\n\n /**\n * Update state and notify listeners\n */\n private setState(updates: Partial<GlobalAuthState>): void {\n this.state = { ...this.state, ...updates };\n this.listeners.forEach((listener) => listener(this.state));\n }\n\n /**\n * Cleanup auth instance\n */\n private async cleanup(): Promise<void> {\n if (this.auth) {\n await this.auth.destroy();\n this.auth = null;\n }\n this.events = null;\n this.config = null;\n this.initializationPromise = null; // Reset promise for clean re-initialization\n }\n}\n\nexport { GlobalAuthManager };\n"]}
|
|
1
|
+
{"version":3,"file":"GlobalAuthManager.js","sourceRoot":"","sources":["../../../src/reactjs/core/GlobalAuthManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,SAAS,GACV,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AA+CvF;;;GAGG;AACH,MAAM,iBAAiB;IACb,MAAM,CAAC,QAAQ,GAA6B,IAAI,CAAC;IACjD,IAAI,GAAqB,IAAI,CAAC;IAC9B,MAAM,GAAgC,IAAI,CAAC;IAC3C,MAAM,GAA4B,IAAI,CAAC;IACvC,SAAS,GAAG,IAAI,GAAG,EAAiB,CAAC;IACrC,SAAS,GAGb,EAAE,CAAC;IACC,qBAAqB,GAAyB,IAAI,CAAC;IAEnD,KAAK,GAAoB;QAC/B,IAAI,EAAE,IAAI;QACV,OAAO,EA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EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACtE,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED;;OAEG;IACK,QAAQ,CAAC,OAAiC;QAChD,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,OAAO;QACnB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC,4CAA4C;IACjF,CAAC;;AAGH,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["/**\n * GlobalAuthManager - Singleton Authentication State Manager\n *\n * This module provides a global singleton that manages authentication state across a React application\n * without requiring React Context providers or prop drilling. It acts as a centralized authentication\n * manager that wraps the CivicAuth vanilla JavaScript library and provides a React-friendly interface.\n *\n * Key Features:\n * - Singleton pattern ensures single auth instance across the entire app\n * - Eliminates need for React Context providers and reduces bundle size\n * - Manages authentication state (user, session, loading, errors)\n * - Handles sign-in/sign-out flows with event-driven updates\n * - Provides idempotent initialization (safe to call multiple times)\n * - Supports multiple React hooks subscribing to the same auth state\n * - Automatic session refresh and user data synchronization\n *\n * Usage:\n * - Initialize once in your app with authentication configuration\n * - Use React hooks (useCivicAuth, useAuth, etc.) to access auth state\n * - The manager handles all underlying CivicAuth SDK interactions\n * - State updates are automatically propagated to all subscribed components\n *\n * This design pattern is particularly useful for:\n * - Large applications with many components needing auth state\n * - Avoiding provider wrapper hell in React component trees\n * - Ensuring consistent auth state across disconnected component hierarchies\n * - Server-side rendering scenarios where providers might be problematic\n */\n\nimport {\n CivicAuth,\n AuthenticationEvents,\n AuthEvent,\n} from \"../../vanillajs/index.js\";\nimport type {\n User,\n Session,\n CivicAuthClientConfig,\n} from \"../../vanillajs/index.js\";\nimport type { DisplayMode, FrameworkType } from \"../../types.js\";\nimport type { LoggingConfig } from \"@/vanillajs/auth/types/AuthTypes.js\";\nimport { DEFAULT_AUTH_PROCESS_TIMEOUT } from \"../../vanillajs/auth/types/AuthTypes.js\";\n\n// Event payload interfaces\ninterface SignInErrorEvent {\n detail: string;\n}\n\nexport interface GlobalAuthConfig {\n clientId: string;\n redirectUrl?: string;\n config?: {\n oauthServer?: string;\n };\n displayMode?: DisplayMode;\n iframeMode?: \"modal\" | \"embedded\";\n nonce?: string;\n logoutRedirectUrl?: string;\n scopes?: string[];\n authProcessTimeout?: number;\n onSignIn?: (error?: Error) => void;\n onSignOut?: () => void;\n logging?: LoggingConfig;\n preloadIframe?: boolean;\n autoRedirect?: boolean;\n /** Framework being used (for analytics) - internal use only */\n framework?: FrameworkType;\n}\n\nexport type AuthStatus =\n | \"authenticated\"\n | \"unauthenticated\"\n | \"authenticating\"\n | \"error\"\n | \"signing_out\";\n\nexport interface GlobalAuthState {\n user: User | null;\n session: Session | null;\n isLoading: boolean;\n authStatus: AuthStatus;\n error: Error | null;\n displayMode?: DisplayMode;\n isPreloaded?: boolean;\n}\n\ntype StateListener = (state: GlobalAuthState) => void;\n\n/**\n * Global singleton that manages CivicAuth instance for React hooks\n * Eliminates the need for React providers\n */\nclass GlobalAuthManager {\n private static instance: GlobalAuthManager | null = null;\n private auth: CivicAuth | null = null;\n private events: AuthenticationEvents | null = null;\n private config: GlobalAuthConfig | null = null;\n private listeners = new Set<StateListener>();\n private callbacks: {\n onSignIn?: (error?: Error) => void;\n onSignOut?: () => void;\n } = {};\n private initializationPromise: Promise<void> | null = null;\n\n private state: GlobalAuthState = {\n user: null,\n session: null,\n isLoading: false,\n authStatus: \"unauthenticated\",\n error: null,\n displayMode: undefined,\n };\n\n private constructor() {\n // Private constructor for singleton\n }\n\n static getInstance(): GlobalAuthManager {\n if (!GlobalAuthManager.instance) {\n GlobalAuthManager.instance = new GlobalAuthManager();\n }\n return GlobalAuthManager.instance;\n }\n\n /**\n * Initialize auth with config (idempotent)\n * Returns the same promise for concurrent calls with same config\n */\n async initialize(config: GlobalAuthConfig): Promise<void> {\n // If we have a promise and same config, return existing promise\n if (\n this.initializationPromise &&\n this.config &&\n this.isSameConfig(config)\n ) {\n return this.initializationPromise;\n }\n\n // If different config, reset everything\n if (this.config && !this.isSameConfig(config)) {\n this.initializationPromise = null;\n await this.cleanup();\n }\n\n // Create new initialization promise if needed\n if (!this.initializationPromise) {\n this.initializationPromise = this._doInitialize(config);\n }\n\n return this.initializationPromise;\n }\n\n /**\n * Private method that does the actual initialization work\n */\n private async _doInitialize(config: GlobalAuthConfig): Promise<void> {\n this.config = config;\n this.callbacks = {\n onSignIn: config.onSignIn,\n onSignOut: config.onSignOut,\n };\n this.setState({ isLoading: true, error: null });\n\n try {\n this.events = new AuthenticationEvents();\n this.setupEventListeners();\n\n const authConfig: CivicAuthClientConfig = {\n clientId: config.clientId,\n oauthServerBaseUrl: config.config?.oauthServer,\n scopes: config.scopes || [\n \"openid\",\n \"profile\",\n \"email\",\n \"offline_access\",\n ],\n displayMode: config.displayMode || \"iframe\",\n iframeDisplayMode: config.iframeMode || \"modal\",\n nonce: config.nonce,\n authProcessTimeout:\n config.authProcessTimeout || DEFAULT_AUTH_PROCESS_TIMEOUT,\n preloadIframe: config.preloadIframe,\n autoRedirect: config.autoRedirect,\n events: this.events,\n logging: {\n enabled: true,\n level: \"debug\" as const,\n },\n framework: config.framework,\n };\n\n // Only add redirectUrl if provided\n if (config.redirectUrl) {\n authConfig.redirectUrl = config.redirectUrl;\n }\n\n // Only add logoutRedirectUrl if provided\n if (config.logoutRedirectUrl) {\n authConfig.logoutRedirectUrl = config.logoutRedirectUrl;\n }\n\n this.auth = await CivicAuth.create(authConfig);\n\n // Check initial auth state\n const isAuthenticated = await this.auth.isAuthenticated();\n if (isAuthenticated) {\n await this.refreshUserAndSession();\n this.setState({ authStatus: \"authenticated\" });\n } else {\n this.setState({ authStatus: \"unauthenticated\" });\n\n // Note: Preloading is now handled automatically by CivicAuth based on config.preloadIframe\n }\n\n this.setState({\n isLoading: false,\n displayMode: config.displayMode,\n });\n } catch (error) {\n // Reset promise on error so it can be retried\n this.initializationPromise = null;\n\n const authError =\n error instanceof Error\n ? error\n : new Error(\"Auth initialization failed\");\n this.setState({\n error: authError,\n authStatus: \"error\",\n isLoading: false,\n });\n throw authError;\n }\n }\n\n /**\n * Subscribe to state changes\n */\n subscribe(listener: StateListener): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n /**\n * Get current state\n */\n getState(): GlobalAuthState {\n return { ...this.state };\n }\n\n /**\n * Sign in\n */\n async signIn(): Promise<{ user: User }> {\n if (!this.auth) {\n throw new Error(\"Auth not initialized\");\n }\n\n const { user } = await this.auth.startAuthentication();\n await this.refreshUserAndSession();\n\n // Ensure we have a user to return\n if (!user) {\n throw new Error(\"Authentication succeeded but no user was returned\");\n }\n\n // Return the user object\n return { user };\n }\n\n /**\n * Sign out\n */\n async signOut(): Promise<void> {\n if (!this.auth) {\n throw new Error(\"Auth not initialized\");\n }\n\n await this.auth.logout();\n this.setState({\n user: null,\n session: null,\n authStatus: \"unauthenticated\",\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 return this.auth?.isAuthenticationPreloaded() ?? false;\n }\n\n /**\n * Enable or disable iframe preloading\n */\n setPreloadEnabled(enabled: boolean): void {\n if (!this.auth) {\n throw new Error(\"Auth not initialized\");\n }\n this.auth.setPreloadEnabled(enabled);\n }\n\n /**\n * Check if iframe preloading is enabled\n */\n getPreloadEnabled(): boolean {\n return this.auth?.getPreloadEnabled() ?? true;\n }\n\n /**\n * Check if config is the same (for idempotent initialization)\n */\n private isSameConfig(newConfig: GlobalAuthConfig): boolean {\n if (!this.config) return false;\n return (\n this.config.clientId === newConfig.clientId &&\n this.config.config?.oauthServer === newConfig.config?.oauthServer &&\n this.config.displayMode === newConfig.displayMode &&\n this.config.nonce === newConfig.nonce &&\n this.config.preloadIframe === newConfig.preloadIframe &&\n this.config.autoRedirect === newConfig.autoRedirect\n );\n }\n\n /**\n * Setup event listeners for auth state changes\n */\n private setupEventListeners(): void {\n if (!this.events) return;\n\n this.events.on(AuthEvent.SIGN_IN_STARTED, () => {\n this.setState({\n isLoading: true,\n authStatus: \"authenticating\",\n error: null,\n });\n });\n\n this.events.on(AuthEvent.SIGN_IN_COMPLETE, () => {\n this.setState({\n isLoading: false,\n authStatus: \"authenticated\",\n error: null,\n });\n this.refreshUserAndSession();\n this.callbacks.onSignIn?.();\n });\n\n this.events.on(AuthEvent.SIGN_IN_ERROR, (event?: SignInErrorEvent) => {\n const errorDetail = event?.detail || \"Authentication failed\";\n const authError = new Error(errorDetail);\n this.setState({\n isLoading: false,\n authStatus: \"error\",\n error: authError,\n });\n this.callbacks.onSignIn?.(authError);\n });\n\n this.events.on(AuthEvent.SIGN_OUT_STARTED, () => {\n this.setState({\n isLoading: true,\n authStatus: \"signing_out\",\n error: null,\n });\n });\n\n this.events.on(AuthEvent.SIGN_OUT_COMPLETE, () => {\n this.setState({\n isLoading: false,\n authStatus: \"unauthenticated\",\n user: null,\n session: null,\n error: null,\n });\n this.callbacks.onSignOut?.();\n });\n\n this.events.on(AuthEvent.USER_SESSION_CHANGED, () => {\n this.refreshUserAndSession();\n });\n }\n\n /**\n * Refresh user and session data\n */\n private async refreshUserAndSession(): Promise<void> {\n if (!this.auth) return;\n\n try {\n const [session, user] = await Promise.all([\n this.auth.getCurrentSession(),\n this.auth.getCurrentUser(),\n ]);\n\n this.setState({ session, user });\n } catch (error) {\n const sessionError =\n error instanceof Error ? error : new Error(\"Failed to get session\");\n this.setState({ error: sessionError });\n }\n }\n\n /**\n * Update state and notify listeners\n */\n private setState(updates: Partial<GlobalAuthState>): void {\n this.state = { ...this.state, ...updates };\n this.listeners.forEach((listener) => listener(this.state));\n }\n\n /**\n * Cleanup auth instance\n */\n private async cleanup(): Promise<void> {\n if (this.auth) {\n await this.auth.destroy();\n this.auth = null;\n }\n this.events = null;\n this.config = null;\n this.initializationPromise = null; // Reset promise for clean re-initialization\n }\n}\n\nexport { GlobalAuthManager };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CivicAuthContext.d.ts","sourceRoot":"","sources":["../../../src/reactjs/providers/CivicAuthContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EACL,SAAS,EAET,KAAK,OAAO,EACZ,KAAK,IAAI,EACV,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"CivicAuthContext.d.ts","sourceRoot":"","sources":["../../../src/reactjs/providers/CivicAuthContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EACL,SAAS,EAET,KAAK,OAAO,EACZ,KAAK,IAAI,EACV,MAAM,0BAA0B,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AC;IACzC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAC7C,6BAA6B,CA+W9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,oBAQtC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -4,8 +4,9 @@ import React, { createContext, useContext, useEffect, useState, useCallback, use
|
|
|
4
4
|
import { CivicAuth, AuthEvent, } from "../../vanillajs/index.js";
|
|
5
5
|
import { AuthenticationEvents } from "../../vanillajs/auth/AuthenticationEvents.js";
|
|
6
6
|
import { extractTokensFromSession } from "../../vanillajs/utils/auth-utils.js";
|
|
7
|
+
import { DEFAULT_AUTH_PROCESS_TIMEOUT } from "../../vanillajs/auth/types/AuthTypes.js";
|
|
7
8
|
const CivicAuthContext = createContext(null);
|
|
8
|
-
export const CivicAuthContextProvider = ({ children, clientId, redirectUrl, oauthServerBaseUrl = "https://auth.civic.com/oauth/", scopes = ["openid", "profile", "email", "offline_access"], displayMode = "iframe", iframeDisplayMode = "modal", onSignIn, onSignOut, nonce, authProcessTimeout =
|
|
9
|
+
export const CivicAuthContextProvider = ({ children, clientId, redirectUrl, oauthServerBaseUrl = "https://auth.civic.com/oauth/", scopes = ["openid", "profile", "email", "offline_access"], displayMode = "iframe", iframeDisplayMode = "modal", onSignIn, onSignOut, nonce, authProcessTimeout = DEFAULT_AUTH_PROCESS_TIMEOUT, preloadIframe, }) => {
|
|
9
10
|
const [auth, setAuth] = useState(null);
|
|
10
11
|
const [user, setUser] = useState(null);
|
|
11
12
|
const [session, setSession] = useState(null);
|
|
@@ -1 +1 @@
|
|
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yB;QACzB,iBAAiB;QACjB,iBAAiB;QACjB,WAAW;KACZ,CACF,CAAC;IAEF,OAAO,CACL,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC3C,QAAQ,GACiB,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAyB,EAAE;IAC5D,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n useContext,\n useEffect,\n useState,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CivicAuth,\n AuthEvent,\n type Session,\n type User,\n} from \"../../vanillajs/index.js\";\nimport { AuthenticationEvents } from \"../../vanillajs/auth/AuthenticationEvents.js\";\nimport type { DisplayMode, ForwardedTokens } from \"../../types.js\";\nimport { extractTokensFromSession } from \"../../vanillajs/utils/auth-utils.js\";\n\n// Event payload interfaces\ninterface SignInErrorEvent {\n detail: string;\n}\n\nexport type AuthStatusEnum =\n | \"authenticated\"\n | \"unauthenticated\"\n | \"authenticating\"\n | \"error\"\n | \"signing_out\";\n\nexport interface CivicAuthContextType {\n // Core auth instance\n auth: CivicAuth | null;\n\n // User and session state\n user: User | null;\n session: Session | null;\n\n // Auth state\n isLoading: boolean;\n authStatus: AuthStatusEnum;\n error: Error | null;\n\n // Tokens\n idToken?: string;\n accessToken?: string;\n refreshToken?: string;\n forwardedTokens?: ForwardedTokens;\n\n // Auth methods\n signIn: () => Promise<{ user: User }>;\n signOut: () => Promise<void>;\n\n // Preloading methods\n isAuthenticationPreloaded: () => boolean;\n setPreloadEnabled: (enabled: boolean) => void;\n getPreloadEnabled: () => boolean;\n\n // Config\n displayMode?: DisplayMode;\n}\n\nconst CivicAuthContext = createContext<CivicAuthContextType | null>(null);\n\nexport interface CivicAuthContextProviderProps {\n children: ReactNode;\n clientId: string;\n redirectUrl?: string;\n oauthServerBaseUrl?: string;\n scopes?: string[];\n displayMode?: DisplayMode;\n iframeDisplayMode?: \"modal\" | \"embedded\";\n onSignIn?: (error?: Error) => void;\n onSignOut?: () => void;\n nonce?: string;\n authProcessTimeout?: number;\n preloadIframe?: boolean;\n}\n\nexport const CivicAuthContextProvider: React.FC<\n CivicAuthContextProviderProps\n> = ({\n children,\n clientId,\n redirectUrl,\n oauthServerBaseUrl = \"https://auth.civic.com/oauth/\",\n scopes = [\"openid\", \"profile\", \"email\", \"offline_access\"],\n displayMode = \"iframe\",\n iframeDisplayMode = \"modal\",\n onSignIn,\n onSignOut,\n nonce,\n authProcessTimeout = 120000,\n preloadIframe,\n}) => {\n const [auth, setAuth] = useState<CivicAuth | null>(null);\n const [user, setUser] = useState<User | null>(null);\n const [session, setSession] = useState<Session | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [authStatus, setAuthStatus] =\n useState<AuthStatusEnum>(\"unauthenticated\");\n const [error, setError] = useState<Error | null>(null);\n\n // Track initialization to prevent double-execution in React StrictMode\n const initializationRef = useRef<{\n isInitializing: boolean;\n isInitialized: boolean;\n }>({\n isInitializing: false,\n isInitialized: false,\n });\n\n useEffect(() => {\n let isMounted = true;\n\n // Prevent double initialization in React StrictMode\n if (\n initializationRef.current.isInitializing ||\n initializationRef.current.isInitialized\n ) {\n // `[CivicAuthContext] Skipping initialization ${initId} - already initializing/initialized`,\n\n return;\n }\n\n // Capture ref value at effect setup time for cleanup\n const initializationState = initializationRef.current;\n\n initializationRef.current.isInitializing = true;\n\n const refreshUserAndSession = async () => {\n if (!auth) return;\n\n try {\n const currentSession = await auth.getCurrentSession();\n const currentUser = await auth.getCurrentUser();\n\n if (isMounted) {\n setSession(currentSession);\n setUser(currentUser);\n }\n } catch (err) {\n if (isMounted) {\n const sessionError =\n err instanceof Error ? err : new Error(\"Failed to get session\");\n setError(sessionError);\n }\n }\n };\n\n const initializeAuth = async () => {\n try {\n const events = new AuthenticationEvents();\n\n // Set up event listeners\n events.on(AuthEvent.SIGN_IN_STARTED, () => {\n if (isMounted) {\n setIsLoading(true);\n setAuthStatus(\"authenticating\");\n setError(null);\n }\n });\n\n events.on(AuthEvent.SIGN_IN_COMPLETE, () => {\n if (isMounted) {\n setIsLoading(false);\n setAuthStatus(\"authenticated\");\n setError(null);\n onSignIn?.();\n }\n });\n\n events.on(AuthEvent.SIGN_IN_ERROR, (event?: SignInErrorEvent) => {\n if (isMounted) {\n setIsLoading(false);\n setAuthStatus(\"error\");\n const errorDetail = event?.detail || \"Authentication failed\";\n const authError = new Error(errorDetail);\n setError(authError);\n onSignIn?.(authError);\n }\n });\n\n events.on(AuthEvent.SIGN_OUT_STARTED, () => {\n if (isMounted) {\n setIsLoading(true);\n setAuthStatus(\"signing_out\");\n setError(null);\n }\n });\n\n events.on(AuthEvent.SIGN_OUT_COMPLETE, () => {\n if (isMounted) {\n setIsLoading(false);\n setAuthStatus(\"unauthenticated\");\n setUser(null);\n setSession(null);\n setError(null);\n onSignOut?.();\n }\n });\n\n events.on(AuthEvent.USER_SESSION_CHANGED, () => {\n if (isMounted) {\n refreshUserAndSession();\n }\n });\n\n const authInstance = await CivicAuth.create({\n clientId,\n redirectUrl:\n redirectUrl ||\n `${window.location.origin}${window.location.pathname}`,\n oauthServerBaseUrl,\n scopes,\n displayMode,\n iframeDisplayMode,\n nonce,\n authProcessTimeout,\n preloadIframe,\n events,\n });\n\n if (isMounted) {\n setAuth(authInstance);\n\n // Mark initialization as complete\n initializationRef.current.isInitializing = false;\n initializationRef.current.isInitialized = true;\n\n // Check initial auth state\n const isAuthenticated = await authInstance.isAuthenticated();\n if (isAuthenticated) {\n setAuthStatus(\"authenticated\");\n await refreshUserAndSession();\n } else {\n setAuthStatus(\"unauthenticated\");\n\n // Note: Preloading is now handled automatically by CivicAuth based on config.preloadIframe\n }\n\n // Mark initialization as complete\n setIsLoading(false);\n }\n } catch (err) {\n console.error(err);\n if (isMounted) {\n const initError =\n err instanceof Error ? err : new Error(\"Failed to initialize auth\");\n setError(initError);\n setAuthStatus(\"error\");\n setIsLoading(false); // Stop loading even on error\n\n // Mark initialization as failed\n initializationRef.current.isInitializing = false;\n // Don't mark as initialized on error so it can be retried\n }\n }\n };\n\n initializeAuth();\n\n return () => {\n isMounted = false;\n\n // Reset initialization guards to allow remount to reinitialize\n // This is necessary for React StrictMode compatibility\n if (initializationState.isInitializing) {\n initializationState.isInitializing = false;\n initializationState.isInitialized = false;\n }\n\n if (auth) {\n auth.destroy();\n }\n };\n // Refresh user and session when auth instance changes\n /*\n * Intentionally omitting dependencies to prevent infinite loops.\n * Adding auth, onSignIn, onSignOut, and scopes to the dependency array would cause\n * the effect to re-run whenever these values change, which could lead to unnecessary\n * re-renders and potential infinite loops since the effect updates state that might\n * trigger re-renders of parent components.\n *\n * IMPORTANT: redirectUrl is intentionally omitted to prevent re-initialization\n * during OAuth callback when URL parameters change, which would cause\n * \"invalid_grant\" errors due to authorization code reuse.\n */\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n clientId,\n oauthServerBaseUrl,\n displayMode,\n iframeDisplayMode,\n nonce,\n authProcessTimeout,\n preloadIframe,\n ]);\n\n // This is on load to get the user and session\n useEffect(() => {\n if (auth && authStatus === \"authenticated\") {\n const refreshUserAndSession = async () => {\n try {\n const currentSession = await auth.getCurrentSession();\n const currentUser = await auth.getCurrentUser();\n setSession(currentSession);\n setUser(currentUser);\n } catch (err) {\n const sessionError =\n err instanceof Error ? err : new Error(\"Failed to get session\");\n setError(sessionError);\n }\n };\n\n refreshUserAndSession();\n }\n }, [auth, authStatus]);\n\n const signIn = useCallback(async () => {\n if (!auth) {\n // If auth is still loading, provide a more helpful error\n if (isLoading) {\n throw new Error(\"Authentication is still initializing, please wait...\");\n }\n throw new Error(\"Auth not initialized\");\n }\n\n try {\n const { user } = await auth.startAuthentication();\n\n // Refresh user and session after successful authentication\n const currentSession = await auth.getCurrentSession();\n\n setSession(currentSession);\n setUser(user ?? null);\n\n // Ensure we have a user to return\n if (!user) {\n throw new Error(\"Authentication succeeded but no user was returned\");\n }\n\n // Return the user object\n return { user };\n } catch (err) {\n const signInError =\n err instanceof Error ? err : new Error(\"Sign in failed\");\n setError(signInError);\n throw signInError;\n }\n }, [auth, isLoading]);\n\n const signOut = useCallback(async () => {\n if (!auth) {\n // If auth is still loading, provide a more helpful error\n if (isLoading) {\n throw new Error(\"Authentication is still initializing, please wait...\");\n }\n throw new Error(\"Auth not initialized\");\n }\n\n try {\n await auth.logout();\n setUser(null);\n setSession(null);\n } catch (err) {\n const signOutError =\n err instanceof Error ? err : new Error(\"Sign out failed\");\n setError(signOutError);\n throw signOutError;\n }\n }, [auth, isLoading]);\n\n const isAuthenticationPreloaded = useCallback(() => {\n return auth?.isAuthenticationPreloaded() ?? false;\n }, [auth]);\n\n const setPreloadEnabled = useCallback(\n (enabled: boolean) => {\n if (!auth) {\n throw new Error(\"Auth not initialized\");\n }\n auth.setPreloadEnabled(enabled);\n },\n [auth],\n );\n\n const getPreloadEnabled = useCallback(() => {\n return auth?.getPreloadEnabled() ?? true;\n }, [auth]);\n\n // Extract tokens from session\n const idToken = session?.idToken;\n const accessToken = session?.accessToken;\n const refreshToken = session?.refreshToken;\n\n // Extract forwardedTokens from session's ID token\n const forwardedTokens = useMemo(() => {\n if (!session) return undefined;\n const tokens = extractTokensFromSession(session);\n return tokens.forwardedTokens;\n }, [session]);\n\n const contextValue: CivicAuthContextType = useMemo(\n () => ({\n auth,\n user,\n session,\n isLoading,\n authStatus,\n error,\n idToken,\n accessToken,\n refreshToken,\n forwardedTokens,\n signIn,\n signOut,\n isAuthenticationPreloaded,\n setPreloadEnabled,\n getPreloadEnabled,\n displayMode,\n }),\n [\n auth,\n user,\n session,\n isLoading,\n authStatus,\n error,\n idToken,\n accessToken,\n refreshToken,\n forwardedTokens,\n signIn,\n signOut,\n isAuthenticationPreloaded,\n setPreloadEnabled,\n getPreloadEnabled,\n displayMode,\n ],\n );\n\n return (\n <CivicAuthContext.Provider value={contextValue}>\n {children}\n </CivicAuthContext.Provider>\n );\n};\n\nexport const useCivicAuthContext = (): CivicAuthContextType => {\n const context = useContext(CivicAuthContext);\n if (!context) {\n throw new Error(\n \"useCivicAuthContext must be used within a CivicAuthContextProvider\",\n );\n }\n return context;\n};\n\nexport { CivicAuthContext };\n"]}
|
|
1
|
+
{"version":3,"file":"CivicAuthContext.js","sourceRoot":"","sources":["../../../src/reactjs/providers/CivicAuthContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,UAAU,EACV,SAAS,EACT,QAAQ,EACR,WAAW,EACX,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,SAAS,EACT,SAAS,GAGV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAEpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AA8CvF,MAAM,gBAAgB,GAAG,aAAa,CAA8B,IAAI,CAAC,CAAC;AAiB1E,MAAM,CAAC,MAAM,wBAAwB,GAEjC,CAAC,EACH,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,kBAAkB,GAAG,+BAA+B,EACpD,MAAM,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,CAAC,EACzD,WAAW,GAAG,QAAQ,EACtB,iBAAiB,GAAG,OAAO,EAC3B,QAAQ,EACR,SAAS,EACT,KAAK,EACL,kBAAkB,GAAG,4BAA4B,EACjD,aAAa,GACd,EAAE,EAAE;IACH,MAAM,CAAC,IAAI,EAAE,OA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,MAAM,YAAY,GAAyB,OAAO,CAChD,GAAG,EAAE,CAAC,CAAC;QACL,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,SAAS;QACT,UAAU;QACV,KAAK;QACL,OAAO;QACP,WAAW;QACX,YAAY;QACZ,eAAe;QACf,MAAM;QACN,OAAO;QACP,yBAAyB;QACzB,iBAAiB;QACjB,iBAAiB;QACjB,WAAW;KACZ,CAAC,EACF;QACE,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,SAAS;QACT,UAAU;QACV,KAAK;QACL,OAAO;QACP,WAAW;QACX,YAAY;QACZ,eAAe;QACf,MAAM;QACN,OAAO;QACP,yBAAyB;QACzB,iBAAiB;QACjB,iBAAiB;QACjB,WAAW;KACZ,CACF,CAAC;IAEF,OAAO,CACL,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC3C,QAAQ,GACiB,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAyB,EAAE;IAC5D,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["\"use client\";\nimport React, {\n createContext,\n useContext,\n useEffect,\n useState,\n useCallback,\n useMemo,\n useRef,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CivicAuth,\n AuthEvent,\n type Session,\n type User,\n} from \"../../vanillajs/index.js\";\nimport { AuthenticationEvents } from \"../../vanillajs/auth/AuthenticationEvents.js\";\nimport type { DisplayMode, ForwardedTokens } from \"../../types.js\";\nimport { extractTokensFromSession } from \"../../vanillajs/utils/auth-utils.js\";\nimport { DEFAULT_AUTH_PROCESS_TIMEOUT } from \"../../vanillajs/auth/types/AuthTypes.js\";\n\n// Event payload interfaces\ninterface SignInErrorEvent {\n detail: string;\n}\n\nexport type AuthStatusEnum =\n | \"authenticated\"\n | \"unauthenticated\"\n | \"authenticating\"\n | \"error\"\n | \"signing_out\";\n\nexport interface CivicAuthContextType {\n // Core auth instance\n auth: CivicAuth | null;\n\n // User and session state\n user: User | null;\n session: Session | null;\n\n // Auth state\n isLoading: boolean;\n authStatus: AuthStatusEnum;\n error: Error | null;\n\n // Tokens\n idToken?: string;\n accessToken?: string;\n refreshToken?: string;\n forwardedTokens?: ForwardedTokens;\n\n // Auth methods\n signIn: () => Promise<{ user: User }>;\n signOut: () => Promise<void>;\n\n // Preloading methods\n isAuthenticationPreloaded: () => boolean;\n setPreloadEnabled: (enabled: boolean) => void;\n getPreloadEnabled: () => boolean;\n\n // Config\n displayMode?: DisplayMode;\n}\n\nconst CivicAuthContext = createContext<CivicAuthContextType | null>(null);\n\nexport interface CivicAuthContextProviderProps {\n children: ReactNode;\n clientId: string;\n redirectUrl?: string;\n oauthServerBaseUrl?: string;\n scopes?: string[];\n displayMode?: DisplayMode;\n iframeDisplayMode?: \"modal\" | \"embedded\";\n onSignIn?: (error?: Error) => void;\n onSignOut?: () => void;\n nonce?: string;\n authProcessTimeout?: number;\n preloadIframe?: boolean;\n}\n\nexport const CivicAuthContextProvider: React.FC<\n CivicAuthContextProviderProps\n> = ({\n children,\n clientId,\n redirectUrl,\n oauthServerBaseUrl = \"https://auth.civic.com/oauth/\",\n scopes = [\"openid\", \"profile\", \"email\", \"offline_access\"],\n displayMode = \"iframe\",\n iframeDisplayMode = \"modal\",\n onSignIn,\n onSignOut,\n nonce,\n authProcessTimeout = DEFAULT_AUTH_PROCESS_TIMEOUT,\n preloadIframe,\n}) => {\n const [auth, setAuth] = useState<CivicAuth | null>(null);\n const [user, setUser] = useState<User | null>(null);\n const [session, setSession] = useState<Session | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [authStatus, setAuthStatus] =\n useState<AuthStatusEnum>(\"unauthenticated\");\n const [error, setError] = useState<Error | null>(null);\n\n // Track initialization to prevent double-execution in React StrictMode\n const initializationRef = useRef<{\n isInitializing: boolean;\n isInitialized: boolean;\n }>({\n isInitializing: false,\n isInitialized: false,\n });\n\n useEffect(() => {\n let isMounted = true;\n\n // Prevent double initialization in React StrictMode\n if (\n initializationRef.current.isInitializing ||\n initializationRef.current.isInitialized\n ) {\n // `[CivicAuthContext] Skipping initialization ${initId} - already initializing/initialized`,\n\n return;\n }\n\n // Capture ref value at effect setup time for cleanup\n const initializationState = initializationRef.current;\n\n initializationRef.current.isInitializing = true;\n\n const refreshUserAndSession = async () => {\n if (!auth) return;\n\n try {\n const currentSession = await auth.getCurrentSession();\n const currentUser = await auth.getCurrentUser();\n\n if (isMounted) {\n setSession(currentSession);\n setUser(currentUser);\n }\n } catch (err) {\n if (isMounted) {\n const sessionError =\n err instanceof Error ? err : new Error(\"Failed to get session\");\n setError(sessionError);\n }\n }\n };\n\n const initializeAuth = async () => {\n try {\n const events = new AuthenticationEvents();\n\n // Set up event listeners\n events.on(AuthEvent.SIGN_IN_STARTED, () => {\n if (isMounted) {\n setIsLoading(true);\n setAuthStatus(\"authenticating\");\n setError(null);\n }\n });\n\n events.on(AuthEvent.SIGN_IN_COMPLETE, () => {\n if (isMounted) {\n setIsLoading(false);\n setAuthStatus(\"authenticated\");\n setError(null);\n onSignIn?.();\n }\n });\n\n events.on(AuthEvent.SIGN_IN_ERROR, (event?: SignInErrorEvent) => {\n if (isMounted) {\n setIsLoading(false);\n setAuthStatus(\"error\");\n const errorDetail = event?.detail || \"Authentication failed\";\n const authError = new Error(errorDetail);\n setError(authError);\n onSignIn?.(authError);\n }\n });\n\n events.on(AuthEvent.SIGN_OUT_STARTED, () => {\n if (isMounted) {\n setIsLoading(true);\n setAuthStatus(\"signing_out\");\n setError(null);\n }\n });\n\n events.on(AuthEvent.SIGN_OUT_COMPLETE, () => {\n if (isMounted) {\n setIsLoading(false);\n setAuthStatus(\"unauthenticated\");\n setUser(null);\n setSession(null);\n setError(null);\n onSignOut?.();\n }\n });\n\n events.on(AuthEvent.USER_SESSION_CHANGED, () => {\n if (isMounted) {\n refreshUserAndSession();\n }\n });\n\n const authInstance = await CivicAuth.create({\n clientId,\n redirectUrl:\n redirectUrl ||\n `${window.location.origin}${window.location.pathname}`,\n oauthServerBaseUrl,\n scopes,\n displayMode,\n iframeDisplayMode,\n nonce,\n authProcessTimeout,\n preloadIframe,\n events,\n });\n\n if (isMounted) {\n setAuth(authInstance);\n\n // Mark initialization as complete\n initializationRef.current.isInitializing = false;\n initializationRef.current.isInitialized = true;\n\n // Check initial auth state\n const isAuthenticated = await authInstance.isAuthenticated();\n if (isAuthenticated) {\n setAuthStatus(\"authenticated\");\n await refreshUserAndSession();\n } else {\n setAuthStatus(\"unauthenticated\");\n\n // Note: Preloading is now handled automatically by CivicAuth based on config.preloadIframe\n }\n\n // Mark initialization as complete\n setIsLoading(false);\n }\n } catch (err) {\n console.error(err);\n if (isMounted) {\n const initError =\n err instanceof Error ? err : new Error(\"Failed to initialize auth\");\n setError(initError);\n setAuthStatus(\"error\");\n setIsLoading(false); // Stop loading even on error\n\n // Mark initialization as failed\n initializationRef.current.isInitializing = false;\n // Don't mark as initialized on error so it can be retried\n }\n }\n };\n\n initializeAuth();\n\n return () => {\n isMounted = false;\n\n // Reset initialization guards to allow remount to reinitialize\n // This is necessary for React StrictMode compatibility\n if (initializationState.isInitializing) {\n initializationState.isInitializing = false;\n initializationState.isInitialized = false;\n }\n\n if (auth) {\n auth.destroy();\n }\n };\n // Refresh user and session when auth instance changes\n /*\n * Intentionally omitting dependencies to prevent infinite loops.\n * Adding auth, onSignIn, onSignOut, and scopes to the dependency array would cause\n * the effect to re-run whenever these values change, which could lead to unnecessary\n * re-renders and potential infinite loops since the effect updates state that might\n * trigger re-renders of parent components.\n *\n * IMPORTANT: redirectUrl is intentionally omitted to prevent re-initialization\n * during OAuth callback when URL parameters change, which would cause\n * \"invalid_grant\" errors due to authorization code reuse.\n */\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n clientId,\n oauthServerBaseUrl,\n displayMode,\n iframeDisplayMode,\n nonce,\n authProcessTimeout,\n preloadIframe,\n ]);\n\n // This is on load to get the user and session\n useEffect(() => {\n if (auth && authStatus === \"authenticated\") {\n const refreshUserAndSession = async () => {\n try {\n const currentSession = await auth.getCurrentSession();\n const currentUser = await auth.getCurrentUser();\n setSession(currentSession);\n setUser(currentUser);\n } catch (err) {\n const sessionError =\n err instanceof Error ? err : new Error(\"Failed to get session\");\n setError(sessionError);\n }\n };\n\n refreshUserAndSession();\n }\n }, [auth, authStatus]);\n\n const signIn = useCallback(async () => {\n if (!auth) {\n // If auth is still loading, provide a more helpful error\n if (isLoading) {\n throw new Error(\"Authentication is still initializing, please wait...\");\n }\n throw new Error(\"Auth not initialized\");\n }\n\n try {\n const { user } = await auth.startAuthentication();\n\n // Refresh user and session after successful authentication\n const currentSession = await auth.getCurrentSession();\n\n setSession(currentSession);\n setUser(user ?? null);\n\n // Ensure we have a user to return\n if (!user) {\n throw new Error(\"Authentication succeeded but no user was returned\");\n }\n\n // Return the user object\n return { user };\n } catch (err) {\n const signInError =\n err instanceof Error ? err : new Error(\"Sign in failed\");\n setError(signInError);\n throw signInError;\n }\n }, [auth, isLoading]);\n\n const signOut = useCallback(async () => {\n if (!auth) {\n // If auth is still loading, provide a more helpful error\n if (isLoading) {\n throw new Error(\"Authentication is still initializing, please wait...\");\n }\n throw new Error(\"Auth not initialized\");\n }\n\n try {\n await auth.logout();\n setUser(null);\n setSession(null);\n } catch (err) {\n const signOutError =\n err instanceof Error ? err : new Error(\"Sign out failed\");\n setError(signOutError);\n throw signOutError;\n }\n }, [auth, isLoading]);\n\n const isAuthenticationPreloaded = useCallback(() => {\n return auth?.isAuthenticationPreloaded() ?? false;\n }, [auth]);\n\n const setPreloadEnabled = useCallback(\n (enabled: boolean) => {\n if (!auth) {\n throw new Error(\"Auth not initialized\");\n }\n auth.setPreloadEnabled(enabled);\n },\n [auth],\n );\n\n const getPreloadEnabled = useCallback(() => {\n return auth?.getPreloadEnabled() ?? true;\n }, [auth]);\n\n // Extract tokens from session\n const idToken = session?.idToken;\n const accessToken = session?.accessToken;\n const refreshToken = session?.refreshToken;\n\n // Extract forwardedTokens from session's ID token\n const forwardedTokens = useMemo(() => {\n if (!session) return undefined;\n const tokens = extractTokensFromSession(session);\n return tokens.forwardedTokens;\n }, [session]);\n\n const contextValue: CivicAuthContextType = useMemo(\n () => ({\n auth,\n user,\n session,\n isLoading,\n authStatus,\n error,\n idToken,\n accessToken,\n refreshToken,\n forwardedTokens,\n signIn,\n signOut,\n isAuthenticationPreloaded,\n setPreloadEnabled,\n getPreloadEnabled,\n displayMode,\n }),\n [\n auth,\n user,\n session,\n isLoading,\n authStatus,\n error,\n idToken,\n accessToken,\n refreshToken,\n forwardedTokens,\n signIn,\n signOut,\n isAuthenticationPreloaded,\n setPreloadEnabled,\n getPreloadEnabled,\n displayMode,\n ],\n );\n\n return (\n <CivicAuthContext.Provider value={contextValue}>\n {children}\n </CivicAuthContext.Provider>\n );\n};\n\nexport const useCivicAuthContext = (): CivicAuthContextType => {\n const context = useContext(CivicAuthContext);\n if (!context) {\n throw new Error(\n \"useCivicAuthContext must be used within a CivicAuthContextProvider\",\n );\n }\n return context;\n};\n\nexport { CivicAuthContext };\n"]}
|
package/dist/shared/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "@civic/auth:0.9.0
|
|
1
|
+
export declare const VERSION = "@civic/auth:0.9.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,sBAAsB,CAAC"}
|
package/dist/shared/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,mBAAmB,CAAC","sourcesContent":["// This is an auto-generated file. Do not edit.\n\nexport const VERSION = \"@civic/auth:0.9.0\";\n"]}
|
|
@@ -32,9 +32,10 @@ export declare enum CivicAuthErrorCode {
|
|
|
32
32
|
/**
|
|
33
33
|
* Constants for the auth client
|
|
34
34
|
*/
|
|
35
|
+
export declare const DEFAULT_AUTH_PROCESS_TIMEOUT = 600000;
|
|
35
36
|
export declare const CIVIC_AUTH_CONSTANTS: {
|
|
36
37
|
readonly DEFAULT_IFRAME_ID: "civic-auth-iframe";
|
|
37
|
-
readonly DEFAULT_AUTH_PROCESS_TIMEOUT:
|
|
38
|
+
readonly DEFAULT_AUTH_PROCESS_TIMEOUT: 600000;
|
|
38
39
|
readonly SUCCESS_SIGNAL_ID: "civic-auth-success-signal";
|
|
39
40
|
readonly ERROR_SIGNAL_ID: "civic-auth-error-signal";
|
|
40
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthTypes.d.ts","sourceRoot":"","sources":["../../../../src/vanillajs/auth/types/AuthTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EACV,WAAW,IAAI,eAAe,EAC9B,WAAW,EACX,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAA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C;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,GAAG;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,cAAc,EAAE,WAAW,CAAC;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,eAAe,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;CAEvB,CAAC"}
|
|
@@ -24,9 +24,10 @@ export var CivicAuthErrorCode;
|
|
|
24
24
|
/**
|
|
25
25
|
* Constants for the auth client
|
|
26
26
|
*/
|
|
27
|
+
export const DEFAULT_AUTH_PROCESS_TIMEOUT = 600000; // 10 minutes
|
|
27
28
|
export const CIVIC_AUTH_CONSTANTS = {
|
|
28
29
|
DEFAULT_IFRAME_ID: "civic-auth-iframe",
|
|
29
|
-
DEFAULT_AUTH_PROCESS_TIMEOUT
|
|
30
|
+
DEFAULT_AUTH_PROCESS_TIMEOUT,
|
|
30
31
|
SUCCESS_SIGNAL_ID: "civic-auth-success-signal",
|
|
31
32
|
ERROR_SIGNAL_ID: "civic-auth-error-signal",
|
|
32
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthTypes.js","sourceRoot":"","sources":["../../../../src/vanillajs/auth/types/AuthTypes.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,CAAN,IAAY,kBAkBX;AAlBD,WAAY,kBAAkB;IAC5B,yDAAmC,CAAA;IACnC,iDAA2B,CAAA;IAC3B,6EAAuD,CAAA;IACvD,iEAA2C,CAAA;IAC3C,mEAA6C,CAAA;IAC7C,6DAAuC,CAAA;IACvC,qEAA+C,CAAA;IAC/C,yDAAmC,CAAA;IACnC,qDAA+B,CAAA;IAC/B,qDAA+B,CAAA;IAC/B,uDAAiC,CAAA;IACjC,iEAA2C,CAAA;IAC3C,mEAA6C,CAAA;IAC7C,6DAAuC,CAAA;IACvC,qDAA+B,CAAA;IAC/B,2DAAqC,CAAA;IACrC,uDAAiC,CAAA;AACnC,CAAC,EAlBW,kBAAkB,KAAlB,kBAAkB,QAkB7B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,iBAAiB,EAAE,mBAAmB;IACtC,4BAA4B
|
|
1
|
+
{"version":3,"file":"AuthTypes.js","sourceRoot":"","sources":["../../../../src/vanillajs/auth/types/AuthTypes.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,CAAN,IAAY,kBAkBX;AAlBD,WAAY,kBAAkB;IAC5B,yDAAmC,CAAA;IACnC,iDAA2B,CAAA;IAC3B,6EAAuD,CAAA;IACvD,iEAA2C,CAAA;IAC3C,mEAA6C,CAAA;IAC7C,6DAAuC,CAAA;IACvC,qEAA+C,CAAA;IAC/C,yDAAmC,CAAA;IACnC,qDAA+B,CAAA;IAC/B,qDAA+B,CAAA;IAC/B,uDAAiC,CAAA;IACjC,iEAA2C,CAAA;IAC3C,mEAA6C,CAAA;IAC7C,6DAAuC,CAAA;IACvC,qDAA+B,CAAA;IAC/B,2DAAqC,CAAA;IACrC,uDAAiC,CAAA;AACnC,CAAC,EAlBW,kBAAkB,KAAlB,kBAAkB,QAkB7B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,CAAC,aAAa;AAEjE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,iBAAiB,EAAE,mBAAmB;IACtC,4BAA4B;IAC5B,iBAAiB,EAAE,2BAA2B;IAC9C,eAAe,EAAE,yBAAyB;CAClC,CAAC;AAgCX,MAAM,OAAO,cAAe,SAAQ,KAAK;IAGrB;IAFlB,YACE,OAAe,EACC,IAAwB;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAoB;QAGxC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import type { AuthenticationEvents } from \"../AuthenticationEvents.js\";\nimport type {\n DisplayMode as BaseDisplayMode,\n AuthStorage,\n FrameworkType,\n} from \"../../../types.js\";\nimport type { BackendEndpoints } from \"../../../server/config.js\";\n\n/**\n * Extended DisplayMode for VanillaJS that includes \"embedded\" option\n * This provides a cleaner API where users can simply use displayMode: \"embedded\"\n * instead of displayMode: \"iframe\" + iframeDisplayMode: \"embedded\"\n */\nexport type VanillaJSDisplayMode = BaseDisplayMode | \"embedded\";\n\n/**\n * Error codes for CivicAuth errors\n */\nexport enum CivicAuthErrorCode {\n CONFIG_REQUIRED = \"CONFIG_REQUIRED\",\n INIT_FAILED = \"INIT_FAILED\",\n ENDPOINTS_NOT_INITIALIZED = \"ENDPOINTS_NOT_INITIALIZED\",\n CONTAINER_NOT_FOUND = \"CONTAINER_NOT_FOUND\",\n AUTH_PROCESS_TIMEOUT = \"AUTH_PROCESS_TIMEOUT\",\n IFRAME_LOAD_ERROR = \"IFRAME_LOAD_ERROR\",\n IFRAME_PRELOAD_FAILED = \"IFRAME_PRELOAD_FAILED\",\n INVALID_MESSAGE = \"INVALID_MESSAGE\",\n LOGOUT_FAILED = \"LOGOUT_FAILED\",\n POPUP_BLOCKED = \"popup_blocked\",\n USER_CANCELLED = \"user_cancelled\",\n CONFIGURATION_ERROR = \"configuration_error\",\n TOKEN_REFRESH_FAILED = \"token_refresh_failed\",\n SESSION_NOT_FOUND = \"session_not_found\",\n STORAGE_ERROR = \"storage_error\",\n IFRAME_NOT_FOUND = \"iframe_not_found\",\n INTERNAL_ERROR = \"internal_error\",\n}\n\n/**\n * Constants for the auth client\n */\nexport const DEFAULT_AUTH_PROCESS_TIMEOUT = 600000; // 10 minutes\n\nexport const CIVIC_AUTH_CONSTANTS = {\n DEFAULT_IFRAME_ID: \"civic-auth-iframe\",\n DEFAULT_AUTH_PROCESS_TIMEOUT,\n SUCCESS_SIGNAL_ID: \"civic-auth-success-signal\",\n ERROR_SIGNAL_ID: \"civic-auth-error-signal\",\n} as const;\n\n/**\n * Message types for postMessage communication\n */\nexport type AuthMessageType = \"auth_success\" | \"auth_error\";\n\nexport interface AuthMessage {\n type: AuthMessageType;\n detail?: string;\n data?: unknown;\n error?: unknown;\n}\n\n/**\n * Login app message types for postMessage communication\n */\nexport interface LoginAppMessage {\n source: \"civicloginApp\";\n type: \"design\" | \"generatePopupFailed\" | \"auth_success\" | string;\n clientId: string;\n data?: unknown;\n}\n\n/**\n * Combined message type for all iframe communications\n */\nexport type IframeMessage =\n | AuthMessage\n | LoginAppMessage\n | Record<string, unknown>;\n\nexport class CivicAuthError extends Error {\n constructor(\n message: string,\n public readonly code: CivicAuthErrorCode,\n ) {\n super(message);\n this.name = \"CivicAuthError\";\n }\n}\n\n/**\n * Configuration options for the CivicAuth client\n */\nexport interface CivicAuthClientConfig {\n /** OAuth client ID */\n clientId: string;\n /** URL to redirect to after authentication */\n redirectUrl?: string;\n /** URL to redirect to after logout - if not provided, will use redirectUrl */\n logoutRedirectUrl?: string;\n /** Base URL of the OAuth server */\n oauthServerBaseUrl?: string;\n /** Array of OAuth scopes to request */\n scopes?: string[];\n /** HTML element or element ID where the auth iframe will be mounted (required for embedded iframe mode) */\n targetContainerElement?: HTMLElement | string;\n /** Text signals for success and error states */\n textSignals?: {\n /** Text to display on successful authentication */\n success: string;\n /** Optional text to display on authentication error */\n error?: string;\n };\n /** Display mode for the authentication UI - VanillaJS supports \"embedded\" for simplified API */\n displayMode?: VanillaJSDisplayMode;\n /** Display mode for iframe rendering - modal (full-screen overlay) or embedded (within container) */\n iframeDisplayMode?: \"modal\" | \"embedded\";\n /**\n * Timeout duration in milliseconds for the entire authentication process.\n * If the authentication process takes longer than this duration, it will be cancelled\n * and an error will be thrown.\n * Note: This timeout is not applied to embedded iframe mode, where the iframe remains persistent.\n */\n authProcessTimeout?: number;\n /** Event handlers for authentication events */\n events?: AuthenticationEvents;\n /** Custom ID for the auth iframe */\n iframeId?: string;\n /** Custom storage adapter for auth state - uses shared AuthStorage interface */\n storageAdapter?: AuthStorage;\n /** OAuth nonce parameter for security */\n nonce?: string;\n /** Initial state for OAuth flow */\n initialState?: string;\n /** Logging configuration */\n logging?: LoggingConfig;\n /**\n * Custom login URL for backend integration (e.g., \"http://example.com/custom-backendurl\")\n * When provided, automatically uses BrowserCookieStorage for session sharing with backend\n */\n loginUrl?: string;\n /**\n * Custom backend endpoints configuration for backend integration\n * Only used when loginUrl is provided. Allows overriding default endpoints.\n */\n backendEndpoints?: BackendEndpoints;\n /** Framework being used (for analytics) - internal use only */\n framework?: FrameworkType;\n /** Whether to automatically preload the iframe for instant sign-in (defaults to true) */\n preloadIframe?: boolean;\n /** Whether to automatically switch to redirect mode when browser doesn't support iframe-based auth (defaults to true) */\n autoRedirect?: boolean;\n}\n\nexport interface LoggingConfig {\n enabled: boolean;\n namespace?: string;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\";\n}\n\n/**\n * Internal configuration with all optional properties resolved to required ones.\n */\nexport type ProcessedCivicAuthConfig = CivicAuthClientConfig & {\n redirectUrl: string;\n logoutRedirectUrl: string;\n oauthServerBaseUrl: string;\n scopes: string[];\n textSignals: {\n success: string;\n error?: string;\n };\n storageAdapter: AuthStorage;\n logging: LoggingConfig;\n displayMode: BaseDisplayMode; // Internal config uses base DisplayMode after processing\n authProcessTimeout: number;\n iframeId: string;\n prompt: string;\n nonce?: string;\n loginUrl?: string;\n backendEndpoints?: BackendEndpoints;\n preloadIframe: boolean;\n autoRedirect: boolean;\n // targetContainerElement remains optional as it's not needed for all display modes\n};\n"]}
|
|
@@ -142,6 +142,10 @@ export declare class IframeManager {
|
|
|
142
142
|
* Get the URL of the preloaded iframe
|
|
143
143
|
*/
|
|
144
144
|
getPreloadedUrl(): string | null;
|
|
145
|
+
/**
|
|
146
|
+
* Check if shimmer loader is currently active/showing
|
|
147
|
+
*/
|
|
148
|
+
private isShimmerActive;
|
|
145
149
|
/**
|
|
146
150
|
* Update the onClose handler for the iframe manager
|
|
147
151
|
* This is useful when transitioning from preload to active authentication
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IframeManager.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/iframe/IframeManager.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,WAAW,CAAC;IACvB,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,aAAa;IAExB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAU;IAC/C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAW;IAC9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAA2B;IACvE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAe;IAC1D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAU;IAC/C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAW;IAC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OAEG;IACH,OAAO,CAAC,yBAAyB;IAMjC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAMlC;;OAEG;IACI,iBAAiB,IAAI,OAAO;IAInC;;OAEG;IACI,eAAe,IAAI,MAAM,GAAG,IAAI;IAIvC;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;;OAGG;IACI,oBAAoB,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAI/C,gCAAgC,IAAI,IAAI;CAgDhD"}
|
|
@@ -144,7 +144,7 @@ export class IframeManager {
|
|
|
144
144
|
this.setupEmbeddedIframeForPreload();
|
|
145
145
|
}
|
|
146
146
|
// Initialize resizer - this will handle all the message-based resizing
|
|
147
|
-
this.resizer = new CivicIframeResizer(this.iframe, this.container);
|
|
147
|
+
this.resizer = new CivicIframeResizer(this.iframe, this.container, () => this.isShimmerActive());
|
|
148
148
|
// Mark as preloaded
|
|
149
149
|
this.isPreloaded = true;
|
|
150
150
|
this.preloadUrl = url;
|
|
@@ -224,7 +224,7 @@ export class IframeManager {
|
|
|
224
224
|
this.setupEmbeddedIframe();
|
|
225
225
|
}
|
|
226
226
|
// Initialize resizer - this will handle all the message-based resizing
|
|
227
|
-
this.resizer = new CivicIframeResizer(this.iframe, this.container);
|
|
227
|
+
this.resizer = new CivicIframeResizer(this.iframe, this.container, () => this.isShimmerActive());
|
|
228
228
|
return this.iframe;
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
@@ -309,7 +309,11 @@ export class IframeManager {
|
|
|
309
309
|
// wait a bit to ensure any initial loading is complete
|
|
310
310
|
// to give the login-app time to send any post message signals
|
|
311
311
|
setTimeout(() => {
|
|
312
|
+
// Mark iframe as loaded FIRST to disable shimmer blocking
|
|
312
313
|
this.markIframeAsLoaded();
|
|
314
|
+
// Replay any blocked resize messages now that shimmer is inactive
|
|
315
|
+
this.resizer?.replayBlockedMessages();
|
|
316
|
+
this.resizer?.resize();
|
|
313
317
|
}, WAIT_FOR_LOGIN_APP_BROWSER_DETECTION_TIMEOUT);
|
|
314
318
|
}
|
|
315
319
|
}
|
|
@@ -507,14 +511,17 @@ export class IframeManager {
|
|
|
507
511
|
}
|
|
508
512
|
hideShimmerLoader() {
|
|
509
513
|
if (this.shimmerLoader && this.shimmerLoader.parentNode) {
|
|
514
|
+
// Store reference for cleanup
|
|
515
|
+
const shimmerElement = this.shimmerLoader;
|
|
516
|
+
// Clear reference immediately to allow resize operations
|
|
517
|
+
this.shimmerLoader = null;
|
|
510
518
|
// Add fade-out transition before removing
|
|
511
|
-
|
|
512
|
-
|
|
519
|
+
shimmerElement.style.opacity = "0";
|
|
520
|
+
shimmerElement.style.transition = `opacity ${IframeManager.TRANSITION_DURATION} ease`;
|
|
513
521
|
// Remove after transition completes
|
|
514
522
|
setTimeout(() => {
|
|
515
|
-
if (
|
|
516
|
-
|
|
517
|
-
this.shimmerLoader = null;
|
|
523
|
+
if (shimmerElement && shimmerElement.parentNode) {
|
|
524
|
+
shimmerElement.parentNode.removeChild(shimmerElement);
|
|
518
525
|
}
|
|
519
526
|
}, parseInt(IframeManager.TRANSITION_DURATION));
|
|
520
527
|
}
|
|
@@ -773,6 +780,12 @@ export class IframeManager {
|
|
|
773
780
|
getPreloadedUrl() {
|
|
774
781
|
return this.preloadUrl;
|
|
775
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* Check if shimmer loader is currently active/showing
|
|
785
|
+
*/
|
|
786
|
+
isShimmerActive() {
|
|
787
|
+
return !this.isIframeLoaded || !!this.shimmerLoader;
|
|
788
|
+
}
|
|
776
789
|
/**
|
|
777
790
|
* Update the onClose handler for the iframe manager
|
|
778
791
|
* This is useful when transitioning from preload to active authentication
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IframeManager.js","sourceRoot":"","sources":["../../../src/vanillajs/iframe/IframeManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACL,yBAAyB,EACzB,iBA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AC,mCAAmC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC","sourcesContent":["import { CivicIframeResizer } from \"./IframeResizer.js\";\nimport {\n createIframeShimmerLoader,\n createCloseButton,\n} from \"../ui/LoadingComponents.js\";\nimport { createLogger } from \"../utils/logger.js\";\nimport { WAIT_FOR_LOGIN_APP_BROWSER_DETECTION_TIMEOUT } from \"@/constants.js\";\n\nexport interface IframeConfig {\n container: HTMLElement;\n displayMode: \"embedded\" | \"modal\";\n width?: string;\n height?: string;\n iframeId?: string;\n onClose?: () => void;\n}\n\n/**\n * IframeManager - Manages iframe visual presentation and DOM lifecycle\n * Handles styling, positioning, UI components, and iframe element creation/cleanup\n */\nexport class IframeManager {\n // Constants for styling and configuration\n private static readonly MODAL_Z_INDEX = \"1050\";\n private static readonly MODAL_WIDTH = \"20rem\"; // 320px\n private static readonly MODAL_BACKDROP_COLOR = \"rgba(17, 24, 39, 0.5)\";\n private static readonly MODAL_BACKDROP_BLUR = \"blur(4px)\";\n private static readonly BORDER_RADIUS = \"24px\";\n private static readonly TRANSITION_DURATION = \"250ms\";\n private static readonly MODAL_MIN_HEIGHT = \"26px\";\n private static readonly EMBEDDED_MIN_HEIGHT = \"225px\";\n private static readonly IFRAME_READY_DELAY = 100; // ms\n\n private iframe: HTMLIFrameElement | null = null;\n private container: HTMLElement;\n private resizer: CivicIframeResizer | null = null;\n private displayMode: \"embedded\" | \"modal\";\n private keydownHandler?: (event: KeyboardEvent) => void;\n private clickHandler?: (event: MouseEvent) => void;\n private iframeId: string;\n private onClose?: () => void;\n private shimmerLoader: HTMLElement | null = null;\n private closeButton: HTMLButtonElement | null = null;\n private isIframeLoaded = false;\n private iframeReadyMessageListener?: (event: MessageEvent) => void;\n private logger: ReturnType<typeof createLogger>;\n // Store references to wrapper elements for styling control\n private contentWrapper: HTMLElement | null = null;\n private iframeWrapper: HTMLElement | null = null;\n // Preloading support\n private isPreloaded = false;\n private preloadUrl: string | null = null;\n public static browserCorsFailsSilentlyUrl: string | null = null;\n\n public static handleBrowserCorsFailsSilently(url: string): void {\n // Store the URL that caused CORS failure for later reference\n IframeManager.browserCorsFailsSilentlyUrl = url;\n }\n\n constructor(config: IframeConfig) {\n // we aren't going to render the iframe if the browser fails silently as we're redirecting\n\n this.container = config.container;\n this.displayMode = config.displayMode;\n this.iframeId = config.iframeId || \"civic-auth-iframe\";\n this.onClose = config.onClose;\n this.logger = createLogger(\"iframe\");\n this.initializeContainer(config);\n this.setupKeyboardHandlers();\n }\n\n private initializeContainer(config: IframeConfig): void {\n if (this.displayMode === \"modal\") {\n this.applyModalStyles();\n return;\n }\n\n // Embedded mode\n this.container.style.position = \"relative\";\n this.container.style.width = config.width || \"auto\";\n this.container.style.height = config.height || \"auto\";\n this.container.style.backgroundColor = \"white\";\n this.container.style.borderRadius = IframeManager.BORDER_RADIUS;\n this.container.style.overflow = \"hidden\";\n this.container.style.transition = \"all 0.5s ease-in-out\";\n }\n\n /**\n * Applies modal backdrop styles to create a full-screen overlay\n * Uses !important to override any existing styles\n */\n private applyModalStyles(): void {\n const modalStyles = {\n position: \"fixed\",\n left: \"0\",\n top: \"0\",\n width: \"100vw\",\n height: \"100vh\",\n \"z-index\": IframeManager.MODAL_Z_INDEX,\n display: \"flex\",\n \"align-items\": \"center\",\n \"justify-content\": \"center\",\n \"background-color\": IframeManager.MODAL_BACKDROP_COLOR,\n \"backdrop-filter\": IframeManager.MODAL_BACKDROP_BLUR,\n opacity: \"1\",\n transition: `opacity ${IframeManager.TRANSITION_DURATION} ease`,\n // Reset any conflicting styles that might prevent modal from working\n margin: \"0\",\n padding: \"0\",\n border: \"none\",\n \"border-radius\": \"0\",\n \"min-height\": \"100vh\",\n };\n\n Object.entries(modalStyles).forEach(([property, value]) => {\n this.container.style.setProperty(property, value, \"important\");\n });\n }\n\n private setupKeyboardHandlers(): void {\n if (this.displayMode === \"modal\") {\n this.keydownHandler = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n this.onClose?.();\n }\n };\n window.addEventListener(\"keydown\", this.keydownHandler);\n }\n }\n\n /**\n * Preloads an iframe in the background for instant display later\n * The iframe is created but kept completely hidden and non-interactable\n */\n public preloadIframe(url: string): HTMLIFrameElement {\n this.logger.debug(\"Preloading iframe in background\", { url });\n\n // Clean up any existing iframe content, but preserve container styles for modal mode\n this.cleanupIframeOnly();\n\n // Create new iframe for preloading\n this.iframe = document.createElement(\"iframe\");\n this.iframe.id = this.iframeId;\n this.iframe.src = url;\n this.iframe.setAttribute(\"data-testid\", \"civic-auth-iframe-with-resizer\");\n\n // Apply base iframe styles but keep it completely hidden for preloading\n this.applyIframeStyles();\n\n // Make iframe completely invisible and non-interactable during preload\n this.iframe.style.display = \"none\";\n this.iframe.style.visibility = \"hidden\";\n this.iframe.style.pointerEvents = \"none\";\n this.iframe.style.position = \"absolute\";\n this.iframe.style.left = \"-9999px\";\n this.iframe.style.top = \"-9999px\";\n\n // Add attributes that prevent scrollbars\n this.setIframeAttributes();\n\n // Add CSS to prevent scrollbars\n this.addScrollbarHidingStyles();\n\n // Set up message listener for iframe ready events (more reliable than onload)\n this.setupIframeMessageListener();\n\n // Set up iframe onload handler\n this.setupIframeOnloadHandler();\n\n // For preloading, we need to add the iframe to the DOM but keep it hidden\n // Create a minimal container structure without showing it\n if (this.displayMode === \"modal\") {\n this.setupModalIframeForPreload();\n } else {\n this.setupEmbeddedIframeForPreload();\n }\n\n // Initialize resizer - this will handle all the message-based resizing\n this.resizer = new CivicIframeResizer(this.iframe, this.container);\n\n // Mark as preloaded\n this.isPreloaded = true;\n this.preloadUrl = url;\n\n // Keep the container hidden during preload\n this.hide();\n\n this.logger.debug(\"Iframe preloaded successfully\", { url });\n return this.iframe;\n }\n\n public createIframe(url: string): HTMLIFrameElement {\n // If we have a preloaded iframe, show it instantly (even if URL differs)\n // URLs may differ due to fresh PKCE challenges and other dynamic parameters\n if (this.isPreloaded && this.iframe) {\n this.logger.debug(\"Using preloaded iframe for instant display\", {\n preloadedUrl: this.preloadUrl,\n requestedUrl: url,\n urlsMatch: this.preloadUrl === url,\n });\n\n // Don't change iframe.src for preloaded iframes - use them as-is to avoid reload\n // The preloaded authentication flow will work perfectly without URL changes\n this.logger.debug(\"Using preloaded iframe without reload\", {\n preloadedUrl: this.preloadUrl,\n requestedUrl: url,\n action: \"skipping_url_change_to_prevent_reload\",\n });\n\n // Make the preloaded iframe visible and interactable\n this.iframe.style.display = \"block\";\n this.iframe.style.visibility = \"visible\";\n this.iframe.style.pointerEvents = \"auto\";\n this.iframe.style.position = \"relative\";\n this.iframe.style.left = \"0\";\n this.iframe.style.top = \"0\";\n\n // Show the wrappers that were hidden during preload\n if (this.displayMode === \"modal\") {\n if (this.contentWrapper) {\n this.contentWrapper.style.display = \"block\";\n // Apply modal visual styling that was skipped during preload\n this.applyModalVisualStyling();\n\n // Set up modal behaviors (backdrop click, etc.)\n this.setupModalBehaviors();\n }\n } else {\n if (this.iframeWrapper) {\n this.iframeWrapper.style.display = \"block\";\n // Apply wrapper styling that was skipped during preload\n this.applyIframeWrapperStyling();\n }\n }\n\n // Show the container\n this.show();\n\n // Reset preload state since we're now showing the iframe\n this.isPreloaded = false;\n this.preloadUrl = null;\n\n return this.iframe;\n }\n\n // Clean up any existing iframe content, but preserve container styles for modal mode\n this.cleanupIframeOnly();\n\n // Create new iframe\n this.iframe = document.createElement(\"iframe\");\n this.iframe.id = this.iframeId;\n this.iframe.src = url;\n this.iframe.setAttribute(\"data-testid\", \"civic-auth-iframe-with-resizer\");\n\n // Apply iframe styles\n this.applyIframeStyles();\n\n // Add attributes that prevent scrollbars\n this.setIframeAttributes();\n\n // Add CSS to prevent scrollbars\n this.addScrollbarHidingStyles();\n\n // Set up message listener for iframe ready events (more reliable than onload)\n this.setupIframeMessageListener();\n\n // Set up iframe onload handler\n this.setupIframeOnloadHandler();\n\n if (this.displayMode === \"modal\") {\n this.setupModalIframe();\n } else {\n this.setupEmbeddedIframe();\n }\n\n // Initialize resizer - this will handle all the message-based resizing\n this.resizer = new CivicIframeResizer(this.iframe, this.container);\n\n return this.iframe;\n }\n\n /**\n * Applies base styles to the iframe element\n */\n private applyIframeStyles(): void {\n if (!this.iframe) return;\n\n const baseStyles = {\n border: \"none\",\n display: \"block\",\n pointerEvents: \"auto\",\n width: \"100%\",\n minWidth: \"100%\",\n overflow: \"hidden\",\n overflowX: \"hidden\",\n overflowY: \"hidden\",\n opacity: \"0\",\n transition: `opacity ${IframeManager.TRANSITION_DURATION} ease, height ${IframeManager.TRANSITION_DURATION} ease`,\n };\n\n Object.entries(baseStyles).forEach(([property, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Required to handle dynamic CSS property assignment since CSSStyleDeclaration type doesn't fully capture all possible properties\n this.iframe!.style[property as any] = value;\n });\n\n // Set initial height based on display mode\n if (this.displayMode === \"modal\") {\n this.iframe!.style.height = IframeManager.MODAL_MIN_HEIGHT;\n this.iframe!.style.minHeight = IframeManager.MODAL_MIN_HEIGHT;\n } else {\n this.iframe!.style.height = \"auto\";\n this.iframe!.style.minHeight = IframeManager.EMBEDDED_MIN_HEIGHT; // Embedded mode minimum\n }\n }\n\n /**\n * Sets iframe attributes to prevent scrollbars\n */\n private setIframeAttributes(): void {\n if (!this.iframe) return;\n\n this.iframe.setAttribute(\"scrolling\", \"no\");\n this.iframe.setAttribute(\"frameborder\", \"0\");\n this.iframe.setAttribute(\"seamless\", \"seamless\");\n this.iframe.setAttribute(\n \"allow\",\n \"camera; screen-wake-lock; publickey-credentials-get *; publickey-credentials-create *\",\n );\n this.iframe.setAttribute(\"allowFullScreen\", \"true\");\n\n // Add additional CSS to prevent scrollbars\n this.iframe.style.cssText +=\n \"; -ms-overflow-style: none; scrollbar-width: none;\";\n }\n\n /**\n * Adds CSS styles to hide scrollbars across different browsers\n */\n private addScrollbarHidingStyles(): void {\n const iframeStyle = document.createElement(\"style\");\n iframeStyle.textContent = `\n iframe[id=\"${this.iframeId}\"] {\n -webkit-overflow-scrolling: touch !important;\n }\n iframe[id=\"${this.iframeId}\"]::webkit-scrollbar {\n display: none !important;\n width: 0 !important;\n height: 0 !important;\n }\n `;\n document.head.appendChild(iframeStyle);\n }\n\n /**\n * Sets up the message listener for iframe ready events\n */\n private setupIframeMessageListener(): void {\n this.iframeReadyMessageListener = (event: MessageEvent) => {\n try {\n // Only handle messages from our iframe\n if (\n !this.iframe?.contentWindow ||\n event.source !== this.iframe.contentWindow\n ) {\n return;\n }\n\n const message = event.data;\n\n // Handle ready message from iframe resizer\n if (message.type === \"civic-iframe-ready\") {\n this.logger.debug(\"Iframe content is ready - hiding shimmer loader\");\n // wait a bit to ensure any initial loading is complete\n // to give the login-app time to send any post message signals\n setTimeout(() => {\n this.markIframeAsLoaded();\n }, WAIT_FOR_LOGIN_APP_BROWSER_DETECTION_TIMEOUT);\n }\n } catch (error) {\n this.logger.debug(\"Error processing iframe ready message:\", error);\n }\n };\n\n window.addEventListener(\"message\", this.iframeReadyMessageListener);\n }\n\n /**\n * Sets up the iframe onload handler with CSS injection\n */\n private setupIframeOnloadHandler(): void {\n if (!this.iframe) return;\n\n this.iframe.onload = () => {\n // Use a small delay to allow ready message to arrive first\n setTimeout(() => {\n if (!this.isIframeLoaded) {\n this.logger.debug(\n \"Iframe onload fired - hiding shimmer loader (fallback)\",\n );\n this.markIframeAsLoaded();\n }\n }, IframeManager.IFRAME_READY_DELAY);\n\n try {\n const iframeDoc =\n this.iframe?.contentDocument || this.iframe?.contentWindow?.document;\n if (iframeDoc && iframeDoc.head) {\n const style = iframeDoc.createElement(\"style\");\n style.textContent = `\n html, body {\n overflow: hidden !important;\n overflow-x: hidden !important;\n overflow-y: hidden !important;\n -ms-overflow-style: none !important;\n scrollbar-width: none !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n body::-webkit-scrollbar {\n display: none !important;\n }\n * {\n box-sizing: border-box !important;\n }\n `;\n iframeDoc.head.appendChild(style);\n }\n } catch (error) {\n this.logger.debug(\n \"Could not inject CSS into iframe (likely cross-origin):\",\n error,\n );\n }\n };\n }\n\n /**\n * Sets up the iframe for modal display mode during preload\n * Creates the structure but keeps everything hidden\n */\n private setupModalIframeForPreload(): void {\n if (!this.iframe) return;\n\n // Create content wrapper for modal but keep it hidden\n this.contentWrapper = document.createElement(\"div\");\n this.contentWrapper.style.position = \"relative\";\n this.contentWrapper.style.overflow = \"hidden\";\n this.contentWrapper.style.width = IframeManager.MODAL_WIDTH;\n this.contentWrapper.style.display = \"none\"; // Keep hidden during preload\n\n // Create inner iframe wrapper\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\n this.iframeWrapper.style.overflowX = \"hidden\";\n this.iframeWrapper.style.overflowY = \"hidden\";\n this.iframeWrapper.style.transition = `all ${IframeManager.TRANSITION_DURATION} ease`;\n this.iframeWrapper.style.width = \"100%\";\n this.iframeWrapper.style.height = \"auto\";\n this.iframeWrapper.style.minHeight = IframeManager.MODAL_MIN_HEIGHT;\n\n // Add iframe to wrapper, then wrapper to content, then content to container\n this.iframeWrapper.appendChild(this.iframe);\n this.contentWrapper.appendChild(this.iframeWrapper);\n this.container.appendChild(this.contentWrapper);\n }\n\n /**\n * Sets up the iframe for embedded display mode during preload\n * Creates the structure but keeps everything hidden\n */\n private setupEmbeddedIframeForPreload(): void {\n if (!this.iframe) return;\n\n // Create wrapper but keep it hidden\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\n this.iframeWrapper.style.overflowX = \"hidden\";\n this.iframeWrapper.style.overflowY = \"hidden\";\n this.iframeWrapper.style.transition = \"all 0.5s ease-in-out\";\n this.iframeWrapper.style.width = \"100%\";\n this.iframeWrapper.style.height = \"auto\";\n this.iframeWrapper.style.minHeight = IframeManager.EMBEDDED_MIN_HEIGHT;\n this.iframeWrapper.style.display = \"none\"; // Keep hidden during preload\n\n // Add iframe to wrapper, then wrapper to container\n this.iframeWrapper.appendChild(this.iframe);\n this.container.appendChild(this.iframeWrapper);\n }\n\n /**\n * Sets up the iframe for modal display mode\n */\n private setupModalIframe(): void {\n if (!this.iframe) return;\n\n // Ensure modal is visible (in case it was hidden by cleanup)\n this.container.style.setProperty(\"display\", \"flex\", \"important\");\n\n // Create content wrapper for modal\n this.contentWrapper = document.createElement(\"div\");\n this.contentWrapper.style.position = \"relative\";\n this.contentWrapper.style.overflow = \"hidden\";\n this.contentWrapper.style.width = IframeManager.MODAL_WIDTH; // 320px like React version\n\n // Apply initial visual styling\n this.applyModalVisualStyling();\n\n // Create inner iframe wrapper to match React structure\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\n this.iframeWrapper.style.overflowX = \"hidden\";\n this.iframeWrapper.style.overflowY = \"hidden\";\n this.iframeWrapper.style.transition = `all ${IframeManager.TRANSITION_DURATION} ease`;\n this.iframeWrapper.style.width = \"100%\";\n this.iframeWrapper.style.height = \"auto\";\n this.iframeWrapper.style.minHeight = IframeManager.MODAL_MIN_HEIGHT; // Start small for modal mode\n\n // Apply initial wrapper styling\n this.applyIframeWrapperStyling();\n\n // Add shimmer loader for modal mode\n this.showShimmerLoader(this.iframeWrapper, \"white\");\n\n // Add iframe to wrapper, then wrapper to content, then content to container\n this.iframeWrapper.appendChild(this.iframe);\n this.contentWrapper.appendChild(this.iframeWrapper);\n this.container.appendChild(this.contentWrapper);\n\n this.setupModalBehaviors();\n }\n\n /**\n * Sets up modal-specific behaviors like click handlers and close button\n */\n private setupModalBehaviors(): void {\n if (!this.contentWrapper) return;\n\n // Stop propagation on content wrapper to prevent backdrop clicks\n this.contentWrapper.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n });\n\n // Add close button for modal mode (initially hidden if not loaded)\n if (this.onClose && !this.closeButton) {\n this.closeButton = createCloseButton(this.onClose);\n // Show close button immediately if iframe is already loaded, otherwise keep hidden\n this.closeButton.style.opacity = this.isIframeLoaded ? \"1\" : \"0\";\n this.contentWrapper.appendChild(this.closeButton);\n }\n\n // Add click-to-close functionality after content is added\n if (!this.clickHandler) {\n this.clickHandler = (e: MouseEvent) => {\n if (e.target === this.container) {\n // Only close if clicking the backdrop, not the iframe content\n this.onClose?.();\n }\n };\n this.container.addEventListener(\"click\", this.clickHandler);\n }\n }\n\n /**\n * Sets up the iframe for embedded display mode\n */\n private setupEmbeddedIframe(): void {\n if (!this.iframe) return;\n\n // Embedded mode - create wrapper with border radius and overflow hidden\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\n this.iframeWrapper.style.overflowX = \"hidden\";\n this.iframeWrapper.style.overflowY = \"hidden\";\n this.iframeWrapper.style.transition = \"all 0.5s ease-in-out\";\n this.iframeWrapper.style.width = \"100%\";\n this.iframeWrapper.style.height = \"auto\";\n this.iframeWrapper.style.minHeight = IframeManager.EMBEDDED_MIN_HEIGHT; // Embedded mode minimum\n\n // Apply initial wrapper styling\n this.applyIframeWrapperStyling();\n\n // Add shimmer loader for embedded mode with max width\n this.showShimmerLoader(\n this.iframeWrapper,\n \"white\",\n IframeManager.MODAL_WIDTH,\n );\n\n // Add iframe to wrapper, then wrapper to container\n this.iframeWrapper.appendChild(this.iframe);\n this.container.appendChild(this.iframeWrapper);\n }\n\n private showShimmerLoader(\n parentElement: HTMLElement,\n backgroundColor = \"white\",\n maxWidth?: string,\n ): void {\n if (!this.isIframeLoaded && !this.shimmerLoader) {\n this.shimmerLoader = createIframeShimmerLoader(backgroundColor, maxWidth);\n parentElement.appendChild(this.shimmerLoader);\n }\n }\n\n private hideShimmerLoader(): void {\n if (this.shimmerLoader && this.shimmerLoader.parentNode) {\n // Add fade-out transition before removing\n this.shimmerLoader.style.opacity = \"0\";\n this.shimmerLoader.style.transition = `opacity ${IframeManager.TRANSITION_DURATION} ease`;\n // Remove after transition completes\n setTimeout(() => {\n if (this.shimmerLoader && this.shimmerLoader.parentNode) {\n this.shimmerLoader.parentNode.removeChild(this.shimmerLoader);\n this.shimmerLoader = null;\n }\n }, parseInt(IframeManager.TRANSITION_DURATION));\n }\n }\n\n private markIframeAsLoaded(): void {\n if (IframeManager.browserCorsFailsSilentlyUrl) {\n return;\n }\n if (!this.isIframeLoaded) {\n this.isIframeLoaded = true;\n this.hideShimmerLoader();\n this.updateWrapperForLoadedContent();\n }\n }\n\n private updateWrapperForLoadedContent(): void {\n // Fade in the iframe\n if (this.iframe) {\n this.iframe.style.opacity = \"1\";\n }\n\n // Show close button for modal mode when content is loaded\n if (this.displayMode === \"modal\" && this.closeButton) {\n this.closeButton.style.opacity = \"1\";\n }\n\n // Find the iframe wrapper and update its styles for loaded content\n const iframeWrapper = this.iframe?.parentElement;\n if (iframeWrapper) {\n // Remove minimum height constraints to allow natural sizing\n if (this.displayMode === \"modal\") {\n iframeWrapper.style.minHeight = \"auto\";\n } else {\n // For embedded mode, keep some minimum but allow natural growth\n iframeWrapper.style.minHeight = \"auto\";\n }\n\n // Add border radius transition for loaded state (matching React implementation)\n iframeWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n }\n }\n\n public hide(): void {\n if (this.displayMode === \"modal\") {\n // Hide immediately without transition\n this.container.style.transition = \"none\";\n this.container.style.opacity = \"0\";\n }\n this.container.style.display = \"none\";\n }\n\n public show(): void {\n if (this.displayMode === \"modal\") {\n // Show immediately, then fade in\n this.container.style.display = \"flex\";\n this.container.style.opacity = \"0\";\n this.container.style.transition = `opacity ${IframeManager.TRANSITION_DURATION} ease`;\n\n // Use setTimeout to ensure display change takes effect before opacity transition\n setTimeout(() => {\n this.container.style.opacity = \"1\";\n }, 10);\n } else {\n // For embedded mode, just show immediately\n this.container.style.display = \"block\";\n this.container.style.opacity = \"1\";\n }\n }\n\n private cleanupIframeOnly(): void {\n if (this.resizer) {\n this.resizer.cleanup();\n this.resizer = null;\n }\n\n // Clean up shimmer loader\n this.hideShimmerLoader();\n\n // Clean up close button\n if (this.closeButton && this.closeButton.parentNode) {\n this.closeButton.parentNode.removeChild(this.closeButton);\n this.closeButton = null;\n }\n\n // Clean up message listener\n if (this.iframeReadyMessageListener) {\n window.removeEventListener(\"message\", this.iframeReadyMessageListener);\n this.iframeReadyMessageListener = undefined;\n }\n\n if (this.iframe && this.iframe.parentNode) {\n this.iframe.parentNode.removeChild(this.iframe);\n this.iframe = null;\n }\n\n // Reset loading state\n this.isIframeLoaded = false;\n\n // Reset preload state\n this.isPreloaded = false;\n this.preloadUrl = null;\n\n // Clear wrapper references\n this.contentWrapper = null;\n this.iframeWrapper = null;\n\n // Clear container content but DON'T reset styles for modal mode\n this.container.innerHTML = \"\";\n }\n\n public cleanup(): void {\n if (this.resizer) {\n this.resizer.cleanup();\n this.resizer = null;\n }\n\n // Clean up shimmer loader\n this.hideShimmerLoader();\n\n // Clean up close button\n if (this.closeButton && this.closeButton.parentNode) {\n this.closeButton.parentNode.removeChild(this.closeButton);\n this.closeButton = null;\n }\n\n // Clean up message listener\n if (this.iframeReadyMessageListener) {\n window.removeEventListener(\"message\", this.iframeReadyMessageListener);\n this.iframeReadyMessageListener = undefined;\n }\n\n if (this.iframe && this.iframe.parentNode) {\n this.iframe.parentNode.removeChild(this.iframe);\n this.iframe = null;\n }\n\n // Reset loading state\n this.isIframeLoaded = false;\n\n // Reset preload state\n this.isPreloaded = false;\n this.preloadUrl = null;\n\n // Remove keyboard event listener\n if (this.keydownHandler) {\n window.removeEventListener(\"keydown\", this.keydownHandler);\n this.keydownHandler = undefined;\n }\n\n // Remove click event listener\n if (this.clickHandler) {\n this.container.removeEventListener(\"click\", this.clickHandler);\n this.clickHandler = undefined;\n }\n\n // Clear wrapper references\n this.contentWrapper = null;\n this.iframeWrapper = null;\n\n // Clear container content and reset styles\n this.container.innerHTML = \"\";\n\n if (this.displayMode === \"modal\") {\n // Reset all modal-specific styles to ensure clean state\n this.resetModalStyles();\n }\n }\n\n /**\n * Resets all modal-specific styles by removing CSS properties that were set with !important\n */\n private resetModalStyles(): void {\n const modalStyleProperties = [\n \"position\",\n \"left\",\n \"top\",\n \"width\",\n \"height\",\n \"z-index\",\n \"display\",\n \"align-items\",\n \"justify-content\",\n \"background-color\",\n \"backdrop-filter\",\n \"opacity\",\n \"transition\",\n \"margin\",\n \"padding\",\n \"border\",\n \"border-radius\",\n \"min-height\",\n ];\n\n modalStyleProperties.forEach((property) => {\n this.container.style.removeProperty(property);\n });\n }\n\n public resize(): void {\n if (this.resizer) {\n this.resizer.resize();\n }\n }\n\n /**\n * Force show the shimmer loader and hide iframe content\n * Used when we want to mask non-login content\n */\n public forceShowLoader(): void {\n // Reset loading state to show shimmer\n this.isIframeLoaded = false;\n\n // Hide iframe content\n if (this.iframe) {\n this.iframe.style.opacity = \"0\";\n }\n\n // Hide close button\n if (this.displayMode === \"modal\" && this.closeButton) {\n this.closeButton.style.opacity = \"0\";\n }\n\n // Hide visual decorations (borders, shadows) when masking content\n if (this.displayMode === \"modal\") {\n this.removeModalVisualStyling();\n }\n this.removeIframeWrapperStyling();\n\n // Show shimmer loader\n if (this.iframeWrapper && !this.shimmerLoader) {\n this.showShimmerLoader(\n this.iframeWrapper,\n \"white\",\n this.displayMode === \"embedded\" ? IframeManager.MODAL_WIDTH : undefined,\n );\n }\n }\n\n /**\n * Force hide the shimmer loader and show iframe content\n * Used when we want to show the login app\n */\n public forceHideLoader(): void {\n // Restore visual decorations when showing content\n if (this.displayMode === \"modal\") {\n this.applyModalVisualStyling();\n }\n this.applyIframeWrapperStyling();\n\n this.markIframeAsLoaded();\n }\n\n /**\n * Applies visual styling (borders, shadows) to modal content wrapper\n */\n private applyModalVisualStyling(): void {\n if (!this.contentWrapper) return;\n\n this.contentWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n this.contentWrapper.style.boxShadow =\n \"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)\";\n }\n\n /**\n * Removes visual styling (borders, shadows) from modal content wrapper\n */\n private removeModalVisualStyling(): void {\n if (!this.contentWrapper) return;\n\n this.contentWrapper.style.borderRadius = \"0\";\n this.contentWrapper.style.boxShadow = \"none\";\n }\n\n /**\n * Applies visual styling (borders) to iframe wrapper\n */\n private applyIframeWrapperStyling(): void {\n if (!this.iframeWrapper) return;\n\n this.iframeWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n }\n\n /**\n * Removes visual styling (borders) from iframe wrapper\n */\n private removeIframeWrapperStyling(): void {\n if (!this.iframeWrapper) return;\n\n this.iframeWrapper.style.borderRadius = \"0\";\n }\n\n /**\n * Check if an iframe is currently preloaded\n */\n public isIframePreloaded(): boolean {\n return this.isPreloaded;\n }\n\n /**\n * Get the URL of the preloaded iframe\n */\n public getPreloadedUrl(): string | null {\n return this.preloadUrl;\n }\n\n /**\n * Update the onClose handler for the iframe manager\n * This is useful when transitioning from preload to active authentication\n */\n public updateOnCloseHandler(onClose: () => void): void {\n this.onClose = onClose;\n }\n\n public showSubtlePopupFallbackIndicator(): void {\n if (!this.iframeWrapper && !this.contentWrapper) {\n this.logger.warn(\n \"Cannot show popup fallback indicator, no iframe wrapper or content wrapper found.\",\n );\n return;\n }\n\n const targetElement = this.iframeWrapper || this.contentWrapper;\n\n if (targetElement) {\n this.logger.debug(\"Showing popup fallback overlay.\");\n\n // Create overlay element\n const overlay = document.createElement(\"div\");\n overlay.id = \"civic-popup-fallback-overlay\";\n overlay.style.cssText = `\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: transparent;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 1000;\n border-radius: ${IframeManager.BORDER_RADIUS};\n backdrop-filter: blur(.4px);\n opacity: 1;\n `;\n\n // Add overlay to target element\n targetElement.style.position = \"relative\";\n targetElement.appendChild(overlay);\n\n // Remove overlay quickly\n setTimeout(() => {\n if (overlay.parentNode) {\n overlay.parentNode.removeChild(overlay);\n }\n this.logger.debug(\"Popup fallback overlay removed.\");\n }, 500); // Remove after 500ms\n\n this.logger.debug(\"Popup fallback overlay display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,8BAA8B,CAAC;YAC5C,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG;;;;;;;;;;;;yBAYL,aAAa,CAAC,aAAa;;;OAG7C,CAAC;YAEF,gCAAgC;YAChC,aAAa,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;YAC1C,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAEnC,yBAAyB;YACzB,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;oBACvB,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBAC1C,CAAC;gBACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACvD,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,qBAAqB;YAE9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC","sourcesContent":["import { CivicIframeResizer } from \"./IframeResizer.js\";\nimport {\n createIframeShimmerLoader,\n createCloseButton,\n} from \"../ui/LoadingComponents.js\";\nimport { createLogger } from \"../utils/logger.js\";\nimport { WAIT_FOR_LOGIN_APP_BROWSER_DETECTION_TIMEOUT } from \"@/constants.js\";\n\nexport interface IframeConfig {\n container: HTMLElement;\n displayMode: \"embedded\" | \"modal\";\n width?: string;\n height?: string;\n iframeId?: string;\n onClose?: () => void;\n}\n\n/**\n * IframeManager - Manages iframe visual presentation and DOM lifecycle\n * Handles styling, positioning, UI components, and iframe element creation/cleanup\n */\nexport class IframeManager {\n // Constants for styling and configuration\n private static readonly MODAL_Z_INDEX = \"1050\";\n private static readonly MODAL_WIDTH = \"20rem\"; // 320px\n private static readonly MODAL_BACKDROP_COLOR = \"rgba(17, 24, 39, 0.5)\";\n private static readonly MODAL_BACKDROP_BLUR = \"blur(4px)\";\n private static readonly BORDER_RADIUS = \"24px\";\n private static readonly TRANSITION_DURATION = \"250ms\";\n private static readonly MODAL_MIN_HEIGHT = \"26px\";\n private static readonly EMBEDDED_MIN_HEIGHT = \"225px\";\n private static readonly IFRAME_READY_DELAY = 100; // ms\n\n private iframe: HTMLIFrameElement | null = null;\n private container: HTMLElement;\n private resizer: CivicIframeResizer | null = null;\n private displayMode: \"embedded\" | \"modal\";\n private keydownHandler?: (event: KeyboardEvent) => void;\n private clickHandler?: (event: MouseEvent) => void;\n private iframeId: string;\n private onClose?: () => void;\n private shimmerLoader: HTMLElement | null = null;\n private closeButton: HTMLButtonElement | null = null;\n private isIframeLoaded = false;\n private iframeReadyMessageListener?: (event: MessageEvent) => void;\n private logger: ReturnType<typeof createLogger>;\n // Store references to wrapper elements for styling control\n private contentWrapper: HTMLElement | null = null;\n private iframeWrapper: HTMLElement | null = null;\n // Preloading support\n private isPreloaded = false;\n private preloadUrl: string | null = null;\n public static browserCorsFailsSilentlyUrl: string | null = null;\n\n public static handleBrowserCorsFailsSilently(url: string): void {\n // Store the URL that caused CORS failure for later reference\n IframeManager.browserCorsFailsSilentlyUrl = url;\n }\n\n constructor(config: IframeConfig) {\n // we aren't going to render the iframe if the browser fails silently as we're redirecting\n\n this.container = config.container;\n this.displayMode = config.displayMode;\n this.iframeId = config.iframeId || \"civic-auth-iframe\";\n this.onClose = config.onClose;\n this.logger = createLogger(\"iframe\");\n this.initializeContainer(config);\n this.setupKeyboardHandlers();\n }\n\n private initializeContainer(config: IframeConfig): void {\n if (this.displayMode === \"modal\") {\n this.applyModalStyles();\n return;\n }\n\n // Embedded mode\n this.container.style.position = \"relative\";\n this.container.style.width = config.width || \"auto\";\n this.container.style.height = config.height || \"auto\";\n this.container.style.backgroundColor = \"white\";\n this.container.style.borderRadius = IframeManager.BORDER_RADIUS;\n this.container.style.overflow = \"hidden\";\n this.container.style.transition = \"all 0.5s ease-in-out\";\n }\n\n /**\n * Applies modal backdrop styles to create a full-screen overlay\n * Uses !important to override any existing styles\n */\n private applyModalStyles(): void {\n const modalStyles = {\n position: \"fixed\",\n left: \"0\",\n top: \"0\",\n width: \"100vw\",\n height: \"100vh\",\n \"z-index\": IframeManager.MODAL_Z_INDEX,\n display: \"flex\",\n \"align-items\": \"center\",\n \"justify-content\": \"center\",\n \"background-color\": IframeManager.MODAL_BACKDROP_COLOR,\n \"backdrop-filter\": IframeManager.MODAL_BACKDROP_BLUR,\n opacity: \"1\",\n transition: `opacity ${IframeManager.TRANSITION_DURATION} ease`,\n // Reset any conflicting styles that might prevent modal from working\n margin: \"0\",\n padding: \"0\",\n border: \"none\",\n \"border-radius\": \"0\",\n \"min-height\": \"100vh\",\n };\n\n Object.entries(modalStyles).forEach(([property, value]) => {\n this.container.style.setProperty(property, value, \"important\");\n });\n }\n\n private setupKeyboardHandlers(): void {\n if (this.displayMode === \"modal\") {\n this.keydownHandler = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n this.onClose?.();\n }\n };\n window.addEventListener(\"keydown\", this.keydownHandler);\n }\n }\n\n /**\n * Preloads an iframe in the background for instant display later\n * The iframe is created but kept completely hidden and non-interactable\n */\n public preloadIframe(url: string): HTMLIFrameElement {\n this.logger.debug(\"Preloading iframe in background\", { url });\n\n // Clean up any existing iframe content, but preserve container styles for modal mode\n this.cleanupIframeOnly();\n\n // Create new iframe for preloading\n this.iframe = document.createElement(\"iframe\");\n this.iframe.id = this.iframeId;\n this.iframe.src = url;\n this.iframe.setAttribute(\"data-testid\", \"civic-auth-iframe-with-resizer\");\n\n // Apply base iframe styles but keep it completely hidden for preloading\n this.applyIframeStyles();\n\n // Make iframe completely invisible and non-interactable during preload\n this.iframe.style.display = \"none\";\n this.iframe.style.visibility = \"hidden\";\n this.iframe.style.pointerEvents = \"none\";\n this.iframe.style.position = \"absolute\";\n this.iframe.style.left = \"-9999px\";\n this.iframe.style.top = \"-9999px\";\n\n // Add attributes that prevent scrollbars\n this.setIframeAttributes();\n\n // Add CSS to prevent scrollbars\n this.addScrollbarHidingStyles();\n\n // Set up message listener for iframe ready events (more reliable than onload)\n this.setupIframeMessageListener();\n\n // Set up iframe onload handler\n this.setupIframeOnloadHandler();\n\n // For preloading, we need to add the iframe to the DOM but keep it hidden\n // Create a minimal container structure without showing it\n if (this.displayMode === \"modal\") {\n this.setupModalIframeForPreload();\n } else {\n this.setupEmbeddedIframeForPreload();\n }\n\n // Initialize resizer - this will handle all the message-based resizing\n this.resizer = new CivicIframeResizer(this.iframe, this.container, () =>\n this.isShimmerActive(),\n );\n\n // Mark as preloaded\n this.isPreloaded = true;\n this.preloadUrl = url;\n\n // Keep the container hidden during preload\n this.hide();\n\n this.logger.debug(\"Iframe preloaded successfully\", { url });\n return this.iframe;\n }\n\n public createIframe(url: string): HTMLIFrameElement {\n // If we have a preloaded iframe, show it instantly (even if URL differs)\n // URLs may differ due to fresh PKCE challenges and other dynamic parameters\n if (this.isPreloaded && this.iframe) {\n this.logger.debug(\"Using preloaded iframe for instant display\", {\n preloadedUrl: this.preloadUrl,\n requestedUrl: url,\n urlsMatch: this.preloadUrl === url,\n });\n\n // Don't change iframe.src for preloaded iframes - use them as-is to avoid reload\n // The preloaded authentication flow will work perfectly without URL changes\n this.logger.debug(\"Using preloaded iframe without reload\", {\n preloadedUrl: this.preloadUrl,\n requestedUrl: url,\n action: \"skipping_url_change_to_prevent_reload\",\n });\n\n // Make the preloaded iframe visible and interactable\n this.iframe.style.display = \"block\";\n this.iframe.style.visibility = \"visible\";\n this.iframe.style.pointerEvents = \"auto\";\n this.iframe.style.position = \"relative\";\n this.iframe.style.left = \"0\";\n this.iframe.style.top = \"0\";\n\n // Show the wrappers that were hidden during preload\n if (this.displayMode === \"modal\") {\n if (this.contentWrapper) {\n this.contentWrapper.style.display = \"block\";\n // Apply modal visual styling that was skipped during preload\n this.applyModalVisualStyling();\n\n // Set up modal behaviors (backdrop click, etc.)\n this.setupModalBehaviors();\n }\n } else {\n if (this.iframeWrapper) {\n this.iframeWrapper.style.display = \"block\";\n // Apply wrapper styling that was skipped during preload\n this.applyIframeWrapperStyling();\n }\n }\n\n // Show the container\n this.show();\n\n // Reset preload state since we're now showing the iframe\n this.isPreloaded = false;\n this.preloadUrl = null;\n\n return this.iframe;\n }\n\n // Clean up any existing iframe content, but preserve container styles for modal mode\n this.cleanupIframeOnly();\n\n // Create new iframe\n this.iframe = document.createElement(\"iframe\");\n this.iframe.id = this.iframeId;\n this.iframe.src = url;\n this.iframe.setAttribute(\"data-testid\", \"civic-auth-iframe-with-resizer\");\n\n // Apply iframe styles\n this.applyIframeStyles();\n\n // Add attributes that prevent scrollbars\n this.setIframeAttributes();\n\n // Add CSS to prevent scrollbars\n this.addScrollbarHidingStyles();\n\n // Set up message listener for iframe ready events (more reliable than onload)\n this.setupIframeMessageListener();\n\n // Set up iframe onload handler\n this.setupIframeOnloadHandler();\n\n if (this.displayMode === \"modal\") {\n this.setupModalIframe();\n } else {\n this.setupEmbeddedIframe();\n }\n\n // Initialize resizer - this will handle all the message-based resizing\n this.resizer = new CivicIframeResizer(this.iframe, this.container, () =>\n this.isShimmerActive(),\n );\n\n return this.iframe;\n }\n\n /**\n * Applies base styles to the iframe element\n */\n private applyIframeStyles(): void {\n if (!this.iframe) return;\n\n const baseStyles = {\n border: \"none\",\n display: \"block\",\n pointerEvents: \"auto\",\n width: \"100%\",\n minWidth: \"100%\",\n overflow: \"hidden\",\n overflowX: \"hidden\",\n overflowY: \"hidden\",\n opacity: \"0\",\n transition: `opacity ${IframeManager.TRANSITION_DURATION} ease, height ${IframeManager.TRANSITION_DURATION} ease`,\n };\n\n Object.entries(baseStyles).forEach(([property, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Required to handle dynamic CSS property assignment since CSSStyleDeclaration type doesn't fully capture all possible properties\n this.iframe!.style[property as any] = value;\n });\n\n // Set initial height based on display mode\n if (this.displayMode === \"modal\") {\n this.iframe!.style.height = IframeManager.MODAL_MIN_HEIGHT;\n this.iframe!.style.minHeight = IframeManager.MODAL_MIN_HEIGHT;\n } else {\n this.iframe!.style.height = \"auto\";\n this.iframe!.style.minHeight = IframeManager.EMBEDDED_MIN_HEIGHT; // Embedded mode minimum\n }\n }\n\n /**\n * Sets iframe attributes to prevent scrollbars\n */\n private setIframeAttributes(): void {\n if (!this.iframe) return;\n\n this.iframe.setAttribute(\"scrolling\", \"no\");\n this.iframe.setAttribute(\"frameborder\", \"0\");\n this.iframe.setAttribute(\"seamless\", \"seamless\");\n this.iframe.setAttribute(\n \"allow\",\n \"camera; screen-wake-lock; publickey-credentials-get *; publickey-credentials-create *\",\n );\n this.iframe.setAttribute(\"allowFullScreen\", \"true\");\n\n // Add additional CSS to prevent scrollbars\n this.iframe.style.cssText +=\n \"; -ms-overflow-style: none; scrollbar-width: none;\";\n }\n\n /**\n * Adds CSS styles to hide scrollbars across different browsers\n */\n private addScrollbarHidingStyles(): void {\n const iframeStyle = document.createElement(\"style\");\n iframeStyle.textContent = `\n iframe[id=\"${this.iframeId}\"] {\n -webkit-overflow-scrolling: touch !important;\n }\n iframe[id=\"${this.iframeId}\"]::webkit-scrollbar {\n display: none !important;\n width: 0 !important;\n height: 0 !important;\n }\n `;\n document.head.appendChild(iframeStyle);\n }\n\n /**\n * Sets up the message listener for iframe ready events\n */\n private setupIframeMessageListener(): void {\n this.iframeReadyMessageListener = (event: MessageEvent) => {\n try {\n // Only handle messages from our iframe\n if (\n !this.iframe?.contentWindow ||\n event.source !== this.iframe.contentWindow\n ) {\n return;\n }\n\n const message = event.data;\n\n // Handle ready message from iframe resizer\n if (message.type === \"civic-iframe-ready\") {\n this.logger.debug(\"Iframe content is ready - hiding shimmer loader\");\n // wait a bit to ensure any initial loading is complete\n // to give the login-app time to send any post message signals\n setTimeout(() => {\n // Mark iframe as loaded FIRST to disable shimmer blocking\n this.markIframeAsLoaded();\n\n // Replay any blocked resize messages now that shimmer is inactive\n this.resizer?.replayBlockedMessages();\n this.resizer?.resize();\n }, WAIT_FOR_LOGIN_APP_BROWSER_DETECTION_TIMEOUT);\n }\n } catch (error) {\n this.logger.debug(\"Error processing iframe ready message:\", error);\n }\n };\n\n window.addEventListener(\"message\", this.iframeReadyMessageListener);\n }\n\n /**\n * Sets up the iframe onload handler with CSS injection\n */\n private setupIframeOnloadHandler(): void {\n if (!this.iframe) return;\n\n this.iframe.onload = () => {\n // Use a small delay to allow ready message to arrive first\n setTimeout(() => {\n if (!this.isIframeLoaded) {\n this.logger.debug(\n \"Iframe onload fired - hiding shimmer loader (fallback)\",\n );\n this.markIframeAsLoaded();\n }\n }, IframeManager.IFRAME_READY_DELAY);\n\n try {\n const iframeDoc =\n this.iframe?.contentDocument || this.iframe?.contentWindow?.document;\n if (iframeDoc && iframeDoc.head) {\n const style = iframeDoc.createElement(\"style\");\n style.textContent = `\n html, body {\n overflow: hidden !important;\n overflow-x: hidden !important;\n overflow-y: hidden !important;\n -ms-overflow-style: none !important;\n scrollbar-width: none !important;\n margin: 0 !important;\n padding: 0 !important;\n }\n body::-webkit-scrollbar {\n display: none !important;\n }\n * {\n box-sizing: border-box !important;\n }\n `;\n iframeDoc.head.appendChild(style);\n }\n } catch (error) {\n this.logger.debug(\n \"Could not inject CSS into iframe (likely cross-origin):\",\n error,\n );\n }\n };\n }\n\n /**\n * Sets up the iframe for modal display mode during preload\n * Creates the structure but keeps everything hidden\n */\n private setupModalIframeForPreload(): void {\n if (!this.iframe) return;\n\n // Create content wrapper for modal but keep it hidden\n this.contentWrapper = document.createElement(\"div\");\n this.contentWrapper.style.position = \"relative\";\n this.contentWrapper.style.overflow = \"hidden\";\n this.contentWrapper.style.width = IframeManager.MODAL_WIDTH;\n this.contentWrapper.style.display = \"none\"; // Keep hidden during preload\n\n // Create inner iframe wrapper\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\n this.iframeWrapper.style.overflowX = \"hidden\";\n this.iframeWrapper.style.overflowY = \"hidden\";\n this.iframeWrapper.style.transition = `all ${IframeManager.TRANSITION_DURATION} ease`;\n this.iframeWrapper.style.width = \"100%\";\n this.iframeWrapper.style.height = \"auto\";\n this.iframeWrapper.style.minHeight = IframeManager.MODAL_MIN_HEIGHT;\n\n // Add iframe to wrapper, then wrapper to content, then content to container\n this.iframeWrapper.appendChild(this.iframe);\n this.contentWrapper.appendChild(this.iframeWrapper);\n this.container.appendChild(this.contentWrapper);\n }\n\n /**\n * Sets up the iframe for embedded display mode during preload\n * Creates the structure but keeps everything hidden\n */\n private setupEmbeddedIframeForPreload(): void {\n if (!this.iframe) return;\n\n // Create wrapper but keep it hidden\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\n this.iframeWrapper.style.overflowX = \"hidden\";\n this.iframeWrapper.style.overflowY = \"hidden\";\n this.iframeWrapper.style.transition = \"all 0.5s ease-in-out\";\n this.iframeWrapper.style.width = \"100%\";\n this.iframeWrapper.style.height = \"auto\";\n this.iframeWrapper.style.minHeight = IframeManager.EMBEDDED_MIN_HEIGHT;\n this.iframeWrapper.style.display = \"none\"; // Keep hidden during preload\n\n // Add iframe to wrapper, then wrapper to container\n this.iframeWrapper.appendChild(this.iframe);\n this.container.appendChild(this.iframeWrapper);\n }\n\n /**\n * Sets up the iframe for modal display mode\n */\n private setupModalIframe(): void {\n if (!this.iframe) return;\n\n // Ensure modal is visible (in case it was hidden by cleanup)\n this.container.style.setProperty(\"display\", \"flex\", \"important\");\n\n // Create content wrapper for modal\n this.contentWrapper = document.createElement(\"div\");\n this.contentWrapper.style.position = \"relative\";\n this.contentWrapper.style.overflow = \"hidden\";\n this.contentWrapper.style.width = IframeManager.MODAL_WIDTH; // 320px like React version\n\n // Apply initial visual styling\n this.applyModalVisualStyling();\n\n // Create inner iframe wrapper to match React structure\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\n this.iframeWrapper.style.overflowX = \"hidden\";\n this.iframeWrapper.style.overflowY = \"hidden\";\n this.iframeWrapper.style.transition = `all ${IframeManager.TRANSITION_DURATION} ease`;\n this.iframeWrapper.style.width = \"100%\";\n this.iframeWrapper.style.height = \"auto\";\n this.iframeWrapper.style.minHeight = IframeManager.MODAL_MIN_HEIGHT; // Start small for modal mode\n\n // Apply initial wrapper styling\n this.applyIframeWrapperStyling();\n\n // Add shimmer loader for modal mode\n this.showShimmerLoader(this.iframeWrapper, \"white\");\n\n // Add iframe to wrapper, then wrapper to content, then content to container\n this.iframeWrapper.appendChild(this.iframe);\n this.contentWrapper.appendChild(this.iframeWrapper);\n this.container.appendChild(this.contentWrapper);\n\n this.setupModalBehaviors();\n }\n\n /**\n * Sets up modal-specific behaviors like click handlers and close button\n */\n private setupModalBehaviors(): void {\n if (!this.contentWrapper) return;\n\n // Stop propagation on content wrapper to prevent backdrop clicks\n this.contentWrapper.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n });\n\n // Add close button for modal mode (initially hidden if not loaded)\n if (this.onClose && !this.closeButton) {\n this.closeButton = createCloseButton(this.onClose);\n // Show close button immediately if iframe is already loaded, otherwise keep hidden\n this.closeButton.style.opacity = this.isIframeLoaded ? \"1\" : \"0\";\n this.contentWrapper.appendChild(this.closeButton);\n }\n\n // Add click-to-close functionality after content is added\n if (!this.clickHandler) {\n this.clickHandler = (e: MouseEvent) => {\n if (e.target === this.container) {\n // Only close if clicking the backdrop, not the iframe content\n this.onClose?.();\n }\n };\n this.container.addEventListener(\"click\", this.clickHandler);\n }\n }\n\n /**\n * Sets up the iframe for embedded display mode\n */\n private setupEmbeddedIframe(): void {\n if (!this.iframe) return;\n\n // Embedded mode - create wrapper with border radius and overflow hidden\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\n this.iframeWrapper.style.overflowX = \"hidden\";\n this.iframeWrapper.style.overflowY = \"hidden\";\n this.iframeWrapper.style.transition = \"all 0.5s ease-in-out\";\n this.iframeWrapper.style.width = \"100%\";\n this.iframeWrapper.style.height = \"auto\";\n this.iframeWrapper.style.minHeight = IframeManager.EMBEDDED_MIN_HEIGHT; // Embedded mode minimum\n\n // Apply initial wrapper styling\n this.applyIframeWrapperStyling();\n\n // Add shimmer loader for embedded mode with max width\n this.showShimmerLoader(\n this.iframeWrapper,\n \"white\",\n IframeManager.MODAL_WIDTH,\n );\n\n // Add iframe to wrapper, then wrapper to container\n this.iframeWrapper.appendChild(this.iframe);\n this.container.appendChild(this.iframeWrapper);\n }\n\n private showShimmerLoader(\n parentElement: HTMLElement,\n backgroundColor = \"white\",\n maxWidth?: string,\n ): void {\n if (!this.isIframeLoaded && !this.shimmerLoader) {\n this.shimmerLoader = createIframeShimmerLoader(backgroundColor, maxWidth);\n parentElement.appendChild(this.shimmerLoader);\n }\n }\n\n private hideShimmerLoader(): void {\n if (this.shimmerLoader && this.shimmerLoader.parentNode) {\n // Store reference for cleanup\n const shimmerElement = this.shimmerLoader;\n\n // Clear reference immediately to allow resize operations\n this.shimmerLoader = null;\n\n // Add fade-out transition before removing\n shimmerElement.style.opacity = \"0\";\n shimmerElement.style.transition = `opacity ${IframeManager.TRANSITION_DURATION} ease`;\n\n // Remove after transition completes\n setTimeout(() => {\n if (shimmerElement && shimmerElement.parentNode) {\n shimmerElement.parentNode.removeChild(shimmerElement);\n }\n }, parseInt(IframeManager.TRANSITION_DURATION));\n }\n }\n\n private markIframeAsLoaded(): void {\n if (IframeManager.browserCorsFailsSilentlyUrl) {\n return;\n }\n if (!this.isIframeLoaded) {\n this.isIframeLoaded = true;\n this.hideShimmerLoader();\n this.updateWrapperForLoadedContent();\n }\n }\n\n private updateWrapperForLoadedContent(): void {\n // Fade in the iframe\n if (this.iframe) {\n this.iframe.style.opacity = \"1\";\n }\n\n // Show close button for modal mode when content is loaded\n if (this.displayMode === \"modal\" && this.closeButton) {\n this.closeButton.style.opacity = \"1\";\n }\n\n // Find the iframe wrapper and update its styles for loaded content\n const iframeWrapper = this.iframe?.parentElement;\n if (iframeWrapper) {\n // Remove minimum height constraints to allow natural sizing\n if (this.displayMode === \"modal\") {\n iframeWrapper.style.minHeight = \"auto\";\n } else {\n // For embedded mode, keep some minimum but allow natural growth\n iframeWrapper.style.minHeight = \"auto\";\n }\n\n // Add border radius transition for loaded state (matching React implementation)\n iframeWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n }\n }\n\n public hide(): void {\n if (this.displayMode === \"modal\") {\n // Hide immediately without transition\n this.container.style.transition = \"none\";\n this.container.style.opacity = \"0\";\n }\n this.container.style.display = \"none\";\n }\n\n public show(): void {\n if (this.displayMode === \"modal\") {\n // Show immediately, then fade in\n this.container.style.display = \"flex\";\n this.container.style.opacity = \"0\";\n this.container.style.transition = `opacity ${IframeManager.TRANSITION_DURATION} ease`;\n\n // Use setTimeout to ensure display change takes effect before opacity transition\n setTimeout(() => {\n this.container.style.opacity = \"1\";\n }, 10);\n } else {\n // For embedded mode, just show immediately\n this.container.style.display = \"block\";\n this.container.style.opacity = \"1\";\n }\n }\n\n private cleanupIframeOnly(): void {\n if (this.resizer) {\n this.resizer.cleanup();\n this.resizer = null;\n }\n\n // Clean up shimmer loader\n this.hideShimmerLoader();\n\n // Clean up close button\n if (this.closeButton && this.closeButton.parentNode) {\n this.closeButton.parentNode.removeChild(this.closeButton);\n this.closeButton = null;\n }\n\n // Clean up message listener\n if (this.iframeReadyMessageListener) {\n window.removeEventListener(\"message\", this.iframeReadyMessageListener);\n this.iframeReadyMessageListener = undefined;\n }\n\n if (this.iframe && this.iframe.parentNode) {\n this.iframe.parentNode.removeChild(this.iframe);\n this.iframe = null;\n }\n\n // Reset loading state\n this.isIframeLoaded = false;\n\n // Reset preload state\n this.isPreloaded = false;\n this.preloadUrl = null;\n\n // Clear wrapper references\n this.contentWrapper = null;\n this.iframeWrapper = null;\n\n // Clear container content but DON'T reset styles for modal mode\n this.container.innerHTML = \"\";\n }\n\n public cleanup(): void {\n if (this.resizer) {\n this.resizer.cleanup();\n this.resizer = null;\n }\n\n // Clean up shimmer loader\n this.hideShimmerLoader();\n\n // Clean up close button\n if (this.closeButton && this.closeButton.parentNode) {\n this.closeButton.parentNode.removeChild(this.closeButton);\n this.closeButton = null;\n }\n\n // Clean up message listener\n if (this.iframeReadyMessageListener) {\n window.removeEventListener(\"message\", this.iframeReadyMessageListener);\n this.iframeReadyMessageListener = undefined;\n }\n\n if (this.iframe && this.iframe.parentNode) {\n this.iframe.parentNode.removeChild(this.iframe);\n this.iframe = null;\n }\n\n // Reset loading state\n this.isIframeLoaded = false;\n\n // Reset preload state\n this.isPreloaded = false;\n this.preloadUrl = null;\n\n // Remove keyboard event listener\n if (this.keydownHandler) {\n window.removeEventListener(\"keydown\", this.keydownHandler);\n this.keydownHandler = undefined;\n }\n\n // Remove click event listener\n if (this.clickHandler) {\n this.container.removeEventListener(\"click\", this.clickHandler);\n this.clickHandler = undefined;\n }\n\n // Clear wrapper references\n this.contentWrapper = null;\n this.iframeWrapper = null;\n\n // Clear container content and reset styles\n this.container.innerHTML = \"\";\n\n if (this.displayMode === \"modal\") {\n // Reset all modal-specific styles to ensure clean state\n this.resetModalStyles();\n }\n }\n\n /**\n * Resets all modal-specific styles by removing CSS properties that were set with !important\n */\n private resetModalStyles(): void {\n const modalStyleProperties = [\n \"position\",\n \"left\",\n \"top\",\n \"width\",\n \"height\",\n \"z-index\",\n \"display\",\n \"align-items\",\n \"justify-content\",\n \"background-color\",\n \"backdrop-filter\",\n \"opacity\",\n \"transition\",\n \"margin\",\n \"padding\",\n \"border\",\n \"border-radius\",\n \"min-height\",\n ];\n\n modalStyleProperties.forEach((property) => {\n this.container.style.removeProperty(property);\n });\n }\n\n public resize(): void {\n if (this.resizer) {\n this.resizer.resize();\n }\n }\n\n /**\n * Force show the shimmer loader and hide iframe content\n * Used when we want to mask non-login content\n */\n public forceShowLoader(): void {\n // Reset loading state to show shimmer\n this.isIframeLoaded = false;\n\n // Hide iframe content\n if (this.iframe) {\n this.iframe.style.opacity = \"0\";\n }\n\n // Hide close button\n if (this.displayMode === \"modal\" && this.closeButton) {\n this.closeButton.style.opacity = \"0\";\n }\n\n // Hide visual decorations (borders, shadows) when masking content\n if (this.displayMode === \"modal\") {\n this.removeModalVisualStyling();\n }\n this.removeIframeWrapperStyling();\n\n // Show shimmer loader\n if (this.iframeWrapper && !this.shimmerLoader) {\n this.showShimmerLoader(\n this.iframeWrapper,\n \"white\",\n this.displayMode === \"embedded\" ? IframeManager.MODAL_WIDTH : undefined,\n );\n }\n }\n\n /**\n * Force hide the shimmer loader and show iframe content\n * Used when we want to show the login app\n */\n public forceHideLoader(): void {\n // Restore visual decorations when showing content\n if (this.displayMode === \"modal\") {\n this.applyModalVisualStyling();\n }\n this.applyIframeWrapperStyling();\n\n this.markIframeAsLoaded();\n }\n\n /**\n * Applies visual styling (borders, shadows) to modal content wrapper\n */\n private applyModalVisualStyling(): void {\n if (!this.contentWrapper) return;\n\n this.contentWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n this.contentWrapper.style.boxShadow =\n \"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)\";\n }\n\n /**\n * Removes visual styling (borders, shadows) from modal content wrapper\n */\n private removeModalVisualStyling(): void {\n if (!this.contentWrapper) return;\n\n this.contentWrapper.style.borderRadius = \"0\";\n this.contentWrapper.style.boxShadow = \"none\";\n }\n\n /**\n * Applies visual styling (borders) to iframe wrapper\n */\n private applyIframeWrapperStyling(): void {\n if (!this.iframeWrapper) return;\n\n this.iframeWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n }\n\n /**\n * Removes visual styling (borders) from iframe wrapper\n */\n private removeIframeWrapperStyling(): void {\n if (!this.iframeWrapper) return;\n\n this.iframeWrapper.style.borderRadius = \"0\";\n }\n\n /**\n * Check if an iframe is currently preloaded\n */\n public isIframePreloaded(): boolean {\n return this.isPreloaded;\n }\n\n /**\n * Get the URL of the preloaded iframe\n */\n public getPreloadedUrl(): string | null {\n return this.preloadUrl;\n }\n\n /**\n * Check if shimmer loader is currently active/showing\n */\n private isShimmerActive(): boolean {\n return !this.isIframeLoaded || !!this.shimmerLoader;\n }\n\n /**\n * Update the onClose handler for the iframe manager\n * This is useful when transitioning from preload to active authentication\n */\n public updateOnCloseHandler(onClose: () => void): void {\n this.onClose = onClose;\n }\n\n public showSubtlePopupFallbackIndicator(): void {\n if (!this.iframeWrapper && !this.contentWrapper) {\n this.logger.warn(\n \"Cannot show popup fallback indicator, no iframe wrapper or content wrapper found.\",\n );\n return;\n }\n\n const targetElement = this.iframeWrapper || this.contentWrapper;\n\n if (targetElement) {\n this.logger.debug(\"Showing popup fallback overlay.\");\n\n // Create overlay element\n const overlay = document.createElement(\"div\");\n overlay.id = \"civic-popup-fallback-overlay\";\n overlay.style.cssText = `\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: transparent;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: 1000;\n border-radius: ${IframeManager.BORDER_RADIUS};\n backdrop-filter: blur(.4px);\n opacity: 1;\n `;\n\n // Add overlay to target element\n targetElement.style.position = \"relative\";\n targetElement.appendChild(overlay);\n\n // Remove overlay quickly\n setTimeout(() => {\n if (overlay.parentNode) {\n overlay.parentNode.removeChild(overlay);\n }\n this.logger.debug(\"Popup fallback overlay removed.\");\n }, 500); // Remove after 500ms\n\n this.logger.debug(\"Popup fallback overlay displayed.\");\n }\n }\n}\n"]}
|
|
@@ -4,12 +4,15 @@ export declare class CivicIframeResizer {
|
|
|
4
4
|
private logger;
|
|
5
5
|
private messageListener;
|
|
6
6
|
private requestSizeTimeouts;
|
|
7
|
-
|
|
7
|
+
private isShimmerActiveCallback?;
|
|
8
|
+
private blockedResizeMessages;
|
|
9
|
+
constructor(iframe: HTMLIFrameElement, container: HTMLElement, isShimmerActiveCallback?: () => boolean);
|
|
8
10
|
private initializeResizer;
|
|
9
11
|
private handleMessage;
|
|
10
12
|
private requestSizeFromChild;
|
|
11
13
|
private resizeIframe;
|
|
12
14
|
cleanup(): void;
|
|
13
15
|
resize(): void;
|
|
16
|
+
replayBlockedMessages(): void;
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=IframeResizer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IframeResizer.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/iframe/IframeResizer.ts"],"names":[],"mappings":"AAeA,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,eAAe,CAAgD;IACvE,OAAO,CAAC,mBAAmB,CAAgB;
|
|
1
|
+
{"version":3,"file":"IframeResizer.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/iframe/IframeResizer.ts"],"names":[],"mappings":"AAeA,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,eAAe,CAAgD;IACvE,OAAO,CAAC,mBAAmB,CAAgB;IAC3C,OAAO,CAAC,uBAAuB,CAAC,CAAgB;IAChD,OAAO,CAAC,qBAAqB,CAAuB;gBAGlD,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,WAAW,EACtB,uBAAuB,CAAC,EAAE,MAAM,OAAO;IAUzC,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,YAAY;IAyDb,OAAO,IAAI,IAAI;IAef,MAAM,IAAI,IAAI;IAKd,qBAAqB,IAAI,IAAI;CAgBrC"}
|
|
@@ -11,9 +11,12 @@ export class CivicIframeResizer {
|
|
|
11
11
|
logger;
|
|
12
12
|
messageListener = null;
|
|
13
13
|
requestSizeTimeouts = [];
|
|
14
|
-
|
|
14
|
+
isShimmerActiveCallback;
|
|
15
|
+
blockedResizeMessages = [];
|
|
16
|
+
constructor(iframe, container, isShimmerActiveCallback) {
|
|
15
17
|
this.iframe = iframe;
|
|
16
18
|
this.container = container;
|
|
19
|
+
this.isShimmerActiveCallback = isShimmerActiveCallback;
|
|
17
20
|
this.logger = createLogger("iframe");
|
|
18
21
|
this.initializeResizer();
|
|
19
22
|
}
|
|
@@ -75,6 +78,19 @@ export class CivicIframeResizer {
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
resizeIframe(height, animationDuration) {
|
|
81
|
+
// Skip resizing if shimmer is currently active, but store the message for later
|
|
82
|
+
if (this.isShimmerActiveCallback?.()) {
|
|
83
|
+
this.logger.debug("Skipping iframe resize - shimmer is active");
|
|
84
|
+
// Store the blocked message for later replay
|
|
85
|
+
const blockedMessage = {
|
|
86
|
+
type: MessageType.RESIZE,
|
|
87
|
+
height,
|
|
88
|
+
suggestedAnimationDuration: animationDuration,
|
|
89
|
+
};
|
|
90
|
+
// Replace any existing blocked message (keep only the latest)
|
|
91
|
+
this.blockedResizeMessages = [blockedMessage];
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
78
94
|
// Ensure minimum height
|
|
79
95
|
const minHeight = 200;
|
|
80
96
|
const finalHeight = Math.max(height, minHeight);
|
|
@@ -123,5 +139,18 @@ export class CivicIframeResizer {
|
|
|
123
139
|
// Request size from child iframe
|
|
124
140
|
this.requestSizeFromChild();
|
|
125
141
|
}
|
|
142
|
+
replayBlockedMessages() {
|
|
143
|
+
if (this.blockedResizeMessages.length > 0) {
|
|
144
|
+
// Process all blocked messages
|
|
145
|
+
this.blockedResizeMessages.forEach((message) => {
|
|
146
|
+
if (message.type === MessageType.RESIZE &&
|
|
147
|
+
typeof message.height === "number") {
|
|
148
|
+
this.resizeIframe(message.height, message.suggestedAnimationDuration);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
// Clear the blocked messages
|
|
152
|
+
this.blockedResizeMessages = [];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
126
155
|
}
|
|
127
156
|
//# sourceMappingURL=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AC,SAAS,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;IAChC,CAAC;IAEM,MAAM;QACX,iCAAiC;QACjC,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;CACF","sourcesContent":["// Message types for communication between parent and child\nimport { createLogger } from \"../utils/logger.js\";\n\nenum MessageType {\n RESIZE = \"civic-iframe-resize\",\n READY = \"civic-iframe-ready\",\n}\n\ninterface IframeMessage {\n type: MessageType;\n height?: number;\n messageCount?: number;\n suggestedAnimationDuration?: number;\n}\n\nexport class CivicIframeResizer {\n private iframe: HTMLIFrameElement;\n private container: HTMLElement;\n private logger: ReturnType<typeof createLogger>;\n private messageListener: ((event: MessageEvent) => void) | null = null;\n private requestSizeTimeouts: number[] = [];\n\n constructor(iframe: HTMLIFrameElement, container: HTMLElement) {\n this.iframe = iframe;\n this.container = container;\n this.logger = createLogger(\"iframe\");\n\n this.initializeResizer();\n }\n\n private initializeResizer(): void {\n this.logger.debug(\"Initializing Civic iframe resizer\");\n\n // Set up message listener for iframe resize messages\n this.messageListener = (event: MessageEvent) => {\n this.handleMessage(event);\n };\n\n window.addEventListener(\"message\", this.messageListener);\n\n // Request size from child iframe after it loads\n this.iframe.addEventListener(\"load\", () => {\n this.logger.debug(\"Iframe loaded, requesting size from child\");\n this.requestSizeFromChild();\n\n // Schedule multiple size requests to ensure we get the correct height\n const intervals = [100, 500, 1000, 2000, 3000];\n intervals.forEach((interval) => {\n const timeoutId = window.setTimeout(() => {\n this.requestSizeFromChild();\n }, interval);\n this.requestSizeTimeouts.push(timeoutId);\n });\n });\n }\n\n private handleMessage(event: MessageEvent): void {\n try {\n const message = event.data as IframeMessage;\n\n // Only handle messages from our iframe\n if (\n !this.iframe.contentWindow ||\n event.source !== this.iframe.contentWindow\n ) {\n return;\n }\n\n this.logger.debug(\"Received message from iframe:\", message);\n\n // Handle ready message\n if (message.type === MessageType.READY) {\n this.logger.debug(\"Iframe child is ready\");\n this.requestSizeFromChild();\n }\n\n // Handle resize message\n if (\n message.type === MessageType.RESIZE &&\n typeof message.height === \"number\"\n ) {\n this.logger.debug(\"Resizing iframe to height:\", message.height);\n this.resizeIframe(message.height, message.suggestedAnimationDuration);\n }\n } catch (error) {\n this.logger.debug(\"Error processing iframe message:\", error);\n }\n }\n\n private requestSizeFromChild(): void {\n if (this.iframe.contentWindow) {\n try {\n this.logger.debug(\"Requesting size from iframe child\");\n this.iframe.contentWindow.postMessage({ type: \"request-size\" }, \"*\");\n } catch (error) {\n this.logger.debug(\"Error requesting size from iframe:\", error);\n }\n }\n }\n\n private resizeIframe(height: number, animationDuration?: number): void {\n // Ensure minimum height\n const minHeight = 200;\n const finalHeight = Math.max(height, minHeight);\n\n // Apply height to iframe and ensure no overflow\n this.iframe.style.height = `${finalHeight}px`;\n this.iframe.style.maxHeight = `${finalHeight}px`;\n this.iframe.style.overflow = \"hidden\";\n this.iframe.style.overflowX = \"hidden\";\n this.iframe.style.overflowY = \"hidden\";\n\n // Apply transition if animation duration is suggested\n if (animationDuration) {\n this.iframe.style.transition = `height ${animationDuration}ms ease`;\n }\n\n // Try to inject additional CSS to prevent scrollbars after resize\n try {\n const iframeDoc =\n this.iframe.contentDocument || this.iframe.contentWindow?.document;\n if (iframeDoc && iframeDoc.body) {\n iframeDoc.body.style.overflow = \"hidden\";\n iframeDoc.body.style.overflowX = \"hidden\";\n iframeDoc.body.style.overflowY = \"hidden\";\n if (iframeDoc.documentElement) {\n iframeDoc.documentElement.style.overflow = \"hidden\";\n iframeDoc.documentElement.style.overflowX = \"hidden\";\n iframeDoc.documentElement.style.overflowY = \"hidden\";\n }\n }\n } catch (error) {\n this.logger.debug(\n \"Could not apply overflow styles to iframe content (likely cross-origin):\",\n error,\n );\n }\n\n this.logger.debug(`Iframe resized to ${finalHeight}px`);\n }\n\n public cleanup(): void {\n this.logger.debug(\"Cleaning up iframe resizer\");\n\n if (this.messageListener) {\n window.removeEventListener(\"message\", this.messageListener);\n this.messageListener = null;\n }\n\n // Clear any pending timeouts\n this.requestSizeTimeouts.forEach((timeoutId) => {\n window.clearTimeout(timeoutId);\n });\n this.requestSizeTimeouts = [];\n }\n\n public resize(): void {\n // Request size from child iframe\n this.requestSizeFromChild();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IframeResizer.js","sourceRoot":"","sources":["../../../src/vanillajs/iframe/IframeResizer.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,IAAK,WAGJ;AAHD,WAAK,WAAW;IACd,6CAA8B,CAAA;IAC9B,2CAA4B,CAAA;AAC9B,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;AASD,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAoB;IAC1B,SAAS,CAAc;IACvB,MAAM,CAAkC;IACxC,eAAe,GAA2C,IAAI,CAAC;IAC/D,mBAAmB,GAAa,EAAE,CAAC;IACnC,uBAAuB,CAAiB;IACxC,qBAAqB,GAAoB,EAAE,CAAC;IAEpD,YACE,MAAyB,EACzB,SAAsB,EACtB,uBAAuC;QAEvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;QACvD,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAErC,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAEvD,qDAAqD;QACrD,IAAI,CAAC,eAAe,GAAG,CAAC,KAAmB,EAAE,EAAE;YAC7C,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CA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AAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;QAClC,CAAC;IACH,CAAC;CACF","sourcesContent":["// Message types for communication between parent and child\nimport { createLogger } from \"../utils/logger.js\";\n\nenum MessageType {\n RESIZE = \"civic-iframe-resize\",\n READY = \"civic-iframe-ready\",\n}\n\ninterface IframeMessage {\n type: MessageType;\n height?: number;\n messageCount?: number;\n suggestedAnimationDuration?: number;\n}\n\nexport class CivicIframeResizer {\n private iframe: HTMLIFrameElement;\n private container: HTMLElement;\n private logger: ReturnType<typeof createLogger>;\n private messageListener: ((event: MessageEvent) => void) | null = null;\n private requestSizeTimeouts: number[] = [];\n private isShimmerActiveCallback?: () => boolean;\n private blockedResizeMessages: IframeMessage[] = [];\n\n constructor(\n iframe: HTMLIFrameElement,\n container: HTMLElement,\n isShimmerActiveCallback?: () => boolean,\n ) {\n this.iframe = iframe;\n this.container = container;\n this.isShimmerActiveCallback = isShimmerActiveCallback;\n this.logger = createLogger(\"iframe\");\n\n this.initializeResizer();\n }\n\n private initializeResizer(): void {\n this.logger.debug(\"Initializing Civic iframe resizer\");\n\n // Set up message listener for iframe resize messages\n this.messageListener = (event: MessageEvent) => {\n this.handleMessage(event);\n };\n\n window.addEventListener(\"message\", this.messageListener);\n\n // Request size from child iframe after it loads\n this.iframe.addEventListener(\"load\", () => {\n this.logger.debug(\"Iframe loaded, requesting size from child\");\n this.requestSizeFromChild();\n\n // Schedule multiple size requests to ensure we get the correct height\n const intervals = [100, 500, 1000, 2000, 3000];\n intervals.forEach((interval) => {\n const timeoutId = window.setTimeout(() => {\n this.requestSizeFromChild();\n }, interval);\n this.requestSizeTimeouts.push(timeoutId);\n });\n });\n }\n\n private handleMessage(event: MessageEvent): void {\n try {\n const message = event.data as IframeMessage;\n\n // Only handle messages from our iframe\n if (\n !this.iframe.contentWindow ||\n event.source !== this.iframe.contentWindow\n ) {\n return;\n }\n\n this.logger.debug(\"Received message from iframe:\", message);\n\n // Handle ready message\n if (message.type === MessageType.READY) {\n this.logger.debug(\"Iframe child is ready\");\n this.requestSizeFromChild();\n }\n\n // Handle resize message\n if (\n message.type === MessageType.RESIZE &&\n typeof message.height === \"number\"\n ) {\n this.logger.debug(\"Resizing iframe to height:\", message.height);\n this.resizeIframe(message.height, message.suggestedAnimationDuration);\n }\n } catch (error) {\n this.logger.debug(\"Error processing iframe message:\", error);\n }\n }\n\n private requestSizeFromChild(): void {\n if (this.iframe.contentWindow) {\n try {\n this.logger.debug(\"Requesting size from iframe child\");\n this.iframe.contentWindow.postMessage({ type: \"request-size\" }, \"*\");\n } catch (error) {\n this.logger.debug(\"Error requesting size from iframe:\", error);\n }\n }\n }\n\n private resizeIframe(height: number, animationDuration?: number): void {\n // Skip resizing if shimmer is currently active, but store the message for later\n if (this.isShimmerActiveCallback?.()) {\n this.logger.debug(\"Skipping iframe resize - shimmer is active\");\n\n // Store the blocked message for later replay\n const blockedMessage: IframeMessage = {\n type: MessageType.RESIZE,\n height,\n suggestedAnimationDuration: animationDuration,\n };\n\n // Replace any existing blocked message (keep only the latest)\n this.blockedResizeMessages = [blockedMessage];\n return;\n }\n\n // Ensure minimum height\n const minHeight = 200;\n const finalHeight = Math.max(height, minHeight);\n\n // Apply height to iframe and ensure no overflow\n this.iframe.style.height = `${finalHeight}px`;\n this.iframe.style.maxHeight = `${finalHeight}px`;\n this.iframe.style.overflow = \"hidden\";\n this.iframe.style.overflowX = \"hidden\";\n this.iframe.style.overflowY = \"hidden\";\n\n // Apply transition if animation duration is suggested\n if (animationDuration) {\n this.iframe.style.transition = `height ${animationDuration}ms ease`;\n }\n\n // Try to inject additional CSS to prevent scrollbars after resize\n try {\n const iframeDoc =\n this.iframe.contentDocument || this.iframe.contentWindow?.document;\n if (iframeDoc && iframeDoc.body) {\n iframeDoc.body.style.overflow = \"hidden\";\n iframeDoc.body.style.overflowX = \"hidden\";\n iframeDoc.body.style.overflowY = \"hidden\";\n if (iframeDoc.documentElement) {\n iframeDoc.documentElement.style.overflow = \"hidden\";\n iframeDoc.documentElement.style.overflowX = \"hidden\";\n iframeDoc.documentElement.style.overflowY = \"hidden\";\n }\n }\n } catch (error) {\n this.logger.debug(\n \"Could not apply overflow styles to iframe content (likely cross-origin):\",\n error,\n );\n }\n\n this.logger.debug(`Iframe resized to ${finalHeight}px`);\n }\n\n public cleanup(): void {\n this.logger.debug(\"Cleaning up iframe resizer\");\n\n if (this.messageListener) {\n window.removeEventListener(\"message\", this.messageListener);\n this.messageListener = null;\n }\n\n // Clear any pending timeouts\n this.requestSizeTimeouts.forEach((timeoutId) => {\n window.clearTimeout(timeoutId);\n });\n this.requestSizeTimeouts = [];\n }\n\n public resize(): void {\n // Request size from child iframe\n this.requestSizeFromChild();\n }\n\n public replayBlockedMessages(): void {\n if (this.blockedResizeMessages.length > 0) {\n // Process all blocked messages\n this.blockedResizeMessages.forEach((message) => {\n if (\n message.type === MessageType.RESIZE &&\n typeof message.height === \"number\"\n ) {\n this.resizeIframe(message.height, message.suggestedAnimationDuration);\n }\n });\n\n // Clear the blocked messages\n this.blockedResizeMessages = [];\n }\n }\n}\n"]}
|