@web3auth/modal 9.0.0-alpha.0 → 9.0.0-alpha.1
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.
- package/dist/lib.cjs/config.js +10 -22
- package/dist/lib.cjs/modalManager.js +28 -28
- package/dist/lib.esm/config.js +10 -22
- package/dist/lib.esm/modalManager.js +25 -25
- package/dist/modal.cjs.js +41 -53
- package/dist/modal.esm.js +35 -47
- package/dist/modal.umd.min.js +1 -1
- package/package.json +8 -8
package/dist/modal.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CHAIN_NAMESPACES, SOLANA_ADAPTERS, EVM_ADAPTERS, cloneDeep, WalletInitializationError, fetchProjectConfig, log, fetchWalletRegistry, WALLET_ADAPTERS, getChainConfig, ADAPTER_CATEGORY, ADAPTER_STATUS, ADAPTER_EVENTS } from '@web3auth/base';
|
|
2
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import { LOGIN_PROVIDER, getAuthDefaultOptions, AuthAdapter } from '@web3auth/auth-adapter';
|
|
4
5
|
import { CommonJRPCProvider } from '@web3auth/base-provider';
|
|
5
6
|
import { Web3AuthNoModal } from '@web3auth/no-modal';
|
|
6
|
-
import {
|
|
7
|
-
import { getUserLanguage, LoginModal, capitalizeFirstLetter, getAdapterSocialLogins, LOGIN_MODAL_EVENTS, OPENLOGIN_PROVIDERS } from '@web3auth/ui';
|
|
7
|
+
import { getUserLanguage, LoginModal, capitalizeFirstLetter, getAdapterSocialLogins, LOGIN_MODAL_EVENTS, AUTH_PROVIDERS } from '@web3auth/ui';
|
|
8
8
|
import deepmerge from 'deepmerge';
|
|
9
9
|
|
|
10
10
|
const defaultSolanaDappModalConfig = {
|
|
@@ -16,14 +16,8 @@ const defaultSolanaDappModalConfig = {
|
|
|
16
16
|
showOnMobile: true,
|
|
17
17
|
showOnDesktop: true
|
|
18
18
|
},
|
|
19
|
-
[SOLANA_ADAPTERS.
|
|
20
|
-
label: "
|
|
21
|
-
showOnModal: true,
|
|
22
|
-
showOnMobile: true,
|
|
23
|
-
showOnDesktop: true
|
|
24
|
-
},
|
|
25
|
-
[SOLANA_ADAPTERS.PHANTOM]: {
|
|
26
|
-
label: "Phantom",
|
|
19
|
+
[SOLANA_ADAPTERS.AUTH]: {
|
|
20
|
+
label: "Auth",
|
|
27
21
|
showOnModal: true,
|
|
28
22
|
showOnMobile: true,
|
|
29
23
|
showOnDesktop: true
|
|
@@ -39,14 +33,8 @@ const defaultEvmDappModalConfig = {
|
|
|
39
33
|
showOnMobile: true,
|
|
40
34
|
showOnDesktop: true
|
|
41
35
|
},
|
|
42
|
-
[EVM_ADAPTERS.
|
|
43
|
-
label: "
|
|
44
|
-
showOnModal: true,
|
|
45
|
-
showOnMobile: true,
|
|
46
|
-
showOnDesktop: true
|
|
47
|
-
},
|
|
48
|
-
[EVM_ADAPTERS.OPENLOGIN]: {
|
|
49
|
-
label: "OpenLogin",
|
|
36
|
+
[EVM_ADAPTERS.AUTH]: {
|
|
37
|
+
label: "Auth",
|
|
50
38
|
showOnModal: true,
|
|
51
39
|
showOnMobile: true,
|
|
52
40
|
showOnDesktop: true
|
|
@@ -62,8 +50,8 @@ const defaultEvmDappModalConfig = {
|
|
|
62
50
|
const defaultSolanaWalletModalConfig = {
|
|
63
51
|
chainNamespace: CHAIN_NAMESPACES.SOLANA,
|
|
64
52
|
adapters: {
|
|
65
|
-
[SOLANA_ADAPTERS.
|
|
66
|
-
label: "
|
|
53
|
+
[SOLANA_ADAPTERS.AUTH]: {
|
|
54
|
+
label: "Auth",
|
|
67
55
|
showOnModal: true,
|
|
68
56
|
showOnMobile: true,
|
|
69
57
|
showOnDesktop: true
|
|
@@ -73,8 +61,8 @@ const defaultSolanaWalletModalConfig = {
|
|
|
73
61
|
const defaultEvmWalletModalConfig = {
|
|
74
62
|
chainNamespace: CHAIN_NAMESPACES.EIP155,
|
|
75
63
|
adapters: {
|
|
76
|
-
[EVM_ADAPTERS.
|
|
77
|
-
label: "
|
|
64
|
+
[EVM_ADAPTERS.AUTH]: {
|
|
65
|
+
label: "Auth",
|
|
78
66
|
showOnModal: true,
|
|
79
67
|
showOnMobile: true,
|
|
80
68
|
showOnDesktop: true
|
|
@@ -84,8 +72,8 @@ const defaultEvmWalletModalConfig = {
|
|
|
84
72
|
const defaultOtherModalConfig = {
|
|
85
73
|
chainNamespace: CHAIN_NAMESPACES.OTHER,
|
|
86
74
|
adapters: {
|
|
87
|
-
[EVM_ADAPTERS.
|
|
88
|
-
label: "
|
|
75
|
+
[EVM_ADAPTERS.AUTH]: {
|
|
76
|
+
label: "Auth",
|
|
89
77
|
showOnModal: true,
|
|
90
78
|
showOnMobile: true,
|
|
91
79
|
showOnDesktop: true
|
|
@@ -143,8 +131,8 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
143
131
|
if (smsOtpEnabled !== undefined) {
|
|
144
132
|
var _params;
|
|
145
133
|
const adapterConfig = {
|
|
146
|
-
[WALLET_ADAPTERS.
|
|
147
|
-
label: WALLET_ADAPTERS.
|
|
134
|
+
[WALLET_ADAPTERS.AUTH]: {
|
|
135
|
+
label: WALLET_ADAPTERS.AUTH,
|
|
148
136
|
loginMethods: {
|
|
149
137
|
[LOGIN_PROVIDER.SMS_PASSWORDLESS]: {
|
|
150
138
|
name: LOGIN_PROVIDER.SMS_PASSWORDLESS,
|
|
@@ -188,9 +176,9 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
188
176
|
// and if adapter is not hidden by user
|
|
189
177
|
if (!adapter && (_this$modalConfig$ada3 = this.modalConfig.adapters) !== null && _this$modalConfig$ada3 !== void 0 && _this$modalConfig$ada3[adapterName].showOnModal) {
|
|
190
178
|
// Adapters to be shown on modal should be pre-configured.
|
|
191
|
-
if (adapterName === WALLET_ADAPTERS.
|
|
179
|
+
if (adapterName === WALLET_ADAPTERS.AUTH) {
|
|
192
180
|
var _this$coreOptions$cha;
|
|
193
|
-
const defaultOptions =
|
|
181
|
+
const defaultOptions = getAuthDefaultOptions();
|
|
194
182
|
const {
|
|
195
183
|
clientId,
|
|
196
184
|
useCoreKitKey,
|
|
@@ -203,13 +191,13 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
203
191
|
if (!privateKeyProvider) {
|
|
204
192
|
throw WalletInitializationError.invalidParams("privateKeyProvider is required");
|
|
205
193
|
}
|
|
206
|
-
const
|
|
194
|
+
const finalAuthAdapterSettings = _objectSpread(_objectSpread({}, defaultOptions.adapterSettings), {}, {
|
|
207
195
|
clientId,
|
|
208
196
|
network: web3AuthNetwork,
|
|
209
197
|
whiteLabel: this.options.uiConfig
|
|
210
198
|
});
|
|
211
199
|
if (smsOtpEnabled !== undefined) {
|
|
212
|
-
|
|
200
|
+
finalAuthAdapterSettings.loginConfig = {
|
|
213
201
|
[LOGIN_PROVIDER.SMS_PASSWORDLESS]: {
|
|
214
202
|
showOnModal: smsOtpEnabled,
|
|
215
203
|
showOnDesktop: smsOtpEnabled,
|
|
@@ -219,21 +207,21 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
219
207
|
};
|
|
220
208
|
}
|
|
221
209
|
if (whitelist) {
|
|
222
|
-
|
|
210
|
+
finalAuthAdapterSettings.originData = whitelist.signed_urls;
|
|
223
211
|
}
|
|
224
212
|
if (this.options.uiConfig.uxMode) {
|
|
225
|
-
|
|
213
|
+
finalAuthAdapterSettings.uxMode = this.options.uiConfig.uxMode;
|
|
226
214
|
}
|
|
227
|
-
const
|
|
215
|
+
const authAdapter = new AuthAdapter(_objectSpread(_objectSpread({}, defaultOptions), {}, {
|
|
228
216
|
clientId,
|
|
229
217
|
useCoreKitKey,
|
|
230
218
|
chainConfig: _objectSpread({}, finalChainConfig),
|
|
231
|
-
adapterSettings:
|
|
219
|
+
adapterSettings: finalAuthAdapterSettings,
|
|
232
220
|
sessionTime,
|
|
233
221
|
web3AuthNetwork,
|
|
234
222
|
privateKeyProvider
|
|
235
223
|
}));
|
|
236
|
-
this.walletAdapters[adapterName] =
|
|
224
|
+
this.walletAdapters[adapterName] = authAdapter;
|
|
237
225
|
return adapterName;
|
|
238
226
|
}
|
|
239
227
|
throw WalletInitializationError.invalidParams(`Adapter ${adapterName} is not configured`);
|
|
@@ -258,19 +246,19 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
258
246
|
chainConfig
|
|
259
247
|
});
|
|
260
248
|
}
|
|
261
|
-
if (adapterName === WALLET_ADAPTERS.
|
|
249
|
+
if (adapterName === WALLET_ADAPTERS.AUTH) {
|
|
262
250
|
var _this$options$uiConfi;
|
|
263
|
-
const
|
|
251
|
+
const authAdapter = this.walletAdapters[adapterName];
|
|
264
252
|
if (this.coreOptions.privateKeyProvider) {
|
|
265
|
-
if (
|
|
266
|
-
throw WalletInitializationError.incompatibleChainNameSpace("private key provider is not compatible with provided chainNamespace for
|
|
253
|
+
if (authAdapter.currentChainNamespace !== this.coreOptions.privateKeyProvider.currentChainConfig.chainNamespace) {
|
|
254
|
+
throw WalletInitializationError.incompatibleChainNameSpace("private key provider is not compatible with provided chainNamespace for auth adapter");
|
|
267
255
|
}
|
|
268
|
-
|
|
256
|
+
authAdapter.setAdapterSettings({
|
|
269
257
|
privateKeyProvider: this.coreOptions.privateKeyProvider
|
|
270
258
|
});
|
|
271
259
|
}
|
|
272
260
|
if (smsOtpEnabled !== undefined) {
|
|
273
|
-
|
|
261
|
+
authAdapter.setAdapterSettings({
|
|
274
262
|
loginConfig: {
|
|
275
263
|
[LOGIN_PROVIDER.SMS_PASSWORDLESS]: {
|
|
276
264
|
showOnModal: smsOtpEnabled,
|
|
@@ -282,20 +270,20 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
282
270
|
});
|
|
283
271
|
}
|
|
284
272
|
if (whitelist) {
|
|
285
|
-
|
|
273
|
+
authAdapter.setAdapterSettings({
|
|
286
274
|
originData: whitelist.signed_urls
|
|
287
275
|
});
|
|
288
276
|
}
|
|
289
277
|
if ((_this$options$uiConfi = this.options.uiConfig) !== null && _this$options$uiConfi !== void 0 && _this$options$uiConfi.uxMode) {
|
|
290
|
-
|
|
278
|
+
authAdapter.setAdapterSettings({
|
|
291
279
|
uxMode: this.options.uiConfig.uxMode
|
|
292
280
|
});
|
|
293
281
|
}
|
|
294
|
-
|
|
282
|
+
authAdapter.setAdapterSettings({
|
|
295
283
|
whiteLabel: this.options.uiConfig
|
|
296
284
|
});
|
|
297
|
-
if (!
|
|
298
|
-
throw WalletInitializationError.invalidParams("privateKeyProvider is required for
|
|
285
|
+
if (!authAdapter.privateKeyProvider) {
|
|
286
|
+
throw WalletInitializationError.invalidParams("privateKeyProvider is required for auth adapter");
|
|
299
287
|
}
|
|
300
288
|
} else if (adapterName === WALLET_ADAPTERS.WALLET_CONNECT_V2) {
|
|
301
289
|
const walletConnectAdapter = this.walletAdapters[adapterName];
|
|
@@ -457,7 +445,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
457
445
|
log.info("adapterInitResults", adapterName);
|
|
458
446
|
if (this.walletAdapters[adapterName].type === ADAPTER_CATEGORY.IN_APP) {
|
|
459
447
|
var _adapterName, _this$options$uiConfi2, _this$options$uiConfi3, _this$options$uiConfi4;
|
|
460
|
-
this.loginModal.addSocialLogins(adapterName, getAdapterSocialLogins(adapterName, (_adapterName = this.modalConfig.adapters[adapterName]) === null || _adapterName === void 0 ? void 0 : _adapterName.loginMethods), ((_this$options$uiConfi2 = this.options.uiConfig) === null || _this$options$uiConfi2 === void 0 ? void 0 : _this$options$uiConfi2.loginMethodsOrder) ||
|
|
448
|
+
this.loginModal.addSocialLogins(adapterName, getAdapterSocialLogins(adapterName, (_adapterName = this.modalConfig.adapters[adapterName]) === null || _adapterName === void 0 ? void 0 : _adapterName.loginMethods), ((_this$options$uiConfi2 = this.options.uiConfig) === null || _this$options$uiConfi2 === void 0 ? void 0 : _this$options$uiConfi2.loginMethodsOrder) || AUTH_PROVIDERS, _objectSpread(_objectSpread({}, this.options.uiConfig), {}, {
|
|
461
449
|
loginGridCol: ((_this$options$uiConfi3 = this.options.uiConfig) === null || _this$options$uiConfi3 === void 0 ? void 0 : _this$options$uiConfi3.loginGridCol) || 3,
|
|
462
450
|
primaryButton: ((_this$options$uiConfi4 = this.options.uiConfig) === null || _this$options$uiConfi4 === void 0 ? void 0 : _this$options$uiConfi4.primaryButton) || "socialLogin"
|
|
463
451
|
}));
|