@web3auth/modal 10.0.0-beta.9 → 10.0.1-beta.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 (80) hide show
  1. package/README.md +2 -2
  2. package/dist/lib.cjs/packages/modal/src/config.js +1 -1
  3. package/dist/lib.cjs/packages/modal/src/connectors/coinbase-connector/index.js +12 -0
  4. package/dist/lib.cjs/packages/modal/src/modalManager.js +165 -92
  5. package/dist/lib.cjs/packages/modal/src/providers/ethereum-mpc-provider/index.js +12 -0
  6. package/dist/lib.cjs/packages/modal/src/providers/xrpl-provider/index.js +12 -0
  7. package/dist/lib.cjs/packages/modal/src/react/Web3AuthProvider.js +3 -1
  8. package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +23 -19
  9. package/dist/lib.cjs/packages/modal/src/react/hooks/useIdentityToken.js +3 -3
  10. package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3AuthConnect.js +17 -1
  11. package/dist/lib.cjs/packages/modal/src/react/solana/hooks/useSolanaWallet.js +1 -1
  12. package/dist/lib.cjs/packages/modal/src/react/wagmi/constants.js +16 -0
  13. package/dist/lib.cjs/packages/modal/src/react/wagmi/provider.js +12 -6
  14. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +36 -5
  15. package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +8 -5
  16. package/dist/lib.cjs/packages/modal/src/ui/components/Footer/Footer.js +6 -9
  17. package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +23 -4
  18. package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +6 -2
  19. package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +2 -2
  20. package/dist/lib.cjs/packages/modal/src/ui/context/AnalyticsContext.js +9 -0
  21. package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
  22. package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +42 -15
  23. package/dist/lib.cjs/packages/modal/src/utils.js +22 -0
  24. package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +11 -2
  25. package/dist/lib.cjs/packages/modal/src/vue/composables/useIdentityToken.js +3 -3
  26. package/dist/lib.cjs/packages/modal/src/vue/composables/useManageMFA.js +1 -1
  27. package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthConnect.js +17 -1
  28. package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSolanaWallet.js +17 -14
  29. package/dist/lib.cjs/packages/modal/src/vue/wagmi/constants.js +16 -0
  30. package/dist/lib.cjs/packages/modal/src/vue/wagmi/provider.js +32 -13
  31. package/dist/lib.cjs/types/connectors/coinbase-connector/index.d.ts +1 -0
  32. package/dist/lib.cjs/types/interface.d.ts +0 -3
  33. package/dist/lib.cjs/types/modalManager.d.ts +5 -4
  34. package/dist/lib.cjs/types/providers/ethereum-mpc-provider/index.d.ts +1 -0
  35. package/dist/lib.cjs/types/providers/xrpl-provider/index.d.ts +1 -0
  36. package/dist/lib.cjs/types/react/Web3AuthProvider.d.ts +1 -1
  37. package/dist/lib.cjs/types/react/hooks/useIdentityToken.d.ts +2 -2
  38. package/dist/lib.cjs/types/react/hooks/useWeb3AuthConnect.d.ts +2 -1
  39. package/dist/lib.cjs/types/react/interfaces.d.ts +2 -1
  40. package/dist/lib.cjs/types/react/wagmi/constants.d.ts +43 -0
  41. package/dist/lib.cjs/types/ui/context/AnalyticsContext.d.ts +4 -0
  42. package/dist/lib.cjs/types/ui/interfaces.d.ts +4 -2
  43. package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -0
  44. package/dist/lib.cjs/types/utils.d.ts +17 -0
  45. package/dist/lib.cjs/types/vue/composables/useIdentityToken.d.ts +1 -1
  46. package/dist/lib.cjs/types/vue/composables/useWeb3AuthConnect.d.ts +2 -1
  47. package/dist/lib.cjs/types/vue/wagmi/constants.d.ts +43 -0
  48. package/dist/lib.cjs/types/vue/wagmi/provider.d.ts +1 -0
  49. package/dist/lib.esm/packages/modal/src/config.js +1 -1
  50. package/dist/lib.esm/packages/modal/src/connectors/coinbase-connector/index.js +1 -0
  51. package/dist/lib.esm/packages/modal/src/modalManager.js +173 -98
  52. package/dist/lib.esm/packages/modal/src/providers/ethereum-mpc-provider/index.js +1 -0
  53. package/dist/lib.esm/packages/modal/src/providers/xrpl-provider/index.js +1 -0
  54. package/dist/lib.esm/packages/modal/src/react/Web3AuthProvider.js +3 -1
  55. package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +25 -21
  56. package/dist/lib.esm/packages/modal/src/react/hooks/useIdentityToken.js +3 -3
  57. package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3AuthConnect.js +17 -1
  58. package/dist/lib.esm/packages/modal/src/react/solana/hooks/useSolanaWallet.js +1 -1
  59. package/dist/lib.esm/packages/modal/src/react/wagmi/constants.js +14 -0
  60. package/dist/lib.esm/packages/modal/src/react/wagmi/provider.js +14 -9
  61. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +40 -6
  62. package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainFilter/ConnectWalletChainFilter.js +8 -5
  63. package/dist/lib.esm/packages/modal/src/ui/components/Footer/Footer.js +6 -9
  64. package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +24 -5
  65. package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +6 -2
  66. package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +2 -2
  67. package/dist/lib.esm/packages/modal/src/ui/context/AnalyticsContext.js +7 -0
  68. package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
  69. package/dist/lib.esm/packages/modal/src/ui/loginModal.js +41 -14
  70. package/dist/lib.esm/packages/modal/src/utils.js +20 -0
  71. package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +12 -3
  72. package/dist/lib.esm/packages/modal/src/vue/composables/useIdentityToken.js +3 -3
  73. package/dist/lib.esm/packages/modal/src/vue/composables/useManageMFA.js +1 -1
  74. package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthConnect.js +17 -1
  75. package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSolanaWallet.js +17 -14
  76. package/dist/lib.esm/packages/modal/src/vue/wagmi/constants.js +14 -0
  77. package/dist/lib.esm/packages/modal/src/vue/wagmi/provider.js +35 -16
  78. package/dist/modal.umd.min.js +1 -1
  79. package/dist/modal.umd.min.js.LICENSE.txt +4 -6
  80. package/package.json +41 -16
