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

@basis-theory/basis-theory-js

Package Overview
Dependencies
Maintainers
0
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@basis-theory/basis-theory-js - npm Package Compare versions

Comparing version 4.22.1 to 4.23.0

2

common/constants.js

@@ -31,3 +31,3 @@ "use strict";

exports.DD_TOKEN = DD_TOKEN;
const DD_GIT_SHA = "316bf0c2304e914cd0a3767fdb3fc684c2fe0779";
const DD_GIT_SHA = "f6e1c47d5deee3b136e999171243c4cad67757a2";
exports.DD_GIT_SHA = DD_GIT_SHA;

@@ -34,0 +34,0 @@ const CLIENT_BASE_PATHS = {

@@ -294,3 +294,3 @@ "use strict";

const errorInterceptor = error => {
var _error$response$statu, _error$response, _error$response2, _error$config, _error$config$method, _error$config2, _error$config3, _error$config4, _error$config4$method, _error$config5, _error$config5$header, _error$response3, _error$response4, _error$response5;
var _error$response$statu, _error$response, _error$response2, _error$config, _error$config$method, _error$config2, _error$config3, _error$config4, _error$config4$method, _error$config5, _error$config5$header, _error$response3, _error$response4, _error$response5, _error$response6;

@@ -317,3 +317,4 @@ const status = (_error$response$statu = (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) !== null && _error$response$statu !== void 0 ? _error$response$statu : -1;

status: error === null || error === void 0 ? void 0 : (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.status,
statusText: error === null || error === void 0 ? void 0 : (_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : _error$response5.statusText
statusText: error === null || error === void 0 ? void 0 : (_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : _error$response5.statusText,
data: error === null || error === void 0 ? void 0 : (_error$response6 = error.response) === null || _error$response6 === void 0 ? void 0 : _error$response6.data
}

@@ -320,0 +321,0 @@ });

declare const ELEMENTS_INIT_ERROR_MESSAGE = "BasisTheory Elements was not properly initialized.";
declare const ELEMENTS_NOM_DOM_ERROR_MESSAGE = "Tried to load BasisTheoryElements in a non-DOM environment.";
declare const ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = "Basis Theory Elements did not load properly. Check network tab for more details.";
declare const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = "There was an unknown error when loading Basis Theory Elements. Check the console for details.";
declare const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = "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.";
declare const ELEMENTS_SCRIPT_FAILED_TO_DELIVER = "Failed to deliver Elements script from Basis Theory. Check your network connection and try again or contact support@basistheory.com";
declare const CARD_BRANDS: readonly ["visa", "mastercard", "american-express", "discover", "diners-club", "jcb", "unionpay", "maestro", "elo", "hiper", "hipercard", "mir", "unknown"];
declare const CARD_ICON_POSITIONS: readonly ["left", "right", "none"];
declare const AUTOCOMPLETE_VALUES: readonly ["additional-name", "address-level1", "address-level2", "address-level3", "address-level4", "address-line1", "address-line2", "address-line3", "bday-day", "bday-month", "bday-year", "bday", "billing", "cc-additional-name", "cc-csc", "cc-exp-month", "cc-exp-year", "cc-exp", "cc-family-name", "cc-given-name", "cc-name", "cc-number", "cc-type", "country-name", "country", "current-password", "email", "family-name", "fax", "given-name", "home", "honorific-prefix", "honorific-suffix", "language", "mobile", "name", "new-password", "nickname", "off", "on", "one-time-code", "organization-title", "organization", "page", "postal-code", "sex", "shipping", "street-address", "tel-area-code", "tel-country-code", "tel-extension", "tel-local-prefix", "tel-local-suffix", "tel-local", "tel-national", "tel", "transaction-amount", "transaction-currency", "url", "username", "work"];
export { ELEMENTS_INIT_ERROR_MESSAGE, ELEMENTS_NOM_DOM_ERROR_MESSAGE, ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE, ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE, CARD_BRANDS, CARD_ICON_POSITIONS, AUTOCOMPLETE_VALUES, };
export { ELEMENTS_INIT_ERROR_MESSAGE, ELEMENTS_NOM_DOM_ERROR_MESSAGE, ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE, ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE, ELEMENTS_SCRIPT_FAILED_TO_DELIVER, CARD_BRANDS, CARD_ICON_POSITIONS, AUTOCOMPLETE_VALUES, };

@@ -6,3 +6,3 @@ "use strict";

});
exports.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = exports.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = exports.ELEMENTS_NOM_DOM_ERROR_MESSAGE = exports.ELEMENTS_INIT_ERROR_MESSAGE = exports.CARD_ICON_POSITIONS = exports.CARD_BRANDS = exports.AUTOCOMPLETE_VALUES = void 0;
exports.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = exports.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = exports.ELEMENTS_SCRIPT_FAILED_TO_DELIVER = exports.ELEMENTS_NOM_DOM_ERROR_MESSAGE = exports.ELEMENTS_INIT_ERROR_MESSAGE = exports.CARD_ICON_POSITIONS = exports.CARD_BRANDS = exports.AUTOCOMPLETE_VALUES = void 0;
const ELEMENTS_INIT_ERROR_MESSAGE = 'BasisTheory Elements was not properly initialized.';

@@ -14,4 +14,6 @@ exports.ELEMENTS_INIT_ERROR_MESSAGE = ELEMENTS_INIT_ERROR_MESSAGE;

exports.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE;
const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = 'There was an unknown error when loading Basis Theory Elements. Check the console for details.';
const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = '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.';
exports.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE;
const ELEMENTS_SCRIPT_FAILED_TO_DELIVER = 'Failed to deliver Elements script from Basis Theory. Check your network connection and try again or contact support@basistheory.com';
exports.ELEMENTS_SCRIPT_FAILED_TO_DELIVER = ELEMENTS_SCRIPT_FAILED_TO_DELIVER;
const CARD_BRANDS = ['visa', 'mastercard', 'american-express', 'discover', 'diners-club', 'jcb', 'unionpay', 'maestro', 'elo', 'hiper', 'hipercard', 'mir', 'unknown'];

@@ -18,0 +20,0 @@ exports.CARD_BRANDS = CARD_BRANDS;

@@ -12,6 +12,111 @@ "use strict";

var _script = require("./script");
var _script2 = require("./script");
let elementsPromise;
const loadScript = (url, retryCount) => new Promise((resolve, reject) => {
let script = (0, _script2.findScript)(url);
if (!script) {
script = (0, _script2.injectScript)(url);
} // flag to prevent double rejection (if somehow script was not removed)
let isSettled = false; // script load success
script.addEventListener('load', () => {
if (window.BasisTheoryElements) {
resolve(window.BasisTheoryElements);
} else {
(async () => {
await _logging.logger.log.error('Elements not found on window on load', {
logType: 'elementsNotFoundOnWindow',
logOrigin: 'loadScript',
retryCount
});
})();
reject(new Error(_constants.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE));
}
}); // script error event
script.addEventListener('error', async event => {
if (isSettled) {
return;
}
isSettled = true;
await _logging.logger.log.error('Elements script onError event', {
logType: 'elementsScriptOnError',
logOrigin: 'loadScript',
retryCount,
event: {
message: event === null || event === void 0 ? void 0 : event.message,
source: event === null || event === void 0 ? void 0 : event.filename,
lineno: event === null || event === void 0 ? void 0 : event.lineno,
colno: event === null || event === void 0 ? void 0 : event.colno,
error: event === null || event === void 0 ? void 0 : event.error,
target: event === null || event === void 0 ? void 0 : event.target
}
}); // remove from dom to avoid duplicates
try {
var _script;
(_script = script) === null || _script === void 0 ? void 0 : _script.remove();
} catch (error) {
await _logging.logger.log.error(`Error removing script from DOM on retry attempt ${retryCount}`, {
logType: 'scriptRemovalError',
logOrigin: 'loadScript',
retryCount,
removalError: error
});
} // retry 1x if first attempt
if (retryCount === 0) {
loadScript(url, retryCount + 1).then(resolve).catch(reject);
return;
} // second attempt has failed: try fetching the script to inspect the response
try {
const response = await fetch(url);
if (!response.ok) {
await _logging.logger.log.error(`Second attempt to load elements script failed, fetch failed with status: ${response.status}.`, {
logType: 'elementsScriptFetchFailure',
logOrigin: 'loadScript',
retryCount,
fetchResult: 'error',
fetchResponse: response
});
reject(new Error(_constants.ELEMENTS_SCRIPT_FAILED_TO_DELIVER));
} else {
await _logging.logger.log.error(`Second attempt to load elements script failed, fetch success`, {
logType: 'elementsScriptFetchFailure',
logOrigin: 'loadScript',
retryCount,
fetchResult: 'success',
fetchResponse: response
});
reject(new Error(_constants.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE));
}
} catch (error) {
// fetch also failed
await _logging.logger.log.error('Second attempt failed to load elements script failed, fetch network error.', {
logType: 'elementsScriptFetchError',
logOrigin: 'loadScript',
retryCount,
fetchResult: 'error',
fetchError: error
});
reject(new Error(_constants.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE));
} // ultimately reject with browser message
reject((event === null || event === void 0 ? void 0 : event.error) || (event === null || event === void 0 ? void 0 : event.message) || new Error(_constants.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE));
});
});
const loadElements = elementsClientUrl => {

@@ -37,63 +142,23 @@ if (!elementsPromise) {

try {
let url = `https://${"js.basistheory.com"}/elements`;
let url = `https://${"js.basistheory.com"}/elements`;
if (typeof elementsClientUrl !== 'undefined') {
try {
const urlObject = new URL(elementsClientUrl);
url = urlObject.toString().replace(/\/$/u, '');
} catch {
(async () => {
await _logging.logger.log.warn('Invalid format for the given Elements client url.', {
logType: 'invalidClientUrlError',
logOrigin: 'loadElements'
});
})();
if (typeof elementsClientUrl !== 'undefined') {
try {
const urlObject = new URL(elementsClientUrl);
url = urlObject.toString().replace(/\/$/u, '');
} catch {
(async () => {
await _logging.logger.log.warn('Invalid format for the given Elements client url.', {
logType: 'invalidClientUrlError',
logOrigin: 'loadElements'
});
})();
throw new Error('Invalid format for the given Elements client url.');
}
throw new Error('Invalid format for the given Elements client url.');
}
}
let script = (0, _script.findScript)(url);
if (!script) {
script = (0, _script.injectScript)(url);
}
script.addEventListener('load', async () => {
if (window.BasisTheoryElements) {
resolve(window.BasisTheoryElements);
} else {
await _logging.logger.log.error('Elements not found on window on load', {
logType: 'elementsNotFoundOnWindow',
logOrigin: 'loadElements'
});
reject(new Error(_constants.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE));
}
});
script.addEventListener('error', async event => {
await _logging.logger.log.error('Elements script onError event', {
logType: 'elementsScriptOnError',
logOrigin: 'loadElements',
event: {
message: event === null || event === void 0 ? void 0 : event.message,
source: event === null || event === void 0 ? void 0 : event.filename,
lineno: event === null || event === void 0 ? void 0 : event.lineno,
colno: event === null || event === void 0 ? void 0 : event.colno,
error: event === null || event === void 0 ? void 0 : event.error,
target: event === null || event === void 0 ? void 0 : event.target
}
});
reject((event === null || event === void 0 ? void 0 : event.error) || (event === null || event === void 0 ? void 0 : event.message) || new Error(_constants.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE));
});
} catch (error) {
_logging.logger.log.error('Unexpected error loading Elements script', {
logType: 'unexpectedError',
logOrigin: 'loadElements',
errorObject: error
});
loadScript(url, 0).then(resolve).catch(error => {
reject(error);
return;
}
});
});

@@ -100,0 +165,0 @@ }

{
"name": "@basis-theory/basis-theory-js",
"version": "4.22.1",
"version": "4.23.0",
"repository": "https://github.com/Basis-Theory/basis-theory-js",

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

# Basis Theory JS SDK (aka BasisTheory.js)
> [!CAUTION]
> This SDK has been deprecated.
> This SDK has been deprecated for use in Node.js environments. It is still supported for use in web elements and reactor environments.
>
> Our new SDK can be found at https://github.com/Basis-Theory/node-sdk
> Our new Node.js SDK can be found at https://github.com/Basis-Theory/node-sdk
>

@@ -8,0 +8,0 @@ > See our documentation site for more information. https://developers.basistheory.com/docs/sdks/server-side/node

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc