@imtbl/passport 2.4.10-alpha.0 → 2.4.10-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.
- package/dist/browser/index.js +31 -33
- package/dist/node/index.cjs +27 -29
- package/dist/node/index.js +22 -24
- package/dist/types/Passport.d.ts +4 -4
- package/dist/types/config/config.d.ts +2 -0
- package/dist/types/magic/index.d.ts +1 -5
- package/dist/types/magic/magicTEESigner.d.ts +24 -0
- package/dist/types/mocks/zkEvm/msw.d.ts +10 -0
- package/dist/types/starkEx/passportImxProvider.d.ts +6 -6
- package/dist/types/starkEx/passportImxProviderFactory.d.ts +5 -5
- package/dist/types/types.d.ts +9 -9
- package/dist/types/zkEvm/zkEvmProvider.d.ts +5 -4
- package/package.json +7 -7
- package/dist/types/magic/magicAdapter.d.ts +0 -12
- package/dist/types/magic/magicProviderProxyFactory.d.ts +0 -15
- package/dist/types/magic/magicProviderProxyFactory.test.d.ts +0 -1
- /package/dist/types/magic/{magicAdapter.test.d.ts → magicTEESigner.test.d.ts} +0 -0
|
@@ -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';
|
|
6
5
|
import AuthManager from '../authManager';
|
|
7
6
|
import GuardianClient from '../guardian';
|
|
8
7
|
import { PassportEventMap } from '../types';
|
|
9
|
-
import
|
|
8
|
+
import MagicTEESigner from '../magic/magicTEESigner';
|
|
9
|
+
import TypedEventEmitter from '../utils/typedEventEmitter';
|
|
10
10
|
export interface PassportImxProviderOptions {
|
|
11
11
|
authManager: AuthManager;
|
|
12
12
|
immutableXClient: IMXClient;
|
|
13
13
|
passportEventEmitter: TypedEventEmitter<PassportEventMap>;
|
|
14
|
-
|
|
14
|
+
magicTEESigner: MagicTEESigner;
|
|
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
|
|
24
|
+
protected magicTEESigner: MagicTEESigner;
|
|
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
|
|
31
|
+
private starkSigner;
|
|
32
32
|
private signerInitialisationError;
|
|
33
|
-
constructor({ authManager, immutableXClient, passportEventEmitter,
|
|
33
|
+
constructor({ authManager, immutableXClient, passportEventEmitter, magicTEESigner, 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';
|
|
6
5
|
import { PassportEventMap } from '../types';
|
|
7
|
-
import TypedEventEmitter from '../utils/typedEventEmitter';
|
|
8
6
|
import GuardianClient from '../guardian';
|
|
7
|
+
import MagicTEESigner from '../magic/magicTEESigner';
|
|
8
|
+
import TypedEventEmitter from '../utils/typedEventEmitter';
|
|
9
9
|
export type PassportImxProviderFactoryInput = {
|
|
10
10
|
authManager: AuthManager;
|
|
11
11
|
immutableXClient: IMXClient;
|
|
12
|
-
|
|
12
|
+
magicTEESigner: MagicTEESigner;
|
|
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
|
|
20
|
+
private readonly magicTEESigner;
|
|
21
21
|
private readonly passportEventEmitter;
|
|
22
22
|
readonly imxApiClients: ImxApiClients;
|
|
23
23
|
private readonly guardianClient;
|
|
24
|
-
constructor({ authManager, immutableXClient,
|
|
24
|
+
constructor({ authManager, immutableXClient, magicTEESigner, passportEventEmitter, imxApiClients, guardianClient, }: PassportImxProviderFactoryInput);
|
|
25
25
|
getProvider(): Promise<IMXProvider>;
|
|
26
26
|
getProviderSilent(): Promise<IMXProvider | null>;
|
|
27
27
|
private createProviderInstance;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Environment, ModuleConfiguration } from '@imtbl/config';
|
|
2
|
-
import {
|
|
2
|
+
import { IMXClient } from '@imtbl/x-client';
|
|
3
3
|
import { ImxApiClients } from '@imtbl/generated-clients';
|
|
4
4
|
import { Flow } from '@imtbl/metrics';
|
|
5
5
|
/**
|
|
@@ -30,18 +30,22 @@ 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
|
+
}
|
|
33
37
|
export type User = {
|
|
34
38
|
idToken?: string;
|
|
35
39
|
accessToken: string;
|
|
36
40
|
refreshToken?: string;
|
|
37
41
|
profile: UserProfile;
|
|
38
42
|
expired?: boolean;
|
|
39
|
-
|
|
43
|
+
[RollupType.IMX]?: {
|
|
40
44
|
ethAddress: string;
|
|
41
45
|
starkAddress: string;
|
|
42
46
|
userAdminAddress: string;
|
|
43
47
|
};
|
|
44
|
-
|
|
48
|
+
[RollupType.ZKEVM]?: {
|
|
45
49
|
ethAddress: string;
|
|
46
50
|
userAdminAddress: string;
|
|
47
51
|
};
|
|
@@ -106,8 +110,8 @@ export interface PassportModuleConfiguration extends ModuleConfiguration<Passpor
|
|
|
106
110
|
type WithRequired<T, K extends keyof T> = T & {
|
|
107
111
|
[P in K]-?: T[P];
|
|
108
112
|
};
|
|
109
|
-
export type UserImx = WithRequired<User,
|
|
110
|
-
export type UserZkEvm = WithRequired<User,
|
|
113
|
+
export type UserImx = WithRequired<User, RollupType.IMX>;
|
|
114
|
+
export type UserZkEvm = WithRequired<User, RollupType.ZKEVM>;
|
|
111
115
|
export declare const isUserZkEvm: (user: User) => user is UserZkEvm;
|
|
112
116
|
export declare const isUserImx: (user: User) => user is UserImx;
|
|
113
117
|
export type DeviceTokenResponse = {
|
|
@@ -134,10 +138,6 @@ export type PKCEData = {
|
|
|
134
138
|
state: string;
|
|
135
139
|
verifier: string;
|
|
136
140
|
};
|
|
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,23 +1,24 @@
|
|
|
1
1
|
import { MultiRollupApiClients } from '@imtbl/generated-clients';
|
|
2
|
+
import { Signer } from 'ethers';
|
|
2
3
|
import { Provider, RequestArguments } from './types';
|
|
3
4
|
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 } from '../types';
|
|
7
|
+
import { PassportEventMap, User } from '../types';
|
|
8
8
|
import GuardianClient from '../guardian';
|
|
9
9
|
export type ZkEvmProviderInput = {
|
|
10
10
|
authManager: AuthManager;
|
|
11
|
-
magicAdapter: MagicAdapter;
|
|
12
11
|
config: PassportConfiguration;
|
|
13
12
|
multiRollupApiClients: MultiRollupApiClients;
|
|
14
13
|
passportEventEmitter: TypedEventEmitter<PassportEventMap>;
|
|
15
14
|
guardianClient: GuardianClient;
|
|
15
|
+
ethSigner: Signer;
|
|
16
|
+
user: User | null;
|
|
16
17
|
};
|
|
17
18
|
export declare class ZkEvmProvider implements Provider {
|
|
18
19
|
#private;
|
|
19
20
|
readonly isPassport: boolean;
|
|
20
|
-
constructor({ authManager,
|
|
21
|
+
constructor({ authManager, config, multiRollupApiClients, passportEventEmitter, guardianClient, ethSigner, user, }: ZkEvmProviderInput);
|
|
21
22
|
request(request: RequestArguments): Promise<any>;
|
|
22
23
|
on(event: string, listener: (...args: any[]) => void): void;
|
|
23
24
|
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.
|
|
4
|
+
"version": "2.4.10-alpha.1",
|
|
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.
|
|
11
|
-
"@imtbl/generated-clients": "2.4.10-alpha.
|
|
12
|
-
"@imtbl/metrics": "2.4.10-alpha.
|
|
13
|
-
"@imtbl/toolkit": "2.4.10-alpha.
|
|
14
|
-
"@imtbl/x-client": "2.4.10-alpha.
|
|
15
|
-
"@imtbl/x-provider": "2.4.10-alpha.
|
|
10
|
+
"@imtbl/config": "2.4.10-alpha.1",
|
|
11
|
+
"@imtbl/generated-clients": "2.4.10-alpha.1",
|
|
12
|
+
"@imtbl/metrics": "2.4.10-alpha.1",
|
|
13
|
+
"@imtbl/toolkit": "2.4.10-alpha.1",
|
|
14
|
+
"@imtbl/x-client": "2.4.10-alpha.1",
|
|
15
|
+
"@imtbl/x-provider": "2.4.10-alpha.1",
|
|
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,12 +0,0 @@
|
|
|
1
|
-
import { Eip1193Provider } from 'ethers';
|
|
2
|
-
import { PassportConfiguration } from '../config';
|
|
3
|
-
import { MagicProviderProxyFactory } from './magicProviderProxyFactory';
|
|
4
|
-
export default class MagicAdapter {
|
|
5
|
-
private readonly config;
|
|
6
|
-
private readonly magicProviderProxyFactory;
|
|
7
|
-
private readonly magicClient?;
|
|
8
|
-
constructor(config: PassportConfiguration, magicProviderProxyFactory: MagicProviderProxyFactory);
|
|
9
|
-
private getMagicClient;
|
|
10
|
-
login(idToken: string): Promise<Eip1193Provider>;
|
|
11
|
-
logout(): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Eip1193Provider } from 'ethers';
|
|
2
|
-
import AuthManager from '../authManager';
|
|
3
|
-
import { PassportConfiguration } from '../config';
|
|
4
|
-
import { MagicClient } from './types';
|
|
5
|
-
/**
|
|
6
|
-
* Factory class for creating a Magic provider that automatically handles re-authentication.
|
|
7
|
-
* This proxy wraps the Magic RPC provider to intercept certain RPC methods (`personal_sign`, `eth_accounts`)
|
|
8
|
-
* and ensures the user is properly authenticated before executing them.
|
|
9
|
-
*/
|
|
10
|
-
export declare class MagicProviderProxyFactory {
|
|
11
|
-
private authManager;
|
|
12
|
-
private config;
|
|
13
|
-
constructor(authManager: AuthManager, config: PassportConfiguration);
|
|
14
|
-
createProxy(magicClient: MagicClient): Eip1193Provider;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|