@web3auth/modal 10.0.0-alpha.2 → 10.0.0-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 (55) hide show
  1. package/dist/lib.cjs/packages/modal/src/config.js +3 -57
  2. package/dist/lib.cjs/packages/modal/src/index.js +1 -5
  3. package/dist/lib.cjs/packages/modal/src/modalManager.js +132 -89
  4. package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +1 -12
  5. package/dist/lib.cjs/packages/modal/src/ui/components/ExternalWallets.js +10 -5
  6. package/dist/lib.cjs/packages/modal/src/ui/components/Modal.js +36 -2
  7. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLoginPasswordless.js +8 -6
  8. package/dist/lib.cjs/packages/modal/src/ui/components/SocialLogins.js +2 -1
  9. package/dist/lib.cjs/packages/modal/src/ui/config.js +1 -2
  10. package/dist/lib.cjs/packages/modal/src/ui/css/web3auth.css.js +1 -1
  11. package/dist/lib.cjs/packages/modal/src/ui/i18n/dutch.json.js +1 -0
  12. package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +1 -0
  13. package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +1 -0
  14. package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +1 -0
  15. package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +1 -0
  16. package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +1 -0
  17. package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +1 -0
  18. package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +1 -0
  19. package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +1 -0
  20. package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +1 -0
  21. package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +2 -1
  22. package/dist/lib.cjs/packages/modal/src/ui/utils.js +0 -21
  23. package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +1 -12
  24. package/dist/lib.cjs/types/config.d.ts +1 -5
  25. package/dist/lib.cjs/types/interface.d.ts +2 -6
  26. package/dist/lib.cjs/types/modalManager.d.ts +7 -3
  27. package/dist/lib.cjs/types/react/interfaces.d.ts +1 -6
  28. package/dist/lib.cjs/types/ui/interfaces.d.ts +2 -2
  29. package/dist/lib.cjs/types/ui/utils.d.ts +1 -3
  30. package/dist/lib.cjs/types/vue/interfaces.d.ts +1 -6
  31. package/dist/lib.esm/packages/modal/src/config.js +4 -54
  32. package/dist/lib.esm/packages/modal/src/index.js +1 -1
  33. package/dist/lib.esm/packages/modal/src/modalManager.js +144 -93
  34. package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +1 -12
  35. package/dist/lib.esm/packages/modal/src/ui/components/ExternalWallets.js +10 -5
  36. package/dist/lib.esm/packages/modal/src/ui/components/Modal.js +37 -3
  37. package/dist/lib.esm/packages/modal/src/ui/components/SocialLoginPasswordless.js +8 -6
  38. package/dist/lib.esm/packages/modal/src/ui/components/SocialLogins.js +2 -1
  39. package/dist/lib.esm/packages/modal/src/ui/config.js +2 -2
  40. package/dist/lib.esm/packages/modal/src/ui/css/web3auth.css.js +1 -1
  41. package/dist/lib.esm/packages/modal/src/ui/i18n/dutch.json.js +1 -0
  42. package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +1 -0
  43. package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +1 -0
  44. package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +1 -0
  45. package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +1 -0
  46. package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +1 -0
  47. package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +1 -0
  48. package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +1 -0
  49. package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +1 -0
  50. package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +1 -0
  51. package/dist/lib.esm/packages/modal/src/ui/loginModal.js +2 -1
  52. package/dist/lib.esm/packages/modal/src/ui/utils.js +2 -22
  53. package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +1 -12
  54. package/dist/modal.umd.min.js +1 -1
  55. package/package.json +3 -3
@@ -2,58 +2,8 @@
2
2
 
3
3
  var noModal = require('@web3auth/no-modal');
4
4
 
