@web3auth/modal 8.0.0-alpha.7 → 8.0.0-alpha.8
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/modal.cjs.js +24 -33
- package/dist/modal.cjs.js.map +1 -1
- package/dist/modal.esm.js +24 -33
- package/dist/modal.esm.js.map +1 -1
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.map +1 -1
- package/dist/types/modalManager.d.ts +2 -10
- package/package.json +8 -8
- package/src/modalManager.ts +21 -42
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { IProvider, WALLET_ADAPTER_TYPE, Web3AuthNoModalOptions } from "@web3auth/base";
|
|
2
2
|
import { Web3AuthNoModal } from "@web3auth/no-modal";
|
|
3
3
|
import { LoginModal, UIConfig } from "@web3auth/ui";
|
|
4
|
-
import { IWeb3AuthModal, ModalConfig } from "./interface";
|
|
4
|
+
import { AdaptersModalConfig, IWeb3AuthModal, ModalConfig } from "./interface";
|
|
5
5
|
export interface Web3AuthOptions extends Web3AuthNoModalOptions {
|
|
6
|
-
/**
|
|
7
|
-
* web3auth instance provides different adapters for different type of usages. If you are dapp and want to
|
|
8
|
-
* use external wallets like metamask, then you can use the `DAPP` authMode.
|
|
9
|
-
* If you are a wallet and only want to use you own wallet implementations along with openlogin,
|
|
10
|
-
* then you should use `WALLET` authMode.
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue `DAPP`
|
|
13
|
-
*/
|
|
14
|
-
authMode?: "DAPP" | "WALLET";
|
|
15
6
|
/**
|
|
16
7
|
* Config for configuring modal ui display properties
|
|
17
8
|
*/
|
|
@@ -22,6 +13,7 @@ export declare class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal
|
|
|
22
13
|
readonly options: Web3AuthOptions;
|
|
23
14
|
private modalConfig;
|
|
24
15
|
constructor(options: Web3AuthOptions);
|
|
16
|
+
setModalConfig(modalConfig: AdaptersModalConfig): void;
|
|
25
17
|
initModal(params?: {
|
|
26
18
|
modalConfig?: Record<WALLET_ADAPTER_TYPE, ModalConfig>;
|
|
27
19
|
}): Promise<void>;
|
package/package.json
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
"url": "https://github.com/Web3Auth/Web3Auth/issues"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@web3auth/base": "^8.0.0-alpha.
|
|
8
|
-
"@web3auth/base-provider": "^8.0.0-alpha.
|
|
9
|
-
"@web3auth/no-modal": "^8.0.0-alpha.
|
|
10
|
-
"@web3auth/openlogin-adapter": "^8.0.0-alpha.
|
|
11
|
-
"@web3auth/ui": "^8.0.0-alpha.
|
|
7
|
+
"@web3auth/base": "^8.0.0-alpha.8",
|
|
8
|
+
"@web3auth/base-provider": "^8.0.0-alpha.8",
|
|
9
|
+
"@web3auth/no-modal": "^8.0.0-alpha.8",
|
|
10
|
+
"@web3auth/openlogin-adapter": "^8.0.0-alpha.8",
|
|
11
|
+
"@web3auth/ui": "^8.0.0-alpha.8"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@svgr/webpack": "^8.1.0",
|
|
15
15
|
"@toruslabs/isomorphic-style-loader": "^5.3.3",
|
|
16
16
|
"@toruslabs/openlogin-utils": "^6.2.5",
|
|
17
|
-
"@web3auth/wallet-connect-v2-adapter": "^8.0.0-alpha.
|
|
17
|
+
"@web3auth/wallet-connect-v2-adapter": "^8.0.0-alpha.8",
|
|
18
18
|
"css-loader": "^6.9.1",
|
|
19
19
|
"postcss-prefix-selector": "^1.16.0",
|
|
20
20
|
"style-loader": "^3.3.4",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
},
|
|
70
70
|
"types": "dist/types/index.d.ts",
|
|
71
71
|
"unpkg": "dist/modal.umd.min.js",
|
|
72
|
-
"version": "8.0.0-alpha.
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "8.0.0-alpha.8",
|
|
73
|
+
"gitHead": "6ca3c8fee49b28687d8294dad0c32523eae9bc32"
|
|
74
74
|
}
|
package/src/modalManager.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
ADAPTER_EVENTS,
|
|
4
4
|
ADAPTER_STATUS,
|
|
5
5
|
BaseAdapterConfig,
|
|
6
|
-
CHAIN_NAMESPACES,
|
|
7
6
|
CustomChainConfig,
|
|
8
7
|
getChainConfig,
|
|
9
8
|
IProvider,
|
|
@@ -20,25 +19,10 @@ import { getOpenloginDefaultOptions, OpenloginAdapter } from "@web3auth/openlogi
|
|
|
20
19
|
import { getAdapterSocialLogins, getUserLanguage, LOGIN_MODAL_EVENTS, LoginModal, OPENLOGIN_PROVIDERS, UIConfig } from "@web3auth/ui";
|
|
21
20
|
import type { WalletConnectV2Adapter } from "@web3auth/wallet-connect-v2-adapter";
|
|
22
21
|
|
|
23
|
-
import {
|
|
24
|
-
defaultEvmDappModalConfig,
|
|
25
|
-
defaultEvmWalletModalConfig,
|
|
26
|
-
defaultOtherModalConfig,
|
|
27
|
-
defaultSolanaDappModalConfig,
|
|
28
|
-
defaultSolanaWalletModalConfig,
|
|
29
|
-
} from "./config";
|
|
22
|
+
import { defaultOtherModalConfig } from "./config";
|
|
30
23
|
import { AdaptersModalConfig, IWeb3AuthModal, ModalConfig } from "./interface";
|
|
31
24
|
|
|
32
25
|
export interface Web3AuthOptions extends Web3AuthNoModalOptions {
|
|
33
|
-
/**
|
|
34
|
-
* web3auth instance provides different adapters for different type of usages. If you are dapp and want to
|
|
35
|
-
* use external wallets like metamask, then you can use the `DAPP` authMode.
|
|
36
|
-
* If you are a wallet and only want to use you own wallet implementations along with openlogin,
|
|
37
|
-
* then you should use `WALLET` authMode.
|
|
38
|
-
*
|
|
39
|
-
* @defaultValue `DAPP`
|
|
40
|
-
*/
|
|
41
|
-
authMode?: "DAPP" | "WALLET";
|
|
42
26
|
/**
|
|
43
27
|
* Config for configuring modal ui display properties
|
|
44
28
|
*/
|
|
@@ -50,33 +34,11 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
|
|
|
50
34
|
|
|
51
35
|
readonly options: Web3AuthOptions;
|
|
52
36
|
|
|
53
|
-
private modalConfig: AdaptersModalConfig =
|
|
37
|
+
private modalConfig: AdaptersModalConfig = defaultOtherModalConfig;
|
|
54
38
|
|
|
55
39
|
constructor(options: Web3AuthOptions) {
|
|
56
40
|
super(options);
|
|
57
41
|
this.options = { ...options };
|
|
58
|
-
const providedChainConfig = this.options.chainConfig;
|
|
59
|
-
if (providedChainConfig.chainNamespace === CHAIN_NAMESPACES.SOLANA) {
|
|
60
|
-
if (options.authMode === "WALLET") {
|
|
61
|
-
// default config for solana wallet modal
|
|
62
|
-
this.modalConfig = defaultSolanaWalletModalConfig;
|
|
63
|
-
} else {
|
|
64
|
-
// default config for solana dapp modal
|
|
65
|
-
this.modalConfig = defaultSolanaDappModalConfig;
|
|
66
|
-
}
|
|
67
|
-
} else if (providedChainConfig.chainNamespace === CHAIN_NAMESPACES.EIP155) {
|
|
68
|
-
if (options.authMode === "WALLET") {
|
|
69
|
-
// default config for evm wallet modal
|
|
70
|
-
this.modalConfig = defaultEvmWalletModalConfig;
|
|
71
|
-
} else {
|
|
72
|
-
// default config for evm dapp modal
|
|
73
|
-
this.modalConfig = defaultEvmDappModalConfig;
|
|
74
|
-
}
|
|
75
|
-
} else if (providedChainConfig.chainNamespace === CHAIN_NAMESPACES.OTHER) {
|
|
76
|
-
this.modalConfig = defaultOtherModalConfig;
|
|
77
|
-
} else {
|
|
78
|
-
throw new Error(`Invalid chainNamespace provided: ${providedChainConfig.chainNamespace}`);
|
|
79
|
-
}
|
|
80
42
|
|
|
81
43
|
if (!this.options.uiConfig) this.options.uiConfig = {};
|
|
82
44
|
if (!this.options.uiConfig.defaultLanguage) this.options.uiConfig.defaultLanguage = getUserLanguage(this.options.uiConfig.defaultLanguage);
|
|
@@ -89,6 +51,11 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
|
|
|
89
51
|
this.subscribeToLoginModalEvents();
|
|
90
52
|
}
|
|
91
53
|
|
|
54
|
+
public setModalConfig(modalConfig: AdaptersModalConfig): void {
|
|
55
|
+
super.checkInitRequirements();
|
|
56
|
+
this.modalConfig = modalConfig;
|
|
57
|
+
}
|
|
58
|
+
|
|
92
59
|
public async initModal(params?: { modalConfig?: Record<WALLET_ADAPTER_TYPE, ModalConfig> }): Promise<void> {
|
|
93
60
|
super.checkInitRequirements();
|
|
94
61
|
await this.loginModal.initModal();
|
|
@@ -122,7 +89,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
|
|
|
122
89
|
// Adapters to be shown on modal should be pre-configured.
|
|
123
90
|
if (adapterName === WALLET_ADAPTERS.OPENLOGIN) {
|
|
124
91
|
const defaultOptions = getOpenloginDefaultOptions();
|
|
125
|
-
const { clientId, useCoreKitKey, chainConfig, web3AuthNetwork,
|
|
92
|
+
const { clientId, useCoreKitKey, chainConfig, web3AuthNetwork, sessionTime, privateKeyProvider } = this.coreOptions;
|
|
126
93
|
const finalChainConfig = {
|
|
127
94
|
...getChainConfig(providedChainConfig.chainNamespace, this.coreOptions.chainConfig?.chainId),
|
|
128
95
|
...chainConfig,
|
|
@@ -130,12 +97,21 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
|
|
|
130
97
|
if (!privateKeyProvider) {
|
|
131
98
|
throw WalletInitializationError.invalidParams("privateKeyProvider is required");
|
|
132
99
|
}
|
|
100
|
+
const finalOpenloginAdapterSettings = {
|
|
101
|
+
...defaultOptions.adapterSettings,
|
|
102
|
+
clientId,
|
|
103
|
+
network: web3AuthNetwork,
|
|
104
|
+
whiteLabel: this.options.uiConfig,
|
|
105
|
+
};
|
|
106
|
+
if (this.options.uiConfig.uxMode) {
|
|
107
|
+
finalOpenloginAdapterSettings.uxMode = this.options.uiConfig.uxMode;
|
|
108
|
+
}
|
|
133
109
|
const openloginAdapter = new OpenloginAdapter({
|
|
134
110
|
...defaultOptions,
|
|
135
111
|
clientId,
|
|
136
112
|
useCoreKitKey,
|
|
137
113
|
chainConfig: { ...finalChainConfig },
|
|
138
|
-
adapterSettings:
|
|
114
|
+
adapterSettings: finalOpenloginAdapterSettings,
|
|
139
115
|
sessionTime,
|
|
140
116
|
web3AuthNetwork,
|
|
141
117
|
privateKeyProvider,
|
|
@@ -175,6 +151,9 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal {
|
|
|
175
151
|
}
|
|
176
152
|
openloginAdapter.setAdapterSettings({ privateKeyProvider: this.coreOptions.privateKeyProvider });
|
|
177
153
|
}
|
|
154
|
+
if (this.options.uiConfig?.uxMode) {
|
|
155
|
+
openloginAdapter.setAdapterSettings({ uxMode: this.options.uiConfig.uxMode });
|
|
156
|
+
}
|
|
178
157
|
openloginAdapter.setAdapterSettings({ whiteLabel: this.options.uiConfig });
|
|
179
158
|
if (!openloginAdapter.privateKeyProvider) {
|
|
180
159
|
throw WalletInitializationError.invalidParams("privateKeyProvider is required for openlogin adapter");
|