@web3auth/no-modal 11.0.0-beta.0 → 11.0.0-beta.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/lib.cjs/account-linking/index.js +8 -0
- package/dist/lib.cjs/account-linking/react.js +95 -0
- package/dist/lib.cjs/account-linking/rest.js +54 -0
- package/dist/lib.cjs/account-linking/vue.js +98 -0
- package/dist/lib.cjs/base/analytics.js +17 -2
- package/dist/lib.cjs/base/connector/constants.js +2 -0
- package/dist/lib.cjs/base/errors/index.js +48 -0
- package/dist/lib.cjs/base/utils.js +15 -3
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +427 -50
- package/dist/lib.cjs/connectors/base-evm-connector/baseEvmConnector.js +42 -23
- package/dist/lib.cjs/connectors/base-solana-connector/baseSolanaConnector.js +41 -24
- package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +76 -45
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +41 -13
- package/dist/lib.cjs/index.js +20 -13
- package/dist/lib.cjs/noModal.js +811 -110
- package/dist/lib.cjs/plugins/wallet-services-plugin/plugin.js +1 -1
- package/dist/lib.cjs/providers/base-provider/baseProvider.js +65 -33
- package/dist/lib.cjs/react/context/useWeb3AuthInnerContextValue.js +34 -20
- package/dist/lib.cjs/react/hooks/useWallets.js +51 -0
- package/dist/lib.cjs/react/hooks/useWeb3AuthConnect.js +2 -2
- package/dist/lib.cjs/react/index.js +2 -0
- package/dist/lib.cjs/react/solana/hooks/useSolanaWallet.js +2 -2
- package/dist/lib.cjs/react/solana/provider.js +2 -0
- package/dist/lib.cjs/types/account-linking/index.d.ts +2 -0
- package/dist/lib.cjs/types/account-linking/interfaces.d.ts +90 -0
- package/dist/lib.cjs/types/account-linking/react.d.ts +19 -0
- package/dist/lib.cjs/types/account-linking/rest.d.ts +9 -0
- package/dist/lib.cjs/types/account-linking/vue.d.ts +20 -0
- package/dist/lib.cjs/types/base/analytics.d.ts +9 -0
- package/dist/lib.cjs/types/base/connector/baseConnector.d.ts +5 -0
- package/dist/lib.cjs/types/base/connector/constants.d.ts +2 -0
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +51 -6
- package/dist/lib.cjs/types/base/core/IWeb3Auth.d.ts +39 -2
- package/dist/lib.cjs/types/base/errors/index.d.ts +13 -0
- package/dist/lib.cjs/types/base/interfaces.d.ts +3 -1
- package/dist/lib.cjs/types/base/utils.d.ts +7 -1
- package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +27 -3
- package/dist/lib.cjs/types/connectors/auth-connector/interface.d.ts +77 -2
- package/dist/lib.cjs/types/connectors/base-evm-connector/baseEvmConnector.d.ts +6 -0
- package/dist/lib.cjs/types/connectors/base-solana-connector/baseSolanaConnector.d.ts +6 -0
- package/dist/lib.cjs/types/index.d.ts +1 -0
- package/dist/lib.cjs/types/noModal.d.ts +104 -5
- package/dist/lib.cjs/types/providers/base-provider/baseProvider.d.ts +7 -0
- package/dist/lib.cjs/types/react/hooks/index.d.ts +1 -0
- package/dist/lib.cjs/types/react/hooks/useWallets.d.ts +8 -0
- package/dist/lib.cjs/types/vue/composables/index.d.ts +1 -0
- package/dist/lib.cjs/types/vue/composables/useWallets.d.ts +9 -0
- package/dist/lib.cjs/vue/composables/useWallets.js +52 -0
- package/dist/lib.cjs/vue/composables/useWeb3AuthConnect.js +2 -2
- package/dist/lib.cjs/vue/index.js +2 -0
- package/dist/lib.cjs/vue/solana/composables/useSolanaWallet.js +2 -2
- package/dist/lib.cjs/vue/solana/provider.js +3 -0
- package/dist/lib.cjs/vue/useWeb3AuthInnerContextValue.js +13 -4
- package/dist/lib.cjs/vue/wagmi/provider.js +19 -7
- package/dist/lib.esm/account-linking/index.js +1 -0
- package/dist/lib.esm/account-linking/react.js +74 -0
- package/dist/lib.esm/account-linking/rest.js +51 -0
- package/dist/lib.esm/account-linking/vue.js +78 -0
- package/dist/lib.esm/base/analytics.js +17 -2
- package/dist/lib.esm/base/connector/constants.js +2 -0
- package/dist/lib.esm/base/errors/index.js +48 -1
- package/dist/lib.esm/base/utils.js +16 -4
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +386 -9
- package/dist/lib.esm/connectors/base-evm-connector/baseEvmConnector.js +43 -24
- package/dist/lib.esm/connectors/base-solana-connector/baseSolanaConnector.js +43 -26
- package/dist/lib.esm/connectors/coinbase-connector/coinbaseConnector.js +2 -2
- package/dist/lib.esm/connectors/injected-evm-connector/injectedEvmConnector.js +2 -2
- package/dist/lib.esm/connectors/injected-solana-connector/walletStandardConnector.js +3 -3
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +80 -49
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/WalletConnectV2Provider.js +2 -2
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +43 -15
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/wcSolanaWallet.js +1 -1
- package/dist/lib.esm/index.js +4 -3
- package/dist/lib.esm/noModal.js +828 -119
- package/dist/lib.esm/plugins/wallet-services-plugin/plugin.js +3 -3
- package/dist/lib.esm/providers/base-provider/baseProvider.js +68 -38
- package/dist/lib.esm/react/context/useWeb3AuthInnerContextValue.js +36 -21
- package/dist/lib.esm/react/hooks/useWallets.js +33 -0
- package/dist/lib.esm/react/hooks/useWeb3AuthConnect.js +2 -2
- package/dist/lib.esm/react/index.js +1 -0
- package/dist/lib.esm/react/solana/hooks/useSolanaWallet.js +2 -2
- package/dist/lib.esm/react/solana/provider.js +4 -1
- package/dist/lib.esm/react/wagmi/provider.js +1 -1
- package/dist/lib.esm/vue/composables/useCheckout.js +1 -1
- package/dist/lib.esm/vue/composables/useFunding.js +1 -1
- package/dist/lib.esm/vue/composables/useReceive.js +1 -1
- package/dist/lib.esm/vue/composables/useSwap.js +1 -1
- package/dist/lib.esm/vue/composables/useWalletConnectScanner.js +1 -1
- package/dist/lib.esm/vue/composables/useWalletUI.js +1 -1
- package/dist/lib.esm/vue/composables/useWallets.js +35 -0
- package/dist/lib.esm/vue/composables/useWeb3AuthConnect.js +2 -2
- package/dist/lib.esm/vue/index.js +1 -0
- package/dist/lib.esm/vue/solana/composables/useSignAndSendTransaction.js +1 -1
- package/dist/lib.esm/vue/solana/composables/useSignMessage.js +1 -1
- package/dist/lib.esm/vue/solana/composables/useSignTransaction.js +1 -1
- package/dist/lib.esm/vue/solana/composables/useSolanaWallet.js +2 -2
- package/dist/lib.esm/vue/solana/provider.js +4 -0
- package/dist/lib.esm/vue/useWeb3AuthInnerContextValue.js +12 -3
- package/dist/lib.esm/vue/wagmi/provider.js +20 -8
- package/package.json +43 -19
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { CaipAccountId } from "@metamask/connect-evm";
|
|
1
2
|
import type { Wallet } from "@wallet-standard/base";
|
|
2
3
|
import { AUTH_CONNECTION_TYPE, AuthUserInfo, ExtraLoginOptions, JRPCRequest, JRPCResponse, Maybe, RequestArguments, SafeEventEmitter, SendCallBack, UX_MODE, type UX_MODE_TYPE, WEB3AUTH_NETWORK, type WEB3AUTH_NETWORK_TYPE } from "@web3auth/auth";
|
|
4
|
+
import { BaseLinkedAccountInfo } from "../../account-linking/interfaces";
|
|
3
5
|
import { type Analytics } from "../analytics";
|
|
4
6
|
import type { ChainNamespaceType, ConnectorNamespaceType, CustomChainConfig } from "../chain/IChainInterface";
|
|
5
7
|
import type { IWeb3AuthCoreOptions } from "../core/IWeb3Auth";
|
|
@@ -8,7 +10,28 @@ import type { LoginModeType, ProjectConfig } from "../interfaces";
|
|
|
8
10
|
import type { ProviderEvents, SafeEventEmitterProvider } from "../provider/IProvider";
|
|
9
11
|
import { WALLET_CONNECTOR_TYPE } from "../wallet";
|
|
10
12
|
import { CONNECTOR_CATEGORY, CONNECTOR_EVENTS, CONNECTOR_STATUS } from "./constants";
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export interface LinkedAccountInfo extends BaseLinkedAccountInfo {
|
|
17
|
+
/** Linked account id */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Whether the account is the primary account for the user */
|
|
20
|
+
isPrimary: boolean;
|
|
21
|
+
/** Wallet address of the connected account */
|
|
22
|
+
eoaAddress: string;
|
|
23
|
+
/** Address of the account abstraction for the account */
|
|
24
|
+
aaAddress?: string;
|
|
25
|
+
/** Provider of the account abstraction for the account */
|
|
26
|
+
aaProvider?: string;
|
|
27
|
+
/** Connector name of the account */
|
|
28
|
+
connector: string;
|
|
29
|
+
/** Indicates if the account is the active account */
|
|
30
|
+
active: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type UserInfo = AuthUserInfo & {
|
|
33
|
+
linkedAccounts?: LinkedAccountInfo[];
|
|
34
|
+
};
|
|
12
35
|
export { UX_MODE, UX_MODE_TYPE, WEB3AUTH_NETWORK, WEB3AUTH_NETWORK_TYPE };
|
|
13
36
|
export type CONNECTOR_CATEGORY_TYPE = (typeof CONNECTOR_CATEGORY)[keyof typeof CONNECTOR_CATEGORY];
|
|
14
37
|
export interface ConnectorInitOptions {
|
|
@@ -72,9 +95,7 @@ export interface IConnector<T> extends SafeEventEmitter {
|
|
|
72
95
|
disconnect(options?: {
|
|
73
96
|
cleanup: boolean;
|
|
74
97
|
}): Promise<void>;
|
|
75
|
-
connect(params: T &
|
|
76
|
-
chainId: string;
|
|
77
|
-
}): Promise<Connection | null>;
|
|
98
|
+
connect(params: T & BaseConnectorLoginParams): Promise<Connection | null>;
|
|
78
99
|
getUserInfo(): Promise<Partial<UserInfo>>;
|
|
79
100
|
enableMFA(params?: T): Promise<void>;
|
|
80
101
|
manageMFA(params?: T): Promise<void>;
|
|
@@ -82,6 +103,11 @@ export interface IConnector<T> extends SafeEventEmitter {
|
|
|
82
103
|
chainId: string;
|
|
83
104
|
}): Promise<void>;
|
|
84
105
|
getAuthTokenInfo(): Promise<AuthTokenInfo>;
|
|
106
|
+
generateChallengeAndSign(authServerUrl?: string, accounts?: string[]): Promise<{
|
|
107
|
+
challenge: string;
|
|
108
|
+
signature: string;
|
|
109
|
+
chainNamespace: ChainNamespaceType;
|
|
110
|
+
}>;
|
|
85
111
|
cleanup?(): Promise<void>;
|
|
86
112
|
}
|
|
87
113
|
export type ConnectorParams = {
|
|
@@ -91,13 +117,24 @@ export type ConnectorParams = {
|
|
|
91
117
|
};
|
|
92
118
|
export type BaseConnectorLoginParams = {
|
|
93
119
|
chainId: string;
|
|
94
|
-
getAuthTokenInfo
|
|
120
|
+
getAuthTokenInfo?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* for metamask connector, array of caip account ids to be used for connecting to the wallet
|
|
123
|
+
*/
|
|
124
|
+
caipAccountIds?: CaipAccountId[];
|
|
125
|
+
/**
|
|
126
|
+
* Whether the connection is for the primary account or account linking
|
|
127
|
+
*/
|
|
128
|
+
isAccountLinking?: boolean;
|
|
95
129
|
};
|
|
96
130
|
export type ConnectorFn = (params: ConnectorParams) => IConnector<unknown>;
|
|
97
131
|
export type CONNECTED_EVENT_DATA = Connection & {
|
|
98
132
|
reconnected: boolean;
|
|
99
133
|
pendingUserConsent?: boolean;
|
|
100
134
|
};
|
|
135
|
+
export type DISCONNECTED_EVENT_DATA = {
|
|
136
|
+
connector: WALLET_CONNECTOR_TYPE | string;
|
|
137
|
+
};
|
|
101
138
|
export type AUTHORIZED_EVENT_DATA = {
|
|
102
139
|
connector: WALLET_CONNECTOR_TYPE | string;
|
|
103
140
|
authTokenInfo: AuthTokenInfo;
|
|
@@ -106,11 +143,12 @@ export interface IConnectorDataEvent {
|
|
|
106
143
|
connectorName: string;
|
|
107
144
|
data: unknown;
|
|
108
145
|
}
|
|
146
|
+
export type CONNECTION_UPDATED_EVENT_DATA = Connection;
|
|
109
147
|
export type ConnectorEvents = {
|
|
110
148
|
[CONNECTOR_EVENTS.NOT_READY]: () => void;
|
|
111
149
|
[CONNECTOR_EVENTS.READY]: (connector: WALLET_CONNECTOR_TYPE | string) => void;
|
|
112
150
|
[CONNECTOR_EVENTS.CONNECTED]: (data: CONNECTED_EVENT_DATA) => void;
|
|
113
|
-
[CONNECTOR_EVENTS.DISCONNECTED]: () => void;
|
|
151
|
+
[CONNECTOR_EVENTS.DISCONNECTED]: (data?: DISCONNECTED_EVENT_DATA) => void;
|
|
114
152
|
[CONNECTOR_EVENTS.CONNECTING]: (data: {
|
|
115
153
|
connector: WALLET_CONNECTOR_TYPE | string;
|
|
116
154
|
}) => void;
|
|
@@ -130,6 +168,7 @@ export type ConnectorEvents = {
|
|
|
130
168
|
[CONNECTOR_EVENTS.CONSENT_ACCEPTED]: (data: CONNECTED_EVENT_DATA & {
|
|
131
169
|
loginMode: LoginModeType;
|
|
132
170
|
}) => void;
|
|
171
|
+
[CONNECTOR_EVENTS.CONNECTION_UPDATED]: (data: CONNECTION_UPDATED_EVENT_DATA) => void;
|
|
133
172
|
};
|
|
134
173
|
export interface BaseConnectorConfig {
|
|
135
174
|
label: string;
|
|
@@ -199,3 +238,9 @@ export type WalletConnectV2Data = {
|
|
|
199
238
|
export type MetaMaskConnectorData = {
|
|
200
239
|
uri: string;
|
|
201
240
|
};
|
|
241
|
+
export type ConnectedAccountsWithProviders = Omit<LinkedAccountInfo, "connector"> & {
|
|
242
|
+
connector: IConnector<unknown>;
|
|
243
|
+
signingProvider: IProvider | null;
|
|
244
|
+
solanaWallet: Connection["solanaWallet"];
|
|
245
|
+
connected: boolean;
|
|
246
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type AccountAbstractionMultiChainConfig } from "@toruslabs/ethereum-controllers";
|
|
2
2
|
import { type BUILD_ENV_TYPE, type CookieOptions, type LoginParams, MfaLevelType, MfaSettings, SafeEventEmitter, type StorageConfig, UX_MODE_TYPE, type WhiteLabelData } from "@web3auth/auth";
|
|
3
3
|
import { type WsEmbedParams } from "@web3auth/ws-embed";
|
|
4
|
+
import { type LinkAccountParams, type LinkAccountResult, UnlinkAccountResult } from "../../account-linking";
|
|
4
5
|
import { type ChainNamespaceType, type CustomChainConfig } from "../chain/IChainInterface";
|
|
5
|
-
import { type AuthTokenInfo, CONNECTED_EVENT_DATA, type Connection, CONNECTOR_EVENTS, CONNECTOR_INITIAL_AUTHENTICATION_MODE, type CONNECTOR_STATUS_TYPE, ConnectorEvents, type ConnectorFn, type IBaseProvider, type IConnector, type UserInfo, type WEB3AUTH_NETWORK_TYPE } from "../connector";
|
|
6
|
+
import { type AuthTokenInfo, CONNECTED_EVENT_DATA, type Connection, CONNECTION_UPDATED_EVENT_DATA, CONNECTOR_EVENTS, CONNECTOR_INITIAL_AUTHENTICATION_MODE, type CONNECTOR_STATUS_TYPE, ConnectorEvents, type ConnectorFn, type IBaseProvider, type IConnector, LinkedAccountInfo, type UserInfo, type WEB3AUTH_NETWORK_TYPE } from "../connector";
|
|
6
7
|
import { Web3AuthError } from "../errors";
|
|
7
8
|
import { LoginModeType } from "../interfaces";
|
|
8
9
|
import { type IPlugin, type PluginFn } from "../plugin";
|
|
@@ -138,6 +139,11 @@ export interface IWeb3AuthCoreOptions {
|
|
|
138
139
|
* @defaultValue "connect-and-sign"
|
|
139
140
|
*/
|
|
140
141
|
initialAuthenticationMode?: ConnectorInitialAuthenticationModeType;
|
|
142
|
+
/**
|
|
143
|
+
* Whether to disable analytics
|
|
144
|
+
* @defaultValue false
|
|
145
|
+
*/
|
|
146
|
+
disableAnalytics?: boolean;
|
|
141
147
|
}
|
|
142
148
|
export type LoginParamMap = {
|
|
143
149
|
[WALLET_CONNECTORS.AUTH]: Partial<AuthLoginParams>;
|
|
@@ -154,7 +160,7 @@ export type LoginParamMap = {
|
|
|
154
160
|
export interface IWeb3AuthCore extends SafeEventEmitter {
|
|
155
161
|
currentChainId: string | null;
|
|
156
162
|
readonly coreOptions: IWeb3AuthCoreOptions;
|
|
157
|
-
|
|
163
|
+
primaryConnectorName: WALLET_CONNECTOR_TYPE | null;
|
|
158
164
|
currentChain: CustomChainConfig | undefined;
|
|
159
165
|
status: CONNECTOR_STATUS_TYPE;
|
|
160
166
|
connection: Connection | null;
|
|
@@ -186,6 +192,36 @@ export interface IWeb3Auth extends IWeb3AuthCore {
|
|
|
186
192
|
manageMFA<T>(params: T): Promise<void>;
|
|
187
193
|
setAnalyticsProperties(properties: Record<string, unknown>): void;
|
|
188
194
|
cleanup(): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Switch the active connection to a linked wallet: connects an isolated
|
|
197
|
+
* instance of that wallet’s connector, updates `connection.ethereumProvider` / `solanaWallet`,
|
|
198
|
+
* and emits `connection_updated` so Wagmi/UI can resync.
|
|
199
|
+
* The auxiliary connector stays connected (not torn down after switch). The previous auxiliary
|
|
200
|
+
* connector is disconnected when starting another switch or when the primary session disconnects.
|
|
201
|
+
*
|
|
202
|
+
* Requires an AUTH primary session and a matching `userInfo.linkedAccounts` entry.
|
|
203
|
+
*/
|
|
204
|
+
switchAccount(account: LinkedAccountInfo): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Link an external wallet to the currently authenticated user account
|
|
207
|
+
* via the Citadel account-linking endpoint.
|
|
208
|
+
*
|
|
209
|
+
* Requires:
|
|
210
|
+
* - The user to be currently connected with the AUTH connector.
|
|
211
|
+
* - `accountLinking.serverUrl` to be set in the Web3Auth constructor options.
|
|
212
|
+
*
|
|
213
|
+
* @param params - Linking parameters including the target connector name.
|
|
214
|
+
* @returns A result object confirming the link, including the linked address.
|
|
215
|
+
*/
|
|
216
|
+
linkAccount(params?: LinkAccountParams): Promise<LinkAccountResult>;
|
|
217
|
+
/**
|
|
218
|
+
* Unlink an external wallet from the currently authenticated user account
|
|
219
|
+
* via the Citadel account-unlinking endpoint.
|
|
220
|
+
*
|
|
221
|
+
* @param params - Unlinking parameters including the target account address.
|
|
222
|
+
* @returns A result object confirming the unlink.
|
|
223
|
+
*/
|
|
224
|
+
unlinkAccount(address: string): Promise<UnlinkAccountResult>;
|
|
189
225
|
}
|
|
190
226
|
export type SDK_CONNECTED_EVENT_DATA = CONNECTED_EVENT_DATA & {
|
|
191
227
|
loginMode: LoginModeType;
|
|
@@ -200,6 +236,7 @@ export type Web3AuthNoModalEvents = Omit<ConnectorEvents, "connected" | "errored
|
|
|
200
236
|
[CONNECTOR_EVENTS.CONSENT_REQUIRING]: () => void;
|
|
201
237
|
[CONNECTOR_EVENTS.CONSENT_ACCEPTED]: (data: SDK_CONSENT_ACCEPTED_EVENT_DATA) => void;
|
|
202
238
|
[CONNECTOR_EVENTS.ERRORED]: (error: Web3AuthError, loginMode: LoginModeType) => void;
|
|
239
|
+
[CONNECTOR_EVENTS.CONNECTION_UPDATED]: (data: CONNECTION_UPDATED_EVENT_DATA) => void;
|
|
203
240
|
MODAL_VISIBILITY: (visibility: boolean) => void;
|
|
204
241
|
};
|
|
205
242
|
export type Web3AuthNoModalOptions = IWeb3AuthCoreOptions;
|
|
@@ -57,6 +57,19 @@ export declare class WalletOperationsError extends Web3AuthError {
|
|
|
57
57
|
static operationNotAllowed(extraMessage?: string, cause?: unknown): IWeb3AuthError;
|
|
58
58
|
static chainNamespaceNotAllowed(extraMessage?: string, cause?: unknown): IWeb3AuthError;
|
|
59
59
|
}
|
|
60
|
+
export declare class AccountLinkingError extends Web3AuthError {
|
|
61
|
+
protected static messages: ErrorCodes;
|
|
62
|
+
constructor(code: number, message?: string, cause?: unknown);
|
|
63
|
+
static fromCode(code: number, extraMessage?: string, cause?: unknown): AccountLinkingError;
|
|
64
|
+
static requestFailed(extraMessage?: string, cause?: unknown): AccountLinkingError;
|
|
65
|
+
static serverNotConfigured(extraMessage?: string, cause?: unknown): AccountLinkingError;
|
|
66
|
+
static primaryTokenNotAvailable(extraMessage?: string, cause?: unknown): AccountLinkingError;
|
|
67
|
+
static walletProofFailed(extraMessage?: string, cause?: unknown): AccountLinkingError;
|
|
68
|
+
static unsupportedConnector(extraMessage?: string, cause?: unknown): AccountLinkingError;
|
|
69
|
+
static cannotUnlinkActiveAccount(): AccountLinkingError;
|
|
70
|
+
static accountNotLinked(message?: string, cause?: unknown): AccountLinkingError;
|
|
71
|
+
static cannotUnlinkPrimaryAccount(): AccountLinkingError;
|
|
72
|
+
}
|
|
60
73
|
export declare class WalletProviderError extends Web3AuthError {
|
|
61
74
|
protected static messages: ErrorCodes;
|
|
62
75
|
constructor(code: number, message?: string, cause?: unknown);
|
|
@@ -2,6 +2,7 @@ import { type BUTTON_POSITION_TYPE } from "@toruslabs/base-controllers";
|
|
|
2
2
|
import type { SmartAccountEipStandardType, SmartAccountType } from "@toruslabs/ethereum-controllers";
|
|
3
3
|
import { AuthConnectionConfigItem, type WhiteLabelData } from "@web3auth/auth";
|
|
4
4
|
import { type ChainNamespaceType, type CustomChainConfig } from "./chain/IChainInterface";
|
|
5
|
+
import { LinkedAccountInfo } from "./connector";
|
|
5
6
|
import { LOGIN_MODE, MODAL_SIGN_IN_METHODS, SMART_ACCOUNT_WALLET_SCOPE, WIDGET_TYPE } from "./constants";
|
|
6
7
|
import { WALLET_CONNECTOR_TYPE } from "./wallet";
|
|
7
8
|
export interface WhitelistResponse {
|
|
@@ -10,11 +11,12 @@ export interface WhitelistResponse {
|
|
|
10
11
|
}
|
|
11
12
|
export interface IWeb3AuthState {
|
|
12
13
|
cachedConnector: string | null;
|
|
13
|
-
|
|
14
|
+
primaryConnectorName: WALLET_CONNECTOR_TYPE | null;
|
|
14
15
|
currentChainId: string;
|
|
15
16
|
idToken: string | null;
|
|
16
17
|
accessToken: string | null;
|
|
17
18
|
refreshToken: string | null;
|
|
19
|
+
activeAccount: LinkedAccountInfo | null;
|
|
18
20
|
hasUserConsent?: boolean;
|
|
19
21
|
}
|
|
20
22
|
export type ChainsConfig = CustomChainConfig[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cloneDeep } from "@toruslabs/base-controllers";
|
|
1
|
+
import { ChainNamespaceType, cloneDeep } from "@toruslabs/base-controllers";
|
|
2
2
|
import { type AccountAbstractionMultiChainConfig } from "@toruslabs/ethereum-controllers";
|
|
3
3
|
import { type BUILD_ENV_TYPE } from "@web3auth/auth";
|
|
4
4
|
import { type Chain } from "viem";
|
|
@@ -67,3 +67,9 @@ export declare const getErrorAnalyticsProperties: (error: unknown) => {
|
|
|
67
67
|
};
|
|
68
68
|
export declare const getHostname: (url: string) => string;
|
|
69
69
|
export declare const getCaipChainId: (chain: Pick<CustomChainConfig, "chainNamespace" | "chainId">) => string;
|
|
70
|
+
/**
|
|
71
|
+
* Parse the chain namespace from the citadel response
|
|
72
|
+
* @param chainNamespace - The chain namespace from the citadel response
|
|
73
|
+
* @returns The parsed chain namespace
|
|
74
|
+
*/
|
|
75
|
+
export declare const parseChainNamespaceFromCitadelResponse: (chainNamespace: string) => ChainNamespaceType;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ChainNamespaceType } from "@toruslabs/base-controllers";
|
|
1
2
|
import type { Wallet } from "@wallet-standard/base";
|
|
2
3
|
import { Auth, AuthConnectionConfigItem } from "@web3auth/auth";
|
|
3
4
|
import { type default as WsEmbed } from "@web3auth/ws-embed";
|
|
4
|
-
import {
|
|
5
|
-
import type
|
|
6
|
-
|
|
5
|
+
import { LinkAccountResult, UnlinkAccountResult } from "../../account-linking";
|
|
6
|
+
import { AccountLinkingError, AuthLoginParams, AuthTokenInfo, BaseConnector, BaseConnectorLoginParams, type Connection, CONNECTOR_CATEGORY_TYPE, CONNECTOR_STATUS_TYPE, ConnectorFn, ConnectorInitOptions, ConnectorNamespaceType, IConnector, IProvider, LinkedAccountInfo, UserInfo, WALLET_CONNECTOR_TYPE } from "../../base";
|
|
7
|
+
import { type AuthConnectorLinkAccountParams, type AuthConnectorOptions, type AuthConnectorSwitchAccountContext, type AuthConnectorSwitchAccountResult, type AuthConnectorUnlinkAccountParams, IAuthConnector, type PrivateKeyProvider } from "./interface";
|
|
8
|
+
declare class AuthConnector extends BaseConnector<AuthLoginParams> implements IAuthConnector {
|
|
7
9
|
readonly name: WALLET_CONNECTOR_TYPE;
|
|
8
10
|
readonly connectorNamespace: ConnectorNamespaceType;
|
|
9
11
|
readonly type: CONNECTOR_CATEGORY_TYPE;
|
|
@@ -17,6 +19,7 @@ declare class AuthConnector extends BaseConnector<AuthLoginParams> {
|
|
|
17
19
|
private authConnectionConfig;
|
|
18
20
|
private wsEmbedInstancePromise;
|
|
19
21
|
private _solanaWallet;
|
|
22
|
+
private analytics;
|
|
20
23
|
constructor(params: AuthConnectorOptions);
|
|
21
24
|
get provider(): IProvider | null;
|
|
22
25
|
get wsEmbed(): WsEmbed;
|
|
@@ -31,6 +34,7 @@ declare class AuthConnector extends BaseConnector<AuthLoginParams> {
|
|
|
31
34
|
}): Promise<void>;
|
|
32
35
|
getAuthTokenInfo(): Promise<AuthTokenInfo>;
|
|
33
36
|
getUserInfo(): Promise<Partial<UserInfo>>;
|
|
37
|
+
getLinkedAccounts(): Promise<LinkedAccountInfo[]>;
|
|
34
38
|
switchChain(params: {
|
|
35
39
|
chainId: string;
|
|
36
40
|
}, init?: boolean): Promise<void>;
|
|
@@ -38,6 +42,24 @@ declare class AuthConnector extends BaseConnector<AuthLoginParams> {
|
|
|
38
42
|
getOAuthProviderConfig(params: Pick<AuthLoginParams, "authConnection" | "authConnectionId" | "groupedAuthConnectionId">): AuthConnectionConfigItem & {
|
|
39
43
|
isDefault?: boolean;
|
|
40
44
|
};
|
|
45
|
+
generateChallengeAndSign(): Promise<{
|
|
46
|
+
challenge: string;
|
|
47
|
+
signature: string;
|
|
48
|
+
chainNamespace: ChainNamespaceType;
|
|
49
|
+
}>;
|
|
50
|
+
switchAccount(account: LinkedAccountInfo, context: AuthConnectorSwitchAccountContext): Promise<AuthConnectorSwitchAccountResult>;
|
|
51
|
+
trackSwitchAccountCompleted(account: LinkedAccountInfo): Promise<void>;
|
|
52
|
+
trackSwitchAccountFailed(account: Pick<LinkedAccountInfo, "id" | "accountType" | "eoaAddress">, error: unknown): Promise<void>;
|
|
53
|
+
linkAccount(params: AuthConnectorLinkAccountParams): Promise<LinkAccountResult>;
|
|
54
|
+
unlinkAccount(params: AuthConnectorUnlinkAccountParams): Promise<UnlinkAccountResult>;
|
|
55
|
+
getChainIdForLinkedAccount(account: Pick<LinkedAccountInfo, "chainNamespace" | "connector">, preferredChainId?: string | null): string;
|
|
56
|
+
assertSwitchAccountConnectorMatchesTarget(connector: IConnector<unknown>, account: Pick<LinkedAccountInfo, "chainNamespace" | "connector" | "eoaAddress">): Promise<void>;
|
|
57
|
+
toSwitchAccountConnectorError(account: Pick<LinkedAccountInfo, "connector" | "eoaAddress">, error: unknown): AccountLinkingError;
|
|
58
|
+
private getSwitchAccountTrackData;
|
|
59
|
+
private getPrimaryAuthSession;
|
|
60
|
+
private getNetworkForUnlinkAddress;
|
|
61
|
+
private createWalletLinkingProof;
|
|
62
|
+
private getLinkingWalletAddress;
|
|
41
63
|
private setupSolanaWallet;
|
|
42
64
|
private _getFinalPrivKey;
|
|
43
65
|
private connectWithProvider;
|
|
@@ -52,5 +74,7 @@ type AuthConnectorFuncParams = Omit<AuthConnectorOptions, "coreOptions" | "authC
|
|
|
52
74
|
connectorSettings?: Omit<AuthConnectorOptions["connectorSettings"], "buildEnv">;
|
|
53
75
|
};
|
|
54
76
|
export declare const authConnector: (params?: AuthConnectorFuncParams) => ConnectorFn;
|
|
77
|
+
export declare function isAuthConnector(connector: IConnector<unknown> | null | undefined): connector is AuthConnectorType;
|
|
78
|
+
export declare function assertAuthConnector(connector: IConnector<unknown> | null | undefined, errorMessage?: string): asserts connector is AuthConnectorType;
|
|
55
79
|
export type AuthConnectorType = AuthConnector;
|
|
56
80
|
export {};
|
|
@@ -1,11 +1,46 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Wallet } from "@wallet-standard/base";
|
|
2
|
+
import { type AuthConnectionConfigItem, type AuthOptions, type LoginParams, type WEB3AUTH_NETWORK_TYPE } from "@web3auth/auth";
|
|
2
3
|
import { type WsEmbedParams } from "@web3auth/ws-embed";
|
|
3
|
-
import {
|
|
4
|
+
import { LinkAccountResult, UnlinkAccountResult } from "../../account-linking";
|
|
5
|
+
import { type BaseConnectorSettings, type ConnectorNamespaceType, type IBaseProvider, type IConnector, type IProvider, type LinkedAccountInfo, type WALLET_CONNECTOR_TYPE } from "../../base";
|
|
4
6
|
export type LoginSettings = Partial<LoginParams>;
|
|
5
7
|
export type PrivateKeyProvider = IBaseProvider<string>;
|
|
6
8
|
export type WalletServicesSettings = Omit<WsEmbedParams, "chains" | "chainId"> & {
|
|
7
9
|
modalZIndex?: number;
|
|
8
10
|
};
|
|
11
|
+
export interface AuthConnectorSessionTokens {
|
|
12
|
+
accessToken: string | null;
|
|
13
|
+
idToken: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface AuthConnectorLinkAccountParams {
|
|
16
|
+
authSessionTokens: AuthConnectorSessionTokens;
|
|
17
|
+
walletConnector: IConnector<unknown>;
|
|
18
|
+
connectorName: WALLET_CONNECTOR_TYPE | string;
|
|
19
|
+
chainId?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AuthConnectorSwitchAccountContext {
|
|
22
|
+
activeAccount: LinkedAccountInfo | null;
|
|
23
|
+
currentChainId: string | null;
|
|
24
|
+
}
|
|
25
|
+
export type AuthConnectorSwitchAccountResult = {
|
|
26
|
+
kind: "primary";
|
|
27
|
+
targetAccount: LinkedAccountInfo;
|
|
28
|
+
activeAccount: null;
|
|
29
|
+
activeChainId: string;
|
|
30
|
+
connectorName: WALLET_CONNECTOR_TYPE;
|
|
31
|
+
connectorNamespace: ConnectorNamespaceType;
|
|
32
|
+
ethereumProvider: IProvider | null;
|
|
33
|
+
solanaWallet: Wallet | null;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "external";
|
|
36
|
+
targetAccount: LinkedAccountInfo;
|
|
37
|
+
activeAccount: LinkedAccountInfo;
|
|
38
|
+
activeChainId: string;
|
|
39
|
+
};
|
|
40
|
+
export interface AuthConnectorUnlinkAccountParams {
|
|
41
|
+
authSessionTokens: AuthConnectorSessionTokens;
|
|
42
|
+
address: string;
|
|
43
|
+
}
|
|
9
44
|
export interface AuthConnectorOptions extends BaseConnectorSettings {
|
|
10
45
|
connectorSettings?: Omit<AuthOptions, "clientId" | "network" | "authConnectionConfig" | "mfaSettings">;
|
|
11
46
|
loginSettings?: LoginSettings;
|
|
@@ -14,4 +49,44 @@ export interface AuthConnectorOptions extends BaseConnectorSettings {
|
|
|
14
49
|
isDefault?: boolean;
|
|
15
50
|
})[];
|
|
16
51
|
}
|
|
52
|
+
export interface UserInfoWithLinkedAccounts {
|
|
53
|
+
/** User id from the Citadel Server */
|
|
54
|
+
id: string;
|
|
55
|
+
/** Connection id of the user */
|
|
56
|
+
connectionId: string;
|
|
57
|
+
/** Identifier of the user. e.g. email, sub */
|
|
58
|
+
identifier: string;
|
|
59
|
+
/** Public address of the user */
|
|
60
|
+
publicAddress: string;
|
|
61
|
+
/** Web3Auth network of the user */
|
|
62
|
+
web3AuthNetwork: WEB3AUTH_NETWORK_TYPE;
|
|
63
|
+
/** Type of the user. e.g. v1, v2 */
|
|
64
|
+
userType: string;
|
|
65
|
+
/** Connected accounts info, including the primary account */
|
|
66
|
+
accounts: LinkedAccountInfo[];
|
|
67
|
+
/** Created at timestamp of the user */
|
|
68
|
+
createdAt: string;
|
|
69
|
+
/** Updated at timestamp of the user */
|
|
70
|
+
updatedAt: string;
|
|
71
|
+
}
|
|
17
72
|
export { AUTH_CONNECTION, type AUTH_CONNECTION_TYPE, type AuthConnectionConfig, type AuthOptions, type AuthUserInfo, type LoginParams, MFA_FACTOR, type MFA_FACTOR_TYPE, MFA_LEVELS, type MFA_SETTINGS, type MfaLevelType, } from "@web3auth/auth";
|
|
73
|
+
export interface IAuthConnector {
|
|
74
|
+
/**
|
|
75
|
+
* Resolve the target account and connector-owned switch metadata.
|
|
76
|
+
* `noModal` applies the returned result to SDK state and providers.
|
|
77
|
+
*/
|
|
78
|
+
switchAccount(account: LinkedAccountInfo, context: AuthConnectorSwitchAccountContext): Promise<AuthConnectorSwitchAccountResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Link an external wallet to the authenticated user by using the
|
|
81
|
+
* `noModal`-provided isolated wallet connector to generate the proof.
|
|
82
|
+
*/
|
|
83
|
+
linkAccount(params: AuthConnectorLinkAccountParams): Promise<LinkAccountResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Unlink an external wallet from the authenticated user account.
|
|
86
|
+
*/
|
|
87
|
+
unlinkAccount(params: AuthConnectorUnlinkAccountParams): Promise<UnlinkAccountResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Get the connected accounts for the authenticated user.
|
|
90
|
+
*/
|
|
91
|
+
getLinkedAccounts(): Promise<LinkedAccountInfo[]>;
|
|
92
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { ChainNamespaceType } from "@toruslabs/base-controllers";
|
|
1
2
|
import { AuthTokenInfo, BaseConnector, ConnectorInitOptions } from "../../base";
|
|
2
3
|
export declare abstract class BaseEvmConnector<T> extends BaseConnector<T> {
|
|
3
4
|
init(_?: ConnectorInitOptions): Promise<void>;
|
|
4
5
|
getAuthTokenInfo(): Promise<AuthTokenInfo>;
|
|
6
|
+
generateChallengeAndSign(authServerUrl?: string, accounts?: string[]): Promise<{
|
|
7
|
+
challenge: string;
|
|
8
|
+
signature: string;
|
|
9
|
+
chainNamespace: ChainNamespaceType;
|
|
10
|
+
}>;
|
|
5
11
|
disconnectSession(): Promise<void>;
|
|
6
12
|
disconnect(): Promise<void>;
|
|
7
13
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { ChainNamespaceType } from "@toruslabs/base-controllers";
|
|
1
2
|
import { AuthTokenInfo, BaseConnector, ConnectorInitOptions } from "../../base";
|
|
2
3
|
export declare abstract class BaseSolanaConnector<T> extends BaseConnector<T> {
|
|
3
4
|
init(_?: ConnectorInitOptions): Promise<void>;
|
|
4
5
|
getAuthTokenInfo(): Promise<AuthTokenInfo>;
|
|
6
|
+
generateChallengeAndSign(authServerUrl?: string, accounts?: string[]): Promise<{
|
|
7
|
+
challenge: string;
|
|
8
|
+
signature: string;
|
|
9
|
+
chainNamespace: ChainNamespaceType;
|
|
10
|
+
}>;
|
|
5
11
|
disconnectSession(): Promise<void>;
|
|
6
12
|
disconnect(): Promise<void>;
|
|
7
13
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { SafeEventEmitter } from "@web3auth/auth";
|
|
2
|
-
import {
|
|
2
|
+
import { type LinkAccountParams, type LinkAccountResult, UnlinkAccountResult } from "./account-linking";
|
|
3
|
+
import { Analytics, type AuthTokenInfo, type ChainNamespaceType, ConnectedAccountsWithProviders, type Connection, type CONNECTOR_STATUS_TYPE, type CustomChainConfig, type IConnector, type IPlugin, type IProvider, type IWeb3Auth, type IWeb3AuthCoreOptions, IWeb3AuthState, LinkedAccountInfo, LoginModeType, type LoginParamMap, type ProjectConfig, type UserInfo, type WALLET_CONNECTOR_TYPE, type Web3AuthNoModalEvents } from "./base";
|
|
4
|
+
import { type AuthConnectorSwitchAccountResult, type AuthConnectorType } from "./connectors/auth-connector";
|
|
3
5
|
import { type AccountAbstractionProvider } from "./providers/account-abstraction-provider";
|
|
4
6
|
import { CommonJRPCProvider } from "./providers/base-provider";
|
|
7
|
+
type ConnectedWalletAccountRef = LinkedAccountInfo | Pick<LinkedAccountInfo, "id" | "isPrimary"> | null | undefined;
|
|
5
8
|
export declare class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEvents> implements IWeb3Auth {
|
|
6
9
|
readonly coreOptions: IWeb3AuthCoreOptions;
|
|
7
10
|
status: CONNECTOR_STATUS_TYPE;
|
|
@@ -12,20 +15,33 @@ export declare class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEve
|
|
|
12
15
|
protected analytics: Analytics;
|
|
13
16
|
protected plugins: Record<string, IPlugin>;
|
|
14
17
|
protected consentRequired: boolean;
|
|
18
|
+
protected projectConfig: ProjectConfig | null;
|
|
15
19
|
private storage;
|
|
16
|
-
private
|
|
17
|
-
|
|
20
|
+
private connectionReconnected;
|
|
21
|
+
/** Connected wallet state keyed by linked account id; the primary session uses a reserved key. */
|
|
22
|
+
private connectedWalletConnectorMap;
|
|
23
|
+
private activeWalletConnectorKey;
|
|
18
24
|
private state;
|
|
19
25
|
constructor(options: IWeb3AuthCoreOptions, initialState?: Partial<IWeb3AuthState>);
|
|
20
26
|
get currentChain(): CustomChainConfig | undefined;
|
|
21
27
|
get connected(): boolean;
|
|
22
28
|
get connection(): Connection | null;
|
|
23
|
-
get
|
|
29
|
+
get primaryConnectorName(): WALLET_CONNECTOR_TYPE | null;
|
|
24
30
|
get cachedConnector(): string | null;
|
|
25
31
|
get currentChainId(): string | null;
|
|
26
|
-
|
|
32
|
+
/**
|
|
33
|
+
* This is always the primary connector that is connected to the user.
|
|
34
|
+
*/
|
|
35
|
+
get primaryConnector(): IConnector<unknown> | null;
|
|
27
36
|
get accountAbstractionProvider(): AccountAbstractionProvider | null;
|
|
28
37
|
get idToken(): string | null;
|
|
38
|
+
get accessToken(): string | null;
|
|
39
|
+
get refreshToken(): string | null;
|
|
40
|
+
protected get activeAccount(): LinkedAccountInfo | null;
|
|
41
|
+
/**
|
|
42
|
+
* This is the current active connector.
|
|
43
|
+
*/
|
|
44
|
+
private get activeConnector();
|
|
29
45
|
set provider(_: IProvider | null);
|
|
30
46
|
init(options?: {
|
|
31
47
|
signal?: AbortSignal;
|
|
@@ -45,10 +61,15 @@ export declare class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEve
|
|
|
45
61
|
cleanup: boolean;
|
|
46
62
|
}): Promise<void>;
|
|
47
63
|
getUserInfo(): Promise<Partial<UserInfo>>;
|
|
64
|
+
getLinkedAccounts(): Promise<LinkedAccountInfo[]>;
|
|
65
|
+
getConnectedAccountsWithProviders(): ConnectedAccountsWithProviders[];
|
|
48
66
|
enableMFA<T>(loginParams?: T): Promise<void>;
|
|
49
67
|
manageMFA<T>(loginParams?: T): Promise<void>;
|
|
50
68
|
getAuthTokenInfo(): Promise<Pick<AuthTokenInfo, "idToken">>;
|
|
51
69
|
getPlugin(name: string): IPlugin | null;
|
|
70
|
+
switchAccount(account: LinkedAccountInfo): Promise<void>;
|
|
71
|
+
linkAccount(params?: LinkAccountParams): Promise<LinkAccountResult>;
|
|
72
|
+
unlinkAccount(address: string): Promise<UnlinkAccountResult>;
|
|
52
73
|
setAnalyticsProperties(properties: Record<string, unknown>): void;
|
|
53
74
|
protected initChainsConfig(projectConfig: ProjectConfig): void;
|
|
54
75
|
protected initAccountAbstractionConfig(projectConfig?: ProjectConfig): void;
|
|
@@ -74,10 +95,88 @@ export declare class Web3AuthNoModal extends SafeEventEmitter<Web3AuthNoModalEve
|
|
|
74
95
|
*/
|
|
75
96
|
protected getInitialChainIdForConnector(connector: IConnector<unknown>): CustomChainConfig;
|
|
76
97
|
protected completeConsentAcceptance(): Promise<void>;
|
|
98
|
+
protected resolveLinkAccountChainId(chainId?: string | null): string;
|
|
99
|
+
/**
|
|
100
|
+
* Resolves the chain ID for a switch account operation.
|
|
101
|
+
* If the account's chain namespace is the same as the current chain namespace, return the current chain ID.
|
|
102
|
+
* If the account's chain namespace is different from the current chain namespace, return the chainId the account was linked in.
|
|
103
|
+
*
|
|
104
|
+
* @param account - The account to switch to.
|
|
105
|
+
* @param activeChainId - The current active chain ID.
|
|
106
|
+
* @returns The resolved chain ID.
|
|
107
|
+
*/
|
|
108
|
+
protected resolveSwitchAccountChainId(account: Pick<LinkedAccountInfo, "chainNamespace">, activeChainId: string): string;
|
|
109
|
+
protected createLinkingWalletConnector(connectorName: WALLET_CONNECTOR_TYPE | string, chainId: string, config?: ProjectConfig): Promise<IConnector<unknown>>;
|
|
110
|
+
protected createSwitchingWalletConnector(connectorName: WALLET_CONNECTOR_TYPE | string, chainId: string, config?: ProjectConfig): Promise<IConnector<unknown>>;
|
|
111
|
+
protected getConnectedWalletConnector(account?: Pick<LinkedAccountInfo, "id" | "isPrimary"> | null): IConnector<unknown> | null;
|
|
112
|
+
protected getConnectedWalletConnectorState(account?: Pick<LinkedAccountInfo, "id" | "isPrimary"> | null): ConnectedAccountsWithProviders | null;
|
|
113
|
+
protected setConnectedWalletConnectorState(connectedWallet: ConnectedAccountsWithProviders, account?: Pick<LinkedAccountInfo, "id" | "isPrimary"> | null): void;
|
|
114
|
+
protected setConnectedWalletConnector(connector: IConnector<unknown>, account?: Pick<LinkedAccountInfo, "id" | "isPrimary"> | null): void;
|
|
115
|
+
protected deleteConnectedWalletConnector(account?: Pick<LinkedAccountInfo, "id" | "isPrimary"> | null): void;
|
|
116
|
+
protected getConnectedWalletConnection(account?: Pick<LinkedAccountInfo, "id" | "isPrimary"> | null): Connection | null;
|
|
117
|
+
protected hasUsableConnectedSwitchConnector(connector: IConnector<unknown> | null): boolean;
|
|
118
|
+
protected setActiveWalletConnectorKey(account?: Pick<LinkedAccountInfo, "id" | "isPrimary"> | null): void;
|
|
119
|
+
protected getConnectedWalletConnectorKey(account?: Pick<LinkedAccountInfo, "id" | "isPrimary"> | null): string;
|
|
120
|
+
protected getConnectedWalletConnectorStateByKey(accountKey: string): ConnectedAccountsWithProviders | null;
|
|
121
|
+
protected isLinkedAccountInfo(account: ConnectedWalletAccountRef): account is LinkedAccountInfo;
|
|
122
|
+
protected toConnectedWalletLinkedAccountInfo(account: Omit<LinkedAccountInfo, "connector">): Omit<LinkedAccountInfo, "connector">;
|
|
123
|
+
protected getConnectedWalletLinkedAccountInfo(account?: ConnectedWalletAccountRef): Omit<LinkedAccountInfo, "connector">;
|
|
124
|
+
protected syncConnectedWalletLinkedAccounts(linkedAccounts: LinkedAccountInfo[]): void;
|
|
125
|
+
protected refreshConnectedWalletActiveStates(activeAccount: LinkedAccountInfo | null): void;
|
|
126
|
+
protected getConnectedWalletConnectionByKey(accountKey: string): Connection | null;
|
|
127
|
+
protected buildConnectionFromConnectedWalletConnectorState(connectedWallet: ConnectedAccountsWithProviders): Connection;
|
|
128
|
+
protected buildImmediateConnectedWalletConnectorState(params: {
|
|
129
|
+
connector: IConnector<unknown>;
|
|
130
|
+
ethereumProvider: IProvider | null;
|
|
131
|
+
solanaWallet: Connection["solanaWallet"];
|
|
132
|
+
usePrimaryProxy: boolean;
|
|
133
|
+
account?: ConnectedWalletAccountRef;
|
|
134
|
+
}): ConnectedAccountsWithProviders;
|
|
135
|
+
protected resolveConnectedWalletConnectorState(params: {
|
|
136
|
+
connector: IConnector<unknown>;
|
|
137
|
+
ethereumProvider: IProvider | null;
|
|
138
|
+
solanaWallet: Connection["solanaWallet"];
|
|
139
|
+
usePrimaryProxy: boolean;
|
|
140
|
+
account?: ConnectedWalletAccountRef;
|
|
141
|
+
}): Promise<ConnectedAccountsWithProviders>;
|
|
142
|
+
protected linkAccountWithConnector(connectorName: WALLET_CONNECTOR_TYPE | string, chainId: string, walletConnector: IConnector<unknown>): Promise<LinkAccountResult>;
|
|
143
|
+
protected getMainAuthConnector(): AuthConnectorType;
|
|
144
|
+
/**
|
|
145
|
+
* Processes the result of a switch account operation.
|
|
146
|
+
*
|
|
147
|
+
* - If the target account is a primary account, we will switch back to the primary account.
|
|
148
|
+
* - If the target account is an external account and already connected (i.e. connector is available with connected state), we will just switch to it without re-connecting again.
|
|
149
|
+
* - If the target account is an external account and not connected (i.e. connector is not available with connected state), we will create a new isolated connector and connect to it.
|
|
150
|
+
* @param authConnector - The main auth connector to use.
|
|
151
|
+
* @param switchResult - The result of the switch account operation.
|
|
152
|
+
* @param options - The options for the switch account operation.
|
|
153
|
+
* @returns A promise that resolves when the switch account operation is complete.
|
|
154
|
+
*/
|
|
155
|
+
protected processSwitchAccountResult(authConnector: AuthConnectorType, switchResult: AuthConnectorSwitchAccountResult, options?: {
|
|
156
|
+
walletConnector?: IConnector<unknown>;
|
|
157
|
+
projectConfig?: ProjectConfig;
|
|
158
|
+
}): Promise<void>;
|
|
159
|
+
private isActiveConnectorEventSource;
|
|
160
|
+
private shouldIgnoreInactiveConnectorEvent;
|
|
161
|
+
private findLinkedAccountByAddress;
|
|
162
|
+
private findLinkedAccountByWalletAddress;
|
|
163
|
+
private getConnectedWalletAddress;
|
|
164
|
+
private cacheConnectedLinkedWalletConnector;
|
|
77
165
|
private cacheWallet;
|
|
78
166
|
private setCurrentChain;
|
|
79
167
|
private connectToPlugins;
|
|
168
|
+
private bindPrimaryEthereumSigningProxy;
|
|
169
|
+
private getChainConfigForIsolatedConnector;
|
|
170
|
+
private resolveInstalledDiscoveredWalletConnector;
|
|
171
|
+
private resolveDiscoveredWalletConnector;
|
|
172
|
+
/**
|
|
173
|
+
* Create a new connector instance that is NOT registered in this.connectors and NOT
|
|
174
|
+
* subscribed to the main SDK event loop. Its lifecycle events are therefore isolated
|
|
175
|
+
* and will not mutate any global SDK state (connectedConnectorName, connection, idToken).
|
|
176
|
+
*/
|
|
177
|
+
private createIsolatedWalletConnector;
|
|
80
178
|
private setState;
|
|
81
179
|
private loadState;
|
|
82
180
|
private getStorageMethod;
|
|
83
181
|
}
|
|
182
|
+
export {};
|
|
@@ -14,6 +14,8 @@ export interface BaseProviderConfig extends BaseConfig {
|
|
|
14
14
|
export declare abstract class BaseProvider<C extends BaseProviderConfig, S extends BaseProviderState, P> extends BaseController<C, S, BaseProviderEvents<S>> implements IBaseProvider<P> {
|
|
15
15
|
_providerEngineProxy: SafeEventEmitterProvider<ProviderEvents> | null;
|
|
16
16
|
private keyExportFlagSetByCode;
|
|
17
|
+
private providerEventBridges;
|
|
18
|
+
private providerListenerBridgeRegistered;
|
|
17
19
|
constructor({ config, state }: {
|
|
18
20
|
config: C;
|
|
19
21
|
state?: S;
|
|
@@ -30,6 +32,11 @@ export declare abstract class BaseProvider<C extends BaseProviderConfig, S exten
|
|
|
30
32
|
setKeyExportFlag(flag: boolean): void;
|
|
31
33
|
protected getProviderEngineProxy(): SafeEventEmitterProvider | null;
|
|
32
34
|
protected getChain(chainId: string): CustomChainConfig;
|
|
35
|
+
private ensureProviderListenerBridge;
|
|
36
|
+
private ensureProviderEventBridge;
|
|
37
|
+
private attachProviderEventBridges;
|
|
38
|
+
private attachProviderEventBridge;
|
|
39
|
+
private detachProviderEventBridges;
|
|
33
40
|
abstract setupProvider(provider: P, chainId: string): Promise<void>;
|
|
34
41
|
abstract switchChain(params: {
|
|
35
42
|
chainId: string;
|
|
@@ -8,6 +8,7 @@ export * from "./useReceive";
|
|
|
8
8
|
export * from "./useSwap";
|
|
9
9
|
export * from "./useSwitchChain";
|
|
10
10
|
export * from "./useWalletConnectScanner";
|
|
11
|
+
export * from "./useWallets";
|
|
11
12
|
export * from "./useWalletServicesPlugin";
|
|
12
13
|
export * from "./useWalletUI";
|
|
13
14
|
export * from "./useWeb3Auth";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConnectedAccountsWithProviders, Web3AuthError } from "../../base";
|
|
2
|
+
export interface IUseWallets {
|
|
3
|
+
loading: boolean;
|
|
4
|
+
error: Web3AuthError | null;
|
|
5
|
+
wallets: ConnectedAccountsWithProviders[];
|
|
6
|
+
syncWallets(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useWallets: () => IUseWallets;
|
|
@@ -9,6 +9,7 @@ export * from "./useReceive";
|
|
|
9
9
|
export * from "./useSwap";
|
|
10
10
|
export * from "./useSwitchChain";
|
|
11
11
|
export * from "./useWalletConnectScanner";
|
|
12
|
+
export * from "./useWallets";
|
|
12
13
|
export * from "./useWalletServicesPlugin";
|
|
13
14
|
export * from "./useWalletUI";
|
|
14
15
|
export * from "./useWeb3Auth";
|