New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@basis-theory/3ds-web

Package Overview
Dependencies
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@basis-theory/3ds-web - npm Package Compare versions

Comparing version 1.3.0 to 1.4.1

2

dist/bundle/index.js

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

!function(){var e,t,r,n,o,i,a,s,c,l,u,d,f={FRAME_CONTAINER_ID:"methodFrameContainer",IFRAME_NAME:"methodIframe",FORM_NAME:"threeDSMethodForm",INPUT_NAME:"threeDSMethodData"},p={FRAME_CONTAINER_ID:"challengeFrameContainer",IFRAME_NAME:"challengeIframe",FORM_NAME:"threeDSCReqForm",INPUT_NAME:"threeDSSessionData"};function h(e,t,r,n,o,i,a){try{var s=e[i](a),c=s.value}catch(e){r(e);return}s.done?t(c):Promise.resolve(c).then(n,o)}function y(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){h(i,n,o,a,s,"next",e)}function s(e){h(i,n,o,a,s,"throw",e)}a(void 0)})}}function m(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function v(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function b(e,t){if(e){if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(e,t)}}"function"==typeof SuppressedError&&SuppressedError;var g=(e=y(function(e,t,r){var n,o=arguments;return m(this,function(i){switch(i.label){case 0:var a,s;a=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){v(e,t,r[t])})}return e}({application:"3ds-web",ddsource:"3ds-web",service:"3ds-web"},o.length>3&&void 0!==o[3]?o[3]:{}),s=s={level:t,message:"error"===t&&r?"".concat(e,": ").concat(r.message):e},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(s)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(s,e))}),n=a,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,fetch("https://http-intake.logs.datadoghq.com/v1/input/".concat("pubb96b84a13912504f4354f2d794ea4fab"),{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})];case 2:if(!i.sent().ok)throw Error("Network response was not ok");return[3,4];case 3:return i.sent(),[3,4];case 4:return[2]}})}),t=function(t,r,n){return e.apply(this,arguments)},{log:{error:function(e,r,n){return t(e,"error",r,n)},info:function(e,r){return t(e,"info",void 0,r)},warn:function(e,r){return t(e,"warn",void 0,r)}}});(r=u||(u={})).ONE="01",r.TWO="02",r.THREE="03",r.FOUR="04",r.FIVE="05";var w=function(e){return null==e?"":JSON.stringify(e)},T=function(){var e,t=[1,4,8,15,16,24,32,48],r=window.screen.colorDepth,n=t.filter(function(e){return e<=r});return 0===n.length?t[0]:(e=Math).max.apply(e,function(e){if(Array.isArray(e))return E(e)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||b(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())},A=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"05",r=(v(e={},"01",["250px","400px"]),v(e,"02",["390px","400px"]),v(e,"03",["500px","600px"]),v(e,"04",["600px","400px"]),v(e,"05",["100%","100%"]),e)[t];if(r)return r;var n=Error("Window size ".concat(t," is not supported"));throw g.log.error("Unsupported window size",n),n},O=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"0",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"0",i=arguments.length>5?arguments[5]:void 0;if(!(!e||e instanceof HTMLElement)||!t||!r){var a="Unable to create iframe. Container must be a HTML element ".concat(JSON.stringify(e)," ").concat(t," ").concat(r);throw g.log.error("Unable to create iframe",Error()),Error(a)}var s=document.createElement("iframe");return s.name=t,s.width=n,s.height=o,s.setAttribute("id",r),s.setAttribute("frameborder","0"),s.setAttribute("border","0"),i&&"function"==typeof i&&s.addEventListener("onload",i),e.appendChild(s),s},M=function(e,t,r){var n=document.createElement("form");return n.name=e,n.action=t,n.method="POST",n.target=r,n},I=function(e,t){var r=document.createElement("input");return r.name=e,r.value=t,r},S=function(e,t){var r=document.createElement(e);return r.appendChild(t),r},_=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t=document.getElementById(e)){t.innerHTML="",r&&t.setAttribute("style","display:none;");return}(t=document.createElement("div")).id=e,r&&t.setAttribute("style","display:none;"),document.body.appendChild(t)},N=function(e){return null==e?void 0:e.map(function(e){var t;return null===(t=document.getElementById(e))||void 0===t?void 0:t.remove()})},R=function(e,t){var r=function(e){return"string"==typeof e?t(e):"object"!=typeof e||null===e?e:Array.isArray(e)?e.map(r):Object.fromEntries(Object.entries(e).map(function(e){var n=function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,s=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),2!==i.length);a=!0);}catch(e){s=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(s)throw n}}return i}}(e,2)||b(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=n[0],i=n[1];return[t(o),"object"==typeof i||Array.isArray(i)?r(i):i]}))};return r(e)},D=function(e){return R(e,function(e){return e.replace(/_./g,function(e){return e[1].toUpperCase()})})},C=function(e){return btoa(JSON.stringify(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},j={client:(n=y(function(e,t,r){var n;return m(this,function(a){switch(a.label){case 0:if(!o)throw Error("Missing api key");return i&&g.log.info("Using custom api base url in 3DS SDK ".concat(i)),[4,fetch("".concat(null!=i?i:"https://api.basistheory.com","/3ds").concat(t),{method:e,body:JSON.stringify(r),headers:(v(n={},"BT-API-KEY",o),v(n,"Content-Type","application/json"),n)})];case 1:return[2,a.sent()]}})}),function(e,t,r){return n.apply(this,arguments)}),init:function(e,t){o=e,i=t}};(a=d||(d={})).METHOD="method",a.CHALLENGE="challenge",a.METHOD_TIME_OUT="methodTimeout",a.START_METHOD_TIME_OUT="startMethodTimeout",a.ERROR="error";var F=function(e){return window.postMessage(e,"*")},P=function(e){return"object"==typeof e&&null!==e&&"isCompleted"in e&&"boolean"==typeof e.isCompleted&&"id"in e&&"string"==typeof e.id&&"type"in e&&Object.values(d).includes(e.type)},U=function(e){var t,r;return null===(t=(v(r={},d.CHALLENGE,p.IFRAME_NAME),v(r,d.METHOD,f.IFRAME_NAME),v(r,d.METHOD_TIME_OUT,f.IFRAME_NAME),v(r,d.ERROR,"".concat(f.IFRAME_NAME,",").concat(p.IFRAME_NAME)),v(r,d.START_METHOD_TIME_OUT,""),r)[e])||void 0===t?void 0:t.split(",")},H=function(e){var t;return new Promise(function(r,n){var o=function(i){if(P(i.data)&&(null===(s=i.data)||void 0===s?void 0:s.type)===d.START_METHOD_TIME_OUT)t=setTimeout(function(){F({id:i.data.id,type:d.METHOD_TIME_OUT,isCompleted:!1})},1e4);else if(P(i.data)&&i.data.type!==d.ERROR&&i.data.type!==d.CHALLENGE){window.removeEventListener("message",o);var a,s,c,l={id:i.data.id,cardBrand:e.cardBrand};g.log.info("".concat(i.data.type," notification received for session: ").concat(l.id)),r(l),N(U(null===(c=i.data)||void 0===c?void 0:c.type)),clearTimeout(t)}else i.isTrusted&&(n("Something happened during session creation, please try again."),N(U(null===(a=i.data)||void 0===a?void 0:a.type)),clearTimeout(t))};window.addEventListener("message",o)})},L={},k={"The card was not supported by any card schemes":"3DS is not supported for the provided card"},x=function(e){var t=!0,r=!1,n=void 0;if("errors"in e&&void 0!==e.errors&&"object"==typeof e.errors&&null!==e.errors)try{for(var o,i=Object.keys(e.errors)[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value;if(k[a])throw Error(k[a])}}catch(e){r=!0,n=e}finally{try{t||null==i.return||i.return()}finally{if(r)throw n}}else if(e.title&&L[e.title])throw Error(L[e.title]);throw Error(e.title||"An unknown error occurred")},B=function(e,t,r){var n=C({threeDSServerTransID:t,threeDSMethodNotificationURL:r}),o=O(document.getElementById(f.FRAME_CONTAINER_ID),f.IFRAME_NAME,f.IFRAME_NAME,"0","0"),i=M(f.FORM_NAME,e,o.name);i.appendChild(I(f.INPUT_NAME,n)),o.appendChild(S("html",S("body",i))),i.submit()},z=(s=y(function(e){var t,r,n,o,i,a,s;return m(this,function(c){switch(c.label){case 0:return t=e.pan,r={browserColorDepth:w(T()),browserJavascriptEnabled:!0,browserJavaEnabled:window.navigator.javaEnabled(),browserLanguage:window.navigator.language,browserScreenHeight:w(window.screen.height),browserScreenWidth:w(window.screen.width),browserTZ:w(new Date().getTimezoneOffset()),browserUserAgent:window.navigator.userAgent},[4,j.client("POST","/sessions",R({pan:t,device:"browser",deviceInfo:r},function(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()}))];case 1:if((n=c.sent()).ok)return[3,6];c.label=2;case 2:return c.trys.push([2,4,,5]),[4,n.json()];case 3:return o=c.sent(),[3,5];case 4:throw c.sent(),i="Failed to parse error response. HTTP Status: ".concat(n.status),g.log.error(i),Error(i);case 5:var l;if("object"==typeof(l=o)&&null!==l&&("title"in l||"status"in l||"detail"in l))x(o);else throw a="An unknown error occurred while creating session. Status: ".concat(n.status,"."),g.log.error("".concat(a," Response: ").concat(JSON.stringify(o,null,2))),Error(a);c.label=6;case 6:return[4,n.json()];case 7:return s=D.apply(void 0,[c.sent()]),g.log.info("3DS session response received with ID ".concat(s.id)),s.methodUrl&&(F({isCompleted:!1,id:s.id,type:d.START_METHOD_TIME_OUT}),B(s.methodUrl,s.id,s.methodNotificationUrl)),[2,s]}})}),function(e){return s.apply(this,arguments)}),J=(c=y(function(e){var t;return m(this,function(r){switch(r.label){case 0:return[4,z({pan:e.pan}).catch(function(e){return Promise.reject(e.message)})];case 1:if(!(t=r.sent()).methodUrl)return[2,{id:t.id,cardBrand:t.cardBrand}];return[4,H(t)];case 2:return[2,r.sent()]}})}),function(e){return c.apply(this,arguments)}),q=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4;return new Promise(function(r,n){var o=function(t){if(P(t.data)&&t.data.type===d.CHALLENGE){clearTimeout(e),window.removeEventListener("message",o);var n={id:t.data.id};g.log.info("".concat(t.data.type," notification received for session: ").concat(n.id)),r(n),N([p.IFRAME_NAME])}else t.isTrusted};window.addEventListener("message",o),e=setTimeout(function(){window.removeEventListener("message",o),n("Timed out waiting for a challenge response. Please try again."),N([p.IFRAME_NAME])},t)})},V=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=document.getElementById(p.FRAME_CONTAINER_ID),o=A(t.challengeWindowSize),i=C(t),a=C(r),s=p.IFRAME_NAME,c=document.createElement("html"),l=document.createElement("body"),u=O(n,s,s,o[0],o[1]),d=M(p.FORM_NAME,e,u.name),f=I("creq",i),h=I(p.INPUT_NAME,a);d.appendChild(f),d.appendChild(h),l.appendChild(d),c.appendChild(l),u.appendChild(c),d.submit()},W=function(e){var t,r,n,o,i,a=e.sessionId,s=e.acsTransactionId,c=e.acsChallengeUrl,l=e.threeDSVersion,d=e.windowSize;if(!a)throw Error("Session ID is required");var f={messageType:"CReq",messageVersion:l,threeDSServerTransID:a,acsTransID:s,challengeWindowSize:null!=d?d:u.THREE};if(t=f.messageType,r=f.messageVersion,n=f.threeDSServerTransID,o=f.acsTransID,i=f.challengeWindowSize,null!==f&&"string"==typeof t&&"string"==typeof r&&"string"==typeof n&&"string"==typeof o&&Object.values(u).includes(i))V(c,f);else{var p="Invalid challenge request payload for session: ".concat(a);return g.log.error(p),Promise.reject(Error(p))}return Promise.resolve({id:a})},G=(l=y(function(e){var t,r,n,o,i,a,s;return m(this,function(c){switch(c.label){case 0:return t=e.sessionId,r=e.acsTransactionId,n=e.acsChallengeUrl,o=e.threeDSVersion,i=e.windowSize,s=void 0===(a=e.timeout)?6e4:a,[4,W({sessionId:t,acsTransactionId:r,acsChallengeUrl:n,threeDSVersion:o,windowSize:i}).catch(function(e){return Promise.reject(e.message)})];case 1:return c.sent(),[2,q(s)]}})}),function(e){return l.apply(this,arguments)});window.BasisTheory3ds=function(e,t){try{var r,n;_(f.FRAME_CONTAINER_ID,!0),_(null!==(n=null==t?void 0:null===(r=t.challengeContainerOptions)||void 0===r?void 0:r.id)&&void 0!==n?n:p.FRAME_CONTAINER_ID)}catch(e){g.log.error("Unable to create iframe container",e)}return j.init(e,null==t?void 0:t.apiBaseUrl),{createSession:J,startChallenge:G}}}();
!function(){var e,t,r,n,o,i,a,s,c,l,u,d,f={FRAME_CONTAINER_ID:"methodFrameContainer",IFRAME_NAME:"methodIframe",FORM_NAME:"threeDSMethodForm",INPUT_NAME:"threeDSMethodData"},p={FRAME_CONTAINER_ID:"challengeFrameContainer",IFRAME_NAME:"challengeIframe",FORM_NAME:"threeDSCReqForm",INPUT_NAME:"threeDSSessionData"};function h(e,t,r,n,o,i,a){try{var s=e[i](a),c=s.value}catch(e){r(e);return}s.done?t(c):Promise.resolve(c).then(n,o)}function y(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){h(i,n,o,a,s,"next",e)}function s(e){h(i,n,o,a,s,"throw",e)}a(void 0)})}}function m(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function b(e,t){if(e){if("string"==typeof e)return E(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return E(e,t)}}"function"==typeof SuppressedError&&SuppressedError;var g=(e=y(function(e,t,r){var n,o=arguments;return v(this,function(i){switch(i.label){case 0:var a,s;a=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){m(e,t,r[t])})}return e}({application:"3ds-web",ddsource:"3ds-web",service:"3ds-web"},o.length>3&&void 0!==o[3]?o[3]:{}),s=s={level:t,message:"error"===t&&r?"".concat(e,": ").concat(r.message):e},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(s)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(s,e))}),n=a,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,fetch("https://http-intake.logs.datadoghq.com/v1/input/".concat("pubb96b84a13912504f4354f2d794ea4fab"),{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}})];case 2:if(!i.sent().ok)throw Error("Network response was not ok");return[3,4];case 3:return i.sent(),[3,4];case 4:return[2]}})}),t=function(t,r,n){return e.apply(this,arguments)},{log:{error:function(e,r,n){return t(e,"error",r,n)},info:function(e,r){return t(e,"info",void 0,r)},warn:function(e,r){return t(e,"warn",void 0,r)}}});(r=u||(u={})).ONE="01",r.TWO="02",r.THREE="03",r.FOUR="04",r.FIVE="05";var w=function(e){return null==e?"":JSON.stringify(e)},I=function(){var e,t=[1,4,8,15,16,24,32,48],r=window.screen.colorDepth,n=t.filter(function(e){return e<=r});return 0===n.length?t[0]:(e=Math).max.apply(e,function(e){if(Array.isArray(e))return E(e)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||b(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())},T=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"05",r=(m(e={},"01",["250px","400px"]),m(e,"02",["390px","400px"]),m(e,"03",["500px","600px"]),m(e,"04",["600px","400px"]),m(e,"05",["100%","100%"]),e)[t];if(r)return r;var n=Error("Window size ".concat(t," is not supported"));throw g.log.error("Unsupported window size",n),n},A=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"0",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"0",i=arguments.length>5?arguments[5]:void 0;if(!(!e||e instanceof HTMLElement)||!t||!r){var a="Unable to create iframe. Container must be a HTML element ".concat(JSON.stringify(e)," ").concat(t," ").concat(r);throw g.log.error("Unable to create iframe",Error()),Error(a)}var s=document.createElement("iframe");return s.name=t,s.width=n,s.height=o,s.setAttribute("id",r),s.setAttribute("frameborder","0"),s.setAttribute("border","0"),i&&"function"==typeof i&&s.addEventListener("onload",i),e.appendChild(s),s},O=function(e,t,r){var n=document.createElement("form");return n.name=e,n.action=t,n.method="POST",n.target=r,n},M=function(e,t){var r=document.createElement("input");return r.name=e,r.value=t,r},S=function(e,t){var r=document.createElement(e);return r.appendChild(t),r},_=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t=document.getElementById(e)){t.innerHTML="",r&&t.setAttribute("style","display:none;");return}(t=document.createElement("div")).id=e,r&&t.setAttribute("style","display:none;"),document.body.appendChild(t)},N=function(e){return null==e?void 0:e.map(function(e){var t;return null===(t=document.getElementById(e))||void 0===t?void 0:t.remove()})},R=function(e,t){var r=function(e){return"string"==typeof e?t(e):"object"!=typeof e||null===e?e:Array.isArray(e)?e.map(r):Object.fromEntries(Object.entries(e).map(function(e){var n=function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,s=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),2!==i.length);a=!0);}catch(e){s=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(s)throw n}}return i}}(e,2)||b(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=n[0],i=n[1];return[t(o),"object"==typeof i||Array.isArray(i)?r(i):i]}))};return r(e)},D=function(e){return R(e,function(e){return e.replace(/_./g,function(e){return e[1].toUpperCase()})})},C=function(e){return btoa(JSON.stringify(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},j={client:(n=y(function(e,t,r){var n;return v(this,function(a){switch(a.label){case 0:if(!o)throw Error("Missing api key");return i&&g.log.info("Using custom api base url in 3DS SDK ".concat(i)),[4,fetch("".concat(null!=i?i:"https://api.basistheory.com","/3ds").concat(t),{method:e,body:JSON.stringify(r),headers:(m(n={},"BT-API-KEY",o),m(n,"Content-Type","application/json"),n)})];case 1:return[2,a.sent()]}})}),function(e,t,r){return n.apply(this,arguments)}),init:function(e,t){o=e,i=t}};(a=d||(d={})).METHOD="method",a.CHALLENGE="challenge",a.METHOD_TIME_OUT="methodTimeout",a.START_METHOD_TIME_OUT="startMethodTimeout",a.ERROR="error";var F=function(e){return window.postMessage(e,"*")},P=function(e){return"object"==typeof e&&null!==e&&"isCompleted"in e&&"boolean"==typeof e.isCompleted&&"id"in e&&"string"==typeof e.id&&"type"in e&&Object.values(d).includes(e.type)},U=function(e){var t,r;return null===(t=(m(r={},d.CHALLENGE,p.IFRAME_NAME),m(r,d.METHOD,f.IFRAME_NAME),m(r,d.METHOD_TIME_OUT,f.IFRAME_NAME),m(r,d.ERROR,"".concat(f.IFRAME_NAME,",").concat(p.IFRAME_NAME)),m(r,d.START_METHOD_TIME_OUT,""),r)[e])||void 0===t?void 0:t.split(",")},k=function(e){var t;return new Promise(function(r,n){var o=function(i){if(P(i.data)&&(null===(s=i.data)||void 0===s?void 0:s.type)===d.START_METHOD_TIME_OUT)t=setTimeout(function(){F({id:i.data.id,type:d.METHOD_TIME_OUT,isCompleted:!1})},1e4);else if(P(i.data)&&i.data.type!==d.ERROR&&i.data.type!==d.CHALLENGE){window.removeEventListener("message",o);var a,s,c,l={id:i.data.id,cardBrand:e.cardBrand};g.log.info("".concat(i.data.type," notification received for session: ").concat(l.id)),r(l),N(U(null===(c=i.data)||void 0===c?void 0:c.type)),clearTimeout(t)}else i.isTrusted&&(n("Something happened during session creation, please try again."),N(U(null===(a=i.data)||void 0===a?void 0:a.type)),clearTimeout(t))};window.addEventListener("message",o)})},H={},L={"The card was not supported by any card schemes":"3DS is not supported for the provided card"},x=function(e){var t=!0,r=!1,n=void 0;if("errors"in e&&void 0!==e.errors&&"object"==typeof e.errors&&null!==e.errors)try{for(var o,i=Object.keys(e.errors)[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var a=o.value;if(L[a])throw Error(L[a])}}catch(e){r=!0,n=e}finally{try{t||null==i.return||i.return()}finally{if(r)throw n}}else if(e.title&&H[e.title])throw Error(H[e.title]);throw Error(e.title||"An unknown error occurred")},B=function(e,t,r){var n=C({threeDSServerTransID:t,threeDSMethodNotificationURL:r}),o=A(document.getElementById(f.FRAME_CONTAINER_ID),f.IFRAME_NAME,f.IFRAME_NAME,"0","0"),i=O(f.FORM_NAME,e,o.name);i.appendChild(M(f.INPUT_NAME,n)),o.appendChild(S("html",S("body",i))),i.submit()},z=(s=y(function(e){var t,r,n,o,i,a,s,c,l,u,f,p,h;return v(this,function(y){switch(y.label){case 0:if(t=e.tokenId,r=e.tokenIntentId,0===(o=[n=e.pan,t,r].filter(function(e){return void 0!==e})).length)throw Error("One of pan, tokenId, or tokenIntentId is required.");if(o.length>1)throw Error("Only one of pan, tokenId, or tokenIntentId should be provided.");return i=n?"pan":t?"tokenId":"tokenIntentId",a=n||t||r,s={browserColorDepth:w(I()),browserJavascriptEnabled:!0,browserJavaEnabled:window.navigator.javaEnabled(),browserLanguage:window.navigator.language,browserScreenHeight:w(window.screen.height),browserScreenWidth:w(window.screen.width),browserTZ:w(new Date().getTimezoneOffset()),browserUserAgent:window.navigator.userAgent},[4,j.client("POST","/sessions",R((m(c={},i,a),m(c,"device","browser"),m(c,"deviceInfo",s),c),function(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()}))];case 1:if((l=y.sent()).ok)return[3,6];y.label=2;case 2:return y.trys.push([2,4,,5]),[4,l.json()];case 3:return u=y.sent(),[3,5];case 4:throw y.sent(),f="Failed to parse error response. HTTP Status: ".concat(l.status),g.log.error(f),Error(f);case 5:var v;if("object"==typeof(v=u)&&null!==v&&("title"in v||"status"in v||"detail"in v))x(u);else throw p="An unknown error occurred while creating session. Status: ".concat(l.status,"."),g.log.error("".concat(p," Response: ").concat(JSON.stringify(u,null,2))),Error(p);y.label=6;case 6:return[4,l.json()];case 7:return h=D.apply(void 0,[y.sent()]),g.log.info("3DS session response received with ID ".concat(h.id)),h.methodUrl&&(F({isCompleted:!1,id:h.id,type:d.START_METHOD_TIME_OUT}),B(h.methodUrl,h.id,h.methodNotificationUrl)),[2,h]}})}),function(e){return s.apply(this,arguments)}),J=(c=y(function(e){var t;return v(this,function(r){switch(r.label){case 0:return[4,z({tokenId:e.tokenId,tokenIntentId:e.tokenIntentId,pan:e.pan}).catch(function(e){return Promise.reject(e.message)})];case 1:if(!(t=r.sent()).methodUrl)return[2,{id:t.id,cardBrand:t.cardBrand}];return[4,k(t)];case 2:return[2,r.sent()]}})}),function(e){return c.apply(this,arguments)}),q=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4;return new Promise(function(r,n){var o=function(t){if(P(t.data)&&t.data.type===d.CHALLENGE){clearTimeout(e),window.removeEventListener("message",o);var n={id:t.data.id};g.log.info("".concat(t.data.type," notification received for session: ").concat(n.id)),r(n),N([p.IFRAME_NAME])}else t.isTrusted};window.addEventListener("message",o),e=setTimeout(function(){window.removeEventListener("message",o),n("Timed out waiting for a challenge response. Please try again."),N([p.IFRAME_NAME])},t)})},V=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=document.getElementById(p.FRAME_CONTAINER_ID),o=T(t.challengeWindowSize),i=C(t),a=C(r),s=p.IFRAME_NAME,c=document.createElement("html"),l=document.createElement("body"),u=A(n,s,s,o[0],o[1]),d=O(p.FORM_NAME,e,u.name),f=M("creq",i),h=M(p.INPUT_NAME,a);d.appendChild(f),d.appendChild(h),l.appendChild(d),c.appendChild(l),u.appendChild(c),d.submit()},W=function(e){var t,r,n,o,i,a=e.sessionId,s=e.acsTransactionId,c=e.acsChallengeUrl,l=e.threeDSVersion,d=e.windowSize;if(!a)throw Error("Session ID is required");var f={messageType:"CReq",messageVersion:l,threeDSServerTransID:a,acsTransID:s,challengeWindowSize:null!=d?d:u.THREE};if(t=f.messageType,r=f.messageVersion,n=f.threeDSServerTransID,o=f.acsTransID,i=f.challengeWindowSize,null!==f&&"string"==typeof t&&"string"==typeof r&&"string"==typeof n&&"string"==typeof o&&Object.values(u).includes(i))V(c,f);else{var p="Invalid challenge request payload for session: ".concat(a);return g.log.error(p),Promise.reject(Error(p))}return Promise.resolve({id:a})},G=(l=y(function(e){var t,r,n,o,i,a,s;return v(this,function(c){switch(c.label){case 0:return t=e.sessionId,r=e.acsTransactionId,n=e.acsChallengeUrl,o=e.threeDSVersion,i=e.windowSize,s=void 0===(a=e.timeout)?6e4:a,[4,W({sessionId:t,acsTransactionId:r,acsChallengeUrl:n,threeDSVersion:o,windowSize:i}).catch(function(e){return Promise.reject(e.message)})];case 1:return c.sent(),[2,q(s)]}})}),function(e){return l.apply(this,arguments)});window.BasisTheory3ds=function(e,t){try{var r,n;_(f.FRAME_CONTAINER_ID,!0),_(null!==(n=null==t?void 0:null===(r=t.challengeContainerOptions)||void 0===r?void 0:r.id)&&void 0!==n?n:p.FRAME_CONTAINER_ID)}catch(e){g.log.error("Unable to create iframe container",e)}return j.init(e,null==t?void 0:t.apiBaseUrl),{createSession:J,startChallenge:G}}}();

