@basis-theory/web-elements 1.11.5 → 1.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [1.11.6] - 2025-04-09
2
+
3
+ ### Bug Fixes
4
+
5
+ - 5d23abe 2025-04-09 fix: remove dependency on env variables (#418) by kevin@basistheory.com
6
+
1
7
  ## [1.11.5] - 2025-04-08
2
8
 
3
9
  ### Bug Fixes
@@ -1 +1 @@
1
- !function(){function e(e,r,t,n,o,i,l){try{var s=e[i](l),c=s.value}catch(e){t(e);return}s.done?r(c):Promise.resolve(c).then(n,o)}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,i){var l=r.apply(t,n);function s(r){e(l,o,i,s,c,"next",r)}function c(r){e(l,o,i,s,c,"throw",r)}s(void 0)})}}function t(e,r){var t,n,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){var c=[i,s];if(t)throw TypeError("Generator is already executing.");for(;l;)try{if(t=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,n=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=r.call(e,l)}catch(e){c=[6,e],n=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var n,o,i,l,s,c,a=function(e){var r=document.querySelector('script[src^="'.concat(e,'"]'));if(r)return r;var t=document.head||document.body;if(!t)throw Error("No <head> or <body> elements found in the document.");var n=Object.assign(document.createElement("script"),{src:e});return t.append(n),n},u="Tried to load BasisTheoryElements in a non-DOM environment.",d="Unable to load the Elements script. This may be due to network restrictions or browser extensions like ad blockers interfering with script loading. Check browser settings or network connection and try again.",f="https://".concat(void 0),h=(o=!0,i=r(function(e,r){var n,i,l,s,c,a,u,d=arguments;return t(this,function(t){switch(t.label){case 0:if(n=d.length>2&&void 0!==d[2]?d[2]:{},!o)return[2];u=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){var n;n=t[r],r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n})}return e}({level:r,message:e,service:"web-elements-loader",env:f.includes("localhost")?"local":f.includes("dev")?"dev":"prod",referrer:null===(i=document)||void 0===i?void 0:i.referrer,origin:null===(l=window)||void 0===l?void 0:l.location.origin,url:null===(s=window)||void 0===s?void 0:s.location.href,userAgent:null===(c=navigator)||void 0===c?void 0:c.userAgent},n),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch("https://http-intake.logs.datadoghq.com/v1/input/".concat("pubb96b84a13912504f4354f2d794ea4fab"),{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json"}})];case 2:return t.sent(),[3,4];case 3:return t.sent(),console.warn("There was an error sending telemetry."),[3,4];case 4:return[2]}})}),l=function(e,r){return i.apply(this,arguments)},{setTelemetryEnabled:function(e){o=e},log:{error:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l(e,"error",r)},info:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l(e,"info",r)},warn:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l(e,"warn",r)}}}),p=function(e,n){return new Promise(function(o,i){var l,s=a(e),c=!1;s.addEventListener("load",function(){window.BasisTheoryElements?o(window.BasisTheoryElements):(r(function(){return t(this,function(e){switch(e.label){case 0:return[4,h.log.error("Elements not found on window on load",{logType:"elementsNotFoundOnWindow",logOrigin:"loadScript",retryCount:n})];case 1:return e.sent(),[2]}})})(),i(Error("Basis Theory Elements did not load properly. Check network tab for more details.")))}),s.addEventListener("error",(l=r(function(r){var l,a,f;return t(this,function(t){switch(t.label){case 0:if(c)return[2];return c=!0,[4,h.log.error("Elements script onError event",{logType:"elementsScriptOnError",logOrigin:"loadScript",retryCount:n,event:{message:null==r?void 0:r.message,source:null==r?void 0:r.filename,lineno:null==r?void 0:r.lineno,colno:null==r?void 0:r.colno,error:null==r?void 0:r.error,target:null==r?void 0:r.target}})];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,3,,5]),null==s||s.remove(),[3,5];case 3:return l=t.sent(),[4,h.log.error("Error removing script from DOM on retry attempt ".concat(n),{logType:"scriptRemovalError",logOrigin:"loadScript",retryCount:n,removalError:l})];case 4:return t.sent(),[3,5];case 5:if(0===n)return p(e,n+1).then(o).catch(i),[2];t.label=6;case 6:return t.trys.push([6,12,,14]),[4,fetch(e)];case 7:if((a=t.sent()).ok)return[3,9];return[4,h.log.error("Second attempt to load elements script failed, fetch failed with status: ".concat(a.status,"."),{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchResponse:a})];case 8:return t.sent(),i(Error(u)),[3,11];case 9:return[4,h.log.error("Second attempt to load elements script failed, fetch success",{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"success",fetchResponse:a})];case 10:t.sent(),i(Error(d)),t.label=11;case 11:return[3,14];case 12:return f=t.sent(),[4,h.log.error("Second attempt failed to load elements script failed, fetch network error.",{logType:"elementsScriptFetchError",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchError:f})];case 13:return t.sent(),i(Error(d)),[3,14];case 14:return i((null==r?void 0:r.error)||(null==r?void 0:r.message)||Error(d)),[2]}})}),function(e){return l.apply(this,arguments)}))})},v={};v={version:"1.11.5"};var m=(s=r(function(e,o){var i,l,s,c;return t(this,function(a){switch(a.label){case 0:var d;if(!e||0===e.length)throw Error("API key is required");return i=(null==o?void 0:o._devMode)?"js.flock-dev.com":"js.basistheory.com",[4,(d="https://".concat(i,"/web-elements/").concat(v.version,"/client/index.js"),n||(n=new Promise(function(e,n){if(("undefined"==typeof window?"undefined":(o=window)&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)!="object"){r(function(){return t(this,function(e){switch(e.label){case 0:return[4,h.log.warn(u,{logType:"elementsNonDomError",logOrigin:"loadElements"})];case 1:return e.sent(),n(Error(u)),[2]}})})();return}if(window.BasisTheoryElements){e(window.BasisTheoryElements);return}var o,i="https://".concat(void 0,"/elements");if(void 0!==d)try{i=new URL(d).toString().replace(RegExp("\\/$","u"),"")}catch(e){throw r(function(){return t(this,function(e){switch(e.label){case 0:return[4,h.log.warn("Invalid format for the given Elements client url.",{logType:"invalidClientUrlError",logOrigin:"loadElements"})];case 1:return e.sent(),[2]}})})(),Error("Invalid format for the given Elements client url.")}p(i,0).then(e).catch(function(e){n(e)})})),n)];case 1:return[2,a.sent().init(e,"https://".concat(i,"/web-elements/").concat(v.version,"/hosted-elements/"),!1,null===(l=null==o?void 0:o.useSameOriginApi)||void 0===l||l,null!==(s=null==o?void 0:o.disableTelemetry)&&void 0!==s&&s,null!==(c=null==o?void 0:o.debug)&&void 0!==c&&c)]}})}),function(e,r){return s.apply(this,arguments)}),g=((c=g||{}).DECIMAL="decimal",c.EMAIL="email",c.NONE="none",c.NUMERIC="numeric",c.SEARCH="search",c.TEL="tel",c.TEXT="text",c.URL="url",c);"undefined"!=typeof window&&document.currentScript&&!window.basistheory&&(window.basistheory=m)}();
1
+ !function(){function e(e,r,t,n,o,i,l){try{var c=e[i](l),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function r(r){return function(){var t=this,n=arguments;return new Promise(function(o,i){var l=r.apply(t,n);function c(r){e(l,o,i,c,s,"next",r)}function s(r){e(l,o,i,c,s,"throw",r)}c(void 0)})}}function t(e,r){var t,n,o,i,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var s=[i,c];if(t)throw TypeError("Generator is already executing.");for(;l;)try{if(t=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 l.label++,{value:s[1],done:!1};case 5:l.label++,n=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){l.label=s[1];break}if(6===s[0]&&l.label<o[1]){l.label=o[1],o=s;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(s);break}o[2]&&l.ops.pop(),l.trys.pop();continue}s=r.call(e,l)}catch(e){s=[6,e],n=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var n,o,i,l,c,s,u,a,d,f,h={},p=h={};function m(){throw Error("setTimeout has not been defined")}function v(){throw Error("clearTimeout has not been defined")}try{n="function"==typeof setTimeout?setTimeout:m}catch(e){n=m}try{o="function"==typeof clearTimeout?clearTimeout:v}catch(e){o=v}function y(e){if(n===setTimeout)return setTimeout(e,0);if((n===m||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(r){try{return n.call(null,e,0)}catch(r){return n.call(this,e,0)}}}var g=[],w=!1,b=-1;function E(){w&&i&&(w=!1,i.length?g=i.concat(g):b=-1,g.length&&T())}function T(){if(!w){var e=y(E);w=!0;for(var r=g.length;r;){for(i=g,g=[];++b<r;)i&&i[b].run();b=-1,r=g.length}i=null,w=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===v||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{o(e)}catch(r){try{return o.call(null,e)}catch(r){return o.call(this,e)}}}(e)}}function O(e,r){this.fun=e,this.array=r}function S(){}p.nextTick=function(e){var r=Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)r[t-1]=arguments[t];g.push(new O(e,r)),1!==g.length||w||y(T)},O.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=S,p.addListener=S,p.once=S,p.off=S,p.removeListener=S,p.removeAllListeners=S,p.emit=S,p.prependListener=S,p.prependOnceListener=S,p.listeners=function(e){return[]},p.binding=function(e){throw Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw Error("process.chdir is not supported")},p.umask=function(){return 0};var k=(s=(null==h?void 0:h.env.NODE_ENV)!=="test",u=r(function(e,r){var n,o,i,l,u,a,d,f=arguments;return t(this,function(t){switch(t.label){case 0:if(n=f.length>2&&void 0!==f[2]?f[2]:{},s)return[2];d=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){var n;n=t[r],r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n})}return e}({level:r,message:e,service:"web-elements-loader",env:a=!c||(null==c?void 0:c.includes("localhost"))?"local":c.includes("dev")?"dev":"prod",referrer:null===(o=document)||void 0===o?void 0:o.referrer,origin:null===(i=window)||void 0===i?void 0:i.location.origin,url:null===(l=window)||void 0===l?void 0:l.location.href,userAgent:null===(u=navigator)||void 0===u?void 0:u.userAgent},n),["local","dev"].includes(a)&&console.log(d),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch("https://http-intake.logs.datadoghq.com/v1/input/".concat("pubb96b84a13912504f4354f2d794ea4fab"),{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"}})];case 2:return t.sent(),[3,4];case 3:return t.sent(),console.warn("There was an error sending telemetry."),[3,4];case 4:return[2]}})}),a=function(e,r){return u.apply(this,arguments)},{disableTelemetry:function(e){s=e},setBaseUrl:function(e){c=e},log:{error:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a(e,"error",r)},info:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a(e,"info",r)},warn:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a(e,"warn",r)}}}),C=function(e){var r=document.querySelector('script[src^="'.concat(e,'"]'));if(r)return r;var t=document.head||document.body;if(!t)throw Error("No <head> or <body> elements found in the document.");var n=Object.assign(document.createElement("script"),{src:e});return t.append(n),n},L="Tried to load BasisTheoryElements in a non-DOM environment.",j="Unable to load the Elements script. This may be due to network restrictions or browser extensions like ad blockers interfering with script loading. Check browser settings or network connection and try again.",R=function(e,n){return new Promise(function(o,i){var l,c=C(e),s=!1;c.addEventListener("load",function(){window.BasisTheoryElements?o(window.BasisTheoryElements):(r(function(){return t(this,function(e){switch(e.label){case 0:return[4,k.log.error("Elements not found on window on load",{logType:"elementsNotFoundOnWindow",logOrigin:"loadScript",retryCount:n})];case 1:return e.sent(),[2]}})})(),i(Error("Basis Theory Elements did not load properly. Check network tab for more details.")))}),c.addEventListener("error",(l=r(function(r){var l,u,a;return t(this,function(t){switch(t.label){case 0:if(s)return[2];return s=!0,[4,k.log.error("Elements script onError event",{logType:"elementsScriptOnError",logOrigin:"loadScript",retryCount:n,event:{message:null==r?void 0:r.message,source:null==r?void 0:r.filename,lineno:null==r?void 0:r.lineno,colno:null==r?void 0:r.colno,error:null==r?void 0:r.error,target:null==r?void 0:r.target}})];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,3,,5]),null==c||c.remove(),[3,5];case 3:return l=t.sent(),[4,k.log.error("Error removing script from DOM on retry attempt ".concat(n),{logType:"scriptRemovalError",logOrigin:"loadScript",retryCount:n,removalError:l})];case 4:return t.sent(),[3,5];case 5:if(0===n)return R(e,n+1).then(o).catch(i),[2];t.label=6;case 6:return t.trys.push([6,12,,14]),[4,fetch(e)];case 7:if((u=t.sent()).ok)return[3,9];return[4,k.log.error("Second attempt to load elements script failed, fetch failed with status: ".concat(u.status,"."),{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchResponse:u})];case 8:return t.sent(),i(Error(L)),[3,11];case 9:return[4,k.log.error("Second attempt to load elements script failed, fetch success",{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"success",fetchResponse:u})];case 10:t.sent(),i(Error(j)),t.label=11;case 11:return[3,14];case 12:return a=t.sent(),[4,k.log.error("Second attempt failed to load elements script failed, fetch network error.",{logType:"elementsScriptFetchError",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchError:a})];case 13:return t.sent(),i(Error(j)),[3,14];case 14:return i((null==r?void 0:r.error)||(null==r?void 0:r.message)||Error(j)),[2]}})}),function(e){return l.apply(this,arguments)}))})},P={};P={version:"1.11.6"};var x=(d=r(function(e,n){var o,i,c,s;return t(this,function(u){switch(u.label){case 0:var a;if(!e||0===e.length)throw Error("API key is required");return o=(null==n?void 0:n._devMode)?"js.flock-dev.com":"js.basistheory.com",k.setBaseUrl(o),k.disableTelemetry(!!(null==n?void 0:n.disableTelemetry)),[4,(a="https://".concat(o,"/web-elements/").concat(P.version,"/client/index.js"),l||(l=new Promise(function(e,n){var o;if(("undefined"==typeof window?"undefined":(o=window)&&"undefined"!=typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)!="object"){r(function(){return t(this,function(e){switch(e.label){case 0:return[4,k.log.warn(L,{logType:"elementsNonDomError",logOrigin:"loadElements"})];case 1:return e.sent(),n(Error(L)),[2]}})})();return}if(window.BasisTheoryElements){e(window.BasisTheoryElements);return}R(new URL(a).toString().replace(RegExp("\\/$","u"),""),0).then(e).catch(function(e){n(e)})})),l)];case 1:return[2,u.sent().init(e,"https://".concat(o,"/web-elements/").concat(P.version,"/hosted-elements/"),!1,null===(i=null==n?void 0:n.useSameOriginApi)||void 0===i||i,null!==(c=null==n?void 0:n.disableTelemetry)&&void 0!==c&&c,null!==(s=null==n?void 0:n.debug)&&void 0!==s&&s)]}})}),function(e,r){return d.apply(this,arguments)}),A=((f=A||{}).DECIMAL="decimal",f.EMAIL="email",f.NONE="none",f.NUMERIC="numeric",f.SEARCH="search",f.TEL="tel",f.TEXT="text",f.URL="url",f);"undefined"!=typeof window&&document.currentScript&&!window.basistheory&&(window.basistheory=x)}();
@@ -22,6 +22,66 @@ function $parcel$export(e, n, v, s) {
22
22
  var $316c9c8f85cead13$exports = {};
23
23
 
24
24
  $parcel$export($316c9c8f85cead13$exports, "basistheory", () => $316c9c8f85cead13$export$cbe2892587230861);
25
+ const $fe2ec396f58502a3$export$af88d00dbe7f521 = (()=>{
26
+ const ddTok = 'pubb96b84a13912504f4354f2d794ea4fab';
27
+ let _disableTelemetry = process?.env.NODE_ENV !== 'test';
28
+ let _baseUrl;
29
+ const _log = async (message, level, attributes = {})=>{
30
+ if (_disableTelemetry) return;
31
+ let env;
32
+ if (!_baseUrl || _baseUrl?.includes('localhost')) env = 'local';
33
+ else if (_baseUrl.includes('dev')) env = 'dev';
34
+ else env = 'prod';
35
+ const payload = {
36
+ level: // dd info
37
+ level,
38
+ message: message,
39
+ // for basis theory tracking
40
+ service: 'web-elements-loader',
41
+ env: env,
42
+ // browser information
43
+ referrer: document?.referrer,
44
+ origin: window?.location.origin,
45
+ url: window?.location.href,
46
+ userAgent: navigator?.userAgent,
47
+ // custom values
48
+ ...attributes
49
+ };
50
+ if ([
51
+ 'local',
52
+ 'dev'
53
+ ].includes(env)) console.log(payload);
54
+ try {
55
+ await fetch(`https://http-intake.logs.datadoghq.com/v1/input/${ddTok}`, {
56
+ method: 'POST',
57
+ body: JSON.stringify(payload),
58
+ headers: {
59
+ 'Content-Type': 'application/json'
60
+ }
61
+ });
62
+ } catch {
63
+ // eslint-disable-next-line no-console
64
+ console.warn('There was an error sending telemetry.');
65
+ }
66
+ };
67
+ const disableTelemetry = (val)=>{
68
+ _disableTelemetry = val;
69
+ };
70
+ const setBaseUrl = (baseUrl)=>{
71
+ _baseUrl = baseUrl;
72
+ };
73
+ return {
74
+ disableTelemetry: disableTelemetry,
75
+ setBaseUrl: setBaseUrl,
76
+ log: {
77
+ error: (message, attributes = {})=>_log(message, 'error', attributes),
78
+ info: (message, attributes = {})=>_log(message, 'info', attributes),
79
+ warn: (message, attributes = {})=>_log(message, 'warn', attributes)
80
+ }
81
+ };
82
+ })();
83
+
84
+
25
85
  const $426651baf7085210$export$74dcf80d122cf64e = (url)=>{
26
86
  const existingScript = document.querySelector(`script[src^="${url}"]`);
27
87
  if (existingScript) return existingScript;
@@ -35,7 +95,6 @@ const $426651baf7085210$export$74dcf80d122cf64e = (url)=>{
35
95
  };
36
96
 
37
97
 
38
- const $ef6e1b024b683770$export$ab49734bd00442f0 = 'BasisTheory Elements was not properly initialized.';
39
98
  const $ef6e1b024b683770$export$6b1a35ff3caa965f = 'Tried to load BasisTheoryElements in a non-DOM environment.';
40
99
  const $ef6e1b024b683770$export$e3797f3a93015b7b = 'Basis Theory Elements did not load properly. Check network tab for more details.';
41
100
  const $ef6e1b024b683770$export$56e79dc97980170 = 'Unable to load the Elements script. This may be due to network restrictions or browser extensions like ad blockers interfering with script loading. Check browser settings or network connection and try again.';
@@ -127,57 +186,6 @@ const $ef6e1b024b683770$export$dea6ebbc92df4fa3 = [
127
186
 
128
187
 
129
188
 
130
- const $fe2ec396f58502a3$var$DEFAULT_BASE_URL = `https://${process.env.API_HOST}`;
131
- const $fe2ec396f58502a3$export$af88d00dbe7f521 = (()=>{
132
- const ddTok = 'pubb96b84a13912504f4354f2d794ea4fab';
133
- let isTelemetryEnabled = process.env.NODE_ENV !== 'test';
134
- const _log = async (message, level, attributes = {})=>{
135
- if (!isTelemetryEnabled) return;
136
- let env;
137
- if ($fe2ec396f58502a3$var$DEFAULT_BASE_URL.includes('localhost')) env = 'local';
138
- else if ($fe2ec396f58502a3$var$DEFAULT_BASE_URL.includes('dev')) env = 'dev';
139
- else env = 'prod';
140
- const payload = {
141
- level: // dd info
142
- level,
143
- message: message,
144
- // for basis theory tracking
145
- service: 'web-elements-loader',
146
- env: env,
147
- // browser information
148
- referrer: document?.referrer,
149
- origin: window?.location.origin,
150
- url: window?.location.href,
151
- userAgent: navigator?.userAgent,
152
- // custom values
153
- ...attributes
154
- };
155
- try {
156
- await fetch(`https://http-intake.logs.datadoghq.com/v1/input/${ddTok}`, {
157
- method: 'POST',
158
- body: JSON.stringify(payload),
159
- headers: {
160
- 'Content-Type': 'application/json'
161
- }
162
- });
163
- } catch {
164
- // eslint-disable-next-line no-console
165
- console.warn('There was an error sending telemetry.');
166
- }
167
- };
168
- const setTelemetryEnabled = (enabled)=>{
169
- isTelemetryEnabled = enabled;
170
- };
171
- return {
172
- setTelemetryEnabled: setTelemetryEnabled,
173
- log: {
174
- error: (message, attributes = {})=>_log(message, 'error', attributes),
175
- info: (message, attributes = {})=>_log(message, 'info', attributes),
176
- warn: (message, attributes = {})=>_log(message, 'warn', attributes)
177
- }
178
- };
179
- })();
180
-
181
189
 
182
190
  let $6477b722f43d24f2$var$elementsPromise;
183
191
  const $6477b722f43d24f2$var$loadScript = (url, retryCount)=>new Promise((resolve, reject)=>{
@@ -268,7 +276,7 @@ const $6477b722f43d24f2$var$loadScript = (url, retryCount)=>new Promise((resolve
268
276
  reject(event?.error || event?.message || new Error((0, $ef6e1b024b683770$export$56e79dc97980170)));
269
277
  });
270
278
  });
271
- const $6477b722f43d24f2$export$2b0a6e5a1c78018f = (elementsClientUrl)=>{
279
+ const $6477b722f43d24f2$export$2b0a6e5a1c78018f = (elementsUrl)=>{
272
280
  if (!$6477b722f43d24f2$var$elementsPromise) $6477b722f43d24f2$var$elementsPromise = new Promise((resolve, reject)=>{
273
281
  if (typeof window !== 'object') {
274
282
  (async ()=>{
@@ -284,20 +292,7 @@ const $6477b722f43d24f2$export$2b0a6e5a1c78018f = (elementsClientUrl)=>{
284
292
  resolve(window.BasisTheoryElements);
285
293
  return;
286
294
  }
287
- // TODO refactor/remove this fallback
288
- let url = `https://${process.env.JS_HOST}/elements`;
289
- if (typeof elementsClientUrl !== 'undefined') try {
290
- const urlObject = new URL(elementsClientUrl);
291
- url = urlObject.toString().replace(/\/$/u, '');
292
- } catch {
293
- (async ()=>{
294
- await (0, $fe2ec396f58502a3$export$af88d00dbe7f521).log.warn('Invalid format for the given Elements client url.', {
295
- logType: 'invalidClientUrlError',
296
- logOrigin: 'loadElements'
297
- });
298
- })();
299
- throw new Error('Invalid format for the given Elements client url.');
300
- }
295
+ const url = new URL(elementsUrl).toString().replace(/\/$/u, '');
301
296
  $6477b722f43d24f2$var$loadScript(url, 0).then(resolve).catch((error)=>{
302
297
  reject(error);
303
298
  });
@@ -309,7 +304,7 @@ const $6477b722f43d24f2$export$2b0a6e5a1c78018f = (elementsClientUrl)=>{
309
304
 
310
305
 
311
306
  var $eef42ce81412d9ae$exports = {};
312
- const $eef42ce81412d9ae$var$version = '1.11.5';
307
+ const $eef42ce81412d9ae$var$version = '1.11.6';
313
308
  $eef42ce81412d9ae$exports = {
314
309
  version: $eef42ce81412d9ae$var$version
315
310
  };
@@ -319,9 +314,11 @@ const $316c9c8f85cead13$var$TEST_ENV = 'js.flock-dev.com';
319
314
  const $316c9c8f85cead13$var$DEFAULT_ENV = 'js.basistheory.com';
320
315
  const $316c9c8f85cead13$export$cbe2892587230861 = async (apiKey, options)=>{
321
316
  if (!apiKey || apiKey.length === 0) throw new Error('API key is required');
322
- const env = options?._devMode ? $316c9c8f85cead13$var$TEST_ENV : $316c9c8f85cead13$var$DEFAULT_ENV;
323
- const elements = await (0, $6477b722f43d24f2$export$2b0a6e5a1c78018f)(`https://${env}/web-elements/${(0, $eef42ce81412d9ae$exports.version)}/client/index.js`);
324
- return elements.init(apiKey, `https://${env}/web-elements/${(0, $eef42ce81412d9ae$exports.version)}/hosted-elements/`, false, options?.useSameOriginApi ?? true, options?.disableTelemetry ?? false, options?.debug ?? false);
317
+ const baseUrl = options?._devMode ? $316c9c8f85cead13$var$TEST_ENV : $316c9c8f85cead13$var$DEFAULT_ENV;
318
+ (0, $fe2ec396f58502a3$export$af88d00dbe7f521).setBaseUrl(baseUrl);
319
+ (0, $fe2ec396f58502a3$export$af88d00dbe7f521).disableTelemetry(Boolean(options?.disableTelemetry));
320
+ const elements = await (0, $6477b722f43d24f2$export$2b0a6e5a1c78018f)(`https://${baseUrl}/web-elements/${(0, $eef42ce81412d9ae$exports.version)}/client/index.js`);
321
+ return elements.init(apiKey, `https://${baseUrl}/web-elements/${(0, $eef42ce81412d9ae$exports.version)}/hosted-elements/`, false, options?.useSameOriginApi ?? true, options?.disableTelemetry ?? false, options?.debug ?? false);
325
322
  };
326
323
 
327
324
 
@@ -22,6 +22,66 @@ function $parcel$exportWildcard(dest, source) {
22
22
  var $65168f0452925da7$exports = {};
23
23
 
24
24
  $parcel$export($65168f0452925da7$exports, "basistheory", () => $65168f0452925da7$export$cbe2892587230861);
25
+ const $367e4a81566d966b$export$af88d00dbe7f521 = (()=>{
26
+ const ddTok = 'pubb96b84a13912504f4354f2d794ea4fab';
27
+ let _disableTelemetry = process?.env.NODE_ENV !== 'test';
28
+ let _baseUrl;
29
+ const _log = async (message, level, attributes = {})=>{
30
+ if (_disableTelemetry) return;
31
+ let env;
32
+ if (!_baseUrl || _baseUrl?.includes('localhost')) env = 'local';
33
+ else if (_baseUrl.includes('dev')) env = 'dev';
34
+ else env = 'prod';
35
+ const payload = {
36
+ level: // dd info
37
+ level,
38
+ message: message,
39
+ // for basis theory tracking
40
+ service: 'web-elements-loader',
41
+ env: env,
42
+ // browser information
43
+ referrer: document?.referrer,
44
+ origin: window?.location.origin,
45
+ url: window?.location.href,
46
+ userAgent: navigator?.userAgent,
47
+ // custom values
48
+ ...attributes
49
+ };
50
+ if ([
51
+ 'local',
52
+ 'dev'
53
+ ].includes(env)) console.log(payload);
54
+ try {
55
+ await fetch(`https://http-intake.logs.datadoghq.com/v1/input/${ddTok}`, {
56
+ method: 'POST',
57
+ body: JSON.stringify(payload),
58
+ headers: {
59
+ 'Content-Type': 'application/json'
60
+ }
61
+ });
62
+ } catch {
63
+ // eslint-disable-next-line no-console
64
+ console.warn('There was an error sending telemetry.');
65
+ }
66
+ };
67
+ const disableTelemetry = (val)=>{
68
+ _disableTelemetry = val;
69
+ };
70
+ const setBaseUrl = (baseUrl)=>{
71
+ _baseUrl = baseUrl;
72
+ };
73
+ return {
74
+ disableTelemetry: disableTelemetry,
75
+ setBaseUrl: setBaseUrl,
76
+ log: {
77
+ error: (message, attributes = {})=>_log(message, 'error', attributes),
78
+ info: (message, attributes = {})=>_log(message, 'info', attributes),
79
+ warn: (message, attributes = {})=>_log(message, 'warn', attributes)
80
+ }
81
+ };
82
+ })();
83
+
84
+
25
85
  const $0da125a57a8274fc$export$74dcf80d122cf64e = (url)=>{
26
86
  const existingScript = document.querySelector(`script[src^="${url}"]`);
27
87
  if (existingScript) return existingScript;
@@ -35,7 +95,6 @@ const $0da125a57a8274fc$export$74dcf80d122cf64e = (url)=>{
35
95
  };
36
96
 
37
97
 
38
- const $2e9038c0999bba06$export$ab49734bd00442f0 = 'BasisTheory Elements was not properly initialized.';
39
98
  const $2e9038c0999bba06$export$6b1a35ff3caa965f = 'Tried to load BasisTheoryElements in a non-DOM environment.';
40
99
  const $2e9038c0999bba06$export$e3797f3a93015b7b = 'Basis Theory Elements did not load properly. Check network tab for more details.';
41
100
  const $2e9038c0999bba06$export$56e79dc97980170 = 'Unable to load the Elements script. This may be due to network restrictions or browser extensions like ad blockers interfering with script loading. Check browser settings or network connection and try again.';
@@ -127,57 +186,6 @@ const $2e9038c0999bba06$export$dea6ebbc92df4fa3 = [
127
186
 
128
187
 
129
188
 
130
- const $367e4a81566d966b$var$DEFAULT_BASE_URL = `https://${process.env.API_HOST}`;
131
- const $367e4a81566d966b$export$af88d00dbe7f521 = (()=>{
132
- const ddTok = 'pubb96b84a13912504f4354f2d794ea4fab';
133
- let isTelemetryEnabled = process.env.NODE_ENV !== 'test';
134
- const _log = async (message, level, attributes = {})=>{
135
- if (!isTelemetryEnabled) return;
136
- let env;
137
- if ($367e4a81566d966b$var$DEFAULT_BASE_URL.includes('localhost')) env = 'local';
138
- else if ($367e4a81566d966b$var$DEFAULT_BASE_URL.includes('dev')) env = 'dev';
139
- else env = 'prod';
140
- const payload = {
141
- level: // dd info
142
- level,
143
- message: message,
144
- // for basis theory tracking
145
- service: 'web-elements-loader',
146
- env: env,
147
- // browser information
148
- referrer: document?.referrer,
149
- origin: window?.location.origin,
150
- url: window?.location.href,
151
- userAgent: navigator?.userAgent,
152
- // custom values
153
- ...attributes
154
- };
155
- try {
156
- await fetch(`https://http-intake.logs.datadoghq.com/v1/input/${ddTok}`, {
157
- method: 'POST',
158
- body: JSON.stringify(payload),
159
- headers: {
160
- 'Content-Type': 'application/json'
161
- }
162
- });
163
- } catch {
164
- // eslint-disable-next-line no-console
165
- console.warn('There was an error sending telemetry.');
166
- }
167
- };
168
- const setTelemetryEnabled = (enabled)=>{
169
- isTelemetryEnabled = enabled;
170
- };
171
- return {
172
- setTelemetryEnabled: setTelemetryEnabled,
173
- log: {
174
- error: (message, attributes = {})=>_log(message, 'error', attributes),
175
- info: (message, attributes = {})=>_log(message, 'info', attributes),
176
- warn: (message, attributes = {})=>_log(message, 'warn', attributes)
177
- }
178
- };
179
- })();
180
-
181
189
 
182
190
  let $2cc07a9862fd14af$var$elementsPromise;
183
191
  const $2cc07a9862fd14af$var$loadScript = (url, retryCount)=>new Promise((resolve, reject)=>{
@@ -268,7 +276,7 @@ const $2cc07a9862fd14af$var$loadScript = (url, retryCount)=>new Promise((resolve
268
276
  reject(event?.error || event?.message || new Error((0, $2e9038c0999bba06$export$56e79dc97980170)));
269
277
  });
270
278
  });
271
- const $2cc07a9862fd14af$export$2b0a6e5a1c78018f = (elementsClientUrl)=>{
279
+ const $2cc07a9862fd14af$export$2b0a6e5a1c78018f = (elementsUrl)=>{
272
280
  if (!$2cc07a9862fd14af$var$elementsPromise) $2cc07a9862fd14af$var$elementsPromise = new Promise((resolve, reject)=>{
273
281
  if (typeof window !== 'object') {
274
282
  (async ()=>{
@@ -284,20 +292,7 @@ const $2cc07a9862fd14af$export$2b0a6e5a1c78018f = (elementsClientUrl)=>{
284
292
  resolve(window.BasisTheoryElements);
285
293
  return;
286
294
  }
287
- // TODO refactor/remove this fallback
288
- let url = `https://${process.env.JS_HOST}/elements`;
289
- if (typeof elementsClientUrl !== 'undefined') try {
290
- const urlObject = new URL(elementsClientUrl);
291
- url = urlObject.toString().replace(/\/$/u, '');
292
- } catch {
293
- (async ()=>{
294
- await (0, $367e4a81566d966b$export$af88d00dbe7f521).log.warn('Invalid format for the given Elements client url.', {
295
- logType: 'invalidClientUrlError',
296
- logOrigin: 'loadElements'
297
- });
298
- })();
299
- throw new Error('Invalid format for the given Elements client url.');
300
- }
295
+ const url = new URL(elementsUrl).toString().replace(/\/$/u, '');
301
296
  $2cc07a9862fd14af$var$loadScript(url, 0).then(resolve).catch((error)=>{
302
297
  reject(error);
303
298
  });
@@ -309,7 +304,7 @@ const $2cc07a9862fd14af$export$2b0a6e5a1c78018f = (elementsClientUrl)=>{
309
304
 
310
305
 
311
306
  var $6a2f0bfcc5905f21$exports = {};
312
- const $6a2f0bfcc5905f21$var$version = '1.11.5';
307
+ const $6a2f0bfcc5905f21$var$version = '1.11.6';
313
308
  $6a2f0bfcc5905f21$exports = {
314
309
  version: $6a2f0bfcc5905f21$var$version
315
310
  };
@@ -319,9 +314,11 @@ const $65168f0452925da7$var$TEST_ENV = 'js.flock-dev.com';
319
314
  const $65168f0452925da7$var$DEFAULT_ENV = 'js.basistheory.com';
320
315
  const $65168f0452925da7$export$cbe2892587230861 = async (apiKey, options)=>{
321
316
  if (!apiKey || apiKey.length === 0) throw new Error('API key is required');
322
- const env = options?._devMode ? $65168f0452925da7$var$TEST_ENV : $65168f0452925da7$var$DEFAULT_ENV;
323
- const elements = await (0, $2cc07a9862fd14af$export$2b0a6e5a1c78018f)(`https://${env}/web-elements/${(0, $6a2f0bfcc5905f21$exports.version)}/client/index.js`);
324
- return elements.init(apiKey, `https://${env}/web-elements/${(0, $6a2f0bfcc5905f21$exports.version)}/hosted-elements/`, false, options?.useSameOriginApi ?? true, options?.disableTelemetry ?? false, options?.debug ?? false);
317
+ const baseUrl = options?._devMode ? $65168f0452925da7$var$TEST_ENV : $65168f0452925da7$var$DEFAULT_ENV;
318
+ (0, $367e4a81566d966b$export$af88d00dbe7f521).setBaseUrl(baseUrl);
319
+ (0, $367e4a81566d966b$export$af88d00dbe7f521).disableTelemetry(Boolean(options?.disableTelemetry));
320
+ const elements = await (0, $2cc07a9862fd14af$export$2b0a6e5a1c78018f)(`https://${baseUrl}/web-elements/${(0, $6a2f0bfcc5905f21$exports.version)}/client/index.js`);
321
+ return elements.init(apiKey, `https://${baseUrl}/web-elements/${(0, $6a2f0bfcc5905f21$exports.version)}/hosted-elements/`, false, options?.useSameOriginApi ?? true, options?.disableTelemetry ?? false, options?.debug ?? false);
325
322
  };
326
323
 
327
324
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/web-elements",
3
- "version": "1.11.5",
3
+ "version": "1.11.6",
4
4
  "repository": "https://github.com/basis-theory/web-elements",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/web-elements",
3
- "version": "1.11.5",
3
+ "version": "1.11.6",
4
4
  "repository": "https://github.com/basis-theory/web-elements",
5
5
  "license": "Apache-2.0",
6
6
  "author": {