idpay-b2b-sdk 2.2.1-beta.1 → 2.2.2-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.
- package/assets/.version.d.ts +1 -1
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/lib/index.d.ts +4 -2
- package/package.json +1 -1
package/assets/.version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "2.2.
|
|
1
|
+
declare const _default: "2.2.1";
|
|
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(){i=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.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: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",v="suspendedYield",d="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 D(e,n,r){var o=p;return function(i,a){if(o===d)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=I(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=d;var s=h(e,n,r);if("normal"===s.type){if(o=r.done?y:v,s.arg===g)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=y,r.method="throw",r.arg=s.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){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 a,c,u,s,l="2.2.0",f=["transactionId","token","onFinish"],h=!1,p=!1,v="REDIRECT",d="SILENT",y="prod",g="idpay",m="idcash",b="byunico",w=n(n(n({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),y,"https://idpay.unico.io"),E={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},O=function(){console.log(">>> reset"),a=void 0,c=void 0,h=!1,p=!1,u=void 0,s=void 0},x=function(){if(s)return Promise.resolve();(s=document.createElement("script")).src="".concat(c,"/sdk-assets/index.js");var t=new Promise((function(t){s.onload=t}));return document.body.appendChild(s),Promise.all([t])},P=function(){var t=document.createElement("link");t.setAttribute("href","".concat(c,"/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])},k=function(){var t=e(i().mark((function t(e){var n,r,o,s,f,g,m,b,O,k,S;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.token,s=e.useCurrentOrigin,f=e.env,g=void 0===f?y:f,m=e.type,b=void 0===m?"IFRAME":m,O=e.app,a=b,c=s?window.location.origin:w[g],t.next=5,x();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=a,t.next=t.t0===d?9:t.t0===v?14:15;break;case 9:return t.next=11,UnicoSDKAssets.clientBoxControl.initSilent();case 11:return u=t.sent,k={collectionId:u},t.abrupt("break",20);case 14:return t.abrupt("break",20);case 15:return t.next=17,P();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:c,token:o,sdkVersion:l,app:O,env:g});case 19:k=t.sent;case 20:if(h=!0,S=!(null!==(n=k)&&void 0!==n&&n.statusPreValidation)||(null===(r=k)||void 0===r?void 0:r.statusPreValidation)===E.DEVICE_SUPPORTED,p&&S&&I(p),!k){t.next=25;break}return t.abrupt("return",k);case 25:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),S=function(){var t=e(i().mark((function t(e){return i().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",k(e));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),D=function(t){var e=t.transactionId,n=t.token,r={transactionId:e,token:n,onFinish:t.onFinish,onWidgetVisibilityChange:t.onWidgetVisibilityChange,host:c,sdkVersion:l,collectionId:u};if(console.log("open",r),h)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),a){case d:UnicoSDKAssets.clientBoxControl.verify(r);break;case v:UnicoSDKAssets.clientBoxControl.redirect(e,n,c,l);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else p=r},I=function(t){var e=t.transactionId,n=t.token,r=t.onFinish;D({transactionId:e,token:n,onFinish:r})},j=function(){O(),UnicoSDKAssets.clientBoxControl.close()},L={init:function(){var t=e(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initByUnicoSDK > options:",e),t.abrupt("return",k(o(o({},e),{},{app:b})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),close:j,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish,i=function(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}(t,f);D(o({transactionId:e,token:n,onFinish:function(t){O(),null==r||r(t)}},i))}},_={init:function(){var t=e(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",e),t.abrupt("return",k(o(o({},e),{},{app:g})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),close:j,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;D({transactionId:e,token:n,onFinish:r})}},T={init:function(){var t=e(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDCashSDK > options:",e),t.next=3,k(o(o({},e),{},{app:m}));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:j,open:function(t){var e=t.invoiceId,n=t.token,r=t.onFinish;D({transactionId:e,token:n,onFinish:r})}},C={init:S,close:j,open:I};export{L as ByUnicoSDK,T as IDCashSDK,_ as IDPaySDK,E as PRE_VALIDATION_STATUS,C as UnicoSDK};
|
|
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};
|
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),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).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,u,"next",t)}function u(t){e(a,o,i,c,u,"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(){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 T(r||[]);return o(a,"_invoke",{value:k(t,n,c)}),a}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",v="executing",y="completed",g={};function m(){}function b(){}function w(){}var E={};l(E,c,(function(){return this}));var x=Object.getPrototypeOf,O=x&&x(x(_([])));O&&O!==n&&r.call(O,c)&&(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 D(t,e){function n(o,i,a,c){var u=p(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 k(e,n,r){var o=h;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=I(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===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var s=p(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 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=p(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[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}},S(D.prototype),l(D.prototype,u,(function(){return this})),e.AsyncIterator=D,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new D(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,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: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 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:_(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),g}},e}var c,u,s,l,f="2.2.0",p=["transactionId","token","onFinish"],h=!1,d=!1,v="REDIRECT",y="SILENT",g="prod",m="idpay",b="idcash",w="byunico",E=r(r(r({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),g,"https://idpay.unico.io"),x={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},O=function(){console.log(">>> reset"),c=void 0,u=void 0,h=!1,d=!1,s=void 0,l=void 0},P=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])},D=function(){var t=n(a().mark((function t(e){var n,r,o,i,l,p,m,b,w,O,D;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.token,i=e.useCurrentOrigin,l=e.env,p=void 0===l?g:l,m=e.type,b=void 0===m?"IFRAME":m,w=e.app,c=b,u=i?window.location.origin:E[p],t.next=5,P();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=c,t.next=t.t0===y?9:t.t0===v?14:15;break;case 9:return t.next=11,UnicoSDKAssets.clientBoxControl.initSilent();case 11:return s=t.sent,O={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:p});case 19:O=t.sent;case 20:if(h=!0,D=!(null!==(n=O)&&void 0!==n&&n.statusPreValidation)||(null===(r=O)||void 0===r?void 0:r.statusPreValidation)===x.DEVICE_SUPPORTED,d&&D&&_(d),!O){t.next=25;break}return t.abrupt("return",O);case 25:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),k=function(){var t=n(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",D(e));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),I=function(){var t=n(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",D(i(i({},e),{},{app:w})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),j=function(){var t=n(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",D(i(i({},e),{},{app:m})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),L=function(){var t=n(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,D(i(i({},e),{},{app:b}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),T=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),h)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),c){case y:UnicoSDKAssets.clientBoxControl.verify(r);break;case v:UnicoSDKAssets.clientBoxControl.redirect(e,n,u,f);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else d=r},_=function(t){var e=t.transactionId,n=t.token,r=t.onFinish;T({transactionId:e,token:n,onFinish:r})},K=function(){O(),UnicoSDKAssets.clientBoxControl.close()},U={init:I,close:K,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish,o=function(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}(t,p);T(i({transactionId:e,token:n,onFinish:function(t){O(),null==r||r(t)}},o))}},A={init:j,close:K,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;T({transactionId:e,token:n,onFinish:r})}},C={init:L,close:K,open:function(t){var e=t.invoiceId,n=t.token,r=t.onFinish;T({transactionId:e,token:n,onFinish:r})}},F={init:k,close:K,open:_};t.ByUnicoSDK=U,t.IDCashSDK=C,t.IDPaySDK=A,t.PRE_VALIDATION_STATUS=x,t.UnicoSDK=F}));
|
|
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}));
|
package/lib/index.d.ts
CHANGED
|
@@ -24,11 +24,12 @@ export namespace UnicoSDK {
|
|
|
24
24
|
}
|
|
25
25
|
declare function initByUnicoSDK(options: any): Promise<any>;
|
|
26
26
|
declare function close(): void;
|
|
27
|
-
declare function openByUnicoSDK({ transactionId, token, onFinish, ...rest }: {
|
|
27
|
+
declare function openByUnicoSDK({ transactionId, token, onFinish, onWidgetVisibilityChange, ...rest }: {
|
|
28
28
|
[x: string]: any;
|
|
29
29
|
transactionId: any;
|
|
30
30
|
token: any;
|
|
31
31
|
onFinish: any;
|
|
32
|
+
onWidgetVisibilityChange: any;
|
|
32
33
|
}): void;
|
|
33
34
|
declare function initIDPaySDK(options: any): Promise<any>;
|
|
34
35
|
declare function openIDPaySDK({ transactionId, token, onFinish }: {
|
|
@@ -55,7 +56,8 @@ declare function openIDCashSDK({ invoiceId, token, onFinish }: {
|
|
|
55
56
|
* See our documentation for more details.
|
|
56
57
|
*/
|
|
57
58
|
declare function init(options: any): Promise<any>;
|
|
58
|
-
declare function open({ transactionId, token, onFinish }: {
|
|
59
|
+
declare function open({ transactionId, token, onFinish, ...rest }: {
|
|
60
|
+
[x: string]: any;
|
|
59
61
|
transactionId: any;
|
|
60
62
|
token: any;
|
|
61
63
|
onFinish: any;
|