@@ -326,6 +326,15 @@

};
const $18f82d365a93c819$var$makeSessionRequest = async ({ pan: pan })=>{
const $18f82d365a93c819$var$makeSessionRequest = async ({ tokenId: tokenId, tokenIntentId: tokenIntentId, pan: pan })=>{
const providedParams = [
pan,
tokenId,
tokenIntentId
].filter((param)=>param !== undefined);
if (providedParams.length === 0) throw new Error("One of pan, tokenId, or tokenIntentId is required.");
if (providedParams.length > 1) throw new Error("Only one of pan, tokenId, or tokenIntentId should be provided.");
const sessionParamKey = pan ? "pan" : tokenId ? "tokenId" : "tokenIntentId";
const sessionParamValue = pan || tokenId || tokenIntentId;
const deviceInfo = (0, $944918a4514227a1$export$a5202107d3e3cdb0)();
const response = await (0, $1fcbbbb68dcca4cc$export$7d6f1c8842f9f527).client("POST", `/sessions`, (0, $d8adca4734643193$export$3561b44d041d13c)({
pan: pan,
[sessionParamKey]: sessionParamValue,
device: "browser",

@@ -362,4 +371,6 @@ deviceInfo: deviceInfo

};
const $18f82d365a93c819$export$f7c62c73429afa28 = async ({ pan: pan })=>{
const $18f82d365a93c819$export$f7c62c73429afa28 = async ({ tokenId: tokenId, tokenIntentId: tokenIntentId, pan: pan })=>{
const session = await $18f82d365a93c819$var$makeSessionRequest({
tokenId: tokenId,
tokenIntentId: tokenIntentId,
pan: pan

@@ -366,0 +377,0 @@ }).catch((error)=>{

@@ -320,6 +320,15 @@ const $ede1e6694b13a411$export$3f521420530811cf = {

};
const $2bc795de5a692819$var$makeSessionRequest = async ({ pan: pan })=>{
const $2bc795de5a692819$var$makeSessionRequest = async ({ tokenId: tokenId, tokenIntentId: tokenIntentId, pan: pan })=>{
const providedParams = [
pan,
tokenId,
tokenIntentId
].filter((param)=>param !== undefined);
if (providedParams.length === 0) throw new Error("One of pan, tokenId, or tokenIntentId is required.");
if (providedParams.length > 1) throw new Error("Only one of pan, tokenId, or tokenIntentId should be provided.");
const sessionParamKey = pan ? "pan" : tokenId ? "tokenId" : "tokenIntentId";
const sessionParamValue = pan || tokenId || tokenIntentId;
const deviceInfo = (0, $12389938bc382e86$export$a5202107d3e3cdb0)();
const response = await (0, $263638c749818df0$export$7d6f1c8842f9f527).client("POST", `/sessions`, (0, $fa75e9b184a0a110$export$3561b44d041d13c)({
pan: pan,
[sessionParamKey]: sessionParamValue,
device: "browser",

@@ -356,4 +365,6 @@ deviceInfo: deviceInfo

};
const $2bc795de5a692819$export$f7c62c73429afa28 = async ({ pan: pan })=>{
const $2bc795de5a692819$export$f7c62c73429afa28 = async ({ tokenId: tokenId, tokenIntentId: tokenIntentId, pan: pan })=>{
const session = await $2bc795de5a692819$var$makeSessionRequest({
tokenId: tokenId,
tokenIntentId: tokenIntentId,
pan: pan

@@ -360,0 +371,0 @@ }).catch((error)=>{

{
"name": "@basis-theory/3ds-web",
"version": "1.3.0",
"version": "1.4.1",
"repository": "https://github.com/Basis-Theory/3ds-web",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -19,3 +19,3 @@ declare global {

export const BasisTheory3ds: (apiKey: string, configOptions?: ConfigOptions) => {
createSession: ({ pan }: import("~src/session").Create3dsSessionRequest) => Promise<{
createSession: ({ tokenId, tokenIntentId, pan, }: import("~src/session").Create3dsSessionRequest) => Promise<{
id: string;

@@ -22,0 +22,0 @@ cardBrand?: string;

export interface Create3dsSessionRequest {
pan: string;
tokenId?: string;
tokenIntentId?: string;
/**
* @deprecated This property is deprecated in favor of `tokenId`
*/
pan?: string;
}

@@ -10,5 +15,5 @@ export type Create3dsSessionResponse = {

};
export declare const createSession: ({ pan }: Create3dsSessionRequest) => Promise<{
export declare const createSession: ({ tokenId, tokenIntentId, pan, }: Create3dsSessionRequest) => Promise<{
id: string;
cardBrand?: string;
}>;
{
"name": "@basis-theory/3ds-web",
"version": "1.3.0",
"version": "1.4.1",
"repository": "https://github.com/Basis-Theory/3ds-web",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

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