@imtbl/passport 2.10.7-alpha.5 → 2.10.7-alpha.7

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 +410 -10
  2. package/dist/node/index.cjs +437 -29
  3. package/dist/node/index.js +410 -10
  4. package/dist/types/Passport.d.ts +70 -68
  5. package/dist/types/Passport.int.test.d.ts +1 -0
  6. package/dist/types/Passport.test.d.ts +1 -0
  7. package/dist/types/authManager.d.ts +61 -0
  8. package/dist/types/authManager.test.d.ts +1 -0
  9. package/dist/types/config/config.d.ts +1 -3
  10. package/dist/types/confirmation/confirmation.d.ts +28 -0
  11. package/dist/types/confirmation/confirmation.test.d.ts +1 -0
  12. package/dist/types/confirmation/embeddedLoginPrompt.d.ts +10 -0
  13. package/dist/types/confirmation/embeddedLoginPrompt.test.d.ts +1 -0
  14. package/dist/types/confirmation/index.d.ts +3 -0
  15. package/dist/types/confirmation/popup.d.ts +8 -0
  16. package/dist/types/confirmation/popup.test.d.ts +1 -0
  17. package/dist/types/confirmation/types.d.ts +33 -0
  18. package/dist/types/errors/passportError.d.ts +1 -2
  19. package/dist/types/guardian/index.d.ts +58 -0
  20. package/dist/types/guardian/index.test.d.ts +1 -0
  21. package/dist/types/index.d.ts +4 -4
  22. package/dist/types/magic/index.d.ts +1 -0
  23. package/dist/types/magic/magicTEESigner.d.ts +24 -0
  24. package/dist/types/magic/magicTEESigner.test.d.ts +1 -0
  25. package/dist/types/mocks/zkEvm/msw.d.ts +39 -0
  26. package/dist/types/network/chains.d.ts +32 -0
  27. package/dist/types/network/constants.d.ts +3 -0
  28. package/dist/types/network/retry.d.ts +8 -0
  29. package/dist/types/network/retry.test.d.ts +1 -0
  30. package/dist/types/overlay/confirmationOverlay.d.ts +17 -0
  31. package/dist/types/overlay/confirmationOverlay.test.d.ts +1 -0
  32. package/dist/types/overlay/constants.d.ts +7 -0
  33. package/dist/types/overlay/elements.d.ts +12 -0
  34. package/dist/types/overlay/embeddedLoginPromptOverlay.d.ts +7 -0
  35. package/dist/types/overlay/embeddedLoginPromptOverlay.test.d.ts +1 -0
  36. package/dist/types/starkEx/passportImxProvider.d.ts +7 -7
  37. package/dist/types/starkEx/passportImxProvider.test.d.ts +1 -0
  38. package/dist/types/starkEx/passportImxProviderFactory.d.ts +7 -7
  39. package/dist/types/starkEx/passportImxProviderFactory.test.d.ts +1 -0
  40. package/dist/types/starkEx/workflows/exchange.test.d.ts +1 -0
  41. package/dist/types/starkEx/workflows/order.d.ts +3 -3
  42. package/dist/types/starkEx/workflows/order.test.d.ts +1 -0
  43. package/dist/types/starkEx/workflows/registerOffchain.d.ts +2 -1
  44. package/dist/types/starkEx/workflows/registerOffchain.test.d.ts +1 -0
  45. package/dist/types/starkEx/workflows/trades.d.ts +2 -2
  46. package/dist/types/starkEx/workflows/trades.test.d.ts +1 -0
  47. package/dist/types/starkEx/workflows/transfer.d.ts +3 -3
  48. package/dist/types/starkEx/workflows/transfer.test.d.ts +1 -0
  49. package/dist/types/storage/LocalForageAsyncStorage.d.ts +11 -0
  50. package/dist/types/storage/device_credentials_manager.d.ts +6 -0
  51. package/dist/types/test/mocks.d.ts +56 -0
  52. package/dist/types/types.d.ts +81 -22
  53. package/dist/types/utils/metrics.d.ts +1 -0
  54. package/dist/types/utils/metrics.test.d.ts +1 -0
  55. package/dist/types/utils/string.d.ts +1 -0
  56. package/dist/types/utils/string.test.d.ts +1 -0
  57. package/dist/types/utils/token.d.ts +2 -0
  58. package/dist/types/utils/token.test.d.ts +1 -0
  59. package/dist/types/utils/typedEventEmitter.d.ts +6 -0
  60. package/dist/types/utils/typedEventEmitter.test.d.ts +1 -0
  61. package/dist/types/zkEvm/JsonRpcError.d.ts +25 -0
  62. package/dist/types/zkEvm/index.d.ts +2 -0
  63. package/dist/types/zkEvm/personalSign.d.ts +15 -0
  64. package/dist/types/zkEvm/personalSign.test.d.ts +1 -0
  65. package/dist/types/zkEvm/provider/eip6963.d.ts +3 -0
  66. package/dist/types/zkEvm/relayerClient.d.ts +60 -0
  67. package/dist/types/zkEvm/relayerClient.test.d.ts +1 -0
  68. package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.d.ts +6 -0
  69. package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.test.d.ts +1 -0
  70. package/dist/types/zkEvm/sendTransaction.d.ts +6 -0
  71. package/dist/types/zkEvm/sendTransaction.test.d.ts +1 -0
  72. package/dist/types/zkEvm/sessionActivity/errorBoundary.d.ts +1 -0
  73. package/dist/types/zkEvm/sessionActivity/request.d.ts +15 -0
  74. package/dist/types/zkEvm/sessionActivity/sessionActivity.d.ts +2 -0
  75. package/dist/types/zkEvm/signEjectionTransaction.d.ts +6 -0
  76. package/dist/types/zkEvm/signEjectionTransaction.test.d.ts +1 -0
  77. package/dist/types/zkEvm/signTypedDataV4.d.ts +14 -0
  78. package/dist/types/zkEvm/signTypedDataV4.test.d.ts +1 -0
  79. package/dist/types/zkEvm/transactionHelpers.d.ts +31 -0
  80. package/dist/types/zkEvm/transactionHelpers.test.d.ts +1 -0
  81. package/dist/types/zkEvm/types.d.ts +120 -0
  82. package/dist/types/zkEvm/user/index.d.ts +1 -0
  83. package/dist/types/zkEvm/user/registerZkEvmUser.d.ts +13 -0
  84. package/dist/types/zkEvm/user/registerZkEvmUser.test.d.ts +1 -0
  85. package/dist/types/zkEvm/walletHelpers.d.ts +33 -0
  86. package/dist/types/zkEvm/walletHelpers.test.d.ts +1 -0
  87. package/dist/types/zkEvm/zkEvmProvider.d.ts +25 -0
  88. package/dist/types/zkEvm/zkEvmProvider.test.d.ts +1 -0
  89. package/package.json +17 -11
  90. package/dist/types/starkEx/imxGuardianClient.d.ts +0 -18
  91. package/dist/types/utils/imxUser.d.ts +0 -9
