idpay-b2b-sdk 2.1.1 → 2.1.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- declare const _default: "2.1.1";
1
+ declare const _default: "2.1.3-beta.1";
2
2
  export default _default;
package/index.esm.js CHANGED
@@ -1 +1 @@
1
- var n="2.1.1";let e,t,o,i,s=!1,c=!1;const a="IFRAME",r="REDIRECT",l="SILENT",d="dev",u="uat",p="prod",h={[d]:"https://idpay-dev.unico.io",[u]:"https://idpay-uat.unico.io",[p]:"https://idpay.unico.io"},k=()=>{console.log(">>> reset"),e=void 0,t=void 0,s=!1,c=!1,o=void 0},S=async d=>{let{token:u,useCurrentOrigin:k,env:S=p,type:I=a}=d;switch(e=I,t=k?window.location.origin:h[S],await(()=>{if(i)return Promise.resolve();i=document.createElement("script"),i.src=`${t}/sdk-assets/index.js`;const n=new Promise((n=>{i.onload=n}));return document.body.appendChild(i),Promise.all([n])})(),UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),e){case l:o=await UnicoSDKAssets.clientBoxControl.initSilent();break;case r:break;default:await(()=>{const n=document.createElement("link");n.setAttribute("href",`${t}/sdk-assets/assets/styles.css`),n.setAttribute("rel","stylesheet");const e=new Promise((e=>{n.onload=e}));return document.head.appendChild(n),Promise.all([e])})(),UnicoSDKAssets.clientBoxControl.create({host:t,token:u,sdkVersion:n})}if(s=!0,c&&y(c),o)return o},I=i=>{let{transactionId:a,token:d,onFinish:u}=i;const p={transactionId:a,token:d,onFinish:u,host:t,sdkVersion:n,collectionId:o};if(console.log("open",p),s)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,p),e){case l:UnicoSDKAssets.clientBoxControl.verify(p);break;case r:UnicoSDKAssets.clientBoxControl.redirect(a,d,t,n);break;default:UnicoSDKAssets.clientBoxControl.open(p)}else c=p},y=n=>{let{transactionId:e,token:t,onFinish:o}=n;I({transactionId:e,token:t,onFinish:o})},D=()=>{k(),UnicoSDKAssets.clientBoxControl.close()},A={init:async n=>(console.log(">>> initByUnicoSDK > options:",n),S({...n})),close:D,open:n=>{let{transactionId:e,token:t,onFinish:o}=n;I({transactionId:e,token:t,onFinish:n=>{k(),o?.(n)}})}},E={init:async n=>(console.log(">>> initIDPaySDK > options:",n),S({...n,token:null})),close:D,open:n=>{let{transactionId:e,token:t,onFinish:o}=n;I({transactionId:e,token:t,onFinish:o})}},m={init:async n=>(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({ ... })` or `ByUnicoSDK.init({ ... })`. See our documentation for more details."),S(n)),close:D,open:y};export{A as ByUnicoSDK,E as IDPaySDK,m 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(){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 w(){}function b(){}var E={};l(E,c,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(T([])));P&&P!==n&&r.call(P,c)&&(E=P);var O=b.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 L(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,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 w.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=l(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,s,"GeneratorFunction")),t.prototype=Object.create(O),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(O),l(O,s,"Generator"),l(O,c,(function(){return this})),l(O,"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(j),!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),j(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;j(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.1.3-beta.1",f=!1,h=!1,p="REDIRECT",v="SILENT",d="prod",y="idpay",g="idcash",m="byunico",w=n(n(n({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),d,"https://idpay.unico.io"),b={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},E=function(){console.log(">>> reset"),a=void 0,c=void 0,f=!1,h=!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])},O=function(){var t=e(i().mark((function t(e){var n,r,o,s,y,g,m,E,O,k,S;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.token,s=e.useCurrentOrigin,y=e.env,g=void 0===y?d:y,m=e.type,E=void 0===m?"IFRAME":m,O=e.app,a=E,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===v?9:t.t0===p?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(f=!0,S=!(null!==(n=k)&&void 0!==n&&n.statusPreValidation)||(null===(r=k)||void 0===r?void 0:r.statusPreValidation)===b.DEVICE_SUPPORTED,h&&S&&D(h),!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)}}(),k=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",O(e));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),S=function(t){var e=t.transactionId,n=t.token,r={transactionId:e,token:n,onFinish:t.onFinish,host:c,sdkVersion:l,collectionId:u};if(console.log("open",r),f)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),a){case v:UnicoSDKAssets.clientBoxControl.verify(r);break;case p:UnicoSDKAssets.clientBoxControl.redirect(e,n,c,l);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else h=r},D=function(t){var e=t.transactionId,n=t.token,r=t.onFinish;S({transactionId:e,token:n,onFinish:r})},I=function(){E(),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",O(o(o({},e),{},{app:m})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),close:I,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;S({transactionId:e,token:n,onFinish:function(t){E(),null==r||r(t)}})}},j={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",O(o(o({},e),{},{app:y})));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),close:I,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;S({transactionId:e,token:n,onFinish:r})}},_={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,O(o(o({},e),{},{app:g}));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:I,open:function(t){var e=t.invoiceId,n=t.token,r=t.onFinish;S({transactionId:e,token:n,onFinish:r})}},T={init:k,close:I,open:D};export{L as ByUnicoSDK,_ as IDCashSDK,j as IDPaySDK,b as PRE_VALIDATION_STATUS,T as UnicoSDK};
package/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).UnicoSDK={})}(this,(function(e){"use strict";var n="2.1.1";let o,t,i,s,c=!1,a=!1;const r="IFRAME",l="REDIRECT",d="SILENT",u="dev",p="uat",h="prod",S={[u]:"https://idpay-dev.unico.io",[p]:"https://idpay-uat.unico.io",[h]:"https://idpay.unico.io"},f=()=>{console.log(">>> reset"),o=void 0,t=void 0,c=!1,a=!1,i=void 0},y=async e=>{let{token:u,useCurrentOrigin:p,env:f=h,type:y=r}=e;switch(o=y,t=p?window.location.origin:S[f],await(()=>{if(s)return Promise.resolve();s=document.createElement("script"),s.src=`${t}/sdk-assets/index.js`;const e=new Promise((e=>{s.onload=e}));return document.body.appendChild(s),Promise.all([e])})(),UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),o){case d:i=await UnicoSDKAssets.clientBoxControl.initSilent();break;case l:break;default:await(()=>{const e=document.createElement("link");e.setAttribute("href",`${t}/sdk-assets/assets/styles.css`),e.setAttribute("rel","stylesheet");const n=new Promise((n=>{e.onload=n}));return document.head.appendChild(e),Promise.all([n])})(),UnicoSDKAssets.clientBoxControl.create({host:t,token:u,sdkVersion:n})}if(c=!0,a&&D(a),i)return i},k=e=>{let{transactionId:s,token:r,onFinish:u}=e;const p={transactionId:s,token:r,onFinish:u,host:t,sdkVersion:n,collectionId:i};if(console.log("open",p),c)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,p),o){case d:UnicoSDKAssets.clientBoxControl.verify(p);break;case l:UnicoSDKAssets.clientBoxControl.redirect(s,r,t,n);break;default:UnicoSDKAssets.clientBoxControl.open(p)}else a=p},D=e=>{let{transactionId:n,token:o,onFinish:t}=e;k({transactionId:n,token:o,onFinish:t})},I=()=>{f(),UnicoSDKAssets.clientBoxControl.close()},K={init:async e=>(console.log(">>> initByUnicoSDK > options:",e),y({...e})),close:I,open:e=>{let{transactionId:n,token:o,onFinish:t}=e;k({transactionId:n,token:o,onFinish:e=>{f(),t?.(e)}})}},m={init:async e=>(console.log(">>> initIDPaySDK > options:",e),y({...e,token:null})),close:I,open:e=>{let{transactionId:n,token:o,onFinish:t}=e;k({transactionId:n,token:o,onFinish:t})}},A={init:async e=>(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({ ... })` or `ByUnicoSDK.init({ ... })`. See our documentation for more details."),y(e)),close:I,open:D};e.ByUnicoSDK=K,e.IDPaySDK=m,e.UnicoSDK=A}));
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,P=x&&x(x(_([])));P&&P!==n&&r.call(P,c)&&(E=P);var S=w.prototype=m.prototype=Object.create(E);function O(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 L(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 j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,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(S,"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(S),t},e.awrap=function(t){return{__await:t}},O(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()}))},O(S),l(S,s,"Generator"),l(S,c,(function(){return this})),l(S,"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(j),!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),j(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;j(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.1.3-beta.1",p=!1,h=!1,d="REDIRECT",v="SILENT",y="prod",g="idpay",m="idcash",b="byunico",w=r(r(r({},"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"},x=function(){console.log(">>> reset"),c=void 0,u=void 0,p=!1,h=!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])},O=function(){var t=n(a().mark((function t(e){var n,r,o,i,l,g,m,b,x,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,g=void 0===l?y:l,m=e.type,b=void 0===m?"IFRAME":m,x=e.app,c=b,u=i?window.location.origin:w[g],t.next=5,P();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=c,t.next=t.t0===v?9:t.t0===d?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:x,env:g});case 19:O=t.sent;case 20:if(p=!0,D=!(null!==(n=O)&&void 0!==n&&n.statusPreValidation)||(null===(r=O)||void 0===r?void 0:r.statusPreValidation)===E.DEVICE_SUPPORTED,h&&D&&T(h),!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)}}(),D=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",O(e));case 2: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.log(">>> initByUnicoSDK > options:",e),t.abrupt("return",O(i(i({},e),{},{app:b})));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(">>> initIDPaySDK > options:",e),t.abrupt("return",O(i(i({},e),{},{app:g})));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,O(i(i({},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)}}(),j=function(t){var e=t.transactionId,n=t.token,r={transactionId:e,token:n,onFinish:t.onFinish,host:u,sdkVersion:f,collectionId:s};if(console.log("open",r),p)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),c){case v:UnicoSDKAssets.clientBoxControl.verify(r);break;case d:UnicoSDKAssets.clientBoxControl.redirect(e,n,u,f);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else h=r},T=function(t){var e=t.transactionId,n=t.token,r=t.onFinish;j({transactionId:e,token:n,onFinish:r})},_=function(){x(),UnicoSDKAssets.clientBoxControl.close()},K={init:k,close:_,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;j({transactionId:e,token:n,onFinish:function(t){x(),null==r||r(t)}})}},U={init:I,close:_,open:function(t){var e=t.transactionId,n=t.token,r=t.onFinish;j({transactionId:e,token:n,onFinish:r})}},A={init:L,close:_,open:function(t){var e=t.invoiceId,n=t.token,r=t.onFinish;j({transactionId:e,token:n,onFinish:r})}},C={init:D,close:_,open:T};t.ByUnicoSDK=K,t.IDCashSDK=A,t.IDPaySDK=U,t.PRE_VALIDATION_STATUS=E,t.UnicoSDK=C}));
package/lib/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export namespace PRE_VALIDATION_STATUS {
2
+ let DEVICE_SUPPORTED: string;
3
+ let DEVICE_NOT_SUPPORT: string;
4
+ }
1
5
  export namespace ByUnicoSDK {
2
6
  export { initByUnicoSDK as init };
3
7
  export { close };
@@ -8,6 +12,11 @@ export namespace IDPaySDK {
8
12
  export { close };
9
13
  export { openIDPaySDK as open };
10
14
  }
15
+ export namespace IDCashSDK {
16
+ export { initIDCashSDK as init };
17
+ export { close };
18
+ export { openIDCashSDK as open };
19
+ }
11
20
  export namespace UnicoSDK {
12
21
  export { init };
13
22
  export { close };
@@ -26,6 +35,12 @@ declare function openIDPaySDK({ transactionId, token, onFinish }: {
26
35
  token: any;
27
36
  onFinish: any;
28
37
  }): void;
38
+ declare function initIDCashSDK(options: any): Promise<any>;
39
+ declare function openIDCashSDK({ invoiceId, token, onFinish }: {
40
+ invoiceId: any;
41
+ token: any;
42
+ onFinish: any;
43
+ }): void;
29
44
  /**
30
45
  * @deprecated
31
46
  * The `init()` function is deprecated.
@@ -33,6 +48,7 @@ declare function openIDPaySDK({ transactionId, token, onFinish }: {
33
48
  *
34
49
  * Examples:
35
50
  * - `IDPaySDK.init({ ... })`
51
+ * - `IDCashSDK.init({ ... })`
36
52
  * - `ByUnicoSDK.init({ ... })`
37
53
  *
38
54
  * See our documentation for more details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idpay-b2b-sdk",
3
- "version": "2.1.1",
3
+ "version": "2.1.3-beta.1",
4
4
  "main": "./index.js",
5
5
  "module": "./index.esm.js",
6
6
  "types": "./index.d.ts",
@@ -10,7 +10,8 @@
10
10
  "directory": "libs/pay/sdk/idpay-b2b-sdk"
11
11
  },
12
12
  "publishConfig": {
13
- "registry": "https://registry.npmjs.org"
13
+ "registry": "https://registry.npmjs.org",
14
+ "access": "public"
14
15
  },
15
16
  "scripts": {
16
17
  "correct-dts": "node correct-dts.js",