@web3auth/no-modal 8.0.1 → 8.1.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.
@@ -68,6 +68,274 @@ const base_namespaceObject = require("@web3auth/base");
68
68
  const base_plugin_namespaceObject = require("@web3auth/base-plugin");
69
69
  ;// CONCATENATED MODULE: external "@web3auth/base-provider"
70
70
  const base_provider_namespaceObject = require("@web3auth/base-provider");
71
+ ;// CONCATENATED MODULE: external "@toruslabs/openlogin-utils"
72
+ const openlogin_utils_namespaceObject = require("@toruslabs/openlogin-utils");
73
+ ;// CONCATENATED MODULE: external "@toruslabs/openlogin"
74
+ const openlogin_namespaceObject = require("@toruslabs/openlogin");
75
+ var openlogin_default = /*#__PURE__*/__webpack_require__.n(openlogin_namespaceObject);
76
+ ;// CONCATENATED MODULE: external "lodash.merge"
77
+ const external_lodash_merge_namespaceObject = require("lodash.merge");
78
+ var external_lodash_merge_default = /*#__PURE__*/__webpack_require__.n(external_lodash_merge_namespaceObject);
79
+ ;// CONCATENATED MODULE: ../adapters/openlogin-adapter/dist/openloginAdapter.esm.js
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+ const getOpenloginDefaultOptions = () => {
88
+ return {
89
+ adapterSettings: {
90
+ network: openlogin_utils_namespaceObject.OPENLOGIN_NETWORK.SAPPHIRE_MAINNET,
91
+ clientId: "",
92
+ uxMode: openlogin_utils_namespaceObject.UX_MODE.POPUP
93
+ },
94
+ loginSettings: {},
95
+ privateKeyProvider: undefined
96
+ };
97
+ };
98
+ class OpenloginAdapter extends base_namespaceObject.BaseAdapter {
99
+ constructor() {
100
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
101
+ super(params);
102
+ defineProperty_default()(this, "name", base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN);
103
+ defineProperty_default()(this, "adapterNamespace", base_namespaceObject.ADAPTER_NAMESPACES.MULTICHAIN);
104
+ defineProperty_default()(this, "type", base_namespaceObject.ADAPTER_CATEGORY.IN_APP);
105
+ defineProperty_default()(this, "openloginInstance", null);
106
+ defineProperty_default()(this, "status", base_namespaceObject.ADAPTER_STATUS.NOT_READY);
107
+ defineProperty_default()(this, "currentChainNamespace", base_namespaceObject.CHAIN_NAMESPACES.EIP155);
108
+ defineProperty_default()(this, "privateKeyProvider", null);
109
+ defineProperty_default()(this, "openloginOptions", void 0);
110
+ defineProperty_default()(this, "loginSettings", {
111
+ loginProvider: ""
112
+ });
113
+ this.setAdapterSettings(objectSpread2_default()(objectSpread2_default()({}, params.adapterSettings), {}, {
114
+ chainConfig: params.chainConfig,
115
+ clientId: params.clientId || "",
116
+ sessionTime: params.sessionTime,
117
+ web3AuthNetwork: params.web3AuthNetwork,
118
+ useCoreKitKey: params.useCoreKitKey,
119
+ privateKeyProvider: params.privateKeyProvider
120
+ }));
121
+ this.loginSettings = params.loginSettings || {
122
+ loginProvider: ""
123
+ };
124
+ this.privateKeyProvider = params.privateKeyProvider || null;
125
+ }
126
+ get chainConfigProxy() {
127
+ return this.chainConfig ? objectSpread2_default()({}, this.chainConfig) : null;
128
+ }
129
+ get provider() {
130
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.NOT_READY && this.privateKeyProvider) {
131
+ return this.privateKeyProvider;
132
+ }
133
+ return null;
134
+ }
135
+ set provider(_) {
136
+ throw new Error("Not implemented");
137
+ }
138
+ async init(options) {
139
+ super.checkInitializationRequirements();
140
+ if (!this.clientId) throw base_namespaceObject.WalletInitializationError.invalidParams("clientId is required before openlogin's initialization");
141
+ if (!this.openloginOptions) throw base_namespaceObject.WalletInitializationError.invalidParams("openloginOptions is required before openlogin's initialization");
142
+ const isRedirectResult = this.openloginOptions.uxMode === openlogin_utils_namespaceObject.UX_MODE.REDIRECT;
143
+ this.openloginOptions = objectSpread2_default()(objectSpread2_default()({}, this.openloginOptions), {}, {
144
+ replaceUrlOnRedirect: isRedirectResult
145
+ });
146
+ this.openloginInstance = new (openlogin_default())(objectSpread2_default()(objectSpread2_default()({}, this.openloginOptions), {}, {
147
+ clientId: this.clientId,
148
+ network: this.openloginOptions.network || this.web3AuthNetwork || openlogin_utils_namespaceObject.OPENLOGIN_NETWORK.SAPPHIRE_MAINNET
149
+ }));
150
+ base_namespaceObject.log.debug("initializing openlogin adapter init");
151
+ await this.openloginInstance.init();
152
+ if (!this.chainConfig) throw base_namespaceObject.WalletInitializationError.invalidParams("chainConfig is required before initialization");
153
+ this.status = base_namespaceObject.ADAPTER_STATUS.READY;
154
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.READY, base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN);
155
+ try {
156
+ base_namespaceObject.log.debug("initializing openlogin adapter");
157
+ const finalPrivKey = this._getFinalPrivKey();
158
+ // connect only if it is redirect result or if connect (adapter is cached/already connected in same session) is true
159
+ if (finalPrivKey && (options.autoConnect || isRedirectResult)) {
160
+ this.rehydrated = true;
161
+ await this.connect();
162
+ }
163
+ } catch (error) {
164
+ base_namespaceObject.log.error("Failed to connect with cached openlogin provider", error);
165
+ this.emit("ERRORED", error);
166
+ }
167
+ }
168
+ async connect() {
169
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
170
+ loginProvider: ""
171
+ };
172
+ super.checkConnectionRequirements();
173
+ this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTING;
174
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTING, objectSpread2_default()(objectSpread2_default()({}, params), {}, {
175
+ adapter: base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN
176
+ }));
177
+ try {
178
+ await this.connectWithProvider(params);
179
+ return this.provider;
180
+ } catch (error) {
181
+ base_namespaceObject.log.error("Failed to connect with openlogin provider", error);
182
+ // ready again to be connected
183
+ this.status = base_namespaceObject.ADAPTER_STATUS.READY;
184
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.ERRORED, error);
185
+ if (error !== null && error !== void 0 && error.message.includes("user closed popup")) {
186
+ throw base_namespaceObject.WalletLoginError.popupClosed();
187
+ } else if (error instanceof base_namespaceObject.Web3AuthError) {
188
+ throw error;
189
+ }
190
+ throw base_namespaceObject.WalletLoginError.connectionError("Failed to login with openlogin");
191
+ }
192
+ }
193
+ async enableMFA() {
194
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
195
+ loginProvider: ""
196
+ };
197
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet");
198
+ if (!this.openloginInstance) throw base_namespaceObject.WalletInitializationError.notReady("openloginInstance is not ready");
199
+ try {
200
+ await this.openloginInstance.enableMFA(params);
201
+ } catch (error) {
202
+ base_namespaceObject.log.error("Failed to enable MFA with openlogin provider", error);
203
+ if (error instanceof base_namespaceObject.Web3AuthError) {
204
+ throw error;
205
+ }
206
+ throw base_namespaceObject.WalletLoginError.connectionError(error.message || "Failed to enable MFA with openlogin");
207
+ }
208
+ }
209
+ async disconnect() {
210
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
211
+ cleanup: false
212
+ };
213
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet");
214
+ if (!this.openloginInstance) throw base_namespaceObject.WalletInitializationError.notReady("openloginInstance is not ready");
215
+ await this.openloginInstance.logout();
216
+ if (options.cleanup) {
217
+ this.status = base_namespaceObject.ADAPTER_STATUS.NOT_READY;
218
+ this.openloginInstance = null;
219
+ this.privateKeyProvider = null;
220
+ } else {
221
+ // ready to be connected again
222
+ this.status = base_namespaceObject.ADAPTER_STATUS.READY;
223
+ }
224
+ this.rehydrated = false;
225
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.DISCONNECTED);
226
+ }
227
+ async authenticateUser() {
228
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet, Please login/connect first");
229
+ const userInfo = await this.getUserInfo();
230
+ return {
231
+ idToken: userInfo.idToken
232
+ };
233
+ }
234
+ async getUserInfo() {
235
+ if (this.status !== base_namespaceObject.ADAPTER_STATUS.CONNECTED) throw base_namespaceObject.WalletLoginError.notConnectedError("Not connected with wallet");
236
+ if (!this.openloginInstance) throw base_namespaceObject.WalletInitializationError.notReady("openloginInstance is not ready");
237
+ const userInfo = this.openloginInstance.getUserInfo();
238
+ return userInfo;
239
+ }
240
+
241
+ // should be called only before initialization.
242
+ setAdapterSettings(adapterSettings) {
243
+ super.setAdapterSettings(adapterSettings);
244
+ const defaultOptions = getOpenloginDefaultOptions();
245
+ base_namespaceObject.log.info("setting adapter settings", adapterSettings);
246
+ this.openloginOptions = objectSpread2_default()(objectSpread2_default()(objectSpread2_default()({}, defaultOptions.adapterSettings), this.openloginOptions), adapterSettings);
247
+ if (adapterSettings.web3AuthNetwork) {
248
+ this.openloginOptions.network = adapterSettings.web3AuthNetwork;
249
+ }
250
+ if (adapterSettings.privateKeyProvider) {
251
+ this.privateKeyProvider = adapterSettings.privateKeyProvider;
252
+ }
253
+ }
254
+ async addChain(chainConfig) {
255
+ var _this$privateKeyProvi;
256
+ let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
257
+ super.checkAddChainRequirements(chainConfig, init);
258
+ (_this$privateKeyProvi = this.privateKeyProvider) === null || _this$privateKeyProvi === void 0 || _this$privateKeyProvi.addChain(chainConfig);
259
+ this.addChainConfig(chainConfig);
260
+ }
261
+ async switchChain(params) {
262
+ var _this$privateKeyProvi2;
263
+ let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
264
+ super.checkSwitchChainRequirements(params, init);
265
+ await ((_this$privateKeyProvi2 = this.privateKeyProvider) === null || _this$privateKeyProvi2 === void 0 ? void 0 : _this$privateKeyProvi2.switchChain(params));
266
+ this.setAdapterSettings({
267
+ chainConfig: this.getChainConfig(params.chainId)
268
+ });
269
+ }
270
+ _getFinalPrivKey() {
271
+ if (!this.openloginInstance) return "";
272
+ let finalPrivKey = this.openloginInstance.privKey;
273
+ // coreKitKey is available only for custom verifiers by default
274
+ if (this.useCoreKitKey) {
275
+ // this is to check if the user has already logged in but coreKitKey is not available.
276
+ // when useCoreKitKey is set to true.
277
+ // This is to ensure that when there is no user session active, we don't throw an exception.
278
+ if (this.openloginInstance.privKey && !this.openloginInstance.coreKitKey) {
279
+ throw base_namespaceObject.WalletLoginError.coreKitKeyNotFound();
280
+ }
281
+ finalPrivKey = this.openloginInstance.coreKitKey;
282
+ }
283
+ return finalPrivKey;
284
+ }
285
+ _getFinalEd25519PrivKey() {
286
+ if (!this.openloginInstance) return "";
287
+ let finalPrivKey = this.openloginInstance.ed25519PrivKey;
288
+ // coreKitKey is available only for custom verifiers by default
289
+ if (this.useCoreKitKey) {
290
+ // this is to check if the user has already logged in but coreKitKey is not available.
291
+ // when useCoreKitKey is set to true.
292
+ // This is to ensure that when there is no user session active, we don't throw an exception.
293
+ if (this.openloginInstance.ed25519PrivKey && !this.openloginInstance.coreKitEd25519Key) {
294
+ throw base_namespaceObject.WalletLoginError.coreKitKeyNotFound();
295
+ }
296
+ finalPrivKey = this.openloginInstance.coreKitEd25519Key;
297
+ }
298
+ return finalPrivKey;
299
+ }
300
+ async connectWithProvider() {
301
+ var _params$extraLoginOpt;
302
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
303
+ loginProvider: ""
304
+ };
305
+ if (!this.privateKeyProvider) throw base_namespaceObject.WalletInitializationError.invalidParams("PrivateKey Provider is required before initialization");
306
+ if (!this.openloginInstance) throw base_namespaceObject.WalletInitializationError.notReady("openloginInstance is not ready");
307
+ const keyAvailable = this._getFinalPrivKey();
308
+ // if not logged in then login
309
+ if (!keyAvailable || (_params$extraLoginOpt = params.extraLoginOptions) !== null && _params$extraLoginOpt !== void 0 && _params$extraLoginOpt.id_token) {
310
+ var _params$extraLoginOpt2;
311
+ if (!this.loginSettings.curve) {
312
+ this.loginSettings.curve = this.currentChainNamespace === base_namespaceObject.CHAIN_NAMESPACES.SOLANA ? openlogin_utils_namespaceObject.SUPPORTED_KEY_CURVES.ED25519 : openlogin_utils_namespaceObject.SUPPORTED_KEY_CURVES.SECP256K1;
313
+ }
314
+ if (!params.loginProvider && !this.loginSettings.loginProvider) throw base_namespaceObject.WalletInitializationError.invalidParams("loginProvider is required for login");
315
+ await this.openloginInstance.login(external_lodash_merge_default()(this.loginSettings, params, {
316
+ extraLoginOptions: objectSpread2_default()(objectSpread2_default()({}, params.extraLoginOptions || {}), {}, {
317
+ login_hint: params.login_hint || ((_params$extraLoginOpt2 = params.extraLoginOptions) === null || _params$extraLoginOpt2 === void 0 ? void 0 : _params$extraLoginOpt2.login_hint)
318
+ })
319
+ }));
320
+ }
321
+ let finalPrivKey = this._getFinalPrivKey();
322
+ if (finalPrivKey) {
323
+ if (this.currentChainNamespace === base_namespaceObject.CHAIN_NAMESPACES.SOLANA) {
324
+ finalPrivKey = this._getFinalEd25519PrivKey();
325
+ }
326
+ await this.privateKeyProvider.setupProvider(finalPrivKey);
327
+ this.status = base_namespaceObject.ADAPTER_STATUS.CONNECTED;
328
+ this.emit(base_namespaceObject.ADAPTER_EVENTS.CONNECTED, {
329
+ adapter: base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN,
330
+ reconnected: this.rehydrated
331
+ });
332
+ }
333
+ }
334
+ }
335
+
336
+ ;// CONCATENATED MODULE: external "lodash.clonedeep"
337
+ const external_lodash_clonedeep_namespaceObject = require("lodash.clonedeep");
338
+ var external_lodash_clonedeep_default = /*#__PURE__*/__webpack_require__.n(external_lodash_clonedeep_namespaceObject);
71
339
  ;// CONCATENATED MODULE: ./src/noModal.ts
