@web3auth/no-modal 11.0.0-beta.1 → 11.0.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.
Files changed (59) hide show
  1. package/dist/lib.cjs/account-linking/errors.js +111 -0
  2. package/dist/lib.cjs/account-linking/index.js +4 -0
  3. package/dist/lib.cjs/account-linking/rest.js +6 -6
  4. package/dist/lib.cjs/account-linking/vue.js +0 -1
  5. package/dist/lib.cjs/base/connector/constants.js +2 -0
  6. package/dist/lib.cjs/base/errors/index.js +21 -50
  7. package/dist/lib.cjs/base/utils.js +1 -1
  8. package/dist/lib.cjs/connectors/auth-connector/authConnector.js +125 -58
  9. package/dist/lib.cjs/connectors/metamask-connector/metamaskConnector.js +40 -31
  10. package/dist/lib.cjs/index.js +24 -19
  11. package/dist/lib.cjs/noModal.js +60 -26
  12. package/dist/lib.cjs/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +8 -4
  13. package/dist/lib.cjs/providers/account-abstraction-provider/providers/utils.js +0 -17
  14. package/dist/lib.cjs/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +15 -0
  15. package/dist/lib.cjs/react/context/useWeb3AuthInnerContextValue.js +18 -2
  16. package/dist/lib.cjs/react/solana/provider.js +6 -2
  17. package/dist/lib.cjs/react/wagmi/index.js +6 -0
  18. package/dist/lib.cjs/react/wagmi/provider.js +74 -23
  19. package/dist/lib.cjs/types/account-linking/errors.d.ts +17 -0
  20. package/dist/lib.cjs/types/account-linking/index.d.ts +1 -0
  21. package/dist/lib.cjs/types/base/connector/constants.d.ts +1 -0
  22. package/dist/lib.cjs/types/base/connector/interfaces.d.ts +1 -1
  23. package/dist/lib.cjs/types/base/errors/index.d.ts +2 -13
  24. package/dist/lib.cjs/types/connectors/auth-connector/authConnector.d.ts +8 -2
  25. package/dist/lib.cjs/types/connectors/auth-connector/interface.d.ts +1 -1
  26. package/dist/lib.cjs/types/noModal.d.ts +1 -1
  27. package/dist/lib.cjs/types/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.d.ts +1 -0
  28. package/dist/lib.cjs/types/react/wagmi/constants.d.ts +2 -0
  29. package/dist/lib.cjs/types/react/wagmi/provider.d.ts +7 -0
  30. package/dist/lib.cjs/types/vue/wagmi/constants.d.ts +2 -0
  31. package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +7 -1
  32. package/dist/lib.cjs/vue/solana/provider.js +50 -26
  33. package/dist/lib.cjs/vue/useWeb3AuthInnerContextValue.js +13 -6
  34. package/dist/lib.cjs/vue/wagmi/index.js +6 -0
  35. package/dist/lib.cjs/vue/wagmi/provider.js +78 -35
  36. package/dist/lib.esm/account-linking/errors.js +92 -0
  37. package/dist/lib.esm/account-linking/index.js +1 -0
  38. package/dist/lib.esm/account-linking/rest.js +3 -3
  39. package/dist/lib.esm/account-linking/vue.js +0 -1
  40. package/dist/lib.esm/base/connector/constants.js +2 -1
  41. package/dist/lib.esm/base/errors/index.js +21 -50
  42. package/dist/lib.esm/base/utils.js +1 -1
  43. package/dist/lib.esm/connectors/auth-connector/authConnector.js +109 -41
  44. package/dist/lib.esm/connectors/base-solana-connector/baseSolanaConnector.js +1 -1
  45. package/dist/lib.esm/connectors/metamask-connector/metamaskConnector.js +42 -33
  46. package/dist/lib.esm/index.js +3 -2
  47. package/dist/lib.esm/noModal.js +56 -20
  48. package/dist/lib.esm/providers/account-abstraction-provider/providers/AccountAbstractionProvider.js +10 -5
  49. package/dist/lib.esm/providers/account-abstraction-provider/providers/utils.js +0 -3
  50. package/dist/lib.esm/providers/account-abstraction-provider/rpc/ethRpcMiddlewares.js +17 -3
  51. package/dist/lib.esm/react/context/useWeb3AuthInnerContextValue.js +18 -2
  52. package/dist/lib.esm/react/solana/provider.js +6 -2
  53. package/dist/lib.esm/react/wagmi/index.js +1 -1
  54. package/dist/lib.esm/react/wagmi/provider.js +74 -25
  55. package/dist/lib.esm/vue/solana/provider.js +51 -28
  56. package/dist/lib.esm/vue/useWeb3AuthInnerContextValue.js +11 -4
  57. package/dist/lib.esm/vue/wagmi/index.js +1 -1
  58. package/dist/lib.esm/vue/wagmi/provider.js +73 -34
  59. package/package.json +20 -20
