@imtbl/passport 2.4.10-alpha.2 → 2.4.10-alpha.4

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.
@@ -2,16 +2,16 @@ 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 TypedEventEmitter from '../utils/typedEventEmitter';
5
6
  import AuthManager from '../authManager';
6
7
  import GuardianClient from '../guardian';
7
8
  import { PassportEventMap } from '../types';
8
- import MagicTEESigner from '../magic/magicTEESigner';
9
- import TypedEventEmitter from '../utils/typedEventEmitter';
9
+ import MagicAdapter from '../magic/magicAdapter';
10
10
  export interface PassportImxProviderOptions {
11
11
  authManager: AuthManager;
12
12
  immutableXClient: IMXClient;
13
13
  passportEventEmitter: TypedEventEmitter<PassportEventMap>;
14
- magicTEESigner: MagicTEESigner;
14
+ magicAdapter: MagicAdapter;
15
15
  imxApiClients: ImxApiClients;
16
16
  guardianClient: GuardianClient;
17
17
  }
@@ -21,16 +21,16 @@ export declare class PassportImxProvider implements IMXProvider {
21
21
  private readonly immutableXClient;
22
22
  protected readonly guardianClient: GuardianClient;
23
23
  protected readonly imxApiClients: ImxApiClients;
24
- protected magicTEESigner: MagicTEESigner;
24
+ protected magicAdapter: MagicAdapter;
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
28
28
  * `#getSigners` method.
29
29
  * @see #getSigners
30
30
  */
31
- private starkSigner;
31
+ private signers;
32
32
  private signerInitialisationError;
33
- constructor({ authManager, immutableXClient, passportEventEmitter, magicTEESigner, imxApiClients, guardianClient, }: PassportImxProviderOptions);
33
+ constructor({ authManager, immutableXClient, passportEventEmitter, magicAdapter, imxApiClients, guardianClient, }: PassportImxProviderOptions);
34
34
  private handleLogout;
35
35
  transfer(request: UnsignedTransferRequest): Promise<imx.CreateTransferResponseV1>;
36
36
  registerOffchain(): Promise<imx.RegisterUserResponse>;
@@ -2,14 +2,14 @@ import { IMXClient } from '@imtbl/x-client';
2
2
  import { IMXProvider } from '@imtbl/x-provider';
3
3
  import { ImxApiClients } from '@imtbl/generated-clients';
4
4
  import AuthManager from '../authManager';
5
+ import MagicAdapter from '../magic/magicAdapter';
5
6
  import { PassportEventMap } from '../types';
6
- import GuardianClient from '../guardian';
7
- import MagicTEESigner from '../magic/magicTEESigner';
8
7
  import TypedEventEmitter from '../utils/typedEventEmitter';
8
+ import GuardianClient from '../guardian';
9
9
  export type PassportImxProviderFactoryInput = {
10
10
  authManager: AuthManager;
11
11
  immutableXClient: IMXClient;
12
- magicTEESigner: MagicTEESigner;
12
+ magicAdapter: MagicAdapter;
13
13
  passportEventEmitter: TypedEventEmitter<PassportEventMap>;
14
14
  imxApiClients: ImxApiClients;
15
15
  guardianClient: GuardianClient;
@@ -17,11 +17,11 @@ export type PassportImxProviderFactoryInput = {
17
17
  export declare class PassportImxProviderFactory {
18
18
  private readonly authManager;
19
19
  private readonly immutableXClient;
20
- private readonly magicTEESigner;
20
+ private readonly magicAdapter;
21
21
  private readonly passportEventEmitter;
22
22
  readonly imxApiClients: ImxApiClients;
23
23
  private readonly guardianClient;
24
- constructor({ authManager, immutableXClient, magicTEESigner, passportEventEmitter, imxApiClients, guardianClient, }: PassportImxProviderFactoryInput);
24
+ constructor({ authManager, immutableXClient, magicAdapter, passportEventEmitter, imxApiClients, guardianClient, }: PassportImxProviderFactoryInput);
25
25
  getProvider(): Promise<IMXProvider>;
26
26
  getProviderSilent(): Promise<IMXProvider | null>;
27
27
  private createProviderInstance;
@@ -1,5 +1,5 @@
1
1
  import { Environment, ModuleConfiguration } from '@imtbl/config';
2
- import { IMXClient } from '@imtbl/x-client';
2
+ import { EthSigner, IMXClient, StarkSigner } from '@imtbl/x-client';
3
3
  import { ImxApiClients } from '@imtbl/generated-clients';
4
4
  import { Flow } from '@imtbl/metrics';
5
5
  /**
@@ -30,22 +30,18 @@ export type UserProfile = {
30
30
  nickname?: string;
31
31
  sub: string;
32
32
  };
33
- export declare enum RollupType {
34
- IMX = "imx",
35
- ZKEVM = "zkEvm"
36
- }
37
33
  export type User = {
38
34
  idToken?: string;
39
35
  accessToken: string;
40
36
  refreshToken?: string;
41
37
  profile: UserProfile;
42
38
  expired?: boolean;
43
- [RollupType.IMX]?: {
39
+ imx?: {
44
40
  ethAddress: string;
45
41
  starkAddress: string;
46
42
  userAdminAddress: string;
47
43
  };
48
- [RollupType.ZKEVM]?: {
44
+ zkEvm?: {
49
45
  ethAddress: string;
50
46
  userAdminAddress: string;
51
47
  };
@@ -110,8 +106,8 @@ export interface PassportModuleConfiguration extends ModuleConfiguration<Passpor
110
106
  type WithRequired<T, K extends keyof T> = T & {
111
107
  [P in K]-?: T[P];
112
108
  };
113
- export type UserImx = WithRequired<User, RollupType.IMX>;
114
- export type UserZkEvm = WithRequired<User, RollupType.ZKEVM>;
109
+ export type UserImx = WithRequired<User, 'imx'>;
110
+ export type UserZkEvm = WithRequired<User, 'zkEvm'>;
115
111
  export declare const isUserZkEvm: (user: User) => user is UserZkEvm;
116
112
  export declare const isUserImx: (user: User) => user is UserImx;
117
113
  export type DeviceTokenResponse = {
@@ -138,6 +134,10 @@ export type PKCEData = {
138
134
  state: string;
139
135
  verifier: string;
140
136
  };
137
+ export type IMXSigners = {
138
+ starkSigner: StarkSigner;
139
+ ethSigner: EthSigner;
140
+ };
141
141
  export type LinkWalletParams = {
142
142
  type: string;
143
143
  walletAddress: string;
@@ -1,24 +1,23 @@
1
1
  import { MultiRollupApiClients } from '@imtbl/generated-clients';
2
- import { Signer } from 'ethers';
3
2
  import { Provider, RequestArguments } from './types';
4
3
  import AuthManager from '../authManager';
4
+ import MagicAdapter from '../magic/magicAdapter';
5
5
  import TypedEventEmitter from '../utils/typedEventEmitter';
6
6
  import { PassportConfiguration } from '../config';
7
- import { PassportEventMap, User } from '../types';
7
+ import { PassportEventMap } from '../types';
8
8
  import GuardianClient from '../guardian';
9
9
  export type ZkEvmProviderInput = {
10
10
  authManager: AuthManager;
11
+ magicAdapter: MagicAdapter;
11
12
  config: PassportConfiguration;
12
13
  multiRollupApiClients: MultiRollupApiClients;
13
14
  passportEventEmitter: TypedEventEmitter<PassportEventMap>;
14
15
  guardianClient: GuardianClient;
15
- ethSigner: Signer;
16
- user: User | null;
17
16
  };
18
17
  export declare class ZkEvmProvider implements Provider {
19
18
  #private;
20
19
  readonly isPassport: boolean;
21
- constructor({ authManager, config, multiRollupApiClients, passportEventEmitter, guardianClient, ethSigner, user, }: ZkEvmProviderInput);
20
+ constructor({ authManager, magicAdapter, config, multiRollupApiClients, passportEventEmitter, guardianClient, }: ZkEvmProviderInput);
22
21
  request(request: RequestArguments): Promise<any>;
23
22
  on(event: string, listener: (...args: any[]) => void): void;
24
23
  removeListener(event: string, listener: (...args: any[]) => void): void;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@imtbl/passport",
3
3
  "description": "Passport module for Immutable SDK",
4
- "version": "2.4.10-alpha.2",
4
+ "version": "2.4.10-alpha.4",
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.4.10-alpha.2",
11
- "@imtbl/generated-clients": "2.4.10-alpha.2",
12
- "@imtbl/metrics": "2.4.10-alpha.2",
13
- "@imtbl/toolkit": "2.4.10-alpha.2",
14
- "@imtbl/x-client": "2.4.10-alpha.2",
15
- "@imtbl/x-provider": "2.4.10-alpha.2",
10
+ "@imtbl/config": "2.4.10-alpha.4",
11
+ "@imtbl/generated-clients": "2.4.10-alpha.4",
12
+ "@imtbl/metrics": "2.4.10-alpha.4",
13
+ "@imtbl/toolkit": "2.4.10-alpha.4",
14
+ "@imtbl/x-client": "2.4.10-alpha.4",
15
+ "@imtbl/x-provider": "2.4.10-alpha.4",
16
16
  "@magic-ext/oidc": "12.0.5",
17
17
  "@magic-sdk/provider": "^29.0.5",
18
18
  "@metamask/detect-provider": "^2.0.0",
@@ -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
- }