@web3auth/no-modal 10.14.0 → 10.15.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 (26) hide show
  1. package/dist/lib.cjs/base/utils.js +1 -1
  2. package/dist/lib.cjs/connectors/auth-connector/authConnector.js +9 -1
  3. package/dist/lib.cjs/connectors/wallet-connect-v2-connector/WalletConnectV2Provider.js +1 -0
  4. package/dist/lib.cjs/connectors/wallet-connect-v2-connector/walletConnectV2Utils.js +20 -0
  5. package/dist/lib.cjs/index.js +63 -63
  6. package/dist/lib.cjs/providers/ethereum-mpc-provider/providers/signingProviders/EthereumSigningProvider.js +1 -0
  7. package/dist/lib.cjs/providers/ethereum-provider/rpc/ethRpcMiddlewares.js +10 -2
  8. package/dist/lib.cjs/providers/ethereum-provider/rpc/walletMidddleware.js +82 -2
  9. package/dist/lib.cjs/types/providers/ethereum-provider/rpc/interfaces.d.ts +6 -0
  10. package/dist/lib.cjs/types/providers/ethereum-provider/rpc/walletMidddleware.d.ts +1 -1
  11. package/dist/lib.esm/base/utils.js +1 -1
  12. package/dist/lib.esm/connectors/auth-connector/authConnector.js +10 -1
  13. package/dist/lib.esm/connectors/injected-evm-connector/index.js +6 -1
  14. package/dist/lib.esm/connectors/injected-solana-connector/index.js +3 -2
  15. package/dist/lib.esm/connectors/wallet-connect-v2-connector/index.js +5 -1
  16. package/dist/lib.esm/connectors/wallet-connect-v2-connector/walletConnectV2Utils.js +20 -0
  17. package/dist/lib.esm/index.js +36 -36
  18. package/dist/lib.esm/providers/account-abstraction-provider/index.js +5 -1
  19. package/dist/lib.esm/providers/base-provider/index.js +5 -1
  20. package/dist/lib.esm/providers/ethereum-provider/rpc/ethRpcMiddlewares.js +11 -3
  21. package/dist/lib.esm/providers/ethereum-provider/rpc/walletMidddleware.js +83 -2
  22. package/dist/lib.esm/react/context/WalletServicesInnerContext.js +1 -1
  23. package/dist/lib.esm/vue/index.js +1 -1
  24. package/dist/noModal.umd.min.js +1 -1
  25. package/dist/noModal.umd.min.js.LICENSE.txt +0 -2
  26. package/package.json +4 -4
@@ -147,7 +147,7 @@ const getWalletServicesAnalyticsProperties = walletServicesConfig => {
147
147
  ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig10 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig10 === void 0 ? void 0 : _walletServicesConfig10.defaultPortfolio
148
148
  };
149
149
  };