@@ -3,7 +3,6 @@
3
3
  var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
4
4
  var core = require('@wagmi/core');
5
5
  var vue$1 = require('@wagmi/vue');
6
- var connectors = require('@wagmi/vue/connectors');
7
6
  var auth = require('@web3auth/auth');
8
7
  var viem = require('viem');
9
8
  var vue = require('vue');
@@ -18,7 +17,7 @@ require('@toruslabs/http-helpers');
18
17
  require('../../base/constants.js');
19
18
  require('../../base/wallet/index.js');
20
19
  require('../../base/connector/connectorStatus.js');
21
- require('../../base/connector/constants.js');
20
+ var constants$1 = require('../../base/connector/constants.js');
22
21
  require('jwt-decode');
23
22
  require('../../base/plugin/errors.js');
24
23
  require('../../base/plugin/IPlugin.js');
@@ -26,23 +25,42 @@ var useWeb3Auth = require('../composables/useWeb3Auth.js');
26
25
  var useWeb3AuthDisconnect = require('../composables/useWeb3AuthDisconnect.js');
27
26
  var constants = require('./constants.js');
28
27
 
29
- const WEB3AUTH_CONNECTOR_ID = "web3auth";
30
28
  function getWeb3authConnector(config) {
31
- return config.connectors.find(c => c.id === WEB3AUTH_CONNECTOR_ID);
29
+ return config.connectors.find(c => c.id === constants$1.WEB3AUTH_CONNECTOR_ID);
32
30
  }
