@imtbl/sdk 0.28.10-alpha.1 → 0.29.0-alpha.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.
package/dist/index.js CHANGED
@@ -5,10 +5,10 @@ import jwt_decode from 'jwt-decode';
5
5
  import * as crypto from 'crypto';
6
6
  import { Magic } from 'magic-sdk';
7
7
  import { OpenIdExtension } from '@magic-ext/oidc';
8
+ import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers';
8
9
  import { BigNumber as BigNumber$1, ethers, providers, constants as constants$1, ContractFactory, utils as utils$1, Contract as Contract$1 } from 'ethers';
9
10
  import BN$2 from 'bn.js';
10
11
  import * as encUtils from 'enc-utils';
11
- import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
12
12
  import { EventEmitter } from 'events';
13
13
  import { walletContracts } from '@0xsequence/abi';
14
14
  import { encodeSignature, decodeSignature } from '@0xsequence/config';
@@ -33,34 +33,38 @@ class ImmutableConfiguration {
33
33
  environment;
34
34
  rateLimitingKey;
35
35
  apiKey;
36
- clientAppId;
36
+ publishableKey;
37
37
  constructor(options) {
38
38
  this.environment = options.environment;
39
- if (options.rateLimitingKey) {
40
- this.rateLimitingKey = options.rateLimitingKey;
41
- globalAxios$1.defaults.headers.common['x-api-key'] = this.rateLimitingKey;
42
- }
43
- if (options.apiKey) {
44
- if (!options.apiKey.startsWith('sk_imapik-')) {
45
- throw new Error('Invalid API key');
46
- }
47
- this.apiKey = options.apiKey;
48
- globalAxios$1.defaults.headers.common['x-immutable-api-key'] = this.apiKey;
49
- }
50
- if (options.clientAppId) {
51
- if (!options.clientAppId.startsWith('cai_imapik-')) {
52
- throw new Error('Invalid Client App Id');
53
- }
54
- this.clientAppId = options.clientAppId;
55
- globalAxios$1.defaults.headers.common['x-immutable-client-app-id'] = this.clientAppId;
56
- }
57
39
  }
58
40
  }
41
+ const API_KEY_PREFIX = 'sk_imapik-';
42
+ const PUBLISHABLE_KEY_PREFIX = 'pk_imapik-';
43
+ const PUBLISHABLE_KEY_LENGTH = 30;
44
+ const addApiKeyToAxiosHeader = (apiKey) => {
45
+ if (!apiKey.startsWith(API_KEY_PREFIX)) {
46
+ throw new Error('Invalid API key. Create your api key in Immutable developer hub. https://hub.immutable.com');
47
+ }
48
+ globalAxios$1.defaults.headers.common['x-immutable-api-key'] = apiKey;
49
+ };
50
+ const addPublishableKeyToAxiosHeader = (publishableKey) => {
51
+ if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX) || publishableKey.length !== PUBLISHABLE_KEY_LENGTH) {
52
+ throw new Error('Invalid Publishable key. Create your Publishable key in Immutable developer hub.'
53
+ + ' https://hub.immutable.com');
54
+ }
55
+ globalAxios$1.defaults.headers.common['x-immutable-publishable-key'] = publishableKey;
56
+ };
57
+ const addRateLimitingKeyToAxiosHeader = (rateLimitingKey) => {
58
+ globalAxios$1.defaults.headers.common['x-api-key'] = rateLimitingKey;
59
+ };
59
60
 
60
61
  var config = /*#__PURE__*/Object.freeze({
61
62
  __proto__: null,
62
63
  get Environment () { return Environment$1; },
63
- ImmutableConfiguration: ImmutableConfiguration
64
+ ImmutableConfiguration: ImmutableConfiguration,
65
+ addApiKeyToAxiosHeader: addApiKeyToAxiosHeader,
66
+ addPublishableKeyToAxiosHeader: addPublishableKeyToAxiosHeader,
67
+ addRateLimitingKeyToAxiosHeader: addRateLimitingKeyToAxiosHeader
64
68
  });
