@juspay-tech/hyperswitch-control-center-embed-core 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -76
- package/dist/element.d.ts +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +162 -57
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +163 -56
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +163 -56
- package/dist/index.umd.js.map +1 -1
- package/dist/payments.d.ts +8 -0
- package/dist/refunds.d.ts +8 -0
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/element.ts","../src/connector-configuration.ts","../src/init-config.ts","../src/hyperswitch.ts","../src/index.ts"],"sourcesContent":["import { Hyperswitch } from './hyperswitch';\nimport { ElementOptions } from './types';\n\nconst isBrowser = typeof window !== 'undefined';\n\nabstract class HyperswitchElement {\n protected instance: Hyperswitch;\n protected options: ElementOptions;\n public element!: HTMLElement;\n protected iframe!: HTMLIFrameElement;\n private boundMessageHandler: ((event: MessageEvent) => void) | null;\n public readonly _internalId: string;\n \n constructor(instance: Hyperswitch, options?: ElementOptions) {\n this.instance = instance;\n this.options = options || {};\n this._internalId = `hyper-el-${Math.random().toString(36).substring(7)}`;\n this.boundMessageHandler = null;\n // In SSR / non-browser environments, avoid touching DOM APIs.\n // The React wrapper only creates and mounts elements on the client,\n // so it's safe for server-side usage as long as we no-op here.\n if (!isBrowser) {\n return;\n }\n \n this.element = document.createElement('div');\n this.iframe = document.createElement('iframe');\n this.boundMessageHandler = this.handleMessage.bind(this);\n \n this.setupElement();\n this.setupIframe();\n window.addEventListener('message', this.boundMessageHandler);\n }\n\n private setupElement(): void {\n if (!isBrowser) {\n return;\n }\n\n this.element.className = `hyperswitch-element ${this.options.className || ''}`.trim();\n this.element.dataset.hyperswitchElement = this.getElementType();\n \n Object.assign(this.element.style, {\n width: this.options.width || '100%',\n height: this.options.height || '500px',\n overflow: 'hidden',\n ...(this.options.style || {})\n });\n }\n \n private setupIframe(): void {\n if (!isBrowser) {\n return;\n }\n\n this.iframe.src = this.getIframeSrc();\n this.iframe.style.border = 'none';\n this.iframe.style.width = '100%';\n this.iframe.style.height = '100%';\n this.iframe.title = `Hyperswitch ${this.getElementType()}`;\n this.iframe.setAttribute('allow', 'clipboard-read; clipboard-write; clipboard-sanitized-write');\n this.iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-presentation allow-downloads');\n \n this.element.appendChild(this.iframe);\n }\n \n private handleMessage(event: MessageEvent): void {\n if (!isBrowser) {\n return;\n }\n\n if (this.options.onMessage) {\n this.options.onMessage(event.data);\n }\n \n if (event.data?.type === 'EMBEDDED_COMPONENT_RESIZE') {\n const newHeight = event.data.height;\n const messageComponent = event.data.component || '';\n \n if (messageComponent === this.getElementType() && typeof newHeight === 'number' && newHeight > 0) {\n this.element.style.height = `${newHeight}px`;\n \n if (this.options.onResize) {\n this.options.onResize({\n width: this.element.clientWidth,\n height: newHeight\n });\n }\n }\n }\n }\n \n mount(domNode: string | HTMLElement): HyperswitchElement {\n if (!isBrowser) {\n throw new Error('HyperswitchElement.mount can only be called in a browser environment');\n }\n\n const parent = typeof domNode === 'string' \n ? document.querySelector(domNode) \n : domNode;\n \n if (!parent) {\n throw new Error(`Invalid mount point: ${domNode}`);\n }\n \n parent.appendChild(this.element);\n return this;\n }\n \n destroy(): void {\n if (!isBrowser) {\n return;\n }\n if (this.boundMessageHandler) {\n window.removeEventListener('message', this.boundMessageHandler);\n }\n \n if (this.element && this.element.parentNode) {\n this.element.parentNode.removeChild(this.element);\n }\n }\n \n protected abstract getElementType(): string;\n protected abstract getIframeSrc(): string;\n\n public getIframe(): HTMLIFrameElement {\n return this.iframe;\n }\n}\n\nexport { HyperswitchElement };\n","import { Hyperswitch } from './hyperswitch';\nimport { HyperswitchElement } from './element';\nimport { ElementOptions } from './types';\n\nexport class ConnectorConfigurationComponent extends HyperswitchElement {\n constructor(instance: Hyperswitch, options?: ElementOptions) {\n super(instance, options);\n }\n \n protected getElementType(): string {\n return 'connectors';\n }\n \n protected getIframeSrc(): string {\n const baseUrl = this.options.url || 'http://localhost:9000';\n return `${baseUrl}/embedded/connectors`;\n }\n}\n","/**\n * Theme configuration received from the merchant.\n * This is the ONLY contract we expect merchants to follow.\n */\nexport type MerchantTheme = {\n /** Primary color */\n primaryColor?: string;\n /** Page background color */\n backgroundColor?: string;\n /** Button configurations */\n buttons?: {\n /** Primary button configuration */\n primary?: {\n /** Primary button background color */\n backgroundColor?: string;\n /** Primary button text color */\n textColor?: string;\n /** Primary button hover background color */\n hoverBackgroundColor?: string;\n };\n /** Secondary button configuration */\n secondary?: {\n /** Secondary button background color */\n backgroundColor?: string;\n /** Secondary button text color */\n textColor?: string;\n /** Secondary button hover background color */\n hoverBackgroundColor?: string;\n };\n };\n};\n\n/**\n * Full init_config payload shape sent to the Control Center.\n * Most fields are null for now; Control Center applies defaults.\n */\nexport type InitConfig = {\n settings: {\n colors: {\n primary: string | null;\n secondary: string | null;\n background: string | null;\n };\n sidebar: null;\n typography: null;\n buttons: {\n primary: {\n backgroundColor: string | null;\n textColor: string | null;\n hoverBackgroundColor: string | null;\n };\n secondary: {\n backgroundColor: string | null;\n textColor: string | null;\n hoverBackgroundColor: string | null;\n };\n };\n borders: null;\n spacing: null;\n };\n urls: {\n faviconUrl: null;\n logoUrl: null;\n };\n};\n\n/**\n * Build the init_config object that Control Center expects\n * from the simple MerchantTheme contract.\n *\n * Any missing value is set to null.\n */\nexport function buildInitConfig(merchantTheme: MerchantTheme | undefined | null): InitConfig {\n const safeTheme = merchantTheme || {};\n\n return {\n settings: {\n colors: {\n primary: safeTheme.primaryColor ?? null,\n secondary: null,\n background: safeTheme.backgroundColor ?? null\n },\n sidebar: null,\n typography: null,\n buttons: {\n primary: {\n backgroundColor: safeTheme.buttons?.primary?.backgroundColor ?? null,\n textColor: safeTheme.buttons?.primary?.textColor ?? null,\n hoverBackgroundColor: safeTheme.buttons?.primary?.hoverBackgroundColor ?? null\n },\n secondary: {\n backgroundColor: safeTheme.buttons?.secondary?.backgroundColor ?? null,\n textColor: safeTheme.buttons?.secondary?.textColor ?? null,\n hoverBackgroundColor: safeTheme.buttons?.secondary?.hoverBackgroundColor ?? null\n }\n },\n borders: null,\n spacing: null\n },\n urls: {\n faviconUrl: null,\n logoUrl: null\n }\n };\n}\n\n\n","import { HyperswitchElement } from './element';\nimport { ConnectorConfigurationComponent } from './connector-configuration';\nimport { HyperswitchInitOptions } from './types';\nimport { buildInitConfig,InitConfig } from './init-config';\n\nconst isBrowser = typeof window !== 'undefined';\n\nclass Hyperswitch {\n private token: string | null = null;\n private fetchToken: () => Promise<string | undefined>;\n private initConfig: InitConfig | null = null;\n private activeElements: Map<string, HyperswitchElement> = new Map();\n private isRefetchingToken: boolean = false;\n private initPromise: Promise<void>;\n private tokenError: string | null = null;\n\n constructor(options: HyperswitchInitOptions) {\n if (!options || typeof options.fetchToken !== 'function') {\n throw new Error('loadHyperswitch requires a fetchToken callback function');\n }\n\n this.fetchToken = options.fetchToken;\n this.initConfig = options.initConfig ? buildInitConfig(options.initConfig) : null;\n this.initPromise = this.fetchInitialToken();\n this.listenForMessages();\n }\n\n private fetchInitialToken(): Promise<void> {\n const eagerTokenPromise = (() => {\n try {\n return this.fetchToken();\n } catch (error) {\n return Promise.reject(error);\n }\n })();\n\n return eagerTokenPromise.then((token) => {\n if (token) {\n this.token = token;\n } else {\n this.tokenError = 'Failed to fetch token: Token returned empty or undefined';\n }\n }).catch((error) => {\n this.tokenError = `Failed to fetch token: ${error instanceof Error ? error.message : String(error)}`;\n });\n } \n\n private listenForMessages(): void {\n if (!isBrowser) {\n // In SSR / non-browser environments we can't listen for postMessage events,\n // but it's still safe to create a Hyperswitch instance (it will become\n // useful on the client where another instance will typically be created).\n return;\n }\n\n window.addEventListener(\"message\", async (event) => {\n if (event.data?.type === \"TOKEN_EXPIRED\" && event.data?.value === true) {\n await this.refetchAndBroadcastToken();\n } else if (event.data?.type === \"EMBEDDED_IFRAME_READY\") {\n // Find the element whose iframe matches the event source\n this.activeElements.forEach((element) => {\n const iframe = element.getIframe();\n if (iframe?.contentWindow === event.source) {\n this.onElementIframeLoaded(element);\n }\n });\n }\n });\n }\n\n private async refetchAndBroadcastToken(): Promise<void> {\n if (this.isRefetchingToken) {\n return;\n }\n \n this.isRefetchingToken = true;\n \n try {\n const newToken = await this.fetchToken();\n \n if (newToken) {\n this.token = newToken;\n this.tokenError = null;\n this.activeElements.forEach((element, elementId) => {\n const iframe = element.getIframe();\n if (iframe?.contentWindow) {\n iframe.contentWindow.postMessage({\n type: 'AUTH_TOKEN',\n token: this.token\n }, '*');\n }\n });\n } else {\n this.tokenError = 'Failed to refetch token: Token returned empty or undefined';\n this.sendErrorToActiveElements(this.tokenError);\n }\n } catch (error) {\n this.tokenError = `Failed to refetch token: ${error instanceof Error ? error.message : String(error)}`;\n this.sendErrorToActiveElements(this.tokenError);\n } finally {\n this.isRefetchingToken = false;\n }\n }\n\n private sendErrorToActiveElements(errorMessage: string): void {\n this.activeElements.forEach((element) => {\n const iframe = element.getIframe();\n if (iframe?.contentWindow) {\n iframe.contentWindow.postMessage({\n type: 'AUTH_ERROR',\n error: errorMessage\n }, '*');\n }\n });\n }\n\n public create(type: string, options?: any): HyperswitchElement {\n let element: HyperswitchElement;\n \n switch (type) {\n case 'connectors':\n element = new ConnectorConfigurationComponent(this, options);\n break;\n default:\n throw new Error(`Unknown element type: ${type}`);\n }\n \n this.activeElements.set(element._internalId, element);\n \n return element;\n }\n\n public onElementIframeLoaded(element: HyperswitchElement): void {\n this.initPromise.then(() => {\n const iframe = element.getIframe();\n if (!iframe?.contentWindow) {\n return;\n }\n \n setTimeout(() => {\n try {\n const contentWindow = iframe.contentWindow;\n if (!contentWindow) {\n return;\n }\n\n if (this.tokenError) {\n contentWindow.postMessage({\n type: 'AUTH_ERROR',\n error: this.tokenError\n }, '*');\n } else if (this.token) {\n contentWindow.postMessage({\n type: 'AUTH_TOKEN',\n token: this.token\n }, '*');\n } else {\n contentWindow.postMessage({\n type: 'AUTH_ERROR',\n error: 'No token available'\n }, '*');\n }\n\n // Send init_config (if available) as a separate message\n if (this.initConfig) {\n contentWindow.postMessage({\n type: 'INIT_CONFIG',\n init_config: this.initConfig\n }, '*');\n }\n } catch (error) {\n }\n }, 100);\n }).catch((error) => {\n const iframe = element.getIframe();\n const contentWindow = iframe?.contentWindow;\n if (contentWindow) {\n setTimeout(() => {\n try {\n contentWindow.postMessage({\n type: 'AUTH_ERROR',\n error: `Token initialization failed: ${error instanceof Error ? error.message : String(error)}`\n }, '*');\n } catch {\n }\n }, 100);\n }\n });\n }\n}\n\nexport function loadHyperswitch(options: HyperswitchInitOptions): Hyperswitch {\n return new Hyperswitch(options);\n}\n\nexport { Hyperswitch };\n","export { loadHyperswitch, Hyperswitch } from './hyperswitch';\nexport { HyperswitchElement } from './element';\nexport { ConnectorConfigurationComponent } from './connector-configuration';\nexport type { HyperswitchInitOptions, ElementOptions } from './types';\nexport type { MerchantTheme } from './init-config';\n\nexport const VERSION = '1.0.0';\n"],"names":["isBrowser"],"mappings":"AAGA,MAAMA,WAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD,MAAe,kBAAkB,CAAA;IAQ/B,WAAY,CAAA,QAAqB,EAAE,OAAwB,EAAA;AACzD,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;AAC7B,QAAA,IAAI,CAAC,WAAW,GAAG,YAAY,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;AACzE,QAAA,IAAI,C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AK,KAAI;AACjB,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;YACnC,MAAM,aAAa,GAAG,MAAM,KAAA,IAAA,IAAN,MAAM,KAAN,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,MAAM,CAAE,aAAa,CAAC;YAC5C,IAAI,aAAa,EAAE;gBACjB,UAAU,CAAC,MAAK;AACd,oBAAA,IAAI;wBACF,aAAa,CAAC,WAAW,CAAC;AACxB,4BAAA,IAAI,EAAE,YAAY;AAClB,4BAAA,KAAK,EAAE,CAAgC,6BAAA,EAAA,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAE,CAAA;yBAChG,EAAE,GAAG,CAAC,CAAC;qBACT;AAAC,oBAAA,OAAA,EAAA,EAAM;qBACP;iBACF,EAAE,GAAG,CAAC,CAAC;aACT;AACH,SAAC,CAAC,CAAC;KACJ;AACF,CAAA;AAEK,SAAU,eAAe,CAAC,OAA+B,EAAA;AAC7D,IAAA,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC;;AC3LO,MAAM,OAAO,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/element.ts","../src/connector-configuration.ts","../src/payments.ts","../src/refunds.ts","../src/init-config.ts","../src/hyperswitch.ts","../src/index.ts"],"sourcesContent":["import { Hyperswitch } from './hyperswitch';\nimport { ElementOptions } from './types';\n\nconst isBrowser = typeof window !== 'undefined';\n\nabstract class HyperswitchElement {\n protected instance: Hyperswitch;\n protected options: ElementOptions;\n public element!: HTMLElement;\n protected iframe!: HTMLIFrameElement;\n private boundMessageHandler: ((event: MessageEvent) => void) | null;\n public readonly _internalId: string;\n private isFullPage: boolean = false;\n private previousBodyOverflow: string = '';\n private showIframeTimer: ReturnType<typeof setTimeout> | null = null;\n private iframeOrigin: string | null = null;\n \n constructor(instance: Hyperswitch, options?: ElementOptions) {\n this.instance = instance;\n this.options = options || {};\n this._internalId = `hyper-el-${Math.random().toString(36).substring(7)}`;\n this.boundMessageHandler = null;\n // In SSR / non-browser environments, avoid touching DOM APIs.\n // The React wrapper only creates and mounts elements on the client,\n // so it's safe for server-side usage as long as we no-op here.\n if (!isBrowser) {\n return;\n }\n \n this.element = document.createElement('div');\n this.iframe = document.createElement('iframe');\n this.boundMessageHandler = this.handleMessage.bind(this);\n \n this.setupElement();\n this.setupIframe();\n window.addEventListener('message', this.boundMessageHandler);\n }\n\n private setupElement(): void {\n if (!isBrowser) {\n return;\n }\n\n this.element.className = `hyperswitch-element ${this.options.className || ''}`.trim();\n this.element.dataset.hyperswitchElement = this.getElementType();\n \n Object.assign(this.element.style, {\n width: this.options.width || '100%',\n height: this.options.height || '500px',\n overflow: 'hidden',\n ...(this.options.style || {})\n });\n }\n \n private setupIframe(): void {\n if (!isBrowser) {\n return;\n }\n\n this.iframe.src = this.getIframeSrc();\n this.iframe.style.border = 'none';\n this.iframe.style.width = '100%';\n this.iframe.style.height = '100%';\n this.iframe.title = `Hyperswitch ${this.getElementType()}`;\n this.iframe.setAttribute('allow', 'clipboard-read; clipboard-write; clipboard-sanitized-write');\n this.iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-presentation allow-downloads');\n \n this.element.appendChild(this.iframe);\n }\n \n private handleMessage(event: MessageEvent): void {\n if (!isBrowser) {\n return;\n }\n\n if (this.options.onMessage) {\n this.options.onMessage(event.data);\n }\n \n if (!this.acceptMessage(event)) {\n return;\n }\n \n if (this.isFullPageModalEnabled()) {\n if (event.data?.type === 'EMBEDDED_MODAL_OPEN') {\n this.setFullPage(true);\n } else if (event.data?.type === 'EMBEDDED_MODAL_CLOSE') {\n this.setFullPage(false);\n } else if (event.data?.type === 'EMBEDDED_MODAL_VISIBLE') {\n this.showIframe();\n }\n }\n \n if (event.data?.type === 'EMBEDDED_COMPONENT_RESIZE') {\n const newHeight = event.data.height;\n const messageComponent = event.data.component || '';\n \n if (!this.isFullPage && messageComponent === this.getElementType() && typeof newHeight === 'number' && newHeight > 0) {\n this.element.style.height = `${newHeight}px`;\n \n if (this.options.onResize) {\n this.options.onResize({\n width: this.element.clientWidth,\n height: newHeight\n });\n }\n }\n }\n }\n \n private setFullPage(isFullPage: boolean): void {\n if (isFullPage !== this.isFullPage) {\n this.isFullPage = isFullPage;\n this.iframe.style.visibility = 'hidden';\n \n if (isFullPage) {\n this.previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n Object.assign(this.iframe.style, {\n position: 'fixed',\n top: '0',\n left: '0',\n width: '100vw',\n height: '100vh',\n zIndex: '2147483647'\n });\n } else {\n document.body.style.overflow = this.previousBodyOverflow;\n Object.assign(this.iframe.style, {\n position: '',\n top: '',\n left: '',\n width: '100%',\n height: '100%',\n zIndex: ''\n });\n }\n \n if (this.showIframeTimer) {\n clearTimeout(this.showIframeTimer);\n }\n this.showIframeTimer = setTimeout(() => this.showIframe(), 300);\n }\n \n this.postMessageToIframe({\n type: isFullPage ? 'EMBEDDED_MODAL_OPENED' : 'EMBEDDED_MODAL_CLOSED'\n });\n }\n \n private showIframe(): void {\n if (this.showIframeTimer) {\n clearTimeout(this.showIframeTimer);\n this.showIframeTimer = null;\n }\n this.iframe.style.visibility = '';\n }\n \n mount(domNode: string | HTMLElement): HyperswitchElement {\n if (!isBrowser) {\n throw new Error('HyperswitchElement.mount can only be called in a browser environment');\n }\n\n const parent = typeof domNode === 'string' \n ? document.querySelector(domNode) \n : domNode;\n \n if (!parent) {\n throw new Error(`Invalid mount point: ${domNode}`);\n }\n \n parent.appendChild(this.element);\n return this;\n }\n \n destroy(): void {\n if (!isBrowser) {\n return;\n }\n if (this.isFullPage) {\n this.isFullPage = false;\n document.body.style.overflow = this.previousBodyOverflow;\n }\n if (this.showIframeTimer) {\n clearTimeout(this.showIframeTimer);\n this.showIframeTimer = null;\n }\n if (this.boundMessageHandler) {\n window.removeEventListener('message', this.boundMessageHandler);\n }\n \n if (this.element && this.element.parentNode) {\n this.element.parentNode.removeChild(this.element);\n }\n }\n \n protected abstract getElementType(): string;\n protected abstract getIframeSrc(): string;\n\n public getIframe(): HTMLIFrameElement {\n return this.iframe;\n }\n\n public acceptMessage(event: MessageEvent): boolean {\n if (event.source !== this.iframe?.contentWindow) {\n return false;\n }\n if (this.iframeOrigin === null && event.origin && event.origin !== 'null') {\n this.iframeOrigin = event.origin;\n }\n return this.iframeOrigin === null || event.origin === this.iframeOrigin;\n }\n\n public postMessageToIframe(message: Record<string, unknown>): void {\n if (this.iframeOrigin === null) {\n return;\n }\n this.iframe?.contentWindow?.postMessage(message, this.iframeOrigin);\n }\n\n public isFullPageModalEnabled(): boolean {\n return this.options.fullPageModals !== false;\n }\n}\n\nexport { HyperswitchElement };\n","import { Hyperswitch } from './hyperswitch';\nimport { HyperswitchElement } from './element';\nimport { ElementOptions } from './types';\n\nexport class ConnectorConfigurationComponent extends HyperswitchElement {\n constructor(instance: Hyperswitch, options?: ElementOptions) {\n super(instance, options);\n }\n \n protected getElementType(): string {\n return 'connectors';\n }\n \n protected getIframeSrc(): string {\n const baseUrl = this.options.url || 'http://localhost:9000';\n return `${baseUrl}/embedded/connectors`;\n }\n}\n","import { Hyperswitch } from './hyperswitch';\nimport { HyperswitchElement } from './element';\nimport { ElementOptions } from './types';\n\nexport class PaymentsComponent extends HyperswitchElement {\n constructor(instance: Hyperswitch, options?: ElementOptions) {\n super(instance, options);\n }\n \n protected getElementType(): string {\n return 'payments';\n }\n \n protected getIframeSrc(): string {\n const baseUrl = this.options.url || 'http://localhost:9000';\n return `${baseUrl}/embedded/payments`;\n }\n}\n","import { Hyperswitch } from './hyperswitch';\nimport { HyperswitchElement } from './element';\nimport { ElementOptions } from './types';\n\nexport class RefundsComponent extends HyperswitchElement {\n constructor(instance: Hyperswitch, options?: ElementOptions) {\n super(instance, options);\n }\n \n protected getElementType(): string {\n return 'refunds';\n }\n \n protected getIframeSrc(): string {\n const baseUrl = this.options.url || 'http://localhost:9000';\n return `${baseUrl}/embedded/refunds`;\n }\n}\n","/**\n * Theme configuration received from the merchant.\n * This is the ONLY contract we expect merchants to follow.\n */\nexport type MerchantTheme = {\n /** Primary color */\n primaryColor?: string;\n /** Page background color */\n backgroundColor?: string;\n /** Button configurations */\n buttons?: {\n /** Primary button configuration */\n primary?: {\n /** Primary button background color */\n backgroundColor?: string;\n /** Primary button text color */\n textColor?: string;\n /** Primary button hover background color */\n hoverBackgroundColor?: string;\n };\n /** Secondary button configuration */\n secondary?: {\n /** Secondary button background color */\n backgroundColor?: string;\n /** Secondary button text color */\n textColor?: string;\n /** Secondary button hover background color */\n hoverBackgroundColor?: string;\n };\n };\n};\n\n/**\n * Full init_config payload shape sent to the Control Center.\n * Most fields are null for now; Control Center applies defaults.\n */\nexport type InitConfig = {\n settings: {\n colors: {\n primary: string | null;\n secondary: string | null;\n background: string | null;\n };\n sidebar: null;\n typography: null;\n buttons: {\n primary: {\n backgroundColor: string | null;\n textColor: string | null;\n hoverBackgroundColor: string | null;\n };\n secondary: {\n backgroundColor: string | null;\n textColor: string | null;\n hoverBackgroundColor: string | null;\n };\n };\n borders: null;\n spacing: null;\n };\n urls: {\n faviconUrl: null;\n logoUrl: null;\n };\n};\n\n/**\n * Build the init_config object that Control Center expects\n * from the simple MerchantTheme contract.\n *\n * Any missing value is set to null.\n */\nexport function buildInitConfig(merchantTheme: MerchantTheme | undefined | null): InitConfig {\n const safeTheme = merchantTheme || {};\n\n return {\n settings: {\n colors: {\n primary: safeTheme.primaryColor ?? null,\n secondary: null,\n background: safeTheme.backgroundColor ?? null\n },\n sidebar: null,\n typography: null,\n buttons: {\n primary: {\n backgroundColor: safeTheme.buttons?.primary?.backgroundColor ?? null,\n textColor: safeTheme.buttons?.primary?.textColor ?? null,\n hoverBackgroundColor: safeTheme.buttons?.primary?.hoverBackgroundColor ?? null\n },\n secondary: {\n backgroundColor: safeTheme.buttons?.secondary?.backgroundColor ?? null,\n textColor: safeTheme.buttons?.secondary?.textColor ?? null,\n hoverBackgroundColor: safeTheme.buttons?.secondary?.hoverBackgroundColor ?? null\n }\n },\n borders: null,\n spacing: null\n },\n urls: {\n faviconUrl: null,\n logoUrl: null\n }\n };\n}\n\n\n","import { HyperswitchElement } from './element';\nimport { ConnectorConfigurationComponent } from './connector-configuration';\nimport { PaymentsComponent } from './payments';\nimport { RefundsComponent } from './refunds';\nimport { HyperswitchInitOptions } from './types';\nimport { buildInitConfig,InitConfig } from './init-config';\n\nconst isBrowser = typeof window !== 'undefined';\n\nclass Hyperswitch {\n private token: string | null = null;\n private fetchToken: () => Promise<string | undefined>;\n private initConfig: InitConfig | null = null;\n private activeElements: Map<string, HyperswitchElement> = new Map();\n private isRefetchingToken: boolean = false;\n private initPromise: Promise<void>;\n private tokenError: string | null = null;\n\n constructor(options: HyperswitchInitOptions) {\n if (!options || typeof options.fetchToken !== 'function') {\n throw new Error('loadHyperswitch requires a fetchToken callback function');\n }\n\n this.fetchToken = options.fetchToken;\n this.initConfig = options.initConfig ? buildInitConfig(options.initConfig) : null;\n this.initPromise = this.fetchInitialToken();\n this.listenForMessages();\n }\n\n private fetchInitialToken(): Promise<void> {\n const eagerTokenPromise = (() => {\n try {\n return this.fetchToken();\n } catch (error) {\n return Promise.reject(error);\n }\n })();\n\n return eagerTokenPromise.then((token) => {\n if (token) {\n this.token = token;\n } else {\n this.tokenError = 'Failed to fetch token: Token returned empty or undefined';\n }\n }).catch((error) => {\n this.tokenError = `Failed to fetch token: ${error instanceof Error ? error.message : String(error)}`;\n });\n } \n\n private listenForMessages(): void {\n if (!isBrowser) {\n // In SSR / non-browser environments we can't listen for postMessage events,\n // but it's still safe to create a Hyperswitch instance (it will become\n // useful on the client where another instance will typically be created).\n return;\n }\n\n window.addEventListener(\"message\", async (event) => {\n const sourceElement = Array.from(this.activeElements.values()).find(\n (element) => element.acceptMessage(event)\n );\n if (!sourceElement) {\n return;\n }\n\n if (event.data?.type === \"TOKEN_EXPIRED\" && event.data?.value === true) {\n await this.refetchAndBroadcastToken();\n } else if (event.data?.type === \"EMBEDDED_IFRAME_READY\") {\n this.onElementIframeLoaded(sourceElement);\n }\n });\n }\n\n private async refetchAndBroadcastToken(): Promise<void> {\n if (this.isRefetchingToken) {\n return;\n }\n \n this.isRefetchingToken = true;\n \n try {\n const newToken = await this.fetchToken();\n \n if (newToken) {\n this.token = newToken;\n this.tokenError = null;\n this.activeElements.forEach((element) => {\n element.postMessageToIframe({\n type: 'AUTH_TOKEN',\n token: this.token\n });\n });\n } else {\n this.tokenError = 'Failed to refetch token: Token returned empty or undefined';\n this.sendErrorToActiveElements(this.tokenError);\n }\n } catch (error) {\n this.tokenError = `Failed to refetch token: ${error instanceof Error ? error.message : String(error)}`;\n this.sendErrorToActiveElements(this.tokenError);\n } finally {\n this.isRefetchingToken = false;\n }\n }\n\n private sendErrorToActiveElements(errorMessage: string): void {\n this.activeElements.forEach((element) => {\n element.postMessageToIframe({\n type: 'AUTH_ERROR',\n error: errorMessage\n });\n });\n }\n\n public create(type: string, options?: any): HyperswitchElement {\n let element: HyperswitchElement;\n \n switch (type) {\n case 'connectors':\n element = new ConnectorConfigurationComponent(this, options);\n break;\n case 'payments':\n element = new PaymentsComponent(this, options);\n break;\n case 'refunds':\n element = new RefundsComponent(this, options);\n break;\n default:\n throw new Error(`Unknown element type: ${type}`);\n }\n \n this.activeElements.set(element._internalId, element);\n \n return element;\n }\n\n public onElementIframeLoaded(element: HyperswitchElement): void {\n this.initPromise.then(() => {\n const iframe = element.getIframe();\n if (!iframe?.contentWindow) {\n return;\n }\n \n setTimeout(() => {\n try {\n if (this.tokenError) {\n element.postMessageToIframe({\n type: 'AUTH_ERROR',\n error: this.tokenError\n });\n } else if (this.token) {\n element.postMessageToIframe({\n type: 'AUTH_TOKEN',\n token: this.token\n });\n } else {\n element.postMessageToIframe({\n type: 'AUTH_ERROR',\n error: 'No token available'\n });\n }\n\n // Always send init_config. If merchant doesn't provide it, send an empty object.\n element.postMessageToIframe({\n type: 'INIT_CONFIG',\n init_config: this.initConfig ?? {},\n sdk_capabilities: { full_page_modal: element.isFullPageModalEnabled() }\n });\n } catch (error) {\n }\n }, 100);\n }).catch((error) => {\n setTimeout(() => {\n try {\n element.postMessageToIframe({\n type: 'AUTH_ERROR',\n error: `Token initialization failed: ${error instanceof Error ? error.message : String(error)}`\n });\n } catch {\n }\n }, 100);\n });\n }\n}\n\nexport function loadHyperswitch(options: HyperswitchInitOptions): Hyperswitch {\n return new Hyperswitch(options);\n}\n\nexport { Hyperswitch };\n","export { loadHyperswitch, Hyperswitch } from './hyperswitch';\nexport { HyperswitchElement } from './element';\nexport { ConnectorConfigurationComponent } from './connector-configuration';\nexport { PaymentsComponent } from './payments';\nexport { RefundsComponent } from './refunds';\nexport type { HyperswitchInitOptions, ElementOptions } from './types';\nexport type { MerchantTheme } from './init-config';\n\nexport const VERSION = '1.0.0';\n"],"names":["isBrowser"],"mappings":"AAGA,MAAMA,WAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD,MAAe,kBAAkB,CAAA;IAY/B,WAAY,CAAA,QAAqB,EAAE,OAAwB,EAAA;QALnD,IAAU,CAAA,UAAA,GAAY,KAAK,CAAC;QAC5B,IAAoB,CAAA,oBAAA,GAAW,EAAE,CAAC;QAClC,IAAe,CAAA,eAAA,GAAyC,IAAI,CAAC;QAC7D,IAAY,CAAA,YAAA,GAAkB,IAAI,CAAC;AAGzC,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;AAC7B,QAAA,IAAI,CAAC,WAAW,GAAG,YAAY,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;AACzE,QAAA,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;;;;QAIhC,IAAI,CAACA,WAAS,EAAE;YACd,OAAO;SACR;QAED,IAAI,CAAC,OA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C,CAAC;iBACJ;gBAAC,OAAO,KAAK,EAAE;iBACf;aACF,EAAE,GAAG,CAAC,CAAC;AACV,SAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;YACjB,UAAU,CAAC,MAAK;AACd,gBAAA,IAAI;oBACF,OAAO,CAAC,mBAAmB,CAAC;AAC1B,wBAAA,IAAI,EAAE,YAAY;AAClB,wBAAA,KAAK,EAAE,CAAgC,6BAAA,EAAA,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAE,CAAA;AAChG,qBAAA,CAAC,CAAC;iBACJ;AAAC,gBAAA,OAAA,EAAA,EAAM;iBACP;aACF,EAAE,GAAG,CAAC,CAAC;AACV,SAAC,CAAC,CAAC;KACJ;AACF,CAAA;AAEK,SAAU,eAAe,CAAC,OAA+B,EAAA;AAC7D,IAAA,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC;;AClLO,MAAM,OAAO,GAAG;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const isBrowser$1 = typeof window !== 'undefined';
|
|
6
6
|
class HyperswitchElement {
|
|
7
7
|
constructor(instance, options) {
|
|
8
|
+
this.isFullPage = false;
|
|
9
|
+
this.previousBodyOverflow = '';
|
|
10
|
+
this.showIframeTimer = null;
|
|
11
|
+
this.iframeOrigin = null;
|
|
8
12
|
this.instance = instance;
|
|
9
13
|
this.options = options || {};
|
|
10
14
|
this._internalId = `hyper-el-${Math.random().toString(36).substring(7)}`;
|
|
@@ -44,17 +48,31 @@ class HyperswitchElement {
|
|
|
44
48
|
this.element.appendChild(this.iframe);
|
|
45
49
|
}
|
|
46
50
|
handleMessage(event) {
|
|
47
|
-
var _a;
|
|
51
|
+
var _a, _b, _c, _d;
|
|
48
52
|
if (!isBrowser$1) {
|
|
49
53
|
return;
|
|
50
54
|
}
|
|
51
55
|
if (this.options.onMessage) {
|
|
52
56
|
this.options.onMessage(event.data);
|
|
53
57
|
}
|
|
54
|
-
if ((
|
|
58
|
+
if (!this.acceptMessage(event)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (this.isFullPageModalEnabled()) {
|
|
62
|
+
if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'EMBEDDED_MODAL_OPEN') {
|
|
63
|
+
this.setFullPage(true);
|
|
64
|
+
}
|
|
65
|
+
else if (((_b = event.data) === null || _b === void 0 ? void 0 : _b.type) === 'EMBEDDED_MODAL_CLOSE') {
|
|
66
|
+
this.setFullPage(false);
|
|
67
|
+
}
|
|
68
|
+
else if (((_c = event.data) === null || _c === void 0 ? void 0 : _c.type) === 'EMBEDDED_MODAL_VISIBLE') {
|
|
69
|
+
this.showIframe();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (((_d = event.data) === null || _d === void 0 ? void 0 : _d.type) === 'EMBEDDED_COMPONENT_RESIZE') {
|
|
55
73
|
const newHeight = event.data.height;
|
|
56
74
|
const messageComponent = event.data.component || '';
|
|
57
|
-
if (messageComponent === this.getElementType() && typeof newHeight === 'number' && newHeight > 0) {
|
|
75
|
+
if (!this.isFullPage && messageComponent === this.getElementType() && typeof newHeight === 'number' && newHeight > 0) {
|
|
58
76
|
this.element.style.height = `${newHeight}px`;
|
|
59
77
|
if (this.options.onResize) {
|
|
60
78
|
this.options.onResize({
|
|
@@ -65,6 +83,49 @@ class HyperswitchElement {
|
|
|
65
83
|
}
|
|
66
84
|
}
|
|
67
85
|
}
|
|
86
|
+
setFullPage(isFullPage) {
|
|
87
|
+
if (isFullPage !== this.isFullPage) {
|
|
88
|
+
this.isFullPage = isFullPage;
|
|
89
|
+
this.iframe.style.visibility = 'hidden';
|
|
90
|
+
if (isFullPage) {
|
|
91
|
+
this.previousBodyOverflow = document.body.style.overflow;
|
|
92
|
+
document.body.style.overflow = 'hidden';
|
|
93
|
+
Object.assign(this.iframe.style, {
|
|
94
|
+
position: 'fixed',
|
|
95
|
+
top: '0',
|
|
96
|
+
left: '0',
|
|
97
|
+
width: '100vw',
|
|
98
|
+
height: '100vh',
|
|
99
|
+
zIndex: '2147483647'
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
document.body.style.overflow = this.previousBodyOverflow;
|
|
104
|
+
Object.assign(this.iframe.style, {
|
|
105
|
+
position: '',
|
|
106
|
+
top: '',
|
|
107
|
+
left: '',
|
|
108
|
+
width: '100%',
|
|
109
|
+
height: '100%',
|
|
110
|
+
zIndex: ''
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (this.showIframeTimer) {
|
|
114
|
+
clearTimeout(this.showIframeTimer);
|
|
115
|
+
}
|
|
116
|
+
this.showIframeTimer = setTimeout(() => this.showIframe(), 300);
|
|
117
|
+
}
|
|
118
|
+
this.postMessageToIframe({
|
|
119
|
+
type: isFullPage ? 'EMBEDDED_MODAL_OPENED' : 'EMBEDDED_MODAL_CLOSED'
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
showIframe() {
|
|
123
|
+
if (this.showIframeTimer) {
|
|
124
|
+
clearTimeout(this.showIframeTimer);
|
|
125
|
+
this.showIframeTimer = null;
|
|
126
|
+
}
|
|
127
|
+
this.iframe.style.visibility = '';
|
|
128
|
+
}
|
|
68
129
|
mount(domNode) {
|
|
69
130
|
if (!isBrowser$1) {
|
|
70
131
|
throw new Error('HyperswitchElement.mount can only be called in a browser environment');
|
|
@@ -82,6 +143,14 @@ class HyperswitchElement {
|
|
|
82
143
|
if (!isBrowser$1) {
|
|
83
144
|
return;
|
|
84
145
|
}
|
|
146
|
+
if (this.isFullPage) {
|
|
147
|
+
this.isFullPage = false;
|
|
148
|
+
document.body.style.overflow = this.previousBodyOverflow;
|
|
149
|
+
}
|
|
150
|
+
if (this.showIframeTimer) {
|
|
151
|
+
clearTimeout(this.showIframeTimer);
|
|
152
|
+
this.showIframeTimer = null;
|
|
153
|
+
}
|
|
85
154
|
if (this.boundMessageHandler) {
|
|
86
155
|
window.removeEventListener('message', this.boundMessageHandler);
|
|
87
156
|
}
|
|
@@ -92,6 +161,26 @@ class HyperswitchElement {
|
|
|
92
161
|
getIframe() {
|
|
93
162
|
return this.iframe;
|
|
94
163
|
}
|
|
164
|
+
acceptMessage(event) {
|
|
165
|
+
var _a;
|
|
166
|
+
if (event.source !== ((_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
if (this.iframeOrigin === null && event.origin && event.origin !== 'null') {
|
|
170
|
+
this.iframeOrigin = event.origin;
|
|
171
|
+
}
|
|
172
|
+
return this.iframeOrigin === null || event.origin === this.iframeOrigin;
|
|
173
|
+
}
|
|
174
|
+
postMessageToIframe(message) {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
if (this.iframeOrigin === null) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
(_b = (_a = this.iframe) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(message, this.iframeOrigin);
|
|
180
|
+
}
|
|
181
|
+
isFullPageModalEnabled() {
|
|
182
|
+
return this.options.fullPageModals !== false;
|
|
183
|
+
}
|
|
95
184
|
}
|
|
96
185
|
|
|
97
186
|
class ConnectorConfigurationComponent extends HyperswitchElement {
|
|
@@ -107,6 +196,32 @@ class ConnectorConfigurationComponent extends HyperswitchElement {
|
|
|
107
196
|
}
|
|
108
197
|
}
|
|
109
198
|
|
|
199
|
+
class PaymentsComponent extends HyperswitchElement {
|
|
200
|
+
constructor(instance, options) {
|
|
201
|
+
super(instance, options);
|
|
202
|
+
}
|
|
203
|
+
getElementType() {
|
|
204
|
+
return 'payments';
|
|
205
|
+
}
|
|
206
|
+
getIframeSrc() {
|
|
207
|
+
const baseUrl = this.options.url || 'http://localhost:9000';
|
|
208
|
+
return `${baseUrl}/embedded/payments`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
class RefundsComponent extends HyperswitchElement {
|
|
213
|
+
constructor(instance, options) {
|
|
214
|
+
super(instance, options);
|
|
215
|
+
}
|
|
216
|
+
getElementType() {
|
|
217
|
+
return 'refunds';
|
|
218
|
+
}
|
|
219
|
+
getIframeSrc() {
|
|
220
|
+
const baseUrl = this.options.url || 'http://localhost:9000';
|
|
221
|
+
return `${baseUrl}/embedded/refunds`;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
110
225
|
/**
|
|
111
226
|
* Build the init_config object that Control Center expects
|
|
112
227
|
* from the simple MerchantTheme contract.
|
|
@@ -192,17 +307,15 @@ class Hyperswitch {
|
|
|
192
307
|
}
|
|
193
308
|
window.addEventListener("message", async (event) => {
|
|
194
309
|
var _a, _b, _c;
|
|
310
|
+
const sourceElement = Array.from(this.activeElements.values()).find((element) => element.acceptMessage(event));
|
|
311
|
+
if (!sourceElement) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
195
314
|
if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === "TOKEN_EXPIRED" && ((_b = event.data) === null || _b === void 0 ? void 0 : _b.value) === true) {
|
|
196
315
|
await this.refetchAndBroadcastToken();
|
|
197
316
|
}
|
|
198
317
|
else if (((_c = event.data) === null || _c === void 0 ? void 0 : _c.type) === "EMBEDDED_IFRAME_READY") {
|
|
199
|
-
|
|
200
|
-
this.activeElements.forEach((element) => {
|
|
201
|
-
const iframe = element.getIframe();
|
|
202
|
-
if ((iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === event.source) {
|
|
203
|
-
this.onElementIframeLoaded(element);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
318
|
+
this.onElementIframeLoaded(sourceElement);
|
|
206
319
|
}
|
|
207
320
|
});
|
|
208
321
|
}
|
|
@@ -216,14 +329,11 @@ class Hyperswitch {
|
|
|
216
329
|
if (newToken) {
|
|
217
330
|
this.token = newToken;
|
|
218
331
|
this.tokenError = null;
|
|
219
|
-
this.activeElements.forEach((element
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
token: this.token
|
|
225
|
-
}, '*');
|
|
226
|
-
}
|
|
332
|
+
this.activeElements.forEach((element) => {
|
|
333
|
+
element.postMessageToIframe({
|
|
334
|
+
type: 'AUTH_TOKEN',
|
|
335
|
+
token: this.token
|
|
336
|
+
});
|
|
227
337
|
});
|
|
228
338
|
}
|
|
229
339
|
else {
|
|
@@ -241,13 +351,10 @@ class Hyperswitch {
|
|
|
241
351
|
}
|
|
242
352
|
sendErrorToActiveElements(errorMessage) {
|
|
243
353
|
this.activeElements.forEach((element) => {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
error: errorMessage
|
|
249
|
-
}, '*');
|
|
250
|
-
}
|
|
354
|
+
element.postMessageToIframe({
|
|
355
|
+
type: 'AUTH_ERROR',
|
|
356
|
+
error: errorMessage
|
|
357
|
+
});
|
|
251
358
|
});
|
|
252
359
|
}
|
|
253
360
|
create(type, options) {
|
|
@@ -256,6 +363,12 @@ class Hyperswitch {
|
|
|
256
363
|
case 'connectors':
|
|
257
364
|
element = new ConnectorConfigurationComponent(this, options);
|
|
258
365
|
break;
|
|
366
|
+
case 'payments':
|
|
367
|
+
element = new PaymentsComponent(this, options);
|
|
368
|
+
break;
|
|
369
|
+
case 'refunds':
|
|
370
|
+
element = new RefundsComponent(this, options);
|
|
371
|
+
break;
|
|
259
372
|
default:
|
|
260
373
|
throw new Error(`Unknown element type: ${type}`);
|
|
261
374
|
}
|
|
@@ -269,55 +382,47 @@ class Hyperswitch {
|
|
|
269
382
|
return;
|
|
270
383
|
}
|
|
271
384
|
setTimeout(() => {
|
|
385
|
+
var _a;
|
|
272
386
|
try {
|
|
273
|
-
const contentWindow = iframe.contentWindow;
|
|
274
|
-
if (!contentWindow) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
387
|
if (this.tokenError) {
|
|
278
|
-
|
|
388
|
+
element.postMessageToIframe({
|
|
279
389
|
type: 'AUTH_ERROR',
|
|
280
390
|
error: this.tokenError
|
|
281
|
-
}
|
|
391
|
+
});
|
|
282
392
|
}
|
|
283
393
|
else if (this.token) {
|
|
284
|
-
|
|
394
|
+
element.postMessageToIframe({
|
|
285
395
|
type: 'AUTH_TOKEN',
|
|
286
396
|
token: this.token
|
|
287
|
-
}
|
|
397
|
+
});
|
|
288
398
|
}
|
|
289
399
|
else {
|
|
290
|
-
|
|
400
|
+
element.postMessageToIframe({
|
|
291
401
|
type: 'AUTH_ERROR',
|
|
292
402
|
error: 'No token available'
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
// Send init_config (if available) as a separate message
|
|
296
|
-
if (this.initConfig) {
|
|
297
|
-
contentWindow.postMessage({
|
|
298
|
-
type: 'INIT_CONFIG',
|
|
299
|
-
init_config: this.initConfig
|
|
300
|
-
}, '*');
|
|
403
|
+
});
|
|
301
404
|
}
|
|
405
|
+
// Always send init_config. If merchant doesn't provide it, send an empty object.
|
|
406
|
+
element.postMessageToIframe({
|
|
407
|
+
type: 'INIT_CONFIG',
|
|
408
|
+
init_config: (_a = this.initConfig) !== null && _a !== void 0 ? _a : {},
|
|
409
|
+
sdk_capabilities: { full_page_modal: element.isFullPageModalEnabled() }
|
|
410
|
+
});
|
|
302
411
|
}
|
|
303
412
|
catch (error) {
|
|
304
413
|
}
|
|
305
414
|
}, 100);
|
|
306
415
|
}).catch((error) => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
catch (_a) {
|
|
318
|
-
}
|
|
319
|
-
}, 100);
|
|
320
|
-
}
|
|
416
|
+
setTimeout(() => {
|
|
417
|
+
try {
|
|
418
|
+
element.postMessageToIframe({
|
|
419
|
+
type: 'AUTH_ERROR',
|
|
420
|
+
error: `Token initialization failed: ${error instanceof Error ? error.message : String(error)}`
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
catch (_a) {
|
|
424
|
+
}
|
|
425
|
+
}, 100);
|
|
321
426
|
});
|
|
322
427
|
}
|
|
323
428
|
}
|
|
@@ -330,6 +435,8 @@ const VERSION = '1.0.0';
|
|
|
330
435
|
exports.ConnectorConfigurationComponent = ConnectorConfigurationComponent;
|
|
331
436
|
exports.Hyperswitch = Hyperswitch;
|
|
332
437
|
exports.HyperswitchElement = HyperswitchElement;
|
|
438
|
+
exports.PaymentsComponent = PaymentsComponent;
|
|
439
|
+
exports.RefundsComponent = RefundsComponent;
|
|
333
440
|
exports.VERSION = VERSION;
|
|
334
441
|
exports.loadHyperswitch = loadHyperswitch;
|
|
335
442
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/element.ts","../src/connector-configuration.ts","../src/init-config.ts","../src/hyperswitch.ts","../src/index.ts"],"sourcesContent":["import { Hyperswitch } from './hyperswitch';\nimport { ElementOptions } from './types';\n\nconst isBrowser = typeof window !== 'undefined';\n\nabstract class HyperswitchElement {\n protected instance: Hyperswitch;\n protected options: ElementOptions;\n public element!: HTMLElement;\n protected iframe!: HTMLIFrameElement;\n private boundMessageHandler: ((event: MessageEvent) => void) | null;\n public readonly _internalId: string;\n \n constructor(instance: Hyperswitch, options?: ElementOptions) {\n this.instance = instance;\n this.options = options || {};\n this._internalId = `hyper-el-${Math.random().toString(36).substring(7)}`;\n this.boundMessageHandler = null;\n // In SSR / non-browser environments, avoid touching DOM APIs.\n // The React wrapper only creates and mounts elements on the client,\n // so it's safe for server-side usage as long as we no-op here.\n if (!isBrowser) {\n return;\n }\n \n this.element = document.createElement('div');\n this.iframe = document.createElement('iframe');\n this.boundMessageHandler = this.handleMessage.bind(this);\n \n this.setupElement();\n this.setupIframe();\n window.addEventListener('message', this.boundMessageHandler);\n }\n\n private setupElement(): void {\n if (!isBrowser) {\n return;\n }\n\n this.element.className = `hyperswitch-element ${this.options.className || ''}`.trim();\n this.element.dataset.hyperswitchElement = this.getElementType();\n \n Object.assign(this.element.style, {\n width: this.options.width || '100%',\n height: this.options.height || '500px',\n overflow: 'hidden',\n ...(this.options.style || {})\n });\n }\n \n private setupIframe(): void {\n if (!isBrowser) {\n return;\n }\n\n this.iframe.src = this.getIframeSrc();\n this.iframe.style.border = 'none';\n this.iframe.style.width = '100%';\n this.iframe.style.height = '100%';\n this.iframe.title = `Hyperswitch ${this.getElementType()}`;\n this.iframe.setAttribute('allow', 'clipboard-read; clipboard-write; clipboard-sanitized-write');\n this.iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-presentation allow-downloads');\n \n this.element.appendChild(this.iframe);\n }\n \n private handleMessage(event: MessageEvent): void {\n if (!isBrowser) {\n return;\n }\n\n if (this.options.onMessage) {\n this.options.onMessage(event.data);\n }\n \n if (event.data?.type === 'EMBEDDED_COMPONENT_RESIZE') {\n const newHeight = event.data.height;\n const messageComponent = event.data.component || '';\n \n if (messageComponent === this.getElementType() && typeof newHeight === 'number' && newHeight > 0) {\n this.element.style.height = `${newHeight}px`;\n \n if (this.options.onResize) {\n this.options.onResize({\n width: this.element.clientWidth,\n height: newHeight\n });\n }\n }\n }\n }\n \n mount(domNode: string | HTMLElement): HyperswitchElement {\n if (!isBrowser) {\n throw new Error('HyperswitchElement.mount can only be called in a browser environment');\n }\n\n const parent = typeof domNode === 'string' \n ? document.querySelector(domNode) \n : domNode;\n \n if (!parent) {\n throw new Error(`Invalid mount point: ${domNode}`);\n }\n \n parent.appendChild(this.element);\n return this;\n }\n \n destroy(): void {\n if (!isBrowser) {\n return;\n }\n if (this.boundMessageHandler) {\n window.removeEventListener('message', this.boundMessageHandler);\n }\n \n if (this.element && this.element.parentNode) {\n this.element.parentNode.removeChild(this.element);\n }\n }\n \n protected abstract getElementType(): string;\n protected abstract getIframeSrc(): string;\n\n public getIframe(): HTMLIFrameElement {\n return this.iframe;\n }\n}\n\nexport { HyperswitchElement };\n","import { Hyperswitch } from './hyperswitch';\nimport { HyperswitchElement } from './element';\nimport { ElementOptions } from './types';\n\nexport class ConnectorConfigurationComponent extends HyperswitchElement {\n constructor(instance: Hyperswitch, options?: ElementOptions) {\n super(instance, options);\n }\n \n protected getElementType(): string {\n return 'connectors';\n }\n \n protected getIframeSrc(): string {\n const baseUrl = this.options.url || 'http://localhost:9000';\n return `${baseUrl}/embedded/connectors`;\n }\n}\n","/**\n * Theme configuration received from the merchant.\n * This is the ONLY contract we expect merchants to follow.\n */\nexport type MerchantTheme = {\n /** Primary color */\n primaryColor?: string;\n /** Page background color */\n backgroundColor?: string;\n /** Button configurations */\n buttons?: {\n /** Primary button configuration */\n primary?: {\n /** Primary button background color */\n backgroundColor?: string;\n /** Primary button text color */\n textColor?: string;\n /** Primary button hover background color */\n hoverBackgroundColor?: string;\n };\n /** Secondary button configuration */\n secondary?: {\n /** Secondary button background color */\n backgroundColor?: string;\n /** Secondary button text color */\n textColor?: string;\n /** Secondary button hover background color */\n hoverBackgroundColor?: string;\n };\n };\n};\n\n/**\n * Full init_config payload shape sent to the Control Center.\n * Most fields are null for now; Control Center applies defaults.\n */\nexport type InitConfig = {\n settings: {\n colors: {\n primary: string | null;\n secondary: string | null;\n background: string | null;\n };\n sidebar: null;\n typography: null;\n buttons: {\n primary: {\n backgroundColor: string | null;\n textColor: string | null;\n hoverBackgroundColor: string | null;\n };\n secondary: {\n backgroundColor: string | null;\n textColor: string | null;\n hoverBackgroundColor: string | null;\n };\n };\n borders: null;\n spacing: null;\n };\n urls: {\n faviconUrl: null;\n logoUrl: null;\n };\n};\n\n/**\n * Build the init_config object that Control Center expects\n * from the simple MerchantTheme contract.\n *\n * Any missing value is set to null.\n */\nexport function buildInitConfig(merchantTheme: MerchantTheme | undefined | null): InitConfig {\n const safeTheme = merchantTheme || {};\n\n return {\n settings: {\n colors: {\n primary: safeTheme.primaryColor ?? null,\n secondary: null,\n background: safeTheme.backgroundColor ?? null\n },\n sidebar: null,\n typography: null,\n buttons: {\n primary: {\n backgroundColor: safeTheme.buttons?.primary?.backgroundColor ?? null,\n textColor: safeTheme.buttons?.primary?.textColor ?? null,\n hoverBackgroundColor: safeTheme.buttons?.primary?.hoverBackgroundColor ?? null\n },\n secondary: {\n backgroundColor: safeTheme.buttons?.secondary?.backgroundColor ?? null,\n textColor: safeTheme.buttons?.secondary?.textColor ?? null,\n hoverBackgroundColor: safeTheme.buttons?.secondary?.hoverBackgroundColor ?? null\n }\n },\n borders: null,\n spacing: null\n },\n urls: {\n faviconUrl: null,\n logoUrl: null\n }\n };\n}\n\n\n","import { HyperswitchElement } from './element';\nimport { ConnectorConfigurationComponent } from './connector-configuration';\nimport { HyperswitchInitOptions } from './types';\nimport { buildInitConfig,InitConfig } from './init-config';\n\nconst isBrowser = typeof window !== 'undefined';\n\nclass Hyperswitch {\n private token: string | null = null;\n private fetchToken: () => Promise<string | undefined>;\n private initConfig: InitConfig | null = null;\n private activeElements: Map<string, HyperswitchElement> = new Map();\n private isRefetchingToken: boolean = false;\n private initPromise: Promise<void>;\n private tokenError: string | null = null;\n\n constructor(options: HyperswitchInitOptions) {\n if (!options || typeof options.fetchToken !== 'function') {\n throw new Error('loadHyperswitch requires a fetchToken callback function');\n }\n\n this.fetchToken = options.fetchToken;\n this.initConfig = options.initConfig ? buildInitConfig(options.initConfig) : null;\n this.initPromise = this.fetchInitialToken();\n this.listenForMessages();\n }\n\n private fetchInitialToken(): Promise<void> {\n const eagerTokenPromise = (() => {\n try {\n return this.fetchToken();\n } catch (error) {\n return Promise.reject(error);\n }\n })();\n\n return eagerTokenPromise.then((token) => {\n if (token) {\n this.token = token;\n } else {\n this.tokenError = 'Failed to fetch token: Token returned empty or undefined';\n }\n }).catch((error) => {\n this.tokenError = `Failed to fetch token: ${error instanceof Error ? error.message : String(error)}`;\n });\n } \n\n private listenForMessages(): void {\n if (!isBrowser) {\n // In SSR / non-browser environments we can't listen for postMessage events,\n // but it's still safe to create a Hyperswitch instance (it will become\n // useful on the client where another instance will typically be created).\n return;\n }\n\n window.addEventListener(\"message\", async (event) => {\n if (event.data?.type === \"TOKEN_EXPIRED\" && event.data?.value === true) {\n await this.refetchAndBroadcastToken();\n } else if (event.data?.type === \"EMBEDDED_IFRAME_READY\") {\n // Find the element whose iframe matches the event source\n this.activeElements.forEach((element) => {\n const iframe = element.getIframe();\n if (iframe?.contentWindow === event.source) {\n this.onElementIframeLoaded(element);\n }\n });\n }\n });\n }\n\n private async refetchAndBroadcastToken(): Promise<void> {\n if (this.isRefetchingToken) {\n return;\n }\n \n this.isRefetchingToken = true;\n \n try {\n const newToken = await this.fetchToken();\n \n if (newToken) {\n this.token = newToken;\n this.tokenError = null;\n this.activeElements.forEach((element, elementId) => {\n const iframe = element.getIframe();\n if (iframe?.contentWindow) {\n iframe.contentWindow.postMessage({\n type: 'AUTH_TOKEN',\n token: this.token\n }, '*');\n }\n });\n } else {\n this.tokenError = 'Failed to refetch token: Token returned empty or undefined';\n this.sendErrorToActiveElements(this.tokenError);\n }\n } catch (error) {\n this.tokenError = `Failed to refetch token: ${error instanceof Error ? error.message : String(error)}`;\n this.sendErrorToActiveElements(this.tokenError);\n } finally {\n this.isRefetchingToken = false;\n }\n }\n\n private sendErrorToActiveElements(errorMessage: string): void {\n this.activeElements.forEach((element) => {\n const iframe = element.getIframe();\n if (iframe?.contentWindow) {\n iframe.contentWindow.postMessage({\n type: 'AUTH_ERROR',\n error: errorMessage\n }, '*');\n }\n });\n }\n\n public create(type: string, options?: any): HyperswitchElement {\n let element: HyperswitchElement;\n \n switch (type) {\n case 'connectors':\n element = new ConnectorConfigurationComponent(this, options);\n break;\n default:\n throw new Error(`Unknown element type: ${type}`);\n }\n \n this.activeElements.set(element._internalId, element);\n \n return element;\n }\n\n public onElementIframeLoaded(element: HyperswitchElement): void {\n this.initPromise.then(() => {\n const iframe = element.getIframe();\n if (!iframe?.contentWindow) {\n return;\n }\n \n setTimeout(() => {\n try {\n const contentWindow = iframe.contentWindow;\n if (!contentWindow) {\n return;\n }\n\n if (this.tokenError) {\n contentWindow.postMessage({\n type: 'AUTH_ERROR',\n error: this.tokenError\n }, '*');\n } else if (this.token) {\n contentWindow.postMessage({\n type: 'AUTH_TOKEN',\n token: this.token\n }, '*');\n } else {\n contentWindow.postMessage({\n type: 'AUTH_ERROR',\n error: 'No token available'\n }, '*');\n }\n\n // Send init_config (if available) as a separate message\n if (this.initConfig) {\n contentWindow.postMessage({\n type: 'INIT_CONFIG',\n init_config: this.initConfig\n }, '*');\n }\n } catch (error) {\n }\n }, 100);\n }).catch((error) => {\n const iframe = element.getIframe();\n const contentWindow = iframe?.contentWindow;\n if (contentWindow) {\n setTimeout(() => {\n try {\n contentWindow.postMessage({\n type: 'AUTH_ERROR',\n error: `Token initialization failed: ${error instanceof Error ? error.message : String(error)}`\n }, '*');\n } catch {\n }\n }, 100);\n }\n });\n }\n}\n\nexport function loadHyperswitch(options: HyperswitchInitOptions): Hyperswitch {\n return new Hyperswitch(options);\n}\n\nexport { Hyperswitch };\n","export { loadHyperswitch, Hyperswitch } from './hyperswitch';\nexport { HyperswitchElement } from './element';\nexport { ConnectorConfigurationComponent } from './connector-configuration';\nexport type { HyperswitchInitOptions, ElementOptions } from './types';\nexport type { MerchantTheme } from './init-config';\n\nexport const VERSION = '1.0.0';\n"],"names":["isBrowser"],"mappings":";;;;AAGA,MAAMA,WAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD,MAAe,kBAAkB,CAAA;IAQ/B,WAAY,CAAA,QAAqB,EAAE,OAAwB,EAAA;AACzD,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;AAC7B,QAAA,IAAI,CAAC,WAAW,GAAG,YAAY,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC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,GAAG,CAAC,CAAC;AACV,SAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;AACjB,YAAA,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;YACnC,MAAM,aAAa,GAAG,MAAM,KAAA,IAAA,IAAN,MAAM,KAAN,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,MAAM,CAAE,aAAa,CAAC;YAC5C,IAAI,aAAa,EAAE;gBACjB,UAAU,CAAC,MAAK;AACd,oBAAA,IAAI;wBACF,aAAa,CAAC,WAAW,CAAC;AACxB,4BAAA,IAAI,EAAE,YAAY;AAClB,4BAAA,KAAK,EAAE,CAAgC,6BAAA,EAAA,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAE,CAAA;yBAChG,EAAE,GAAG,CAAC,CAAC;qBACT;AAAC,oBAAA,OAAA,EAAA,EAAM;qBACP;iBACF,EAAE,GAAG,CAAC,CAAC;aACT;AACH,SAAC,CAAC,CAAC;KACJ;AACF,CAAA;AAEK,SAAU,eAAe,CAAC,OAA+B,EAAA;AAC7D,IAAA,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC;;AC3LO,MAAM,OAAO,GAAG;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/element.ts","../src/connector-configuration.ts","../src/payments.ts","../src/refunds.ts","../src/init-config.ts","../src/hyperswitch.ts","../src/index.ts"],"sourcesContent":["import { Hyperswitch } from './hyperswitch';\nimport { ElementOptions } from './types';\n\nconst isBrowser = typeof window !== 'undefined';\n\nabstract class HyperswitchElement {\n protected instance: Hyperswitch;\n protected options: ElementOptions;\n public element!: HTMLElement;\n protected iframe!: HTMLIFrameElement;\n private boundMessageHandler: ((event: MessageEvent) => void) | null;\n public readonly _internalId: string;\n private isFullPage: boolean = false;\n private previousBodyOverflow: string = '';\n private showIframeTimer: ReturnType<typeof setTimeout> | null = null;\n private iframeOrigin: string | null = null;\n \n constructor(instance: Hyperswitch, options?: ElementOptions) {\n this.instance = instance;\n this.options = options || {};\n this._internalId = `hyper-el-${Math.random().toString(36).substring(7)}`;\n this.boundMessageHandler = null;\n // In SSR / non-browser environments, avoid touching DOM APIs.\n // The React wrapper only creates and mounts elements on the client,\n // so it's safe for server-side usage as long as we no-op here.\n if (!isBrowser) {\n return;\n }\n \n this.element = document.createElement('div');\n this.iframe = document.createElement('iframe');\n this.boundMessageHandler = this.handleMessage.bind(this);\n \n this.setupElement();\n this.setupIframe();\n window.addEventListener('message', this.boundMessageHandler);\n }\n\n private setupElement(): void {\n if (!isBrowser) {\n return;\n }\n\n this.element.className = `hyperswitch-element ${this.options.className || ''}`.trim();\n this.element.dataset.hyperswitchElement = this.getElementType();\n \n Object.assign(this.element.style, {\n width: this.options.width || '100%',\n height: this.options.height || '500px',\n overflow: 'hidden',\n ...(this.options.style || {})\n });\n }\n \n private setupIframe(): void {\n if (!isBrowser) {\n return;\n }\n\n this.iframe.src = this.getIframeSrc();\n this.iframe.style.border = 'none';\n this.iframe.style.width = '100%';\n this.iframe.style.height = '100%';\n this.iframe.title = `Hyperswitch ${this.getElementType()}`;\n this.iframe.setAttribute('allow', 'clipboard-read; clipboard-write; clipboard-sanitized-write');\n this.iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-presentation allow-downloads');\n \n this.element.appendChild(this.iframe);\n }\n \n private handleMessage(event: MessageEvent): void {\n if (!isBrowser) {\n return;\n }\n\n if (this.options.onMessage) {\n this.options.onMessage(event.data);\n }\n \n if (!this.acceptMessage(event)) {\n return;\n }\n \n if (this.isFullPageModalEnabled()) {\n if (event.data?.type === 'EMBEDDED_MODAL_OPEN') {\n this.setFullPage(true);\n } else if (event.data?.type === 'EMBEDDED_MODAL_CLOSE') {\n this.setFullPage(false);\n } else if (event.data?.type === 'EMBEDDED_MODAL_VISIBLE') {\n this.showIframe();\n }\n }\n \n if (event.data?.type === 'EMBEDDED_COMPONENT_RESIZE') {\n const newHeight = event.data.height;\n const messageComponent = event.data.component || '';\n \n if (!this.isFullPage && messageComponent === this.getElementType() && typeof newHeight === 'number' && newHeight > 0) {\n this.element.style.height = `${newHeight}px`;\n \n if (this.options.onResize) {\n this.options.onResize({\n width: this.element.clientWidth,\n height: newHeight\n });\n }\n }\n }\n }\n \n private setFullPage(isFullPage: boolean): void {\n if (isFullPage !== this.isFullPage) {\n this.isFullPage = isFullPage;\n this.iframe.style.visibility = 'hidden';\n \n if (isFullPage) {\n this.previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n Object.assign(this.iframe.style, {\n position: 'fixed',\n top: '0',\n left: '0',\n width: '100vw',\n height: '100vh',\n zIndex: '2147483647'\n });\n } else {\n document.body.style.overflow = this.previousBodyOverflow;\n Object.assign(this.iframe.style, {\n position: '',\n top: '',\n left: '',\n width: '100%',\n height: '100%',\n zIndex: ''\n });\n }\n \n if (this.showIframeTimer) {\n clearTimeout(this.showIframeTimer);\n }\n this.showIframeTimer = setTimeout(() => this.showIframe(), 300);\n }\n \n this.postMessageToIframe({\n type: isFullPage ? 'EMBEDDED_MODAL_OPENED' : 'EMBEDDED_MODAL_CLOSED'\n });\n }\n \n private showIframe(): void {\n if (this.showIframeTimer) {\n clearTimeout(this.showIframeTimer);\n this.showIframeTimer = null;\n }\n this.iframe.style.visibility = '';\n }\n \n mount(domNode: string | HTMLElement): HyperswitchElement {\n if (!isBrowser) {\n throw new Error('HyperswitchElement.mount can only be called in a browser environment');\n }\n\n const parent = typeof domNode === 'string' \n ? document.querySelector(domNode) \n : domNode;\n \n if (!parent) {\n throw new Error(`Invalid mount point: ${domNode}`);\n }\n \n parent.appendChild(this.element);\n return this;\n }\n \n destroy(): void {\n if (!isBrowser) {\n return;\n }\n if (this.isFullPage) {\n this.isFullPage = false;\n document.body.style.overflow = this.previousBodyOverflow;\n }\n if (this.showIframeTimer) {\n clearTimeout(this.showIframeTimer);\n this.showIframeTimer = null;\n }\n if (this.boundMessageHandler) {\n window.removeEventListener('message', this.boundMessageHandler);\n }\n \n if (this.element && this.element.parentNode) {\n this.element.parentNode.removeChild(this.element);\n }\n }\n \n protected abstract getElementType(): string;\n protected abstract getIframeSrc(): string;\n\n public getIframe(): HTMLIFrameElement {\n return this.iframe;\n }\n\n public acceptMessage(event: MessageEvent): boolean {\n if (event.source !== this.iframe?.contentWindow) {\n return false;\n }\n if (this.iframeOrigin === null && event.origin && event.origin !== 'null') {\n this.iframeOrigin = event.origin;\n }\n return this.iframeOrigin === null || event.origin === this.iframeOrigin;\n }\n\n public postMessageToIframe(message: Record<string, unknown>): void {\n if (this.iframeOrigin === null) {\n return;\n }\n this.iframe?.contentWindow?.postMessage(message, this.iframeOrigin);\n }\n\n public isFullPageModalEnabled(): boolean {\n return this.options.fullPageModals !== false;\n }\n}\n\nexport { HyperswitchElement };\n","import { Hyperswitch } from './hyperswitch';\nimport { HyperswitchElement } from './element';\nimport { ElementOptions } from './types';\n\nexport class ConnectorConfigurationComponent extends HyperswitchElement {\n constructor(instance: Hyperswitch, options?: ElementOptions) {\n super(instance, options);\n }\n \n protected getElementType(): string {\n return 'connectors';\n }\n \n protected getIframeSrc(): string {\n const baseUrl = this.options.url || 'http://localhost:9000';\n return `${baseUrl}/embedded/connectors`;\n }\n}\n","import { Hyperswitch } from './hyperswitch';\nimport { HyperswitchElement } from './element';\nimport { ElementOptions } from './types';\n\nexport class PaymentsComponent extends HyperswitchElement {\n constructor(instance: Hyperswitch, options?: ElementOptions) {\n super(instance, options);\n }\n \n protected getElementType(): string {\n return 'payments';\n }\n \n protected getIframeSrc(): string {\n const baseUrl = this.options.url || 'http://localhost:9000';\n return `${baseUrl}/embedded/payments`;\n }\n}\n","import { Hyperswitch } from './hyperswitch';\nimport { HyperswitchElement } from './element';\nimport { ElementOptions } from './types';\n\nexport class RefundsComponent extends HyperswitchElement {\n constructor(instance: Hyperswitch, options?: ElementOptions) {\n super(instance, options);\n }\n \n protected getElementType(): string {\n return 'refunds';\n }\n \n protected getIframeSrc(): string {\n const baseUrl = this.options.url || 'http://localhost:9000';\n return `${baseUrl}/embedded/refunds`;\n }\n}\n","/**\n * Theme configuration received from the merchant.\n * This is the ONLY contract we expect merchants to follow.\n */\nexport type MerchantTheme = {\n /** Primary color */\n primaryColor?: string;\n /** Page background color */\n backgroundColor?: string;\n /** Button configurations */\n buttons?: {\n /** Primary button configuration */\n primary?: {\n /** Primary button background color */\n backgroundColor?: string;\n /** Primary button text color */\n textColor?: string;\n /** Primary button hover background color */\n hoverBackgroundColor?: string;\n };\n /** Secondary button configuration */\n secondary?: {\n /** Secondary button background color */\n backgroundColor?: string;\n /** Secondary button text color */\n textColor?: string;\n /** Secondary button hover background color */\n hoverBackgroundColor?: string;\n };\n };\n};\n\n/**\n * Full init_config payload shape sent to the Control Center.\n * Most fields are null for now; Control Center applies defaults.\n */\nexport type InitConfig = {\n settings: {\n colors: {\n primary: string | null;\n secondary: string | null;\n background: string | null;\n };\n sidebar: null;\n typography: null;\n buttons: {\n primary: {\n backgroundColor: string | null;\n textColor: string | null;\n hoverBackgroundColor: string | null;\n };\n secondary: {\n backgroundColor: string | null;\n textColor: string | null;\n hoverBackgroundColor: string | null;\n };\n };\n borders: null;\n spacing: null;\n };\n urls: {\n faviconUrl: null;\n logoUrl: null;\n };\n};\n\n/**\n * Build the init_config object that Control Center expects\n * from the simple MerchantTheme contract.\n *\n * Any missing value is set to null.\n */\nexport function buildInitConfig(merchantTheme: MerchantTheme | undefined | null): InitConfig {\n const safeTheme = merchantTheme || {};\n\n return {\n settings: {\n colors: {\n primary: safeTheme.primaryColor ?? null,\n secondary: null,\n background: safeTheme.backgroundColor ?? null\n },\n sidebar: null,\n typography: null,\n buttons: {\n primary: {\n backgroundColor: safeTheme.buttons?.primary?.backgroundColor ?? null,\n textColor: safeTheme.buttons?.primary?.textColor ?? null,\n hoverBackgroundColor: safeTheme.buttons?.primary?.hoverBackgroundColor ?? null\n },\n secondary: {\n backgroundColor: safeTheme.buttons?.secondary?.backgroundColor ?? null,\n textColor: safeTheme.buttons?.secondary?.textColor ?? null,\n hoverBackgroundColor: safeTheme.buttons?.secondary?.hoverBackgroundColor ?? null\n }\n },\n borders: null,\n spacing: null\n },\n urls: {\n faviconUrl: null,\n logoUrl: null\n }\n };\n}\n\n\n","import { HyperswitchElement } from './element';\nimport { ConnectorConfigurationComponent } from './connector-configuration';\nimport { PaymentsComponent } from './payments';\nimport { RefundsComponent } from './refunds';\nimport { HyperswitchInitOptions } from './types';\nimport { buildInitConfig,InitConfig } from './init-config';\n\nconst isBrowser = typeof window !== 'undefined';\n\nclass Hyperswitch {\n private token: string | null = null;\n private fetchToken: () => Promise<string | undefined>;\n private initConfig: InitConfig | null = null;\n private activeElements: Map<string, HyperswitchElement> = new Map();\n private isRefetchingToken: boolean = false;\n private initPromise: Promise<void>;\n private tokenError: string | null = null;\n\n constructor(options: HyperswitchInitOptions) {\n if (!options || typeof options.fetchToken !== 'function') {\n throw new Error('loadHyperswitch requires a fetchToken callback function');\n }\n\n this.fetchToken = options.fetchToken;\n this.initConfig = options.initConfig ? buildInitConfig(options.initConfig) : null;\n this.initPromise = this.fetchInitialToken();\n this.listenForMessages();\n }\n\n private fetchInitialToken(): Promise<void> {\n const eagerTokenPromise = (() => {\n try {\n return this.fetchToken();\n } catch (error) {\n return Promise.reject(error);\n }\n })();\n\n return eagerTokenPromise.then((token) => {\n if (token) {\n this.token = token;\n } else {\n this.tokenError = 'Failed to fetch token: Token returned empty or undefined';\n }\n }).catch((error) => {\n this.tokenError = `Failed to fetch token: ${error instanceof Error ? error.message : String(error)}`;\n });\n } \n\n private listenForMessages(): void {\n if (!isBrowser) {\n // In SSR / non-browser environments we can't listen for postMessage events,\n // but it's still safe to create a Hyperswitch instance (it will become\n // useful on the client where another instance will typically be created).\n return;\n }\n\n window.addEventListener(\"message\", async (event) => {\n const sourceElement = Array.from(this.activeElements.values()).find(\n (element) => element.acceptMessage(event)\n );\n if (!sourceElement) {\n return;\n }\n\n if (event.data?.type === \"TOKEN_EXPIRED\" && event.data?.value === true) {\n await this.refetchAndBroadcastToken();\n } else if (event.data?.type === \"EMBEDDED_IFRAME_READY\") {\n this.onElementIframeLoaded(sourceElement);\n }\n });\n }\n\n private async refetchAndBroadcastToken(): Promise<void> {\n if (this.isRefetchingToken) {\n return;\n }\n \n this.isRefetchingToken = true;\n \n try {\n const newToken = await this.fetchToken();\n \n if (newToken) {\n this.token = newToken;\n this.tokenError = null;\n this.activeElements.forEach((element) => {\n element.postMessageToIframe({\n type: 'AUTH_TOKEN',\n token: this.token\n });\n });\n } else {\n this.tokenError = 'Failed to refetch token: Token returned empty or undefined';\n this.sendErrorToActiveElements(this.tokenError);\n }\n } catch (error) {\n this.tokenError = `Failed to refetch token: ${error instanceof Error ? error.message : String(error)}`;\n this.sendErrorToActiveElements(this.tokenError);\n } finally {\n this.isRefetchingToken = false;\n }\n }\n\n private sendErrorToActiveElements(errorMessage: string): void {\n this.activeElements.forEach((element) => {\n element.postMessageToIframe({\n type: 'AUTH_ERROR',\n error: errorMessage\n });\n });\n }\n\n public create(type: string, options?: any): HyperswitchElement {\n let element: HyperswitchElement;\n \n switch (type) {\n case 'connectors':\n element = new ConnectorConfigurationComponent(this, options);\n break;\n case 'payments':\n element = new PaymentsComponent(this, options);\n break;\n case 'refunds':\n element = new RefundsComponent(this, options);\n break;\n default:\n throw new Error(`Unknown element type: ${type}`);\n }\n \n this.activeElements.set(element._internalId, element);\n \n return element;\n }\n\n public onElementIframeLoaded(element: HyperswitchElement): void {\n this.initPromise.then(() => {\n const iframe = element.getIframe();\n if (!iframe?.contentWindow) {\n return;\n }\n \n setTimeout(() => {\n try {\n if (this.tokenError) {\n element.postMessageToIframe({\n type: 'AUTH_ERROR',\n error: this.tokenError\n });\n } else if (this.token) {\n element.postMessageToIframe({\n type: 'AUTH_TOKEN',\n token: this.token\n });\n } else {\n element.postMessageToIframe({\n type: 'AUTH_ERROR',\n error: 'No token available'\n });\n }\n\n // Always send init_config. If merchant doesn't provide it, send an empty object.\n element.postMessageToIframe({\n type: 'INIT_CONFIG',\n init_config: this.initConfig ?? {},\n sdk_capabilities: { full_page_modal: element.isFullPageModalEnabled() }\n });\n } catch (error) {\n }\n }, 100);\n }).catch((error) => {\n setTimeout(() => {\n try {\n element.postMessageToIframe({\n type: 'AUTH_ERROR',\n error: `Token initialization failed: ${error instanceof Error ? error.message : String(error)}`\n });\n } catch {\n }\n }, 100);\n });\n }\n}\n\nexport function loadHyperswitch(options: HyperswitchInitOptions): Hyperswitch {\n return new Hyperswitch(options);\n}\n\nexport { Hyperswitch };\n","export { loadHyperswitch, Hyperswitch } from './hyperswitch';\nexport { HyperswitchElement } from './element';\nexport { ConnectorConfigurationComponent } from './connector-configuration';\nexport { PaymentsComponent } from './payments';\nexport { RefundsComponent } from './refunds';\nexport type { HyperswitchInitOptions, ElementOptions } from './types';\nexport type { MerchantTheme } from './init-config';\n\nexport const VERSION = '1.0.0';\n"],"names":["isBrowser"],"mappings":";;;;AAGA,MAAMA,WAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AAEhD,MAAe,kBAAkB,CAAA;IAY/B,WAAY,CAAA,QAAqB,EAAE,OAAwB,EAAA;QALnD,IAAU,CAAA,UAAA,GAAY,KAAK,CAAC;QAC5B,IAAoB,CAAA,oBAAA,GAAW,EAAE,CAAC;QAClC,IAAe,CAAA,eAAA,GAAyC,IAAI,CAAC;QAC7D,IAAY,CAAA,YAAA,GAAkB,IAAI,CAAC;AAGzC,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;AAC7B,QAAA,IAAI,CAAC,WAAW,GAAG,YAAY,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;AACzE,QAAA,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;;;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