idpay-b2b-sdk 2.2.2-beta.1 → 2.2.3

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.2.1";
1
+ declare const _default: "2.2.3";
2
2
  export default _default;
package/index.esm.js CHANGED
@@ -1 +1 @@
1
- function t(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function e(e){return function(){var n=this,r=arguments;return new Promise((function(o,i){var a=e.apply(n,r);function c(e){t(a,o,i,c,u,"next",e)}function u(e){t(a,o,i,c,u,"throw",e)}c(void 0)}))}}function n(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 r(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 o(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?r(Object(o),!0).forEach((function(e){n(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function i(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 a(){a=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:{},c=i.iterator||"@@iterator",u=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 m?e:m,a=Object.create(i.prototype),c=new _(r||[]);return o(a,"_invoke",{value:I(t,n,c)}),a}function h(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",d="suspendedYield",v="executing",y="completed",g={};function m(){}function b(){}function w(){}var E={};l(E,c,(function(){return this}));var O=Object.getPrototypeOf,x=O&&O(O(T([])));x&&x!==n&&r.call(x,c)&&(E=x);var P=w.prototype=m.prototype=Object.create(E);function k(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,c){var u=h(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.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 I(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 c=r.delegate;if(c){var u=D(c,r);if(u){if(u===g)continue;return u}}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=h(e,n,r);if("normal"===s.type){if(o=r.done?y:d,s.arg===g)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=y,r.method="throw",r.arg=s.arg)}}}function D(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,D(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var i=h(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,g;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,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(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 L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function T(e){if(e||""===e){var n=e[c];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 b.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"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}},k(S.prototype),l(S.prototype,u,(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()}))},k(P),l(P,s,"Generator"),l(P,c,(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=T,_.prototype={constructor:_,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(L),!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 c.type="throw",c.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],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){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,g):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),g},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),L(n),g}},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;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:T(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),g}},e}var c,u,s,l,f="2.2.1",h=["transactionId","token","onFinish","onWidgetVisibilityChange"],p=["transactionId","token","onFinish"],d=!1,v=!1,y="REDIRECT",g="SILENT",m="prod",b="idpay",w="idcash",E="byunico",O=n(n(n({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),m,"https://idpay.unico.io"),x={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},P=function(){console.log(">>> reset"),c=void 0,u=void 0,d=!1,v=!1,s=void 0,l=void 0},k=function(){if(l)return Promise.resolve();(l=document.createElement("script")).src="".concat(u,"/sdk-assets/index.js");var t=new Promise((function(t){l.onload=t}));return document.body.appendChild(l),Promise.all([t])},S=function(){var t=document.createElement("link");t.setAttribute("href","".concat(u,"/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])},I=function(){var t=e(a().mark((function t(e){var n,r,o,i,l,h,p,b,w,E,P;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.token,i=e.useCurrentOrigin,l=e.env,h=void 0===l?m:l,p=e.type,b=void 0===p?"IFRAME":p,w=e.app,c=b,u=i?window.location.origin:O[h],t.next=5,k();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=c,t.next=t.t0===g?9:t.t0===y?14:15;break;case 9:return t.next=11,UnicoSDKAssets.clientBoxControl.initSilent();case 11:return s=t.sent,E={collectionId:s},t.abrupt("break",20);case 14:return t.abrupt("break",20);case 15:return t.next=17,S();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:u,token:o,sdkVersion:f,app:w,env:h});case 19:E=t.sent;case 20:if(d=!0,P=!(null!==(n=E)&&void 0!==n&&n.statusPreValidation)||(null===(r=E)||void 0===r?void 0:r.statusPreValidation)===x.DEVICE_SUPPORTED,v&&P&&L(v),!E){t.next=25;break}return t.abrupt("return",E);case 25:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),D=function(){var t=e(a().mark((function t(e){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({ ... })` or `ByUnicoSDK.init({ ... })`. See our documentation for more details."),t.abrupt("return",I(e));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),j=function(t){var e=t.transactionId,n=t.token,r={transactionId:e,token:n,onFinish:t.onFinish,onWidgetVisibilityChange:t.onWidgetVisibilityChange,host:u,sdkVersion:f,collectionId:s};if(console.log("open",r),d)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),c){case g:UnicoSDKAssets.clientBoxControl.verify(r);break;case y:UnicoSDKAssets.clientBoxControl.redirect(e,n,u,f);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else v=r},L=function(t){var e=t.transactionId,n=t.token,r=t.onFinish,a=i(t,p);j(o({transactionId:e,token:n,onFinish:r},a))},_=function(){P(),UnicoSDKAssets.clientBoxControl.close()},T={init:function(){var t=e(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initByUnicoSDK > options:",e),t.abrupt("return",I(o(o({},e),{},{app:E})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),close:_,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish,a=t.onWidgetVisibilityChange,c=i(t,h);j(o({transactionId:e,token:n,onFinish:function(t){P(),null==r||r(t)},onWidgetVisibilityChange:a},c))}},C={init:function(){var t=e(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",e),t.abrupt("return",I(o(o({},e),{},{app:b})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),close:_,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;j({transactionId:e,token:n,onFinish:r})}},F={init:function(){var t=e(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDCashSDK > options:",e),t.next=3,I(o(o({},e),{},{app:w}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),close:_,open:function(t){var e=t.invoiceId,n=t.token,r=t.onFinish;j({transactionId:e,token:n,onFinish:r})}},A={init:D,close:_,open:L};export{T as ByUnicoSDK,F as IDCashSDK,C as IDPaySDK,x as PRE_VALIDATION_STATUS,A as UnicoSDK};
1
+ function t(t,n,e,r,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).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 c(n){t(a,o,i,c,s,"next",n)}function s(n){t(a,o,i,c,s,"throw",n)}c(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:{},c=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=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 m?n:m,a=Object.create(i.prototype),c=new _(r||[]);return o(a,"_invoke",{value:I(t,e,c)}),a}function h(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",d="suspendedYield",v="executing",y="completed",g={};function m(){}function b(){}function w(){}var E={};l(E,c,(function(){return this}));var P=Object.getPrototypeOf,x=P&&P(P(T([])));x&&x!==e&&r.call(x,c)&&(E=x);var O=w.prototype=m.prototype=Object.create(E);function k(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,c){var s=h(t[o],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):n.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return e("throw",t,a,c)}))}c(s.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 I(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 c=r.delegate;if(c){var s=D(c,r);if(s){if(s===g)continue;return s}}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 u=h(n,e,r);if("normal"===u.type){if(o=r.done?y:d,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=y,r.method="throw",r.arg=u.arg)}}}function D(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,D(n,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var i=h(o,n.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;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,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function j(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 L(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function T(n){if(n||""===n){var e=n[c];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 b.prototype=w,o(O,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===b||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},n.awrap=function(t){return{__await:t}},k(S.prototype),l(S.prototype,s,(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()}))},k(O),l(O,u,"Generator"),l(O,c,(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=T,_.prototype={constructor:_,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(L),!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 c.type="throw",c.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],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)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,g):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),g},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),L(e),g}},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;L(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:T(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),g}},n}var c,s,u,l,f="2.2.3",h=["hasPayments"],p=["transactionId","token","onFinish","onWidgetVisibilityChange"],d=["transactionId","token","onFinish"],v=!1,y=!1,g="REDIRECT",m="SILENT",b="prod",w="idpay",E="idcash",P="byunico",x="you",O=e(e(e({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),b,"https://idpay.unico.io"),k={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},S=function(){console.log(">>> reset"),c=void 0,s=void 0,v=!1,y=!1,u=void 0,l=void 0},I=function(){if(l)return Promise.resolve();(l=document.createElement("script")).src="".concat(s,"/sdk-assets/index.js");var t=new Promise((function(t){l.onload=t}));return document.body.appendChild(l),Promise.all([t])},D=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])},j=function(){var t=n(a().mark((function t(n){var e,r,o,i,l,h,p,d,w,E,P,x;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=n.token,i=n.useCurrentOrigin,l=n.env,h=void 0===l?b:l,p=n.type,d=void 0===p?"IFRAME":p,w=n.app,E=n.hasPayments,c=d,s=i?window.location.origin:O[h],t.next=5,I();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=c,t.next=t.t0===m?9:t.t0===g?14:15;break;case 9:return t.next=11,UnicoSDKAssets.clientBoxControl.initSilent();case 11:return u=t.sent,P={collectionId:u},t.abrupt("break",20);case 14:return t.abrupt("break",20);case 15:return t.next=17,D();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:s,token:o,sdkVersion:f,app:w,env:h,hasPayments:E});case 19:P=t.sent;case 20:if(v=!0,x=!(null!==(e=P)&&void 0!==e&&e.statusPreValidation)||(null===(r=P)||void 0===r?void 0:r.statusPreValidation)===k.DEVICE_SUPPORTED,y&&x&&T(y),!P){t.next=25;break}return t.abrupt("return",P);case 25: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",j(n));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),_=function(t){var n=t.transactionId,e=t.token,r={transactionId:n,token:e,onFinish:t.onFinish,onWidgetVisibilityChange:t.onWidgetVisibilityChange,host:s,sdkVersion:f,collectionId:u};if(console.log("open",r),v)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),c){case m:UnicoSDKAssets.clientBoxControl.verify(r);break;case g:UnicoSDKAssets.clientBoxControl.redirect(n,e,s,f);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else y=r},T=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=i(t,d);_(o({transactionId:n,token:e,onFinish:r},a))},C=function(){S(),UnicoSDKAssets.clientBoxControl.close()},F={init: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",j(o(o({},n),{},{app:P})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),close:C,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=t.onWidgetVisibilityChange,c=i(t,p);_(o({transactionId:n,token:e,onFinish:function(t){S(),null==r||r(t)},onWidgetVisibilityChange:a},c))}},K={init: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",j(o(o({},n),{},{app:w})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),close:C,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;_({transactionId:n,token:e,onFinish:r})}},A={init: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,j(o(o({},n),{},{app:E}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),close:C,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;_({transactionId:n,token:e,onFinish:r})}},U={init: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,h),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,j(o(o({},r),{},{app:x,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)}}(),close:C,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;_({transactionId:n,token:e,onFinish:r})}},V={init:L,close:C,open:T};export{F as ByUnicoSDK,A as IDCashSDK,K as IDPaySDK,k as PRE_VALIDATION_STATUS,V as UnicoSDK,U as YouSDK};
package/index.js CHANGED
@@ -1 +1 @@
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 c=t[i](a),s=c.value}catch(t){return void n(t)}c.done?e(s):Promise.resolve(s).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 c(t){e(a,o,i,c,s,"next",t)}function s(t){e(a,o,i,c,s,"throw",t)}c(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 c(){c=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",s=i.asyncIterator||"@@asyncIterator",u=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 m?e:m,a=Object.create(i.prototype),c=new T(r||[]);return o(a,"_invoke",{value:D(t,n,c)}),a}function h(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",d="suspendedYield",y="executing",v="completed",g={};function m(){}function b(){}function w(){}var E={};l(E,a,(function(){return this}));var x=Object.getPrototypeOf,O=x&&x(x(_([])));O&&O!==n&&r.call(O,a)&&(E=O);var P=w.prototype=m.prototype=Object.create(E);function S(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function n(o,i,a,c){var s=h(t[o],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return n("throw",t,a,c)}))}c(s.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===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=I(c,r);if(s){if(s===g)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===p)throw o=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=y;var u=h(e,n,r);if("normal"===u.type){if(o=r.done?v:d,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=v,r.method="throw",r.arg=u.arg)}}}function I(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,I(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var i=h(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,g;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,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(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 L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function _(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 b.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(k.prototype),l(k.prototype,s,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new k(f(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(P),l(P,u,"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=_,T.prototype={constructor:T,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(L),!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 c.type="throw",c.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],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)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,g):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),g},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),L(n),g}},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;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:_(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),g}},e}var s,u,l,f,h="2.2.1",p=["transactionId","token","onFinish","onWidgetVisibilityChange"],d=["transactionId","token","onFinish"],y=!1,v=!1,g="REDIRECT",m="SILENT",b="prod",w="idpay",E="idcash",x="byunico",O=r(r(r({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),b,"https://idpay.unico.io"),P={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},S=function(){console.log(">>> reset"),s=void 0,u=void 0,y=!1,v=!1,l=void 0,f=void 0},k=function(){if(f)return Promise.resolve();(f=document.createElement("script")).src="".concat(u,"/sdk-assets/index.js");var t=new Promise((function(t){f.onload=t}));return document.body.appendChild(f),Promise.all([t])},D=function(){var t=document.createElement("link");t.setAttribute("href","".concat(u,"/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])},I=function(){var t=n(c().mark((function t(e){var n,r,o,i,a,f,p,d,w,E,x;return c().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?b:a,p=e.type,d=void 0===p?"IFRAME":p,w=e.app,s=d,u=i?window.location.origin:O[f],t.next=5,k();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=s,t.next=t.t0===m?9:t.t0===g?14:15;break;case 9:return t.next=11,UnicoSDKAssets.clientBoxControl.initSilent();case 11:return l=t.sent,E={collectionId:l},t.abrupt("break",20);case 14:return t.abrupt("break",20);case 15:return t.next=17,D();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:u,token:o,sdkVersion:h,app:w,env:f});case 19:E=t.sent;case 20:if(y=!0,x=!(null!==(n=E)&&void 0!==n&&n.statusPreValidation)||(null===(r=E)||void 0===r?void 0:r.statusPreValidation)===P.DEVICE_SUPPORTED,v&&x&&K(v),!E){t.next=25;break}return t.abrupt("return",E);case 25:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),j=function(){var t=n(c().mark((function t(e){return c().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({ ... })` or `ByUnicoSDK.init({ ... })`. See our documentation for more details."),t.abrupt("return",I(e));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),L=function(){var t=n(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initByUnicoSDK > options:",e),t.abrupt("return",I(i(i({},e),{},{app:x})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),T=function(){var t=n(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",e),t.abrupt("return",I(i(i({},e),{},{app:w})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),_=function(){var t=n(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDCashSDK > options:",e),t.next=3,I(i(i({},e),{},{app:E}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),C=function(t){var e=t.transactionId,n=t.token,r={transactionId:e,token:n,onFinish:t.onFinish,onWidgetVisibilityChange:t.onWidgetVisibilityChange,host:u,sdkVersion:h,collectionId:l};if(console.log("open",r),y)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),s){case m:UnicoSDKAssets.clientBoxControl.verify(r);break;case g:UnicoSDKAssets.clientBoxControl.redirect(e,n,u,h);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else v=r},K=function(t){var e=t.transactionId,n=t.token,r=t.onFinish,o=a(t,d);C(i({transactionId:e,token:n,onFinish:r},o))},U=function(){S(),UnicoSDKAssets.clientBoxControl.close()},A={init:L,close:U,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,c=a(t,p);C(i({transactionId:e,token:n,onFinish:function(t){S(),null==r||r(t)},onWidgetVisibilityChange:o},c))}},F={init:T,close:U,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;C({transactionId:e,token:n,onFinish:r})}},V={init:_,close:U,open:function(t){var e=t.invoiceId,n=t.token,r=t.onFinish;C({transactionId:e,token:n,onFinish:r})}},N={init:j,close:U,open:K};t.ByUnicoSDK=A,t.IDCashSDK=V,t.IDPaySDK=F,t.PRE_VALIDATION_STATUS=P,t.UnicoSDK=N}));
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 c=t[i](a),s=c.value}catch(t){return void e(t)}c.done?n(s):Promise.resolve(s).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 c(t){n(a,o,i,c,s,"next",t)}function s(t){n(a,o,i,c,s,"throw",t)}c(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 c(){c=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",s=i.asyncIterator||"@@asyncIterator",u=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 m?n:m,a=Object.create(i.prototype),c=new T(r||[]);return o(a,"_invoke",{value:D(t,e,c)}),a}function h(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",d="suspendedYield",y="executing",v="completed",g={};function m(){}function b(){}function w(){}var E={};l(E,a,(function(){return this}));var P=Object.getPrototypeOf,x=P&&P(P(_([])));x&&x!==e&&r.call(x,a)&&(E=x);var O=w.prototype=m.prototype=Object.create(E);function S(t){["next","throw","return"].forEach((function(n){l(t,n,(function(t){return this._invoke(n,t)}))}))}function k(t,n){function e(o,i,a,c){var s=h(t[o],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):n.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return e("throw",t,a,c)}))}c(s.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===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var s=I(c,r);if(s){if(s===g)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===p)throw o=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=y;var u=h(n,e,r);if("normal"===u.type){if(o=r.done?v:d,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=v,r.method="throw",r.arg=u.arg)}}}function I(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,I(n,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var i=h(o,n.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;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,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function j(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 L(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function _(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 b.prototype=w,o(O,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===b||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},n.awrap=function(t){return{__await:t}},S(k.prototype),l(k.prototype,s,(function(){return this})),n.AsyncIterator=k,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new k(f(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),l(O,u,"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=_,T.prototype={constructor:T,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(L),!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 c.type="throw",c.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],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)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,g):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),g},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),L(e),g}},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;L(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:_(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),g}},n}var s,u,l,f,h="2.2.3",p=["hasPayments"],d=["transactionId","token","onFinish","onWidgetVisibilityChange"],y=["transactionId","token","onFinish"],v=!1,g=!1,m="REDIRECT",b="SILENT",w="prod",E="idpay",P="idcash",x="byunico",O="you",S=r(r(r({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),w,"https://idpay.unico.io"),k={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},D=function(){console.log(">>> reset"),s=void 0,u=void 0,v=!1,g=!1,l=void 0,f=void 0},I=function(){if(f)return Promise.resolve();(f=document.createElement("script")).src="".concat(u,"/sdk-assets/index.js");var t=new Promise((function(t){f.onload=t}));return document.body.appendChild(f),Promise.all([t])},j=function(){var t=document.createElement("link");t.setAttribute("href","".concat(u,"/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(c().mark((function t(n){var e,r,o,i,a,f,p,d,y,E,P,x;return c().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?w:a,p=n.type,d=void 0===p?"IFRAME":p,y=n.app,E=n.hasPayments,s=d,u=i?window.location.origin:S[f],t.next=5,I();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=s,t.next=t.t0===b?9:t.t0===m?14:15;break;case 9:return t.next=11,UnicoSDKAssets.clientBoxControl.initSilent();case 11:return l=t.sent,P={collectionId:l},t.abrupt("break",20);case 14:return t.abrupt("break",20);case 15:return t.next=17,j();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:u,token:o,sdkVersion:h,app:y,env:f,hasPayments:E});case 19:P=t.sent;case 20:if(v=!0,x=!(null!==(e=P)&&void 0!==e&&e.statusPreValidation)||(null===(r=P)||void 0===r?void 0:r.statusPreValidation)===k.DEVICE_SUPPORTED,g&&x&&A(g),!P){t.next=25;break}return t.abrupt("return",P);case 25:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),T=function(){var t=e(c().mark((function t(n){return c().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)}}(),_=function(){var t=e(c().mark((function t(n){return c().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:x})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),K=function(){var t=e(c().mark((function t(n){return c().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:E})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),C=function(){var t=e(c().mark((function t(n){return c().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: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)}}(),F=function(){var t=e(c().mark((function t(n){var e,r;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.hasPayments,r=a(n,p),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,L(i(i({},r),{},{app:O,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)}}(),U=function(t){var n=t.transactionId,e=t.token,r={transactionId:n,token:e,onFinish:t.onFinish,onWidgetVisibilityChange:t.onWidgetVisibilityChange,host:u,sdkVersion:h,collectionId:l};if(console.log("open",r),v)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),s){case b:UnicoSDKAssets.clientBoxControl.verify(r);break;case m:UnicoSDKAssets.clientBoxControl.redirect(n,e,u,h);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else g=r},A=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=a(t,y);U(i({transactionId:n,token:e,onFinish:r},o))},V=function(){D(),UnicoSDKAssets.clientBoxControl.close()},N={init:_,close:V,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,c=a(t,d);U(i({transactionId:n,token:e,onFinish:function(t){D(),null==r||r(t)},onWidgetVisibilityChange:o},c))}},R={init:K,close:V,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;U({transactionId:n,token:e,onFinish:r})}},B={init:C,close:V,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;U({transactionId:n,token:e,onFinish:r})}},G={init:F,close:V,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;U({transactionId:n,token:e,onFinish:r})}},W={init:T,close:V,open:A};t.ByUnicoSDK=N,t.IDCashSDK=B,t.IDPaySDK=R,t.PRE_VALIDATION_STATUS=k,t.UnicoSDK=W,t.YouSDK=G}));
package/lib/index.d.ts CHANGED
@@ -17,6 +17,11 @@ export namespace IDCashSDK {
17
17
  export { close };
18
18
  export { openIDCashSDK as open };
19
19
  }
20
+ export namespace YouSDK {
21
+ export { initYouSDK as init };
22
+ export { close };
23
+ export { openYouSDK as open };
24
+ }
20
25
  export namespace UnicoSDK {
21
26
  export { init };
22
27
  export { close };
@@ -43,6 +48,15 @@ declare function openIDCashSDK({ invoiceId, token, onFinish }: {
43
48
  token: any;
44
49
  onFinish: any;
45
50
  }): void;
51
+ declare function initYouSDK({ hasPayments, ...options }: {
52
+ [x: string]: any;
53
+ hasPayments: any;
54
+ }): Promise<any>;
55
+ declare function openYouSDK({ transactionId, token, onFinish }: {
56
+ transactionId: any;
57
+ token: any;
58
+ onFinish: any;
59
+ }): void;
46
60
  /**
47
61
  * @deprecated
48
62
  * The `init()` function is deprecated.
@@ -52,6 +66,7 @@ declare function openIDCashSDK({ invoiceId, token, onFinish }: {
52
66
  * - `IDPaySDK.init({ ... })`
53
67
  * - `IDCashSDK.init({ ... })`
54
68
  * - `ByUnicoSDK.init({ ... })`
69
+ * - `YouSDK.init({ ... })`
55
70
  *
56
71
  * See our documentation for more details.
57
72
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idpay-b2b-sdk",
3
- "version": "2.2.2-beta.1",
3
+ "version": "2.2.3",
4
4
  "main": "./index.js",
5
5
  "module": "./index.esm.js",
6
6
  "types": "./index.d.ts",
@@ -18,4 +18,4 @@
18
18
  "build-with-postbuild": "nx run idpay-b2b-sdk:build-with-postbuild"
19
19
  },
20
20
  "type": "module"
21
- }
21
+ }