65
69
 
66
70
  /* tslint:disable */
@@ -817,7 +821,7 @@ const CollectionsApiAxiosParamCreator = function (configuration) {
817
821
  const localVarHeaderParameter = {};
818
822
  const localVarQueryParameter = {};
819
823
  // authentication ImmutableApiKey required
820
- await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-Key", configuration);
824
+ await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-key", configuration);
821
825
  localVarHeaderParameter['Content-Type'] = 'application/json';
822
826
  setSearchParams$1(localVarUrlObj, localVarQueryParameter);
823
827
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
@@ -1127,7 +1131,7 @@ const MetadataApiAxiosParamCreator = function (configuration) {
1127
1131
  const localVarHeaderParameter = {};
1128
1132
  const localVarQueryParameter = {};
1129
1133
  // authentication ImmutableApiKey required
1130
- await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-Key", configuration);
1134
+ await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-key", configuration);
1131
1135
  localVarHeaderParameter['Content-Type'] = 'application/json';
1132
1136
  setSearchParams$1(localVarUrlObj, localVarQueryParameter);
1133
1137
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
@@ -1167,7 +1171,7 @@ const MetadataApiAxiosParamCreator = function (configuration) {
1167
1171
  const localVarHeaderParameter = {};
1168
1172
  const localVarQueryParameter = {};
1169
1173
  // authentication ImmutableApiKey required
1170
- await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-Key", configuration);
1174
+ await setApiKeyToObject(localVarHeaderParameter, "x-immutable-api-key", configuration);
1171
1175
  localVarHeaderParameter['Content-Type'] = 'application/json';
1172
1176
  setSearchParams$1(localVarUrlObj, localVarQueryParameter);
1173
1177
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
@@ -3627,7 +3631,7 @@ class MultiRollupApiClients {
3627
3631
  }
3628
3632
 
3629
3633
  // eslint-disable-next-line @typescript-eslint/naming-convention
3630
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.10-alpha.1' };
3634
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.29.0-alpha.1' };
3631
3635
  const createConfig = ({ basePath, headers, }) => {
3632
3636
  if (!basePath.trim()) {
3633
3637
  throw Error('basePath can not be empty');
@@ -3687,7 +3691,7 @@ class APIError extends Error {
3687
3691
 
3688
3692
  /* eslint-disable implicit-arrow-linebreak */
3689
3693
  const defaultHeaders = {
3690
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.10-alpha.1',
3694
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.29.0-alpha.1',
3691
3695
  };
3692
3696
  /**
3693
3697
  * createAPIConfiguration to create a custom Configuration
@@ -4098,7 +4102,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
4098
4102
  chainID,
4099
4103
  coreContractAddress,
4100
4104
  registrationContractAddress,
4101
- sdkVersion: 'ts-immutable-sdk-0.28.10-alpha.1',
4105
+ sdkVersion: 'ts-immutable-sdk-0.29.0-alpha.1',
4102
4106
  });
4103
4107
  /**
4104
4108
  * Sets `sdkVersion` at the time of build
@@ -8753,9 +8757,9 @@ class AuthManager {
8753
8757
  };
8754
8758
  if (passport?.imx_eth_address) {
8755
8759
  user.imx = {
8756
- ethAddress: passport?.imx_eth_address,
8757
- starkAddress: passport?.imx_stark_address,
8758
- userAdminAddress: passport?.imx_user_admin_address,
8760
+ ethAddress: passport.imx_eth_address,
8761
+ starkAddress: passport.imx_stark_address,
8762
+ userAdminAddress: passport.imx_user_admin_address,
8759
8763
  };
8760
8764
  }
8761
8765
  if (passport?.zkevm_eth_address) {
@@ -8778,11 +8782,11 @@ class AuthManager {
8778
8782
  nickname: idTokenPayload.nickname,
8779
8783
  },
8780
8784
  };
8781
- if (idTokenPayload?.passport?.imx_eth_address) {
8785
+ if (idTokenPayload?.passport.imx_eth_address) {
8782
8786
  user.imx = {
8783
- ethAddress: idTokenPayload?.passport?.imx_eth_address,
8784
- starkAddress: idTokenPayload?.passport?.imx_stark_address,
8785
- userAdminAddress: idTokenPayload?.passport?.imx_user_admin_address,
8787
+ ethAddress: idTokenPayload.passport.imx_eth_address,
8788
+ starkAddress: idTokenPayload.passport.imx_stark_address,
8789
+ userAdminAddress: idTokenPayload.passport.imx_user_admin_address,
8786
8790
  };
8787
8791
  }
8788
8792
  if (idTokenPayload?.passport?.zkevm_eth_address) {
@@ -9043,7 +9047,7 @@ class AuthManager {
9043
9047
  }
9044
9048
  }
9045
9049
 
9046
- const lazyLoad = (promiseToAwait, initialiseFunction) => (promiseToAwait().then(initialiseFunction));
9050
+ const lazyLoad = (promiseToAwait, initialiseFunction) => promiseToAwait().then(initialiseFunction);
9047
9051
  const lazyDocumentReady = (initialiseFunction) => {
9048
9052
  const documentReadyPromise = () => new Promise((resolve) => {
9049
9053
  if (window.document.readyState === 'complete') {
@@ -9457,33 +9461,31 @@ async function cancelOrder$1({ user, starkSigner, request, ordersApi, guardianCl
9457
9461
  }
9458
9462
 
9459
9463
  async function registerPassport({ ethSigner, starkSigner, usersApi }, authorization) {
9460
- return withPassportError(async () => {
9461
- const [userAddress, starkPublicKey] = await Promise.all([
9462
- ethSigner.getAddress(),
9463
- starkSigner.getAddress(),
9464
- ]);
9465
- const signableResult = await usersApi.getSignableRegistrationOffchain({
9466
- getSignableRegistrationRequest: {
9467
- ether_key: userAddress,
9468
- stark_key: starkPublicKey,
9469
- },
9470
- });
9471
- const { signable_message: signableMessage, payload_hash: payloadHash } = signableResult.data;
9472
- const [ethSignature, starkSignature] = await Promise.all([
9473
- signRaw(signableMessage, ethSigner),
9474
- starkSigner.signMessage(payloadHash),
9475
- ]);
9476
- const response = await usersApi.registerPassportUser({
9477
- authorization: `Bearer ${authorization}`,
9478
- registerPassportUserRequest: {
9479
- eth_signature: ethSignature,
9480
- ether_key: userAddress,
9481
- stark_signature: starkSignature,
9482
- stark_key: starkPublicKey,
9483
- },
9484
- });
9485
- return response.statusText;
9486
- }, PassportErrorType.USER_REGISTRATION_ERROR);
9464
+ const [userAddress, starkPublicKey] = await Promise.all([
9465
+ ethSigner.getAddress(),
9466
+ starkSigner.getAddress(),
9467
+ ]);
9468
+ const signableResult = await usersApi.getSignableRegistrationOffchain({
9469
+ getSignableRegistrationRequest: {
9470
+ ether_key: userAddress,
9471
+ stark_key: starkPublicKey,
9472
+ },
9473
+ });
9474
+ const { signable_message: signableMessage, payload_hash: payloadHash } = signableResult.data;
9475
+ const [ethSignature, starkSignature] = await Promise.all([
9476
+ signRaw(signableMessage, ethSigner),
9477
+ starkSigner.signMessage(payloadHash),
9478
+ ]);
9479
+ const response = await usersApi.registerPassportUser({
9480
+ authorization: `Bearer ${authorization}`,
9481
+ registerPassportUserRequest: {
9482
+ eth_signature: ethSignature,
9483
+ ether_key: userAddress,
9484
+ stark_signature: starkSignature,
9485
+ stark_key: starkPublicKey,
9486
+ },
9487
+ });
9488
+ return response.data;
9487
9489
  }
9488
9490
 
9489
9491
  async function createTrade$1({ request, tradesApi, user, starkSigner, guardianClient, }) {
@@ -9629,37 +9631,123 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, guar
9629
9631
  }), PassportErrorType.TRANSFER_ERROR);
9630
9632
  }
9631
9633
 
9634
+ async function forceUserRefresh(authManager) {
9635
+ // User metadata is updated asynchronously. Poll userinfo endpoint until it is updated.
9636
+ await retryWithDelay(async () => {
9637
+ const user = await authManager.loginSilent({ forceRefresh: true }); // force refresh to get updated user info
9638
+ if (user?.imx)
9639
+ return user;
9640
+ return Promise.reject(new Error('user wallet addresses not exist'));
9641
+ });
9642
+ }
9643
+ async function registerOffchain$1(userAdminKeySigner, starkSigner, unregisteredUser, authManager, usersApi) {
9644
+ return withPassportError(async () => {
9645
+ try {
9646
+ const response = await registerPassport({
9647
+ ethSigner: userAdminKeySigner,
9648
+ starkSigner,
9649
+ usersApi,
9650
+ }, unregisteredUser.accessToken);
9651
+ await forceUserRefresh(authManager);
9652
+ return response;
9653
+ }
9654
+ catch (err) {
9655
+ if (globalAxios$1.isAxiosError(err) && err.status === 409) {
9656
+ // The user already registered, but the user token is not updated yet.
9657
+ await forceUserRefresh(authManager);
9658
+ return { tx_hash: '' };
9659
+ }
9660
+ throw err;
9661
+ }
9662
+ }, PassportErrorType.USER_REGISTRATION_ERROR);
9663
+ }
9664
+
9632
9665
  class PassportImxProvider {
9633
9666
  authManager;
9634
- starkSigner;
9635
9667
  immutableXClient;
9636
9668
  guardianClient;
9637
- constructor({ authManager, starkSigner, immutableXClient, confirmationScreen, config, passportEventEmitter, }) {
9669
+ magicAdapter;
9670
+ /**
9671
+ * This property is set during initialisation and stores the signers in a promise.
9672
+ * This property is not meant to be accessed directly, but through the
9673
+ * `getAuthenticatedUserAndSigners` method.
9674
+ * @see getAuthenticatedUserAndSigners
9675
+ */
9676
+ signers;
9677
+ signerInitialisationError;
9678
+ constructor({ authManager, immutableXClient, confirmationScreen, config, passportEventEmitter, magicAdapter, }) {
9638
9679
  this.authManager = authManager;
9639
- this.starkSigner = starkSigner;
9640
9680
  this.immutableXClient = immutableXClient;
9641
9681
  this.guardianClient = new GuardianClient({
9642
9682
  confirmationScreen,
9643
9683
  config,
9644
9684
  });
9685
+ this.magicAdapter = magicAdapter;
9686
+ this.initialiseSigners();
9645
9687
  passportEventEmitter.on(PassportEvents.LOGGED_OUT, this.handleLogout);
9646
9688
  }
9647
9689
  handleLogout = () => {
9648
- this.starkSigner = undefined;
9690
+ this.signers = undefined;
9649
9691
  };
9650
- async getAuthenticatedUserSigner() {
9692
+ /**
9693
+ * This method is called by the constructor and asynchronously initialises the signers.
9694
+ * The signers are stored in a promise so that they can be retrieved by the provider
9695
+ * when needed.
9696
+ *
9697
+ * If an error is thrown during initialisation, it is stored in the `signerInitialisationError`,
9698
+ * so that it doesn't result in an unhandled promise rejection.
9699
+ *
9700
+ * This error is thrown when the signers are requested through:
9701
+ * @see getAuthenticatedUserAndSigners
9702
+ *
9703
+ */
9704
+ async initialiseSigners() {
9705
+ const generateSigners = async () => {
9706
+ const user = await this.authManager.getUser();
9707
+ // The user will be present because the factory validates it
9708
+ const magicRpcProvider = await this.magicAdapter.login(user.idToken);
9709
+ const web3Provider = new Web3Provider(magicRpcProvider);
9710
+ const ethSigner = web3Provider.getSigner();
9711
+ const starkSigner = await getStarkSigner(ethSigner);
9712
+ return { ethSigner, starkSigner };
9713
+ };
9714
+ // eslint-disable-next-line no-async-promise-executor
9715
+ this.signers = new Promise(async (resolve) => {
9716
+ try {
9717
+ resolve(await generateSigners());
9718
+ }
9719
+ catch (err) {
9720
+ // Capture and store the initialization error
9721
+ this.signerInitialisationError = err;
9722
+ resolve(undefined);
9723
+ }
9724
+ });
9725
+ }
9726
+ async getAuthenticatedUserAndSigners() {
9651
9727
  const user = await this.authManager.getUser();
9652
- if (!user || this.starkSigner === undefined) {
9728
+ if (!user || !this.signers) {
9653
9729
  throw new PassportError('User has been logged out', PassportErrorType.NOT_LOGGED_IN_ERROR);
9654
9730
  }
9731
+ const signers = await this.signers;
9732
+ // Throw the stored error if the signers failed to initialise
9733
+ if (typeof signers === 'undefined') {
9734
+ if (typeof this.signerInitialisationError !== 'undefined') {
9735
+ throw this.signerInitialisationError;
9736
+ }
9737
+ throw new Error('Signers failed to initialise');
9738
+ }
9739
+ return { user, ...signers };
9740
+ }
9741
+ async getRegisteredImxUserAndSigners() {
9742
+ const { user, starkSigner, ethSigner } = await this.getAuthenticatedUserAndSigners();
9655
9743
  const isUserImx = (oidcUser) => oidcUser?.imx !== undefined;
9656
9744
  if (!isUserImx(user)) {
9657
9745
  throw new PassportError('User has not been registered with StarkEx', PassportErrorType.USER_NOT_REGISTERED_ERROR);
9658
9746
  }
9659
- return { user, starkSigner: this.starkSigner };
9747
+ return { user, starkSigner, ethSigner };
9660
9748
  }
9661
9749
  async transfer(request) {
9662
- const { user, starkSigner } = await this.getAuthenticatedUserSigner();
9750
+ const { user, starkSigner } = await this.getRegisteredImxUserAndSigners();
9663
9751
  return transfer$1({
9664
9752
  request,
9665
9753
  user,
@@ -9668,23 +9756,21 @@ class PassportImxProvider {
9668
9756
  guardianClient: this.guardianClient,
9669
9757
  });
9670
9758
  }
9671
- // TODO: Remove once implemented
9672
- // eslint-disable-next-line class-methods-use-this
9673
- registerOffchain() {
9674
- throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
9759
+ async registerOffchain() {
9760
+ const { user, ethSigner, starkSigner } = await this.getAuthenticatedUserAndSigners();
9761
+ return await registerOffchain$1(ethSigner, starkSigner, user, this.authManager, this.immutableXClient.usersApi);
9675
9762
  }
9676
- // TODO: Remove once implemented
9677
- // eslint-disable-next-line class-methods-use-this
9678
- isRegisteredOffchain() {
9679
- throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
9763
+ async isRegisteredOffchain() {
9764
+ const { user } = await this.getAuthenticatedUserAndSigners();
9765
+ return !!user.imx;
9680
9766
  }
9681
9767
  // TODO: Remove once implemented
9682
- // eslint-disable-next-line class-methods-use-this
9768
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
9683
9769
  isRegisteredOnchain() {
9684
9770
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
9685
9771
  }
9686
9772
  async createOrder(request) {
9687
- const { user, starkSigner } = await this.getAuthenticatedUserSigner();
9773
+ const { user, starkSigner } = await this.getRegisteredImxUserAndSigners();
9688
9774
  return createOrder$1({
9689
9775
  request,
9690
9776
  user,
@@ -9694,7 +9780,7 @@ class PassportImxProvider {
9694
9780
  });
9695
9781
  }
9696
9782
  async cancelOrder(request) {
9697
- const { user, starkSigner } = await this.getAuthenticatedUserSigner();
9783
+ const { user, starkSigner } = await this.getRegisteredImxUserAndSigners();
9698
9784
  return cancelOrder$1({
9699
9785
  request,
9700
9786
  user,
@@ -9704,7 +9790,7 @@ class PassportImxProvider {
9704
9790
  });
9705
9791
  }
9706
9792
  async createTrade(request) {
9707
- const { user, starkSigner } = await this.getAuthenticatedUserSigner();
9793
+ const { user, starkSigner } = await this.getRegisteredImxUserAndSigners();
9708
9794
  return createTrade$1({
9709
9795
  request,
9710
9796
  user,
@@ -9714,7 +9800,7 @@ class PassportImxProvider {
9714
9800
  });
9715
9801
  }
9716
9802
  async batchNftTransfer(request) {
9717
- const { user, starkSigner } = await this.getAuthenticatedUserSigner();
9803
+ const { user, starkSigner } = await this.getRegisteredImxUserAndSigners();
9718
9804
  return batchNftTransfer({
9719
9805
  request,
9720
9806
  user,
@@ -9724,7 +9810,7 @@ class PassportImxProvider {
9724
9810
  });
9725
9811
  }
9726
9812
  async exchangeTransfer(request) {
9727
- const { user, starkSigner } = await this.getAuthenticatedUserSigner();
9813
+ const { user, starkSigner } = await this.getRegisteredImxUserAndSigners();
9728
9814
  return exchangeTransfer$1({
9729
9815
  request,
9730
9816
  user,
@@ -9752,7 +9838,7 @@ class PassportImxProvider {
9752
9838
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
9753
9839
  }
9754
9840
  async getAddress() {
9755
- const { user } = await this.getAuthenticatedUserSigner();
9841
+ const { user } = await this.getRegisteredImxUserAndSigners();
9756
9842
  return Promise.resolve(user.imx.ethAddress);
9757
9843
  }
9758
9844
  }
@@ -9812,49 +9898,15 @@ class PassportImxProviderFactory {
9812
9898
  if (!user.idToken) {
9813
9899
  throw new PassportError('Failed to initialise', PassportErrorType.WALLET_CONNECTION_ERROR);
9814
9900
  }
9815
- const magicRpcProvider = await this.magicAdapter.login(user.idToken);
9816
- const web3Provider = new Web3Provider(magicRpcProvider);
9817
- const ethSigner = web3Provider.getSigner();
9818
- const starkSigner = await getStarkSigner(ethSigner);
9819
- if (!user.imx?.ethAddress) {
9820
- await this.registerStarkEx(ethSigner, starkSigner, user.accessToken);
9821
- return new PassportImxProvider({
9822
- authManager: this.authManager,
9823
- starkSigner,
9824
- immutableXClient: this.immutableXClient,
9825
- confirmationScreen: this.confirmationScreen,
9826
- config: this.config,
9827
- passportEventEmitter: this.passportEventEmitter,
9828
- });
9829
- }
9830
9901
  return new PassportImxProvider({
9902
+ config: this.config,
9831
9903
  authManager: this.authManager,
9832
- starkSigner,
9833
9904
  immutableXClient: this.immutableXClient,
9834
9905
  confirmationScreen: this.confirmationScreen,
9835
- config: this.config,
9836
9906
  passportEventEmitter: this.passportEventEmitter,
9907
+ magicAdapter: this.magicAdapter,
9837
9908
  });
9838
9909
  }
9839
- async registerStarkEx(userAdminKeySigner, starkSigner, jwt) {
9840
- return withPassportError(async () => {
9841
- await registerPassport({
9842
- ethSigner: userAdminKeySigner,
9843
- starkSigner,
9844
- usersApi: this.immutableXClient.usersApi,
9845
- }, jwt);
9846
- // User metadata is updated asynchronously. Poll userinfo endpoint until it is updated.
9847
- const updatedUser = await retryWithDelay(async () => {
9848
- const user = await this.authManager.loginSilent({ forceRefresh: true }); // force refresh to get updated user info
9849
- const metadataExists = !!user?.imx;
9850
- if (metadataExists) {
9851
- return user;
9852
- }
9853
- return Promise.reject(new Error('user wallet addresses not exist'));
9854
- });
9855
- return updatedUser;
9856
- }, PassportErrorType.REFRESH_TOKEN_ERROR);
9857
- }
9858
9910
  }
9859
9911
 
9860
9912
  const validateConfiguration = (configuration, requiredKeys, prefix) => {
@@ -33738,7 +33790,7 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
33738
33790
  return itemRequirements;
33739
33791
  }
33740
33792
 
33741
- const SDK_VERSION_MARKER = '0.28.10-alpha.1';
33793
+ const SDK_VERSION_MARKER = '0.29.0-alpha.1';
33742
33794
  // This SDK version is replaced by the `yarn build` command ran on the root level
33743
33795
  const globalPackageVersion = () => SDK_VERSION_MARKER;
33744
33796
 
@@ -7,16 +7,25 @@ declare class ImmutableConfiguration {
7
7
  readonly environment: Environment;
8
8
  readonly rateLimitingKey?: string;
9
9
  readonly apiKey?: string;
10
- readonly clientAppId?: string;
10
+ readonly publishableKey?: string;
11
11
  constructor(options: {
12
12
  environment: Environment;
13
- rateLimitingKey?: string;
14
- apiKey?: string;
15
- clientAppId?: string;
16
13
  });
17
14
  }
15
+ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
16
+ apiKey: 'required';
17
+ } ? Required<{
18
+ apiKey: string;
19
+ }> : {}) & (T extends {
20
+ publishableKey: 'required';
21
+ } ? Required<{
22
+ publishableKey: string;
23
+ }> : {});
24
+ type ImmutableConfigurationWithOmitableFields<T> = (T extends {
25
+ apiKey: 'omit';
26
+ } ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
18
27
  interface ModuleConfiguration<T> {
19
- baseConfig: ImmutableConfiguration;
28
+ baseConfig: ImmutableConfigurationWithOmitableFields<T>;
20
29
  overrides?: T;
21
30
  }
22
31
 
@@ -9818,16 +9818,25 @@ declare class ImmutableConfiguration {
9818
9818
  readonly environment: Environment;
9819
9819
  readonly rateLimitingKey?: string;
9820
9820
  readonly apiKey?: string;
9821
- readonly clientAppId?: string;
9821
+ readonly publishableKey?: string;
9822
9822
  constructor(options: {
9823
9823
  environment: Environment;
9824
- rateLimitingKey?: string;
9825
- apiKey?: string;
9826
- clientAppId?: string;
9827
9824
  });
9828
9825
  }
9826
+ type ImmutableConfigurationWithRequireableFields<T> = ImmutableConfiguration & (T extends {
9827
+ apiKey: 'required';
9828
+ } ? Required<{
9829
+ apiKey: string;
9830
+ }> : {}) & (T extends {
9831
+ publishableKey: 'required';
9832
+ } ? Required<{
9833
+ publishableKey: string;
9834
+ }> : {});
9835
+ type ImmutableConfigurationWithOmitableFields<T> = (T extends {
9836
+ apiKey: 'omit';
9837
+ } ? Omit<ImmutableConfigurationWithRequireableFields<T>, 'apiKey'> : ImmutableConfigurationWithRequireableFields<T>);
9829
9838
  interface ModuleConfiguration<T> {
9830
- baseConfig: ImmutableConfiguration;
9839
+ baseConfig: ImmutableConfigurationWithOmitableFields<T>;
9831
9840
  overrides?: T;
9832
9841
  }
9833
9842