@imtbl/passport 2.11.0 → 2.11.1-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.
Files changed (91) hide show
  1. package/dist/browser/index.js +9 -410
  2. package/dist/node/index.cjs +27 -439
  3. package/dist/node/index.js +9 -410
  4. package/dist/types/Passport.d.ts +68 -70
  5. package/dist/types/config/config.d.ts +3 -1
  6. package/dist/types/errors/passportError.d.ts +1 -30
  7. package/dist/types/index.d.ts +4 -4
  8. package/dist/types/starkEx/imxGuardianClient.d.ts +18 -0
  9. package/dist/types/starkEx/passportImxProvider.d.ts +9 -9
  10. package/dist/types/starkEx/passportImxProviderFactory.d.ts +9 -9
  11. package/dist/types/starkEx/workflows/order.d.ts +3 -3
  12. package/dist/types/starkEx/workflows/registerOffchain.d.ts +2 -3
  13. package/dist/types/starkEx/workflows/trades.d.ts +2 -2
  14. package/dist/types/starkEx/workflows/transfer.d.ts +3 -3
  15. package/dist/types/types.d.ts +22 -83
  16. package/dist/types/utils/httpError.d.ts +8 -0
  17. package/dist/types/utils/imxUser.d.ts +9 -0
  18. package/dist/types/utils/metrics.d.ts +0 -1
  19. package/package.json +14 -23
  20. package/dist/types/Passport.int.test.d.ts +0 -1
  21. package/dist/types/authManager.d.ts +0 -61
  22. package/dist/types/authManager.test.d.ts +0 -1
  23. package/dist/types/confirmation/confirmation.d.ts +0 -28
  24. package/dist/types/confirmation/confirmation.test.d.ts +0 -1
  25. package/dist/types/confirmation/embeddedLoginPrompt.d.ts +0 -10
  26. package/dist/types/confirmation/embeddedLoginPrompt.test.d.ts +0 -1
  27. package/dist/types/confirmation/index.d.ts +0 -3
  28. package/dist/types/confirmation/popup.d.ts +0 -8
  29. package/dist/types/confirmation/popup.test.d.ts +0 -1
  30. package/dist/types/confirmation/types.d.ts +0 -33
  31. package/dist/types/guardian/index.d.ts +0 -58
  32. package/dist/types/guardian/index.test.d.ts +0 -1
  33. package/dist/types/magic/index.d.ts +0 -1
  34. package/dist/types/magic/magicTEESigner.d.ts +0 -24
  35. package/dist/types/magic/magicTEESigner.test.d.ts +0 -1
  36. package/dist/types/mocks/zkEvm/msw.d.ts +0 -39
  37. package/dist/types/network/chains.d.ts +0 -32
  38. package/dist/types/network/constants.d.ts +0 -3
  39. package/dist/types/network/retry.d.ts +0 -8
  40. package/dist/types/network/retry.test.d.ts +0 -1
  41. package/dist/types/overlay/confirmationOverlay.d.ts +0 -17
  42. package/dist/types/overlay/confirmationOverlay.test.d.ts +0 -1
  43. package/dist/types/overlay/constants.d.ts +0 -7
  44. package/dist/types/overlay/elements.d.ts +0 -12
  45. package/dist/types/overlay/embeddedLoginPromptOverlay.d.ts +0 -7
  46. package/dist/types/overlay/embeddedLoginPromptOverlay.test.d.ts +0 -1
  47. package/dist/types/starkEx/passportImxProvider.test.d.ts +0 -1
  48. package/dist/types/starkEx/passportImxProviderFactory.test.d.ts +0 -1
  49. package/dist/types/starkEx/workflows/exchange.test.d.ts +0 -1
  50. package/dist/types/starkEx/workflows/order.test.d.ts +0 -1
  51. package/dist/types/starkEx/workflows/registerOffchain.test.d.ts +0 -1
  52. package/dist/types/starkEx/workflows/trades.test.d.ts +0 -1
  53. package/dist/types/starkEx/workflows/transfer.test.d.ts +0 -1
  54. package/dist/types/storage/LocalForageAsyncStorage.d.ts +0 -11
  55. package/dist/types/storage/device_credentials_manager.d.ts +0 -6
  56. package/dist/types/test/mocks.d.ts +0 -56
  57. package/dist/types/utils/metrics.test.d.ts +0 -1
  58. package/dist/types/utils/string.d.ts +0 -1
  59. package/dist/types/utils/string.test.d.ts +0 -1
  60. package/dist/types/utils/token.d.ts +0 -2
  61. package/dist/types/utils/token.test.d.ts +0 -1
  62. package/dist/types/utils/typedEventEmitter.d.ts +0 -6
  63. package/dist/types/utils/typedEventEmitter.test.d.ts +0 -1
  64. package/dist/types/zkEvm/JsonRpcError.d.ts +0 -25
  65. package/dist/types/zkEvm/index.d.ts +0 -2
  66. package/dist/types/zkEvm/personalSign.d.ts +0 -15
  67. package/dist/types/zkEvm/personalSign.test.d.ts +0 -1
  68. package/dist/types/zkEvm/provider/eip6963.d.ts +0 -3
  69. package/dist/types/zkEvm/relayerClient.d.ts +0 -60
  70. package/dist/types/zkEvm/relayerClient.test.d.ts +0 -1
  71. package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.d.ts +0 -6
  72. package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.test.d.ts +0 -1
  73. package/dist/types/zkEvm/sendTransaction.d.ts +0 -6
  74. package/dist/types/zkEvm/sendTransaction.test.d.ts +0 -1
  75. package/dist/types/zkEvm/sessionActivity/errorBoundary.d.ts +0 -1
  76. package/dist/types/zkEvm/sessionActivity/request.d.ts +0 -15
  77. package/dist/types/zkEvm/sessionActivity/sessionActivity.d.ts +0 -2
  78. package/dist/types/zkEvm/signEjectionTransaction.d.ts +0 -6
  79. package/dist/types/zkEvm/signEjectionTransaction.test.d.ts +0 -1
  80. package/dist/types/zkEvm/signTypedDataV4.d.ts +0 -14
  81. package/dist/types/zkEvm/signTypedDataV4.test.d.ts +0 -1
  82. package/dist/types/zkEvm/transactionHelpers.d.ts +0 -31
  83. package/dist/types/zkEvm/transactionHelpers.test.d.ts +0 -1
  84. package/dist/types/zkEvm/types.d.ts +0 -120
  85. package/dist/types/zkEvm/user/index.d.ts +0 -1
  86. package/dist/types/zkEvm/user/registerZkEvmUser.d.ts +0 -13
  87. package/dist/types/zkEvm/user/registerZkEvmUser.test.d.ts +0 -1
  88. package/dist/types/zkEvm/walletHelpers.d.ts +0 -33
  89. package/dist/types/zkEvm/walletHelpers.test.d.ts +0 -1
  90. package/dist/types/zkEvm/zkEvmProvider.d.ts +0 -25
  91. package/dist/types/zkEvm/zkEvmProvider.test.d.ts +0 -1
