@imtbl/sdk 0.0.1-alpha.2 → 0.1.0-alpha

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.
@@ -3,6 +3,7 @@ declare enum PassportErrorType {
3
3
  INVALID_CONFIGURATION = "INVALID_CONFIGURATION",
4
4
  WALLET_CONNECTION_ERROR = "WALLET_CONNECTION_ERROR",
5
5
  NOT_LOGGED_IN_ERROR = "NOT_LOGGED_IN_ERROR",
6
+ SILENT_LOGIN_ERROR = "SILENT_LOGIN_ERROR",
6
7
  REFRESH_TOKEN_ERROR = "REFRESH_TOKEN_ERROR",
7
8
  USER_REGISTRATION_ERROR = "USER_REGISTRATION_ERROR",
8
9
  LOGOUT_ERROR = "LOGOUT_ERROR",
@@ -663,6 +664,23 @@ interface IMXProvider {
663
664
  completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
664
665
  }
665
666
 
667
+ declare enum Environment {
668
+ PRODUCTION = "production",
669
+ SANDBOX = "sandbox"
670
+ }
671
+ declare class ImmutableConfiguration {
672
+ readonly environment: Environment;
673
+ readonly apiKey?: string;
674
+ constructor(options: {
675
+ environment: Environment;
676
+ apiKey?: string;
677
+ });
678
+ }
679
+ interface ModuleConfiguration<T> {
680
+ baseConfig: ImmutableConfiguration;
681
+ overrides?: T;
682
+ }
683
+
666
684
  type UserProfile = {
667
685
  email?: string;
668
686
  nickname?: string;
@@ -672,14 +690,6 @@ declare enum Networks {
672
690
  PRODUCTION = "mainnet",
673
691
  SANDBOX = "goerli"
674
692
  }
675
- interface EnvironmentConfiguration {
676
- network: Networks;
677
- authenticationDomain: string;
678
- magicPublishableApiKey: string;
679
- magicProviderId: string;
680
- baseIMXApiPath: string;
681
- passportDomain: string;
682
- }
683
693
  interface OidcConfiguration {
684
694
  clientId: string;
685
695
  logoutRedirectUri: string;
@@ -687,24 +697,43 @@ interface OidcConfiguration {
687
697
  scope?: string;
688
698
  audience?: string;
689
699
  }
700
+ interface PassportOverrides {
701
+ network: Networks;
702
+ authenticationDomain: string;
703
+ magicPublishableApiKey: string;
704
+ magicProviderId: string;
705
+ passportDomain: string;
706
+ imxApiBasePath: string;
707
+ }
708
+ interface PassportModuleConfiguration extends ModuleConfiguration<PassportOverrides>, OidcConfiguration {
709
+ }
690
710
 
691
711
  declare class Passport {
692
712
  private authManager;
693
713
  private magicAdapter;
694
714
  private readonly config;
695
- constructor(environmentConfiguration: EnvironmentConfiguration, oidcConfiguration: OidcConfiguration);
715
+ constructor(passportModuleConfiguration: PassportModuleConfiguration);
716
+ private getImxProvider;
717
+ connectImxSilent(): Promise<IMXProvider | null>;
696
718
  connectImx(): Promise<IMXProvider>;
697
719
  loginCallback(): Promise<void>;
698
720
  logout(): Promise<void>;
699
- getUserInfo(): Promise<UserProfile>;
721
+ getUserInfo(): Promise<UserProfile | undefined>;
700
722
  getIdToken(): Promise<string | undefined>;
701
- getAccessToken(): Promise<string>;
723
+ getAccessToken(): Promise<string | undefined>;
702
724
  private registerUser;
703
725
  }
704
726
 
705
- declare const Config: {
706
- PRODUCTION: EnvironmentConfiguration;
707
- SANDBOX: EnvironmentConfiguration;
708
- };
727
+ declare class PassportConfiguration {
728
+ readonly network: Networks;
729
+ readonly authenticationDomain: string;
730
+ readonly passportDomain: string;
731
+ readonly magicPublishableApiKey: string;
732
+ readonly magicProviderId: string;
733
+ readonly imxApiBasePath: string;
734
+ readonly oidcConfiguration: OidcConfiguration;
735
+ readonly baseConfig: ImmutableConfiguration;
736
+ constructor({ baseConfig, overrides, ...oidcConfiguration }: PassportModuleConfiguration);
737
+ }
709
738
 
710
- export { Config, Passport, PassportError };
739
+ export { Passport, PassportConfiguration, PassportError };
package/dist/passport.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { Configuration, UsersApi, TransfersApi, OrdersApi, ExchangesApi, TradesApi, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
1
2
  import { UserManager } from 'oidc-client-ts';
2
3
  import { ethers } from 'ethers';
3
4
  import { Magic } from 'magic-sdk';
4
5
  import { OpenIdExtension } from '@magic-ext/oidc';
5
- import { Configuration, UsersApi, TransfersApi, OrdersApi, ExchangesApi, TradesApi, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
6
6
  import BN from 'bn.js';
7
7
  import * as encUtils from 'enc-utils';
8
8
 
@@ -67,12 +67,19 @@ function convertToSignableToken(token) {
67
67
  }
68
68
  }
69
69
 
70
+ var Environment;
71
+ (function (Environment) {
72
+ Environment["PRODUCTION"] = "production";
73
+ Environment["SANDBOX"] = "sandbox";
74
+ })(Environment || (Environment = {}));
75
+
70
76
  var PassportErrorType;
71
77
  (function (PassportErrorType) {
72
78
  PassportErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
73
79
  PassportErrorType["INVALID_CONFIGURATION"] = "INVALID_CONFIGURATION";
74
80
  PassportErrorType["WALLET_CONNECTION_ERROR"] = "WALLET_CONNECTION_ERROR";
75
81
  PassportErrorType["NOT_LOGGED_IN_ERROR"] = "NOT_LOGGED_IN_ERROR";
82
+ PassportErrorType["SILENT_LOGIN_ERROR"] = "SILENT_LOGIN_ERROR";
76
83
  PassportErrorType["REFRESH_TOKEN_ERROR"] = "REFRESH_TOKEN_ERROR";
77
84
  PassportErrorType["USER_REGISTRATION_ERROR"] = "USER_REGISTRATION_ERROR";
78
85
  PassportErrorType["LOGOUT_ERROR"] = "LOGOUT_ERROR";
@@ -119,17 +126,17 @@ const retryWithDelay = async (fn, options) => {
119
126
  }
120
127
  };
121
128
 
122
- const getAuthConfiguration = ({ oidcConfiguration, }) => {
129
+ const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
123
130
  const baseConfiguration = {
124
- authority: oidcConfiguration.authenticationDomain,
131
+ authority: authenticationDomain,
125
132
  redirect_uri: oidcConfiguration.redirectUri,
126
133
  popup_redirect_uri: oidcConfiguration.redirectUri,
127
134
  client_id: oidcConfiguration.clientId,
128
135
  metadata: {
129
- authorization_endpoint: `${oidcConfiguration.authenticationDomain}/authorize`,
130
- token_endpoint: `${oidcConfiguration.authenticationDomain}/oauth/token`,
131
- userinfo_endpoint: `${oidcConfiguration.authenticationDomain}/userinfo`,
132
- end_session_endpoint: `${oidcConfiguration.authenticationDomain}/v2/logout` +
136
+ authorization_endpoint: `${authenticationDomain}/authorize`,
137
+ token_endpoint: `${authenticationDomain}/oauth/token`,
138
+ userinfo_endpoint: `${authenticationDomain}/userinfo`,
139
+ end_session_endpoint: `${authenticationDomain}/v2/logout` +
133
140
  `?returnTo=${encodeURIComponent(oidcConfiguration.logoutRedirectUri)}` +
134
141
  `&client_id=${oidcConfiguration.clientId}`,
135
142
  },
@@ -154,6 +161,7 @@ class AuthManager {
154
161
  mapOidcUserToDomainModel = (oidcUser) => {
155
162
  const passport = oidcUser.profile?.passport;
156
163
  return {
164
+ expired: oidcUser.expired,
157
165
  idToken: oidcUser.id_token,
158
166
  accessToken: oidcUser.access_token,
159
167
  refreshToken: oidcUser.refresh_token,
@@ -167,7 +175,10 @@ class AuthManager {
167
175
  };
168
176
  async login() {
169
177
  return withPassportError(async () => {
170
- const oidcUser = await this.userManager.signinPopup();
178
+ const popupWindowFeatures = { width: 410, height: 450 };
179
+ const oidcUser = await this.userManager.signinPopup({
180
+ popupWindowFeatures,
181
+ });
171
182
  return this.mapOidcUserToDomainModel(oidcUser);
172
183
  }, PassportErrorType.AUTHENTICATION_ERROR);
173
184
  }
@@ -177,11 +188,24 @@ class AuthManager {
177
188
  async logout() {
178
189
  return withPassportError(async () => this.userManager.signoutRedirect(), PassportErrorType.LOGOUT_ERROR);
179
190
  }
191
+ async loginSilent() {
192
+ return withPassportError(async () => {
193
+ const existedUser = await this.getUser();
194
+ if (!existedUser) {
195
+ return null;
196
+ }
197
+ const oidcUser = await this.userManager.signinSilent();
198
+ if (!oidcUser) {
199
+ return null;
200
+ }
201
+ return this.mapOidcUserToDomainModel(oidcUser);
202
+ }, PassportErrorType.SILENT_LOGIN_ERROR);
203
+ }
180
204
  async getUser() {
181
205
  return withPassportError(async () => {
182
206
  const oidcUser = await this.userManager.getUser();
183
207
  if (!oidcUser) {
184
- throw new Error('Failed to retrieve user');
208
+ return null;
185
209
  }
186
210
  return this.mapOidcUserToDomainModel(oidcUser);
187
211
  }, PassportErrorType.NOT_LOGGED_IN_ERROR);
@@ -250,26 +274,12 @@ var TransactionTypes;
250
274
  const PassportEventType = 'imx_passport_confirmation';
251
275
 
252
276
  const openPopupCenter = ({ url, title, width, height, }) => {
253
- // Fixes dual-screen position Most browsers Firefox
254
- const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
255
- const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
256
- const windowWidth = window.innerWidth
257
- ? window.innerWidth
258
- : document.documentElement.clientWidth
259
- ? document.documentElement.clientWidth
260
- : screen.width;
261
- const windowHeight = window.innerHeight
262
- ? window.innerHeight
263
- : document.documentElement.clientHeight
264
- ? document.documentElement.clientHeight
265
- : screen.height;
266
- const systemZoom = windowWidth / window.screen.availWidth;
267
- const left = (windowWidth - width) / 2 / systemZoom + dualScreenLeft;
268
- const top = (windowHeight - height) / 2 / systemZoom + dualScreenTop;
277
+ const left = Math.max(0, Math.round(window.screenX + (window.outerWidth - width) / 2));
278
+ const top = Math.max(0, Math.round(window.screenY + (window.outerHeight - height) / 2));
269
279
  const newWindow = window.open(url, title, `
270
280
  scrollbars=yes,
271
- width=${width / systemZoom},
272
- height=${height / systemZoom},
281
+ width=${width},
282
+ height=${height},
273
283
  top=${top},
274
284
  left=${left}
275
285
  `);
@@ -281,8 +291,8 @@ const openPopupCenter = ({ url, title, width, height, }) => {
281
291
  };
282
292
 
283
293
  const ConfirmationWindowTitle = 'Confirm this transaction';
284
- const ConfirmationWindowHeight = 600;
285
- const ConfirmationWindowWidth = 600;
294
+ const ConfirmationWindowHeight = 380;
295
+ const ConfirmationWindowWidth = 480;
286
296
  const ConfirmationWindowClosedPollingDuration = 1000;
287
297
  class ConfirmationScreen {
288
298
  config;
@@ -296,7 +306,7 @@ class ConfirmationScreen {
296
306
  ...message,
297
307
  }, this.config.passportDomain);
298
308
  }
299
- startTransaction(accessToken, transaction) {
309
+ startTransaction(accessToken, transaction, popupOptions) {
300
310
  return new Promise((resolve, reject) => {
301
311
  const messageHandler = ({ data, origin }) => {
302
312
  if (origin != this.config.passportDomain ||
@@ -327,8 +337,8 @@ class ConfirmationScreen {
327
337
  const confirmationWindow = openPopupCenter({
328
338
  url: `${this.config.passportDomain}/transaction-confirmation`,
329
339
  title: ConfirmationWindowTitle,
330
- width: ConfirmationWindowWidth,
331
- height: ConfirmationWindowHeight,
340
+ width: popupOptions?.width || ConfirmationWindowWidth,
341
+ height: popupOptions?.height || ConfirmationWindowHeight,
332
342
  });
333
343
  // https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128
334
344
  const timer = setInterval(function () {
@@ -415,10 +425,11 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
415
425
  getSignableTransferRequestV2,
416
426
  });
417
427
  const confirmationScreen = new ConfirmationScreen(passportConfig);
428
+ const popupWindowSize = { width: 480, height: 784 };
418
429
  const confirmationResult = await confirmationScreen.startTransaction(user.accessToken, {
419
430
  transactionType: TransactionTypes.CreateBatchTransfer,
420
431
  transactionData: getSignableTransferRequestV2,
421
- });
432
+ }, popupWindowSize);
422
433
  if (!confirmationResult.confirmed) {
423
434
  throw new Error('Transaction rejected by user');
424
435
  }
@@ -627,7 +638,7 @@ async function createTrade({ request, tradesApi, user, starkSigner, passportConf
627
638
  },
628
639
  };
629
640
  const headers = { Authorization: 'Bearer ' + user.accessToken };
630
- const { data: createTradeResponse } = await tradesApi.createTrade(tradeParams, {
641
+ const { data: createTradeResponse } = await tradesApi.createTradeV3(tradeParams, {
631
642
  headers,
632
643
  });
633
644
  return createTradeResponse;
@@ -647,7 +658,7 @@ class PassportImxProvider {
647
658
  this.starkSigner = starkSigner;
648
659
  this.passportConfig = passportConfig;
649
660
  const apiConfig = new Configuration({
650
- basePath: passportConfig.imxAPIConfiguration.basePath,
661
+ basePath: passportConfig.imxApiBasePath,
651
662
  });
652
663
  this.transfersApi = new TransfersApi(apiConfig);
653
664
  this.ordersApi = new OrdersApi(apiConfig);
@@ -739,67 +750,75 @@ var Networks;
739
750
  Networks["SANDBOX"] = "goerli";
740
751
  })(Networks || (Networks = {}));
741
752
 
742
- const Config = {
743
- PRODUCTION: {
744
- network: Networks.PRODUCTION,
745
- authenticationDomain: 'https://auth.immutable.com',
746
- magicPublishableApiKey: 'pk_live_10F423798A540ED7',
747
- magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
748
- baseIMXApiPath: 'https://api.x.immutable.com',
749
- passportDomain: 'https://passport.immutable.com',
750
- },
751
- SANDBOX: {
752
- network: Networks.SANDBOX,
753
- authenticationDomain: 'https://auth.immutable.com',
754
- magicPublishableApiKey: 'pk_live_10F423798A540ED7',
755
- magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
756
- baseIMXApiPath: 'https://api.sandbox.x.immutable.com',
757
- passportDomain: 'https://passport.sandbox.immutable.com',
758
- },
759
- };
760
- const validateConfiguration = (configurationName, configuration, requiredKeys) => {
761
- if (!configuration) {
762
- throw new PassportError(`${configurationName} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
763
- }
753
+ const validateConfiguration = (configuration, requiredKeys, prefix) => {
764
754
  const missingKeys = requiredKeys
765
755
  .map((key) => !configuration[key] && key)
766
756
  .filter((n) => n)
767
757
  .join(', ');
768
758
  if (missingKeys !== '') {
769
- throw new PassportError(`${configurationName} - ${missingKeys} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
759
+ const errorMessage = prefix
760
+ ? `${prefix} - ${missingKeys} cannot be null`
761
+ : `${missingKeys} cannot be null`;
762
+ throw new PassportError(errorMessage, PassportErrorType.INVALID_CONFIGURATION);
770
763
  }
771
764
  };
772
- const getPassportConfiguration = (environmentConfiguration, oidcConfiguration) => {
773
- validateConfiguration('EnvironmentConfiguration', environmentConfiguration, [
774
- 'network',
775
- 'authenticationDomain',
776
- 'magicPublishableApiKey',
777
- 'magicProviderId',
778
- 'passportDomain',
779
- ]);
780
- validateConfiguration('OidcConfiguration', oidcConfiguration, [
781
- 'clientId',
782
- 'logoutRedirectUri',
783
- 'redirectUri',
784
- ]);
785
- return {
786
- network: environmentConfiguration.network,
787
- oidcConfiguration: {
788
- authenticationDomain: environmentConfiguration.authenticationDomain,
789
- clientId: oidcConfiguration.clientId,
790
- logoutRedirectUri: oidcConfiguration.logoutRedirectUri,
791
- redirectUri: oidcConfiguration.redirectUri,
792
- scope: oidcConfiguration.scope,
793
- audience: oidcConfiguration.audience,
794
- },
795
- imxAPIConfiguration: {
796
- basePath: environmentConfiguration.baseIMXApiPath,
797
- },
798
- passportDomain: environmentConfiguration.passportDomain,
799
- magicPublishableApiKey: environmentConfiguration.magicPublishableApiKey,
800
- magicProviderId: environmentConfiguration.magicProviderId,
801
- };
802
- };
765
+ class PassportConfiguration {
766
+ network;
767
+ authenticationDomain;
768
+ passportDomain;
769
+ magicPublishableApiKey;
770
+ magicProviderId;
771
+ imxApiBasePath;
772
+ oidcConfiguration;
773
+ baseConfig;
774
+ constructor({ baseConfig, overrides, ...oidcConfiguration }) {
775
+ validateConfiguration(oidcConfiguration, [
776
+ 'clientId',
777
+ 'logoutRedirectUri',
778
+ 'redirectUri',
779
+ ]);
780
+ this.oidcConfiguration = oidcConfiguration;
781
+ this.baseConfig = baseConfig;
782
+ if (overrides) {
783
+ validateConfiguration(overrides, [
784
+ 'network',
785
+ 'authenticationDomain',
786
+ 'magicPublishableApiKey',
787
+ 'magicProviderId',
788
+ 'passportDomain',
789
+ 'imxApiBasePath',
790
+ ], 'overrides');
791
+ this.network = overrides.network;
792
+ this.authenticationDomain = overrides.authenticationDomain;
793
+ this.passportDomain = overrides.passportDomain;
794
+ this.magicPublishableApiKey = overrides.magicPublishableApiKey;
795
+ this.magicProviderId = overrides.magicProviderId;
796
+ this.imxApiBasePath = overrides.imxApiBasePath;
797
+ }
798
+ else {
799
+ switch (baseConfig.environment) {
800
+ case Environment.SANDBOX: {
801
+ this.network = Networks.SANDBOX;
802
+ this.authenticationDomain = 'https://auth.immutable.com';
803
+ this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
804
+ this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
805
+ this.passportDomain = 'https://passport.sandbox.immutable.com';
806
+ this.imxApiBasePath = 'https://api.sandbox.x.immutable.com';
807
+ break;
808
+ }
809
+ case Environment.PRODUCTION: {
810
+ this.network = Networks.PRODUCTION;
811
+ this.authenticationDomain = 'https://auth.immutable.com';
812
+ this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
813
+ this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
814
+ this.passportDomain = 'https://passport.immutable.com';
815
+ this.imxApiBasePath = 'https://api.x.immutable.com';
816
+ break;
817
+ }
818
+ }
819
+ }
820
+ }
821
+ }
803
822
 
804
823
  const getStarkSigner = async (signer) => {
805
824
  return withPassportError(async () => {
@@ -838,15 +857,14 @@ class Passport {
838
857
  authManager;
839
858
  magicAdapter;
840
859
  config;
841
- constructor(environmentConfiguration, oidcConfiguration) {
842
- const passportConfiguration = getPassportConfiguration(environmentConfiguration, oidcConfiguration);
860
+ constructor(passportModuleConfiguration) {
861
+ const passportConfiguration = new PassportConfiguration(passportModuleConfiguration);
843
862
  this.config = passportConfiguration;
844
863
  this.authManager = new AuthManager(this.config);
845
864
  this.magicAdapter = new MagicAdapter(this.config);
846
865
  }
847
- async connectImx() {
848
- const user = await this.authManager.login();
849
- if (!user.idToken) {
866
+ async getImxProvider(user) {
867
+ if (!user || !user.idToken) {
850
868
  throw new PassportError('Failed to initialise', PassportErrorType.WALLET_CONNECTION_ERROR);
851
869
  }
852
870
  const provider = await this.magicAdapter.login(user.idToken);
@@ -867,6 +885,17 @@ class Passport {
867
885
  passportConfig: this.config,
868
886
  });
869
887
  }
888
+ async connectImxSilent() {
889
+ const user = await this.authManager.loginSilent();
890
+ if (!user) {
891
+ return null;
892
+ }
893
+ return this.getImxProvider(user);
894
+ }
895
+ async connectImx() {
896
+ const user = await this.authManager.login();
897
+ return this.getImxProvider(user);
898
+ }
870
899
  async loginCallback() {
871
900
  return this.authManager.loginCallback();
872
901
  }
@@ -875,19 +904,19 @@ class Passport {
875
904
  }
876
905
  async getUserInfo() {
877
906
  const user = await this.authManager.getUser();
878
- return user.profile;
907
+ return user?.profile;
879
908
  }
880
909
  async getIdToken() {
881
910
  const user = await this.authManager.getUser();
882
- return user.idToken;
911
+ return user?.idToken;
883
912
  }
884
913
  async getAccessToken() {
885
914
  const user = await this.authManager.getUser();
886
- return user.accessToken;
915
+ return user?.accessToken;
887
916
  }
888
917
  async registerUser(userAdminKeySigner, starkSigner, jwt) {
889
918
  const configuration = new Configuration({
890
- basePath: this.config.imxAPIConfiguration.basePath,
919
+ basePath: this.config.imxApiBasePath,
891
920
  });
892
921
  const usersApi = new UsersApi(configuration);
893
922
  await registerPassport({
@@ -903,4 +932,4 @@ class Passport {
903
932
  }
904
933
  }
905
934
 
906
- export { Config, Passport, PassportError };
935
+ export { Passport, PassportConfiguration, PassportError };
@@ -1,3 +1,5 @@
1
+ import { ProviderConfiguration as ProviderConfiguration$1 } from 'config';
2
+
1
3
  declare type Bytes = ArrayLike<number>;
2
4
  declare type BytesLike = Bytes | string;
3
5
  interface Hexable {
@@ -329,7 +331,7 @@ interface ConfigurationParameters {
329
331
  baseOptions?: any;
330
332
  formDataCtor?: new () => any;
331
333
  }
332
- declare class Configuration$1 {
334
+ declare class Configuration {
333
335
  /**
334
336
  * parameter for apiKey security
335
337
  * @param name security name
@@ -811,7 +813,7 @@ interface ImmutableXConfiguration {
811
813
  /**
812
814
  * The configuration for the API client
813
815
  */
814
- apiConfiguration: Configuration$1;
816
+ apiConfiguration: Configuration;
815
817
  /**
816
818
  * The configuration for the Ethereum network
817
819
  */
@@ -903,24 +905,10 @@ interface IMXProvider {
903
905
  completeWithdrawal(starkPublicKey: string, token: AnyToken): Promise<TransactionResponse>;
904
906
  }
905
907
 
906
- declare enum Environment {
907
- DEVELOPMENT = "development",
908
- SANDBOX = "sandbox",
909
- PRODUCTION = "production"
910
- }
911
- type StarkExConfig = ImmutableXConfiguration & {
912
- env: Environment;
913
- };
914
- declare class Configuration {
915
- private readonly starkExConfig;
916
- constructor(config: StarkExConfig);
917
- getStarkExConfig(): StarkExConfig;
918
- }
919
-
920
908
  declare class GenericIMXProvider implements IMXProvider {
921
909
  private readonly config;
922
910
  private readonly signers;
923
- constructor(config: Configuration, ethSigner: Signer, starkExSigner: StarkSigner);
911
+ constructor(config: ProviderConfiguration$1, ethSigner: Signer, starkSigner: StarkSigner);
924
912
  getAddress(): Promise<string>;
925
913
  registerOffchain(): Promise<RegisterUserResponse>;
926
914
  batchNftTransfer(request: Array<NftTransferDetails>): Promise<CreateTransferResponse>;
@@ -937,10 +925,38 @@ declare class GenericIMXProvider implements IMXProvider {
937
925
 
938
926
  declare class MetaMaskIMXProvider extends GenericIMXProvider {
939
927
  private static imxSigner;
940
- constructor(config: Configuration, ethSigner: Signer, starkExSigner: StarkSigner);
941
- static connect(config: Configuration): Promise<MetaMaskIMXProvider>;
928
+ constructor(config: ProviderConfiguration$1, ethSigner: Signer, starkSigner: StarkSigner);
929
+ static connect(config: ProviderConfiguration$1): Promise<MetaMaskIMXProvider>;
942
930
  static disconnect(): Promise<void>;
943
931
  static signMessage(message: string): Promise<string>;
944
932
  }
945
933
 
946
- export { GenericIMXProvider, IMXProvider, MetaMaskIMXProvider };
934
+ declare enum Environment {
935
+ PRODUCTION = "production",
936
+ SANDBOX = "sandbox"
937
+ }
938
+ declare class ImmutableConfiguration {
939
+ readonly environment: Environment;
940
+ readonly apiKey?: string;
941
+ constructor(options: {
942
+ environment: Environment;
943
+ apiKey?: string;
944
+ });
945
+ }
946
+ interface ModuleConfiguration<T> {
947
+ baseConfig: ImmutableConfiguration;
948
+ overrides?: T;
949
+ }
950
+
951
+ interface ProviderOverrides {
952
+ immutableXConfig: ImmutableXConfiguration;
953
+ }
954
+ interface ProviderModuleConfiguration extends ModuleConfiguration<ProviderOverrides> {
955
+ }
956
+ declare class ProviderConfiguration {
957
+ readonly immutableXConfig: ImmutableXConfiguration;
958
+ readonly baseConfig: ImmutableConfiguration;
959
+ constructor({ baseConfig, overrides }: ProviderModuleConfiguration);
960
+ }
961
+
962
+ export { GenericIMXProvider, IMXProvider, MetaMaskIMXProvider, ProviderConfiguration };