@web3auth/modal 4.3.3-beta.0 → 4.4.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.
- package/dist/modal.cjs.js +397 -712
- package/dist/modal.cjs.js.map +1 -1
- package/dist/modal.esm.js +379 -653
- 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/default.d.ts +3 -0
- package/dist/types/modalManager.d.ts +2 -41
- package/dist/types/utils.d.ts +1 -0
- package/package.json +13 -13
- package/src/config.ts +2 -2
- package/src/default.ts +13 -9
- package/src/modalManager.ts +11 -51
- package/src/utils.ts +1 -0
package/dist/types/default.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { OPENLOGIN_NETWORK_TYPE } from "@toruslabs/openlogin";
|
|
1
2
|
import { CustomChainConfig, IAdapter, WALLET_ADAPTER_TYPE } from "@web3auth/base";
|
|
2
3
|
export declare const getDefaultAdapterModule: (params: {
|
|
3
4
|
name: WALLET_ADAPTER_TYPE;
|
|
4
5
|
clientId: string;
|
|
5
6
|
customChainConfig: Partial<CustomChainConfig> & Pick<CustomChainConfig, "chainNamespace">;
|
|
7
|
+
sessionTime?: number;
|
|
8
|
+
web3AuthNetwork?: OPENLOGIN_NETWORK_TYPE;
|
|
6
9
|
}) => Promise<IAdapter<unknown>>;
|
|
@@ -1,40 +1,7 @@
|
|
|
1
1
|
import { SafeEventEmitterProvider, WALLET_ADAPTER_TYPE } from "@web3auth/base";
|
|
2
2
|
import { Web3AuthCore, Web3AuthCoreOptions } from "@web3auth/core";
|
|
3
|
-
import { LoginModal } from "@web3auth/ui";
|
|
3
|
+
import { LoginModal, UIConfig } from "@web3auth/ui";
|
|
4
4
|
import { IWeb3AuthModal, ModalConfig } from "./interface";
|
|
5
|
-
export interface UIConfig {
|
|
6
|
-
/**
|
|
7
|
-
* App name to display in the UI.
|
|
8
|
-
*/
|
|
9
|
-
appName?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Logo for your app.
|
|
12
|
-
*/
|
|
13
|
-
appLogo?: string;
|
|
14
|
-
/**
|
|
15
|
-
* theme for the modal
|
|
16
|
-
*
|
|
17
|
-
* @defaultValue `light`
|
|
18
|
-
*/
|
|
19
|
-
theme?: "light" | "dark";
|
|
20
|
-
/**
|
|
21
|
-
* order of how login methods are shown
|
|
22
|
-
*
|
|
23
|
-
* @defaultValue `["google", "facebook", "twitter", "reddit", "discord", "twitch", "apple", "line", "github", "kakao", "linkedin", "weibo", "wechat", "email_passwordless"]`
|
|
24
|
-
*/
|
|
25
|
-
loginMethodsOrder?: string[];
|
|
26
|
-
/**
|
|
27
|
-
* language which will be used by web3auth. app will use browser language if not specified. if language is not supported it will use "en"
|
|
28
|
-
* en: english
|
|
29
|
-
* de: german
|
|
30
|
-
* ja: japanese
|
|
31
|
-
* ko: korean
|
|
32
|
-
* zh: mandarin
|
|
33
|
-
* es: spanish
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
defaultLanguage?: string;
|
|
37
|
-
}
|
|
38
5
|
export interface Web3AuthOptions extends Web3AuthCoreOptions {
|
|
39
6
|
/**
|
|
40
7
|
* web3auth instance provides different adapters for different type of usages. If you are dapp and want to
|
|
@@ -48,13 +15,7 @@ export interface Web3AuthOptions extends Web3AuthCoreOptions {
|
|
|
48
15
|
/**
|
|
49
16
|
* Config for configuring modal ui display properties
|
|
50
17
|
*/
|
|
51
|
-
uiConfig?: UIConfig
|
|
52
|
-
/**
|
|
53
|
-
* Whether to show errors on Web3Auth modal.
|
|
54
|
-
*
|
|
55
|
-
* @defaultValue `true`
|
|
56
|
-
*/
|
|
57
|
-
displayErrorsOnModal?: boolean;
|
|
18
|
+
uiConfig?: Omit<UIConfig, "adapterListener">;
|
|
58
19
|
}
|
|
59
20
|
export declare class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
60
21
|
loginModal: LoginModal;
|
package/dist/types/utils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web3auth/modal",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"homepage": "https://github.com/Web3Auth/Web3Auth#readme",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/modal.cjs.js",
|
|
@@ -19,21 +19,21 @@
|
|
|
19
19
|
"pre-commit": "lint-staged --cwd ."
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@web3auth/base": "^4.
|
|
23
|
-
"@web3auth/core": "^4.
|
|
24
|
-
"@web3auth/metamask-adapter": "^4.
|
|
25
|
-
"@web3auth/openlogin-adapter": "^4.
|
|
26
|
-
"@web3auth/phantom-adapter": "^4.
|
|
27
|
-
"@web3auth/torus-evm-adapter": "^4.
|
|
28
|
-
"@web3auth/torus-solana-adapter": "^4.
|
|
29
|
-
"@web3auth/ui": "^4.
|
|
30
|
-
"@web3auth/wallet-connect-v1-adapter": "^4.
|
|
22
|
+
"@web3auth/base": "^4.4.0",
|
|
23
|
+
"@web3auth/core": "^4.4.0",
|
|
24
|
+
"@web3auth/metamask-adapter": "^4.4.0",
|
|
25
|
+
"@web3auth/openlogin-adapter": "^4.4.0",
|
|
26
|
+
"@web3auth/phantom-adapter": "^4.4.0",
|
|
27
|
+
"@web3auth/torus-evm-adapter": "^4.4.0",
|
|
28
|
+
"@web3auth/torus-solana-adapter": "^4.4.0",
|
|
29
|
+
"@web3auth/ui": "^4.4.0",
|
|
30
|
+
"@web3auth/wallet-connect-v1-adapter": "^4.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@svgr/webpack": "^6.5.1",
|
|
34
34
|
"@toruslabs/isomorphic-style-loader": "^5.3.3",
|
|
35
|
-
"@toruslabs/openlogin": "^
|
|
36
|
-
"css-loader": "^6.7.
|
|
35
|
+
"@toruslabs/openlogin": "^3.0.0",
|
|
36
|
+
"css-loader": "^6.7.3",
|
|
37
37
|
"postcss-prefix-selector": "^1.16.0",
|
|
38
38
|
"style-loader": "^3.3.1",
|
|
39
39
|
"tailwindcss": "^3.2.4",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "92ee041e92c6c7492b70bee7bbca79119a2b0d14"
|
|
67
67
|
}
|
package/src/config.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const defaultSolanaDappModalConfig: AdaptersModalConfig = {
|
|
|
20
20
|
[SOLANA_ADAPTERS.PHANTOM]: {
|
|
21
21
|
label: "Phantom",
|
|
22
22
|
showOnModal: true,
|
|
23
|
-
showOnMobile:
|
|
23
|
+
showOnMobile: true,
|
|
24
24
|
showOnDesktop: true,
|
|
25
25
|
},
|
|
26
26
|
},
|
|
@@ -38,7 +38,7 @@ export const defaultEvmDappModalConfig: AdaptersModalConfig = {
|
|
|
38
38
|
[EVM_ADAPTERS.METAMASK]: {
|
|
39
39
|
label: "MetaMask",
|
|
40
40
|
showOnModal: true,
|
|
41
|
-
showOnMobile:
|
|
41
|
+
showOnMobile: true,
|
|
42
42
|
showOnDesktop: true,
|
|
43
43
|
},
|
|
44
44
|
[EVM_ADAPTERS.OPENLOGIN]: {
|
package/src/default.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { OpenLoginOptions } from "@toruslabs/openlogin";
|
|
1
|
+
import type { OPENLOGIN_NETWORK_TYPE, OpenLoginOptions } from "@toruslabs/openlogin";
|
|
2
2
|
import { CHAIN_NAMESPACES, CustomChainConfig, getChainConfig, IAdapter, WALLET_ADAPTER_TYPE, WALLET_ADAPTERS } from "@web3auth/base";
|
|
3
3
|
|
|
4
|
-
// warning: this function is not compatible with "OTHER"
|
|
4
|
+
// warning: this function is not compatible with "OTHER" chain namespace.
|
|
5
5
|
export const getDefaultAdapterModule = async (params: {
|
|
6
6
|
name: WALLET_ADAPTER_TYPE;
|
|
7
7
|
clientId: string;
|
|
8
8
|
customChainConfig: Partial<CustomChainConfig> & Pick<CustomChainConfig, "chainNamespace">;
|
|
9
|
+
sessionTime?: number;
|
|
10
|
+
web3AuthNetwork?: OPENLOGIN_NETWORK_TYPE;
|
|
9
11
|
}): Promise<IAdapter<unknown>> => {
|
|
10
|
-
const { name, customChainConfig, clientId } = params;
|
|
12
|
+
const { name, customChainConfig, clientId, sessionTime, web3AuthNetwork } = params;
|
|
11
13
|
if (!Object.values(CHAIN_NAMESPACES).includes(customChainConfig.chainNamespace))
|
|
12
14
|
throw new Error(`Invalid chainNamespace: ${customChainConfig.chainNamespace}`);
|
|
13
15
|
const finalChainConfig = {
|
|
@@ -16,23 +18,23 @@ export const getDefaultAdapterModule = async (params: {
|
|
|
16
18
|
};
|
|
17
19
|
if (name === WALLET_ADAPTERS.TORUS_EVM) {
|
|
18
20
|
const { TorusWalletAdapter } = await import("@web3auth/torus-evm-adapter");
|
|
19
|
-
const adapter = new TorusWalletAdapter({ chainConfig: finalChainConfig, clientId });
|
|
21
|
+
const adapter = new TorusWalletAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork });
|
|
20
22
|
return adapter;
|
|
21
23
|
} else if (name === WALLET_ADAPTERS.TORUS_SOLANA) {
|
|
22
24
|
const { SolanaWalletAdapter } = await import("@web3auth/torus-solana-adapter");
|
|
23
|
-
const adapter = new SolanaWalletAdapter({ chainConfig: finalChainConfig, clientId });
|
|
25
|
+
const adapter = new SolanaWalletAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork });
|
|
24
26
|
return adapter;
|
|
25
27
|
} else if (name === WALLET_ADAPTERS.METAMASK) {
|
|
26
28
|
const { MetamaskAdapter } = await import("@web3auth/metamask-adapter");
|
|
27
|
-
const adapter = new MetamaskAdapter({ chainConfig: finalChainConfig, clientId });
|
|
29
|
+
const adapter = new MetamaskAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork });
|
|
28
30
|
return adapter;
|
|
29
31
|
} else if (name === WALLET_ADAPTERS.PHANTOM) {
|
|
30
32
|
const { PhantomAdapter } = await import("@web3auth/phantom-adapter");
|
|
31
|
-
const adapter = new PhantomAdapter({ chainConfig: finalChainConfig, clientId });
|
|
33
|
+
const adapter = new PhantomAdapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork });
|
|
32
34
|
return adapter;
|
|
33
35
|
} else if (name === WALLET_ADAPTERS.WALLET_CONNECT_V1) {
|
|
34
36
|
const { WalletConnectV1Adapter } = await import("@web3auth/wallet-connect-v1-adapter");
|
|
35
|
-
const adapter = new WalletConnectV1Adapter({ chainConfig: finalChainConfig, clientId });
|
|
37
|
+
const adapter = new WalletConnectV1Adapter({ chainConfig: finalChainConfig, clientId, sessionTime, web3AuthNetwork });
|
|
36
38
|
return adapter;
|
|
37
39
|
} else if (name === WALLET_ADAPTERS.OPENLOGIN) {
|
|
38
40
|
const { OpenloginAdapter, getOpenloginDefaultOptions } = await import("@web3auth/openlogin-adapter");
|
|
@@ -41,7 +43,9 @@ export const getDefaultAdapterModule = async (params: {
|
|
|
41
43
|
...defaultOptions,
|
|
42
44
|
clientId,
|
|
43
45
|
chainConfig: { ...finalChainConfig },
|
|
44
|
-
adapterSettings: { ...(defaultOptions.adapterSettings as OpenLoginOptions), clientId },
|
|
46
|
+
adapterSettings: { ...(defaultOptions.adapterSettings as OpenLoginOptions), clientId, network: web3AuthNetwork },
|
|
47
|
+
sessionTime,
|
|
48
|
+
web3AuthNetwork,
|
|
45
49
|
});
|
|
46
50
|
return adapter;
|
|
47
51
|
}
|
package/src/modalManager.ts
CHANGED
|
@@ -7,12 +7,13 @@ import {
|
|
|
7
7
|
CustomChainConfig,
|
|
8
8
|
getChainConfig,
|
|
9
9
|
log,
|
|
10
|
+
LoginMethodConfig,
|
|
10
11
|
SafeEventEmitterProvider,
|
|
11
12
|
WALLET_ADAPTER_TYPE,
|
|
12
13
|
WALLET_ADAPTERS,
|
|
13
14
|
} from "@web3auth/base";
|
|
14
15
|
import { Web3AuthCore, Web3AuthCoreOptions } from "@web3auth/core";
|
|
15
|
-
import { getAdapterSocialLogins, LOGIN_MODAL_EVENTS, LoginModal, OPENLOGIN_PROVIDERS } from "@web3auth/ui";
|
|
16
|
+
import { getAdapterSocialLogins, LOGIN_MODAL_EVENTS, LoginModal, OPENLOGIN_PROVIDERS, UIConfig } from "@web3auth/ui";
|
|
16
17
|
|
|
17
18
|
import {
|
|
18
19
|
defaultEvmDappModalConfig,
|
|
@@ -25,43 +26,6 @@ import { getDefaultAdapterModule } from "./default";
|
|
|
25
26
|
import { AdaptersModalConfig, IWeb3AuthModal, ModalConfig } from "./interface";
|
|
26
27
|
import { getUserLanguage } from "./utils";
|
|
27
28
|
|
|
28
|
-
export interface UIConfig {
|
|
29
|
-
/**
|
|
30
|
-
* App name to display in the UI.
|
|
31
|
-
*/
|
|
32
|
-
appName?: string;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Logo for your app.
|
|
36
|
-
*/
|
|
37
|
-
appLogo?: string;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* theme for the modal
|
|
41
|
-
*
|
|
42
|
-
* @defaultValue `light`
|
|
43
|
-
*/
|
|
44
|
-
theme?: "light" | "dark";
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* order of how login methods are shown
|
|
48
|
-
*
|
|
49
|
-
* @defaultValue `["google", "facebook", "twitter", "reddit", "discord", "twitch", "apple", "line", "github", "kakao", "linkedin", "weibo", "wechat", "email_passwordless"]`
|
|
50
|
-
*/
|
|
51
|
-
loginMethodsOrder?: string[];
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* language which will be used by web3auth. app will use browser language if not specified. if language is not supported it will use "en"
|
|
55
|
-
* en: english
|
|
56
|
-
* de: german
|
|
57
|
-
* ja: japanese
|
|
58
|
-
* ko: korean
|
|
59
|
-
* zh: mandarin
|
|
60
|
-
* es: spanish
|
|
61
|
-
*
|
|
62
|
-
*/
|
|
63
|
-
defaultLanguage?: string;
|
|
64
|
-
}
|
|
65
29
|
export interface Web3AuthOptions extends Web3AuthCoreOptions {
|
|
66
30
|
/**
|
|
67
31
|
* web3auth instance provides different adapters for different type of usages. If you are dapp and want to
|
|
@@ -75,15 +39,9 @@ export interface Web3AuthOptions extends Web3AuthCoreOptions {
|
|
|
75
39
|
/**
|
|
76
40
|
* Config for configuring modal ui display properties
|
|
77
41
|
*/
|
|
78
|
-
uiConfig?: UIConfig
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Whether to show errors on Web3Auth modal.
|
|
82
|
-
*
|
|
83
|
-
* @defaultValue `true`
|
|
84
|
-
*/
|
|
85
|
-
displayErrorsOnModal?: boolean;
|
|
42
|
+
uiConfig?: Omit<UIConfig, "adapterListener">;
|
|
86
43
|
}
|
|
44
|
+
|
|
87
45
|
export class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
88
46
|
public loginModal: LoginModal;
|
|
89
47
|
|
|
@@ -124,10 +82,10 @@ export class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
|
124
82
|
theme: this.options.uiConfig?.theme,
|
|
125
83
|
appName: this.options.uiConfig?.appName || "blockchain",
|
|
126
84
|
appLogo: this.options.uiConfig?.appLogo || "",
|
|
127
|
-
version: "",
|
|
128
85
|
adapterListener: this,
|
|
129
|
-
displayErrorsOnModal: this.options.displayErrorsOnModal,
|
|
86
|
+
displayErrorsOnModal: this.options.uiConfig?.displayErrorsOnModal,
|
|
130
87
|
defaultLanguage,
|
|
88
|
+
modalZIndex: this.options.uiConfig?.modalZIndex || "99998",
|
|
131
89
|
});
|
|
132
90
|
this.subscribeToLoginModalEvents();
|
|
133
91
|
}
|
|
@@ -167,6 +125,8 @@ export class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
|
167
125
|
name: adapterName,
|
|
168
126
|
customChainConfig: this.options.chainConfig,
|
|
169
127
|
clientId: this.options.clientId,
|
|
128
|
+
sessionTime: this.options.sessionTime,
|
|
129
|
+
web3AuthNetwork: this.options.web3AuthNetwork,
|
|
170
130
|
});
|
|
171
131
|
|
|
172
132
|
this.walletAdapters[adapterName] = ad;
|
|
@@ -199,14 +159,14 @@ export class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
|
199
159
|
const adapterNames = await Promise.all(adapterConfigurationPromises);
|
|
200
160
|
const hasInAppWallets = Object.values(this.walletAdapters).some((adapter) => {
|
|
201
161
|
if (adapter.type !== ADAPTER_CATEGORY.IN_APP) return false;
|
|
202
|
-
if (this.modalConfig.adapters[adapter.name]
|
|
203
|
-
if (!this.modalConfig.adapters[adapter.name]
|
|
162
|
+
if (this.modalConfig.adapters?.[adapter.name]?.showOnModal !== true) return false;
|
|
163
|
+
if (!this.modalConfig.adapters?.[adapter.name]?.loginMethods) return true;
|
|
204
164
|
const mergedLoginMethods = getAdapterSocialLogins(
|
|
205
165
|
adapter.name,
|
|
206
166
|
this.walletAdapters[adapter.name],
|
|
207
167
|
(this.modalConfig.adapters as Record<WALLET_ADAPTER_TYPE, ModalConfig>)[adapter.name]?.loginMethods
|
|
208
168
|
);
|
|
209
|
-
if (Object.values(mergedLoginMethods).some((method) => method.showOnModal)) return true;
|
|
169
|
+
if (Object.values(mergedLoginMethods).some((method: LoginMethodConfig[keyof LoginMethodConfig]) => method.showOnModal)) return true;
|
|
210
170
|
return false;
|
|
211
171
|
});
|
|
212
172
|
log.debug(hasInAppWallets, this.walletAdapters, "hasInAppWallets");
|