idpay-b2b-sdk 2.3.0 → 2.3.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/LICENSE +21 -0
- package/assets/.version.d.ts +1 -1
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +20 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 unico
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/assets/.version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "2.3.
|
|
1
|
+
declare const _default: "2.3.1";
|
|
2
2
|
export default _default;
|
package/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,n,e,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?n(u):Promise.resolve(u).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,u,"next",n)}function u(n){t(a,o,i,c,u,"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",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{l({},"")}catch(t){l=function(t,n,e){return t[n]=e}}function f(t,n,e,r){var i=n&&n.prototype instanceof b?n:b,a=Object.create(i.prototype),c=new T(r||[]);return o(a,"_invoke",{value:D(t,e,c)}),a}function p(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=f;var h="suspendedStart",d="suspendedYield",v="executing",y="completed",g={};function b(){}function m(){}function w(){}var E={};l(E,c,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(L([])));P&&P!==e&&r.call(P,c)&&(E=P);var k=w.prototype=b.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(n){l(t,n,(function(t){return this._invoke(n,t)}))}))}function S(t,n){function e(o,i,a,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")?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){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.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=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(n,e,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(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=p(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 _(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 C(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function L(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 m.prototype=w,o(k,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=l(w,s,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===m||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(k),t},n.awrap=function(t){return{__await:t}},O(S.prototype),l(S.prototype,u,(function(){return this})),n.AsyncIterator=S,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new S(f(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(k),l(k,s,"Generator"),l(k,c,(function(){return this})),l(k,"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=L,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(C),!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 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,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),C(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;C(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:L(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),g}},n}var c,u,s,l,f,p="2.3.0",h=["hasPayments"],d=["transactionId","token","onFinish","onWidgetVisibilityChange"],v=["transactionId","token","onFinish"],y=!1,g=!1,b="REDIRECT",m="SILENT",w="prod",E="idpay",x="idcash",P="byunico",k="you",O=e(e(e({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),w,"https://idpay.unico.io"),S={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},D=function(){console.log(">>> reset"),c=void 0,u=void 0,y=!1,g=!1,s=void 0,l=void 0,f=void 0},I=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])},_=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])},C=function(){var t=n(a().mark((function t(n){var e,r,o,i,l,h,d,v,E,x,P,k;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?w:l,d=n.type,v=void 0===d?"IFRAME":d,E=n.app,x=n.hasPayments,c=v,u=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===b?14:15;break;case 9:return t.next=11,UnicoSDKAssets.clientBoxControl.initSilent();case 11:return s=t.sent,P={collectionId:s},t.abrupt("break",20);case 14:return t.abrupt("break",20);case 15:return t.next=17,_();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:u,token:o,sdkVersion:p,app:E,env:h,hasPayments:x});case 19:P=t.sent;case 20:if(y=!0,f=P,k=!(null!==(e=P)&&void 0!==e&&e.statusPreValidation)||(null===(r=P)||void 0===r?void 0:r.statusPreValidation)===S.DEVICE_SUPPORTED,g&&k&&F(g),!P){t.next=26;break}return t.abrupt("return",P);case 26:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),T=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",C(n));case 2: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.log(">>> initByUnicoSDK > options:",n),t.abrupt("return",C(o(o({},n),{},{app:P})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),j=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",n),t.abrupt("return",C(o(o({},n),{},{app:E})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),U=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,C(o(o({},n),{},{app:x}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),V=function(){var t=n(a().mark((function t(n){var e,r;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.hasPayments,r=i(n,h),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,C(o(o({},r),{},{app:k,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)}}(),A=function(t){var n=t.transactionId,e=t.token,r={transactionId:n,token:e,onFinish:t.onFinish,onWidgetVisibilityChange:t.onWidgetVisibilityChange,host:u,sdkVersion:p,collectionId:s};if(console.log("open",r),y)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),c){case m:UnicoSDKAssets.clientBoxControl.verify(r);break;case b:UnicoSDKAssets.clientBoxControl.redirect(n,e,u,p);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else g=r},F=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=i(t,v);A(o({transactionId:n,token:e,onFinish:r},a))},K=function(){D(),UnicoSDKAssets.clientBoxControl.close()},N=function(){var t=n(a().mark((function t(e){var r,o,i,c,u,s,l,h,d,v,g,b,m,E,x;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.container,c=e.id,u=e.token,s=e.env,l=void 0===s?w:s,h=e.app,d=e.config,v=e.onFinish,g=e.onReady,b=e.onClick,m=e.onError,y){t.next=4;break}return t.next=4,C({token:u,env:l,app:h});case 4:if((null===(r=f)||void 0===r?void 0:r.statusPreValidation)!==S.DEVICE_NOT_SUPPORT){t.next=7;break}return null==m||m({reason:S.DEVICE_NOT_SUPPORT}),t.abrupt("return",{destroy:function(){},deviceSupported:!1});case 7:if("function"==typeof(null===(o=UnicoSDKAssets)||void 0===o||null===(o=o.clientBoxControl)||void 0===o?void 0:o.renderButton)){t.next=11;break}return console.warn("Warning: the loaded sdk-assets does not expose clientBoxControl.renderButton. Deploy the sdk-assets build that includes button-box (or serve it locally and init with useCurrentOrigin)."),null==m||m({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",{destroy:function(){},refresh:function(){},deviceSupported:!0});case 11:return x=function(){var t=n(a().mark((function t(n){var e,r,o,i,c,u,s,l;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o="payment"===(null==n?void 0:n.flow),i=!(null===(e=f)||void 0===e||!e.statusPreValidation),c="function"==typeof(null===(r=UnicoSDKAssets)||void 0===r||null===(r=r.clientBoxControl)||void 0===r?void 0:r.preValidateDevice),!o||i||!c){t.next=11;break}return t.next=6,UnicoSDKAssets.clientBoxControl.preValidateDevice();case 6:if(f=t.sent,(null===(u=f)||void 0===u?void 0:u.statusPreValidation)!==S.DEVICE_NOT_SUPPORT){t.next=11;break}return null===(s=E)||void 0===s||null===(l=s.destroy)||void 0===l||l.call(s),null==m||m({reason:S.DEVICE_NOT_SUPPORT}),t.abrupt("return");case 11:null==g||g(n);case 12:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),E=UnicoSDKAssets.clientBoxControl.renderButton({container:i,token:u,env:l,sdkVersion:p,config:d,onReady:x,onError:m,onClicked:function(){null==b||b(),A({transactionId:c,token:u,onFinish:v})}}),t.abrupt("return",{destroy:function(){var t,n;return null===(t=E)||void 0===t||null===(n=t.destroy)||void 0===n?void 0:n.call(t)},refresh:function(){var t,n;return null===(t=E)||void 0===t||null===(n=t.refresh)||void 0===n?void 0:n.call(t)},deviceSupported:!0});case 14:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),B={init:L,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=t.onWidgetVisibilityChange,c=i(t,d);A(o({transactionId:n,token:e,onFinish:function(t){D(),null==r||r(t)},onWidgetVisibilityChange:a},c))}},R={init:j,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})}},G={init:U,close:K,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})}},W={init:V,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})},renderButton:function(t){return N(o(o({},t),{},{app:k}))}},Y={init:T,close:K,open:F,renderButton:N};export{B as ByUnicoSDK,G as IDCashSDK,R as IDPaySDK,S as PRE_VALIDATION_STATUS,Y as UnicoSDK,W as YouSDK};
|
|
1
|
+
function t(t,n,e,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?n(u):Promise.resolve(u).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,u,"next",n)}function u(n){t(a,o,i,c,u,"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",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{l({},"")}catch(t){l=function(t,n,e){return t[n]=e}}function f(t,n,e,r){var i=n&&n.prototype instanceof b?n:b,a=Object.create(i.prototype),c=new T(r||[]);return o(a,"_invoke",{value:D(t,e,c)}),a}function p(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=f;var h="suspendedStart",d="suspendedYield",v="executing",y="completed",g={};function b(){}function m(){}function w(){}var E={};l(E,c,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(L([])));P&&P!==e&&r.call(P,c)&&(E=P);var k=w.prototype=b.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(n){l(t,n,(function(t){return this._invoke(n,t)}))}))}function S(t,n){function e(o,i,a,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")?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){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.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=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(n,e,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(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=p(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 _(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 C(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function L(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 m.prototype=w,o(k,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=l(w,s,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===m||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(k),t},n.awrap=function(t){return{__await:t}},O(S.prototype),l(S.prototype,u,(function(){return this})),n.AsyncIterator=S,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new S(f(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(k),l(k,s,"Generator"),l(k,c,(function(){return this})),l(k,"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=L,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(C),!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 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,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),C(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;C(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:L(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),g}},n}var c,u,s,l,f,p="2.3.1",h=["hasPayments"],d=["transactionId","token","onFinish","onWidgetVisibilityChange"],v=["transactionId","token","onFinish"],y=!1,g=!1,b="REDIRECT",m="SILENT",w="prod",E="idpay",x="idcash",P="byunico",k="you",O=e(e(e({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),w,"https://idpay.unico.io"),S={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},D=function(){console.log(">>> reset"),c=void 0,u=void 0,y=!1,g=!1,s=void 0,l=void 0,f=void 0},I=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])},_=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])},C=function(){var t=n(a().mark((function t(n){var e,r,o,i,l,h,d,v,E,x,P,k;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?w:l,d=n.type,v=void 0===d?"IFRAME":d,E=n.app,x=n.hasPayments,c=v,u=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===b?14:15;break;case 9:return t.next=11,UnicoSDKAssets.clientBoxControl.initSilent();case 11:return s=t.sent,P={collectionId:s},t.abrupt("break",20);case 14:return t.abrupt("break",20);case 15:return t.next=17,_();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:u,token:o,sdkVersion:p,app:E,env:h,hasPayments:x});case 19:P=t.sent;case 20:if(y=!0,f=P,k=!(null!==(e=P)&&void 0!==e&&e.statusPreValidation)||(null===(r=P)||void 0===r?void 0:r.statusPreValidation)===S.DEVICE_SUPPORTED,g&&k&&F(g),!P){t.next=26;break}return t.abrupt("return",P);case 26:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),T=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",C(n));case 2: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.log(">>> initByUnicoSDK > options:",n),t.abrupt("return",C(o(o({},n),{},{app:P})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),j=function(){var t=n(a().mark((function t(n){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.log(">>> initIDPaySDK > options:",n),t.abrupt("return",C(o(o({},n),{},{app:E})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),U=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,C(o(o({},n),{},{app:x}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),V=function(){var t=n(a().mark((function t(n){var e,r;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.hasPayments,r=i(n,h),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,C(o(o({},r),{},{app:k,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)}}(),A=function(t){var n=t.transactionId,e=t.token,r={transactionId:n,token:e,onFinish:t.onFinish,onWidgetVisibilityChange:t.onWidgetVisibilityChange,host:u,sdkVersion:p,collectionId:s};if(console.log("open",r),y)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),c){case m:UnicoSDKAssets.clientBoxControl.verify(r);break;case b:UnicoSDKAssets.clientBoxControl.redirect(n,e,u,p);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else g=r},F=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=i(t,v);A(o({transactionId:n,token:e,onFinish:r},a))},K=function(){D(),UnicoSDKAssets.clientBoxControl.close()},N=function(){var t=n(a().mark((function t(e){var r,o,i,c,u,s,l,h,d,v,g,b,m,E,x;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.container,c=e.id,u=e.token,s=e.env,l=void 0===s?w:s,h=e.app,d=e.config,v=e.onFinish,g=e.onReady,b=e.onClick,m=e.onError,y){t.next=4;break}return t.next=4,C({token:u,env:l,app:h});case 4:if((null===(r=f)||void 0===r?void 0:r.statusPreValidation)!==S.DEVICE_NOT_SUPPORT){t.next=7;break}return null==m||m({reason:S.DEVICE_NOT_SUPPORT}),t.abrupt("return",{destroy:function(){},deviceSupported:!1});case 7:if("function"==typeof(null===(o=UnicoSDKAssets)||void 0===o||null===(o=o.clientBoxControl)||void 0===o?void 0:o.renderButton)){t.next=11;break}return console.warn("Warning: the loaded sdk-assets does not expose clientBoxControl.renderButton. Deploy the sdk-assets build that includes button-box (or serve it locally and init with useCurrentOrigin)."),null==m||m({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",{destroy:function(){},refresh:function(){},deviceSupported:!0});case 11:return x=function(){var t=n(a().mark((function t(n){var e,r,o,i,c,u,s,l;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o="payment"===(null==n?void 0:n.flow),i=!(null===(e=f)||void 0===e||!e.statusPreValidation),c="function"==typeof(null===(r=UnicoSDKAssets)||void 0===r||null===(r=r.clientBoxControl)||void 0===r?void 0:r.preValidateDevice),!o||i||!c){t.next=11;break}return t.next=6,UnicoSDKAssets.clientBoxControl.preValidateDevice();case 6:if(f=t.sent,(null===(u=f)||void 0===u?void 0:u.statusPreValidation)!==S.DEVICE_NOT_SUPPORT){t.next=11;break}return null===(s=E)||void 0===s||null===(l=s.destroy)||void 0===l||l.call(s),null==m||m({reason:S.DEVICE_NOT_SUPPORT}),t.abrupt("return");case 11:null==g||g(n);case 12:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),E=UnicoSDKAssets.clientBoxControl.renderButton({container:i,token:u,env:l,sdkVersion:p,config:d,onReady:x,onError:m,onClicked:function(){null==b||b(),A({transactionId:c,token:u,onFinish:v})}}),t.abrupt("return",{destroy:function(){var t,n;return null===(t=E)||void 0===t||null===(n=t.destroy)||void 0===n?void 0:n.call(t)},refresh:function(){var t,n;return null===(t=E)||void 0===t||null===(n=t.refresh)||void 0===n?void 0:n.call(t)},deviceSupported:!0});case 14:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),B={init:L,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,a=t.onWidgetVisibilityChange,c=i(t,d);A(o({transactionId:n,token:e,onFinish:function(t){D(),null==r||r(t)},onWidgetVisibilityChange:a},c))}},R={init:j,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})}},G={init:U,close:K,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})}},W={init:V,close:K,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})},renderButton:function(t){return N(o(o({},t),{},{app:k}))}},Y={init:T,close:K,open:F,renderButton:N};export{B as ByUnicoSDK,G as IDCashSDK,R as IDPaySDK,S as PRE_VALIDATION_STATUS,Y as UnicoSDK,W as YouSDK};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).UnicoSDK={})}(this,(function(t){"use strict";function n(t,n,e,r,o,i,a){try{var 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 b?n:b,a=Object.create(i.prototype),c=new C(r||[]);return o(a,"_invoke",{value:D(t,e,c)}),a}function p(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=f;var h="suspendedStart",d="suspendedYield",v="executing",y="completed",g={};function b(){}function m(){}function w(){}var E={};l(E,a,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(L([])));P&&P!==e&&r.call(P,a)&&(E=P);var k=w.prototype=b.prototype=Object.create(E);function S(t){["next","throw","return"].forEach((function(n){l(t,n,(function(t){return this._invoke(n,t)}))}))}function O(t,n){function e(o,i,a,c){var s=p(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=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 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===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=p(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 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=p(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 T(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function _(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function L(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 m.prototype=w,o(k,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=l(w,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===m||"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(k),t},n.awrap=function(t){return{__await:t}},S(O.prototype),l(O.prototype,s,(function(){return this})),n.AsyncIterator=O,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new O(f(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(k),l(k,u,"Generator"),l(k,a,(function(){return this})),l(k,"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=L,C.prototype={constructor:C,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!n)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var e=this;function o(r,o){return 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),_(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;_(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:L(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),g}},n}var s,u,l,f,p,h="2.3.0",d=["hasPayments"],v=["transactionId","token","onFinish","onWidgetVisibilityChange"],y=["transactionId","token","onFinish"],g=!1,b=!1,m="REDIRECT",w="SILENT",E="prod",x="idpay",P="idcash",k="byunico",S="you",O=r(r(r({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),E,"https://idpay.unico.io"),D={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},I=function(){console.log(">>> reset"),s=void 0,u=void 0,g=!1,b=!1,l=void 0,f=void 0,p=void 0},T=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])},_=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])},C=function(){var t=e(c().mark((function t(n){var e,r,o,i,a,f,d,v,y,x,P,k;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?E:a,d=n.type,v=void 0===d?"IFRAME":d,y=n.app,x=n.hasPayments,s=v,u=i?window.location.origin:O[f],t.next=5,T();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=s,t.next=t.t0===w?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,_();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:u,token:o,sdkVersion:h,app:y,env:f,hasPayments:x});case 19:P=t.sent;case 20:if(g=!0,p=P,k=!(null!==(e=P)&&void 0!==e&&e.statusPreValidation)||(null===(r=P)||void 0===r?void 0:r.statusPreValidation)===D.DEVICE_SUPPORTED,b&&k&&F(b),!P){t.next=26;break}return t.abrupt("return",P);case 26:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),L=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",C(n));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),j=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",C(i(i({},n),{},{app:k})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),U=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",C(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(">>> initIDCashSDK > options:",n),t.next=3,C(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)}}(),V=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,d),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,C(i(i({},r),{},{app:S,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)}}(),A=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),g)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),s){case w:UnicoSDKAssets.clientBoxControl.verify(r);break;case m:UnicoSDKAssets.clientBoxControl.redirect(n,e,u,h);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else b=r},F=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=a(t,y);A(i({transactionId:n,token:e,onFinish:r},o))},N=function(){I(),UnicoSDKAssets.clientBoxControl.close()},B=function(){var t=e(c().mark((function t(n){var r,o,i,a,s,u,l,f,d,v,y,b,m,w,x;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.container,a=n.id,s=n.token,u=n.env,l=void 0===u?E:u,f=n.app,d=n.config,v=n.onFinish,y=n.onReady,b=n.onClick,m=n.onError,g){t.next=4;break}return t.next=4,C({token:s,env:l,app:f});case 4:if((null===(r=p)||void 0===r?void 0:r.statusPreValidation)!==D.DEVICE_NOT_SUPPORT){t.next=7;break}return null==m||m({reason:D.DEVICE_NOT_SUPPORT}),t.abrupt("return",{destroy:function(){},deviceSupported:!1});case 7:if("function"==typeof(null===(o=UnicoSDKAssets)||void 0===o||null===(o=o.clientBoxControl)||void 0===o?void 0:o.renderButton)){t.next=11;break}return console.warn("Warning: the loaded sdk-assets does not expose clientBoxControl.renderButton. Deploy the sdk-assets build that includes button-box (or serve it locally and init with useCurrentOrigin)."),null==m||m({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",{destroy:function(){},refresh:function(){},deviceSupported:!0});case 11:return x=function(){var t=e(c().mark((function t(n){var e,r,o,i,a,s,u,l;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o="payment"===(null==n?void 0:n.flow),i=!(null===(e=p)||void 0===e||!e.statusPreValidation),a="function"==typeof(null===(r=UnicoSDKAssets)||void 0===r||null===(r=r.clientBoxControl)||void 0===r?void 0:r.preValidateDevice),!o||i||!a){t.next=11;break}return t.next=6,UnicoSDKAssets.clientBoxControl.preValidateDevice();case 6:if(p=t.sent,(null===(s=p)||void 0===s?void 0:s.statusPreValidation)!==D.DEVICE_NOT_SUPPORT){t.next=11;break}return null===(u=w)||void 0===u||null===(l=u.destroy)||void 0===l||l.call(u),null==m||m({reason:D.DEVICE_NOT_SUPPORT}),t.abrupt("return");case 11:null==y||y(n);case 12:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),w=UnicoSDKAssets.clientBoxControl.renderButton({container:i,token:s,env:l,sdkVersion:h,config:d,onReady:x,onError:m,onClicked:function(){null==b||b(),A({transactionId:a,token:s,onFinish:v})}}),t.abrupt("return",{destroy:function(){var t,n;return null===(t=w)||void 0===t||null===(n=t.destroy)||void 0===n?void 0:n.call(t)},refresh:function(){var t,n;return null===(t=w)||void 0===t||null===(n=t.refresh)||void 0===n?void 0:n.call(t)},deviceSupported:!0});case 14:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),R={init:j,close:N,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,c=a(t,v);A(i({transactionId:n,token:e,onFinish:function(t){I(),null==r||r(t)},onWidgetVisibilityChange:o},c))}},G={init:U,close:N,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})}},W={init:K,close:N,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})}},Y={init:V,close:N,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})},renderButton:function(t){return B(i(i({},t),{},{app:S}))}},z={init:L,close:N,open:F,renderButton:B};t.ByUnicoSDK=R,t.IDCashSDK=W,t.IDPaySDK=G,t.PRE_VALIDATION_STATUS=D,t.UnicoSDK=z,t.YouSDK=Y}));
|
|
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 b?n:b,a=Object.create(i.prototype),c=new C(r||[]);return o(a,"_invoke",{value:D(t,e,c)}),a}function p(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=f;var h="suspendedStart",d="suspendedYield",v="executing",y="completed",g={};function b(){}function m(){}function w(){}var E={};l(E,a,(function(){return this}));var x=Object.getPrototypeOf,P=x&&x(x(L([])));P&&P!==e&&r.call(P,a)&&(E=P);var k=w.prototype=b.prototype=Object.create(E);function S(t){["next","throw","return"].forEach((function(n){l(t,n,(function(t){return this._invoke(n,t)}))}))}function O(t,n){function e(o,i,a,c){var s=p(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=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 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===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=v;var u=p(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 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=p(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 T(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function _(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function L(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 m.prototype=w,o(k,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=l(w,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===m||"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(k),t},n.awrap=function(t){return{__await:t}},S(O.prototype),l(O.prototype,s,(function(){return this})),n.AsyncIterator=O,n.async=function(t,e,r,o,i){void 0===i&&(i=Promise);var a=new O(f(t,e,r,o),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(k),l(k,u,"Generator"),l(k,a,(function(){return this})),l(k,"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=L,C.prototype={constructor:C,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!n)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var e=this;function o(r,o){return 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),_(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;_(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(n,e,r){return this.delegate={iterator:L(n),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=t),g}},n}var s,u,l,f,p,h="2.3.1",d=["hasPayments"],v=["transactionId","token","onFinish","onWidgetVisibilityChange"],y=["transactionId","token","onFinish"],g=!1,b=!1,m="REDIRECT",w="SILENT",E="prod",x="idpay",P="idcash",k="byunico",S="you",O=r(r(r({},"dev","https://idpay-dev.unico.io"),"uat","https://idpay-uat.unico.io"),E,"https://idpay.unico.io"),D={DEVICE_SUPPORTED:"DEVICE_SUPPORTED",DEVICE_NOT_SUPPORT:"DEVICE_NOT_SUPPORT"},I=function(){console.log(">>> reset"),s=void 0,u=void 0,g=!1,b=!1,l=void 0,f=void 0,p=void 0},T=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])},_=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])},C=function(){var t=e(c().mark((function t(n){var e,r,o,i,a,f,d,v,y,x,P,k;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?E:a,d=n.type,v=void 0===d?"IFRAME":d,y=n.app,x=n.hasPayments,s=v,u=i?window.location.origin:O[f],t.next=5,T();case 5:UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t.t0=s,t.next=t.t0===w?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,_();case 17:return t.next=19,UnicoSDKAssets.clientBoxControl.create({host:u,token:o,sdkVersion:h,app:y,env:f,hasPayments:x});case 19:P=t.sent;case 20:if(g=!0,p=P,k=!(null!==(e=P)&&void 0!==e&&e.statusPreValidation)||(null===(r=P)||void 0===r?void 0:r.statusPreValidation)===D.DEVICE_SUPPORTED,b&&k&&F(b),!P){t.next=26;break}return t.abrupt("return",P);case 26:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),L=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",C(n));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),j=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",C(i(i({},n),{},{app:k})));case 2:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),U=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",C(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(">>> initIDCashSDK > options:",n),t.next=3,C(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)}}(),V=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,d),console.log(">>> initYouSDK > options:",r,"hasPayments:",e),t.next=4,C(i(i({},r),{},{app:S,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)}}(),A=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),g)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,r),s){case w:UnicoSDKAssets.clientBoxControl.verify(r);break;case m:UnicoSDKAssets.clientBoxControl.redirect(n,e,u,h);break;default:UnicoSDKAssets.clientBoxControl.open(r)}else b=r},F=function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=a(t,y);A(i({transactionId:n,token:e,onFinish:r},o))},N=function(){I(),UnicoSDKAssets.clientBoxControl.close()},B=function(){var t=e(c().mark((function t(n){var r,o,i,a,s,u,l,f,d,v,y,b,m,w,x;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.container,a=n.id,s=n.token,u=n.env,l=void 0===u?E:u,f=n.app,d=n.config,v=n.onFinish,y=n.onReady,b=n.onClick,m=n.onError,g){t.next=4;break}return t.next=4,C({token:s,env:l,app:f});case 4:if((null===(r=p)||void 0===r?void 0:r.statusPreValidation)!==D.DEVICE_NOT_SUPPORT){t.next=7;break}return null==m||m({reason:D.DEVICE_NOT_SUPPORT}),t.abrupt("return",{destroy:function(){},deviceSupported:!1});case 7:if("function"==typeof(null===(o=UnicoSDKAssets)||void 0===o||null===(o=o.clientBoxControl)||void 0===o?void 0:o.renderButton)){t.next=11;break}return console.warn("Warning: the loaded sdk-assets does not expose clientBoxControl.renderButton. Deploy the sdk-assets build that includes button-box (or serve it locally and init with useCurrentOrigin)."),null==m||m({reason:"RENDER_BUTTON_UNAVAILABLE"}),t.abrupt("return",{destroy:function(){},refresh:function(){},deviceSupported:!0});case 11:return x=function(){var t=e(c().mark((function t(n){var e,r,o,i,a,s,u,l;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o="payment"===(null==n?void 0:n.flow),i=!(null===(e=p)||void 0===e||!e.statusPreValidation),a="function"==typeof(null===(r=UnicoSDKAssets)||void 0===r||null===(r=r.clientBoxControl)||void 0===r?void 0:r.preValidateDevice),!o||i||!a){t.next=11;break}return t.next=6,UnicoSDKAssets.clientBoxControl.preValidateDevice();case 6:if(p=t.sent,(null===(s=p)||void 0===s?void 0:s.statusPreValidation)!==D.DEVICE_NOT_SUPPORT){t.next=11;break}return null===(u=w)||void 0===u||null===(l=u.destroy)||void 0===l||l.call(u),null==m||m({reason:D.DEVICE_NOT_SUPPORT}),t.abrupt("return");case 11:null==y||y(n);case 12:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),w=UnicoSDKAssets.clientBoxControl.renderButton({container:i,token:s,env:l,sdkVersion:h,config:d,onReady:x,onError:m,onClicked:function(){null==b||b(),A({transactionId:a,token:s,onFinish:v})}}),t.abrupt("return",{destroy:function(){var t,n;return null===(t=w)||void 0===t||null===(n=t.destroy)||void 0===n?void 0:n.call(t)},refresh:function(){var t,n;return null===(t=w)||void 0===t||null===(n=t.refresh)||void 0===n?void 0:n.call(t)},deviceSupported:!0});case 14:case"end":return t.stop()}}),t)})));return function(n){return t.apply(this,arguments)}}(),R={init:j,close:N,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish,o=t.onWidgetVisibilityChange,c=a(t,v);A(i({transactionId:n,token:e,onFinish:function(t){I(),null==r||r(t)},onWidgetVisibilityChange:o},c))}},G={init:U,close:N,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})}},W={init:K,close:N,open:function(t){var n=t.invoiceId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})}},Y={init:V,close:N,open:function(t){var n=t.transactionId,e=t.token,r=t.onFinish;A({transactionId:n,token:e,onFinish:r})},renderButton:function(t){return B(i(i({},t),{},{app:S}))}},z={init:L,close:N,open:F,renderButton:B};t.ByUnicoSDK=R,t.IDCashSDK=W,t.IDPaySDK=G,t.PRE_VALIDATION_STATUS=D,t.UnicoSDK=z,t.YouSDK=Y}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "idpay-b2b-sdk",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
|
+
"description": "Embed Unico's identity verification journeys (document capture, facial liveness, and more) directly into your web application.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Unico",
|
|
8
|
+
"url": "https://unico.io"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://developer.unico.io/developers/sdks-and-tools/web/web-integration/index.html",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"unico",
|
|
13
|
+
"identity",
|
|
14
|
+
"identity-verification",
|
|
15
|
+
"kyc",
|
|
16
|
+
"document-capture",
|
|
17
|
+
"liveness",
|
|
18
|
+
"biometrics",
|
|
19
|
+
"journeys",
|
|
20
|
+
"sdk"
|
|
21
|
+
],
|
|
4
22
|
"main": "./index.js",
|
|
5
23
|
"module": "./index.esm.js",
|
|
6
24
|
"types": "./index.d.ts",
|
|
@@ -13,9 +31,5 @@
|
|
|
13
31
|
"registry": "https://registry.npmjs.org",
|
|
14
32
|
"access": "public"
|
|
15
33
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"correct-dts": "node correct-dts.js",
|
|
18
|
-
"build-with-postbuild": "nx run idpay-b2b-sdk:build-with-postbuild"
|
|
19
|
-
},
|
|
20
34
|
"type": "module"
|
|
21
|
-
}
|
|
35
|
+
}
|