@bigcommerce/checkout-sdk 1.193.0 → 1.196.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/CHANGELOG.md +28 -0
- package/dist/checkout-button.js +1 -1
- package/dist/checkout-button.js.map +1 -1
- package/dist/checkout-button.umd.js +6 -6
- package/dist/checkout-button.umd.js.map +1 -1
- package/dist/checkout-sdk.d.ts +1 -0
- package/dist/checkout-sdk.js +1 -1
- package/dist/checkout-sdk.js.map +1 -1
- package/dist/checkout-sdk.umd.js +8 -8
- package/dist/checkout-sdk.umd.js.map +1 -1
- package/dist/embedded-checkout.js +1 -1
- package/dist/embedded-checkout.js.map +1 -1
- package/dist/embedded-checkout.umd.js +6 -6
- package/dist/embedded-checkout.umd.js.map +1 -1
- package/dist/hosted-form.js +1 -1
- package/dist/hosted-form.js.map +1 -1
- package/dist/hosted-form.umd.js +3 -3
- package/dist/hosted-form.umd.js.map +1 -1
- package/dist/internal-mappers.js +1 -1
- package/dist/internal-mappers.js.map +1 -1
- package/dist/internal-mappers.umd.js +2 -2
- package/dist/internal-mappers.umd.js.map +1 -1
- package/docs/interfaces/paymentmethodconfig.md +7 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=205)}({0:function(t,e){t.exports=require("tslib")},100:function(t,e,n){"use strict";var r=n(0);function o(t,e,n){if("function"!=typeof n.value)return n;var o=n.value;return{get:function(){var t=o.bind(this);return Object.defineProperty(this,e,Object(r.__assign)(Object(r.__assign)({},n),{value:t})),t},set:function(t){o=t}}}e.a=function(t,e,n){return e&&n?o(t,e,n):function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e}(t);return Object.getOwnPropertyNames(t.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t.prototype,n);r&&"constructor"!==n&&Object.defineProperty(e.prototype,n,o(t.prototype,n,r))})),e}(t)}},109:function(t,e,n){"use strict";var r;n.d(e,"a",(function(){return r})),function(t){t.StyleConfigured="STYLE_CONFIGURED"}(r||(r={}))},115:function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(54);function o(t){return Object(r.a)(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,"www."+t.hostname))}},130:function(t,e){t.exports=require("iframe-resizer")},131:function(t,e){t.exports=require("iframe-resizer/js/iframeResizer.contentWindow")},150:function(t,e,n){"use strict";var r=n(3),o=n(8),i=n(54),s=n(58),a=function(){function t(t,e){this._targetWindow=e,this._targetOrigin="*"===t?"*":Object(i.a)(t).origin}return t.prototype.post=function(t,e){var n=this,i=this._targetWindow;if(window!==i){if(!i)throw new Error("Unable to post message because target window is not set.");var a=e&&Object(r.fromEvent)(window,"message").pipe(Object(o.filter)((function(t){return t.origin===n._targetOrigin&&Object(s.a)(t.data,t.data.type)&&-1!==[e.successType,e.errorType].indexOf(t.data.type)})),Object(o.map)((function(t){if(e.errorType===t.data.type)throw t.data;return t.data})),Object(o.take)(1)).toPromise();return i.postMessage(t,this._targetOrigin),a}},t.prototype.setTarget=function(t){this._targetWindow=t},t}();e.a=a},151:function(t,e,n){"use strict";var r=n(0),o=n(54),i=n(115),s=n(100),a=n(58),c=function(){function t(t){this._sourceOrigins=[Object(o.a)(t).origin,Object(i.a)(Object(o.a)(t)).origin],this._isListening=!1,this._listeners={}}return t.prototype.listen=function(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))},t.prototype.stopListen=function(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))},t.prototype.addListener=function(t,e){var n=this._listeners[t];n||(this._listeners[t]=n=[]),-1===n.indexOf(e)&&n.push(e)},t.prototype.removeListener=function(t,e){var n=this._listeners[t];if(n){var r=n.indexOf(e);r>=0&&n.splice(r,1)}},t.prototype.trigger=function(t){var e=this._listeners[t.type];e&&e.forEach((function(e){return e(t)}))},t.prototype._handleMessage=function(t){-1!==this._sourceOrigins.indexOf(t.origin)&&Object(a.a)(t.data,t.data.type)&&this.trigger(t.data)},Object(r.__decorate)([s.a],t.prototype,"_handleMessage",null),t}();e.a=c},153:function(t,e,n){"use strict";var r,o=n(49),i=n(151),s=n(150),a=n(202),c=n(68),u=n.n(c),d=function(){function t(t){this._namespace=t}return t.prototype.getItem=function(t){var e=u.a.getItem(this.withNamespace(t));if(null===e)return null;try{return JSON.parse(e)}catch(e){return this.removeItem(this.withNamespace(t)),null}},t.prototype.getItemOnce=function(t){var e=this.getItem(t);return this.removeItem(t),e},t.prototype.setItem=function(t,e){return u.a.setItem(this.withNamespace(t),JSON.stringify(e))},t.prototype.removeItem=function(t){return u.a.removeItem(this.withNamespace(t))},t.prototype.withNamespace=function(t){return this._namespace+"."+t},t}(),p=n(54),l=n(0),h=n(100),f=n(25),m=function(t){function e(e){var n=t.call(this,e,{message:e.body.title})||this;return n.name="InvalidLoginTokenError",n.type="invalid_login_token",n}return Object(l.__extends)(e,t),e}(n(36).a),y=n(23);!function(t){t.MissingContainer="missing_container",t.MissingContent="missing_content",t.UnknownError="unknown_error"}(r||(r={}));var _=function(t){function e(e,n){void 0===n&&(n=r.UnknownError);var o=t.call(this,e||"Unable to embed the checkout form.")||this;return o.subtype=n,o.name="NotEmbeddableError",o.type="not_embeddable",o}return Object(l.__extends)(e,t),e}(y.a),g=n(109),b=function(){function t(t,e,n,r,o,i,s,a){var c=this;this._iframeCreator=t,this._messageListener=e,this._messagePoster=n,this._loadingIndicator=r,this._requestSender=o,this._storage=i,this._location=s,this._options=a,this._isAttached=!1,this._options.onComplete&&this._messageListener.addListener(f.a.CheckoutComplete,this._options.onComplete),this._options.onError&&this._messageListener.addListener(f.a.CheckoutError,this._options.onError),this._options.onLoad&&this._messageListener.addListener(f.a.CheckoutLoaded,this._options.onLoad),this._options.onFrameLoad&&this._messageListener.addListener(f.a.FrameLoaded,this._options.onFrameLoad),this._options.onSignOut&&this._messageListener.addListener(f.a.SignedOut,this._options.onSignOut),this._messageListener.addListener(f.a.FrameLoaded,(function(){return c._configureStyles()}))}return t.prototype.attach=function(){var t=this;return this._isAttached?Promise.resolve(this):(this._isAttached=!0,this._messageListener.listen(),this._loadingIndicator.show(this._options.containerId),this._allowCookie().then((function(){return t._attemptLogin()})).then((function(e){return t._iframeCreator.createFrame(e,t._options.containerId)})).then((function(e){t._iframe=e,t._configureStyles(),t._loadingIndicator.hide()})).catch((function(e){return t._isAttached=!1,t._retryAllowCookie(e).catch((function(){throw t._messageListener.trigger({type:f.a.FrameError,payload:e}),t._loadingIndicator.hide(),e}))})).then((function(){return t})))},t.prototype.detach=function(){this._isAttached&&(this._isAttached=!1,this._messageListener.stopListen(),this._iframe&&this._iframe.parentNode&&(this._iframe.parentNode.removeChild(this._iframe),this._iframe.iFrameResizer.close()))},t.prototype._configureStyles=function(){this._iframe&&this._iframe.contentWindow&&this._options.styles&&(this._messagePoster.setTarget(this._iframe.contentWindow),this._messagePoster.post({type:g.a.StyleConfigured,payload:this._options.styles}))},t.prototype._attemptLogin=function(){return/^\/login\/token/.test(Object(p.a)(this._options.url).pathname)?this._requestSender.post(this._options.url).then((function(t){return t.body.redirectUrl})).catch((function(t){return Promise.reject(new m(t))})):Promise.resolve(this._options.url)},t.prototype._allowCookie=function(){if(this._storage.getItem("isCookieAllowed"))return Promise.resolve();this._storage.setItem("isCookieAllowed",!0),this._storage.setItem("lastAllowCookieAttempt",Date.now());var t=Object(p.a)(this._options.url).origin+"/embedded-checkout/allow-cookie?returnUrl="+encodeURIComponent(this._location.href);return document.body.style.visibility="hidden",this._location.replace(t),new Promise((function(){}))},t.prototype._retryAllowCookie=function(t){var e=Number(this._storage.getItem("lastAllowCookieAttempt"));return(!e||Date.now()-e>6e5)&&t instanceof _&&t.subtype===r.MissingContent?(this._storage.removeItem("lastAllowCookieAttempt"),this._storage.removeItem("isCookieAllowed"),this._allowCookie()):Promise.reject()},t=Object(l.__decorate)([h.a],t)}(),v=n(58),w=n(203),O=function(){function t(t){this._options=t}return t.prototype.createFrame=function(t,e){var n=document.getElementById(e),o=(this._options||{}).timeout,i=void 0===o?6e4:o;if(!n)throw new _("Unable to embed the iframe because the container element could not be found.",r.MissingContainer);var s=document.createElement("iframe");return s.src=t,s.style.border="none",s.style.display="none",s.style.width="100%",s.allowPaymentRequest=!0,n.appendChild(s),this._toResizableFrame(s,i).catch((function(t){throw n.removeChild(s),t}))},t.prototype._toResizableFrame=function(t,e){return new Promise((function(n,o){var i=window.setTimeout((function(){o(new _("Unable to embed the iframe because the content could not be loaded."))}),e),s=function(e){if(e.origin===Object(p.a)(t.src).origin&&(Object(v.a)(e.data,f.a.FrameError)&&(a(),o(new _(e.data.payload.message,r.MissingContent))),Object(v.a)(e.data,f.a.FrameLoaded))){t.style.display="";var i=e.data.payload&&e.data.payload.contentId,s=Object(w.a)({scrolling:!1,sizeWidth:!1,heightCalculationMethod:i?"taggedElement":"lowestElement"},t);a(),n(s[s.length-1])}},a=function(){window.removeEventListener("message",s),window.clearTimeout(i)};window.addEventListener("message",s)}))},t}();n.d(e,"a",(function(){return C}));var E="BigCommerce.EmbeddedCheckout";function C(t){var e=Object(p.a)(t.url).origin;return new b(new O,new i.a(e),new s.a(e),new a.a({styles:t.styles&&t.styles.loadingIndicator}),Object(o.createRequestSender)(),new d(E),window.location,t).attach()}},154:function(t,e,n){"use strict";var r=n(203),o=n(151),i=n(150),s=n(25);function a(t){if(t.payload&&t.payload.contentId){var e=document.getElementById(t.payload.contentId);e&&!e.hasAttribute("data-iframe-height")&&e.setAttribute("data-iframe-height","")}}var c=n(0);function u(t){return"string"==typeof t.message&&"string"==typeof t.type&&("string"==typeof t.subtype||!t.subtype)&&t instanceof Error}var d=n(100),p=n(109),l=function(){function t(t,e,n,r){void 0===r&&(r={}),this._messageListener=t,this._messagePoster=e,this._untargetedMessagePoster=n,this._messageHandlers=r,this._messageListener.listen()}return t.prototype.postComplete=function(){var t={type:s.a.CheckoutComplete};this._postMessage(t)},t.prototype.postError=function(t){var e={type:s.a.CheckoutError,payload:this._transformError(t)};this._postMessage(e)},t.prototype.postFrameError=function(t){var e={type:s.a.FrameError,payload:this._transformError(t)};this._postMessage(e,{untargeted:!0})},t.prototype.postFrameLoaded=function(t){var e={type:s.a.FrameLoaded,payload:t};this._postMessage(e)},t.prototype.postLoaded=function(){var t={type:s.a.CheckoutLoaded};this._postMessage(t)},t.prototype.postSignedOut=function(){var t={type:s.a.SignedOut};this._postMessage(t)},t.prototype.receiveStyles=function(t){this._messageListener.addListener(p.a.StyleConfigured,(function(e){var n=e.payload;t(n)}))},t.prototype._postMessage=function(t,e){if(this._notifyMessageHandlers(t),e&&e.untargeted)return this._untargetedMessagePoster.post(t);this._messagePoster.post(t)},t.prototype._notifyMessageHandlers=function(t){var e=this;Object.keys(this._messageHandlers).forEach((function(n){if(t.type===n){var r=e._messageHandlers[n];r&&r.call(null,t)}}))},t.prototype._transformError=function(t){return{message:t.message,type:u(t)?t.type:void 0,subtype:u(t)?t.subtype:void 0}},t=Object(c.__decorate)([d.a],t)}(),h=function(){function t(){}return t.prototype.postComplete=function(){},t.prototype.postError=function(){},t.prototype.postFrameError=function(){},t.prototype.postFrameLoaded=function(){},t.prototype.postLoaded=function(){},t.prototype.postSignedOut=function(){},t.prototype.receiveStyles=function(){},t=Object(c.__decorate)([d.a],t)}();function f(t){var e;Object(r.b)();var n=t.parentWindow||window.parent;return window===n?new h:new l(new o.a(t.parentOrigin),new i.a(t.parentOrigin,n),new i.a("*",n),((e={})[s.a.FrameLoaded]=a,e))}n.d(e,"a",(function(){return f}))},202:function(t,e,n){"use strict";var r=n(0),o={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},i="embedded-checkout-loading-indicator-rotation",s=function(){function t(t){this._styles=Object(r.__assign)(Object(r.__assign)({},o),t&&t.styles),this._defineAnimation(),this._container=this._buildContainer(),this._indicator=this._buildIndicator(),this._container.appendChild(this._indicator)}return t.prototype.show=function(t){if(t){var e=document.getElementById(t);if(!e)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");e.appendChild(this._container)}this._container.style.visibility="visible",this._container.style.opacity="1"},t.prototype.hide=function(){var t=this,e=function(){t._container.style.visibility="hidden",t._container.removeEventListener("transitionend",e)};this._container.addEventListener("transitionend",e),this._container.style.opacity="0"},t.prototype._buildContainer=function(){var t=document.createElement("div");return t.style.display="block",t.style.bottom="0",t.style.left="0",t.style.height="100%",t.style.width="100%",t.style.position="absolute",t.style.right="0",t.style.top="0",t.style.transition="all 250ms ease-out",t.style.opacity="0",t},t.prototype._buildIndicator=function(){var t=document.createElement("div");return t.style.display="block",t.style.width=this._styles.size+"px",t.style.height=this._styles.size+"px",t.style.borderRadius=this._styles.size+"px",t.style.border="solid 1px",t.style.borderColor=this._styles.backgroundColor+" "+this._styles.backgroundColor+" "+this._styles.color+" "+this._styles.color,t.style.margin="0 auto",t.style.position="absolute",t.style.left="0",t.style.right="0",t.style.top="50%",t.style.transform="translateY(-50%) rotate(0deg)",t.style.transformStyle="preserve-3d",t.style.animation=i+" 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)",t},t.prototype._defineAnimation=function(){if(!document.getElementById(i)){var t=document.createElement("style");t.id=i,document.head.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule("\n @keyframes "+i+" {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n ",0)}},t}();e.a=s},203:function(t,e,n){"use strict";function r(t,e){return(0,n(130).iframeResizer)(t,e)}function o(){n(131)}n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return o}))},205:function(t,e,n){"use strict";n.r(e);var r=n(153);n.d(e,"embedCheckout",(function(){return r.a}));var o=n(154);n.d(e,"createEmbeddedCheckoutMessenger",(function(){return o.a}))},23:function(t,e,n){"use strict";var r=n(0);var o=function(t){function e(e){var n,r,o=this.constructor,i=t.call(this,e||"An unexpected error has occurred.")||this;return i.name="StandardError",i.type="standard",n=i,r=o.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,o):i.stack=new Error(i.message).stack,i}return Object(r.__extends)(e,t),e}(Error);e.a=o},25:function(t,e,n){"use strict";var r;n.d(e,"a",(function(){return r})),function(t){t.CheckoutComplete="CHECKOUT_COMPLETE",t.CheckoutError="CHECKOUT_ERROR",t.CheckoutLoaded="CHECKOUT_LOADED",t.FrameError="FRAME_ERROR",t.FrameLoaded="FRAME_LOADED",t.SignedOut="SIGNED_OUT"}(r||(r={}))},3:function(t,e){t.exports=require("rxjs")},36:function(t,e,n){"use strict";var r=n(0),o=n(23),i={body:{},headers:{},status:0},s=function(t){function e(e,n){var r=void 0===n?{}:n,o=r.message,s=r.errors,a=this,c=e||i,u=c.body,d=c.headers,p=c.status;return(a=t.call(this,o||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=u,a.headers=d,a.status=p,a.errors=s||[],a}return Object(r.__extends)(e,t),e}(o.a);e.a=s},49:function(t,e){t.exports=require("@bigcommerce/request-sender")},54:function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(55);function o(t){if(!/^(https?:)?\/\//.test(t))throw new r.a("The provided URL must be absolute.");var e=document.createElement("a");e.href=t;var n=e.port&&-1!==t.indexOf(e.hostname+":"+e.port)?e.port:"";return{hash:e.hash,hostname:e.hostname,href:e.href,origin:e.protocol+"//"+e.hostname+(n?":"+n:""),pathname:e.pathname,port:n,protocol:e.protocol,search:e.search}}},55:function(t,e,n){"use strict";var r=n(0),o=function(t){function e(e){var n=t.call(this,e||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return Object(r.__extends)(e,t),e}(n(23).a);e.a=o},58:function(t,e,n){"use strict";function r(t,e){return t.type===e}n.d(e,"a",(function(){return r}))},68:function(t,e){t.exports=require("local-storage-fallback")},8:function(t,e){t.exports=require("rxjs/operators")}});
|
|
1
|
+
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=206)}({0:function(t,e){t.exports=require("tslib")},108:function(t,e,n){"use strict";var r;n.d(e,"a",(function(){return r})),function(t){t.StyleConfigured="STYLE_CONFIGURED"}(r||(r={}))},114:function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(54);function o(t){return Object(r.a)(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,"www."+t.hostname))}},130:function(t,e){t.exports=require("iframe-resizer")},131:function(t,e){t.exports=require("iframe-resizer/js/iframeResizer.contentWindow")},150:function(t,e,n){"use strict";var r=n(3),o=n(8),i=n(54),s=n(58),a=function(){function t(t,e){this._targetWindow=e,this._targetOrigin="*"===t?"*":Object(i.a)(t).origin}return t.prototype.post=function(t,e){var n=this,i=this._targetWindow;if(window!==i){if(!i)throw new Error("Unable to post message because target window is not set.");var a=e&&Object(r.fromEvent)(window,"message").pipe(Object(o.filter)((function(t){return t.origin===n._targetOrigin&&Object(s.a)(t.data,t.data.type)&&-1!==[e.successType,e.errorType].indexOf(t.data.type)})),Object(o.map)((function(t){if(e.errorType===t.data.type)throw t.data;return t.data})),Object(o.take)(1)).toPromise();return i.postMessage(t,this._targetOrigin),a}},t.prototype.setTarget=function(t){this._targetWindow=t},t}();e.a=a},151:function(t,e,n){"use strict";var r=n(0),o=n(54),i=n(114),s=n(99),a=n(58),c=function(){function t(t){this._sourceOrigins=[Object(o.a)(t).origin,Object(i.a)(Object(o.a)(t)).origin],this._isListening=!1,this._listeners={}}return t.prototype.listen=function(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))},t.prototype.stopListen=function(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))},t.prototype.addListener=function(t,e){var n=this._listeners[t];n||(this._listeners[t]=n=[]),-1===n.indexOf(e)&&n.push(e)},t.prototype.removeListener=function(t,e){var n=this._listeners[t];if(n){var r=n.indexOf(e);r>=0&&n.splice(r,1)}},t.prototype.trigger=function(t){var e=this._listeners[t.type];e&&e.forEach((function(e){return e(t)}))},t.prototype._handleMessage=function(t){-1!==this._sourceOrigins.indexOf(t.origin)&&Object(a.a)(t.data,t.data.type)&&this.trigger(t.data)},Object(r.__decorate)([s.a],t.prototype,"_handleMessage",null),t}();e.a=c},153:function(t,e,n){"use strict";var r,o=n(49),i=n(151),s=n(150),a=n(203),c=n(68),u=n.n(c),d=function(){function t(t){this._namespace=t}return t.prototype.getItem=function(t){var e=u.a.getItem(this.withNamespace(t));if(null===e)return null;try{return JSON.parse(e)}catch(e){return this.removeItem(this.withNamespace(t)),null}},t.prototype.getItemOnce=function(t){var e=this.getItem(t);return this.removeItem(t),e},t.prototype.setItem=function(t,e){return u.a.setItem(this.withNamespace(t),JSON.stringify(e))},t.prototype.removeItem=function(t){return u.a.removeItem(this.withNamespace(t))},t.prototype.withNamespace=function(t){return this._namespace+"."+t},t}(),p=n(54),l=n(0),h=n(99),f=n(25),m=function(t){function e(e){var n=t.call(this,e,{message:e.body.title})||this;return n.name="InvalidLoginTokenError",n.type="invalid_login_token",n}return Object(l.__extends)(e,t),e}(n(36).a),y=n(23);!function(t){t.MissingContainer="missing_container",t.MissingContent="missing_content",t.UnknownError="unknown_error"}(r||(r={}));var _=function(t){function e(e,n){void 0===n&&(n=r.UnknownError);var o=t.call(this,e||"Unable to embed the checkout form.")||this;return o.subtype=n,o.name="NotEmbeddableError",o.type="not_embeddable",o}return Object(l.__extends)(e,t),e}(y.a),g=n(108),b=function(){function t(t,e,n,r,o,i,s,a){var c=this;this._iframeCreator=t,this._messageListener=e,this._messagePoster=n,this._loadingIndicator=r,this._requestSender=o,this._storage=i,this._location=s,this._options=a,this._isAttached=!1,this._options.onComplete&&this._messageListener.addListener(f.a.CheckoutComplete,this._options.onComplete),this._options.onError&&this._messageListener.addListener(f.a.CheckoutError,this._options.onError),this._options.onLoad&&this._messageListener.addListener(f.a.CheckoutLoaded,this._options.onLoad),this._options.onFrameLoad&&this._messageListener.addListener(f.a.FrameLoaded,this._options.onFrameLoad),this._options.onSignOut&&this._messageListener.addListener(f.a.SignedOut,this._options.onSignOut),this._messageListener.addListener(f.a.FrameLoaded,(function(){return c._configureStyles()}))}return t.prototype.attach=function(){var t=this;return this._isAttached?Promise.resolve(this):(this._isAttached=!0,this._messageListener.listen(),this._loadingIndicator.show(this._options.containerId),this._allowCookie().then((function(){return t._attemptLogin()})).then((function(e){return t._iframeCreator.createFrame(e,t._options.containerId)})).then((function(e){t._iframe=e,t._configureStyles(),t._loadingIndicator.hide()})).catch((function(e){return t._isAttached=!1,t._retryAllowCookie(e).catch((function(){throw t._messageListener.trigger({type:f.a.FrameError,payload:e}),t._loadingIndicator.hide(),e}))})).then((function(){return t})))},t.prototype.detach=function(){this._isAttached&&(this._isAttached=!1,this._messageListener.stopListen(),this._iframe&&this._iframe.parentNode&&(this._iframe.parentNode.removeChild(this._iframe),this._iframe.iFrameResizer.close()))},t.prototype._configureStyles=function(){this._iframe&&this._iframe.contentWindow&&this._options.styles&&(this._messagePoster.setTarget(this._iframe.contentWindow),this._messagePoster.post({type:g.a.StyleConfigured,payload:this._options.styles}))},t.prototype._attemptLogin=function(){return/^\/login\/token/.test(Object(p.a)(this._options.url).pathname)?this._requestSender.post(this._options.url).then((function(t){return t.body.redirectUrl})).catch((function(t){return Promise.reject(new m(t))})):Promise.resolve(this._options.url)},t.prototype._allowCookie=function(){if(this._storage.getItem("isCookieAllowed"))return Promise.resolve();this._storage.setItem("isCookieAllowed",!0),this._storage.setItem("lastAllowCookieAttempt",Date.now());var t=Object(p.a)(this._options.url).origin+"/embedded-checkout/allow-cookie?returnUrl="+encodeURIComponent(this._location.href);return document.body.style.visibility="hidden",this._location.replace(t),new Promise((function(){}))},t.prototype._retryAllowCookie=function(t){var e=Number(this._storage.getItem("lastAllowCookieAttempt"));return(!e||Date.now()-e>6e5)&&t instanceof _&&t.subtype===r.MissingContent?(this._storage.removeItem("lastAllowCookieAttempt"),this._storage.removeItem("isCookieAllowed"),this._allowCookie()):Promise.reject()},t=Object(l.__decorate)([h.a],t)}(),v=n(58),w=n(204),O=function(){function t(t){this._options=t}return t.prototype.createFrame=function(t,e){var n=document.getElementById(e),o=(this._options||{}).timeout,i=void 0===o?6e4:o;if(!n)throw new _("Unable to embed the iframe because the container element could not be found.",r.MissingContainer);var s=document.createElement("iframe");return s.src=t,s.style.border="none",s.style.display="none",s.style.width="100%",s.allowPaymentRequest=!0,n.appendChild(s),this._toResizableFrame(s,i).catch((function(t){throw n.removeChild(s),t}))},t.prototype._toResizableFrame=function(t,e){return new Promise((function(n,o){var i=window.setTimeout((function(){o(new _("Unable to embed the iframe because the content could not be loaded."))}),e),s=function(e){if(e.origin===Object(p.a)(t.src).origin&&(Object(v.a)(e.data,f.a.FrameError)&&(a(),o(new _(e.data.payload.message,r.MissingContent))),Object(v.a)(e.data,f.a.FrameLoaded))){t.style.display="";var i=e.data.payload&&e.data.payload.contentId,s=Object(w.a)({scrolling:!1,sizeWidth:!1,heightCalculationMethod:i?"taggedElement":"lowestElement"},t);a(),n(s[s.length-1])}},a=function(){window.removeEventListener("message",s),window.clearTimeout(i)};window.addEventListener("message",s)}))},t}();n.d(e,"a",(function(){return C}));var E="BigCommerce.EmbeddedCheckout";function C(t){var e=Object(p.a)(t.url).origin;return new b(new O,new i.a(e),new s.a(e),new a.a({styles:t.styles&&t.styles.loadingIndicator}),Object(o.createRequestSender)(),new d(E),window.location,t).attach()}},154:function(t,e,n){"use strict";var r=n(204),o=n(151),i=n(150),s=n(25);function a(t){if(t.payload&&t.payload.contentId){var e=document.getElementById(t.payload.contentId);e&&!e.hasAttribute("data-iframe-height")&&e.setAttribute("data-iframe-height","")}}var c=n(0);function u(t){return"string"==typeof t.message&&"string"==typeof t.type&&("string"==typeof t.subtype||!t.subtype)&&t instanceof Error}var d=n(99),p=n(108),l=function(){function t(t,e,n,r){void 0===r&&(r={}),this._messageListener=t,this._messagePoster=e,this._untargetedMessagePoster=n,this._messageHandlers=r,this._messageListener.listen()}return t.prototype.postComplete=function(){var t={type:s.a.CheckoutComplete};this._postMessage(t)},t.prototype.postError=function(t){var e={type:s.a.CheckoutError,payload:this._transformError(t)};this._postMessage(e)},t.prototype.postFrameError=function(t){var e={type:s.a.FrameError,payload:this._transformError(t)};this._postMessage(e,{untargeted:!0})},t.prototype.postFrameLoaded=function(t){var e={type:s.a.FrameLoaded,payload:t};this._postMessage(e)},t.prototype.postLoaded=function(){var t={type:s.a.CheckoutLoaded};this._postMessage(t)},t.prototype.postSignedOut=function(){var t={type:s.a.SignedOut};this._postMessage(t)},t.prototype.receiveStyles=function(t){this._messageListener.addListener(p.a.StyleConfigured,(function(e){var n=e.payload;t(n)}))},t.prototype._postMessage=function(t,e){if(this._notifyMessageHandlers(t),e&&e.untargeted)return this._untargetedMessagePoster.post(t);this._messagePoster.post(t)},t.prototype._notifyMessageHandlers=function(t){var e=this;Object.keys(this._messageHandlers).forEach((function(n){if(t.type===n){var r=e._messageHandlers[n];r&&r.call(null,t)}}))},t.prototype._transformError=function(t){return{message:t.message,type:u(t)?t.type:void 0,subtype:u(t)?t.subtype:void 0}},t=Object(c.__decorate)([d.a],t)}(),h=function(){function t(){}return t.prototype.postComplete=function(){},t.prototype.postError=function(){},t.prototype.postFrameError=function(){},t.prototype.postFrameLoaded=function(){},t.prototype.postLoaded=function(){},t.prototype.postSignedOut=function(){},t.prototype.receiveStyles=function(){},t=Object(c.__decorate)([d.a],t)}();function f(t){var e;Object(r.b)();var n=t.parentWindow||window.parent;return window===n?new h:new l(new o.a(t.parentOrigin),new i.a(t.parentOrigin,n),new i.a("*",n),((e={})[s.a.FrameLoaded]=a,e))}n.d(e,"a",(function(){return f}))},203:function(t,e,n){"use strict";var r=n(0),o={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},i="embedded-checkout-loading-indicator-rotation",s=function(){function t(t){this._styles=Object(r.__assign)(Object(r.__assign)({},o),t&&t.styles),this._defineAnimation(),this._container=this._buildContainer(),this._indicator=this._buildIndicator(),this._container.appendChild(this._indicator)}return t.prototype.show=function(t){if(t){var e=document.getElementById(t);if(!e)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");e.appendChild(this._container)}this._container.style.visibility="visible",this._container.style.opacity="1"},t.prototype.hide=function(){var t=this,e=function(){t._container.style.visibility="hidden",t._container.removeEventListener("transitionend",e)};this._container.addEventListener("transitionend",e),this._container.style.opacity="0"},t.prototype._buildContainer=function(){var t=document.createElement("div");return t.style.display="block",t.style.bottom="0",t.style.left="0",t.style.height="100%",t.style.width="100%",t.style.position="absolute",t.style.right="0",t.style.top="0",t.style.transition="all 250ms ease-out",t.style.opacity="0",t},t.prototype._buildIndicator=function(){var t=document.createElement("div");return t.style.display="block",t.style.width=this._styles.size+"px",t.style.height=this._styles.size+"px",t.style.borderRadius=this._styles.size+"px",t.style.border="solid 1px",t.style.borderColor=this._styles.backgroundColor+" "+this._styles.backgroundColor+" "+this._styles.color+" "+this._styles.color,t.style.margin="0 auto",t.style.position="absolute",t.style.left="0",t.style.right="0",t.style.top="50%",t.style.transform="translateY(-50%) rotate(0deg)",t.style.transformStyle="preserve-3d",t.style.animation=i+" 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)",t},t.prototype._defineAnimation=function(){if(!document.getElementById(i)){var t=document.createElement("style");t.id=i,document.head.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule("\n @keyframes "+i+" {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n ",0)}},t}();e.a=s},204:function(t,e,n){"use strict";function r(t,e){return(0,n(130).iframeResizer)(t,e)}function o(){n(131)}n.d(e,"a",(function(){return r})),n.d(e,"b",(function(){return o}))},206:function(t,e,n){"use strict";n.r(e);var r=n(153);n.d(e,"embedCheckout",(function(){return r.a}));var o=n(154);n.d(e,"createEmbeddedCheckoutMessenger",(function(){return o.a}))},23:function(t,e,n){"use strict";var r=n(0);var o=function(t){function e(e){var n,r,o=this.constructor,i=t.call(this,e||"An unexpected error has occurred.")||this;return i.name="StandardError",i.type="standard",n=i,r=o.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,o):i.stack=new Error(i.message).stack,i}return Object(r.__extends)(e,t),e}(Error);e.a=o},25:function(t,e,n){"use strict";var r;n.d(e,"a",(function(){return r})),function(t){t.CheckoutComplete="CHECKOUT_COMPLETE",t.CheckoutError="CHECKOUT_ERROR",t.CheckoutLoaded="CHECKOUT_LOADED",t.FrameError="FRAME_ERROR",t.FrameLoaded="FRAME_LOADED",t.SignedOut="SIGNED_OUT"}(r||(r={}))},3:function(t,e){t.exports=require("rxjs")},36:function(t,e,n){"use strict";var r=n(0),o=n(23),i={body:{},headers:{},status:0},s=function(t){function e(e,n){var r=void 0===n?{}:n,o=r.message,s=r.errors,a=this,c=e||i,u=c.body,d=c.headers,p=c.status;return(a=t.call(this,o||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=u,a.headers=d,a.status=p,a.errors=s||[],a}return Object(r.__extends)(e,t),e}(o.a);e.a=s},49:function(t,e){t.exports=require("@bigcommerce/request-sender")},54:function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(55);function o(t){if(!/^(https?:)?\/\//.test(t))throw new r.a("The provided URL must be absolute.");var e=document.createElement("a");e.href=t;var n=e.port&&-1!==t.indexOf(e.hostname+":"+e.port)?e.port:"";return{hash:e.hash,hostname:e.hostname,href:e.href,origin:e.protocol+"//"+e.hostname+(n?":"+n:""),pathname:e.pathname,port:n,protocol:e.protocol,search:e.search}}},55:function(t,e,n){"use strict";var r=n(0),o=function(t){function e(e){var n=t.call(this,e||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return Object(r.__extends)(e,t),e}(n(23).a);e.a=o},58:function(t,e,n){"use strict";function r(t,e){return t.type===e}n.d(e,"a",(function(){return r}))},68:function(t,e){t.exports=require("local-storage-fallback")},8:function(t,e){t.exports=require("rxjs/operators")},99:function(t,e,n){"use strict";var r=n(0);function o(t,e,n){if("function"!=typeof n.value)return n;var o=n.value;return{get:function(){var t=o.bind(this);return Object.defineProperty(this,e,Object(r.__assign)(Object(r.__assign)({},n),{value:t})),t},set:function(t){o=t}}}e.a=function(t,e,n){return e&&n?o(t,e,n):function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e}(t);return Object.getOwnPropertyNames(t.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t.prototype,n);r&&"constructor"!==n&&Object.defineProperty(e.prototype,n,o(t.prototype,n,r))})),e}(t)}}});
|
|
2
2
|
//# sourceMappingURL=embedded-checkout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"tslib\"","webpack:///./src/common/utility/bind-decorator.ts","webpack:///./src/embedded-checkout/iframe-content/embedded-content-events.ts","webpack:///./src/common/url/append-www.ts","webpack:///external \"iframe-resizer\"","webpack:///external \"iframe-resizer/js/iframeResizer.contentWindow\"","webpack:///./src/common/iframe/iframe-event-poster.ts","webpack:///./src/common/iframe/iframe-event-listener.ts","webpack:///./src/embedded-checkout/errors/not-embeddable-error.ts","webpack:///./src/common/storage/browser-storage.ts","webpack:///./src/embedded-checkout/errors/invalid-login-token-error.ts","webpack:///./src/embedded-checkout/embedded-checkout.ts","webpack:///./src/embedded-checkout/resizable-iframe-creator.ts","webpack:///./src/embedded-checkout/embed-checkout.ts","webpack:///./src/embedded-checkout/iframe-content/handle-frame-loaded-event.ts","webpack:///./src/common/error/errors/custom-error.ts","webpack:///./src/embedded-checkout/iframe-content/iframe-embedded-checkout-messenger.ts","webpack:///./src/embedded-checkout/iframe-content/noop-embedded-checkout-messenger.ts","webpack:///./src/embedded-checkout/iframe-content/create-embedded-checkout-messenger.ts","webpack:///./src/common/loading-indicator/loading-indicator.ts","webpack:///./src/common/iframe/iframe-resizer.ts","webpack:///./src/bundles/embedded-checkout.ts","webpack:///./src/common/error/errors/standard-error.ts","webpack:///./src/common/utility/set-prototype-of.ts","webpack:///./src/embedded-checkout/embedded-checkout-events.ts","webpack:///external \"rxjs\"","webpack:///./src/common/error/errors/request-error.ts","webpack:///external \"@bigcommerce/request-sender\"","webpack:///./src/common/url/parse-url.ts","webpack:///./src/common/error/errors/invalid-argument-error.ts","webpack:///./src/common/iframe/is-iframe-event.ts","webpack:///external \"local-storage-fallback\"","webpack:///external \"rxjs/operators\""],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","bindMethodDecorator","_","descriptor","method","boundMethod","this","set","target","decoratedTarget","getOwnPropertyNames","forEach","getOwnPropertyDescriptor","bindClassDecorator","EmbeddedContentEventType","appendWww","url","hostname","indexOf","href","replace","targetOrigin","_targetWindow","_targetOrigin","origin","post","event","options","targetWindow","window","Error","result","pipe","data","type","successType","errorType","toPromise","postMessage","setTarget","sourceOrigin","_sourceOrigins","_isListening","_listeners","listen","addEventListener","_handleMessage","stopListen","removeEventListener","addListener","listener","listeners","push","removeListener","index","splice","trigger","NotEmbeddableErrorType","_namespace","getItem","rawValue","withNamespace","JSON","parse","error","removeItem","getItemOnce","setItem","stringify","response","message","body","title","subtype","UnknownError","_iframeCreator","_messageListener","_messagePoster","_loadingIndicator","_requestSender","_storage","_location","_options","_isAttached","onComplete","CheckoutComplete","onError","CheckoutError","onLoad","CheckoutLoaded","onFrameLoad","FrameLoaded","onSignOut","SignedOut","_configureStyles","attach","Promise","resolve","show","containerId","_allowCookie","then","_attemptLogin","createFrame","iframe","_iframe","hide","catch","_retryAllowCookie","FrameError","payload","detach","parentNode","removeChild","iFrameResizer","close","contentWindow","styles","StyleConfigured","test","pathname","reject","Date","now","redirectUrl","encodeURIComponent","document","style","visibility","lastAttempt","Number","MissingContent","EmbeddedCheckout","src","container","getElementById","timeout","MissingContainer","createElement","border","display","width","allowPaymentRequest","appendChild","_toResizableFrame","timeoutInterval","setTimeout","handleMessage","teardown","contentId","iframes","scrolling","sizeWidth","heightCalculationMethod","length","clearTimeout","STORAGE_PREFIX","embedCheckout","loadingIndicator","location","handleFrameLoadedEvent","hasAttribute","setAttribute","isCustomError","_untargetedMessagePoster","_messageHandlers","postComplete","_postMessage","postError","_transformError","postFrameError","untargeted","postFrameLoaded","postLoaded","postSignedOut","receiveStyles","handler","_notifyMessageHandlers","keys","undefined","IframeEmbeddedCheckoutMessenger","NoopEmbeddedCheckoutMessenger","createEmbeddedCheckoutMessenger","parentWindow","parent","parentOrigin","DEFAULT_STYLES","size","color","backgroundColor","ROTATION_ANIMATION","_styles","_defineAnimation","_container","_buildContainer","_indicator","_buildIndicator","parentId","opacity","handleTransitionEnd","bottom","left","height","position","right","top","transition","indicator","borderRadius","borderColor","margin","transform","transformStyle","animation","id","head","sheet","CSSStyleSheet","insertRule","iframeResizer","originalIframeResizer","setupContentWindowForIframeResizer","setPrototypeOf","__proto__","captureStackTrace","stack","EmbeddedCheckoutEventType","DEFAULT_RESPONSE","headers","status","errors","parseUrl","anchor","port","hash","protocol","search","isIframeEvent"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OA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O,IACrEjH,SAAUgH,EAAOhH,SACjBiH,KAAI,EACJE,SAAUH,EAAOG,SACjBC,OAAQJ,EAAOI,U,2CCrBvB,cACI,WAAYtK,GAAZ,MACI,YAAMA,GAAW,0CAAwC,K,OAEzD,EAAK/F,KAAO,uBACZ,EAAK2D,KAAO,mB,EAEpB,OAPkD,yBAOlD,EAPA,C,MAAkD,G,uCCLnC,SAAS2M,EACpBnP,EACAwC,GAEA,OAAOxC,EAAOwC,OAASA,EAJ3B,mC,iBCFAnE,EAAOD,QAAUkC,QAAQ,2B,gBCAzBjC,EAAOD,QAAUkC,QAAQ","file":"embedded-checkout.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 205);\n","module.exports = require(\"tslib\");","/**\n * Decorates a class or a method by binding all its prototype methods or itself\n * to the calling instance respectively.\n */\nfunction bindDecorator<T extends Method>(target: object, key: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;\nfunction bindDecorator<T extends Constructor<object>>(target: T): T;\nfunction bindDecorator(target: any, key?: any, descriptor?: any): any {\n if (!key || !descriptor) {\n return bindClassDecorator(target);\n }\n\n return bindMethodDecorator(target, key, descriptor);\n}\n\nexport default bindDecorator;\n\n/**\n * Decorates a class by binding all its prototype methods to the calling\n * instance.\n */\nexport function bindClassDecorator<T extends Constructor<object>>(target: T): T {\n const decoratedTarget = class extends target {};\n\n Object.getOwnPropertyNames(target.prototype)\n .forEach(key => {\n const descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);\n\n if (!descriptor || key === 'constructor') {\n return;\n }\n\n Object.defineProperty(\n decoratedTarget.prototype,\n key,\n bindMethodDecorator(target.prototype, key, descriptor)\n );\n });\n\n return decoratedTarget;\n}\n\n/**\n * Decorates a method by binding it to the calling instance.\n */\nexport function bindMethodDecorator<T extends Method>(_: object, key: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> {\n if (typeof descriptor.value !== 'function') {\n return descriptor;\n }\n\n let method: T = descriptor.value;\n\n return {\n get() {\n const boundMethod = method.bind(this) as T;\n\n Object.defineProperty(this, key, {\n ...descriptor,\n value: boundMethod,\n });\n\n return boundMethod;\n },\n set(value) {\n method = value;\n },\n };\n}\n\nexport type Constructor<T> = new (...args: any[]) => T;\nexport type Method = (...args: any[]) => any;\n","import EmbeddedCheckoutStyles from '../embedded-checkout-styles';\n\nexport enum EmbeddedContentEventType {\n StyleConfigured = 'STYLE_CONFIGURED',\n}\n\nexport interface EmbeddedContentEventMap {\n [EmbeddedContentEventType.StyleConfigured]: EmbeddedContentStyleConfiguredEvent;\n}\n\nexport type EmbeddedContentEvent = (\n EmbeddedContentStyleConfiguredEvent\n);\n\nexport interface EmbeddedContentStyleConfiguredEvent {\n type: EmbeddedContentEventType.StyleConfigured;\n payload: EmbeddedCheckoutStyles;\n}\n","import parseUrl from './parse-url';\nimport Url from './url';\n\nexport default function appendWww(url: Url): Url {\n return parseUrl(\n url.hostname.indexOf('www') === 0 ?\n url.href :\n url.href.replace(url.hostname, `www.${url.hostname}`)\n );\n}\n","module.exports = require(\"iframe-resizer\");","module.exports = require(\"iframe-resizer/js/iframeResizer.contentWindow\");","import { fromEvent } from 'rxjs';\nimport { filter, map, take } from 'rxjs/operators';\n\nimport { parseUrl } from '../url';\n\nimport IframeEvent from './iframe-event';\nimport isIframeEvent from './is-iframe-event';\n\nexport interface IframeEventPostOptions<TSuccessEvent extends IframeEvent, TErrorEvent extends IframeEvent> {\n errorType?: TErrorEvent['type'];\n successType?: TSuccessEvent['type'];\n}\n\nexport default class IframeEventPoster<TEvent> {\n private _targetOrigin: string;\n\n constructor(\n targetOrigin: string,\n private _targetWindow?: Window\n ) {\n this._targetOrigin = targetOrigin === '*' ? '*' : parseUrl(targetOrigin).origin;\n }\n\n post(event: TEvent): void;\n post<TSuccessEvent extends IframeEvent = IframeEvent, TErrorEvent extends IframeEvent = IframeEvent>(\n event: TEvent,\n options: IframeEventPostOptions<TSuccessEvent, TErrorEvent>\n ): Promise<TSuccessEvent>;\n post<TSuccessEvent extends IframeEvent = IframeEvent, TErrorEvent extends IframeEvent = IframeEvent>(\n event: TEvent,\n options?: IframeEventPostOptions<TSuccessEvent, TErrorEvent>\n ): Promise<TSuccessEvent> | void {\n const targetWindow = this._targetWindow;\n\n if (window === targetWindow) {\n return;\n }\n\n if (!targetWindow) {\n throw new Error('Unable to post message because target window is not set.');\n }\n\n const result = options && fromEvent<MessageEvent>(window, 'message')\n .pipe(\n filter(event =>\n event.origin === this._targetOrigin &&\n isIframeEvent(event.data, event.data.type) &&\n [options.successType, options.errorType].indexOf(event.data.type) !== -1\n ),\n map(event => {\n if (options.errorType === event.data.type) {\n throw event.data;\n }\n\n return event.data;\n }),\n take(1)\n )\n .toPromise();\n\n targetWindow.postMessage(event, this._targetOrigin);\n\n return result;\n }\n\n setTarget(window: Window) {\n this._targetWindow = window;\n }\n}\n","import { appendWww, parseUrl } from '../url';\nimport { bindDecorator as bind } from '../utility';\n\nimport { IframeEventMap } from './iframe-event';\nimport isIframeEvent from './is-iframe-event';\n\nexport default class IframeEventListener<TEventMap extends IframeEventMap<keyof TEventMap>> {\n private _isListening: boolean;\n private _listeners: EventListeners<TEventMap>;\n private _sourceOrigins: string[];\n\n constructor(\n sourceOrigin: string\n ) {\n this._sourceOrigins = [\n parseUrl(sourceOrigin).origin,\n appendWww(parseUrl(sourceOrigin)).origin,\n ];\n this._isListening = false;\n this._listeners = {};\n }\n\n listen(): void {\n if (this._isListening) {\n return;\n }\n\n this._isListening = true;\n\n window.addEventListener('message', this._handleMessage);\n }\n\n stopListen(): void {\n if (!this._isListening) {\n return;\n }\n\n this._isListening = false;\n\n window.removeEventListener('message', this._handleMessage);\n }\n\n addListener<TType extends keyof TEventMap>(type: TType, listener: (event: TEventMap[TType]) => void): void {\n let listeners = this._listeners[type];\n\n if (!listeners) {\n this._listeners[type] = listeners = [];\n }\n\n if (listeners.indexOf(listener) === -1) {\n listeners.push(listener);\n }\n }\n\n removeListener<TType extends keyof TEventMap>(type: TType, listener: (event: TEventMap[TType]) => void): void {\n const listeners = this._listeners[type];\n\n if (!listeners) {\n return;\n }\n\n const index = listeners.indexOf(listener);\n\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n }\n\n trigger<TType extends keyof TEventMap>(event: TEventMap[TType]): void {\n const listeners = this._listeners[event.type];\n\n if (!listeners) {\n return;\n }\n\n listeners.forEach(listener => listener(event));\n }\n\n @bind\n private _handleMessage(event: MessageEvent): void {\n if ((this._sourceOrigins.indexOf(event.origin) === -1) ||\n !isIframeEvent(event.data as TEventMap[keyof TEventMap], event.data.type)\n ) {\n return;\n }\n\n this.trigger(event.data);\n }\n}\n\ntype EventListeners<TEventMap> = {\n [key in keyof TEventMap]?: Array<(event: TEventMap[key]) => void>;\n};\n","import { StandardError } from '../../common/error/errors';\n\nexport enum NotEmbeddableErrorType {\n MissingContainer = 'missing_container',\n MissingContent = 'missing_content',\n UnknownError = 'unknown_error',\n}\n\n/**\n * Throw this error if we are not able to embed the checkout form as an iframe.\n * This can be due to the fact that the provided container ID is invalid, or the\n * checkout form fails to load inside the iframe. It can also be due to an\n * unknown reason.\n */\nexport default class NotEmbeddableError extends StandardError {\n constructor(\n message?: string,\n public subtype: NotEmbeddableErrorType = NotEmbeddableErrorType.UnknownError\n ) {\n super(message || 'Unable to embed the checkout form.');\n\n this.name = 'NotEmbeddableError';\n this.type = 'not_embeddable';\n }\n}\n","import { default as storage } from 'local-storage-fallback';\n\nexport default class BrowserStorage {\n constructor(\n private _namespace: string\n ) {}\n\n getItem<TValue = any>(key: string): TValue | null {\n const rawValue = storage.getItem(this.withNamespace(key));\n\n if (rawValue === null) {\n return null;\n }\n\n try {\n return JSON.parse(rawValue);\n } catch (error) {\n // Clean up invalid values\n this.removeItem(this.withNamespace(key));\n\n return null;\n }\n }\n\n getItemOnce<TValue = any>(key: string): TValue | null {\n const value = this.getItem(key);\n\n this.removeItem(key);\n\n return value;\n }\n\n setItem<TValue = any>(key: string, value: TValue): void {\n return storage.setItem(this.withNamespace(key), JSON.stringify(value));\n }\n\n removeItem(key: string): void {\n return storage.removeItem(this.withNamespace(key));\n }\n\n private withNamespace(key: string): string {\n return `${this._namespace}.${key}`;\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { InternalErrorResponseBody } from '../../common/error';\nimport { RequestError } from '../../common/error/errors';\n\n/**\n * Throw this error we are not able to sign in a shopper because the provided\n * login token is invalid.\n */\nexport default class InvalidLoginTokenError extends RequestError {\n constructor(response: Response<InternalErrorResponseBody>) {\n super(response, { message: response.body.title });\n\n this.name = 'InvalidLoginTokenError';\n this.type = 'invalid_login_token';\n }\n}\n","import { RequestSender } from '@bigcommerce/request-sender';\n\nimport { IframeEventListener, IframeEventPoster, IFrameComponent } from '../common/iframe';\nimport { LoadingIndicator } from '../common/loading-indicator';\nimport { BrowserStorage } from '../common/storage';\nimport { parseUrl } from '../common/url';\nimport { bindDecorator as bind } from '../common/utility';\n\nimport EmbeddedCheckoutError from './embedded-checkout-error';\nimport { EmbeddedCheckoutEventMap, EmbeddedCheckoutEventType } from './embedded-checkout-events';\nimport EmbeddedCheckoutOptions from './embedded-checkout-options';\nimport { InvalidLoginTokenError, NotEmbeddableError, NotEmbeddableErrorType } from './errors';\nimport { EmbeddedContentEvent, EmbeddedContentEventType } from './iframe-content';\nimport ResizableIframeCreator from './resizable-iframe-creator';\n\nexport const ALLOW_COOKIE_ATTEMPT_INTERVAL = 10 * 60 * 1000;\nexport const IS_COOKIE_ALLOWED_KEY = 'isCookieAllowed';\nexport const LAST_ALLOW_COOKIE_ATTEMPT_KEY = 'lastAllowCookieAttempt';\n\n@bind\nexport default class EmbeddedCheckout {\n private _iframe?: IFrameComponent;\n private _isAttached: boolean;\n\n /**\n * @internal\n */\n constructor(\n private _iframeCreator: ResizableIframeCreator,\n private _messageListener: IframeEventListener<EmbeddedCheckoutEventMap>,\n private _messagePoster: IframeEventPoster<EmbeddedContentEvent>,\n private _loadingIndicator: LoadingIndicator,\n private _requestSender: RequestSender,\n private _storage: BrowserStorage,\n private _location: Location,\n private _options: EmbeddedCheckoutOptions\n ) {\n this._isAttached = false;\n\n if (this._options.onComplete) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.CheckoutComplete, this._options.onComplete);\n }\n\n if (this._options.onError) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.CheckoutError, this._options.onError);\n }\n\n if (this._options.onLoad) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.CheckoutLoaded, this._options.onLoad);\n }\n\n if (this._options.onFrameLoad) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.FrameLoaded, this._options.onFrameLoad);\n }\n\n if (this._options.onSignOut) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.SignedOut, this._options.onSignOut);\n }\n\n this._messageListener.addListener(EmbeddedCheckoutEventType.FrameLoaded, () => this._configureStyles());\n }\n\n attach(): Promise<this> {\n if (this._isAttached) {\n return Promise.resolve(this);\n }\n\n this._isAttached = true;\n this._messageListener.listen();\n this._loadingIndicator.show(this._options.containerId);\n\n return this._allowCookie()\n .then(() => this._attemptLogin())\n .then(url => this._iframeCreator.createFrame(url, this._options.containerId))\n .then(iframe => {\n this._iframe = iframe;\n\n this._configureStyles();\n this._loadingIndicator.hide();\n })\n .catch(error => {\n this._isAttached = false;\n\n return this._retryAllowCookie(error)\n .catch(() => {\n this._messageListener.trigger({\n type: EmbeddedCheckoutEventType.FrameError,\n payload: error,\n });\n\n this._loadingIndicator.hide();\n\n throw error;\n });\n })\n .then(() => this);\n }\n\n detach(): void {\n if (!this._isAttached) {\n return;\n }\n\n this._isAttached = false;\n this._messageListener.stopListen();\n\n if (this._iframe && this._iframe.parentNode) {\n this._iframe.parentNode.removeChild(this._iframe);\n this._iframe.iFrameResizer.close();\n }\n }\n\n private _configureStyles(): void {\n if (!this._iframe || !this._iframe.contentWindow || !this._options.styles) {\n return;\n }\n\n this._messagePoster.setTarget(this._iframe.contentWindow);\n\n this._messagePoster.post({\n type: EmbeddedContentEventType.StyleConfigured,\n payload: this._options.styles,\n });\n }\n\n private _attemptLogin(): Promise<string> {\n if (!/^\\/login\\/token/.test(parseUrl(this._options.url).pathname)) {\n return Promise.resolve(this._options.url);\n }\n\n return this._requestSender.post<{ redirectUrl: string }>(this._options.url)\n .then(({ body: { redirectUrl } }) => redirectUrl)\n .catch(response => Promise.reject(new InvalidLoginTokenError(response)));\n }\n\n /**\n * This workaround is required for certain browsers (namely Safari) that\n * prevent session cookies to be set for a third party website unless the\n * user has recently visited such website. Therefore, before we attempt to\n * login or set an active cart in the session, we need to first redirect the\n * user to the domain of Embedded Checkout.\n */\n private _allowCookie(): Promise<void> {\n if (this._storage.getItem(IS_COOKIE_ALLOWED_KEY)) {\n return Promise.resolve();\n }\n\n this._storage.setItem(IS_COOKIE_ALLOWED_KEY, true);\n\n // It could be possible that the flag is set to true but the browser has\n // already removed the permission to store third-party cookies. In that\n // case, we should try to redirect the user again. But we only want to\n // do it once within a fixed interval. This is to avoid getting into a\n // redirect loop if the shopper actually doesn't have a valid card\n // session.\n this._storage.setItem(LAST_ALLOW_COOKIE_ATTEMPT_KEY, Date.now());\n\n const { origin } = parseUrl(this._options.url);\n const redirectUrl = `${origin}/embedded-checkout/allow-cookie?returnUrl=${encodeURIComponent(this._location.href)}`;\n\n document.body.style.visibility = 'hidden';\n this._location.replace(redirectUrl);\n\n return new Promise<never>(() => {});\n }\n\n private _retryAllowCookie(error: EmbeddedCheckoutError): Promise<void> {\n const lastAttempt = Number(this._storage.getItem(LAST_ALLOW_COOKIE_ATTEMPT_KEY));\n const canRetry = (\n (!lastAttempt || Date.now() - lastAttempt > ALLOW_COOKIE_ATTEMPT_INTERVAL) &&\n error instanceof NotEmbeddableError &&\n error.subtype === NotEmbeddableErrorType.MissingContent\n );\n\n if (!canRetry) {\n return Promise.reject();\n }\n\n this._storage.removeItem(LAST_ALLOW_COOKIE_ATTEMPT_KEY);\n this._storage.removeItem(IS_COOKIE_ALLOWED_KEY);\n\n return this._allowCookie();\n }\n}\n","import { iframeResizer, isIframeEvent, IFrameComponent } from '../common/iframe';\nimport { parseUrl } from '../common/url';\n\nimport { EmbeddedCheckoutEventType } from './embedded-checkout-events';\nimport { NotEmbeddableError, NotEmbeddableErrorType } from './errors';\n\nexport default class ResizableIframeCreator {\n constructor(\n private _options?: { timeout: number }\n ) {}\n\n createFrame(src: string, containerId: string): Promise<IFrameComponent> {\n const container = document.getElementById(containerId);\n const { timeout = 60000 } = this._options || {};\n\n if (!container) {\n throw new NotEmbeddableError(\n 'Unable to embed the iframe because the container element could not be found.',\n NotEmbeddableErrorType.MissingContainer\n );\n }\n\n const iframe = document.createElement('iframe');\n\n iframe.src = src;\n iframe.style.border = 'none';\n iframe.style.display = 'none';\n iframe.style.width = '100%';\n iframe.allowPaymentRequest = true;\n\n container.appendChild(iframe);\n\n return this._toResizableFrame(iframe, timeout)\n .catch(error => {\n container.removeChild(iframe);\n\n throw error;\n });\n }\n\n private _toResizableFrame(iframe: HTMLIFrameElement, timeoutInterval: number): Promise<IFrameComponent> {\n // Can't simply listen to `load` event because it always gets triggered even if there's an error.\n // Instead, listen to the `load` inside the iframe and let the parent frame know when it happens.\n return new Promise((resolve, reject) => {\n const timeout = window.setTimeout(() => {\n reject(new NotEmbeddableError('Unable to embed the iframe because the content could not be loaded.'));\n }, timeoutInterval);\n\n const handleMessage = (event: MessageEvent) => {\n if (event.origin !== parseUrl(iframe.src).origin) {\n return;\n }\n\n if (isIframeEvent(event.data, EmbeddedCheckoutEventType.FrameError)) {\n teardown();\n reject(new NotEmbeddableError(event.data.payload.message, NotEmbeddableErrorType.MissingContent));\n }\n\n if (isIframeEvent(event.data, EmbeddedCheckoutEventType.FrameLoaded)) {\n iframe.style.display = '';\n\n const contentId = event.data.payload && event.data.payload.contentId;\n const iframes = iframeResizer({\n scrolling: false,\n sizeWidth: false,\n heightCalculationMethod: contentId ? 'taggedElement' : 'lowestElement',\n }, iframe);\n\n teardown();\n resolve(iframes[iframes.length - 1]);\n }\n };\n\n const teardown = () => {\n window.removeEventListener('message', handleMessage);\n window.clearTimeout(timeout);\n };\n\n window.addEventListener('message', handleMessage);\n });\n }\n}\n","import { createRequestSender } from '@bigcommerce/request-sender';\n\nimport { IframeEventListener, IframeEventPoster } from '../common/iframe';\nimport { LoadingIndicator } from '../common/loading-indicator';\nimport { BrowserStorage } from '../common/storage';\nimport { parseUrl } from '../common/url';\n\nimport EmbeddedCheckout from './embedded-checkout';\nimport { EmbeddedCheckoutEventMap } from './embedded-checkout-events';\nimport EmbeddedCheckoutOptions from './embedded-checkout-options';\nimport { EmbeddedContentEvent } from './iframe-content';\nimport ResizableIframeCreator from './resizable-iframe-creator';\n\nconst STORAGE_PREFIX = 'BigCommerce.EmbeddedCheckout';\n\n/**\n * Embed the checkout form in an iframe.\n *\n * @remarks\n * Once the iframe is embedded, it will automatically resize according to the\n * size of the checkout form. It will also notify the parent window when certain\n * events have occurred. i.e.: when the form is loaded and ready to be used.\n *\n * ```js\n * embedCheckout({\n * url: 'https://checkout/url',\n * containerId: 'container-id',\n * });\n * ```\n *\n * @param options - Options for embedding the checkout form.\n * @returns A promise that resolves to an instance of `EmbeddedCheckout`.\n */\nexport default function embedCheckout(options: EmbeddedCheckoutOptions): Promise<EmbeddedCheckout> {\n const origin = parseUrl(options.url).origin;\n const embeddedCheckout = new EmbeddedCheckout(\n new ResizableIframeCreator(),\n new IframeEventListener<EmbeddedCheckoutEventMap>(origin),\n new IframeEventPoster<EmbeddedContentEvent>(origin),\n new LoadingIndicator({ styles: options.styles && options.styles.loadingIndicator }),\n createRequestSender(),\n new BrowserStorage(STORAGE_PREFIX),\n window.location,\n options\n );\n\n return embeddedCheckout.attach();\n}\n","import { EmbeddedCheckoutFrameLoadedEvent } from '../embedded-checkout-events';\n\nexport default function handleFrameLoadedEvent(message: EmbeddedCheckoutFrameLoadedEvent): void {\n if (!message.payload || !message.payload.contentId) {\n return;\n }\n\n const body = document.getElementById(message.payload.contentId);\n\n if (!body || body.hasAttribute('data-iframe-height')) {\n return;\n }\n\n body.setAttribute('data-iframe-height', '');\n}\n","export default interface CustomError extends Error {\n message: string;\n type: string;\n subtype?: string;\n}\n\nexport function isCustomError(error: any): error is CustomError {\n return (\n typeof error.message === 'string' &&\n typeof error.type === 'string' &&\n (typeof error.subtype === 'string' || !error.subtype) &&\n error instanceof Error\n );\n}\n","import { isCustomError, CustomError } from '../../common/error/errors';\nimport { IframeEventListener, IframeEventPoster } from '../../common/iframe';\nimport { bindDecorator as bind } from '../../common/utility';\nimport EmbeddedCheckoutError from '../embedded-checkout-error';\nimport { EmbeddedCheckoutCompleteEvent, EmbeddedCheckoutErrorEvent, EmbeddedCheckoutEvent, EmbeddedCheckoutEventMap, EmbeddedCheckoutEventType, EmbeddedCheckoutFrameErrorEvent, EmbeddedCheckoutFrameLoadedEvent, EmbeddedCheckoutLoadedEvent, EmbeddedCheckoutSignedOutEvent } from '../embedded-checkout-events';\nimport EmbeddedCheckoutStyles from '../embedded-checkout-styles';\n\nimport EmbeddedCheckoutMessenger from './embedded-checkout-messenger';\nimport { EmbeddedContentEventMap, EmbeddedContentEventType } from './embedded-content-events';\nimport EmbeddedContentOptions from './embedded-content-options';\n\n@bind\nexport default class IframeEmbeddedCheckoutMessenger implements EmbeddedCheckoutMessenger {\n /**\n * @internal\n */\n constructor(\n private _messageListener: IframeEventListener<EmbeddedContentEventMap>,\n private _messagePoster: IframeEventPoster<EmbeddedCheckoutEvent>,\n private _untargetedMessagePoster: IframeEventPoster<EmbeddedCheckoutEvent>,\n private _messageHandlers: EventCallbacks<EmbeddedCheckoutEventMap> = {}\n ) {\n this._messageListener.listen();\n }\n\n postComplete(): void {\n const message: EmbeddedCheckoutCompleteEvent = {\n type: EmbeddedCheckoutEventType.CheckoutComplete,\n };\n\n this._postMessage(message);\n }\n\n postError(payload: Error | CustomError): void {\n const message: EmbeddedCheckoutErrorEvent = {\n type: EmbeddedCheckoutEventType.CheckoutError,\n payload: this._transformError(payload),\n };\n\n this._postMessage(message);\n }\n\n postFrameError(payload: Error | CustomError): void {\n const message: EmbeddedCheckoutFrameErrorEvent = {\n type: EmbeddedCheckoutEventType.FrameError,\n payload: this._transformError(payload),\n };\n\n // Ideally, all messages should be targeted at a specific origin.\n // However, for `FrameError` message, we have to post it in an\n // untargeted fashion. This is because the error could be caused by a\n // missing cart. That makes it not possible to determine of site origin\n // of the parent window. Nevertheless, we still want to notify the\n // parent window about the error.\n this._postMessage(message, { untargeted: true });\n }\n\n postFrameLoaded(payload?: EmbeddedContentOptions): void {\n const message: EmbeddedCheckoutFrameLoadedEvent = {\n type: EmbeddedCheckoutEventType.FrameLoaded,\n payload,\n };\n\n this._postMessage(message);\n }\n\n postLoaded(): void {\n const message: EmbeddedCheckoutLoadedEvent = {\n type: EmbeddedCheckoutEventType.CheckoutLoaded,\n };\n\n this._postMessage(message);\n }\n\n postSignedOut(): void {\n const message: EmbeddedCheckoutSignedOutEvent = {\n type: EmbeddedCheckoutEventType.SignedOut,\n };\n\n this._postMessage(message);\n }\n\n receiveStyles(handler: (styles: EmbeddedCheckoutStyles) => void): void {\n this._messageListener.addListener(EmbeddedContentEventType.StyleConfigured, ({ payload }) => {\n handler(payload);\n });\n }\n\n private _postMessage(message: EmbeddedCheckoutEvent, options?: { untargeted?: boolean }): void {\n this._notifyMessageHandlers(message);\n\n if (options && options.untargeted) {\n return this._untargetedMessagePoster.post(message);\n }\n\n this._messagePoster.post(message);\n }\n\n private _notifyMessageHandlers(message: EmbeddedCheckoutEvent): void {\n Object.keys(this._messageHandlers)\n .forEach(key => {\n if (message.type !== key) {\n return;\n }\n\n const handler = this._messageHandlers[key];\n\n if (handler) {\n (handler as (event: EmbeddedCheckoutEvent) => void).call(null, message);\n }\n });\n }\n\n private _transformError(error: Error | CustomError): EmbeddedCheckoutError {\n return {\n message: error.message,\n type: isCustomError(error) ? error.type : undefined,\n subtype: isCustomError(error) ? error.subtype : undefined,\n };\n }\n}\n\nexport type EventCallbacks<TEventMap> = {\n [key in keyof TEventMap]?: (event: TEventMap[key]) => void;\n};\n","import { bindDecorator as bind } from '../../common/utility';\n\nimport EmbeddedCheckoutMessenger from './embedded-checkout-messenger';\n\n@bind\nexport default class NoopEmbeddedCheckoutMessenger implements EmbeddedCheckoutMessenger {\n postComplete(): void {}\n\n postError(): void {}\n\n postFrameError(): void {}\n\n postFrameLoaded(): void {}\n\n postLoaded(): void {}\n\n postSignedOut(): void {}\n\n receiveStyles(): void {}\n}\n","import { setupContentWindowForIframeResizer, IframeEventListener, IframeEventPoster } from '../../common/iframe';\nimport { EmbeddedCheckoutEvent, EmbeddedCheckoutEventType } from '../embedded-checkout-events';\n\nimport EmbeddedCheckoutMessenger from './embedded-checkout-messenger';\nimport EmbeddedCheckoutMessengerOptions from './embedded-checkout-messenger-options';\nimport { EmbeddedContentEventMap } from './embedded-content-events';\nimport handleFrameLoadedEvent from './handle-frame-loaded-event';\nimport IframeEmbeddedCheckoutMessenger from './iframe-embedded-checkout-messenger';\nimport NoopEmbeddedCheckoutMessenger from './noop-embedded-checkout-messenger';\n\n/**\n * Create an instance of `EmbeddedCheckoutMessenger`.\n *\n * @remarks\n * The object is responsible for posting messages to the parent window from the\n * iframe when certain events have occurred. For example, when the checkout\n * form is first loaded, you should notify the parent window about it.\n *\n * The iframe can only be embedded in domains that are allowed by the store.\n *\n * ```ts\n * const messenger = createEmbeddedCheckoutMessenger({\n * parentOrigin: 'https://some/website',\n * });\n *\n * messenger.postFrameLoaded();\n * ```\n *\n * @alpha\n * Please note that this feature is currently in an early stage of development.\n * Therefore the API is unstable and not ready for public consumption.\n *\n * @param options - Options for creating `EmbeddedCheckoutMessenger`\n * @returns - An instance of `EmbeddedCheckoutMessenger`\n */\nexport default function createEmbeddedCheckoutMessenger(options: EmbeddedCheckoutMessengerOptions): EmbeddedCheckoutMessenger {\n setupContentWindowForIframeResizer();\n\n const parentWindow = options.parentWindow || window.parent;\n\n // Return a No-op messenger if it is not called inside an iframe\n if (window === parentWindow) {\n return new NoopEmbeddedCheckoutMessenger();\n }\n\n return new IframeEmbeddedCheckoutMessenger(\n new IframeEventListener<EmbeddedContentEventMap>(options.parentOrigin),\n new IframeEventPoster<EmbeddedCheckoutEvent>(options.parentOrigin, parentWindow),\n new IframeEventPoster<EmbeddedCheckoutEvent>('*', parentWindow),\n { [EmbeddedCheckoutEventType.FrameLoaded]: handleFrameLoadedEvent }\n );\n}\n","import { LoadingIndicatorStyles } from './loading-indicator-styles';\n\nconst DEFAULT_STYLES: LoadingIndicatorStyles = {\n size: 70,\n color: '#d9d9d9',\n backgroundColor: '#ffffff',\n};\n\nconst ROTATION_ANIMATION = 'embedded-checkout-loading-indicator-rotation';\n\nexport default class LoadingIndicator {\n private _container: HTMLElement;\n private _indicator: HTMLElement;\n private _styles: LoadingIndicatorStyles;\n\n constructor(\n options?: { styles?: LoadingIndicatorStyles }\n ) {\n this._styles = { ...DEFAULT_STYLES, ...options && options.styles };\n\n this._defineAnimation();\n\n this._container = this._buildContainer();\n this._indicator = this._buildIndicator();\n\n this._container.appendChild(this._indicator);\n }\n\n show(parentId?: string): void {\n if (parentId) {\n const parent = document.getElementById(parentId);\n\n if (!parent) {\n throw new Error('Unable to attach the loading indicator because the parent ID is not valid.');\n }\n\n parent.appendChild(this._container);\n }\n\n this._container.style.visibility = 'visible';\n this._container.style.opacity = '1';\n }\n\n hide(): void {\n const handleTransitionEnd = () => {\n this._container.style.visibility = 'hidden';\n\n this._container.removeEventListener('transitionend', handleTransitionEnd);\n };\n\n this._container.addEventListener('transitionend', handleTransitionEnd);\n\n this._container.style.opacity = '0';\n }\n\n private _buildContainer(): HTMLElement {\n const container = document.createElement('div');\n\n container.style.display = 'block';\n container.style.bottom = '0';\n container.style.left = '0';\n container.style.height = '100%';\n container.style.width = '100%';\n container.style.position = 'absolute';\n container.style.right = '0';\n container.style.top = '0';\n container.style.transition = 'all 250ms ease-out';\n container.style.opacity = '0';\n\n return container;\n }\n\n private _buildIndicator(): HTMLElement {\n const indicator = document.createElement('div');\n\n indicator.style.display = 'block';\n indicator.style.width = `${this._styles.size}px`;\n indicator.style.height = `${this._styles.size}px`;\n indicator.style.borderRadius = `${this._styles.size}px`;\n indicator.style.border = 'solid 1px';\n indicator.style.borderColor = `${this._styles.backgroundColor} ${this._styles.backgroundColor} ${this._styles.color} ${this._styles.color}`;\n indicator.style.margin = '0 auto';\n indicator.style.position = 'absolute';\n indicator.style.left = '0';\n indicator.style.right = '0';\n indicator.style.top = '50%';\n indicator.style.transform = 'translateY(-50%) rotate(0deg)';\n indicator.style.transformStyle = 'preserve-3d';\n indicator.style.animation = `${ROTATION_ANIMATION} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`;\n\n return indicator;\n }\n\n private _defineAnimation(): void {\n // In order to define CSS animation, we need to insert a stylesheet into the host frame.\n // We only have to do it once.\n if (document.getElementById(ROTATION_ANIMATION)) {\n return;\n }\n\n const style = document.createElement('style');\n\n style.id = ROTATION_ANIMATION;\n\n document.head.appendChild(style);\n\n if (style.sheet instanceof CSSStyleSheet) {\n // We need to provide the 2nd parameter for IE11, even though it is\n // 0 by default for all other browsers.\n style.sheet.insertRule(`\n @keyframes ${ROTATION_ANIMATION} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `, 0);\n }\n }\n}\n","import { IFrameComponent, IFrameOptions } from 'iframe-resizer';\n\nexport {\n HeightCalculationMethod,\n IFrameComponent,\n IFrameMessageData,\n IFrameObject,\n IFrameOptions,\n IFramePage,\n IFramePageOptions,\n IFrameResizedData,\n IFrameScrollData,\n PageInfo,\n WidthCalculationMethod,\n} from 'iframe-resizer';\n\n// The reason why we are wrapping the original `iframeResizer` function imported\n// from the package is because the package sets up event listeners (window\n// resize etc...) as soon as the package is imported. Therefore, to defer the\n// side effect from happening until the function is actually being used, we are\n// importing the package inside this function. To minimise the chance of\n// importing the original package inadvertently, we are also re-exporting all of\n// its public interfaces. The re-exports do not cause any side effect because\n// they are plain TypeScript interfaces; meaning they are only used for type\n// checks rather than for code output.\nexport function iframeResizer(options: IFrameOptions, target: string | HTMLElement): IFrameComponent[] {\n const { iframeResizer: originalIframeResizer } = require('iframe-resizer');\n\n return originalIframeResizer(options, target);\n}\n\n// We also need to wrap the original `iframeResizer.contentWindow` because\n// similarly the package sets up event listeners as soon as the package gets\n// imported. Another reason is that if it is imported at the top level using a\n// regular import statement, it will be stripped out by Webpack as it is\n// considered as \"unused\", unless we explicitly mark it as a package that\n// produces side effects.\nexport function setupContentWindowForIframeResizer(): void {\n /* eslint-disable-next-line import/no-internal-modules */\n require('iframe-resizer/js/iframeResizer.contentWindow');\n}\n","export { embedCheckout } from '../embedded-checkout';\nexport { createEmbeddedCheckoutMessenger } from '../embedded-checkout/iframe-content';\n","import { setPrototypeOf } from '../../utility';\n\nimport CustomError from './custom-error';\n\n/**\n * This error type should not be constructed directly. It is a base class for\n * all custom errors thrown in this library.\n */\nexport default abstract class StandardError extends Error implements CustomError {\n name = 'StandardError';\n type = 'standard';\n\n constructor(message?: string) {\n super(message || 'An unexpected error has occurred.');\n\n setPrototypeOf(this, new.target.prototype);\n\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(this, new.target);\n } else {\n this.stack = (new Error(this.message)).stack;\n }\n }\n}\n","export default function setPrototypeOf(object: any, prototype: object) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(object, prototype);\n } else {\n object.__proto__ = prototype;\n }\n\n return object;\n}\n","import EmbeddedCheckoutError from './embedded-checkout-error';\nimport { EmbeddedContentOptions } from './iframe-content';\n\nexport enum EmbeddedCheckoutEventType {\n CheckoutComplete = 'CHECKOUT_COMPLETE',\n CheckoutError = 'CHECKOUT_ERROR',\n CheckoutLoaded = 'CHECKOUT_LOADED',\n FrameError = 'FRAME_ERROR',\n FrameLoaded = 'FRAME_LOADED',\n SignedOut = 'SIGNED_OUT',\n}\n\nexport interface EmbeddedCheckoutEventMap {\n [EmbeddedCheckoutEventType.CheckoutComplete]: EmbeddedCheckoutCompleteEvent;\n [EmbeddedCheckoutEventType.CheckoutError]: EmbeddedCheckoutErrorEvent;\n [EmbeddedCheckoutEventType.CheckoutLoaded]: EmbeddedCheckoutLoadedEvent;\n [EmbeddedCheckoutEventType.FrameError]: EmbeddedCheckoutFrameErrorEvent;\n [EmbeddedCheckoutEventType.FrameLoaded]: EmbeddedCheckoutFrameLoadedEvent;\n [EmbeddedCheckoutEventType.SignedOut]: EmbeddedCheckoutSignedOutEvent;\n}\n\nexport type EmbeddedCheckoutEvent = (\n EmbeddedCheckoutCompleteEvent |\n EmbeddedCheckoutErrorEvent |\n EmbeddedCheckoutFrameErrorEvent |\n EmbeddedCheckoutFrameLoadedEvent |\n EmbeddedCheckoutLoadedEvent |\n EmbeddedCheckoutSignedOutEvent\n);\n\nexport interface EmbeddedCheckoutCompleteEvent {\n type: EmbeddedCheckoutEventType.CheckoutComplete;\n}\n\nexport interface EmbeddedCheckoutErrorEvent {\n type: EmbeddedCheckoutEventType.CheckoutError;\n payload: EmbeddedCheckoutError;\n}\n\nexport interface EmbeddedCheckoutLoadedEvent {\n type: EmbeddedCheckoutEventType.CheckoutLoaded;\n}\n\nexport interface EmbeddedCheckoutFrameErrorEvent {\n type: EmbeddedCheckoutEventType.FrameError;\n payload: EmbeddedCheckoutError;\n}\n\nexport interface EmbeddedCheckoutFrameLoadedEvent {\n type: EmbeddedCheckoutEventType.FrameLoaded;\n payload?: EmbeddedContentOptions;\n}\n\nexport interface EmbeddedCheckoutSignedOutEvent {\n type: EmbeddedCheckoutEventType.SignedOut;\n}\n","module.exports = require(\"rxjs\");","import { Response } from '@bigcommerce/request-sender';\n\nimport StandardError from './standard-error';\n\nconst DEFAULT_RESPONSE = {\n body: {},\n headers: {},\n status: 0,\n};\n\n/**\n * Throw this error if we are unable to make a request to the server. It wraps\n * any server response into a JS error object.\n */\nexport default class RequestError<TBody = any> extends StandardError {\n body: TBody | {};\n headers: { [key: string]: any };\n errors: Array<{ code: string; message?: string }>;\n status: number;\n\n constructor(\n response?: Response<TBody | {}>,\n { message, errors }: {\n message?: string;\n errors?: Array<{ code: string; message?: string }>;\n } = {}\n ) {\n const { body, headers, status } = response || DEFAULT_RESPONSE;\n\n super(message || 'An unexpected error has occurred.');\n\n this.name = 'RequestError';\n this.type = 'request';\n this.body = body;\n this.headers = headers;\n this.status = status;\n this.errors = errors || [];\n }\n}\n","module.exports = require(\"@bigcommerce/request-sender\");","import { InvalidArgumentError } from '../error/errors';\n\nimport Url from './url';\n\nexport default function parseUrl(url: string): Url {\n if (!/^(https?:)?\\/\\//.test(url)) {\n throw new InvalidArgumentError('The provided URL must be absolute.');\n }\n\n // new URL() is not supported in IE11, use anchor tag instead\n const anchor = document.createElement('a');\n\n anchor.href = url;\n\n // IE11 returns 80 or 443 for the port number depending on the URL scheme,\n // even if the port number is not specified in the URL.\n const port = anchor.port && url.indexOf(`${anchor.hostname}:${anchor.port}`) !== -1 ?\n anchor.port :\n '';\n\n return {\n hash: anchor.hash,\n hostname: anchor.hostname,\n href: anchor.href,\n origin: `${anchor.protocol}//${anchor.hostname}${port ? ':' + port : ''}`,\n pathname: anchor.pathname,\n port,\n protocol: anchor.protocol,\n search: anchor.search,\n };\n}\n","import StandardError from './standard-error';\n\n/**\n * This error should be thrown when a method is unable to proceed because the\n * caller has not provided all the arguments according to their requirements,\n * i.e.: if an argument is missing or it is not the expected data type.\n */\nexport default class InvalidArgumentError extends StandardError {\n constructor(message?: string) {\n super(message || 'Invalid arguments have been provided.');\n\n this.name = 'InvalidArgumentError';\n this.type = 'invalid_argument';\n }\n}\n","import IframeEvent from './iframe-event';\n\nexport default function isIframeEvent<TEvent extends IframeEvent<TType>, TType extends string>(\n object: any,\n type: TType\n): object is TEvent {\n return object.type === type;\n}\n","module.exports = require(\"local-storage-fallback\");","module.exports = require(\"rxjs/operators\");"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"tslib\"","webpack:///./src/embedded-checkout/iframe-content/embedded-content-events.ts","webpack:///./src/common/url/append-www.ts","webpack:///external \"iframe-resizer\"","webpack:///external \"iframe-resizer/js/iframeResizer.contentWindow\"","webpack:///./src/common/iframe/iframe-event-poster.ts","webpack:///./src/common/iframe/iframe-event-listener.ts","webpack:///./src/embedded-checkout/errors/not-embeddable-error.ts","webpack:///./src/common/storage/browser-storage.ts","webpack:///./src/embedded-checkout/errors/invalid-login-token-error.ts","webpack:///./src/embedded-checkout/embedded-checkout.ts","webpack:///./src/embedded-checkout/resizable-iframe-creator.ts","webpack:///./src/embedded-checkout/embed-checkout.ts","webpack:///./src/embedded-checkout/iframe-content/handle-frame-loaded-event.ts","webpack:///./src/common/error/errors/custom-error.ts","webpack:///./src/embedded-checkout/iframe-content/iframe-embedded-checkout-messenger.ts","webpack:///./src/embedded-checkout/iframe-content/noop-embedded-checkout-messenger.ts","webpack:///./src/embedded-checkout/iframe-content/create-embedded-checkout-messenger.ts","webpack:///./src/common/loading-indicator/loading-indicator.ts","webpack:///./src/common/iframe/iframe-resizer.ts","webpack:///./src/bundles/embedded-checkout.ts","webpack:///./src/common/error/errors/standard-error.ts","webpack:///./src/common/utility/set-prototype-of.ts","webpack:///./src/embedded-checkout/embedded-checkout-events.ts","webpack:///external \"rxjs\"","webpack:///./src/common/error/errors/request-error.ts","webpack:///external \"@bigcommerce/request-sender\"","webpack:///./src/common/url/parse-url.ts","webpack:///./src/common/error/errors/invalid-argument-error.ts","webpack:///./src/common/iframe/is-iframe-event.ts","webpack:///external \"local-storage-fallback\"","webpack:///external \"rxjs/operators\"","webpack:///./src/common/utility/bind-decorator.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","require","EmbeddedContentEventType","appendWww","url","hostname","indexOf","href","replace","targetOrigin","_targetWindow","this","_targetOrigin","origin","post","event","options","targetWindow","window","Error","result","pipe","data","type","successType","errorType","toPromise","postMessage","setTarget","sourceOrigin","_sourceOrigins","_isListening","_listeners","listen","addEventListener","_handleMessage","stopListen","removeEventListener","addListener","listener","listeners","push","removeListener","index","splice","trigger","forEach","NotEmbeddableErrorType","_namespace","getItem","rawValue","withNamespace","JSON","parse","error","removeItem","getItemOnce","setItem","stringify","response","message","body","title","subtype","UnknownError","_iframeCreator","_messageListener","_messagePoster","_loadingIndicator","_requestSender","_storage","_location","_options","_isAttached","onComplete","CheckoutComplete","onError","CheckoutError","onLoad","CheckoutLoaded","onFrameLoad","FrameLoaded","onSignOut","SignedOut","_configureStyles","attach","Promise","resolve","show","containerId","_allowCookie","then","_attemptLogin","createFrame","iframe","_iframe","hide","catch","_retryAllowCookie","FrameError","payload","detach","parentNode","removeChild","iFrameResizer","close","contentWindow","styles","StyleConfigured","test","pathname","reject","Date","now","redirectUrl","encodeURIComponent","document","style","visibility","lastAttempt","Number","MissingContent","EmbeddedCheckout","src","container","getElementById","timeout","MissingContainer","createElement","border","display","width","allowPaymentRequest","appendChild","_toResizableFrame","timeoutInterval","setTimeout","handleMessage","teardown","contentId","iframes","scrolling","sizeWidth","heightCalculationMethod","length","clearTimeout","STORAGE_PREFIX","embedCheckout","loadingIndicator","location","handleFrameLoadedEvent","hasAttribute","setAttribute","isCustomError","_untargetedMessagePoster","_messageHandlers","postComplete","_postMessage","postError","_transformError","postFrameError","untargeted","postFrameLoaded","postLoaded","postSignedOut","receiveStyles","handler","_notifyMessageHandlers","keys","undefined","IframeEmbeddedCheckoutMessenger","NoopEmbeddedCheckoutMessenger","createEmbeddedCheckoutMessenger","parentWindow","parent","parentOrigin","DEFAULT_STYLES","size","color","backgroundColor","ROTATION_ANIMATION","_styles","_defineAnimation","_container","_buildContainer","_indicator","_buildIndicator","parentId","opacity","handleTransitionEnd","bottom","left","height","position","right","top","transition","indicator","borderRadius","borderColor","margin","transform","transformStyle","animation","id","head","sheet","CSSStyleSheet","insertRule","iframeResizer","target","originalIframeResizer","setupContentWindowForIframeResizer","setPrototypeOf","__proto__","captureStackTrace","stack","EmbeddedCheckoutEventType","DEFAULT_RESPONSE","headers","status","errors","parseUrl","anchor","port","hash","protocol","search","isIframeEvent","bindMethodDecorator","_","descriptor","method","boundMethod","set","decoratedTarget","getOwnPropertyNames","getOwnPropertyDescriptor","bindClassDecorator"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBq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EAAK+O,GASrC,SAA2DrB,GAC9D,IAAMyB,EAAe,YAAG,a,+CAAsB,OAAR,yBAAQ,EAAzB,CAAiBzB,GAiBtC,OAfAvO,OAAOiQ,oBAAoB1B,EAAOrN,WAC7BiD,SAAQ,SAAAtD,GACL,IAAM+O,EAAa5P,OAAOkQ,yBAAyB3B,EAAOrN,UAAWL,GAEhE+O,GAAsB,gBAAR/O,GAInBb,OAAOC,eACH+P,EAAgB9O,UAChBL,EACA6O,EAAoBnB,EAAOrN,UAAWL,EAAK+O,OAIhDI,EA9BIG,CAAmB5B","file":"embedded-checkout.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 206);\n","module.exports = require(\"tslib\");","import EmbeddedCheckoutStyles from '../embedded-checkout-styles';\n\nexport enum EmbeddedContentEventType {\n StyleConfigured = 'STYLE_CONFIGURED',\n}\n\nexport interface EmbeddedContentEventMap {\n [EmbeddedContentEventType.StyleConfigured]: EmbeddedContentStyleConfiguredEvent;\n}\n\nexport type EmbeddedContentEvent = (\n EmbeddedContentStyleConfiguredEvent\n);\n\nexport interface EmbeddedContentStyleConfiguredEvent {\n type: EmbeddedContentEventType.StyleConfigured;\n payload: EmbeddedCheckoutStyles;\n}\n","import parseUrl from './parse-url';\nimport Url from './url';\n\nexport default function appendWww(url: Url): Url {\n return parseUrl(\n url.hostname.indexOf('www') === 0 ?\n url.href :\n url.href.replace(url.hostname, `www.${url.hostname}`)\n );\n}\n","module.exports = require(\"iframe-resizer\");","module.exports = require(\"iframe-resizer/js/iframeResizer.contentWindow\");","import { fromEvent } from 'rxjs';\nimport { filter, map, take } from 'rxjs/operators';\n\nimport { parseUrl } from '../url';\n\nimport IframeEvent from './iframe-event';\nimport isIframeEvent from './is-iframe-event';\n\nexport interface IframeEventPostOptions<TSuccessEvent extends IframeEvent, TErrorEvent extends IframeEvent> {\n errorType?: TErrorEvent['type'];\n successType?: TSuccessEvent['type'];\n}\n\nexport default class IframeEventPoster<TEvent> {\n private _targetOrigin: string;\n\n constructor(\n targetOrigin: string,\n private _targetWindow?: Window\n ) {\n this._targetOrigin = targetOrigin === '*' ? '*' : parseUrl(targetOrigin).origin;\n }\n\n post(event: TEvent): void;\n post<TSuccessEvent extends IframeEvent = IframeEvent, TErrorEvent extends IframeEvent = IframeEvent>(\n event: TEvent,\n options: IframeEventPostOptions<TSuccessEvent, TErrorEvent>\n ): Promise<TSuccessEvent>;\n post<TSuccessEvent extends IframeEvent = IframeEvent, TErrorEvent extends IframeEvent = IframeEvent>(\n event: TEvent,\n options?: IframeEventPostOptions<TSuccessEvent, TErrorEvent>\n ): Promise<TSuccessEvent> | void {\n const targetWindow = this._targetWindow;\n\n if (window === targetWindow) {\n return;\n }\n\n if (!targetWindow) {\n throw new Error('Unable to post message because target window is not set.');\n }\n\n const result = options && fromEvent<MessageEvent>(window, 'message')\n .pipe(\n filter(event =>\n event.origin === this._targetOrigin &&\n isIframeEvent(event.data, event.data.type) &&\n [options.successType, options.errorType].indexOf(event.data.type) !== -1\n ),\n map(event => {\n if (options.errorType === event.data.type) {\n throw event.data;\n }\n\n return event.data;\n }),\n take(1)\n )\n .toPromise();\n\n targetWindow.postMessage(event, this._targetOrigin);\n\n return result;\n }\n\n setTarget(window: Window) {\n this._targetWindow = window;\n }\n}\n","import { appendWww, parseUrl } from '../url';\nimport { bindDecorator as bind } from '../utility';\n\nimport { IframeEventMap } from './iframe-event';\nimport isIframeEvent from './is-iframe-event';\n\nexport default class IframeEventListener<TEventMap extends IframeEventMap<keyof TEventMap>> {\n private _isListening: boolean;\n private _listeners: EventListeners<TEventMap>;\n private _sourceOrigins: string[];\n\n constructor(\n sourceOrigin: string\n ) {\n this._sourceOrigins = [\n parseUrl(sourceOrigin).origin,\n appendWww(parseUrl(sourceOrigin)).origin,\n ];\n this._isListening = false;\n this._listeners = {};\n }\n\n listen(): void {\n if (this._isListening) {\n return;\n }\n\n this._isListening = true;\n\n window.addEventListener('message', this._handleMessage);\n }\n\n stopListen(): void {\n if (!this._isListening) {\n return;\n }\n\n this._isListening = false;\n\n window.removeEventListener('message', this._handleMessage);\n }\n\n addListener<TType extends keyof TEventMap>(type: TType, listener: (event: TEventMap[TType]) => void): void {\n let listeners = this._listeners[type];\n\n if (!listeners) {\n this._listeners[type] = listeners = [];\n }\n\n if (listeners.indexOf(listener) === -1) {\n listeners.push(listener);\n }\n }\n\n removeListener<TType extends keyof TEventMap>(type: TType, listener: (event: TEventMap[TType]) => void): void {\n const listeners = this._listeners[type];\n\n if (!listeners) {\n return;\n }\n\n const index = listeners.indexOf(listener);\n\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n }\n\n trigger<TType extends keyof TEventMap>(event: TEventMap[TType]): void {\n const listeners = this._listeners[event.type];\n\n if (!listeners) {\n return;\n }\n\n listeners.forEach(listener => listener(event));\n }\n\n @bind\n private _handleMessage(event: MessageEvent): void {\n if ((this._sourceOrigins.indexOf(event.origin) === -1) ||\n !isIframeEvent(event.data as TEventMap[keyof TEventMap], event.data.type)\n ) {\n return;\n }\n\n this.trigger(event.data);\n }\n}\n\ntype EventListeners<TEventMap> = {\n [key in keyof TEventMap]?: Array<(event: TEventMap[key]) => void>;\n};\n","import { StandardError } from '../../common/error/errors';\n\nexport enum NotEmbeddableErrorType {\n MissingContainer = 'missing_container',\n MissingContent = 'missing_content',\n UnknownError = 'unknown_error',\n}\n\n/**\n * Throw this error if we are not able to embed the checkout form as an iframe.\n * This can be due to the fact that the provided container ID is invalid, or the\n * checkout form fails to load inside the iframe. It can also be due to an\n * unknown reason.\n */\nexport default class NotEmbeddableError extends StandardError {\n constructor(\n message?: string,\n public subtype: NotEmbeddableErrorType = NotEmbeddableErrorType.UnknownError\n ) {\n super(message || 'Unable to embed the checkout form.');\n\n this.name = 'NotEmbeddableError';\n this.type = 'not_embeddable';\n }\n}\n","import { default as storage } from 'local-storage-fallback';\n\nexport default class BrowserStorage {\n constructor(\n private _namespace: string\n ) {}\n\n getItem<TValue = any>(key: string): TValue | null {\n const rawValue = storage.getItem(this.withNamespace(key));\n\n if (rawValue === null) {\n return null;\n }\n\n try {\n return JSON.parse(rawValue);\n } catch (error) {\n // Clean up invalid values\n this.removeItem(this.withNamespace(key));\n\n return null;\n }\n }\n\n getItemOnce<TValue = any>(key: string): TValue | null {\n const value = this.getItem(key);\n\n this.removeItem(key);\n\n return value;\n }\n\n setItem<TValue = any>(key: string, value: TValue): void {\n return storage.setItem(this.withNamespace(key), JSON.stringify(value));\n }\n\n removeItem(key: string): void {\n return storage.removeItem(this.withNamespace(key));\n }\n\n private withNamespace(key: string): string {\n return `${this._namespace}.${key}`;\n }\n}\n","import { Response } from '@bigcommerce/request-sender';\n\nimport { InternalErrorResponseBody } from '../../common/error';\nimport { RequestError } from '../../common/error/errors';\n\n/**\n * Throw this error we are not able to sign in a shopper because the provided\n * login token is invalid.\n */\nexport default class InvalidLoginTokenError extends RequestError {\n constructor(response: Response<InternalErrorResponseBody>) {\n super(response, { message: response.body.title });\n\n this.name = 'InvalidLoginTokenError';\n this.type = 'invalid_login_token';\n }\n}\n","import { RequestSender } from '@bigcommerce/request-sender';\n\nimport { IframeEventListener, IframeEventPoster, IFrameComponent } from '../common/iframe';\nimport { LoadingIndicator } from '../common/loading-indicator';\nimport { BrowserStorage } from '../common/storage';\nimport { parseUrl } from '../common/url';\nimport { bindDecorator as bind } from '../common/utility';\n\nimport EmbeddedCheckoutError from './embedded-checkout-error';\nimport { EmbeddedCheckoutEventMap, EmbeddedCheckoutEventType } from './embedded-checkout-events';\nimport EmbeddedCheckoutOptions from './embedded-checkout-options';\nimport { InvalidLoginTokenError, NotEmbeddableError, NotEmbeddableErrorType } from './errors';\nimport { EmbeddedContentEvent, EmbeddedContentEventType } from './iframe-content';\nimport ResizableIframeCreator from './resizable-iframe-creator';\n\nexport const ALLOW_COOKIE_ATTEMPT_INTERVAL = 10 * 60 * 1000;\nexport const IS_COOKIE_ALLOWED_KEY = 'isCookieAllowed';\nexport const LAST_ALLOW_COOKIE_ATTEMPT_KEY = 'lastAllowCookieAttempt';\n\n@bind\nexport default class EmbeddedCheckout {\n private _iframe?: IFrameComponent;\n private _isAttached: boolean;\n\n /**\n * @internal\n */\n constructor(\n private _iframeCreator: ResizableIframeCreator,\n private _messageListener: IframeEventListener<EmbeddedCheckoutEventMap>,\n private _messagePoster: IframeEventPoster<EmbeddedContentEvent>,\n private _loadingIndicator: LoadingIndicator,\n private _requestSender: RequestSender,\n private _storage: BrowserStorage,\n private _location: Location,\n private _options: EmbeddedCheckoutOptions\n ) {\n this._isAttached = false;\n\n if (this._options.onComplete) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.CheckoutComplete, this._options.onComplete);\n }\n\n if (this._options.onError) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.CheckoutError, this._options.onError);\n }\n\n if (this._options.onLoad) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.CheckoutLoaded, this._options.onLoad);\n }\n\n if (this._options.onFrameLoad) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.FrameLoaded, this._options.onFrameLoad);\n }\n\n if (this._options.onSignOut) {\n this._messageListener.addListener(EmbeddedCheckoutEventType.SignedOut, this._options.onSignOut);\n }\n\n this._messageListener.addListener(EmbeddedCheckoutEventType.FrameLoaded, () => this._configureStyles());\n }\n\n attach(): Promise<this> {\n if (this._isAttached) {\n return Promise.resolve(this);\n }\n\n this._isAttached = true;\n this._messageListener.listen();\n this._loadingIndicator.show(this._options.containerId);\n\n return this._allowCookie()\n .then(() => this._attemptLogin())\n .then(url => this._iframeCreator.createFrame(url, this._options.containerId))\n .then(iframe => {\n this._iframe = iframe;\n\n this._configureStyles();\n this._loadingIndicator.hide();\n })\n .catch(error => {\n this._isAttached = false;\n\n return this._retryAllowCookie(error)\n .catch(() => {\n this._messageListener.trigger({\n type: EmbeddedCheckoutEventType.FrameError,\n payload: error,\n });\n\n this._loadingIndicator.hide();\n\n throw error;\n });\n })\n .then(() => this);\n }\n\n detach(): void {\n if (!this._isAttached) {\n return;\n }\n\n this._isAttached = false;\n this._messageListener.stopListen();\n\n if (this._iframe && this._iframe.parentNode) {\n this._iframe.parentNode.removeChild(this._iframe);\n this._iframe.iFrameResizer.close();\n }\n }\n\n private _configureStyles(): void {\n if (!this._iframe || !this._iframe.contentWindow || !this._options.styles) {\n return;\n }\n\n this._messagePoster.setTarget(this._iframe.contentWindow);\n\n this._messagePoster.post({\n type: EmbeddedContentEventType.StyleConfigured,\n payload: this._options.styles,\n });\n }\n\n private _attemptLogin(): Promise<string> {\n if (!/^\\/login\\/token/.test(parseUrl(this._options.url).pathname)) {\n return Promise.resolve(this._options.url);\n }\n\n return this._requestSender.post<{ redirectUrl: string }>(this._options.url)\n .then(({ body: { redirectUrl } }) => redirectUrl)\n .catch(response => Promise.reject(new InvalidLoginTokenError(response)));\n }\n\n /**\n * This workaround is required for certain browsers (namely Safari) that\n * prevent session cookies to be set for a third party website unless the\n * user has recently visited such website. Therefore, before we attempt to\n * login or set an active cart in the session, we need to first redirect the\n * user to the domain of Embedded Checkout.\n */\n private _allowCookie(): Promise<void> {\n if (this._storage.getItem(IS_COOKIE_ALLOWED_KEY)) {\n return Promise.resolve();\n }\n\n this._storage.setItem(IS_COOKIE_ALLOWED_KEY, true);\n\n // It could be possible that the flag is set to true but the browser has\n // already removed the permission to store third-party cookies. In that\n // case, we should try to redirect the user again. But we only want to\n // do it once within a fixed interval. This is to avoid getting into a\n // redirect loop if the shopper actually doesn't have a valid card\n // session.\n this._storage.setItem(LAST_ALLOW_COOKIE_ATTEMPT_KEY, Date.now());\n\n const { origin } = parseUrl(this._options.url);\n const redirectUrl = `${origin}/embedded-checkout/allow-cookie?returnUrl=${encodeURIComponent(this._location.href)}`;\n\n document.body.style.visibility = 'hidden';\n this._location.replace(redirectUrl);\n\n return new Promise<never>(() => {});\n }\n\n private _retryAllowCookie(error: EmbeddedCheckoutError): Promise<void> {\n const lastAttempt = Number(this._storage.getItem(LAST_ALLOW_COOKIE_ATTEMPT_KEY));\n const canRetry = (\n (!lastAttempt || Date.now() - lastAttempt > ALLOW_COOKIE_ATTEMPT_INTERVAL) &&\n error instanceof NotEmbeddableError &&\n error.subtype === NotEmbeddableErrorType.MissingContent\n );\n\n if (!canRetry) {\n return Promise.reject();\n }\n\n this._storage.removeItem(LAST_ALLOW_COOKIE_ATTEMPT_KEY);\n this._storage.removeItem(IS_COOKIE_ALLOWED_KEY);\n\n return this._allowCookie();\n }\n}\n","import { iframeResizer, isIframeEvent, IFrameComponent } from '../common/iframe';\nimport { parseUrl } from '../common/url';\n\nimport { EmbeddedCheckoutEventType } from './embedded-checkout-events';\nimport { NotEmbeddableError, NotEmbeddableErrorType } from './errors';\n\nexport default class ResizableIframeCreator {\n constructor(\n private _options?: { timeout: number }\n ) {}\n\n createFrame(src: string, containerId: string): Promise<IFrameComponent> {\n const container = document.getElementById(containerId);\n const { timeout = 60000 } = this._options || {};\n\n if (!container) {\n throw new NotEmbeddableError(\n 'Unable to embed the iframe because the container element could not be found.',\n NotEmbeddableErrorType.MissingContainer\n );\n }\n\n const iframe = document.createElement('iframe');\n\n iframe.src = src;\n iframe.style.border = 'none';\n iframe.style.display = 'none';\n iframe.style.width = '100%';\n iframe.allowPaymentRequest = true;\n\n container.appendChild(iframe);\n\n return this._toResizableFrame(iframe, timeout)\n .catch(error => {\n container.removeChild(iframe);\n\n throw error;\n });\n }\n\n private _toResizableFrame(iframe: HTMLIFrameElement, timeoutInterval: number): Promise<IFrameComponent> {\n // Can't simply listen to `load` event because it always gets triggered even if there's an error.\n // Instead, listen to the `load` inside the iframe and let the parent frame know when it happens.\n return new Promise((resolve, reject) => {\n const timeout = window.setTimeout(() => {\n reject(new NotEmbeddableError('Unable to embed the iframe because the content could not be loaded.'));\n }, timeoutInterval);\n\n const handleMessage = (event: MessageEvent) => {\n if (event.origin !== parseUrl(iframe.src).origin) {\n return;\n }\n\n if (isIframeEvent(event.data, EmbeddedCheckoutEventType.FrameError)) {\n teardown();\n reject(new NotEmbeddableError(event.data.payload.message, NotEmbeddableErrorType.MissingContent));\n }\n\n if (isIframeEvent(event.data, EmbeddedCheckoutEventType.FrameLoaded)) {\n iframe.style.display = '';\n\n const contentId = event.data.payload && event.data.payload.contentId;\n const iframes = iframeResizer({\n scrolling: false,\n sizeWidth: false,\n heightCalculationMethod: contentId ? 'taggedElement' : 'lowestElement',\n }, iframe);\n\n teardown();\n resolve(iframes[iframes.length - 1]);\n }\n };\n\n const teardown = () => {\n window.removeEventListener('message', handleMessage);\n window.clearTimeout(timeout);\n };\n\n window.addEventListener('message', handleMessage);\n });\n }\n}\n","import { createRequestSender } from '@bigcommerce/request-sender';\n\nimport { IframeEventListener, IframeEventPoster } from '../common/iframe';\nimport { LoadingIndicator } from '../common/loading-indicator';\nimport { BrowserStorage } from '../common/storage';\nimport { parseUrl } from '../common/url';\n\nimport EmbeddedCheckout from './embedded-checkout';\nimport { EmbeddedCheckoutEventMap } from './embedded-checkout-events';\nimport EmbeddedCheckoutOptions from './embedded-checkout-options';\nimport { EmbeddedContentEvent } from './iframe-content';\nimport ResizableIframeCreator from './resizable-iframe-creator';\n\nconst STORAGE_PREFIX = 'BigCommerce.EmbeddedCheckout';\n\n/**\n * Embed the checkout form in an iframe.\n *\n * @remarks\n * Once the iframe is embedded, it will automatically resize according to the\n * size of the checkout form. It will also notify the parent window when certain\n * events have occurred. i.e.: when the form is loaded and ready to be used.\n *\n * ```js\n * embedCheckout({\n * url: 'https://checkout/url',\n * containerId: 'container-id',\n * });\n * ```\n *\n * @param options - Options for embedding the checkout form.\n * @returns A promise that resolves to an instance of `EmbeddedCheckout`.\n */\nexport default function embedCheckout(options: EmbeddedCheckoutOptions): Promise<EmbeddedCheckout> {\n const origin = parseUrl(options.url).origin;\n const embeddedCheckout = new EmbeddedCheckout(\n new ResizableIframeCreator(),\n new IframeEventListener<EmbeddedCheckoutEventMap>(origin),\n new IframeEventPoster<EmbeddedContentEvent>(origin),\n new LoadingIndicator({ styles: options.styles && options.styles.loadingIndicator }),\n createRequestSender(),\n new BrowserStorage(STORAGE_PREFIX),\n window.location,\n options\n );\n\n return embeddedCheckout.attach();\n}\n","import { EmbeddedCheckoutFrameLoadedEvent } from '../embedded-checkout-events';\n\nexport default function handleFrameLoadedEvent(message: EmbeddedCheckoutFrameLoadedEvent): void {\n if (!message.payload || !message.payload.contentId) {\n return;\n }\n\n const body = document.getElementById(message.payload.contentId);\n\n if (!body || body.hasAttribute('data-iframe-height')) {\n return;\n }\n\n body.setAttribute('data-iframe-height', '');\n}\n","export default interface CustomError extends Error {\n message: string;\n type: string;\n subtype?: string;\n}\n\nexport function isCustomError(error: any): error is CustomError {\n return (\n typeof error.message === 'string' &&\n typeof error.type === 'string' &&\n (typeof error.subtype === 'string' || !error.subtype) &&\n error instanceof Error\n );\n}\n","import { isCustomError, CustomError } from '../../common/error/errors';\nimport { IframeEventListener, IframeEventPoster } from '../../common/iframe';\nimport { bindDecorator as bind } from '../../common/utility';\nimport EmbeddedCheckoutError from '../embedded-checkout-error';\nimport { EmbeddedCheckoutCompleteEvent, EmbeddedCheckoutErrorEvent, EmbeddedCheckoutEvent, EmbeddedCheckoutEventMap, EmbeddedCheckoutEventType, EmbeddedCheckoutFrameErrorEvent, EmbeddedCheckoutFrameLoadedEvent, EmbeddedCheckoutLoadedEvent, EmbeddedCheckoutSignedOutEvent } from '../embedded-checkout-events';\nimport EmbeddedCheckoutStyles from '../embedded-checkout-styles';\n\nimport EmbeddedCheckoutMessenger from './embedded-checkout-messenger';\nimport { EmbeddedContentEventMap, EmbeddedContentEventType } from './embedded-content-events';\nimport EmbeddedContentOptions from './embedded-content-options';\n\n@bind\nexport default class IframeEmbeddedCheckoutMessenger implements EmbeddedCheckoutMessenger {\n /**\n * @internal\n */\n constructor(\n private _messageListener: IframeEventListener<EmbeddedContentEventMap>,\n private _messagePoster: IframeEventPoster<EmbeddedCheckoutEvent>,\n private _untargetedMessagePoster: IframeEventPoster<EmbeddedCheckoutEvent>,\n private _messageHandlers: EventCallbacks<EmbeddedCheckoutEventMap> = {}\n ) {\n this._messageListener.listen();\n }\n\n postComplete(): void {\n const message: EmbeddedCheckoutCompleteEvent = {\n type: EmbeddedCheckoutEventType.CheckoutComplete,\n };\n\n this._postMessage(message);\n }\n\n postError(payload: Error | CustomError): void {\n const message: EmbeddedCheckoutErrorEvent = {\n type: EmbeddedCheckoutEventType.CheckoutError,\n payload: this._transformError(payload),\n };\n\n this._postMessage(message);\n }\n\n postFrameError(payload: Error | CustomError): void {\n const message: EmbeddedCheckoutFrameErrorEvent = {\n type: EmbeddedCheckoutEventType.FrameError,\n payload: this._transformError(payload),\n };\n\n // Ideally, all messages should be targeted at a specific origin.\n // However, for `FrameError` message, we have to post it in an\n // untargeted fashion. This is because the error could be caused by a\n // missing cart. That makes it not possible to determine of site origin\n // of the parent window. Nevertheless, we still want to notify the\n // parent window about the error.\n this._postMessage(message, { untargeted: true });\n }\n\n postFrameLoaded(payload?: EmbeddedContentOptions): void {\n const message: EmbeddedCheckoutFrameLoadedEvent = {\n type: EmbeddedCheckoutEventType.FrameLoaded,\n payload,\n };\n\n this._postMessage(message);\n }\n\n postLoaded(): void {\n const message: EmbeddedCheckoutLoadedEvent = {\n type: EmbeddedCheckoutEventType.CheckoutLoaded,\n };\n\n this._postMessage(message);\n }\n\n postSignedOut(): void {\n const message: EmbeddedCheckoutSignedOutEvent = {\n type: EmbeddedCheckoutEventType.SignedOut,\n };\n\n this._postMessage(message);\n }\n\n receiveStyles(handler: (styles: EmbeddedCheckoutStyles) => void): void {\n this._messageListener.addListener(EmbeddedContentEventType.StyleConfigured, ({ payload }) => {\n handler(payload);\n });\n }\n\n private _postMessage(message: EmbeddedCheckoutEvent, options?: { untargeted?: boolean }): void {\n this._notifyMessageHandlers(message);\n\n if (options && options.untargeted) {\n return this._untargetedMessagePoster.post(message);\n }\n\n this._messagePoster.post(message);\n }\n\n private _notifyMessageHandlers(message: EmbeddedCheckoutEvent): void {\n Object.keys(this._messageHandlers)\n .forEach(key => {\n if (message.type !== key) {\n return;\n }\n\n const handler = this._messageHandlers[key];\n\n if (handler) {\n (handler as (event: EmbeddedCheckoutEvent) => void).call(null, message);\n }\n });\n }\n\n private _transformError(error: Error | CustomError): EmbeddedCheckoutError {\n return {\n message: error.message,\n type: isCustomError(error) ? error.type : undefined,\n subtype: isCustomError(error) ? error.subtype : undefined,\n };\n }\n}\n\nexport type EventCallbacks<TEventMap> = {\n [key in keyof TEventMap]?: (event: TEventMap[key]) => void;\n};\n","import { bindDecorator as bind } from '../../common/utility';\n\nimport EmbeddedCheckoutMessenger from './embedded-checkout-messenger';\n\n@bind\nexport default class NoopEmbeddedCheckoutMessenger implements EmbeddedCheckoutMessenger {\n postComplete(): void {}\n\n postError(): void {}\n\n postFrameError(): void {}\n\n postFrameLoaded(): void {}\n\n postLoaded(): void {}\n\n postSignedOut(): void {}\n\n receiveStyles(): void {}\n}\n","import { setupContentWindowForIframeResizer, IframeEventListener, IframeEventPoster } from '../../common/iframe';\nimport { EmbeddedCheckoutEvent, EmbeddedCheckoutEventType } from '../embedded-checkout-events';\n\nimport EmbeddedCheckoutMessenger from './embedded-checkout-messenger';\nimport EmbeddedCheckoutMessengerOptions from './embedded-checkout-messenger-options';\nimport { EmbeddedContentEventMap } from './embedded-content-events';\nimport handleFrameLoadedEvent from './handle-frame-loaded-event';\nimport IframeEmbeddedCheckoutMessenger from './iframe-embedded-checkout-messenger';\nimport NoopEmbeddedCheckoutMessenger from './noop-embedded-checkout-messenger';\n\n/**\n * Create an instance of `EmbeddedCheckoutMessenger`.\n *\n * @remarks\n * The object is responsible for posting messages to the parent window from the\n * iframe when certain events have occurred. For example, when the checkout\n * form is first loaded, you should notify the parent window about it.\n *\n * The iframe can only be embedded in domains that are allowed by the store.\n *\n * ```ts\n * const messenger = createEmbeddedCheckoutMessenger({\n * parentOrigin: 'https://some/website',\n * });\n *\n * messenger.postFrameLoaded();\n * ```\n *\n * @alpha\n * Please note that this feature is currently in an early stage of development.\n * Therefore the API is unstable and not ready for public consumption.\n *\n * @param options - Options for creating `EmbeddedCheckoutMessenger`\n * @returns - An instance of `EmbeddedCheckoutMessenger`\n */\nexport default function createEmbeddedCheckoutMessenger(options: EmbeddedCheckoutMessengerOptions): EmbeddedCheckoutMessenger {\n setupContentWindowForIframeResizer();\n\n const parentWindow = options.parentWindow || window.parent;\n\n // Return a No-op messenger if it is not called inside an iframe\n if (window === parentWindow) {\n return new NoopEmbeddedCheckoutMessenger();\n }\n\n return new IframeEmbeddedCheckoutMessenger(\n new IframeEventListener<EmbeddedContentEventMap>(options.parentOrigin),\n new IframeEventPoster<EmbeddedCheckoutEvent>(options.parentOrigin, parentWindow),\n new IframeEventPoster<EmbeddedCheckoutEvent>('*', parentWindow),\n { [EmbeddedCheckoutEventType.FrameLoaded]: handleFrameLoadedEvent }\n );\n}\n","import { LoadingIndicatorStyles } from './loading-indicator-styles';\n\nconst DEFAULT_STYLES: LoadingIndicatorStyles = {\n size: 70,\n color: '#d9d9d9',\n backgroundColor: '#ffffff',\n};\n\nconst ROTATION_ANIMATION = 'embedded-checkout-loading-indicator-rotation';\n\nexport default class LoadingIndicator {\n private _container: HTMLElement;\n private _indicator: HTMLElement;\n private _styles: LoadingIndicatorStyles;\n\n constructor(\n options?: { styles?: LoadingIndicatorStyles }\n ) {\n this._styles = { ...DEFAULT_STYLES, ...options && options.styles };\n\n this._defineAnimation();\n\n this._container = this._buildContainer();\n this._indicator = this._buildIndicator();\n\n this._container.appendChild(this._indicator);\n }\n\n show(parentId?: string): void {\n if (parentId) {\n const parent = document.getElementById(parentId);\n\n if (!parent) {\n throw new Error('Unable to attach the loading indicator because the parent ID is not valid.');\n }\n\n parent.appendChild(this._container);\n }\n\n this._container.style.visibility = 'visible';\n this._container.style.opacity = '1';\n }\n\n hide(): void {\n const handleTransitionEnd = () => {\n this._container.style.visibility = 'hidden';\n\n this._container.removeEventListener('transitionend', handleTransitionEnd);\n };\n\n this._container.addEventListener('transitionend', handleTransitionEnd);\n\n this._container.style.opacity = '0';\n }\n\n private _buildContainer(): HTMLElement {\n const container = document.createElement('div');\n\n container.style.display = 'block';\n container.style.bottom = '0';\n container.style.left = '0';\n container.style.height = '100%';\n container.style.width = '100%';\n container.style.position = 'absolute';\n container.style.right = '0';\n container.style.top = '0';\n container.style.transition = 'all 250ms ease-out';\n container.style.opacity = '0';\n\n return container;\n }\n\n private _buildIndicator(): HTMLElement {\n const indicator = document.createElement('div');\n\n indicator.style.display = 'block';\n indicator.style.width = `${this._styles.size}px`;\n indicator.style.height = `${this._styles.size}px`;\n indicator.style.borderRadius = `${this._styles.size}px`;\n indicator.style.border = 'solid 1px';\n indicator.style.borderColor = `${this._styles.backgroundColor} ${this._styles.backgroundColor} ${this._styles.color} ${this._styles.color}`;\n indicator.style.margin = '0 auto';\n indicator.style.position = 'absolute';\n indicator.style.left = '0';\n indicator.style.right = '0';\n indicator.style.top = '50%';\n indicator.style.transform = 'translateY(-50%) rotate(0deg)';\n indicator.style.transformStyle = 'preserve-3d';\n indicator.style.animation = `${ROTATION_ANIMATION} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`;\n\n return indicator;\n }\n\n private _defineAnimation(): void {\n // In order to define CSS animation, we need to insert a stylesheet into the host frame.\n // We only have to do it once.\n if (document.getElementById(ROTATION_ANIMATION)) {\n return;\n }\n\n const style = document.createElement('style');\n\n style.id = ROTATION_ANIMATION;\n\n document.head.appendChild(style);\n\n if (style.sheet instanceof CSSStyleSheet) {\n // We need to provide the 2nd parameter for IE11, even though it is\n // 0 by default for all other browsers.\n style.sheet.insertRule(`\n @keyframes ${ROTATION_ANIMATION} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `, 0);\n }\n }\n}\n","import { IFrameComponent, IFrameOptions } from 'iframe-resizer';\n\nexport {\n HeightCalculationMethod,\n IFrameComponent,\n IFrameMessageData,\n IFrameObject,\n IFrameOptions,\n IFramePage,\n IFramePageOptions,\n IFrameResizedData,\n IFrameScrollData,\n PageInfo,\n WidthCalculationMethod,\n} from 'iframe-resizer';\n\n// The reason why we are wrapping the original `iframeResizer` function imported\n// from the package is because the package sets up event listeners (window\n// resize etc...) as soon as the package is imported. Therefore, to defer the\n// side effect from happening until the function is actually being used, we are\n// importing the package inside this function. To minimise the chance of\n// importing the original package inadvertently, we are also re-exporting all of\n// its public interfaces. The re-exports do not cause any side effect because\n// they are plain TypeScript interfaces; meaning they are only used for type\n// checks rather than for code output.\nexport function iframeResizer(options: IFrameOptions, target: string | HTMLElement): IFrameComponent[] {\n const { iframeResizer: originalIframeResizer } = require('iframe-resizer');\n\n return originalIframeResizer(options, target);\n}\n\n// We also need to wrap the original `iframeResizer.contentWindow` because\n// similarly the package sets up event listeners as soon as the package gets\n// imported. Another reason is that if it is imported at the top level using a\n// regular import statement, it will be stripped out by Webpack as it is\n// considered as \"unused\", unless we explicitly mark it as a package that\n// produces side effects.\nexport function setupContentWindowForIframeResizer(): void {\n /* eslint-disable-next-line import/no-internal-modules */\n require('iframe-resizer/js/iframeResizer.contentWindow');\n}\n","export { embedCheckout } from '../embedded-checkout';\nexport { createEmbeddedCheckoutMessenger } from '../embedded-checkout/iframe-content';\n","import { setPrototypeOf } from '../../utility';\n\nimport CustomError from './custom-error';\n\n/**\n * This error type should not be constructed directly. It is a base class for\n * all custom errors thrown in this library.\n */\nexport default abstract class StandardError extends Error implements CustomError {\n name = 'StandardError';\n type = 'standard';\n\n constructor(message?: string) {\n super(message || 'An unexpected error has occurred.');\n\n setPrototypeOf(this, new.target.prototype);\n\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(this, new.target);\n } else {\n this.stack = (new Error(this.message)).stack;\n }\n }\n}\n","export default function setPrototypeOf(object: any, prototype: object) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(object, prototype);\n } else {\n object.__proto__ = prototype;\n }\n\n return object;\n}\n","import EmbeddedCheckoutError from './embedded-checkout-error';\nimport { EmbeddedContentOptions } from './iframe-content';\n\nexport enum EmbeddedCheckoutEventType {\n CheckoutComplete = 'CHECKOUT_COMPLETE',\n CheckoutError = 'CHECKOUT_ERROR',\n CheckoutLoaded = 'CHECKOUT_LOADED',\n FrameError = 'FRAME_ERROR',\n FrameLoaded = 'FRAME_LOADED',\n SignedOut = 'SIGNED_OUT',\n}\n\nexport interface EmbeddedCheckoutEventMap {\n [EmbeddedCheckoutEventType.CheckoutComplete]: EmbeddedCheckoutCompleteEvent;\n [EmbeddedCheckoutEventType.CheckoutError]: EmbeddedCheckoutErrorEvent;\n [EmbeddedCheckoutEventType.CheckoutLoaded]: EmbeddedCheckoutLoadedEvent;\n [EmbeddedCheckoutEventType.FrameError]: EmbeddedCheckoutFrameErrorEvent;\n [EmbeddedCheckoutEventType.FrameLoaded]: EmbeddedCheckoutFrameLoadedEvent;\n [EmbeddedCheckoutEventType.SignedOut]: EmbeddedCheckoutSignedOutEvent;\n}\n\nexport type EmbeddedCheckoutEvent = (\n EmbeddedCheckoutCompleteEvent |\n EmbeddedCheckoutErrorEvent |\n EmbeddedCheckoutFrameErrorEvent |\n EmbeddedCheckoutFrameLoadedEvent |\n EmbeddedCheckoutLoadedEvent |\n EmbeddedCheckoutSignedOutEvent\n);\n\nexport interface EmbeddedCheckoutCompleteEvent {\n type: EmbeddedCheckoutEventType.CheckoutComplete;\n}\n\nexport interface EmbeddedCheckoutErrorEvent {\n type: EmbeddedCheckoutEventType.CheckoutError;\n payload: EmbeddedCheckoutError;\n}\n\nexport interface EmbeddedCheckoutLoadedEvent {\n type: EmbeddedCheckoutEventType.CheckoutLoaded;\n}\n\nexport interface EmbeddedCheckoutFrameErrorEvent {\n type: EmbeddedCheckoutEventType.FrameError;\n payload: EmbeddedCheckoutError;\n}\n\nexport interface EmbeddedCheckoutFrameLoadedEvent {\n type: EmbeddedCheckoutEventType.FrameLoaded;\n payload?: EmbeddedContentOptions;\n}\n\nexport interface EmbeddedCheckoutSignedOutEvent {\n type: EmbeddedCheckoutEventType.SignedOut;\n}\n","module.exports = require(\"rxjs\");","import { Response } from '@bigcommerce/request-sender';\n\nimport StandardError from './standard-error';\n\nconst DEFAULT_RESPONSE = {\n body: {},\n headers: {},\n status: 0,\n};\n\n/**\n * Throw this error if we are unable to make a request to the server. It wraps\n * any server response into a JS error object.\n */\nexport default class RequestError<TBody = any> extends StandardError {\n body: TBody | {};\n headers: { [key: string]: any };\n errors: Array<{ code: string; message?: string }>;\n status: number;\n\n constructor(\n response?: Response<TBody | {}>,\n { message, errors }: {\n message?: string;\n errors?: Array<{ code: string; message?: string }>;\n } = {}\n ) {\n const { body, headers, status } = response || DEFAULT_RESPONSE;\n\n super(message || 'An unexpected error has occurred.');\n\n this.name = 'RequestError';\n this.type = 'request';\n this.body = body;\n this.headers = headers;\n this.status = status;\n this.errors = errors || [];\n }\n}\n","module.exports = require(\"@bigcommerce/request-sender\");","import { InvalidArgumentError } from '../error/errors';\n\nimport Url from './url';\n\nexport default function parseUrl(url: string): Url {\n if (!/^(https?:)?\\/\\//.test(url)) {\n throw new InvalidArgumentError('The provided URL must be absolute.');\n }\n\n // new URL() is not supported in IE11, use anchor tag instead\n const anchor = document.createElement('a');\n\n anchor.href = url;\n\n // IE11 returns 80 or 443 for the port number depending on the URL scheme,\n // even if the port number is not specified in the URL.\n const port = anchor.port && url.indexOf(`${anchor.hostname}:${anchor.port}`) !== -1 ?\n anchor.port :\n '';\n\n return {\n hash: anchor.hash,\n hostname: anchor.hostname,\n href: anchor.href,\n origin: `${anchor.protocol}//${anchor.hostname}${port ? ':' + port : ''}`,\n pathname: anchor.pathname,\n port,\n protocol: anchor.protocol,\n search: anchor.search,\n };\n}\n","import StandardError from './standard-error';\n\n/**\n * This error should be thrown when a method is unable to proceed because the\n * caller has not provided all the arguments according to their requirements,\n * i.e.: if an argument is missing or it is not the expected data type.\n */\nexport default class InvalidArgumentError extends StandardError {\n constructor(message?: string) {\n super(message || 'Invalid arguments have been provided.');\n\n this.name = 'InvalidArgumentError';\n this.type = 'invalid_argument';\n }\n}\n","import IframeEvent from './iframe-event';\n\nexport default function isIframeEvent<TEvent extends IframeEvent<TType>, TType extends string>(\n object: any,\n type: TType\n): object is TEvent {\n return object.type === type;\n}\n","module.exports = require(\"local-storage-fallback\");","module.exports = require(\"rxjs/operators\");","/**\n * Decorates a class or a method by binding all its prototype methods or itself\n * to the calling instance respectively.\n */\nfunction bindDecorator<T extends Method>(target: object, key: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;\nfunction bindDecorator<T extends Constructor<object>>(target: T): T;\nfunction bindDecorator(target: any, key?: any, descriptor?: any): any {\n if (!key || !descriptor) {\n return bindClassDecorator(target);\n }\n\n return bindMethodDecorator(target, key, descriptor);\n}\n\nexport default bindDecorator;\n\n/**\n * Decorates a class by binding all its prototype methods to the calling\n * instance.\n */\nexport function bindClassDecorator<T extends Constructor<object>>(target: T): T {\n const decoratedTarget = class extends target {};\n\n Object.getOwnPropertyNames(target.prototype)\n .forEach(key => {\n const descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);\n\n if (!descriptor || key === 'constructor') {\n return;\n }\n\n Object.defineProperty(\n decoratedTarget.prototype,\n key,\n bindMethodDecorator(target.prototype, key, descriptor)\n );\n });\n\n return decoratedTarget;\n}\n\n/**\n * Decorates a method by binding it to the calling instance.\n */\nexport function bindMethodDecorator<T extends Method>(_: object, key: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> {\n if (typeof descriptor.value !== 'function') {\n return descriptor;\n }\n\n let method: T = descriptor.value;\n\n return {\n get() {\n const boundMethod = method.bind(this) as T;\n\n Object.defineProperty(this, key, {\n ...descriptor,\n value: boundMethod,\n });\n\n return boundMethod;\n },\n set(value) {\n method = value;\n },\n };\n}\n\nexport type Constructor<T> = new (...args: any[]) => T;\nexport type Method = (...args: any[]) => any;\n"],"sourceRoot":""}
|