@web3auth/modal 4.2.1-alpha.0 → 4.2.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/modal.cjs.js +36 -19
- package/dist/modal.cjs.js.map +1 -1
- package/dist/modal.esm.js +36 -19
- 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 -37
- package/dist/types/utils.d.ts +1 -0
- package/package.json +13 -13
- package/src/default.ts +13 -9
- package/src/modalManager.ts +8 -43
- 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,36 +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
|
-
* Logo for your app.
|
|
8
|
-
*/
|
|
9
|
-
appLogo?: string;
|
|
10
|
-
/**
|
|
11
|
-
* theme for the modal
|
|
12
|
-
*
|
|
13
|
-
* @defaultValue `light`
|
|
14
|
-
*/
|
|
15
|
-
theme?: "light" | "dark";
|
|
16
|
-
/**
|
|
17
|
-
* order of how login methods are shown
|
|
18
|
-
*
|
|
19
|
-
* @defaultValue `["google", "facebook", "twitter", "reddit", "discord", "twitch", "apple", "line", "github", "kakao", "linkedin", "weibo", "wechat", "email_passwordless"]`
|
|
20
|
-
*/
|
|
21
|
-
loginMethodsOrder?: string[];
|
|
22
|
-
/**
|
|
23
|
-
* language which will be used by web3auth. app will use browser language if not specified. if language is not supported it will use "en"
|
|
24
|
-
* en: english
|
|
25
|
-
* de: german
|
|
26
|
-
* ja: japanese
|
|
27
|
-
* ko: korean
|
|
28
|
-
* zh: mandarin
|
|
29
|
-
* es: spanish
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
defaultLanguage?: string;
|
|
33
|
-
}
|
|
34
5
|
export interface Web3AuthOptions extends Web3AuthCoreOptions {
|
|
35
6
|
/**
|
|
36
7
|
* web3auth instance provides different adapters for different type of usages. If you are dapp and want to
|
|
@@ -44,13 +15,7 @@ export interface Web3AuthOptions extends Web3AuthCoreOptions {
|
|
|
44
15
|
/**
|
|
45
16
|
* Config for configuring modal ui display properties
|
|
46
17
|
*/
|
|
47
|
-
uiConfig?: UIConfig
|
|
48
|
-
/**
|
|
49
|
-
* Whether to show errors on Web3Auth modal.
|
|
50
|
-
*
|
|
51
|
-
* @defaultValue `true`
|
|
52
|
-
*/
|
|
53
|
-
displayErrorsOnModal?: boolean;
|
|
18
|
+
uiConfig?: Omit<UIConfig, "adapterListener">;
|
|
54
19
|
}
|
|
55
20
|
export declare class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
56
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.2.1
|
|
3
|
+
"version": "4.2.1",
|
|
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.0.0
|
|
23
|
-
"@web3auth/core": "^4.0.0
|
|
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.1
|
|
30
|
-
"@web3auth/wallet-connect-v1-adapter": "^4.
|
|
22
|
+
"@web3auth/base": "^4.0.0",
|
|
23
|
+
"@web3auth/core": "^4.0.0",
|
|
24
|
+
"@web3auth/metamask-adapter": "^4.2.0",
|
|
25
|
+
"@web3auth/openlogin-adapter": "^4.2.0",
|
|
26
|
+
"@web3auth/phantom-adapter": "^4.2.0",
|
|
27
|
+
"@web3auth/torus-evm-adapter": "^4.2.0",
|
|
28
|
+
"@web3auth/torus-solana-adapter": "^4.2.0",
|
|
29
|
+
"@web3auth/ui": "^4.2.1",
|
|
30
|
+
"@web3auth/wallet-connect-v1-adapter": "^4.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@svgr/webpack": "^6.5.1",
|
|
34
|
+
"@toruslabs/isomorphic-style-loader": "^5.3.3",
|
|
34
35
|
"@toruslabs/openlogin": "^2.10.0",
|
|
35
|
-
"css-loader": "^6.7.
|
|
36
|
-
"isomorphic-style-loader": "^5.3.2",
|
|
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": "1f3ef6e1f4c0a2d88c709a18e720c409d4ef36e6"
|
|
67
67
|
}
|
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
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
WALLET_ADAPTERS,
|
|
13
13
|
} from "@web3auth/base";
|
|
14
14
|
import { Web3AuthCore, Web3AuthCoreOptions } from "@web3auth/core";
|
|
15
|
-
import { getAdapterSocialLogins, LOGIN_MODAL_EVENTS, LoginModal, OPENLOGIN_PROVIDERS } from "@web3auth/ui";
|
|
15
|
+
import { getAdapterSocialLogins, LOGIN_MODAL_EVENTS, LoginModal, OPENLOGIN_PROVIDERS, UIConfig } from "@web3auth/ui";
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
defaultEvmDappModalConfig,
|
|
@@ -25,38 +25,6 @@ import { getDefaultAdapterModule } from "./default";
|
|
|
25
25
|
import { AdaptersModalConfig, IWeb3AuthModal, ModalConfig } from "./interface";
|
|
26
26
|
import { getUserLanguage } from "./utils";
|
|
27
27
|
|
|
28
|
-
export interface UIConfig {
|
|
29
|
-
/**
|
|
30
|
-
* Logo for your app.
|
|
31
|
-
*/
|
|
32
|
-
appLogo?: string;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* theme for the modal
|
|
36
|
-
*
|
|
37
|
-
* @defaultValue `light`
|
|
38
|
-
*/
|
|
39
|
-
theme?: "light" | "dark";
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* order of how login methods are shown
|
|
43
|
-
*
|
|
44
|
-
* @defaultValue `["google", "facebook", "twitter", "reddit", "discord", "twitch", "apple", "line", "github", "kakao", "linkedin", "weibo", "wechat", "email_passwordless"]`
|
|
45
|
-
*/
|
|
46
|
-
loginMethodsOrder?: string[];
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* language which will be used by web3auth. app will use browser language if not specified. if language is not supported it will use "en"
|
|
50
|
-
* en: english
|
|
51
|
-
* de: german
|
|
52
|
-
* ja: japanese
|
|
53
|
-
* ko: korean
|
|
54
|
-
* zh: mandarin
|
|
55
|
-
* es: spanish
|
|
56
|
-
*
|
|
57
|
-
*/
|
|
58
|
-
defaultLanguage?: string;
|
|
59
|
-
}
|
|
60
28
|
export interface Web3AuthOptions extends Web3AuthCoreOptions {
|
|
61
29
|
/**
|
|
62
30
|
* web3auth instance provides different adapters for different type of usages. If you are dapp and want to
|
|
@@ -70,15 +38,9 @@ export interface Web3AuthOptions extends Web3AuthCoreOptions {
|
|
|
70
38
|
/**
|
|
71
39
|
* Config for configuring modal ui display properties
|
|
72
40
|
*/
|
|
73
|
-
uiConfig?: UIConfig
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Whether to show errors on Web3Auth modal.
|
|
77
|
-
*
|
|
78
|
-
* @defaultValue `true`
|
|
79
|
-
*/
|
|
80
|
-
displayErrorsOnModal?: boolean;
|
|
41
|
+
uiConfig?: Omit<UIConfig, "adapterListener">;
|
|
81
42
|
}
|
|
43
|
+
|
|
82
44
|
export class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
83
45
|
public loginModal: LoginModal;
|
|
84
46
|
|
|
@@ -117,11 +79,12 @@ export class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
|
117
79
|
|
|
118
80
|
this.loginModal = new LoginModal({
|
|
119
81
|
theme: this.options.uiConfig?.theme,
|
|
82
|
+
appName: this.options.uiConfig?.appName || "blockchain",
|
|
120
83
|
appLogo: this.options.uiConfig?.appLogo || "",
|
|
121
|
-
version: "",
|
|
122
84
|
adapterListener: this,
|
|
123
|
-
displayErrorsOnModal: this.options.displayErrorsOnModal,
|
|
85
|
+
displayErrorsOnModal: this.options.uiConfig?.displayErrorsOnModal,
|
|
124
86
|
defaultLanguage,
|
|
87
|
+
modalZIndex: this.options.uiConfig?.modalZIndex || "99998",
|
|
125
88
|
});
|
|
126
89
|
this.subscribeToLoginModalEvents();
|
|
127
90
|
}
|
|
@@ -161,6 +124,8 @@ export class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
|
161
124
|
name: adapterName,
|
|
162
125
|
customChainConfig: this.options.chainConfig,
|
|
163
126
|
clientId: this.options.clientId,
|
|
127
|
+
sessionTime: this.options.sessionTime,
|
|
128
|
+
web3AuthNetwork: this.options.web3AuthNetwork,
|
|
164
129
|
});
|
|
165
130
|
|
|
166
131
|
this.walletAdapters[adapterName] = ad;
|