@movmo/express-checkout-button 1.6.1 → 1.7.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 CHANGED
@@ -117,6 +117,51 @@ The `isProd` prop controls which Movmo endpoints are used:
117
117
  - API endpoint: `https://api.movmo.io`
118
118
  - Flights UI: `https://flights.movmo.io`
119
119
 
120
+ ## Analytics (scoped)
121
+
122
+ `MovmoCheckoutButton` self-instruments the pre-iframe funnel — from the button rendering on
123
+ the airline page through the traveler landing inside the Movmo checkout — using
124
+ `@movmo_app/analytics` in **scoped mode**. Scoped mode disables every document-level listener
125
+ the SDK would otherwise install (click/rage-click/hover/scroll/field/section autocapture);
126
+ the button only ever attaches listeners to its own DOM node and the checkout overlay it
127
+ creates. It never observes the partner's page, reads partner form fields, or inspects
128
+ anything outside those two elements. The airline identifier passed as `iataCode` becomes
129
+ `partner_id`, and the partner page's **hostname** is the only page context transmitted —
130
+ never the path, full URL, referrer, page content, or DOM structure.
131
+
132
+ Ten events cover the funnel:
133
+
134
+ | Event | Fires when |
135
+ | ------------------------------ | ------------------------------------------------------------------------ |
136
+ | `plugin_loaded` | The button mounts and the scoped tracker initializes |
137
+ | `button_viewed` | The button crosses 50% viewport visibility (once per mount) |
138
+ | `button_hovered` | The pointer leaves the button after a ≥200ms hover |
139
+ | `button_clicked` | The button is clicked |
140
+ | `offer_save_started` | A raw flight offer begins saving (no pre-saved `flightOfferID`) |
141
+ | `offer_save_succeeded` | The offer save call returns an offer ID |
142
+ | `offer_save_failed` | The offer save call returns no offer ID (previously a silent no-op) |
143
+ | `overlay_opened` | The checkout overlay iframe is created |
144
+ | `iframe_ready` | The embedded flights-ui document sends its first `MOVMO_READY` handshake |
145
+ | `overlay_abandoned_pre_iframe` | The overlay is torn down before `MOVMO_READY` was ever seen |
146
+
147
+ `iframe_ready` and `overlay_abandoned_pre_iframe` are mutually exclusive per overlay open —
148
+ whichever happens first wins, and neither fires again until the overlay is reopened. Both
149
+ carry a `ms_since_open` property so you can track how long the iframe took to load or how
150
+ quickly a traveler bounced.
151
+
152
+ Every tracking call is fail-open: analytics never throws, and a network or init failure
153
+ never blocks or delays checkout.
154
+
155
+ **Configuration:**
156
+
157
+ - The analytics ingest endpoint defaults to `https://api.movmo.io/v1/t` (prod) /
158
+ `https://e2e.api.movmo.io/v1/t` (e2e), selected by the same `isProd` prop as the checkout
159
+ URL. Override it with `REACT_APP_MOVMO_ANALYTICS_URL` (inlined at build time), the same
160
+ mechanism as `REACT_APP_MOVMO_CHECKOUT_URL`.
161
+ - On click, the button appends an `mvs` (Movmo session) query param to the checkout URL with
162
+ its current analytics session id. The embedded flights-ui SDK adopts that id on load, so
163
+ `button_viewed` → … → `booking_confirmed` all land in one session instead of two.
164
+
120
165
  ## CSS Integration
121
166
 
122
167
  You must import the component's CSS for proper styling:
@@ -0,0 +1,11 @@
1
+ import { EVENTS } from '@movmo_app/analytics';
2
+ export { EVENTS };
3
+ /**
4
+ * Scoped-mode analytics for the partner page (MOVMO-464). Autocapture stays OFF —
5
+ * we never observe the partner's DOM or inputs; listeners attach only to
6
+ * Movmo-rendered elements. Analytics must never break checkout: every entry
7
+ * point here is fail-open.
8
+ */
9
+ export declare function initScopedTracker(iataCode: string, isProd: boolean): void;
10
+ export declare function trackSafe(event: string, props?: Record<string, unknown>): void;
11
+ export declare function trackerSessionId(): string | null;
package/dist/index.cjs.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @movmo/express-checkout-button v1.6.1
2
+ * @movmo/express-checkout-button v1.7.0
3
3
  * React component plugin for embedding Movmo Express Checkout on airline websites.
