@bigcommerce/checkout-sdk 1.276.2 → 1.278.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- (()=>{"use strict";var t={780:t=>{t.exports=require("iframe-resizer")},444:t=>{t.exports=require("iframe-resizer/js/iframeResizer.contentWindow")}},e={};function o(r){var n=e[r];if(void 0!==n)return n.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};(()=>{o.r(r),o.d(r,{createEmbeddedCheckoutMessenger:()=>T,embedCheckout:()=>x});const t=require("@bigcommerce/request-sender"),e=require("tslib"),n=function(t){function o(e){var o,r,n=this.constructor,i=t.call(this,e||"An unexpected error has occurred.")||this;return i.name="StandardError",i.type="standard",o=i,r=n.prototype,Object.setPrototypeOf?Object.setPrototypeOf(o,r):o.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,n):i.stack=new Error(i.message).stack,i}return(0,e.__extends)(o,t),o}(Error),i=function(t){function o(e){var o=t.call(this,e||"Invalid arguments have been provided.")||this;return o.name="InvalidArgumentError",o.type="invalid_argument",o}return(0,e.__extends)(o,t),o}(n);function s(t){if(!/^(https?:)?\/\//.test(t))throw new i("The provided URL must be absolute.");var e=document.createElement("a");e.href=t;var o=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+(o?":"+o:""),pathname:e.pathname,port:o,protocol:e.protocol,search:e.search}}const a=function(t,o,r){return o&&r?c(0,o,r):function(t){var o=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(o,t),o}(t);return Object.getOwnPropertyNames(t.prototype).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t.prototype,e);r&&"constructor"!==e&&Object.defineProperty(o.prototype,e,c(t.prototype,e,r))})),o}(t)};function c(t,o,r){if("function"!=typeof r.value)return r;var n=r.value;return{get:function(){var t=n.bind(this);return Object.defineProperty(this,o,(0,e.__assign)((0,e.__assign)({},r),{value:t})),t},set:function(t){n=t}}}function d(t,e){return t.type===e}const u=function(){function t(t){var e;this._sourceOrigins=[s(t).origin,(e=s(t),s(0===e.hostname.indexOf("www")?e.href:e.href.replace(e.hostname,"www."+e.hostname))).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 o=this._listeners[t];o||(this._listeners[t]=o=[]),-1===o.indexOf(e)&&o.push(e)},t.prototype.removeListener=function(t,e){var o=this._listeners[t];if(o){var r=o.indexOf(e);r>=0&&o.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)&&d(t.data,t.data.type)&&this.trigger(t.data)},(0,e.__decorate)([a],t.prototype,"_handleMessage",null),t}(),p=require("rxjs"),h=require("rxjs/operators"),l=function(){function t(t,e){this._targetWindow=e,this._targetOrigin="*"===t?"*":s(t).origin}return t.prototype.post=function(t,e){var o=this,r=this._targetWindow;if(window!==r){if(!r)throw new Error("Unable to post message because target window is not set.");var n=e&&(0,p.fromEvent)(window,"message").pipe((0,h.filter)((function(t){return t.origin===o._targetOrigin&&d(t.data,t.data.type)&&-1!==[e.successType,e.errorType].indexOf(t.data.type)})),(0,h.map)((function(t){if(e.errorType===t.data.type)throw t.data;return t.data})),(0,h.take)(1)).toPromise();return r.postMessage(t,this._targetOrigin),n}},t.prototype.setTarget=function(t){this._targetWindow=t},t}();var m={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},f="embedded-checkout-loading-indicator-rotation";const y=function(){function t(t){this._styles=(0,e.__assign)((0,e.__assign)({},m),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=f+" 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)",t},t.prototype._defineAnimation=function(){if(!document.getElementById(f)){var t=document.createElement("style");t.id=f,document.head.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule("\n @keyframes "+f+" {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n ",0)}},t}(),_=require("local-storage-fallback");var g=o.n(_);const v=function(){function t(t){this._namespace=t}return t.prototype.getItem=function(t){var e=g().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 g().setItem(this.withNamespace(t),JSON.stringify(e))},t.prototype.removeItem=function(t){return g().removeItem(this.withNamespace(t))},t.prototype.withNamespace=function(t){return this._namespace+"."+t},t}();var w;!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"}(w||(w={}));var b={body:{},headers:{},status:0};const E=function(t){function o(e){var o=t.call(this,e,{message:e.body.title})||this;return o.name="InvalidLoginTokenError",o.type="invalid_login_token",o}return(0,e.__extends)(o,t),o}(function(t){function o(e,o){var r=void 0===o?{}:o,n=r.message,i=r.errors,s=this,a=e||b,c=a.body,d=a.headers,u=a.status;return(s=t.call(this,n||"An unexpected error has occurred.")||this).name="RequestError",s.type="request",s.body=c,s.headers=d,s.status=u,s.errors=i||[],s}return(0,e.__extends)(o,t),o}(n));var C;!function(t){t.MissingContainer="missing_container",t.MissingContent="missing_content",t.UnknownError="unknown_error"}(C||(C={}));const L=function(t){function o(e,o){void 0===o&&(o=C.UnknownError);var r=t.call(this,e||"Unable to embed the checkout form.")||this;return r.subtype=o,r.name="NotEmbeddableError",r.type="not_embeddable",r}return(0,e.__extends)(o,t),o}(n);var O;!function(t){t.StyleConfigured="STYLE_CONFIGURED"}(O||(O={}));var k="isCookieAllowed",I="lastAllowCookieAttempt";const S=function(){function t(t,e,o,r,n,i,s,a){var c=this;this._iframeCreator=t,this._messageListener=e,this._messagePoster=o,this._loadingIndicator=r,this._requestSender=n,this._storage=i,this._location=s,this._options=a,this._isAttached=!1,this._options.onComplete&&this._messageListener.addListener(w.CheckoutComplete,this._options.onComplete),this._options.onError&&this._messageListener.addListener(w.CheckoutError,this._options.onError),this._options.onLoad&&this._messageListener.addListener(w.CheckoutLoaded,this._options.onLoad),this._options.onFrameLoad&&this._messageListener.addListener(w.FrameLoaded,this._options.onFrameLoad),this._options.onSignOut&&this._messageListener.addListener(w.SignedOut,this._options.onSignOut),this._messageListener.addListener(w.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:w.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:O.StyleConfigured,payload:this._options.styles}))},t.prototype._attemptLogin=function(){return/^\/login\/token/.test(s(this._options.url).pathname)?this._requestSender.post(this._options.url).then((function(t){return t.body.redirectUrl})).catch((function(t){return Promise.reject(new E(t))})):Promise.resolve(this._options.url)},t.prototype._allowCookie=function(){if(this._storage.getItem(k))return Promise.resolve();this._storage.setItem(k,!0),this._storage.setItem(I,Date.now());var t=s(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(I));return(!e||Date.now()-e>6e5)&&t instanceof L&&t.subtype===C.MissingContent?(this._storage.removeItem(I),this._storage.removeItem(k),this._allowCookie()):Promise.reject()},(0,e.__decorate)([a],t)}(),M=function(){function t(t){this._options=t}return t.prototype.createFrame=function(t,e){var o=document.getElementById(e),r=(this._options||{}).timeout,n=void 0===r?6e4:r;if(!o)throw new L("Unable to embed the iframe because the container element could not be found.",C.MissingContainer);var i=document.createElement("iframe");return i.src=t,i.style.border="none",i.style.display="none",i.style.width="100%",i.allowPaymentRequest=!0,o.appendChild(i),this._toResizableFrame(i,n).catch((function(t){throw o.removeChild(i),t}))},t.prototype._toResizableFrame=function(t,e){return new Promise((function(r,n){var i=window.setTimeout((function(){n(new L("Unable to embed the iframe because the content could not be loaded."))}),e),a=function(e){var i,a;if(e.origin===s(t.src).origin&&(d(e.data,w.FrameError)&&(c(),n(new L(e.data.payload.message,C.MissingContent))),d(e.data,w.FrameLoaded))){t.style.display="";var u=(i={scrolling:!1,sizeWidth:!1,heightCalculationMethod:e.data.payload&&e.data.payload.contentId?"taggedElement":"lowestElement"},a=t,(0,o(780).iframeResizer)(i,a));c(),r(u[u.length-1])}},c=function(){window.removeEventListener("message",a),window.clearTimeout(i)};window.addEventListener("message",a)}))},t}();function x(e){var o=s(e.url).origin;return new S(new M,new u(o),new l(o),new y({styles:e.styles&&e.styles.loadingIndicator}),(0,t.createRequestSender)(),new v("BigCommerce.EmbeddedCheckout"),window.location,e).attach()}function P(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","")}}function F(t){return"string"==typeof t.message&&"string"==typeof t.type&&("string"==typeof t.subtype||!t.subtype)&&t instanceof Error}const A=function(){function t(t,e,o,r){void 0===r&&(r={}),this._messageListener=t,this._messagePoster=e,this._untargetedMessagePoster=o,this._messageHandlers=r,this._messageListener.listen()}return t.prototype.postComplete=function(){var t={type:w.CheckoutComplete};this._postMessage(t)},t.prototype.postError=function(t){var e={type:w.CheckoutError,payload:this._transformError(t)};this._postMessage(e)},t.prototype.postFrameError=function(t){var e={type:w.FrameError,payload:this._transformError(t)};this._postMessage(e,{untargeted:!0})},t.prototype.postFrameLoaded=function(t){var e={type:w.FrameLoaded,payload:t};this._postMessage(e)},t.prototype.postLoaded=function(){var t={type:w.CheckoutLoaded};this._postMessage(t)},t.prototype.postSignedOut=function(){var t={type:w.SignedOut};this._postMessage(t)},t.prototype.receiveStyles=function(t){this._messageListener.addListener(O.StyleConfigured,(function(e){var o=e.payload;t(o)}))},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(o){if(t.type===o){var r=e._messageHandlers[o];r&&r.call(null,t)}}))},t.prototype._transformError=function(t){return{message:t.message,type:F(t)?t.type:void 0,subtype:F(t)?t.subtype:void 0}},(0,e.__decorate)([a],t)}(),R=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(){},(0,e.__decorate)([a],t)}();function T(t){var e;o(444);var r=t.parentWindow||window.parent;return window===r?new R:new A(new u(t.parentOrigin),new l(t.parentOrigin,r),new l("*",r),((e={})[w.FrameLoaded]=P,e))}})(),module.exports=r})();
1
+ (()=>{"use strict";var t={780:t=>{t.exports=require("iframe-resizer")},252:t=>{t.exports=require("iframe-resizer/js/iframeResizer.contentWindow")}},e={};function o(r){var n=e[r];if(void 0!==n)return n.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};(()=>{o.r(r),o.d(r,{createEmbeddedCheckoutMessenger:()=>T,embedCheckout:()=>x});const t=require("@bigcommerce/request-sender"),e=require("tslib"),n=function(t){function o(e){var o,r,n=this.constructor,i=t.call(this,e||"An unexpected error has occurred.")||this;return i.name="StandardError",i.type="standard",o=i,r=n.prototype,Object.setPrototypeOf?Object.setPrototypeOf(o,r):o.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,n):i.stack=new Error(i.message).stack,i}return(0,e.__extends)(o,t),o}(Error),i=function(t){function o(e){var o=t.call(this,e||"Invalid arguments have been provided.")||this;return o.name="InvalidArgumentError",o.type="invalid_argument",o}return(0,e.__extends)(o,t),o}(n);function s(t){if(!/^(https?:)?\/\//.test(t))throw new i("The provided URL must be absolute.");var e=document.createElement("a");e.href=t;var o=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+(o?":"+o:""),pathname:e.pathname,port:o,protocol:e.protocol,search:e.search}}const a=function(t,o,r){return o&&r?c(0,o,r):function(t){var o=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return(0,e.__extends)(o,t),o}(t);return Object.getOwnPropertyNames(t.prototype).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t.prototype,e);r&&"constructor"!==e&&Object.defineProperty(o.prototype,e,c(t.prototype,e,r))})),o}(t)};function c(t,o,r){if("function"!=typeof r.value)return r;var n=r.value;return{get:function(){var t=n.bind(this);return Object.defineProperty(this,o,(0,e.__assign)((0,e.__assign)({},r),{value:t})),t},set:function(t){n=t}}}function d(t,e){return t.type===e}const u=function(){function t(t){var e;this._sourceOrigins=[s(t).origin,(e=s(t),s(0===e.hostname.indexOf("www")?e.href:e.href.replace(e.hostname,"www."+e.hostname))).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 o=this._listeners[t];o||(this._listeners[t]=o=[]),-1===o.indexOf(e)&&o.push(e)},t.prototype.removeListener=function(t,e){var o=this._listeners[t];if(o){var r=o.indexOf(e);r>=0&&o.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)&&d(t.data,t.data.type)&&this.trigger(t.data)},(0,e.__decorate)([a],t.prototype,"_handleMessage",null),t}(),p=require("rxjs"),h=require("rxjs/operators"),l=function(){function t(t,e){this._targetWindow=e,this._targetOrigin="*"===t?"*":s(t).origin}return t.prototype.post=function(t,e){var o=this,r=this._targetWindow;if(window!==r){if(!r)throw new Error("Unable to post message because target window is not set.");var n=e&&(0,p.fromEvent)(window,"message").pipe((0,h.filter)((function(t){return t.origin===o._targetOrigin&&d(t.data,t.data.type)&&-1!==[e.successType,e.errorType].indexOf(t.data.type)})),(0,h.map)((function(t){if(e.errorType===t.data.type)throw t.data;return t.data})),(0,h.take)(1)).toPromise();return r.postMessage(t,this._targetOrigin),n}},t.prototype.setTarget=function(t){this._targetWindow=t},t}();var m={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},f="embedded-checkout-loading-indicator-rotation";const y=function(){function t(t){this._styles=(0,e.__assign)((0,e.__assign)({},m),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=f+" 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)",t},t.prototype._defineAnimation=function(){if(!document.getElementById(f)){var t=document.createElement("style");t.id=f,document.head.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule("\n @keyframes "+f+" {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n ",0)}},t}(),_=require("local-storage-fallback");var g=o.n(_);const v=function(){function t(t){this._namespace=t}return t.prototype.getItem=function(t){var e=g().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 g().setItem(this.withNamespace(t),JSON.stringify(e))},t.prototype.removeItem=function(t){return g().removeItem(this.withNamespace(t))},t.prototype.withNamespace=function(t){return this._namespace+"."+t},t}();var w;!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"}(w||(w={}));var b={body:{},headers:{},status:0};const E=function(t){function o(e){var o=t.call(this,e,{message:e.body.title})||this;return o.name="InvalidLoginTokenError",o.type="invalid_login_token",o}return(0,e.__extends)(o,t),o}(function(t){function o(e,o){var r=void 0===o?{}:o,n=r.message,i=r.errors,s=this,a=e||b,c=a.body,d=a.headers,u=a.status;return(s=t.call(this,n||"An unexpected error has occurred.")||this).name="RequestError",s.type="request",s.body=c,s.headers=d,s.status=u,s.errors=i||[],s}return(0,e.__extends)(o,t),o}(n));var C;!function(t){t.MissingContainer="missing_container",t.MissingContent="missing_content",t.UnknownError="unknown_error"}(C||(C={}));const L=function(t){function o(e,o){void 0===o&&(o=C.UnknownError);var r=t.call(this,e||"Unable to embed the checkout form.")||this;return r.subtype=o,r.name="NotEmbeddableError",r.type="not_embeddable",r}return(0,e.__extends)(o,t),o}(n);var O;!function(t){t.StyleConfigured="STYLE_CONFIGURED"}(O||(O={}));var k="isCookieAllowed",I="lastAllowCookieAttempt";const S=function(){function t(t,e,o,r,n,i,s,a){var c=this;this._iframeCreator=t,this._messageListener=e,this._messagePoster=o,this._loadingIndicator=r,this._requestSender=n,this._storage=i,this._location=s,this._options=a,this._isAttached=!1,this._options.onComplete&&this._messageListener.addListener(w.CheckoutComplete,this._options.onComplete),this._options.onError&&this._messageListener.addListener(w.CheckoutError,this._options.onError),this._options.onLoad&&this._messageListener.addListener(w.CheckoutLoaded,this._options.onLoad),this._options.onFrameLoad&&this._messageListener.addListener(w.FrameLoaded,this._options.onFrameLoad),this._options.onSignOut&&this._messageListener.addListener(w.SignedOut,this._options.onSignOut),this._messageListener.addListener(w.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:w.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:O.StyleConfigured,payload:this._options.styles}))},t.prototype._attemptLogin=function(){return/^\/login\/token/.test(s(this._options.url).pathname)?this._requestSender.post(this._options.url).then((function(t){return t.body.redirectUrl})).catch((function(t){return Promise.reject(new E(t))})):Promise.resolve(this._options.url)},t.prototype._allowCookie=function(){if(this._storage.getItem(k))return Promise.resolve();this._storage.setItem(k,!0),this._storage.setItem(I,Date.now());var t=s(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(I));return(!e||Date.now()-e>6e5)&&t instanceof L&&t.subtype===C.MissingContent?(this._storage.removeItem(I),this._storage.removeItem(k),this._allowCookie()):Promise.reject()},(0,e.__decorate)([a],t)}(),M=function(){function t(t){this._options=t}return t.prototype.createFrame=function(t,e){var o=document.getElementById(e),r=(this._options||{}).timeout,n=void 0===r?6e4:r;if(!o)throw new L("Unable to embed the iframe because the container element could not be found.",C.MissingContainer);var i=document.createElement("iframe");return i.src=t,i.style.border="none",i.style.display="none",i.style.width="100%",i.allowPaymentRequest=!0,o.appendChild(i),this._toResizableFrame(i,n).catch((function(t){throw o.removeChild(i),t}))},t.prototype._toResizableFrame=function(t,e){return new Promise((function(r,n){var i=window.setTimeout((function(){n(new L("Unable to embed the iframe because the content could not be loaded."))}),e),a=function(e){var i,a;if(e.origin===s(t.src).origin&&(d(e.data,w.FrameError)&&(c(),n(new L(e.data.payload.message,C.MissingContent))),d(e.data,w.FrameLoaded))){t.style.display="";var u=(i={scrolling:!1,sizeWidth:!1,heightCalculationMethod:e.data.payload&&e.data.payload.contentId?"taggedElement":"lowestElement"},a=t,(0,o(780).iframeResizer)(i,a));c(),r(u[u.length-1])}},c=function(){window.removeEventListener("message",a),window.clearTimeout(i)};window.addEventListener("message",a)}))},t}();function x(e){var o=s(e.url).origin;return new S(new M,new u(o),new l(o),new y({styles:e.styles&&e.styles.loadingIndicator}),(0,t.createRequestSender)(),new v("BigCommerce.EmbeddedCheckout"),window.location,e).attach()}function P(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","")}}function F(t){return"string"==typeof t.message&&"string"==typeof t.type&&("string"==typeof t.subtype||!t.subtype)&&t instanceof Error}const A=function(){function t(t,e,o,r){void 0===r&&(r={}),this._messageListener=t,this._messagePoster=e,this._untargetedMessagePoster=o,this._messageHandlers=r,this._messageListener.listen()}return t.prototype.postComplete=function(){var t={type:w.CheckoutComplete};this._postMessage(t)},t.prototype.postError=function(t){var e={type:w.CheckoutError,payload:this._transformError(t)};this._postMessage(e)},t.prototype.postFrameError=function(t){var e={type:w.FrameError,payload:this._transformError(t)};this._postMessage(e,{untargeted:!0})},t.prototype.postFrameLoaded=function(t){var e={type:w.FrameLoaded,payload:t};this._postMessage(e)},t.prototype.postLoaded=function(){var t={type:w.CheckoutLoaded};this._postMessage(t)},t.prototype.postSignedOut=function(){var t={type:w.SignedOut};this._postMessage(t)},t.prototype.receiveStyles=function(t){this._messageListener.addListener(O.StyleConfigured,(function(e){var o=e.payload;t(o)}))},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(o){if(t.type===o){var r=e._messageHandlers[o];r&&r.call(null,t)}}))},t.prototype._transformError=function(t){return{message:t.message,type:F(t)?t.type:void 0,subtype:F(t)?t.subtype:void 0}},(0,e.__decorate)([a],t)}(),R=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(){},(0,e.__decorate)([a],t)}();function T(t){var e;o(252);var r=t.parentWindow||window.parent;return window===r?new R:new A(new u(t.parentOrigin),new l(t.parentOrigin,r),new l("*",r),((e={})[w.FrameLoaded]=P,e))}})(),module.exports=r})();
2
2
  //# sourceMappingURL=embedded-checkout.js.map
package/docs/README.md CHANGED
@@ -359,7 +359,7 @@
359
359
  - [WithCheckoutcomiDealInstrument](interfaces/WithCheckoutcomiDealInstrument.md)
360
360
  - [WithDocumentInstrument](interfaces/WithDocumentInstrument.md)
361
361
  - [WithMollieIssuerInstrument](interfaces/WithMollieIssuerInstrument.md)
362
- - [WorldpayPaymentInitializeOptions](interfaces/WorldpayPaymentInitializeOptions.md)
362
+ - [WorldpayAccessPaymentInitializeOptions](interfaces/WorldpayAccessPaymentInitializeOptions.md)
363
363
  - [ZipCodeElementOptions](interfaces/ZipCodeElementOptions.md)
364
364
 
365
365
  ### Type aliases
@@ -21,6 +21,7 @@ service.initializePayment({
21
21
  editButtonId: 'edit-button',
22
22
  },
23
23
  });
24
+ ```
24
25
 
25
26
  ## Table of contents
26
27
 
@@ -390,7 +390,7 @@ ___
390
390
 
391
391
  ### worldpay
392
392
 
393
- • `Optional` **worldpay**: [`WorldpayPaymentInitializeOptions`](WorldpayPaymentInitializeOptions.md)
393
+ • `Optional` **worldpay**: [`WorldpayAccessPaymentInitializeOptions`](WorldpayAccessPaymentInitializeOptions.md)
394
394
 
395
395
  The options that are required to initialize the Worldpay payment method.
396
396
  They can be omitted unless you need to support Worldpay.
@@ -31,6 +31,7 @@ service.initializePayment({
31
31
  },
32
32
  },
33
33
  });
34
+ ```
34
35
 
35
36
  ## Table of contents
36
37
 
@@ -24,6 +24,7 @@ service.initializePayment({
24
24
  }
25
25
  }
26
26
  });
27
+ ```
27
28
 
28
29
  ## Table of contents
29
30
 
@@ -36,11 +37,6 @@ service.initializePayment({
36
37
  - [containerId](MolliePaymentInitializeOptions.md#containerid)
37
38
  - [form](MolliePaymentInitializeOptions.md#form)
38
39
  - [styles](MolliePaymentInitializeOptions.md#styles)
39
- - [unsupportedMethodMessage](MolliePaymentInitializeOptions.md#unsupportedmethodmessage)
40
-
41
- ### Methods
42
-
43
- - [disableButton](MolliePaymentInitializeOptions.md#disablebutton)
44
40
 
45
41
  ## Properties
46
42
 
@@ -99,19 +95,3 @@ ___
99
95
  • **styles**: `object`
100
96
 
101
97
  A set of styles required for the mollie components
102
-
103
- ___
104
-
105
- ### unsupportedMethodMessage
106
-
107
- • `Optional` **unsupportedMethodMessage**: `string`
108
-
109
- ## Methods
110
-
111
- ### disableButton
112
-
113
- ▸ **disableButton**(): `void`
114
-
115
- #### Returns
116
-
117
- `void`
@@ -1,12 +1,12 @@
1
- [@bigcommerce/checkout-sdk](../README.md) / WorldpayPaymentInitializeOptions
1
+ [@bigcommerce/checkout-sdk](../README.md) / WorldpayAccessPaymentInitializeOptions
2
2
 
3
- # Interface: WorldpayPaymentInitializeOptions
3
+ # Interface: WorldpayAccessPaymentInitializeOptions
4
4
 
5
5
  ## Table of contents
6
6
 
7
7
  ### Methods
8
8
 
9
- - [onLoad](WorldpayPaymentInitializeOptions.md#onload)
9
+ - [onLoad](WorldpayAccessPaymentInitializeOptions.md#onload)
10
10
 
11
11
  ## Methods
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcommerce/checkout-sdk",
3
- "version": "1.276.2",
3
+ "version": "1.278.1",
4
4
  "description": "BigCommerce Checkout JavaScript SDK",
5
5
  "license": "MIT",
6
6
  "main": "dist/checkout-sdk.js",