@web3auth/no-modal 11.0.2 → 11.2.0
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/react.js +1 -0
- package/dist/lib.cjs/account-linking/vue.js +1 -0
- package/dist/lib.cjs/base/connector/baseConnector.js +42 -11
- package/dist/lib.cjs/base/errors/index.js +5 -1
- package/dist/lib.cjs/base/utils.js +1 -1
- package/dist/lib.cjs/connectors/auth-connector/authConnector.js +23 -16
- package/dist/lib.cjs/connectors/coinbase-connector/coinbaseConnector.js +5 -5
- package/dist/lib.cjs/connectors/injected-evm-connector/injectedEvmConnector.js +6 -5
- package/dist/lib.cjs/connectors/injected-solana-connector/walletStandardConnector.js +6 -5
- package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +82 -31
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/config.js +0 -3
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/index.js +0 -1
- package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +8 -6
- package/dist/lib.cjs/index.js +8 -8
- package/dist/lib.cjs/noModal.js +48 -22
- package/dist/lib.cjs/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +9 -2
- package/dist/lib.cjs/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +1 -43
- package/dist/lib.cjs/react/context/useWeb3AuthInnerContextValue.js +10 -0
- package/dist/lib.cjs/react/solana/provider.js +65 -32
- package/dist/lib.cjs/types/base/connector/baseConnector.d.ts +2 -1
- package/dist/lib.cjs/types/base/connector/interfaces.d.ts +1 -0
- package/dist/lib.cjs/types/base/errors/index.d.ts +1 -0
- package/dist/lib.cjs/types/base/interfaces.d.ts +2 -1
- package/dist/lib.cjs/types/connectors/metamask-connector/metamaskConnector.d.ts +1 -0
- package/dist/lib.cjs/types/connectors/wallet-connect-v2-connector/config.d.ts +0 -1
- package/dist/lib.cjs/types/vue/solana/provider.d.ts +2 -2
- package/dist/lib.cjs/vue/solana/provider.js +55 -21
- package/dist/lib.cjs/vue/useWeb3AuthInnerContextValue.js +12 -2
- package/dist/lib.esm/base/connector/baseConnector.js +42 -11
- package/dist/lib.esm/base/errors/index.js +5 -1
- package/dist/lib.esm/base/utils.js +1 -1
- package/dist/lib.esm/connectors/auth-connector/authConnector.js +21 -15
- package/dist/lib.esm/connectors/coinbase-connector/coinbaseConnector.js +5 -5
- package/dist/lib.esm/connectors/injected-evm-connector/injectedEvmConnector.js +6 -5
- package/dist/lib.esm/connectors/injected-solana-connector/walletStandardConnector.js +6 -5
- package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +86 -31
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/config.js +1 -4
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/index.js +1 -1
- package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Connector.js +8 -7
- package/dist/lib.esm/index.js +2 -2
- package/dist/lib.esm/noModal.js +48 -22
- package/dist/lib.esm/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +9 -2
- package/dist/lib.esm/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +1 -9
- package/dist/lib.esm/react/context/useWeb3AuthInnerContextValue.js +10 -0
- package/dist/lib.esm/react/solana/provider.js +64 -30
- package/dist/lib.esm/vue/solana/provider.js +55 -19
- package/dist/lib.esm/vue/useWeb3AuthInnerContextValue.js +10 -0
- package/package.json +7 -7
|
@@ -10,13 +10,12 @@ var baseControllers = require('@toruslabs/base-controllers');
|
|
|
10
10
|
require('@toruslabs/session-manager');
|
|
11
11
|
require('@web3auth/auth');
|
|
12
12
|
require('../../base/errors/index.js');
|
|
13
|
-
require('
|
|
14
|
-
require('@toruslabs/http-helpers');
|
|
15
|
-
require('../../base/constants.js');
|
|
13
|
+
var utils = require('../../base/utils.js');
|
|
16
14
|
require('../../base/wallet/index.js');
|
|
17
15
|
require('../../base/connector/connectorStatus.js');
|
|
18
16
|
require('../../base/connector/constants.js');
|
|
19
17
|
require('jwt-decode');
|
|
18
|
+
require('../../base/constants.js');
|
|
20
19
|
require('../../base/plugin/errors.js');
|
|
21
20
|
require('../../base/plugin/IPlugin.js');
|
|
22
21
|
var useChain = require('../composables/useChain.js');
|
|
@@ -24,17 +23,28 @@ var useWeb3Auth = require('../composables/useWeb3Auth.js');
|
|
|
24
23
|
var constants = require('./constants.js');
|
|
25
24
|
|
|
26
25
|
const disposeClient = async client => {
|
|
27
|
-
try {
|
|
28
|
-
await client.actions.disconnectWallet();
|
|
29
|
-
} catch (e) {
|
|
30
|
-
loglevel.log.warn("Solana client disconnect", e);
|
|
31
|
-
}
|
|
32
26
|
client.destroy();
|
|
33
27
|
};
|
|
28
|
+
const resolveSolanaChain = (web3Auth, connection) => {
|
|
29
|
+
var _web3Auth$coreOptions2;
|
|
30
|
+
const currentChain = web3Auth === null || web3Auth === void 0 ? void 0 : web3Auth.currentChain;
|
|
31
|
+
if ((currentChain === null || currentChain === void 0 ? void 0 : currentChain.chainNamespace) === baseControllers.CHAIN_NAMESPACES.SOLANA) {
|
|
32
|
+
return currentChain;
|
|
33
|
+
}
|
|
34
|
+
const connectedScope = connection !== null && connection !== void 0 && connection.solanaWallet && "scope" in connection.solanaWallet && typeof connection.solanaWallet.scope === "string" ? connection.solanaWallet.scope : null;
|
|
35
|
+
if (connectedScope) {
|
|
36
|
+
var _web3Auth$coreOptions;
|
|
37
|
+
const connectedChain = web3Auth === null || web3Auth === void 0 || (_web3Auth$coreOptions = web3Auth.coreOptions.chains) === null || _web3Auth$coreOptions === void 0 ? void 0 : _web3Auth$coreOptions.find(chain => {
|
|
38
|
+
return chain.chainNamespace === baseControllers.CHAIN_NAMESPACES.SOLANA && utils.getCaipChainId(chain) === connectedScope;
|
|
39
|
+
});
|
|
40
|
+
if (connectedChain) return connectedChain;
|
|
41
|
+
}
|
|
42
|
+
return (web3Auth === null || web3Auth === void 0 || (_web3Auth$coreOptions2 = web3Auth.coreOptions.chains) === null || _web3Auth$coreOptions2 === void 0 ? void 0 : _web3Auth$coreOptions2.find(chain => chain.chainNamespace === baseControllers.CHAIN_NAMESPACES.SOLANA)) || null;
|
|
43
|
+
};
|
|
34
44
|
/**
|
|
35
45
|
* Syncs Web3Auth Solana connection with Framework Kit client.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
46
|
+
* For multichain wallets, keep the Solana client warm across namespace switches so
|
|
47
|
+
* switching back to Solana can reuse the existing wallet session.
|
|
38
48
|
*/
|
|
39
49
|
const SolanaProvider = vue.defineComponent({
|
|
40
50
|
name: "SolanaProvider",
|
|
@@ -50,6 +60,8 @@ const SolanaProvider = vue.defineComponent({
|
|
|
50
60
|
chainId
|
|
51
61
|
} = useChain.useChain();
|
|
52
62
|
const clientRef = vue.ref(null);
|
|
63
|
+
let connectedClient = null;
|
|
64
|
+
// let connectedClientKey: string | null = null;
|
|
53
65
|
// Holds the token for the newest requested sync run. Older async runs compare against it
|
|
54
66
|
// before publishing results so a slower reconnect cannot overwrite a newer chain/account update.
|
|
55
67
|
let activeSyncToken = null;
|
|
@@ -64,21 +76,26 @@ const SolanaProvider = vue.defineComponent({
|
|
|
64
76
|
const newIsConnected = isConnected.value;
|
|
65
77
|
const newConnection = connection.value;
|
|
66
78
|
const currentChain = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.currentChain;
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
if ((currentChain === null || currentChain === void 0 ? void 0 : currentChain.chainNamespace) !== baseControllers.CHAIN_NAMESPACES.SOLANA) {
|
|
80
|
+
// Mirror the React provider behavior: hide the live Solana client from injected
|
|
81
|
+
// consumers whenever Web3Auth is currently scoped to a non-Solana namespace.
|
|
82
|
+
clientRef.value = null;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const preferredSolanaChain = resolveSolanaChain(web3Auth.value, newConnection);
|
|
86
|
+
const shouldKeepSolanaClient = newIsConnected && Boolean(newConnection === null || newConnection === void 0 ? void 0 : newConnection.solanaWallet) && Boolean(preferredSolanaChain) &&
|
|
87
|
+
// only manage the client for the primary connector
|
|
88
|
+
(newConnection === null || newConnection === void 0 ? void 0 : newConnection.connectorName) === ((_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 ? void 0 : _web3Auth$value2.primaryConnectorName);
|
|
89
|
+
if (!shouldKeepSolanaClient) {
|
|
71
90
|
clientRef.value = null;
|
|
91
|
+
const prevClient = connectedClient;
|
|
92
|
+
connectedClient = null;
|
|
93
|
+
// connectedClientKey = null;
|
|
72
94
|
if (prevClient) {
|
|
73
95
|
await disposeClient(prevClient);
|
|
74
96
|
}
|
|
75
97
|
return;
|
|
76
98
|
}
|
|
77
|
-
const prevClient = clientRef.value;
|
|
78
|
-
clientRef.value = null;
|
|
79
|
-
if (prevClient) {
|
|
80
|
-
await disposeClient(prevClient);
|
|
81
|
-
}
|
|
82
99
|
let client$1 = null;
|
|
83
100
|
try {
|
|
84
101
|
// create a wallet standard connector from connected wallet
|
|
@@ -91,7 +108,7 @@ const SolanaProvider = vue.defineComponent({
|
|
|
91
108
|
const {
|
|
92
109
|
rpcTarget,
|
|
93
110
|
wsTarget
|
|
94
|
-
} =
|
|
111
|
+
} = preferredSolanaChain;
|
|
95
112
|
client$1 = client.createClient({
|
|
96
113
|
endpoint: rpcTarget,
|
|
97
114
|
websocketEndpoint: wsTarget,
|
|
@@ -106,7 +123,13 @@ const SolanaProvider = vue.defineComponent({
|
|
|
106
123
|
await disposeClient(client$1);
|
|
107
124
|
return;
|
|
108
125
|
}
|
|
109
|
-
|
|
126
|
+
const prevClient = connectedClient;
|
|
127
|
+
connectedClient = client$1;
|
|
128
|
+
// connectedClientKey = nextClientKey;
|
|
129
|
+
clientRef.value = (currentChain === null || currentChain === void 0 ? void 0 : currentChain.chainNamespace) === baseControllers.CHAIN_NAMESPACES.SOLANA ? client$1 : null;
|
|
130
|
+
if (prevClient) {
|
|
131
|
+
await disposeClient(prevClient);
|
|
132
|
+
}
|
|
110
133
|
} catch (err) {
|
|
111
134
|
if (client$1) {
|
|
112
135
|
await disposeClient(client$1);
|
|
@@ -124,6 +147,17 @@ const SolanaProvider = vue.defineComponent({
|
|
|
124
147
|
}, {
|
|
125
148
|
immediate: true
|
|
126
149
|
});
|
|
150
|
+
vue.onBeforeUnmount(() => {
|
|
151
|
+
const publishedClient = clientRef.value;
|
|
152
|
+
clientRef.value = null;
|
|
153
|
+
const prevClient = connectedClient;
|
|
154
|
+
connectedClient = null;
|
|
155
|
+
if (prevClient) {
|
|
156
|
+
void disposeClient(prevClient);
|
|
157
|
+
} else if (publishedClient) {
|
|
158
|
+
void disposeClient(publishedClient);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
127
161
|
return () => {
|
|
128
162
|
var _slots$default, _slots$default2;
|
|
129
163
|
return vue.h(vue.Fragment, null, (_slots$default = (_slots$default2 = slots.default) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots)) !== null && _slots$default !== void 0 ? _slots$default : []);
|
|
@@ -161,6 +161,14 @@ function useWeb3AuthInnerContextValue({
|
|
|
161
161
|
chainId.value = web3Auth.value.currentChainId;
|
|
162
162
|
chainNamespace.value = (_web3Auth$value$curre7 = (_web3Auth$value$curre8 = web3Auth.value.currentChain) === null || _web3Auth$value$curre8 === void 0 ? void 0 : _web3Auth$value$curre8.chainNamespace) !== null && _web3Auth$value$curre7 !== void 0 ? _web3Auth$value$curre7 : null;
|
|
163
163
|
};
|
|
164
|
+
const connectorDataUpdatedListener = data => {
|
|
165
|
+
const updatedData = data.data;
|
|
166
|
+
if (updatedData.chainId && chainId.value !== updatedData.chainId) {
|
|
167
|
+
var _web3Auth$value$curre9;
|
|
168
|
+
chainId.value = updatedData.chainId;
|
|
169
|
+
chainNamespace.value = (_web3Auth$value$curre9 = web3Auth.value.currentChain) === null || _web3Auth$value$curre9 === void 0 ? void 0 : _web3Auth$value$curre9.chainNamespace;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
164
172
|
if (prevWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
|
|
165
173
|
prevWeb3Auth.removeListener(constants.CONNECTOR_EVENTS.NOT_READY, notReadyListener);
|
|
166
174
|
prevWeb3Auth.removeListener(constants.CONNECTOR_EVENTS.READY, readyListener);
|
|
@@ -172,6 +180,7 @@ function useWeb3AuthInnerContextValue({
|
|
|
172
180
|
prevWeb3Auth.removeListener(constants.CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
|
|
173
181
|
prevWeb3Auth.removeListener(constants.CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
174
182
|
prevWeb3Auth.removeListener(constants.CONNECTOR_EVENTS.CONNECTION_UPDATED, connectionUpdatedListener);
|
|
183
|
+
prevWeb3Auth.removeListener(constants.CONNECTOR_EVENTS.CONNECTOR_DATA_UPDATED, connectorDataUpdatedListener);
|
|
175
184
|
if (prevWeb3Auth.loginMode === constants$1.LOGIN_MODE.MODAL) {
|
|
176
185
|
prevWeb3Auth.removeListener(constants.CONNECTOR_EVENTS.CONSENT_ACCEPTED, consentAcceptedListener);
|
|
177
186
|
}
|
|
@@ -188,6 +197,7 @@ function useWeb3AuthInnerContextValue({
|
|
|
188
197
|
newWeb3Auth.on(constants.CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
|
|
189
198
|
newWeb3Auth.on(constants.CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
190
199
|
newWeb3Auth.on(constants.CONNECTOR_EVENTS.CONNECTION_UPDATED, connectionUpdatedListener);
|
|
200
|
+
newWeb3Auth.on(constants.CONNECTOR_EVENTS.CONNECTOR_DATA_UPDATED, connectorDataUpdatedListener);
|
|
191
201
|
if (newWeb3Auth.loginMode === constants$1.LOGIN_MODE.MODAL) {
|
|
192
202
|
newWeb3Auth.on(constants.CONNECTOR_EVENTS.CONSENT_ACCEPTED, consentAcceptedListener);
|
|
193
203
|
}
|
|
@@ -198,9 +208,9 @@ function useWeb3AuthInnerContextValue({
|
|
|
198
208
|
vue.watch(connection, (newConnection, prevConnection) => {
|
|
199
209
|
var _prevConnection$ether, _newConnection$ethere;
|
|
200
210
|
const handleChainChange = newChainId => {
|
|
201
|
-
var _web3Auth$value$
|
|
211
|
+
var _web3Auth$value$curre0, _web3Auth$value;
|
|
202
212
|
chainId.value = newChainId;
|
|
203
|
-
chainNamespace.value = (_web3Auth$value$
|
|
213
|
+
chainNamespace.value = (_web3Auth$value$curre0 = (_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 || (_web3Auth$value = _web3Auth$value.currentChain) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.chainNamespace) !== null && _web3Auth$value$curre0 !== void 0 ? _web3Auth$value$curre0 : null;
|
|
204
214
|
};
|
|
205
215
|
const prevProvider = (_prevConnection$ether = prevConnection === null || prevConnection === void 0 ? void 0 : prevConnection.ethereumProvider) !== null && _prevConnection$ether !== void 0 ? _prevConnection$ether : null;
|
|
206
216
|
const newProvider = (_newConnection$ethere = newConnection === null || newConnection === void 0 ? void 0 : newConnection.ethereumProvider) !== null && _newConnection$ethere !== void 0 ? _newConnection$ethere : null;
|
|
@@ -130,17 +130,28 @@ class BaseConnector extends SafeEventEmitter {
|
|
|
130
130
|
return cached;
|
|
131
131
|
}
|
|
132
132
|
async verifyAndAuthorize(params) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
let tokens;
|
|
134
|
+
try {
|
|
135
|
+
tokens = await verifySignedChallenge({
|
|
136
|
+
chainNamespace: params.chainNamespace,
|
|
137
|
+
signedMessage: params.signedMessage,
|
|
138
|
+
challenge: params.challenge,
|
|
139
|
+
connector: this.name,
|
|
140
|
+
authServer: params.authServer,
|
|
141
|
+
web3AuthClientId: this.coreOptions.clientId,
|
|
142
|
+
web3AuthNetwork: this.coreOptions.web3AuthNetwork,
|
|
143
|
+
sessionTimeout: this.coreOptions.sessionTime,
|
|
144
|
+
deviceInfo: getDeviceInfo()
|
|
145
|
+
});
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if (error instanceof Response && error.status === 401) {
|
|
148
|
+
const body = await error.clone().json().catch(() => ({}));
|
|
149
|
+
if (body.message === "ACCESS_CONTROL_DENIED") {
|
|
150
|
+
throw WalletLoginError.userBlocked("User is blocked by the application", error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
144
155
|
await this.saveAuthTokenInfo(tokens);
|
|
145
156
|
const tokenInfo = {
|
|
146
157
|
idToken: tokens.idToken,
|
|
@@ -154,6 +165,26 @@ class BaseConnector extends SafeEventEmitter {
|
|
|
154
165
|
});
|
|
155
166
|
return tokenInfo;
|
|
156
167
|
}
|
|
168
|
+
async authorizeOrDisconnect(getAuthTokenInfo, chainId) {
|
|
169
|
+
if (!getAuthTokenInfo) return;
|
|
170
|
+
try {
|
|
171
|
+
await this.getAuthTokenInfo(chainId);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
log.error("Authorization failed after connect; disconnecting wallet to keep state consistent", error);
|
|
174
|
+
const wasRehydrated = this.rehydrated;
|
|
175
|
+
try {
|
|
176
|
+
// getAuthTokenInfo moved status to AUTHORIZING; restore CONNECTED so disconnect requirements pass.
|
|
177
|
+
if (!this.connected) this.status = CONNECTOR_STATUS.CONNECTED;
|
|
178
|
+
await this.disconnect();
|
|
179
|
+
} catch (disconnectError) {
|
|
180
|
+
log.error("Failed to disconnect wallet after authorization error", disconnectError);
|
|
181
|
+
} finally {
|
|
182
|
+
// disconnect() resets rehydrated=false; restore so caller catch emits the right event.
|
|
183
|
+
this.rehydrated = wasRehydrated;
|
|
184
|
+
}
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
157
188
|
async clearWalletSession() {
|
|
158
189
|
if (!this.authSessionManager) return;
|
|
159
190
|
try {
|
|
@@ -163,6 +163,9 @@ class WalletLoginError extends Web3AuthError {
|
|
|
163
163
|
static userNotLoggedIn(extraMessage = "", cause) {
|
|
164
164
|
return WalletLoginError.fromCode(5119, extraMessage, cause);
|
|
165
165
|
}
|
|
166
|
+
static userBlocked(extraMessage = "", cause) {
|
|
167
|
+
return WalletLoginError.fromCode(5120, extraMessage, cause);
|
|
168
|
+
}
|
|
166
169
|
}
|
|
167
170
|
_defineProperty(WalletLoginError, "messages", {
|
|
168
171
|
5000: "Custom",
|
|
@@ -174,7 +177,8 @@ _defineProperty(WalletLoginError, "messages", {
|
|
|
174
177
|
5116: "Chain config has not been added. Please add the chain config before calling switchChain",
|
|
175
178
|
5117: "Unsupported operation",
|
|
176
179
|
5118: "useSFAKey flag is enabled but SFA key is not available",
|
|
177
|
-
5119: "User not logged in."
|
|
180
|
+
5119: "User not logged in.",
|
|
181
|
+
5120: "User is blocked by the application"
|
|
178
182
|
});
|
|
179
183
|
class WalletOperationsError extends Web3AuthError {
|
|
180
184
|
constructor(code, message, cause) {
|
|
@@ -149,7 +149,7 @@ const getWalletServicesAnalyticsProperties = walletServicesConfig => {
|
|
|
149
149
|
ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig10 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig10 === void 0 ? void 0 : _walletServicesConfig10.defaultPortfolio
|
|
150
150
|
};
|
|
151
151
|
};
|
|
152
|
-
const sdkVersion = "11.0
|
|
152
|
+
const sdkVersion = "11.2.0";
|
|
153
153
|
const getErrorAnalyticsProperties = error => {
|
|
154
154
|
try {
|
|
155
155
|
const code = error instanceof Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
|
|
@@ -206,7 +206,8 @@ class AuthConnector extends BaseConnector {
|
|
|
206
206
|
return {
|
|
207
207
|
ethereumProvider: this.provider,
|
|
208
208
|
solanaWallet: this._solanaWallet,
|
|
209
|
-
connectorName: this.name
|
|
209
|
+
connectorName: this.name,
|
|
210
|
+
connectorNamespace: this.connectorNamespace
|
|
210
211
|
};
|
|
211
212
|
} catch (error) {
|
|
212
213
|
var _message;
|
|
@@ -370,11 +371,9 @@ class AuthConnector extends BaseConnector {
|
|
|
370
371
|
}
|
|
371
372
|
}
|
|
372
373
|
async cleanup() {
|
|
373
|
-
|
|
374
|
-
await this.authInstance.cleanup();
|
|
375
|
-
|
|
376
|
-
this.wsEmbedInstance.clearInit();
|
|
377
|
-
}
|
|
374
|
+
var _this$authInstance, _this$wsEmbedInstance2;
|
|
375
|
+
await ((_this$authInstance = this.authInstance) === null || _this$authInstance === void 0 ? void 0 : _this$authInstance.cleanup());
|
|
376
|
+
(_this$wsEmbedInstance2 = this.wsEmbedInstance) === null || _this$wsEmbedInstance2 === void 0 || _this$wsEmbedInstance2.clearInit();
|
|
378
377
|
this._solanaWallet = null;
|
|
379
378
|
this.unbindWsEmbedProviderEvents();
|
|
380
379
|
}
|
|
@@ -740,8 +739,8 @@ class AuthConnector extends BaseConnector {
|
|
|
740
739
|
return accounts[0];
|
|
741
740
|
}
|
|
742
741
|
getWsEmbedProvider() {
|
|
743
|
-
var _ref, _this$
|
|
744
|
-
return (_ref = (_this$
|
|
742
|
+
var _ref, _this$wsEmbedInstance3;
|
|
743
|
+
return (_ref = (_this$wsEmbedInstance3 = this.wsEmbedInstance) === null || _this$wsEmbedInstance3 === void 0 ? void 0 : _this$wsEmbedInstance3.provider) !== null && _ref !== void 0 ? _ref : null;
|
|
745
744
|
}
|
|
746
745
|
bindWsEmbedProviderEvents() {
|
|
747
746
|
const rawProvider = this.getWsEmbedProvider();
|
|
@@ -786,7 +785,7 @@ class AuthConnector extends BaseConnector {
|
|
|
786
785
|
return finalPrivKey;
|
|
787
786
|
}
|
|
788
787
|
async connectWithProvider(params) {
|
|
789
|
-
var _this$
|
|
788
|
+
var _this$authInstance2, _params$extraLoginOpt, _this$authInstance3, _this$authInstance4;
|
|
790
789
|
if (!this.authInstance) throw WalletInitializationError.notReady("authInstance is not ready");
|
|
791
790
|
const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId);
|
|
792
791
|
if (!chainConfig) throw WalletLoginError.connectionError("Chain config is not available");
|
|
@@ -795,7 +794,7 @@ class AuthConnector extends BaseConnector {
|
|
|
795
794
|
} = chainConfig;
|
|
796
795
|
|
|
797
796
|
// if not logged in then login
|
|
798
|
-
const keyAvailable = chainNamespace === CHAIN_NAMESPACES.EIP155 || chainNamespace === CHAIN_NAMESPACES.SOLANA ? (_this$
|
|
797
|
+
const keyAvailable = chainNamespace === CHAIN_NAMESPACES.EIP155 || chainNamespace === CHAIN_NAMESPACES.SOLANA ? (_this$authInstance2 = this.authInstance) === null || _this$authInstance2 === void 0 ? void 0 : _this$authInstance2.sessionId : this._getFinalPrivKey();
|
|
799
798
|
if (params.idToken) params.extraLoginOptions = _objectSpread(_objectSpread({}, params.extraLoginOptions), {}, {
|
|
800
799
|
id_token: params.idToken
|
|
801
800
|
});
|
|
@@ -812,14 +811,14 @@ class AuthConnector extends BaseConnector {
|
|
|
812
811
|
}
|
|
813
812
|
|
|
814
813
|
// if useSFAKey is true and privKey is available but coreKitKey is not available, throw an error
|
|
815
|
-
if (this.coreOptions.useSFAKey && (_this$
|
|
814
|
+
if (this.coreOptions.useSFAKey && (_this$authInstance3 = this.authInstance) !== null && _this$authInstance3 !== void 0 && _this$authInstance3.privKey && !((_this$authInstance4 = this.authInstance) !== null && _this$authInstance4 !== void 0 && _this$authInstance4.coreKitKey)) {
|
|
816
815
|
// If the user is already logged in, logout and throw an error
|
|
817
816
|
if (this.authInstance.sessionId) {
|
|
818
817
|
await this.authInstance.logout();
|
|
819
818
|
}
|
|
820
819
|
throw WalletLoginError.sfaKeyNotFound("This typically occurs when the authentication method used does not provide SFA keys (e.g., default auth connection).");
|
|
821
820
|
}
|
|
822
|
-
|
|
821
|
+
const connectorNamespace = this.connectorNamespace;
|
|
823
822
|
// setup WS embed if chainNamespace is EIP155 or SOLANA
|
|
824
823
|
if (chainNamespace === CHAIN_NAMESPACES.EIP155 || chainNamespace === CHAIN_NAMESPACES.SOLANA) {
|
|
825
824
|
// wait for ws embed instance to be ready.
|
|
@@ -845,7 +844,8 @@ class AuthConnector extends BaseConnector {
|
|
|
845
844
|
connectorName: WALLET_CONNECTORS.AUTH,
|
|
846
845
|
reconnected: this.rehydrated,
|
|
847
846
|
ethereumProvider: this.provider,
|
|
848
|
-
solanaWallet: this._solanaWallet
|
|
847
|
+
solanaWallet: this._solanaWallet,
|
|
848
|
+
connectorNamespace
|
|
849
849
|
});
|
|
850
850
|
if (params.getAuthTokenInfo) {
|
|
851
851
|
await this.getAuthTokenInfo();
|
|
@@ -862,7 +862,8 @@ class AuthConnector extends BaseConnector {
|
|
|
862
862
|
connectorName: WALLET_CONNECTORS.AUTH,
|
|
863
863
|
ethereumProvider: this.provider,
|
|
864
864
|
solanaWallet: this._solanaWallet,
|
|
865
|
-
reconnected: this.rehydrated
|
|
865
|
+
reconnected: this.rehydrated,
|
|
866
|
+
connectorNamespace
|
|
866
867
|
});
|
|
867
868
|
}
|
|
868
869
|
}
|
|
@@ -965,7 +966,12 @@ class AuthConnector extends BaseConnector {
|
|
|
965
966
|
if (error instanceof Web3AuthError) {
|
|
966
967
|
throw error;
|
|
967
968
|
}
|
|
968
|
-
|
|
969
|
+
const errorMessage = error instanceof Error ? error.message : error;
|
|
970
|
+
if (errorMessage === "Access control denied") {
|
|
971
|
+
reject(WalletLoginError.userBlocked(errorMessage, error));
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
reject(WalletLoginError.connectionError(errorMessage || "Failed to login with social"));
|
|
969
975
|
});
|
|
970
976
|
});
|
|
971
977
|
}
|
|
@@ -99,15 +99,15 @@ class CoinbaseConnector extends BaseEvmConnector {
|
|
|
99
99
|
connectorName: WALLET_CONNECTORS.COINBASE,
|
|
100
100
|
reconnected: this.rehydrated,
|
|
101
101
|
ethereumProvider: this.provider,
|
|
102
|
-
solanaWallet: null
|
|
102
|
+
solanaWallet: null,
|
|
103
|
+
connectorNamespace: this.connectorNamespace
|
|
103
104
|
});
|
|
104
|
-
|
|
105
|
-
await this.getAuthTokenInfo();
|
|
106
|
-
}
|
|
105
|
+
await this.authorizeOrDisconnect(getAuthTokenInfo);
|
|
107
106
|
return {
|
|
108
107
|
ethereumProvider: this.provider,
|
|
109
108
|
solanaWallet: null,
|
|
110
|
-
connectorName: this.name
|
|
109
|
+
connectorName: this.name,
|
|
110
|
+
connectorNamespace: this.connectorNamespace
|
|
111
111
|
};
|
|
112
112
|
} catch (error) {
|
|
113
113
|
// ready again to be connected
|
|
@@ -89,19 +89,20 @@ class InjectedEvmConnector extends BaseEvmConnector {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
this.injectedProvider.on("accountsChanged", accountDisconnectHandler);
|
|
92
|
+
const connectorNamespace = this.connectorNamespace;
|
|
92
93
|
this.emit(CONNECTOR_EVENTS.CONNECTED, {
|
|
93
94
|
connectorName: this.name,
|
|
94
95
|
reconnected: this.rehydrated,
|
|
95
96
|
ethereumProvider: this.injectedProvider,
|
|
96
|
-
solanaWallet: null
|
|
97
|
+
solanaWallet: null,
|
|
98
|
+
connectorNamespace
|
|
97
99
|
});
|
|
98
|
-
|
|
99
|
-
await this.getAuthTokenInfo();
|
|
100
|
-
}
|
|
100
|
+
await this.authorizeOrDisconnect(getAuthTokenInfo);
|
|
101
101
|
return {
|
|
102
102
|
ethereumProvider: this.injectedProvider,
|
|
103
103
|
solanaWallet: null,
|
|
104
|
-
connectorName: this.name
|
|
104
|
+
connectorName: this.name,
|
|
105
|
+
connectorNamespace
|
|
105
106
|
};
|
|
106
107
|
} catch (error) {
|
|
107
108
|
// ready again to be connected
|
|
@@ -76,19 +76,20 @@ class WalletStandardConnector extends BaseSolanaConnector {
|
|
|
76
76
|
}
|
|
77
77
|
if (this.wallet.accounts.length === 0) throw WalletLoginError.connectionError();
|
|
78
78
|
this.status = CONNECTOR_STATUS.CONNECTED;
|
|
79
|
+
const connectorNamespace = this.connectorNamespace;
|
|
79
80
|
this.emit(CONNECTOR_EVENTS.CONNECTED, {
|
|
80
81
|
connectorName: this.name,
|
|
81
82
|
reconnected: this.rehydrated,
|
|
82
83
|
ethereumProvider: null,
|
|
83
|
-
solanaWallet: this.solanaWallet
|
|
84
|
+
solanaWallet: this.solanaWallet,
|
|
85
|
+
connectorNamespace
|
|
84
86
|
});
|
|
85
|
-
|
|
86
|
-
await this.getAuthTokenInfo();
|
|
87
|
-
}
|
|
87
|
+
await this.authorizeOrDisconnect(getAuthTokenInfo);
|
|
88
88
|
return {
|
|
89
89
|
ethereumProvider: null,
|
|
90
90
|
solanaWallet: this.solanaWallet,
|
|
91
|
-
connectorName: this.name
|
|
91
|
+
connectorName: this.name,
|
|
92
|
+
connectorNamespace
|
|
92
93
|
};
|
|
93
94
|
} catch (error) {
|
|
94
95
|
// ready again to be connected
|