4
4
  * (c) 2026 Movmo
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("react/jsx-runtime"),o=require("react"),t=require("axios"),n=require("@movmo_app/types");const i=(e,o,n=!1)=>{const i=n?"https://flights.movmo.io":"https://flights.e2e.movmo.io",s=process.env.REACT_APP_MOVMO_CHECKOUT_API_URL||`${i}/v1/proxy`,r=t.create({baseURL:s,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":e,"X-Forwarded-Host":"undefined"!=typeof window?window.location.host:"","movmo-customer-id":o,..."undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname||!process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER?{}:{"X-Movmo-Proxy-Auth":process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER}},withCredentials:!0,timeout:3e4});return r.interceptors.request.use((e=>{e.headers?.Authorization&&delete e.headers.Authorization;const o=(e=>{const o=document.cookie.split(";");for(let t=0;t<o.length;t++){const n=o[t].trim();if(n.startsWith(e+"="))return decodeURIComponent(n.substring(e.length+1))}return null})("movmo_csrf_token");return o&&(e.headers["X-CSRF-Token"]=o),e})),r};let s,r=!1,c=!1;const a=50,d=20;function m(e){const o=[process.env.REACT_APP_MOVMO_CHECKOUT_URL];if(!n.isTrustedOrigin(e.origin,n.MOVMO_FLIGHTS_ORIGINS,{isProd:c,extraOrigins:o}))return;const t=e.data;if(t?.type)switch(t.type){case n.MovmoFrameMessageType.READY:{const o={type:n.MovmoFrameMessageType.INIT,parentOrigin:window.location.origin};e.source?.postMessage(o,e.origin);break}case n.MovmoFrameMessageType.BOOKING_COMPLETE:{const{bookingId:e,airlineRef:o,providerId:n}=t;e&&window.history.pushState({checkoutOpen:!0,bookingComplete:!0,bookingId:e,providerId:n},"",`/movmo/checkout/booking/${e}?airlineRef=${o||""}&providerId=${n||""}`);break}case n.MovmoFrameMessageType.BOOKING_FAILED:{const e=t.reason??"search_again",o=s;!function(e){if(document.getElementById("movmo-checkout")?.remove(),window.history.state?.checkoutOpen){if(e){let o=!1,t=0;const n=()=>{o||(o=!0,window.removeEventListener("popstate",n),e())};window.addEventListener("popstate",n,{once:!0});const i=()=>{o||(window.history.state?.checkoutOpen?t>=d?n():(t+=1,setTimeout(i,a)):n())};setTimeout(i,a)}window.history.back()}else e?.()}((()=>{if(o)try{o({reason:e})}catch(e){}}));break}}}function h(e,o=!1,t){if(document.getElementById("movmo-checkout"))return;const n=document.createElement("div");n.id="movmo-checkout",n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ";const i=process.env.REACT_APP_MOVMO_CHECKOUT_URL||(o?"https://flights.movmo.io":"https://flights.e2e.movmo.io");let a=`${i}/index.html#/booking?${e}`;if(window.location.pathname.includes("/movmo/checkout/booking/")){const e=window.location.pathname.split("/").pop(),o=new URLSearchParams(window.location.search);a=`${i}/index.html#/booking/${e}?airlineRef=${o.get("airlineRef")||""}&providerId=${o.get("providerId")||""}`,window.history.replaceState({checkoutOpen:!0,bookingComplete:!0},"",window.location.href)}const d=document.createElement("iframe");d.src=a,d.width="100%",d.height="100%",d.style.border="none",d.id="movmo-checkout-iframe",d.setAttribute("allow","storage-access"),n.appendChild(d),document.body.appendChild(n),c=o,s=t?.onExit,r||(window.addEventListener("message",m),r=!0)}window.addEventListener("popstate",(()=>{const e=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&e&&e.remove()})),"undefined"!=typeof window&&window.addEventListener("DOMContentLoaded",(()=>{const e=window.location.pathname.includes("/movmo/checkout/booking/"),o=window.location.pathname.startsWith("/movmo/checkout");if(e||o){h(window.location.search.substring(1),function(){const e=window.location.hostname;return!e.includes("e2e")&&!e.includes("localhost")}())}}));exports.MovmoCheckoutButton=({iataCode:t,apiKey:n,providerID:s,flightOffer:r,flightOfferID:c,isProd:a=!1,className:d,onExit:m})=>{const[p,u]=o.useState(!1),l=i(n,t,a),w=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${p?"bg-gradient-hover":"bg-gradient-normal"}\n ${d??""}\n `.trim(),f="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return e.jsxs("button",{onClick:async()=>{let e=c;if(!e&&r){const o=await(async(e,o,t)=>await t.post(`/v1/flights/providers/${e}/offers`,o).then((e=>e.data.offer_id)).catch((e=>null)))(s,r,l);if(!o)return;e=o}if(!e)return;const o=new URLSearchParams({offerId:e,providerId:s,airlineRef:t}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${o}`),h(o,a,{onExit:m})},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),className:w,children:["Express Checkout",e.jsx("span",{className:f,children:"Movmo"})]})};
7
+ "use strict";var e=require("react/jsx-runtime"),o=require("react"),t=require("axios"),n=require("@movmo_app/types"),i=require("@movmo_app/analytics");const r=(e,o,n=!1)=>{const i=n?"https://flights.movmo.io":"https://flights.e2e.movmo.io",r=process.env.REACT_APP_MOVMO_CHECKOUT_API_URL||`${i}/v1/proxy`,s=t.create({baseURL:r,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":e,"X-Forwarded-Host":"undefined"!=typeof window?window.location.host:"","movmo-customer-id":o,..."undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname||!process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER?{}:{"X-Movmo-Proxy-Auth":process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER}},withCredentials:!0,timeout:3e4});return s.interceptors.request.use((e=>{e.headers?.Authorization&&delete e.headers.Authorization;const o=(e=>{const o=document.cookie.split(";");for(let t=0;t<o.length;t++){const n=o[t].trim();if(n.startsWith(e+"="))return decodeURIComponent(n.substring(e.length+1))}return null})("movmo_csrf_token");return o&&(e.headers["X-CSRF-Token"]=o),e})),s};function s(e,o={}){try{i.Movmo.track(e,o)}catch{}}let c,a=!1,d=!1,u=null,m=!1;const l=50,p=20;function h(){null===u||m||s(i.EVENTS.OVERLAY_ABANDONED_PRE_IFRAME,{ms_since_open:Date.now()-u}),u=null}function E(e){const o=[process.env.REACT_APP_MOVMO_CHECKOUT_URL];if(!n.isTrustedOrigin(e.origin,n.MOVMO_FLIGHTS_ORIGINS,{isProd:d,extraOrigins:o}))return;const t=e.data;if(t?.type)switch(t.type){case n.MovmoFrameMessageType.READY:{m||(m=!0,null!==u&&s(i.EVENTS.IFRAME_READY,{ms_since_open:Date.now()-u}));const o={type:n.MovmoFrameMessageType.INIT,parentOrigin:window.location.origin};e.source?.postMessage(o,e.origin);break}case n.MovmoFrameMessageType.BOOKING_COMPLETE:{const{bookingId:e,airlineRef:o,providerId:n}=t;e&&window.history.pushState({checkoutOpen:!0,bookingComplete:!0,bookingId:e,providerId:n},"",`/movmo/checkout/booking/${e}?airlineRef=${o||""}&providerId=${n||""}`);break}case n.MovmoFrameMessageType.BOOKING_FAILED:{const e=t.reason??"search_again",o=c;!function(e){if(h(),document.getElementById("movmo-checkout")?.remove(),window.history.state?.checkoutOpen){if(e){let o=!1,t=0;const n=()=>{o||(o=!0,window.removeEventListener("popstate",n),e())};window.addEventListener("popstate",n,{once:!0});const i=()=>{o||(window.history.state?.checkoutOpen?t>=p?n():(t+=1,setTimeout(i,l)):n())};setTimeout(i,l)}window.history.back()}else e?.()}((()=>{if(o)try{o({reason:e})}catch(e){}}));break}}}function w(e,o=!1,t){if(document.getElementById("movmo-checkout"))return;const n=document.createElement("div");n.id="movmo-checkout",n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ";const i=process.env.REACT_APP_MOVMO_CHECKOUT_URL||(o?"https://flights.movmo.io":"https://flights.e2e.movmo.io");let r=`${i}/index.html#/booking?${e}`;if(window.location.pathname.includes("/movmo/checkout/booking/")){const e=window.location.pathname.split("/").pop(),o=new URLSearchParams(window.location.search);r=`${i}/index.html#/booking/${e}?airlineRef=${o.get("airlineRef")||""}&providerId=${o.get("providerId")||""}`,window.history.replaceState({checkoutOpen:!0,bookingComplete:!0},"",window.location.href)}const s=document.createElement("iframe");s.src=r,s.width="100%",s.height="100%",s.style.border="none",s.id="movmo-checkout-iframe",s.setAttribute("allow","storage-access"),n.appendChild(s),document.body.appendChild(n),d=o,c=t?.onExit,u=Date.now(),m=!1,a||(window.addEventListener("message",E),a=!0)}window.addEventListener("popstate",(()=>{const e=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&e&&(h(),e.remove())})),"undefined"!=typeof window&&window.addEventListener("DOMContentLoaded",(()=>{const e=window.location.pathname.includes("/movmo/checkout/booking/"),o=window.location.pathname.startsWith("/movmo/checkout");if(e||o){w(window.location.search.substring(1),function(){const e=window.location.hostname;return!e.includes("e2e")&&!e.includes("localhost")}())}}));exports.MovmoCheckoutButton=({iataCode:t,apiKey:n,providerID:c,flightOffer:a,flightOfferID:d,isProd:u=!1,className:m,onExit:l})=>{const[p,h]=o.useState(!1),E=o.useRef(null),f=o.useRef(null),v=r(n,t,u);o.useEffect((()=>{if(function(e,o){try{if(i.Movmo.isInitialized())return;const t=process.env.REACT_APP_MOVMO_ANALYTICS_URL||(o?"https://api.movmo.io/v1/t":"https://e2e.api.movmo.io/v1/t");i.Movmo.init({app:"express-checkout-button",env:o?"prd":"e2e",partnerId:e,endpoint:t,scoped:!0}),i.Movmo.track(i.EVENTS.PLUGIN_LOADED)}catch{}}(t,u),"undefined"==typeof IntersectionObserver||!E.current)return;const e=new IntersectionObserver((o=>{o.some((e=>e.isIntersecting))&&(s(i.EVENTS.BUTTON_VIEWED),e.disconnect())}),{threshold:.5});return e.observe(E.current),()=>e.disconnect()}),[]);const _=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${p?"bg-gradient-hover":"bg-gradient-normal"}\n ${m??""}\n `.trim(),g="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return e.jsxs("button",{ref:E,onClick:async()=>{f.current=null,s(i.EVENTS.BUTTON_CLICKED);let e=d;if(!e&&a){s(i.EVENTS.OFFER_SAVE_STARTED);const o=Date.now(),t=await(async(e,o,t)=>await t.post(`/v1/flights/providers/${e}/offers`,o).then((e=>e.data.offer_id)).catch((e=>null)))(c,a,v),n=Date.now()-o;if(!t)return void s(i.EVENTS.OFFER_SAVE_FAILED,{latency_ms:n});s(i.EVENTS.OFFER_SAVE_SUCCEEDED,{latency_ms:n}),e=t}if(!e)return;const o=new URLSearchParams({offerId:e,providerId:c,airlineRef:t}),n=function(){try{return i.Movmo.getSessionId()}catch{return null}}();n&&o.set("mvs",n);const r=o.toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${r}`),w(r,u,{onExit:l}),s(i.EVENTS.OVERLAY_OPENED)},onMouseEnter:()=>{h(!0),f.current=Date.now()},onMouseLeave:()=>{if(h(!1),null!==f.current){const e=Date.now()-f.current;f.current=null,e>=200&&s(i.EVENTS.BUTTON_HOVERED,{dwell_ms:e})}},className:_,children:["Express Checkout",e.jsx("span",{className:g,children:"Movmo"})]})};
8
8
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/api.ts","../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\n\n// Helper function to read cookie value from document.cookie\nconst getCookie = (name: string): string | null => {\n const cookieString = document.cookie;\n const cookies = cookieString.split(';');\n for (let i = 0; i < cookies.length; i++) {\n const cookie = cookies[i].trim();\n if (cookie.startsWith(name + '=')) {\n // URL-decode the cookie value to match what backend expects\n return decodeURIComponent(cookie.substring(name.length + 1));\n }\n }\n return null;\n};\n\nconst isLocalHost = () =>\n typeof window !== 'undefined' &&\n (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');\n\nexport const createAxiosClient = (apiKey: string, airlineRef: string, isProd: boolean = false) => {\n const baseUrl = isProd ? 'https://flights.movmo.io' : 'https://flights.e2e.movmo.io';\n // REACT_APP_MOVMO_CHECKOUT_API_URL overrides the API base (e.g. the offline demo\n // talks directly to the local monolith-api at http://localhost:8080, bypassing the\n // CloudFront /v1/proxy hop). Defaults are unchanged when the env var is unset.\n const proxyBaseUrl =\n process.env.REACT_APP_MOVMO_CHECKOUT_API_URL || `${baseUrl}/v1/proxy`;\n\n const client = axios.create({\n baseURL: proxyBaseUrl,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n 'X-Forwarded-Host': typeof window !== 'undefined' ? window.location.host : '',\n 'movmo-customer-id': airlineRef,\n ...(isLocalHost() && process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER\n ? { 'X-Movmo-Proxy-Auth': process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER }\n : {}),\n },\n withCredentials: true,\n timeout: 30000,\n });\n\n client.interceptors.request.use((config) => {\n if (config.headers?.Authorization) {\n delete config.headers.Authorization;\n }\n const token = getCookie('movmo_csrf_token');\n if (token) {\n config.headers['X-CSRF-Token'] = token;\n }\n\n return config;\n });\n\n return client;\n};\n\nexport const saveProviderOffer = async (\n providerID: string,\n rawOffer: object,\n client: AxiosInstance,\n): Promise<string | null> => {\n return await client\n .post(`/v1/flights/providers/${providerID}/offers`, rawOffer)\n .then((res) => res.data.offer_id)\n .catch((err) => {\n console.error(err);\n return null;\n });\n};\n","import {\n MOVMO_FLIGHTS_ORIGINS,\n MovmoExitReason,\n MovmoFrameMessage,\n MovmoFrameMessageType,\n MovmoInitMessage,\n isTrustedOrigin,\n} from '@movmo_app/types';\n\n/** Passed to the airline's onExit callback when the checkout hands control back. */\nexport interface MovmoCheckoutExitInfo {\n reason: MovmoExitReason;\n}\n\nexport interface MovmoCheckoutOverlayOptions {\n /**\n * Fires after an iframe-initiated exit (e.g. the traveler clicked\n * \"Return to airline\" on a dead-end screen) once the overlay is removed and\n * the page URL has been restored to where the checkout was opened. Use it to\n * route the traveler onward or record analytics. It does NOT fire when the\n * user closes the checkout with the browser back button (they are already\n * back where they were), and it cannot survive a page refresh — a\n * re-hydrated overlay falls back to the default close behavior.\n */\n onExit?: (info: MovmoCheckoutExitInfo) => void;\n}\n\n// A single message listener for the page lifetime, attached on the first overlay open and\n// never re-added. Re-adding per call would stack orphaned listeners every time the overlay\n// is torn down and reopened — each would reply to READY (duplicate INIT handshakes the\n// iframe can't disambiguate) and push duplicate history entries on BOOKING_COMPLETE.\nlet messageListenerAttached = false;\nlet overlayIsProd = false;\nlet overlayOnExit: MovmoCheckoutOverlayOptions['onExit'];\n\n/**\n * Tear down the overlay and restore the page to where the checkout was opened.\n *\n * Order matters: the iframe is removed FIRST. Its navigations join the\n * parent's joint session history, so a history.back() issued while the iframe\n * is still attached could pop an iframe entry instead of the parent's — the\n * overlay would never close. Removing the browsing context prunes its entries,\n * making the subsequent back() deterministically land on the airline page the\n * user was on when they clicked the button (handleClick pushes\n * {checkoutOpen:true} synchronously before opening).\n *\n * history.back() is asynchronous, so onClosed is deferred until the traversal\n * settles (one-shot popstate, with a short timeout fallback) — an airline\n * callback that navigates would otherwise race the pending traversal. When\n * there is no checkoutOpen state to pop (direct navigation to a\n * /movmo/checkout URL), no back() is issued and onClosed fires immediately;\n * the airline's onExit is the remedy for the lingering URL in that case.\n */\n// Poll interval and cap for the popstate fallback below.\nconst CLOSE_POLL_MS = 50;\nconst CLOSE_POLL_MAX_ATTEMPTS = 20; // ~1s ceiling\n\nfunction closeOverlay(onClosed?: () => void) {\n document.getElementById('movmo-checkout')?.remove();\n\n if (!window.history.state?.checkoutOpen) {\n onClosed?.();\n return;\n }\n\n if (onClosed) {\n let settled = false;\n let attempts = 0;\n const settle = () => {\n if (settled) return;\n settled = true;\n window.removeEventListener('popstate', settle);\n onClosed();\n };\n // popstate = the back() traversal completed and the pre-checkout URL is\n // restored: notify immediately. This is the path real browsers take.\n window.addEventListener('popstate', settle, { once: true });\n // Fallback for environments where popstate never fires (jsdom mocks\n // history.back). Only settle once the checkoutOpen entry is actually gone,\n // so onExit never runs against a still-current /movmo/checkout URL — an\n // airline callback that navigates would otherwise be undone when the\n // pending back() finally lands. Bounded so a genuinely stuck traversal\n // can't hang the callback forever; if we exhaust the budget we settle\n // anyway and warn, since the URL guarantee can't be met.\n const poll = () => {\n if (settled) return;\n if (!window.history.state?.checkoutOpen) {\n settle();\n return;\n }\n if (attempts >= CLOSE_POLL_MAX_ATTEMPTS) {\n console.warn(\n '[movmo] overlay close: history did not settle; onExit may see an unrestored URL',\n );\n settle();\n return;\n }\n attempts += 1;\n setTimeout(poll, CLOSE_POLL_MS);\n };\n setTimeout(poll, CLOSE_POLL_MS);\n }\n window.history.back();\n}\n\nfunction handleIframeMessage(event: MessageEvent) {\n // Only ever trust messages from a Movmo flights-ui origin. REACT_APP_MOVMO_CHECKOUT_URL\n // widens the non-prod allowlist for the offline demo; prod keeps its hardcoded list.\n const extraOrigins = [process.env.REACT_APP_MOVMO_CHECKOUT_URL];\n if (\n !isTrustedOrigin(event.origin, MOVMO_FLIGHTS_ORIGINS, { isProd: overlayIsProd, extraOrigins })\n ) {\n return;\n }\n\n const data = event.data as MovmoFrameMessage | undefined;\n if (!data?.type) return;\n\n switch (data.type) {\n case MovmoFrameMessageType.READY: {\n // Handshake: reply with our origin so the iframe can target us directly on\n // subsequent messages instead of broadcasting to \"*\".\n const initMessage: MovmoInitMessage = {\n type: MovmoFrameMessageType.INIT,\n parentOrigin: window.location.origin,\n };\n (event.source as Window | null)?.postMessage(initMessage, event.origin);\n break;\n }\n case MovmoFrameMessageType.BOOKING_COMPLETE: {\n const { bookingId, airlineRef, providerId } = data;\n if (bookingId) {\n // Update the parent URL to reflect booking completion\n window.history.pushState(\n { checkoutOpen: true, bookingComplete: true, bookingId, providerId },\n '',\n `/movmo/checkout/booking/${bookingId}?airlineRef=${airlineRef || ''}&providerId=${providerId || ''}`,\n );\n } else {\n console.warn(\n '[movmo] BOOKING_COMPLETE received without a bookingId; leaving the overlay in place',\n );\n }\n break;\n }\n case MovmoFrameMessageType.BOOKING_FAILED: {\n // The iframe is handing control back to the airline page: a booking\n // failed non-retryably, or a dead-end screen's exit was clicked\n // (reason: 'offer_unavailable', MOVMO-474). Older flights-ui builds\n // send no reason — treat as 'search_again'.\n const reason: MovmoExitReason = data.reason ?? 'search_again';\n // Capture the callback before the async close: a reopen during the\n // pending history traversal must not swap callbacks mid-flight.\n const exit = overlayOnExit;\n closeOverlay(() => {\n if (!exit) return;\n try {\n exit({ reason });\n } catch (e) {\n console.error('[movmo] onExit callback threw', e);\n }\n });\n break;\n }\n default: {\n console.warn('[movmo] ignoring unexpected message type from a trusted origin:', data.type);\n }\n }\n}\n\nexport function showMovmoOverlay(\n queryParams: string,\n isProd: boolean = false,\n options?: MovmoCheckoutOverlayOptions,\n) {\n if (document.getElementById('movmo-checkout')) return;\n\n const container = document.createElement('div');\n container.id = 'movmo-checkout';\n container.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n `;\n\n // Use production or development URL based on isProd flag. REACT_APP_MOVMO_CHECKOUT_URL\n // overrides both (e.g. the offline demo points the overlay at http://localhost:3000);\n // defaults are unchanged when the env var is unset.\n const baseUrl =\n process.env.REACT_APP_MOVMO_CHECKOUT_URL ||\n (isProd ? 'https://flights.movmo.io' : 'https://flights.e2e.movmo.io');\n\n // Load index.html explicitly and use hash routing to avoid CloudFront error response issues\n // This ensures we load a file that actually exists in S3, then let React Router handle navigation\n let iframeUrl = `${baseUrl}/index.html#/booking?${queryParams}`;\n\n // If the URL indicates we're on a booking confirmation page, load that instead\n if (window.location.pathname.includes('/movmo/checkout/booking/')) {\n const bookingId = window.location.pathname.split('/').pop();\n const urlParams = new URLSearchParams(window.location.search);\n const airlineRef = urlParams.get('airlineRef') || '';\n const providerId = urlParams.get('providerId') || '';\n\n // Direct the iframe to the booking confirmation page using hash routing\n iframeUrl = `${baseUrl}/index.html#/booking/${bookingId}?airlineRef=${airlineRef}&providerId=${providerId}`;\n\n // Ensure we maintain the checkout state\n window.history.replaceState(\n { checkoutOpen: true, bookingComplete: true },\n '',\n window.location.href,\n );\n }\n\n // Create iframe element imperatively to prevent XSS (APP-XSS-001 fix)\n const iframe = document.createElement('iframe');\n iframe.src = iframeUrl;\n iframe.width = '100%';\n iframe.height = '100%';\n iframe.style.border = 'none';\n iframe.id = 'movmo-checkout-iframe';\n // Permit the embedded flights-ui document to call document.requestStorageAccess()\n // for cross-site Movmo recognition (MOVMO-427/429; the in-iframe request this\n // enables is MOVMO-428). WebKit rejects the request outright unless the\n // embedding iframe carries `allow=\"storage-access\"`.\n iframe.setAttribute('allow', 'storage-access');\n\n container.appendChild(iframe);\n\n document.body.appendChild(container);\n\n // Keep the (single, page-lifetime) message listener's environment current, then attach\n // it exactly once. See handleIframeMessage above for why it's not re-added per call.\n // overlayOnExit is set UNCONDITIONALLY on every successful open: the\n // DOMContentLoaded re-hydration path calls showMovmoOverlay with no options,\n // and this assignment resets any stale callback (a closure over a React\n // tree from before the refresh) rather than invoking dead code later.\n overlayIsProd = isProd;\n overlayOnExit = options?.onExit;\n if (!messageListenerAttached) {\n window.addEventListener('message', handleIframeMessage);\n messageListenerAttached = true;\n }\n}\n\n// Clean up when back button is used\nwindow.addEventListener('popstate', () => {\n const container = document.getElementById('movmo-checkout');\n if (!window.history.state?.checkoutOpen && container) {\n container.remove();\n }\n});\n\n/**\n * Determine if the current environment is production based on hostname\n * - Production: hostname contains neither 'e2e' nor 'localhost'\n * - Development/Testing: hostname contains 'e2e' or 'localhost'\n */\nfunction isProductionEnvironment(): boolean {\n const hostname = window.location.hostname;\n // Check if we're on production (neither e2e nor localhost)\n return !hostname.includes('e2e') && !hostname.includes('localhost');\n}\n\n// Handle page refresh or direct navigation to a booking confirmation URL\nif (typeof window !== 'undefined') {\n window.addEventListener('DOMContentLoaded', () => {\n const isBookingConfirmation = window.location.pathname.includes('/movmo/checkout/booking/');\n const isCheckoutPath = window.location.pathname.startsWith('/movmo/checkout');\n\n if (isBookingConfirmation || isCheckoutPath) {\n const queryParams = window.location.search.substring(1);\n const isProd = isProductionEnvironment();\n showMovmoOverlay(queryParams, isProd);\n }\n });\n}\n","import React, { useState } from 'react';\n\nimport { createAxiosClient, saveProviderOffer } from './api';\nimport { MovmoCheckoutExitInfo, showMovmoOverlay } from './MovmoCheckoutOverlay';\n\nexport interface MovmoCheckoutButtonProps {\n iataCode: string;\n apiKey: string;\n providerID: string;\n // TODO: support fare splitting\n flightOffer?: object;\n flightOfferID?: string;\n isProd?: boolean;\n className?: string;\n /**\n * Fires when the traveler exits the Movmo checkout from inside the overlay\n * (e.g. \"Return to airline\" on a dead-end screen, or a non-retryable\n * booking failure), after the overlay is removed and the page URL is\n * restored to where the checkout was opened. Use it to route the traveler\n * onward (e.g. back to your search results) or record analytics; without\n * it the traveler is simply returned to the page they clicked the button\n * on. Not invoked for browser-back closes, and it does not survive a page\n * refresh inside the checkout.\n */\n onExit?: (info: MovmoCheckoutExitInfo) => void;\n}\n\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\n iataCode,\n apiKey,\n providerID,\n flightOffer,\n flightOfferID,\n isProd = false,\n className,\n onExit,\n}) => {\n const [isHovered, setIsHovered] = useState(false);\n const client = createAxiosClient(apiKey, iataCode, isProd);\n\n const handleClick = async () => {\n let offerId = flightOfferID;\n\n // If no pre-saved offer ID, save the raw offer\n if (!offerId && flightOffer) {\n const savedOfferId = await saveProviderOffer(providerID, flightOffer, client);\n if (!savedOfferId) {\n // TODO: handle error by displaying a message to the user\n return;\n }\n offerId = savedOfferId;\n }\n\n if (!offerId) {\n // TODO: handle error - neither flightOfferID nor flightOffer provided\n console.error('Neither flightOfferID nor flightOffer provided');\n return;\n }\n\n const queryParams = new URLSearchParams({\n offerId,\n providerId: providerID,\n airlineRef: iataCode,\n }).toString();\n\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${queryParams}`);\n showMovmoOverlay(queryParams, isProd, { onExit });\n };\n\n const buttonClasses = `\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\n ${className ?? ''}\n `.trim();\n\n const badgeClasses = `\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n `.trim();\n\n return (\n <button\n onClick={handleClick}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n className={buttonClasses}\n >\n Express Checkout\n <span className={badgeClasses}>Movmo</span>\n </button>\n );\n};\n"],"names":["createAxiosClient","apiKey","airlineRef","isProd","baseUrl","proxyBaseUrl","process","env","REACT_APP_MOVMO_CHECKOUT_API_URL","client","axios","create","baseURL","headers","Accept","window","location","host","hostname","REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER","withCredentials","timeout","interceptors","request","use","config","Authorization","token","name","cookies","document","cookie","split","i","length","trim","startsWith","decodeURIComponent","substring","getCookie","overlayOnExit","messageListenerAttached","overlayIsProd","CLOSE_POLL_MS","CLOSE_POLL_MAX_ATTEMPTS","handleIframeMessage","event","extraOrigins","REACT_APP_MOVMO_CHECKOUT_URL","isTrustedOrigin","origin","MOVMO_FLIGHTS_ORIGINS","data","type","MovmoFrameMessageType","READY","initMessage","INIT","parentOrigin","source","postMessage","BOOKING_COMPLETE","bookingId","providerId","history","pushState","checkoutOpen","bookingComplete","BOOKING_FAILED","reason","exit","onClosed","getElementById","remove","state","settled","attempts","settle","removeEventListener","addEventListener","once","poll","setTimeout","back","closeOverlay","e","showMovmoOverlay","queryParams","options","container","createElement","id","style","cssText","iframeUrl","pathname","includes","pop","urlParams","URLSearchParams","search","get","replaceState","href","iframe","src","width","height","border","setAttribute","appendChild","body","onExit","isBookingConfirmation","isCheckoutPath","isProductionEnvironment","iataCode","providerID","flightOffer","flightOfferID","className","isHovered","setIsHovered","useState","buttonClasses","badgeClasses","_jsxs","onClick","async","offerId","savedOfferId","rawOffer","post","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AAOC,SAASoF,OAAO9D,UAAU,GAb3D,WACE,MAAMpB,EAAWH,OAAOC,SAASE,SAEjC,OAAQA,EAAS8E,SAAS,SAAW9E,EAAS8E,SAAS,YACzD,CAUqBmB,GAEjB,iCC3PmE,EACrEC,WACAnH,SACAoH,aACAC,cACAC,gBACApH,UAAS,EACTqH,YACAR,aAEA,MAAOS,EAAWC,GAAgBC,EAAAA,UAAS,GACrClH,EAAST,EAAkBC,EAAQmH,EAAUjH,GA+B7CyH,EAAgB,sRASdH,EAAY,oBAAsB,iCAClCD,GAAa,WACjBrF,OAEE0F,EAAe,mHAMjB1F,OAEJ,OACE2F,OAAA,SAAA,CACEC,QApDgBC,UAClB,IAAIC,EAAUV,EAGd,IAAKU,GAAWX,EAAa,CAC3B,MAAMY,OFcqBF,OAC/BX,EACAc,EACA1H,UAEaA,EACV2H,KAAK,yBAAyBf,WAAqBc,GACnDE,MAAMC,GAAQA,EAAIlF,KAAKmF,WACvBC,OAAOC,GAEC,OExBoBC,CAAkBrB,EAAYC,EAAa7G,GACtE,IAAKyH,EAEH,OAEFD,EAAUC,CACZ,CAEA,IAAKD,EAGH,OAGF,MAAM1C,EAAc,IAAIY,gBAAgB,CACtC8B,UACAlE,WAAYsD,EACZnH,WAAYkH,IACXuB,WAEH5H,OAAOiD,QAAQC,UAAU,CAAEC,cAAc,GAAQ,GAAI,mBAAmBqB,KACxED,EAAiBC,EAAapF,EAAQ,CAAE6G,UAAS,EA2B/C4B,aAAc,IAAMlB,GAAa,GACjCmB,aAAc,IAAMnB,GAAa,GACjCF,UAAWI,EAAakB,SAAA,CAAA,mBAGxBC,EAAAA,YAAMvB,UAAWK,EAAYiB,SAAA,YACtB"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/api.ts","../src/tracking.ts","../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\n\n// Helper function to read cookie value from document.cookie\nconst getCookie = (name: string): string | null => {\n const cookieString = document.cookie;\n const cookies = cookieString.split(';');\n for (let i = 0; i < cookies.length; i++) {\n const cookie = cookies[i].trim();\n if (cookie.startsWith(name + '=')) {\n // URL-decode the cookie value to match what backend expects\n return decodeURIComponent(cookie.substring(name.length + 1));\n }\n }\n return null;\n};\n\nconst isLocalHost = () =>\n typeof window !== 'undefined' &&\n (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');\n\nexport const createAxiosClient = (apiKey: string, airlineRef: string, isProd: boolean = false) => {\n const baseUrl = isProd ? 'https://flights.movmo.io' : 'https://flights.e2e.movmo.io';\n // REACT_APP_MOVMO_CHECKOUT_API_URL overrides the API base (e.g. the offline demo\n // talks directly to the local monolith-api at http://localhost:8080, bypassing the\n // CloudFront /v1/proxy hop). Defaults are unchanged when the env var is unset.\n const proxyBaseUrl =\n process.env.REACT_APP_MOVMO_CHECKOUT_API_URL || `${baseUrl}/v1/proxy`;\n\n const client = axios.create({\n baseURL: proxyBaseUrl,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n 'X-Forwarded-Host': typeof window !== 'undefined' ? window.location.host : '',\n 'movmo-customer-id': airlineRef,\n ...(isLocalHost() && process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER\n ? { 'X-Movmo-Proxy-Auth': process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER }\n : {}),\n },\n withCredentials: true,\n timeout: 30000,\n });\n\n client.interceptors.request.use((config) => {\n if (config.headers?.Authorization) {\n delete config.headers.Authorization;\n }\n const token = getCookie('movmo_csrf_token');\n if (token) {\n config.headers['X-CSRF-Token'] = token;\n }\n\n return config;\n });\n\n return client;\n};\n\nexport const saveProviderOffer = async (\n providerID: string,\n rawOffer: object,\n client: AxiosInstance,\n): Promise<string | null> => {\n return await client\n .post(`/v1/flights/providers/${providerID}/offers`, rawOffer)\n .then((res) => res.data.offer_id)\n .catch((err) => {\n console.error(err);\n return null;\n });\n};\n","import { EVENTS, Movmo } from '@movmo_app/analytics';\n\nexport { EVENTS };\n\n/**\n * Scoped-mode analytics for the partner page (MOVMO-464). Autocapture stays OFF —\n * we never observe the partner's DOM or inputs; listeners attach only to\n * Movmo-rendered elements. Analytics must never break checkout: every entry\n * point here is fail-open.\n */\nexport function initScopedTracker(iataCode: string, isProd: boolean): void {\n try {\n if (Movmo.isInitialized()) return;\n // Same override mechanism as REACT_APP_MOVMO_CHECKOUT_URL (inlined by the consumer's CRA build).\n const endpoint =\n process.env.REACT_APP_MOVMO_ANALYTICS_URL ||\n (isProd ? 'https://api.movmo.io/v1/t' : 'https://e2e.api.movmo.io/v1/t');\n Movmo.init({\n app: 'express-checkout-button',\n env: isProd ? 'prd' : 'e2e',\n partnerId: iataCode,\n endpoint,\n scoped: true,\n });\n Movmo.track(EVENTS.PLUGIN_LOADED);\n } catch {\n /* fail-open */\n }\n}\n\nexport function trackSafe(event: string, props: Record<string, unknown> = {}): void {\n try {\n Movmo.track(event, props);\n } catch {\n /* fail-open */\n }\n}\n\nexport function trackerSessionId(): string | null {\n try {\n return Movmo.getSessionId();\n } catch {\n return null;\n }\n}\n","import {\n MOVMO_FLIGHTS_ORIGINS,\n MovmoExitReason,\n MovmoFrameMessage,\n MovmoFrameMessageType,\n MovmoInitMessage,\n isTrustedOrigin,\n} from '@movmo_app/types';\n\nimport { EVENTS, trackSafe } from './tracking';\n\n/** Passed to the airline's onExit callback when the checkout hands control back. */\nexport interface MovmoCheckoutExitInfo {\n reason: MovmoExitReason;\n}\n\nexport interface MovmoCheckoutOverlayOptions {\n /**\n * Fires after an iframe-initiated exit (e.g. the traveler clicked\n * \"Return to airline\" on a dead-end screen) once the overlay is removed and\n * the page URL has been restored to where the checkout was opened. Use it to\n * route the traveler onward or record analytics. It does NOT fire when the\n * user closes the checkout with the browser back button (they are already\n * back where they were), and it cannot survive a page refresh — a\n * re-hydrated overlay falls back to the default close behavior.\n */\n onExit?: (info: MovmoCheckoutExitInfo) => void;\n}\n\n// A single message listener for the page lifetime, attached on the first overlay open and\n// never re-added. Re-adding per call would stack orphaned listeners every time the overlay\n// is torn down and reopened — each would reply to READY (duplicate INIT handshakes the\n// iframe can't disambiguate) and push duplicate history entries on BOOKING_COMPLETE.\nlet messageListenerAttached = false;\nlet overlayIsProd = false;\nlet overlayOnExit: MovmoCheckoutOverlayOptions['onExit'];\n\n// Pre-iframe funnel analytics (MOVMO-464). Module-level for the same reason as\n// overlayOnExit/overlayIsProd above — the overlay outlives React, so this state must\n// survive teardown/reopen outside any component lifecycle.\nlet overlayOpenedAt: number | null = null;\nlet iframeReadySeen = false;\n\n/**\n * Tear down the overlay and restore the page to where the checkout was opened.\n *\n * Order matters: the iframe is removed FIRST. Its navigations join the\n * parent's joint session history, so a history.back() issued while the iframe\n * is still attached could pop an iframe entry instead of the parent's — the\n * overlay would never close. Removing the browsing context prunes its entries,\n * making the subsequent back() deterministically land on the airline page the\n * user was on when they clicked the button (handleClick pushes\n * {checkoutOpen:true} synchronously before opening).\n *\n * history.back() is asynchronous, so onClosed is deferred until the traversal\n * settles (one-shot popstate, with a short timeout fallback) — an airline\n * callback that navigates would otherwise race the pending traversal. When\n * there is no checkoutOpen state to pop (direct navigation to a\n * /movmo/checkout URL), no back() is issued and onClosed fires immediately;\n * the airline's onExit is the remedy for the lingering URL in that case.\n */\n// Poll interval and cap for the popstate fallback below.\nconst CLOSE_POLL_MS = 50;\nconst CLOSE_POLL_MAX_ATTEMPTS = 20; // ~1s ceiling\n\n/**\n * Fires `overlay_abandoned_pre_iframe` at most once per open, only when the overlay is\n * torn down before flights-ui ever sent MOVMO_READY (a traveler who bounced before the\n * checkout even loaded). Once READY has been seen, teardown is unremarkable and this is\n * a no-op. Call from EVERY teardown path — closeOverlay and the popstate\n * container-removal listener both count as \"the overlay went away\".\n */\nfunction trackOverlayTeardown(): void {\n if (overlayOpenedAt !== null && !iframeReadySeen) {\n trackSafe(EVENTS.OVERLAY_ABANDONED_PRE_IFRAME, {\n ms_since_open: Date.now() - overlayOpenedAt,\n });\n }\n overlayOpenedAt = null; // fire at most once per open\n}\n\nfunction closeOverlay(onClosed?: () => void) {\n trackOverlayTeardown();\n document.getElementById('movmo-checkout')?.remove();\n\n if (!window.history.state?.checkoutOpen) {\n onClosed?.();\n return;\n }\n\n if (onClosed) {\n let settled = false;\n let attempts = 0;\n const settle = () => {\n if (settled) return;\n settled = true;\n window.removeEventListener('popstate', settle);\n onClosed();\n };\n // popstate = the back() traversal completed and the pre-checkout URL is\n // restored: notify immediately. This is the path real browsers take.\n window.addEventListener('popstate', settle, { once: true });\n // Fallback for environments where popstate never fires (jsdom mocks\n // history.back). Only settle once the checkoutOpen entry is actually gone,\n // so onExit never runs against a still-current /movmo/checkout URL — an\n // airline callback that navigates would otherwise be undone when the\n // pending back() finally lands. Bounded so a genuinely stuck traversal\n // can't hang the callback forever; if we exhaust the budget we settle\n // anyway and warn, since the URL guarantee can't be met.\n const poll = () => {\n if (settled) return;\n if (!window.history.state?.checkoutOpen) {\n settle();\n return;\n }\n if (attempts >= CLOSE_POLL_MAX_ATTEMPTS) {\n console.warn(\n '[movmo] overlay close: history did not settle; onExit may see an unrestored URL',\n );\n settle();\n return;\n }\n attempts += 1;\n setTimeout(poll, CLOSE_POLL_MS);\n };\n setTimeout(poll, CLOSE_POLL_MS);\n }\n window.history.back();\n}\n\nfunction handleIframeMessage(event: MessageEvent) {\n // Only ever trust messages from a Movmo flights-ui origin. REACT_APP_MOVMO_CHECKOUT_URL\n // widens the non-prod allowlist for the offline demo; prod keeps its hardcoded list.\n const extraOrigins = [process.env.REACT_APP_MOVMO_CHECKOUT_URL];\n if (\n !isTrustedOrigin(event.origin, MOVMO_FLIGHTS_ORIGINS, { isProd: overlayIsProd, extraOrigins })\n ) {\n return;\n }\n\n const data = event.data as MovmoFrameMessage | undefined;\n if (!data?.type) return;\n\n switch (data.type) {\n case MovmoFrameMessageType.READY: {\n // Fire the pre-iframe funnel's terminal \"success\" event exactly once per open,\n // before anything else — a duplicate READY (or a slow reopen) must not double-count.\n if (!iframeReadySeen) {\n iframeReadySeen = true;\n if (overlayOpenedAt !== null) {\n trackSafe(EVENTS.IFRAME_READY, { ms_since_open: Date.now() - overlayOpenedAt });\n }\n }\n // Handshake: reply with our origin so the iframe can target us directly on\n // subsequent messages instead of broadcasting to \"*\".\n const initMessage: MovmoInitMessage = {\n type: MovmoFrameMessageType.INIT,\n parentOrigin: window.location.origin,\n };\n (event.source as Window | null)?.postMessage(initMessage, event.origin);\n break;\n }\n case MovmoFrameMessageType.BOOKING_COMPLETE: {\n const { bookingId, airlineRef, providerId } = data;\n if (bookingId) {\n // Update the parent URL to reflect booking completion\n window.history.pushState(\n { checkoutOpen: true, bookingComplete: true, bookingId, providerId },\n '',\n `/movmo/checkout/booking/${bookingId}?airlineRef=${airlineRef || ''}&providerId=${providerId || ''}`,\n );\n } else {\n console.warn(\n '[movmo] BOOKING_COMPLETE received without a bookingId; leaving the overlay in place',\n );\n }\n break;\n }\n case MovmoFrameMessageType.BOOKING_FAILED: {\n // The iframe is handing control back to the airline page: a booking\n // failed non-retryably, or a dead-end screen's exit was clicked\n // (reason: 'offer_unavailable', MOVMO-474). Older flights-ui builds\n // send no reason — treat as 'search_again'.\n const reason: MovmoExitReason = data.reason ?? 'search_again';\n // Capture the callback before the async close: a reopen during the\n // pending history traversal must not swap callbacks mid-flight.\n const exit = overlayOnExit;\n closeOverlay(() => {\n if (!exit) return;\n try {\n exit({ reason });\n } catch (e) {\n console.error('[movmo] onExit callback threw', e);\n }\n });\n break;\n }\n default: {\n console.warn('[movmo] ignoring unexpected message type from a trusted origin:', data.type);\n }\n }\n}\n\nexport function showMovmoOverlay(\n queryParams: string,\n isProd: boolean = false,\n options?: MovmoCheckoutOverlayOptions,\n) {\n if (document.getElementById('movmo-checkout')) return;\n\n const container = document.createElement('div');\n container.id = 'movmo-checkout';\n container.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n `;\n\n // Use production or development URL based on isProd flag. REACT_APP_MOVMO_CHECKOUT_URL\n // overrides both (e.g. the offline demo points the overlay at http://localhost:3000);\n // defaults are unchanged when the env var is unset.\n const baseUrl =\n process.env.REACT_APP_MOVMO_CHECKOUT_URL ||\n (isProd ? 'https://flights.movmo.io' : 'https://flights.e2e.movmo.io');\n\n // Load index.html explicitly and use hash routing to avoid CloudFront error response issues\n // This ensures we load a file that actually exists in S3, then let React Router handle navigation\n let iframeUrl = `${baseUrl}/index.html#/booking?${queryParams}`;\n\n // If the URL indicates we're on a booking confirmation page, load that instead\n if (window.location.pathname.includes('/movmo/checkout/booking/')) {\n const bookingId = window.location.pathname.split('/').pop();\n const urlParams = new URLSearchParams(window.location.search);\n const airlineRef = urlParams.get('airlineRef') || '';\n const providerId = urlParams.get('providerId') || '';\n\n // Direct the iframe to the booking confirmation page using hash routing\n iframeUrl = `${baseUrl}/index.html#/booking/${bookingId}?airlineRef=${airlineRef}&providerId=${providerId}`;\n\n // Ensure we maintain the checkout state\n window.history.replaceState(\n { checkoutOpen: true, bookingComplete: true },\n '',\n window.location.href,\n );\n }\n\n // Create iframe element imperatively to prevent XSS (APP-XSS-001 fix)\n const iframe = document.createElement('iframe');\n iframe.src = iframeUrl;\n iframe.width = '100%';\n iframe.height = '100%';\n iframe.style.border = 'none';\n iframe.id = 'movmo-checkout-iframe';\n // Permit the embedded flights-ui document to call document.requestStorageAccess()\n // for cross-site Movmo recognition (MOVMO-427/429; the in-iframe request this\n // enables is MOVMO-428). WebKit rejects the request outright unless the\n // embedding iframe carries `allow=\"storage-access\"`.\n iframe.setAttribute('allow', 'storage-access');\n\n container.appendChild(iframe);\n\n document.body.appendChild(container);\n\n // Keep the (single, page-lifetime) message listener's environment current, then attach\n // it exactly once. See handleIframeMessage above for why it's not re-added per call.\n // overlayOnExit is set UNCONDITIONALLY on every successful open: the\n // DOMContentLoaded re-hydration path calls showMovmoOverlay with no options,\n // and this assignment resets any stale callback (a closure over a React\n // tree from before the refresh) rather than invoking dead code later.\n overlayIsProd = isProd;\n overlayOnExit = options?.onExit;\n overlayOpenedAt = Date.now();\n iframeReadySeen = false;\n if (!messageListenerAttached) {\n window.addEventListener('message', handleIframeMessage);\n messageListenerAttached = true;\n }\n}\n\n// Clean up when back button is used\nwindow.addEventListener('popstate', () => {\n const container = document.getElementById('movmo-checkout');\n if (!window.history.state?.checkoutOpen && container) {\n trackOverlayTeardown();\n container.remove();\n }\n});\n\n/**\n * Determine if the current environment is production based on hostname\n * - Production: hostname contains neither 'e2e' nor 'localhost'\n * - Development/Testing: hostname contains 'e2e' or 'localhost'\n */\nfunction isProductionEnvironment(): boolean {\n const hostname = window.location.hostname;\n // Check if we're on production (neither e2e nor localhost)\n return !hostname.includes('e2e') && !hostname.includes('localhost');\n}\n\n// Handle page refresh or direct navigation to a booking confirmation URL\nif (typeof window !== 'undefined') {\n window.addEventListener('DOMContentLoaded', () => {\n const isBookingConfirmation = window.location.pathname.includes('/movmo/checkout/booking/');\n const isCheckoutPath = window.location.pathname.startsWith('/movmo/checkout');\n\n if (isBookingConfirmation || isCheckoutPath) {\n const queryParams = window.location.search.substring(1);\n const isProd = isProductionEnvironment();\n showMovmoOverlay(queryParams, isProd);\n }\n });\n}\n","import React, { useEffect, useRef, useState } from 'react';\n\nimport { createAxiosClient, saveProviderOffer } from './api';\nimport { MovmoCheckoutExitInfo, showMovmoOverlay } from './MovmoCheckoutOverlay';\nimport { EVENTS, initScopedTracker, trackSafe, trackerSessionId } from './tracking';\n\nexport interface MovmoCheckoutButtonProps {\n iataCode: string;\n apiKey: string;\n providerID: string;\n // TODO: support fare splitting\n flightOffer?: object;\n flightOfferID?: string;\n isProd?: boolean;\n className?: string;\n /**\n * Fires when the traveler exits the Movmo checkout from inside the overlay\n * (e.g. \"Return to airline\" on a dead-end screen, or a non-retryable\n * booking failure), after the overlay is removed and the page URL is\n * restored to where the checkout was opened. Use it to route the traveler\n * onward (e.g. back to your search results) or record analytics; without\n * it the traveler is simply returned to the page they clicked the button\n * on. Not invoked for browser-back closes, and it does not survive a page\n * refresh inside the checkout.\n */\n onExit?: (info: MovmoCheckoutExitInfo) => void;\n}\n\nconst HOVER_DWELL_MIN_MS = 200;\n\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\n iataCode,\n apiKey,\n providerID,\n flightOffer,\n flightOfferID,\n isProd = false,\n className,\n onExit,\n}) => {\n const [isHovered, setIsHovered] = useState(false);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const hoverStartRef = useRef<number | null>(null);\n const client = createAxiosClient(apiKey, iataCode, isProd);\n\n useEffect(() => {\n initScopedTracker(iataCode, isProd);\n if (typeof IntersectionObserver === 'undefined' || !buttonRef.current) return;\n const observer = new IntersectionObserver(\n (entries) => {\n if (entries.some((e) => e.isIntersecting)) {\n trackSafe(EVENTS.BUTTON_VIEWED);\n observer.disconnect(); // impression fires once per mount\n }\n },\n { threshold: 0.5 },\n );\n observer.observe(buttonRef.current);\n return () => observer.disconnect();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n hoverStartRef.current = Date.now();\n };\n\n const handleMouseLeave = () => {\n setIsHovered(false);\n if (hoverStartRef.current !== null) {\n const dwell = Date.now() - hoverStartRef.current;\n hoverStartRef.current = null;\n if (dwell >= HOVER_DWELL_MIN_MS) trackSafe(EVENTS.BUTTON_HOVERED, { dwell_ms: dwell });\n }\n };\n\n const handleClick = async () => {\n // A click ends the \"hover consideration\" window. Without this, a user who clicks\n // without ever mousing away leaves hoverStartRef set from the original mouseenter;\n // a LATER mouseleave (e.g. after minutes on the checkout overlay) would then report a\n // wildly inflated dwell_ms instead of being ignored.\n hoverStartRef.current = null;\n trackSafe(EVENTS.BUTTON_CLICKED);\n let offerId = flightOfferID;\n\n // If no pre-saved offer ID, save the raw offer\n if (!offerId && flightOffer) {\n trackSafe(EVENTS.OFFER_SAVE_STARTED);\n const startedAt = Date.now();\n const savedOfferId = await saveProviderOffer(providerID, flightOffer, client);\n const latency = Date.now() - startedAt;\n if (!savedOfferId) {\n // Previously a silent return — a lost booking with zero trace (MOVMO-464).\n trackSafe(EVENTS.OFFER_SAVE_FAILED, { latency_ms: latency });\n return;\n }\n trackSafe(EVENTS.OFFER_SAVE_SUCCEEDED, { latency_ms: latency });\n offerId = savedOfferId;\n }\n\n if (!offerId) {\n // TODO: handle error - neither flightOfferID nor flightOffer provided\n console.error('Neither flightOfferID nor flightOffer provided');\n return;\n }\n\n const queryParams = new URLSearchParams({\n offerId,\n providerId: providerID,\n airlineRef: iataCode,\n });\n // Session stitching (MOVMO-464): the iframe-side SDK adopts this id so\n // button_viewed -> booking_confirmed joins as one session.\n const sid = trackerSessionId();\n if (sid) queryParams.set('mvs', sid);\n const qs = queryParams.toString();\n\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${qs}`);\n showMovmoOverlay(qs, isProd, { onExit });\n trackSafe(EVENTS.OVERLAY_OPENED);\n };\n\n const buttonClasses = `\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\n ${className ?? ''}\n `.trim();\n\n const badgeClasses = `\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n `.trim();\n\n return (\n <button\n ref={buttonRef}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n className={buttonClasses}\n >\n Express Checkout\n <span className={badgeClasses}>Movmo</span>\n </button>\n );\n};\n"],"names":["createAxiosClient","apiKey","airlineRef","isProd","baseUrl","proxyBaseUrl","process","env","REACT_APP_MOVMO_CHECKOUT_API_URL","client","axios","create","baseURL","headers","Accept","window","location","host","hostname","REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER","withCredentials","timeout","interceptors","request","use","config","Authorization","token","name","cookies","document","cookie","split","i","length","trim","startsWith","decodeURIComponent","substring","getCookie","trackSafe","event","props","Movmo","track","overlayOnExit","messageListenerAttached","overlayIsProd","overlayOpenedAt","iframeReadySeen","CLOSE_POLL_MS","CLOSE_POLL_MAX_ATTEMPTS","trackOverlayTeardown","EVENTS","OVERLAY_ABANDONED_PRE_IFRAME","ms_since_open","Date","now","handleIframeMessage","extraOrigins","REACT_APP_MOVMO_CHECKOUT_URL","isTrustedOrigin","origin","MOVMO_FLIGHTS_ORIGINS","data","type","MovmoFrameMessageType","READY","IFRAME_READY","initMessage","INIT","parentOrigin","source","postMessage","BOOKING_COMPLETE","bookingId","providerId","history","pushState","checkoutOpen","bookingComplete","BOOKING_FAILED","reason","exit","onClosed","getElementById","remove","state","settled","attempts","settle","removeEventListener","addEventListener","once","poll","setTimeout","back","closeOverlay","e","showMovmoOverlay","queryParams","options","container","createElement","id","style","cssText","iframeUrl","pathname","includes","pop","urlParams","URLSearchParams","search","get","replaceState","href","iframe","src","width","height","border","setAttribute","appendChild","body","onExit","isBookingConfirmation","isCheckoutPath","isProductionEnvironment","iataCode","providerID","flightOffer","flightOfferID","className","isHovered","setIsHovered","useState","buttonRef","useRef","hoverStartRef","useEffect","isInitialized","endpoint","REACT_APP_MOVMO_ANALYTICS_URL","init","app","partnerId","scoped","PLUGIN_LOADED","initScopedTracker","IntersectionObserver","current","observer","entries","some","isIntersecting","BUTTON_VIEWED","disconnect","threshold","observe","buttonClasses","badgeClasses","_jsxs","ref","onClick","async","BUTTON_CLICKED","offerId","OFFER_SAVE_STARTED","startedAt","savedOfferId","rawOffer","post","then","res","offer_id","catch","err","saveProviderOffer","latency","OFFER_SAVE_FAILED","latency_ms","OFFER_SAVE_SUCCEEDED","sid","getSessionId","trackerSessionId","set","qs","toString","OVERLAY_OPENED","onMouseEnter","onMouseLeave","dwell","BUTTON_HOVERED","dwell_ms","children","_jsx"],"mappings":";;;;;;sJAGA,MAiBaA,EAAoB,CAACC,EAAgBC,EAAo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,EAAQxI,KAAKC,MAAQkF,EAAcY,QACzCZ,EAAcY,QAAU,KACpByC,GA5CiB,KA4CYxJ,EAAUa,EAAAA,OAAO4I,eAAgB,CAAEC,SAAUF,GAChF,GA4EE3D,UAAW2B,EAAamC,SAAA,CAAA,mBAGxBC,EAAAA,IAAA,OAAA,CAAM/D,UAAW4B,EAAYkC,SAAA,YACtB"}
package/dist/index.css CHANGED
@@ -1,2 +1,2 @@
1
- @import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.fixed{position:fixed}.ml-2{margin-left:.5rem}.cursor-pointer{cursor:pointer}.rounded-md{border-radius:.375rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-none{border-style:none}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-gradient-hover{background-image:linear-gradient(90deg,#e02f59,#c41d7e)}.bg-gradient-normal{background-image:linear-gradient(90deg,#f63d68,#dd2590)}.px-2{padding-left:.5rem;padding-right:.5rem}.px-7{padding-left:1.75rem;padding-right:1.75rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.font-inter{font-family:Inter,sans-serif}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-semibold{font-weight:600}.text-\[\#171412\]{--tw-text-opacity:1;color:rgb(23 20 18/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.outline-none{outline:2px solid transparent;outline-offset:2px}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-200{transition-duration:.2s}.focus\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-\[\#F63D68\]:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(246 61 104/var(--tw-ring-opacity))}.focus\:ring-opacity-50:focus{--tw-ring-opacity:0.5}
1
+ @import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.fixed{position:fixed}.ml-2{margin-left:.5rem}.cursor-pointer{cursor:pointer}.rounded-md{border-radius:.375rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-none{border-style:none}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-gradient-hover{background-image:linear-gradient(90deg,#e02f59,#c41d7e)}.bg-gradient-normal{background-image:linear-gradient(90deg,#f63d68,#dd2590)}.px-2{padding-left:.5rem;padding-right:.5rem}.px-7{padding-left:1.75rem;padding-right:1.75rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.font-inter{font-family:Inter,sans-serif}.text-lg{font-size:1.125rem;line-height:1.75rem}.font-semibold{font-weight:600}.text-\[\#171412\]{--tw-text-opacity:1;color:rgb(23 20 18/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.outline-none{outline:2px solid transparent;outline-offset:2px}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-200{transition-duration:.2s}.focus\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-\[\#F63D68\]:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(246 61 104/var(--tw-ring-opacity))}.focus\:ring-opacity-50:focus{--tw-ring-opacity:0.5}
2
2
  /*# sourceMappingURL=index.css.map */
@@ -1 +1 @@
1
- {"version":3,"sources":["index.css"],"names":[],"mappings":"AACA,+FAA+F,CAiB/F,WAAA,UAAoB,CAApB,yBAAA,WAAA,eAAoB,CAAA,CAApB,yBAAA,WAAA,eAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CACpB,OAAA,cAAmB,CAAnB,MAAA,iBAAmB,CAAnB,gBAAA,cAAmB,CAAnB,YAAA,qBAAmB,CAAnB,YAAA,oBAAmB,CAAnB,QAAA,gBAAmB,CAAnB,aAAA,iBAAmB,CAAnB,UAAA,iBAAmB,CAAnB,sDAAmB,CAAnB,mBAAA,uDAAmB,CAAnB,oBAAA,uDAAmB,CAAnB,MAAA,kBAAmB,CAAnB,mBAAmB,CAAnB,MAAA,oBAAmB,CAAnB,qBAAmB,CAAnB,MAAA,qBAAA,CAAA,kBAAmB,CAAnB,MAAA,sBAAA,CAAA,mBAAmB,CAAnB,YAAA,4BAAmB,CAAnB,SAAA,kBAAmB,CAAnB,mBAAmB,CAAnB,eAAA,eAAmB,CAAnB,mBAAA,mBAAmB,CAAnB,0CAAmB,CAAnB,YAAA,mBAAmB,CAAnB,6CAAmB,CAAnB,cAAA,6BAAmB,CAAnB,kBAAmB,CAAnB,gBAAA,wBAAA,CAAA,uBAAmB,CAAnB,kDAAmB,CAAnB,cAAA,uBAAmB,CAnBnB,qBAAA,0GAoBA,CApBA,wGAoBA,CApBA,wFAoBA,CApBA,gCAAA,mBAoBA,CApBA,sDAoBA,CApBA,8BAAA,qBAoBA","file":"index.css","sourcesContent":["/* Import Inter font from Google Fonts */\n@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');\n\n/*\n * Intentionally NOT importing `@tailwind base` (Tailwind's preflight reset).\n *\n * Preflight is a global stylesheet that resets margins, line-heights, font\n * families, text colors, list styles, etc. on every element of the host\n * page. For a published component package that's a heavy hand — partners\n * importing this CSS to render a single button get their entire page styles\n * silently rewritten. Most visibly: inherited text color is reset, so plain\n * <pre>/<code> blocks on the host page render white-on-white.\n *\n * The button only depends on @tailwind components and @tailwind utilities.\n * The button uses `border-none` explicitly so it doesn't depend on\n * preflight's `border-style: solid` default (the one utility-side\n * dependency on preflight that would matter for our class set).\n */\n@tailwind components;\n@tailwind utilities;\n"]}
1
+ {"version":3,"sources":["index.css"],"names":[],"mappings":"AACA,+FAA+F,CAiB/F,WAAA,UAAoB,CAApB,yBAAA,WAAA,eAAoB,CAAA,CAApB,yBAAA,WAAA,eAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CAApB,0BAAA,WAAA,gBAAoB,CAAA,CACpB,OAAA,cAAmB,CAAnB,MAAA,iBAAmB,CAAnB,gBAAA,cAAmB,CAAnB,YAAA,qBAAmB,CAAnB,YAAA,oBAAmB,CAAnB,QAAA,gBAAmB,CAAnB,aAAA,iBAAmB,CAAnB,UAAA,iBAAmB,CAAnB,sDAAmB,CAAnB,mBAAA,uDAAmB,CAAnB,oBAAA,uDAAmB,CAAnB,MAAA,kBAAmB,CAAnB,mBAAmB,CAAnB,MAAA,oBAAmB,CAAnB,qBAAmB,CAAnB,MAAA,qBAAA,CAAA,kBAAmB,CAAnB,MAAA,sBAAA,CAAA,mBAAmB,CAAnB,YAAA,4BAAmB,CAAnB,SAAA,kBAAmB,CAAnB,mBAAmB,CAAnB,eAAA,eAAmB,CAAnB,mBAAA,mBAAmB,CAAnB,0CAAmB,CAAnB,YAAA,mBAAmB,CAAnB,6CAAmB,CAAnB,cAAA,6BAAmB,CAAnB,kBAAmB,CAAnB,QAAA,gLAAmB,CAAnB,gBAAA,wBAAA,CAAA,uBAAmB,CAAnB,kDAAmB,CAAnB,cAAA,uBAAmB,CAnBnB,qBAAA,0GAoBA,CApBA,wGAoBA,CApBA,wFAoBA,CApBA,gCAAA,mBAoBA,CApBA,sDAoBA,CApBA,8BAAA,qBAoBA","file":"index.css","sourcesContent":["/* Import Inter font from Google Fonts */\n@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');\n\n/*\n * Intentionally NOT importing `@tailwind base` (Tailwind's preflight reset).\n *\n * Preflight is a global stylesheet that resets margins, line-heights, font\n * families, text colors, list styles, etc. on every element of the host\n * page. For a published component package that's a heavy hand — partners\n * importing this CSS to render a single button get their entire page styles\n * silently rewritten. Most visibly: inherited text color is reset, so plain\n * <pre>/<code> blocks on the host page render white-on-white.\n *\n * The button only depends on @tailwind components and @tailwind utilities.\n * The button uses `border-none` explicitly so it doesn't depend on\n * preflight's `border-style: solid` default (the one utility-side\n * dependency on preflight that would matter for our class set).\n */\n@tailwind components;\n@tailwind utilities;\n"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @movmo/express-checkout-button v1.6.1
2
+ * @movmo/express-checkout-button v1.7.0
3
3
  * React component plugin for embedding Movmo Express Checkout on airline websites.
4
4
  * (c) 2026 Movmo
5
5
  * @license MIT
package/dist/index.es.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @movmo/express-checkout-button v1.6.1
2
+ * @movmo/express-checkout-button v1.7.0
3
3
  * React component plugin for embedding Movmo Express Checkout on airline websites.
4
4
  * (c) 2026 Movmo
5
5
  * @license MIT
6
6
  */
7
- import{jsxs as o,jsx as e}from"react/jsx-runtime";import{useState as t}from"react";import n from"axios";import{isTrustedOrigin as i,MOVMO_FLIGHTS_ORIGINS as r,MovmoFrameMessageType as s}from"@movmo_app/types";const c=(o,e,t=!1)=>{const i=t?"https://flights.movmo.io":"https://flights.e2e.movmo.io",r=process.env.REACT_APP_MOVMO_CHECKOUT_API_URL||`${i}/v1/proxy`,s=n.create({baseURL:r,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":o,"X-Forwarded-Host":"undefined"!=typeof window?window.location.host:"","movmo-customer-id":e,..."undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname||!process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER?{}:{"X-Movmo-Proxy-Auth":process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER}},withCredentials:!0,timeout:3e4});return s.interceptors.request.use((o=>{o.headers?.Authorization&&delete o.headers.Authorization;const e=(o=>{const e=document.cookie.split(";");for(let t=0;t<e.length;t++){const n=e[t].trim();if(n.startsWith(o+"="))return decodeURIComponent(n.substring(o.length+1))}return null})("movmo_csrf_token");return e&&(o.headers["X-CSRF-Token"]=e),o})),s};let a,d=!1,m=!1;const h=50,p=20;function l(o){const e=[process.env.REACT_APP_MOVMO_CHECKOUT_URL];if(!i(o.origin,r,{isProd:m,extraOrigins:e}))return;const t=o.data;if(t?.type)switch(t.type){case s.READY:{const e={type:s.INIT,parentOrigin:window.location.origin};o.source?.postMessage(e,o.origin);break}case s.BOOKING_COMPLETE:{const{bookingId:o,airlineRef:e,providerId:n}=t;o&&window.history.pushState({checkoutOpen:!0,bookingComplete:!0,bookingId:o,providerId:n},"",`/movmo/checkout/booking/${o}?airlineRef=${e||""}&providerId=${n||""}`);break}case s.BOOKING_FAILED:{const o=t.reason??"search_again",e=a;!function(o){if(document.getElementById("movmo-checkout")?.remove(),window.history.state?.checkoutOpen){if(o){let e=!1,t=0;const n=()=>{e||(e=!0,window.removeEventListener("popstate",n),o())};window.addEventListener("popstate",n,{once:!0});const i=()=>{e||(window.history.state?.checkoutOpen?t>=p?n():(t+=1,setTimeout(i,h)):n())};setTimeout(i,h)}window.history.back()}else o?.()}((()=>{if(e)try{e({reason:o})}catch(o){}}));break}}}function u(o,e=!1,t){if(document.getElementById("movmo-checkout"))return;const n=document.createElement("div");n.id="movmo-checkout",n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ";const i=process.env.REACT_APP_MOVMO_CHECKOUT_URL||(e?"https://flights.movmo.io":"https://flights.e2e.movmo.io");let r=`${i}/index.html#/booking?${o}`;if(window.location.pathname.includes("/movmo/checkout/booking/")){const o=window.location.pathname.split("/").pop(),e=new URLSearchParams(window.location.search);r=`${i}/index.html#/booking/${o}?airlineRef=${e.get("airlineRef")||""}&providerId=${e.get("providerId")||""}`,window.history.replaceState({checkoutOpen:!0,bookingComplete:!0},"",window.location.href)}const s=document.createElement("iframe");s.src=r,s.width="100%",s.height="100%",s.style.border="none",s.id="movmo-checkout-iframe",s.setAttribute("allow","storage-access"),n.appendChild(s),document.body.appendChild(n),m=e,a=t?.onExit,d||(window.addEventListener("message",l),d=!0)}window.addEventListener("popstate",(()=>{const o=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&o&&o.remove()})),"undefined"!=typeof window&&window.addEventListener("DOMContentLoaded",(()=>{const o=window.location.pathname.includes("/movmo/checkout/booking/"),e=window.location.pathname.startsWith("/movmo/checkout");if(o||e){u(window.location.search.substring(1),function(){const o=window.location.hostname;return!o.includes("e2e")&&!o.includes("localhost")}())}}));const w=({iataCode:n,apiKey:i,providerID:r,flightOffer:s,flightOfferID:a,isProd:d=!1,className:m,onExit:h})=>{const[p,l]=t(!1),w=c(i,n,d),f=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${p?"bg-gradient-hover":"bg-gradient-normal"}\n ${m??""}\n `.trim(),g="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return o("button",{onClick:async()=>{let o=a;if(!o&&s){const e=await(async(o,e,t)=>await t.post(`/v1/flights/providers/${o}/offers`,e).then((o=>o.data.offer_id)).catch((o=>null)))(r,s,w);if(!e)return;o=e}if(!o)return;const e=new URLSearchParams({offerId:o,providerId:r,airlineRef:n}).toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${e}`),u(e,d,{onExit:h})},onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:f,children:["Express Checkout",e("span",{className:g,children:"Movmo"})]})};export{w as MovmoCheckoutButton};
7
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as n,useEffect as i}from"react";import r from"axios";import{isTrustedOrigin as s,MOVMO_FLIGHTS_ORIGINS as c,MovmoFrameMessageType as a}from"@movmo_app/types";import{Movmo as d,EVENTS as l}from"@movmo_app/analytics";const m=(e,t,o=!1)=>{const n=o?"https://flights.movmo.io":"https://flights.e2e.movmo.io",i=process.env.REACT_APP_MOVMO_CHECKOUT_API_URL||`${n}/v1/proxy`,s=r.create({baseURL:i,headers:{Accept:"application/json","Content-Type":"application/json","x-api-key":e,"X-Forwarded-Host":"undefined"!=typeof window?window.location.host:"","movmo-customer-id":t,..."undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname||!process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER?{}:{"X-Movmo-Proxy-Auth":process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER}},withCredentials:!0,timeout:3e4});return s.interceptors.request.use((e=>{e.headers?.Authorization&&delete e.headers.Authorization;const t=(e=>{const t=document.cookie.split(";");for(let o=0;o<t.length;o++){const n=t[o].trim();if(n.startsWith(e+"="))return decodeURIComponent(n.substring(e.length+1))}return null})("movmo_csrf_token");return t&&(e.headers["X-CSRF-Token"]=t),e})),s};function u(e,t={}){try{d.track(e,t)}catch{}}let p,h=!1,w=!1,f=null,E=!1;const v=50,_=20;function g(){null===f||E||u(l.OVERLAY_ABANDONED_PRE_IFRAME,{ms_since_open:Date.now()-f}),f=null}function O(e){const t=[process.env.REACT_APP_MOVMO_CHECKOUT_URL];if(!s(e.origin,c,{isProd:w,extraOrigins:t}))return;const o=e.data;if(o?.type)switch(o.type){case a.READY:{E||(E=!0,null!==f&&u(l.IFRAME_READY,{ms_since_open:Date.now()-f}));const t={type:a.INIT,parentOrigin:window.location.origin};e.source?.postMessage(t,e.origin);break}case a.BOOKING_COMPLETE:{const{bookingId:e,airlineRef:t,providerId:n}=o;e&&window.history.pushState({checkoutOpen:!0,bookingComplete:!0,bookingId:e,providerId:n},"",`/movmo/checkout/booking/${e}?airlineRef=${t||""}&providerId=${n||""}`);break}case a.BOOKING_FAILED:{const e=o.reason??"search_again",t=p;!function(e){if(g(),document.getElementById("movmo-checkout")?.remove(),window.history.state?.checkoutOpen){if(e){let t=!1,o=0;const n=()=>{t||(t=!0,window.removeEventListener("popstate",n),e())};window.addEventListener("popstate",n,{once:!0});const i=()=>{t||(window.history.state?.checkoutOpen?o>=_?n():(o+=1,setTimeout(i,v)):n())};setTimeout(i,v)}window.history.back()}else e?.()}((()=>{if(t)try{t({reason:e})}catch(e){}}));break}}}function R(e,t=!1,o){if(document.getElementById("movmo-checkout"))return;const n=document.createElement("div");n.id="movmo-checkout",n.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n ";const i=process.env.REACT_APP_MOVMO_CHECKOUT_URL||(t?"https://flights.movmo.io":"https://flights.e2e.movmo.io");let r=`${i}/index.html#/booking?${e}`;if(window.location.pathname.includes("/movmo/checkout/booking/")){const e=window.location.pathname.split("/").pop(),t=new URLSearchParams(window.location.search);r=`${i}/index.html#/booking/${e}?airlineRef=${t.get("airlineRef")||""}&providerId=${t.get("providerId")||""}`,window.history.replaceState({checkoutOpen:!0,bookingComplete:!0},"",window.location.href)}const s=document.createElement("iframe");s.src=r,s.width="100%",s.height="100%",s.style.border="none",s.id="movmo-checkout-iframe",s.setAttribute("allow","storage-access"),n.appendChild(s),document.body.appendChild(n),w=t,p=o?.onExit,f=Date.now(),E=!1,h||(window.addEventListener("message",O),h=!0)}window.addEventListener("popstate",(()=>{const e=document.getElementById("movmo-checkout");!window.history.state?.checkoutOpen&&e&&(g(),e.remove())})),"undefined"!=typeof window&&window.addEventListener("DOMContentLoaded",(()=>{const e=window.location.pathname.includes("/movmo/checkout/booking/"),t=window.location.pathname.startsWith("/movmo/checkout");if(e||t){R(window.location.search.substring(1),function(){const e=window.location.hostname;return!e.includes("e2e")&&!e.includes("localhost")}())}}));const k=({iataCode:r,apiKey:s,providerID:c,flightOffer:a,flightOfferID:p,isProd:h=!1,className:w,onExit:f})=>{const[E,v]=o(!1),_=n(null),g=n(null),O=m(s,r,h);i((()=>{if(function(e,t){try{if(d.isInitialized())return;const o=process.env.REACT_APP_MOVMO_ANALYTICS_URL||(t?"https://api.movmo.io/v1/t":"https://e2e.api.movmo.io/v1/t");d.init({app:"express-checkout-button",env:t?"prd":"e2e",partnerId:e,endpoint:o,scoped:!0}),d.track(l.PLUGIN_LOADED)}catch{}}(r,h),"undefined"==typeof IntersectionObserver||!_.current)return;const e=new IntersectionObserver((t=>{t.some((e=>e.isIntersecting))&&(u(l.BUTTON_VIEWED),e.disconnect())}),{threshold:.5});return e.observe(_.current),()=>e.disconnect()}),[]);const k=`\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${E?"bg-gradient-hover":"bg-gradient-normal"}\n ${w??""}\n `.trim(),y="\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n ".trim();return e("button",{ref:_,onClick:async()=>{g.current=null,u(l.BUTTON_CLICKED);let e=p;if(!e&&a){u(l.OFFER_SAVE_STARTED);const t=Date.now(),o=await(async(e,t,o)=>await o.post(`/v1/flights/providers/${e}/offers`,t).then((e=>e.data.offer_id)).catch((e=>null)))(c,a,O),n=Date.now()-t;if(!o)return void u(l.OFFER_SAVE_FAILED,{latency_ms:n});u(l.OFFER_SAVE_SUCCEEDED,{latency_ms:n}),e=o}if(!e)return;const t=new URLSearchParams({offerId:e,providerId:c,airlineRef:r}),o=function(){try{return d.getSessionId()}catch{return null}}();o&&t.set("mvs",o);const n=t.toString();window.history.pushState({checkoutOpen:!0},"",`/movmo/checkout?${n}`),R(n,h,{onExit:f}),u(l.OVERLAY_OPENED)},onMouseEnter:()=>{v(!0),g.current=Date.now()},onMouseLeave:()=>{if(v(!1),null!==g.current){const e=Date.now()-g.current;g.current=null,e>=200&&u(l.BUTTON_HOVERED,{dwell_ms:e})}},className:k,children:["Express Checkout",t("span",{className:y,children:"Movmo"})]})};export{k as MovmoCheckoutButton};
8
8
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/api.ts","../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\n\n// Helper function to read cookie value from document.cookie\nconst getCookie = (name: string): string | null => {\n const cookieString = document.cookie;\n const cookies = cookieString.split(';');\n for (let i = 0; i < cookies.length; i++) {\n const cookie = cookies[i].trim();\n if (cookie.startsWith(name + '=')) {\n // URL-decode the cookie value to match what backend expects\n return decodeURIComponent(cookie.substring(name.length + 1));\n }\n }\n return null;\n};\n\nconst isLocalHost = () =>\n typeof window !== 'undefined' &&\n (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');\n\nexport const createAxiosClient = (apiKey: string, airlineRef: string, isProd: boolean = false) => {\n const baseUrl = isProd ? 'https://flights.movmo.io' : 'https://flights.e2e.movmo.io';\n // REACT_APP_MOVMO_CHECKOUT_API_URL overrides the API base (e.g. the offline demo\n // talks directly to the local monolith-api at http://localhost:8080, bypassing the\n // CloudFront /v1/proxy hop). Defaults are unchanged when the env var is unset.\n const proxyBaseUrl =\n process.env.REACT_APP_MOVMO_CHECKOUT_API_URL || `${baseUrl}/v1/proxy`;\n\n const client = axios.create({\n baseURL: proxyBaseUrl,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n 'X-Forwarded-Host': typeof window !== 'undefined' ? window.location.host : '',\n 'movmo-customer-id': airlineRef,\n ...(isLocalHost() && process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER\n ? { 'X-Movmo-Proxy-Auth': process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER }\n : {}),\n },\n withCredentials: true,\n timeout: 30000,\n });\n\n client.interceptors.request.use((config) => {\n if (config.headers?.Authorization) {\n delete config.headers.Authorization;\n }\n const token = getCookie('movmo_csrf_token');\n if (token) {\n config.headers['X-CSRF-Token'] = token;\n }\n\n return config;\n });\n\n return client;\n};\n\nexport const saveProviderOffer = async (\n providerID: string,\n rawOffer: object,\n client: AxiosInstance,\n): Promise<string | null> => {\n return await client\n .post(`/v1/flights/providers/${providerID}/offers`, rawOffer)\n .then((res) => res.data.offer_id)\n .catch((err) => {\n console.error(err);\n return null;\n });\n};\n","import {\n MOVMO_FLIGHTS_ORIGINS,\n MovmoExitReason,\n MovmoFrameMessage,\n MovmoFrameMessageType,\n MovmoInitMessage,\n isTrustedOrigin,\n} from '@movmo_app/types';\n\n/** Passed to the airline's onExit callback when the checkout hands control back. */\nexport interface MovmoCheckoutExitInfo {\n reason: MovmoExitReason;\n}\n\nexport interface MovmoCheckoutOverlayOptions {\n /**\n * Fires after an iframe-initiated exit (e.g. the traveler clicked\n * \"Return to airline\" on a dead-end screen) once the overlay is removed and\n * the page URL has been restored to where the checkout was opened. Use it to\n * route the traveler onward or record analytics. It does NOT fire when the\n * user closes the checkout with the browser back button (they are already\n * back where they were), and it cannot survive a page refresh — a\n * re-hydrated overlay falls back to the default close behavior.\n */\n onExit?: (info: MovmoCheckoutExitInfo) => void;\n}\n\n// A single message listener for the page lifetime, attached on the first overlay open and\n// never re-added. Re-adding per call would stack orphaned listeners every time the overlay\n// is torn down and reopened — each would reply to READY (duplicate INIT handshakes the\n// iframe can't disambiguate) and push duplicate history entries on BOOKING_COMPLETE.\nlet messageListenerAttached = false;\nlet overlayIsProd = false;\nlet overlayOnExit: MovmoCheckoutOverlayOptions['onExit'];\n\n/**\n * Tear down the overlay and restore the page to where the checkout was opened.\n *\n * Order matters: the iframe is removed FIRST. Its navigations join the\n * parent's joint session history, so a history.back() issued while the iframe\n * is still attached could pop an iframe entry instead of the parent's — the\n * overlay would never close. Removing the browsing context prunes its entries,\n * making the subsequent back() deterministically land on the airline page the\n * user was on when they clicked the button (handleClick pushes\n * {checkoutOpen:true} synchronously before opening).\n *\n * history.back() is asynchronous, so onClosed is deferred until the traversal\n * settles (one-shot popstate, with a short timeout fallback) — an airline\n * callback that navigates would otherwise race the pending traversal. When\n * there is no checkoutOpen state to pop (direct navigation to a\n * /movmo/checkout URL), no back() is issued and onClosed fires immediately;\n * the airline's onExit is the remedy for the lingering URL in that case.\n */\n// Poll interval and cap for the popstate fallback below.\nconst CLOSE_POLL_MS = 50;\nconst CLOSE_POLL_MAX_ATTEMPTS = 20; // ~1s ceiling\n\nfunction closeOverlay(onClosed?: () => void) {\n document.getElementById('movmo-checkout')?.remove();\n\n if (!window.history.state?.checkoutOpen) {\n onClosed?.();\n return;\n }\n\n if (onClosed) {\n let settled = false;\n let attempts = 0;\n const settle = () => {\n if (settled) return;\n settled = true;\n window.removeEventListener('popstate', settle);\n onClosed();\n };\n // popstate = the back() traversal completed and the pre-checkout URL is\n // restored: notify immediately. This is the path real browsers take.\n window.addEventListener('popstate', settle, { once: true });\n // Fallback for environments where popstate never fires (jsdom mocks\n // history.back). Only settle once the checkoutOpen entry is actually gone,\n // so onExit never runs against a still-current /movmo/checkout URL — an\n // airline callback that navigates would otherwise be undone when the\n // pending back() finally lands. Bounded so a genuinely stuck traversal\n // can't hang the callback forever; if we exhaust the budget we settle\n // anyway and warn, since the URL guarantee can't be met.\n const poll = () => {\n if (settled) return;\n if (!window.history.state?.checkoutOpen) {\n settle();\n return;\n }\n if (attempts >= CLOSE_POLL_MAX_ATTEMPTS) {\n console.warn(\n '[movmo] overlay close: history did not settle; onExit may see an unrestored URL',\n );\n settle();\n return;\n }\n attempts += 1;\n setTimeout(poll, CLOSE_POLL_MS);\n };\n setTimeout(poll, CLOSE_POLL_MS);\n }\n window.history.back();\n}\n\nfunction handleIframeMessage(event: MessageEvent) {\n // Only ever trust messages from a Movmo flights-ui origin. REACT_APP_MOVMO_CHECKOUT_URL\n // widens the non-prod allowlist for the offline demo; prod keeps its hardcoded list.\n const extraOrigins = [process.env.REACT_APP_MOVMO_CHECKOUT_URL];\n if (\n !isTrustedOrigin(event.origin, MOVMO_FLIGHTS_ORIGINS, { isProd: overlayIsProd, extraOrigins })\n ) {\n return;\n }\n\n const data = event.data as MovmoFrameMessage | undefined;\n if (!data?.type) return;\n\n switch (data.type) {\n case MovmoFrameMessageType.READY: {\n // Handshake: reply with our origin so the iframe can target us directly on\n // subsequent messages instead of broadcasting to \"*\".\n const initMessage: MovmoInitMessage = {\n type: MovmoFrameMessageType.INIT,\n parentOrigin: window.location.origin,\n };\n (event.source as Window | null)?.postMessage(initMessage, event.origin);\n break;\n }\n case MovmoFrameMessageType.BOOKING_COMPLETE: {\n const { bookingId, airlineRef, providerId } = data;\n if (bookingId) {\n // Update the parent URL to reflect booking completion\n window.history.pushState(\n { checkoutOpen: true, bookingComplete: true, bookingId, providerId },\n '',\n `/movmo/checkout/booking/${bookingId}?airlineRef=${airlineRef || ''}&providerId=${providerId || ''}`,\n );\n } else {\n console.warn(\n '[movmo] BOOKING_COMPLETE received without a bookingId; leaving the overlay in place',\n );\n }\n break;\n }\n case MovmoFrameMessageType.BOOKING_FAILED: {\n // The iframe is handing control back to the airline page: a booking\n // failed non-retryably, or a dead-end screen's exit was clicked\n // (reason: 'offer_unavailable', MOVMO-474). Older flights-ui builds\n // send no reason — treat as 'search_again'.\n const reason: MovmoExitReason = data.reason ?? 'search_again';\n // Capture the callback before the async close: a reopen during the\n // pending history traversal must not swap callbacks mid-flight.\n const exit = overlayOnExit;\n closeOverlay(() => {\n if (!exit) return;\n try {\n exit({ reason });\n } catch (e) {\n console.error('[movmo] onExit callback threw', e);\n }\n });\n break;\n }\n default: {\n console.warn('[movmo] ignoring unexpected message type from a trusted origin:', data.type);\n }\n }\n}\n\nexport function showMovmoOverlay(\n queryParams: string,\n isProd: boolean = false,\n options?: MovmoCheckoutOverlayOptions,\n) {\n if (document.getElementById('movmo-checkout')) return;\n\n const container = document.createElement('div');\n container.id = 'movmo-checkout';\n container.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n `;\n\n // Use production or development URL based on isProd flag. REACT_APP_MOVMO_CHECKOUT_URL\n // overrides both (e.g. the offline demo points the overlay at http://localhost:3000);\n // defaults are unchanged when the env var is unset.\n const baseUrl =\n process.env.REACT_APP_MOVMO_CHECKOUT_URL ||\n (isProd ? 'https://flights.movmo.io' : 'https://flights.e2e.movmo.io');\n\n // Load index.html explicitly and use hash routing to avoid CloudFront error response issues\n // This ensures we load a file that actually exists in S3, then let React Router handle navigation\n let iframeUrl = `${baseUrl}/index.html#/booking?${queryParams}`;\n\n // If the URL indicates we're on a booking confirmation page, load that instead\n if (window.location.pathname.includes('/movmo/checkout/booking/')) {\n const bookingId = window.location.pathname.split('/').pop();\n const urlParams = new URLSearchParams(window.location.search);\n const airlineRef = urlParams.get('airlineRef') || '';\n const providerId = urlParams.get('providerId') || '';\n\n // Direct the iframe to the booking confirmation page using hash routing\n iframeUrl = `${baseUrl}/index.html#/booking/${bookingId}?airlineRef=${airlineRef}&providerId=${providerId}`;\n\n // Ensure we maintain the checkout state\n window.history.replaceState(\n { checkoutOpen: true, bookingComplete: true },\n '',\n window.location.href,\n );\n }\n\n // Create iframe element imperatively to prevent XSS (APP-XSS-001 fix)\n const iframe = document.createElement('iframe');\n iframe.src = iframeUrl;\n iframe.width = '100%';\n iframe.height = '100%';\n iframe.style.border = 'none';\n iframe.id = 'movmo-checkout-iframe';\n // Permit the embedded flights-ui document to call document.requestStorageAccess()\n // for cross-site Movmo recognition (MOVMO-427/429; the in-iframe request this\n // enables is MOVMO-428). WebKit rejects the request outright unless the\n // embedding iframe carries `allow=\"storage-access\"`.\n iframe.setAttribute('allow', 'storage-access');\n\n container.appendChild(iframe);\n\n document.body.appendChild(container);\n\n // Keep the (single, page-lifetime) message listener's environment current, then attach\n // it exactly once. See handleIframeMessage above for why it's not re-added per call.\n // overlayOnExit is set UNCONDITIONALLY on every successful open: the\n // DOMContentLoaded re-hydration path calls showMovmoOverlay with no options,\n // and this assignment resets any stale callback (a closure over a React\n // tree from before the refresh) rather than invoking dead code later.\n overlayIsProd = isProd;\n overlayOnExit = options?.onExit;\n if (!messageListenerAttached) {\n window.addEventListener('message', handleIframeMessage);\n messageListenerAttached = true;\n }\n}\n\n// Clean up when back button is used\nwindow.addEventListener('popstate', () => {\n const container = document.getElementById('movmo-checkout');\n if (!window.history.state?.checkoutOpen && container) {\n container.remove();\n }\n});\n\n/**\n * Determine if the current environment is production based on hostname\n * - Production: hostname contains neither 'e2e' nor 'localhost'\n * - Development/Testing: hostname contains 'e2e' or 'localhost'\n */\nfunction isProductionEnvironment(): boolean {\n const hostname = window.location.hostname;\n // Check if we're on production (neither e2e nor localhost)\n return !hostname.includes('e2e') && !hostname.includes('localhost');\n}\n\n// Handle page refresh or direct navigation to a booking confirmation URL\nif (typeof window !== 'undefined') {\n window.addEventListener('DOMContentLoaded', () => {\n const isBookingConfirmation = window.location.pathname.includes('/movmo/checkout/booking/');\n const isCheckoutPath = window.location.pathname.startsWith('/movmo/checkout');\n\n if (isBookingConfirmation || isCheckoutPath) {\n const queryParams = window.location.search.substring(1);\n const isProd = isProductionEnvironment();\n showMovmoOverlay(queryParams, isProd);\n }\n });\n}\n","import React, { useState } from 'react';\n\nimport { createAxiosClient, saveProviderOffer } from './api';\nimport { MovmoCheckoutExitInfo, showMovmoOverlay } from './MovmoCheckoutOverlay';\n\nexport interface MovmoCheckoutButtonProps {\n iataCode: string;\n apiKey: string;\n providerID: string;\n // TODO: support fare splitting\n flightOffer?: object;\n flightOfferID?: string;\n isProd?: boolean;\n className?: string;\n /**\n * Fires when the traveler exits the Movmo checkout from inside the overlay\n * (e.g. \"Return to airline\" on a dead-end screen, or a non-retryable\n * booking failure), after the overlay is removed and the page URL is\n * restored to where the checkout was opened. Use it to route the traveler\n * onward (e.g. back to your search results) or record analytics; without\n * it the traveler is simply returned to the page they clicked the button\n * on. Not invoked for browser-back closes, and it does not survive a page\n * refresh inside the checkout.\n */\n onExit?: (info: MovmoCheckoutExitInfo) => void;\n}\n\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\n iataCode,\n apiKey,\n providerID,\n flightOffer,\n flightOfferID,\n isProd = false,\n className,\n onExit,\n}) => {\n const [isHovered, setIsHovered] = useState(false);\n const client = createAxiosClient(apiKey, iataCode, isProd);\n\n const handleClick = async () => {\n let offerId = flightOfferID;\n\n // If no pre-saved offer ID, save the raw offer\n if (!offerId && flightOffer) {\n const savedOfferId = await saveProviderOffer(providerID, flightOffer, client);\n if (!savedOfferId) {\n // TODO: handle error by displaying a message to the user\n return;\n }\n offerId = savedOfferId;\n }\n\n if (!offerId) {\n // TODO: handle error - neither flightOfferID nor flightOffer provided\n console.error('Neither flightOfferID nor flightOffer provided');\n return;\n }\n\n const queryParams = new URLSearchParams({\n offerId,\n providerId: providerID,\n airlineRef: iataCode,\n }).toString();\n\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${queryParams}`);\n showMovmoOverlay(queryParams, isProd, { onExit });\n };\n\n const buttonClasses = `\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\n ${className ?? ''}\n `.trim();\n\n const badgeClasses = `\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n `.trim();\n\n return (\n <button\n onClick={handleClick}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n className={buttonClasses}\n >\n Express Checkout\n <span className={badgeClasses}>Movmo</span>\n </button>\n );\n};\n"],"names":["createAxiosClient","apiKey","airlineRef","isProd","baseUrl","proxyBaseUrl","process","env","REACT_APP_MOVMO_CHECKOUT_API_URL","client","axios","create","baseURL","headers","Accept","window","location","host","hostname","REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER","withCredentials","timeout","interceptors","request","use","config","Authorization","token","name","cookies","document","cookie","split","i","length","trim","startsWith","decodeURIComponent","substring","getCookie","overlayOnExit","messageListenerAttached","overlayIsProd","CLOSE_POLL_MS","CLOSE_POLL_MAX_ATTEMPTS","handleIframeMessage","event","extraOrigins","REACT_APP_MOVMO_CHECKOUT_URL","isTrustedOrigin","origin","MOVMO_FLIGHTS_ORIGINS","data","type","MovmoFrameMessageType","READY","initMessage","INIT","parentOrigin","source","postMessage","BOOKING_COMPLETE","bookingId","providerId","history","pushState","checkoutOpen","bookingComplete","BOOKING_FAILED","reason","exit","onClosed","getElementById","remove","state","settled","attempts","settle","removeEventListener","addEventListener","once","poll","setTimeout","back","closeOverlay","e","showMovmoOverlay","queryParams","options","container","createElement","id","style","cssText","iframeUrl","pathname","includes","pop","urlParams","URLSearchParams","search","get","replaceState","href","iframe","src","width","height","border","setAttribute","appendChild","body","onExit","isBookingConfirmation","isCheckoutPath","isProductionEnvironment","MovmoCheckoutButton","iataCode","providerID","flightOffer","flightOfferID","className","isHovered","setIsHovered","useState","buttonClasses","badgeClasses","_jsxs","onClick","async","offerId","savedOfferId","rawOffer","post","then","res","offer_id","catch","err","saveProviderOffer","toString","onMouseEnter","onMouseLeave","children","_jsx"],"mappings":";;;;;;iNAGA,MAiBaA,EAAoB,CAACC,EAAgBC,EAAoBC,GAAkB,KACtF,MAAMC,EAAUD,EAAS,2BAA6B,+BAIhDE,EACJC,QAAQC,IAAIC,kCAAoC,GAAGJ,aAE/CK,EAASC,EAAMC,OAAO,CAC1BC,QAASP,EACTQ,QAAS,CACPC,OAAQ,mBACR,eAAgB,mBAChB,YAAab,EACb,mBAAsC,oBAAXc,OAAyBA,OAAOC,SAASC,KAAO,GAC3E,oBAAqBf,KAlBP,oBAAXa,QACuB,cAA7BA,OAAOC,SAASE,UAAyD,cAA7BH,OAAOC,SAASE,WAkBpCZ,QAAQC,IAAIY,0CAE7B,GADA,CAAE,qBAAsBb,QAAQC,IAAIY,4CAG1CC,iBAAiB,EACjBC,QAAS,MAeX,OAZAZ,EAAOa,aAAaC,QAAQC,KAAKC,IAC3BA,EAAOZ,SAASa,sBACXD,EAAOZ,QAAQa,cAExB,MAAMC,EA7CQ,CAACC,IACjB,MACMC,EADeC,SAASC,OACDC,MAAM,KACnC,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAQK,OAAQD,IAAK,CACvC,MAAMF,EAASF,EAAQI,GAAGE,OAC1B,GAAIJ,EAAOK,WAAWR,EAAO,KAE3B,OAAOS,mBAAmBN,EAAOO,UAAUV,EAAKM,OAAS,GAE7D,CACA,OAAO,IAAI,EAmCKK,CAAU,oBAKxB,OAJIZ,IACFF,EAAOZ,QAAQ,gBAAkBc,GAG5BF,CAAM,IAGRhB,CAAM,ECzBf,IAEI+B,EAFAC,GAA0B,EAC1BC,GAAgB,EAsBpB,MAAMC,EAAgB,GAChBC,EAA0B,GAkDhC,SAASC,EAAoBC,GAG3B,MAAMC,EAAe,CAACzC,QAAQ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AE3D,GAAI6E,GAAyBC,EAAgB,CAG3C5B,EAFoBvE,OAAOC,SAASoF,OAAO9D,UAAU,GAb3D,WACE,MAAMpB,EAAWH,OAAOC,SAASE,SAEjC,OAAQA,EAAS8E,SAAS,SAAW9E,EAAS8E,SAAS,YACzD,CAUqBmB,GAEjB,KC3PG,MAAMC,EAA0D,EACrEC,WACApH,SACAqH,aACAC,cACAC,gBACArH,UAAS,EACTsH,YACAT,aAEA,MAAOU,EAAWC,GAAgBC,GAAS,GACrCnH,EAAST,EAAkBC,EAAQoH,EAAUlH,GA+B7C0H,EAAgB,sRASdH,EAAY,oBAAsB,iCAClCD,GAAa,WACjBtF,OAEE2F,EAAe,mHAMjB3F,OAEJ,OACE4F,EAAA,SAAA,CACEC,QApDgBC,UAClB,IAAIC,EAAUV,EAGd,IAAKU,GAAWX,EAAa,CAC3B,MAAMY,OFcqBF,OAC/BX,EACAc,EACA3H,UAEaA,EACV4H,KAAK,yBAAyBf,WAAqBc,GACnDE,MAAMC,GAAQA,EAAInF,KAAKoF,WACvBC,OAAOC,GAEC,OExBoBC,CAAkBrB,EAAYC,EAAa9G,GACtE,IAAK0H,EAEH,OAEFD,EAAUC,CACZ,CAEA,IAAKD,EAGH,OAGF,MAAM3C,EAAc,IAAIY,gBAAgB,CACtC+B,UACAnE,WAAYuD,EACZpH,WAAYmH,IACXuB,WAEH7H,OAAOiD,QAAQC,UAAU,CAAEC,cAAc,GAAQ,GAAI,mBAAmBqB,KACxED,EAAiBC,EAAapF,EAAQ,CAAE6G,UAAS,EA2B/C6B,aAAc,IAAMlB,GAAa,GACjCmB,aAAc,IAAMnB,GAAa,GACjCF,UAAWI,EAAakB,SAAA,CAAA,mBAGxBC,UAAMvB,UAAWK,EAAYiB,SAAA,YACtB"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/api.ts","../src/tracking.ts","../src/MovmoCheckoutOverlay.tsx","../src/MovmoCheckoutButton.tsx"],"sourcesContent":["import axios, { AxiosInstance } from 'axios';\n\n// Helper function to read cookie value from document.cookie\nconst getCookie = (name: string): string | null => {\n const cookieString = document.cookie;\n const cookies = cookieString.split(';');\n for (let i = 0; i < cookies.length; i++) {\n const cookie = cookies[i].trim();\n if (cookie.startsWith(name + '=')) {\n // URL-decode the cookie value to match what backend expects\n return decodeURIComponent(cookie.substring(name.length + 1));\n }\n }\n return null;\n};\n\nconst isLocalHost = () =>\n typeof window !== 'undefined' &&\n (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');\n\nexport const createAxiosClient = (apiKey: string, airlineRef: string, isProd: boolean = false) => {\n const baseUrl = isProd ? 'https://flights.movmo.io' : 'https://flights.e2e.movmo.io';\n // REACT_APP_MOVMO_CHECKOUT_API_URL overrides the API base (e.g. the offline demo\n // talks directly to the local monolith-api at http://localhost:8080, bypassing the\n // CloudFront /v1/proxy hop). Defaults are unchanged when the env var is unset.\n const proxyBaseUrl =\n process.env.REACT_APP_MOVMO_CHECKOUT_API_URL || `${baseUrl}/v1/proxy`;\n\n const client = axios.create({\n baseURL: proxyBaseUrl,\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n 'x-api-key': apiKey,\n 'X-Forwarded-Host': typeof window !== 'undefined' ? window.location.host : '',\n 'movmo-customer-id': airlineRef,\n ...(isLocalHost() && process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER\n ? { 'X-Movmo-Proxy-Auth': process.env.REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER }\n : {}),\n },\n withCredentials: true,\n timeout: 30000,\n });\n\n client.interceptors.request.use((config) => {\n if (config.headers?.Authorization) {\n delete config.headers.Authorization;\n }\n const token = getCookie('movmo_csrf_token');\n if (token) {\n config.headers['X-CSRF-Token'] = token;\n }\n\n return config;\n });\n\n return client;\n};\n\nexport const saveProviderOffer = async (\n providerID: string,\n rawOffer: object,\n client: AxiosInstance,\n): Promise<string | null> => {\n return await client\n .post(`/v1/flights/providers/${providerID}/offers`, rawOffer)\n .then((res) => res.data.offer_id)\n .catch((err) => {\n console.error(err);\n return null;\n });\n};\n","import { EVENTS, Movmo } from '@movmo_app/analytics';\n\nexport { EVENTS };\n\n/**\n * Scoped-mode analytics for the partner page (MOVMO-464). Autocapture stays OFF —\n * we never observe the partner's DOM or inputs; listeners attach only to\n * Movmo-rendered elements. Analytics must never break checkout: every entry\n * point here is fail-open.\n */\nexport function initScopedTracker(iataCode: string, isProd: boolean): void {\n try {\n if (Movmo.isInitialized()) return;\n // Same override mechanism as REACT_APP_MOVMO_CHECKOUT_URL (inlined by the consumer's CRA build).\n const endpoint =\n process.env.REACT_APP_MOVMO_ANALYTICS_URL ||\n (isProd ? 'https://api.movmo.io/v1/t' : 'https://e2e.api.movmo.io/v1/t');\n Movmo.init({\n app: 'express-checkout-button',\n env: isProd ? 'prd' : 'e2e',\n partnerId: iataCode,\n endpoint,\n scoped: true,\n });\n Movmo.track(EVENTS.PLUGIN_LOADED);\n } catch {\n /* fail-open */\n }\n}\n\nexport function trackSafe(event: string, props: Record<string, unknown> = {}): void {\n try {\n Movmo.track(event, props);\n } catch {\n /* fail-open */\n }\n}\n\nexport function trackerSessionId(): string | null {\n try {\n return Movmo.getSessionId();\n } catch {\n return null;\n }\n}\n","import {\n MOVMO_FLIGHTS_ORIGINS,\n MovmoExitReason,\n MovmoFrameMessage,\n MovmoFrameMessageType,\n MovmoInitMessage,\n isTrustedOrigin,\n} from '@movmo_app/types';\n\nimport { EVENTS, trackSafe } from './tracking';\n\n/** Passed to the airline's onExit callback when the checkout hands control back. */\nexport interface MovmoCheckoutExitInfo {\n reason: MovmoExitReason;\n}\n\nexport interface MovmoCheckoutOverlayOptions {\n /**\n * Fires after an iframe-initiated exit (e.g. the traveler clicked\n * \"Return to airline\" on a dead-end screen) once the overlay is removed and\n * the page URL has been restored to where the checkout was opened. Use it to\n * route the traveler onward or record analytics. It does NOT fire when the\n * user closes the checkout with the browser back button (they are already\n * back where they were), and it cannot survive a page refresh — a\n * re-hydrated overlay falls back to the default close behavior.\n */\n onExit?: (info: MovmoCheckoutExitInfo) => void;\n}\n\n// A single message listener for the page lifetime, attached on the first overlay open and\n// never re-added. Re-adding per call would stack orphaned listeners every time the overlay\n// is torn down and reopened — each would reply to READY (duplicate INIT handshakes the\n// iframe can't disambiguate) and push duplicate history entries on BOOKING_COMPLETE.\nlet messageListenerAttached = false;\nlet overlayIsProd = false;\nlet overlayOnExit: MovmoCheckoutOverlayOptions['onExit'];\n\n// Pre-iframe funnel analytics (MOVMO-464). Module-level for the same reason as\n// overlayOnExit/overlayIsProd above — the overlay outlives React, so this state must\n// survive teardown/reopen outside any component lifecycle.\nlet overlayOpenedAt: number | null = null;\nlet iframeReadySeen = false;\n\n/**\n * Tear down the overlay and restore the page to where the checkout was opened.\n *\n * Order matters: the iframe is removed FIRST. Its navigations join the\n * parent's joint session history, so a history.back() issued while the iframe\n * is still attached could pop an iframe entry instead of the parent's — the\n * overlay would never close. Removing the browsing context prunes its entries,\n * making the subsequent back() deterministically land on the airline page the\n * user was on when they clicked the button (handleClick pushes\n * {checkoutOpen:true} synchronously before opening).\n *\n * history.back() is asynchronous, so onClosed is deferred until the traversal\n * settles (one-shot popstate, with a short timeout fallback) — an airline\n * callback that navigates would otherwise race the pending traversal. When\n * there is no checkoutOpen state to pop (direct navigation to a\n * /movmo/checkout URL), no back() is issued and onClosed fires immediately;\n * the airline's onExit is the remedy for the lingering URL in that case.\n */\n// Poll interval and cap for the popstate fallback below.\nconst CLOSE_POLL_MS = 50;\nconst CLOSE_POLL_MAX_ATTEMPTS = 20; // ~1s ceiling\n\n/**\n * Fires `overlay_abandoned_pre_iframe` at most once per open, only when the overlay is\n * torn down before flights-ui ever sent MOVMO_READY (a traveler who bounced before the\n * checkout even loaded). Once READY has been seen, teardown is unremarkable and this is\n * a no-op. Call from EVERY teardown path — closeOverlay and the popstate\n * container-removal listener both count as \"the overlay went away\".\n */\nfunction trackOverlayTeardown(): void {\n if (overlayOpenedAt !== null && !iframeReadySeen) {\n trackSafe(EVENTS.OVERLAY_ABANDONED_PRE_IFRAME, {\n ms_since_open: Date.now() - overlayOpenedAt,\n });\n }\n overlayOpenedAt = null; // fire at most once per open\n}\n\nfunction closeOverlay(onClosed?: () => void) {\n trackOverlayTeardown();\n document.getElementById('movmo-checkout')?.remove();\n\n if (!window.history.state?.checkoutOpen) {\n onClosed?.();\n return;\n }\n\n if (onClosed) {\n let settled = false;\n let attempts = 0;\n const settle = () => {\n if (settled) return;\n settled = true;\n window.removeEventListener('popstate', settle);\n onClosed();\n };\n // popstate = the back() traversal completed and the pre-checkout URL is\n // restored: notify immediately. This is the path real browsers take.\n window.addEventListener('popstate', settle, { once: true });\n // Fallback for environments where popstate never fires (jsdom mocks\n // history.back). Only settle once the checkoutOpen entry is actually gone,\n // so onExit never runs against a still-current /movmo/checkout URL — an\n // airline callback that navigates would otherwise be undone when the\n // pending back() finally lands. Bounded so a genuinely stuck traversal\n // can't hang the callback forever; if we exhaust the budget we settle\n // anyway and warn, since the URL guarantee can't be met.\n const poll = () => {\n if (settled) return;\n if (!window.history.state?.checkoutOpen) {\n settle();\n return;\n }\n if (attempts >= CLOSE_POLL_MAX_ATTEMPTS) {\n console.warn(\n '[movmo] overlay close: history did not settle; onExit may see an unrestored URL',\n );\n settle();\n return;\n }\n attempts += 1;\n setTimeout(poll, CLOSE_POLL_MS);\n };\n setTimeout(poll, CLOSE_POLL_MS);\n }\n window.history.back();\n}\n\nfunction handleIframeMessage(event: MessageEvent) {\n // Only ever trust messages from a Movmo flights-ui origin. REACT_APP_MOVMO_CHECKOUT_URL\n // widens the non-prod allowlist for the offline demo; prod keeps its hardcoded list.\n const extraOrigins = [process.env.REACT_APP_MOVMO_CHECKOUT_URL];\n if (\n !isTrustedOrigin(event.origin, MOVMO_FLIGHTS_ORIGINS, { isProd: overlayIsProd, extraOrigins })\n ) {\n return;\n }\n\n const data = event.data as MovmoFrameMessage | undefined;\n if (!data?.type) return;\n\n switch (data.type) {\n case MovmoFrameMessageType.READY: {\n // Fire the pre-iframe funnel's terminal \"success\" event exactly once per open,\n // before anything else — a duplicate READY (or a slow reopen) must not double-count.\n if (!iframeReadySeen) {\n iframeReadySeen = true;\n if (overlayOpenedAt !== null) {\n trackSafe(EVENTS.IFRAME_READY, { ms_since_open: Date.now() - overlayOpenedAt });\n }\n }\n // Handshake: reply with our origin so the iframe can target us directly on\n // subsequent messages instead of broadcasting to \"*\".\n const initMessage: MovmoInitMessage = {\n type: MovmoFrameMessageType.INIT,\n parentOrigin: window.location.origin,\n };\n (event.source as Window | null)?.postMessage(initMessage, event.origin);\n break;\n }\n case MovmoFrameMessageType.BOOKING_COMPLETE: {\n const { bookingId, airlineRef, providerId } = data;\n if (bookingId) {\n // Update the parent URL to reflect booking completion\n window.history.pushState(\n { checkoutOpen: true, bookingComplete: true, bookingId, providerId },\n '',\n `/movmo/checkout/booking/${bookingId}?airlineRef=${airlineRef || ''}&providerId=${providerId || ''}`,\n );\n } else {\n console.warn(\n '[movmo] BOOKING_COMPLETE received without a bookingId; leaving the overlay in place',\n );\n }\n break;\n }\n case MovmoFrameMessageType.BOOKING_FAILED: {\n // The iframe is handing control back to the airline page: a booking\n // failed non-retryably, or a dead-end screen's exit was clicked\n // (reason: 'offer_unavailable', MOVMO-474). Older flights-ui builds\n // send no reason — treat as 'search_again'.\n const reason: MovmoExitReason = data.reason ?? 'search_again';\n // Capture the callback before the async close: a reopen during the\n // pending history traversal must not swap callbacks mid-flight.\n const exit = overlayOnExit;\n closeOverlay(() => {\n if (!exit) return;\n try {\n exit({ reason });\n } catch (e) {\n console.error('[movmo] onExit callback threw', e);\n }\n });\n break;\n }\n default: {\n console.warn('[movmo] ignoring unexpected message type from a trusted origin:', data.type);\n }\n }\n}\n\nexport function showMovmoOverlay(\n queryParams: string,\n isProd: boolean = false,\n options?: MovmoCheckoutOverlayOptions,\n) {\n if (document.getElementById('movmo-checkout')) return;\n\n const container = document.createElement('div');\n container.id = 'movmo-checkout';\n container.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: white;\n z-index: 9999;\n `;\n\n // Use production or development URL based on isProd flag. REACT_APP_MOVMO_CHECKOUT_URL\n // overrides both (e.g. the offline demo points the overlay at http://localhost:3000);\n // defaults are unchanged when the env var is unset.\n const baseUrl =\n process.env.REACT_APP_MOVMO_CHECKOUT_URL ||\n (isProd ? 'https://flights.movmo.io' : 'https://flights.e2e.movmo.io');\n\n // Load index.html explicitly and use hash routing to avoid CloudFront error response issues\n // This ensures we load a file that actually exists in S3, then let React Router handle navigation\n let iframeUrl = `${baseUrl}/index.html#/booking?${queryParams}`;\n\n // If the URL indicates we're on a booking confirmation page, load that instead\n if (window.location.pathname.includes('/movmo/checkout/booking/')) {\n const bookingId = window.location.pathname.split('/').pop();\n const urlParams = new URLSearchParams(window.location.search);\n const airlineRef = urlParams.get('airlineRef') || '';\n const providerId = urlParams.get('providerId') || '';\n\n // Direct the iframe to the booking confirmation page using hash routing\n iframeUrl = `${baseUrl}/index.html#/booking/${bookingId}?airlineRef=${airlineRef}&providerId=${providerId}`;\n\n // Ensure we maintain the checkout state\n window.history.replaceState(\n { checkoutOpen: true, bookingComplete: true },\n '',\n window.location.href,\n );\n }\n\n // Create iframe element imperatively to prevent XSS (APP-XSS-001 fix)\n const iframe = document.createElement('iframe');\n iframe.src = iframeUrl;\n iframe.width = '100%';\n iframe.height = '100%';\n iframe.style.border = 'none';\n iframe.id = 'movmo-checkout-iframe';\n // Permit the embedded flights-ui document to call document.requestStorageAccess()\n // for cross-site Movmo recognition (MOVMO-427/429; the in-iframe request this\n // enables is MOVMO-428). WebKit rejects the request outright unless the\n // embedding iframe carries `allow=\"storage-access\"`.\n iframe.setAttribute('allow', 'storage-access');\n\n container.appendChild(iframe);\n\n document.body.appendChild(container);\n\n // Keep the (single, page-lifetime) message listener's environment current, then attach\n // it exactly once. See handleIframeMessage above for why it's not re-added per call.\n // overlayOnExit is set UNCONDITIONALLY on every successful open: the\n // DOMContentLoaded re-hydration path calls showMovmoOverlay with no options,\n // and this assignment resets any stale callback (a closure over a React\n // tree from before the refresh) rather than invoking dead code later.\n overlayIsProd = isProd;\n overlayOnExit = options?.onExit;\n overlayOpenedAt = Date.now();\n iframeReadySeen = false;\n if (!messageListenerAttached) {\n window.addEventListener('message', handleIframeMessage);\n messageListenerAttached = true;\n }\n}\n\n// Clean up when back button is used\nwindow.addEventListener('popstate', () => {\n const container = document.getElementById('movmo-checkout');\n if (!window.history.state?.checkoutOpen && container) {\n trackOverlayTeardown();\n container.remove();\n }\n});\n\n/**\n * Determine if the current environment is production based on hostname\n * - Production: hostname contains neither 'e2e' nor 'localhost'\n * - Development/Testing: hostname contains 'e2e' or 'localhost'\n */\nfunction isProductionEnvironment(): boolean {\n const hostname = window.location.hostname;\n // Check if we're on production (neither e2e nor localhost)\n return !hostname.includes('e2e') && !hostname.includes('localhost');\n}\n\n// Handle page refresh or direct navigation to a booking confirmation URL\nif (typeof window !== 'undefined') {\n window.addEventListener('DOMContentLoaded', () => {\n const isBookingConfirmation = window.location.pathname.includes('/movmo/checkout/booking/');\n const isCheckoutPath = window.location.pathname.startsWith('/movmo/checkout');\n\n if (isBookingConfirmation || isCheckoutPath) {\n const queryParams = window.location.search.substring(1);\n const isProd = isProductionEnvironment();\n showMovmoOverlay(queryParams, isProd);\n }\n });\n}\n","import React, { useEffect, useRef, useState } from 'react';\n\nimport { createAxiosClient, saveProviderOffer } from './api';\nimport { MovmoCheckoutExitInfo, showMovmoOverlay } from './MovmoCheckoutOverlay';\nimport { EVENTS, initScopedTracker, trackSafe, trackerSessionId } from './tracking';\n\nexport interface MovmoCheckoutButtonProps {\n iataCode: string;\n apiKey: string;\n providerID: string;\n // TODO: support fare splitting\n flightOffer?: object;\n flightOfferID?: string;\n isProd?: boolean;\n className?: string;\n /**\n * Fires when the traveler exits the Movmo checkout from inside the overlay\n * (e.g. \"Return to airline\" on a dead-end screen, or a non-retryable\n * booking failure), after the overlay is removed and the page URL is\n * restored to where the checkout was opened. Use it to route the traveler\n * onward (e.g. back to your search results) or record analytics; without\n * it the traveler is simply returned to the page they clicked the button\n * on. Not invoked for browser-back closes, and it does not survive a page\n * refresh inside the checkout.\n */\n onExit?: (info: MovmoCheckoutExitInfo) => void;\n}\n\nconst HOVER_DWELL_MIN_MS = 200;\n\nexport const MovmoCheckoutButton: React.FC<MovmoCheckoutButtonProps> = ({\n iataCode,\n apiKey,\n providerID,\n flightOffer,\n flightOfferID,\n isProd = false,\n className,\n onExit,\n}) => {\n const [isHovered, setIsHovered] = useState(false);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const hoverStartRef = useRef<number | null>(null);\n const client = createAxiosClient(apiKey, iataCode, isProd);\n\n useEffect(() => {\n initScopedTracker(iataCode, isProd);\n if (typeof IntersectionObserver === 'undefined' || !buttonRef.current) return;\n const observer = new IntersectionObserver(\n (entries) => {\n if (entries.some((e) => e.isIntersecting)) {\n trackSafe(EVENTS.BUTTON_VIEWED);\n observer.disconnect(); // impression fires once per mount\n }\n },\n { threshold: 0.5 },\n );\n observer.observe(buttonRef.current);\n return () => observer.disconnect();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n hoverStartRef.current = Date.now();\n };\n\n const handleMouseLeave = () => {\n setIsHovered(false);\n if (hoverStartRef.current !== null) {\n const dwell = Date.now() - hoverStartRef.current;\n hoverStartRef.current = null;\n if (dwell >= HOVER_DWELL_MIN_MS) trackSafe(EVENTS.BUTTON_HOVERED, { dwell_ms: dwell });\n }\n };\n\n const handleClick = async () => {\n // A click ends the \"hover consideration\" window. Without this, a user who clicks\n // without ever mousing away leaves hoverStartRef set from the original mouseenter;\n // a LATER mouseleave (e.g. after minutes on the checkout overlay) would then report a\n // wildly inflated dwell_ms instead of being ignored.\n hoverStartRef.current = null;\n trackSafe(EVENTS.BUTTON_CLICKED);\n let offerId = flightOfferID;\n\n // If no pre-saved offer ID, save the raw offer\n if (!offerId && flightOffer) {\n trackSafe(EVENTS.OFFER_SAVE_STARTED);\n const startedAt = Date.now();\n const savedOfferId = await saveProviderOffer(providerID, flightOffer, client);\n const latency = Date.now() - startedAt;\n if (!savedOfferId) {\n // Previously a silent return — a lost booking with zero trace (MOVMO-464).\n trackSafe(EVENTS.OFFER_SAVE_FAILED, { latency_ms: latency });\n return;\n }\n trackSafe(EVENTS.OFFER_SAVE_SUCCEEDED, { latency_ms: latency });\n offerId = savedOfferId;\n }\n\n if (!offerId) {\n // TODO: handle error - neither flightOfferID nor flightOffer provided\n console.error('Neither flightOfferID nor flightOffer provided');\n return;\n }\n\n const queryParams = new URLSearchParams({\n offerId,\n providerId: providerID,\n airlineRef: iataCode,\n });\n // Session stitching (MOVMO-464): the iframe-side SDK adopts this id so\n // button_viewed -> booking_confirmed joins as one session.\n const sid = trackerSessionId();\n if (sid) queryParams.set('mvs', sid);\n const qs = queryParams.toString();\n\n window.history.pushState({ checkoutOpen: true }, '', `/movmo/checkout?${qs}`);\n showMovmoOverlay(qs, isProd, { onExit });\n trackSafe(EVENTS.OVERLAY_OPENED);\n };\n\n const buttonClasses = `\n px-7 py-5 \n font-inter font-semibold text-lg \n rounded-xl \n text-white \n border-none\n cursor-pointer\n transition-all duration-200\n outline-none focus:ring-2 focus:ring-[#F63D68] focus:ring-opacity-50\n ${isHovered ? 'bg-gradient-hover' : 'bg-gradient-normal'}\n ${className ?? ''}\n `.trim();\n\n const badgeClasses = `\n ml-2 px-2 py-1\n bg-white \n text-[#171412] \n rounded-md \n text-lg\n `.trim();\n\n return (\n <button\n ref={buttonRef}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n className={buttonClasses}\n >\n Express Checkout\n <span className={badgeClasses}>Movmo</span>\n </button>\n );\n};\n"],"names":["createAxiosClient","apiKey","airlineRef","isProd","baseUrl","proxyBaseUrl","process","env","REACT_APP_MOVMO_CHECKOUT_API_URL","client","axios","create","baseURL","headers","Accept","window","location","host","hostname","REACT_APP_CLOUD_FRONT_PROXY_SECRET_HEADER","withCredentials","timeout","interceptors","request","use","config","Authorization","token","name","cookies","document","cookie","split","i","length","trim","startsWith","decodeURIComponent","substring","getCookie","trackSafe","event","props","Movmo","track","overlayOnExit","messageListenerAttached","overlayIsProd","overlayOpenedAt","iframeReadySeen","CLOSE_POLL_MS","CLOSE_POLL_MAX_ATTEMPTS","trackOverlayTeardown","EVENTS","OVERLAY_ABANDONED_PRE_IFRAME","ms_since_open","Date","now","handleIframeMessage","extraOrigins","REACT_APP_MOVMO_CHECKOUT_URL","isTrustedOrigin","origin","MOVMO_FLIGHTS_ORIGINS","data","type","MovmoFrameMessageType","READY","IFRAME_READY","initMessage","INIT","parentOrigin","source","postMessage","BOOKING_COMPLETE","bookingId","providerId","history","pushState","checkoutOpen","bookingComplete","BOOKING_FAILED","reason","exit","onClosed","getElementById","remove","state","settled","attempts","settle","removeEventListener","addEventListener","once","poll","setTimeout","back","closeOverlay","e","showMovmoOverlay","queryParams","options","container","createElement","id","style","cssText","iframeUrl","pathname","includes","pop","urlParams","URLSearchParams","search","get","replaceState","href","iframe","src","width","height","border","setAttribute","appendChild","body","onExit","isBookingConfirmation","isCheckoutPath","isProductionEnvironment","MovmoCheckoutButton","iataCode","providerID","flightOffer","flightOfferID","className","isHovered","setIsHovered","useState","buttonRef","useRef","hoverStartRef","useEffect","isInitialized","endpoint","REACT_APP_MOVMO_ANALYTICS_URL","init","app","partnerId","scoped","PLUGIN_LOADED","initScopedTracker","IntersectionObserver","current","observer","entries","some","isIntersecting","BUTTON_VIEWED","disconnect","threshold","observe","buttonClasses","badgeClasses","_jsxs","ref","onClick","async","BUTTON_CLICKED","offerId","OFFER_SAVE_STARTED","startedAt","savedOfferId","rawOffer","post","then","res","offer_id","catch","err","saveProviderOffer","latency","OFFER_SAVE_FAILED","latency_ms","OFFER_SAVE_SUCCEEDED","sid","getSessionId","trackerSessionId","set","qs","toString","OVERLAY_OPENED","onMouseEnter","onMouseLeave","dwell","BUTTON_HOVERED","dwell_ms","children","_js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I,eAAgB,CAAEC,SAAUF,GAChF,GA4EE3D,UAAW2B,EAAamC,SAAA,CAAA,mBAGxBC,EAAA,OAAA,CAAM/D,UAAW4B,EAAYkC,SAAA,YACtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movmo/express-checkout-button",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "React component plugin for embedding Movmo Express Checkout on airline websites.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
@@ -30,6 +30,7 @@
30
30
  "iframe"
31
31
  ],
32
32
  "dependencies": {
33
+ "@movmo_app/analytics": "^0.2.0",
33
34
  "@movmo_app/types": "^1.12.0",
34
35
  "axios": "^1.13.5"
35
36
  },
@@ -49,6 +50,7 @@
49
50
  "@storybook/react": "^8.6.17",
50
51
  "@storybook/react-vite": "^8.6.17",
51
52
  "@storybook/test": "^8.6.17",
53
+ "@testing-library/react": "^16.1.0",
52
54
  "@types/node": "^22.15.3",
53
55
  "@types/react": "^17.0.0 || ^18.0.0",
54
56
  "@types/react-dom": "^17.0.0 || ^18.0.0",