@imtbl/sdk 1.7.3 → 1.8.1

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.
Files changed (37) hide show
  1. package/dist/blockchain_data.js +2 -2
  2. package/dist/browser/checkout/BridgeWidget-85db50d2.js +1 -0
  3. package/dist/browser/checkout/OnRampWidget-58400404.js +1 -0
  4. package/dist/browser/checkout/SaleWidget-549f0f75.js +2 -0
  5. package/dist/browser/checkout/SpendingCapHero-24fed6d2.js +1 -0
  6. package/dist/browser/checkout/SwapWidget-9eecba27.js +1 -0
  7. package/dist/browser/checkout/TopUpView-26964a9e.js +1 -0
  8. package/dist/browser/checkout/WalletWidget-7e6fed9c.js +1 -0
  9. package/dist/browser/checkout/auto-track-da38e5a8.js +1 -0
  10. package/dist/browser/checkout/balance-310539bb.js +1 -0
  11. package/dist/browser/checkout/index-392bc434.js +1 -0
  12. package/dist/browser/checkout/index-3d847e0c.js +1 -0
  13. package/dist/browser/checkout/index-4e77760b.js +773 -0
  14. package/dist/browser/checkout/index-8184ffea.js +1 -0
  15. package/dist/browser/checkout/index-919a5df1.js +1 -0
  16. package/dist/browser/checkout/index-e6159023.js +1 -0
  17. package/dist/browser/checkout/index-eb42cd09.js +106 -0
  18. package/dist/browser/checkout/index.umd-c2e32802.js +1 -0
  19. package/dist/browser/checkout/is-plan-event-enabled-80f76ce6.js +1 -0
  20. package/dist/browser/checkout/retry-355e44f2.js +1 -0
  21. package/dist/browser/checkout/sdk.js +4 -4
  22. package/dist/browser/checkout/useTransakEvents-c6a83ea5.js +2 -0
  23. package/dist/browser/checkout/widgets-esm.js +1 -0
  24. package/dist/browser/checkout/widgets.js +50 -51
  25. package/dist/checkout.d.ts +8 -2
  26. package/dist/checkout.js +65 -32
  27. package/dist/config.js +1 -1
  28. package/dist/index.browser.js +7 -7
  29. package/dist/index.browser.js.map +1 -1
  30. package/dist/index.cjs +228 -164
  31. package/dist/index.d.ts +8 -2
  32. package/dist/index.js +228 -164
  33. package/dist/orderbook.js +1 -1
  34. package/dist/passport.d.ts +5 -1
  35. package/dist/passport.js +164 -133
  36. package/dist/x.js +2 -2
  37. package/package.json +1 -1
@@ -21355,13 +21355,17 @@ declare class Passport {
21355
21355
  *
21356
21356
  * @param options.useCachedSession = false - If true, and no active session exists, then the user will not be
21357
21357
  * prompted to log in and the Promise will resolve with a null value.
21358
+ * @param options.anonymousId - If provided, Passport internal metrics will be enriched with this value.
21358
21359
  * @returns {Promise<UserProfile | null>} the user profile if the user is logged in, otherwise null
21359
21360
  */
21360
21361
  login(options?: {
21361
21362
  useCachedSession: boolean;
21363
+ anonymousId?: string;
21362
21364
  }): Promise<UserProfile | null>;
21363
21365
  loginCallback(): Promise<void>;
21364
- loginWithDeviceFlow(): Promise<DeviceConnectResponse>;
21366
+ loginWithDeviceFlow(options?: {
21367
+ anonymousId?: string;
21368
+ }): Promise<DeviceConnectResponse>;
21365
21369
  loginWithDeviceFlowCallback(deviceCode: string, interval: number, timeoutMs?: number): Promise<UserProfile>;
21366
21370
  loginWithPKCEFlow(): string;
21367
21371
  loginWithPKCEFlowCallback(authorizationCode: string, state: string): Promise<UserProfile>;
@@ -23749,7 +23753,7 @@ type CheckoutWidgetsConfig = {
23749
23753
  /**
23750
23754
  * Represents the configuration options for instantiating the Checkout Widgets factory.
23751
23755
  * @property {WidgetConfiguration} config - global configuration options for the widgets.
23752
- * @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle (default latest version will be used).
23756
+ * @property {SemanticVersion | undefined} version - version of the Checkout widgets bundle(default latest version will be used).
23753
23757
  */
23754
23758
  type WidgetsInit = {
23755
23759
  config: WidgetConfiguration;
@@ -23773,6 +23777,8 @@ declare class Checkout {
23773
23777
  * @param {WidgetsInit} init - The initialisation parameters for loading the widgets bundle and applying configuration
23774
23778
  */
23775
23779
  widgets(init: WidgetsInit): Promise<ImmutableCheckoutWidgets.WidgetsFactory>;
23780
+ private loadUmdBundle;
23781
+ private loadEsModules;
23776
23782
  /**
23777
23783
  * Creates a provider using the given parameters.
23778
23784
  * @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.3';
142
+ const SDK_VERSION$1 = '1.8.1';
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.3';
17482
+ const SDK_VERSION = '1.8.1';
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.3',
27728
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.8.1',
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.3';
29095
+ const SDK_VERSION_MARKER = '1.8.1';
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
- function loadUnresolved(version) {
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
- return { loaded: false, element: tag };
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 script = loadUnresolved(init.version);
32858
- if (script.loaded && typeof ImmutableCheckoutWidgets !== 'undefined') {
32859
- resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
32860
- }
32861
- else {
32862
- checkForWidgetsBundleLoaded();
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.3';
131
+ const SDK_VERSION = '1.8.1';
132
132
  const getReferrer = () => {
133
133
  if (isNode()) {
134
134
  return '';