5
- const defaultSolanaDappModalConfig = {
6
- chainNamespace: noModal.CHAIN_NAMESPACES.SOLANA,
7
- connectors: {
8
- [noModal.SOLANA_CONNECTORS.AUTH]: {
9
- label: "Auth",
10
- showOnModal: true,
11
- showOnMobile: true,
12
- showOnDesktop: true
13
- }
14
- }
15
- };
16
- const defaultEvmDappModalConfig = {
17
- chainNamespace: noModal.CHAIN_NAMESPACES.EIP155,
18
- connectors: {
19
- [noModal.EVM_CONNECTORS.AUTH]: {
20
- label: "Auth",
21
- showOnModal: true,
22
- showOnMobile: true,
23
- showOnDesktop: true
24
- },
25
- [noModal.EVM_CONNECTORS.WALLET_CONNECT_V2]: {
26
- label: "Wallet Connect",
27
- showOnModal: true,
28
- showOnMobile: true,
29
- showOnDesktop: true
30
- }
31
- }
32
- };
33
- const defaultSolanaWalletModalConfig = {
34
- chainNamespace: noModal.CHAIN_NAMESPACES.SOLANA,
35
- connectors: {
36
- [noModal.SOLANA_CONNECTORS.AUTH]: {
37
- label: "Auth",
38
- showOnModal: true,
39
- showOnMobile: true,
40
- showOnDesktop: true
41
- }
42
- }
43
- };
44
- const defaultEvmWalletModalConfig = {
45
- chainNamespace: noModal.CHAIN_NAMESPACES.EIP155,
46
- connectors: {
47
- [noModal.EVM_CONNECTORS.AUTH]: {
48
- label: "Auth",
49
- showOnModal: true,
50
- showOnMobile: true,
51
- showOnDesktop: true
52
- }
53
- }
54
- };
55
- const defaultOtherModalConfig = {
56
- chainNamespace: noModal.CHAIN_NAMESPACES.OTHER,
5
+ const defaultConnectorsModalConfig = {
6
+ hideWalletDiscovery: false,
57
7
  connectors: {
58
8
  [noModal.EVM_CONNECTORS.AUTH]: {
59
9
  label: "Auth",
@@ -65,9 +15,5 @@ const defaultOtherModalConfig = {
65
15
  };
66
16
  const walletRegistryUrl = "https://assets.web3auth.io/v1/wallet-registry.json";
67
17
 
68
- exports.defaultEvmDappModalConfig = defaultEvmDappModalConfig;
69
- exports.defaultEvmWalletModalConfig = defaultEvmWalletModalConfig;
70
- exports.defaultOtherModalConfig = defaultOtherModalConfig;
71
- exports.defaultSolanaDappModalConfig = defaultSolanaDappModalConfig;
72
- exports.defaultSolanaWalletModalConfig = defaultSolanaWalletModalConfig;
18
+ exports.defaultConnectorsModalConfig = defaultConnectorsModalConfig;
73
19
  exports.walletRegistryUrl = walletRegistryUrl;
@@ -6,11 +6,7 @@ var noModal = require('@web3auth/no-modal');
6
6
 
7
7
 
8
8
 
9
- exports.defaultEvmDappModalConfig = config.defaultEvmDappModalConfig;
10
- exports.defaultEvmWalletModalConfig = config.defaultEvmWalletModalConfig;
11
- exports.defaultOtherModalConfig = config.defaultOtherModalConfig;
12
- exports.defaultSolanaDappModalConfig = config.defaultSolanaDappModalConfig;
13
- exports.defaultSolanaWalletModalConfig = config.defaultSolanaWalletModalConfig;
9
+ exports.defaultConnectorsModalConfig = config.defaultConnectorsModalConfig;
14
10
  exports.walletRegistryUrl = config.walletRegistryUrl;
15
11
  exports.Web3Auth = modalManager.Web3Auth;
16
12
  Object.keys(noModal).forEach(function (k) {
@@ -15,31 +15,36 @@ class Web3Auth extends noModal.Web3AuthNoModal {
15
15
  super(options);
16
16
  _defineProperty(this, "loginModal", void 0);
17
17
  _defineProperty(this, "options", void 0);
18
- _defineProperty(this, "modalConfig", noModal.cloneDeep(config.defaultOtherModalConfig));
18
+ _defineProperty(this, "modalConfig", noModal.cloneDeep(config.defaultConnectorsModalConfig));
19
19
  this.options = _objectSpread({}, options);
20
20
  if (!this.options.uiConfig) this.options.uiConfig = {};
21
+ if (this.options.modalConfig) this.modalConfig = this.options.modalConfig;
22
+ noModal.log.info("modalConfig", this.modalConfig);
21
23
  }
22
- setModalConfig(modalConfig) {
23
- super.checkInitRequirements();
24
- this.modalConfig = modalConfig;
25
- }
26
- async initModal(params) {
24
+ async initModal() {
27
25
  var _this$coreOptions$cha;
28
26
  super.checkInitRequirements();
29
- super.initCachedConnectorAndChainId();
30
27
  // get project config and wallet registry
31
28
  const {
32
29
  projectConfig,
33
30
  walletRegistry
34
- } = await this.getProjectAndWalletConfig(params);
31
+ } = await this.getProjectAndWalletConfig();
35
32
  this.options.uiConfig = deepmerge(noModal.cloneDeep(projectConfig.whitelabel || {}), this.options.uiConfig || {});
36
33
  if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = utils.getUserLanguage(this.options.uiConfig.defaultLanguage);
37
34
  if (!this.options.uiConfig.mode) this.options.uiConfig.mode = "light";
35
+ // init config
36
+ super.initAccountAbstractionConfig(projectConfig);
37
+ super.initChainsConfig(projectConfig);
38
+ super.initCachedConnectorAndChainId();
38
39
  // init login modal
40
+ const {
41
+ filteredWalletRegistry,
42
+ disabledExternalWallets
43
+ } = this.filterWalletRegistry(walletRegistry, projectConfig);
39
44
  this.loginModal = new loginModal.LoginModal(_objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
40
45
  connectorListener: this,
41
46
  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
- walletRegistry
47
+ walletRegistry: filteredWalletRegistry
43
48
  }));
44
49
  this.subscribeToLoginModalEvents();
45
50
  await this.loginModal.initModal();
@@ -51,7 +56,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
51
56
  }) => this.initConnectors({
52
57
  connectors: newConnectors,
53
58
  projectConfig,
54
- modalConfig: params
59
+ disabledExternalWallets
55
60
  }));
56
61
  await this.loadConnectors({
57
62
  projectConfig
@@ -79,7 +84,33 @@ class Web3Auth extends noModal.Web3AuthNoModal {
79
84
  });
80
85
  });
81
86
  }
