@web3auth/modal 10.0.0-alpha.1 → 10.0.0-alpha.2

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 (106) hide show
  1. package/dist/lib.cjs/packages/modal/src/modalManager.js +19 -26
  2. package/dist/lib.cjs/packages/modal/src/ui/components/AdapterLoader.js +24 -24
  3. package/dist/lib.cjs/packages/modal/src/ui/components/Button/Button.js +3 -4
  4. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletButton.js +6 -6
  5. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletChainNamespace.js +91 -0
  6. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletConnect.js +12 -12
  7. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +14 -5
  8. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletHeader.js +9 -9
  9. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallet/ExternalWalletInstall.js +16 -16
  10. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +38 -37
  11. package/dist/lib.cjs/packages/modal/src/ui/components/Footer.js +6 -6
  12. package/dist/lib.cjs/packages/modal/src/ui/components/Header.js +17 -17
  13. package/dist/lib.cjs/packages/modal/src/ui/components/Icon.js +4 -4
  14. package/dist/lib.cjs/packages/modal/src/ui/components/Image.js +4 -4
  15. package/dist/lib.cjs/packages/modal/src/ui/components/Loader.js +11 -11
  16. package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +26 -26
  17. package/dist/lib.cjs/packages/modal/src/ui/components/SelfCustodyViaWeb3Auth.js +5 -5
  18. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +24 -17
  19. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +29 -25
  20. package/dist/lib.cjs/packages/modal/src/ui/components/WalletConnect.js +9 -9
  21. package/dist/lib.cjs/packages/modal/src/ui/config.js +2 -2
  22. package/dist/lib.cjs/packages/modal/src/ui/css/web3auth.css.js +1 -1
  23. package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +2 -0
  24. package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +2 -0
  25. package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +2 -0
  26. package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +2 -0
  27. package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +2 -0
  28. package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +2 -0
  29. package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +2 -0
  30. package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +2 -0
  31. package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +2 -0
  32. package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +2 -0
  33. package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +2 -4
  34. package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +18 -16
  35. package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +1 -2
  36. package/dist/lib.cjs/types/ui/components/ExternalWallet/ExternalWalletChainNamespace.d.ts +9 -0
  37. package/dist/{types → lib.cjs/types}/ui/components/ExternalWallet/ExternalWalletDetails.d.ts +2 -1
  38. package/dist/{types → lib.cjs/types}/ui/components/ExternalWallets.d.ts +4 -6
  39. package/dist/{types → lib.cjs/types}/ui/components/Modal.d.ts +1 -1
  40. package/dist/{types → lib.cjs/types}/ui/components/SocialLoginPasswordless.d.ts +3 -5
  41. package/dist/{types → lib.cjs/types}/ui/components/SocialLogins.d.ts +2 -6
  42. package/dist/lib.cjs/types/ui/config.d.ts +4 -0
  43. package/dist/{types → lib.cjs/types}/ui/interfaces.d.ts +10 -8
  44. package/dist/{types → lib.cjs/types}/ui/loginModal.d.ts +1 -1
  45. package/dist/lib.esm/packages/modal/src/modalManager.js +14 -6
  46. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletChainNamespace.js +90 -0
  47. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallet/ExternalWalletDetails.js +13 -1
  48. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +19 -14
  49. package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +10 -9
  50. package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +11 -4
  51. package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +16 -11
  52. package/dist/lib.esm/packages/modal/src/ui/config.js +3 -3
  53. package/dist/lib.esm/packages/modal/src/ui/css/web3auth.css.js +1 -1
  54. package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +2 -0
  55. package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +2 -0
  56. package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +2 -0
  57. package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +2 -0
  58. package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +2 -0
  59. package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +2 -0
  60. package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +2 -0
  61. package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +2 -0
  62. package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +2 -0
  63. package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +2 -0
  64. package/dist/lib.esm/packages/modal/src/ui/interfaces.js +2 -1
  65. package/dist/lib.esm/packages/modal/src/ui/loginModal.js +15 -10
  66. package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +1 -1
  67. package/dist/modal.umd.min.js +1 -1
  68. package/package.json +18 -18
  69. package/dist/modal.cjs.js +0 -5884
  70. package/dist/types/ui/config.d.ts +0 -4
  71. /package/dist/{types → lib.cjs/types}/config.d.ts +0 -0
  72. /package/dist/{types → lib.cjs/types}/index.d.ts +0 -0
  73. /package/dist/{types → lib.cjs/types}/interface.d.ts +0 -0
  74. /package/dist/{types → lib.cjs/types}/modalManager.d.ts +0 -0
  75. /package/dist/{types → lib.cjs/types}/react/Web3AuthProvider.d.ts +0 -0
  76. /package/dist/{types → lib.cjs/types}/react/context/Web3AuthInnerContext.d.ts +0 -0
  77. /package/dist/{types → lib.cjs/types}/react/context/index.d.ts +0 -0
  78. /package/dist/{types → lib.cjs/types}/react/hooks/index.d.ts +0 -0
  79. /package/dist/{types → lib.cjs/types}/react/hooks/useWeb3Auth.d.ts +0 -0
  80. /package/dist/{types → lib.cjs/types}/react/index.d.ts +0 -0
  81. /package/dist/{types → lib.cjs/types}/react/interfaces.d.ts +0 -0
  82. /package/dist/{types → lib.cjs/types}/ui/components/AdapterLoader.d.ts +0 -0
  83. /package/dist/{types → lib.cjs/types}/ui/components/Button/Button.d.ts +0 -0
  84. /package/dist/{types → lib.cjs/types}/ui/components/Button/index.d.ts +0 -0
  85. /package/dist/{types → lib.cjs/types}/ui/components/ExternalWallet/ExternalWalletButton.d.ts +0 -0
  86. /package/dist/{types → lib.cjs/types}/ui/components/ExternalWallet/ExternalWalletConnect.d.ts +0 -0
  87. /package/dist/{types → lib.cjs/types}/ui/components/ExternalWallet/ExternalWalletHeader.d.ts +0 -0
  88. /package/dist/{types → lib.cjs/types}/ui/components/ExternalWallet/ExternalWalletInstall.d.ts +0 -0
  89. /package/dist/{types → lib.cjs/types}/ui/components/Footer.d.ts +0 -0
  90. /package/dist/{types → lib.cjs/types}/ui/components/Header.d.ts +0 -0
  91. /package/dist/{types → lib.cjs/types}/ui/components/Icon.d.ts +0 -0
  92. /package/dist/{types → lib.cjs/types}/ui/components/Image.d.ts +0 -0
  93. /package/dist/{types → lib.cjs/types}/ui/components/Loader.d.ts +0 -0
  94. /package/dist/{types → lib.cjs/types}/ui/components/SelfCustodyViaWeb3Auth.d.ts +0 -0
  95. /package/dist/{types → lib.cjs/types}/ui/components/WalletConnect.d.ts +0 -0
  96. /package/dist/{types → lib.cjs/types}/ui/context/ThemeContext.d.ts +0 -0
  97. /package/dist/{types → lib.cjs/types}/ui/helper/countryData.d.ts +0 -0
  98. /package/dist/{types → lib.cjs/types}/ui/i18n/index.d.ts +0 -0
  99. /package/dist/{types → lib.cjs/types}/ui/index.d.ts +0 -0
  100. /package/dist/{types → lib.cjs/types}/ui/localeImport.d.ts +0 -0
  101. /package/dist/{types → lib.cjs/types}/ui/utils.d.ts +0 -0
  102. /package/dist/{types → lib.cjs/types}/vue/Web3AuthProvider.d.ts +0 -0
  103. /package/dist/{types → lib.cjs/types}/vue/composables/index.d.ts +0 -0
  104. /package/dist/{types → lib.cjs/types}/vue/composables/useWeb3Auth.d.ts +0 -0
  105. /package/dist/{types → lib.cjs/types}/vue/index.d.ts +0 -0
  106. /package/dist/{types → lib.cjs/types}/vue/interfaces.d.ts +0 -0
