@civic/auth 0.11.8-beta.0 → 0.11.8-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "@civic/auth:0.11.8-beta.0";
1
+ export declare const VERSION = "@civic/auth:0.11.8-beta.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // This is an auto-generated file. Do not edit.
2
- export const VERSION = "@civic/auth:0.11.8-beta.0";
2
+ export const VERSION = "@civic/auth:0.11.8-beta.1";
3
3
  //# sourceMappingURL=version.js.map
@@ -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,2BAA2B,CAAC","sourcesContent":["// This is an auto-generated file. Do not edit.\n\nexport const VERSION = \"@civic/auth:0.11.8-beta.0\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/shared/version.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,MAAM,CAAC,MAAM,OAAO,GAAG,2BAA2B,CAAC","sourcesContent":["// This is an auto-generated file. Do not edit.\n\nexport const VERSION = \"@civic/auth:0.11.8-beta.1\";\n"]}
@@ -143,6 +143,15 @@ export declare class MessageHandler {
143
143
  * @param message - The civicloginApp popup failure message to process
144
144
  */
145
145
  private handlePopupFailure;
146
+ /**
147
+ * Handles design messages from civicloginApp.
148
+ *
149
+ * Processes design messages containing customer preferences like colorMode
150
+ * and forwards them to the appropriate handlers.
151
+ *
152
+ * @param data - The design message data payload
153
+ */
154
+ private handleDesignMessage;
146
155
  /**
147
156
  * Handles unknown or unrecognized civicloginApp message types.
148
157
  *
@@ -1 +1 @@
1
- {"version":3,"file":"MessageHandler.d.ts","sourceRoot":"","sources":["../../../../src/vanillajs/auth/handlers/MessageHandler.ts"],"names":[],"mappings":"AACA,OA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AAO,CAAC,kBAAkB;IA8B1B;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAsB3B;;;;;;;OAOG;IACH,OAAO,CAAC,iCAAiC;IAqBzC;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;;;;;;OAOG;IACH,OAAO,CAAC,0BAA0B;IAYlC;;;;;;;OAOG;IACH,OAAO,CAAC,yBAAyB;IAmCjC;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;CAcxB"}
@@ -245,6 +245,7 @@ export class MessageHandler {
245
245
  this.logger.debug("civicloginApp design message", {
246
246
  data: message.data,
247
247
  });
248
+ this.handleDesignMessage(message.data);
248
249
  break;
249
250
  case "auth_success_early":
250
251
  this.logger.info("civicloginApp auth success early message", {
@@ -366,6 +367,35 @@ export class MessageHandler {
366
367
  }
367
368
  this.onPopupFailure(failedUrl);
368
369
  }
370
+ /**
371
+ * Handles design messages from civicloginApp.
372
+ *
373
+ * Processes design messages containing customer preferences like colorMode
374
+ * and forwards them to the appropriate handlers.
375
+ *
376
+ * @param data - The design message data payload
377
+ */
378
+ handleDesignMessage(data) {
379
+ if (!data) {
380
+ this.logger.debug("Design message received with no data");
381
+ return;
382
+ }
383
+ // Handle colorMode preference
384
+ if (data.colorMode) {
385
+ const validColorModes = ["light", "dark", "auto"];
386
+ if (validColorModes.includes(data.colorMode)) {
387
+ this.logger.debug("Setting customer color mode", {
388
+ colorMode: data.colorMode,
389
+ });
390
+ IframeManager.handleLoginAppColorMode(data.colorMode);
391
+ }
392
+ else {
393
+ this.logger.debug("Invalid colorMode value received", {
394
+ colorMode: data.colorMode,
395
+ });
396
+ }
397
+ }
398
+ }
369
399
  /**
370
400
  * Handles unknown or unrecognized civicloginApp message types.
371
401
  *
@@ -1 +1 @@
1
- {"version":3,"file":"MessageHandler.js","sourceRoot":"","sources":["../../../../src/vanillajs/auth/handlers/MessageHandler.ts"],"names":[],"mappings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/C,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,IAAI,cAAc,CAC9B,IAAI,EAAE,MAAM,IAAI,uCAAuC,EACvD,kBAAkB,CAAC,eAAe,CACnC,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { AuthEvent } from \"../../types/index.js\";\nimport type { AuthResult } from \"../../types/index.js\";\nimport type {\n IframeMessage,\n AuthMessage,\n LoginAppMessage,\n ProcessedCivicAuthConfig,\n} from \"../types/AuthTypes.js\";\nimport { CivicAuthError, CivicAuthErrorCode } from \"../types/AuthTypes.js\";\nimport type { createLogger } from \"../../utils/logger.js\";\nimport { createLogger as createLoggerFn } from \"../../utils/logger.js\";\nimport { IframeManager } from \"@/vanillajs/iframe/IframeManager.js\";\n\nexport interface MessageHandlerConfig {\n config: ProcessedCivicAuthConfig;\n logger: ReturnType<typeof createLogger>;\n iframeElement?: HTMLIFrameElement;\n onAuthSuccess: (result: AuthResult) => void;\n onAuthError: (error: Error) => void;\n onPopupFailure: (failedUrl?: string) => void;\n onBrowserCorsFailsSilently: (failedUrl?: string) => Promise<void>;\n cleanup: () => void;\n}\n\n/**\n * MessageHandler - Handles postMessage communication and authentication flow logic\n * Processes messages from iframe, validates origins, and manages auth state transitions\n */\nexport class MessageHandler {\n private config: ProcessedCivicAuthConfig;\n private logger = createLoggerFn(\"message-handler\");\n private iframeElement?: HTMLIFrameElement;\n private onAuthSuccess: (result: AuthResult) => void;\n private onAuthError: (error: Error) => void;\n private onPopupFailure: (failedUrl?: string) => void;\n private onBrowserCorsFailsSilently: (failedUrl?: string) => Promise<void> =\n () => {\n return Promise.resolve(); // No-op by default, can be overridden\n };\n private cleanup: () => void;\n\n // Backend integration - custom expected origin\n private customExpectedOrigin?: string;\n\n constructor(handlerConfig: MessageHandlerConfig) {\n this.config = handlerConfig.config;\n this.iframeElement = handlerConfig.iframeElement;\n this.onAuthSuccess = handlerConfig.onAuthSuccess;\n this.onAuthError = handlerConfig.onAuthError;\n this.onPopupFailure = handlerConfig.onPopupFailure;\n this.onBrowserCorsFailsSilently = handlerConfig.onBrowserCorsFailsSilently;\n this.cleanup = handlerConfig.cleanup;\n }\n\n /**\n * Updates the iframe element reference used for message validation.\n *\n * This method allows updating the iframe element after the MessageHandler\n * has been instantiated, which is useful when the iframe is created\n * dynamically after the handler setup.\n *\n * @param iframeElement - The new iframe element to associate with this handler\n */\n public updateIframeElement(iframeElement: HTMLIFrameElement): void {\n this.iframeElement = iframeElement;\n }\n\n /**\n * Sets a custom expected origin for backend integration.\n *\n * This allows the MessageHandler to accept messages from a custom backend\n * origin instead of the default OAuth server origin.\n *\n * @param customLoginUrl - The custom login URL to derive the origin from\n */\n public setCustomExpectedOrigin(customLoginUrl: string): void {\n this.customExpectedOrigin = new URL(customLoginUrl).origin;\n this.logger.info(\"🔗 Custom expected origin set for backend integration\", {\n customExpectedOrigin: this.customExpectedOrigin,\n customLoginUrl,\n });\n }\n\n /**\n * Clears the custom expected origin and returns to OAuth server origin.\n */\n public clearCustomExpectedOrigin(): void {\n this.customExpectedOrigin = undefined;\n this.logger.info(\n \"🔗 Custom expected origin cleared, returning to OAuth server origin\",\n );\n }\n\n /**\n * Main message handler for processing postMessage events.\n *\n * Validates message origin and source, then routes valid messages to\n * appropriate handlers. This is the entry point for all iframe communication.\n *\n * @param event - The MessageEvent received from the iframe or other sources\n */\n public handleMessage = (event: MessageEvent): void => {\n // Use custom origin if set (for backend integration), otherwise use OAuth server origin\n const expectedOrigin =\n this.customExpectedOrigin ||\n new URL(this.config.oauthServerBaseUrl).origin;\n this.logIncomingMessage(event, expectedOrigin);\n\n if (!this.isValidMessageSource(event, expectedOrigin)) {\n return;\n }\n\n this.handleValidMessage(event);\n };\n\n /**\n * Logs incoming message details for debugging purposes.\n *\n * Provides comprehensive logging of message properties including origin,\n * source validation, and iframe state for troubleshooting communication issues.\n *\n * @param event - The MessageEvent to log\n * @param expectedOrigin - The expected origin for comparison\n */\n private logIncomingMessage(\n event: MessageEvent,\n expectedOrigin: string,\n ): void {\n this.logger.debug(\"Global window received message:\", {\n data: event.data,\n origin: event.origin,\n sourceProvided: !!event.source,\n iframeContentWindow: this.iframeElement?.contentWindow,\n expectedIframeOrigin: expectedOrigin,\n });\n }\n\n /**\n * Validates that a message comes from the expected origin and source.\n *\n * Performs security checks to ensure messages are only processed from\n * the configured OAuth server origin and the designated iframe element.\n *\n * @param event - The MessageEvent to validate\n * @param expectedOrigin - The expected origin URL for the message\n * @returns True if the message source and origin are valid, false otherwise\n */\n private isValidMessageSource(\n event: MessageEvent,\n expectedOrigin: string,\n ): boolean {\n // Check if message is from the iframe source\n const isValidSource = event.source === this.iframeElement?.contentWindow;\n\n // Build list of allowed origins\n const allowedOrigins = [expectedOrigin];\n\n // Add the actual iframe origin (to handle redirects)\n if (this.iframeElement?.src) {\n try {\n const actualIframeOrigin = new URL(this.iframeElement.src).origin;\n allowedOrigins.push(actualIframeOrigin);\n } catch {\n // ignore URL parsing errors\n }\n }\n\n if (this.config.oauthServerBaseUrl) {\n allowedOrigins.push(new URL(this.config.oauthServerBaseUrl).origin);\n }\n\n // Add the client app's own origin (same-origin) for messages sent after token exchange\n // This is needed when the iframe navigates to the client app's callback URL\n const clientOrigin = window.location.origin;\n if (!allowedOrigins.includes(clientOrigin)) {\n allowedOrigins.push(clientOrigin);\n }\n\n // Add common development login app origins for localhost\n const expectedUrl = new URL(expectedOrigin);\n if (expectedUrl.hostname === \"localhost\") {\n // For localhost, also allow common development ports\n allowedOrigins.push(\"http://localhost:3004\"); // default login-app port\n allowedOrigins.push(\"http://localhost:3001\"); // auth server port\n }\n\n const isValidOrigin = allowedOrigins.includes(event.origin);\n\n if (!isValidOrigin) {\n this.logger.warn(\"Ignored message from unexpected origin.\", {\n receivedOrigin: event.origin,\n expectedOrigin,\n allowedOrigins,\n iframeSrc: this.iframeElement?.src,\n });\n }\n\n if (!isValidSource) {\n this.logger.warn(\"Ignored message from unexpected source.\", {\n isSourceProvided: !!event.source,\n isIframeContentWindowAvailable: !!this.iframeElement?.contentWindow,\n iframeSrc: this.iframeElement?.src,\n });\n }\n\n return isValidOrigin && isValidSource;\n }\n\n /**\n * Processes messages that have passed origin and source validation.\n *\n * Routes validated messages to specific handlers based on message type,\n * including civicloginApp messages, iframe resizer messages, and standard auth messages.\n *\n * @param event - The validated MessageEvent to process\n */\n private handleValidMessage(event: MessageEvent): void {\n this.logger.info(\n \"Message from configured iframe source and origin received\",\n {\n data: event.data,\n iframeSrc: this.iframeElement?.src,\n },\n );\n\n const message = event.data as IframeMessage;\n\n this.logger.debug(\"Processing iframe message\", {\n messageType: typeof message,\n hasType: message && typeof message === \"object\" && \"type\" in message,\n hasSource: message && typeof message === \"object\" && \"source\" in message,\n messageKeys:\n message && typeof message === \"object\" ? Object.keys(message) : [],\n rawData: message,\n });\n\n // Handle civicloginApp messages\n if (this.isCivicLoginAppMessage(message)) {\n this.handleCivicLoginAppMessage(message);\n return;\n }\n\n // Handle iframe resizer messages\n if (this.isIframeResizerMessage(message)) {\n this.handleIframeResizerMessage(message);\n return;\n }\n\n // Handle standard auth messages\n this.handleStandardAuthMessage(message);\n }\n\n /**\n * Type guard to identify civicloginApp messages.\n *\n * Checks if a message object has the structure and source property\n * that identifies it as coming from the civicloginApp.\n *\n * @param message - The message object to check\n * @returns True if the message is a LoginAppMessage, false otherwise\n */\n private isCivicLoginAppMessage(message: unknown): message is LoginAppMessage {\n return (\n message !== null &&\n typeof message === \"object\" &&\n \"source\" in message &&\n (message as Record<string, unknown>).source === \"civicloginApp\"\n );\n }\n\n /**\n * Handles messages originating from the civicloginApp.\n *\n * Processes various civicloginApp message types including authentication errors,\n * popup failures, design updates, and other app-specific communications.\n * Validates client ID matches before processing.\n *\n * @param message - The validated civicloginApp message to process\n */\n private handleCivicLoginAppMessage(message: LoginAppMessage): void {\n this.logger.info(\"Received civicloginApp message\", {\n type: message.type,\n clientId: message.clientId,\n data: message.data,\n });\n\n // Validate clientId matches our config\n if (\n message.clientId !== this.config.clientId &&\n this.config.loginUrl === undefined\n ) {\n this.logger.warn(\"civicloginApp message clientId mismatch\", {\n received: message.clientId,\n expected: this.config.clientId,\n });\n return;\n }\n\n switch (message.type) {\n case \"auth_error\":\n case \"auth_error_try_again\":\n this.handleCivicLoginAppError(message);\n break;\n case \"generatePopupFailed\":\n this.handlePopupFailure(message);\n break;\n case \"browserCorsFailsSilently\":\n this.handleBrowserCorsFailsSilently(message);\n break;\n case \"design\":\n this.logger.debug(\"civicloginApp design message\", {\n data: message.data,\n });\n break;\n case \"auth_success_early\":\n this.logger.info(\"civicloginApp auth success early message\", {\n data: message.data,\n });\n this.handleAuthSuccessEarly(message);\n break;\n case \"auth_success\":\n this.logger.info(\"civicloginApp auth success message\", {\n data: message.data,\n });\n\n // Dispatch early auth success event for immediate modal closing\n\n // Still handle auth success normally (for callback processing)\n this.handleAuthSuccess({\n type: \"auth_success\",\n detail: \"Authentication successful\",\n data: message.data,\n });\n break;\n default:\n this.handleUnknownCivicLoginAppMessage(message);\n break;\n }\n }\n\n /**\n * Handles auth success early messages from civicloginApp.\n *\n * Processes auth_success_early messages, emits success events,\n * and triggers the success callback with authentication results.\n *\n * @param message - The civicloginApp auth success early message to process\n */\n\n private handleAuthSuccessEarly(message: LoginAppMessage): void {\n this.logger.info(\"civicloginApp auth success early message\", {\n data: message.data,\n });\n\n const earlySuccessEvent = new CustomEvent(\"civic-auth-success-early\", {\n detail: {\n clientId: message.clientId,\n data: message.data,\n },\n });\n window.dispatchEvent(earlySuccessEvent);\n }\n\n /**\n * Handles authentication error messages from civicloginApp.\n *\n * Processes auth_error and auth_error_try_again messages, creates\n * appropriate error objects, emits error events, and triggers cleanup.\n *\n * @param message - The civicloginApp error message to process\n */\n private handleCivicLoginAppError(message: LoginAppMessage): void {\n this.logger.error(\"civicloginApp authentication error\", {\n type: message.type,\n data: message.data,\n });\n\n const error = new CivicAuthError(\n `Login app error: ${message.type}`,\n CivicAuthErrorCode.INVALID_MESSAGE,\n );\n\n this.config.events?.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: error.message,\n error: message.data,\n });\n\n this.onAuthError(error);\n this.cleanup();\n }\n\n /**\n * Handle the case where we know in advance that the browser will not prompt the user to open\n * a popup and will fail silently instead. We want to handle this case gracefully by switching to redirect\n * mode if the iframe is in modal display mode. This will be done when the auth flow actually starts\n * @param message\n */\n private handleBrowserCorsFailsSilently(message: LoginAppMessage): void {\n const failedUrl = (message.data as Record<string, unknown> | undefined)\n ?.url as string | undefined;\n this.logger.warn(\"civicloginApp browser CORS fail silently\", {\n failedUrl,\n config: this.config,\n autoRedirect: this.config.autoRedirect,\n });\n if (\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"modal\" &&\n this.config.autoRedirect !== false && // Add this check\n failedUrl\n ) {\n IframeManager.handleBrowserCorsFailsSilently(failedUrl);\n this.onBrowserCorsFailsSilently(failedUrl);\n }\n }\n /**\n * Handles popup generation failure messages from civicloginApp.\n *\n * Processes generatePopupFailed messages, extracts the failed URL,\n * emits appropriate events, and triggers the popup failure callback\n * to enable fallback authentication methods.\n *\n * @param message - The civicloginApp popup failure message to process\n */\n private handlePopupFailure(message: LoginAppMessage): void {\n this.logger.warn(\"civicloginApp popup generation failed\", {\n data: message.data,\n });\n\n const failedUrl = (message.data as Record<string, unknown> | undefined)\n ?.url as string | undefined;\n if (failedUrl) {\n this.logger.info(\"Popup failed for URL, considering fallback options\", {\n failedUrl,\n displayMode: this.config.displayMode,\n });\n\n this.config.events?.emit(AuthEvent.URL_CHANGE, {\n detail: \"Popup blocked by browser - switching to redirect mode\",\n url: failedUrl,\n source: \"login_app\",\n failedUrl,\n error: {\n type: \"popup_blocked\",\n failedUrl,\n suggestion:\n \"The browser blocked a popup window. Redirecting to complete authentication in a new page.\",\n },\n });\n }\n\n this.onPopupFailure(failedUrl);\n }\n\n /**\n * Handles unknown or unrecognized civicloginApp message types.\n *\n * Provides fallback handling for unexpected message types, with special\n * logic to detect potential success messages that don't match standard types.\n *\n * @param message - The unrecognized civicloginApp message to process\n */\n private handleUnknownCivicLoginAppMessage(message: LoginAppMessage): void {\n this.logger.debug(\"Unhandled civicloginApp message type\", {\n type: message.type,\n data: message.data,\n });\n\n // Check if this might be a success message with a different type\n if (message.type && message.type.toLowerCase().includes(\"success\")) {\n this.logger.info(\"Potential success message from civicloginApp\", {\n type: message.type,\n data: message.data,\n });\n\n this.handleAuthSuccess({\n type: \"auth_success\",\n detail: `civicloginApp success: ${message.type}`,\n data: message.data,\n });\n }\n }\n\n /**\n * Type guard to identify iframe resizer messages.\n *\n * Checks if a message is related to iframe resizing functionality,\n * including both civic-specific resize messages and iFrameResizerChild messages.\n *\n * @param message - The message object to check\n * @returns True if the message is an iframe resizer message, false otherwise\n */\n private isIframeResizerMessage(message: unknown): boolean {\n return (\n (message !== null &&\n typeof message === \"object\" &&\n \"type\" in message &&\n ((message as Record<string, unknown>).type === \"civic-iframe-resize\" ||\n (message as Record<string, unknown>).type ===\n \"civic-iframe-ready\")) ||\n (typeof message === \"string\" && message.includes(\"iFrameResizerChild\"))\n );\n }\n\n /**\n * Handles iframe resizer messages for dynamic iframe sizing.\n *\n * Processes messages related to iframe resizing, including height adjustments\n * and ready state notifications from the iframe resizer library.\n *\n * @param message - The iframe resizer message to process\n */\n private handleIframeResizerMessage(message: unknown): void {\n if (typeof message === \"string\") {\n this.logger.debug(\"Received iframe resizer child message\", { message });\n } else if (message && typeof message === \"object\" && message !== null) {\n const messageObj = message as Record<string, unknown>;\n this.logger.debug(\"Received iframe resizer message\", {\n type: messageObj.type,\n height: messageObj.height,\n });\n }\n }\n\n /**\n * Handles standard authentication messages.\n *\n * Processes auth_success and auth_error messages that follow the standard\n * authentication message format, routing them to appropriate success or error handlers.\n *\n * @param message - The standard auth message to process\n */\n private handleStandardAuthMessage(message: unknown): void {\n const messageObj =\n message && typeof message === \"object\" && message !== null\n ? (message as Record<string, unknown>)\n : null;\n const messageType = messageObj?.type;\n\n switch (messageType) {\n case \"auth_success\":\n this.handleAuthSuccess(message as AuthMessage);\n break;\n case \"auth_error\":\n this.handleAuthError(message as AuthMessage);\n break;\n default:\n // Check if this is a calculateSubFramePositioning message (expected and harmless)\n if (messageObj?.command === \"calculateSubFramePositioning\") {\n this.logger.debug(\"Received iframe positioning message (expected)\", {\n command: messageObj.command,\n hasSubFrameData: !!messageObj.subFrameData,\n });\n } else {\n this.logger.debug(\n \"Message from iframe did not match expected types (auth_success, auth_error, civicloginApp, iframe-resizer)\",\n {\n data: message,\n messageType: typeof message,\n hasType: messageObj?.type ?? \"none\",\n messageKeys: messageObj ? Object.keys(messageObj) : [],\n },\n );\n }\n }\n }\n\n /**\n * Handles successful authentication completion.\n *\n * Processes authentication success messages, emits success events,\n * triggers the success callback with authentication results, and performs cleanup.\n *\n * @param data - The authentication success message containing result data\n */\n private handleAuthSuccess(data: AuthMessage): void {\n this.config.events?.emit(AuthEvent.SIGN_IN_COMPLETE, {\n detail: \"Success signal received via postMessage\",\n data,\n });\n this.onAuthSuccess((data?.data as AuthResult) || {});\n this.cleanup();\n }\n\n /**\n * Handles authentication errors.\n *\n * Processes authentication error messages, creates appropriate error objects,\n * emits error events, triggers the error callback, and performs cleanup.\n *\n * @param data - The authentication error message containing error details\n */\n private handleAuthError(data: AuthMessage): void {\n this.config.events?.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: \"Error signal received via postMessage\",\n error: data,\n });\n\n const error = new CivicAuthError(\n data?.detail || \"Error signal received via postMessage\",\n CivicAuthErrorCode.INVALID_MESSAGE,\n );\n\n this.onAuthError(error);\n this.cleanup();\n }\n}\n"]}
1
+ {"version":3,"file":"MessageHandler.js","sourceRoot":"","sources":["../../../../src/vanillajs/auth/handlers/MessageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAUjD,OAAO,EAAE,cAAc,EAAE,k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AI,EAAE,OAAO;wBACb,WAAW,EAAE,OAAO,OAAO;wBAC3B,OAAO,EAAE,UAAU,EAAE,IAAI,IAAI,MAAM;wBACnC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;qBACvD,CACF,CAAC;gBACJ,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACK,iBAAiB,CAAC,IAAiB;QACzC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE;YACnD,MAAM,EAAE,yCAAyC;YACjD,IAAI;SACL,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,CAAE,IAAI,EAAE,IAAmB,IAAI,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACK,eAAe,CAAC,IAAiB;QACvC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;YAChD,MAAM,EAAE,uCAAuC;YAC/C,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,IAAI,cAAc,CAC9B,IAAI,EAAE,MAAM,IAAI,uCAAuC,EACvD,kBAAkB,CAAC,eAAe,CACnC,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { AuthEvent } from \"../../types/index.js\";\nimport type { AuthResult } from \"../../types/index.js\";\nimport type {\n IframeMessage,\n AuthMessage,\n LoginAppMessage,\n ProcessedCivicAuthConfig,\n ColorMode,\n DesignMessageData,\n} from \"../types/AuthTypes.js\";\nimport { CivicAuthError, CivicAuthErrorCode } from \"../types/AuthTypes.js\";\nimport type { createLogger } from \"../../utils/logger.js\";\nimport { createLogger as createLoggerFn } from \"../../utils/logger.js\";\nimport { IframeManager } from \"@/vanillajs/iframe/IframeManager.js\";\n\nexport interface MessageHandlerConfig {\n config: ProcessedCivicAuthConfig;\n logger: ReturnType<typeof createLogger>;\n iframeElement?: HTMLIFrameElement;\n onAuthSuccess: (result: AuthResult) => void;\n onAuthError: (error: Error) => void;\n onPopupFailure: (failedUrl?: string) => void;\n onBrowserCorsFailsSilently: (failedUrl?: string) => Promise<void>;\n cleanup: () => void;\n}\n\n/**\n * MessageHandler - Handles postMessage communication and authentication flow logic\n * Processes messages from iframe, validates origins, and manages auth state transitions\n */\nexport class MessageHandler {\n private config: ProcessedCivicAuthConfig;\n private logger = createLoggerFn(\"message-handler\");\n private iframeElement?: HTMLIFrameElement;\n private onAuthSuccess: (result: AuthResult) => void;\n private onAuthError: (error: Error) => void;\n private onPopupFailure: (failedUrl?: string) => void;\n private onBrowserCorsFailsSilently: (failedUrl?: string) => Promise<void> =\n () => {\n return Promise.resolve(); // No-op by default, can be overridden\n };\n private cleanup: () => void;\n\n // Backend integration - custom expected origin\n private customExpectedOrigin?: string;\n\n constructor(handlerConfig: MessageHandlerConfig) {\n this.config = handlerConfig.config;\n this.iframeElement = handlerConfig.iframeElement;\n this.onAuthSuccess = handlerConfig.onAuthSuccess;\n this.onAuthError = handlerConfig.onAuthError;\n this.onPopupFailure = handlerConfig.onPopupFailure;\n this.onBrowserCorsFailsSilently = handlerConfig.onBrowserCorsFailsSilently;\n this.cleanup = handlerConfig.cleanup;\n }\n\n /**\n * Updates the iframe element reference used for message validation.\n *\n * This method allows updating the iframe element after the MessageHandler\n * has been instantiated, which is useful when the iframe is created\n * dynamically after the handler setup.\n *\n * @param iframeElement - The new iframe element to associate with this handler\n */\n public updateIframeElement(iframeElement: HTMLIFrameElement): void {\n this.iframeElement = iframeElement;\n }\n\n /**\n * Sets a custom expected origin for backend integration.\n *\n * This allows the MessageHandler to accept messages from a custom backend\n * origin instead of the default OAuth server origin.\n *\n * @param customLoginUrl - The custom login URL to derive the origin from\n */\n public setCustomExpectedOrigin(customLoginUrl: string): void {\n this.customExpectedOrigin = new URL(customLoginUrl).origin;\n this.logger.info(\"🔗 Custom expected origin set for backend integration\", {\n customExpectedOrigin: this.customExpectedOrigin,\n customLoginUrl,\n });\n }\n\n /**\n * Clears the custom expected origin and returns to OAuth server origin.\n */\n public clearCustomExpectedOrigin(): void {\n this.customExpectedOrigin = undefined;\n this.logger.info(\n \"🔗 Custom expected origin cleared, returning to OAuth server origin\",\n );\n }\n\n /**\n * Main message handler for processing postMessage events.\n *\n * Validates message origin and source, then routes valid messages to\n * appropriate handlers. This is the entry point for all iframe communication.\n *\n * @param event - The MessageEvent received from the iframe or other sources\n */\n public handleMessage = (event: MessageEvent): void => {\n // Use custom origin if set (for backend integration), otherwise use OAuth server origin\n const expectedOrigin =\n this.customExpectedOrigin ||\n new URL(this.config.oauthServerBaseUrl).origin;\n this.logIncomingMessage(event, expectedOrigin);\n\n if (!this.isValidMessageSource(event, expectedOrigin)) {\n return;\n }\n\n this.handleValidMessage(event);\n };\n\n /**\n * Logs incoming message details for debugging purposes.\n *\n * Provides comprehensive logging of message properties including origin,\n * source validation, and iframe state for troubleshooting communication issues.\n *\n * @param event - The MessageEvent to log\n * @param expectedOrigin - The expected origin for comparison\n */\n private logIncomingMessage(\n event: MessageEvent,\n expectedOrigin: string,\n ): void {\n this.logger.debug(\"Global window received message:\", {\n data: event.data,\n origin: event.origin,\n sourceProvided: !!event.source,\n iframeContentWindow: this.iframeElement?.contentWindow,\n expectedIframeOrigin: expectedOrigin,\n });\n }\n\n /**\n * Validates that a message comes from the expected origin and source.\n *\n * Performs security checks to ensure messages are only processed from\n * the configured OAuth server origin and the designated iframe element.\n *\n * @param event - The MessageEvent to validate\n * @param expectedOrigin - The expected origin URL for the message\n * @returns True if the message source and origin are valid, false otherwise\n */\n private isValidMessageSource(\n event: MessageEvent,\n expectedOrigin: string,\n ): boolean {\n // Check if message is from the iframe source\n const isValidSource = event.source === this.iframeElement?.contentWindow;\n\n // Build list of allowed origins\n const allowedOrigins = [expectedOrigin];\n\n // Add the actual iframe origin (to handle redirects)\n if (this.iframeElement?.src) {\n try {\n const actualIframeOrigin = new URL(this.iframeElement.src).origin;\n allowedOrigins.push(actualIframeOrigin);\n } catch {\n // ignore URL parsing errors\n }\n }\n\n if (this.config.oauthServerBaseUrl) {\n allowedOrigins.push(new URL(this.config.oauthServerBaseUrl).origin);\n }\n\n // Add the client app's own origin (same-origin) for messages sent after token exchange\n // This is needed when the iframe navigates to the client app's callback URL\n const clientOrigin = window.location.origin;\n if (!allowedOrigins.includes(clientOrigin)) {\n allowedOrigins.push(clientOrigin);\n }\n\n // Add common development login app origins for localhost\n const expectedUrl = new URL(expectedOrigin);\n if (expectedUrl.hostname === \"localhost\") {\n // For localhost, also allow common development ports\n allowedOrigins.push(\"http://localhost:3004\"); // default login-app port\n allowedOrigins.push(\"http://localhost:3001\"); // auth server port\n }\n\n const isValidOrigin = allowedOrigins.includes(event.origin);\n\n if (!isValidOrigin) {\n this.logger.warn(\"Ignored message from unexpected origin.\", {\n receivedOrigin: event.origin,\n expectedOrigin,\n allowedOrigins,\n iframeSrc: this.iframeElement?.src,\n });\n }\n\n if (!isValidSource) {\n this.logger.warn(\"Ignored message from unexpected source.\", {\n isSourceProvided: !!event.source,\n isIframeContentWindowAvailable: !!this.iframeElement?.contentWindow,\n iframeSrc: this.iframeElement?.src,\n });\n }\n\n return isValidOrigin && isValidSource;\n }\n\n /**\n * Processes messages that have passed origin and source validation.\n *\n * Routes validated messages to specific handlers based on message type,\n * including civicloginApp messages, iframe resizer messages, and standard auth messages.\n *\n * @param event - The validated MessageEvent to process\n */\n private handleValidMessage(event: MessageEvent): void {\n this.logger.info(\n \"Message from configured iframe source and origin received\",\n {\n data: event.data,\n iframeSrc: this.iframeElement?.src,\n },\n );\n\n const message = event.data as IframeMessage;\n\n this.logger.debug(\"Processing iframe message\", {\n messageType: typeof message,\n hasType: message && typeof message === \"object\" && \"type\" in message,\n hasSource: message && typeof message === \"object\" && \"source\" in message,\n messageKeys:\n message && typeof message === \"object\" ? Object.keys(message) : [],\n rawData: message,\n });\n\n // Handle civicloginApp messages\n if (this.isCivicLoginAppMessage(message)) {\n this.handleCivicLoginAppMessage(message);\n return;\n }\n\n // Handle iframe resizer messages\n if (this.isIframeResizerMessage(message)) {\n this.handleIframeResizerMessage(message);\n return;\n }\n\n // Handle standard auth messages\n this.handleStandardAuthMessage(message);\n }\n\n /**\n * Type guard to identify civicloginApp messages.\n *\n * Checks if a message object has the structure and source property\n * that identifies it as coming from the civicloginApp.\n *\n * @param message - The message object to check\n * @returns True if the message is a LoginAppMessage, false otherwise\n */\n private isCivicLoginAppMessage(message: unknown): message is LoginAppMessage {\n return (\n message !== null &&\n typeof message === \"object\" &&\n \"source\" in message &&\n (message as Record<string, unknown>).source === \"civicloginApp\"\n );\n }\n\n /**\n * Handles messages originating from the civicloginApp.\n *\n * Processes various civicloginApp message types including authentication errors,\n * popup failures, design updates, and other app-specific communications.\n * Validates client ID matches before processing.\n *\n * @param message - The validated civicloginApp message to process\n */\n private handleCivicLoginAppMessage(message: LoginAppMessage): void {\n this.logger.info(\"Received civicloginApp message\", {\n type: message.type,\n clientId: message.clientId,\n data: message.data,\n });\n\n // Validate clientId matches our config\n if (\n message.clientId !== this.config.clientId &&\n this.config.loginUrl === undefined\n ) {\n this.logger.warn(\"civicloginApp message clientId mismatch\", {\n received: message.clientId,\n expected: this.config.clientId,\n });\n return;\n }\n\n switch (message.type) {\n case \"auth_error\":\n case \"auth_error_try_again\":\n this.handleCivicLoginAppError(message);\n break;\n case \"generatePopupFailed\":\n this.handlePopupFailure(message);\n break;\n case \"browserCorsFailsSilently\":\n this.handleBrowserCorsFailsSilently(message);\n break;\n case \"design\":\n this.logger.debug(\"civicloginApp design message\", {\n data: message.data,\n });\n this.handleDesignMessage(message.data as DesignMessageData | undefined);\n break;\n case \"auth_success_early\":\n this.logger.info(\"civicloginApp auth success early message\", {\n data: message.data,\n });\n this.handleAuthSuccessEarly(message);\n break;\n case \"auth_success\":\n this.logger.info(\"civicloginApp auth success message\", {\n data: message.data,\n });\n\n // Dispatch early auth success event for immediate modal closing\n\n // Still handle auth success normally (for callback processing)\n this.handleAuthSuccess({\n type: \"auth_success\",\n detail: \"Authentication successful\",\n data: message.data,\n });\n break;\n default:\n this.handleUnknownCivicLoginAppMessage(message);\n break;\n }\n }\n\n /**\n * Handles auth success early messages from civicloginApp.\n *\n * Processes auth_success_early messages, emits success events,\n * and triggers the success callback with authentication results.\n *\n * @param message - The civicloginApp auth success early message to process\n */\n\n private handleAuthSuccessEarly(message: LoginAppMessage): void {\n this.logger.info(\"civicloginApp auth success early message\", {\n data: message.data,\n });\n\n const earlySuccessEvent = new CustomEvent(\"civic-auth-success-early\", {\n detail: {\n clientId: message.clientId,\n data: message.data,\n },\n });\n window.dispatchEvent(earlySuccessEvent);\n }\n\n /**\n * Handles authentication error messages from civicloginApp.\n *\n * Processes auth_error and auth_error_try_again messages, creates\n * appropriate error objects, emits error events, and triggers cleanup.\n *\n * @param message - The civicloginApp error message to process\n */\n private handleCivicLoginAppError(message: LoginAppMessage): void {\n this.logger.error(\"civicloginApp authentication error\", {\n type: message.type,\n data: message.data,\n });\n\n const error = new CivicAuthError(\n `Login app error: ${message.type}`,\n CivicAuthErrorCode.INVALID_MESSAGE,\n );\n\n this.config.events?.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: error.message,\n error: message.data,\n });\n\n this.onAuthError(error);\n this.cleanup();\n }\n\n /**\n * Handle the case where we know in advance that the browser will not prompt the user to open\n * a popup and will fail silently instead. We want to handle this case gracefully by switching to redirect\n * mode if the iframe is in modal display mode. This will be done when the auth flow actually starts\n * @param message\n */\n private handleBrowserCorsFailsSilently(message: LoginAppMessage): void {\n const failedUrl = (message.data as Record<string, unknown> | undefined)\n ?.url as string | undefined;\n this.logger.warn(\"civicloginApp browser CORS fail silently\", {\n failedUrl,\n config: this.config,\n autoRedirect: this.config.autoRedirect,\n });\n if (\n this.config.displayMode === \"iframe\" &&\n this.config.iframeDisplayMode === \"modal\" &&\n this.config.autoRedirect !== false && // Add this check\n failedUrl\n ) {\n IframeManager.handleBrowserCorsFailsSilently(failedUrl);\n this.onBrowserCorsFailsSilently(failedUrl);\n }\n }\n /**\n * Handles popup generation failure messages from civicloginApp.\n *\n * Processes generatePopupFailed messages, extracts the failed URL,\n * emits appropriate events, and triggers the popup failure callback\n * to enable fallback authentication methods.\n *\n * @param message - The civicloginApp popup failure message to process\n */\n private handlePopupFailure(message: LoginAppMessage): void {\n this.logger.warn(\"civicloginApp popup generation failed\", {\n data: message.data,\n });\n\n const failedUrl = (message.data as Record<string, unknown> | undefined)\n ?.url as string | undefined;\n if (failedUrl) {\n this.logger.info(\"Popup failed for URL, considering fallback options\", {\n failedUrl,\n displayMode: this.config.displayMode,\n });\n\n this.config.events?.emit(AuthEvent.URL_CHANGE, {\n detail: \"Popup blocked by browser - switching to redirect mode\",\n url: failedUrl,\n source: \"login_app\",\n failedUrl,\n error: {\n type: \"popup_blocked\",\n failedUrl,\n suggestion:\n \"The browser blocked a popup window. Redirecting to complete authentication in a new page.\",\n },\n });\n }\n\n this.onPopupFailure(failedUrl);\n }\n\n /**\n * Handles design messages from civicloginApp.\n *\n * Processes design messages containing customer preferences like colorMode\n * and forwards them to the appropriate handlers.\n *\n * @param data - The design message data payload\n */\n private handleDesignMessage(data: DesignMessageData | undefined): void {\n if (!data) {\n this.logger.debug(\"Design message received with no data\");\n return;\n }\n\n // Handle colorMode preference\n if (data.colorMode) {\n const validColorModes: ColorMode[] = [\"light\", \"dark\", \"auto\"];\n if (validColorModes.includes(data.colorMode)) {\n this.logger.debug(\"Setting customer color mode\", {\n colorMode: data.colorMode,\n });\n IframeManager.handleLoginAppColorMode(data.colorMode);\n } else {\n this.logger.debug(\"Invalid colorMode value received\", {\n colorMode: data.colorMode,\n });\n }\n }\n }\n\n /**\n * Handles unknown or unrecognized civicloginApp message types.\n *\n * Provides fallback handling for unexpected message types, with special\n * logic to detect potential success messages that don't match standard types.\n *\n * @param message - The unrecognized civicloginApp message to process\n */\n private handleUnknownCivicLoginAppMessage(message: LoginAppMessage): void {\n this.logger.debug(\"Unhandled civicloginApp message type\", {\n type: message.type,\n data: message.data,\n });\n\n // Check if this might be a success message with a different type\n if (message.type && message.type.toLowerCase().includes(\"success\")) {\n this.logger.info(\"Potential success message from civicloginApp\", {\n type: message.type,\n data: message.data,\n });\n\n this.handleAuthSuccess({\n type: \"auth_success\",\n detail: `civicloginApp success: ${message.type}`,\n data: message.data,\n });\n }\n }\n\n /**\n * Type guard to identify iframe resizer messages.\n *\n * Checks if a message is related to iframe resizing functionality,\n * including both civic-specific resize messages and iFrameResizerChild messages.\n *\n * @param message - The message object to check\n * @returns True if the message is an iframe resizer message, false otherwise\n */\n private isIframeResizerMessage(message: unknown): boolean {\n return (\n (message !== null &&\n typeof message === \"object\" &&\n \"type\" in message &&\n ((message as Record<string, unknown>).type === \"civic-iframe-resize\" ||\n (message as Record<string, unknown>).type ===\n \"civic-iframe-ready\")) ||\n (typeof message === \"string\" && message.includes(\"iFrameResizerChild\"))\n );\n }\n\n /**\n * Handles iframe resizer messages for dynamic iframe sizing.\n *\n * Processes messages related to iframe resizing, including height adjustments\n * and ready state notifications from the iframe resizer library.\n *\n * @param message - The iframe resizer message to process\n */\n private handleIframeResizerMessage(message: unknown): void {\n if (typeof message === \"string\") {\n this.logger.debug(\"Received iframe resizer child message\", { message });\n } else if (message && typeof message === \"object\" && message !== null) {\n const messageObj = message as Record<string, unknown>;\n this.logger.debug(\"Received iframe resizer message\", {\n type: messageObj.type,\n height: messageObj.height,\n });\n }\n }\n\n /**\n * Handles standard authentication messages.\n *\n * Processes auth_success and auth_error messages that follow the standard\n * authentication message format, routing them to appropriate success or error handlers.\n *\n * @param message - The standard auth message to process\n */\n private handleStandardAuthMessage(message: unknown): void {\n const messageObj =\n message && typeof message === \"object\" && message !== null\n ? (message as Record<string, unknown>)\n : null;\n const messageType = messageObj?.type;\n\n switch (messageType) {\n case \"auth_success\":\n this.handleAuthSuccess(message as AuthMessage);\n break;\n case \"auth_error\":\n this.handleAuthError(message as AuthMessage);\n break;\n default:\n // Check if this is a calculateSubFramePositioning message (expected and harmless)\n if (messageObj?.command === \"calculateSubFramePositioning\") {\n this.logger.debug(\"Received iframe positioning message (expected)\", {\n command: messageObj.command,\n hasSubFrameData: !!messageObj.subFrameData,\n });\n } else {\n this.logger.debug(\n \"Message from iframe did not match expected types (auth_success, auth_error, civicloginApp, iframe-resizer)\",\n {\n data: message,\n messageType: typeof message,\n hasType: messageObj?.type ?? \"none\",\n messageKeys: messageObj ? Object.keys(messageObj) : [],\n },\n );\n }\n }\n }\n\n /**\n * Handles successful authentication completion.\n *\n * Processes authentication success messages, emits success events,\n * triggers the success callback with authentication results, and performs cleanup.\n *\n * @param data - The authentication success message containing result data\n */\n private handleAuthSuccess(data: AuthMessage): void {\n this.config.events?.emit(AuthEvent.SIGN_IN_COMPLETE, {\n detail: \"Success signal received via postMessage\",\n data,\n });\n this.onAuthSuccess((data?.data as AuthResult) || {});\n this.cleanup();\n }\n\n /**\n * Handles authentication errors.\n *\n * Processes authentication error messages, creates appropriate error objects,\n * emits error events, triggers the error callback, and performs cleanup.\n *\n * @param data - The authentication error message containing error details\n */\n private handleAuthError(data: AuthMessage): void {\n this.config.events?.emit(AuthEvent.SIGN_IN_ERROR, {\n detail: \"Error signal received via postMessage\",\n error: data,\n });\n\n const error = new CivicAuthError(\n data?.detail || \"Error signal received via postMessage\",\n CivicAuthErrorCode.INVALID_MESSAGE,\n );\n\n this.onAuthError(error);\n this.cleanup();\n }\n}\n"]}
@@ -39,6 +39,16 @@ export declare const CIVIC_AUTH_CONSTANTS: {
39
39
  readonly SUCCESS_SIGNAL_ID: "civic-auth-success-signal";
40
40
  readonly ERROR_SIGNAL_ID: "civic-auth-error-signal";
41
41
  };
42
+ /**
43
+ * Color mode preference for iframe background
44
+ */
45
+ export type ColorMode = "light" | "dark" | "auto";
46
+ /**
47
+ * Data payload for design messages from login-app
48
+ */
49
+ export interface DesignMessageData {
50
+ colorMode?: ColorMode;
51
+ }
42
52
  /**
43
53
  * Message types for postMessage communication
44
54
  */
@@ -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,EACb,IAAI,EACL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,UAAU,CAAC;AAEhE;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,eAAe,oBAAoB;IACnC,WAAW,gBAAgB;IAC3B,yBAAyB,8BAA8B;IACvD,mBAAmB,wBAAwB;IAC3C,oBAAoB,yBAAyB;IAC7C,iBAAiB,sBAAsB;IACvC,qBAAqB,0BAA0B;IAC/C,eAAe,oBAAoB;IACnC,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,oBAAoB,yBAAyB;IAC7C,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;CAClC;AAED;;GAEG;AACH,eAAO,MAAM,4BAA4B,SAAS,CAAC;AAEnD,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,YAAY,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,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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 User,\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 * Uses discriminated union to make clientId optional when loginUrl is provided\n */\nexport type CivicAuthClientConfig = {\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 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 /** URL to redirect to after successful login - defaults to the page that initiated login */\n loginSuccessUrl?: string;\n /** Initial user data to avoid backend calls during authentication state checks.\n * - User object: user is authenticated\n * - null: explicitly no user (skip backend checks)\n * - undefined: unknown state (check backend)\n */\n initialUser?: User | null;\n /** Base path for application deployment - affects all URLs, redirects, and cookie paths when app is served from a subdirectory */\n basePath?: string;\n} & (\n | {\n /** OAuth client ID - required for standard OAuth flow */\n clientId: string;\n /** Custom login URL for backend integration - optional */\n loginUrl?: string;\n }\n | {\n /** OAuth client ID - optional when using backend integration */\n clientId?: string;\n /** Custom login URL for backend integration - required when clientId is not provided */\n loginUrl: string;\n }\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 * Maintains the discriminated union structure for clientId/loginUrl\n */\nexport type ProcessedCivicAuthConfig = {\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 backendEndpoints?: BackendEndpoints;\n preloadIframe: boolean;\n autoRedirect: boolean;\n // targetContainerElement remains optional as it's not needed for all display modes\n targetContainerElement?: HTMLElement | string;\n iframeDisplayMode?: \"modal\" | \"embedded\";\n events?: AuthenticationEvents;\n initialState?: string;\n framework?: FrameworkType;\n loginSuccessUrl?: string;\n initialUser?: User | null;\n basePath?: string;\n} & (\n | {\n /** OAuth client ID - required for standard OAuth flow */\n clientId: string;\n /** Custom login URL for backend integration - optional */\n loginUrl?: string;\n }\n | {\n /** OAuth client ID - optional when using backend integration */\n clientId?: string;\n /** Custom login URL for backend integration - required when clientId is not provided */\n loginUrl: string;\n }\n);\n"]}
1
+ {"version":3,"file":"AuthTypes.js","sourceRoot":"","sources":["../../../../src/vanillajs/auth/types/AuthTypes.ts"],"names":[],"mappings":"AAgBA;;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;AA4CX,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 User,\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 * Color mode preference for iframe background\n */\nexport type ColorMode = \"light\" | \"dark\" | \"auto\";\n\n/**\n * Data payload for design messages from login-app\n */\nexport interface DesignMessageData {\n colorMode?: ColorMode;\n}\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 * Uses discriminated union to make clientId optional when loginUrl is provided\n */\nexport type CivicAuthClientConfig = {\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 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 /** URL to redirect to after successful login - defaults to the page that initiated login */\n loginSuccessUrl?: string;\n /** Initial user data to avoid backend calls during authentication state checks.\n * - User object: user is authenticated\n * - null: explicitly no user (skip backend checks)\n * - undefined: unknown state (check backend)\n */\n initialUser?: User | null;\n /** Base path for application deployment - affects all URLs, redirects, and cookie paths when app is served from a subdirectory */\n basePath?: string;\n} & (\n | {\n /** OAuth client ID - required for standard OAuth flow */\n clientId: string;\n /** Custom login URL for backend integration - optional */\n loginUrl?: string;\n }\n | {\n /** OAuth client ID - optional when using backend integration */\n clientId?: string;\n /** Custom login URL for backend integration - required when clientId is not provided */\n loginUrl: string;\n }\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 * Maintains the discriminated union structure for clientId/loginUrl\n */\nexport type ProcessedCivicAuthConfig = {\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 backendEndpoints?: BackendEndpoints;\n preloadIframe: boolean;\n autoRedirect: boolean;\n // targetContainerElement remains optional as it's not needed for all display modes\n targetContainerElement?: HTMLElement | string;\n iframeDisplayMode?: \"modal\" | \"embedded\";\n events?: AuthenticationEvents;\n initialState?: string;\n framework?: FrameworkType;\n loginSuccessUrl?: string;\n initialUser?: User | null;\n basePath?: string;\n} & (\n | {\n /** OAuth client ID - required for standard OAuth flow */\n clientId: string;\n /** Custom login URL for backend integration - optional */\n loginUrl?: string;\n }\n | {\n /** OAuth client ID - optional when using backend integration */\n clientId?: string;\n /** Custom login URL for backend integration - required when clientId is not provided */\n loginUrl: string;\n }\n);\n"]}
@@ -1,3 +1,4 @@
1
+ import type { ColorMode } from "../../vanillajs/auth/types/AuthTypes.js";
1
2
  export interface IframeConfig {
2
3
  container: HTMLElement;
3
4
  displayMode: "embedded" | "modal";
@@ -38,7 +39,46 @@ export declare class IframeManager {
38
39
  private isPreloaded;
39
40
  private preloadUrl;
40
41
  static browserCorsFailsSilentlyUrl: string | null;
42
+ /**
43
+ * Customer color mode preference from login-app.
44
+ * This is static/global state shared across all IframeManager instances.
45
+ * Only one active color mode preference is supported at a time.
46
+ */
47
+ private static customerColorMode;
48
+ /**
49
+ * Reference to the current active iframe wrapper for color mode updates.
50
+ * This is static/global state - only one active iframe wrapper is supported.
51
+ * The wrapper is registered when created and cleared on cleanup.
52
+ */
53
+ private static activeIframeWrapper;
41
54
  static handleBrowserCorsFailsSilently(url: string): void;
55
+ /**
56
+ * Sets the customer's color mode preference received from login-app
57
+ * and updates the background color of any active iframe wrapper.
58
+ *
59
+ * Note: This is a static method that maintains global state across all
60
+ * IframeManager instances. Only one active iframe wrapper is supported.
61
+ *
62
+ * @param colorMode - The color mode preference: "light", "dark", or "auto"
63
+ */
64
+ static handleLoginAppColorMode(colorMode: ColorMode): void;
65
+ /**
66
+ * Gets the background color for a given color mode.
67
+ * For "auto" mode, uses the system preference via matchMedia.
68
+ *
69
+ * @param colorMode - The color mode: "light", "dark", or "auto"
70
+ * @returns The appropriate background color string
71
+ */
72
+ private static getBackgroundColorForMode;
73
+ /**
74
+ * Gets the current customer color mode preference.
75
+ * @returns The current color mode or null if not set
76
+ */
77
+ static getCustomerColorMode(): ColorMode | null;
78
+ /**
79
+ * Clears the customer color mode preference
80
+ */
81
+ static clearCustomerColorMode(): void;
42
82
  constructor(config: IframeConfig);
43
83
  private initializeContainer;
44
84
  /**
@@ -101,7 +141,7 @@ export declare class IframeManager {
101
141
  */
102
142
  private showLoadingSpinner;
103
143
  /**
104
- * Gets the background color based on the user's theme preference
144
+ * Gets the background color based on customer preference or user's system theme
105
145
  */
106
146
  private getBackgroundColor;
107
147
  private hideShimmerLoader;
@@ -1 +1 @@
1
- {"version":3,"file":"IframeManager.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/iframe/IframeManager.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAA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7C;;;OAGG;IACI,eAAe,IAAI,IAAI;IAgC9B;;;OAGG;IACI,eAAe,IAAI,IAAI;IAU9B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAQ/B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAMhC;;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"}
@@ -1,7 +1,7 @@
1
1
  import { CivicIframeResizer } from "./IframeResizer.js";
2
2
  import { createIframeShimmerLoader, createCenteredLoadingSpinner, createCloseButton, } from "../ui/LoadingComponents.js";
3
3
  import { createLogger } from "../utils/logger.js";
4
- import { WAIT_FOR_LOGIN_APP_BROWSER_DETECTION_TIMEOUT } from "../../constants.js";
4
+ import { WAIT_FOR_LOGIN_APP_BROWSER_DETECTION_TIMEOUT, DARK_BACKGROUND_COLOR, LIGHT_BACKGROUND_COLOR, } from "../../constants.js";
5
5
  /**
6
6
  * IframeManager - Manages iframe visual presentation and DOM lifecycle
7
7
  * Handles styling, positioning, UI components, and iframe element creation/cleanup
@@ -37,10 +37,73 @@ export class IframeManager {
37
37
  isPreloaded = false;
38
38
  preloadUrl = null;
39
39
  static browserCorsFailsSilentlyUrl = null;
40
+ /**
41
+ * Customer color mode preference from login-app.
42
+ * This is static/global state shared across all IframeManager instances.
43
+ * Only one active color mode preference is supported at a time.
44
+ */
45
+ static customerColorMode = null;
46
+ /**
47
+ * Reference to the current active iframe wrapper for color mode updates.
48
+ * This is static/global state - only one active iframe wrapper is supported.
49
+ * The wrapper is registered when created and cleared on cleanup.
50
+ */
51
+ static activeIframeWrapper = null;
40
52
  static handleBrowserCorsFailsSilently(url) {
41
53
  // Store the URL that caused CORS failure for later reference
42
54
  IframeManager.browserCorsFailsSilentlyUrl = url;
43
55
  }
56
+ /**
57
+ * Sets the customer's color mode preference received from login-app
58
+ * and updates the background color of any active iframe wrapper.
59
+ *
60
+ * Note: This is a static method that maintains global state across all
61
+ * IframeManager instances. Only one active iframe wrapper is supported.
62
+ *
63
+ * @param colorMode - The color mode preference: "light", "dark", or "auto"
64
+ */
65
+ static handleLoginAppColorMode(colorMode) {
66
+ IframeManager.customerColorMode = colorMode;
67
+ // Update the active iframe wrapper's background color if it exists
68
+ if (IframeManager.activeIframeWrapper) {
69
+ const backgroundColor = IframeManager.getBackgroundColorForMode(colorMode);
70
+ IframeManager.activeIframeWrapper.style.backgroundColor = backgroundColor;
71
+ }
72
+ }
73
+ /**
74
+ * Gets the background color for a given color mode.
75
+ * For "auto" mode, uses the system preference via matchMedia.
76
+ *
77
+ * @param colorMode - The color mode: "light", "dark", or "auto"
78
+ * @returns The appropriate background color string
79
+ */
80
+ static getBackgroundColorForMode(colorMode) {
81
+ if (colorMode === "dark") {
82
+ return DARK_BACKGROUND_COLOR;
83
+ }
84
+ if (colorMode === "light") {
85
+ return LIGHT_BACKGROUND_COLOR;
86
+ }
87
+ // "auto" - use system preference
88
+ if (typeof window !== "undefined" && window.matchMedia) {
89
+ const isDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
90
+ return isDarkMode ? DARK_BACKGROUND_COLOR : LIGHT_BACKGROUND_COLOR;
91
+ }
92
+ return LIGHT_BACKGROUND_COLOR;
93
+ }
94
+ /**
95
+ * Gets the current customer color mode preference.
96
+ * @returns The current color mode or null if not set
97
+ */
98
+ static getCustomerColorMode() {
99
+ return IframeManager.customerColorMode;
100
+ }
101
+ /**
102
+ * Clears the customer color mode preference
103
+ */
104
+ static clearCustomerColorMode() {
105
+ IframeManager.customerColorMode = null;
106
+ }
44
107
  constructor(config) {
45
108
  // we aren't going to render the iframe if the browser fails silently as we're redirecting
46
109
  this.container = config.container;
@@ -406,6 +469,7 @@ export class IframeManager {
406
469
  this.contentWrapper.style.display = "none"; // Keep hidden during preload
407
470
  // Create inner iframe wrapper
408
471
  this.iframeWrapper = document.createElement("div");
472
+ IframeManager.activeIframeWrapper = this.iframeWrapper;
409
473
  this.iframeWrapper.style.position = "relative";
410
474
  this.iframeWrapper.style.overflow = "hidden";
411
475
  this.iframeWrapper.style.overflowX = "hidden";
@@ -428,6 +492,7 @@ export class IframeManager {
428
492
  return;
429
493
  // Create wrapper but keep it hidden
430
494
  this.iframeWrapper = document.createElement("div");
495
+ IframeManager.activeIframeWrapper = this.iframeWrapper;
431
496
  this.iframeWrapper.style.position = "relative";
432
497
  this.iframeWrapper.style.overflow = "hidden";
433
498
  this.iframeWrapper.style.overflowX = "hidden";
@@ -478,6 +543,7 @@ export class IframeManager {
478
543
  this.applyModalVisualStyling();
479
544
  // Create inner iframe wrapper to match React structure
480
545
  this.iframeWrapper = document.createElement("div");
546
+ IframeManager.activeIframeWrapper = this.iframeWrapper;
481
547
  this.iframeWrapper.style.position = "relative";
482
548
  this.iframeWrapper.style.overflow = "hidden";
483
549
  this.iframeWrapper.style.overflowX = "hidden";
@@ -532,6 +598,7 @@ export class IframeManager {
532
598
  return;
533
599
  // Embedded mode - create wrapper with border radius and overflow hidden
534
600
  this.iframeWrapper = document.createElement("div");
601
+ IframeManager.activeIframeWrapper = this.iframeWrapper;
535
602
  this.iframeWrapper.style.position = "relative";
536
603
  this.iframeWrapper.style.overflow = "hidden";
537
604
  this.iframeWrapper.style.overflowX = "hidden";
@@ -584,18 +651,20 @@ export class IframeManager {
584
651
  }
585
652
  }
586
653
  /**
587
- * Gets the background color based on the user's theme preference
654
+ * Gets the background color based on customer preference or user's system theme
588
655
  */
589
656
  getBackgroundColor() {
590
657
  // Check if we're in a browser environment
591
658
  if (typeof window === "undefined") {
592
659
  return "#8E949D"; // Default gray when SSR
593
660
  }
594
- // Use media query to detect dark mode preference
595
- const isDarkMode = window.matchMedia &&
596
- window.matchMedia("(prefers-color-scheme: dark)").matches;
597
- // Return appropriate background color - matching React constants
598
- return isDarkMode ? "rgb(30, 41, 59)" : "white";
661
+ // Check for customer color mode preference first
662
+ const customerColorMode = IframeManager.customerColorMode;
663
+ if (customerColorMode && customerColorMode !== "auto") {
664
+ return IframeManager.getBackgroundColorForMode(customerColorMode);
665
+ }
666
+ // For "auto" mode or when no preference is set, use system preference
667
+ return IframeManager.getBackgroundColorForMode("auto");
599
668
  }
600
669
  hideShimmerLoader() {
601
670
  if (this.shimmerLoader && this.shimmerLoader.parentNode) {
@@ -716,6 +785,7 @@ export class IframeManager {
716
785
  // Clear wrapper references
717
786
  this.contentWrapper = null;
718
787
  this.iframeWrapper = null;
788
+ IframeManager.activeIframeWrapper = null;
719
789
  // Clear container content but DON'T reset styles for modal mode
720
790
  this.container.innerHTML = "";
721
791
  }
@@ -758,6 +828,7 @@ export class IframeManager {
758
828
  // Clear wrapper references
759
829
  this.contentWrapper = null;
760
830
  this.iframeWrapper = null;
831
+ IframeManager.activeIframeWrapper = null;
761
832
  // Clear container content and reset styles
762
833
  this.container.innerHTML = "";
763
834
  if (this.displayMode === "modal") {
@@ -804,12 +875,14 @@ export class IframeManager {
804
875
  // Clear wrapper references but don't remove from DOM
805
876
  this.contentWrapper = null;
806
877
  this.iframeWrapper = null;
878
+ IframeManager.activeIframeWrapper = null;
807
879
  // For embedded mode, show loading state after cleanup
808
880
  if (this.displayMode === "embedded") {
809
881
  // Find the existing wrapper or create structure for loading state
810
882
  const existingWrapper = this.container.querySelector("[data-civic-wrapper]");
811
883
  if (existingWrapper) {
812
884
  this.iframeWrapper = existingWrapper;
885
+ IframeManager.activeIframeWrapper = this.iframeWrapper;
813
886
  this.forceShowLoader();
814
887
  }
815
888
  else {
@@ -824,6 +897,7 @@ export class IframeManager {
824
897
  recreateEmbeddedStructure() {
825
898
  // Create wrapper for embedded mode
826
899
  this.iframeWrapper = document.createElement("div");
900
+ IframeManager.activeIframeWrapper = this.iframeWrapper;
827
901
  this.iframeWrapper.style.position = "relative";
828
902
  this.iframeWrapper.style.overflow = "hidden";
829
903
  this.iframeWrapper.style.width = "100%";
@@ -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,4BAA4B,EAC5B,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,4CAA4C,EAAE,MAAM,gBAAgB,CAAC;AAW9E;;;GAGG;AACH,MAAM,OAAO,aAAa;IACxB,0CAA0C;IAClC,MAAM,CAAU,aAAa,GAAG,MAAM,CAAC;IACvC,MAAM,CAAU,WAAW,GAAG,OAAO,CAAC,CAAC,QAAQ;IAC/C,MAAM,CAAU,oBAAoB,GAAG,uBAAuB,CAAC;IAC/D,MAAM,CAAU,mBAAmB,GAAG,WAAW,CAAC;IAClD,MAAM,CAAU,aAAa,GAAG,MAAM,CAAC;IACvC,MAAM,CAAU,mBAAmB,GAAG,OAAO,CAAC;IAC9C,MAAM,CAAU,gBAAgB,GAAG,MAAM,CAAC;IAC1C,MAAM,CAAU,mBAAmB,GAAG,OAAO,CAAC;IAC9C,MAAM,CAAU,kBAAkB,GAAG,GAAG,CAAC,CAAC,KAAK;IAE/C,MAAM,GAA6B,IAAI,CAAC;IACxC,SAAS,CAAc;IACvB,OAAO,GAA8B,IAAI,CAAC;IAC1C,WAAW,CAAuB;IAClC,cAAc,CAAkC;IAChD,YAAY,CAA+B;IAC3C,QAAQ,CAAS;IACjB,OAAO,CAAc;IACrB,aAAa,GAAuB,IAAI,CAAC;IACzC,WAAW,GAA6B,IAAI,CAAC;IAC7C,cAAc,GAAG,KAAK,CAAC;IACvB,0BAA0B,CAAiC;IAC3D,MA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AC;YAChD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,mFAAmF,CACpF,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,cAAc,CAAC;QAEhE,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;YAErD,yBAAyB;YACzB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC9C,OAAO,CAAC,EAAE,GAAG,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 createCenteredLoadingSpinner,\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 = \"22rem\"; // 360px\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 = \"26px\";\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 = \"transparent\";\n this.container.style.background = \"transparent\";\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 = \"flex\";\n // Apply wrapper styling that was skipped during preload\n this.applyIframeWrapperStyling();\n // Add loading spinner if content isn't loaded yet\n if (!this.isIframeLoaded) {\n this.showLoadingSpinner();\n }\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 // Show the iframe container for non-preloaded iframes\n // Note: For preloaded iframes, show() is called earlier in the createIframe method\n // For modal mode, setupModalIframe() handles visibility, but embedded mode needs explicit show()\n if (this.displayMode === \"embedded\") {\n this.show();\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 and enable local network access\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 // Include local-network-access permission to allow OAuth redirects to localhost in Chrome 142+\n // The wildcard (*) allows all origins that load in the iframe (including during SSO redirects)\n // to make local network requests when redirecting back to localhost callback URLs.\n //\n // Security Note: The wildcard is necessary because the iframe navigates through multiple origins\n // during OAuth/SSO flows (auth.civic.com → IdP → auth.civic.com → localhost). Third-party IdPs\n // (Google, Microsoft, Apple, custom OIDC) cannot be enumerated ahead of time. This is explicitly\n // recommended by Chrome for SSO scenarios. Security is maintained through:\n // - OAuth state validation preventing redirect hijacking\n // - Server-side redirect_uri whitelist validation\n // - HTTPS requirement preventing MitM attacks\n // - Limited permission lifetime (only while iframe exists)\n //\n // See: https://developer.chrome.com/blog/private-network-access-preflight\n this.iframe.setAttribute(\n \"allow\",\n \"camera; screen-wake-lock; publickey-credentials-get *; publickey-credentials-create *; local-network-access *\",\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.backgroundColor = this.getBackgroundColor();\n this.iframeWrapper.style.display = \"none\"; // Keep hidden during preload\n this.iframeWrapper.style.alignItems = \"center\";\n this.iframeWrapper.style.justifyContent = \"center\";\n\n // Apply initial wrapper styling (border radius)\n this.applyIframeWrapperStyling();\n\n // Create a content wrapper for the iframe\n const iframeContentWrapper = document.createElement(\"div\");\n iframeContentWrapper.style.width = \"100%\";\n iframeContentWrapper.style.minWidth = \"100%\";\n iframeContentWrapper.style.alignItems = \"center\";\n iframeContentWrapper.style.justifyContent = \"center\";\n iframeContentWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n iframeContentWrapper.style.overflow = \"hidden\";\n iframeContentWrapper.style.opacity = \"1\"; // Already loaded during preload\n iframeContentWrapper.style.transition = \"opacity 0.5s ease-in-out\";\n\n // Add iframe to content wrapper\n iframeContentWrapper.appendChild(this.iframe);\n\n // Add content wrapper to main wrapper\n this.iframeWrapper.appendChild(iframeContentWrapper);\n\n // Store reference for later use\n this.contentWrapper = iframeContentWrapper;\n\n // Add wrapper to container\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; // 360px 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 this.iframeWrapper.style.backgroundColor = this.getBackgroundColor();\n this.iframeWrapper.style.display = \"flex\";\n this.iframeWrapper.style.alignItems = \"center\";\n this.iframeWrapper.style.justifyContent = \"center\";\n this.iframeWrapper.setAttribute(\"data-civic-wrapper\", \"true\");\n\n // Apply initial wrapper styling (border radius)\n this.applyIframeWrapperStyling();\n\n // Add centered loading spinner for embedded mode\n this.showLoadingSpinner();\n\n // Create a content wrapper for the iframe\n const iframeContentWrapper = document.createElement(\"div\");\n iframeContentWrapper.style.width = \"100%\";\n iframeContentWrapper.style.minWidth = \"100%\";\n iframeContentWrapper.style.alignItems = \"center\";\n iframeContentWrapper.style.justifyContent = \"center\";\n iframeContentWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n iframeContentWrapper.style.overflow = \"hidden\";\n iframeContentWrapper.style.opacity = \"0\";\n iframeContentWrapper.style.transition = \"opacity 0.5s ease-in-out\";\n\n // Add iframe to content wrapper\n iframeContentWrapper.appendChild(this.iframe);\n\n // Add content wrapper to main wrapper\n this.iframeWrapper.appendChild(iframeContentWrapper);\n\n // Store reference for later use\n this.contentWrapper = iframeContentWrapper;\n\n // Add wrapper to container\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 /**\n * Shows a centered loading spinner for embedded mode\n */\n private showLoadingSpinner(): void {\n if (!this.isIframeLoaded && !this.shimmerLoader && this.iframeWrapper) {\n this.shimmerLoader = createCenteredLoadingSpinner();\n this.iframeWrapper.appendChild(this.shimmerLoader);\n }\n }\n\n /**\n * Gets the background color based on the user's theme preference\n */\n private getBackgroundColor(): string {\n // Check if we're in a browser environment\n if (typeof window === \"undefined\") {\n return \"#8E949D\"; // Default gray when SSR\n }\n\n // Use media query to detect dark mode preference\n const isDarkMode =\n window.matchMedia &&\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n\n // Return appropriate background color - matching React constants\n return isDarkMode ? \"rgb(30, 41, 59)\" : \"white\";\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 // For embedded mode, fade in both the content wrapper and iframe\n if (this.displayMode === \"embedded\" && this.contentWrapper) {\n this.contentWrapper.style.opacity = \"1\";\n // Also make sure the iframe itself is visible\n if (this.iframe) {\n this.iframe.style.opacity = \"1\";\n }\n } else if (this.iframe) {\n // For modal mode, fade in the iframe directly\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 // Fix: Ensure the iframe itself is also visible immediately for embedded mode\n // The iframe starts with opacity: 0 from applyIframeStyles, but embedded mode\n // should show the iframe immediately without waiting for loaded content\n if (this.iframe) {\n this.iframe.style.opacity = \"1\";\n }\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 * Clean up resources without removing the iframe - useful for embedded mode\n * This preserves the iframe and shows loading state after auth success\n */\n public cleanupResourcesOnly(): 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 (only exists in modal mode)\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 // 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 // Reset loading state but keep iframe structure\n this.isIframeLoaded = false;\n\n // Reset preload state\n this.isPreloaded = false;\n this.preloadUrl = null;\n\n // Clear wrapper references but don't remove from DOM\n this.contentWrapper = null;\n this.iframeWrapper = null;\n\n // For embedded mode, show loading state after cleanup\n if (this.displayMode === \"embedded\") {\n // Find the existing wrapper or create structure for loading state\n const existingWrapper = this.container.querySelector(\n \"[data-civic-wrapper]\",\n );\n if (existingWrapper) {\n this.iframeWrapper = existingWrapper as HTMLElement;\n this.forceShowLoader();\n } else {\n // Fallback: recreate basic structure for embedded mode\n this.recreateEmbeddedStructure();\n }\n }\n }\n\n /**\n * Recreate basic embedded structure after cleanup for showing loading state\n */\n private recreateEmbeddedStructure(): void {\n // Create wrapper for embedded mode\n this.iframeWrapper = document.createElement(\"div\");\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\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.backgroundColor = this.getBackgroundColor();\n this.iframeWrapper.style.display = \"flex\";\n this.iframeWrapper.style.alignItems = \"center\";\n this.iframeWrapper.style.justifyContent = \"center\";\n this.iframeWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n this.iframeWrapper.setAttribute(\"data-civic-wrapper\", \"true\");\n\n // Add to container\n this.container.appendChild(this.iframeWrapper);\n\n // Show loading spinner\n this.forceShowLoader();\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 * Get the current display mode\n */\n public getDisplayMode(): \"embedded\" | \"modal\" {\n return this.displayMode;\n }\n\n /**\n * Force show the appropriate 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 loader\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 appropriate loader based on display mode\n if (this.iframeWrapper && !this.shimmerLoader) {\n if (this.displayMode === \"embedded\") {\n // For embedded mode, use the centered loading spinner (original loader)\n this.showLoadingSpinner();\n } else {\n // For modal mode, use the shimmer loader\n this.showShimmerLoader(this.iframeWrapper, \"white\");\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.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 // Add any styles you want to remove here\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"]}
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,4BAA4B,EAC5B,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,4CAA4C,EAC5C,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAYxB;;;GAGG;AACH,MAAM,OAAO,aAAa;IACxB,0CAA0C;IAClC,MAAM,CAAU,aAAa,GAAG,MAAM,CAAC;IACvC,MAAM,CAAU,WAAW,GAAG,OAAO,CAAC,CAAC,QAAQ;IAC/C,MAAM,CAAU,oBAAoB,GAAG,uBAAuB,CAAC;IAC/D,MAAM,CAAU,mBAAmB,GAAG,WAAW,CAAC;IAClD,MAAM,CAAU,aAAa,GAAG,MAAM,CAAC;IACvC,MAAM,CAAU,mBAAmB,GAAG,OAAO,CAAC;IAC9C,MAAM,CAAU,gBAAgB,GAAG,MAAM,CAAC;IAC1C,MAAM,CAAU,mBAAmB,GAAG,OAAO,CAAC;IAC9C,MAAM,CAAU,kBAAkB,GAAG,GAAG,CAAC,CAAC,KAAK;IAE/C,MAAM,GA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AAa,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 createCenteredLoadingSpinner,\n createCloseButton,\n} from \"../ui/LoadingComponents.js\";\nimport { createLogger } from \"../utils/logger.js\";\nimport {\n WAIT_FOR_LOGIN_APP_BROWSER_DETECTION_TIMEOUT,\n DARK_BACKGROUND_COLOR,\n LIGHT_BACKGROUND_COLOR,\n} from \"@/constants.js\";\nimport type { ColorMode } from \"@/vanillajs/auth/types/AuthTypes.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 = \"22rem\"; // 360px\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 = \"26px\";\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 * Customer color mode preference from login-app.\n * This is static/global state shared across all IframeManager instances.\n * Only one active color mode preference is supported at a time.\n */\n private static customerColorMode: ColorMode | null = null;\n\n /**\n * Reference to the current active iframe wrapper for color mode updates.\n * This is static/global state - only one active iframe wrapper is supported.\n * The wrapper is registered when created and cleared on cleanup.\n */\n private static activeIframeWrapper: HTMLElement | 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 /**\n * Sets the customer's color mode preference received from login-app\n * and updates the background color of any active iframe wrapper.\n *\n * Note: This is a static method that maintains global state across all\n * IframeManager instances. Only one active iframe wrapper is supported.\n *\n * @param colorMode - The color mode preference: \"light\", \"dark\", or \"auto\"\n */\n public static handleLoginAppColorMode(colorMode: ColorMode): void {\n IframeManager.customerColorMode = colorMode;\n\n // Update the active iframe wrapper's background color if it exists\n if (IframeManager.activeIframeWrapper) {\n const backgroundColor =\n IframeManager.getBackgroundColorForMode(colorMode);\n IframeManager.activeIframeWrapper.style.backgroundColor = backgroundColor;\n }\n }\n\n /**\n * Gets the background color for a given color mode.\n * For \"auto\" mode, uses the system preference via matchMedia.\n *\n * @param colorMode - The color mode: \"light\", \"dark\", or \"auto\"\n * @returns The appropriate background color string\n */\n private static getBackgroundColorForMode(colorMode: ColorMode): string {\n if (colorMode === \"dark\") {\n return DARK_BACKGROUND_COLOR;\n }\n if (colorMode === \"light\") {\n return LIGHT_BACKGROUND_COLOR;\n }\n // \"auto\" - use system preference\n if (typeof window !== \"undefined\" && window.matchMedia) {\n const isDarkMode = window.matchMedia(\n \"(prefers-color-scheme: dark)\",\n ).matches;\n return isDarkMode ? DARK_BACKGROUND_COLOR : LIGHT_BACKGROUND_COLOR;\n }\n return LIGHT_BACKGROUND_COLOR;\n }\n\n /**\n * Gets the current customer color mode preference.\n * @returns The current color mode or null if not set\n */\n public static getCustomerColorMode(): ColorMode | null {\n return IframeManager.customerColorMode;\n }\n\n /**\n * Clears the customer color mode preference\n */\n public static clearCustomerColorMode(): void {\n IframeManager.customerColorMode = null;\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 = \"transparent\";\n this.container.style.background = \"transparent\";\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 = \"flex\";\n // Apply wrapper styling that was skipped during preload\n this.applyIframeWrapperStyling();\n // Add loading spinner if content isn't loaded yet\n if (!this.isIframeLoaded) {\n this.showLoadingSpinner();\n }\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 // Show the iframe container for non-preloaded iframes\n // Note: For preloaded iframes, show() is called earlier in the createIframe method\n // For modal mode, setupModalIframe() handles visibility, but embedded mode needs explicit show()\n if (this.displayMode === \"embedded\") {\n this.show();\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 and enable local network access\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 // Include local-network-access permission to allow OAuth redirects to localhost in Chrome 142+\n // The wildcard (*) allows all origins that load in the iframe (including during SSO redirects)\n // to make local network requests when redirecting back to localhost callback URLs.\n //\n // Security Note: The wildcard is necessary because the iframe navigates through multiple origins\n // during OAuth/SSO flows (auth.civic.com → IdP → auth.civic.com → localhost). Third-party IdPs\n // (Google, Microsoft, Apple, custom OIDC) cannot be enumerated ahead of time. This is explicitly\n // recommended by Chrome for SSO scenarios. Security is maintained through:\n // - OAuth state validation preventing redirect hijacking\n // - Server-side redirect_uri whitelist validation\n // - HTTPS requirement preventing MitM attacks\n // - Limited permission lifetime (only while iframe exists)\n //\n // See: https://developer.chrome.com/blog/private-network-access-preflight\n this.iframe.setAttribute(\n \"allow\",\n \"camera; screen-wake-lock; publickey-credentials-get *; publickey-credentials-create *; local-network-access *\",\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 IframeManager.activeIframeWrapper = this.iframeWrapper;\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 IframeManager.activeIframeWrapper = this.iframeWrapper;\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.backgroundColor = this.getBackgroundColor();\n this.iframeWrapper.style.display = \"none\"; // Keep hidden during preload\n this.iframeWrapper.style.alignItems = \"center\";\n this.iframeWrapper.style.justifyContent = \"center\";\n\n // Apply initial wrapper styling (border radius)\n this.applyIframeWrapperStyling();\n\n // Create a content wrapper for the iframe\n const iframeContentWrapper = document.createElement(\"div\");\n iframeContentWrapper.style.width = \"100%\";\n iframeContentWrapper.style.minWidth = \"100%\";\n iframeContentWrapper.style.alignItems = \"center\";\n iframeContentWrapper.style.justifyContent = \"center\";\n iframeContentWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n iframeContentWrapper.style.overflow = \"hidden\";\n iframeContentWrapper.style.opacity = \"1\"; // Already loaded during preload\n iframeContentWrapper.style.transition = \"opacity 0.5s ease-in-out\";\n\n // Add iframe to content wrapper\n iframeContentWrapper.appendChild(this.iframe);\n\n // Add content wrapper to main wrapper\n this.iframeWrapper.appendChild(iframeContentWrapper);\n\n // Store reference for later use\n this.contentWrapper = iframeContentWrapper;\n\n // Add wrapper to container\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; // 360px 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 IframeManager.activeIframeWrapper = this.iframeWrapper;\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 IframeManager.activeIframeWrapper = this.iframeWrapper;\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 this.iframeWrapper.style.backgroundColor = this.getBackgroundColor();\n this.iframeWrapper.style.display = \"flex\";\n this.iframeWrapper.style.alignItems = \"center\";\n this.iframeWrapper.style.justifyContent = \"center\";\n this.iframeWrapper.setAttribute(\"data-civic-wrapper\", \"true\");\n\n // Apply initial wrapper styling (border radius)\n this.applyIframeWrapperStyling();\n\n // Add centered loading spinner for embedded mode\n this.showLoadingSpinner();\n\n // Create a content wrapper for the iframe\n const iframeContentWrapper = document.createElement(\"div\");\n iframeContentWrapper.style.width = \"100%\";\n iframeContentWrapper.style.minWidth = \"100%\";\n iframeContentWrapper.style.alignItems = \"center\";\n iframeContentWrapper.style.justifyContent = \"center\";\n iframeContentWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n iframeContentWrapper.style.overflow = \"hidden\";\n iframeContentWrapper.style.opacity = \"0\";\n iframeContentWrapper.style.transition = \"opacity 0.5s ease-in-out\";\n\n // Add iframe to content wrapper\n iframeContentWrapper.appendChild(this.iframe);\n\n // Add content wrapper to main wrapper\n this.iframeWrapper.appendChild(iframeContentWrapper);\n\n // Store reference for later use\n this.contentWrapper = iframeContentWrapper;\n\n // Add wrapper to container\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 /**\n * Shows a centered loading spinner for embedded mode\n */\n private showLoadingSpinner(): void {\n if (!this.isIframeLoaded && !this.shimmerLoader && this.iframeWrapper) {\n this.shimmerLoader = createCenteredLoadingSpinner();\n this.iframeWrapper.appendChild(this.shimmerLoader);\n }\n }\n\n /**\n * Gets the background color based on customer preference or user's system theme\n */\n private getBackgroundColor(): string {\n // Check if we're in a browser environment\n if (typeof window === \"undefined\") {\n return \"#8E949D\"; // Default gray when SSR\n }\n\n // Check for customer color mode preference first\n const customerColorMode = IframeManager.customerColorMode;\n if (customerColorMode && customerColorMode !== \"auto\") {\n return IframeManager.getBackgroundColorForMode(customerColorMode);\n }\n\n // For \"auto\" mode or when no preference is set, use system preference\n return IframeManager.getBackgroundColorForMode(\"auto\");\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 // For embedded mode, fade in both the content wrapper and iframe\n if (this.displayMode === \"embedded\" && this.contentWrapper) {\n this.contentWrapper.style.opacity = \"1\";\n // Also make sure the iframe itself is visible\n if (this.iframe) {\n this.iframe.style.opacity = \"1\";\n }\n } else if (this.iframe) {\n // For modal mode, fade in the iframe directly\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 // Fix: Ensure the iframe itself is also visible immediately for embedded mode\n // The iframe starts with opacity: 0 from applyIframeStyles, but embedded mode\n // should show the iframe immediately without waiting for loaded content\n if (this.iframe) {\n this.iframe.style.opacity = \"1\";\n }\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 IframeManager.activeIframeWrapper = 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 IframeManager.activeIframeWrapper = 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 * Clean up resources without removing the iframe - useful for embedded mode\n * This preserves the iframe and shows loading state after auth success\n */\n public cleanupResourcesOnly(): 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 (only exists in modal mode)\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 // 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 // Reset loading state but keep iframe structure\n this.isIframeLoaded = false;\n\n // Reset preload state\n this.isPreloaded = false;\n this.preloadUrl = null;\n\n // Clear wrapper references but don't remove from DOM\n this.contentWrapper = null;\n this.iframeWrapper = null;\n IframeManager.activeIframeWrapper = null;\n\n // For embedded mode, show loading state after cleanup\n if (this.displayMode === \"embedded\") {\n // Find the existing wrapper or create structure for loading state\n const existingWrapper = this.container.querySelector(\n \"[data-civic-wrapper]\",\n );\n if (existingWrapper) {\n this.iframeWrapper = existingWrapper as HTMLElement;\n IframeManager.activeIframeWrapper = this.iframeWrapper;\n this.forceShowLoader();\n } else {\n // Fallback: recreate basic structure for embedded mode\n this.recreateEmbeddedStructure();\n }\n }\n }\n\n /**\n * Recreate basic embedded structure after cleanup for showing loading state\n */\n private recreateEmbeddedStructure(): void {\n // Create wrapper for embedded mode\n this.iframeWrapper = document.createElement(\"div\");\n IframeManager.activeIframeWrapper = this.iframeWrapper;\n this.iframeWrapper.style.position = \"relative\";\n this.iframeWrapper.style.overflow = \"hidden\";\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.backgroundColor = this.getBackgroundColor();\n this.iframeWrapper.style.display = \"flex\";\n this.iframeWrapper.style.alignItems = \"center\";\n this.iframeWrapper.style.justifyContent = \"center\";\n this.iframeWrapper.style.borderRadius = IframeManager.BORDER_RADIUS;\n this.iframeWrapper.setAttribute(\"data-civic-wrapper\", \"true\");\n\n // Add to container\n this.container.appendChild(this.iframeWrapper);\n\n // Show loading spinner\n this.forceShowLoader();\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 * Get the current display mode\n */\n public getDisplayMode(): \"embedded\" | \"modal\" {\n return this.displayMode;\n }\n\n /**\n * Force show the appropriate 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 loader\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 appropriate loader based on display mode\n if (this.iframeWrapper && !this.shimmerLoader) {\n if (this.displayMode === \"embedded\") {\n // For embedded mode, use the centered loading spinner (original loader)\n this.showLoadingSpinner();\n } else {\n // For modal mode, use the shimmer loader\n this.showShimmerLoader(this.iframeWrapper, \"white\");\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.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 // Add any styles you want to remove here\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civic/auth",
3
- "version": "0.11.8-beta.0",
3
+ "version": "0.11.8-beta.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",