@@ -1,38 +1,25 @@
1
1
  import { IMXProvider } from '@imtbl/x-provider';
2
- import { MultiRollupApiClients } from '@imtbl/generated-clients';
3
- import { IMXClient } from '@imtbl/x-client';
4
- import AuthManager from './authManager';
5
- import MagicTEESigner from './magic/magicTEESigner';
2
+ import { Environment } from '@imtbl/config';
3
+ import { Auth, UserProfile, DeviceTokenResponse } from '@imtbl/auth';
4
+ import type { DirectLoginOptions } from '@imtbl/auth';
5
+ import { ZkEvmProvider, WalletConfiguration } from '@imtbl/wallet';
6
+ import type { LinkWalletParams, LinkedWallet } from '@imtbl/wallet';
7
+ import { PassportModuleConfiguration, ConnectEvmArguments, LoginArguments } from './types';
6
8
  import { PassportImxProviderFactory } from './starkEx';
7
9
  import { PassportConfiguration } from './config';
8
- import { DirectLoginOptions, DeviceTokenResponse, LinkedWallet, LinkWalletParams, PassportEventMap, PassportModuleConfiguration, UserProfile, ConnectEvmArguments, LoginArguments } from './types';
9
- import { ConfirmationScreen, EmbeddedLoginPrompt } from './confirmation';
10
- import { Provider } from './zkEvm/types';
11
- import TypedEventEmitter from './utils/typedEventEmitter';
12
- import GuardianClient from './guardian';
13
10
  export declare const buildPrivateVars: (passportModuleConfiguration: PassportModuleConfiguration) => {
14
- config: PassportConfiguration;
15
- authManager: AuthManager;
16
- magicTEESigner: MagicTEESigner;
17
- confirmationScreen: ConfirmationScreen;
18
- embeddedLoginPrompt: EmbeddedLoginPrompt;
19
- immutableXClient: IMXClient;
20
- multiRollupApiClients: MultiRollupApiClients;
21
- passportEventEmitter: TypedEventEmitter<PassportEventMap>;
11
+ passportConfig: PassportConfiguration;
12
+ auth: Auth;
22
13
  passportImxProviderFactory: PassportImxProviderFactory;
23
- guardianClient: GuardianClient;
14
+ environment: Environment;
15
+ walletConfig: WalletConfiguration;
24
16
  };
