Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@paybyrd/threedsecure-service

Package Overview
Dependencies
Maintainers
5
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paybyrd/threedsecure-service - npm Package Compare versions

Comparing version 3.2.3 to 3.2.4

2

dist/index.module.js

@@ -1,2 +0,2 @@

function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},e.apply(this,arguments)}function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},t.apply(this,arguments)}var r,n=/*#__PURE__*/function(){function e(){}var r=e.prototype;return r.flush=function(){return Promise.resolve()},r.log=function(e){var r,n=t({},e,{error:null==(r=e.error)?void 0:r.toString()});console.log(n)},e}();function o(e,t,r){if(!e.s){if(r instanceof i){if(!r.s)return void(r.o=o.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(o.bind(null,e,t),o.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(r||(r={}));var i=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{o(n,1,a(this.v))}catch(e){o(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?o(n,1,t?t(i):i):r?o(n,1,r(i)):o(n,2,i)}catch(e){o(n,2,e)}},n},e}();function a(e){return e instanceof i&&1&e.s}var s=/*#__PURE__*/function(){function e(t,r){void 0===r&&(r=new n),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=r,this._options=t,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))}var t=e.prototype;return t.log=function(t){if(this._logger.log(t),this._options.restLoggerUrl){var r="["+this._options.service.name+"] "+t.message;t.elapsedTimeInMilliseconds&&(r=r+" in "+t.elapsedTimeInMilliseconds+"ms"),this._logs.unshift({customMessage:t.message,message:r,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:e.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds})}},t.flush=function(){try{var t=function(){r._interval=setInterval(r.sendBatch.bind(r),1e3*(r._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))},r=this;clearInterval(r._interval);var n=function(e,t,r){for(var n;;){var s=e();if(a(s)&&(s=s.v),!s)return l;if(s.then){n=0;break}var l=r();if(l&&l.then){if(!a(l)){n=1;break}l=l.s}if(t){var c=t();if(c&&c.then&&!a(c)){n=2;break}}}var u=new i,h=o.bind(null,u,2);return(0===n?s.then(m):1===n?l.then(d):c.then(v)).then(void 0,h),u;function d(n){l=n;do{if(t&&(c=t())&&c.then&&!a(c))return void c.then(v).then(void 0,h);if(!(s=e())||a(s)&&!s.v)return void o(u,1,l);if(s.then)return void s.then(m).then(void 0,h);a(l=r())&&(l=l.v)}while(!l||!l.then);l.then(d).then(void 0,h)}function m(e){e?(l=r())&&l.then?l.then(d).then(void 0,h):d(l):o(u,1,l)}function v(){(s=e())?s.then?s.then(m).then(void 0,h):m(s):o(u,1,l)}}(function(){return!!r._logs.length},void 0,function(){return Promise.resolve(r.sendBatch()).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},t.sendBatch=function(){try{var e=this,t=e._logs.splice(0,10);if(!t.length)return Promise.resolve();var n=crypto.randomUUID(),o=function(o,i){try{var a=(s=1e3*(e._options.timeoutInSeconds||30),l=new AbortController,c=setTimeout(function(){return l.abort()},s),Promise.resolve(fetch(e._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(t),signal:l.signal})).then(function(o){clearTimeout(c),o.ok||e._logger.log({message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:n,level:r.Error})}))}catch(e){return i(e)}var s,l,c;return a&&a.then?a.then(void 0,i):a}(0,function(o){e._logger.log({error:o,message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:n,level:r.Error})});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},e.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},e}();s.DEFAULT_BATCH_TIMEOUT=5;var l=/*#__PURE__*/function(){function e(){this.start=void 0,this.end=void 0,this.start=Date.now()}var t,r;return e.prototype.stop=function(){this.end=Date.now()},t=e,(r=[{key:"elapsed",get:function(){return(this.end||Date.now())-this.start}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}(),c=/*#__PURE__*/function(){function e(){}return e.convert=function(e){var t=JSON.stringify(e);return btoa(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e}(),u=/*#__PURE__*/function(){function e(){}return e.create=function(){var e=[48,32,24,16,15,8,4,1].find(function(e){return e<=screen.colorDepth});return{javaEnabled:navigator.javaEnabled(),javascriptEnabled:!0,language:navigator.language,userAgent:navigator.userAgent,screenWidth:window.screen.width,screenHeight:window.screen.height,timezoneOffset:(new Date).getTimezoneOffset(),colorDepth:e,acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}},e}(),h=/*#__PURE__*/function(){function e(e){var t=this;this._task=void 0,this._timeout=void 0,this._task=new Promise(function(r){t._timeout=setTimeout(r,e)})}var t=e.prototype;return t.wait=function(){return this._task},t.cancel=function(){clearTimeout(this._timeout),this._task=Promise.reject({message:"Timer cancelled"})},e.sleep=function(t){return new e(t)},e.cancel=function(e){clearTimeout(e)},e}(),d=/*#__PURE__*/function(){function e(){}return e.createIFrame=function(e){var t=document.createElement("iframe");return t.id=e.name,t.name=e.name,e.onReadyFn&&e.onReadyFn(t,e.isVisible),e.onCreatedFn&&(e.onCreatedFn(t),t.style.opacity=e.isVisible?"1":"0"),e.parent.appendChild(t),t},e.createForm=function(e){var t=document.createElement("form");return t.id=e.name,t.name=e.name,t.action=e.actionUrl,t.target=e.target,t.method=e.method,e.parent.appendChild(t),t},e.createInput=function(e){var t=document.createElement("input");return t.id=e.name,t.name=e.name,t.type=e.type,e.parent.appendChild(t),t},e}();function m(e,t,r){if(!e.s){if(r instanceof v){if(!r.s)return void(r.o=m.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(m.bind(null,e,t),m.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var v=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{m(n,1,i(this.v))}catch(e){m(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?m(n,1,t?t(o):o):r?m(n,1,r(o)):m(n,2,o)}catch(e){m(n,2,e)}},n},e}();function g(e){return e instanceof v&&1&e.s}var p,f=/*#__PURE__*/function(){function e(e,t){this._options=void 0,this._logger=void 0,this._options=e,this._logger=t}return e.prototype.execute=function(e){var t=this,n=e.executeFn,o=e.method,i=e.correlationId;return new Promise(function(e,a){try{var s,l=function(e){var n;if(s)return e;a(u),t._logger.log({message:'Unhandled error calling "'+o+'"',error:null==(n=u)?void 0:n.error,content:{attempt:c,maxAttempts:t._options.maxAttempts},method:o,correlationId:i,level:r.Error})},c=1,u=null,d=function(e,t){var r;do{var n=e();if(n&&n.then){if(!g(n)){r=!0;break}n=n.v}var o=t();if(g(o)&&(o=o.v),!o)return n}while(!o.then);var i=new v,a=m.bind(null,i,2);return(r?n.then(s):o.then(l)).then(void 0,a),i;function s(r){for(n=r;g(o=t())&&(o=o.v),o;){if(o.then)return void o.then(l).then(void 0,a);if((n=e())&&n.then){if(!g(n))return void n.then(s).then(void 0,a);n=n.v}}m(i,1,n)}function l(r){if(r){do{if((n=e())&&n.then){if(!g(n))return void n.then(s).then(void 0,a);n=n.v}if(g(r=t())&&(r=r.v),!r)return void m(i,1,n)}while(!r.then);r.then(l).then(void 0,a)}else m(i,1,n)}}(function(){function l(e){return s?e:(c++,Promise.resolve(h.sleep(1e3*t._options.attemptDelayInSeconds).wait()).then(function(){}))}var d=function(r,o){try{var i=Promise.resolve(n({attempt:c,maxAttempts:t._options.maxAttempts})).then(function(t){if(t.isSuccess)return e(t),void(s=1);t.isTransientError||(a(t),s=1)})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){u={message:'Unhandled error calling "'+o+'"',error:e,additionalData:{attempt:c,maxAttempts:t._options.maxAttempts}},t._logger.log({message:'Unhandled error calling "'+o+'"',error:e,content:{attempt:c,maxAttempts:t._options.maxAttempts},method:o,correlationId:i,level:r.Warning})});return d&&d.then?d.then(l):l(d)},function(){return!s&&c<=t._options.maxAttempts});return Promise.resolve(d&&d.then?d.then(l):l(d))}catch(e){return Promise.reject(e)}})},e}(),I=/*#__PURE__*/function(){function t(e,t,r){void 0===r&&(r=new f(e,t)),this._options=void 0,this._retryPolicy=void 0,this._logger=void 0,this._retryPolicy=r,this._logger=t,this._options=e}var n=t.prototype;return n.send=function(t){try{var n=this,o=n;return Promise.resolve(n._retryPolicy.execute({executeFn:function(i){var a=i.attempt,s=i.maxAttempts;try{var c=function(e){clearTimeout(d);var t={isSuccess:v.ok,isTransientError:n.isTransientError(v),getData:function(){try{return Promise.resolve(v.json()).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}};return t},u=1e3*(o._options.timeoutInSeconds||30),h=new AbortController,d=setTimeout(function(){return h.abort()},u),m=new URL(t.url);n._logger.log({message:"ExternalService - Request ("+m.host+")",content:{request:t,attempt:a,maxAttempts:s},method:"send",correlationId:t.correlationId,level:r.Information});var v,g=new l,p=function(o,i){try{var l=Promise.resolve(fetch(t.url,{headers:e({},t.headers,{"x-attempt":a.toString(),"x-max-attempt":s.toString(),accept:"application/json","content-type":"application/json",correlationId:t.correlationId}),keepalive:!0,body:JSON.stringify(t.body),method:t.method,signal:h.signal})).then(function(e){var o=n._logger,i=o.log,l="ExternalService - Response ("+m.host+")",c=(v=e).status;return Promise.resolve(v.clone().text()).then(function(e){i.call(o,{message:l,content:{request:t,attempt:a,maxAttempts:s,response:{statusCode:c,data:e}},method:"send",correlationId:t.correlationId,level:r.Information,elapsedTimeInMilliseconds:g.elapsed})})})}catch(e){return i(e)}return l&&l.then?l.then(void 0,i):l}(0,function(e){throw n._logger.log({message:"ExternalService - Error ("+m.host+")",content:{request:t,attempt:a,maxAttempts:s,error:e},method:"send",correlationId:t.correlationId,level:r.Error,elapsedTimeInMilliseconds:g.elapsed}),e});return Promise.resolve(p&&p.then?p.then(c):c())}catch(e){return Promise.reject(e)}},method:"["+t.method+"] "+t.url,correlationId:t.correlationId}))}catch(e){return Promise.reject(e)}},n.isTransientError=function(e){return[409,424,500,503,504].includes(e.status)},t}();!function(e){e.width250xheight400="01",e.width390xheight400="02",e.width500xheight600="03",e.width600xheight400="04",e.fullscreen="05"}(p||(p={}));var _=/*#__PURE__*/function(){function e(e,t){this._options=void 0,this._logger=void 0,this._options=e,this._logger=t}var t=e.prototype;return t.execute=function(t){var n=this;return t.authResponse.challengeUrl?new Promise(function(o,i){try{n._logger.log({message:"Challenge - Start",content:{authResponse:t.authResponse},method:"executeChallenge",correlationId:t.correlationId,level:r.Information}),n._options.container.innerHTML="";var a=d.createIFrame({parent:n._options.container,name:e.IFRAME_NAME,isVisible:!0,useDefaultStyle:!!n._options.onIFrameCreatedFn,onCreatedFn:n._options.onIFrameCreatedFn,onReadyFn:n._options.onIFrameReadyFn});n._logger.log({message:"Challenge - Create iFrame",method:"executeChallenge",correlationId:t.correlationId,level:r.Information});var s=d.createForm({parent:n._options.container,name:e.FORM_NAME,actionUrl:t.authResponse.challengeUrl,target:e.IFRAME_NAME,method:"post"});n._logger.log({message:"Challenge - Create form",method:"executeChallenge",correlationId:t.correlationId,level:r.Information});var u=d.createInput({parent:s,name:e.CREQ_INPUT_NAME,type:e.CREQ_INPUT_TYPE});n._logger.log({message:"Challenge - Create input",method:"executeChallenge",correlationId:t.correlationId,level:r.Information});var h={threeDSServerTransID:t.authResponse.processId,acsTransID:t.authResponse.challengeId,messageVersion:t.authResponse.challengeVersion,messageType:"CReq",challengeWindowSize:n._options.challengeWindowSize||p.width250xheight400},m=c.convert(h);u.value=m,n._logger.log({message:"Challenge - Prepare cReq",content:{cReq:h,base64CReq:m},method:"executeChallenge",correlationId:t.correlationId,level:r.Information});var v=new l;s.submit(),setTimeout(function e(){var o,i=a.contentDocument||(null==(o=a.contentWindow)?void 0:o.document);"complete"!=(null==i?void 0:i.readyState)?setTimeout(e,100):n._logger.log({message:"Challenge - iFrame loaded in "+v.elapsed+"ms",content:{iFrame:i.body.innerText},method:"executeChallenge",correlationId:t.correlationId,level:r.Information})},100),n._logger.log({message:"Challenge - Submit form",content:{authResponse:t.authResponse,cReq:h,base64CReq:m},method:"executeChallenge",correlationId:t.correlationId,level:r.Information}),o()}catch(e){return n._logger.log({message:"Challenge - error",content:{authResponse:t.authResponse},error:e,method:"executeChallenge",correlationId:t.correlationId,level:r.Error}),i({message:e.toString()})}}):Promise.resolve()},t.reset=function(){try{var t,r,n;null==(t=document.getElementById(e.IFRAME_NAME))||t.remove(),null==(r=document.getElementById(e.FORM_NAME))||r.remove(),null==(n=document.getElementById(e.CREQ_INPUT_NAME))||n.remove()}catch(e){}},e}();_.IFRAME_NAME="challengeIframe",_.FORM_NAME="challengeForm",_.CREQ_INPUT_NAME="creq",_.CREQ_INPUT_TYPE="hidden";var y,A=/*#__PURE__*/function(){function e(e,t){this._logger=void 0,this._options=void 0,this._logger=t,this._options=e}var t=e.prototype;return t.execute=function(t){var n=this;return t.preAuthResponse.dsMethodUrl?new Promise(function(o,i){try{var a;n._logger.log({message:"DirectoryServer - Start",content:{preAuthResponse:t},method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information}),n._options.container.innerHTML="";var s=d.createIFrame({parent:n._options.container,isVisible:!1,name:e.IFRAME_NAME,useDefaultStyle:!!n._options.onIFrameCreatedFn});null==(a=n._options.onIFrameCreatedFn)||a.call(n._options,s),n._logger.log({message:"DirectoryServer - Create iFrame",method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information});var u=d.createForm({parent:n._options.container,name:e.FORM_NAME,actionUrl:t.preAuthResponse.dsMethodUrl,target:e.IFRAME_NAME,method:"POST"});n._logger.log({message:"DirectoryServer - Create Form",method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information});var h=d.createInput({parent:u,name:e.FORM_INPUT_NAME,type:e.FROM_INPUT_TYPE});n._logger.log({message:"DirectoryServer - Create Input",method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information});var m={threeDSServerTransID:t.preAuthResponse.processId,threeDSMethodNotificationURL:t.preAuthResponse.notificationUrl},v=c.convert(m);h.value=v,n._logger.log({message:"DirectoryServer - Prepare threeDSMethodData",content:{threeDSMethodData:m,threeDSMethodDataBase64:v},method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information});var g=new l;u.submit(),setTimeout(function e(){var o,i=s.contentDocument||(null==(o=s.contentWindow)?void 0:o.document);"complete"!=(null==i?void 0:i.readyState)?setTimeout(e,100):n._logger.log({message:"DirectoryServer - iFrame loaded in "+g.elapsed+"ms",content:{iFrame:i.body.innerText},method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information})},100),n._logger.log({message:"DirectoryServer - Submit form",content:{threeDSMethodData:m,threeDSMethodDataBase64:v},method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information}),o()}catch(e){return n._logger.log({message:"DirectoryServer - Error",content:{preAuthResponse:t},error:e,method:"directoryServerExecute",correlationId:t.correlationId,level:r.Error}),i({message:e.toString()})}}):Promise.resolve()},t.reset=function(){try{var t,r,n;null==(t=document.getElementById(e.IFRAME_NAME))||t.remove(),null==(r=document.getElementById(e.FORM_NAME))||r.remove(),null==(n=document.getElementById(e.FORM_INPUT_NAME))||n.remove()}catch(e){}},e}();A.IFRAME_NAME="threeDSMethodIframe",A.FORM_NAME="threeDSMethodForm",A.FORM_INPUT_NAME="threeDSMethodData",A.FROM_INPUT_TYPE="hidden",function(e){e.PreAuthStarted="preAuth:started",e.PreAuthCompleted="preAuth:completed",e.AuthStarted="auth:started",e.AuthCompleted="auth:completed",e.PostAuthStarted="postAuth:started",e.PostAuthCompleted="postAuth:completed",e.PostAuthFailed="postAuth:failed",e.ResetStarted="reset:started",e.ResetCompleted="reset:completed"}(y||(y={}));var S=/*#__PURE__*/function(){function e(t,r,n,o,i){void 0===r&&(r=new s(e.getLoggerOptions(t))),void 0===n&&(n=new I(e.getHttpClientOptions(t),r)),void 0===o&&(o=new A(t,r)),void 0===i&&(i=new _(t,r)),this._options=void 0,this._logger=void 0,this._client=void 0,this._directoryServer=void 0,this._challenge=void 0,this._observers=[],this._options=t,this._logger=r,this._client=n,this._directoryServer=o,this._challenge=i}var t=e.prototype;return t.subscribe=function(e){this._observers.push(e)},t.unsubscribe=function(e){var t=this._observers.indexOf(e);t>-1&&this._observers.splice(t,1)},t.execute=function(e,t){try{var n=this;return void 0===t&&(t=crypto.randomUUID()),e.correlationId||(e.correlationId=t,n._logger.log({message:"Obsolete request. CorrelationId is not set.",content:e,method:"execute",correlationId:e.correlationId,level:r.Information})),Promise.resolve(function(t,r){try{var o=Promise.resolve(n.preAuth(e)).then(function(t){return Promise.resolve(n._directoryServer.execute({preAuthResponse:t,correlationId:e.correlationId})).then(function(){return Promise.resolve(n.auth(e)).then(function(t){return Promise.resolve(n._challenge.execute({authResponse:t,correlationId:e.correlationId})).then(function(){return Promise.resolve(n.postAuth(e))})})})})}catch(e){return r(!0,e)}return o&&o.then?o.then(r.bind(null,!1),r.bind(null,!0)):r(!1,o)}(0,function(e,t){return n.reset(),Promise.resolve(n._logger.flush()).then(function(){if(e)throw t;return t})}))}catch(e){return Promise.reject(e)}},t.preAuth=function(e){try{var t=this;return t._logger.log({message:"Executing PreAuth",content:e,method:"_preAuth",correlationId:e.correlationId,level:r.Information}),t.notifyAll({name:y.PreAuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v2/"+e.id+"/preAuth",method:"POST",body:{browser:u.create()},correlationId:e.correlationId})).then(function(e){return t.notifyAll({name:y.PreAuthCompleted,data:e}),Promise.resolve(e.getData())})}catch(e){return Promise.reject(e)}},t.auth=function(e){try{var t=this;return t._logger.log({message:"Executing Auth",content:e,method:"_auth",correlationId:e.correlationId,level:r.Information}),t.notifyAll({name:y.AuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v1/"+e.id+"/auth",method:"POST",correlationId:e.correlationId})).then(function(e){return t.notifyAll({name:y.AuthCompleted,data:e}),Promise.resolve(e.getData())})}catch(e){return Promise.reject(e)}},t.postAuth=function(e){try{var t=this;return t._logger.log({message:"Executing PostAuth",content:e,method:"_postAuth",correlationId:e.correlationId,level:r.Information}),t.notifyAll({name:y.PostAuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v2/"+e.id+"/postAuth",method:"POST",correlationId:e.correlationId})).then(function(e){return Promise.resolve(e.getData()).then(function(e){return t.notifyAll({name:y.PostAuthCompleted,data:e}),e})})}catch(e){return Promise.reject(e)}},t.reset=function(){this.notifyAll({name:y.ResetStarted}),this._challenge.reset(),this._directoryServer.reset(),this.notifyAll({name:y.ResetCompleted})},t.notifyAll=function(e){this._observers.forEach(function(t){return t.notify(e)})},e.getLoggerOptions=function(e){return{restLoggerUrl:e.logUrl,timeoutInSeconds:e.timeoutInSeconds||30,environment:e.environment||"Production",batchLogIntervalInSeconds:e.batchLogIntervalInSeconds||5,service:{name:"Paybyrd.ThreeDSecure.JS",version:"3.2.3"}}},e.getHttpClientOptions=function(e){return{timeoutInSeconds:e.timeoutInSeconds||30,attemptDelayInSeconds:e.attemptDelayInSeconds||2,maxAttempts:e.maxAttempts||50}},e}();export{p as ChallengeWindowSize,f as LinearRetryPolicy,S as ThreeDSecureService};
function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},e.apply(this,arguments)}function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},t.apply(this,arguments)}var r,n=/*#__PURE__*/function(){function e(){}var r=e.prototype;return r.flush=function(){return Promise.resolve()},r.log=function(e){var r,n=t({},e,{error:null==(r=e.error)?void 0:r.toString()});console.log(n)},e}();function o(e,t,r){if(!e.s){if(r instanceof i){if(!r.s)return void(r.o=o.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(o.bind(null,e,t),o.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(r||(r={}));var i=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{o(n,1,a(this.v))}catch(e){o(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?o(n,1,t?t(i):i):r?o(n,1,r(i)):o(n,2,i)}catch(e){o(n,2,e)}},n},e}();function a(e){return e instanceof i&&1&e.s}var s=/*#__PURE__*/function(){function e(t,r){void 0===r&&(r=new n),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=r,this._options=t,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))}var t=e.prototype;return t.log=function(t){if(this._logger.log(t),this._options.restLoggerUrl){var r="["+this._options.service.name+"] "+t.message;t.elapsedTimeInMilliseconds&&(r=r+" in "+t.elapsedTimeInMilliseconds+"ms"),this._logs.unshift({customMessage:t.message,message:r,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:e.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds})}},t.flush=function(){try{var t=function(){r._interval=setInterval(r.sendBatch.bind(r),1e3*(r._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))},r=this;clearInterval(r._interval);var n=function(e,t,r){for(var n;;){var s=e();if(a(s)&&(s=s.v),!s)return l;if(s.then){n=0;break}var l=r();if(l&&l.then){if(!a(l)){n=1;break}l=l.s}if(t){var c=t();if(c&&c.then&&!a(c)){n=2;break}}}var u=new i,h=o.bind(null,u,2);return(0===n?s.then(m):1===n?l.then(d):c.then(v)).then(void 0,h),u;function d(n){l=n;do{if(t&&(c=t())&&c.then&&!a(c))return void c.then(v).then(void 0,h);if(!(s=e())||a(s)&&!s.v)return void o(u,1,l);if(s.then)return void s.then(m).then(void 0,h);a(l=r())&&(l=l.v)}while(!l||!l.then);l.then(d).then(void 0,h)}function m(e){e?(l=r())&&l.then?l.then(d).then(void 0,h):d(l):o(u,1,l)}function v(){(s=e())?s.then?s.then(m).then(void 0,h):m(s):o(u,1,l)}}(function(){return!!r._logs.length},void 0,function(){return Promise.resolve(r.sendBatch()).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},t.sendBatch=function(){try{var e=this,t=e._logs.splice(0,10);if(!t.length)return Promise.resolve();var n=crypto.randomUUID(),o=function(o,i){try{var a=(s=1e3*(e._options.timeoutInSeconds||30),l=new AbortController,c=setTimeout(function(){return l.abort()},s),Promise.resolve(fetch(e._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(t),signal:l.signal})).then(function(o){clearTimeout(c),o.ok||e._logger.log({message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:n,level:r.Error})}))}catch(e){return i(e)}var s,l,c;return a&&a.then?a.then(void 0,i):a}(0,function(o){e._logger.log({error:o,message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:n,level:r.Error})});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},e.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},e}();s.DEFAULT_BATCH_TIMEOUT=5;var l=/*#__PURE__*/function(){function e(){this.start=void 0,this.end=void 0,this.start=Date.now()}var t,r;return e.prototype.stop=function(){this.end=Date.now()},t=e,(r=[{key:"elapsed",get:function(){return(this.end||Date.now())-this.start}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}(),c=/*#__PURE__*/function(){function e(){}return e.convert=function(e){var t=JSON.stringify(e);return btoa(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e}(),u=/*#__PURE__*/function(){function e(){}return e.create=function(){var e=[48,32,24,16,15,8,4,1].find(function(e){return e<=screen.colorDepth});return{javaEnabled:navigator.javaEnabled(),javascriptEnabled:!0,language:navigator.language,userAgent:navigator.userAgent,screenWidth:window.screen.width,screenHeight:window.screen.height,timezoneOffset:(new Date).getTimezoneOffset(),colorDepth:e,acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}},e}(),h=/*#__PURE__*/function(){function e(e){var t=this;this._task=void 0,this._timeout=void 0,this._task=new Promise(function(r){t._timeout=setTimeout(r,e)})}var t=e.prototype;return t.wait=function(){return this._task},t.cancel=function(){clearTimeout(this._timeout),this._task=Promise.reject({message:"Timer cancelled"})},e.sleep=function(t){return new e(t)},e.cancel=function(e){clearTimeout(e)},e}(),d=/*#__PURE__*/function(){function e(){}return e.createIFrame=function(e){var t=document.createElement("iframe");return t.id=e.name,t.name=e.name,e.onReadyFn&&e.onReadyFn(t,e.isVisible),e.onCreatedFn&&(e.onCreatedFn(t),t.style.opacity=e.isVisible?"1":"0"),e.parent.appendChild(t),t},e.createForm=function(e){var t=document.createElement("form");return t.id=e.name,t.name=e.name,t.action=e.actionUrl,t.target=e.target,t.method=e.method,e.parent.appendChild(t),t},e.createInput=function(e){var t=document.createElement("input");return t.id=e.name,t.name=e.name,t.type=e.type,e.parent.appendChild(t),t},e}();function m(e,t,r){if(!e.s){if(r instanceof v){if(!r.s)return void(r.o=m.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(m.bind(null,e,t),m.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var v=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{m(n,1,i(this.v))}catch(e){m(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?m(n,1,t?t(o):o):r?m(n,1,r(o)):m(n,2,o)}catch(e){m(n,2,e)}},n},e}();function g(e){return e instanceof v&&1&e.s}var p,f=/*#__PURE__*/function(){function e(e,t){this._options=void 0,this._logger=void 0,this._options=e,this._logger=t}return e.prototype.execute=function(e){var t=this,n=e.executeFn,o=e.method,i=e.correlationId;return new Promise(function(e,a){try{var s,l=function(e){var n;if(s)return e;a(u),t._logger.log({message:'Unhandled error calling "'+o+'"',error:null==(n=u)?void 0:n.error,content:{attempt:c,maxAttempts:t._options.maxAttempts},method:o,correlationId:i,level:r.Error})},c=1,u=null,d=function(e,t){var r;do{var n=e();if(n&&n.then){if(!g(n)){r=!0;break}n=n.v}var o=t();if(g(o)&&(o=o.v),!o)return n}while(!o.then);var i=new v,a=m.bind(null,i,2);return(r?n.then(s):o.then(l)).then(void 0,a),i;function s(r){for(n=r;g(o=t())&&(o=o.v),o;){if(o.then)return void o.then(l).then(void 0,a);if((n=e())&&n.then){if(!g(n))return void n.then(s).then(void 0,a);n=n.v}}m(i,1,n)}function l(r){if(r){do{if((n=e())&&n.then){if(!g(n))return void n.then(s).then(void 0,a);n=n.v}if(g(r=t())&&(r=r.v),!r)return void m(i,1,n)}while(!r.then);r.then(l).then(void 0,a)}else m(i,1,n)}}(function(){function l(e){return s?e:(c++,Promise.resolve(h.sleep(1e3*t._options.attemptDelayInSeconds).wait()).then(function(){}))}var d=function(r,o){try{var i=Promise.resolve(n({attempt:c,maxAttempts:t._options.maxAttempts})).then(function(t){if(t.isSuccess)return e(t),void(s=1);t.isTransientError||(a(t),s=1)})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){u={message:'Unhandled error calling "'+o+'"',error:e,additionalData:{attempt:c,maxAttempts:t._options.maxAttempts}},t._logger.log({message:'Unhandled error calling "'+o+'"',error:e,content:{attempt:c,maxAttempts:t._options.maxAttempts},method:o,correlationId:i,level:r.Warning})});return d&&d.then?d.then(l):l(d)},function(){return!s&&c<=t._options.maxAttempts});return Promise.resolve(d&&d.then?d.then(l):l(d))}catch(e){return Promise.reject(e)}})},e}(),I=/*#__PURE__*/function(){function t(e,t,r){void 0===r&&(r=new f(e,t)),this._options=void 0,this._retryPolicy=void 0,this._logger=void 0,this._retryPolicy=r,this._logger=t,this._options=e}var n=t.prototype;return n.send=function(t){try{var n=this,o=n;return Promise.resolve(n._retryPolicy.execute({executeFn:function(i){var a=i.attempt,s=i.maxAttempts;try{var c=function(e){clearTimeout(d);var t={isSuccess:v.ok,isTransientError:n.isTransientError(v),getData:function(){try{return Promise.resolve(v.clone().json()).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}};return t},u=1e3*(o._options.timeoutInSeconds||30),h=new AbortController,d=setTimeout(function(){return h.abort()},u),m=new URL(t.url);n._logger.log({message:"ExternalService - Request ("+m.host+")",content:{request:t,attempt:a,maxAttempts:s},method:"send",correlationId:t.correlationId,level:r.Information});var v,g=new l,p=function(o,i){try{var l=Promise.resolve(fetch(t.url,{headers:e({},t.headers,{"x-attempt":a.toString(),"x-max-attempt":s.toString(),accept:"application/json","content-type":"application/json",correlationId:t.correlationId}),keepalive:!0,body:JSON.stringify(t.body),method:t.method,signal:h.signal})).then(function(e){var o=n._logger,i=o.log,l="ExternalService - Response ("+m.host+")",c=(v=e).status;return Promise.resolve(v.clone().text()).then(function(e){i.call(o,{message:l,content:{request:t,attempt:a,maxAttempts:s,response:{statusCode:c,data:e}},method:"send",correlationId:t.correlationId,level:r.Information,elapsedTimeInMilliseconds:g.elapsed})})})}catch(e){return i(e)}return l&&l.then?l.then(void 0,i):l}(0,function(e){throw n._logger.log({message:"ExternalService - Error ("+m.host+")",content:{request:t,attempt:a,maxAttempts:s,error:e},method:"send",correlationId:t.correlationId,level:r.Error,elapsedTimeInMilliseconds:g.elapsed}),e});return Promise.resolve(p&&p.then?p.then(c):c())}catch(e){return Promise.reject(e)}},method:"["+t.method+"] "+t.url,correlationId:t.correlationId}))}catch(e){return Promise.reject(e)}},n.isTransientError=function(e){return[409,424,500,503,504].includes(e.status)},t}();!function(e){e.width250xheight400="01",e.width390xheight400="02",e.width500xheight600="03",e.width600xheight400="04",e.fullscreen="05"}(p||(p={}));var _=/*#__PURE__*/function(){function e(e,t){this._options=void 0,this._logger=void 0,this._options=e,this._logger=t}var t=e.prototype;return t.execute=function(t){var n=this;return t.authResponse.challengeUrl?new Promise(function(o,i){try{n._logger.log({message:"Challenge - Start",content:{authResponse:t.authResponse},method:"executeChallenge",correlationId:t.correlationId,level:r.Information}),n._options.container.innerHTML="";var a=d.createIFrame({parent:n._options.container,name:e.IFRAME_NAME,isVisible:!0,useDefaultStyle:!!n._options.onIFrameCreatedFn,onCreatedFn:n._options.onIFrameCreatedFn,onReadyFn:n._options.onIFrameReadyFn});n._logger.log({message:"Challenge - Create iFrame",method:"executeChallenge",correlationId:t.correlationId,level:r.Information});var s=d.createForm({parent:n._options.container,name:e.FORM_NAME,actionUrl:t.authResponse.challengeUrl,target:e.IFRAME_NAME,method:"post"});n._logger.log({message:"Challenge - Create form",method:"executeChallenge",correlationId:t.correlationId,level:r.Information});var u=d.createInput({parent:s,name:e.CREQ_INPUT_NAME,type:e.CREQ_INPUT_TYPE});n._logger.log({message:"Challenge - Create input",method:"executeChallenge",correlationId:t.correlationId,level:r.Information});var h={threeDSServerTransID:t.authResponse.processId,acsTransID:t.authResponse.challengeId,messageVersion:t.authResponse.challengeVersion,messageType:"CReq",challengeWindowSize:n._options.challengeWindowSize||p.width250xheight400},m=c.convert(h);u.value=m,n._logger.log({message:"Challenge - Prepare cReq",content:{cReq:h,base64CReq:m},method:"executeChallenge",correlationId:t.correlationId,level:r.Information});var v=new l;s.submit(),setTimeout(function e(){var o,i=a.contentDocument||(null==(o=a.contentWindow)?void 0:o.document);"complete"!=(null==i?void 0:i.readyState)?setTimeout(e,100):n._logger.log({message:"Challenge - iFrame loaded in "+v.elapsed+"ms",content:{iFrame:i.body.innerText},method:"executeChallenge",correlationId:t.correlationId,level:r.Information})},100),n._logger.log({message:"Challenge - Submit form",content:{authResponse:t.authResponse,cReq:h,base64CReq:m},method:"executeChallenge",correlationId:t.correlationId,level:r.Information}),o()}catch(e){return n._logger.log({message:"Challenge - error",content:{authResponse:t.authResponse},error:e,method:"executeChallenge",correlationId:t.correlationId,level:r.Error}),i({message:e.toString()})}}):Promise.resolve()},t.reset=function(){try{var t,r,n;null==(t=document.getElementById(e.IFRAME_NAME))||t.remove(),null==(r=document.getElementById(e.FORM_NAME))||r.remove(),null==(n=document.getElementById(e.CREQ_INPUT_NAME))||n.remove()}catch(e){}},e}();_.IFRAME_NAME="challengeIframe",_.FORM_NAME="challengeForm",_.CREQ_INPUT_NAME="creq",_.CREQ_INPUT_TYPE="hidden";var y,A=/*#__PURE__*/function(){function e(e,t){this._logger=void 0,this._options=void 0,this._logger=t,this._options=e}var t=e.prototype;return t.execute=function(t){var n=this;return t.preAuthResponse.dsMethodUrl?new Promise(function(o,i){try{var a;n._logger.log({message:"DirectoryServer - Start",content:{preAuthResponse:t},method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information}),n._options.container.innerHTML="";var s=d.createIFrame({parent:n._options.container,isVisible:!1,name:e.IFRAME_NAME,useDefaultStyle:!!n._options.onIFrameCreatedFn});null==(a=n._options.onIFrameCreatedFn)||a.call(n._options,s),n._logger.log({message:"DirectoryServer - Create iFrame",method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information});var u=d.createForm({parent:n._options.container,name:e.FORM_NAME,actionUrl:t.preAuthResponse.dsMethodUrl,target:e.IFRAME_NAME,method:"POST"});n._logger.log({message:"DirectoryServer - Create Form",method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information});var h=d.createInput({parent:u,name:e.FORM_INPUT_NAME,type:e.FROM_INPUT_TYPE});n._logger.log({message:"DirectoryServer - Create Input",method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information});var m={threeDSServerTransID:t.preAuthResponse.processId,threeDSMethodNotificationURL:t.preAuthResponse.notificationUrl},v=c.convert(m);h.value=v,n._logger.log({message:"DirectoryServer - Prepare threeDSMethodData",content:{threeDSMethodData:m,threeDSMethodDataBase64:v},method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information});var g=new l;u.submit(),setTimeout(function e(){var o,i=s.contentDocument||(null==(o=s.contentWindow)?void 0:o.document);"complete"!=(null==i?void 0:i.readyState)?setTimeout(e,100):n._logger.log({message:"DirectoryServer - iFrame loaded in "+g.elapsed+"ms",content:{iFrame:i.body.innerText},method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information})},100),n._logger.log({message:"DirectoryServer - Submit form",content:{threeDSMethodData:m,threeDSMethodDataBase64:v},method:"executeDirectoryServer",correlationId:t.correlationId,level:r.Information}),o()}catch(e){return n._logger.log({message:"DirectoryServer - Error",content:{preAuthResponse:t},error:e,method:"directoryServerExecute",correlationId:t.correlationId,level:r.Error}),i({message:e.toString()})}}):Promise.resolve()},t.reset=function(){try{var t,r,n;null==(t=document.getElementById(e.IFRAME_NAME))||t.remove(),null==(r=document.getElementById(e.FORM_NAME))||r.remove(),null==(n=document.getElementById(e.FORM_INPUT_NAME))||n.remove()}catch(e){}},e}();A.IFRAME_NAME="threeDSMethodIframe",A.FORM_NAME="threeDSMethodForm",A.FORM_INPUT_NAME="threeDSMethodData",A.FROM_INPUT_TYPE="hidden",function(e){e.PreAuthStarted="preAuth:started",e.PreAuthCompleted="preAuth:completed",e.AuthStarted="auth:started",e.AuthCompleted="auth:completed",e.PostAuthStarted="postAuth:started",e.PostAuthCompleted="postAuth:completed",e.PostAuthFailed="postAuth:failed",e.ResetStarted="reset:started",e.ResetCompleted="reset:completed"}(y||(y={}));var S=/*#__PURE__*/function(){function e(t,r,n,o,i){void 0===r&&(r=new s(e.getLoggerOptions(t))),void 0===n&&(n=new I(e.getHttpClientOptions(t),r)),void 0===o&&(o=new A(t,r)),void 0===i&&(i=new _(t,r)),this._options=void 0,this._logger=void 0,this._client=void 0,this._directoryServer=void 0,this._challenge=void 0,this._observers=[],this._options=t,this._logger=r,this._client=n,this._directoryServer=o,this._challenge=i}var t=e.prototype;return t.subscribe=function(e){this._observers.push(e)},t.unsubscribe=function(e){var t=this._observers.indexOf(e);t>-1&&this._observers.splice(t,1)},t.execute=function(e,t){try{var n=this;return void 0===t&&(t=crypto.randomUUID()),e.correlationId||(e.correlationId=t,n._logger.log({message:"Obsolete request. CorrelationId is not set.",content:e,method:"execute",correlationId:e.correlationId,level:r.Information})),Promise.resolve(function(t,r){try{var o=Promise.resolve(n.preAuth(e)).then(function(t){return Promise.resolve(n._directoryServer.execute({preAuthResponse:t,correlationId:e.correlationId})).then(function(){return Promise.resolve(n.auth(e)).then(function(t){return Promise.resolve(n._challenge.execute({authResponse:t,correlationId:e.correlationId})).then(function(){return Promise.resolve(n.postAuth(e))})})})})}catch(e){return r(!0,e)}return o&&o.then?o.then(r.bind(null,!1),r.bind(null,!0)):r(!1,o)}(0,function(e,t){return n.reset(),Promise.resolve(n._logger.flush()).then(function(){if(e)throw t;return t})}))}catch(e){return Promise.reject(e)}},t.preAuth=function(e){try{var t=this;return t._logger.log({message:"Executing PreAuth",content:e,method:"_preAuth",correlationId:e.correlationId,level:r.Information}),t.notifyAll({name:y.PreAuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v2/"+e.id+"/preAuth",method:"POST",body:{browser:u.create()},correlationId:e.correlationId})).then(function(e){return t.notifyAll({name:y.PreAuthCompleted,data:e}),Promise.resolve(e.getData())})}catch(e){return Promise.reject(e)}},t.auth=function(e){try{var t=this;return t._logger.log({message:"Executing Auth",content:e,method:"_auth",correlationId:e.correlationId,level:r.Information}),t.notifyAll({name:y.AuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v1/"+e.id+"/auth",method:"POST",correlationId:e.correlationId})).then(function(e){return t.notifyAll({name:y.AuthCompleted,data:e}),Promise.resolve(e.getData())})}catch(e){return Promise.reject(e)}},t.postAuth=function(e){try{var t=this;return t._logger.log({message:"Executing PostAuth",content:e,method:"_postAuth",correlationId:e.correlationId,level:r.Information}),t.notifyAll({name:y.PostAuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v2/"+e.id+"/postAuth",method:"POST",correlationId:e.correlationId})).then(function(e){return Promise.resolve(e.getData()).then(function(e){return t.notifyAll({name:y.PostAuthCompleted,data:e}),e})})}catch(e){return Promise.reject(e)}},t.reset=function(){this.notifyAll({name:y.ResetStarted}),this._challenge.reset(),this._directoryServer.reset(),this.notifyAll({name:y.ResetCompleted})},t.notifyAll=function(e){this._observers.forEach(function(t){return t.notify(e)})},e.getLoggerOptions=function(e){return{restLoggerUrl:e.logUrl,timeoutInSeconds:e.timeoutInSeconds||30,environment:e.environment||"Production",batchLogIntervalInSeconds:e.batchLogIntervalInSeconds||5,service:{name:"Paybyrd.ThreeDSecure.JS",version:"3.2.4"}}},e.getHttpClientOptions=function(e){return{timeoutInSeconds:e.timeoutInSeconds||30,attemptDelayInSeconds:e.attemptDelayInSeconds||2,maxAttempts:e.maxAttempts||50}},e}();export{p as ChallengeWindowSize,f as LinearRetryPolicy,S as ThreeDSecureService};
//# sourceMappingURL=index.module.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).threedsecureService={})}(this,function(e){function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},t.apply(this,arguments)}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},r.apply(this,arguments)}var n,o=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.flush=function(){return Promise.resolve()},t.log=function(e){var t,n=r({},e,{error:null==(t=e.error)?void 0:t.toString()});console.log(n)},e}();function i(e,t,r){if(!e.s){if(r instanceof a){if(!r.s)return void(r.o=i.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(i.bind(null,e,t),i.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(n||(n={}));var a=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var a=1&o?t:r;if(a){try{i(n,1,a(this.v))}catch(e){i(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?i(n,1,t?t(o):o):r?i(n,1,r(o)):i(n,2,o)}catch(e){i(n,2,e)}},n},e}();function s(e){return e instanceof a&&1&e.s}var l=/*#__PURE__*/function(){function e(t,r){void 0===r&&(r=new o),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=r,this._options=t,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))}var t=e.prototype;return t.log=function(t){if(this._logger.log(t),this._options.restLoggerUrl){var r="["+this._options.service.name+"] "+t.message;t.elapsedTimeInMilliseconds&&(r=r+" in "+t.elapsedTimeInMilliseconds+"ms"),this._logs.unshift({customMessage:t.message,message:r,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:e.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds})}},t.flush=function(){try{var t=function(){r._interval=setInterval(r.sendBatch.bind(r),1e3*(r._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))},r=this;clearInterval(r._interval);var n=function(e,t,r){for(var n;;){var o=e();if(s(o)&&(o=o.v),!o)return l;if(o.then){n=0;break}var l=r();if(l&&l.then){if(!s(l)){n=1;break}l=l.s}if(t){var c=t();if(c&&c.then&&!s(c)){n=2;break}}}var u=new a,h=i.bind(null,u,2);return(0===n?o.then(m):1===n?l.then(d):c.then(v)).then(void 0,h),u;function d(n){l=n;do{if(t&&(c=t())&&c.then&&!s(c))return void c.then(v).then(void 0,h);if(!(o=e())||s(o)&&!o.v)return void i(u,1,l);if(o.then)return void o.then(m).then(void 0,h);s(l=r())&&(l=l.v)}while(!l||!l.then);l.then(d).then(void 0,h)}function m(e){e?(l=r())&&l.then?l.then(d).then(void 0,h):d(l):i(u,1,l)}function v(){(o=e())?o.then?o.then(m).then(void 0,h):m(o):i(u,1,l)}}(function(){return!!r._logs.length},void 0,function(){return Promise.resolve(r.sendBatch()).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},t.sendBatch=function(){try{var e=this,t=e._logs.splice(0,10);if(!t.length)return Promise.resolve();var r=crypto.randomUUID(),o=function(o,i){try{var a=(s=1e3*(e._options.timeoutInSeconds||30),l=new AbortController,c=setTimeout(function(){return l.abort()},s),Promise.resolve(fetch(e._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(t),signal:l.signal})).then(function(o){clearTimeout(c),o.ok||e._logger.log({message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:r,level:n.Error})}))}catch(e){return i(e)}var s,l,c;return a&&a.then?a.then(void 0,i):a}(0,function(o){e._logger.log({error:o,message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:r,level:n.Error})});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},e.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},e}();l.DEFAULT_BATCH_TIMEOUT=5;var c=/*#__PURE__*/function(){function e(){this.start=void 0,this.end=void 0,this.start=Date.now()}var t,r;return e.prototype.stop=function(){this.end=Date.now()},t=e,(r=[{key:"elapsed",get:function(){return(this.end||Date.now())-this.start}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}(),u=/*#__PURE__*/function(){function e(){}return e.convert=function(e){var t=JSON.stringify(e);return btoa(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e}(),h=/*#__PURE__*/function(){function e(){}return e.create=function(){var e=[48,32,24,16,15,8,4,1].find(function(e){return e<=screen.colorDepth});return{javaEnabled:navigator.javaEnabled(),javascriptEnabled:!0,language:navigator.language,userAgent:navigator.userAgent,screenWidth:window.screen.width,screenHeight:window.screen.height,timezoneOffset:(new Date).getTimezoneOffset(),colorDepth:e,acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}},e}(),d=/*#__PURE__*/function(){function e(e){var t=this;this._task=void 0,this._timeout=void 0,this._task=new Promise(function(r){t._timeout=setTimeout(r,e)})}var t=e.prototype;return t.wait=function(){return this._task},t.cancel=function(){clearTimeout(this._timeout),this._task=Promise.reject({message:"Timer cancelled"})},e.sleep=function(t){return new e(t)},e.cancel=function(e){clearTimeout(e)},e}(),m=/*#__PURE__*/function(){function e(){}return e.createIFrame=function(e){var t=document.createElement("iframe");return t.id=e.name,t.name=e.name,e.onReadyFn&&e.onReadyFn(t,e.isVisible),e.onCreatedFn&&(e.onCreatedFn(t),t.style.opacity=e.isVisible?"1":"0"),e.parent.appendChild(t),t},e.createForm=function(e){var t=document.createElement("form");return t.id=e.name,t.name=e.name,t.action=e.actionUrl,t.target=e.target,t.method=e.method,e.parent.appendChild(t),t},e.createInput=function(e){var t=document.createElement("input");return t.id=e.name,t.name=e.name,t.type=e.type,e.parent.appendChild(t),t},e}();function v(e,t,r){if(!e.s){if(r instanceof g){if(!r.s)return void(r.o=v.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(v.bind(null,e,t),v.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var g=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{v(n,1,i(this.v))}catch(e){v(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?v(n,1,t?t(o):o):r?v(n,1,r(o)):v(n,2,o)}catch(e){v(n,2,e)}},n},e}();function p(e){return e instanceof g&&1&e.s}var f,I=/*#__PURE__*/function(){function e(e,t){this._options=void 0,this._logger=void 0,this._options=e,this._logger=t}return e.prototype.execute=function(e){var t=this,r=e.executeFn,o=e.method,i=e.correlationId;return new Promise(function(e,a){try{var s,l=function(e){var r;if(s)return e;a(u),t._logger.log({message:'Unhandled error calling "'+o+'"',error:null==(r=u)?void 0:r.error,content:{attempt:c,maxAttempts:t._options.maxAttempts},method:o,correlationId:i,level:n.Error})},c=1,u=null,h=function(e,t){var r;do{var n=e();if(n&&n.then){if(!p(n)){r=!0;break}n=n.v}var o=t();if(p(o)&&(o=o.v),!o)return n}while(!o.then);var i=new g,a=v.bind(null,i,2);return(r?n.then(s):o.then(l)).then(void 0,a),i;function s(r){for(n=r;p(o=t())&&(o=o.v),o;){if(o.then)return void o.then(l).then(void 0,a);if((n=e())&&n.then){if(!p(n))return void n.then(s).then(void 0,a);n=n.v}}v(i,1,n)}function l(r){if(r){do{if((n=e())&&n.then){if(!p(n))return void n.then(s).then(void 0,a);n=n.v}if(p(r=t())&&(r=r.v),!r)return void v(i,1,n)}while(!r.then);r.then(l).then(void 0,a)}else v(i,1,n)}}(function(){function l(e){return s?e:(c++,Promise.resolve(d.sleep(1e3*t._options.attemptDelayInSeconds).wait()).then(function(){}))}var h=function(n,o){try{var i=Promise.resolve(r({attempt:c,maxAttempts:t._options.maxAttempts})).then(function(t){if(t.isSuccess)return e(t),void(s=1);t.isTransientError||(a(t),s=1)})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){u={message:'Unhandled error calling "'+o+'"',error:e,additionalData:{attempt:c,maxAttempts:t._options.maxAttempts}},t._logger.log({message:'Unhandled error calling "'+o+'"',error:e,content:{attempt:c,maxAttempts:t._options.maxAttempts},method:o,correlationId:i,level:n.Warning})});return h&&h.then?h.then(l):l(h)},function(){return!s&&c<=t._options.maxAttempts});return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}})},e}(),_=/*#__PURE__*/function(){function e(e,t,r){void 0===r&&(r=new I(e,t)),this._options=void 0,this._retryPolicy=void 0,this._logger=void 0,this._retryPolicy=r,this._logger=t,this._options=e}var r=e.prototype;return r.send=function(e){try{var r=this,o=r;return Promise.resolve(r._retryPolicy.execute({executeFn:function(i){var a=i.attempt,s=i.maxAttempts;try{var l=function(e){clearTimeout(d);var t={isSuccess:v.ok,isTransientError:r.isTransientError(v),getData:function(){try{return Promise.resolve(v.json()).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}};return t},u=1e3*(o._options.timeoutInSeconds||30),h=new AbortController,d=setTimeout(function(){return h.abort()},u),m=new URL(e.url);r._logger.log({message:"ExternalService - Request ("+m.host+")",content:{request:e,attempt:a,maxAttempts:s},method:"send",correlationId:e.correlationId,level:n.Information});var v,g=new c,p=function(o,i){try{var l=Promise.resolve(fetch(e.url,{headers:t({},e.headers,{"x-attempt":a.toString(),"x-max-attempt":s.toString(),accept:"application/json","content-type":"application/json",correlationId:e.correlationId}),keepalive:!0,body:JSON.stringify(e.body),method:e.method,signal:h.signal})).then(function(t){var o=r._logger,i=o.log,l="ExternalService - Response ("+m.host+")",c=(v=t).status;return Promise.resolve(v.clone().text()).then(function(t){i.call(o,{message:l,content:{request:e,attempt:a,maxAttempts:s,response:{statusCode:c,data:t}},method:"send",correlationId:e.correlationId,level:n.Information,elapsedTimeInMilliseconds:g.elapsed})})})}catch(e){return i(e)}return l&&l.then?l.then(void 0,i):l}(0,function(t){throw r._logger.log({message:"ExternalService - Error ("+m.host+")",content:{request:e,attempt:a,maxAttempts:s,error:t},method:"send",correlationId:e.correlationId,level:n.Error,elapsedTimeInMilliseconds:g.elapsed}),t});return Promise.resolve(p&&p.then?p.then(l):l())}catch(e){return Promise.reject(e)}},method:"["+e.method+"] "+e.url,correlationId:e.correlationId}))}catch(e){return Promise.reject(e)}},r.isTransientError=function(e){return[409,424,500,503,504].includes(e.status)},e}();e.ChallengeWindowSize=void 0,(f=e.ChallengeWindowSize||(e.ChallengeWindowSize={})).width250xheight400="01",f.width390xheight400="02",f.width500xheight600="03",f.width600xheight400="04",f.fullscreen="05";var y=/*#__PURE__*/function(){function t(e,t){this._options=void 0,this._logger=void 0,this._options=e,this._logger=t}var r=t.prototype;return r.execute=function(r){var o=this;return r.authResponse.challengeUrl?new Promise(function(i,a){try{o._logger.log({message:"Challenge - Start",content:{authResponse:r.authResponse},method:"executeChallenge",correlationId:r.correlationId,level:n.Information}),o._options.container.innerHTML="";var s=m.createIFrame({parent:o._options.container,name:t.IFRAME_NAME,isVisible:!0,useDefaultStyle:!!o._options.onIFrameCreatedFn,onCreatedFn:o._options.onIFrameCreatedFn,onReadyFn:o._options.onIFrameReadyFn});o._logger.log({message:"Challenge - Create iFrame",method:"executeChallenge",correlationId:r.correlationId,level:n.Information});var l=m.createForm({parent:o._options.container,name:t.FORM_NAME,actionUrl:r.authResponse.challengeUrl,target:t.IFRAME_NAME,method:"post"});o._logger.log({message:"Challenge - Create form",method:"executeChallenge",correlationId:r.correlationId,level:n.Information});var h=m.createInput({parent:l,name:t.CREQ_INPUT_NAME,type:t.CREQ_INPUT_TYPE});o._logger.log({message:"Challenge - Create input",method:"executeChallenge",correlationId:r.correlationId,level:n.Information});var d={threeDSServerTransID:r.authResponse.processId,acsTransID:r.authResponse.challengeId,messageVersion:r.authResponse.challengeVersion,messageType:"CReq",challengeWindowSize:o._options.challengeWindowSize||e.ChallengeWindowSize.width250xheight400},v=u.convert(d);h.value=v,o._logger.log({message:"Challenge - Prepare cReq",content:{cReq:d,base64CReq:v},method:"executeChallenge",correlationId:r.correlationId,level:n.Information});var g=new c;l.submit(),setTimeout(function e(){var t,i=s.contentDocument||(null==(t=s.contentWindow)?void 0:t.document);"complete"!=(null==i?void 0:i.readyState)?setTimeout(e,100):o._logger.log({message:"Challenge - iFrame loaded in "+g.elapsed+"ms",content:{iFrame:i.body.innerText},method:"executeChallenge",correlationId:r.correlationId,level:n.Information})},100),o._logger.log({message:"Challenge - Submit form",content:{authResponse:r.authResponse,cReq:d,base64CReq:v},method:"executeChallenge",correlationId:r.correlationId,level:n.Information}),i()}catch(e){return o._logger.log({message:"Challenge - error",content:{authResponse:r.authResponse},error:e,method:"executeChallenge",correlationId:r.correlationId,level:n.Error}),a({message:e.toString()})}}):Promise.resolve()},r.reset=function(){try{var e,r,n;null==(e=document.getElementById(t.IFRAME_NAME))||e.remove(),null==(r=document.getElementById(t.FORM_NAME))||r.remove(),null==(n=document.getElementById(t.CREQ_INPUT_NAME))||n.remove()}catch(e){}},t}();y.IFRAME_NAME="challengeIframe",y.FORM_NAME="challengeForm",y.CREQ_INPUT_NAME="creq",y.CREQ_INPUT_TYPE="hidden";var A,S=/*#__PURE__*/function(){function e(e,t){this._logger=void 0,this._options=void 0,this._logger=t,this._options=e}var t=e.prototype;return t.execute=function(t){var r=this;return t.preAuthResponse.dsMethodUrl?new Promise(function(o,i){try{var a;r._logger.log({message:"DirectoryServer - Start",content:{preAuthResponse:t},method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information}),r._options.container.innerHTML="";var s=m.createIFrame({parent:r._options.container,isVisible:!1,name:e.IFRAME_NAME,useDefaultStyle:!!r._options.onIFrameCreatedFn});null==(a=r._options.onIFrameCreatedFn)||a.call(r._options,s),r._logger.log({message:"DirectoryServer - Create iFrame",method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information});var l=m.createForm({parent:r._options.container,name:e.FORM_NAME,actionUrl:t.preAuthResponse.dsMethodUrl,target:e.IFRAME_NAME,method:"POST"});r._logger.log({message:"DirectoryServer - Create Form",method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information});var h=m.createInput({parent:l,name:e.FORM_INPUT_NAME,type:e.FROM_INPUT_TYPE});r._logger.log({message:"DirectoryServer - Create Input",method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information});var d={threeDSServerTransID:t.preAuthResponse.processId,threeDSMethodNotificationURL:t.preAuthResponse.notificationUrl},v=u.convert(d);h.value=v,r._logger.log({message:"DirectoryServer - Prepare threeDSMethodData",content:{threeDSMethodData:d,threeDSMethodDataBase64:v},method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information});var g=new c;l.submit(),setTimeout(function e(){var o,i=s.contentDocument||(null==(o=s.contentWindow)?void 0:o.document);"complete"!=(null==i?void 0:i.readyState)?setTimeout(e,100):r._logger.log({message:"DirectoryServer - iFrame loaded in "+g.elapsed+"ms",content:{iFrame:i.body.innerText},method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information})},100),r._logger.log({message:"DirectoryServer - Submit form",content:{threeDSMethodData:d,threeDSMethodDataBase64:v},method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information}),o()}catch(e){return r._logger.log({message:"DirectoryServer - Error",content:{preAuthResponse:t},error:e,method:"directoryServerExecute",correlationId:t.correlationId,level:n.Error}),i({message:e.toString()})}}):Promise.resolve()},t.reset=function(){try{var t,r,n;null==(t=document.getElementById(e.IFRAME_NAME))||t.remove(),null==(r=document.getElementById(e.FORM_NAME))||r.remove(),null==(n=document.getElementById(e.FORM_INPUT_NAME))||n.remove()}catch(e){}},e}();S.IFRAME_NAME="threeDSMethodIframe",S.FORM_NAME="threeDSMethodForm",S.FORM_INPUT_NAME="threeDSMethodData",S.FROM_INPUT_TYPE="hidden",function(e){e.PreAuthStarted="preAuth:started",e.PreAuthCompleted="preAuth:completed",e.AuthStarted="auth:started",e.AuthCompleted="auth:completed",e.PostAuthStarted="postAuth:started",e.PostAuthCompleted="postAuth:completed",e.PostAuthFailed="postAuth:failed",e.ResetStarted="reset:started",e.ResetCompleted="reset:completed"}(A||(A={}));var P=/*#__PURE__*/function(){function e(t,r,n,o,i){void 0===r&&(r=new l(e.getLoggerOptions(t))),void 0===n&&(n=new _(e.getHttpClientOptions(t),r)),void 0===o&&(o=new S(t,r)),void 0===i&&(i=new y(t,r)),this._options=void 0,this._logger=void 0,this._client=void 0,this._directoryServer=void 0,this._challenge=void 0,this._observers=[],this._options=t,this._logger=r,this._client=n,this._directoryServer=o,this._challenge=i}var t=e.prototype;return t.subscribe=function(e){this._observers.push(e)},t.unsubscribe=function(e){var t=this._observers.indexOf(e);t>-1&&this._observers.splice(t,1)},t.execute=function(e,t){try{var r=this;return void 0===t&&(t=crypto.randomUUID()),e.correlationId||(e.correlationId=t,r._logger.log({message:"Obsolete request. CorrelationId is not set.",content:e,method:"execute",correlationId:e.correlationId,level:n.Information})),Promise.resolve(function(t,n){try{var o=Promise.resolve(r.preAuth(e)).then(function(t){return Promise.resolve(r._directoryServer.execute({preAuthResponse:t,correlationId:e.correlationId})).then(function(){return Promise.resolve(r.auth(e)).then(function(t){return Promise.resolve(r._challenge.execute({authResponse:t,correlationId:e.correlationId})).then(function(){return Promise.resolve(r.postAuth(e))})})})})}catch(e){return n(!0,e)}return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!1,o)}(0,function(e,t){return r.reset(),Promise.resolve(r._logger.flush()).then(function(){if(e)throw t;return t})}))}catch(e){return Promise.reject(e)}},t.preAuth=function(e){try{var t=this;return t._logger.log({message:"Executing PreAuth",content:e,method:"_preAuth",correlationId:e.correlationId,level:n.Information}),t.notifyAll({name:A.PreAuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v2/"+e.id+"/preAuth",method:"POST",body:{browser:h.create()},correlationId:e.correlationId})).then(function(e){return t.notifyAll({name:A.PreAuthCompleted,data:e}),Promise.resolve(e.getData())})}catch(e){return Promise.reject(e)}},t.auth=function(e){try{var t=this;return t._logger.log({message:"Executing Auth",content:e,method:"_auth",correlationId:e.correlationId,level:n.Information}),t.notifyAll({name:A.AuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v1/"+e.id+"/auth",method:"POST",correlationId:e.correlationId})).then(function(e){return t.notifyAll({name:A.AuthCompleted,data:e}),Promise.resolve(e.getData())})}catch(e){return Promise.reject(e)}},t.postAuth=function(e){try{var t=this;return t._logger.log({message:"Executing PostAuth",content:e,method:"_postAuth",correlationId:e.correlationId,level:n.Information}),t.notifyAll({name:A.PostAuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v2/"+e.id+"/postAuth",method:"POST",correlationId:e.correlationId})).then(function(e){return Promise.resolve(e.getData()).then(function(e){return t.notifyAll({name:A.PostAuthCompleted,data:e}),e})})}catch(e){return Promise.reject(e)}},t.reset=function(){this.notifyAll({name:A.ResetStarted}),this._challenge.reset(),this._directoryServer.reset(),this.notifyAll({name:A.ResetCompleted})},t.notifyAll=function(e){this._observers.forEach(function(t){return t.notify(e)})},e.getLoggerOptions=function(e){return{restLoggerUrl:e.logUrl,timeoutInSeconds:e.timeoutInSeconds||30,environment:e.environment||"Production",batchLogIntervalInSeconds:e.batchLogIntervalInSeconds||5,service:{name:"Paybyrd.ThreeDSecure.JS",version:"3.2.3"}}},e.getHttpClientOptions=function(e){return{timeoutInSeconds:e.timeoutInSeconds||30,attemptDelayInSeconds:e.attemptDelayInSeconds||2,maxAttempts:e.maxAttempts||50}},e}();e.LinearRetryPolicy=I,e.ThreeDSecureService=P});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).threedsecureService={})}(this,function(e){function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},t.apply(this,arguments)}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},r.apply(this,arguments)}var n,o=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.flush=function(){return Promise.resolve()},t.log=function(e){var t,n=r({},e,{error:null==(t=e.error)?void 0:t.toString()});console.log(n)},e}();function i(e,t,r){if(!e.s){if(r instanceof a){if(!r.s)return void(r.o=i.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(i.bind(null,e,t),i.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(n||(n={}));var a=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var a=1&o?t:r;if(a){try{i(n,1,a(this.v))}catch(e){i(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?i(n,1,t?t(o):o):r?i(n,1,r(o)):i(n,2,o)}catch(e){i(n,2,e)}},n},e}();function s(e){return e instanceof a&&1&e.s}var l=/*#__PURE__*/function(){function e(t,r){void 0===r&&(r=new o),this._logger=void 0,this._options=void 0,this._logs=[],this._interval=void 0,this._logger=r,this._options=t,this._interval=setInterval(this.sendBatch.bind(this),1e3*(this._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))}var t=e.prototype;return t.log=function(t){if(this._logger.log(t),this._options.restLoggerUrl){var r="["+this._options.service.name+"] "+t.message;t.elapsedTimeInMilliseconds&&(r=r+" in "+t.elapsedTimeInMilliseconds+"ms"),this._logs.unshift({customMessage:t.message,message:r,service:this._options.service,environment:this._options.environment||"Development",executionDate:new Date,entrypoint:"Execute",method:t.method,correlationId:t.correlationId,content:t.content,exeption:e.getException(t.error),level:t.level,elapsedTimeInMilliseconds:t.elapsedTimeInMilliseconds})}},t.flush=function(){try{var t=function(){r._interval=setInterval(r.sendBatch.bind(r),1e3*(r._options.batchLogIntervalInSeconds||e.DEFAULT_BATCH_TIMEOUT))},r=this;clearInterval(r._interval);var n=function(e,t,r){for(var n;;){var o=e();if(s(o)&&(o=o.v),!o)return l;if(o.then){n=0;break}var l=r();if(l&&l.then){if(!s(l)){n=1;break}l=l.s}if(t){var c=t();if(c&&c.then&&!s(c)){n=2;break}}}var u=new a,h=i.bind(null,u,2);return(0===n?o.then(m):1===n?l.then(d):c.then(v)).then(void 0,h),u;function d(n){l=n;do{if(t&&(c=t())&&c.then&&!s(c))return void c.then(v).then(void 0,h);if(!(o=e())||s(o)&&!o.v)return void i(u,1,l);if(o.then)return void o.then(m).then(void 0,h);s(l=r())&&(l=l.v)}while(!l||!l.then);l.then(d).then(void 0,h)}function m(e){e?(l=r())&&l.then?l.then(d).then(void 0,h):d(l):i(u,1,l)}function v(){(o=e())?o.then?o.then(m).then(void 0,h):m(o):i(u,1,l)}}(function(){return!!r._logs.length},void 0,function(){return Promise.resolve(r.sendBatch()).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},t.sendBatch=function(){try{var e=this,t=e._logs.splice(0,10);if(!t.length)return Promise.resolve();var r=crypto.randomUUID(),o=function(o,i){try{var a=(s=1e3*(e._options.timeoutInSeconds||30),l=new AbortController,c=setTimeout(function(){return l.abort()},s),Promise.resolve(fetch(e._options.restLoggerUrl,{headers:{"content-type":"application/json"},method:"POST",keepalive:!0,body:JSON.stringify(t),signal:l.signal})).then(function(o){clearTimeout(c),o.ok||e._logger.log({message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:r,level:n.Error})}))}catch(e){return i(e)}var s,l,c;return a&&a.then?a.then(void 0,i):a}(0,function(o){e._logger.log({error:o,message:"Error sending messages to API",content:t,method:"sendBatch",correlationId:r,level:n.Error})});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},e.getException=function(e){return e?{stackTrace:e.stack,message:e.message,className:e.name}:null},e}();l.DEFAULT_BATCH_TIMEOUT=5;var c=/*#__PURE__*/function(){function e(){this.start=void 0,this.end=void 0,this.start=Date.now()}var t,r;return e.prototype.stop=function(){this.end=Date.now()},t=e,(r=[{key:"elapsed",get:function(){return(this.end||Date.now())-this.start}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}(),u=/*#__PURE__*/function(){function e(){}return e.convert=function(e){var t=JSON.stringify(e);return btoa(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},e}(),h=/*#__PURE__*/function(){function e(){}return e.create=function(){var e=[48,32,24,16,15,8,4,1].find(function(e){return e<=screen.colorDepth});return{javaEnabled:navigator.javaEnabled(),javascriptEnabled:!0,language:navigator.language,userAgent:navigator.userAgent,screenWidth:window.screen.width,screenHeight:window.screen.height,timezoneOffset:(new Date).getTimezoneOffset(),colorDepth:e,acceptHeader:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}},e}(),d=/*#__PURE__*/function(){function e(e){var t=this;this._task=void 0,this._timeout=void 0,this._task=new Promise(function(r){t._timeout=setTimeout(r,e)})}var t=e.prototype;return t.wait=function(){return this._task},t.cancel=function(){clearTimeout(this._timeout),this._task=Promise.reject({message:"Timer cancelled"})},e.sleep=function(t){return new e(t)},e.cancel=function(e){clearTimeout(e)},e}(),m=/*#__PURE__*/function(){function e(){}return e.createIFrame=function(e){var t=document.createElement("iframe");return t.id=e.name,t.name=e.name,e.onReadyFn&&e.onReadyFn(t,e.isVisible),e.onCreatedFn&&(e.onCreatedFn(t),t.style.opacity=e.isVisible?"1":"0"),e.parent.appendChild(t),t},e.createForm=function(e){var t=document.createElement("form");return t.id=e.name,t.name=e.name,t.action=e.actionUrl,t.target=e.target,t.method=e.method,e.parent.appendChild(t),t},e.createInput=function(e){var t=document.createElement("input");return t.id=e.name,t.name=e.name,t.type=e.type,e.parent.appendChild(t),t},e}();function v(e,t,r){if(!e.s){if(r instanceof g){if(!r.s)return void(r.o=v.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(v.bind(null,e,t),v.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var g=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{v(n,1,i(this.v))}catch(e){v(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?v(n,1,t?t(o):o):r?v(n,1,r(o)):v(n,2,o)}catch(e){v(n,2,e)}},n},e}();function p(e){return e instanceof g&&1&e.s}var f,I=/*#__PURE__*/function(){function e(e,t){this._options=void 0,this._logger=void 0,this._options=e,this._logger=t}return e.prototype.execute=function(e){var t=this,r=e.executeFn,o=e.method,i=e.correlationId;return new Promise(function(e,a){try{var s,l=function(e){var r;if(s)return e;a(u),t._logger.log({message:'Unhandled error calling "'+o+'"',error:null==(r=u)?void 0:r.error,content:{attempt:c,maxAttempts:t._options.maxAttempts},method:o,correlationId:i,level:n.Error})},c=1,u=null,h=function(e,t){var r;do{var n=e();if(n&&n.then){if(!p(n)){r=!0;break}n=n.v}var o=t();if(p(o)&&(o=o.v),!o)return n}while(!o.then);var i=new g,a=v.bind(null,i,2);return(r?n.then(s):o.then(l)).then(void 0,a),i;function s(r){for(n=r;p(o=t())&&(o=o.v),o;){if(o.then)return void o.then(l).then(void 0,a);if((n=e())&&n.then){if(!p(n))return void n.then(s).then(void 0,a);n=n.v}}v(i,1,n)}function l(r){if(r){do{if((n=e())&&n.then){if(!p(n))return void n.then(s).then(void 0,a);n=n.v}if(p(r=t())&&(r=r.v),!r)return void v(i,1,n)}while(!r.then);r.then(l).then(void 0,a)}else v(i,1,n)}}(function(){function l(e){return s?e:(c++,Promise.resolve(d.sleep(1e3*t._options.attemptDelayInSeconds).wait()).then(function(){}))}var h=function(n,o){try{var i=Promise.resolve(r({attempt:c,maxAttempts:t._options.maxAttempts})).then(function(t){if(t.isSuccess)return e(t),void(s=1);t.isTransientError||(a(t),s=1)})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){u={message:'Unhandled error calling "'+o+'"',error:e,additionalData:{attempt:c,maxAttempts:t._options.maxAttempts}},t._logger.log({message:'Unhandled error calling "'+o+'"',error:e,content:{attempt:c,maxAttempts:t._options.maxAttempts},method:o,correlationId:i,level:n.Warning})});return h&&h.then?h.then(l):l(h)},function(){return!s&&c<=t._options.maxAttempts});return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}})},e}(),_=/*#__PURE__*/function(){function e(e,t,r){void 0===r&&(r=new I(e,t)),this._options=void 0,this._retryPolicy=void 0,this._logger=void 0,this._retryPolicy=r,this._logger=t,this._options=e}var r=e.prototype;return r.send=function(e){try{var r=this,o=r;return Promise.resolve(r._retryPolicy.execute({executeFn:function(i){var a=i.attempt,s=i.maxAttempts;try{var l=function(e){clearTimeout(d);var t={isSuccess:v.ok,isTransientError:r.isTransientError(v),getData:function(){try{return Promise.resolve(v.clone().json()).then(function(e){return e.data})}catch(e){return Promise.reject(e)}}};return t},u=1e3*(o._options.timeoutInSeconds||30),h=new AbortController,d=setTimeout(function(){return h.abort()},u),m=new URL(e.url);r._logger.log({message:"ExternalService - Request ("+m.host+")",content:{request:e,attempt:a,maxAttempts:s},method:"send",correlationId:e.correlationId,level:n.Information});var v,g=new c,p=function(o,i){try{var l=Promise.resolve(fetch(e.url,{headers:t({},e.headers,{"x-attempt":a.toString(),"x-max-attempt":s.toString(),accept:"application/json","content-type":"application/json",correlationId:e.correlationId}),keepalive:!0,body:JSON.stringify(e.body),method:e.method,signal:h.signal})).then(function(t){var o=r._logger,i=o.log,l="ExternalService - Response ("+m.host+")",c=(v=t).status;return Promise.resolve(v.clone().text()).then(function(t){i.call(o,{message:l,content:{request:e,attempt:a,maxAttempts:s,response:{statusCode:c,data:t}},method:"send",correlationId:e.correlationId,level:n.Information,elapsedTimeInMilliseconds:g.elapsed})})})}catch(e){return i(e)}return l&&l.then?l.then(void 0,i):l}(0,function(t){throw r._logger.log({message:"ExternalService - Error ("+m.host+")",content:{request:e,attempt:a,maxAttempts:s,error:t},method:"send",correlationId:e.correlationId,level:n.Error,elapsedTimeInMilliseconds:g.elapsed}),t});return Promise.resolve(p&&p.then?p.then(l):l())}catch(e){return Promise.reject(e)}},method:"["+e.method+"] "+e.url,correlationId:e.correlationId}))}catch(e){return Promise.reject(e)}},r.isTransientError=function(e){return[409,424,500,503,504].includes(e.status)},e}();e.ChallengeWindowSize=void 0,(f=e.ChallengeWindowSize||(e.ChallengeWindowSize={})).width250xheight400="01",f.width390xheight400="02",f.width500xheight600="03",f.width600xheight400="04",f.fullscreen="05";var y=/*#__PURE__*/function(){function t(e,t){this._options=void 0,this._logger=void 0,this._options=e,this._logger=t}var r=t.prototype;return r.execute=function(r){var o=this;return r.authResponse.challengeUrl?new Promise(function(i,a){try{o._logger.log({message:"Challenge - Start",content:{authResponse:r.authResponse},method:"executeChallenge",correlationId:r.correlationId,level:n.Information}),o._options.container.innerHTML="";var s=m.createIFrame({parent:o._options.container,name:t.IFRAME_NAME,isVisible:!0,useDefaultStyle:!!o._options.onIFrameCreatedFn,onCreatedFn:o._options.onIFrameCreatedFn,onReadyFn:o._options.onIFrameReadyFn});o._logger.log({message:"Challenge - Create iFrame",method:"executeChallenge",correlationId:r.correlationId,level:n.Information});var l=m.createForm({parent:o._options.container,name:t.FORM_NAME,actionUrl:r.authResponse.challengeUrl,target:t.IFRAME_NAME,method:"post"});o._logger.log({message:"Challenge - Create form",method:"executeChallenge",correlationId:r.correlationId,level:n.Information});var h=m.createInput({parent:l,name:t.CREQ_INPUT_NAME,type:t.CREQ_INPUT_TYPE});o._logger.log({message:"Challenge - Create input",method:"executeChallenge",correlationId:r.correlationId,level:n.Information});var d={threeDSServerTransID:r.authResponse.processId,acsTransID:r.authResponse.challengeId,messageVersion:r.authResponse.challengeVersion,messageType:"CReq",challengeWindowSize:o._options.challengeWindowSize||e.ChallengeWindowSize.width250xheight400},v=u.convert(d);h.value=v,o._logger.log({message:"Challenge - Prepare cReq",content:{cReq:d,base64CReq:v},method:"executeChallenge",correlationId:r.correlationId,level:n.Information});var g=new c;l.submit(),setTimeout(function e(){var t,i=s.contentDocument||(null==(t=s.contentWindow)?void 0:t.document);"complete"!=(null==i?void 0:i.readyState)?setTimeout(e,100):o._logger.log({message:"Challenge - iFrame loaded in "+g.elapsed+"ms",content:{iFrame:i.body.innerText},method:"executeChallenge",correlationId:r.correlationId,level:n.Information})},100),o._logger.log({message:"Challenge - Submit form",content:{authResponse:r.authResponse,cReq:d,base64CReq:v},method:"executeChallenge",correlationId:r.correlationId,level:n.Information}),i()}catch(e){return o._logger.log({message:"Challenge - error",content:{authResponse:r.authResponse},error:e,method:"executeChallenge",correlationId:r.correlationId,level:n.Error}),a({message:e.toString()})}}):Promise.resolve()},r.reset=function(){try{var e,r,n;null==(e=document.getElementById(t.IFRAME_NAME))||e.remove(),null==(r=document.getElementById(t.FORM_NAME))||r.remove(),null==(n=document.getElementById(t.CREQ_INPUT_NAME))||n.remove()}catch(e){}},t}();y.IFRAME_NAME="challengeIframe",y.FORM_NAME="challengeForm",y.CREQ_INPUT_NAME="creq",y.CREQ_INPUT_TYPE="hidden";var A,S=/*#__PURE__*/function(){function e(e,t){this._logger=void 0,this._options=void 0,this._logger=t,this._options=e}var t=e.prototype;return t.execute=function(t){var r=this;return t.preAuthResponse.dsMethodUrl?new Promise(function(o,i){try{var a;r._logger.log({message:"DirectoryServer - Start",content:{preAuthResponse:t},method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information}),r._options.container.innerHTML="";var s=m.createIFrame({parent:r._options.container,isVisible:!1,name:e.IFRAME_NAME,useDefaultStyle:!!r._options.onIFrameCreatedFn});null==(a=r._options.onIFrameCreatedFn)||a.call(r._options,s),r._logger.log({message:"DirectoryServer - Create iFrame",method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information});var l=m.createForm({parent:r._options.container,name:e.FORM_NAME,actionUrl:t.preAuthResponse.dsMethodUrl,target:e.IFRAME_NAME,method:"POST"});r._logger.log({message:"DirectoryServer - Create Form",method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information});var h=m.createInput({parent:l,name:e.FORM_INPUT_NAME,type:e.FROM_INPUT_TYPE});r._logger.log({message:"DirectoryServer - Create Input",method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information});var d={threeDSServerTransID:t.preAuthResponse.processId,threeDSMethodNotificationURL:t.preAuthResponse.notificationUrl},v=u.convert(d);h.value=v,r._logger.log({message:"DirectoryServer - Prepare threeDSMethodData",content:{threeDSMethodData:d,threeDSMethodDataBase64:v},method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information});var g=new c;l.submit(),setTimeout(function e(){var o,i=s.contentDocument||(null==(o=s.contentWindow)?void 0:o.document);"complete"!=(null==i?void 0:i.readyState)?setTimeout(e,100):r._logger.log({message:"DirectoryServer - iFrame loaded in "+g.elapsed+"ms",content:{iFrame:i.body.innerText},method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information})},100),r._logger.log({message:"DirectoryServer - Submit form",content:{threeDSMethodData:d,threeDSMethodDataBase64:v},method:"executeDirectoryServer",correlationId:t.correlationId,level:n.Information}),o()}catch(e){return r._logger.log({message:"DirectoryServer - Error",content:{preAuthResponse:t},error:e,method:"directoryServerExecute",correlationId:t.correlationId,level:n.Error}),i({message:e.toString()})}}):Promise.resolve()},t.reset=function(){try{var t,r,n;null==(t=document.getElementById(e.IFRAME_NAME))||t.remove(),null==(r=document.getElementById(e.FORM_NAME))||r.remove(),null==(n=document.getElementById(e.FORM_INPUT_NAME))||n.remove()}catch(e){}},e}();S.IFRAME_NAME="threeDSMethodIframe",S.FORM_NAME="threeDSMethodForm",S.FORM_INPUT_NAME="threeDSMethodData",S.FROM_INPUT_TYPE="hidden",function(e){e.PreAuthStarted="preAuth:started",e.PreAuthCompleted="preAuth:completed",e.AuthStarted="auth:started",e.AuthCompleted="auth:completed",e.PostAuthStarted="postAuth:started",e.PostAuthCompleted="postAuth:completed",e.PostAuthFailed="postAuth:failed",e.ResetStarted="reset:started",e.ResetCompleted="reset:completed"}(A||(A={}));var P=/*#__PURE__*/function(){function e(t,r,n,o,i){void 0===r&&(r=new l(e.getLoggerOptions(t))),void 0===n&&(n=new _(e.getHttpClientOptions(t),r)),void 0===o&&(o=new S(t,r)),void 0===i&&(i=new y(t,r)),this._options=void 0,this._logger=void 0,this._client=void 0,this._directoryServer=void 0,this._challenge=void 0,this._observers=[],this._options=t,this._logger=r,this._client=n,this._directoryServer=o,this._challenge=i}var t=e.prototype;return t.subscribe=function(e){this._observers.push(e)},t.unsubscribe=function(e){var t=this._observers.indexOf(e);t>-1&&this._observers.splice(t,1)},t.execute=function(e,t){try{var r=this;return void 0===t&&(t=crypto.randomUUID()),e.correlationId||(e.correlationId=t,r._logger.log({message:"Obsolete request. CorrelationId is not set.",content:e,method:"execute",correlationId:e.correlationId,level:n.Information})),Promise.resolve(function(t,n){try{var o=Promise.resolve(r.preAuth(e)).then(function(t){return Promise.resolve(r._directoryServer.execute({preAuthResponse:t,correlationId:e.correlationId})).then(function(){return Promise.resolve(r.auth(e)).then(function(t){return Promise.resolve(r._challenge.execute({authResponse:t,correlationId:e.correlationId})).then(function(){return Promise.resolve(r.postAuth(e))})})})})}catch(e){return n(!0,e)}return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!1,o)}(0,function(e,t){return r.reset(),Promise.resolve(r._logger.flush()).then(function(){if(e)throw t;return t})}))}catch(e){return Promise.reject(e)}},t.preAuth=function(e){try{var t=this;return t._logger.log({message:"Executing PreAuth",content:e,method:"_preAuth",correlationId:e.correlationId,level:n.Information}),t.notifyAll({name:A.PreAuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v2/"+e.id+"/preAuth",method:"POST",body:{browser:h.create()},correlationId:e.correlationId})).then(function(e){return t.notifyAll({name:A.PreAuthCompleted,data:e}),Promise.resolve(e.getData())})}catch(e){return Promise.reject(e)}},t.auth=function(e){try{var t=this;return t._logger.log({message:"Executing Auth",content:e,method:"_auth",correlationId:e.correlationId,level:n.Information}),t.notifyAll({name:A.AuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v1/"+e.id+"/auth",method:"POST",correlationId:e.correlationId})).then(function(e){return t.notifyAll({name:A.AuthCompleted,data:e}),Promise.resolve(e.getData())})}catch(e){return Promise.reject(e)}},t.postAuth=function(e){try{var t=this;return t._logger.log({message:"Executing PostAuth",content:e,method:"_postAuth",correlationId:e.correlationId,level:n.Information}),t.notifyAll({name:A.PostAuthStarted,data:e}),Promise.resolve(t._client.send({url:t._options.threeDSecureUrl+"/api/v2/"+e.id+"/postAuth",method:"POST",correlationId:e.correlationId})).then(function(e){return Promise.resolve(e.getData()).then(function(e){return t.notifyAll({name:A.PostAuthCompleted,data:e}),e})})}catch(e){return Promise.reject(e)}},t.reset=function(){this.notifyAll({name:A.ResetStarted}),this._challenge.reset(),this._directoryServer.reset(),this.notifyAll({name:A.ResetCompleted})},t.notifyAll=function(e){this._observers.forEach(function(t){return t.notify(e)})},e.getLoggerOptions=function(e){return{restLoggerUrl:e.logUrl,timeoutInSeconds:e.timeoutInSeconds||30,environment:e.environment||"Production",batchLogIntervalInSeconds:e.batchLogIntervalInSeconds||5,service:{name:"Paybyrd.ThreeDSecure.JS",version:"3.2.4"}}},e.getHttpClientOptions=function(e){return{timeoutInSeconds:e.timeoutInSeconds||30,attemptDelayInSeconds:e.attemptDelayInSeconds||2,maxAttempts:e.maxAttempts||50}},e}();e.LinearRetryPolicy=I,e.ThreeDSecureService=P});
//# sourceMappingURL=index.umd.js.map
{
"name": "@paybyrd/threedsecure-service",
"version": "3.2.3",
"version": "3.2.4",
"description": "JS service implementation to control the 3DS flow over Paybyrd API",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc