@basis-theory/web-elements 1.3.1 → 1.5.0

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,20 @@
1
+ ## [1.5.0] - 2025-02-06
2
+
3
+ ### Features
4
+
5
+ - d9c1408 2025-02-04 feat: adds versioning (#379) by kevin@basistheory.com
6
+
7
+ ### Bug Fixes
8
+
9
+ - 429a5c8 2025-02-04 test: update playwright fixtures (#382) by kevin@basistheory.com
10
+ - d609a6a 2025-02-04 fix: deploy versioned client/hosted (#381) by kevin@basistheory.com
11
+
12
+ ## [1.4.0] - 2025-02-03
13
+
14
+ ### Features
15
+
16
+ - 1a231c7 2025-01-31 feat: add debug object (#380) by lucas@basistheory.com
17
+
1
18
  ## [1.3.1] - 2025-01-29
2
19
 
3
20
  ### 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){return function(i){if(t)throw TypeError("Generator is already executing.");for(;l;)try{if(t=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return l.label++,{value:i[1],done:!1};case 5:l.label++,n=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){l.label=i[1];break}if(6===i[0]&&l.label<o[1]){l.label=o[1],o=i;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(i);break}o[2]&&l.ops.pop(),l.trys.pop();continue}i=r.call(e,l)}catch(e){i=[6,e],n=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var n,o,i,l,s,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},a="Tried to load BasisTheoryElements in a non-DOM environment.",u="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.",d="https://".concat(void 0),f=(o=!0,i=r(function(e,r){var n,i,l,s,c,a,u=arguments;return t(this,function(t){switch(t.label){case 0:if(n=u.length>2&&void 0!==u[2]?u[2]:{},!o)return[2];a=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:d.includes("localhost")?"local":d.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(a),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)}}}),h=function(e,n){return new Promise(function(o,i){var l,s=c(e),d=!1;s.addEventListener("load",function(){window.BasisTheoryElements?o(window.BasisTheoryElements):(r(function(){return t(this,function(e){switch(e.label){case 0:return[4,f.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,c,p;return t(this,function(t){switch(t.label){case 0:if(d)return[2];return d=!0,[4,f.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,f.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 h(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((c=t.sent()).ok)return[3,9];return[4,f.log.error("Second attempt to load elements script failed, fetch failed with status: ".concat(c.status,"."),{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchResponse:c})];case 8:return t.sent(),i(Error(a)),[3,11];case 9:return[4,f.log.error("Second attempt to load elements script failed, fetch success",{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"success",fetchResponse:c})];case 10:t.sent(),i(Error(u)),t.label=11;case 11:return[3,14];case 12:return p=t.sent(),[4,f.log.error("Second attempt failed to load elements script failed, fetch network error.",{logType:"elementsScriptFetchError",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchError:p})];case 13:return t.sent(),i(Error(u)),[3,14];case 14:return i((null==r?void 0:r.error)||(null==r?void 0:r.message)||Error(u)),[2]}})}),function(e){return l.apply(this,arguments)}))})},p=(s=r(function(e,o){var i,l,s;return t(this,function(c){switch(c.label){case 0:var u;if(!e)throw Error("API key is required");return i=(null==o?void 0:o._devMode)?"js.flock-dev.com":"js.basistheory.com",[4,(u="https://".concat(i,"/elements"),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,f.log.warn(a,{logType:"elementsNonDomError",logOrigin:"loadElements"})];case 1:return e.sent(),n(Error(a)),[2]}})})();return}if(window.BasisTheoryElements){e(window.BasisTheoryElements);return}var o,i="https://".concat(void 0,"/elements");if(void 0!==u)try{i=new URL(u).toString().replace(RegExp("\\/$","u"),"")}catch(e){throw r(function(){return t(this,function(e){switch(e.label){case 0:return[4,f.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.")}h(i,0).then(e).catch(function(e){n(e)})})),n)];case 1:return[2,c.sent().init(e,"https://".concat(i,"/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)]}})}),function(e,r){return s.apply(this,arguments)});"undefined"!=typeof window&&document.currentScript&&!window.basistheory&&(window.basistheory=p)}();
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){return function(i){if(t)throw TypeError("Generator is already executing.");for(;l;)try{if(t=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return l.label++,{value:i[1],done:!1};case 5:l.label++,n=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){l.label=i[1];break}if(6===i[0]&&l.label<o[1]){l.label=o[1],o=i;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(i);break}o[2]&&l.ops.pop(),l.trys.pop();continue}i=r.call(e,l)}catch(e){i=[6,e],n=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var n,o,i,l,s,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},a="Tried to load BasisTheoryElements in a non-DOM environment.",u="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.",d="https://".concat(void 0),f=(o=!0,i=r(function(e,r){var n,i,l,s,c,a,u=arguments;return t(this,function(t){switch(t.label){case 0:if(n=u.length>2&&void 0!==u[2]?u[2]:{},!o)return[2];a=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:d.includes("localhost")?"local":d.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(a),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)}}}),h=function(e,n){return new Promise(function(o,i){var l,s=c(e),d=!1;s.addEventListener("load",function(){window.BasisTheoryElements?o(window.BasisTheoryElements):(r(function(){return t(this,function(e){switch(e.label){case 0:return[4,f.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,c,p;return t(this,function(t){switch(t.label){case 0:if(d)return[2];return d=!0,[4,f.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,f.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 h(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((c=t.sent()).ok)return[3,9];return[4,f.log.error("Second attempt to load elements script failed, fetch failed with status: ".concat(c.status,"."),{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchResponse:c})];case 8:return t.sent(),i(Error(a)),[3,11];case 9:return[4,f.log.error("Second attempt to load elements script failed, fetch success",{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"success",fetchResponse:c})];case 10:t.sent(),i(Error(u)),t.label=11;case 11:return[3,14];case 12:return p=t.sent(),[4,f.log.error("Second attempt failed to load elements script failed, fetch network error.",{logType:"elementsScriptFetchError",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchError:p})];case 13:return t.sent(),i(Error(u)),[3,14];case 14:return i((null==r?void 0:r.error)||(null==r?void 0:r.message)||Error(u)),[2]}})}),function(e){return l.apply(this,arguments)}))})},p={};p={version:"1.5.0"};var v=(s=r(function(e,o){var i;return t(this,function(l){switch(l.label){case 0:var s;if(!e)throw Error("API key is required");return i=(null==o?void 0:o._devMode)?"js.flock-dev.com":"js.basistheory.com",[4,(s="https://".concat(i,"/web-elements/").concat(p.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,f.log.warn(a,{logType:"elementsNonDomError",logOrigin:"loadElements"})];case 1:return e.sent(),n(Error(a)),[2]}})})();return}if(window.BasisTheoryElements){e(window.BasisTheoryElements);return}var o,i="https://".concat(void 0,"/elements");if(void 0!==s)try{i=new URL(s).toString().replace(RegExp("\\/$","u"),"")}catch(e){throw r(function(){return t(this,function(e){switch(e.label){case 0:return[4,f.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.")}h(i,0).then(e).catch(function(e){n(e)})})),n)];case 1:return[2,l.sent().init(e,"https://".concat(i,"/web-elements/").concat(p.version,"/hosted-elements/"),!1,!1,!1)]}})}),function(e,r){return s.apply(this,arguments)});"undefined"!=typeof window&&document.currentScript&&!window.basistheory&&(window.basistheory=v)}();
@@ -307,13 +307,20 @@ const $6477b722f43d24f2$export$2b0a6e5a1c78018f = (elementsClientUrl)=>{
307
307
 
308
308
 
309
309
 
310
+ var $eef42ce81412d9ae$exports = {};
311
+ const $eef42ce81412d9ae$var$version = '1.5.0';
312
+ $eef42ce81412d9ae$exports = {
313
+ version: $eef42ce81412d9ae$var$version
314
+ };
315
+
316
+
310
317
  const $316c9c8f85cead13$var$TEST_ENV = 'js.flock-dev.com';
311
318
  const $316c9c8f85cead13$var$DEFAULT_ENV = 'js.basistheory.com';
312
319
  const $316c9c8f85cead13$export$cbe2892587230861 = async (apiKey, options)=>{
313
320
  if (!apiKey) throw new Error('API key is required');
314
321
  const env = options?._devMode ? $316c9c8f85cead13$var$TEST_ENV : $316c9c8f85cead13$var$DEFAULT_ENV;
315
- const elements = await (0, $6477b722f43d24f2$export$2b0a6e5a1c78018f)(`https://${env}/elements`);
316
- return elements.init(apiKey, `https://${env}/hosted-elements`, false, options?.useSameOriginApi ?? false, options?.disableTelemetry ?? false);
322
+ const elements = await (0, $6477b722f43d24f2$export$2b0a6e5a1c78018f)(`https://${env}/web-elements/${(0, $eef42ce81412d9ae$exports.version)}/client/index.js`);
323
+ return elements.init(apiKey, `https://${env}/web-elements/${(0, $eef42ce81412d9ae$exports.version)}/hosted-elements/`, false, false, false);
317
324
  };
318
325
 
319
326
 
@@ -290,13 +290,20 @@ const $2cc07a9862fd14af$export$2b0a6e5a1c78018f = (elementsClientUrl)=>{
290
290
 
291
291
 
292
292
 
293
+ var $6a2f0bfcc5905f21$exports = {};
294
+ const $6a2f0bfcc5905f21$var$version = '1.5.0';
295
+ $6a2f0bfcc5905f21$exports = {
296
+ version: $6a2f0bfcc5905f21$var$version
297
+ };
298
+
299
+
293
300
  const $65168f0452925da7$var$TEST_ENV = 'js.flock-dev.com';
294
301
  const $65168f0452925da7$var$DEFAULT_ENV = 'js.basistheory.com';
295
302
  const $65168f0452925da7$export$cbe2892587230861 = async (apiKey, options)=>{
296
303
  if (!apiKey) throw new Error('API key is required');
297
304
  const env = options?._devMode ? $65168f0452925da7$var$TEST_ENV : $65168f0452925da7$var$DEFAULT_ENV;
298
- const elements = await (0, $2cc07a9862fd14af$export$2b0a6e5a1c78018f)(`https://${env}/elements`);
299
- return elements.init(apiKey, `https://${env}/hosted-elements`, false, options?.useSameOriginApi ?? false, options?.disableTelemetry ?? false);
305
+ const elements = await (0, $2cc07a9862fd14af$export$2b0a6e5a1c78018f)(`https://${env}/web-elements/${(0, $6a2f0bfcc5905f21$exports.version)}/client/index.js`);
306
+ return elements.init(apiKey, `https://${env}/web-elements/${(0, $6a2f0bfcc5905f21$exports.version)}/hosted-elements/`, false, false, false);
300
307
  };
301
308
 
302
309
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/web-elements",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "repository": "https://github.com/basis-theory/web-elements",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -15,6 +15,7 @@
15
15
  "!/bundle"
16
16
  ],
17
17
  "scripts": {
18
+ "prebuild": "TARGET_DIR=../../web-elements/src node ../scripts/web-elements/write-version-file.js",
18
19
  "build:dev": "yarn clean && yarn generateTypes && parcel build && npx size-limit",
19
20
  "build": "node ../scripts/web-elements/prepare.js && yarn generateTypes && parcel build --no-cache",
20
21
  "clean": "rimraf dist .parcel-cache",
@@ -0,0 +1 @@
1
+ export const version: "1.5.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/web-elements",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "repository": "https://github.com/basis-theory/web-elements",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -15,6 +15,7 @@
15
15
  "dist"
16
16
  ],
17
17
  "scripts": {
18
+ "prebuild": "TARGET_DIR=../../web-elements/src node ../scripts/web-elements/write-version-file.js",
18
19
  "build:dev": "yarn clean && yarn generateTypes && parcel build && npx size-limit",
19
20
  "build": "node ../scripts/web-elements/prepare.js && yarn generateTypes && parcel build --no-cache",
20
21
  "clean": "rimraf dist .parcel-cache",