@transferwise/approve-api-action-helpers
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).twApproveApiActionHelpers={})}(this,(function(e){function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function c(e,t,n){return(c=i()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&a(o,n.prototype),o}).apply(null,arguments)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return c(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,e)})(e)}function u(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}var l=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(c,e);var t,n,r=(t=c,n=i(),function(){var e,r=o(t);if(n){var a=o(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return u(this,e)});function c(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),(t=r.call(this,e.statusText)).name="HTTPError",t.response=e,t}return c}(p(Error));function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return fetch(e,r(r({},t),{},{headers:r(r({},{"Content-Type":"application/json"}),t.headers)})).then((function(e){if(!e.ok)throw new l(e);return e}))}var d="tw-approve-api-action-success",f="tw-approve-api-action-failed",v="tw-approve-api-action-closed";function h(e){var t,n,r=e.token,o=e.approvalPageUrl,a=e.resolve,i=e.reject;document.getElementById("tw-approve-api-action-styles")||(t=document.head,(n=document.createElement("style")).id="tw-approve-api-action-styles",n.appendChild(document.createTextNode("\n .tw-approval-modal-overlay {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n top: 0;\n height: 100%;\n width: 100%;\n background: rgba(55,81,126,0);\n transition: background-color .35s cubic-bezier(0,.94,.62,1);\n z-index: 1050;\n }\n .tw-approval-modal-overlay--open {\n background: rgba(55,81,126,0.8);\n }\n .tw-approval-modal-wrapper {\n height: 100%;\n width: 100vw;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 16px;\n }\n .tw-approval-modal {\n display: flex;\n max-height: 100%;\n height: 540px;\n width: 540px;\n background-color: #fff;\n border-radius: 3px;\n box-shadow: 0 5px 15px rgba(0,0,0,.2);\n overflow: auto;\n }\n")),t.appendChild(n));var c=document.createElement("div");c.id="tw-approval-modal-overlay",c.classList.add("tw-approval-modal-overlay");var p=document.createElement("div");p.classList.add("tw-approval-modal-wrapper"),c.appendChild(p);var u=document.createElement("div");u.classList.add("tw-approval-modal"),p.appendChild(u);var l=document.createElement("iframe");l.name="tw-approve-api-action",l.width="100%",l.height="100%",l.style.border="0",u.appendChild(l);var s=document.createElement("form"),h=document.createElement("input");s.style.display="none",s.method="POST",s.action=o,h.value=r,h.name="ott",s.appendChild(h),u.appendChild(s),document.body.appendChild(c),c.classList.add("tw-approval-modal-overlay--open"),s.setAttribute("target","tw-approve-api-action"),s.submit();var m=function(e){switch(e.data){case d:return w(),void a();case f:return w(),void i();case v:w()}},w=function(){var e=document.getElementById("tw-approval-modal-overlay");e.parentNode.removeChild(e),window.removeEventListener("message",m)};c.addEventListener("click",w,{once:!0}),window.addEventListener("message",m)}function m(e){var t=e.token,n=e.approvalPageUrl,r=e.resolve,o=e.reject,a="tw-approve-api-action",i=function(e){var t=e.name,n=e.token,r=e.approvalPageUrl,o=document.createElement("form"),a=document.createElement("input");return o.style.display="none",o.target=t,o.method="POST",o.action=r,a.value=n,a.name="ott",o.appendChild(a),o}({name:a,token:t,approvalPageUrl:n});document.body.appendChild(i);var c=window.open(n,a);i.submit();var p=function(e){switch(e.data){case d:return u(),void r();case f:return u(),void o();case v:u()}},u=function(){c.close(),window.removeEventListener("message",p)};window.addEventListener("message",p)}var w={IFRAME:"iframe",TAB:"tab"},y={PRODUCTION:"production",SANDBOX:"sandbox"},b=function(e){return e===y.SANDBOX?"https://sandbox.transferwise.tech/approve-api-action/":"https://transferwise.com/approve-api-action/"};function g(e){var t=e.token,n=e.flow,r=void 0===n?w.IFRAME:n,o=e.mode,a=void 0===o?y.PRODUCTION:o,i=e.approvalPageUrl;return new Promise((function(e,n){var o={token:t,approvalPageUrl:i||b(a),resolve:e,reject:n};r===w.TAB?m(o):h(o)}))}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};e()}function P(e){if(!e||!e.response)return!1;var t=j(e.response),n=e.response.status;return(403===n||400===n)&&t}function j(e){return e&&e.headers&&e.headers.get?e.headers.get("X-2FA-APPROVAL"):null}e.Flow=w,e.Mode=y,e.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(t,n).then((function(e){return{response:e,metadata:{scaRequired:!1}}})).catch((function(o){if(P(o)){var a=j(o.response);return O(e.onSCARequired),g({token:a,flow:e.flow,mode:e.mode,approvalPageUrl:e.approvalPageUrl}).then((function(){O(e.onSCACompleted);var o=r(r({},n.headers||{}),{},{"X-2FA-APPROVAL":a});return s(t,r(r({},n),{},{headers:o})).then((function(e){return{response:e,metadata:{scaRequired:!0}}}))}))}throw o})).then((function(e){return n&&n.withMetadata?e:e.response}))}},e.runFlow=g,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).twApproveApiActionHelpers={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function n(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach((function(t){o(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function a(e){var t="function"==typeof Map?new Map:void 0;return(a=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return c(e,arguments,d(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),s(o,e)})(e)}function c(e,t,n){return(c=u()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var i=new(Function.bind.apply(e,o));return n&&s(i,n.prototype),i}).apply(null,arguments)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var l=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(i,e);var t,n,o=(t=i,n=u(),function(){var e,o=d(t);if(n){var i=d(this).constructor;e=Reflect.construct(o,arguments,i)}else e=o.apply(this,arguments);return r(this,e)});function i(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),(t=o.call(this,e.statusText)).name="HTTPError",t.response=e,t}return i}(a(Error));function f(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return fetch(e,n(n({},t),{},{headers:n(n({},{"Content-Type":"application/json"}),t.headers)})).then((function(e){if(!e.ok)throw new l(e);return e}))}function m(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var p=m((function(e){!function(t){if("undefined"!=typeof window){var n,o=0,i=!1,r=!1,a="message".length,c="[iFrameSizer]",u=c.length,s=null,d=window.requestAnimationFrame,l={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},f={},m=null,p={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){E("onMessage function not defined")},onResized:function(){},onScroll:function(){return!0}},h={};window.jQuery&&((n=window.jQuery).fn?n.fn.iFrameResize||(n.fn.iFrameResize=function(e){return this.filter("iframe").each((function(t,n){L(n,e)})).end()}):T("","Unable to bind to jQuery, it is not fully loaded.")),e.exports=q(),window.iFrameResize=window.iFrameResize||q()}function g(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function w(e,t,n){e.addEventListener(t,n,!1)}function v(e,t,n){e.removeEventListener(t,n,!1)}function y(e){return c+"["+function(e){var t="Host page: "+e;return window.top!==window.self&&(t=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+e:"Nested host page: "+e),t}(e)+"]"}function b(e){return f[e]?f[e].log:i}function O(e,t){x("log",e,t,b(e))}function T(e,t){x("info",e,t,b(e))}function E(e,t){x("warn",e,t,!0)}function x(e,t,n,o){!0===o&&"object"==typeof window.console&&console[e](y(t),n)}function M(e){function t(){i("Height"),i("Width"),F((function(){j(H),P(D),g("onResized",H)}),H,"init")}function n(e){return"border-box"!==e.boxSizing?0:(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function o(e){return"border-box"!==e.boxSizing?0:(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function i(e){var t=Number(f[D]["max"+e]),n=Number(f[D]["min"+e]),o=e.toLowerCase(),i=Number(H[o]);O(D,"Checking "+o+" is in range "+n+"-"+t),i<n&&(i=n,O(D,"Set "+o+" to min value")),i>t&&(i=t,O(D,"Set "+o+" to max value")),H[o]=""+i}function r(e){return W.substr(W.indexOf(":")+a+e)}function d(e,t){var n,o,i;n=function(){var n,o;N("Send Page Info","pageInfo:"+(n=document.body.getBoundingClientRect(),o=H.iframe.getBoundingClientRect(),JSON.stringify({iframeHeight:o.height,iframeWidth:o.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(o.top-n.top,10),offsetLeft:parseInt(o.left-n.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})),e,t)},o=32,h[i=t]||(h[i]=setTimeout((function(){h[i]=null,n()}),o))}function l(e){var t=e.getBoundingClientRect();return R(D),{x:Math.floor(Number(t.left)+Number(s.x)),y:Math.floor(Number(t.top)+Number(s.y))}}function m(e){var t=e?l(H.iframe):{x:0,y:0},n={x:Number(H.width)+t.x,y:Number(H.height)+t.y};O(D,"Reposition requested from iFrame (offset x:"+t.x+" y:"+t.y+")"),window.top!==window.self?window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](n.x,n.y):E(D,"Unable to scroll to requested position, window.parentIFrame not found"):(s=n,p(),O(D,"--"))}function p(){!1!==g("onScroll",s)?P(D):z()}function g(e,t){return I(D,e,t)}var y,b,x,M,S,L,W=e.data,H={},D=null;"[iFrameResizerChild]Ready"===W?function(){for(var e in f)N("iFrame requested init",A(e),f[e].iframe,e)}():c===(""+W).substr(0,u)&&W.substr(u).split(":")[0]in f?(x=W.substr(u).split(":"),M=x[1]?parseInt(x[1],10):0,S=f[x[0]]&&f[x[0]].iframe,L=getComputedStyle(S),H={iframe:S,id:x[0],height:M+n(L)+o(L),width:x[2],type:x[3]},D=H.id,f[D]&&(f[D].loaded=!0),(b=H.type in{true:1,false:1,undefined:1})&&O(D,"Ignoring init message from meta parent page"),!b&&function(e){var t=!0;return f[e]||(t=!1,E(H.type+" No settings for "+e+". Message was: "+W)),t}(D)&&(O(D,"Received: "+W),y=!0,null===H.iframe&&(E(D,"IFrame ("+H.id+") not found"),y=!1),y&&function(){var t,n=e.origin,o=f[D]&&f[D].checkOrigin;if(o&&""+n!="null"&&!(o.constructor===Array?function(){var e=0,t=!1;for(O(D,"Checking connection is from allowed list of origins: "+o);e<o.length;e++)if(o[e]===n){t=!0;break}return t}():(t=f[D]&&f[D].remoteHost,O(D,"Checking connection is from: "+t),n===t)))throw new Error("Unexpected message received from: "+n+" for "+H.iframe.id+". Message was: "+e.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}()&&function(){switch(f[D]&&f[D].firstRun&&f[D]&&(f[D].firstRun=!1),H.type){case"close":k(H.iframe);break;case"message":e=r(6),O(D,"onMessage passed: {iframe: "+H.iframe.id+", message: "+e+"}"),g("onMessage",{iframe:H.iframe,message:JSON.parse(e)}),O(D,"--");break;case"autoResize":f[D].autoResize=JSON.parse(r(9));break;case"scrollTo":m(!1);break;case"scrollToOffset":m(!0);break;case"pageInfo":d(f[D]&&f[D].iframe,D),function(){function e(e,o){function i(){f[n]?d(f[n].iframe,n):t()}["scroll","resize"].forEach((function(t){O(n,e+t+" listener for sendPageInfo"),o(window,t,i)}))}function t(){e("Remove ",v)}var n=D;e("Add ",w),f[n]&&(f[n].stopPageInfo=t)}();break;case"pageInfoStop":f[D]&&f[D].stopPageInfo&&(f[D].stopPageInfo(),delete f[D].stopPageInfo);break;case"inPageLink":!function(e){var t,n=e.split("#")[1]||"",o=decodeURIComponent(n),i=document.getElementById(o)||document.getElementsByName(o)[0];i?(t=l(i),O(D,"Moving to in page link (#"+n+") at x: "+t.x+" y: "+t.y),s={x:t.x,y:t.y},p(),O(D,"--")):window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(n):O(D,"In page link #"+n+" not found and window.parentIFrame not found"):O(D,"In page link #"+n+" not found")}(r(9));break;case"reset":C(H);break;case"init":t(),g("onInit",H.iframe);break;default:t()}var e}())):T(D,"Ignored: "+W)}function I(e,t,n){var o=null,i=null;if(f[e]){if("function"!=typeof(o=f[e][t]))throw new TypeError(t+" on iFrame["+e+"] is not a function");i=o(n)}return i}function S(e){var t=e.id;delete f[t]}function k(e){var t=e.id;if(!1!==I(t,"onClose",t)){O(t,"Removing iFrame: "+t);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){E(e)}I(t,"onClosed",t),O(t,"--"),S(e)}else O(t,"Close iframe cancelled by onClose event")}function R(e){null===s&&O(e,"Get page position: "+(s={x:window.pageXOffset!==t?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==t?window.pageYOffset:document.documentElement.scrollTop}).x+","+s.y)}function P(e){null!==s&&(window.scrollTo(s.x,s.y),O(e,"Set page position: "+s.x+","+s.y),z())}function z(){s=null}function C(e){O(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),R(e.id),F((function(){j(e),N("reset","reset",e.iframe,e.id)}),e,"reset")}function j(e){function t(t){r||"0"!==e[t]||(r=!0,O(o,"Hidden iFrame detected, creating visibility listener"),function(){function e(){function e(e){function t(t){return"0px"===(f[e]&&f[e].iframe.style[t])}function n(e){return null!==e.offsetParent}f[e]&&n(f[e].iframe)&&(t("height")||t("width"))&&N("Visibility change","resize",f[e].iframe,e)}Object.keys(f).forEach((function(t){e(t)}))}function t(t){O("window","Mutation observed: "+t[0].target+" "+t[0].type),W(e,16)}function n(){var e=document.querySelector("body"),n={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};new o(t).observe(e,n)}var o=g();o&&n()}())}function n(n){!function(t){e.id?(e.iframe.style[t]=e[t]+"px",O(e.id,"IFrame ("+o+") "+t+" set to "+e[t]+"px")):O("undefined","messageData id not set")}(n),t(n)}var o=e.iframe.id;f[o]&&(f[o].sizeHeight&&n("height"),f[o].sizeWidth&&n("width"))}function F(e,t,n){n!==t.type&&d&&!window.jasmine?(O(t.id,"Requesting animation frame"),d(e)):e()}function N(e,t,n,o,i){var r,a=!1;o=o||n.id,f[o]&&(n&&"contentWindow"in n&&null!==n.contentWindow?(r=f[o]&&f[o].targetOrigin,O(o,"["+e+"] Sending msg to iframe["+o+"] ("+t+") targetOrigin: "+r),n.contentWindow.postMessage(c+t,r)):E(o,"["+e+"] IFrame("+o+") not found"),i&&f[o]&&f[o].warningTimeout&&(f[o].msgTimeout=setTimeout((function(){!f[o]||f[o].loaded||a||(a=!0,E(o,"IFrame has not responded within "+f[o].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}),f[o].warningTimeout)))}function A(e){return e+":"+f[e].bodyMarginV1+":"+f[e].sizeWidth+":"+f[e].log+":"+f[e].interval+":"+f[e].enablePublicMethods+":"+f[e].autoResize+":"+f[e].bodyMargin+":"+f[e].heightCalculationMethod+":"+f[e].bodyBackground+":"+f[e].bodyPadding+":"+f[e].tolerance+":"+f[e].inPageLinks+":"+f[e].resizeFrom+":"+f[e].widthCalculationMethod}function L(e,n){function r(e){var t=e.split("Callback");if(2===t.length){var n="on"+t[0].charAt(0).toUpperCase()+t[0].slice(1);this[n]=this[e],delete this[e],E(u,"Deprecated: '"+e+"' has been renamed '"+n+"'. The old method will be removed in the next major version.")}}var a,c,u=function(t){var r;return""===t&&(e.id=(r=n&&n.id||p.id+o++,null!==document.getElementById(r)&&(r+=o++),t=r),i=(n||{}).log,O(t,"Added missing iframe ID: "+t+" ("+e.src+")")),t}(e.id);u in f&&"iFrameResizer"in e?E(u,"Ignored iFrame, already setup."):(!function(t){var n;t=t||{},f[u]={firstRun:!0,iframe:e,remoteHost:e.src&&e.src.split("/").slice(0,3).join("/")},function(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}(t),Object.keys(t).forEach(r,t),function(e){for(var t in p)Object.prototype.hasOwnProperty.call(p,t)&&(f[u][t]=Object.prototype.hasOwnProperty.call(e,t)?e[t]:p[t])}(t),f[u]&&(f[u].targetOrigin=!0===f[u].checkOrigin?""===(n=f[u].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*")}(n),function(){switch(O(u,"IFrame scrolling "+(f[u]&&f[u].scrolling?"enabled":"disabled")+" for "+u),e.style.overflow=!1===(f[u]&&f[u].scrolling)?"hidden":"auto",f[u]&&f[u].scrolling){case"omit":break;case!0:e.scrolling="yes";break;case!1:e.scrolling="no";break;default:e.scrolling=f[u]?f[u].scrolling:"no"}}(),function(){function t(t){1/0!==f[u][t]&&0!==f[u][t]&&(e.style[t]=f[u][t]+"px",O(u,"Set "+t+" = "+f[u][t]+"px"))}function n(e){if(f[u]["min"+e]>f[u]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}n("Height"),n("Width"),t("maxHeight"),t("minHeight"),t("maxWidth"),t("minWidth")}(),"number"!=typeof(f[u]&&f[u].bodyMargin)&&"0"!==(f[u]&&f[u].bodyMargin)||(f[u].bodyMarginV1=f[u].bodyMargin,f[u].bodyMargin=f[u].bodyMargin+"px"),a=A(u),(c=g())&&function(t){e.parentNode&&new t((function(t){t.forEach((function(t){Array.prototype.slice.call(t.removedNodes).forEach((function(t){t===e&&k(e)}))}))})).observe(e.parentNode,{childList:!0})}(c),w(e,"load",(function(){var n,o;N("iFrame.onload",a,e,t,!0),n=f[u]&&f[u].firstRun,o=f[u]&&f[u].heightCalculationMethod in l,!n&&o&&C({iframe:e,height:0,width:0,type:"init"})})),N("init",a,e,t,!0),f[u]&&(f[u].iframe.iFrameResizer={close:k.bind(null,f[u].iframe),removeListeners:S.bind(null,f[u].iframe),resize:N.bind(null,"Window resize","resize",f[u].iframe),moveToAnchor:function(e){N("Move to anchor","moveToAnchor:"+e,f[u].iframe,u)},sendMessage:function(e){N("Send Message","message:"+(e=JSON.stringify(e)),f[u].iframe,u)}}))}function W(e,t){null===m&&(m=setTimeout((function(){m=null,e()}),t))}function H(){"hidden"!==document.visibilityState&&(O("document","Trigger event: Visiblity change"),W((function(){D("Tab Visable","resize")}),16))}function D(e,t){Object.keys(f).forEach((function(n){(function(e){return f[e]&&"parent"===f[e].resizeFrom&&f[e].autoResize&&!f[e].firstRun})(n)&&N(e,t,f[n].iframe,n)}))}function B(){w(window,"message",M),w(window,"resize",(function(){var e;O("window","Trigger event: "+(e="resize")),W((function(){D("Window "+e,"resize")}),16)})),w(document,"visibilitychange",H),w(document,"-webkit-visibilitychange",H)}function q(){function e(e,t){t&&(!function(){if(!t.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==t.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+t.tagName+">")}(),L(t,e),n.push(t))}var n;return function(){var e,t=["moz","webkit","o","ms"];for(e=0;e<t.length&&!d;e+=1)d=window[t[e]+"RequestAnimationFrame"];d?d=d.bind(window):O("setup","RequestAnimationFrame not supported")}(),B(),function(o,i){switch(n=[],function(e){e&&e.enablePublicMethods&&E("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}(o),typeof i){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(i||"iframe"),e.bind(t,o));break;case"object":e(o,i);break;default:throw new TypeError("Unexpected data type ("+typeof i+")")}return n}}}()})),h={iframeResize:p,iframeResizer:p,iframeResizerContentWindow:m((function(e){!function(t){if("undefined"!=typeof window){var n=!0,o="",i=0,r="",a=null,c="",u=!1,s={resize:1,click:1},d=128,l=!0,f=1,m="bodyOffset",p=m,h=!0,g="",w={},v=32,y=null,b=!1,O="[iFrameSizer]",T=O.length,E="",x={max:1,min:1,bodyScroll:1,documentElementScroll:1},M="child",I=window.parent,S="*",k=0,R=!1,P=null,z=16,C=1,j="scroll",F=j,N=window,A=function(){re("onMessage function not defined")},L=function(){},W=function(){},H={height:function(){return re("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return re("Custom width calculation function not defined"),document.body.scrollWidth}},D={},B=!1;try{var q=Object.create({},{passive:{get:function(){B=!0}}});window.addEventListener("test",ee,q),window.removeEventListener("test",ee,q)}catch(e){}var U,V,_,J,X,Q,Y,K=Date.now||function(){return(new Date).getTime()},G={bodyOffset:function(){return document.body.offsetHeight+ge("marginTop")+ge("marginBottom")},offset:function(){return G.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return H.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,ve(G))},min:function(){return Math.min.apply(null,ve(G))},grow:function(){return G.max()},lowestElement:function(){return Math.max(G.bodyOffset()||G.documentElementOffset(),we("bottom",be()))},taggedElement:function(){return ye("bottom","data-iframe-height")}},Z={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return H.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(Z.bodyScroll(),Z.documentElementScroll())},max:function(){return Math.max.apply(null,ve(Z))},min:function(){return Math.min.apply(null,ve(Z))},rightMostElement:function(){return we("right",be())},taggedElement:function(){return ye("right","data-iframe-width")}},$=(U=Oe,X=null,Q=0,Y=function(){Q=K(),X=null,J=U.apply(V,_),X||(V=_=null)},function(){var e=K();Q||(Q=e);var t=z-(e-Q);return V=this,_=arguments,t<=0||t>z?(X&&(clearTimeout(X),X=null),Q=e,J=U.apply(V,_),X||(V=_=null)):X||(X=setTimeout(Y,t)),J});te(window,"message",(function(t){var n={init:function(){g=t.data,I=t.source,ae(),l=!1,setTimeout((function(){h=!1}),d)},reset:function(){h?ie("Page reset ignored by init"):(ie("Page size reset by host page"),xe("resetPage"))},resize:function(){Te("resizeParent","Parent window requested size check")},moveToAnchor:function(){w.findTarget(i())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var e=i();ie("PageInfoFromParent called from parent: "+e),W(JSON.parse(e)),ie(" --")},message:function(){var e=i();ie("onMessage called from parent: "+e),A(JSON.parse(e)),ie(" --")}};function o(){return t.data.split("]")[1].split(":")[0]}function i(){return t.data.substr(t.data.indexOf(":")+1)}function r(){return t.data.split(":")[2]in{true:1,false:1}}function a(){var i=o();i in n?n[i]():!e.exports&&"iFrameResize"in window||"jQuery"in window&&"iFrameResize"in window.jQuery.prototype||r()||re("Unexpected message ("+t.data+")")}O===(""+t.data).substr(0,T)&&(!1===l?a():r()?n.init():ie('Ignored message of type "'+o()+'". Received before initialization.'))})),te(window,"readystatechange",Se),Se()}function ee(){}function te(e,t,n,o){e.addEventListener(t,n,!!B&&(o||{}))}function ne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function oe(e){return O+"["+E+"] "+e}function ie(e){b&&"object"==typeof window.console&&console.log(oe(e))}function re(e){"object"==typeof window.console&&console.warn(oe(e))}function ae(){var e;!function(){function e(e){return"true"===e}var a=g.substr(T).split(":");E=a[0],i=t!==a[1]?Number(a[1]):i,u=t!==a[2]?e(a[2]):u,b=t!==a[3]?e(a[3]):b,v=t!==a[4]?Number(a[4]):v,n=t!==a[6]?e(a[6]):n,r=a[7],p=t!==a[8]?a[8]:p,o=a[9],c=a[10],k=t!==a[11]?Number(a[11]):k,w.enable=t!==a[12]&&e(a[12]),M=t!==a[13]?a[13]:M,F=t!==a[14]?a[14]:F}(),ie("Initialising iFrame ("+location.href+")"),function(){function e(){var e=window.iFrameResizer;ie("Reading data from page: "+JSON.stringify(e)),Object.keys(e).forEach(ce,e),A="onMessage"in e?e.onMessage:A,L="onReady"in e?e.onReady:L,S="targetOrigin"in e?e.targetOrigin:S,p="heightCalculationMethod"in e?e.heightCalculationMethod:p,F="widthCalculationMethod"in e?e.widthCalculationMethod:F}function t(e,t){return"function"==typeof e&&(ie("Setup custom "+t+"CalcMethod"),H[t]=e,e="custom"),e}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),p=t(p,"height"),F=t(F,"width"));ie("TargetOrigin for parent set to: "+S)}(),function(){t===r&&(r=i+"px");ue("margin",function(e,t){-1!==t.indexOf("-")&&(re("Negative CSS value ignored for "+e),t="");return t}("margin",r))}(),ue("background",o),ue("padding",c),(e=document.createElement("div")).style.clear="both",e.style.display="block",e.style.height="0",document.body.appendChild(e),fe(),me(),document.documentElement.style.height="",document.body.style.height="",ie('HTML & body height set to "auto"'),ie("Enable public methods"),N.parentIFrame={autoResize:function(e){return!0===e&&!1===n?(n=!0,pe()):!1===e&&!0===n&&(n=!1,de("remove"),null!==a&&a.disconnect(),clearInterval(y)),Ie(0,0,"autoResize",JSON.stringify(n)),n},close:function(){Ie(0,0,"close")},getId:function(){return E},getPageInfo:function(e){"function"==typeof e?(W=e,Ie(0,0,"pageInfo")):(W=function(){},Ie(0,0,"pageInfoStop"))},moveToAnchor:function(e){w.findTarget(e)},reset:function(){Me("parentIFrame.reset")},scrollTo:function(e,t){Ie(t,e,"scrollTo")},scrollToOffset:function(e,t){Ie(t,e,"scrollToOffset")},sendMessage:function(e,t){Ie(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod:function(e){p=e,fe()},setWidthCalculationMethod:function(e){F=e,me()},setTargetOrigin:function(e){ie("Set targetOrigin: "+e),S=e},size:function(e,t){Te("size","parentIFrame.size("+(e||"")+(t?","+t:"")+")",e,t)}},pe(),w=function(){function e(){return{x:window.pageXOffset!==t?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==t?window.pageYOffset:document.documentElement.scrollTop}}function n(t){var n=t.getBoundingClientRect(),o=e();return{x:parseInt(n.left,10)+parseInt(o.x,10),y:parseInt(n.top,10)+parseInt(o.y,10)}}function o(e){function o(e){var t=n(e);ie("Moving to in page link (#"+i+") at x: "+t.x+" y: "+t.y),Ie(t.y,t.x,"scrollToOffset")}var i=e.split("#")[1]||e,r=decodeURIComponent(i),a=document.getElementById(r)||document.getElementsByName(r)[0];t!==a?o(a):(ie("In page link (#"+i+") not found in iFrame, so sending to parent"),Ie(0,0,"inPageLink","#"+i))}function i(){""!==location.hash&&"#"!==location.hash&&o(location.href)}function r(){function e(e){function t(e){e.preventDefault(),o(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&te(e,"click",t)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),e)}function a(){te(window,"hashchange",i)}function c(){setTimeout(i,d)}function u(){Array.prototype.forEach&&document.querySelectorAll?(ie("Setting up location.hash handlers"),r(),a(),c()):re("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}w.enable?u():ie("In page linking not enabled");return{findTarget:o}}(),Te("init","Init message from host page"),L()}function ce(e){var t=e.split("Callback");if(2===t.length){var n="on"+t[0].charAt(0).toUpperCase()+t[0].slice(1);this[n]=this[e],delete this[e],re("Deprecated: '"+e+"' has been renamed '"+n+"'. The old method will be removed in the next major version.")}}function ue(e,n){t!==n&&""!==n&&"null"!==n&&(document.body.style[e]=n,ie("Body "+e+' set to "'+n+'"'))}function se(e){var t={add:function(t){function n(){Te(e.eventName,e.eventType)}D[t]=n,te(window,t,n,{passive:!0})},remove:function(e){var t,n,o,i=D[e];delete D[e],t=window,n=e,o=i,t.removeEventListener(n,o,!1)}};e.eventNames&&Array.prototype.map?(e.eventName=e.eventNames[0],e.eventNames.map(t[e.method])):t[e.method](e.eventName),ie(ne(e.method)+" event listener: "+e.eventType)}function de(e){se({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),se({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),se({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),se({method:e,eventType:"Input",eventName:"input"}),se({method:e,eventType:"Mouse Up",eventName:"mouseup"}),se({method:e,eventType:"Mouse Down",eventName:"mousedown"}),se({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),se({method:e,eventType:"Print",eventName:["afterprint","beforeprint"]}),se({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),se({method:e,eventType:"Touch Start",eventName:"touchstart"}),se({method:e,eventType:"Touch End",eventName:"touchend"}),se({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),se({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),se({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),se({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===M&&se({method:e,eventType:"IFrame Resized",eventName:"resize"})}function le(e,t,n,o){return t!==e&&(e in n||(re(e+" is not a valid option for "+o+"CalculationMethod."),e=t),ie(o+' calculation method set to "'+e+'"')),e}function fe(){p=le(p,m,G,"height")}function me(){F=le(F,j,Z,"width")}function pe(){var e;!0===n?(de("add"),e=0>v,window.MutationObserver||window.WebKitMutationObserver?e?he():a=function(){function e(e){function t(e){!1===e.complete&&(ie("Attach listeners to "+e.src),e.addEventListener("load",r,!1),e.addEventListener("error",a,!1),s.push(e))}"attributes"===e.type&&"src"===e.attributeName?t(e.target):"childList"===e.type&&Array.prototype.forEach.call(e.target.querySelectorAll("img"),t)}function n(e){s.splice(s.indexOf(e),1)}function o(e){ie("Remove listeners from "+e.src),e.removeEventListener("load",r,!1),e.removeEventListener("error",a,!1),n(e)}function i(e,n,i){o(e.target),Te(n,i+": "+e.target.src,t,t)}function r(e){i(e,"imageLoad","Image loaded")}function a(e){i(e,"imageLoadFailed","Image load failed")}function c(t){Te("mutationObserver","mutationObserver: "+t[0].target+" "+t[0].type),t.forEach(e)}function u(){var e=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return l=new d(c),ie("Create body MutationObserver"),l.observe(e,t),l}var s=[],d=window.MutationObserver||window.WebKitMutationObserver,l=u();return{disconnect:function(){"disconnect"in l&&(ie("Disconnect body MutationObserver"),l.disconnect(),s.forEach(o))}}}():(ie("MutationObserver not supported in this browser!"),he())):ie("Auto Resize disabled")}function he(){0!==v&&(ie("setInterval: "+v+"ms"),y=setInterval((function(){Te("interval","setInterval: "+v)}),Math.abs(v)))}function ge(e,t){var n=0;return t=t||document.body,n=null!==(n=document.defaultView.getComputedStyle(t,null))?n[e]:0,parseInt(n,10)}function we(e,t){for(var n=t.length,o=0,i=0,r=ne(e),a=K(),c=0;c<n;c++)(o=t[c].getBoundingClientRect()[e]+ge("margin"+r,t[c]))>i&&(i=o);return a=K()-a,ie("Parsed "+n+" HTML elements"),ie("Element position calculated in "+a+"ms"),function(e){e>z/2&&ie("Event throttle increased to "+(z=2*e)+"ms")}(a),i}function ve(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function ye(e,t){var n=document.querySelectorAll("["+t+"]");return 0===n.length&&(re("No tagged elements ("+t+") found on page"),document.querySelectorAll("body *")),we(e,n)}function be(){return document.querySelectorAll("body *")}function Oe(e,n,o,i){var r,a;!function(){function e(e,t){return!(Math.abs(e-t)<=k)}return r=t!==o?o:G[p](),a=t!==i?i:Z[F](),e(f,r)||u&&e(C,a)}()&&"init"!==e?!(e in{init:1,interval:1,size:1})&&(p in x||u&&F in x)?Me(n):e in{interval:1}||ie("No change in size detected"):(Ee(),Ie(f=r,C=a,e))}function Te(e,t,n,o){R&&e in s?ie("Trigger event cancelled: "+e):(e in{reset:1,resetPage:1,init:1}||ie("Trigger event: "+t),"init"===e?Oe(e,t,n,o):$(e,t,n,o))}function Ee(){R||(R=!0,ie("Trigger event lock on")),clearTimeout(P),P=setTimeout((function(){R=!1,ie("Trigger event lock off"),ie("--")}),d)}function xe(e){f=G[p](),C=Z[F](),Ie(f,C,e)}function Me(e){var t=p;p=m,ie("Reset trigger event: "+e),Ee(),xe("reset"),p=t}function Ie(e,n,o,i,r){var a;t===r?r=S:ie("Message targetOrigin: "+r),ie("Sending message to host page ("+(a=E+":"+e+":"+n+":"+o+(t!==i?":"+i:""))+")"),I.postMessage(O+a,r)}function Se(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}}()}))},g="tw-approve-api-action-success",w="tw-approve-api-action-failed",v="tw-approve-api-action-closed";function y(e){var t,n,o=e.token,i=e.approvalPageUrl,r=e.resolve,a=e.reject;document.getElementById("tw-approve-api-action-styles")||(t=document.head,(n=document.createElement("style")).id="tw-approve-api-action-styles",n.appendChild(document.createTextNode("\n .tw-approval-modal-overlay {\n position: fixed;\n bottom: 0;\n left: 0;\n right: 0;\n top: 0;\n height: 100%;\n width: 100%;\n background: rgba(55,81,126,0);\n transition: background-color .35s cubic-bezier(0,.94,.62,1);\n z-index: 1050;\n }\n .tw-approval-modal-overlay--open {\n background: rgba(55,81,126,0.8);\n }\n .tw-approval-modal-wrapper {\n height: 100%;\n width: 100vw;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 16px;\n }\n .tw-approval-modal {\n display: flex;\n max-height: 100%;\n width: 540px;\n background-color: #fff;\n border-radius: 3px;\n box-shadow: 0 5px 15px rgba(0,0,0,.2);\n overflow: auto;\n }\n .tw-approval-modal iframe {\n width: 100%;\n height: 520px;\n transition: height 0.1s ease-in-out;\n }\n")),t.appendChild(n));var c=document.createElement("div");c.id="tw-approval-modal-overlay",c.classList.add("tw-approval-modal-overlay");var u=document.createElement("div");u.classList.add("tw-approval-modal-wrapper"),c.appendChild(u);var s=document.createElement("div");s.classList.add("tw-approval-modal"),u.appendChild(s);var d=document.createElement("iframe");d.name="tw-approve-api-action",d.style.border="0",s.appendChild(d),h.iframeResize({checkOrigin:!1,minHeight:400},d);var l=document.createElement("form"),f=document.createElement("input");l.style.display="none",l.method="POST",l.action=i,f.value=o,f.name="ott",l.appendChild(f),s.appendChild(l),document.body.appendChild(c),c.classList.add("tw-approval-modal-overlay--open"),l.setAttribute("target","tw-approve-api-action"),l.submit();var m=function(e){switch(e.data){case g:return p(),void r();case w:return p(),void a();case v:p()}},p=function(){var e=document.getElementById("tw-approval-modal-overlay");e.parentNode.removeChild(e),window.removeEventListener("message",m)};c.addEventListener("click",p,{once:!0}),window.addEventListener("message",m)}function b(e){var t=e.token,n=e.approvalPageUrl,o=e.resolve,i=e.reject,r="tw-approve-api-action",a=function(e){var t=e.name,n=e.token,o=e.approvalPageUrl,i=document.createElement("form"),r=document.createElement("input");return i.style.display="none",i.target=t,i.method="POST",i.action=o,r.value=n,r.name="ott",i.appendChild(r),i}({name:r,token:t,approvalPageUrl:n});document.body.appendChild(a);var c=window.open(n,r);a.submit();var u=function(e){switch(e.data){case g:return s(),void o();case w:return s(),void i();case v:s()}},s=function(){c.close(),window.removeEventListener("message",u)};window.addEventListener("message",u)}var O={IFRAME:"iframe",TAB:"tab"},T={PRODUCTION:"production",SANDBOX:"sandbox"},E=function(e){return e===T.SANDBOX?"https://sandbox.transferwise.tech/approve-api-action/":"https://transferwise.com/approve-api-action/"};function x(e){var t=e.token,n=e.flow,o=void 0===n?O.IFRAME:n,i=e.mode,r=void 0===i?T.PRODUCTION:i,a=e.approvalPageUrl;return new Promise((function(e,n){var i={token:t,approvalPageUrl:a||E(r),resolve:e,reject:n};o===O.TAB?b(i):y(i)}))}function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function I(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};e()}function R(e){if(!e||!e.response)return!1;var t=P(e.response),n=e.response.status;return(403===n||400===n)&&t}function P(e){return e&&e.headers&&e.headers.get?e.headers.get("X-2FA-APPROVAL"):null}e.Flow=O,e.Mode=T,e.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return f(t,n).then((function(e){return{response:e,metadata:{scaRequired:!1}}})).catch((function(o){if(R(o)){var i=P(o.response);return k(e.onSCARequired),x({token:i,flow:e.flow,mode:e.mode,approvalPageUrl:e.approvalPageUrl}).then((function(){k(e.onSCACompleted);var o=I(I({},n.headers||{}),{},{"X-2FA-APPROVAL":i});return f(t,I(I({},n),{},{headers:o})).then((function(e){return{response:e,metadata:{scaRequired:!0}}}))}))}throw o})).then((function(e){return n&&n.withMetadata?e:e.response}))}},e.runFlow=x,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@transferwise/approve-api-action-helpers", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "An http client that handles SCA required requests gracefully", | ||
@@ -32,2 +32,5 @@ "main": "dist/main.js", | ||
"@babel/preset-env": "^7.5.5", | ||
"@rollup/plugin-babel": "^5.2.1", | ||
"@rollup/plugin-commonjs": "^16.0.0", | ||
"@rollup/plugin-node-resolve": "^10.0.0", | ||
"@transferwise/eslint-config": "^6.1.0", | ||
@@ -47,2 +50,3 @@ "babel-eslint": "^10.0.2", | ||
"husky": "^4.3.0", | ||
"iframe-resizer": "^4.2.11", | ||
"jest": "^26.6.0", | ||
@@ -53,6 +57,3 @@ "jest-fetch-mock": "^3.0.3", | ||
"rollup": "^2.32.1", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-babel-minify": "^10.0.0", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^7.0.2" | ||
@@ -59,0 +60,0 @@ }, |
/* eslint-disable fp/no-mutation */ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { iframeResize } from 'iframe-resizer'; | ||
import { MESSAGE_SUCCESS, MESSAGE_FAILED, MESSAGE_CLOSED } from './config'; | ||
@@ -31,3 +33,2 @@ | ||
max-height: 100%; | ||
height: 540px; | ||
width: 540px; | ||
@@ -39,2 +40,7 @@ background-color: #fff; | ||
} | ||
.tw-approval-modal iframe { | ||
width: 100%; | ||
height: 520px; | ||
transition: height 0.1s ease-in-out; | ||
} | ||
`; | ||
@@ -69,6 +75,5 @@ | ||
iframe.name = 'tw-approve-api-action'; | ||
iframe.width = '100%'; | ||
iframe.height = '100%'; | ||
iframe.style.border = '0'; | ||
modal.appendChild(iframe); | ||
iframeResize({ checkOrigin: false, minHeight: 400 }, iframe); | ||
@@ -75,0 +80,0 @@ const form = document.createElement('form'); |
55257
15
634
27