@imtbl/passport 2.10.6 → 2.10.7-alpha.3

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 (87) hide show
  1. package/dist/browser/index.js +8 -409
  2. package/dist/node/index.cjs +27 -437
  3. package/dist/node/index.js +8 -409
  4. package/dist/types/Passport.d.ts +37 -36
  5. package/dist/types/index.d.ts +4 -4
  6. package/dist/types/starkEx/passportImxProvider.d.ts +2 -4
  7. package/dist/types/starkEx/passportImxProviderFactory.d.ts +2 -4
  8. package/dist/types/starkEx/workflows/order.d.ts +1 -1
  9. package/dist/types/starkEx/workflows/registerOffchain.d.ts +1 -1
  10. package/dist/types/starkEx/workflows/trades.d.ts +1 -1
  11. package/dist/types/starkEx/workflows/transfer.d.ts +1 -1
  12. package/dist/types/types.d.ts +1 -1
  13. package/dist/types/utils/metrics.d.ts +1 -3
  14. package/package.json +11 -18
  15. package/dist/types/Passport.int.test.d.ts +0 -1
  16. package/dist/types/Passport.test.d.ts +0 -1
  17. package/dist/types/authManager.d.ts +0 -62
  18. package/dist/types/authManager.test.d.ts +0 -1
  19. package/dist/types/confirmation/confirmation.d.ts +0 -28
  20. package/dist/types/confirmation/confirmation.test.d.ts +0 -1
  21. package/dist/types/confirmation/embeddedLoginPrompt.d.ts +0 -10
  22. package/dist/types/confirmation/embeddedLoginPrompt.test.d.ts +0 -1
  23. package/dist/types/confirmation/index.d.ts +0 -3
  24. package/dist/types/confirmation/popup.d.ts +0 -8
  25. package/dist/types/confirmation/popup.test.d.ts +0 -1
  26. package/dist/types/confirmation/types.d.ts +0 -33
  27. package/dist/types/guardian/index.d.ts +0 -58
  28. package/dist/types/guardian/index.test.d.ts +0 -1
  29. package/dist/types/magic/index.d.ts +0 -1
  30. package/dist/types/magic/magicTEESigner.d.ts +0 -24
  31. package/dist/types/magic/magicTEESigner.test.d.ts +0 -1
  32. package/dist/types/mocks/zkEvm/msw.d.ts +0 -39
  33. package/dist/types/network/chains.d.ts +0 -32
  34. package/dist/types/network/constants.d.ts +0 -3
  35. package/dist/types/network/retry.d.ts +0 -8
  36. package/dist/types/network/retry.test.d.ts +0 -1
  37. package/dist/types/overlay/confirmationOverlay.d.ts +0 -17
  38. package/dist/types/overlay/confirmationOverlay.test.d.ts +0 -1
  39. package/dist/types/overlay/constants.d.ts +0 -7
  40. package/dist/types/overlay/elements.d.ts +0 -12
  41. package/dist/types/overlay/embeddedLoginPromptOverlay.d.ts +0 -7
  42. package/dist/types/overlay/embeddedLoginPromptOverlay.test.d.ts +0 -1
  43. package/dist/types/starkEx/passportImxProvider.test.d.ts +0 -1
  44. package/dist/types/starkEx/passportImxProviderFactory.test.d.ts +0 -1
  45. package/dist/types/starkEx/workflows/exchange.test.d.ts +0 -1
  46. package/dist/types/starkEx/workflows/order.test.d.ts +0 -1
  47. package/dist/types/starkEx/workflows/registerOffchain.test.d.ts +0 -1
  48. package/dist/types/starkEx/workflows/trades.test.d.ts +0 -1
  49. package/dist/types/starkEx/workflows/transfer.test.d.ts +0 -1
  50. package/dist/types/storage/LocalForageAsyncStorage.d.ts +0 -11
  51. package/dist/types/storage/device_credentials_manager.d.ts +0 -6
  52. package/dist/types/test/mocks.d.ts +0 -56
  53. package/dist/types/utils/metrics.test.d.ts +0 -1
  54. package/dist/types/utils/string.d.ts +0 -1
  55. package/dist/types/utils/string.test.d.ts +0 -1
  56. package/dist/types/utils/token.d.ts +0 -2
  57. package/dist/types/utils/token.test.d.ts +0 -1
  58. package/dist/types/utils/typedEventEmitter.d.ts +0 -6
  59. package/dist/types/utils/typedEventEmitter.test.d.ts +0 -1
  60. package/dist/types/zkEvm/JsonRpcError.d.ts +0 -25
  61. package/dist/types/zkEvm/index.d.ts +0 -2
  62. package/dist/types/zkEvm/personalSign.d.ts +0 -15
  63. package/dist/types/zkEvm/personalSign.test.d.ts +0 -1
  64. package/dist/types/zkEvm/provider/eip6963.d.ts +0 -3
  65. package/dist/types/zkEvm/relayerClient.d.ts +0 -60
  66. package/dist/types/zkEvm/relayerClient.test.d.ts +0 -1
  67. package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.d.ts +0 -6
  68. package/dist/types/zkEvm/sendDeployTransactionAndPersonalSign.test.d.ts +0 -1
  69. package/dist/types/zkEvm/sendTransaction.d.ts +0 -6
  70. package/dist/types/zkEvm/sendTransaction.test.d.ts +0 -1
  71. package/dist/types/zkEvm/sessionActivity/errorBoundary.d.ts +0 -1
  72. package/dist/types/zkEvm/sessionActivity/request.d.ts +0 -15
  73. package/dist/types/zkEvm/sessionActivity/sessionActivity.d.ts +0 -2
  74. package/dist/types/zkEvm/signEjectionTransaction.d.ts +0 -6
  75. package/dist/types/zkEvm/signEjectionTransaction.test.d.ts +0 -1
  76. package/dist/types/zkEvm/signTypedDataV4.d.ts +0 -14
  77. package/dist/types/zkEvm/signTypedDataV4.test.d.ts +0 -1
  78. package/dist/types/zkEvm/transactionHelpers.d.ts +0 -31
  79. package/dist/types/zkEvm/transactionHelpers.test.d.ts +0 -1
  80. package/dist/types/zkEvm/types.d.ts +0 -120
  81. package/dist/types/zkEvm/user/index.d.ts +0 -1
  82. package/dist/types/zkEvm/user/registerZkEvmUser.d.ts +0 -13
  83. package/dist/types/zkEvm/user/registerZkEvmUser.test.d.ts +0 -1
  84. package/dist/types/zkEvm/walletHelpers.d.ts +0 -33
  85. package/dist/types/zkEvm/walletHelpers.test.d.ts +0 -1
  86. package/dist/types/zkEvm/zkEvmProvider.d.ts +0 -25
  87. package/dist/types/zkEvm/zkEvmProvider.test.d.ts +0 -1