82
- async getProjectAndWalletConfig(params) {
87
+ filterWalletRegistry(walletRegistry, projectConfig) {
88
+ const {
89
+ disableAllRecommendedWallets,
90
+ disableAllOtherWallets,
91
+ disabledWallets
92
+ } = projectConfig.externalWalletAuth || {};
93
+ // add disabled wallets to set
94
+ const disabledExternalWallets = new Set(disabledWallets || []);
95
+ if (disableAllRecommendedWallets) {
96
+ Object.keys(walletRegistry.default).forEach(wallet => disabledExternalWallets.add(wallet));
97
+ }
98
+ if (disableAllOtherWallets) {
99
+ Object.keys(walletRegistry.others).forEach(wallet => disabledExternalWallets.add(wallet));
100
+ }
101
+ // remove wallets that are disabled in project config from wallet registry
102
+ const filteredWalletRegistry = noModal.cloneDeep(walletRegistry);
103
+ disabledExternalWallets.forEach(wallet => {
104
+ delete filteredWalletRegistry.default[wallet];
105
+ delete filteredWalletRegistry.others[wallet];
106
+ });
107
+ return {
108
+ disabledExternalWallets,
109
+ filteredWalletRegistry
110
+ };
111
+ }
112
+ async getProjectAndWalletConfig() {
113
+ var _this$modalConfig;
83
114
  // get project config
84
115
  let projectConfig;
85
116
  try {
@@ -94,7 +125,8 @@ class Web3Auth extends noModal.Web3AuthNoModal {
94
125
  others: {},
95
126
  default: {}
96
127
  };
97
- if (!(params !== null && params !== void 0 && params.hideWalletDiscovery)) {
128
+ const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
129
+ if (isExternalWalletEnabled && !((_this$modalConfig = this.modalConfig) !== null && _this$modalConfig !== void 0 && _this$modalConfig.hideWalletDiscovery)) {
98
130
  try {
99
131
  walletRegistry = await noModal.fetchWalletRegistry(config.walletRegistryUrl);
100
132
  } catch (e) {
@@ -109,15 +141,18 @@ class Web3Auth extends noModal.Web3AuthNoModal {
109
141
  async initConnectors({
110
142
  connectors,
111
143
  projectConfig,
112
- modalConfig
144
+ disabledExternalWallets
113
145
  }) {
114
146
  // filter connectors based on config
115
- const filteredConnectorNames = await this.filterConnectors(modalConfig, projectConfig);
147
+ const filteredConnectorNames = await this.filterConnectors({
148
+ projectConfig,
149
+ disabledExternalWallets
150
+ });
116
151
  // initialize connectors based on availability
117
152
  const {
118
153
  hasInAppConnectors,
119
154
  hasExternalConnectors
120
- } = await this.checkConnectorAvailability(filteredConnectorNames, modalConfig);
155
+ } = await this.checkConnectorAvailability(filteredConnectorNames);
121
156
  if (hasInAppConnectors) {
122
157
  await this.initInAppAndCachedConnectors(connectors, filteredConnectorNames);
123
158
  // show connect button if external wallets are available
@@ -134,102 +169,110 @@ class Web3Auth extends noModal.Web3AuthNoModal {
134
169
  this.emit(noModal.CONNECTOR_EVENTS.READY);
135
170
  }
136
171
  }
137
- async filterConnectors(params, projectConfig) {
138
- // update auth connector config
139
- const {
140
- sms_otp_enabled: smsOtpEnabled
141
- } = projectConfig;
142
- if (smsOtpEnabled !== undefined) {
143
- var _params, _params$modalConfig$W;
144
- // TODO: use the new login config method
145
- const connectorConfig = {
146
- [noModal.WALLET_CONNECTORS.AUTH]: {
147
- label: noModal.WALLET_CONNECTORS.AUTH,
148
- loginMethods: {
149
- [noModal.AUTH_CONNECTION.SMS_PASSWORDLESS]: {
150
- name: noModal.AUTH_CONNECTION.SMS_PASSWORDLESS,
151
- showOnModal: smsOtpEnabled,
152
- showOnDesktop: smsOtpEnabled,
153
- showOnMobile: smsOtpEnabled
154
- }
155
- }
156
- }
157
- };
158
- if (!((_params = params) !== null && _params !== void 0 && _params.modalConfig)) params = {
159
- modalConfig: {}
160
- };
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;
162
- if (localSmsOtpEnabled === true && smsOtpEnabled === false) {
163
- throw noModal.WalletInitializationError.invalidParams("must enable sms otp on dashboard in order to utilise it");
172
+ async filterConnectors({
173
+ projectConfig,
174
+ disabledExternalWallets
175
+ }) {
176
+ var _this$modalConfig2, _this$modalConfig3, _projectConfig$loginM, _projectConfig$loginM2;
177
+ // Auth connector config: merge code config with config from dashboard
178
+ const loginMethods = {};
179
+ for (const authConnectionConfig of projectConfig.embeddedWalletAuth || []) {
180
+ const {
181
+ isDefault,
182
+ authConnectionId,
183
+ groupedAuthConnectionId,
184
+ authConnection
185
+ } = authConnectionConfig;
186
+ // for custom auth connections, authConnectionId or groupedAuthConnectionId are required.
187
+ if (!isDefault && (!authConnectionId || !groupedAuthConnectionId)) return;
188
+ loginMethods[authConnection] = _objectSpread(_objectSpread({
189
+ name: authConnection
190
+ }, authConnectionConfig), {}, {
191
+ showOnModal: true,
192
+ showOnDesktop: true,
193
+ showOnMobile: true
194
+ });
195
+ }
196
+ const dashboardConnectorConfig = {
197
+ [noModal.WALLET_CONNECTORS.AUTH]: {
198
+ label: noModal.WALLET_CONNECTORS.AUTH,
199
+ loginMethods
164
200
  }
165
- params.modalConfig = deepmerge(connectorConfig, noModal.cloneDeep(params.modalConfig));
201
+ };
202
+ if ((_this$modalConfig2 = this.modalConfig) !== null && _this$modalConfig2 !== void 0 && (_this$modalConfig2 = _this$modalConfig2.connectors) !== null && _this$modalConfig2 !== void 0 && _this$modalConfig2[noModal.WALLET_CONNECTORS.AUTH]) {
203
+ if (!this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods) this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods = {};
204
+ }
205
+ this.modalConfig.connectors = deepmerge(dashboardConnectorConfig, noModal.cloneDeep(this.modalConfig.connectors || {}));
206
+ // TODO: validate modal connector config here.!!
207
+ if ((_this$modalConfig3 = this.modalConfig) !== null && _this$modalConfig3 !== void 0 && (_this$modalConfig3 = _this$modalConfig3.connectors) !== null && _this$modalConfig3 !== void 0 && (_this$modalConfig3 = _this$modalConfig3[noModal.WALLET_CONNECTORS.AUTH]) !== null && _this$modalConfig3 !== void 0 && _this$modalConfig3.loginMethods) {
208
+ const authProviders = new Set(config$1.AUTH_PROVIDERS);
209
+ Object.keys(this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods).forEach(key => {
210
+ if (!authProviders.has(key)) {
211
+ throw noModal.WalletInitializationError.invalidParams(`Invalid auth connection: ${key}`);
212
+ }
213
+ });
166
214
  }
215
+ // external wallets config
216
+ const isExternalWalletEnabled = Boolean(projectConfig.externalWalletAuth);
217
+ const isInstalledWalletWalletDisplayed = Boolean((_projectConfig$loginM = (_projectConfig$loginM2 = projectConfig.loginModal) === null || _projectConfig$loginM2 === void 0 ? void 0 : _projectConfig$loginM2.displayInstalledExternalWallets) !== null && _projectConfig$loginM !== void 0 ? _projectConfig$loginM : true);
167
218
  // merge default connectors with the custom configured connectors.
168
219
  const allConnectorNames = [...new Set([...Object.keys(this.modalConfig.connectors || {}), ...this.connectors.map(connector => connector.name)])];
169
- const connectorConfigurationPromises = allConnectorNames.map(async connectorName => {
170
- var _this$modalConfig$con, _params2, _this$modalConfig$con2, _this$modalConfig$con3;
220
+ const connectorNames = allConnectorNames.map(connectorName => {
221
+ var _this$modalConfig4, _this$modalConfig$con, _this$modalConfig$con2;
171
222
  // start with the default config of connector.
172
- let connectorConfig = ((_this$modalConfig$con = this.modalConfig.connectors) === null || _this$modalConfig$con === void 0 ? void 0 : _this$modalConfig$con[connectorName]) || {
223
+ const defaultConnectorConfig = {
173
224
  label: noModal.CONNECTOR_NAMES[connectorName] || connectorName.split("-").map(config$1.capitalizeFirstLetter).join(" "),
174
225
  showOnModal: true,
175
226
  showOnMobile: true,
176
227
  showOnDesktop: true
177
228
  };
178
- // override the default config of connector if some config is being provided by the user.
179
- if ((_params2 = params) !== null && _params2 !== void 0 && (_params2 = _params2.modalConfig) !== null && _params2 !== void 0 && _params2[connectorName]) {
180
- connectorConfig = _objectSpread(_objectSpread({}, connectorConfig), params.modalConfig[connectorName]);
181
- }
182
- this.modalConfig.connectors[connectorName] = connectorConfig;
229
+ this.modalConfig.connectors[connectorName] = _objectSpread(_objectSpread({}, defaultConnectorConfig), ((_this$modalConfig4 = this.modalConfig) === null || _this$modalConfig4 === void 0 || (_this$modalConfig4 = _this$modalConfig4.connectors) === null || _this$modalConfig4 === void 0 ? void 0 : _this$modalConfig4[connectorName]) || {});
183
230
  // check if connector is configured/added by user and exist in connectors map.
184
231
  const connector = this.getConnector(connectorName);
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);
186
- // if connector is not custom configured then check if it is available in default connectors.
187
- // and if connector is not hidden by user
188
- if (!connector && (_this$modalConfig$con3 = this.modalConfig.connectors) !== null && _this$modalConfig$con3 !== void 0 && _this$modalConfig$con3[connectorName].showOnModal) {
189
- throw noModal.WalletInitializationError.invalidParams(`Connector ${connectorName} is not configured`);
190
- } else if ((connector === null || connector === void 0 ? void 0 : connector.type) === noModal.CONNECTOR_CATEGORY.IN_APP || (connector === null || connector === void 0 ? void 0 : connector.type) === noModal.CONNECTOR_CATEGORY.EXTERNAL || connectorName === this.cachedConnector) {
191
- var _this$modalConfig$con4;
192
- if (!((_this$modalConfig$con4 = this.modalConfig.connectors) !== null && _this$modalConfig$con4 !== void 0 && _this$modalConfig$con4[connectorName].showOnModal)) return;
193
- if (connectorName === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2) {
194
- const {
195
- wallet_connect_enabled: walletConnectEnabled
196
- } = projectConfig;
197
- if (walletConnectEnabled === false) {
198
- var _this$modalConfig$con5, _this$modalConfig$con6, _this$modalConfig$con7;
199
- // override user specified config by hiding wallet connect
200
- this.modalConfig.connectors = _objectSpread(_objectSpread({}, (_this$modalConfig$con5 = this.modalConfig.connectors) !== null && _this$modalConfig$con5 !== void 0 ? _this$modalConfig$con5 : {}), {}, {
201
- [noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2]: _objectSpread(_objectSpread({}, (_this$modalConfig$con6 = (_this$modalConfig$con7 = this.modalConfig.connectors) === null || _this$modalConfig$con7 === void 0 ? void 0 : _this$modalConfig$con7[noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2]) !== null && _this$modalConfig$con6 !== void 0 ? _this$modalConfig$con6 : {}), {}, {
202
- showOnModal: false
203
- })
204
- });
205
- this.modalConfig.connectors[noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2].showOnModal = false;
206
- }
207
- }
208
- return connectorName;
232
+ noModal.log.debug("connector config", connectorName, (_this$modalConfig$con = this.modalConfig.connectors) === null || _this$modalConfig$con === void 0 || (_this$modalConfig$con = _this$modalConfig$con[connectorName]) === null || _this$modalConfig$con === void 0 ? void 0 : _this$modalConfig$con.showOnModal, connector);
233
+ // check if connector is configured/added by user and exist in connectors map.
234
+ const connectorConfig = (_this$modalConfig$con2 = this.modalConfig.connectors) === null || _this$modalConfig$con2 === void 0 ? void 0 : _this$modalConfig$con2[connectorName];
235
+ if (!connector) {
236
+ if (connectorConfig.showOnModal) throw noModal.WalletInitializationError.invalidParams(`Connector ${connectorName} is not configured`);
237
+ return;
238
+ }
239
+ // skip connector if it is hidden by user
240
+ if (!connectorConfig.showOnModal) return;
241
+ // skip external connector if external wallets are disabled or it is disabled or displayInstalledExternalWallets is false
242
+ if (connector.type === noModal.CONNECTOR_CATEGORY.EXTERNAL) {
243
+ if (!isExternalWalletEnabled) return;
244
+ if (disabledExternalWallets.has(connectorName)) return;
245
+ if (!isInstalledWalletWalletDisplayed) return;
209
246
  }
247
+ // skip WC connector if external wallets are disabled or hideWalletDiscovery is true
248
+ if (connectorName === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2) {
249
+ var _this$modalConfig5;
250
+ if (!isExternalWalletEnabled) return;
251
+ if ((_this$modalConfig5 = this.modalConfig) !== null && _this$modalConfig5 !== void 0 && _this$modalConfig5.hideWalletDiscovery) return;
252
+ }
253
+ this.modalConfig.connectors[connectorName] = connectorConfig;
254
+ return connectorName;
210
255
  });
211
- const connectorNames = await Promise.all(connectorConfigurationPromises);
256
+ // const connectorNames = await Promise.all(connectorConfigurationPromises);
212
257
  return connectorNames.filter(name => name !== undefined);
213
258
  }
214
- async checkConnectorAvailability(connectorNames, modalConfig) {
259
+ async checkConnectorAvailability(connectorNames) {
215
260
  // currently all default in app and external wallets can be hidden or shown based on config.
216
261
  // check if in app connectors are available
217
262
  const hasInAppConnectors = this.connectors.some(connector => {
218
- var _this$modalConfig$con8, _this$modalConfig$con9, _this$modalConfig$con10;
263
+ var _this$modalConfig$con3, _this$modalConfig$con4;
219
264
  if (connector.type !== noModal.CONNECTOR_CATEGORY.IN_APP) return false;
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;
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;
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);
223
- if (Object.values(mergedLoginMethods).some(method => method.showOnModal)) return true;
265
+ if (((_this$modalConfig$con3 = this.modalConfig.connectors) === null || _this$modalConfig$con3 === void 0 || (_this$modalConfig$con3 = _this$modalConfig$con3[connector.name]) === null || _this$modalConfig$con3 === void 0 ? void 0 : _this$modalConfig$con3.showOnModal) !== true) return false;
266
+ if (!((_this$modalConfig$con4 = this.modalConfig.connectors) !== null && _this$modalConfig$con4 !== void 0 && (_this$modalConfig$con4 = _this$modalConfig$con4[connector.name]) !== null && _this$modalConfig$con4 !== void 0 && _this$modalConfig$con4.loginMethods)) return true;
267
+ if (Object.values(this.modalConfig.connectors[connector.name].loginMethods).some(method => method.showOnModal)) return true;
224
268
  return false;
225
269
  });
226
270
  noModal.log.debug(hasInAppConnectors, this.connectors, connectorNames, "hasInAppWallets");
227
271
  // check if external connectors are available
228
272
  const hasExternalConnectors = connectorNames.some(connectorName => {
229
- var _this$getConnector, _this$modalConfig$con11;
230
- // if wallet connect connector is available but hideWalletDiscovery is true then don't consider it as external wallet
231
- if (connectorName === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2 && modalConfig !== null && modalConfig !== void 0 && modalConfig.hideWalletDiscovery) return false;
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);
273
+ var _this$getConnector, _this$modalConfig$con5;
274
+ if (connectorName === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2) return true;
275
+ return ((_this$getConnector = this.getConnector(connectorName)) === null || _this$getConnector === void 0 ? void 0 : _this$getConnector.type) === noModal.CONNECTOR_CATEGORY.EXTERNAL && ((_this$modalConfig$con5 = this.modalConfig.connectors) === null || _this$modalConfig$con5 === void 0 ? void 0 : _this$modalConfig$con5[connectorName].showOnModal);
233
276
  });
234
277
  return {
235
278
  hasInAppConnectors,
@@ -244,7 +287,7 @@ class Web3Auth extends noModal.Web3AuthNoModal {
244
287
  // skip if connector is already initialized
245
288
  if (connector.status !== noModal.CONNECTOR_STATUS.NOT_READY) return;
246
289
  // only initialize a external connectors here if it is a cached connector.
247
- if (this.cachedConnector !== connectorName && connector.type === noModal.CONNECTOR_CATEGORY.EXTERNAL) return;
290
+ if (this.cachedConnector !== connectorName && connectorName !== noModal.WALLET_CONNECTORS.METAMASK && connector.type === noModal.CONNECTOR_CATEGORY.EXTERNAL) return;
248
291
  // in-app wallets or cached wallet (being connected or already connected) are initialized first.
249
292
  // if connector is configured then only initialize in app or cached connector.
250
293
  // external wallets are initialized on INIT_EXTERNAL_WALLET event.
@@ -257,9 +300,9 @@ class Web3Auth extends noModal.Web3AuthNoModal {
257
300
  // note: not adding cachedWallet to modal if it is external wallet.
258
301
  // adding it later if no in-app wallets are available.
259
302
  if (connector.type === noModal.CONNECTOR_CATEGORY.IN_APP) {
260
- var _this$modalConfig$con12, _this$options$uiConfi, _this$options$uiConfi2, _this$options$uiConfi3;
303
+ var _this$modalConfig$con6, _this$options$uiConfi, _this$options$uiConfi2, _this$options$uiConfi3;
261
304
  noModal.log.info("connectorInitResults", connectorName);
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);
305
+ const loginMethods = ((_this$modalConfig$con6 = this.modalConfig.connectors[connectorName]) === null || _this$modalConfig$con6 === void 0 ? void 0 : _this$modalConfig$con6.loginMethods) || {};
263
306
  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), {}, {
264
307
  loginGridCol: ((_this$options$uiConfi2 = this.options.uiConfig) === null || _this$options$uiConfi2 === void 0 ? void 0 : _this$options$uiConfi2.loginGridCol) || 3,
265
308
  primaryButton: ((_this$options$uiConfi3 = this.options.uiConfig) === null || _this$options$uiConfi3 === void 0 ? void 0 : _this$options$uiConfi3.primaryButton) || "socialLogin"
@@ -87,18 +87,7 @@ function Web3AuthInnerProvider(params) {
87
87
  try {
88
88
  setInitError(null);
89
89
  setIsInitializing(true);
90
- const {
91
- modalConfig,
92
- hideWalletDiscovery
93
- } = config;
94
- if (modalConfig) {
95
- await web3Auth.initModal({
96
- modalConfig,
97
- hideWalletDiscovery
98
- });
99
- } else {
100
- await web3Auth.initModal();
101
- }
90
+ await web3Auth.initModal();
102
91
  } catch (error) {
103
92
  setInitError(error);
104
93
  } finally {
@@ -38,7 +38,7 @@ function ExternalWallets(props) {
38
38
  i18n: localeImport
39
39
  });
40
40
  const walletDiscoverySupported = React.useMemo(() => {
41
- const supported = walletRegistry && Object.keys(walletRegistry.default).length > 0 && Object.keys(walletRegistry.others).length > 0;
41
+ const supported = walletRegistry && (Object.keys(walletRegistry.default).length > 0 || Object.keys(walletRegistry.others).length > 0);
42
42
  return supported;
43
43
  }, [walletRegistry]);
44
44
  const deviceDetails = React.useMemo(() => {
@@ -86,11 +86,12 @@ function ExternalWallets(props) {
86
86
  React.useEffect(() => {
87
87
  if (walletDiscoverySupported) {
88
88
  const isWalletConnectAdapterIncluded = Object.keys(config).some(adapter => adapter === noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2);
89
- const defaultButtonKeys = new Set(Object.keys(walletRegistry.default));
90
89
  const generateWalletButtons = wallets => {
91
90
  return Object.keys(wallets).reduce((acc, wallet) => {
92
91
  var _walletRegistryItem$c, _walletRegistryItem$i, _config$wallet, _walletRegistryItem$w;
93
92
  if (adapterVisibilityMap[wallet] === false) return acc;
93
+ // Metamask is always visible in the main screen, no need to show it in the external wallets list
94
+ if (wallet === noModal.WALLET_CONNECTORS.METAMASK) return acc;
94
95
  const walletRegistryItem = wallets[wallet];
95
96
  let href = "";
96
97
  if (deviceDetails.platform === Bowser.PLATFORMS_MAP.mobile) {
@@ -125,6 +126,8 @@ function ExternalWallets(props) {
125
126
  const otherButtons = generateWalletButtons(walletRegistry.others);
126
127
  // Generate custom adapter buttons
127
128
  const customAdapterButtons = Object.keys(config).reduce((acc, adapter) => {
129
+ // Metamask is always visible in the main screen, no need to show it in the external wallets list
130
+ if (adapter === noModal.WALLET_CONNECTORS.METAMASK) return acc;
128
131
  if (![noModal.WALLET_CONNECTORS.WALLET_CONNECT_V2].includes(adapter) && !config[adapter].isInjected && adapterVisibilityMap[adapter]) {
129
132
  noModal.log.debug("custom adapter", adapter, config[adapter]);
130
133
  acc.push({
@@ -144,6 +147,8 @@ function ExternalWallets(props) {
144
147
  noModal.log.debug("filteredLists", filteredList);
145
148
  setExternalButtons(filteredList);
146
149
  } else {
150
+ const finalDefaultButtons = defaultButtons.length > 0 ? defaultButtons : allButtons.slice(0, 10);
151
+ const defaultButtonKeys = new Set(finalDefaultButtons.map(button => button.name));
147
152
  const sortedButtons = [...allButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customAdapterButtons, ...allButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))];
148
153
  setExternalButtons(sortedButtons);
149
154
  }
@@ -199,7 +204,7 @@ function ExternalWallets(props) {
199
204
  }), totalExternalWallets > 15 && jsxRuntime.jsx("div", {
200
205
  className: "w3a--py-4",
201
206
  children: jsxRuntime.jsx("input", {
202
- className: "w3a--w-full w3a-text-field",
207
+ className: "w3a-text-field w3a--w-full",
203
208
  name: "passwordless-input",
204
209
  required: true,
205
210
  value: walletSearch,
@@ -217,7 +222,7 @@ function ExternalWallets(props) {
217
222
  onChange: e => handleWalletSearch(e)
218
223
  })
219
224
  }), externalButtons.length === 0 ? jsxRuntime.jsx("div", {
220
- className: "w3a--w-full w3a--text-center w3a--text-app-gray-400 dark:w3a--text-app-gray-500 w3a--py-6 w3a--flex w3a--justify-center w3a--items-center",
225
+ className: "w3a--flex w3a--w-full w3a--items-center w3a--justify-center w3a--py-6 w3a--text-center w3a--text-app-gray-400 dark:w3a--text-app-gray-500",
221
226
  children: t("modal.external.no-wallets-found")
222
227
  }) : jsxRuntime.jsx("div", {
223
228
  className: `w3a-adapter-list-container ${totalExternalWallets < 15 ? "w3a--py-4" : ""}`,
@@ -247,7 +252,7 @@ function ExternalWallets(props) {
247
252
  }))]
248
253
  }, button.name + button.displayName);
249
254
  }), totalExternalWallets > 10 && !walletSearch && jsxRuntime.jsxs("li", {
250
- className: "w3a--flex w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-0.5 w3a--my-4 w3a--w-full w3a--mx-auto w3a-adapter-item--full",
255
+ className: "w3a-adapter-item--full w3a--mx-auto w3a--my-4 w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-0.5",
251
256
  children: [jsxRuntime.jsx("p", {
252
257
  className: "w3a--text-xs w3a--text-app-gray-500 dark:w3a--text-app-gray-400",
253
258
  children: t("modal.external.search-text")
@@ -14,6 +14,7 @@ var Button = require('./Button/Button.js');
14
14
  var ExternalWallets = require('./ExternalWallets.js');
15
15
  var Footer = require('./Footer.js');
16
16
  var Header = require('./Header.js');
17
+ var Image = require('./Image.js');
17
18
  var SocialLoginPasswordless = require('./SocialLoginPasswordless.js');
18
19
  var SocialLogins = require('./SocialLogins.js');
19
20
 
@@ -139,7 +140,7 @@ function Modal(props) {
139
140
  children: jsxRuntime.jsx(Button, {
140
141
  variant: isExternalPrimary ? "primary" : "tertiary",
141
142
  type: "button",
142
- className: "w3a--w-full w3ajs-external-toggle__button",
143
+ className: "w3ajs-external-toggle__button w3a--w-full",
143
144
  style: {
144
145
  width: "100%"
145
146
  },
@@ -159,6 +160,39 @@ function Modal(props) {
159
160
  })
160
161
  })
161
162
  });
163
+ const metamaskWalletButton = jsxRuntime.jsx("div", {
164
+ className: "w3ajs-external-wallet w3a-group w3a--w-full",
165
+ children: jsxRuntime.jsx("div", {
166
+ className: "w3a-external-toggle w3ajs-external-toggle",
167
+ children: jsxRuntime.jsxs(Button, {
168
+ variant: isExternalPrimary ? "primary" : "tertiary",
169
+ type: "button",
170
+ className: "w3a--w-full w3ajs-external-toggle__button",
171
+ style: {
172
+ width: "100%"
173
+ },
174
+ onClick: () => {
175
+ preHandleExternalWalletClick({
176
+ connector: noModal.WALLET_CONNECTORS.METAMASK
177
+ });
178
+ },
179
+ children: [jsxRuntime.jsx(Image, {
180
+ imageId: "login-metamask",
181
+ hoverImageId: "login-metamask",
182
+ fallbackImageId: "wallet",
183
+ height: "24",
184
+ width: "24",
185
+ isButton: true,
186
+ extension: "svg"
187
+ }), jsxRuntime.jsx("span", {
188
+ className: "ml-2",
189
+ children: t("modal.external.continue-custom", {
190
+ wallet: "MetaMask"
191
+ })
192
+ })]
193
+ })
194
+ })
195
+ });
162
196
  const areSocialLoginsVisible = React.useMemo(() => {
163
197
  var _modalState$socialLog3, _modalState$socialLog4;
164
198
  if (modalState.showExternalWalletsOnly) return false;
@@ -216,7 +250,7 @@ function Modal(props) {
216
250
  handleSocialLoginClick: params => preHandleSocialWalletClick(params),
217
251
  socialLoginsConfig: modalState.socialLoginsConfig,
218
252
  isPrimaryBtn: isEmailPrimary
219
- }), modalState.hasExternalWallets && externalWalletButton]
253
+ }), metamaskWalletButton, modalState.hasExternalWallets && externalWalletButton]
220
254
  })]
221
255
  }) : jsxRuntime.jsx("div", {
222
256
  className: "w3a-modal__content_external_wallet w3ajs-content",
@@ -36,7 +36,8 @@ function SocialLoginPasswordless(props) {
36
36
  loginParams: {
37
37
  authConnection: auth.AUTH_CONNECTION.EMAIL_PASSWORDLESS,
38
38
  authConnectionId: emailConfig.authConnectionId,
39
- groupedAuthConnectionId: "",
39
+ groupedAuthConnectionId: emailConfig.groupedAuthConnectionId,
40
+ extraLoginOptions: emailConfig.extraLoginOptions,
40
41
  login_hint: value,
41
42
  name: "Email"
42
43
  }
@@ -54,6 +55,7 @@ function SocialLoginPasswordless(props) {
54
55
  authConnection: auth.AUTH_CONNECTION.SMS_PASSWORDLESS,
55
56
  authConnectionId: smsConfig.authConnectionId,
56
57
  groupedAuthConnectionId: smsConfig.groupedAuthConnectionId,
58
+ extraLoginOptions: smsConfig.extraLoginOptions,
57
59
  login_hint: typeof result === "string" ? result : number,
58
60
  name: "Mobile"
59
61
  }
@@ -96,16 +98,16 @@ function SocialLoginPasswordless(props) {
96
98
  children: [jsxRuntime.jsxs("div", {
97
99
  className: "w3a-group__title",
98
100
  children: [t(title), isSmsVisible && jsxRuntime.jsxs("div", {
99
- className: "w3a--relative w3a--flex w3a--flex-col w3a--items-center w3a--cursor-pointer w3a--group",
101
+ className: "w3a--group w3a--relative w3a--flex w3a--cursor-pointer w3a--flex-col w3a--items-center",
100
102
  children: [jsxRuntime.jsx(Icon, {
101
103
  iconName: "information-circle-light",
102
104
  darkIconName: "information-circle"
103
105
  }), jsxRuntime.jsxs("div", {
104
- className: "w3a--absolute w3a--z-20 w3a--flex-col w3a--items-center w3a--hidden w3a--mb-5 w3a--top-4 group-hover:w3a--flex",
106
+ className: "w3a--absolute w3a--top-4 w3a--z-20 w3a--mb-5 w3a--hidden w3a--flex-col w3a--items-center group-hover:w3a--flex",
105
107
  children: [jsxRuntime.jsx("div", {
106
- className: "w3a--w-3 w3a--h-3 w3a--ml-[3px] -w3a--mb-2 w3a--rotate-45 w3a--bg-app-gray-50 dark:w3a--bg-app-gray-600"
108
+ className: "-w3a--mb-2 w3a--ml-[3px] w3a--size-3 w3a--rotate-45 w3a--bg-app-gray-50 dark:w3a--bg-app-gray-600"
107
109
  }), jsxRuntime.jsxs("div", {
108
- className: `w3a--relative w3a--p-4 w3a--w-[300px] w3a--text-xs w3a--leading-none w3a--text-app-white w3a--rounded-md w3a--bg-app-gray-50 dark:w3a--bg-app-gray-600 w3a--shadow-lg ${isSmsVisible && !isEmailVisible ? "w3a--left-20" : "w3a--left-8"}`,
110
+ className: `w3a--relative w3a--w-[300px] w3a--rounded-md w3a--bg-app-gray-50 w3a--p-4 w3a--text-xs w3a--leading-none w3a--text-app-white w3a--shadow-lg dark:w3a--bg-app-gray-600 ${isSmsVisible && !isEmailVisible ? "w3a--left-20" : "w3a--left-8"}`,
109
111
  children: [jsxRuntime.jsx("div", {
110
112
  className: "w3a--mb-1 w3a--text-xs w3a--font-medium w3a--text-app-gray-900 dark:w3a--text-app-white",
111
113
  children: t("modal.popup.phone-header")
@@ -120,7 +122,7 @@ function SocialLoginPasswordless(props) {
120
122
  className: "w3ajs-passwordless-form",
121
123
  onSubmit: e => handleFormSubmit(e),
122
124
  children: [jsxRuntime.jsx("input", {
123
- className: "w3a--w-full w3a--mb-4 w3a-text-field",
125
+ className: "w3a-text-field w3a--mb-4 w3a--w-full",
124
126
  name: "passwordless-input",
125
127
  required: true,
126
128
  placeholder: `${t("modal.social.sms-placeholder-text")} ${placeholder}`,
@@ -81,7 +81,7 @@ function SocialLogins(props) {
81
81
  const loginMethodSpan = classNames("w3a-adapter-item", (socialLoginsConfig === null || socialLoginsConfig === void 0 || (_socialLoginsConfig$u2 = socialLoginsConfig.uiConfig) === null || _socialLoginsConfig$u2 === void 0 ? void 0 : _socialLoginsConfig$u2.loginGridCol) === 2 ? "w3a--col-span-3" : "w3a--col-span-2");
82
82
  if (isMainOption || order === 1) {
83
83
  return jsxRuntime.jsx("li", {
84
- className: "w3a--col-span-6 w3a-adapter-item",
84
+ className: "w3a-adapter-item w3a--col-span-6",
85
85
  style: {
86
86
  order
87
87
  },
@@ -94,6 +94,7 @@ function SocialLogins(props) {
94
94
  name: socialLoginConfig.name,
95
95
  authConnectionId: socialLoginConfig.authConnectionId,
96
96
  groupedAuthConnectionId: socialLoginConfig.groupedAuthConnectionId,
97
+ extraLoginOptions: socialLoginConfig.extraLoginOptions,
97
98
  login_hint: ""
98
99
  }
99
100
  }),