@basis-theory/web-elements 2.0.0 → 2.2.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,16 @@
1
+ ## [2.2.0] - 2025-09-12
2
+
3
+ ### Features
4
+
5
+ - 17f206f 2025-09-12 feat: add copy button to react elements (#521) by kevin@basistheory.com
6
+
7
+ ## [2.1.0] - 2025-09-11
8
+
9
+ ### Features
10
+
11
+ - fdfaabf 2025-09-11 feat: adds copy button (#519) by brian.gonzalez@basistheory.com
12
+ - 6503dd1 2025-09-08 feat: add support for domain whitelabeling (#510) by kevin@basistheory.com
13
+
1
14
  ## [2.0.0] - 2025-09-08
2
15
 
3
16
  ### Breaking Changes
@@ -1 +1 @@
1
- !function(){function e(e,r,t,n,o,i,l){try{var c=e[i](l),u=c.value}catch(e){t(e);return}c.done?r(u):Promise.resolve(u).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,u,"next",r)}function u(r){e(l,o,i,c,u,"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 u=[i,c];if(t)throw TypeError("Generator is already executing.");for(;l;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,n=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){l.label=u[1];break}if(6===u[0]&&l.label<o[1]){l.label=o[1],o=u;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(u);break}o[2]&&l.ops.pop(),l.trys.pop();continue}u=r.call(e,l)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var n,o,i,l,c,u,s,a=(l=r(function(e,r){var n,l,c,u,s,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]:{},o)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=!i||(null==i?void 0:i.includes("localhost"))?"local":i.includes("dev")?"dev":"prod",referrer:null===(l=document)||void 0===l?void 0:l.referrer,origin:null===(c=window)||void 0===c?void 0:c.location.origin,url:null===(u=window)||void 0===u?void 0:u.location.href,userAgent:null===(s=navigator)||void 0===s?void 0:s.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]}})}),c=function(e,r){return l.apply(this,arguments)},{disableTelemetry:function(e){o=e},setBaseUrl:function(e){i=e},log:{error:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e,"error",r)},info:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e,"info",r)},warn:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e,"warn",r)}}}),d=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},f="Tried to load BasisTheoryElements in a non-DOM environment.",p="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.",h=function(e,n){return new Promise(function(o,i){var l,c=d(e),u=!1;c.addEventListener("load",function(){window.BasisTheoryElements?o(window.BasisTheoryElements):(r(function(){return t(this,function(e){switch(e.label){case 0:return[4,a.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,s,d;return t(this,function(t){switch(t.label){case 0:if(u)return[2];return u=!0,[4,a.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,a.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((s=t.sent()).ok)return[3,9];return[4,a.log.error("Second attempt to load elements script failed, fetch failed with status: ".concat(s.status,"."),{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchResponse:s})];case 8:return t.sent(),i(Error(f)),[3,11];case 9:return[4,a.log.error("Second attempt to load elements script failed, fetch success",{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:n,fetchResult:"success",fetchResponse:s})];case 10:t.sent(),i(Error(p)),t.label=11;case 11:return[3,14];case 12:return d=t.sent(),[4,a.log.error("Second attempt failed to load elements script failed, fetch network error.",{logType:"elementsScriptFetchError",logOrigin:"loadScript",retryCount:n,fetchResult:"error",fetchError:d})];case 13:return t.sent(),i(Error(p)),[3,14];case 14:return i((null==r?void 0:r.error)||(null==r?void 0:r.message)||Error(p)),[2]}})}),function(e){return l.apply(this,arguments)}))})},v="2.0.0",y=(u=r(function(e,o){var i,l,c,u,s,d,p,y;return t(this,function(m){switch(m.label){case 0: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",a.setBaseUrl(i),a.disableTelemetry(!!(null==o?void 0:o.disableTelemetry)),l="https://".concat(i,"/web-elements/").concat(v,"/client/index.js"),c="https://".concat(i,"/web-elements/").concat(v,"/hosted-elements/"),[4,(n||(n=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,a.log.warn(f,{logType:"elementsNonDomError",logOrigin:"loadElements"})];case 1:return e.sent(),n(Error(f)),[2]}})})();return}if(window.BasisTheoryElements){e(window.BasisTheoryElements);return}h(new URL(l).toString().replace(RegExp("\\/$","u"),""),0).then(e).catch(function(e){n(e)})})),n)];case 1:return[2,m.sent().init(e,c,!1,null===(u=null==o?void 0:o.useSameOriginApi)||void 0===u||u,null!==(s=null==o?void 0:o.disableTelemetry)&&void 0!==s&&s,null!==(d=null==o?void 0:o.debug)&&void 0!==d&&d,null!==(p=null==o?void 0:o.useUat)&&void 0!==p&&p,null!==(y=null==o?void 0:o.useNetworkCheck)&&void 0!==y&&y)]}})}),function(e,r){return u.apply(this,arguments)}),m=((s=m||{}).DECIMAL="decimal",s.EMAIL="email",s.NONE="none",s.NUMERIC="numeric",s.SEARCH="search",s.TEL="tel",s.TEXT="text",s.URL="url",s);function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}function w(e,r){return(w=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function E(e,r,t){return(E=g()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&w(o,t.prototype),o}).apply(null,arguments)}function O(e){var r="function"==typeof Map?new Map:void 0;return(O=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return E(e,arguments,b(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),w(t,e)})(e)}O(Error),O(Error),O(Error),"undefined"!=typeof window&&document.currentScript&&!window.basistheory&&(window.basistheory=y)}();
1
+ !function(){function e(e,t,r,n,o,i,l){try{var c=e[i](l),a=c.value}catch(e){r(e);return}c.done?t(a):Promise.resolve(a).then(n,o)}function t(t){return function(){var r=this,n=arguments;return new Promise(function(o,i){var l=t.apply(r,n);function c(t){e(l,o,i,c,a,"next",t)}function a(t){e(l,o,i,c,a,"throw",t)}c(void 0)})}}function r(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function n(e,t){var r,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 a=[i,c];if(r)throw TypeError("Generator is already executing.");for(;l;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,n=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}var o,i,l,c,a,s,u,d=(c=t(function(e,t){var r,o,c,a,s,u,d,f=arguments;return n(this,function(n){switch(n.label){case 0:if(r=f.length>2&&void 0!==f[2]?f[2]:{},i)return[2];d=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){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({level:t,message:e,service:"web-elements-loader",env:u=!l||(null==l?void 0:l.includes("localhost"))?"local":l.includes("dev")?"dev":"prod",referrer:null===(o=document)||void 0===o?void 0:o.referrer,origin:null===(c=window)||void 0===c?void 0:c.location.origin,url:null===(a=window)||void 0===a?void 0:a.location.href,userAgent:null===(s=navigator)||void 0===s?void 0:s.userAgent},r),["local","dev"].includes(u)&&console.log(d),n.label=1;case 1:return n.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 n.sent(),[3,4];case 3:return n.sent(),console.warn("There was an error sending telemetry."),[3,4];case 4:return[2]}})}),a=function(e,t){return c.apply(this,arguments)},{disableTelemetry:function(e){i=e},setBaseUrl:function(e){l=e},log:{error:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a(e,"error",t)},info:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a(e,"info",t)},warn:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a(e,"warn",t)}}});function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e,t,r){return(m=p()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&h(o,r.prototype),o}).apply(null,arguments)}function v(e){var t="function"==typeof Map?new Map:void 0;return(v=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return m(e,arguments,f(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,e)})(e)}var y=function(e){"use strict";if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(e,n,o){var i;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return(i=function(e,t,n){t=f(t);var o=p()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n);if(o&&("object"===r(o)||"function"==typeof o))return o;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,t,[e])).details=n,i.validation=o,i.name="BasisTheoryValidationError",Object.setPrototypeOf(i,t.prototype),i}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&h(t,e),t}(v(Error)),w=function(e){var t;if("string"!=typeof e||!e.trim())throw Error("Custom domain must be a non-empty string.");try{t=new URL(e.toLowerCase().startsWith("http")?e:"https://".concat(e))}catch(t){throw new y('Invalid custom domain: "'.concat(e,'"'),{})}if("https:"!==t.protocol)throw new y('Custom domain must use HTTPS (got "'.concat(t.protocol,'")'),{});if("/"!==t.pathname||t.search||t.hash)throw new y('Custom domain must not include path, query, or hash (got "'.concat(t.href,'")'),{});if(t.port)throw new y('Custom domain must not include a port (got ":'.concat(t.port,'")'),{});if(!/^(?=.{1,253}$)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}$/.test(t.hostname))throw new y('Invalid hostname: "'.concat(t.hostname,'"'),{});return t.origin},b=function(e){var t=document.querySelector('script[src^="'.concat(e,'"]'));if(t)return t;var r=document.head||document.body;if(!r)throw Error("No <head> or <body> elements found in the document.");var n=Object.assign(document.createElement("script"),{src:e});return r.append(n),n},g="Tried to load BasisTheoryElements in a non-DOM environment.",E="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.",O=function(e,r){return new Promise(function(o,i){var l,c=b(e),a=!1;c.addEventListener("load",function(){window.BasisTheoryElements?o(window.BasisTheoryElements):(t(function(){return n(this,function(e){switch(e.label){case 0:return[4,d.log.error("Elements not found on window on load",{logType:"elementsNotFoundOnWindow",logOrigin:"loadScript",retryCount:r})];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=t(function(t){var l,s,u;return n(this,function(n){switch(n.label){case 0:if(a)return[2];return a=!0,[4,d.log.error("Elements script onError event",{logType:"elementsScriptOnError",logOrigin:"loadScript",retryCount:r,event:{message:null==t?void 0:t.message,source:null==t?void 0:t.filename,lineno:null==t?void 0:t.lineno,colno:null==t?void 0:t.colno,error:null==t?void 0:t.error,target:null==t?void 0:t.target}})];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,3,,5]),null==c||c.remove(),[3,5];case 3:return l=n.sent(),[4,d.log.error("Error removing script from DOM on retry attempt ".concat(r),{logType:"scriptRemovalError",logOrigin:"loadScript",retryCount:r,removalError:l})];case 4:return n.sent(),[3,5];case 5:if(0===r)return O(e,r+1).then(o).catch(i),[2];n.label=6;case 6:return n.trys.push([6,12,,14]),[4,fetch(e)];case 7:if((s=n.sent()).ok)return[3,9];return[4,d.log.error("Second attempt to load elements script failed, fetch failed with status: ".concat(s.status,"."),{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:r,fetchResult:"error",fetchResponse:s})];case 8:return n.sent(),i(Error(g)),[3,11];case 9:return[4,d.log.error("Second attempt to load elements script failed, fetch success",{logType:"elementsScriptFetchFailure",logOrigin:"loadScript",retryCount:r,fetchResult:"success",fetchResponse:s})];case 10:n.sent(),i(Error(E)),n.label=11;case 11:return[3,14];case 12:return u=n.sent(),[4,d.log.error("Second attempt failed to load elements script failed, fetch network error.",{logType:"elementsScriptFetchError",logOrigin:"loadScript",retryCount:r,fetchResult:"error",fetchError:u})];case 13:return n.sent(),i(Error(E)),[3,14];case 14:return i((null==t?void 0:t.error)||(null==t?void 0:t.message)||Error(E)),[2]}})}),function(e){return l.apply(this,arguments)}))})},T=function(e){(null==e?void 0:e._devMode)&&(null==e?void 0:e.customDomain)&&console.warn("Dev mode and domain whitelabeling are both enabled - dev mode takes precedence.");var t=(null==e?void 0:e._devMode)?"https://js.flock-dev.com":(null==e?void 0:e.customDomain)?w(e.customDomain):"https://js.basistheory.com",r="".concat(t,"/web-elements/").concat("2.2.0"),n="".concat(r,"/client/index.js"),o="".concat(r,"/hosted-elements/");return(null==e?void 0:e.customDomain)&&!e._devMode,{origin:t,clientJsUrl:n,hostedElementsBaseUrl:o}},S=(s=t(function(e,i){var l,c,a,s,u,f,p,h,m;return n(this,function(v){switch(v.label){case 0:if(!e||0===e.length)throw Error("API key is required");return c=(l=T(i)).origin,a=l.clientJsUrl,s=l.hostedElementsBaseUrl,d.setBaseUrl(c),d.disableTelemetry(!!(null==i?void 0:i.disableTelemetry)),[4,(o||(o=new Promise(function(e,o){if(("undefined"==typeof window?"undefined":r(window))!=="object"){t(function(){return n(this,function(e){switch(e.label){case 0:return[4,d.log.warn(g,{logType:"elementsNonDomError",logOrigin:"loadElements"})];case 1:return e.sent(),o(Error(g)),[2]}})})();return}if(window.BasisTheoryElements){e(window.BasisTheoryElements);return}O(new URL(a).toString().replace(RegExp("\\/$","u"),""),0).then(e).catch(function(e){o(e)})})),o)];case 1:return[2,v.sent().init(e,s,!1,null===(u=null==i?void 0:i.useSameOriginApi)||void 0===u||u,null!==(f=null==i?void 0:i.disableTelemetry)&&void 0!==f&&f,null!==(p=null==i?void 0:i.debug)&&void 0!==p&&p,null!==(h=null==i?void 0:i.useUat)&&void 0!==h&&h,null!==(m=null==i?void 0:i.useNetworkCheck)&&void 0!==m&&m,(null==i?void 0:i.customDomain)?c:void 0)]}})}),function(e,t){return s.apply(this,arguments)}),k=((u=k||{}).DECIMAL="decimal",u.EMAIL="email",u.NONE="none",u.NUMERIC="numeric",u.SEARCH="search",u.TEL="tel",u.TEXT="text",u.URL="url",u);v(Error),v(Error),"undefined"!=typeof window&&document.currentScript&&!window.basistheory&&(window.basistheory=S)}();
@@ -82,6 +82,34 @@ const $fe2ec396f58502a3$export$af88d00dbe7f521 = (()=>{
82
82
  })();
83
83
 
84
84
 
85
+ class $3c527b4ad66b1eeb$export$925a29a6f046f0b5 extends Error {
86
+ constructor(message, details, /**
87
+ * @deprecated use {@link details}
88
+ */ validation){
89
+ super(message), this.details = details, this.validation = validation;
90
+ this.name = 'BasisTheoryValidationError';
91
+ Object.setPrototypeOf(this, $3c527b4ad66b1eeb$export$925a29a6f046f0b5.prototype);
92
+ }
93
+ }
94
+
95
+
96
+ const $bf863f47081878c5$export$8ec0597b01ce7a1a = (domain)=>{
97
+ if (typeof domain !== 'string' || !domain.trim()) throw new Error('Custom domain must be a non-empty string.');
98
+ let url;
99
+ try {
100
+ url = new URL(domain.toLowerCase().startsWith('http') ? domain : `https://${domain}`);
101
+ } catch {
102
+ throw new (0, $3c527b4ad66b1eeb$export$925a29a6f046f0b5)(`Invalid custom domain: "${domain}"`, {});
103
+ }
104
+ if (url.protocol !== 'https:') throw new (0, $3c527b4ad66b1eeb$export$925a29a6f046f0b5)(`Custom domain must use HTTPS (got "${url.protocol}")`, {});
105
+ if (url.pathname !== '/' || url.search || url.hash) throw new (0, $3c527b4ad66b1eeb$export$925a29a6f046f0b5)(`Custom domain must not include path, query, or hash (got "${url.href}")`, {});
106
+ if (url.port) throw new (0, $3c527b4ad66b1eeb$export$925a29a6f046f0b5)(`Custom domain must not include a port (got ":${url.port}")`, {});
107
+ const hostRegex = /^(?=.{1,253}$)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}$/;
108
+ if (!hostRegex.test(url.hostname)) throw new (0, $3c527b4ad66b1eeb$export$925a29a6f046f0b5)(`Invalid hostname: "${url.hostname}"`, {});
109
+ return url.origin;
110
+ };
111
+
112
+
85
113
  const $426651baf7085210$export$74dcf80d122cf64e = (url)=>{
86
114
  const existingScript = document.querySelector(`script[src^="${url}"]`);
87
115
  if (existingScript) return existingScript;
@@ -324,21 +352,38 @@ const $5dbc1ef1648671b0$export$9c5c779c8690dca6 = null;
324
352
 
325
353
 
326
354
  // Auto-generated version file
327
- const $eef42ce81412d9ae$export$83d89fbfd8236492 = '2.0.0';
328
-
329
-
330
- const $316c9c8f85cead13$var$TEST_ENV = 'js.flock-dev.com';
331
- const $316c9c8f85cead13$var$DEFAULT_ENV = 'js.basistheory.com';
355
+ const $eef42ce81412d9ae$export$83d89fbfd8236492 = '2.2.0';
356
+
357
+
358
+ const $316c9c8f85cead13$var$TEST_ORIGIN = 'https://js.flock-dev.com';
359
+ const $316c9c8f85cead13$var$DEFAULT_ORIGIN = 'https://js.basistheory.com';
360
+ const $316c9c8f85cead13$var$resolveUrls = (options)=>{
361
+ if (options?._devMode && options?.customDomain) console.warn('Dev mode and domain whitelabeling are both enabled - dev mode takes precedence.');
362
+ let origin;
363
+ if (options?._devMode) origin = $316c9c8f85cead13$var$TEST_ORIGIN;
364
+ else if (options?.customDomain) origin = (0, $bf863f47081878c5$export$8ec0597b01ce7a1a)(options.customDomain);
365
+ else origin = $316c9c8f85cead13$var$DEFAULT_ORIGIN;
366
+ const base = `${origin}/web-elements/${(0, $eef42ce81412d9ae$export$83d89fbfd8236492)}`;
367
+ const client = `${base}/client/index.js`;
368
+ const hosted = `${base}/hosted-elements/`;
369
+ if (options?.customDomain && !options._devMode) return {
370
+ origin: origin,
371
+ clientJsUrl: client,
372
+ hostedElementsBaseUrl: hosted
373
+ };
374
+ return {
375
+ origin: origin,
376
+ clientJsUrl: (0, $5dbc1ef1648671b0$export$67c92c3b857d033a) ?? client,
377
+ hostedElementsBaseUrl: (0, $5dbc1ef1648671b0$export$9c5c779c8690dca6) ?? hosted
378
+ };
379
+ };
332
380
  const $316c9c8f85cead13$export$cbe2892587230861 = async (apiKey, options)=>{
333
381
  if (!apiKey || apiKey.length === 0) throw new Error('API key is required');
334
- const baseUrl = options?._devMode ? $316c9c8f85cead13$var$TEST_ENV : $316c9c8f85cead13$var$DEFAULT_ENV;
335
- (0, $fe2ec396f58502a3$export$af88d00dbe7f521).setBaseUrl(baseUrl);
382
+ const { origin: origin, clientJsUrl: clientJsUrl, hostedElementsBaseUrl: hostedElementsBaseUrl } = $316c9c8f85cead13$var$resolveUrls(options);
383
+ (0, $fe2ec396f58502a3$export$af88d00dbe7f521).setBaseUrl(origin);
336
384
  (0, $fe2ec396f58502a3$export$af88d00dbe7f521).disableTelemetry(Boolean(options?.disableTelemetry));
337
- // Use build-time generated URLs if available, otherwise fall back to version-based URLs
338
- const clientJsUrl = (0, $5dbc1ef1648671b0$export$67c92c3b857d033a) || `https://${baseUrl}/web-elements/${0, $eef42ce81412d9ae$export$83d89fbfd8236492}/client/index.js`;
339
- const hostedElementsBaseUrl = (0, $5dbc1ef1648671b0$export$9c5c779c8690dca6) || `https://${baseUrl}/web-elements/${0, $eef42ce81412d9ae$export$83d89fbfd8236492}/hosted-elements/`;
340
385
  const elements = await (0, $6477b722f43d24f2$export$2b0a6e5a1c78018f)(clientJsUrl);
341
- return elements.init(apiKey, hostedElementsBaseUrl, false, options?.useSameOriginApi ?? true, options?.disableTelemetry ?? false, options?.debug ?? false, options?.useUat ?? false, options?.useNetworkCheck ?? false);
386
+ return elements.init(apiKey, hostedElementsBaseUrl, false, options?.useSameOriginApi ?? true, options?.disableTelemetry ?? false, options?.debug ?? false, options?.useUat ?? false, options?.useNetworkCheck ?? false, options?.customDomain ? origin : undefined);
342
387
  };
343
388
 
344
389
 
@@ -843,6 +888,7 @@ const $2ac94b510629d419$export$8141e4f9a897abe6 = [
843
888
  'cardExpirationDate',
844
889
  'cardNumber',
845
890
  'cardVerificationCode',
891
+ 'copyButton',
846
892
  'data',
847
893
  'text'
848
894
  ];
@@ -884,11 +930,14 @@ var $e6da8ffa145ef6b4$exports = {};
884
930
  var $79ee1b48c572ec2c$exports = {};
885
931
 
886
932
  $parcel$export($79ee1b48c572ec2c$exports, "SAFE_CSS_PROPERTIES", () => $79ee1b48c572ec2c$export$e2bf52fc7723ec89);
933
+ $parcel$export($79ee1b48c572ec2c$exports, "BUTTON_CSS_PROPERTIES", () => $79ee1b48c572ec2c$export$93133f730762aee4);
887
934
  $parcel$export($79ee1b48c572ec2c$exports, "SAFE_CSS_PROPERTIES_ALTERNATES", () => $79ee1b48c572ec2c$export$e22a44f86989e3f4);
888
935
  $parcel$export($79ee1b48c572ec2c$exports, "SAFE_CSS_PROPERTIES_WITH_ALTERNATES", () => $79ee1b48c572ec2c$export$b5b27feb4cf29129);
889
936
  $parcel$export($79ee1b48c572ec2c$exports, "CARD_ELEMENT_STYLE_VARIANT_SELECTORS", () => $79ee1b48c572ec2c$export$fc323aec0bf844b);
937
+ $parcel$export($79ee1b48c572ec2c$exports, "BUTTON_ELEMENT_STYLE_VARIANT_SELECTORS", () => $79ee1b48c572ec2c$export$8cce4e63ba22bae);
890
938
  $parcel$export($79ee1b48c572ec2c$exports, "CARD_ELEMENT_STYLE_VARIANTS", () => $79ee1b48c572ec2c$export$a15fff7fac404fd9);
891
939
  $parcel$export($79ee1b48c572ec2c$exports, "CARD_ELEMENT_STYLE_FONTS_ATTR", () => $79ee1b48c572ec2c$export$c3a88e1ff160bfd6);
940
+ $parcel$export($79ee1b48c572ec2c$exports, "BUTTON_ELEMENT_STYLE_VARIANTS", () => $79ee1b48c572ec2c$export$612b2fbe2f6ee5db);
892
941
  const $79ee1b48c572ec2c$export$e2bf52fc7723ec89 = [
893
942
  'backgroundColor',
894
943
  'color',
@@ -898,14 +947,53 @@ const $79ee1b48c572ec2c$export$e2bf52fc7723ec89 = [
898
947
  'fontStyle',
899
948
  'fontVariant',
900
949
  'fontWeight',
901
- 'lineHeight',
902
950
  'letterSpacing',
903
- 'textAlign',
951
+ 'lineHeight',
904
952
  'padding',
953
+ 'textAlign',
905
954
  'textDecoration',
906
955
  'textShadow',
907
956
  'textTransform'
908
957
  ];
958
+ // Button-specific CSS properties for styling interactive buttons
959
+ const $79ee1b48c572ec2c$export$93133f730762aee4 = [
960
+ 'alignItems',
961
+ 'backgroundColor',
962
+ 'border',
963
+ 'borderBottom',
964
+ 'borderColor',
965
+ 'borderLeft',
966
+ 'borderRadius',
967
+ 'borderRight',
968
+ 'borderStyle',
969
+ 'borderTop',
970
+ 'borderWidth',
971
+ 'boxShadow',
972
+ 'color',
973
+ 'cursor',
974
+ 'display',
975
+ 'fontFamily',
976
+ 'fontSize',
977
+ 'fontWeight',
978
+ 'gap',
979
+ 'height',
980
+ 'justifyContent',
981
+ 'letterSpacing',
982
+ 'lineHeight',
983
+ 'margin',
984
+ 'maxHeight',
985
+ 'maxWidth',
986
+ 'minHeight',
987
+ 'minWidth',
988
+ 'opacity',
989
+ 'outline',
990
+ 'padding',
991
+ 'textAlign',
992
+ 'textTransform',
993
+ 'transform',
994
+ 'transition',
995
+ 'width'
996
+ ];
909
997
  const $79ee1b48c572ec2c$export$e22a44f86989e3f4 = {
910
998
  fontSmooth: [
911
999
  '-webkit-font-smoothing',
@@ -921,6 +1009,11 @@ const $79ee1b48c572ec2c$export$fc323aec0bf844b = [
921
1009
  '::selection',
922
1010
  ':disabled'
923
1011
  ];
1012
+ const $79ee1b48c572ec2c$export$8cce4e63ba22bae = [
1013
+ ':hover',
1014
+ ':focus',
1015
+ ':active'
1016
+ ];
924
1017
  const $79ee1b48c572ec2c$export$a15fff7fac404fd9 = [
925
1018
  'base',
926
1019
  'container',
@@ -929,6 +1022,10 @@ const $79ee1b48c572ec2c$export$a15fff7fac404fd9 = [
929
1022
  'empty'
930
1023
  ];
931
1024
  const $79ee1b48c572ec2c$export$c3a88e1ff160bfd6 = 'fonts';
1025
+ const $79ee1b48c572ec2c$export$612b2fbe2f6ee5db = [
1026
+ 'base',
1027
+ 'container'
1028
+ ];
932
1029
 
933
1030
 
934
1031
  $parcel$exportWildcard($94e2e5607fad631e$exports, $eb72fa80cc6cce99$exports);
@@ -1028,16 +1125,6 @@ class $d4608c0b4e5d8cb4$export$5a9a4feb38dee587 extends Error {
1028
1125
  }
1029
1126
 
1030
1127
 
1031
- class $3c527b4ad66b1eeb$export$925a29a6f046f0b5 extends Error {
1032
- constructor(message, details, /**
1033
- * @deprecated use {@link details}
1034
- */ validation){
1035
- super(message), this.details = details, this.validation = validation;
1036
- this.name = 'BasisTheoryValidationError';
1037
- Object.setPrototypeOf(this, $3c527b4ad66b1eeb$export$925a29a6f046f0b5.prototype);
1038
- }
1039
- }
1040
-
1041
1128
 
1042
1129
  class $815b13df3d182116$export$83d862a6bd4a93c5 extends Error {
1043
1130
  constructor(message, status, data, headers){
@@ -82,6 +82,34 @@ const $367e4a81566d966b$export$af88d00dbe7f521 = (()=>{
82
82
  })();
83
83
 
84
84
 
85
+ class $16b549d313b97bf4$export$925a29a6f046f0b5 extends Error {
86
+ constructor(message, details, /**
87
+ * @deprecated use {@link details}
88
+ */ validation){
89
+ super(message), this.details = details, this.validation = validation;
90
+ this.name = 'BasisTheoryValidationError';
91
+ Object.setPrototypeOf(this, $16b549d313b97bf4$export$925a29a6f046f0b5.prototype);
92
+ }
93
+ }
94
+
95
+
96
+ const $c03aa13093e09dc3$export$8ec0597b01ce7a1a = (domain)=>{
97
+ if (typeof domain !== 'string' || !domain.trim()) throw new Error('Custom domain must be a non-empty string.');
98
+ let url;
99
+ try {
100
+ url = new URL(domain.toLowerCase().startsWith('http') ? domain : `https://${domain}`);
101
+ } catch {
102
+ throw new (0, $16b549d313b97bf4$export$925a29a6f046f0b5)(`Invalid custom domain: "${domain}"`, {});
103
+ }
104
+ if (url.protocol !== 'https:') throw new (0, $16b549d313b97bf4$export$925a29a6f046f0b5)(`Custom domain must use HTTPS (got "${url.protocol}")`, {});
105
+ if (url.pathname !== '/' || url.search || url.hash) throw new (0, $16b549d313b97bf4$export$925a29a6f046f0b5)(`Custom domain must not include path, query, or hash (got "${url.href}")`, {});
106
+ if (url.port) throw new (0, $16b549d313b97bf4$export$925a29a6f046f0b5)(`Custom domain must not include a port (got ":${url.port}")`, {});
107
+ const hostRegex = /^(?=.{1,253}$)([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,63}$/;
108
+ if (!hostRegex.test(url.hostname)) throw new (0, $16b549d313b97bf4$export$925a29a6f046f0b5)(`Invalid hostname: "${url.hostname}"`, {});
109
+ return url.origin;
110
+ };
111
+
112
+
85
113
  const $0da125a57a8274fc$export$74dcf80d122cf64e = (url)=>{
86
114
  const existingScript = document.querySelector(`script[src^="${url}"]`);
87
115
  if (existingScript) return existingScript;
@@ -324,21 +352,38 @@ const $c9bd4b894cc03378$export$9c5c779c8690dca6 = null;
324
352
 
325
353
 
326
354
  // Auto-generated version file
327
- const $6a2f0bfcc5905f21$export$83d89fbfd8236492 = '2.0.0';
328
-
329
-
330
- const $65168f0452925da7$var$TEST_ENV = 'js.flock-dev.com';
331
- const $65168f0452925da7$var$DEFAULT_ENV = 'js.basistheory.com';
355
+ const $6a2f0bfcc5905f21$export$83d89fbfd8236492 = '2.2.0';
356
+
357
+
358
+ const $65168f0452925da7$var$TEST_ORIGIN = 'https://js.flock-dev.com';
359
+ const $65168f0452925da7$var$DEFAULT_ORIGIN = 'https://js.basistheory.com';
360
+ const $65168f0452925da7$var$resolveUrls = (options)=>{
361
+ if (options?._devMode && options?.customDomain) console.warn('Dev mode and domain whitelabeling are both enabled - dev mode takes precedence.');
362
+ let origin;
363
+ if (options?._devMode) origin = $65168f0452925da7$var$TEST_ORIGIN;
364
+ else if (options?.customDomain) origin = (0, $c03aa13093e09dc3$export$8ec0597b01ce7a1a)(options.customDomain);
365
+ else origin = $65168f0452925da7$var$DEFAULT_ORIGIN;
366
+ const base = `${origin}/web-elements/${(0, $6a2f0bfcc5905f21$export$83d89fbfd8236492)}`;
367
+ const client = `${base}/client/index.js`;
368
+ const hosted = `${base}/hosted-elements/`;
369
+ if (options?.customDomain && !options._devMode) return {
370
+ origin: origin,
371
+ clientJsUrl: client,
372
+ hostedElementsBaseUrl: hosted
373
+ };
374
+ return {
375
+ origin: origin,
376
+ clientJsUrl: (0, $c9bd4b894cc03378$export$67c92c3b857d033a) ?? client,
377
+ hostedElementsBaseUrl: (0, $c9bd4b894cc03378$export$9c5c779c8690dca6) ?? hosted
378
+ };
379
+ };
332
380
  const $65168f0452925da7$export$cbe2892587230861 = async (apiKey, options)=>{
333
381
  if (!apiKey || apiKey.length === 0) throw new Error('API key is required');
334
- const baseUrl = options?._devMode ? $65168f0452925da7$var$TEST_ENV : $65168f0452925da7$var$DEFAULT_ENV;
335
- (0, $367e4a81566d966b$export$af88d00dbe7f521).setBaseUrl(baseUrl);
382
+ const { origin: origin, clientJsUrl: clientJsUrl, hostedElementsBaseUrl: hostedElementsBaseUrl } = $65168f0452925da7$var$resolveUrls(options);
383
+ (0, $367e4a81566d966b$export$af88d00dbe7f521).setBaseUrl(origin);
336
384
  (0, $367e4a81566d966b$export$af88d00dbe7f521).disableTelemetry(Boolean(options?.disableTelemetry));
337
- // Use build-time generated URLs if available, otherwise fall back to version-based URLs
338
- const clientJsUrl = (0, $c9bd4b894cc03378$export$67c92c3b857d033a) || `https://${baseUrl}/web-elements/${0, $6a2f0bfcc5905f21$export$83d89fbfd8236492}/client/index.js`;
339
- const hostedElementsBaseUrl = (0, $c9bd4b894cc03378$export$9c5c779c8690dca6) || `https://${baseUrl}/web-elements/${0, $6a2f0bfcc5905f21$export$83d89fbfd8236492}/hosted-elements/`;
340
385
  const elements = await (0, $2cc07a9862fd14af$export$2b0a6e5a1c78018f)(clientJsUrl);
341
- return elements.init(apiKey, hostedElementsBaseUrl, false, options?.useSameOriginApi ?? true, options?.disableTelemetry ?? false, options?.debug ?? false, options?.useUat ?? false, options?.useNetworkCheck ?? false);
386
+ return elements.init(apiKey, hostedElementsBaseUrl, false, options?.useSameOriginApi ?? true, options?.disableTelemetry ?? false, options?.debug ?? false, options?.useUat ?? false, options?.useNetworkCheck ?? false, options?.customDomain ? origin : undefined);
342
387
  };
343
388
 
344
389
 
@@ -843,6 +888,7 @@ const $0b7f2ce91f71c8fb$export$8141e4f9a897abe6 = [
843
888
  'cardExpirationDate',
844
889
  'cardNumber',
845
890
  'cardVerificationCode',
891
+ 'copyButton',
846
892
  'data',
847
893
  'text'
848
894
  ];
@@ -884,11 +930,14 @@ var $5c3fd4ec5ab25a5b$exports = {};
884
930
  var $ce70703c3ce2f3a0$exports = {};
885
931
 
886
932
  $parcel$export($ce70703c3ce2f3a0$exports, "SAFE_CSS_PROPERTIES", () => $ce70703c3ce2f3a0$export$e2bf52fc7723ec89);
933
+ $parcel$export($ce70703c3ce2f3a0$exports, "BUTTON_CSS_PROPERTIES", () => $ce70703c3ce2f3a0$export$93133f730762aee4);
887
934
  $parcel$export($ce70703c3ce2f3a0$exports, "SAFE_CSS_PROPERTIES_ALTERNATES", () => $ce70703c3ce2f3a0$export$e22a44f86989e3f4);
888
935
  $parcel$export($ce70703c3ce2f3a0$exports, "SAFE_CSS_PROPERTIES_WITH_ALTERNATES", () => $ce70703c3ce2f3a0$export$b5b27feb4cf29129);
889
936
  $parcel$export($ce70703c3ce2f3a0$exports, "CARD_ELEMENT_STYLE_VARIANT_SELECTORS", () => $ce70703c3ce2f3a0$export$fc323aec0bf844b);
937
+ $parcel$export($ce70703c3ce2f3a0$exports, "BUTTON_ELEMENT_STYLE_VARIANT_SELECTORS", () => $ce70703c3ce2f3a0$export$8cce4e63ba22bae);
890
938
  $parcel$export($ce70703c3ce2f3a0$exports, "CARD_ELEMENT_STYLE_VARIANTS", () => $ce70703c3ce2f3a0$export$a15fff7fac404fd9);
891
939
  $parcel$export($ce70703c3ce2f3a0$exports, "CARD_ELEMENT_STYLE_FONTS_ATTR", () => $ce70703c3ce2f3a0$export$c3a88e1ff160bfd6);
940
+ $parcel$export($ce70703c3ce2f3a0$exports, "BUTTON_ELEMENT_STYLE_VARIANTS", () => $ce70703c3ce2f3a0$export$612b2fbe2f6ee5db);
892
941
  const $ce70703c3ce2f3a0$export$e2bf52fc7723ec89 = [
893
942
  'backgroundColor',
894
943
  'color',
@@ -898,14 +947,53 @@ const $ce70703c3ce2f3a0$export$e2bf52fc7723ec89 = [
898
947
  'fontStyle',
899
948
  'fontVariant',
900
949
  'fontWeight',
901
- 'lineHeight',
902
950
  'letterSpacing',
903
- 'textAlign',
951
+ 'lineHeight',
904
952
  'padding',
953
+ 'textAlign',
905
954
  'textDecoration',
906
955
  'textShadow',
907
956
  'textTransform'
908
957
  ];
958
+ // Button-specific CSS properties for styling interactive buttons
959
+ const $ce70703c3ce2f3a0$export$93133f730762aee4 = [
960
+ 'alignItems',
961
+ 'backgroundColor',
962
+ 'border',
963
+ 'borderBottom',
964
+ 'borderColor',
965
+ 'borderLeft',
966
+ 'borderRadius',
967
+ 'borderRight',
968
+ 'borderStyle',
969
+ 'borderTop',
970
+ 'borderWidth',
971
+ 'boxShadow',
972
+ 'color',
973
+ 'cursor',
974
+ 'display',
975
+ 'fontFamily',
976
+ 'fontSize',
977
+ 'fontWeight',
978
+ 'gap',
979
+ 'height',
980
+ 'justifyContent',
981
+ 'letterSpacing',
982
+ 'lineHeight',
983
+ 'margin',
984
+ 'maxHeight',
985
+ 'maxWidth',
986
+ 'minHeight',
987
+ 'minWidth',
988
+ 'opacity',
989
+ 'outline',
990
+ 'padding',
991
+ 'textAlign',
992
+ 'textTransform',
993
+ 'transform',
994
+ 'transition',
995
+ 'width'
996
+ ];
909
997
  const $ce70703c3ce2f3a0$export$e22a44f86989e3f4 = {
910
998
  fontSmooth: [
911
999
  '-webkit-font-smoothing',
@@ -921,6 +1009,11 @@ const $ce70703c3ce2f3a0$export$fc323aec0bf844b = [
921
1009
  '::selection',
922
1010
  ':disabled'
923
1011
  ];
1012
+ const $ce70703c3ce2f3a0$export$8cce4e63ba22bae = [
1013
+ ':hover',
1014
+ ':focus',
1015
+ ':active'
1016
+ ];
924
1017
  const $ce70703c3ce2f3a0$export$a15fff7fac404fd9 = [
925
1018
  'base',
926
1019
  'container',
@@ -929,6 +1022,10 @@ const $ce70703c3ce2f3a0$export$a15fff7fac404fd9 = [
929
1022
  'empty'
930
1023
  ];
931
1024
  const $ce70703c3ce2f3a0$export$c3a88e1ff160bfd6 = 'fonts';
1025
+ const $ce70703c3ce2f3a0$export$612b2fbe2f6ee5db = [
1026
+ 'base',
1027
+ 'container'
1028
+ ];
932
1029
 
933
1030
 
934
1031
  $parcel$exportWildcard($8142f8fc8bbedd0b$exports, $6011935a2a75da1d$exports);
@@ -1028,16 +1125,6 @@ class $cc8dceaa5ea02f81$export$5a9a4feb38dee587 extends Error {
1028
1125
  }
1029
1126
 
1030
1127
 
1031
- class $16b549d313b97bf4$export$925a29a6f046f0b5 extends Error {
1032
- constructor(message, details, /**
1033
- * @deprecated use {@link details}
1034
- */ validation){
1035
- super(message), this.details = details, this.validation = validation;
1036
- this.name = 'BasisTheoryValidationError';
1037
- Object.setPrototypeOf(this, $16b549d313b97bf4$export$925a29a6f046f0b5.prototype);
1038
- }
1039
- }
1040
-
1041
1128
 
1042
1129
  class $3753a300b9392464$export$83d862a6bd4a93c5 extends Error {
1043
1130
  constructor(message, status, data, headers){
@@ -1058,4 +1145,4 @@ class $3753a300b9392464$export$83d862a6bd4a93c5 extends Error {
1058
1145
  */ if (typeof window !== 'undefined' && document.currentScript && !window.basistheory) window.basistheory = (0, $65168f0452925da7$export$cbe2892587230861);
1059
1146
 
1060
1147
 
1061
- export {$65168f0452925da7$export$cbe2892587230861 as basistheory, $2e9038c0999bba06$export$dea6ebbc92df4fa3 as AUTOCOMPLETE_VALUES, $2e9038c0999bba06$export$51be6d94c4fcf45 as CARD_BRANDS, $2e9038c0999bba06$export$829c91d8f039f695 as CARD_ICON_POSITIONS, $6011935a2a75da1d$export$1748c2651c2c6e25 as VISA, $6011935a2a75da1d$export$1c604828de4cf9cf as MASTERCARD, $6011935a2a75da1d$export$67c5e4e99638ee87 as AMERICAN_EXPRESS, $6011935a2a75da1d$export$fcf88132c9601d5d as DINERS_CLUB, $6011935a2a75da1d$export$27b2e48e28163360 as DISCOVER, $6011935a2a75da1d$export$bf30f1ca7b266454 as JCB, $6011935a2a75da1d$export$8ed8e9ea6bbca19f as UNION_PAY, $6011935a2a75da1d$export$f08651c87c943e8 as MAESTRO, $6011935a2a75da1d$export$c4b8f606caaecf2c as ELO, $6011935a2a75da1d$export$58f9d4150439d06e as MIR, $6011935a2a75da1d$export$8f50e2757841117b as HIPER, $6011935a2a75da1d$export$adb072c9761d9e59 as HIPERCARD, $6011935a2a75da1d$export$35b475386df8059d as DEFAULT_CARD_TYPES, $a7c0ed47a726bc77$export$8dde18ea9019c560 as CoBadgedSupport, $0b7f2ce91f71c8fb$export$8141e4f9a897abe6 as ELEMENTS_TYPES, $ce70703c3ce2f3a0$export$e2bf52fc7723ec89 as SAFE_CSS_PROPERTIES, $ce70703c3ce2f3a0$export$e22a44f86989e3f4 as SAFE_CSS_PROPERTIES_ALTERNATES, $ce70703c3ce2f3a0$export$b5b27feb4cf29129 as SAFE_CSS_PROPERTIES_WITH_ALTERNATES, $ce70703c3ce2f3a0$export$fc323aec0bf844b as CARD_ELEMENT_STYLE_VARIANT_SELECTORS, $ce70703c3ce2f3a0$export$a15fff7fac404fd9 as CARD_ELEMENT_STYLE_VARIANTS, $ce70703c3ce2f3a0$export$c3a88e1ff160bfd6 as CARD_ELEMENT_STYLE_FONTS_ATTR, $88bdfff2114854bc$export$f9a8af5874660c13 as DATA_CLASSIFICATIONS, $88bdfff2114854bc$export$7ea51ced9080f153 as DATA_IMPACT_LEVELS, $88bdfff2114854bc$export$23716d8c8b579500 as DATA_RESTRICTION_POLICIES, $cc8dceaa5ea02f81$export$5a9a4feb38dee587 as BasisTheoryApiError, $16b549d313b97bf4$export$925a29a6f046f0b5 as BasisTheoryValidationError, $3753a300b9392464$export$83d862a6bd4a93c5 as HttpClientError};
1148
+ export {$65168f0452925da7$export$cbe2892587230861 as basistheory, $2e9038c0999bba06$export$dea6ebbc92df4fa3 as AUTOCOMPLETE_VALUES, $2e9038c0999bba06$export$51be6d94c4fcf45 as CARD_BRANDS, $2e9038c0999bba06$export$829c91d8f039f695 as CARD_ICON_POSITIONS, $6011935a2a75da1d$export$1748c2651c2c6e25 as VISA, $6011935a2a75da1d$export$1c604828de4cf9cf as MASTERCARD, $6011935a2a75da1d$export$67c5e4e99638ee87 as AMERICAN_EXPRESS, $6011935a2a75da1d$export$fcf88132c9601d5d as DINERS_CLUB, $6011935a2a75da1d$export$27b2e48e28163360 as DISCOVER, $6011935a2a75da1d$export$bf30f1ca7b266454 as JCB, $6011935a2a75da1d$export$8ed8e9ea6bbca19f as UNION_PAY, $6011935a2a75da1d$export$f08651c87c943e8 as MAESTRO, $6011935a2a75da1d$export$c4b8f606caaecf2c as ELO, $6011935a2a75da1d$export$58f9d4150439d06e as MIR, $6011935a2a75da1d$export$8f50e2757841117b as HIPER, $6011935a2a75da1d$export$adb072c9761d9e59 as HIPERCARD, $6011935a2a75da1d$export$35b475386df8059d as DEFAULT_CARD_TYPES, $a7c0ed47a726bc77$export$8dde18ea9019c560 as CoBadgedSupport, $0b7f2ce91f71c8fb$export$8141e4f9a897abe6 as ELEMENTS_TYPES, $ce70703c3ce2f3a0$export$e2bf52fc7723ec89 as SAFE_CSS_PROPERTIES, $ce70703c3ce2f3a0$export$93133f730762aee4 as BUTTON_CSS_PROPERTIES, $ce70703c3ce2f3a0$export$e22a44f86989e3f4 as SAFE_CSS_PROPERTIES_ALTERNATES, $ce70703c3ce2f3a0$export$b5b27feb4cf29129 as SAFE_CSS_PROPERTIES_WITH_ALTERNATES, $ce70703c3ce2f3a0$export$fc323aec0bf844b as CARD_ELEMENT_STYLE_VARIANT_SELECTORS, $ce70703c3ce2f3a0$export$8cce4e63ba22bae as BUTTON_ELEMENT_STYLE_VARIANT_SELECTORS, $ce70703c3ce2f3a0$export$a15fff7fac404fd9 as CARD_ELEMENT_STYLE_VARIANTS, $ce70703c3ce2f3a0$export$c3a88e1ff160bfd6 as CARD_ELEMENT_STYLE_FONTS_ATTR, $ce70703c3ce2f3a0$export$612b2fbe2f6ee5db as BUTTON_ELEMENT_STYLE_VARIANTS, $88bdfff2114854bc$export$f9a8af5874660c13 as DATA_CLASSIFICATIONS, $88bdfff2114854bc$export$7ea51ced9080f153 as DATA_IMPACT_LEVELS, $88bdfff2114854bc$export$23716d8c8b579500 as DATA_RESTRICTION_POLICIES, $cc8dceaa5ea02f81$export$5a9a4feb38dee587 as BasisTheoryApiError, $16b549d313b97bf4$export$925a29a6f046f0b5 as BasisTheoryValidationError, $3753a300b9392464$export$83d862a6bd4a93c5 as HttpClientError};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/web-elements",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "repository": "https://github.com/basis-theory/web-elements",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -137,7 +137,7 @@ export type DataElementReference = {
137
137
  elementId: string;
138
138
  path: string;
139
139
  };
140
- export type EventType = 'ready' | 'change' | 'focus' | 'blur' | 'keydown';
140
+ export type EventType = 'ready' | 'change' | 'focus' | 'blur' | 'keydown' | 'click';
141
141
  export interface BaseEvent<T extends EventType> {
142
142
  type: T;
143
143
  }
@@ -159,12 +159,14 @@ export type InputBlurEvent = BaseEvent<'blur'> & Targeted;
159
159
  export type InputKeydownEvent = BaseEvent<'keydown'> & Targeted & {
160
160
  key: ListenableKey;
161
161
  } & Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'shiftKey' | 'metaKey'>;
162
+ export type ClickEvent = BaseEvent<'click'> & Targeted;
162
163
  export type BaseElementEvents = ReadyEvent | InputFocusEvent | InputBlurEvent | InputKeydownEvent;
163
164
  export type TextElementEvents = BaseElementEvents | ChangeEvent;
164
165
  export type CardElementEvents = BaseElementEvents | CardChangeEvent;
165
166
  export type CardNumberElementEvents = BaseElementEvents | CardChangeEvent;
166
167
  export type CardExpirationDateElementEvents = BaseElementEvents | ChangeEvent;
167
168
  export type CardVerificationCodeElementEvents = BaseElementEvents | ChangeEvent;
169
+ export type CopyButtonElementEvents = BaseElementEvents | ClickEvent;
168
170
  /**
169
171
  * Utility type that helps find a Union type based on a `type` property
170
172
  */
@@ -175,14 +177,20 @@ export type ElementEventListener<Events, Type> = (event: FindByType<Events, Type
175
177
  export interface Subscription {
176
178
  unsubscribe(): void;
177
179
  }
178
- export const SAFE_CSS_PROPERTIES: readonly ["backgroundColor", "color", "fontFamily", "fontSize", "fontSmooth", "fontStyle", "fontVariant", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "padding", "textDecoration", "textShadow", "textTransform"];
180
+ export const SAFE_CSS_PROPERTIES: readonly ["backgroundColor", "color", "fontFamily", "fontSize", "fontSmooth", "fontStyle", "fontVariant", "fontWeight", "letterSpacing", "lineHeight", "padding", "textAlign", "textDecoration", "textShadow", "textTransform"];
181
+ export const BUTTON_CSS_PROPERTIES: readonly ["alignItems", "backgroundColor", "border", "borderBottom", "borderColor", "borderLeft", "borderRadius", "borderRight", "borderStyle", "borderTop", "borderWidth", "boxShadow", "color", "cursor", "display", "fontFamily", "fontSize", "fontWeight", "gap", "height", "justifyContent", "letterSpacing", "lineHeight", "margin", "maxHeight", "maxWidth", "minHeight", "minWidth", "opacity", "outline", "padding", "textAlign", "textTransform", "transform", "transition", "width"];
179
182
  export type SafeCSSProperty = (typeof SAFE_CSS_PROPERTIES)[number];
183
+ export type ButtonCSSProperty = (typeof BUTTON_CSS_PROPERTIES)[number];
180
184
  export const SAFE_CSS_PROPERTIES_ALTERNATES: Partial<Record<SafeCSSProperty, string[]>>;
181
185
  export const SAFE_CSS_PROPERTIES_WITH_ALTERNATES: string[];
182
186
  export type SafeStyle = Pick<Properties, SafeCSSProperty>;
183
187
  export const CARD_ELEMENT_STYLE_VARIANT_SELECTORS: readonly [":hover", ":focus", ":read-only", "::placeholder", "::selection", ":disabled"];
188
+ export const BUTTON_ELEMENT_STYLE_VARIANT_SELECTORS: readonly [":hover", ":focus", ":active"];
184
189
  export type CardElementStyleVariantSelector = (typeof CARD_ELEMENT_STYLE_VARIANT_SELECTORS)[number];
190
+ export type ButtonElementStyleVariantSelector = (typeof BUTTON_ELEMENT_STYLE_VARIANT_SELECTORS)[number];
191
+ export type ButtonStyle = Pick<Properties, ButtonCSSProperty>;
185
192
  export type CardElementStyleVariantStyle = SafeStyle & Partial<Record<CardElementStyleVariantSelector, SafeStyle>>;
193
+ export type ButtonElementStyleVariantStyle = ButtonStyle & Partial<Record<ButtonElementStyleVariantSelector, ButtonStyle>>;
186
194
  export const CARD_ELEMENT_STYLE_VARIANTS: readonly ["base", "container", "complete", "invalid", "empty"];
187
195
  export const CARD_ELEMENT_STYLE_FONTS_ATTR: "fonts";
188
196
  export type CardElementStyleVariant = (typeof CARD_ELEMENT_STYLE_VARIANTS)[number];
@@ -191,16 +199,21 @@ type FontSource = string;
191
199
  export type FontSources = FontSource[];
192
200
  export type Fonts = Record<CardElementStyleFontAttr, FontSources>;
193
201
  export type CardElementStyle = Partial<Record<CardElementStyleVariant, CardElementStyleVariantStyle> & Fonts>;
194
- export type ElementStyle = CardElementStyle;
202
+ export const BUTTON_ELEMENT_STYLE_VARIANTS: readonly ["base", "container"];
203
+ export type ButtonElementStyleVariant = (typeof BUTTON_ELEMENT_STYLE_VARIANTS)[number];
204
+ export type ButtonElementStyle = Partial<Record<ButtonElementStyleVariant, ButtonElementStyleVariantStyle> & Fonts>;
205
+ export type CopyButtonElementStyle = ButtonElementStyle;
206
+ export type ElementStyle = CardElementStyle | CopyButtonElementStyle;
195
207
  export type CopyIconStyles = {
196
208
  size?: string;
197
209
  color?: string;
198
210
  successColor?: string;
199
211
  };
200
- export const ELEMENTS_TYPES: readonly ["card", "cardExpirationDate", "cardNumber", "cardVerificationCode", "data", "text"];
212
+ export const ELEMENTS_TYPES: readonly ["card", "cardExpirationDate", "cardNumber", "cardVerificationCode", "copyButton", "data", "text"];
201
213
  export type ElementType = (typeof ELEMENTS_TYPES)[number];
202
214
  export interface ElementInternalOptions {
203
215
  apiKey: string | undefined;
216
+ customDomain: string | undefined;
204
217
  baseUrl: string;
205
218
  type: ElementType;
206
219
  debug: boolean | undefined;
@@ -241,6 +254,7 @@ export interface SanitizedElementOptions {
241
254
  skipLuhnValidation?: boolean;
242
255
  style?: ElementStyle;
243
256
  targetId?: string;
257
+ text?: string;
244
258
  title?: string;
245
259
  transform?: [RegExp, string] | null;
246
260
  validateOnChange?: boolean;
@@ -307,6 +321,12 @@ export type CreateCardVerificationCodeElementOptions = CustomizableElementOption
307
321
  value?: string;
308
322
  };
309
323
  export type UpdateCardVerificationCodeElementOptions = Omit<CreateCardVerificationCodeElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
324
+ export type CreateCopyButtonElementOptions = Pick<ElementOptions, 'targetId' | 'title' | 'disabled'> & {
325
+ id?: string;
326
+ style?: CopyButtonElementStyle;
327
+ text?: string;
328
+ };
329
+ export type UpdateCopyButtonElementOptions = Omit<CreateCopyButtonElementOptions, 'targetId'>;
310
330
  export interface BinDetails {
311
331
  cardBrand?: string;
312
332
  type?: string;
@@ -620,6 +640,9 @@ export type ICardVerificationCodeElement = BaseElement<UpdateCardVerificationCod
620
640
  setValueRef(value: ICardVerificationCodeElement): void;
621
641
  setValue(value: DataElementReference): void;
622
642
  };
643
+ export type ICopyButtonElement = BaseElement<UpdateCopyButtonElementOptions, CopyButtonElementEvents> & {
644
+ setValueRef(value: ITextElement | ICardNumberElement | ICardExpirationDateElement | ICardVerificationCodeElement): void;
645
+ };
623
646
  export type ElementWrapper<T extends BaseElement<any, any> = BaseElement<any, any>> = {
624
647
  element: T;
625
648
  method?: string;
@@ -627,7 +650,7 @@ export type ElementWrapper<T extends BaseElement<any, any> = BaseElement<any, an
627
650
  format: string;
628
651
  };
629
652
  };
630
- export type ElementValue = ITextElement | ICardElement | ICardNumberElement | ICardExpirationDateElement | ICardVerificationCodeElement | ElementWrapper;
653
+ export type ElementValue = ITextElement | ICardElement | ICardNumberElement | ICardExpirationDateElement | ICardVerificationCodeElement | ICopyButtonElement | ElementWrapper;
631
654
  export interface BasisTheoryElements {
632
655
  tokens: Tokens;
633
656
  proxy: Proxy;
@@ -641,9 +664,10 @@ export interface BasisTheoryElements {
641
664
  createElement(type: 'cardNumber', options: CreateCardNumberElementOptions): ICardNumberElement;
642
665
  createElement(type: 'cardExpirationDate', options: CreateCardExpirationDateElementOptions): ICardExpirationDateElement;
643
666
  createElement(type: 'cardVerificationCode', options: CreateCardVerificationCodeElementOptions): ICardVerificationCodeElement;
667
+ createElement(type: 'copyButton', options: CreateCopyButtonElementOptions): ICopyButtonElement;
644
668
  }
645
669
  export interface BasisTheoryElementsInternal extends BasisTheoryElements {
646
- init: (apiKey: string | undefined, elementsBaseUrl: string, elementsUseNgApi: boolean | undefined, elementsUseSameOriginApi: boolean | undefined, disableTelemetry: boolean | undefined, debug: boolean | undefined, useUat: boolean | undefined, useNetworkCheck: boolean | undefined) => Promise<BasisTheoryElements>;
670
+ init: (apiKey: string | undefined, elementsBaseUrl: string, elementsUseNgApi: boolean | undefined, elementsUseSameOriginApi: boolean | undefined, disableTelemetry: boolean | undefined, debug: boolean | undefined, useUat: boolean | undefined, useNetworkCheck: boolean | undefined, customDomain: string | undefined) => Promise<BasisTheoryElements>;
647
671
  hasElement: (payload: unknown) => boolean;
648
672
  }
649
673
  declare global {
@@ -651,6 +675,18 @@ declare global {
651
675
  BasisTheoryElements?: BasisTheoryElementsInternal;
652
676
  }
653
677
  }
678
+ export class BasisTheoryValidationError<Details = Record<string, unknown>> extends Error {
679
+ readonly details: Details;
680
+ /**
681
+ * @deprecated use {@link details}
682
+ */
683
+ readonly validation?: FieldError[] | undefined;
684
+ constructor(message: string, details: Details,
685
+ /**
686
+ * @deprecated use {@link details}
687
+ */
688
+ validation?: FieldError[] | undefined);
689
+ }
654
690
  export interface BasisTheoryInitOptions {
655
691
  _devMode?: boolean;
656
692
  disableTelemetry?: boolean;
@@ -658,6 +694,7 @@ export interface BasisTheoryInitOptions {
658
694
  useUat?: boolean;
659
695
  debug?: boolean;
660
696
  useNetworkCheck?: boolean;
697
+ customDomain?: string;
661
698
  }
662
699
  export const basistheory: (apiKey: string, options?: BasisTheoryInitOptions) => Promise<BasisTheoryElements | undefined>;
663
700
  export class BasisTheoryApiError extends Error {
@@ -666,18 +703,6 @@ export class BasisTheoryApiError extends Error {
666
703
  readonly _debug?: Record<string, unknown> | undefined;
667
704
  constructor(message: string, status: number, data?: unknown | undefined, _debug?: Record<string, unknown> | undefined);
668
705
  }
669
- export class BasisTheoryValidationError<Details = Record<string, unknown>> extends Error {
670
- readonly details: Details;
671
- /**
672
- * @deprecated use {@link details}
673
- */
674
- readonly validation?: FieldError[] | undefined;
675
- constructor(message: string, details: Details,
676
- /**
677
- * @deprecated use {@link details}
678
- */
679
- validation?: FieldError[] | undefined);
680
- }
681
706
  export class HttpClientError extends Error {
682
707
  readonly status: number;
683
708
  readonly data?: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/web-elements",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "repository": "https://github.com/basis-theory/web-elements",
5
5
  "license": "Apache-2.0",
6
6
  "author": {