33
- // Helper to initialize connectors for the given wallets
31
+ // Helper to create a Web3Auth connector to connect with wagmi
34
32
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- async function setupConnector(provider, config) {
36
- let connector = getWeb3authConnector(config);
37
- if (connector) return connector;
38
- // Create new connector if not already existing
39
- connector = connectors.injected({
33
+ function createWeb3AuthConnectorForWagmi(provider) {
34
+ const baseConnector = core.injected({
40
35
  target: {
41
36
  provider: provider,
42
- id: WEB3AUTH_CONNECTOR_ID,
37
+ id: constants$1.WEB3AUTH_CONNECTOR_ID,
43
38
  name: "Web3Auth"
44
39
  }
45
40
  });
41
+ return config => {
42
+ const connector = baseConnector(config);
43
+ const baseOnAccountsChanged = connector.onAccountsChanged.bind(connector);
44
+ connector.onAccountsChanged = accounts => {
45
+ // we need to handle the `accountsChanged` event emitted on the cross-namespace chain switch.
46
+ // on evm -> solana, the accountsChanged event is emitted with the solana address, which is not valid for evm.
47
+ // that causes the `invalid account address` error in wagmi. So, here, we're filtering out the solana addresses.
48
+ if (accounts.length > 0 && !accounts.every(account => typeof account === "string" && viem.isAddress(account))) {
49
+ loglevel.log.warn("onAccountsChanged::accountsChanged event received on non-EVM address");
50
+ return;
51
+ }
52
+ baseOnAccountsChanged(accounts);
53
+ };
54
+ return connector;
55
+ };
56
+ }
57
+ // Helper to initialize connectors for the given wallets
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ function setupConnector(provider, config) {
60
+ let connector = getWeb3authConnector(config);
61
+ if (connector) return connector;
62
+ // Create new connector if not already existing
63
+ connector = createWeb3AuthConnectorForWagmi(provider);
46
64
  const result = config._internal.connectors.setup(connector);
47
65
  config._internal.connectors.setState(current => [...current, result]);
48
66
  return result;
@@ -69,8 +87,8 @@ async function connectWeb3AuthWithWagmi(connector, config) {
69
87
  }));
70
88
  }
71
89
  function resetConnectorState(config) {
72
- config._internal.connectors.setState(prev => prev.filter(c => c.id !== WEB3AUTH_CONNECTOR_ID));
73
- config.connectors.filter(c => c.id !== WEB3AUTH_CONNECTOR_ID);
90
+ config._internal.connectors.setState(prev => prev.filter(c => c.id !== constants$1.WEB3AUTH_CONNECTOR_ID));
91
+ config.connectors.filter(c => c.id !== constants$1.WEB3AUTH_CONNECTOR_ID);
74
92
  }
75
93
  async function disconnectWeb3AuthFromWagmi(config) {
76
94
  var _config$storage3, _config$storage4;
@@ -89,7 +107,9 @@ const Web3AuthWagmiProvider = vue.defineComponent({
89
107
  setup() {
90
108
  const {
91
109
  isConnected,
92
- connection
110
+ connection,
111
+ web3Auth,
112
+ chainNamespace
93
113
  } = useWeb3Auth.useWeb3Auth();
94
114
  const {
95
115
  disconnect
@@ -98,11 +118,15 @@ const Web3AuthWagmiProvider = vue.defineComponent({
98
118
  const {
99
119
  mutate: reconnect
100
120
  } = vue$1.useReconnect();
101
- const lastSyncedWeb3AuthConnection = vue.shallowRef(null);
121
+ const lastSyncedProvider = vue.shallowRef(null);
122
+ const lastSyncedConnectorName = vue.ref(null);
123
+ const suppressWagmiDisconnect = vue.ref(false);
102
124
  vue$1.useConnectionEffect({
103
125
  onDisconnect: async () => {
104
126
  loglevel.log.info("Disconnected from wagmi");
105
- if (isConnected.value) await disconnect();
127
+ const isSuppressed = suppressWagmiDisconnect.value;
128
+ suppressWagmiDisconnect.value = false;
129
+ if (!isSuppressed && isConnected.value) await disconnect();
106
130
  const connector = getWeb3authConnector(wagmiConfig);
107
131
  // reset wagmi connector state if the provider handles disconnection because of the accountsChanged event
108
132
  // from the connected provider
@@ -111,30 +135,43 @@ const Web3AuthWagmiProvider = vue.defineComponent({
111
135
  }
112
136
  }
113
137
  });
114
- vue.watch([isConnected, connection], async () => {
138
+ vue.watch([isConnected, connection, chainNamespace], async () => {
115
139
  var _newConnection$ethere;
116
140
  const newIsConnected = isConnected.value;
117
141
  const newConnection = connection.value;
118
142
  const newEth = (_newConnection$ethere = newConnection === null || newConnection === void 0 ? void 0 : newConnection.ethereumProvider) !== null && _newConnection$ethere !== void 0 ? _newConnection$ethere : null;
119
- if (newIsConnected && newConnection && newEth) {
120
- // Linked-account switches can reuse or replace the underlying wallet provider,
121
- // so key wagmi resyncs off the Web3Auth connection object instead of provider identity.
122
- if (lastSyncedWeb3AuthConnection.value !== newConnection) {
123
- if (getWeb3authConnector(wagmiConfig)) {
143
+ const w3aWagmiConnector = getWeb3authConnector(wagmiConfig);
144
+ const shouldBindToWagmi = newIsConnected && chainNamespace.value === baseControllers.CHAIN_NAMESPACES.EIP155 && Boolean(newConnection && newEth);
145
+ if (shouldBindToWagmi) {
146
+ var _web3Auth$value;
147
+ const hasSameBinding = lastSyncedProvider.value === newEth && lastSyncedConnectorName.value === newConnection.connectorName && (newConnection === null || newConnection === void 0 ? void 0 : newConnection.connectorName) === ((_web3Auth$value = web3Auth.value) === null || _web3Auth$value === void 0 ? void 0 : _web3Auth$value.connection.connectorName) && wagmiConfig.state.status === "connected";
148
+ if (hasSameBinding) {
149
+ return;
150
+ }
151
+ if (!hasSameBinding && w3aWagmiConnector) {
152
+ if (wagmiConfig.state.status === "connected") {
153
+ suppressWagmiDisconnect.value = true;
154
+ await disconnectWeb3AuthFromWagmi(wagmiConfig);
155
+ } else {
124
156
  resetConnectorState(wagmiConfig);
125
157
  }
126
- lastSyncedWeb3AuthConnection.value = newConnection;
127
- const connector = await setupConnector(newEth, wagmiConfig);
128
- if (!connector) {
129
- throw new Error("Failed to setup connector");
130
- }
131
- await connectWeb3AuthWithWagmi(connector, wagmiConfig);
132
- reconnect();
133
158
  }
134
- } else if (!newIsConnected) {
135
- lastSyncedWeb3AuthConnection.value = null;
159
+ lastSyncedProvider.value = newEth;
160
+ lastSyncedConnectorName.value = newConnection.connectorName;
161
+ const connector = setupConnector(newEth, wagmiConfig);
162
+ if (!connector) {
163
+ throw new Error("Failed to setup connector");
164
+ }
165
+ await connectWeb3AuthWithWagmi(connector, wagmiConfig);
166
+ reconnect();
167
+ } else if (!newIsConnected || chainNamespace.value !== baseControllers.CHAIN_NAMESPACES.EIP155) {
168
+ lastSyncedProvider.value = null;
169
+ lastSyncedConnectorName.value = null;
136
170
  if (wagmiConfig.state.status === "connected") {
171
+ suppressWagmiDisconnect.value = true;
137
172
  await disconnectWeb3AuthFromWagmi(wagmiConfig);
173
+ } else if (w3aWagmiConnector) {
174
+ resetConnectorState(wagmiConfig);
138
175
  }
139
176
  }
140
177
  }, {
@@ -198,7 +235,7 @@ const WagmiProvider = vue.defineComponent({
198
235
  return viem.fallback(transports);
199
236
  };
200
237
  const defineWagmiConfig = () => {
201
- var _web3Auth$value;
238
+ var _web3Auth$value2;
202
239
  const configParams = _objectSpread(_objectSpread({
203
240
  ssr: true
204
241
  }, config), {}, {
@@ -209,7 +246,7 @@ const WagmiProvider = vue.defineComponent({
209
246
  client: undefined
210
247
  });
211
248
  const wagmiChains = [];
212
- if (isInitialized.value && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$value = web3Auth.value) !== null && _web3Auth$value !== void 0 && (_web3Auth$value = _web3Auth$value.coreOptions) !== null && _web3Auth$value !== void 0 && _web3Auth$value.chains) {
249
+ if (isInitialized.value && web3Auth !== null && web3Auth !== void 0 && (_web3Auth$value2 = web3Auth.value) !== null && _web3Auth$value2 !== void 0 && (_web3Auth$value2 = _web3Auth$value2.coreOptions) !== null && _web3Auth$value2 !== void 0 && _web3Auth$value2.chains) {
213
250
  var _web3Auth$value$curre;
214
251
  const defaultChainId = (_web3Auth$value$curre = web3Auth.value.currentChain) === null || _web3Auth$value$curre === void 0 ? void 0 : _web3Auth$value$curre.chainId;
215
252
  const chains = web3Auth.value.coreOptions.chains.filter(chain => chain.chainNamespace === baseControllers.CHAIN_NAMESPACES.EIP155);
@@ -257,8 +294,8 @@ const WagmiProvider = vue.defineComponent({
257
294
  }
258
295
  };
259
296
  vue.watch(isInitialized, (newIsInitialized, prevIsInitialized) => {
260
- var _web3Auth$value2;
261
- (_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || _web3Auth$value2.setAnalyticsProperties({
297
+ var _web3Auth$value3;
298
+ (_web3Auth$value3 = web3Auth.value) === null || _web3Auth$value3 === void 0 || _web3Auth$value3.setAnalyticsProperties({
262
299
  wagmi_enabled: true
263
300
  });
264
301
  if (newIsInitialized && !prevIsInitialized) {
@@ -291,3 +328,9 @@ const WagmiProvider = vue.defineComponent({
291
328
  });
292
329
 
293
330
  exports.WagmiProvider = WagmiProvider;
331
+ exports.connectWeb3AuthWithWagmi = connectWeb3AuthWithWagmi;
332
+ exports.createWeb3AuthConnectorForWagmi = createWeb3AuthConnectorForWagmi;
333
+ exports.disconnectWeb3AuthFromWagmi = disconnectWeb3AuthFromWagmi;
334
+ exports.getWeb3authConnector = getWeb3authConnector;
335
+ exports.resetConnectorState = resetConnectorState;
336
+ exports.setupConnector = setupConnector;
@@ -0,0 +1,92 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import { Web3AuthError } from '../base/errors/index.js';
3
+
4
+ class AccountLinkingError extends Web3AuthError {
5
+ constructor(code, message, cause) {
6
+ super(code, message, cause);
7
+ Object.defineProperty(this, "name", {
8
+ value: "AccountLinkingError",
9
+ configurable: true
10
+ });
11
+ }
12
+ static fromCode(code, extraMessage = "", cause) {
13
+ return new AccountLinkingError(code, `${AccountLinkingError.messages[code]}. ${extraMessage}`, cause);
14
+ }
15
+ static requestFailed(extraMessage = "", cause) {
16
+ return AccountLinkingError.fromCode(5401, extraMessage, cause);
17
+ }
18
+ static serverNotConfigured(extraMessage = "", cause) {
19
+ return AccountLinkingError.fromCode(5402, extraMessage, cause);
20
+ }
21
+ static primaryTokenNotAvailable(extraMessage = "", cause) {
22
+ return AccountLinkingError.fromCode(5403, extraMessage, cause);
23
+ }
24
+ static walletProofFailed(extraMessage = "", cause) {
25
+ return AccountLinkingError.fromCode(5404, extraMessage, cause);
26
+ }
27
+ static unsupportedConnector(extraMessage = "", cause) {
28
+ return AccountLinkingError.fromCode(5405, extraMessage, cause);
29
+ }
30
+ static cannotUnlinkActiveAccount() {
31
+ return AccountLinkingError.fromCode(5406);
32
+ }
33
+ static accountNotLinked(message = "", cause) {
34
+ return AccountLinkingError.fromCode(5407, message, cause);
35
+ }
36
+ static cannotUnlinkPrimaryAccount() {
37
+ return AccountLinkingError.fromCode(5408);
38
+ }
39
+ toString() {
40
+ return `[${this.code}] ${this.message}`;
41
+ }
42
+ }
43
+ _defineProperty(AccountLinkingError, "messages", {
44
+ 5000: "Custom",
45
+ 5401: "Account linking request failed",
46
+ 5402: "Citadel server URL is not configured",
47
+ 5403: "Primary identity token is not available",
48
+ 5404: "Failed to obtain wallet proof token",
49
+ 5405: "Connector is not supported for wallet linking",
50
+ 5406: "Cannot unlink active account",
51
+ 5407: "Account not linked",
52
+ 5408: "Cannot unlink primary account"
53
+ });
54
+ async function getAccountLinkingRequestError(error) {
55
+ if (error instanceof AccountLinkingError) {
56
+ return error;
57
+ }
58
+ if (error instanceof Response) {
59
+ if (error.status === 409) {
60
+ return AccountLinkingError.requestFailed("This wallet address is already registered on this dApp");
61
+ }
62
+ if (error.json && typeof error.json === "function") {
63
+ try {
64
+ var _json$message;
65
+ const json = await error.json();
66
+ return AccountLinkingError.requestFailed((_json$message = json.message) !== null && _json$message !== void 0 ? _json$message : "Failed to link account");
67
+ } catch {
68
+ // continue
69
+ }
70
+ }
71
+ }
72
+ return AccountLinkingError.requestFailed(error instanceof Error ? error.message : JSON.stringify(error), error);
73
+ }
74
+ function formatAccountLinkingErrorMessage(error, fallbackMessage = "Unknown error during the operation.") {
75
+ if (error instanceof AccountLinkingError) {
76
+ return error.toString();
77
+ }
78
+ if (error instanceof Web3AuthError) {
79
+ return `[${error.code}] Account linking error: ${error.message || fallbackMessage}`;
80
+ }
81
+ if (error instanceof Error) {
82
+ return `Account linking error: ${error.message || fallbackMessage}`;
83
+ }
84
+ try {
85
+ const stringifiedError = JSON.stringify(error);
86
+ return stringifiedError;
87
+ } catch {
88
+ return fallbackMessage;
89
+ }
90
+ }
91
+
92
+ export { AccountLinkingError, formatAccountLinkingErrorMessage, getAccountLinkingRequestError };
@@ -1 +1,2 @@
1
+ export { AccountLinkingError, formatAccountLinkingErrorMessage, getAccountLinkingRequestError } from './errors.js';
1
2
  export { makeAccountLinkingRequest, makeAccountUnlinkingRequest } from './rest.js';
@@ -1,5 +1,5 @@
1
1
  import { post } from '@toruslabs/http-helpers';
2
- import { AccountLinkingError } from '../base/errors/index.js';
2
+ import { getAccountLinkingRequestError, AccountLinkingError } from './errors.js';
3
3
 
4
4
  /**
5
5
  * Send both identity proofs to the Citadel account-linking endpoint and
@@ -17,8 +17,8 @@ async function makeAccountLinkingRequest(authServerUrl, accessToken, payload) {
17
17
  }
18
18
  });
19
19
  } catch (cause) {
20
- const message = cause instanceof Error ? cause.message : String(cause);
21
- throw AccountLinkingError.requestFailed(message, cause);
20
+ const accountLinkingError = await getAccountLinkingRequestError(cause);
21
+ throw accountLinkingError;
22
22
  }
23
23
  if (!result.success) {
24
24
  var _result$message;
@@ -20,7 +20,6 @@ const useLinkAccount = () => {
20
20
  linkedAccounts.value = result.linkedAccounts;
21
21
  return result;
22
22
  } catch (err) {
23
- log.error("Error linking account", err);
24
23
  error.value = err;
25
24
  } finally {
26
25
  loading.value = false;
@@ -1,5 +1,6 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
 
3
+ const WEB3AUTH_CONNECTOR_ID = "web3auth";
3
4
  const CONNECTOR_STATUS = {
4
5
  NOT_READY: "not_ready",
5
6
  READY: "ready",
@@ -31,4 +32,4 @@ const CONNECTOR_INITIAL_AUTHENTICATION_MODE = {
31
32
  CONNECT_AND_SIGN: "connect-and-sign"
32
33
  };
33
34
 
34
- export { CONNECTOR_CATEGORY, CONNECTOR_EVENTS, CONNECTOR_INITIAL_AUTHENTICATION_MODE, CONNECTOR_STATUS };
35
+ export { CONNECTOR_CATEGORY, CONNECTOR_EVENTS, CONNECTOR_INITIAL_AUTHENTICATION_MODE, CONNECTOR_STATUS, WEB3AUTH_CONNECTOR_ID };
@@ -188,7 +188,11 @@ class WalletOperationsError extends Web3AuthError {
188
188
  });
189
189
  }
190
190
  static fromCode(code, extraMessage = "", cause) {
191
- return new WalletOperationsError(code, `${WalletOperationsError.messages[code]}, ${extraMessage}`, cause);
191
+ let message = WalletOperationsError.messages[code];
192
+ if (extraMessage) {
193
+ message = `${message}, ${extraMessage}`;
194
+ }
195
+ return new WalletOperationsError(code, message, cause);
192
196
  }
193
197
 
194
198
  // Custom methods
@@ -201,58 +205,16 @@ class WalletOperationsError extends Web3AuthError {
201
205
  static chainNamespaceNotAllowed(extraMessage = "", cause) {
202
206
  return WalletOperationsError.fromCode(5203, extraMessage, cause);
203
207
  }
208
+ static userRejected(extraMessage = "", cause) {
209
+ return WalletOperationsError.fromCode(5204, extraMessage, cause);
210
+ }
204
211
  }
205
212
  _defineProperty(WalletOperationsError, "messages", {
206
213
  5000: "Custom",
207
214
  5201: "Provided chainId is not allowed",
208
- 5202: "This operation is not allowed"
209
- });
210
- class AccountLinkingError extends Web3AuthError {
211
- constructor(code, message, cause) {
212
- super(code, message, cause);
213
- Object.defineProperty(this, "name", {
214
- value: "AccountLinkingError",
215
- configurable: true
216
- });
217
- }
218
- static fromCode(code, extraMessage = "", cause) {
219
- return new AccountLinkingError(code, `${AccountLinkingError.messages[code]}. ${extraMessage}`, cause);
220
- }
221
- static requestFailed(extraMessage = "", cause) {
222
- return AccountLinkingError.fromCode(5401, extraMessage, cause);
223
- }
224
- static serverNotConfigured(extraMessage = "", cause) {
225
- return AccountLinkingError.fromCode(5402, extraMessage, cause);
226
- }
227
- static primaryTokenNotAvailable(extraMessage = "", cause) {
228
- return AccountLinkingError.fromCode(5403, extraMessage, cause);
229
- }
230
- static walletProofFailed(extraMessage = "", cause) {
231
- return AccountLinkingError.fromCode(5404, extraMessage, cause);
232
- }
233
- static unsupportedConnector(extraMessage = "", cause) {
234
- return AccountLinkingError.fromCode(5405, extraMessage, cause);
235
- }
236
- static cannotUnlinkActiveAccount() {
237
- return AccountLinkingError.fromCode(5406);
238
- }
239
- static accountNotLinked(message = "", cause) {
240
- return AccountLinkingError.fromCode(5407, message, cause);
241
- }
242
- static cannotUnlinkPrimaryAccount() {
243
- return AccountLinkingError.fromCode(5408);
244
- }
245
- }
246
- _defineProperty(AccountLinkingError, "messages", {
247
- 5000: "Custom",
248
- 5401: "Account linking request failed",
249
- 5402: "Citadel server URL is not configured",
250
- 5403: "Primary identity token is not available",
251
- 5404: "Failed to obtain wallet proof token",
252
- 5405: "Connector is not supported for wallet linking",
253
- 5406: "Cannot unlink active account",
254
- 5407: "Account not linked",
255
- 5408: "Cannot unlink primary account"
215
+ 5202: "This operation is not allowed",
216
+ 5203: "Chain namespace is not allowed",
217
+ 5204: "User rejected the request"
256
218
  });
257
219
  class WalletProviderError extends Web3AuthError {
258
220
  constructor(code, message, cause) {
@@ -286,5 +248,14 @@ _defineProperty(WalletProviderError, "messages", {
286
248
  5302: "'args.method' must be a non-empty string.",
287
249
  5303: "'args.params' must be an object or array if provided."
288
250
  });
251
+ function isUserRejectedError(error) {
252
+ if (error instanceof Web3AuthError && error.code === 5203) return true;
253
+ if (error instanceof Error) {
254
+ var _error$message;
255
+ const normalizedMessage = ((_error$message = error.message) === null || _error$message === void 0 ? void 0 : _error$message.toLowerCase()) || "";
256
+ return normalizedMessage.includes("user rejected the request");
257
+ }
258
+ return false;
259
+ }
289
260
 
290
- export { AccountLinkingError, WalletInitializationError, WalletLoginError, WalletOperationsError, WalletProviderError, Web3AuthError };
261
+ export { WalletInitializationError, WalletLoginError, WalletOperationsError, WalletProviderError, Web3AuthError, isUserRejectedError };
@@ -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.0-beta.1";
152
+ const sdkVersion = "11.0.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;