150
- const sdkVersion = "10.14.0";
150
+ const sdkVersion = "10.15.0";
151
151
  const getErrorAnalyticsProperties = error => {
152
152
  try {
153
153
  const code = error instanceof index.Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
@@ -342,7 +342,7 @@ class AuthConnector extends baseConnector.BaseConnector {
342
342
  return finalPrivKey;
343
343
  }
344
344
  async connectWithProvider(params) {
345
- var _this$authInstance, _params$extraLoginOpt;
345
+ var _this$authInstance, _params$extraLoginOpt, _this$authInstance2, _this$authInstance3;
346
346
  if (!this.authInstance) throw index$1.WalletInitializationError.notReady("authInstance is not ready");
347
347
  const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId);
348
348
  if (!chainConfig) throw index$1.WalletLoginError.connectionError("Chain config is not available");
@@ -365,6 +365,14 @@ class AuthConnector extends baseConnector.BaseConnector {
365
365
  await this.connectWithSocialLogin(loginParams);
366
366
  }
367
367
  }
368
+ // if useSFAKey is true and privKey is available but coreKitKey is not available, throw an error
369
+ if (this.coreOptions.useSFAKey && (_this$authInstance2 = this.authInstance) !== null && _this$authInstance2 !== void 0 && _this$authInstance2.privKey && !((_this$authInstance3 = this.authInstance) !== null && _this$authInstance3 !== void 0 && _this$authInstance3.coreKitKey)) {
370
+ // If the user is already logged in, logout and throw an error
371
+ if (this.authInstance.sessionId) {
372
+ await this.authInstance.logout();
373
+ }
374
+ throw index$1.WalletLoginError.sfaKeyNotFound("This typically occurs when the authentication method used does not provide SFA keys (e.g., default auth connection).");
375
+ }
368
376
  // setup WS embed if chainNamespace is EIP155 or SOLANA
369
377
  if (chainNamespace === baseControllers.CHAIN_NAMESPACES.EIP155 || chainNamespace === baseControllers.CHAIN_NAMESPACES.SOLANA) {
370
378
  // wait for ws embed instance to be ready.
@@ -27,6 +27,7 @@ require('bn.js');
27
27
  require('../../providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/interfaces.js');
28
28
  var ethRpcMiddlewares = require('../../providers/ethereum-provider/rpc/ethRpcMiddlewares.js');
29
29
  var jrpcClient = require('../../providers/ethereum-provider/rpc/jrpcClient.js');
30
+ require('viem');
30
31
  require('@solana/wallet-standard-features');
31
32
  require('@solana/web3.js');
32
33
  require('@toruslabs/bs58');
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
4
4
  var bs58 = require('@toruslabs/bs58');
5
+ var ethereumControllers = require('@toruslabs/ethereum-controllers');
5
6
  var utils$1 = require('@walletconnect/utils');
6
7
  var auth = require('@web3auth/auth');
7
8
  var wsEmbed = require('@web3auth/ws-embed');
@@ -101,6 +102,25 @@ function getEthProviderHandlers({
101
102
  processTypedMessageV4: async msgParams => {
102
103
  const methodRes = await sendJrpcRequest(connector, `eip155:${chainId}`, wsEmbed.EVM_METHOD_TYPES.ETH_SIGN_TYPED_DATA_V4, [msgParams.from, msgParams.data]);
103
104
  return methodRes;
105
+ },
106
+ // EIP-5792: wallet_getCapabilities
107
+ processGetCapabilities: async params => {
108
+ const capabilities = await sendJrpcRequest(connector, `eip155:${chainId}`, ethereumControllers.EIP_5792_METHODS.WALLET_GET_CAPABILITIES, params);
109
+ return capabilities;
110
+ },
111
+ // EIP-5792: wallet_sendCalls
112
+ processSendCalls: async params => {
113
+ const results = await sendJrpcRequest(connector, `eip155:${chainId}`, ethereumControllers.EIP_5792_METHODS.WALLET_SEND_CALLS, [params]);
114
+ return results;
115
+ },
116
+ // EIP-5792: wallet_getCallsStatus
117
+ processGetCallsStatus: async batchId => {
118
+ const results = await sendJrpcRequest(connector, `eip155:${chainId}`, ethereumControllers.EIP_5792_METHODS.WALLET_GET_CALLS_STATUS, [batchId]);
119
+ return results;
120
+ },
121
+ // EIP-5792: wallet_showCallsStatus
122
+ processShowCallsStatus: async batchId => {
123
+ await sendJrpcRequest(connector, `eip155:${chainId}`, ethereumControllers.EIP_5792_METHODS.WALLET_SHOW_CALLS_STATUS, [batchId]);
104
124
  }
105
125
  };
106
126
  }
@@ -2,21 +2,21 @@
2
2
 
3
3
  var analytics = require('./base/analytics.js');
4
4
  var IChainInterface = require('./base/chain/IChainInterface.js');
5
- var index = require('./base/composables/index.js');
5
+ var index$2 = require('./base/composables/index.js');
6
6
  var baseConnector = require('./base/connector/baseConnector.js');
7
7
  var connectorStatus = require('./base/connector/connectorStatus.js');
8
8
  var constants = require('./base/connector/constants.js');
9
9
  var auth = require('@web3auth/auth');
10
- var utils = require('./base/connector/utils.js');
11
- var constants$1 = require('./base/constants.js');
10
+ var utils$1 = require('./base/connector/utils.js');
11
+ var constants$2 = require('./base/constants.js');
12
12
  var cookie = require('./base/cookie.js');
13
13
  var index$1 = require('./base/errors/index.js');
14
14
  var loglevel = require('./base/loglevel.js');
15
15
  var errors = require('./base/plugin/errors.js');
16
16
  var IPlugin = require('./base/plugin/IPlugin.js');
17
17
  var IProvider = require('./base/provider/IProvider.js');
18
- var utils$1 = require('./base/utils.js');
19
- var index$2 = require('./base/wallet/index.js');
18
+ var utils$3 = require('./base/utils.js');
19
+ var index = require('./base/wallet/index.js');
20
20
  var authConnector = require('./connectors/auth-connector/authConnector.js');
21
21
  var baseEvmConnector = require('./connectors/base-evm-connector/baseEvmConnector.js');
22
22
  var baseSolanaConnector = require('./connectors/base-solana-connector/baseSolanaConnector.js');
@@ -34,11 +34,11 @@ var ethereumControllers = require('@toruslabs/ethereum-controllers');
34
34
  var baseProvider = require('./providers/base-provider/baseProvider.js');
35
35
  var CommonJRPCProvider = require('./providers/base-provider/CommonJRPCProvider.js');
36
36
  var commonPrivateKeyProvider = require('./providers/base-provider/commonPrivateKeyProvider.js');
37
- var utils$2 = require('./providers/base-provider/utils.js');
38
- var constants$2 = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/constants.js');
37
+ var utils = require('./providers/base-provider/utils.js');
38
+ var constants$1 = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/constants.js');
39
39
  var formatter = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/formatter.js');
40
40
  var interfaces = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/interfaces.js');
41
- var utils$3 = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/utils.js');
41
+ var utils$2 = require('./providers/ethereum-provider/providers/privateKeyProviders/TransactionFormatter/utils.js');
42
42
  var ethRpcMiddlewares = require('./providers/ethereum-provider/rpc/ethRpcMiddlewares.js');
43
43
  var jrpcClient = require('./providers/ethereum-provider/rpc/jrpcClient.js');
44
44
  var walletMidddleware = require('./providers/ethereum-provider/rpc/walletMidddleware.js');
@@ -47,10 +47,10 @@ var walletStandardProvider = require('./providers/solana-provider/providers/inje
47
47
  var JrpcClient = require('./providers/solana-provider/rpc/JrpcClient.js');
48
48
  var solanaRpcMiddlewares = require('./providers/solana-provider/rpc/solanaRpcMiddlewares.js');
49
49
  var solanaWallet = require('./providers/solana-provider/solanaWallet.js');
50
+ var wsEmbed = require('@web3auth/ws-embed');
50
51
  var baseControllers = require('@toruslabs/base-controllers');
51
52
  var app = require('@wallet-standard/app');
52
53
  var walletStandardConnector = require('./connectors/injected-solana-connector/walletStandardConnector.js');
53
- var wsEmbed = require('@web3auth/ws-embed');
54
54
 
55
55
 
56
56
 
@@ -59,7 +59,7 @@ exports.ANALYTICS_INTEGRATION_TYPE = analytics.ANALYTICS_INTEGRATION_TYPE;
59
59
  exports.ANALYTICS_SDK_TYPE = analytics.ANALYTICS_SDK_TYPE;
60
60
  exports.Analytics = analytics.Analytics;
61
61
  exports.CONNECTOR_NAMESPACES = IChainInterface.CONNECTOR_NAMESPACES;
62
- exports.Web3AuthContextKey = index.Web3AuthContextKey;
62
+ exports.Web3AuthContextKey = index$2.Web3AuthContextKey;
63
63
  exports.BaseConnector = baseConnector.BaseConnector;
64
64
  exports.CAN_AUTHORIZE_STATUSES = connectorStatus.CAN_AUTHORIZE_STATUSES;
65
65
  exports.CONNECTED_STATUSES = connectorStatus.CONNECTED_STATUSES;
@@ -91,18 +91,18 @@ Object.defineProperty(exports, "getED25519Key", {
91
91
  enumerable: true,
92
92
  get: function () { return auth.getED25519Key; }
93
93
  });
94
- exports.checkIfTokenIsExpired = utils.checkIfTokenIsExpired;
95
- exports.clearToken = utils.clearToken;
96
- exports.getSavedToken = utils.getSavedToken;
97
- exports.saveToken = utils.saveToken;
98
- exports.storageAvailable = utils.storageAvailable;
99
- exports.LOGIN_MODE = constants$1.LOGIN_MODE;
100
- exports.MODAL_SIGN_IN_METHODS = constants$1.MODAL_SIGN_IN_METHODS;
101
- exports.SMART_ACCOUNT_WALLET_SCOPE = constants$1.SMART_ACCOUNT_WALLET_SCOPE;
102
- exports.SOLANA_CAIP_CHAIN_MAP = constants$1.SOLANA_CAIP_CHAIN_MAP;
103
- exports.WALLET_REGISTRY_URL = constants$1.WALLET_REGISTRY_URL;
104
- exports.WEB3AUTH_STATE_STORAGE_KEY = constants$1.WEB3AUTH_STATE_STORAGE_KEY;
105
- exports.WIDGET_TYPE = constants$1.WIDGET_TYPE;
94
+ exports.checkIfTokenIsExpired = utils$1.checkIfTokenIsExpired;
95
+ exports.clearToken = utils$1.clearToken;
96
+ exports.getSavedToken = utils$1.getSavedToken;
97
+ exports.saveToken = utils$1.saveToken;
98
+ exports.storageAvailable = utils$1.storageAvailable;
99
+ exports.LOGIN_MODE = constants$2.LOGIN_MODE;
100
+ exports.MODAL_SIGN_IN_METHODS = constants$2.MODAL_SIGN_IN_METHODS;
101
+ exports.SMART_ACCOUNT_WALLET_SCOPE = constants$2.SMART_ACCOUNT_WALLET_SCOPE;
102
+ exports.SOLANA_CAIP_CHAIN_MAP = constants$2.SOLANA_CAIP_CHAIN_MAP;
103
+ exports.WALLET_REGISTRY_URL = constants$2.WALLET_REGISTRY_URL;
104
+ exports.WEB3AUTH_STATE_STORAGE_KEY = constants$2.WEB3AUTH_STATE_STORAGE_KEY;
105
+ exports.WIDGET_TYPE = constants$2.WIDGET_TYPE;
106
106
  exports.cookieToWeb3AuthState = cookie.cookieToWeb3AuthState;
107
107
  exports.WalletInitializationError = index$1.WalletInitializationError;
108
108
  exports.WalletLoginError = index$1.WalletLoginError;
@@ -118,27 +118,27 @@ exports.PLUGIN_STATUS = IPlugin.PLUGIN_STATUS;
118
118
  exports.SOLANA_PLUGINS = IPlugin.SOLANA_PLUGINS;
119
119
  exports.WALLET_PLUGINS = IPlugin.WALLET_PLUGINS;
120
120
  exports.PROVIDER_EVENTS = IProvider.PROVIDER_EVENTS;
121
- exports.fetchProjectConfig = utils$1.fetchProjectConfig;
122
- exports.fetchWalletRegistry = utils$1.fetchWalletRegistry;
123
- exports.fromViemChain = utils$1.fromViemChain;
124
- exports.fromWagmiChain = utils$1.fromWagmiChain;
125
- exports.getAaAnalyticsProperties = utils$1.getAaAnalyticsProperties;
126
- exports.getCaipChainId = utils$1.getCaipChainId;
127
- exports.getErrorAnalyticsProperties = utils$1.getErrorAnalyticsProperties;
128
- exports.getHostname = utils$1.getHostname;
129
- exports.getWalletServicesAnalyticsProperties = utils$1.getWalletServicesAnalyticsProperties;
130
- exports.getWhitelabelAnalyticsProperties = utils$1.getWhitelabelAnalyticsProperties;
131
- exports.isBrowser = utils$1.isBrowser;
132
- exports.isHexStrict = utils$1.isHexStrict;
133
- exports.normalizeWalletName = utils$1.normalizeWalletName;
134
- exports.sdkVersion = utils$1.sdkVersion;
135
- exports.signerHost = utils$1.signerHost;
136
- exports.withAbort = utils$1.withAbort;
137
- exports.CONNECTOR_NAMES = index$2.CONNECTOR_NAMES;
138
- exports.EVM_CONNECTORS = index$2.EVM_CONNECTORS;
139
- exports.MULTI_CHAIN_CONNECTORS = index$2.MULTI_CHAIN_CONNECTORS;
140
- exports.SOLANA_CONNECTORS = index$2.SOLANA_CONNECTORS;
141
- exports.WALLET_CONNECTORS = index$2.WALLET_CONNECTORS;
121
+ exports.fetchProjectConfig = utils$3.fetchProjectConfig;
122
+ exports.fetchWalletRegistry = utils$3.fetchWalletRegistry;
123
+ exports.fromViemChain = utils$3.fromViemChain;
124
+ exports.fromWagmiChain = utils$3.fromWagmiChain;
125
+ exports.getAaAnalyticsProperties = utils$3.getAaAnalyticsProperties;
126
+ exports.getCaipChainId = utils$3.getCaipChainId;
127
+ exports.getErrorAnalyticsProperties = utils$3.getErrorAnalyticsProperties;
128
+ exports.getHostname = utils$3.getHostname;
129
+ exports.getWalletServicesAnalyticsProperties = utils$3.getWalletServicesAnalyticsProperties;
130
+ exports.getWhitelabelAnalyticsProperties = utils$3.getWhitelabelAnalyticsProperties;
131
+ exports.isBrowser = utils$3.isBrowser;
132
+ exports.isHexStrict = utils$3.isHexStrict;
133
+ exports.normalizeWalletName = utils$3.normalizeWalletName;
134
+ exports.sdkVersion = utils$3.sdkVersion;
135
+ exports.signerHost = utils$3.signerHost;
136
+ exports.withAbort = utils$3.withAbort;
137
+ exports.CONNECTOR_NAMES = index.CONNECTOR_NAMES;
138
+ exports.EVM_CONNECTORS = index.EVM_CONNECTORS;
139
+ exports.MULTI_CHAIN_CONNECTORS = index.MULTI_CHAIN_CONNECTORS;
140
+ exports.SOLANA_CONNECTORS = index.SOLANA_CONNECTORS;
141
+ exports.WALLET_CONNECTORS = index.WALLET_CONNECTORS;
142
142
  exports.authConnector = authConnector.authConnector;
143
143
  exports.BaseEvmConnector = baseEvmConnector.BaseEvmConnector;
144
144
  exports.BaseSolanaConnector = baseSolanaConnector.BaseSolanaConnector;
@@ -209,24 +209,24 @@ exports.CommonJRPCProvider = CommonJRPCProvider.CommonJRPCProvider;
209
209
  exports.CommonPrivateKeyProvider = commonPrivateKeyProvider.CommonPrivateKeyProvider;
210
210
  Object.defineProperty(exports, "EIP1193_EVENTS", {
211
211
  enumerable: true,
212
- get: function () { return utils$2.EIP1193_EVENTS; }
212
+ get: function () { return utils.EIP1193_EVENTS; }
213
213
  });
214
- exports.createRandomId = utils$2.createRandomId;
215
- exports.EIP1559APIEndpoint = constants$2.EIP1559APIEndpoint;
216
- exports.GAS_ESTIMATE_TYPES = constants$2.GAS_ESTIMATE_TYPES;
217
- exports.LegacyGasAPIEndpoint = constants$2.LegacyGasAPIEndpoint;
218
- exports.TRANSACTION_ENVELOPE_TYPES = constants$2.TRANSACTION_ENVELOPE_TYPES;
219
- exports.TRANSACTION_TYPES = constants$2.TRANSACTION_TYPES;
214
+ exports.createRandomId = utils.createRandomId;
215
+ exports.EIP1559APIEndpoint = constants$1.EIP1559APIEndpoint;
216
+ exports.GAS_ESTIMATE_TYPES = constants$1.GAS_ESTIMATE_TYPES;
217
+ exports.LegacyGasAPIEndpoint = constants$1.LegacyGasAPIEndpoint;
218
+ exports.TRANSACTION_ENVELOPE_TYPES = constants$1.TRANSACTION_ENVELOPE_TYPES;
219
+ exports.TRANSACTION_TYPES = constants$1.TRANSACTION_TYPES;
220
220
  exports.TransactionFormatter = formatter.TransactionFormatter;
221
221
  Object.defineProperty(exports, "SignTypedDataVersion", {
222
222
  enumerable: true,
223
223
  get: function () { return interfaces.SignTypedDataVersion; }
224
224
  });
225
- exports.fetchEip1159GasEstimates = utils$3.fetchEip1159GasEstimates;
226
- exports.fetchLegacyGasPriceEstimates = utils$3.fetchLegacyGasPriceEstimates;
227
- exports.normalizeGWEIDecimalNumbers = utils$3.normalizeGWEIDecimalNumbers;
228
- exports.validateAddress = utils$3.validateAddress;
229
- exports.validateTypedSignMessageDataV4 = utils$3.validateTypedSignMessageDataV4;
225
+ exports.fetchEip1159GasEstimates = utils$2.fetchEip1159GasEstimates;
226
+ exports.fetchLegacyGasPriceEstimates = utils$2.fetchLegacyGasPriceEstimates;
227
+ exports.normalizeGWEIDecimalNumbers = utils$2.normalizeGWEIDecimalNumbers;
228
+ exports.validateAddress = utils$2.validateAddress;
229
+ exports.validateTypedSignMessageDataV4 = utils$2.validateTypedSignMessageDataV4;
230
230
  exports.createEthChainSwitchMiddleware = ethRpcMiddlewares.createEthChainSwitchMiddleware;
231
231
  exports.createEthMiddleware = ethRpcMiddlewares.createEthMiddleware;
232
232
  exports.createEthChainIdMiddleware = jrpcClient.createEthChainIdMiddleware;
@@ -247,6 +247,14 @@ exports.createSolanaAccountMiddleware = solanaRpcMiddlewares.createSolanaAccount
247
247
  exports.createSolanaChainSwitchMiddleware = solanaRpcMiddlewares.createSolanaChainSwitchMiddleware;
248
248
  exports.createSolanaMiddleware = solanaRpcMiddlewares.createSolanaMiddleware;
249
249
  exports.SolanaWallet = solanaWallet.SolanaWallet;
250
+ Object.defineProperty(exports, "BUTTON_POSITION", {
251
+ enumerable: true,
252
+ get: function () { return wsEmbed.BUTTON_POSITION; }
253
+ });
254
+ Object.defineProperty(exports, "CONFIRMATION_STRATEGY", {
255
+ enumerable: true,
256
+ get: function () { return wsEmbed.CONFIRMATION_STRATEGY; }
257
+ });
250
258
  Object.defineProperty(exports, "CHAIN_NAMESPACES", {
251
259
  enumerable: true,
252
260
  get: function () { return baseControllers.CHAIN_NAMESPACES; }
@@ -260,11 +268,3 @@ Object.defineProperty(exports, "createSolanaMipd", {
260
268
  get: function () { return app.getWallets; }
261
269
  });
262
270
  exports.walletStandardConnector = walletStandardConnector.walletStandardConnector;
263
- Object.defineProperty(exports, "BUTTON_POSITION", {
264
- enumerable: true,
265
- get: function () { return wsEmbed.BUTTON_POSITION; }
266
- });
267
- Object.defineProperty(exports, "CONFIRMATION_STRATEGY", {
268
- enumerable: true,
269
- get: function () { return wsEmbed.CONFIRMATION_STRATEGY; }
270
- });
@@ -25,6 +25,7 @@ require('../../../ethereum-provider/providers/privateKeyProviders/TransactionFor
25
25
  require('../../../ethereum-provider/providers/converter.js');
26
26
  var ethRpcMiddlewares = require('../../../ethereum-provider/rpc/ethRpcMiddlewares.js');
27
27
  var jrpcClient = require('../../../ethereum-provider/rpc/jrpcClient.js');
28
+ require('viem');
28
29
  var ethRpcMiddlewares$1 = require('../../rpc/ethRpcMiddlewares.js');
29
30
  var signingUtils = require('./signingUtils.js');
30
31
 
@@ -12,7 +12,11 @@ function createEthMiddleware(providerHandlers) {
12
12
  processSignTransaction,
13
13
  processEthSignMessage,
14
14
  processTypedMessageV4,
15
- processPersonalMessage
15
+ processPersonalMessage,
16
+ processGetCapabilities,
17
+ processSendCalls,
18
+ processGetCallsStatus,
19
+ processShowCallsStatus
16
20
  } = providerHandlers;
17
21
  const ethMiddleware = auth.mergeMiddleware([auth.createScaffoldMiddleware({
18
22
  eth_syncing: false
@@ -24,7 +28,11 @@ function createEthMiddleware(providerHandlers) {
24
28
  processEthSignMessage,
25
29
  processSignTransaction,
26
30
  processTypedMessageV4,
27
- processPersonalMessage
31
+ processPersonalMessage,
32
+ processGetCapabilities,
33
+ processSendCalls,
34
+ processGetCallsStatus,
35
+ processShowCallsStatus
28
36
  })]);
29
37
  return ethMiddleware;
30
38
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
4
4
  var auth = require('@web3auth/auth');
5
+ var viem = require('viem');
5
6
 
6
7
  function createWalletMiddleware({
7
8
  getAccounts,
@@ -11,7 +12,11 @@ function createWalletMiddleware({
11
12
  processPersonalMessage,
12
13
  processTransaction,
13
14
  processSignTransaction,
14
- processTypedMessageV4
15
+ processTypedMessageV4,
16
+ processGetCapabilities,
17
+ processSendCalls,
18
+ processGetCallsStatus,
19
+ processShowCallsStatus
15
20
  }) {
16
21
  if (!getAccounts) {
17
22
  throw new Error("opts.getAccounts is required");
@@ -150,6 +155,76 @@ function createWalletMiddleware({
150
155
  }
151
156
  res.result = await getPublicKey(req);
152
157
  }
158
+ async function getWalletCapabilitiesMiddleware(req, res) {
159
+ if (!processGetCapabilities) {
160
+ throw auth.rpcErrors.methodNotSupported();
161
+ }
162
+ if (!Array.isArray(req.params) || req.params.length === 0) {
163
+ throw auth.rpcErrors.invalidParams("Invalid parameters");
164
+ }
165
+ const account = req.params[0];
166
+ if (!viem.isHex(account)) {
167
+ throw auth.rpcErrors.invalidParams("Invalid account address");
168
+ }
169
+ let chainIds = req.params[1] || []; // if empty array is provided, the wallet will return capabilities for all supported chains
170
+ if (!Array.isArray(chainIds)) {
171
+ throw auth.rpcErrors.invalidParams(`Invalid params, received: ${chainIds}. expected: Array`);
172
+ }
173
+ // format chain ids
174
+ chainIds = chainIds.map(chainId => viem.isHex(chainId) ? chainId : viem.toHex(chainId));
175
+ const getCapabilitiesParams = [account,
176
+ // account address
177
+ chainIds // [`0xstring`, `0xstring`, ...]
178
+ ];
179
+ res.result = await processGetCapabilities(getCapabilitiesParams);
180
+ }
181
+ async function walletSendCallsMiddleware(req, res) {
182
+ if (!processSendCalls) {
183
+ throw auth.rpcErrors.methodNotSupported();
184
+ }
185
+ const params = Array.isArray(req.params) ? req.params[0] : req.params;
186
+ if (!params || typeof params !== "object") {
187
+ throw auth.rpcErrors.invalidParams("Missing or invalid params for wallet_sendCalls");
188
+ }
189
+ if (!params.version || typeof params.version !== "string") {
190
+ throw auth.rpcErrors.invalidParams(`Invalid version: expected string, got "${params.version || "undefined"}"`);
191
+ }
192
+ if (!params.chainId) {
193
+ throw auth.rpcErrors.invalidParams("Missing required field: chainId");
194
+ }
195
+ if (!Array.isArray(params.calls) || params.calls.length === 0) {
196
+ throw auth.rpcErrors.invalidParams("calls must be a non-empty array");
197
+ }
198
+ const from = params.from;
199
+ if (from) {
200
+ await validateAndNormalizeKeyholder(from, req);
201
+ }
202
+ const walletSendCallsParams = _objectSpread(_objectSpread({}, params), {}, {
203
+ chainId: viem.isHex(params.chainId) ? params.chainId : viem.toHex(params.chainId)
204
+ });
205
+ res.result = await processSendCalls(walletSendCallsParams);
206
+ }
207
+ async function walletBatchCallStatusMiddleware(req, res) {
208
+ if (!processGetCallsStatus) {
209
+ throw auth.rpcErrors.methodNotSupported();
210
+ }
211
+ const batchId = Array.isArray(req.params) ? req.params[0] : req.params;
212
+ if (!batchId || typeof batchId !== "string") {
213
+ throw auth.rpcErrors.invalidParams("Missing or invalid batchId");
214
+ }
215
+ res.result = await processGetCallsStatus(batchId);
216
+ }
217
+ async function walletShowCallsStatusMiddleware(req, res) {
218
+ if (!processShowCallsStatus) {
219
+ throw auth.rpcErrors.methodNotSupported();
220
+ }
221
+ const batchId = Array.isArray(req.params) ? req.params[0] : req.params;
222
+ if (!batchId || typeof batchId !== "string") {
223
+ throw auth.rpcErrors.invalidParams("Missing or invalid batchId");
224
+ }
225
+ await processShowCallsStatus(batchId);
226
+ res.result = true;
227
+ }
153
228
  return auth.createScaffoldMiddleware({
154
229
  // account lookups
155
230
  eth_accounts: auth.createAsyncMiddleware(lookupAccounts),
@@ -164,7 +239,12 @@ function createWalletMiddleware({
164
239
  // message signatures
165
240
  eth_sign: auth.createAsyncMiddleware(ethSign),
166
241
  eth_signTypedData_v4: auth.createAsyncMiddleware(signTypedDataV4),
167
- personal_sign: auth.createAsyncMiddleware(personalSign)
242
+ personal_sign: auth.createAsyncMiddleware(personalSign),
243
+ // EIP-5792
244
+ wallet_getCapabilities: auth.createAsyncMiddleware(getWalletCapabilitiesMiddleware),
245
+ wallet_sendCalls: auth.createAsyncMiddleware(walletSendCallsMiddleware),
246
+ wallet_getCallsStatus: auth.createAsyncMiddleware(walletBatchCallStatusMiddleware),
247
+ wallet_showCallsStatus: auth.createAsyncMiddleware(walletShowCallsStatusMiddleware)
168
248
  });
169
249
  }
170
250
 
@@ -1,5 +1,7 @@
1
+ import { Eip5792GetCapabilitiesParams, Eip5792SendCallsParams, Eip5792ShowCallsStatusParams } from "@toruslabs/ethereum-controllers";
1
2
  import type { JRPCRequest } from "@web3auth/auth";
2
3
  import type { TransactionLike, TypedDataDomain, TypedDataField } from "ethers";
4
+ import type { GetCapabilitiesReturnType, SendCallsReturnType, WalletGetCallsStatusReturnType } from "viem";
3
5
  import { AddEthereumChainConfig } from "../../../base";
4
6
  export interface IEthAccountHandlers {
5
7
  updatePrivatekey: (params: {
@@ -50,5 +52,9 @@ export interface WalletMiddlewareOptions {
50
52
  processTransaction?: (txParams: TransactionParams, req: JRPCRequest<unknown>) => Promise<string>;
51
53
  processSignTransaction?: (txParams: TransactionParams, req: JRPCRequest<unknown>) => Promise<string>;
52
54
  processTypedMessageV4?: (msgParams: TypedMessageParams, req: JRPCRequest<unknown>) => Promise<string>;
55
+ processGetCapabilities?: (req: Eip5792GetCapabilitiesParams) => Promise<GetCapabilitiesReturnType>;
56
+ processSendCalls?: (params: Eip5792SendCallsParams) => Promise<SendCallsReturnType>;
57
+ processGetCallsStatus?: (batchId: string) => Promise<WalletGetCallsStatusReturnType>;
58
+ processShowCallsStatus?: (batchId: Eip5792ShowCallsStatusParams) => Promise<void>;
53
59
  }
54
60
  export type IEthProviderHandlers = WalletMiddlewareOptions;
@@ -1,3 +1,3 @@
1
1
  import { JRPCMiddleware } from "@web3auth/auth";
2
2
  import type { WalletMiddlewareOptions } from "./interfaces";
3
- export declare function createWalletMiddleware({ getAccounts, getPrivateKey, getPublicKey, processEthSignMessage, processPersonalMessage, processTransaction, processSignTransaction, processTypedMessageV4, }: WalletMiddlewareOptions): JRPCMiddleware<string, unknown>;
3
+ export declare function createWalletMiddleware({ getAccounts, getPrivateKey, getPublicKey, processEthSignMessage, processPersonalMessage, processTransaction, processSignTransaction, processTypedMessageV4, processGetCapabilities, processSendCalls, processGetCallsStatus, processShowCallsStatus, }: WalletMiddlewareOptions): JRPCMiddleware<string, unknown>;
@@ -146,7 +146,7 @@ const getWalletServicesAnalyticsProperties = walletServicesConfig => {
146
146
  ws_default_portfolio: walletServicesConfig === null || walletServicesConfig === void 0 || (_walletServicesConfig10 = walletServicesConfig.whiteLabel) === null || _walletServicesConfig10 === void 0 ? void 0 : _walletServicesConfig10.defaultPortfolio
147
147
  };
148
148
  };
149
- const sdkVersion = "10.14.0";
149
+ const sdkVersion = "10.15.0";
150
150
  const getErrorAnalyticsProperties = error => {
151
151
  try {
152
152
  const code = error instanceof Web3AuthError ? error.code : error === null || error === void 0 ? void 0 : error.code;
@@ -341,7 +341,7 @@ class AuthConnector extends BaseConnector {
341
341
  return finalPrivKey;
342
342
  }
343
343
  async connectWithProvider(params) {
344
- var _this$authInstance, _params$extraLoginOpt;
344
+ var _this$authInstance, _params$extraLoginOpt, _this$authInstance2, _this$authInstance3;
345
345
  if (!this.authInstance) throw WalletInitializationError.notReady("authInstance is not ready");
346
346
  const chainConfig = this.coreOptions.chains.find(x => x.chainId === params.chainId);
347
347
  if (!chainConfig) throw WalletLoginError.connectionError("Chain config is not available");
@@ -366,6 +366,15 @@ class AuthConnector extends BaseConnector {
366
366
  }
367
367
  }
368
368
 
369
+ // if useSFAKey is true and privKey is available but coreKitKey is not available, throw an error
370
+ if (this.coreOptions.useSFAKey && (_this$authInstance2 = this.authInstance) !== null && _this$authInstance2 !== void 0 && _this$authInstance2.privKey && !((_this$authInstance3 = this.authInstance) !== null && _this$authInstance3 !== void 0 && _this$authInstance3.coreKitKey)) {
371
+ // If the user is already logged in, logout and throw an error
372
+ if (this.authInstance.sessionId) {
373
+ await this.authInstance.logout();
374
+ }
375
+ throw WalletLoginError.sfaKeyNotFound("This typically occurs when the authentication method used does not provide SFA keys (e.g., default auth connection).");
376
+ }
377
+
369
378
  // setup WS embed if chainNamespace is EIP155 or SOLANA
370
379
  if (chainNamespace === CHAIN_NAMESPACES.EIP155 || chainNamespace === CHAIN_NAMESPACES.SOLANA) {
371
380
  // wait for ws embed instance to be ready.
@@ -1,2 +1,7 @@
1
- export { injectedEvmConnector } from './injectedEvmConnector.js';
1
+ import { injectedEvmConnector } from './injectedEvmConnector.js';
2
+ import { createStore } from 'mipd';
2
3
  export { createStore as createMipd } from 'mipd';
4
+
5
+
6
+
7
+ export { injectedEvmConnector };
@@ -1,7 +1,8 @@
1
1
  import { SolanaSignMessage, SolanaSignTransaction, SolanaSignAndSendTransaction } from '@solana/wallet-standard-features';
2
+ import { getWallets } from '@wallet-standard/app';
2
3
  export { getWallets as createSolanaMipd } from '@wallet-standard/app';
3
4
  import { StandardConnect } from '@wallet-standard/features';
4
- export { walletStandardConnector } from './walletStandardConnector.js';
5
+ import { walletStandardConnector } from './walletStandardConnector.js';
5
6
 
6
7
  const hasSolanaWalletStandardFeatures = wallet => {
7
8
  const {
@@ -15,4 +16,4 @@ const hasSolanaWalletStandardFeatures = wallet => {
15
16
  return true;
16
17
  };
17
18
 
18
- export { hasSolanaWalletStandardFeatures };
19
+ export { hasSolanaWalletStandardFeatures, walletStandardConnector };
@@ -1,3 +1,7 @@
1
1
  export { DEFAULT_EIP155_METHODS, DEFAULT_EIP_155_EVENTS, DEFAULT_SOLANA_EVENTS, DEFAULT_SOLANA_METHODS, getNamespacesFromChains, getRequiredNamespaces, getSupportedEventsByNamespace, getSupportedMethodsByNamespace, getWalletConnectV2Settings } from './config.js';
2
- export { walletConnectV2Connector } from './walletConnectV2Connector.js';
2
+ import { walletConnectV2Connector } from './walletConnectV2Connector.js';
3
3
  export { WalletConnectV2Provider } from './WalletConnectV2Provider.js';
4
+
5
+
6
+
7
+ export { walletConnectV2Connector };
@@ -1,5 +1,6 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import { bs58 } from '@toruslabs/bs58';
3
+ import { EIP_5792_METHODS } from '@toruslabs/ethereum-controllers';
3
4
  import { getAccountsFromNamespaces, parseAccountId } from '@walletconnect/utils';
4
5
  import { providerErrors, rpcErrors } from '@web3auth/auth';
5
6
  import { EVM_METHOD_TYPES, SOLANA_METHOD_TYPES } from '@web3auth/ws-embed';
@@ -87,6 +88,25 @@ function getEthProviderHandlers({
87
88
  processTypedMessageV4: async msgParams => {
88
89
  const methodRes = await sendJrpcRequest(connector, `eip155:${chainId}`, EVM_METHOD_TYPES.ETH_SIGN_TYPED_DATA_V4, [msgParams.from, msgParams.data]);
89
90
  return methodRes;
91
+ },
92
+ // EIP-5792: wallet_getCapabilities
93
+ processGetCapabilities: async params => {
94
+ const capabilities = await sendJrpcRequest(connector, `eip155:${chainId}`, EIP_5792_METHODS.WALLET_GET_CAPABILITIES, params);
95
+ return capabilities;
96
+ },
97
+ // EIP-5792: wallet_sendCalls
98
+ processSendCalls: async params => {
99
+ const results = await sendJrpcRequest(connector, `eip155:${chainId}`, EIP_5792_METHODS.WALLET_SEND_CALLS, [params]);
100
+ return results;
101
+ },
102
+ // EIP-5792: wallet_getCallsStatus
103
+ processGetCallsStatus: async batchId => {
104
+ const results = await sendJrpcRequest(connector, `eip155:${chainId}`, EIP_5792_METHODS.WALLET_GET_CALLS_STATUS, [batchId]);
105
+ return results;
106
+ },
107
+ // EIP-5792: wallet_showCallsStatus
108
+ processShowCallsStatus: async batchId => {
109
+ await sendJrpcRequest(connector, `eip155:${chainId}`, EIP_5792_METHODS.WALLET_SHOW_CALLS_STATUS, [batchId]);
90
110
  }
91
111
  };
92
112
  }