@@ -24,6 +24,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
24
24
  this.modalConfig = modalConfig;
25
25
  }
26
26
  async initModal(params) {
27
+ var _this$coreOptions$cha;
27
28
  super.checkInitRequirements();
28
29
  super.initCachedConnectorAndChainId();
29
30
  // get project config and wallet registry
@@ -34,19 +35,16 @@ class Web3Auth extends noModal.Web3AuthNoModal {
34
35
  this.options.uiConfig = deepmerge(noModal.cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
35
36
  if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = utils.getUserLanguage(this.options.uiConfig.defaultLanguage);
36
37
  if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
37
-
38
38
  // init login modal
39
39
  this.loginModal = new loginModal.LoginModal(_objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
40
40
  connectorListener: this,
41
- chainNamespace: this.currentChain.chainNamespace,
41
+ chainNamespaces: [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])],
42
42
  walletRegistry
43
43
  }));
44
44
  this.subscribeToLoginModalEvents();
45
45
  await this.loginModal.initModal();
46
-
47
46
  // setup common JRPC provider
48
47
  await this.setupCommonJRPCProvider();
49
-
50
48
  // initialize connectors
51
49
  this.on(noModal.CONNECTOR_EVENTS.CONNECTORS_UPDATED, ({
52
50
  connectors: newConnectors
@@ -58,7 +56,6 @@ class Web3Auth extends noModal.Web3AuthNoModal {
58
56
  await this.loadConnectors({
59
57
  projectConfig
60
58
  });
61
-
62
59
  // initialize plugins
63
60
  await this.initPlugins();
64
61
  }
@@ -92,7 +89,6 @@ class Web3Auth extends noModal.Web3AuthNoModal {
92
89
  noModal.log.error("Failed to fetch project configurations", e);
93
90
  throw noModal.WalletInitializationError.notReady("failed to fetch project configurations", e);
94
91
  }
95
-
96
92
  // get wallet registry
97
93
  let walletRegistry = {
98
94
  others: {},
@@ -117,7 +113,6 @@ class Web3Auth extends noModal.Web3AuthNoModal {
117
113
  }) {
118
114
  // filter connectors based on config
119
115
  const filteredConnectorNames = await this.filterConnectors(modalConfig, projectConfig);
120
-
121
116
  // initialize connectors based on availability
122
117
  const {
123
118
  hasInAppConnectors,
@@ -133,7 +128,6 @@ class Web3Auth extends noModal.Web3AuthNoModal {
133
128
  showExternalWalletsOnly: true
134
129
  });
135
130
  }
136
-
137
131
  // emit ready event if connector is ready
138
132
  if (this.status === noModal.CONNECTOR_STATUS.NOT_READY) {
139
133
  this.status = noModal.CONNECTOR_STATUS.READY;
@@ -152,8 +146,8 @@ class Web3Auth extends noModal.Web3AuthNoModal {
152
146
  [noModal.WALLET_CONNECTORS.AUTH]: {
153
147
  label: noModal.WALLET_CONNECTORS.AUTH,
154
148
  loginMethods: {
155
- [noModal.LOGIN_PROVIDER.SMS_PASSWORDLESS]: {
156
- name: noModal.LOGIN_PROVIDER.SMS_PASSWORDLESS,
149
+ [noModal.AUTH_CONNECTION.SMS_PASSWORDLESS]: {
150
+ name: noModal.AUTH_CONNECTION.SMS_PASSWORDLESS,
157
151
  showOnModal: smsOtpEnabled,
158
152
  showOnDesktop: smsOtpEnabled,
159
153
  showOnMobile: smsOtpEnabled
@@ -164,13 +158,12 @@ class Web3Auth extends noModal.Web3AuthNoModal {
164
158
  if (!((_params = params) !== null && _params !== void 0 && _params.modalConfig)) params = {
165
159
  modalConfig: {}
166
160
  };
167
- const localSmsOtpEnabled = (_params$modalConfig$W = params.modalConfig[noModal.WALLET_CONNECTORS.AUTH]) === null || _params$modalConfig$W === void 0 || (_params$modalConfig$W = _params$modalConfig$W.loginMethods) === null || _params$modalConfig$W === void 0 || (_params$modalConfig$W = _params$modalConfig$W[noModal.LOGIN_PROVIDER.SMS_PASSWORDLESS]) === null || _params$modalConfig$W === void 0 ? void 0 : _params$modalConfig$W.showOnModal;
161
+ const localSmsOtpEnabled = (_params$modalConfig$W = params.modalConfig[noModal.WALLET_CONNECTORS.AUTH]) === null || _params$modalConfig$W === void 0 || (_params$modalConfig$W = _params$modalConfig$W.loginMethods) === null || _params$modalConfig$W === void 0 || (_params$modalConfig$W = _params$modalConfig$W[noModal.AUTH_CONNECTION.SMS_PASSWORDLESS]) === null || _params$modalConfig$W === void 0 ? void 0 : _params$modalConfig$W.showOnModal;
168
162
  if (localSmsOtpEnabled === true && smsOtpEnabled === false) {
169
163
  throw noModal.WalletInitializationError.invalidParams("must enable sms otp on dashboard in order to utilise it");
170
164
  }
171
165
  params.modalConfig = deepmerge(connectorConfig, noModal.cloneDeep(params.modalConfig));
172
166
  }
173
-
174
167
  // merge default connectors with the custom configured connectors.
175
168
  const allConnectorNames = [...new Set([...Object.keys(this.modalConfig.connectors || {}), ...this.connectors.map(connector => connector.name)])];
176
169
  const connectorConfigurationPromises = allConnectorNames.map(async connectorName => {
@@ -187,11 +180,9 @@ class Web3Auth extends noModal.Web3AuthNoModal {
187
180
  connectorConfig = _objectSpread(_objectSpread({}, connectorConfig), params.modalConfig[connectorName]);
188
181
  }
189
182
  this.modalConfig.connectors[connectorName] = connectorConfig;
190
-
191
183
  // check if connector is configured/added by user and exist in connectors map.
192
184
  const connector = this.getConnector(connectorName);
193
185
  noModal.log.debug("connector config", connectorName, (_this$modalConfig$con2 = this.modalConfig.connectors) === null || _this$modalConfig$con2 === void 0 ? void 0 : _this$modalConfig$con2[connectorName].showOnModal, connector);
194
-
195
186
  // if connector is not custom configured then check if it is available in default connectors.
196
187
  // and if connector is not hidden by user
197
188
  if (!connector && (_this$modalConfig$con3 = this.modalConfig.connectors) !== null && _this$modalConfig$con3 !== void 0 && _this$modalConfig$con3[connectorName].showOnModal) {
@@ -224,22 +215,21 @@ class Web3Auth extends noModal.Web3AuthNoModal {
224
215
  // currently all default in app and external wallets can be hidden or shown based on config.
225
216
  // check if in app connectors are available
226
217
  const hasInAppConnectors = this.connectors.some(connector => {
227
- var _this$modalConfig$con8, _this$modalConfig$con9, _connector$name;
218
+ var _this$modalConfig$con8, _this$modalConfig$con9, _this$modalConfig$con10;
228
219
  if (connector.type !== noModal.CONNECTOR_CATEGORY.IN_APP) return false;
229
220
  if (((_this$modalConfig$con8 = this.modalConfig.connectors) === null || _this$modalConfig$con8 === void 0 || (_this$modalConfig$con8 = _this$modalConfig$con8[connector.name]) === null || _this$modalConfig$con8 === void 0 ? void 0 : _this$modalConfig$con8.showOnModal) !== true) return false;
230
221
  if (!((_this$modalConfig$con9 = this.modalConfig.connectors) !== null && _this$modalConfig$con9 !== void 0 && (_this$modalConfig$con9 = _this$modalConfig$con9[connector.name]) !== null && _this$modalConfig$con9 !== void 0 && _this$modalConfig$con9.loginMethods)) return true;
231
- const mergedLoginMethods = utils.getConnectorSocialLogins(connector.name, (_connector$name = this.modalConfig.connectors[connector.name]) === null || _connector$name === void 0 ? void 0 : _connector$name.loginMethods);
222
+ const mergedLoginMethods = utils.getConnectorSocialLogins(connector.name, (_this$modalConfig$con10 = this.modalConfig.connectors[connector.name]) === null || _this$modalConfig$con10 === void 0 ? void 0 : _this$modalConfig$con10.loginMethods);
232
223
  if (Object.values(mergedLoginMethods).some(method => method.showOnModal)) return true;
233
224
  return false;
234
225
  });
235
226
  noModal.log.debug(hasInAppConnectors, this.connectors, connectorNames, "hasInAppWallets");
236
-
237
227
  // check if external connectors are available
238
228
  const hasExternalConnectors = connectorNames.some(connectorName => {
239
- var _this$getConnector, _this$modalConfig$con10;
229
+ var _this$getConnector, _this$modalConfig$con11;
240
230
  // if wallet connect connector is available but hideWalletDiscovery is true then don't consider it as external wallet
241
231
  if (connectorName === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2 && modalConfig !== null && modalConfig !== void 0 && modalConfig.hideWalletDiscovery) return false;
242
- return ((_this$getConnector = this.getConnector(connectorName)) === null || _this$getConnector === void 0 ? void 0 : _this$getConnector.type) === noModal.CONNECTOR_CATEGORY.EXTERNAL && ((_this$modalConfig$con10 = this.modalConfig.connectors) === null || _this$modalConfig$con10 === void 0 ? void 0 : _this$modalConfig$con10[connectorName].showOnModal);
232
+ return ((_this$getConnector = this.getConnector(connectorName)) === null || _this$getConnector === void 0 ? void 0 : _this$getConnector.type) === noModal.CONNECTOR_CATEGORY.EXTERNAL && ((_this$modalConfig$con11 = this.modalConfig.connectors) === null || _this$modalConfig$con11 === void 0 ? void 0 : _this$modalConfig$con11[connectorName].showOnModal);
243
233
  });
244
234
  return {
245
235
  hasInAppConnectors,
@@ -253,10 +243,8 @@ class Web3Auth extends noModal.Web3AuthNoModal {
253
243
  try {
254
244
  // skip if connector is already initialized
255
245
  if (connector.status !== noModal.CONNECTOR_STATUS.NOT_READY) return;
256
-
257
246
  // only initialize a external connectors here if it is a cached connector.
258
247
  if (this.cachedConnector !== connectorName && connector.type === noModal.CONNECTOR_CATEGORY.EXTERNAL) return;
259
-
260
248
  // in-app wallets or cached wallet (being connected or already connected) are initialized first.
261
249
  // if connector is configured then only initialize in app or cached connector.
262
250
  // external wallets are initialized on INIT_EXTERNAL_WALLET event.
@@ -266,13 +254,12 @@ class Web3Auth extends noModal.Web3AuthNoModal {
266
254
  autoConnect: this.cachedConnector === connectorName,
267
255
  chainId: initialChain.chainId
268
256
  });
269
-
270
257
  // note: not adding cachedWallet to modal if it is external wallet.
271
258
  // adding it later if no in-app wallets are available.
272
259
  if (connector.type === noModal.CONNECTOR_CATEGORY.IN_APP) {
273
- var _connectorName, _this$options$uiConfi, _this$options$uiConfi2, _this$options$uiConfi3;
260
+ var _this$modalConfig$con12, _this$options$uiConfi, _this$options$uiConfi2, _this$options$uiConfi3;
274
261
  noModal.log.info("connectorInitResults", connectorName);
275
- const loginMethods = utils.getConnectorSocialLogins(connectorName, (_connectorName = this.modalConfig.connectors[connectorName]) === null || _connectorName === void 0 ? void 0 : _connectorName.loginMethods);
262
+ const loginMethods = utils.getConnectorSocialLogins(connectorName, (_this$modalConfig$con12 = this.modalConfig.connectors[connectorName]) === null || _this$modalConfig$con12 === void 0 ? void 0 : _this$modalConfig$con12.loginMethods);
276
263
  this.loginModal.addSocialLogins(connectorName, loginMethods, ((_this$options$uiConfi = this.options.uiConfig) === null || _this$options$uiConfi === void 0 ? void 0 : _this$options$uiConfi.loginMethodsOrder) || config$1.AUTH_PROVIDERS, _objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
277
264
  loginGridCol: ((_this$options$uiConfi2 = this.options.uiConfig) === null || _this$options$uiConfi2 === void 0 ? void 0 : _this$options$uiConfi2.loginGridCol) || 3,
278
265
  primaryButton: ((_this$options$uiConfi3 = this.options.uiConfig) === null || _this$options$uiConfi3 === void 0 ? void 0 : _this$options$uiConfi3.primaryButton) || "socialLogin"
@@ -327,7 +314,14 @@ class Web3Auth extends noModal.Web3AuthNoModal {
327
314
  });
328
315
  }
329
316
  subscribeToLoginModalEvents() {
330
- this.loginModal.on(interfaces.LOGIN_MODAL_EVENTS.LOGIN, async params => {
317
+ this.loginModal.on(interfaces.LOGIN_MODAL_EVENTS.EXTERNAL_WALLET_LOGIN, async params => {
318
+ try {
319
+ await this.connectTo(params.connector);
320
+ } catch (error) {
321
+ noModal.log.error(`Error while connecting to connector: ${params.connector}`, error);
322
+ }
323
+ });
324
+ this.loginModal.on(interfaces.LOGIN_MODAL_EVENTS.SOCIAL_LOGIN, async params => {
331
325
  try {
332
326
  await this.connectTo(params.connector, params.loginParams);
333
327
  } catch (error) {
@@ -353,7 +347,6 @@ class Web3Auth extends noModal.Web3AuthNoModal {
353
347
  noModal.log.debug("trying refreshing wc session", visibility, walletConnectStatus);
354
348
  if (visibility && (walletConnectStatus === noModal.CONNECTOR_STATUS.READY || walletConnectStatus === noModal.CONNECTOR_STATUS.CONNECTING)) {
355
349
  noModal.log.debug("refreshing wc session");
356
-
357
350
  // refreshing session for wallet connect whenever modal is opened.
358
351
  try {
359
352
  const initialChain = this.getInitialChainIdForConnector(wcConnector);
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var jsxRuntime = require('react/jsx-runtime');
3
4
  var noModal = require('@web3auth/no-modal');
4
5
  var React = require('react');
5
6
  var reactI18next = require('react-i18next');
@@ -7,9 +8,8 @@ var interfaces = require('../interfaces.js');
7
8
  var localeImport = require('../localeImport.js');
8
9
  var Icon = require('./Icon.js');
9
10
  var Image = require('./Image.js');
10
- var jsxRuntime = require('react/jsx-runtime');
11
11
 
12
- const closeIcon = /*#__PURE__*/jsxRuntime.jsx(Icon, {
12
+ const closeIcon = jsxRuntime.jsx(Icon, {
13
13
  iconName: "x-light",
14
14
  darkIconName: "close"
15
15
  });
@@ -22,9 +22,9 @@ function DetailedLoader(props) {
22
22
  connectorName,
23
23
  onClose
24
24
  } = props;
25
- const providerIcon = connector === "twitter" ? /*#__PURE__*/jsxRuntime.jsx(Image, {
25
+ const providerIcon = connector === "twitter" ? jsxRuntime.jsx(Image, {
26
26
  imageId: "login-x-dark"
27
- }) : /*#__PURE__*/jsxRuntime.jsx(Image, {
27
+ }) : jsxRuntime.jsx(Image, {
28
28
  imageId: `login-${connector}`,
29
29
  height: "30",
30
30
  width: "30"
@@ -40,63 +40,63 @@ function DetailedLoader(props) {
40
40
  }, 3000);
41
41
  }
42
42
  }, [modalStatus, onClose]);
43
- return modalStatus !== interfaces.MODAL_STATUS.INITIALIZED ? /*#__PURE__*/jsxRuntime.jsxs("div", {
43
+ return modalStatus !== interfaces.MODAL_STATUS.INITIALIZED ? jsxRuntime.jsxs("div", {
44
44
  className: "w3ajs-modal-loader w3a-modal__loader w3a--h-full",
45
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
45
+ children: [jsxRuntime.jsx("div", {
46
46
  className: "w3a-modal__loader-content",
47
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
47
+ children: jsxRuntime.jsxs("div", {
48
48
  className: "w3a-modal__loader-info",
49
- children: [modalStatus === interfaces.MODAL_STATUS.CONNECTING && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
50
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
49
+ children: [modalStatus === interfaces.MODAL_STATUS.CONNECTING && jsxRuntime.jsxs(jsxRuntime.Fragment, {
50
+ children: [jsxRuntime.jsxs("div", {
51
51
  className: "w3a-modal__loader-bridge",
52
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
52
+ children: [jsxRuntime.jsxs("div", {
53
53
  className: "w3a-modal__loader-app-logo",
54
- children: [/*#__PURE__*/jsxRuntime.jsx("img", {
54
+ children: [jsxRuntime.jsx("img", {
55
55
  src: appLogo,
56
56
  className: "w3a--block dark:w3a--hidden w3a--h-10 w3a--w-10",
57
57
  alt: ""
58
- }), /*#__PURE__*/jsxRuntime.jsx("img", {
58
+ }), jsxRuntime.jsx("img", {
59
59
  src: appLogo,
60
60
  className: "w3a--hidden dark:w3a--block w3a--h-10 w3a--w-10",
61
61
  alt: ""
62
62
  })]
63
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
63
+ }), jsxRuntime.jsx("div", {
64
64
  className: "w3a-modal__connector",
65
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
65
+ children: jsxRuntime.jsxs("div", {
66
66
  className: "w3a-modal__connector-beat",
67
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {}), /*#__PURE__*/jsxRuntime.jsx("div", {}), /*#__PURE__*/jsxRuntime.jsx("div", {}), /*#__PURE__*/jsxRuntime.jsx("div", {}), /*#__PURE__*/jsxRuntime.jsx("div", {})]
67
+ children: [jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", {})]
68
68
  })
69
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
69
+ }), jsxRuntime.jsx("div", {
70
70
  className: "w3a-modal__loader-social-logo",
71
71
  children: providerIcon
72
72
  })]
73
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
74
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
73
+ }), jsxRuntime.jsxs("div", {
74
+ children: [jsxRuntime.jsx("div", {
75
75
  className: "w3a-modal__loader-bridge-message",
76
76
  children: t("modal.adapter-loader.message1", {
77
77
  adapter: connectorName
78
78
  })
79
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
79
+ }), jsxRuntime.jsx("div", {
80
80
  className: "w3a-modal__loader-bridge-message",
81
81
  children: t("modal.adapter-loader.message2", {
82
82
  adapter: connectorName
83
83
  })
84
84
  })]
85
85
  })]
86
- }), modalStatus === noModal.CONNECTOR_STATUS.CONNECTED && /*#__PURE__*/jsxRuntime.jsxs("div", {
86
+ }), modalStatus === noModal.CONNECTOR_STATUS.CONNECTED && jsxRuntime.jsxs("div", {
87
87
  className: "w3a--flex w3a--flex-col w3a--items-center",
88
- children: [/*#__PURE__*/jsxRuntime.jsx(Icon, {
88
+ children: [jsxRuntime.jsx(Icon, {
89
89
  iconName: "connected"
90
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
90
+ }), jsxRuntime.jsx("div", {
91
91
  className: "w3ajs-modal-loader__message w3a-spinner-message w3a--mt-4",
92
92
  children: message
93
93
  })]
94
- }), modalStatus === noModal.CONNECTOR_STATUS.ERRORED && /*#__PURE__*/jsxRuntime.jsx("div", {
94
+ }), modalStatus === noModal.CONNECTOR_STATUS.ERRORED && jsxRuntime.jsx("div", {
95
95
  className: "w3ajs-modal-loader__message w3a-spinner-message w3a-spinner-message--error",
96
96
  children: message
97
97
  })]
98
98
  })
99
- }), (modalStatus === noModal.CONNECTOR_STATUS.CONNECTED || modalStatus === noModal.CONNECTOR_STATUS.ERRORED) && /*#__PURE__*/jsxRuntime.jsx("button", {
99
+ }), (modalStatus === noModal.CONNECTOR_STATUS.CONNECTED || modalStatus === noModal.CONNECTOR_STATUS.ERRORED) && jsxRuntime.jsx("button", {
100
100
  type: "button",
101
101
  className: "w3a-header__button w3ajs-loader-close-btn",
102
102
  onClick: onClose,
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var jsxRuntime = require('react/jsx-runtime');
3
4
  require('./styles.css.js');
4
5
  var React = require('react');
5
- var jsxRuntime = require('react/jsx-runtime');
6
6
 
7
7
  function Button(props) {
8
8
  const {
@@ -17,10 +17,9 @@ function Button(props) {
17
17
  type = "button"
18
18
  } = props;
19
19
  const sizeClass = `size-${size}`;
20
- return /*#__PURE__*/jsxRuntime.jsx("button", {
21
- disabled: disabled
20
+ return jsxRuntime.jsx("button", {
21
+ disabled: disabled,
22
22
  // eslint-disable-next-line react/button-has-type
23
- ,
24
23
  type: type,
25
24
  className: `t-btn t-btn-${variant} w3a--rounded-full ${sizeClass} ${className}`,
26
25
  onClick: onClick,
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var jsxRuntime = require('react/jsx-runtime');
3
4
  var reactI18next = require('react-i18next');
4
5
  var localeImport = require('../../localeImport.js');
5
6
  var Button = require('../Button/Button.js');
6
7
  var Image = require('../Image.js');
7
- var jsxRuntime = require('react/jsx-runtime');
8
8
 
9
9
  function ExternalWalletButton(props) {
10
10
  const {
@@ -14,15 +14,15 @@ function ExternalWalletButton(props) {
14
14
  const [t] = reactI18next.useTranslation(undefined, {
15
15
  i18n: localeImport
16
16
  });
17
- return /*#__PURE__*/jsxRuntime.jsxs(Button, {
17
+ return jsxRuntime.jsxs(Button, {
18
18
  variant: "tertiary",
19
19
  type: "button",
20
20
  onClick: () => handleWalletClick(button),
21
21
  className: "w3a--w-full w3a--rounded-xl w3a--size-xl !w3a--justify-between w3a--items-center wallet-btn",
22
22
  title: button.name,
23
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
23
+ children: [jsxRuntime.jsxs("div", {
24
24
  className: "w3a--flex w3a--items-center",
25
- children: [/*#__PURE__*/jsxRuntime.jsx(Image, {
25
+ children: [jsxRuntime.jsx(Image, {
26
26
  imageId: `login-${button.name}`,
27
27
  hoverImageId: `login-${button.name}`,
28
28
  fallbackImageId: "wallet",
@@ -30,11 +30,11 @@ function ExternalWalletButton(props) {
30
30
  width: "24",
31
31
  isButton: true,
32
32
  extension: button.imgExtension
33
- }), /*#__PURE__*/jsxRuntime.jsx("p", {
33
+ }), jsxRuntime.jsx("p", {
34
34
  className: "w3a--ml-2 w3a--text-left w3a--text-sm",
35
35
  children: button.displayName
36
36
  })]
37
- }), button.hasInjectedWallet && /*#__PURE__*/jsxRuntime.jsx("span", {
37
+ }), button.hasInjectedWallet && jsxRuntime.jsx("span", {
38
38
  className: "w3a--inline-flex w3a--items-center w3a--rounded-lg w3a--px-2 w3a--py-1 w3a--text-xs w3a--font-medium w3a--bg-app-primary-100 w3a--text-app-primary-800",
39
39
  children: t("modal.external.installed")
40
40
  })]
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var reactI18next = require('react-i18next');
5
+ var localeImport = require('../../localeImport.js');
6
+ var Button = require('../Button/Button.js');
7
+ var Image = require('../Image.js');
8
+ var ExternalWalletHeader = require('./ExternalWalletHeader.js');
9
+
10
+ function ExternalWalletChainNamespace(props) {
11
+ const {
12
+ button,
13
+ goBack,
14
+ closeModal,
15
+ handleExternalWalletClick
16
+ } = props;
17
+ const [t] = reactI18next.useTranslation(undefined, {
18
+ i18n: localeImport
19
+ });
20
+ // chainNames should be available when selecting a chain namespace
21
+ const chainNamespaces = button.chainNamespaces.map(chainNamespace => {
22
+ const imageId = chainNamespace === "eip155" ? "evm" : chainNamespace;
23
+ const displayName = chainNamespace === "eip155" ? "EVM" : chainNamespace;
24
+ return {
25
+ chainNamespace,
26
+ displayName,
27
+ imageId: `chain-${imageId}`
28
+ };
29
+ });
30
+ return jsxRuntime.jsxs("div", {
31
+ children: [jsxRuntime.jsx(ExternalWalletHeader, {
32
+ title: `${t("modal.external.select-chain")}`,
33
+ goBack: goBack,
34
+ closeModal: closeModal
35
+ }), jsxRuntime.jsx("div", {
36
+ className: "w3a--flex w3a--justify-center w3a--my-6",
37
+ children: jsxRuntime.jsx(Image, {
38
+ imageId: `login-${button.name}`,
39
+ hoverImageId: `login-${button.name}`,
40
+ fallbackImageId: "wallet",
41
+ height: "100",
42
+ width: "100",
43
+ isButton: true,
44
+ extension: button.imgExtension
45
+ })
46
+ }), jsxRuntime.jsx("p", {
47
+ className: "w3a--text-center w3a--text-sm w3a--text-app-gray-500 w3a--my-6",
48
+ children: t("modal.external.select-chain-description", {
49
+ wallet: button.displayName
50
+ })
51
+ }), jsxRuntime.jsx("ul", {
52
+ className: "w3a--flex w3a--flex-col w3a--gap-3",
53
+ children: chainNamespaces.map(({
54
+ chainNamespace,
55
+ displayName,
56
+ imageId
57
+ }) => jsxRuntime.jsx("li", {
58
+ children: jsxRuntime.jsxs(Button, {
59
+ variant: "tertiary",
60
+ type: "button",
61
+ onClick: () => handleExternalWalletClick({
62
+ connector: button.name,
63
+ chainNamespace
64
+ }),
65
+ className: "w3a--w-full w3a--size-xl !w3a--justify-between w3a--items-center wallet-btn",
66
+ title: displayName,
67
+ children: [jsxRuntime.jsxs("div", {
68
+ className: "w3a--flex w3a--items-center",
69
+ children: [jsxRuntime.jsx(Image, {
70
+ imageId: imageId,
71
+ hoverImageId: imageId,
72
+ fallbackImageId: "wallet",
73
+ height: "24",
74
+ width: "24",
75
+ isButton: true,
76
+ extension: "svg"
77
+ }), jsxRuntime.jsx("p", {
78
+ className: "w3a--ml-2 w3a--text-left w3a--text-sm first-letter:w3a--capitalize",
79
+ children: displayName
80
+ })]
81
+ }), jsxRuntime.jsx("span", {
82
+ className: "w3a--inline-flex w3a--items-center w3a--rounded-lg w3a--px-2 w3a--py-1 w3a--text-xs w3a--font-medium w3a--bg-app-primary-100 w3a--text-app-primary-800",
83
+ children: t("modal.external.installed")
84
+ })]
85
+ })
86
+ }, chainNamespace))
87
+ })]
88
+ });
89
+ }
90
+
91
+ module.exports = ExternalWalletChainNamespace;
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var jsxRuntime = require('react/jsx-runtime');
3
4
  var React = require('react');
4
5
  var reactI18next = require('react-i18next');
5
6
  var interfaces = require('../../interfaces.js');
@@ -9,7 +10,6 @@ var Loader = require('../Loader.js');
9
10
  var WalletConnect = require('../WalletConnect.js');
10
11
  var ExternalWalletHeader = require('./ExternalWalletHeader.js');
11
12
  var ExternalWalletInstall = require('./ExternalWalletInstall.js');
12
- var jsxRuntime = require('react/jsx-runtime');
13
13
 
14
14
  function ExternalWalletConnect(props) {
15
15
  const {
@@ -25,33 +25,33 @@ function ExternalWalletConnect(props) {
25
25
  const showWalletDownload = () => {
26
26
  setIsWalletDownloadShown(true);
27
27
  };
28
- return /*#__PURE__*/jsxRuntime.jsx("div", {
29
- children: isWalletDownloadShown ? /*#__PURE__*/jsxRuntime.jsx("div", {
30
- children: /*#__PURE__*/jsxRuntime.jsx(ExternalWalletInstall, {
28
+ return jsxRuntime.jsx("div", {
29
+ children: isWalletDownloadShown ? jsxRuntime.jsx("div", {
30
+ children: jsxRuntime.jsx(ExternalWalletInstall, {
31
31
  connectButton: connectButton,
32
32
  goBack: () => setIsWalletDownloadShown(false),
33
33
  closeModal: closeModal
34
34
  })
35
- }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
36
- children: [/*#__PURE__*/jsxRuntime.jsx(ExternalWalletHeader, {
35
+ }) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
36
+ children: [jsxRuntime.jsx(ExternalWalletHeader, {
37
37
  title: connectButton.displayName,
38
38
  goBack: goBack,
39
39
  closeModal: closeModal
40
- }), !walletConnectUri ? /*#__PURE__*/jsxRuntime.jsx(Loader, {
40
+ }), !walletConnectUri ? jsxRuntime.jsx(Loader, {
41
41
  modalStatus: interfaces.MODAL_STATUS.CONNECTING,
42
42
  canEmit: false
43
- }) : /*#__PURE__*/jsxRuntime.jsx(WalletConnect, {
43
+ }) : jsxRuntime.jsx(WalletConnect, {
44
44
  walletConnectUri: walletConnectUri,
45
45
  logoImage: `https://images.web3auth.io/login-${connectButton.name}.${connectButton.imgExtension}`,
46
46
  primaryColor: connectButton.walletRegistryItem.primaryColor
47
- }), connectButton.hasInstallLinks && /*#__PURE__*/jsxRuntime.jsxs("div", {
47
+ }), connectButton.hasInstallLinks && jsxRuntime.jsxs("div", {
48
48
  className: "w3a--flex w3a--flex-row w3a--items-center w3a--justify-between w3a--gap-2 w3a--bg-app-gray-50 dark:w3a--bg-app-gray-700 w3a--text-app-gray-900 dark:w3a--text-app-white w3a--px-3 w3a--py-2 w3a--rounded-xl",
49
- children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
49
+ children: [jsxRuntime.jsxs("span", {
50
50
  className: "w3a--text-sm w3a--truncate w3a--flex-grow-0",
51
- children: [t("modal.external.dont-have"), " ", /*#__PURE__*/jsxRuntime.jsx("span", {
51
+ children: [t("modal.external.dont-have"), " ", jsxRuntime.jsx("span", {
52
52
  children: connectButton.displayName
53
53
  }), "?"]
54
- }), /*#__PURE__*/jsxRuntime.jsx(Button, {
54
+ }), jsxRuntime.jsx(Button, {
55
55
  type: "button",
56
56
  variant: "secondary",
57
57
  size: "xs",
@@ -1,19 +1,29 @@
1
1
  'use strict';
2
2
 
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var ExternalWalletChainNamespace = require('./ExternalWalletChainNamespace.js');
3
5
  var ExternalWalletConnect = require('./ExternalWalletConnect.js');
4
6
  var ExternalWalletInstall = require('./ExternalWalletInstall.js');
5
- var jsxRuntime = require('react/jsx-runtime');
6
7
 
7
8
  function ExternalWalletDetail(props) {
8
9
  const {
9
10
  connectButton,
10
11
  walletConnectUri,
11
12
  goBack,
12
- closeModal
13
+ closeModal,
14
+ handleExternalWalletClick
13
15
  } = props;
14
- return /*#__PURE__*/jsxRuntime.jsx("div", {
16
+ // Select chain namespace for injected wallets
17
+ if (connectButton.hasInjectedWallet) {
18
+ return jsxRuntime.jsx(ExternalWalletChainNamespace, {
19
+ handleExternalWalletClick: handleExternalWalletClick,
20
+ button: connectButton,
21
+ goBack: goBack,
22
+ closeModal: closeModal
23
+ });
24
+ }
25
+ return jsxRuntime.jsx("div", {
15
26
  children: connectButton.hasWalletConnect ?
16
- /*#__PURE__*/
17
27
  // Wallet Connect
18
28
  jsxRuntime.jsx(ExternalWalletConnect, {
19
29
  connectButton: connectButton,
@@ -21,7 +31,6 @@ function ExternalWalletDetail(props) {
21
31
  goBack: goBack,
22
32
  closeModal: closeModal
23
33
  }) :
24
- /*#__PURE__*/
25
34
  // Download wallets
26
35
  jsxRuntime.jsx(ExternalWalletInstall, {
27
36
  connectButton: connectButton,
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var Icon = require('../Icon.js');
4
3
  var jsxRuntime = require('react/jsx-runtime');
4
+ var Icon = require('../Icon.js');
5
5
 
6
6
  function ExternalWalletHeader(props) {
7
7
  const {
@@ -10,31 +10,31 @@ function ExternalWalletHeader(props) {
10
10
  closeModal,
11
11
  disableBackButton
12
12
  } = props;
13
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
13
+ return jsxRuntime.jsxs("div", {
14
14
  className: "w3a--flex w3a--flex-row w3a--justify-center w3a--items-center w3a--gap-1",
15
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
15
+ children: [jsxRuntime.jsx("div", {
16
16
  className: "w3a--flex-grow-1 w3a--flex-shrink-0 w3a--items-center w3a--justify-start w3a--mr-auto",
17
- children: !disableBackButton && /*#__PURE__*/jsxRuntime.jsx("button", {
17
+ children: !disableBackButton && jsxRuntime.jsx("button", {
18
18
  type: "button",
19
19
  className: "w3a-external-back w3ajs-external-back",
20
20
  onClick: goBack,
21
- children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
21
+ children: jsxRuntime.jsx(Icon, {
22
22
  iconName: "arrow-left-light",
23
23
  darkIconName: "arrow-left-dark",
24
24
  width: "16",
25
25
  height: "16"
26
26
  })
27
27
  })
28
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
28
+ }), jsxRuntime.jsx("div", {
29
29
  className: "w3a-header__title w3a--flex-grow-0 w3a--flex-shrink w3a--truncate w3a--mr-6",
30
30
  children: title
31
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
31
+ }), jsxRuntime.jsx("div", {
32
32
  className: "w3a--flex-grow-1 w3a--flex-shrink-0 w3a--items-center w3a--justify-end w3a--ml-auto",
33
- children: /*#__PURE__*/jsxRuntime.jsx("button", {
33
+ children: jsxRuntime.jsx("button", {
34
34
  type: "button",
35
35
  onClick: closeModal,
36
36
  className: "w3a-header__button_wallet w3ajs-close-btn",
37
- children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
37
+ children: jsxRuntime.jsx(Icon, {
38
38
  iconName: "x-light",
39
39
  darkIconName: "x-dark"
40
40
  })