@web3auth/modal 3.3.0 → 4.0.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 +20 -12
- package/dist/modal.cjs.js.map +1 -1
- package/dist/modal.esm.js +19 -12
- package/dist/modal.esm.js.map +1 -1
- package/dist/modal.umd.min.js +1 -1
- package/dist/modal.umd.min.js.LICENSE.txt +15 -0
- package/dist/modal.umd.min.js.map +1 -1
- package/dist/types/interface.d.ts +7 -1
- package/dist/types/modalManager.d.ts +4 -39
- package/dist/types/utils.d.ts +1 -0
- package/package.json +14 -12
- package/src/default.ts +4 -2
- package/src/interface.ts +13 -1
- package/src/modalManager.ts +13 -47
- package/src/utils.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseAdapterConfig, ChainNamespaceType, LoginMethodConfig, WALLET_ADAPTER_TYPE } from "@web3auth/base";
|
|
1
|
+
import type { BaseAdapterConfig, ChainNamespaceType, IWeb3Auth, LoginMethodConfig, SafeEventEmitterProvider, WALLET_ADAPTER_TYPE } from "@web3auth/base";
|
|
2
2
|
export interface ModalConfig extends BaseAdapterConfig {
|
|
3
3
|
loginMethods?: LoginMethodConfig;
|
|
4
4
|
}
|
|
@@ -6,3 +6,9 @@ export interface AdaptersModalConfig {
|
|
|
6
6
|
chainNamespace: ChainNamespaceType;
|
|
7
7
|
adapters?: Record<WALLET_ADAPTER_TYPE, ModalConfig>;
|
|
8
8
|
}
|
|
9
|
+
export interface IWeb3AuthModal extends IWeb3Auth {
|
|
10
|
+
initModal(params?: {
|
|
11
|
+
modalConfig?: Record<WALLET_ADAPTER_TYPE, ModalConfig>;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
connect(): Promise<SafeEventEmitterProvider | null>;
|
|
14
|
+
}
|
|
@@ -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";
|
|
4
|
-
import { 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
|
-
}
|
|
3
|
+
import { LoginModal, UIConfig } from "@web3auth/ui";
|
|
4
|
+
import { IWeb3AuthModal, ModalConfig } from "./interface";
|
|
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,15 +15,9 @@ 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
|
-
export declare class Web3Auth extends Web3AuthCore {
|
|
20
|
+
export declare class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
56
21
|
loginModal: LoginModal;
|
|
57
22
|
readonly options: Web3AuthOptions;
|
|
58
23
|
private modalConfig;
|
package/dist/types/utils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web3auth/modal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"homepage": "https://github.com/Web3Auth/Web3Auth#readme",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/modal.cjs.js",
|
|
@@ -19,22 +19,24 @@
|
|
|
19
19
|
"pre-commit": "lint-staged --cwd ."
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@web3auth/base": "^
|
|
23
|
-
"@web3auth/core": "^
|
|
24
|
-
"@web3auth/metamask-adapter": "^
|
|
25
|
-
"@web3auth/openlogin-adapter": "^
|
|
26
|
-
"@web3auth/phantom-adapter": "^
|
|
27
|
-
"@web3auth/torus-evm-adapter": "^
|
|
28
|
-
"@web3auth/torus-solana-adapter": "^
|
|
29
|
-
"@web3auth/ui": "^
|
|
30
|
-
"@web3auth/wallet-connect-v1-adapter": "^
|
|
22
|
+
"@web3auth/base": "^4.0.0",
|
|
23
|
+
"@web3auth/core": "^4.0.0",
|
|
24
|
+
"@web3auth/metamask-adapter": "^4.0.0",
|
|
25
|
+
"@web3auth/openlogin-adapter": "^4.0.0",
|
|
26
|
+
"@web3auth/phantom-adapter": "^4.0.0",
|
|
27
|
+
"@web3auth/torus-evm-adapter": "^4.0.0",
|
|
28
|
+
"@web3auth/torus-solana-adapter": "^4.0.0",
|
|
29
|
+
"@web3auth/ui": "^4.0.0",
|
|
30
|
+
"@web3auth/wallet-connect-v1-adapter": "^4.0.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
36
|
"css-loader": "^6.7.2",
|
|
36
|
-
"
|
|
37
|
+
"postcss-prefix-selector": "^1.16.0",
|
|
37
38
|
"style-loader": "^3.3.1",
|
|
39
|
+
"tailwindcss": "^3.2.4",
|
|
38
40
|
"url-loader": "^4.1.1"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
@@ -61,5 +63,5 @@
|
|
|
61
63
|
"publishConfig": {
|
|
62
64
|
"access": "public"
|
|
63
65
|
},
|
|
64
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "44f016a57d3984c417df2c4e5ccefb0ad9220835"
|
|
65
67
|
}
|
package/src/default.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import 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" chainnamespace.
|
|
4
5
|
export const getDefaultAdapterModule = async (params: {
|
|
5
6
|
name: WALLET_ADAPTER_TYPE;
|
|
6
7
|
clientId: string;
|
|
@@ -35,10 +36,11 @@ export const getDefaultAdapterModule = async (params: {
|
|
|
35
36
|
return adapter;
|
|
36
37
|
} else if (name === WALLET_ADAPTERS.OPENLOGIN) {
|
|
37
38
|
const { OpenloginAdapter, getOpenloginDefaultOptions } = await import("@web3auth/openlogin-adapter");
|
|
38
|
-
const defaultOptions = getOpenloginDefaultOptions(
|
|
39
|
+
const defaultOptions = getOpenloginDefaultOptions();
|
|
39
40
|
const adapter = new OpenloginAdapter({
|
|
40
41
|
...defaultOptions,
|
|
41
|
-
|
|
42
|
+
clientId,
|
|
43
|
+
chainConfig: { ...finalChainConfig },
|
|
42
44
|
adapterSettings: { ...(defaultOptions.adapterSettings as OpenLoginOptions), clientId },
|
|
43
45
|
});
|
|
44
46
|
return adapter;
|
package/src/interface.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
BaseAdapterConfig,
|
|
3
|
+
ChainNamespaceType,
|
|
4
|
+
IWeb3Auth,
|
|
5
|
+
LoginMethodConfig,
|
|
6
|
+
SafeEventEmitterProvider,
|
|
7
|
+
WALLET_ADAPTER_TYPE,
|
|
8
|
+
} from "@web3auth/base";
|
|
2
9
|
export interface ModalConfig extends BaseAdapterConfig {
|
|
3
10
|
loginMethods?: LoginMethodConfig;
|
|
4
11
|
}
|
|
@@ -7,3 +14,8 @@ export interface AdaptersModalConfig {
|
|
|
7
14
|
chainNamespace: ChainNamespaceType;
|
|
8
15
|
adapters?: Record<WALLET_ADAPTER_TYPE, ModalConfig>;
|
|
9
16
|
}
|
|
17
|
+
|
|
18
|
+
export interface IWeb3AuthModal extends IWeb3Auth {
|
|
19
|
+
initModal(params?: { modalConfig?: Record<WALLET_ADAPTER_TYPE, ModalConfig> }): Promise<void>;
|
|
20
|
+
connect(): Promise<SafeEventEmitterProvider | null>;
|
|
21
|
+
}
|
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,
|
|
@@ -22,41 +22,9 @@ import {
|
|
|
22
22
|
defaultSolanaWalletModalConfig,
|
|
23
23
|
} from "./config";
|
|
24
24
|
import { getDefaultAdapterModule } from "./default";
|
|
25
|
-
import { AdaptersModalConfig, ModalConfig } from "./interface";
|
|
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,16 +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
|
}
|
|
82
|
-
export class Web3Auth extends Web3AuthCore {
|
|
43
|
+
export class Web3Auth extends Web3AuthCore implements IWeb3AuthModal {
|
|
83
44
|
public loginModal: LoginModal;
|
|
84
45
|
|
|
85
46
|
readonly options: Web3AuthOptions;
|
|
@@ -117,11 +78,12 @@ export class Web3Auth extends Web3AuthCore {
|
|
|
117
78
|
|
|
118
79
|
this.loginModal = new LoginModal({
|
|
119
80
|
theme: this.options.uiConfig?.theme,
|
|
81
|
+
appName: this.options.uiConfig?.appName || "blockchain",
|
|
120
82
|
appLogo: this.options.uiConfig?.appLogo || "",
|
|
121
|
-
version: "",
|
|
122
83
|
adapterListener: this,
|
|
123
|
-
displayErrorsOnModal: this.options.displayErrorsOnModal,
|
|
84
|
+
displayErrorsOnModal: this.options.uiConfig?.displayErrorsOnModal,
|
|
124
85
|
defaultLanguage,
|
|
86
|
+
modalZIndex: this.options.uiConfig?.modalZIndex || "99998",
|
|
125
87
|
});
|
|
126
88
|
this.subscribeToLoginModalEvents();
|
|
127
89
|
}
|
|
@@ -170,7 +132,11 @@ export class Web3Auth extends Web3AuthCore {
|
|
|
170
132
|
if (!this.modalConfig.adapters?.[adapterName].showOnModal) return;
|
|
171
133
|
// add client id to adapter, same web3auth client id can be used in adapter.
|
|
172
134
|
// this id is being overridden if user is also passing client id in adapter's constructor.
|
|
173
|
-
this.walletAdapters[adapterName].setAdapterSettings({
|
|
135
|
+
this.walletAdapters[adapterName].setAdapterSettings({
|
|
136
|
+
clientId: this.options.clientId,
|
|
137
|
+
sessionTime: this.options.sessionTime,
|
|
138
|
+
web3AuthNetwork: this.options.web3AuthNetwork,
|
|
139
|
+
});
|
|
174
140
|
|
|
175
141
|
// if adapter doesn't have any chainConfig then we will set the chainConfig based of passed chainNamespace
|
|
176
142
|
// and chainNamespace.
|
|
@@ -179,7 +145,7 @@ export class Web3Auth extends Web3AuthCore {
|
|
|
179
145
|
...getChainConfig(providedChainConfig.chainNamespace, this.coreOptions.chainConfig?.chainId),
|
|
180
146
|
...this.coreOptions.chainConfig,
|
|
181
147
|
} as CustomChainConfig;
|
|
182
|
-
this.walletAdapters[adapterName].
|
|
148
|
+
this.walletAdapters[adapterName].setAdapterSettings({ chainConfig });
|
|
183
149
|
}
|
|
184
150
|
|
|
185
151
|
return adapterName;
|