@@ -1,17 +1,21 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
4
+ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
3
5
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
6
  var jsxRuntime = require('react/jsx-runtime');
5
7
  require('./css/index.css.js');
6
8
  var auth = require('@web3auth/auth');
7
9
  var noModal = require('@web3auth/no-modal');
8
10
  var client = require('react-dom/client');
11
+ var utils = require('../utils.js');
9
12
  var Widget = require('./components/Widget/Widget.js');
10
13
  var constants = require('./constants.js');
14
+ var AnalyticsContext = require('./context/AnalyticsContext.js');
11
15
  var ThemeContext = require('./context/ThemeContext.js');
12
16
  var interfaces = require('./interfaces.js');
13
17
  var localeImport = require('./localeImport.js');
14
- var utils = require('./utils.js');
18
+ var utils$1 = require('./utils.js');
15
19
 
16
20
  function createWrapperForModal(parentZIndex) {
17
21
  const existingWrapper = document.getElementById("w3a-parent-container");
@@ -39,6 +43,7 @@ class LoginModal {
39
43
  _defineProperty(this, "walletRegistry", void 0);
40
44
  _defineProperty(this, "callbacks", void 0);
41
45
  _defineProperty(this, "externalWalletsConfig", void 0);
46
+ _defineProperty(this, "analytics", void 0);
42
47
  _defineProperty(this, "initModal", async () => {
43
48
  const darkState = {
44
49
  isDark: this.isDark
@@ -144,17 +149,22 @@ class LoginModal {
144
149
  const root = client.createRoot(container);
145
150
  root.render(jsxRuntime.jsx(ThemeContext.ThemedContext.Provider, {
146
151
  value: darkState,
147
- children: jsxRuntime.jsx(Widget, {
148
- stateListener: this.stateEmitter,
149
- appLogo: darkState.isDark ? this.uiConfig.logoDark : this.uiConfig.logoLight,
150
- appName: this.uiConfig.appName,
151
- chainNamespaces: this.chainNamespaces,
152
- walletRegistry: this.walletRegistry,
153
- handleShowExternalWallets: this.handleShowExternalWallets,
154
- handleExternalWalletClick: this.handleExternalWalletClick,
155
- handleSocialLoginClick: this.handleSocialLoginClick,
156
- closeModal: this.closeModal,
157
- uiConfig: this.uiConfig
152
+ children: jsxRuntime.jsx(AnalyticsContext.AnalyticsContext.Provider, {
153
+ value: {
154
+ analytics: this.analytics
155
+ },
156
+ children: jsxRuntime.jsx(Widget, {
157
+ stateListener: this.stateEmitter,
158
+ appLogo: darkState.isDark ? this.uiConfig.logoDark : this.uiConfig.logoLight,
159
+ appName: this.uiConfig.appName,
160
+ chainNamespaces: this.chainNamespaces,
161
+ walletRegistry: this.walletRegistry,
162
+ handleShowExternalWallets: this.handleShowExternalWallets,
163
+ handleExternalWalletClick: this.handleExternalWalletClick,
164
+ handleSocialLoginClick: this.handleSocialLoginClick,
165
+ closeModal: this.closeModal,
166
+ uiConfig: this.uiConfig
167
+ })
158
168
  })
159
169
  }));
160
170
  const isDefaultColors = ((_this$uiConfig = this.uiConfig) === null || _this$uiConfig === void 0 || (_this$uiConfig = _this$uiConfig.theme) === null || _this$uiConfig === void 0 ? void 0 : _this$uiConfig.primary) === constants.DEFAULT_PRIMARY_COLOR && ((_this$uiConfig$theme = this.uiConfig.theme) === null || _this$uiConfig$theme === void 0 ? void 0 : _this$uiConfig$theme.onPrimary) === constants.DEFAULT_ON_PRIMARY_COLOR;
@@ -185,18 +195,26 @@ class LoginModal {
185
195
  });
186
196
  });
187
197
  _defineProperty(this, "open", () => {
198
+ var _this$analytics, _this$walletRegistry, _this$walletRegistry2;
188
199
  this.setState({
189
200
  modalVisibility: true
190
201
  });
202
+ (_this$analytics = this.analytics) === null || _this$analytics === void 0 || _this$analytics.track(noModal.ANALYTICS_EVENTS.LOGIN_MODAL_OPENED, _objectSpread(_objectSpread({
203
+ chain_namespaces: this.chainNamespaces,
204
+ wallet_registry_count: Object.keys((_this$walletRegistry = this.walletRegistry) === null || _this$walletRegistry === void 0 ? void 0 : _this$walletRegistry.default).length + Object.keys((_this$walletRegistry2 = this.walletRegistry) === null || _this$walletRegistry2 === void 0 ? void 0 : _this$walletRegistry2.others).length,
205
+ external_wallet_connectors: Object.keys(this.externalWalletsConfig || {})
206
+ }, noModal.getWhitelabelAnalyticsProperties(this.uiConfig)), utils.getLoginModalAnalyticsProperties(this.uiConfig)));
191
207
  if (this.callbacks.onModalVisibility) {
192
208
  this.callbacks.onModalVisibility(true);
193
209
  }
194
210
  });
195
211
  _defineProperty(this, "closeModal", () => {
212
+ var _this$analytics2;
196
213
  this.setState({
197
214
  modalVisibility: false,
198
215
  externalWalletsVisibility: false
199
216
  });
217
+ (_this$analytics2 = this.analytics) === null || _this$analytics2 === void 0 || _this$analytics2.track(noModal.ANALYTICS_EVENTS.LOGIN_MODAL_CLOSED);
200
218
  if (this.callbacks.onModalVisibility) {
201
219
  this.callbacks.onModalVisibility(false);
202
220
  }
@@ -229,11 +247,18 @@ class LoginModal {
229
247
  }
230
248
  });
231
249
  _defineProperty(this, "handleSocialLoginClick", params => {
250
+ var _this$analytics3;
232
251
  noModal.log.info("social login clicked", params);
233
252
  const {
234
253
  connector,
235
254
  loginParams
236
255
  } = params;
256
+ (_this$analytics3 = this.analytics) === null || _this$analytics3 === void 0 || _this$analytics3.track(noModal.ANALYTICS_EVENTS.SOCIAL_LOGIN_SELECTED, {
257
+ connector,
258
+ auth_connection: loginParams.authConnection,
259
+ auth_connection_id: loginParams.authConnectionId,
260
+ group_auth_connection_id: loginParams.groupedAuthConnectionId
261
+ });
237
262
  if (this.callbacks.onSocialLogin) {
238
263
  this.callbacks.onSocialLogin({
239
264
  connector,
@@ -278,7 +303,7 @@ class LoginModal {
278
303
  listener.on(noModal.CONNECTOR_EVENTS.CONNECTED, data => {
279
304
  noModal.log.debug("connected with connector", data);
280
305
  // only show success if not being reconnected again.
281
- if (!data.reconnected) {
306
+ if (!data.reconnected && data.loginMode === noModal.LOGIN_MODE.MODAL) {
282
307
  this.setState({
283
308
  status: interfaces.MODAL_STATUS.CONNECTED,
284
309
  modalVisibility: true,
@@ -291,8 +316,9 @@ class LoginModal {
291
316
  }
292
317
  });
293
318
  // TODO: send connector name in error
294
- listener.on(noModal.CONNECTOR_EVENTS.ERRORED, error => {
319
+ listener.on(noModal.CONNECTOR_EVENTS.ERRORED, (error, loginMode) => {
295
320
  noModal.log.error("error", error, error.message);
321
+ if (loginMode === noModal.LOGIN_MODE.NO_MODAL) return;
296
322
  if (error.code === 5000) {
297
323
  if (this.uiConfig.displayErrorsOnModal) this.setState({
298
324
  modalVisibility: true,
@@ -328,7 +354,7 @@ class LoginModal {
328
354
  if (!_uiConfig.appName) this.uiConfig.appName = "Web3Auth";
329
355
  if (!_uiConfig.loginGridCol) this.uiConfig.loginGridCol = 3;
330
356
  if (!_uiConfig.primaryButton) this.uiConfig.primaryButton = "socialLogin";
331
- if (!_uiConfig.defaultLanguage) this.uiConfig.defaultLanguage = utils.getUserLanguage(_uiConfig.defaultLanguage);
357
+ if (!_uiConfig.defaultLanguage) this.uiConfig.defaultLanguage = utils$1.getUserLanguage(_uiConfig.defaultLanguage);
332
358
  if (!_uiConfig.widgetType) this.uiConfig.widgetType = noModal.WIDGET_TYPE.MODAL;
333
359
  if (_uiConfig.widgetType === noModal.WIDGET_TYPE.EMBED && !_uiConfig.targetId) {
334
360
  noModal.log.error("targetId is required for embed widget");
@@ -338,6 +364,7 @@ class LoginModal {
338
364
  this.chainNamespaces = _uiConfig.chainNamespaces;
339
365
  this.walletRegistry = _uiConfig.walletRegistry;
340
366
  this.callbacks = callbacks;
367
+ this.analytics = _uiConfig.analytics;
341
368
  this.subscribeCoreEvents(this.uiConfig.connectorListener);
342
369
  }
343
370
  get isDark() {
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ const getLoginModalAnalyticsProperties = uiConfig => {
4
+ return {
5
+ ui_modal_login_methods_order: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.loginMethodsOrder,
6
+ ui_modal_z_index: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.modalZIndex,
7
+ ui_modal_display_errors_on_modal: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.displayErrorsOnModal,
8
+ ui_modal_login_grid_col: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.loginGridCol,
9
+ ui_modal_primary_button: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.primaryButton,
10
+ ui_modal_widget_type: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.widgetType,
11
+ ui_modal_target_id_used: Boolean(uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.targetId),
12
+ ui_modal_logo_alignment: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.logoAlignment,
13
+ ui_modal_border_radius_type: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.borderRadiusType,
14
+ ui_modal_button_radius_type: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.buttonRadiusType,
15
+ ui_modal_sign_in_methods: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.signInMethods,
16
+ ui_modal_add_previous_login_hint: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.addPreviousLoginHint,
17
+ ui_modal_display_installed_external_wallets: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.displayInstalledExternalWallets,
18
+ ui_modal_display_external_wallets_count: uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.displayExternalWalletsCount
19
+ };
20
+ };
21
+
22
+ exports.getLoginModalAnalyticsProperties = getLoginModalAnalyticsProperties;
@@ -46,6 +46,9 @@ const Web3AuthProvider = vue.defineComponent({
46
46
  web3AuthOptions
47
47
  } = newConfig;
48
48
  const web3AuthInstance = new modalManager.Web3Auth(web3AuthOptions);
49
+ web3AuthInstance.setAnalyticsProperties({
50
+ integration_type: noModal.ANALYTICS_INTEGRATION_TYPE.VUE_COMPOSABLES
51
+ });
49
52
  web3Auth.value = web3AuthInstance;
50
53
  }, {
51
54
  immediate: true
@@ -60,7 +63,7 @@ const Web3AuthProvider = vue.defineComponent({
60
63
  try {
61
64
  initError.value = null;
62
65
  isInitializing.value = true;
63
- await newWeb3Auth.initModal({
66
+ await newWeb3Auth.init({
64
67
  signal: controller.signal
65
68
  });
66
69
  } catch (error) {
@@ -99,7 +102,11 @@ const Web3AuthProvider = vue.defineComponent({
99
102
  status.value = web3Auth.value.status;
100
103
  };
101
104
  const errorListener = () => {
102
- status.value = noModal.CONNECTOR_EVENTS.ERRORED;
105
+ status.value = web3Auth.value.status;
106
+ if (isConnected.value) {
107
+ isConnected.value = false;
108
+ provider.value = null;
109
+ }
103
110
  };
104
111
  const mfaEnabledListener = () => {
105
112
  isMFAEnabled.value = true;
@@ -112,6 +119,7 @@ const Web3AuthProvider = vue.defineComponent({
112
119
  prevWeb3Auth.off(noModal.CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
113
120
  prevWeb3Auth.off(noModal.CONNECTOR_EVENTS.CONNECTING, connectingListener);
114
121
  prevWeb3Auth.off(noModal.CONNECTOR_EVENTS.ERRORED, errorListener);
122
+ prevWeb3Auth.off(noModal.CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
115
123
  prevWeb3Auth.off(noModal.CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
116
124
  }
117
125
  if (newWeb3Auth && newWeb3Auth !== prevWeb3Auth) {
@@ -123,6 +131,7 @@ const Web3AuthProvider = vue.defineComponent({
123
131
  newWeb3Auth.on(noModal.CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
124
132
  newWeb3Auth.on(noModal.CONNECTOR_EVENTS.CONNECTING, connectingListener);
125
133
  newWeb3Auth.on(noModal.CONNECTOR_EVENTS.ERRORED, errorListener);
134
+ newWeb3Auth.on(noModal.CONNECTOR_EVENTS.REHYDRATION_ERROR, errorListener);
126
135
  newWeb3Auth.on(noModal.CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
127
136
  }
128
137
  }, {
@@ -12,12 +12,12 @@ const useIdentityToken = () => {
12
12
  const loading = vue.ref(false);
13
13
  const error = vue.ref(null);
14
14
  const token = vue.ref(null);
15
- const authenticateUser = async () => {
15
+ const getIdentityToken = async () => {
16
16
  try {
17
17
  if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
18
18
  error.value = null;
19
19
  loading.value = true;
20
- const result = await web3Auth.value.authenticateUser();
20
+ const result = await web3Auth.value.getIdentityToken();
21
21
  if (result !== null && result !== void 0 && result.idToken) {
22
22
  token.value = result.idToken;
23
23
  }
@@ -37,7 +37,7 @@ const useIdentityToken = () => {
37
37
  loading,
38
38
  error,
39
39
  token,
40
- authenticateUser
40
+ getIdentityToken
41
41
  };
42
42
  };
43
43
 
@@ -15,7 +15,7 @@ const useManageMFA = () => {
15
15
  if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
16
16
  error.value = null;
17
17
  loading.value = true;
18
- await web3Auth.value.enableMFA();
18
+ await web3Auth.value.manageMFA();
19
19
  } catch (err) {
20
20
  error.value = err;
21
21
  } finally {
@@ -38,12 +38,28 @@ const useWeb3AuthConnect = () => {
38
38
  loading.value = false;
39
39
  }
40
40
  };
41
+ const connectTo = async (connectorType, loginParams) => {
42
+ try {
43
+ if (!web3Auth.value) throw noModal.WalletInitializationError.notReady();
44
+ error.value = null;
45
+ loading.value = true;
46
+ const localProvider = await web3Auth.value.connectTo(connectorType, loginParams);
47
+ connectorName.value = web3Auth.value.connectedConnectorName;
48
+ return localProvider;
49
+ } catch (err) {
50
+ error.value = err;
51
+ return null;
52
+ } finally {
53
+ loading.value = false;
54
+ }
55
+ };
41
56
  return {
42
57
  isConnected,
43
58
  loading,
44
59
  error,
45
60
  connectorName,
46
- connect
61
+ connect,
62
+ connectTo
47
63
  };
48
64
  };
49
65
 
@@ -14,30 +14,33 @@ const useSolanaWallet = () => {
14
14
  const accounts = vue.ref([]);
15
15
  const solanaWallet = vue.shallowRef(null);
16
16
  const connection = vue.shallowRef(null);
17
- vue.watch(provider, async newVal => {
18
- var _web3Auth$value, _accounts$value;
17
+ const setupWallet = async () => {
18
+ var _web3Auth$value, _web3Auth$value2;
19
19
  if (!((_web3Auth$value = web3Auth.value) !== null && _web3Auth$value !== void 0 && (_web3Auth$value = _web3Auth$value.currentChain) !== null && _web3Auth$value !== void 0 && _web3Auth$value.chainNamespace) || web3Auth.value.currentChain.chainNamespace !== noModal.CHAIN_NAMESPACES.SOLANA) {
20
20
  return;
21
21
  }
22
+ solanaWallet.value = new noModal.SolanaWallet(provider.value);
23
+ const result = await solanaWallet.value.getAccounts();
24
+ if ((result === null || result === void 0 ? void 0 : result.length) > 0) {
25
+ accounts.value = result;
26
+ }
27
+ connection.value = new web3_js.Connection((_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || (_web3Auth$value2 = _web3Auth$value2.currentChain) === null || _web3Auth$value2 === void 0 ? void 0 : _web3Auth$value2.rpcTarget);
28
+ };
29
+ if (provider.value && !solanaWallet.value) {
30
+ setupWallet();
31
+ }
32
+ vue.watch(provider, async newVal => {
22
33
  if (!newVal && solanaWallet.value) {
23
34
  solanaWallet.value = null;
24
35
  accounts.value = null;
25
36
  connection.value = null;
26
37
  return;
27
38
  }
28
- if (!solanaWallet.value) {
29
- solanaWallet.value = new noModal.SolanaWallet(newVal);
30
- }
31
- if (solanaWallet.value && ((_accounts$value = accounts.value) === null || _accounts$value === void 0 ? void 0 : _accounts$value.length) === 0) {
32
- const result = await solanaWallet.value.requestAccounts();
33
- if ((result === null || result === void 0 ? void 0 : result.length) > 0) {
34
- accounts.value = result;
35
- }
36
- }
37
- if (solanaWallet.value && !connection.value) {
38
- var _web3Auth$value2;
39
- connection.value = new web3_js.Connection((_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || (_web3Auth$value2 = _web3Auth$value2.currentChain) === null || _web3Auth$value2 === void 0 ? void 0 : _web3Auth$value2.rpcTarget);
39
+ if (newVal && !solanaWallet.value) {
40
+ setupWallet();
40
41
  }
42
+ }, {
43
+ immediate: true
41
44
  });
42
45
  return {
43
46
  solanaWallet,
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var vue = require('@wagmi/vue');
4
+ var chains = require('@wagmi/vue/chains');
5
+
6
+ const defaultWagmiConfig = vue.createConfig({
7
+ chains: [chains.mainnet],
8
+ connectors: [],
9
+ // or your basic wallets
10
+ ssr: true,
11
+ transports: {
12
+ [chains.mainnet.id]: vue.http(chains.mainnet.rpcUrls.default.http[0])
13
+ }
14
+ });
15
+
16
+ exports.defaultWagmiConfig = defaultWagmiConfig;
@@ -4,12 +4,14 @@ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
4
4
  var core = require('@wagmi/core');
5
5
  var vue$1 = require('@wagmi/vue');
6
6
  var connectors = require('@wagmi/vue/connectors');
7
+ var auth = require('@web3auth/auth');
7
8
  var noModal = require('@web3auth/no-modal');
8
9
  var viem = require('viem');
9
10
  var vue = require('vue');
10
11
  require('@web3auth/no-modal/vue');
11
12
  var useWeb3Auth = require('../composables/useWeb3Auth.js');
12
13
  var useWeb3AuthDisconnect = require('../composables/useWeb3AuthDisconnect.js');
14
+ var constants = require('./constants.js');
13
15
 
14
16
  const WEB3AUTH_CONNECTOR_ID = "web3auth";
15
17
  // Helper to initialize connectors for the given wallets
@@ -70,6 +72,9 @@ const Web3AuthWagmiProvider = vue.defineComponent({
70
72
  disconnect
71
73
  } = useWeb3AuthDisconnect.useWeb3AuthDisconnect();
72
74
  const wagmiConfig = vue$1.useConfig();
75
+ const {
76
+ reconnect
77
+ } = vue$1.useReconnect();
73
78
  vue$1.useAccountEffect({
74
79
  onDisconnect: async () => {
75
80
  noModal.log.info("Disconnected from wagmi");
@@ -84,6 +89,7 @@ const Web3AuthWagmiProvider = vue.defineComponent({
84
89
  throw new Error("Failed to setup connector");
85
90
  }
86
91
  await connectWeb3AuthWithWagmi(connector, wagmiConfig);
92
+ reconnect();
87
93
  } else if (!newIsConnected) {
88
94
  if (wagmiConfig.state.status === "connected") {
89
95
  await disconnectWeb3AuthFromWagmi(wagmiConfig);
@@ -133,7 +139,8 @@ const WagmiProvider = vue.defineComponent({
133
139
  web3Auth,
134
140
  isInitialized
135
141
  } = useWeb3Auth.useWeb3Auth();
136
- const finalConfig = vue.shallowRef(null);
142
+ const finalConfig = vue.shallowRef(constants.defaultWagmiConfig);
143
+ const configKey = vue.ref(auth.randomId());
137
144
  const defineWagmiConfig = () => {
138
145
  var _web3Auth$value;
139
146
  const configParams = _objectSpread(_objectSpread({
@@ -149,7 +156,8 @@ const WagmiProvider = vue.defineComponent({
149
156
  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) {
150
157
  var _web3Auth$value$curre;
151
158
  const defaultChainId = (_web3Auth$value$curre = web3Auth.value.currentChain) === null || _web3Auth$value$curre === void 0 ? void 0 : _web3Auth$value$curre.chainId;
152
- const chains = web3Auth.value.coreOptions.chains;
159
+ const chains = web3Auth.value.coreOptions.chains.filter(chain => chain.chainNamespace === noModal.CHAIN_NAMESPACES.EIP155);
160
+ if (chains.length === 0) throw noModal.WalletInitializationError.invalidParams("No valid chains found in web3auth config for wagmi.");
153
161
  chains.forEach(chain => {
154
162
  const wagmiChain = viem.defineChain({
155
163
  id: Number.parseInt(chain.chainId, 16),
@@ -183,29 +191,40 @@ const WagmiProvider = vue.defineComponent({
183
191
  });
184
192
  configParams.chains = [wagmiChains[0], ...wagmiChains.slice(1)];
185
193
  }
186
- if (!configParams.chains) return;
187
194
  return vue$1.createConfig(configParams);
188
195
  };
189
- vue.watch(isInitialized, newIsInitialized => {
190
- if (newIsInitialized && !finalConfig.value) {
196
+ const hydrateWagmiConfig = () => {
197
+ if (finalConfig.value) {
198
+ core.hydrate(finalConfig.value, _objectSpread({
199
+ reconnectOnMount: false
200
+ }, props.config));
201
+ }
202
+ };
203
+ vue.watch(isInitialized, (newIsInitialized, prevIsInitialized) => {
204
+ var _web3Auth$value2;
205
+ (_web3Auth$value2 = web3Auth.value) === null || _web3Auth$value2 === void 0 || _web3Auth$value2.setAnalyticsProperties({
206
+ wagmi_enabled: true
207
+ });
208
+ if (newIsInitialized && !prevIsInitialized) {
191
209
  finalConfig.value = defineWagmiConfig();
192
- if (finalConfig.value) {
193
- core.hydrate(finalConfig.value, _objectSpread({
194
- reconnectOnMount: false
195
- }, props.config));
196
- }
210
+ hydrateWagmiConfig();
211
+ configKey.value = auth.randomId();
197
212
  }
198
213
  }, {
199
214
  immediate: true
200
215
  });
216
+ if (!isInitialized.value) {
217
+ hydrateWagmiConfig();
218
+ }
201
219
  return {
202
- finalConfig
220
+ finalConfig,
221
+ configKey
203
222
  };
204
223
  },
205
224
  render() {
206
- if (!this.finalConfig) return null;
207
225
  return vue.h(Web3AuthWagmiInnerProvider, {
208
- config: this.finalConfig
226
+ config: this.finalConfig,
227
+ key: this.configKey
209
228
  }, {
210
229
  default: () => {
211
230
  var _this$$slots$default3, _this$$slots;
@@ -0,0 +1 @@
1
+ export * from "@web3auth/no-modal/connectors/coinbase-connector";
@@ -7,8 +7,5 @@ export interface ConnectorsModalConfig {
7
7
  hideWalletDiscovery?: boolean;
8
8
  }
9
9
  export interface IWeb3AuthModal extends IWeb3Auth {
10
- initModal(options?: {
11
- signal?: AbortSignal;
12
- }): Promise<void>;
13
10
  connect(): Promise<IProvider | null>;
14
11
  }
@@ -1,4 +1,4 @@
1
- import { type IProvider, type IWeb3AuthCoreOptions, Web3AuthNoModal } from "@web3auth/no-modal";
1
+ import { type IProvider, type IWeb3AuthCoreOptions, IWeb3AuthState, type ProjectConfig, Web3AuthNoModal } from "@web3auth/no-modal";
2
2
  import { type ConnectorsModalConfig, type IWeb3AuthModal } from "./interface";
3
3
  import { LoginModal, type UIConfig } from "./ui";
4
4
  export interface Web3AuthOptions extends IWeb3AuthCoreOptions {
@@ -15,14 +15,15 @@ export declare class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal
15
15
  loginModal: LoginModal;
16
16
  readonly options: Web3AuthOptions;
17
17
  private modalConfig;
18
- constructor(options: Web3AuthOptions);
19
- initModal(options?: {
18
+ constructor(options: Web3AuthOptions, initialState?: IWeb3AuthState);
19
+ init(options?: {
20
20
  signal?: AbortSignal;
21
21
  }): Promise<void>;
22
22
  connect(): Promise<IProvider | null>;
23
+ protected initUIConfig(projectConfig: ProjectConfig): void;
24
+ protected getInitializationTrackData(): Record<string, unknown>;
23
25
  private filterWalletRegistry;
24
26
  private getProjectAndWalletConfig;
25
- private initUIConfig;
26
27
  private initConnectors;
27
28
  private filterConnectors;
28
29
  private checkConnectorAvailability;
@@ -0,0 +1 @@
1
+ export * from "@web3auth/no-modal/providers/ethereum-mpc-provider";
@@ -0,0 +1 @@
1
+ export * from "@web3auth/no-modal/providers/xrpl-provider";
@@ -1,3 +1,3 @@
1
1
  import { PropsWithChildren } from "react";
2
2
  import { Web3AuthProviderProps } from "./interfaces";
3
- export declare function Web3AuthProvider({ config, children }: PropsWithChildren<Web3AuthProviderProps>): import("react").FunctionComponentElement<PropsWithChildren<Web3AuthProviderProps>>;
3
+ export declare function Web3AuthProvider({ config, initialState, children }: PropsWithChildren<Web3AuthProviderProps>): import("react").FunctionComponentElement<PropsWithChildren<Web3AuthProviderProps>>;
@@ -3,11 +3,11 @@ export interface IUseIdentityToken {
3
3
  loading: boolean;
4
4
  error: Web3AuthError | null;
5
5
  token: string | null;
6
- authenticateUser: () => Promise<string | null>;
6
+ getIdentityToken: () => Promise<string | null>;
7
7
  }
8
8
  export declare const useIdentityToken: () => {
9
9
  loading: boolean;
10
10
  error: Web3AuthError;
11
11
  token: string;
12
- authenticateUser: () => Promise<string>;
12
+ getIdentityToken: () => Promise<string>;
13
13
  };
@@ -1,9 +1,10 @@
1
- import type { IProvider, WALLET_CONNECTOR_TYPE, Web3AuthError } from "@web3auth/no-modal";
1
+ import type { IProvider, LoginParamMap, WALLET_CONNECTOR_TYPE, Web3AuthError } from "@web3auth/no-modal";
2
2
  export interface IUseWeb3AuthConnect {
3
3
  isConnected: boolean;
4
4
  loading: boolean;
5
5
  error: Web3AuthError | null;
6
6
  connectorName: WALLET_CONNECTOR_TYPE | null;
7
7
  connect(): Promise<IProvider | null>;
8
+ connectTo<T extends WALLET_CONNECTOR_TYPE>(connector: T, params?: LoginParamMap[T]): Promise<IProvider | null>;
8
9
  }
9
10
  export declare const useWeb3AuthConnect: () => IUseWeb3AuthConnect;
@@ -1,10 +1,11 @@
1
- import type { IBaseWeb3AuthHookContext, WalletServicesPluginType } from "@web3auth/no-modal";
1
+ import type { IBaseWeb3AuthHookContext, IWeb3AuthState, WalletServicesPluginType } from "@web3auth/no-modal";
2
2
  import type { Web3Auth, Web3AuthOptions } from "../modalManager";
3
3
  export type Web3AuthContextConfig = {
4
4
  web3AuthOptions: Web3AuthOptions;
5
5
  };
6
6
  export interface Web3AuthProviderProps {
7
7
  config: Web3AuthContextConfig;
8
+ initialState?: IWeb3AuthState;
8
9
  }
9
10
  export interface IWeb3AuthInnerContext extends IBaseWeb3AuthHookContext {
10
11
  web3Auth: Web3Auth | null;
@@ -0,0 +1,43 @@
1
+ export declare const defaultWagmiConfig: import("wagmi").Config<readonly [{
2
+ blockExplorers: {
3
+ readonly default: {
4
+ readonly name: "Etherscan";
5
+ readonly url: "https://etherscan.io";
6
+ readonly apiUrl: "https://api.etherscan.io/api";
7
+ };
8
+ };
9
+ contracts: {
10
+ readonly ensRegistry: {
11
+ readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
12
+ };
13
+ readonly ensUniversalResolver: {
14
+ readonly address: "0xce01f8eee7E479C928F8919abD53E553a36CeF67";
15
+ readonly blockCreated: 19258213;
16
+ };
17
+ readonly multicall3: {
18
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
19
+ readonly blockCreated: 14353601;
20
+ };
21
+ };
22
+ ensTlds?: readonly string[] | undefined;
23
+ id: 1;
24
+ name: "Ethereum";
25
+ nativeCurrency: {
26
+ readonly name: "Ether";
27
+ readonly symbol: "ETH";
28
+ readonly decimals: 18;
29
+ };
30
+ rpcUrls: {
31
+ readonly default: {
32
+ readonly http: readonly ["https://eth.merkle.io"];
33
+ };
34
+ };
35
+ sourceId?: number | undefined | undefined;
36
+ testnet?: boolean | undefined | undefined;
37
+ custom?: Record<string, unknown> | undefined;
38
+ fees?: import("viem").ChainFees<undefined> | undefined;
39
+ formatters?: undefined;
40
+ serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
41
+ }], {
42
+ 1: import("viem").HttpTransport<undefined, false>;
43
+ }, readonly []>;
@@ -0,0 +1,4 @@
1
+ import { type Analytics } from "@web3auth/no-modal";
2
+ export declare const AnalyticsContext: import("react").Context<{
3
+ analytics?: Analytics;
4
+ }>;
@@ -1,5 +1,5 @@
1
1
  import type { AUTH_CONNECTION_TYPE, BUILD_ENV_TYPE, EMAIL_FLOW_TYPE, ExtraLoginOptions, LANGUAGES, SafeEventEmitter, THEME_MODE_TYPE, WEB3AUTH_NETWORK_TYPE } from "@web3auth/auth";
2
- import { type AuthLoginParams, type BaseConnectorConfig, type ChainNamespaceType, type LoginMethodConfig, type LoginModalConfig, type UIConfig as CoreUIConfig, type WALLET_CONNECTOR_TYPE, type WalletRegistry, type WalletRegistryItem, type Web3AuthNoModalEvents } from "@web3auth/no-modal";
2
+ import { type Analytics, type AuthLoginParams, type BaseConnectorConfig, type ChainNamespaceType, type LoginMethodConfig, type LoginModalConfig, type UIConfig as CoreUIConfig, type WALLET_CONNECTOR_TYPE, type WalletRegistry, type WalletRegistryItem, type Web3AuthNoModalEvents } from "@web3auth/no-modal";
3
3
  export interface UIConfig extends CoreUIConfig, LoginModalConfig {
4
4
  /**
5
5
  * ID of the element to embed the widget into
@@ -38,7 +38,7 @@ export interface UIConfig extends CoreUIConfig, LoginModalConfig {
38
38
  primaryButton?: "externalLogin" | "socialLogin" | "emailLogin";
39
39
  connectorListener: SafeEventEmitter<Web3AuthNoModalEvents>;
40
40
  }
41
- export type ModalLoginParams = Pick<AuthLoginParams, "authConnection" | "authConnectionId" | "groupedAuthConnectionId" | "login_hint" | "extraLoginOptions"> & {
41
+ export type ModalLoginParams = Pick<AuthLoginParams, "authConnection" | "authConnectionId" | "groupedAuthConnectionId" | "loginHint" | "extraLoginOptions"> & {
42
42
  name: string;
43
43
  };
44
44
  export interface LoginModalProps extends UIConfig {
@@ -47,6 +47,7 @@ export interface LoginModalProps extends UIConfig {
47
47
  web3authClientId: string;
48
48
  web3authNetwork: WEB3AUTH_NETWORK_TYPE;
49
49
  authBuildEnv: BUILD_ENV_TYPE;
50
+ analytics: Analytics;
50
51
  }
51
52
  export interface LoginModalCallbacks {
52
53
  onInitExternalWallets: (params: {
@@ -117,6 +118,7 @@ export type ExternalButton = {
117
118
  displayName?: string;
118
119
  href?: string;
119
120
  icon?: string;
121
+ isInstalled?: boolean;
120
122
  hasInjectedWallet: boolean;
121
123
  hasWalletConnect: boolean;
122
124
  hasInstallLinks: boolean;
@@ -8,6 +8,7 @@ export declare class LoginModal {
8
8
  private walletRegistry;
9
9
  private callbacks;
10
10
  private externalWalletsConfig;
11
+ private analytics;
11
12
  constructor(uiConfig: LoginModalProps, callbacks: LoginModalCallbacks);
12
13
  get isDark(): boolean;
13
14
  initModal: () => Promise<void>;