25
17
  export declare class Passport {
26
- private readonly authManager;
27
- private readonly config;
28
- private readonly confirmationScreen;
29
- private readonly embeddedLoginPrompt;
30
- private readonly immutableXClient;
31
- private readonly magicTEESigner;
32
- private readonly multiRollupApiClients;
18
+ private readonly auth;
33
19
  private readonly passportImxProviderFactory;
34
- private readonly passportEventEmitter;
35
- private readonly guardianClient;
20
+ private readonly multiRollupApiClients;
21
+ private readonly environment;
22
+ private readonly passportConfig;
36
23
  constructor(passportModuleConfiguration: PassportModuleConfiguration);
37
24
  /**
38
25
  * Attempts to connect to IMX silently without user interaction.
@@ -47,16 +34,17 @@ export declare class Passport {
47
34
  connectImx(): Promise<IMXProvider>;
48
35
  /**
49
36
  * Connects to EVM and optionally announces the provider.
37
+ * Uses: Auth + Wallet packages
50
38
  * @param {Object} options - Configuration options
51
39
  * @param {boolean} options.announceProvider - Whether to announce the provider via EIP-6963 for wallet discovery (defaults to true)
52
40
  * @returns {Promise<Provider>} The EVM provider instance
53
41
  */
54
- connectEvm(options?: ConnectEvmArguments): Promise<Provider>;
42
+ connectEvm(options?: ConnectEvmArguments): Promise<ZkEvmProvider>;
55
43
  /**
56
- * Initiates the login process.
57
- * @param {Object} options - Login options
58
- * @param {boolean} [options.useCachedSession] - If true, and no active session exists, the user won't be prompted to log in
59
- * @param {string} [options.anonymousId] - ID used to enrich Passport internal metrics
44
+ * Logs in the user (works for both zkEVM and IMX).
45
+ * Uses: Auth class
46
+ * @param {Object} [options] - Login options
47
+ * @param {boolean} [options.useCachedSession] - If true, attempts to use a cached session without user interaction.
60
48
  * @param {boolean} [options.useSilentLogin] - If true, attempts silent authentication without user interaction.
61
49
  * Note: This takes precedence over useCachedSession if both are true
62
50
  * @param {boolean} [options.useRedirectFlow] - If true, uses redirect flow instead of popup flow
@@ -70,70 +58,80 @@ export declare class Passport {
70
58
  */
71
59
  login(options?: LoginArguments): Promise<UserProfile | null>;
72
60
  /**
73
- * Handles the login callback.
74
- * @returns {Promise<void>} A promise that resolves when the callback is processed
61
+ * Handles the login callback from the authentication service.
62
+ * Uses: Auth class
63
+ * @returns {Promise<void>} A promise that resolves when the login callback is handled
75
64
  */
76
65
  loginCallback(): Promise<void>;
77
66
  /**
78
- * Initiates a PKCE flow login.
79
- * @param {DirectLoginOptions} [directLoginOptions] - If provided, directly redirects to the specified login method
80
- * @param {string} [imPassportTraceId] - The trace ID for the PKCE flow
81
- * @returns {string} The authorization URL for the PKCE flow
82
- */
83
- loginWithPKCEFlow(directLoginOptions?: DirectLoginOptions, imPassportTraceId?: string): Promise<string>;
84
- /**
85
- * Handles the PKCE flow login callback.
86
- * @param {string} authorizationCode - The authorization code received from the OAuth provider
87
- * @param {string} state - The state parameter for CSRF protection
88
- * @returns {Promise<UserProfile>} A promise that resolves to the user profile
89
- */
90
- loginWithPKCEFlowCallback(authorizationCode: string, state: string): Promise<UserProfile>;
91
- storeTokens(tokenResponse: DeviceTokenResponse): Promise<UserProfile>;
92
- /**
93
- * Logs out the current user.
94
- * @returns {Promise<void>} A promise that resolves when the logout is complete
67
+ * Logs out the user (works for both zkEVM and IMX).
68
+ * Uses: Auth class
69
+ * @returns {Promise<void>} A promise that resolves when the user is logged out
95
70
  */
96
71
  logout(): Promise<void>;
97
- /**
98
- * Returns the logout URL for the current user.
99
- * @returns {Promise<string>} The logout URL
100
- */
101
- getLogoutUrl(): Promise<string | null>;
102
- /**
103
- * Handles the silent logout callback.
104
- * @param {string} url - The callback URL to process
105
- * @returns {Promise<void>} A promise that resolves when the silent logout is complete
106
- */
107
- logoutSilentCallback(url: string): Promise<void>;
108
72
  /**
109
73
  * Retrieves the current user's information.
74
+ * Uses: Auth class
110
75
  * @returns {Promise<UserProfile | undefined>} A promise that resolves to the user profile if logged in, undefined otherwise
111
76
  */
112
77
  getUserInfo(): Promise<UserProfile | undefined>;
113
78
  /**
114
- * Retrieves the current user's ID token.
79
+ * Retrieves the ID token.
115
80
  * @returns {Promise<string | undefined>} A promise that resolves to the ID token if available, undefined otherwise
116
81
  */
117
82
  getIdToken(): Promise<string | undefined>;
118
83
  /**
119
- * Retrieves the current user's access token.
84
+ * Retrieves the access token.
120
85
  * @returns {Promise<string | undefined>} A promise that resolves to the access token if available, undefined otherwise
121
86
  */
122
87
  getAccessToken(): Promise<string | undefined>;
88
+ /**
89
+ * Retrieves the PKCE authorization URL for the login flow.
90
+ * Uses: Auth class
91
+ * @param {DirectLoginOptions} [directLoginOptions] - Optional direct login options
92
+ * @param {string} [imPassportTraceId] - Optional trace ID
93
+ * @returns {Promise<string>} A promise that resolves to the authorization URL
94
+ */
95
+ loginWithPKCEFlow(directLoginOptions?: DirectLoginOptions, imPassportTraceId?: string): Promise<string>;
96
+ /**
97
+ * Handles the PKCE login callback.
98
+ * Uses: Auth class
99
+ * @param {string} authorizationCode - The authorization code from the OAuth provider
100
+ * @param {string} state - The state parameter for CSRF protection
101
+ * @returns {Promise<UserProfile>} A promise that resolves to the user profile
102
+ */
103
+ loginWithPKCEFlowCallback(authorizationCode: string, state: string): Promise<UserProfile>;
104
+ /**
105
+ * Stores the provided tokens and retrieves the user profile.
106
+ * Uses: Auth class
107
+ * @param {DeviceTokenResponse} tokenResponse - The token response from device flow
108
+ * @returns {Promise<UserProfile>} A promise that resolves to the user profile
109
+ */
110
+ storeTokens(tokenResponse: DeviceTokenResponse): Promise<UserProfile>;
111
+ /**
112
+ * Retrieves the logout URL.
113
+ * @returns {Promise<string | undefined>} A promise that resolves to the logout URL, or undefined if not available
114
+ */
115
+ getLogoutUrl(): Promise<string | undefined>;
116
+ /**
117
+ * Handles the silent logout callback.
118
+ * @param {string} url - The URL containing the logout information
119
+ * @returns {Promise<void>} A promise that resolves when the silent logout callback is handled
120
+ */
121
+ logoutSilentCallback(url: string): Promise<void>;
123
122
  /**
124
123
  * Retrieves the addresses linked to the current user's account.
125
124
  * @returns {Promise<string[]>} A promise that resolves to an array of linked addresses
126
125
  */
127
126
  getLinkedAddresses(): Promise<string[]>;
128
127
  /**
129
- * Links an external wallet to the current user's account.
128
+ * Links an external wallet to the user's Passport account.
130
129
  * @param {LinkWalletParams} params - Parameters for linking the wallet
131
130
  * @returns {Promise<LinkedWallet>} A promise that resolves to the linked wallet information
132
- * @throws {PassportError} When:
133
- * - User is not logged in (NOT_LOGGED_IN_ERROR)
134
- * - User is not registered (USER_NOT_REGISTERED_ERROR)
135
- * - Wallet is already linked (LINK_WALLET_ALREADY_LINKED_ERROR)
136
- * - Maximum number of wallets reached (LINK_WALLET_MAX_WALLETS_LINKED_ERROR)
131
+ * @throws {PassportError} If the user is not logged in (NOT_LOGGED_IN_ERROR)
132
+ * - If the user is not registered with StarkEx (USER_NOT_REGISTERED_ERROR)
133
+ * - If the wallet is already linked (LINK_WALLET_ALREADY_LINKED_ERROR)
134
+ * - If the maximum number of wallets are linked (LINK_WALLET_MAX_WALLETS_LINKED_ERROR)
137
135
  * - Duplicate nonce used (LINK_WALLET_DUPLICATE_NONCE_ERROR)
138
136
  * - Validation fails (LINK_WALLET_VALIDATION_ERROR)
139
137
  * - Other generic errors (LINK_WALLET_GENERIC_ERROR)
@@ -1,6 +1,6 @@
1
1
  import { ImmutableConfiguration } from '@imtbl/config';
2
2
  import { MultiRollupAPIConfiguration } from '@imtbl/generated-clients';
3
- import { OidcConfiguration, PassportModuleConfiguration, PopupOverlayOptions } from '../types';
3
+ import { OidcConfiguration, PassportModuleConfiguration, PopupOverlayOptions, PassportOverrides } from '../types';
4
4
  export declare class PassportConfiguration {
5
5
  readonly authenticationDomain: string;
6
6
  readonly passportDomain: string;
@@ -16,6 +16,8 @@ export declare class PassportConfiguration {
16
16
  readonly multiRollupConfig: MultiRollupAPIConfiguration;
17
17
  readonly crossSdkBridgeEnabled: boolean;
18
18
  readonly forceScwDeployBeforeMessageSignature: boolean;
19
+ readonly jsonRpcReferrer?: string;
19
20
  readonly popupOverlayOptions: PopupOverlayOptions;
21
+ readonly overrides?: PassportOverrides;
20
22
  constructor({ baseConfig, overrides, crossSdkBridgeEnabled, jsonRpcReferrer, forceScwDeployBeforeMessageSignature, popupOverlayOptions, ...oidcConfiguration }: PassportModuleConfiguration);
21
23
  }
@@ -1,30 +1 @@
1
- import { imx } from '@imtbl/generated-clients';
2
- export declare enum PassportErrorType {
3
- AUTHENTICATION_ERROR = "AUTHENTICATION_ERROR",
4
- INVALID_CONFIGURATION = "INVALID_CONFIGURATION",
5
- WALLET_CONNECTION_ERROR = "WALLET_CONNECTION_ERROR",
6
- NOT_LOGGED_IN_ERROR = "NOT_LOGGED_IN_ERROR",
7
- SILENT_LOGIN_ERROR = "SILENT_LOGIN_ERROR",
8
- REFRESH_TOKEN_ERROR = "REFRESH_TOKEN_ERROR",
9
- USER_REGISTRATION_ERROR = "USER_REGISTRATION_ERROR",
10
- USER_NOT_REGISTERED_ERROR = "USER_NOT_REGISTERED_ERROR",
11
- LOGOUT_ERROR = "LOGOUT_ERROR",
12
- TRANSFER_ERROR = "TRANSFER_ERROR",
13
- CREATE_ORDER_ERROR = "CREATE_ORDER_ERROR",
14
- CANCEL_ORDER_ERROR = "CANCEL_ORDER_ERROR",
15
- EXCHANGE_TRANSFER_ERROR = "EXCHANGE_TRANSFER_ERROR",
16
- CREATE_TRADE_ERROR = "CREATE_TRADE_ERROR",
17
- OPERATION_NOT_SUPPORTED_ERROR = "OPERATION_NOT_SUPPORTED_ERROR",
18
- LINK_WALLET_ALREADY_LINKED_ERROR = "LINK_WALLET_ALREADY_LINKED_ERROR",
19
- LINK_WALLET_MAX_WALLETS_LINKED_ERROR = "LINK_WALLET_MAX_WALLETS_LINKED_ERROR",
20
- LINK_WALLET_VALIDATION_ERROR = "LINK_WALLET_VALIDATION_ERROR",
21
- LINK_WALLET_DUPLICATE_NONCE_ERROR = "LINK_WALLET_DUPLICATE_NONCE_ERROR",
22
- LINK_WALLET_GENERIC_ERROR = "LINK_WALLET_GENERIC_ERROR",
23
- SERVICE_UNAVAILABLE_ERROR = "SERVICE_UNAVAILABLE_ERROR"
24
- }
25
- export declare function isAPIError(error: any): error is imx.APIError;
26
- export declare class PassportError extends Error {
27
- type: PassportErrorType;
28
- constructor(message: string, type: PassportErrorType);
29
- }
30
- export declare const withPassportError: <T>(fn: () => Promise<T>, customErrorType: PassportErrorType) => Promise<T>;
1
+ export { PassportError, PassportErrorType, withPassportError, isAPIError, } from '@imtbl/auth';
@@ -1,7 +1,7 @@
1
1
  export { PassportError } from './errors/passportError';
2
2
  export { Passport } from './Passport';
3
- export { ProviderEvent, } from './zkEvm/types';
4
- export type { RequestArguments, JsonRpcRequestPayload, JsonRpcResponsePayload, JsonRpcRequestCallback, Provider, AccountsChangedEvent, TypedDataPayload, } from './zkEvm/types';
5
- export { JsonRpcError, ProviderErrorCode, RpcErrorCode, } from './zkEvm/JsonRpcError';
6
- export type { LinkWalletParams, LinkedWallet, ConnectEvmArguments, LoginArguments, UserProfile, PassportOverrides, PassportModuleConfiguration, DeviceTokenResponse, DirectLoginOptions, DirectLoginMethod, } from './types';
3
+ export { ProviderEvent, JsonRpcError, ProviderErrorCode, RpcErrorCode, } from '@imtbl/wallet';
4
+ export type { RequestArguments, Provider, AccountsChangedEvent, TypedDataPayload, EIP6963ProviderInfo, EIP6963ProviderDetail, } from '@imtbl/wallet';
5
+ export type { User, } from '@imtbl/auth';
6
+ export type { LinkWalletParams, LinkedWallet, ConnectEvmArguments, LoginArguments, UserProfile, PassportOverrides, PassportModuleConfiguration, DeviceTokenResponse, DirectLoginOptions, DirectLoginMethod, ZkEvmProvider, } from './types';
7
7
  export { MarketingConsentStatus, } from './types';
@@ -0,0 +1,18 @@
1
+ import { Auth } from '@imtbl/auth';
2
+ import { mr as MultiRollup } from '@imtbl/generated-clients';
3
+ import { ConfirmationScreen } from '@imtbl/wallet';
4
+ type ImxGuardianClientParams = {
5
+ auth: Auth;
6
+ guardianApi: MultiRollup.GuardianApi;
7
+ confirmationScreen: ConfirmationScreen;
8
+ crossSdkBridgeEnabled?: boolean;
9
+ };
10
+ export declare class ImxGuardianClient {
11
+ private readonly auth;
12
+ private readonly guardianApi;
13
+ private readonly confirmationScreen;
14
+ private readonly crossSdkBridgeEnabled;
15
+ constructor({ auth, guardianApi, confirmationScreen, crossSdkBridgeEnabled, }: ImxGuardianClientParams);
16
+ evaluateTransaction(payloadHash: string): Promise<void>;
17
+ }
18
+ export {};
@@ -2,26 +2,26 @@ import { AnyToken, IMXClient, NftTransferDetails, TokenAmount, UnsignedExchangeT
2
2
  import { IMXProvider } from '@imtbl/x-provider';
3
3
  import { imx, ImxApiClients } from '@imtbl/generated-clients';
4
4
  import { TransactionResponse } from 'ethers';
5
- import AuthManager from '../authManager';
6
- import GuardianClient from '../guardian';
7
- import { PassportEventMap } from '../types';
8
- import MagicTEESigner from '../magic/magicTEESigner';
9
- import TypedEventEmitter from '../utils/typedEventEmitter';
5
+ import { Auth, AuthEventMap, TypedEventEmitter } from '@imtbl/auth';
6
+ import { GuardianClient, MagicTEESigner } from '@imtbl/wallet';
7
+ import { ImxGuardianClient } from './imxGuardianClient';
10
8
  export interface PassportImxProviderOptions {
11
- authManager: AuthManager;
9
+ auth: Auth;
12
10
  immutableXClient: IMXClient;
13
- passportEventEmitter: TypedEventEmitter<PassportEventMap>;
11
+ passportEventEmitter: TypedEventEmitter<AuthEventMap>;
14
12
  magicTEESigner: MagicTEESigner;
15
13
  imxApiClients: ImxApiClients;
16
14
  guardianClient: GuardianClient;
15
+ imxGuardianClient: ImxGuardianClient;
17
16
  }
18
17
  export declare class PassportImxProvider implements IMXProvider {
19
18
  #private;
20
- protected readonly authManager: AuthManager;
19
+ protected readonly auth: Auth;
21
20
  private readonly immutableXClient;
22
21
  protected readonly guardianClient: GuardianClient;
23
22
  protected readonly imxApiClients: ImxApiClients;
24
23
  protected magicTEESigner: MagicTEESigner;
24
+ private readonly imxGuardianClient;
25
25
  /**
26
26
  * This property is set during initialisation and stores the signers in a promise.
27
27
  * This property is not meant to be accessed directly, but through the
@@ -30,7 +30,7 @@ export declare class PassportImxProvider implements IMXProvider {
30
30
  */
31
31
  private starkSigner;
32
32
  private signerInitialisationError;
33
- constructor({ authManager, immutableXClient, passportEventEmitter, magicTEESigner, imxApiClients, guardianClient, }: PassportImxProviderOptions);
33
+ constructor({ auth, immutableXClient, passportEventEmitter, magicTEESigner, imxApiClients, guardianClient, imxGuardianClient, }: PassportImxProviderOptions);
34
34
  private handleLogout;
35
35
  transfer(request: UnsignedTransferRequest): Promise<imx.CreateTransferResponseV1>;
36
36
  registerOffchain(): Promise<imx.RegisterUserResponse>;
@@ -1,27 +1,27 @@
1
1
  import { IMXClient } from '@imtbl/x-client';
2
2
  import { IMXProvider } from '@imtbl/x-provider';
3
3
  import { ImxApiClients } from '@imtbl/generated-clients';
4
- import AuthManager from '../authManager';
5
- import { PassportEventMap } from '../types';
6
- import GuardianClient from '../guardian';
7
- import MagicTEESigner from '../magic/magicTEESigner';
8
- import TypedEventEmitter from '../utils/typedEventEmitter';
4
+ import { Auth, AuthEventMap, TypedEventEmitter } from '@imtbl/auth';
5
+ import { GuardianClient, MagicTEESigner } from '@imtbl/wallet';
6
+ import { ImxGuardianClient } from './imxGuardianClient';
9
7
  export type PassportImxProviderFactoryInput = {
10
- authManager: AuthManager;
8
+ auth: Auth;
11
9
  immutableXClient: IMXClient;
12
10
  magicTEESigner: MagicTEESigner;
13
- passportEventEmitter: TypedEventEmitter<PassportEventMap>;
11
+ passportEventEmitter: TypedEventEmitter<AuthEventMap>;
14
12
  imxApiClients: ImxApiClients;
15
13
  guardianClient: GuardianClient;
14
+ imxGuardianClient: ImxGuardianClient;
16
15
  };
17
16
  export declare class PassportImxProviderFactory {
18
- private readonly authManager;
17
+ private readonly auth;
19
18
  private readonly immutableXClient;
20
19
  private readonly magicTEESigner;
21
20
  private readonly passportEventEmitter;
22
21
  readonly imxApiClients: ImxApiClients;
23
22
  private readonly guardianClient;
24
- constructor({ authManager, immutableXClient, magicTEESigner, passportEventEmitter, imxApiClients, guardianClient, }: PassportImxProviderFactoryInput);
23
+ private readonly imxGuardianClient;
24
+ constructor({ auth, immutableXClient, magicTEESigner, passportEventEmitter, imxApiClients, guardianClient, imxGuardianClient, }: PassportImxProviderFactoryInput);
25
25
  getProvider(): Promise<IMXProvider>;
26
26
  getProviderSilent(): Promise<IMXProvider | null>;
27
27
  private createProviderInstance;
@@ -1,20 +1,20 @@
1
1
  import { imx } from '@imtbl/generated-clients';
2
2
  import { StarkSigner, UnsignedOrderRequest } from '@imtbl/x-client';
3
+ import { ImxGuardianClient } from '../imxGuardianClient';
3
4
  import { UserImx } from '../../types';
4
- import GuardianClient from '../../guardian';
5
5
  type CancelOrderParams = {
6
6
  request: imx.GetSignableCancelOrderRequest;
7
7
  ordersApi: imx.OrdersApi;
8
8
  user: UserImx;
9
9
  starkSigner: StarkSigner;
10
- guardianClient: GuardianClient;
10
+ guardianClient: ImxGuardianClient;
11
11
  };
12
12
  type CreateOrderParams = {
13
13
  request: UnsignedOrderRequest;
14
14
  ordersApi: imx.OrdersApi;
15
15
  user: UserImx;
16
16
  starkSigner: StarkSigner;
17
- guardianClient: GuardianClient;
17
+ guardianClient: ImxGuardianClient;
18
18
  };
19
19
  export declare function createOrder({ starkSigner, user, request, ordersApi, guardianClient, }: CreateOrderParams): Promise<imx.CreateOrderResponse>;
20
20
  export declare function cancelOrder({ user, starkSigner, request, ordersApi, guardianClient, }: CancelOrderParams): Promise<imx.CancelOrderResponse>;
@@ -1,5 +1,4 @@
1
1
  import { ImxApiClients, imx } from '@imtbl/generated-clients';
2
2
  import { EthSigner, StarkSigner } from '@imtbl/x-client';
3
- import AuthManager from '../../authManager';
4
- import { User } from '../../types';
5
- export default function registerOffchain(userAdminKeySigner: EthSigner, starkSigner: StarkSigner, unregisteredUser: User, authManager: AuthManager, imxApiClients: ImxApiClients): Promise<imx.RegisterUserResponse>;
3
+ import { Auth, User } from '@imtbl/auth';
4
+ export default function registerOffchain(userAdminKeySigner: EthSigner, starkSigner: StarkSigner, unregisteredUser: User, auth: Auth, imxApiClients: ImxApiClients): Promise<imx.RegisterUserResponse>;
@@ -1,13 +1,13 @@
1
1
  import { imx } from '@imtbl/generated-clients';
2
2
  import { StarkSigner } from '@imtbl/x-client';
3
+ import { ImxGuardianClient } from '../imxGuardianClient';
3
4
  import { UserImx } from '../../types';
4
- import GuardianClient from '../../guardian';
5
5
  type CreateTradeParams = {
6
6
  request: imx.GetSignableTradeRequest;
7
7
  tradesApi: imx.TradesApi;
8
8
  user: UserImx;
9
9
  starkSigner: StarkSigner;
10
- guardianClient: GuardianClient;
10
+ guardianClient: ImxGuardianClient;
11
11
  };
12
12
  export declare function createTrade({ request, tradesApi, user, starkSigner, guardianClient, }: CreateTradeParams): Promise<imx.CreateTradeResponse>;
13
13
  export {};
@@ -1,20 +1,20 @@
1
1
  import { imx } from '@imtbl/generated-clients';
2
2
  import { StarkSigner, NftTransferDetails, UnsignedTransferRequest } from '@imtbl/x-client';
3
+ import { ImxGuardianClient } from '../imxGuardianClient';
3
4
  import { UserImx } from '../../types';
4
- import GuardianClient from '../../guardian';
5
5
  type TransferRequest = {
6
6
  request: UnsignedTransferRequest;
7
7
  user: UserImx;
8
8
  starkSigner: StarkSigner;
9
9
  transfersApi: imx.TransfersApi;
10
- guardianClient: GuardianClient;
10
+ guardianClient: ImxGuardianClient;
11
11
  };
12
12
  type BatchTransfersParams = {
13
13
  request: Array<NftTransferDetails>;
14
14
  user: UserImx;
15
15
  starkSigner: StarkSigner;
16
16
  transfersApi: imx.TransfersApi;
17
- guardianClient: GuardianClient;
17
+ guardianClient: ImxGuardianClient;
18
18
  };
19
19
  export declare function transfer({ request, transfersApi, starkSigner, user, guardianClient, }: TransferRequest): Promise<imx.CreateTransferResponseV1>;
20
20
  export declare function batchNftTransfer({ user, starkSigner, request, transfersApi, guardianClient, }: BatchTransfersParams): Promise<imx.CreateTransferResponse>;
@@ -8,11 +8,8 @@ import { Flow } from '@imtbl/metrics';
8
8
  * Additional providers may be supported server-side
9
9
  */
10
10
  export type DirectLoginMethod = string;
11
- export declare enum PassportEvents {
12
- LOGGED_OUT = "loggedOut",
13
- LOGGED_IN = "loggedIn",
14
- ACCOUNTS_REQUESTED = "accountsRequested"
15
- }
11
+ export { AuthEvents } from '@imtbl/auth';
12
+ export { WalletEvents } from '@imtbl/wallet';
16
13
  export type AccountsRequestedEvent = {
17
14
  environment: Environment;
18
15
  sendTransaction: (params: Array<any>, flow: Flow) => Promise<string>;
@@ -20,44 +17,9 @@ export type AccountsRequestedEvent = {
20
17
  passportClient: string;
21
18
  flow?: Flow;
22
19
  };
23
- export interface PassportEventMap extends Record<string, any> {
24
- [PassportEvents.LOGGED_OUT]: [];
25
- [PassportEvents.LOGGED_IN]: [User];
26
- [PassportEvents.ACCOUNTS_REQUESTED]: [AccountsRequestedEvent];
27
- }
28
- export type UserProfile = {
29
- email?: string;
30
- nickname?: string;
31
- sub: string;
32
- username?: string;
33
- };
34
- export declare enum RollupType {
35
- IMX = "imx",
36
- ZKEVM = "zkEvm"
37
- }
38
- export type User = {
39
- idToken?: string;
40
- accessToken: string;
41
- refreshToken?: string;
42
- profile: UserProfile;
43
- expired?: boolean;
44
- [RollupType.IMX]?: {
45
- ethAddress: string;
46
- starkAddress: string;
47
- userAdminAddress: string;
48
- };
49
- [RollupType.ZKEVM]?: {
50
- ethAddress: string;
51
- userAdminAddress: string;
52
- };
53
- };
54
- export type PassportMetadata = {
55
- imx_eth_address: string;
56
- imx_stark_address: string;
57
- imx_user_admin_address: string;
58
- zkevm_eth_address: string;
59
- zkevm_user_admin_address: string;
60
- };
20
+ export type { User, UserProfile, DeviceTokenResponse, IdTokenPayload, } from '@imtbl/auth';
21
+ export { isUserZkEvm } from '@imtbl/auth';
22
+ export type { UserImx } from './utils/imxUser';
61
23
  export interface OidcConfiguration {
62
24
  clientId: string;
63
25
  logoutRedirectUri?: string;
@@ -80,6 +42,21 @@ export interface PassportOverrides {
80
42
  orderBookMrBasePath: string;
81
43
  passportMrBasePath: string;
82
44
  imxApiClients?: ImxApiClients;
45
+ /**
46
+ * Custom chain ID for dev environments (optional)
47
+ * If provided, overrides the default chainId based on environment
48
+ */
49
+ zkEvmChainId?: number;
50
+ /**
51
+ * Custom chain name for dev environments (optional)
52
+ * Used when zkEvmChainId is provided
53
+ */
54
+ zkEvmChainName?: string;
55
+ /**
56
+ * Magic TEE base path (optional, for dev/custom environments)
57
+ * Defaults to 'https://tee.express.magiclabs.com'
58
+ */
59
+ magicTeeBasePath?: string;
83
60
  }
84
61
  export interface PopupOverlayOptions {
85
62
  disableGenericPopupOverlay?: boolean;
@@ -109,55 +86,18 @@ export interface PassportModuleConfiguration extends ModuleConfiguration<Passpor
109
86
  */
110
87
  forceScwDeployBeforeMessageSignature?: boolean;
111
88
  }
112
- type WithRequired<T, K extends keyof T> = T & {
113
- [P in K]-?: T[P];
114
- };
115
- export type UserImx = WithRequired<User, RollupType.IMX>;
116
- export type UserZkEvm = WithRequired<User, RollupType.ZKEVM>;
117
- export declare const isUserZkEvm: (user: User) => user is UserZkEvm;
118
- export declare const isUserImx: (user: User) => user is UserImx;
119
- export type DeviceTokenResponse = {
120
- access_token: string;
121
- refresh_token?: string;
122
- id_token: string;
123
- token_type: string;
124
- expires_in: number;
125
- };
126
89
  export type TokenPayload = {
127
90
  exp?: number;
128
91
  };
129
- export type IdTokenPayload = {
130
- passport?: PassportMetadata;
131
- email: string;
132
- nickname: string;
133
- username?: string;
134
- aud: string;
135
- sub: string;
136
- exp: number;
137
- iss: string;
138
- iat: number;
139
- };
140
92
  export type PKCEData = {
141
93
  state: string;
142
94
  verifier: string;
143
95
  };
144
- export type LinkWalletParams = {
145
- type: string;
146
- walletAddress: string;
147
- signature: string;
148
- nonce: string;
149
- };
150
- export type LinkedWallet = {
151
- address: string;
152
- type: string;
153
- created_at: string;
154
- updated_at: string;
155
- name?: string;
156
- clientName: string;
157
- };
96
+ export type { LinkWalletParams, LinkedWallet } from '@imtbl/wallet';
158
97
  export type ConnectEvmArguments = {
159
98
  announceProvider: boolean;
160
99
  };
100
+ export type { ZkEvmProvider } from '@imtbl/wallet';
161
101
  export type LoginArguments = {
162
102
  useCachedSession?: boolean;
163
103
  anonymousId?: string;
@@ -178,4 +118,3 @@ export type DirectLoginOptions = {
178
118
  directLoginMethod: Exclude<DirectLoginMethod, 'email'>;
179
119
  email?: never;
180
120
  });
181
- export {};
@@ -0,0 +1,8 @@
1
+ type HttpErrorResponse = {
2
+ status?: number;
3
+ data?: unknown;
4
+ };
5
+ export declare const getHttpErrorResponse: (error: unknown) => HttpErrorResponse | undefined;
6
+ export declare const getHttpStatus: (error: unknown) => number | undefined;
7
+ export declare const getHttpResponseData: <T>(error: unknown) => T | undefined;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { User } from '@imtbl/auth';
2
+ export type UserImx = User & {
3
+ imx: {
4
+ ethAddress: string;
5
+ starkAddress: string;
6
+ userAdminAddress: string;
7
+ };
8
+ };
9
+ export declare const toUserImx: (user: User) => UserImx;
@@ -1,3 +1,2 @@
1
1
  import { Flow } from '@imtbl/metrics';
2
- export declare const withMetrics: <T>(fn: (flow: Flow) => T, flowName: string, trackStartEvent?: boolean, trackEndEvent?: boolean) => T;
3
2
  export declare const withMetricsAsync: <T>(fn: (flow: Flow) => Promise<T>, flowName: string, trackStartEvent?: boolean, trackEndEvent?: boolean) => Promise<T>;