@imtbl/sdk 1.7.2 → 1.7.3-alpha.2
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/dist/blockchain_data.d.ts +78 -34
- package/dist/blockchain_data.js +2 -2
- package/dist/browser/checkout/BridgeWidget-85db50d2.js +1 -0
- package/dist/browser/checkout/OnRampWidget-58400404.js +1 -0
- package/dist/browser/checkout/SaleWidget-549f0f75.js +2 -0
- package/dist/browser/checkout/SpendingCapHero-24fed6d2.js +1 -0
- package/dist/browser/checkout/SwapWidget-9eecba27.js +1 -0
- package/dist/browser/checkout/TopUpView-26964a9e.js +1 -0
- package/dist/browser/checkout/WalletWidget-7e6fed9c.js +1 -0
- package/dist/browser/checkout/auto-track-da38e5a8.js +1 -0
- package/dist/browser/checkout/balance-310539bb.js +1 -0
- package/dist/browser/checkout/index-392bc434.js +1 -0
- package/dist/browser/checkout/index-3d847e0c.js +1 -0
- package/dist/browser/checkout/index-4e77760b.js +773 -0
- package/dist/browser/checkout/index-8184ffea.js +1 -0
- package/dist/browser/checkout/index-919a5df1.js +1 -0
- package/dist/browser/checkout/index-e6159023.js +1 -0
- package/dist/browser/checkout/index-eb42cd09.js +106 -0
- package/dist/browser/checkout/index.umd-c2e32802.js +1 -0
- package/dist/browser/checkout/is-plan-event-enabled-80f76ce6.js +1 -0
- package/dist/browser/checkout/retry-355e44f2.js +1 -0
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/browser/checkout/useTransakEvents-c6a83ea5.js +2 -0
- package/dist/browser/checkout/widgets-esm.js +1 -0
- package/dist/browser/checkout/widgets.js +50 -51
- package/dist/checkout.d.ts +3 -1
- package/dist/checkout.js +65 -32
- package/dist/config.js +1 -1
- package/dist/index.browser.js +7 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +200 -143
- package/dist/index.d.ts +81 -35
- package/dist/index.js +200 -143
- package/dist/orderbook.js +1 -1
- package/dist/passport.js +136 -112
- package/dist/x.js +2 -2
- package/package.json +1 -1
package/dist/checkout.d.ts
CHANGED
|
@@ -23749,7 +23749,7 @@ type CheckoutWidgetsConfig = {
|
|
|
23749
23749
|
/**
|
|
23750
23750
|
* Represents the configuration options for instantiating the Checkout Widgets factory.
|
|
23751
23751
|
* @property {WidgetConfiguration} config - global configuration options for the widgets.
|
|
23752
|
-
* @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle
|
|
23752
|
+
* @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle(default latest version will be used).
|
|
23753
23753
|
*/
|
|
23754
23754
|
type WidgetsInit = {
|
|
23755
23755
|
config: WidgetConfiguration;
|
|
@@ -23773,6 +23773,8 @@ declare class Checkout {
|
|
|
23773
23773
|
* @param {WidgetsInit} init - The initialisation parameters for loading the widgets bundle and applying configuration
|
|
23774
23774
|
*/
|
|
23775
23775
|
widgets(init: WidgetsInit): Promise<ImmutableCheckoutWidgets.WidgetsFactory>;
|
|
23776
|
+
private loadUmdBundle;
|
|
23777
|
+
private loadEsModules;
|
|
23776
23778
|
/**
|
|
23777
23779
|
* Creates a provider using the given parameters.
|
|
23778
23780
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
package/dist/checkout.js
CHANGED
|
@@ -139,7 +139,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
142
|
-
const SDK_VERSION$1 = '1.7.2';
|
|
142
|
+
const SDK_VERSION$1 = '1.7.3-alpha.2';
|
|
143
143
|
const getReferrer$1 = () => {
|
|
144
144
|
if (isNode$1()) {
|
|
145
145
|
return '';
|
|
@@ -17479,7 +17479,7 @@ const flattenProperties = (properties) => {
|
|
|
17479
17479
|
};
|
|
17480
17480
|
|
|
17481
17481
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
17482
|
-
const SDK_VERSION = '1.7.2';
|
|
17482
|
+
const SDK_VERSION = '1.7.3-alpha.2';
|
|
17483
17483
|
const getReferrer = () => {
|
|
17484
17484
|
if (isNode()) {
|
|
17485
17485
|
return '';
|
|
@@ -27725,7 +27725,7 @@ class APIError extends Error {
|
|
|
27725
27725
|
|
|
27726
27726
|
/* eslint-disable implicit-arrow-linebreak */
|
|
27727
27727
|
const defaultHeaders = {
|
|
27728
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.7.2',
|
|
27728
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.7.3-alpha.2',
|
|
27729
27729
|
};
|
|
27730
27730
|
/**
|
|
27731
27731
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -29092,7 +29092,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
29092
29092
|
maxPriorityFeePerGas: BigNumber$1.from(10e9),
|
|
29093
29093
|
};
|
|
29094
29094
|
|
|
29095
|
-
const SDK_VERSION_MARKER = '1.7.2';
|
|
29095
|
+
const SDK_VERSION_MARKER = '1.7.3-alpha.2';
|
|
29096
29096
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
29097
29097
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
29098
29098
|
|
|
@@ -32712,27 +32712,25 @@ function validateAndBuildVersion(version) {
|
|
|
32712
32712
|
return validatedVersion;
|
|
32713
32713
|
}
|
|
32714
32714
|
|
|
32715
|
-
|
|
32715
|
+
// Loads the checkout widgets bundle from the CDN and appends the script to the document head
|
|
32716
|
+
function loadUnresolvedBundle(tag, scriptId, validVersion) {
|
|
32716
32717
|
if (window === undefined) {
|
|
32717
32718
|
throw new Error('missing window object: please run Checkout client side');
|
|
32718
32719
|
}
|
|
32719
32720
|
if (document === undefined) {
|
|
32720
32721
|
throw new Error('missing document object: please run Checkout client side');
|
|
32721
32722
|
}
|
|
32722
|
-
const scriptId = 'immutable-checkout-widgets-bundle';
|
|
32723
|
-
const validVersion = validateAndBuildVersion(version);
|
|
32724
|
-
// Prevent the script to be loaded more than once
|
|
32725
|
-
// by checking the presence of the script and its version.
|
|
32726
|
-
const initScript = document.getElementById(scriptId);
|
|
32727
|
-
if (initScript)
|
|
32728
|
-
return { loaded: true, element: initScript };
|
|
32729
|
-
const tag = document.createElement('script');
|
|
32730
32723
|
let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets.js`;
|
|
32731
32724
|
tag.setAttribute('id', scriptId);
|
|
32732
32725
|
tag.setAttribute('data-version', validVersion);
|
|
32733
32726
|
tag.setAttribute('src', cdnUrl);
|
|
32734
32727
|
document.head.appendChild(tag);
|
|
32735
|
-
|
|
32728
|
+
}
|
|
32729
|
+
// Gets the CDN url for the split checkout widgets bundle
|
|
32730
|
+
function getWidgetsEsmUrl(version) {
|
|
32731
|
+
const validVersion = validateAndBuildVersion(version);
|
|
32732
|
+
let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout/widgets-esm.js`;
|
|
32733
|
+
return cdnUrl;
|
|
32736
32734
|
}
|
|
32737
32735
|
|
|
32738
32736
|
const PUBLISHABLE_KEY_PREFIX = 'pk_imapik-';
|
|
@@ -32811,7 +32809,6 @@ const SANDBOX_CONFIGURATION = {
|
|
|
32811
32809
|
},
|
|
32812
32810
|
passport: undefined,
|
|
32813
32811
|
};
|
|
32814
|
-
const WIDGETS_SCRIPT_TIMEOUT = 100;
|
|
32815
32812
|
// Checkout SDK
|
|
32816
32813
|
class Checkout {
|
|
32817
32814
|
readOnlyProviders;
|
|
@@ -32841,26 +32838,44 @@ class Checkout {
|
|
|
32841
32838
|
const checkout = this;
|
|
32842
32839
|
// Preload the configurations
|
|
32843
32840
|
await checkout.config.remote.getConfig();
|
|
32841
|
+
try {
|
|
32842
|
+
const factory = await this.loadEsModules(init.config, init.version);
|
|
32843
|
+
return factory;
|
|
32844
|
+
}
|
|
32845
|
+
catch (err) {
|
|
32846
|
+
throw new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err });
|
|
32847
|
+
}
|
|
32848
|
+
}
|
|
32849
|
+
async loadUmdBundle(config, version) {
|
|
32850
|
+
const checkout = this;
|
|
32844
32851
|
const factory = new Promise((resolve, reject) => {
|
|
32845
|
-
function checkForWidgetsBundleLoaded() {
|
|
32846
|
-
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
32847
|
-
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
|
|
32848
|
-
}
|
|
32849
|
-
else {
|
|
32850
|
-
// If ImmutableCheckoutWidgets is not defined, wait for set amount of time.
|
|
32851
|
-
// When time has elapsed, check again if ImmutableCheckoutWidgets is defined.
|
|
32852
|
-
// Once it's defined, the promise will resolve and setTimeout won't be called again.
|
|
32853
|
-
setTimeout(checkForWidgetsBundleLoaded, WIDGETS_SCRIPT_TIMEOUT);
|
|
32854
|
-
}
|
|
32855
|
-
}
|
|
32856
32852
|
try {
|
|
32857
|
-
const
|
|
32858
|
-
|
|
32859
|
-
|
|
32860
|
-
|
|
32861
|
-
|
|
32862
|
-
|
|
32853
|
+
const scriptId = 'immutable-checkout-widgets-bundle';
|
|
32854
|
+
const validVersion = validateAndBuildVersion(version);
|
|
32855
|
+
// Prevent the script to be loaded more than once
|
|
32856
|
+
// by checking the presence of the script and its version.
|
|
32857
|
+
const initScript = document.getElementById(scriptId);
|
|
32858
|
+
if (initScript) {
|
|
32859
|
+
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
32860
|
+
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, config));
|
|
32861
|
+
}
|
|
32862
|
+
else {
|
|
32863
|
+
reject(new CheckoutError('Failed to find ImmutableCheckoutWidgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR));
|
|
32864
|
+
}
|
|
32863
32865
|
}
|
|
32866
|
+
const tag = document.createElement('script');
|
|
32867
|
+
tag.addEventListener('load', () => {
|
|
32868
|
+
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
32869
|
+
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, config));
|
|
32870
|
+
}
|
|
32871
|
+
else {
|
|
32872
|
+
reject(new CheckoutError('Failed to find ImmutableCheckoutWidgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR));
|
|
32873
|
+
}
|
|
32874
|
+
});
|
|
32875
|
+
tag.addEventListener('error', (err) => {
|
|
32876
|
+
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
|
|
32877
|
+
});
|
|
32878
|
+
loadUnresolvedBundle(tag, scriptId, validVersion);
|
|
32864
32879
|
}
|
|
32865
32880
|
catch (err) {
|
|
32866
32881
|
reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
|
|
@@ -32868,6 +32883,24 @@ class Checkout {
|
|
|
32868
32883
|
});
|
|
32869
32884
|
return factory;
|
|
32870
32885
|
}
|
|
32886
|
+
async loadEsModules(config, version) {
|
|
32887
|
+
const checkout = this;
|
|
32888
|
+
try {
|
|
32889
|
+
const cdnUrl = getWidgetsEsmUrl(version);
|
|
32890
|
+
// WebpackIgnore comment required to prevent webpack modifying the import statement and
|
|
32891
|
+
// breaking the dynamic import in certain applications integrating checkout
|
|
32892
|
+
const checkoutWidgetsModule = await import(/* webpackIgnore: true */ cdnUrl);
|
|
32893
|
+
if (checkoutWidgetsModule && checkoutWidgetsModule.WidgetsFactory) {
|
|
32894
|
+
return new checkoutWidgetsModule.WidgetsFactory(checkout, config);
|
|
32895
|
+
}
|
|
32896
|
+
}
|
|
32897
|
+
catch (err) {
|
|
32898
|
+
// eslint-disable-next-line no-console
|
|
32899
|
+
console.warn(`Failed to resolve checkout widgets module, falling back to UMD bundle. Error: ${err.message}`);
|
|
32900
|
+
}
|
|
32901
|
+
// Fallback to UMD bundle if esm bundle fails to load
|
|
32902
|
+
return await checkout.loadUmdBundle(config, version);
|
|
32903
|
+
}
|
|
32871
32904
|
/**
|
|
32872
32905
|
* Creates a provider using the given parameters.
|
|
32873
32906
|
* @param {CreateProviderParams} params - The parameters for creating the provider.
|
package/dist/config.js
CHANGED
|
@@ -128,7 +128,7 @@ const flattenProperties = (properties) => {
|
|
|
128
128
|
};
|
|
129
129
|
|
|
130
130
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
131
|
-
const SDK_VERSION = '1.7.2';
|
|
131
|
+
const SDK_VERSION = '1.7.3-alpha.2';
|
|
132
132
|
const getReferrer = () => {
|
|
133
133
|
if (isNode()) {
|
|
134
134
|
return '';
|