@basis-theory/basis-theory-js 1.63.0 → 1.65.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/BasisTheory.js CHANGED
@@ -158,7 +158,7 @@ class BasisTheory {
158
158
  throw new Error('Invalid format for the given Elements base url.');
159
159
  }
160
160
 
161
- const elements = await (0, _elements.loadElements)();
161
+ const elements = await (0, _elements.loadElements)(this.initOptions.elementsClientUrl);
162
162
  await elements.init(apiKey, elementsBaseUrl.toString().replace(/\/$/u, ''));
163
163
  this.elements = elements;
164
164
  } // these should be set by the init call only.
@@ -1,3 +1,3 @@
1
1
  import type { BasisTheoryElements } from '../types/elements';
2
- declare const loadElements: () => Promise<BasisTheoryElements>;
2
+ declare const loadElements: (elementsClientUrl?: string | undefined) => Promise<BasisTheoryElements>;
3
3
  export { loadElements };
package/elements/load.js CHANGED
@@ -11,7 +11,7 @@ var _script = require("./script");
11
11
 
12
12
  let elementsPromise;
13
13
 
14
- const loadElements = () => {
14
+ const loadElements = elementsClientUrl => {
15
15
  if (!elementsPromise) {
16
16
  elementsPromise = new Promise((resolve, reject) => {
17
17
  if (typeof window !== 'object') {
@@ -25,7 +25,17 @@ const loadElements = () => {
25
25
  }
26
26
 
27
27
  try {
28
- const url = `https://${"js.basistheory.com"}/elements`;
28
+ let url = `https://${"js.basistheory.com"}/elements`;
29
+
30
+ if (typeof elementsClientUrl !== 'undefined') {
31
+ try {
32
+ const urlObject = new URL(elementsClientUrl);
33
+ url = urlObject.toString().replace(/\/$/u, '');
34
+ } catch {
35
+ throw new Error('Invalid format for the given Elements client url.');
36
+ }
37
+ }
38
+
29
39
  let script = (0, _script.findScript)(url);
30
40
 
31
41
  if (!script) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/basis-theory-js",
3
- "version": "1.63.0",
3
+ "version": "1.65.0",
4
4
  "repository": "https://github.com/Basis-Theory/basis-theory-js",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -8,6 +8,7 @@ interface ElementInternalOptions {
8
8
  baseUrl: string;
9
9
  }
10
10
  interface SanitizedElementOptions {
11
+ validateOnChange?: boolean;
11
12
  style?: ElementStyle;
12
13
  disabled?: boolean;
13
14
  targetId?: string;
@@ -30,7 +31,7 @@ interface TransformOption {
30
31
  interface AutoCompleteOption {
31
32
  autoComplete?: AutoCompleteValue;
32
33
  }
33
- declare type CustomizableElementOptions = Pick<ElementOptions, 'style' | 'disabled'> & AutoCompleteOption;
34
+ declare type CustomizableElementOptions = Pick<ElementOptions, 'style' | 'disabled' | 'validateOnChange'> & AutoCompleteOption;
34
35
  declare type ElementValueType = 'static' | 'reference';
35
36
  interface CardElementValue<T extends ElementValueType> {
36
37
  number?: T extends 'reference' ? DataElementReference : string;
@@ -15,6 +15,7 @@ interface BasisTheoryInitOptionsWithoutElements extends BasisTheoryInitOptions {
15
15
  interface BasisTheoryInitOptionsWithElements extends BasisTheoryInitOptions {
16
16
  elements: true;
17
17
  elementsBaseUrl?: string;
18
+ elementsClientUrl?: string;
18
19
  }
19
20
  interface BasisTheoryInit {
20
21
  init(apiKey: string, options?: BasisTheoryInitOptionsWithoutElements): Promise<BasisTheory>;