72
340
 
73
341
 
@@ -75,6 +343,9 @@ const base_provider_namespaceObject = require("@web3auth/base-provider");
75
343
 
76
344
 
77
345
 
346
+
347
+
348
+
78
349
  const ADAPTER_CACHE_KEY = "Web3Auth-cachedAdapter";
79
350
  class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
80
351
  constructor(options) {
@@ -118,9 +389,13 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
118
389
  this.commonJRPCProvider = await base_provider_namespaceObject.CommonJRPCProvider.getProviderInstance({
119
390
  chainConfig: this.coreOptions.chainConfig
120
391
  });
121
- // TODO: get stuff from dashboard here
122
- // disable sms login
123
- const initPromises = Object.keys(this.walletAdapters).map(adapterName => {
392
+ let projectConfig;
393
+ try {
394
+ projectConfig = await (0,base_namespaceObject.fetchProjectConfig)(this.coreOptions.clientId);
395
+ } catch (e) {
396
+ throw base_namespaceObject.WalletInitializationError.notReady("failed to fetch project configurations");
397
+ }
398
+ const initPromises = Object.keys(this.walletAdapters).map(async adapterName => {
124
399
  this.subscribeToAdapterEvents(this.walletAdapters[adapterName]);
125
400
  // if adapter doesn't have any chain config yet then set it based on provided namespace and chainId.
126
401
  // if no chainNamespace or chainId is being provided, it will connect with mainnet.
@@ -144,6 +419,25 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
144
419
  }
145
420
  if (adapterName === base_namespaceObject.WALLET_ADAPTERS.OPENLOGIN) {
146
421
  const openloginAdapter = this.walletAdapters[adapterName];
422
+ const {
423
+ whitelabel
424
+ } = projectConfig;
425
+ this.coreOptions.uiConfig = external_lodash_merge_default()(external_lodash_clonedeep_default()(whitelabel), this.coreOptions.uiConfig);
426
+ const {
427
+ sms_otp_enabled: smsOtpEnabled
428
+ } = projectConfig;
429
+ if (smsOtpEnabled !== undefined) {
430
+ openloginAdapter.setAdapterSettings({
431
+ loginConfig: {
432
+ [openlogin_utils_namespaceObject.LOGIN_PROVIDER.SMS_PASSWORDLESS]: {
433
+ showOnModal: smsOtpEnabled,
434
+ showOnDesktop: smsOtpEnabled,
435
+ showOnMobile: smsOtpEnabled,
436
+ showOnSocialBackupFactor: smsOtpEnabled
437
+ }
438
+ }
439
+ });
440
+ }
147
441
  if (this.coreOptions.privateKeyProvider) {
148
442
  if (openloginAdapter.currentChainNamespace !== this.coreOptions.privateKeyProvider.currentChainConfig.chainNamespace) {
149
443
  throw base_namespaceObject.WalletInitializationError.incompatibleChainNameSpace("private key provider is not compatible with provided chainNamespace for openlogin adapter");
@@ -160,11 +454,18 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
160
454
  }
161
455
  } else if (adapterName === base_namespaceObject.WALLET_ADAPTERS.WALLET_CONNECT_V2) {
162
456
  const walletConnectAdapter = this.walletAdapters[adapterName];
457
+ const {
458
+ wallet_connect_enabled: walletConnectEnabled,
459
+ wallet_connect_project_id: walletConnectProjectId
460
+ } = projectConfig;
461
+ if (walletConnectEnabled === false) {
462
+ throw base_namespaceObject.WalletInitializationError.invalidParams("Please enable wallet connect v2 addon on dashboard");
463
+ }
464
+ if (!walletConnectProjectId) throw base_namespaceObject.WalletInitializationError.invalidParams("Invalid wallet connect project id. Please configure it on the dashboard");
163
465
  walletConnectAdapter.setAdapterSettings({
164
466
  adapterSettings: {
165
467
  walletConnectInitOptions: {
166
- // Using a default wallet connect project id for web3auth modal integration
167
- projectId: "d3c63f19f9582f8ba48e982057eb096b" // TODO: get from dashboard
468
+ projectId: walletConnectProjectId
168
469
  }
169
470
  }
170
471
  });
@@ -173,8 +474,8 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
173
474
  autoConnect: this.cachedAdapter === adapterName
174
475
  }).catch(e => base_namespaceObject.log.error(e));
175
476
  });
176
- this.status = base_namespaceObject.ADAPTER_STATUS.READY;
177
477
  await Promise.all(initPromises);
478
+ this.status = base_namespaceObject.ADAPTER_STATUS.READY;
178
479
  }
179
480
  getAdapter(adapterName) {
180
481
  return this.walletAdapters[adapterName] || null;
@@ -340,5 +641,4 @@ class Web3AuthNoModal extends openlogin_jrpc_namespaceObject.SafeEventEmitter {
340
641
 
341
642
  module.exports = __webpack_exports__;
342
643
  /******/ })()
343
- ;
344
- //# sourceMappingURL=noModal.cjs.js.map
644
+ ;
@@ -1,9 +1,12 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
3
  import { SafeEventEmitter } from '@toruslabs/openlogin-jrpc';
4
- import { ADAPTER_STATUS, WalletInitializationError, log, CHAIN_NAMESPACES, storageAvailable, getChainConfig, WALLET_ADAPTERS, ADAPTER_NAMESPACES, WalletLoginError, ADAPTER_EVENTS } from '@web3auth/base';
4
+ import { ADAPTER_STATUS, WalletInitializationError, log, CHAIN_NAMESPACES, storageAvailable, getChainConfig, fetchProjectConfig, WALLET_ADAPTERS, ADAPTER_NAMESPACES, WalletLoginError, ADAPTER_EVENTS } from '@web3auth/base';
5
5
  import { PLUGIN_NAMESPACES } from '@web3auth/base-plugin';
6
6
  import { CommonJRPCProvider } from '@web3auth/base-provider';
7
+ import { LOGIN_PROVIDER } from '@web3auth/openlogin-adapter';
8
+ import clonedeep from 'lodash.clonedeep';
9
+ import merge from 'lodash.merge';
7
10
 
8
11
  const ADAPTER_CACHE_KEY = "Web3Auth-cachedAdapter";
9
12
  class Web3AuthNoModal extends SafeEventEmitter {
@@ -48,9 +51,13 @@ class Web3AuthNoModal extends SafeEventEmitter {
48
51
  this.commonJRPCProvider = await CommonJRPCProvider.getProviderInstance({
49
52
  chainConfig: this.coreOptions.chainConfig
50
53
  });
51
- // TODO: get stuff from dashboard here
52
- // disable sms login
53
- const initPromises = Object.keys(this.walletAdapters).map(adapterName => {
54
+ let projectConfig;
55
+ try {
56
+ projectConfig = await fetchProjectConfig(this.coreOptions.clientId);
57
+ } catch (e) {
58
+ throw WalletInitializationError.notReady("failed to fetch project configurations");
59
+ }
60
+ const initPromises = Object.keys(this.walletAdapters).map(async adapterName => {
54
61
  this.subscribeToAdapterEvents(this.walletAdapters[adapterName]);
55
62
  // if adapter doesn't have any chain config yet then set it based on provided namespace and chainId.
56
63
  // if no chainNamespace or chainId is being provided, it will connect with mainnet.
@@ -74,6 +81,25 @@ class Web3AuthNoModal extends SafeEventEmitter {
74
81
  }
75
82
  if (adapterName === WALLET_ADAPTERS.OPENLOGIN) {
76
83
  const openloginAdapter = this.walletAdapters[adapterName];
84
+ const {
85
+ whitelabel
86
+ } = projectConfig;
87
+ this.coreOptions.uiConfig = merge(clonedeep(whitelabel), this.coreOptions.uiConfig);
88
+ const {
89
+ sms_otp_enabled: smsOtpEnabled
90
+ } = projectConfig;
91
+ if (smsOtpEnabled !== undefined) {
92
+ openloginAdapter.setAdapterSettings({
93
+ loginConfig: {
94
+ [LOGIN_PROVIDER.SMS_PASSWORDLESS]: {
95
+ showOnModal: smsOtpEnabled,
96
+ showOnDesktop: smsOtpEnabled,
97
+ showOnMobile: smsOtpEnabled,
98
+ showOnSocialBackupFactor: smsOtpEnabled
99
+ }
100
+ }
101
+ });
102
+ }
77
103
  if (this.coreOptions.privateKeyProvider) {
78
104
  if (openloginAdapter.currentChainNamespace !== this.coreOptions.privateKeyProvider.currentChainConfig.chainNamespace) {
79
105
  throw WalletInitializationError.incompatibleChainNameSpace("private key provider is not compatible with provided chainNamespace for openlogin adapter");
@@ -90,11 +116,18 @@ class Web3AuthNoModal extends SafeEventEmitter {
90
116
  }
91
117
  } else if (adapterName === WALLET_ADAPTERS.WALLET_CONNECT_V2) {
92
118
  const walletConnectAdapter = this.walletAdapters[adapterName];
119
+ const {
120
+ wallet_connect_enabled: walletConnectEnabled,
121
+ wallet_connect_project_id: walletConnectProjectId
122
+ } = projectConfig;
123
+ if (walletConnectEnabled === false) {
124
+ throw WalletInitializationError.invalidParams("Please enable wallet connect v2 addon on dashboard");
125
+ }
126
+ if (!walletConnectProjectId) throw WalletInitializationError.invalidParams("Invalid wallet connect project id. Please configure it on the dashboard");
93
127
  walletConnectAdapter.setAdapterSettings({
94
128
  adapterSettings: {
95
129
  walletConnectInitOptions: {
96
- // Using a default wallet connect project id for web3auth modal integration
97
- projectId: "d3c63f19f9582f8ba48e982057eb096b" // TODO: get from dashboard
130
+ projectId: walletConnectProjectId
98
131
  }
99
132
  }
100
133
  });
@@ -103,8 +136,8 @@ class Web3AuthNoModal extends SafeEventEmitter {
103
136
  autoConnect: this.cachedAdapter === adapterName
104
137
  }).catch(e => log.error(e));
105
138
  });
106
- this.status = ADAPTER_STATUS.READY;
107
139
  await Promise.all(initPromises);
140
+ this.status = ADAPTER_STATUS.READY;
108
141
  }
109
142
  getAdapter(adapterName) {
110
143
  return this.walletAdapters[adapterName] || null;
@@ -268,4 +301,3 @@ class Web3AuthNoModal extends SafeEventEmitter {
268
301
  }
269
302
 
270
303
  export { Web3AuthNoModal };
271
- //# sourceMappingURL=noModal.esm.js.map