idpay-b2b-sdk 2.4.0-beta.0 → 2.4.0-beta.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
- declare const _default: "2.4.0-beta.0";
1
+ declare const _default: "2.4.0-beta.1";
2
2
  export default _default;
package/index.esm.js CHANGED
@@ -1 +1 @@
1
- function t(t,n,e,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?n(c):Promise.resolve(c).then(r,o)}function n(n){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=n.apply(e,r);function u(n){t(a,o,i,u,c,"next",n)}function c(n){t(a,o,i,u,c,"throw",n)}u(void 0)}))}}function e(t,n,e){return(n=function(t){var n=function(t,n){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,n);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==typeof n?n:n+""}(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function r(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function o(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(n){e(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(o,n))}))}return t}function i(t,n){if(null==t)return{};var e,r,o=function(t,n){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==n.indexOf(r))continue;e[r]=t[r]}return e}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)e=i[r],-1===n.indexOf(e)&&{}.propertyIsEnumerable.call(t,e)&&(o[e]=t[e])}return o}function a(){a=function(){return n};var t,n={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,n,e){t[n]=e.value},i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{l({},"")}catch(t){l=function(t,n,e){return t[n]=e}}function f(t,n,e,r){var i=n&&n.prototype instanceof b?n:b,a=Object.create(i.prototype),u=new C(r||[]);return o(a,"_invoke",{value:D(t,e,u)}),a}function d(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=f;var p="suspendedStart",h="suspendedYield",v="executing",y="completed",m={};function b(){}function g(){}function w(){}var E={};l(E,u,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(U([])));x&&x!==e&&r.call(x,u)&&(E=x);var O=w.prototype=b.prototype=Object.create(E);function P(t){["next","throw","return"].forEach((function(n){l(t,n,(function(t){return this._invoke(n,t)}))}))}function S(t,n){function e(o,i,a,u){var c=d(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,a,u)}),(function(t){e("throw",t,a,u)})):n.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new n((function(n,o){e(t,r,n,o)}))}return i=i?i.then(o,o):o()}})}function D(n,e,r){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var u=r.delegate;if(u){var c=T(u,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===p)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var s=d(n,e,r);if("normal"===s.type){if(o=r.done?y:h,s.arg===m)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=y,r.method="throw",r.arg=s.arg)}}}function T(n,e){var r=e.method,o=n.iterator[r];if(o===t)return e.delegate=null,"throw"===r&&n.iterator.return&&(e.method="return",e.arg=t,T(n,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=d(o,n.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[n.resultName]=a.value,e.next=n.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function _(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function I(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function U(n){if(n||""===n){var e=n[u];if(e)return e.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var o=-1,i=function e(){for(;++o<n.length;)if(r.call(n,o))return e.value=n[o],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof n+" is not iterable")}return g.prototype=w,o(O,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:g,configurable:!0}),g.displayName=l(w,s,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===g||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},n.awrap=function(t){return{__await:t}},P(S.prototype),l(S.prototype,c,(function(){return this})),n.AsyncIterator=S,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new S(f(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},P(O),l(O,s,"Generator"),l(O,u,(function(){return this})),l(O,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var n=Object(t),e=[];for(var r in n)e.push(r);return e.reverse(),function t(){for(;e.length;){var r=e.pop();if(r in n)return t.value=r,t.done=!1,t}return t.done=!0,t}},n.values=U,C.prototype={constructor:C,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!n)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var e=this;function o(r,o){return u.type="throw",u.arg=n,e.next=r,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=n,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),m},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),I(e),m}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var r=e.completion;if("throw"===r.type){var o=r.arg;I(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:U(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),m}},n}var u,c,s,l,f,d,p,h="2.4.0-beta.0",v=["hasPayments"],y=["transactionId","token","onFinish","onWidgetVisibilityChange"],m=["transactionId","token","onFinish"],b=!1,g=!1,w=0,E="REDIRECT",k="SILENT",x="prod",O="idpay",P="idcash",S="byunico",D="you",T=e(e(e({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),x,"https://idpay.unico.io"),_={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},I=function(){console.log(">>> reset"),u=void 0,c=void 0,b=!1,g=!1,s=void 0,l=void 0,f=void 0,w+=1},C=function(){if(l)return Promise.resolve();(l=document.createElement("script")).src="".concat(c,"/sdk-assets/index.js");var t=new Promise((function(t){l.onload=t}));return document.body.appendChild(l),Promise.all([t])},U=function(){var t=document.createElement("link");t.setAttribute("href","".concat(c,"/sdk-assets/assets/styles.css")),t.setAttribute("rel","stylesheet");var n=new Promise((function(n){t.onload=n}));return document.head.appendChild(t),Promise.all([n])},N=function(){var t=n(a().mark((function t(n){var e,r,o,i,l,d,p,v,y,m,O,P,S,D,I;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.token,i=n.useCurrentOrigin,l=n.env,d=void 0===l?x:l,p=n.type,v=void 0===p?"IFRAME":p,y=n.app,m=n.hasPayments,O=n.inline,u=v,c=i?window.location.origin:T[d],P=w,S=function(){return O&&P!==w},t.next=7,C();case 7:if(!S()){t.next=9;break}return t.abrupt("return",void 0);case 9:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=u,t.next=t.t0===k?13:t.t0===E?18:19;break;case 13:return t.next=15,UnicoSDKAssets.clientBoxControl.initSilent();case 15:return s=t.sent,D={collectionId:s},t.abrupt("break",26);case 18:return t.abrupt("break",26);case 19:return t.next=21,U();case 21:if(!S()){t.next=23;break}return t.abrupt("return",void 0);case 23:return t.next=25,UnicoSDKAssets.clientBoxControl.create({host:c,token:o,sdkVersion:h,app:y,env:d,hasPayments:m,inline:O});case 25:D=t.sent;case 26:if(!S()){t.next=28;break}return t.abrupt("return",void 0);case 28:if(b=!0,f=D,I=!(null!==(e=D)&&void 0!==e&&e.statusPreValidation)||(null===(r=D)||void 0===r?void 0:r.statusPreValidation)===_.DEVICE_SUPPORTED,g&&I&&F(g),!D){t.next=34;break}return t.abrupt("return",D);case 34:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),L=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Warning: The `init()` function is deprecated and will be removed in future versions.Please initialize directly on the product object, e.g., `IDPaySDK.init({ ... })`, `IDCashSDK.init({ ... })`, `ByUnicoSDK.init({ ... })` or `YouSDK.init({ ... })`. See our documentation for more details."),t.abrupt("return",N(n));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),R=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initByUnicoSDK > options:",n),t.abrupt("return",N(o(o({},n),{},{app:S})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),A=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",n),t.abrupt("return",N(o(o({},n),{},{app:O})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),j=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDCashSDK > options:",n),t.next=3,N(o(o({},n),{},{app:P}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),V=function(){var t=n(a().mark((function t(n){var e,r;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.hasPayments,r=i(n,v),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,N(o(o({},r),{},{app:D,hasPayments:e}));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),B=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,i=t.onProgressUpdate,a={transactionId:n,token:e,onFinish:r,onWidgetVisibilityChange:o,onProgressUpdate:i,onLoad:t.onLoad,onReady:t.onReady,onClick:t.onClick,host:c,sdkVersion:h,collectionId:s};if(console.log("open",a),b)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,a),"function"!=typeof i||u!==k&&u!==E||console.warn("Warning: onProgressUpdate is ignored when the SDK type is ".concat(u,": ")+"there is no iframe to report milestones."),u){case k:UnicoSDKAssets.clientBoxControl.verify(a);break;case E:UnicoSDKAssets.clientBoxControl.redirect(n,e,c,h);break;default:UnicoSDKAssets.clientBoxControl.open(a)}else g=a},F=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=i(t,m);B(o({transactionId:n,token:e,onFinish:r},a))},K=function(){I(),UnicoSDKAssets.clientBoxControl.close()},W=function(){var t=n(a().mark((function t(e){var r,o,i,u,c,s,l,d,p,v,y,m,g,w,E;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.container,u=e.id,c=e.token,s=e.env,l=void 0===s?x:s,d=e.app,p=e.config,v=e.onFinish,y=e.onReady,m=e.onClick,g=e.onError,b){t.next=4;break}return t.next=4,N({token:c,env:l,app:d});case 4:if((null===(r=f)||void 0===r?void 0:r.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=7;break}return null==g||g({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return",{destroy:function(){},deviceSupported:!1});case 7:if("function"==typeof(null===(o=UnicoSDKAssets)||void 0===o||null===(o=o.clientBoxControl)||void 0===o?void 0:o.renderButton)){t.next=11;break}return console.warn("Warning: the loaded sdk-assets does not expose clientBoxControl.renderButton. Deploy the sdk-assets build that includes button-box (or serve it locally and init with useCurrentOrigin)."),null==g||g({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",{destroy:function(){},refresh:function(){},deviceSupported:!0});case 11:return E=function(){var t=n(a().mark((function t(n){var e,r,o,i,u,c,s,l;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o="payment"===(null==n?void 0:n.flow),i=!(null===(e=f)||void 0===e||!e.statusPreValidation),u="function"==typeof(null===(r=UnicoSDKAssets)||void 0===r||null===(r=r.clientBoxControl)||void 0===r?void 0:r.preValidateDevice),!o||i||!u){t.next=11;break}return t.next=6,UnicoSDKAssets.clientBoxControl.preValidateDevice();case 6:if(f=t.sent,(null===(c=f)||void 0===c?void 0:c.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=11;break}return null===(s=w)||void 0===s||null===(l=s.destroy)||void 0===l||l.call(s),null==g||g({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return");case 11:null==y||y(n);case 12:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),w=UnicoSDKAssets.clientBoxControl.renderButton({container:i,token:c,env:l,sdkVersion:h,config:p,onReady:E,onError:g,onClicked:function(){null==m||m(),B({transactionId:u,token:c,onFinish:v})}}),t.abrupt("return",{destroy:function(){var t,n;return null===(t=w)||void 0===t||null===(n=t.destroy)||void 0===n?void 0:n.call(t)},refresh:function(){var t,n;return null===(t=w)||void 0===t||null===(n=t.refresh)||void 0===n?void 0:n.call(t)},deviceSupported:!0});case 14:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),G="unico_iframe_embedded",M=Symbol("init timed out"),Y=function(t){if(t.querySelector("iframe")){var n=new MutationObserver((function(){t.querySelector("iframe")||(n.disconnect(),t.remove())}));n.observe(t,{childList:!0})}else t.remove()},q=function(){var t=n(a().mark((function t(n){var e,r,o,i,u,c,s,l,f,p,h,v,y,m,b,g,w,E,k,O,P,D,T,C,U;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.container,u=n.id,c=n.token,s=n.env,l=void 0===s?x:s,f=n.useCurrentOrigin,p=n.onReady,h=n.onClick,v=n.onFinish,y=n.onProgressUpdate,m=n.onError,b={destroy:function(){}},g="string"==typeof i?document.querySelector(i):i){t.next=6;break}return null==m||m({reason:"CONTAINER_NOT_FOUND"}),t.abrupt("return",b);case 6:if(g.getBoundingClientRect().width){t.next=9;break}return null==m||m({reason:"CONTAINER_UNSUPPORTED"}),t.abrupt("return",b);case 9:return E=!1,k=!1,O=function(){var t,n,e,r;null===(t=window.UnicoSDKAssets)||void 0===t||null===(n=t.trackMetric)||void 0===n||n.call(t,null!==(e=null===(r=window.UnicoSDKAssets.METRIC_EVENTS)||void 0===r?void 0:r.BUTTON_ERROR)&&void 0!==e?e:"journey_sdk_button_error",{reason:"IFRAME_BLOCKED"}),null==m||m({reason:"IFRAME_BLOCKED"})},P={destroy:function(){clearTimeout(w),d===P&&(d=void 0,E?K():I(),Y(D))}},null===(e=d)||void 0===e||e.destroy(),d=P,null===(r=document.getElementById(G))||void 0===r||r.remove(),(D=document.createElement("div")).id=G,g.appendChild(D),C=new Promise((function(t){T=setTimeout((function(){return t(M)}),8e3)})),t.prev=20,t.next=23,Promise.race([N({token:c,env:l,useCurrentOrigin:f,app:S,inline:!0}),C]);case 23:U=t.sent,t.next=31;break;case 26:throw t.prev=26,t.t0=t.catch(20),P.destroy(),D.remove(),t.t0;case 31:return t.prev=31,clearTimeout(T),t.finish(31);case 34:if(U!==M){t.next=39;break}return P.destroy(),D.remove(),O(),t.abrupt("return",b);case 39:if(D.isConnected){t.next=43;break}return P.destroy(),null==m||m({reason:"CONTAINER_NOT_FOUND"}),t.abrupt("return",b);case 43:if(UnicoSDKAssets.INLINE_BUTTON){t.next=49;break}return E=!0,P.destroy(),D.remove(),null==m||m({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",b);case 49:if((null===(o=U)||void 0===o?void 0:o.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=54;break}return P.destroy(),D.remove(),null==m||m({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return",b);case 54:return w=setTimeout(O,8e3),B({transactionId:u,token:c,onProgressUpdate:y,onLoad:function(){return clearTimeout(w)},onReady:p,onClick:h,onFinish:function(t){k||(k=!0,clearTimeout(w),d===P&&(d=void 0),I(),null==v||v(t),Y(D))}}),E=!0,t.abrupt("return",P);case 58:case"end":return t.stop()}}),t,null,[[20,26,31,34]])})));return function(n){return t.apply(this,arguments)}}(),z=function(t){var n=p?p.then((function(){return q(t)})):q(t),e=n.then((function(){}),(function(){}));return p=e,e.then((function(){p===e&&(p=void 0)})),n},Z={init:R,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=t.onWidgetVisibilityChange,u=i(t,y);B(o({transactionId:n,token:e,onFinish:function(t){I(),null==r||r(t)},onWidgetVisibilityChange:a},u))},renderButton:function(){var t=n(a().mark((function t(e){var r,o;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,z(e);case 2:return r=t.sent,o=!1,t.abrupt("return",{destroy:function(){o=!0,r.destroy()},refresh:function(){var t=n(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=!1,r.destroy(),t.next=4,z(e);case 4:r=t.sent,o&&r.destroy();case 6:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()});case 5:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}()},H={init:A,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;B({transactionId:n,token:e,onFinish:r})}},J={init:j,close:K,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;B({transactionId:n,token:e,onFinish:r})}},Q={init:V,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;B({transactionId:n,token:e,onFinish:r})},renderButton:function(t){return W(o(o({},t),{},{app:D}))}},X={init:L,close:K,open:F,renderButton:W};export{Z as ByUnicoSDK,J as IDCashSDK,H as IDPaySDK,_ as PRE_VALIDATION_STATUS,X as UnicoSDK,Q as YouSDK};
1
+ function t(t,n,e,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?n(c):Promise.resolve(c).then(r,o)}function n(n){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=n.apply(e,r);function u(n){t(a,o,i,u,c,"next",n)}function c(n){t(a,o,i,u,c,"throw",n)}u(void 0)}))}}function e(t,n,e){return(n=function(t){var n=function(t,n){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,n);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==typeof n?n:n+""}(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function r(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function o(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(n){e(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(o,n))}))}return t}function i(t,n){if(null==t)return{};var e,r,o=function(t,n){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==n.indexOf(r))continue;e[r]=t[r]}return e}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)e=i[r],-1===n.indexOf(e)&&{}.propertyIsEnumerable.call(t,e)&&(o[e]=t[e])}return o}function a(){a=function(){return n};var t,n={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,n,e){t[n]=e.value},i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{l({},"")}catch(t){l=function(t,n,e){return t[n]=e}}function f(t,n,e,r){var i=n&&n.prototype instanceof b?n:b,a=Object.create(i.prototype),u=new C(r||[]);return o(a,"_invoke",{value:D(t,e,u)}),a}function d(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=f;var p="suspendedStart",h="suspendedYield",v="executing",y="completed",m={};function b(){}function g(){}function w(){}var E={};l(E,u,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(U([])));x&&x!==e&&r.call(x,u)&&(E=x);var P=w.prototype=b.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(n){l(t,n,(function(t){return this._invoke(n,t)}))}))}function S(t,n){function e(o,i,a,u){var c=d(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,a,u)}),(function(t){e("throw",t,a,u)})):n.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new n((function(n,o){e(t,r,n,o)}))}return i=i?i.then(o,o):o()}})}function D(n,e,r){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var u=r.delegate;if(u){var c=T(u,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===p)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var s=d(n,e,r);if("normal"===s.type){if(o=r.done?y:h,s.arg===m)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=y,r.method="throw",r.arg=s.arg)}}}function T(n,e){var r=e.method,o=n.iterator[r];if(o===t)return e.delegate=null,"throw"===r&&n.iterator.return&&(e.method="return",e.arg=t,T(n,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=d(o,n.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[n.resultName]=a.value,e.next=n.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function _(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function I(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function U(n){if(n||""===n){var e=n[u];if(e)return e.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var o=-1,i=function e(){for(;++o<n.length;)if(r.call(n,o))return e.value=n[o],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof n+" is not iterable")}return g.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:g,configurable:!0}),g.displayName=l(w,s,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===g||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},n.awrap=function(t){return{__await:t}},O(S.prototype),l(S.prototype,c,(function(){return this})),n.AsyncIterator=S,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new S(f(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(P),l(P,s,"Generator"),l(P,u,(function(){return this})),l(P,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var n=Object(t),e=[];for(var r in n)e.push(r);return e.reverse(),function t(){for(;e.length;){var r=e.pop();if(r in n)return t.value=r,t.done=!1,t}return t.done=!0,t}},n.values=U,C.prototype={constructor:C,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!n)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var e=this;function o(r,o){return u.type="throw",u.arg=n,e.next=r,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=n,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),m},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),I(e),m}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var r=e.completion;if("throw"===r.type){var o=r.arg;I(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:U(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),m}},n}var u,c,s,l,f,d,p,h="2.4.0-beta.1",v=["hasPayments"],y=["transactionId","token","onFinish","onWidgetVisibilityChange"],m=["transactionId","token","onFinish"],b=!1,g=!1,w=0,E="REDIRECT",k="SILENT",x="prod",P="idpay",O="idcash",S="byunico",D="you",T=e(e(e({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),x,"https://idpay.unico.io"),_={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},I=function(){console.log(">>> reset"),u=void 0,c=void 0,b=!1,g=!1,s=void 0,l=void 0,f=void 0,w+=1},C=function(){if(l)return Promise.resolve();(l=document.createElement("script")).src="".concat(c,"/sdk-assets/index.js");var t=new Promise((function(t){l.onload=t}));return document.body.appendChild(l),Promise.all([t])},U=function(){var t=document.createElement("link");t.setAttribute("href","".concat(c,"/sdk-assets/assets/styles.css")),t.setAttribute("rel","stylesheet");var n=new Promise((function(n){t.onload=n}));return document.head.appendChild(t),Promise.all([n])},N=function(){var t=n(a().mark((function t(n){var e,r,o,i,l,d,p,v,y,m,P,O,S,D,I;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.token,i=n.useCurrentOrigin,l=n.env,d=void 0===l?x:l,p=n.type,v=void 0===p?"IFRAME":p,y=n.app,m=n.hasPayments,P=n.inline,u=v,c=i?window.location.origin:T[d],O=w,S=function(){return P&&O!==w},t.next=7,C();case 7:if(!S()){t.next=9;break}return t.abrupt("return",void 0);case 9:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=u,t.next=t.t0===k?13:t.t0===E?18:19;break;case 13:return t.next=15,UnicoSDKAssets.clientBoxControl.initSilent();case 15:return s=t.sent,D={collectionId:s},t.abrupt("break",26);case 18:return t.abrupt("break",26);case 19:return t.next=21,U();case 21:if(!S()){t.next=23;break}return t.abrupt("return",void 0);case 23:return t.next=25,UnicoSDKAssets.clientBoxControl.create({host:c,token:o,sdkVersion:h,app:y,env:d,hasPayments:m,inline:P});case 25:D=t.sent;case 26:if(!S()){t.next=28;break}return t.abrupt("return",void 0);case 28:if(b=!0,f=D,I=!(null!==(e=D)&&void 0!==e&&e.statusPreValidation)||(null===(r=D)||void 0===r?void 0:r.statusPreValidation)===_.DEVICE_SUPPORTED,g&&I&&F(g),!D){t.next=34;break}return t.abrupt("return",D);case 34:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),L=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Warning: The `init()` function is deprecated and will be removed in future versions.Please initialize directly on the product object, e.g., `IDPaySDK.init({ ... })`, `IDCashSDK.init({ ... })`, `ByUnicoSDK.init({ ... })` or `YouSDK.init({ ... })`. See our documentation for more details."),t.abrupt("return",N(n));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),R=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initByUnicoSDK > options:",n),t.abrupt("return",N(o(o({},n),{},{app:S})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),A=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",n),t.abrupt("return",N(o(o({},n),{},{app:P})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),j=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDCashSDK > options:",n),t.next=3,N(o(o({},n),{},{app:O}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),V=function(){var t=n(a().mark((function t(n){var e,r;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.hasPayments,r=i(n,v),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,N(o(o({},r),{},{app:D,hasPayments:e}));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),B=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,i=t.onProgressUpdate,a={transactionId:n,token:e,onFinish:r,onWidgetVisibilityChange:o,onProgressUpdate:i,onLoad:t.onLoad,onReady:t.onReady,onClick:t.onClick,host:c,sdkVersion:h,collectionId:s};if(console.log("open",a),b)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,a),"function"!=typeof i||u!==k&&u!==E||console.warn("Warning: onProgressUpdate is ignored when the SDK type is ".concat(u,": ")+"there is no iframe to report milestones."),u){case k:UnicoSDKAssets.clientBoxControl.verify(a);break;case E:UnicoSDKAssets.clientBoxControl.redirect(n,e,c,h);break;default:UnicoSDKAssets.clientBoxControl.open(a)}else g=a},F=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=i(t,m);B(o({transactionId:n,token:e,onFinish:r},a))},K=function(){I(),UnicoSDKAssets.clientBoxControl.close()},W=function(){var t=n(a().mark((function t(e){var r,o,i,u,c,s,l,d,p,v,y,m,g,w,E,k;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.container,u=e.id,c=e.token,s=e.env,l=void 0===s?x:s,d=e.app,p=e.config,v=e.onFinish,y=e.onProgressUpdate,m=e.onReady,g=e.onClick,w=e.onError,b){t.next=4;break}return t.next=4,N({token:c,env:l,app:d});case 4:if((null===(r=f)||void 0===r?void 0:r.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=7;break}return null==w||w({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return",{destroy:function(){},deviceSupported:!1});case 7:if("function"==typeof(null===(o=UnicoSDKAssets)||void 0===o||null===(o=o.clientBoxControl)||void 0===o?void 0:o.renderButton)){t.next=11;break}return console.warn("Warning: the loaded sdk-assets does not expose clientBoxControl.renderButton. Deploy the sdk-assets build that includes button-box (or serve it locally and init with useCurrentOrigin)."),null==w||w({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",{destroy:function(){},refresh:function(){},deviceSupported:!0});case 11:return k=function(){var t=n(a().mark((function t(n){var e,r,o,i,u,c,s,l;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o="payment"===(null==n?void 0:n.flow),i=!(null===(e=f)||void 0===e||!e.statusPreValidation),u="function"==typeof(null===(r=UnicoSDKAssets)||void 0===r||null===(r=r.clientBoxControl)||void 0===r?void 0:r.preValidateDevice),!o||i||!u){t.next=11;break}return t.next=6,UnicoSDKAssets.clientBoxControl.preValidateDevice();case 6:if(f=t.sent,(null===(c=f)||void 0===c?void 0:c.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=11;break}return null===(s=E)||void 0===s||null===(l=s.destroy)||void 0===l||l.call(s),null==w||w({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return");case 11:null==m||m(n);case 12:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),E=UnicoSDKAssets.clientBoxControl.renderButton({container:i,token:c,env:l,sdkVersion:h,config:p,onReady:k,onError:w,onClicked:function(){null==g||g(),B({transactionId:u,token:c,onFinish:v,onProgressUpdate:y})}}),t.abrupt("return",{destroy:function(){var t,n;return null===(t=E)||void 0===t||null===(n=t.destroy)||void 0===n?void 0:n.call(t)},refresh:function(){var t,n;return null===(t=E)||void 0===t||null===(n=t.refresh)||void 0===n?void 0:n.call(t)},deviceSupported:!0});case 14:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),G="unico_iframe_embedded",M=Symbol("init timed out"),Y=function(t){if(t.querySelector("iframe")){var n=new MutationObserver((function(){t.querySelector("iframe")||(n.disconnect(),t.remove())}));n.observe(t,{childList:!0})}else t.remove()},q=function(){var t=n(a().mark((function t(n){var e,r,o,i,u,c,s,l,f,p,h,v,y,m,b,g,w,E,k,P,O,D,T,C,U;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.container,u=n.id,c=n.token,s=n.env,l=void 0===s?x:s,f=n.useCurrentOrigin,p=n.onReady,h=n.onClick,v=n.onFinish,y=n.onProgressUpdate,m=n.onError,b={destroy:function(){}},g="string"==typeof i?document.querySelector(i):i){t.next=6;break}return null==m||m({reason:"CONTAINER_NOT_FOUND"}),t.abrupt("return",b);case 6:if(g.getBoundingClientRect().width){t.next=9;break}return null==m||m({reason:"CONTAINER_UNSUPPORTED"}),t.abrupt("return",b);case 9:return E=!1,k=!1,P=function(){var t,n,e,r;null===(t=window.UnicoSDKAssets)||void 0===t||null===(n=t.trackMetric)||void 0===n||n.call(t,null!==(e=null===(r=window.UnicoSDKAssets.METRIC_EVENTS)||void 0===r?void 0:r.BUTTON_ERROR)&&void 0!==e?e:"journey_sdk_button_error",{reason:"IFRAME_BLOCKED"}),null==m||m({reason:"IFRAME_BLOCKED"})},O={destroy:function(){clearTimeout(w),d===O&&(d=void 0,E?K():I(),Y(D))}},null===(e=d)||void 0===e||e.destroy(),d=O,null===(r=document.getElementById(G))||void 0===r||r.remove(),(D=document.createElement("div")).id=G,g.appendChild(D),C=new Promise((function(t){T=setTimeout((function(){return t(M)}),8e3)})),t.prev=20,t.next=23,Promise.race([N({token:c,env:l,useCurrentOrigin:f,app:S,inline:!0}),C]);case 23:U=t.sent,t.next=31;break;case 26:throw t.prev=26,t.t0=t.catch(20),O.destroy(),D.remove(),t.t0;case 31:return t.prev=31,clearTimeout(T),t.finish(31);case 34:if(U!==M){t.next=39;break}return O.destroy(),D.remove(),P(),t.abrupt("return",b);case 39:if(D.isConnected){t.next=43;break}return O.destroy(),null==m||m({reason:"CONTAINER_NOT_FOUND"}),t.abrupt("return",b);case 43:if(UnicoSDKAssets.INLINE_BUTTON){t.next=49;break}return E=!0,O.destroy(),D.remove(),null==m||m({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",b);case 49:if((null===(o=U)||void 0===o?void 0:o.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=54;break}return O.destroy(),D.remove(),null==m||m({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return",b);case 54:return w=setTimeout(P,8e3),B({transactionId:u,token:c,onProgressUpdate:y,onLoad:function(){return clearTimeout(w)},onReady:p,onClick:h,onFinish:function(t){k||(k=!0,clearTimeout(w),d===O&&(d=void 0),I(),null==v||v(t),Y(D))}}),E=!0,t.abrupt("return",O);case 58:case"end":return t.stop()}}),t,null,[[20,26,31,34]])})));return function(n){return t.apply(this,arguments)}}(),z=function(t){var n=p?p.then((function(){return q(t)})):q(t),e=n.then((function(){}),(function(){}));return p=e,e.then((function(){p===e&&(p=void 0)})),n},Z={init:R,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=t.onWidgetVisibilityChange,u=i(t,y);B(o({transactionId:n,token:e,onFinish:function(t){I(),null==r||r(t)},onWidgetVisibilityChange:a},u))},renderButton:function(){var t=n(a().mark((function t(e){var r,o;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,z(e);case 2:return r=t.sent,o=!1,t.abrupt("return",{destroy:function(){o=!0,r.destroy()},refresh:function(){var t=n(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=!1,r.destroy(),t.next=4,z(e);case 4:r=t.sent,o&&r.destroy();case 6:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()});case 5:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}()},H={init:A,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;B({transactionId:n,token:e,onFinish:r})}},J={init:j,close:K,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;B({transactionId:n,token:e,onFinish:r})}},Q={init:V,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=t.onProgressUpdate;B({transactionId:n,token:e,onFinish:r,onProgressUpdate:o})},renderButton:function(t){return W(o(o({},t),{},{app:D}))}},X={init:L,close:K,open:F,renderButton:W};export{Z as ByUnicoSDK,J as IDCashSDK,H as IDPaySDK,_ as PRE_VALIDATION_STATUS,X as UnicoSDK,Q as YouSDK};
package/index.js CHANGED
@@ -1 +1 @@
1
- !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).UnicoSDK={})}(this,(function(t){"use strict";function n(t,n,e,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void e(t)}u.done?n(c):Promise.resolve(c).then(r,o)}function e(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))}}function r(t,n,e){return(n=function(t){var n=function(t,n){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,n);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==typeof n?n:n+""}(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function o(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function i(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?o(Object(e),!0).forEach((function(n){r(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):o(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}function a(t,n){if(null==t)return{};var e,r,o=function(t,n){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==n.indexOf(r))continue;e[r]=t[r]}return e}(t,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)e=i[r],-1===n.indexOf(e)&&{}.propertyIsEnumerable.call(t,e)&&(o[e]=t[e])}return o}function u(){u=function(){return n};var t,n={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,n,e){t[n]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{l({},"")}catch(t){l=function(t,n,e){return t[n]=e}}function f(t,n,e,r){var i=n&&n.prototype instanceof b?n:b,a=Object.create(i.prototype),u=new C(r||[]);return o(a,"_invoke",{value:D(t,e,u)}),a}function d(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=f;var p="suspendedStart",h="suspendedYield",v="executing",y="completed",m={};function b(){}function g(){}function w(){}var E={};l(E,a,(function(){return this}));var x=Object.getPrototypeOf,k=x&&x(x(U([])));k&&k!==e&&r.call(k,a)&&(E=k);var O=w.prototype=b.prototype=Object.create(E);function P(t){["next","throw","return"].forEach((function(n){l(t,n,(function(t){return this._invoke(n,t)}))}))}function S(t,n){function e(o,i,a,u){var c=d(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,a,u)}),(function(t){e("throw",t,a,u)})):n.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new n((function(n,o){e(t,r,n,o)}))}return i=i?i.then(o,o):o()}})}function D(n,e,r){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var u=r.delegate;if(u){var c=T(u,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===p)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var s=d(n,e,r);if("normal"===s.type){if(o=r.done?y:h,s.arg===m)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=y,r.method="throw",r.arg=s.arg)}}}function T(n,e){var r=e.method,o=n.iterator[r];if(o===t)return e.delegate=null,"throw"===r&&n.iterator.return&&(e.method="return",e.arg=t,T(n,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=d(o,n.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[n.resultName]=a.value,e.next=n.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function I(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function _(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function U(n){if(n||""===n){var e=n[a];if(e)return e.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var o=-1,i=function e(){for(;++o<n.length;)if(r.call(n,o))return e.value=n[o],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof n+" is not iterable")}return g.prototype=w,o(O,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:g,configurable:!0}),g.displayName=l(w,s,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===g||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(O),t},n.awrap=function(t){return{__await:t}},P(S.prototype),l(S.prototype,c,(function(){return this})),n.AsyncIterator=S,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new S(f(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},P(O),l(O,s,"Generator"),l(O,a,(function(){return this})),l(O,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var n=Object(t),e=[];for(var r in n)e.push(r);return e.reverse(),function t(){for(;e.length;){var r=e.pop();if(r in n)return t.value=r,t.done=!1,t}return t.done=!0,t}},n.values=U,C.prototype={constructor:C,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!n)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var e=this;function o(r,o){return u.type="throw",u.arg=n,e.next=r,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=n,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),m},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),_(e),m}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var r=e.completion;if("throw"===r.type){var o=r.arg;_(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:U(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),m}},n}var c,s,l,f,d,p,h,v="2.4.0-beta.0",y=["hasPayments"],m=["transactionId","token","onFinish","onWidgetVisibilityChange"],b=["transactionId","token","onFinish"],g=!1,w=!1,E=0,x="REDIRECT",k="SILENT",O="prod",P="idpay",S="idcash",D="byunico",T="you",I=r(r(r({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),O,"https://idpay.unico.io"),_={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},C=function(){console.log(">>> reset"),c=void 0,s=void 0,g=!1,w=!1,l=void 0,f=void 0,d=void 0,E+=1},U=function(){if(f)return Promise.resolve();(f=document.createElement("script")).src="".concat(s,"/sdk-assets/index.js");var t=new Promise((function(t){f.onload=t}));return document.body.appendChild(f),Promise.all([t])},N=function(){var t=document.createElement("link");t.setAttribute("href","".concat(s,"/sdk-assets/assets/styles.css")),t.setAttribute("rel","stylesheet");var n=new Promise((function(n){t.onload=n}));return document.head.appendChild(t),Promise.all([n])},L=function(){var t=e(u().mark((function t(n){var e,r,o,i,a,f,p,h,y,m,b,P,S,D,T;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.token,i=n.useCurrentOrigin,a=n.env,f=void 0===a?O:a,p=n.type,h=void 0===p?"IFRAME":p,y=n.app,m=n.hasPayments,b=n.inline,c=h,s=i?window.location.origin:I[f],P=E,S=function(){return b&&P!==E},t.next=7,U();case 7:if(!S()){t.next=9;break}return t.abrupt("return",void 0);case 9:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=c,t.next=t.t0===k?13:t.t0===x?18:19;break;case 13:return t.next=15,UnicoSDKAssets.clientBoxControl.initSilent();case 15:return l=t.sent,D={collectionId:l},t.abrupt("break",26);case 18:return t.abrupt("break",26);case 19:return t.next=21,N();case 21:if(!S()){t.next=23;break}return t.abrupt("return",void 0);case 23:return t.next=25,UnicoSDKAssets.clientBoxControl.create({host:s,token:o,sdkVersion:v,app:y,env:f,hasPayments:m,inline:b});case 25:D=t.sent;case 26:if(!S()){t.next=28;break}return t.abrupt("return",void 0);case 28:if(g=!0,d=D,T=!(null!==(e=D)&&void 0!==e&&e.statusPreValidation)||(null===(r=D)||void 0===r?void 0:r.statusPreValidation)===_.DEVICE_SUPPORTED,w&&T&&F(w),!D){t.next=34;break}return t.abrupt("return",D);case 34:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),A=function(){var t=e(u().mark((function t(n){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Warning: The `init()` function is deprecated and will be removed in future versions.Please initialize directly on the product object, e.g., `IDPaySDK.init({ ... })`, `IDCashSDK.init({ ... })`, `ByUnicoSDK.init({ ... })` or `YouSDK.init({ ... })`. See our documentation for more details."),t.abrupt("return",L(n));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),R=function(){var t=e(u().mark((function t(n){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initByUnicoSDK > options:",n),t.abrupt("return",L(i(i({},n),{},{app:D})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),K=function(){var t=e(u().mark((function t(n){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",n),t.abrupt("return",L(i(i({},n),{},{app:P})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),j=function(){var t=e(u().mark((function t(n){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDCashSDK > options:",n),t.next=3,L(i(i({},n),{},{app:S}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),V=function(){var t=e(u().mark((function t(n){var e,r;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.hasPayments,r=a(n,y),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,L(i(i({},r),{},{app:T,hasPayments:e}));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),B=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,i=t.onProgressUpdate,a={transactionId:n,token:e,onFinish:r,onWidgetVisibilityChange:o,onProgressUpdate:i,onLoad:t.onLoad,onReady:t.onReady,onClick:t.onClick,host:s,sdkVersion:v,collectionId:l};if(console.log("open",a),g)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,a),"function"!=typeof i||c!==k&&c!==x||console.warn("Warning: onProgressUpdate is ignored when the SDK type is ".concat(c,": ")+"there is no iframe to report milestones."),c){case k:UnicoSDKAssets.clientBoxControl.verify(a);break;case x:UnicoSDKAssets.clientBoxControl.redirect(n,e,s,v);break;default:UnicoSDKAssets.clientBoxControl.open(a)}else w=a},F=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=a(t,b);B(i({transactionId:n,token:e,onFinish:r},o))},W=function(){C(),UnicoSDKAssets.clientBoxControl.close()},G=function(){var t=e(u().mark((function t(n){var r,o,i,a,c,s,l,f,p,h,y,m,b,w,E;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.container,a=n.id,c=n.token,s=n.env,l=void 0===s?O:s,f=n.app,p=n.config,h=n.onFinish,y=n.onReady,m=n.onClick,b=n.onError,g){t.next=4;break}return t.next=4,L({token:c,env:l,app:f});case 4:if((null===(r=d)||void 0===r?void 0:r.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=7;break}return null==b||b({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return",{destroy:function(){},deviceSupported:!1});case 7:if("function"==typeof(null===(o=UnicoSDKAssets)||void 0===o||null===(o=o.clientBoxControl)||void 0===o?void 0:o.renderButton)){t.next=11;break}return console.warn("Warning: the loaded sdk-assets does not expose clientBoxControl.renderButton. Deploy the sdk-assets build that includes button-box (or serve it locally and init with useCurrentOrigin)."),null==b||b({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",{destroy:function(){},refresh:function(){},deviceSupported:!0});case 11:return E=function(){var t=e(u().mark((function t(n){var e,r,o,i,a,c,s,l;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o="payment"===(null==n?void 0:n.flow),i=!(null===(e=d)||void 0===e||!e.statusPreValidation),a="function"==typeof(null===(r=UnicoSDKAssets)||void 0===r||null===(r=r.clientBoxControl)||void 0===r?void 0:r.preValidateDevice),!o||i||!a){t.next=11;break}return t.next=6,UnicoSDKAssets.clientBoxControl.preValidateDevice();case 6:if(d=t.sent,(null===(c=d)||void 0===c?void 0:c.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=11;break}return null===(s=w)||void 0===s||null===(l=s.destroy)||void 0===l||l.call(s),null==b||b({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return");case 11:null==y||y(n);case 12:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),w=UnicoSDKAssets.clientBoxControl.renderButton({container:i,token:c,env:l,sdkVersion:v,config:p,onReady:E,onError:b,onClicked:function(){null==m||m(),B({transactionId:a,token:c,onFinish:h})}}),t.abrupt("return",{destroy:function(){var t,n;return null===(t=w)||void 0===t||null===(n=t.destroy)||void 0===n?void 0:n.call(t)},refresh:function(){var t,n;return null===(t=w)||void 0===t||null===(n=t.refresh)||void 0===n?void 0:n.call(t)},deviceSupported:!0});case 14:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),Y="unico_iframe_embedded",M=Symbol("init timed out"),q=function(t){if(t.querySelector("iframe")){var n=new MutationObserver((function(){t.querySelector("iframe")||(n.disconnect(),t.remove())}));n.observe(t,{childList:!0})}else t.remove()},z=function(){var t=e(u().mark((function t(n){var e,r,o,i,a,c,s,l,f,d,h,v,y,m,b,g,w,E,x,k,P,S,T,I,U;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.container,a=n.id,c=n.token,s=n.env,l=void 0===s?O:s,f=n.useCurrentOrigin,d=n.onReady,h=n.onClick,v=n.onFinish,y=n.onProgressUpdate,m=n.onError,b={destroy:function(){}},g="string"==typeof i?document.querySelector(i):i){t.next=6;break}return null==m||m({reason:"CONTAINER_NOT_FOUND"}),t.abrupt("return",b);case 6:if(g.getBoundingClientRect().width){t.next=9;break}return null==m||m({reason:"CONTAINER_UNSUPPORTED"}),t.abrupt("return",b);case 9:return E=!1,x=!1,k=function(){var t,n,e,r;null===(t=window.UnicoSDKAssets)||void 0===t||null===(n=t.trackMetric)||void 0===n||n.call(t,null!==(e=null===(r=window.UnicoSDKAssets.METRIC_EVENTS)||void 0===r?void 0:r.BUTTON_ERROR)&&void 0!==e?e:"journey_sdk_button_error",{reason:"IFRAME_BLOCKED"}),null==m||m({reason:"IFRAME_BLOCKED"})},P={destroy:function(){clearTimeout(w),p===P&&(p=void 0,E?W():C(),q(S))}},null===(e=p)||void 0===e||e.destroy(),p=P,null===(r=document.getElementById(Y))||void 0===r||r.remove(),(S=document.createElement("div")).id=Y,g.appendChild(S),I=new Promise((function(t){T=setTimeout((function(){return t(M)}),8e3)})),t.prev=20,t.next=23,Promise.race([L({token:c,env:l,useCurrentOrigin:f,app:D,inline:!0}),I]);case 23:U=t.sent,t.next=31;break;case 26:throw t.prev=26,t.t0=t.catch(20),P.destroy(),S.remove(),t.t0;case 31:return t.prev=31,clearTimeout(T),t.finish(31);case 34:if(U!==M){t.next=39;break}return P.destroy(),S.remove(),k(),t.abrupt("return",b);case 39:if(S.isConnected){t.next=43;break}return P.destroy(),null==m||m({reason:"CONTAINER_NOT_FOUND"}),t.abrupt("return",b);case 43:if(UnicoSDKAssets.INLINE_BUTTON){t.next=49;break}return E=!0,P.destroy(),S.remove(),null==m||m({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",b);case 49:if((null===(o=U)||void 0===o?void 0:o.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=54;break}return P.destroy(),S.remove(),null==m||m({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return",b);case 54:return w=setTimeout(k,8e3),B({transactionId:a,token:c,onProgressUpdate:y,onLoad:function(){return clearTimeout(w)},onReady:d,onClick:h,onFinish:function(t){x||(x=!0,clearTimeout(w),p===P&&(p=void 0),C(),null==v||v(t),q(S))}}),E=!0,t.abrupt("return",P);case 58:case"end":return t.stop()}}),t,null,[[20,26,31,34]])})));return function(n){return t.apply(this,arguments)}}(),Z=function(t){var n=h?h.then((function(){return z(t)})):z(t),e=n.then((function(){}),(function(){}));return h=e,e.then((function(){h===e&&(h=void 0)})),n},H=function(){var t=e(u().mark((function t(n){var r,o;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Z(n);case 2:return r=t.sent,o=!1,t.abrupt("return",{destroy:function(){o=!0,r.destroy()},refresh:function(){var t=e(u().mark((function t(){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=!1,r.destroy(),t.next=4,Z(n);case 4:r=t.sent,o&&r.destroy();case 6:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()});case 5:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),J={init:R,close:W,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,u=a(t,m);B(i({transactionId:n,token:e,onFinish:function(t){C(),null==r||r(t)},onWidgetVisibilityChange:o},u))},renderButton:H},Q={init:K,close:W,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;B({transactionId:n,token:e,onFinish:r})}},X={init:j,close:W,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;B({transactionId:n,token:e,onFinish:r})}},$={init:V,close:W,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;B({transactionId:n,token:e,onFinish:r})},renderButton:function(t){return G(i(i({},t),{},{app:T}))}},tt={init:A,close:W,open:F,renderButton:G};t.ByUnicoSDK=J,t.IDCashSDK=X,t.IDPaySDK=Q,t.PRE_VALIDATION_STATUS=_,t.UnicoSDK=tt,t.YouSDK=$}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).UnicoSDK={})}(this,(function(t){"use strict";function e(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function n(t){return function(){var n=this,r=arguments;return new Promise((function(o,i){var a=t.apply(n,r);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(void 0)}))}}function r(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function a(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function u(){u=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),u=new U(r||[]);return o(a,"_invoke",{value:D(t,n,u)}),a}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",h="suspendedYield",v="executing",y="completed",m={};function b(){}function g(){}function w(){}var E={};l(E,a,(function(){return this}));var x=Object.getPrototypeOf,k=x&&x(x(C([])));k&&k!==n&&r.call(k,a)&&(E=k);var P=w.prototype=b.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function n(o,i,a,u){var c=d(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function D(e,n,r){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var u=r.delegate;if(u){var c=T(u,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===p)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var s=d(e,n,r);if("normal"===s.type){if(o=r.done?y:h,s.arg===m)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=y,r.method="throw",r.arg=s.arg)}}}function T(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=d(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function U(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function C(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:g,configurable:!0}),g.displayName=l(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},O(S.prototype),l(S.prototype,c,(function(){return this})),e.AsyncIterator=S,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new S(f(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(P),l(P,s,"Generator"),l(P,a,(function(){return this})),l(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=C,U.prototype={constructor:U,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return u.type="throw",u.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),_(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;_(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:C(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}var c,s,l,f,d,p,h,v="2.4.0-beta.1",y=["hasPayments"],m=["transactionId","token","onFinish","onWidgetVisibilityChange"],b=["transactionId","token","onFinish"],g=!1,w=!1,E=0,x="REDIRECT",k="SILENT",P="prod",O="idpay",S="idcash",D="byunico",T="you",I=r(r(r({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),P,"https://idpay.unico.io"),_={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},U=function(){console.log(">>> reset"),c=void 0,s=void 0,g=!1,w=!1,l=void 0,f=void 0,d=void 0,E+=1},C=function(){if(f)return Promise.resolve();(f=document.createElement("script")).src="".concat(s,"/sdk-assets/index.js");var t=new Promise((function(t){f.onload=t}));return document.body.appendChild(f),Promise.all([t])},N=function(){var t=document.createElement("link");t.setAttribute("href","".concat(s,"/sdk-assets/assets/styles.css")),t.setAttribute("rel","stylesheet");var e=new Promise((function(e){t.onload=e}));return document.head.appendChild(t),Promise.all([e])},L=function(){var t=n(u().mark((function t(e){var n,r,o,i,a,f,p,h,y,m,b,O,S,D,T;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.token,i=e.useCurrentOrigin,a=e.env,f=void 0===a?P:a,p=e.type,h=void 0===p?"IFRAME":p,y=e.app,m=e.hasPayments,b=e.inline,c=h,s=i?window.location.origin:I[f],O=E,S=function(){return b&&O!==E},t.next=7,C();case 7:if(!S()){t.next=9;break}return t.abrupt("return",void 0);case 9:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=c,t.next=t.t0===k?13:t.t0===x?18:19;break;case 13:return t.next=15,UnicoSDKAssets.clientBoxControl.initSilent();case 15:return l=t.sent,D={collectionId:l},t.abrupt("break",26);case 18:return t.abrupt("break",26);case 19:return t.next=21,N();case 21:if(!S()){t.next=23;break}return t.abrupt("return",void 0);case 23:return t.next=25,UnicoSDKAssets.clientBoxControl.create({host:s,token:o,sdkVersion:v,app:y,env:f,hasPayments:m,inline:b});case 25:D=t.sent;case 26:if(!S()){t.next=28;break}return t.abrupt("return",void 0);case 28:if(g=!0,d=D,T=!(null!==(n=D)&&void 0!==n&&n.statusPreValidation)||(null===(r=D)||void 0===r?void 0:r.statusPreValidation)===_.DEVICE_SUPPORTED,w&&T&&F(w),!D){t.next=34;break}return t.abrupt("return",D);case 34:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),A=function(){var t=n(u().mark((function t(e){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Warning: The `init()` function is deprecated and will be removed in future versions.Please initialize directly on the product object, e.g., `IDPaySDK.init({ ... })`, `IDCashSDK.init({ ... })`, `ByUnicoSDK.init({ ... })` or `YouSDK.init({ ... })`. See our documentation for more details."),t.abrupt("return",L(e));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),R=function(){var t=n(u().mark((function t(e){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initByUnicoSDK > options:",e),t.abrupt("return",L(i(i({},e),{},{app:D})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),K=function(){var t=n(u().mark((function t(e){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",e),t.abrupt("return",L(i(i({},e),{},{app:O})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),j=function(){var t=n(u().mark((function t(e){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDCashSDK > options:",e),t.next=3,L(i(i({},e),{},{app:S}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),V=function(){var t=n(u().mark((function t(e){var n,r;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.hasPayments,r=a(e,y),console.log(">>> initYouSDK > options:",r,"hasPayments:",n),t.next=4,L(i(i({},r),{},{app:T,hasPayments:n}));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),B=function(t){var e=t.transactionId,n=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,i=t.onProgressUpdate,a={transactionId:e,token:n,onFinish:r,onWidgetVisibilityChange:o,onProgressUpdate:i,onLoad:t.onLoad,onReady:t.onReady,onClick:t.onClick,host:s,sdkVersion:v,collectionId:l};if(console.log("open",a),g)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,a),"function"!=typeof i||c!==k&&c!==x||console.warn("Warning: onProgressUpdate is ignored when the SDK type is ".concat(c,": ")+"there is no iframe to report milestones."),c){case k:UnicoSDKAssets.clientBoxControl.verify(a);break;case x:UnicoSDKAssets.clientBoxControl.redirect(e,n,s,v);break;default:UnicoSDKAssets.clientBoxControl.open(a)}else w=a},F=function(t){var e=t.transactionId,n=t.token,r=t.onFinish,o=a(t,b);B(i({transactionId:e,token:n,onFinish:r},o))},W=function(){U(),UnicoSDKAssets.clientBoxControl.close()},G=function(){var t=n(u().mark((function t(e){var r,o,i,a,c,s,l,f,p,h,y,m,b,w,E,x;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.container,a=e.id,c=e.token,s=e.env,l=void 0===s?P:s,f=e.app,p=e.config,h=e.onFinish,y=e.onProgressUpdate,m=e.onReady,b=e.onClick,w=e.onError,g){t.next=4;break}return t.next=4,L({token:c,env:l,app:f});case 4:if((null===(r=d)||void 0===r?void 0:r.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=7;break}return null==w||w({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return",{destroy:function(){},deviceSupported:!1});case 7:if("function"==typeof(null===(o=UnicoSDKAssets)||void 0===o||null===(o=o.clientBoxControl)||void 0===o?void 0:o.renderButton)){t.next=11;break}return console.warn("Warning: the loaded sdk-assets does not expose clientBoxControl.renderButton. Deploy the sdk-assets build that includes button-box (or serve it locally and init with useCurrentOrigin)."),null==w||w({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",{destroy:function(){},refresh:function(){},deviceSupported:!0});case 11:return x=function(){var t=n(u().mark((function t(e){var n,r,o,i,a,c,s,l;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o="payment"===(null==e?void 0:e.flow),i=!(null===(n=d)||void 0===n||!n.statusPreValidation),a="function"==typeof(null===(r=UnicoSDKAssets)||void 0===r||null===(r=r.clientBoxControl)||void 0===r?void 0:r.preValidateDevice),!o||i||!a){t.next=11;break}return t.next=6,UnicoSDKAssets.clientBoxControl.preValidateDevice();case 6:if(d=t.sent,(null===(c=d)||void 0===c?void 0:c.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=11;break}return null===(s=E)||void 0===s||null===(l=s.destroy)||void 0===l||l.call(s),null==w||w({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return");case 11:null==m||m(e);case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),E=UnicoSDKAssets.clientBoxControl.renderButton({container:i,token:c,env:l,sdkVersion:v,config:p,onReady:x,onError:w,onClicked:function(){null==b||b(),B({transactionId:a,token:c,onFinish:h,onProgressUpdate:y})}}),t.abrupt("return",{destroy:function(){var t,e;return null===(t=E)||void 0===t||null===(e=t.destroy)||void 0===e?void 0:e.call(t)},refresh:function(){var t,e;return null===(t=E)||void 0===t||null===(e=t.refresh)||void 0===e?void 0:e.call(t)},deviceSupported:!0});case 14:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Y="unico_iframe_embedded",M=Symbol("init timed out"),q=function(t){if(t.querySelector("iframe")){var e=new MutationObserver((function(){t.querySelector("iframe")||(e.disconnect(),t.remove())}));e.observe(t,{childList:!0})}else t.remove()},z=function(){var t=n(u().mark((function t(e){var n,r,o,i,a,c,s,l,f,d,h,v,y,m,b,g,w,E,x,k,O,S,T,I,C;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.container,a=e.id,c=e.token,s=e.env,l=void 0===s?P:s,f=e.useCurrentOrigin,d=e.onReady,h=e.onClick,v=e.onFinish,y=e.onProgressUpdate,m=e.onError,b={destroy:function(){}},g="string"==typeof i?document.querySelector(i):i){t.next=6;break}return null==m||m({reason:"CONTAINER_NOT_FOUND"}),t.abrupt("return",b);case 6:if(g.getBoundingClientRect().width){t.next=9;break}return null==m||m({reason:"CONTAINER_UNSUPPORTED"}),t.abrupt("return",b);case 9:return E=!1,x=!1,k=function(){var t,e,n,r;null===(t=window.UnicoSDKAssets)||void 0===t||null===(e=t.trackMetric)||void 0===e||e.call(t,null!==(n=null===(r=window.UnicoSDKAssets.METRIC_EVENTS)||void 0===r?void 0:r.BUTTON_ERROR)&&void 0!==n?n:"journey_sdk_button_error",{reason:"IFRAME_BLOCKED"}),null==m||m({reason:"IFRAME_BLOCKED"})},O={destroy:function(){clearTimeout(w),p===O&&(p=void 0,E?W():U(),q(S))}},null===(n=p)||void 0===n||n.destroy(),p=O,null===(r=document.getElementById(Y))||void 0===r||r.remove(),(S=document.createElement("div")).id=Y,g.appendChild(S),I=new Promise((function(t){T=setTimeout((function(){return t(M)}),8e3)})),t.prev=20,t.next=23,Promise.race([L({token:c,env:l,useCurrentOrigin:f,app:D,inline:!0}),I]);case 23:C=t.sent,t.next=31;break;case 26:throw t.prev=26,t.t0=t.catch(20),O.destroy(),S.remove(),t.t0;case 31:return t.prev=31,clearTimeout(T),t.finish(31);case 34:if(C!==M){t.next=39;break}return O.destroy(),S.remove(),k(),t.abrupt("return",b);case 39:if(S.isConnected){t.next=43;break}return O.destroy(),null==m||m({reason:"CONTAINER_NOT_FOUND"}),t.abrupt("return",b);case 43:if(UnicoSDKAssets.INLINE_BUTTON){t.next=49;break}return E=!0,O.destroy(),S.remove(),null==m||m({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",b);case 49:if((null===(o=C)||void 0===o?void 0:o.statusPreValidation)!==_.DEVICE_NOT_SUPPORT){t.next=54;break}return O.destroy(),S.remove(),null==m||m({reason:_.DEVICE_NOT_SUPPORT}),t.abrupt("return",b);case 54:return w=setTimeout(k,8e3),B({transactionId:a,token:c,onProgressUpdate:y,onLoad:function(){return clearTimeout(w)},onReady:d,onClick:h,onFinish:function(t){x||(x=!0,clearTimeout(w),p===O&&(p=void 0),U(),null==v||v(t),q(S))}}),E=!0,t.abrupt("return",O);case 58:case"end":return t.stop()}}),t,null,[[20,26,31,34]])})));return function(e){return t.apply(this,arguments)}}(),Z=function(t){var e=h?h.then((function(){return z(t)})):z(t),n=e.then((function(){}),(function(){}));return h=n,n.then((function(){h===n&&(h=void 0)})),e},H=function(){var t=n(u().mark((function t(e){var r,o;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Z(e);case 2:return r=t.sent,o=!1,t.abrupt("return",{destroy:function(){o=!0,r.destroy()},refresh:function(){var t=n(u().mark((function t(){return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=!1,r.destroy(),t.next=4,Z(e);case 4:r=t.sent,o&&r.destroy();case 6:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()});case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),J={init:R,close:W,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,u=a(t,m);B(i({transactionId:e,token:n,onFinish:function(t){U(),null==r||r(t)},onWidgetVisibilityChange:o},u))},renderButton:H},Q={init:K,close:W,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;B({transactionId:e,token:n,onFinish:r})}},X={init:j,close:W,open:function(t){var e=t.invoiceId,n=t.token,r=t.onFinish;B({transactionId:e,token:n,onFinish:r})}},$={init:V,close:W,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish,o=t.onProgressUpdate;B({transactionId:e,token:n,onFinish:r,onProgressUpdate:o})},renderButton:function(t){return G(i(i({},t),{},{app:T}))}},tt={init:A,close:W,open:F,renderButton:G};t.ByUnicoSDK=J,t.IDCashSDK=X,t.IDPaySDK=Q,t.PRE_VALIDATION_STATUS=_,t.UnicoSDK=tt,t.YouSDK=$}));
package/lib/index.d.ts CHANGED
@@ -78,6 +78,21 @@ export type OpenOptions = {
78
78
  onProgressUpdate?: (event: JourneyProgressEvent) => void;
79
79
  [key: string]: any;
80
80
  };
81
+ /**
82
+ * Options of `YouSDK.open`. Other keys are accepted and ignored.
83
+ *
84
+ * `onFinish` keeps an untyped argument on purpose: You sends
85
+ * `{ type, transaction: { id, token, concluded } }`, not `JourneyFinishData`,
86
+ * and `transaction` is absent on CLOSE, so a stricter type would stop compiling
87
+ * the `transaction.concluded` check the public docs teach.
88
+ */
89
+ export type YouOpenOptions = {
90
+ transactionId: string;
91
+ token: string;
92
+ onFinish?: (process: any) => void;
93
+ onProgressUpdate?: (event: JourneyProgressEvent) => void;
94
+ [key: string]: any;
95
+ };
81
96
  /**
82
97
  * Options of `ByUnicoSDK.renderButton`.
83
98
  *
@@ -203,11 +218,28 @@ declare function initYouSDK({ hasPayments, ...options }: {
203
218
  [x: string]: any;
204
219
  hasPayments: any;
205
220
  }): Promise<any>;
206
- declare function openYouSDK({ transactionId, token, onFinish }: {
207
- transactionId: any;
208
- token: any;
209
- onFinish: any;
210
- }): void;
221
+ /**
222
+ * Options of `YouSDK.open`. Other keys are accepted and ignored.
223
+ *
224
+ * `onFinish` keeps an untyped argument on purpose: You sends
225
+ * `{ type, transaction: { id, token, concluded } }`, not `JourneyFinishData`,
226
+ * and `transaction` is absent on CLOSE, so a stricter type would stop compiling
227
+ * the `transaction.concluded` check the public docs teach.
228
+ *
229
+ * @typedef {{
230
+ * transactionId: string,
231
+ * token: string,
232
+ * onFinish?: (process: any) => void,
233
+ * onProgressUpdate?: (event: JourneyProgressEvent) => void,
234
+ * [key: string]: any,
235
+ * }} YouOpenOptions
236
+ */
237
+ /**
238
+ * Opens the You flow.
239
+ *
240
+ * @param {YouOpenOptions} options
241
+ */
242
+ declare function openYouSDK({ transactionId, token, onFinish, onProgressUpdate }: YouOpenOptions): void;
211
243
  declare function renderButtonYouSDK(options: any): Promise<{
212
244
  destroy: () => undefined;
213
245
  deviceSupported: boolean;
@@ -237,7 +269,7 @@ declare function open({ transactionId, token, onFinish, ...rest }: {
237
269
  token: any;
238
270
  onFinish: any;
239
271
  }): void;
240
- declare function _renderButton({ container, id, token, env, app, config, onFinish, onReady, onClick, onError, }: {
272
+ declare function _renderButton({ container, id, token, env, app, config, onFinish, onProgressUpdate, onReady, onClick, onError, }: {
241
273
  container: any;
242
274
  id: any;
243
275
  token: any;
@@ -245,6 +277,7 @@ declare function _renderButton({ container, id, token, env, app, config, onFinis
245
277
  app: any;
246
278
  config: any;
247
279
  onFinish: any;
280
+ onProgressUpdate: any;
248
281
  onReady: any;
249
282
  onClick: any;
250
283
  onError: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idpay-b2b-sdk",
3
- "version": "2.4.0-beta.0",
3
+ "version": "2.4.0-beta.1",
4
4
  "description": "Embed Unico's identity verification journeys (document capture, facial liveness, and more) directly into your web application.",
5
5
  "license": "MIT",
6
6
  "author": {