@@ -1,25 +1,38 @@
1
1
  import { IMXProvider } from '@imtbl/x-provider';
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';
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';
8
6
  import { PassportImxProviderFactory } from './starkEx';
9
7
  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';
10
13
  export declare const buildPrivateVars: (passportModuleConfiguration: PassportModuleConfiguration) => {
11
- passportConfig: PassportConfiguration;
12
- auth: Auth;
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>;
13
22
  passportImxProviderFactory: PassportImxProviderFactory;
14
- environment: Environment;
15
- walletConfig: WalletConfiguration;
23
+ guardianClient: GuardianClient;
16
24
  };
17
25
  export declare class Passport {
18
- private readonly auth;
19
- private readonly passportImxProviderFactory;
26
+ private readonly authManager;
27
+ private readonly config;
28
+ private readonly confirmationScreen;
29
+ private readonly embeddedLoginPrompt;
30
+ private readonly immutableXClient;
31
+ private readonly magicTEESigner;
20
32
  private readonly multiRollupApiClients;
21
- private readonly environment;
22
- private readonly passportConfig;
33
+ private readonly passportImxProviderFactory;
34
+ private readonly passportEventEmitter;
35
+ private readonly guardianClient;
23
36
  constructor(passportModuleConfiguration: PassportModuleConfiguration);
24
37
  /**
25
38
  * Attempts to connect to IMX silently without user interaction.
@@ -34,17 +47,16 @@ export declare class Passport {
34
47
  connectImx(): Promise<IMXProvider>;
35
48
  /**
36
49
  * Connects to EVM and optionally announces the provider.
37
- * Uses: Auth + Wallet packages
38
50
  * @param {Object} options - Configuration options
39
51
  * @param {boolean} options.announceProvider - Whether to announce the provider via EIP-6963 for wallet discovery (defaults to true)
40
52
  * @returns {Promise<Provider>} The EVM provider instance
41
53
  */
42
- connectEvm(options?: ConnectEvmArguments): Promise<ZkEvmProvider>;
54
+ connectEvm(options?: ConnectEvmArguments): Promise<Provider>;
43
55
  /**
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.
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
48
60
  * @param {boolean} [options.useSilentLogin] - If true, attempts silent authentication without user interaction.
49
61
  * Note: This takes precedence over useCachedSession if both are true
50
62
  * @param {boolean} [options.useRedirectFlow] - If true, uses redirect flow instead of popup flow
@@ -58,80 +70,70 @@ export declare class Passport {
58
70
  */
59
71
  login(options?: LoginArguments): Promise<UserProfile | null>;
60
72
  /**
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
73
+ * Handles the login callback.
74
+ * @returns {Promise<void>} A promise that resolves when the callback is processed
64
75
  */
65
76
  loginCallback(): Promise<void>;
66
77
  /**
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
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
70
95
  */
71
96
  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>;
72
108
  /**
73
109
  * Retrieves the current user's information.
74
- * Uses: Auth class
75
110
  * @returns {Promise<UserProfile | undefined>} A promise that resolves to the user profile if logged in, undefined otherwise
76
111
  */
77
112
  getUserInfo(): Promise<UserProfile | undefined>;
78
113
  /**
79
- * Retrieves the ID token.
114
+ * Retrieves the current user's ID token.
80
115
  * @returns {Promise<string | undefined>} A promise that resolves to the ID token if available, undefined otherwise
81
116
  */
82
117
  getIdToken(): Promise<string | undefined>;
83
118
  /**
84
- * Retrieves the access token.
119
+ * Retrieves the current user's access token.
85
120
  * @returns {Promise<string | undefined>} A promise that resolves to the access token if available, undefined otherwise
86
121
  */
87
122
  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>;
122
123
  /**
123
124
  * Retrieves the addresses linked to the current user's account.
124
125
  * @returns {Promise<string[]>} A promise that resolves to an array of linked addresses
125
126
  */
126
127
  getLinkedAddresses(): Promise<string[]>;
127
128
  /**
128
- * Links an external wallet to the user's Passport account.
129
+ * Links an external wallet to the current user's account.
129
130
  * @param {LinkWalletParams} params - Parameters for linking the wallet
130
131
  * @returns {Promise<LinkedWallet>} A promise that resolves to the linked wallet information
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)
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)
135
137
  * - Duplicate nonce used (LINK_WALLET_DUPLICATE_NONCE_ERROR)
136
138
  * - Validation fails (LINK_WALLET_VALIDATION_ERROR)
137
139
  * - Other generic errors (LINK_WALLET_GENERIC_ERROR)
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ import { DirectLoginOptions, User, DeviceTokenResponse, UserZkEvm, UserImx } from './types';
2
+ import { PassportConfiguration } from './config';
3
+ import { EmbeddedLoginPrompt } from './confirmation';
4
+ export default class AuthManager {
5
+ private userManager;
6
+ private deviceCredentialsManager;
7
+ private readonly config;
8
+ private readonly embeddedLoginPrompt;
9
+ private readonly logoutMode;
10
+ /**
11
+ * Promise that is used to prevent multiple concurrent calls to the refresh token endpoint.
12
+ */
13
+ private refreshingPromise;
14
+ constructor(config: PassportConfiguration, embeddedLoginPrompt: EmbeddedLoginPrompt);
15
+ private static mapOidcUserToDomainModel;
16
+ private static mapDeviceTokenResponseToOidcUser;
17
+ private buildExtraQueryParams;
18
+ loginWithRedirect(anonymousId?: string, directLoginOptions?: DirectLoginOptions): Promise<void>;
19
+ /**
20
+ * login
21
+ * @param anonymousId Caller can pass an anonymousId if they want to associate their user's identity with immutable's internal instrumentation.
22
+ * @param directLoginOptions If provided, contains login method and marketing consent options
23
+ * @param directLoginOptions.directLoginMethod The login method to use (e.g., 'google', 'apple', 'email')
24
+ * @param directLoginOptions.marketingConsentStatus Marketing consent status ('opted_in' or 'unsubscribed')
25
+ * @param directLoginOptions.email Required when directLoginMethod is 'email'
26
+ */
27
+ login(anonymousId?: string, directLoginOptions?: DirectLoginOptions): Promise<User>;
28
+ getUserOrLogin(): Promise<User>;
29
+ loginCallback(): Promise<undefined | User>;
30
+ getPKCEAuthorizationUrl(directLoginOptions?: DirectLoginOptions, imPassportTraceId?: string): Promise<string>;
31
+ loginWithPKCEFlowCallback(authorizationCode: string, state: string): Promise<User>;
32
+ private getPKCEToken;
33
+ storeTokens(tokenResponse: DeviceTokenResponse): Promise<User>;
34
+ logout(): Promise<void>;
35
+ logoutSilentCallback(url: string): Promise<void>;
36
+ removeUser(): Promise<void>;
37
+ getLogoutUrl(): Promise<string | null>;
38
+ forceUserRefreshInBackground(): void;
39
+ forceUserRefresh(): Promise<User | null>;
40
+ /**
41
+ * Refreshes the token and returns the user.
42
+ * If the token is already being refreshed, returns the existing promise.
43
+ */
44
+ private refreshTokenAndUpdatePromise;
45
+ /**
46
+ *
47
+ * @param typeAssertion {(user: User) => boolean} - Optional. If provided, then the User will be checked against
48
+ * the typeAssertion. If the user meets the requirements, then it will be typed as T and returned. If the User
49
+ * does NOT meet the type assertion, then execution will continue, and we will attempt to obtain a User that does
50
+ * meet the type assertion.
51
+ *
52
+ * This function will attempt to obtain a User in the following order:
53
+ * 1. If the User is currently refreshing, wait for the refresh to complete.
54
+ * 2. Attempt to obtain a User from storage that has not expired.
55
+ * 3. Attempt to refresh the User if a refresh token is present.
56
+ * 4. Return null if no valid User can be obtained.
57
+ */
58
+ getUser<T extends User>(typeAssertion?: (user: User) => user is T): Promise<T | null>;
59
+ getUserZkEvm(): Promise<UserZkEvm>;
60
+ getUserImx(): Promise<UserImx>;
61
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { ImmutableConfiguration } from '@imtbl/config';
2
2
  import { MultiRollupAPIConfiguration } from '@imtbl/generated-clients';
3
- import { OidcConfiguration, PassportModuleConfiguration, PopupOverlayOptions, PassportOverrides } from '../types';
3
+ import { OidcConfiguration, PassportModuleConfiguration, PopupOverlayOptions } from '../types';
4
4
  export declare class PassportConfiguration {
5
5
  readonly authenticationDomain: string;
6
6
  readonly passportDomain: string;
@@ -16,8 +16,6 @@ export declare class PassportConfiguration {
16
16
  readonly multiRollupConfig: MultiRollupAPIConfiguration;
17
17
  readonly crossSdkBridgeEnabled: boolean;
18
18
  readonly forceScwDeployBeforeMessageSignature: boolean;
19
- readonly jsonRpcReferrer?: string;
20
19
  readonly popupOverlayOptions: PopupOverlayOptions;
21
- readonly overrides?: PassportOverrides;
22
20
  constructor({ baseConfig, overrides, crossSdkBridgeEnabled, jsonRpcReferrer, forceScwDeployBeforeMessageSignature, popupOverlayOptions, ...oidcConfiguration }: PassportModuleConfiguration);
23
21
  }
@@ -0,0 +1,28 @@
1
+ import * as GeneratedClients from '@imtbl/generated-clients';
2
+ import { ConfirmationResult } from './types';
3
+ import { PassportConfiguration } from '../config';
4
+ export declare const CONFIRMATION_IFRAME_ID = "passport-confirm";
5
+ export declare const CONFIRMATION_IFRAME_STYLE = "display: none; position: absolute;width:0px;height:0px;border:0;";
6
+ type MessageHandler = (arg0: MessageEvent) => void;
7
+ type MessageType = 'erc191' | 'eip712';
8
+ export default class ConfirmationScreen {
9
+ private config;
10
+ private confirmationWindow;
11
+ private popupOptions;
12
+ private overlay;
13
+ private overlayClosed;
14
+ private timer;
15
+ constructor(config: PassportConfiguration);
16
+ private getHref;
17
+ requestConfirmation(transactionId: string, etherAddress: string, chainType: GeneratedClients.mr.TransactionApprovalRequestChainTypeEnum, chainId?: string): Promise<ConfirmationResult>;
18
+ requestMessageConfirmation(messageID: string, etherAddress: string, messageType?: MessageType): Promise<ConfirmationResult>;
19
+ showServiceUnavailable(): Promise<void>;
20
+ loading(popupOptions?: {
21
+ width: number;
22
+ height: number;
23
+ }): void;
24
+ closeWindow(): void;
25
+ showConfirmationScreen(href: string, messageHandler: MessageHandler, resolve: Function): void;
26
+ private recreateConfirmationWindow;
27
+ }
28
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { EmbeddedLoginPromptResult } from './types';
2
+ import { PassportConfiguration } from '../config';
3
+ export default class EmbeddedLoginPrompt {
4
+ private config;
5
+ constructor(config: PassportConfiguration);
6
+ private getHref;
7
+ private static appendIFrameStylesIfNeeded;
8
+ private getEmbeddedLoginIFrame;
9
+ displayEmbeddedLoginPrompt(anonymousId?: string): Promise<EmbeddedLoginPromptResult>;
10
+ }
@@ -0,0 +1,3 @@
1
+ export { default as ConfirmationScreen } from './confirmation';
2
+ export { default as EmbeddedLoginPrompt } from './embeddedLoginPrompt';
3
+ export * from './types';
@@ -0,0 +1,8 @@
1
+ export type PopUpProps = {
2
+ url: string;
3
+ title: string;
4
+ width: number;
5
+ height: number;
6
+ query?: string;
7
+ };
8
+ export declare const openPopupCenter: ({ url, title, width, height, }: PopUpProps) => Window;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ import { DirectLoginMethod, MarketingConsentStatus } from '../types';
2
+ export declare enum ConfirmationSendMessage {
3
+ CONFIRMATION_START = "confirmation_start"
4
+ }
5
+ export declare enum ConfirmationReceiveMessage {
6
+ CONFIRMATION_WINDOW_READY = "confirmation_window_ready",
7
+ TRANSACTION_CONFIRMED = "transaction_confirmed",
8
+ TRANSACTION_ERROR = "transaction_error",
9
+ TRANSACTION_REJECTED = "transaction_rejected",
10
+ MESSAGE_CONFIRMED = "message_confirmed",
11
+ MESSAGE_ERROR = "message_error",
12
+ MESSAGE_REJECTED = "message_rejected"
13
+ }
14
+ export declare enum EmbeddedLoginPromptReceiveMessage {
15
+ LOGIN_METHOD_SELECTED = "login_method_selected",
16
+ LOGIN_PROMPT_ERROR = "login_prompt_error",
17
+ LOGIN_PROMPT_CLOSED = "login_prompt_closed"
18
+ }
19
+ export type ConfirmationResult = {
20
+ confirmed: boolean;
21
+ };
22
+ export type EmbeddedLoginPromptResult = {
23
+ marketingConsentStatus: MarketingConsentStatus;
24
+ imPassportTraceId: string;
25
+ } & ({
26
+ directLoginMethod: 'email';
27
+ email: string;
28
+ } | {
29
+ directLoginMethod: Exclude<DirectLoginMethod, 'email'>;
30
+ email?: never;
31
+ });
32
+ export declare const PASSPORT_CONFIRMATION_EVENT_TYPE = "imx_passport_confirmation";
33
+ export declare const EMBEDDED_LOGIN_PROMPT_EVENT_TYPE = "im_passport_embedded_login_prompt";
@@ -20,8 +20,7 @@ export declare enum PassportErrorType {
20
20
  LINK_WALLET_VALIDATION_ERROR = "LINK_WALLET_VALIDATION_ERROR",
21
21
  LINK_WALLET_DUPLICATE_NONCE_ERROR = "LINK_WALLET_DUPLICATE_NONCE_ERROR",
22
22
  LINK_WALLET_GENERIC_ERROR = "LINK_WALLET_GENERIC_ERROR",
23
- SERVICE_UNAVAILABLE_ERROR = "SERVICE_UNAVAILABLE_ERROR",
24
- TRANSACTION_REJECTED = "TRANSACTION_REJECTED"
23
+ SERVICE_UNAVAILABLE_ERROR = "SERVICE_UNAVAILABLE_ERROR"
25
24
  }
26
25
  export declare function isAPIError(error: any): error is imx.APIError;
27
26
  export declare class PassportError extends Error {
@@ -0,0 +1,58 @@
1
+ import * as GeneratedClients from '@imtbl/generated-clients';
2
+ import { BigNumberish } from 'ethers';
3
+ import AuthManager from '../authManager';
4
+ import { ConfirmationScreen } from '../confirmation';
5
+ import { MetaTransaction, TypedDataPayload } from '../zkEvm/types';
6
+ import { PassportConfiguration } from '../config';
7
+ export type GuardianClientParams = {
8
+ confirmationScreen: ConfirmationScreen;
9
+ config: PassportConfiguration;
10
+ authManager: AuthManager;
11
+ guardianApi: GeneratedClients.mr.GuardianApi;
12
+ };
13
+ export type GuardianEvaluateImxTransactionParams = {
14
+ payloadHash: string;
15
+ };
16
+ type GuardianEVMTxnEvaluationParams = {
17
+ chainId: string;
18
+ nonce: string;
19
+ metaTransactions: MetaTransaction[];
20
+ isBackgroundTransaction?: boolean;
21
+ };
22
+ type GuardianEIP712MessageEvaluationParams = {
23
+ chainID: string;
24
+ payload: TypedDataPayload;
25
+ };
26
+ type GuardianERC191MessageEvaluationParams = {
27
+ chainID: bigint;
28
+ payload: string;
29
+ };
30
+ export declare const convertBigNumberishToString: (value: BigNumberish) => string;
31
+ export default class GuardianClient {
32
+ private readonly guardianApi;
33
+ private readonly confirmationScreen;
34
+ private readonly crossSdkBridgeEnabled;
35
+ private readonly authManager;
36
+ constructor({ confirmationScreen, config, authManager, guardianApi, }: GuardianClientParams);
37
+ /**
38
+ * Open confirmation screen and close it automatically if the
39
+ * underlying task fails.
40
+ */
41
+ withConfirmationScreen(popupWindowSize?: {
42
+ width: number;
43
+ height: number;
44
+ }): <T>(task: () => Promise<T>) => Promise<T>;
45
+ withConfirmationScreenTask(popupWindowSize?: {
46
+ width: number;
47
+ height: number;
48
+ }): <T>(task: () => Promise<T>) => (() => Promise<T>);
49
+ withDefaultConfirmationScreenTask<T>(task: () => Promise<T>): (() => Promise<T>);
50
+ evaluateImxTransaction({ payloadHash }: GuardianEvaluateImxTransactionParams): Promise<void>;
51
+ private evaluateEVMTransaction;
52
+ validateEVMTransaction({ chainId, nonce, metaTransactions, isBackgroundTransaction, }: GuardianEVMTxnEvaluationParams): Promise<void>;
53
+ private handleEIP712MessageEvaluation;
54
+ evaluateEIP712Message({ chainID, payload }: GuardianEIP712MessageEvaluationParams): Promise<void>;
55
+ private handleERC191MessageEvaluation;
56
+ evaluateERC191Message({ chainID, payload }: GuardianERC191MessageEvaluationParams): Promise<void>;
57
+ }
58
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  export { PassportError } from './errors/passportError';
2
2
  export { Passport } from './Passport';
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';
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';
7
7
  export { MarketingConsentStatus, } from './types';
@@ -0,0 +1 @@
1
+ export { default as MagicTEESigner } from './magicTEESigner';
@@ -0,0 +1,24 @@
1
+ import { AbstractSigner, Signer } from 'ethers';
2
+ import { MagicTeeApiClients } from '@imtbl/generated-clients';
3
+ import AuthManager from '../authManager';
4
+ export default class MagicTEESigner extends AbstractSigner {
5
+ private readonly authManager;
6
+ private readonly magicTeeApiClient;
7
+ private userWallet;
8
+ private createWalletPromise;
9
+ constructor(authManager: AuthManager, magicTeeApiClient: MagicTeeApiClients);
10
+ private getUserWallet;
11
+ /**
12
+ * This method calls the createWallet endpoint. The user's wallet must be created before it can be used to sign messages.
13
+ * The createWallet endpoint is idempotent, so it can be called multiple times without causing an error.
14
+ * If a createWallet request is already in flight, return the existing promise.
15
+ */
16
+ private createWallet;
17
+ private getUserOrThrow;
18
+ private static getHeaders;
19
+ getAddress(): Promise<string>;
20
+ signMessage(message: string | Uint8Array): Promise<string>;
21
+ connect(): Signer;
22
+ signTransaction(): Promise<string>;
23
+ signTypedData(): Promise<string>;
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ import 'cross-fetch/polyfill';
2
+ import { MockedRequest, RequestHandler } from 'msw';
3
+ export declare const relayerId = "0x745";
4
+ export declare const transactionHash = "0x867";
5
+ export declare const mswHandlers: {
6
+ magicTEE: {
7
+ createWallet: {
8
+ success: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
9
+ internalServerError: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
10
+ };
11
+ personalSign: {
12
+ success: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
13
+ internalServerError: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
14
+ };
15
+ };
16
+ counterfactualAddress: {
17
+ success: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
18
+ internalServerError: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
19
+ };
20
+ rpcProvider: {
21
+ success: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
22
+ };
23
+ relayer: {
24
+ success: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
25
+ };
26
+ guardian: {
27
+ evaluateTransaction: {
28
+ success: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
29
+ };
30
+ };
31
+ api: {
32
+ chains: {
33
+ success: import("msw").RestHandler<MockedRequest<import("msw").DefaultBodyType>>;
34
+ };
35
+ };
36
+ };
37
+ export declare const resetMswHandlers: () => void;
38
+ export declare const useMswHandlers: (handlers: RequestHandler[]) => void;
39
+ export declare const closeMswWorker: () => void;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Enum representing different chain IDs.
3
+ * @enum {number}
4
+ * @property {number} IMTBL_ZKEVM_MAINNET - The chain ID for IMTBL ZKEVM Mainnet.
5
+ * @property {number} IMTBL_ZKEVM_TESTNET - The chain ID for IMTBL ZKEVM Testnet.
6
+ * @property {number} IMTBL_ZKEVM_DEVNET - The chain ID for IMTBL ZKEVM Devnet.
7
+ * @property {number} ETHEREUM - The chain ID for Ethereum.
8
+ * @property {number} SEPOLIA - The chain ID for Sepolia.
9
+ */
10
+ export declare enum ChainId {
11
+ IMTBL_ZKEVM_MAINNET = 13371,
12
+ IMTBL_ZKEVM_TESTNET = 13473,
13
+ IMTBL_ZKEVM_DEVNET = 15003,
14
+ ETHEREUM = 1,
15
+ SEPOLIA = 11155111
16
+ }
17
+ /**
18
+ * Enum representing different chain names.
19
+ * @enum {number}
20
+ * @property {number} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
21
+ * @property {number} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
22
+ * @property {number} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
23
+ * @property {number} ETHEREUM - The chain name for Ethereum.
24
+ * @property {number} SEPOLIA - The chain name for Sepolia.
25
+ */
26
+ export declare enum ChainName {
27
+ ETHEREUM = "Ethereum",
28
+ SEPOLIA = "Sepolia",
29
+ IMTBL_ZKEVM_TESTNET = "Immutable zkEVM Test",
30
+ IMTBL_ZKEVM_DEVNET = "Immutable zkEVM Dev",
31
+ IMTBL_ZKEVM_MAINNET = "Immutable zkEVM"
32
+ }
@@ -0,0 +1,3 @@
1
+ import { ChainId, ChainName } from './chains';
2
+ export type ChainMap = Map<ChainId, ChainName>;
3
+ export declare const CHAIN_NAME_MAP: ChainMap;
@@ -0,0 +1,8 @@
1
+ export declare const MAX_RETRIES = 3;
2
+ export type RetryOption = {
3
+ retries?: number;
4
+ interval?: number;
5
+ finalErr?: Error;
6
+ finallyFn?: () => void;
7
+ };
8
+ export declare const retryWithDelay: <T>(fn: () => Promise<T>, options?: RetryOption) => Promise<T>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import { PopupOverlayOptions } from '../types';
2
+ export default class ConfirmationOverlay {
3
+ private disableGenericPopupOverlay;
4
+ private disableBlockedPopupOverlay;
5
+ private overlay;
6
+ private isBlockedOverlay;
7
+ private tryAgainListener;
8
+ private onCloseListener;
9
+ constructor(popupOverlayOptions: PopupOverlayOptions, isBlockedOverlay?: boolean);
10
+ append(tryAgainOnClick: () => void, onCloseClick: () => void): void;
11
+ update(tryAgainOnClick: () => void): void;
12
+ remove(): void;
13
+ private shouldAppendOverlay;
14
+ private appendOverlay;
15
+ private updateTryAgainButton;
16
+ private updateCloseButton;
17
+ }
@@ -0,0 +1 @@
1
+ export {};