@@ -1,18 +1,16 @@
1
1
  import { IMXProvider } from '@imtbl/x-provider';
2
2
  import { MultiRollupApiClients } from '@imtbl/generated-clients';
3
3
  import { IMXClient } from '@imtbl/x-client';
4
- import AuthManager from './authManager';
5
- import MagicTEESigner from './magic/magicTEESigner';
4
+ import { AuthManager, AuthConfiguration, ConfirmationScreen, EmbeddedLoginPrompt, UserProfile, DirectLoginOptions, DeviceTokenResponse } from '@imtbl/auth';
5
+ import { ZkEvmProvider, WalletConfiguration, GuardianClient, MagicTEESigner, TypedEventEmitter } from '@imtbl/wallet';
6
+ import { PassportEventMap, LinkedWallet, LinkWalletParams, PassportModuleConfiguration, ConnectEvmArguments, LoginArguments } from './types';
6
7
  import { PassportImxProviderFactory } from './starkEx';
7
8
  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
9
  export declare const buildPrivateVars: (passportModuleConfiguration: PassportModuleConfiguration) => {
14
10
  config: PassportConfiguration;
15
11
  authManager: AuthManager;
12
+ authConfig: AuthConfiguration;
13
+ walletConfig: WalletConfiguration;
16
14
  magicTEESigner: MagicTEESigner;
17
15
  confirmationScreen: ConfirmationScreen;
18
16
  embeddedLoginPrompt: EmbeddedLoginPrompt;
@@ -24,7 +22,7 @@ export declare const buildPrivateVars: (passportModuleConfiguration: PassportMod
24
22
  };
25
23
  export declare class Passport {
26
24
  private readonly authManager;
27
- private readonly config;
25
+ private readonly walletConfig;
28
26
  private readonly confirmationScreen;
29
27
  private readonly embeddedLoginPrompt;
30
28
  private readonly immutableXClient;
@@ -51,12 +49,11 @@ export declare class Passport {
51
49
  * @param {boolean} options.announceProvider - Whether to announce the provider via EIP-6963 for wallet discovery (defaults to true)
52
50
  * @returns {Promise<Provider>} The EVM provider instance
53
51
  */
54
- connectEvm(options?: ConnectEvmArguments): Promise<Provider>;
52
+ connectEvm(options?: ConnectEvmArguments): Promise<ZkEvmProvider>;
55
53
  /**
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
54
+ * Logs in the user.
55
+ * @param {Object} [options] - Login options
56
+ * @param {boolean} [options.useCachedSession] - If true, attempts to use a cached session without user interaction.
60
57
  * @param {boolean} [options.useSilentLogin] - If true, attempts silent authentication without user interaction.
61
58
  * Note: This takes precedence over useCachedSession if both are true
62
59
  * @param {boolean} [options.useRedirectFlow] - If true, uses redirect flow instead of popup flow
@@ -70,39 +67,44 @@ export declare class Passport {
70
67
  */
71
68
  login(options?: LoginArguments): Promise<UserProfile | null>;
72
69
  /**
73
- * Handles the login callback.
74
- * @returns {Promise<void>} A promise that resolves when the callback is processed
70
+ * Handles the login callback from the authentication service.
71
+ * @returns {Promise<void>} A promise that resolves when the login callback is handled
75
72
  */
76
73
  loginCallback(): Promise<void>;
77
74
  /**
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
75
+ * Retrieves the PKCE authorization URL for the login flow.
76
+ * @param {DirectLoginOptions} [directLoginOptions] - Optional direct login options
77
+ * @param {string} [imPassportTraceId] - Optional trace ID
78
+ * @returns {Promise<string>} A promise that resolves to the authorization URL
82
79
  */
83
80
  loginWithPKCEFlow(directLoginOptions?: DirectLoginOptions, imPassportTraceId?: string): Promise<string>;
84
81
  /**
85
- * Handles the PKCE flow login callback.
86
- * @param {string} authorizationCode - The authorization code received from the OAuth provider
82
+ * Handles the PKCE login callback.
83
+ * @param {string} authorizationCode - The authorization code from the OAuth provider
87
84
  * @param {string} state - The state parameter for CSRF protection
88
85
  * @returns {Promise<UserProfile>} A promise that resolves to the user profile
89
86
  */
90
87
  loginWithPKCEFlowCallback(authorizationCode: string, state: string): Promise<UserProfile>;
88
+ /**
89
+ * Stores the provided tokens and retrieves the user profile.
90
+ * @param {DeviceTokenResponse} tokenResponse - The token response from device flow
91
+ * @returns {Promise<UserProfile>} A promise that resolves to the user profile
92
+ */
91
93
  storeTokens(tokenResponse: DeviceTokenResponse): Promise<UserProfile>;
92
94
  /**
93
- * Logs out the current user.
94
- * @returns {Promise<void>} A promise that resolves when the logout is complete
95
+ * Logs out the user.
96
+ * @returns {Promise<void>} A promise that resolves when the user is logged out
95
97
  */
96
98
  logout(): Promise<void>;
97
99
  /**
98
- * Returns the logout URL for the current user.
99
- * @returns {Promise<string>} The logout URL
100
+ * Retrieves the logout URL.
101
+ * @returns {Promise<string | undefined>} A promise that resolves to the logout URL, or undefined if not available
100
102
  */
101
- getLogoutUrl(): Promise<string | null>;
103
+ getLogoutUrl(): Promise<string | undefined>;
102
104
  /**
103
105
  * 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
+ * @param {string} url - The URL containing the logout information
107
+ * @returns {Promise<void>} A promise that resolves when the silent logout callback is handled
106
108
  */
107
109
  logoutSilentCallback(url: string): Promise<void>;
108
110
  /**
@@ -111,12 +113,12 @@ export declare class Passport {
111
113
  */
112
114
  getUserInfo(): Promise<UserProfile | undefined>;
113
115
  /**
114
- * Retrieves the current user's ID token.
116
+ * Retrieves the ID token.
115
117
  * @returns {Promise<string | undefined>} A promise that resolves to the ID token if available, undefined otherwise
116
118
  */
117
119
  getIdToken(): Promise<string | undefined>;
118
120
  /**
119
- * Retrieves the current user's access token.
121
+ * Retrieves the access token.
120
122
  * @returns {Promise<string | undefined>} A promise that resolves to the access token if available, undefined otherwise
121
123
  */
122
124
  getAccessToken(): Promise<string | undefined>;
@@ -126,14 +128,13 @@ export declare class Passport {
126
128
  */
127
129
  getLinkedAddresses(): Promise<string[]>;
128
130
  /**
129
- * Links an external wallet to the current user's account.
131
+ * Links an external wallet to the user's Passport account.
130
132
  * @param {LinkWalletParams} params - Parameters for linking the wallet
131
133
  * @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)
134
+ * @throws {PassportError} If the user is not logged in (NOT_LOGGED_IN_ERROR)
135
+ * - If the user is not registered with StarkEx (USER_NOT_REGISTERED_ERROR)
136
+ * - If the wallet is already linked (LINK_WALLET_ALREADY_LINKED_ERROR)
137
+ * - If the maximum number of wallets are linked (LINK_WALLET_MAX_WALLETS_LINKED_ERROR)
137
138
  * - Duplicate nonce used (LINK_WALLET_DUPLICATE_NONCE_ERROR)
138
139
  * - Validation fails (LINK_WALLET_VALIDATION_ERROR)
139
140
  * - Other generic errors (LINK_WALLET_GENERIC_ERROR)
@@ -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';
@@ -2,11 +2,9 @@ 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';
5
+ import { AuthManager } from '@imtbl/auth';
6
+ import { GuardianClient, MagicTEESigner, TypedEventEmitter } from '@imtbl/wallet';
7
7
  import { PassportEventMap } from '../types';
8
- import MagicTEESigner from '../magic/magicTEESigner';
9
- import TypedEventEmitter from '../utils/typedEventEmitter';
10
8
  export interface PassportImxProviderOptions {
11
9
  authManager: AuthManager;
12
10
  immutableXClient: IMXClient;
@@ -1,11 +1,9 @@
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';
4
+ import { AuthManager } from '@imtbl/auth';
5
+ import { GuardianClient, MagicTEESigner, TypedEventEmitter } from '@imtbl/wallet';
5
6
  import { PassportEventMap } from '../types';
6
- import GuardianClient from '../guardian';
7
- import MagicTEESigner from '../magic/magicTEESigner';
8
- import TypedEventEmitter from '../utils/typedEventEmitter';
9
7
  export type PassportImxProviderFactoryInput = {
10
8
  authManager: AuthManager;
11
9
  immutableXClient: IMXClient;
@@ -1,7 +1,7 @@
1
1
  import { imx } from '@imtbl/generated-clients';
2
2
  import { StarkSigner, UnsignedOrderRequest } from '@imtbl/x-client';
3
+ import { GuardianClient } from '@imtbl/wallet';
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;
@@ -1,5 +1,5 @@
1
1
  import { ImxApiClients, imx } from '@imtbl/generated-clients';
2
2
  import { EthSigner, StarkSigner } from '@imtbl/x-client';
3
- import AuthManager from '../../authManager';
3
+ import { AuthManager } from '@imtbl/auth';
4
4
  import { User } from '../../types';
5
5
  export default function registerOffchain(userAdminKeySigner: EthSigner, starkSigner: StarkSigner, unregisteredUser: User, authManager: AuthManager, imxApiClients: ImxApiClients): Promise<imx.RegisterUserResponse>;
@@ -1,7 +1,7 @@
1
1
  import { imx } from '@imtbl/generated-clients';
2
2
  import { StarkSigner } from '@imtbl/x-client';
3
+ import { GuardianClient } from '@imtbl/wallet';
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;
@@ -1,7 +1,7 @@
1
1
  import { imx } from '@imtbl/generated-clients';
2
2
  import { StarkSigner, NftTransferDetails, UnsignedTransferRequest } from '@imtbl/x-client';
3
+ import { GuardianClient } from '@imtbl/wallet';
3
4
  import { UserImx } from '../../types';
4
- import GuardianClient from '../../guardian';
5
5
  type TransferRequest = {
6
6
  request: UnsignedTransferRequest;
7
7
  user: UserImx;
@@ -156,6 +156,7 @@ export type LinkedWallet = {
156
156
  export type ConnectEvmArguments = {
157
157
  announceProvider: boolean;
158
158
  };
159
+ export type { ZkEvmProvider } from '@imtbl/wallet';
159
160
  export type LoginArguments = {
160
161
  useCachedSession?: boolean;
161
162
  anonymousId?: string;
@@ -176,4 +177,3 @@ export type DirectLoginOptions = {
176
177
  directLoginMethod: Exclude<DirectLoginMethod, 'email'>;
177
178
  email?: never;
178
179
  });
179
- export {};
@@ -1,3 +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
- export declare const withMetricsAsync: <T>(fn: (flow: Flow) => Promise<T>, flowName: string, trackStartEvent?: boolean, trackEndEvent?: boolean) => Promise<T>;
1
+ export declare const withMetricsAsync: <T>(fn: () => Promise<T>, _metric: string, _track?: boolean, _flow?: any) => Promise<T>;
package/package.json CHANGED
@@ -1,29 +1,22 @@
1
1
  {
2
2
  "name": "@imtbl/passport",
3
3
  "description": "Passport module for Immutable SDK",
4
- "version": "2.10.6",
4
+ "version": "2.10.7-alpha.3",
5
5
  "author": "Immutable",
6
6
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
7
7
  "dependencies": {
8
8
  "@0xsequence/abi": "^2.0.25",
9
9
  "@0xsequence/core": "^2.0.25",
10
- "@imtbl/config": "2.10.6",
11
- "@imtbl/generated-clients": "2.10.6",
12
- "@imtbl/metrics": "2.10.6",
13
- "@imtbl/toolkit": "2.10.6",
14
- "@imtbl/x-client": "2.10.6",
15
- "@imtbl/x-provider": "2.10.6",
16
- "@magic-ext/oidc": "12.0.5",
17
- "@magic-sdk/provider": "^29.0.5",
18
- "@metamask/detect-provider": "^2.0.0",
10
+ "@imtbl/auth": "2.10.7-alpha.3",
11
+ "@imtbl/wallet": "2.10.7-alpha.3",
12
+ "@imtbl/config": "2.10.7-alpha.3",
13
+ "@imtbl/generated-clients": "2.10.7-alpha.3",
14
+ "@imtbl/metrics": "2.10.7-alpha.3",
15
+ "@imtbl/toolkit": "2.10.7-alpha.3",
16
+ "@imtbl/x-client": "2.10.7-alpha.3",
17
+ "@imtbl/x-provider": "2.10.7-alpha.3",
19
18
  "axios": "^1.6.5",
20
- "ethers": "^6.13.4",
21
- "events": "^3.3.0",
22
- "jwt-decode": "^3.1.2",
23
- "localforage": "^1.10.0",
24
- "magic-sdk": "^29.0.5",
25
- "oidc-client-ts": "3.3.0",
26
- "uuid": "^8.3.2"
19
+ "ethers": "^6.13.4"
27
20
  },
28
21
  "devDependencies": {
29
22
  "@swc/core": "^1.3.36",
@@ -44,7 +37,7 @@
44
37
  "msw": "^1.2.2",
45
38
  "prettier": "^2.8.7",
46
39
  "ts-node": "^10.9.1",
47
- "tsup": "8.3.0",
40
+ "tsup": "^8.3.0",
48
41
  "typescript": "^5.6.2"
49
42
  },
50
43
  "engines": {
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,62 +0,0 @@
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
- private static shouldUseSigninPopupCallback;
30
- loginCallback(): Promise<undefined | User>;
31
- getPKCEAuthorizationUrl(directLoginOptions?: DirectLoginOptions, imPassportTraceId?: string): Promise<string>;
32
- loginWithPKCEFlowCallback(authorizationCode: string, state: string): Promise<User>;
33
- private getPKCEToken;
34
- storeTokens(tokenResponse: DeviceTokenResponse): Promise<User>;
35
- logout(): Promise<void>;
36
- logoutSilentCallback(url: string): Promise<void>;
37
- removeUser(): Promise<void>;
38
- getLogoutUrl(): Promise<string | null>;
39
- forceUserRefreshInBackground(): void;
40
- forceUserRefresh(): Promise<User | null>;
41
- /**
42
- * Refreshes the token and returns the user.
43
- * If the token is already being refreshed, returns the existing promise.
44
- */
45
- private refreshTokenAndUpdatePromise;
46
- /**
47
- *
48
- * @param typeAssertion {(user: User) => boolean} - Optional. If provided, then the User will be checked against
49
- * the typeAssertion. If the user meets the requirements, then it will be typed as T and returned. If the User
50
- * does NOT meet the type assertion, then execution will continue, and we will attempt to obtain a User that does
51
- * meet the type assertion.
52
- *
53
- * This function will attempt to obtain a User in the following order:
54
- * 1. If the User is currently refreshing, wait for the refresh to complete.
55
- * 2. Attempt to obtain a User from storage that has not expired.
56
- * 3. Attempt to refresh the User if a refresh token is present.
57
- * 4. Return null if no valid User can be obtained.
58
- */
59
- getUser<T extends User>(typeAssertion?: (user: User) => user is T): Promise<T | null>;
60
- getUserZkEvm(): Promise<UserZkEvm>;
61
- getUserImx(): Promise<UserImx>;
62
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,28 +0,0 @@
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 {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export { default as ConfirmationScreen } from './confirmation';
2
- export { default as EmbeddedLoginPrompt } from './embeddedLoginPrompt';
3
- export * from './types';
@@ -1,8 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
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";
@@ -1,58 +0,0 @@
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 {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export { default as MagicTEESigner } from './magicTEESigner';
@@ -1,24 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,39 +0,0 @@
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;
@@ -1,32 +0,0 @@
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
- }