@web3auth/modal 10.9.1 → 10.11.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/lib.cjs/packages/modal/src/config.js +1 -1
- package/dist/lib.cjs/packages/modal/src/modalManager.js +27 -9
- package/dist/lib.cjs/packages/modal/src/react/context/WalletServicesInnerContext.js +4 -4
- package/dist/lib.cjs/packages/modal/src/react/context/Web3AuthInnerContext.js +25 -10
- package/dist/lib.cjs/packages/modal/src/react/hooks/useIdentityToken.js +7 -3
- package/dist/lib.cjs/packages/modal/src/react/hooks/useWeb3Auth.js +2 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +5 -3
- package/dist/lib.cjs/packages/modal/src/ui/components/CircularLoader/CircularLoader.js +88 -0
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js +2 -2
- package/dist/lib.cjs/packages/modal/src/ui/components/Loader/Loader.js +67 -5
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +8 -2
- package/dist/lib.cjs/packages/modal/src/ui/components/Widget/Widget.js +18 -5
- package/dist/lib.cjs/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/i18n/english.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/french.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/german.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/japanese.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/korean.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/mandarin.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/portuguese.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/spanish.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/i18n/turkish.json.js +3 -0
- package/dist/lib.cjs/packages/modal/src/ui/interfaces.js +3 -1
- package/dist/lib.cjs/packages/modal/src/ui/loginModal.js +26 -2
- package/dist/lib.cjs/packages/modal/src/vue/WalletServicesInnerProvider.js +4 -4
- package/dist/lib.cjs/packages/modal/src/vue/Web3AuthProvider.js +21 -11
- package/dist/lib.cjs/packages/modal/src/vue/composables/useCheckout.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useEnableMFA.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useFunding.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useIdentityToken.js +10 -3
- package/dist/lib.cjs/packages/modal/src/vue/composables/useManageMFA.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useReceive.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useSwap.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useSwitchChain.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletConnectScanner.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWalletUI.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthConnect.js +2 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthDisconnect.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/composables/useWeb3AuthUser.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignMessage.js +1 -0
- package/dist/lib.cjs/packages/modal/src/vue/solana/composables/useSignTransaction.js +1 -0
- package/dist/lib.cjs/types/modalManager.d.ts +1 -0
- package/dist/lib.cjs/types/ui/components/BottomSheet/BottomSheet.d.ts +1 -1
- package/dist/lib.cjs/types/ui/components/BottomSheet/BottomSheet.type.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/CircularLoader/CircularLoader.d.ts +3 -0
- package/dist/lib.cjs/types/ui/components/CircularLoader/CircularLoader.type.d.ts +19 -0
- package/dist/lib.cjs/types/ui/components/CircularLoader/index.d.ts +2 -0
- package/dist/lib.cjs/types/ui/components/Loader/Loader.type.d.ts +8 -0
- package/dist/lib.cjs/types/ui/components/Root/Root.type.d.ts +5 -1
- package/dist/lib.cjs/types/ui/components/Widget/Widget.type.d.ts +5 -1
- package/dist/lib.cjs/types/ui/interfaces.d.ts +7 -1
- package/dist/lib.cjs/types/ui/loginModal.d.ts +1 -0
- package/dist/lib.cjs/types/vue/interfaces.d.ts +1 -0
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/modalManager.js +28 -10
- package/dist/lib.esm/packages/modal/src/react/context/WalletServicesInnerContext.js +5 -5
- package/dist/lib.esm/packages/modal/src/react/context/Web3AuthInnerContext.js +25 -10
- package/dist/lib.esm/packages/modal/src/react/hooks/useIdentityToken.js +7 -3
- package/dist/lib.esm/packages/modal/src/react/hooks/useWeb3Auth.js +2 -0
- package/dist/lib.esm/packages/modal/src/ui/components/BottomSheet/BottomSheet.js +5 -3
- package/dist/lib.esm/packages/modal/src/ui/components/CircularLoader/CircularLoader.js +86 -0
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWalletChainNamespaceSelect/ConnectWalletChainNamespaceSelect.js +2 -2
- package/dist/lib.esm/packages/modal/src/ui/components/Loader/Loader.js +68 -6
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +8 -2
- package/dist/lib.esm/packages/modal/src/ui/components/Widget/Widget.js +19 -6
- package/dist/lib.esm/packages/modal/src/ui/css/index.css.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/i18n/english.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/french.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/german.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/japanese.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/korean.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/mandarin.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/portuguese.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/spanish.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/i18n/turkish.json.js +3 -0
- package/dist/lib.esm/packages/modal/src/ui/interfaces.js +3 -1
- package/dist/lib.esm/packages/modal/src/ui/loginModal.js +28 -4
- package/dist/lib.esm/packages/modal/src/vue/WalletServicesInnerProvider.js +4 -4
- package/dist/lib.esm/packages/modal/src/vue/Web3AuthProvider.js +22 -12
- package/dist/lib.esm/packages/modal/src/vue/composables/useCheckout.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useEnableMFA.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useFunding.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useIdentityToken.js +11 -4
- package/dist/lib.esm/packages/modal/src/vue/composables/useManageMFA.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useReceive.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useSwap.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useSwitchChain.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletConnectScanner.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useWalletUI.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthConnect.js +3 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthDisconnect.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/composables/useWeb3AuthUser.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignAndSendTransaction.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignMessage.js +2 -1
- package/dist/lib.esm/packages/modal/src/vue/solana/composables/useSignTransaction.js +2 -1
- package/dist/modal.umd.min.js +1 -1
- package/package.json +3 -3
|
@@ -33,6 +33,7 @@ export declare class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal
|
|
|
33
33
|
private onSocialLogin;
|
|
34
34
|
private onExternalWalletLogin;
|
|
35
35
|
private onModalVisibility;
|
|
36
|
+
private onMobileVerifyConnect;
|
|
36
37
|
private getChainNamespaces;
|
|
37
38
|
private getCombinedConnectionId;
|
|
38
39
|
}
|
|
@@ -3,5 +3,5 @@ import { BottomSheetProps } from "./BottomSheet.type";
|
|
|
3
3
|
* BottomSheet component
|
|
4
4
|
* @returns BottomSheet component
|
|
5
5
|
*/
|
|
6
|
-
declare function BottomSheet({ isShown, onClose, children, uiConfig }: BottomSheetProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function BottomSheet({ isShown, onClose, children, uiConfig, sheetClassName, showCloseButton }: BottomSheetProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default BottomSheet;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface CircularLoaderProps {
|
|
3
|
+
width?: number | string;
|
|
4
|
+
height?: number | string;
|
|
5
|
+
thickness?: number;
|
|
6
|
+
showChildren?: boolean;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
trackColor?: string;
|
|
10
|
+
/** Size of the colored arc in degrees (0-360). Default: 40 */
|
|
11
|
+
arcSizeDeg?: number;
|
|
12
|
+
/** Two colors for the orange arc gradient [start, end]. */
|
|
13
|
+
arcColors?: [string, string];
|
|
14
|
+
/**
|
|
15
|
+
* CSS color stops for conic-gradient. Example:
|
|
16
|
+
* "conic-gradient(#f97316, #fdba74 320deg, transparent 320deg)"
|
|
17
|
+
*/
|
|
18
|
+
gradient?: string;
|
|
19
|
+
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { BaseConnectorConfig, WALLET_CONNECTOR_TYPE, WalletRegistry } from "@web3auth/no-modal";
|
|
1
2
|
import type { ModalStatusType } from "../../interfaces";
|
|
2
3
|
export interface LoaderProps {
|
|
4
|
+
externalWalletsConfig: Record<string, BaseConnectorConfig>;
|
|
5
|
+
walletRegistry?: WalletRegistry;
|
|
3
6
|
message?: string;
|
|
4
7
|
appLogo?: string;
|
|
5
8
|
connector: string;
|
|
6
9
|
connectorName: string;
|
|
7
10
|
modalStatus: ModalStatusType;
|
|
8
11
|
onClose: () => void;
|
|
12
|
+
isConnectAndSignAuthenticationMode: boolean;
|
|
13
|
+
handleMobileVerifyConnect: (params: {
|
|
14
|
+
connector: WALLET_CONNECTOR_TYPE;
|
|
15
|
+
}) => void;
|
|
9
16
|
}
|
|
10
17
|
export type ConnectingStatusType = Pick<LoaderProps, "connectorName" | "appLogo" | "connector">;
|
|
11
18
|
export type ConnectedStatusType = Pick<LoaderProps, "message">;
|
|
12
19
|
export type ErroredStatusType = Pick<LoaderProps, "message">;
|
|
20
|
+
export type AuthorizingStatusType = Pick<LoaderProps, "connector" | "externalWalletsConfig" | "walletRegistry" | "handleMobileVerifyConnect">;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChainNamespaceType, WalletRegistry } from "@web3auth/no-modal";
|
|
1
|
+
import type { ChainNamespaceType, WALLET_CONNECTOR_TYPE, WalletRegistry } from "@web3auth/no-modal";
|
|
2
2
|
import { browser, ModalState, os, platform, SocialLoginEventType, SocialLoginsConfig, UIConfig } from "../../interfaces";
|
|
3
3
|
export interface RootProps {
|
|
4
4
|
appLogo?: string;
|
|
@@ -29,4 +29,8 @@ export interface RootProps {
|
|
|
29
29
|
}) => void;
|
|
30
30
|
setModalState: (state: ModalState) => void;
|
|
31
31
|
onCloseLoader: () => void;
|
|
32
|
+
isConnectAndSignAuthenticationMode: boolean;
|
|
33
|
+
handleMobileVerifyConnect: (params: {
|
|
34
|
+
connector: WALLET_CONNECTOR_TYPE;
|
|
35
|
+
}) => void;
|
|
32
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SafeEventEmitter } from "@web3auth/auth";
|
|
2
|
-
import { ChainNamespaceType, WalletRegistry } from "@web3auth/no-modal";
|
|
2
|
+
import { ChainNamespaceType, ConnectorInitialAuthenticationModeType, WALLET_CONNECTOR_TYPE, WalletRegistry } from "@web3auth/no-modal";
|
|
3
3
|
import { browser, ExternalWalletEventType, os, platform, SocialLoginEventType, StateEmitterEvents, UIConfig } from "../../interfaces";
|
|
4
4
|
export interface WidgetProps {
|
|
5
5
|
stateListener: SafeEventEmitter<StateEmitterEvents>;
|
|
@@ -8,6 +8,7 @@ export interface WidgetProps {
|
|
|
8
8
|
chainNamespaces: ChainNamespaceType[];
|
|
9
9
|
walletRegistry?: WalletRegistry;
|
|
10
10
|
uiConfig: UIConfig;
|
|
11
|
+
initialAuthenticationMode: ConnectorInitialAuthenticationModeType;
|
|
11
12
|
deviceDetails: {
|
|
12
13
|
platform: platform;
|
|
13
14
|
browser: browser;
|
|
@@ -15,6 +16,9 @@ export interface WidgetProps {
|
|
|
15
16
|
};
|
|
16
17
|
handleSocialLoginClick: (params: SocialLoginEventType) => void;
|
|
17
18
|
handleExternalWalletClick: (params: ExternalWalletEventType) => void;
|
|
19
|
+
handleMobileVerifyConnect: (params: {
|
|
20
|
+
connector: WALLET_CONNECTOR_TYPE;
|
|
21
|
+
}) => void;
|
|
18
22
|
handleShowExternalWallets: (externalWalletsInitialized: boolean) => void;
|
|
19
23
|
closeModal: () => void;
|
|
20
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AUTH_CONNECTION_TYPE, BUILD_ENV_TYPE, EMAIL_FLOW_TYPE, ExtraLoginOptions, LANGUAGES, SafeEventEmitter, THEME_MODE_TYPE, WEB3AUTH_NETWORK_TYPE } from "@web3auth/auth";
|
|
2
|
-
import { type Analytics, type AuthLoginParams, type BaseConnectorConfig, type ChainNamespaceType, type LoginMethodConfig, type LoginModalConfig, type UIConfig as CoreUIConfig, type WALLET_CONNECTOR_TYPE, type WalletRegistry, type WalletRegistryItem, type Web3AuthNoModalEvents } from "@web3auth/no-modal";
|
|
2
|
+
import { type Analytics, type AuthLoginParams, type BaseConnectorConfig, type ChainNamespaceType, type ConnectorInitialAuthenticationModeType, type LoginMethodConfig, type LoginModalConfig, type UIConfig as CoreUIConfig, type WALLET_CONNECTOR_TYPE, type WalletRegistry, type WalletRegistryItem, type Web3AuthNoModalEvents } from "@web3auth/no-modal";
|
|
3
3
|
export interface UIConfig extends CoreUIConfig, LoginModalConfig {
|
|
4
4
|
/**
|
|
5
5
|
* ID of the element to embed the widget into
|
|
@@ -42,6 +42,7 @@ export type ModalLoginParams = Pick<AuthLoginParams, "authConnection" | "authCon
|
|
|
42
42
|
name: string;
|
|
43
43
|
};
|
|
44
44
|
export interface LoginModalProps extends UIConfig {
|
|
45
|
+
initialAuthenticationMode: ConnectorInitialAuthenticationModeType;
|
|
45
46
|
chainNamespaces: ChainNamespaceType[];
|
|
46
47
|
walletRegistry: WalletRegistry;
|
|
47
48
|
web3authClientId: string;
|
|
@@ -64,6 +65,9 @@ export interface LoginModalCallbacks {
|
|
|
64
65
|
};
|
|
65
66
|
}) => Promise<void>;
|
|
66
67
|
onModalVisibility: (visibility: boolean) => Promise<void>;
|
|
68
|
+
onMobileVerifyConnect: (params: {
|
|
69
|
+
connector: WALLET_CONNECTOR_TYPE;
|
|
70
|
+
}) => Promise<void>;
|
|
67
71
|
}
|
|
68
72
|
export declare const LOGIN_MODAL_EVENTS: {
|
|
69
73
|
readonly MODAL_VISIBILITY: "MODAL_VISIBILITY";
|
|
@@ -79,6 +83,8 @@ export declare const MODAL_STATUS: {
|
|
|
79
83
|
readonly CONNECTED: "connected";
|
|
80
84
|
readonly CONNECTING: "connecting";
|
|
81
85
|
readonly ERRORED: "errored";
|
|
86
|
+
readonly AUTHORIZING: "authorizing";
|
|
87
|
+
readonly AUTHORIZED: "authorized";
|
|
82
88
|
};
|
|
83
89
|
export type ModalStatusType = (typeof MODAL_STATUS)[keyof typeof MODAL_STATUS];
|
|
84
90
|
export interface ModalState {
|
|
@@ -28,6 +28,7 @@ export declare class LoginModal {
|
|
|
28
28
|
initExternalWalletContainer: () => void;
|
|
29
29
|
private handleShowExternalWallets;
|
|
30
30
|
private handleExternalWalletClick;
|
|
31
|
+
private handleMobileVerifyConnect;
|
|
31
32
|
private handleSocialLoginClick;
|
|
32
33
|
private setState;
|
|
33
34
|
private handleConnectorData;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import { serializeError } from '@web3auth/auth';
|
|
4
|
-
import { Web3AuthNoModal, cloneDeep, WALLET_CONNECTORS, LOGIN_MODE, log, CONNECTOR_STATUS, sdkVersion, ANALYTICS_SDK_TYPE, withAbort, CONNECTOR_EVENTS, ANALYTICS_EVENTS, getErrorAnalyticsProperties, WalletInitializationError, fetchProjectConfig, fetchWalletRegistry, WALLET_REGISTRY_URL, CONNECTOR_CATEGORY, CONNECTOR_NAMES, CONNECTOR_NAMESPACES } from '@web3auth/no-modal';
|
|
4
|
+
import { Web3AuthNoModal, cloneDeep, WALLET_CONNECTORS, LOGIN_MODE, log, CONNECTOR_STATUS, CONNECTED_STATUSES, sdkVersion, ANALYTICS_SDK_TYPE, withAbort, CONNECTOR_EVENTS, ANALYTICS_EVENTS, getErrorAnalyticsProperties, WalletInitializationError, CONNECTOR_INITIAL_AUTHENTICATION_MODE, fetchProjectConfig, fetchWalletRegistry, WALLET_REGISTRY_URL, CONNECTOR_CATEGORY, CONNECTOR_NAMES, CONNECTOR_NAMESPACES } from '@web3auth/no-modal';
|
|
5
5
|
import deepmerge from 'deepmerge';
|
|
6
6
|
import { defaultConnectorsModalConfig } from './config.js';
|
|
7
7
|
import { AUTH_PROVIDERS_NAMES, AUTH_PROVIDERS, capitalizeFirstLetter } from './ui/config.js';
|
|
@@ -70,12 +70,20 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
70
70
|
log.error(`Error while disconnecting to wallet connect in core`, error);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
if (!visibility && this.status
|
|
73
|
+
if (!visibility && CONNECTED_STATUSES.includes(this.status) && (walletConnectStatus === CONNECTOR_STATUS.READY || walletConnectStatus === CONNECTOR_STATUS.CONNECTING)) {
|
|
74
74
|
log.debug("this stops wc connector from trying to reconnect once proposal expires");
|
|
75
75
|
wcConnector.status = CONNECTOR_STATUS.READY;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
+
_defineProperty(this, "onMobileVerifyConnect", async params => {
|
|
80
|
+
try {
|
|
81
|
+
const connector = this.getConnector(params.connector);
|
|
82
|
+
await connector.getIdentityToken();
|
|
83
|
+
} catch (error) {
|
|
84
|
+
log.error(`Error while connecting to connector: ${params.connector}`, error);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
79
87
|
_defineProperty(this, "getChainNamespaces", () => {
|
|
80
88
|
var _this$coreOptions$cha;
|
|
81
89
|
return [...new Set(((_this$coreOptions$cha = this.coreOptions.chains) === null || _this$coreOptions$cha === void 0 ? void 0 : _this$coreOptions$cha.map(x => x.chainNamespace)) || [])];
|
|
@@ -138,12 +146,14 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
138
146
|
authBuildEnv: this.options.authBuildEnv,
|
|
139
147
|
chainNamespaces: this.getChainNamespaces(),
|
|
140
148
|
walletRegistry: filteredWalletRegistry,
|
|
141
|
-
analytics: this.analytics
|
|
149
|
+
analytics: this.analytics,
|
|
150
|
+
initialAuthenticationMode: this.options.initialAuthenticationMode
|
|
142
151
|
}), {
|
|
143
152
|
onInitExternalWallets: this.onInitExternalWallets,
|
|
144
153
|
onSocialLogin: this.onSocialLogin,
|
|
145
154
|
onExternalWalletLogin: this.onExternalWalletLogin,
|
|
146
|
-
onModalVisibility: this.onModalVisibility
|
|
155
|
+
onModalVisibility: this.onModalVisibility,
|
|
156
|
+
onMobileVerifyConnect: this.onMobileVerifyConnect
|
|
147
157
|
});
|
|
148
158
|
await withAbort(() => this.loginModal.initModal(), signal);
|
|
149
159
|
|
|
@@ -199,7 +209,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
199
209
|
async connect() {
|
|
200
210
|
if (!this.loginModal) throw WalletInitializationError.notReady("Login modal is not initialized");
|
|
201
211
|
// if already connected return provider
|
|
202
|
-
if (this.connectedConnectorName && this.status
|
|
212
|
+
if (this.connectedConnectorName && CONNECTED_STATUSES.includes(this.status) && this.provider) return this.provider;
|
|
203
213
|
this.loginModal.open();
|
|
204
214
|
return new Promise((resolve, reject) => {
|
|
205
215
|
// remove all listeners when promise is resolved or rejected.
|
|
@@ -211,18 +221,24 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
211
221
|
};
|
|
212
222
|
const handleError = err => {
|
|
213
223
|
this.removeListener(CONNECTOR_EVENTS.CONNECTED, handleConnected);
|
|
224
|
+
this.removeListener(CONNECTOR_EVENTS.AUTHORIZED, handleConnected);
|
|
214
225
|
this.removeListener(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
|
|
215
226
|
return reject(err);
|
|
216
227
|
};
|
|
217
228
|
const handleVisibility = visibility => {
|
|
218
229
|
// modal is closed but user is not connected to any wallet.
|
|
219
|
-
if (!visibility && this.status
|
|
230
|
+
if (!visibility && !CONNECTED_STATUSES.includes(this.status)) {
|
|
220
231
|
this.removeListener(CONNECTOR_EVENTS.CONNECTED, handleConnected);
|
|
221
232
|
this.removeListener(CONNECTOR_EVENTS.ERRORED, handleError);
|
|
233
|
+
this.removeListener(CONNECTOR_EVENTS.AUTHORIZED, handleConnected);
|
|
222
234
|
return reject(new Error("User closed the modal"));
|
|
223
235
|
}
|
|
224
236
|
};
|
|
225
|
-
this.
|
|
237
|
+
if (this.coreOptions.initialAuthenticationMode === CONNECTOR_INITIAL_AUTHENTICATION_MODE.CONNECT_AND_SIGN) {
|
|
238
|
+
this.once(CONNECTOR_EVENTS.AUTHORIZED, handleConnected);
|
|
239
|
+
} else {
|
|
240
|
+
this.once(CONNECTOR_EVENTS.CONNECTED, handleConnected);
|
|
241
|
+
}
|
|
226
242
|
this.once(CONNECTOR_EVENTS.ERRORED, handleError);
|
|
227
243
|
this.once(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, handleVisibility);
|
|
228
244
|
});
|
|
@@ -534,7 +550,8 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
534
550
|
const autoConnect = super.checkIfAutoConnect(connector);
|
|
535
551
|
await connector.init({
|
|
536
552
|
autoConnect,
|
|
537
|
-
chainId: initialChain.chainId
|
|
553
|
+
chainId: initialChain.chainId,
|
|
554
|
+
getIdentityToken: this.options.initialAuthenticationMode === CONNECTOR_INITIAL_AUTHENTICATION_MODE.CONNECT_AND_SIGN
|
|
538
555
|
});
|
|
539
556
|
|
|
540
557
|
// note: not adding cachedWallet to modal if it is external wallet.
|
|
@@ -578,7 +595,8 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
578
595
|
const initialChain = this.getInitialChainIdForConnector(connector);
|
|
579
596
|
await connector.init({
|
|
580
597
|
autoConnect: this.cachedConnector === connectorName,
|
|
581
|
-
chainId: initialChain.chainId
|
|
598
|
+
chainId: initialChain.chainId,
|
|
599
|
+
getIdentityToken: this.options.initialAuthenticationMode === CONNECTOR_INITIAL_AUTHENTICATION_MODE.CONNECT_AND_SIGN
|
|
582
600
|
});
|
|
583
601
|
} catch (error) {
|
|
584
602
|
log.error(error, "error while initializing connector", connectorName);
|
|
@@ -586,7 +604,7 @@ class Web3Auth extends Web3AuthNoModal {
|
|
|
586
604
|
}
|
|
587
605
|
|
|
588
606
|
// update connector config
|
|
589
|
-
if ([CONNECTOR_STATUS.NOT_READY, CONNECTOR_STATUS.READY, CONNECTOR_STATUS.CONNECTING, CONNECTOR_STATUS.CONNECTED].includes(connector.status)) {
|
|
607
|
+
if ([CONNECTOR_STATUS.NOT_READY, CONNECTOR_STATUS.READY, CONNECTOR_STATUS.CONNECTING, CONNECTOR_STATUS.CONNECTED, CONNECTOR_STATUS.AUTHORIZING, CONNECTOR_STATUS.AUTHORIZED].includes(connector.status)) {
|
|
590
608
|
const connectorModalConfig = this.modalConfig.connectors[connectorName];
|
|
591
609
|
connectorsConfig[connectorName] = _objectSpread(_objectSpread({}, connectorModalConfig), {}, {
|
|
592
610
|
isInjected: connector.isInjected,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EVM_PLUGINS,
|
|
1
|
+
import { EVM_PLUGINS, CONNECTED_STATUSES, PLUGIN_EVENTS } from '@web3auth/no-modal';
|
|
2
2
|
import { createContext, useContext, useState, useEffect, useMemo, createElement } from 'react';
|
|
3
3
|
|
|
4
4
|
const WalletServicesContext = /*#__PURE__*/createContext(null);
|
|
@@ -26,7 +26,7 @@ function WalletServicesContextProvider({
|
|
|
26
26
|
const plugin = getPlugin(EVM_PLUGINS.WALLET_SERVICES);
|
|
27
27
|
setWalletServicesPlugin(plugin);
|
|
28
28
|
// when rehydrating, the connectedListener may be registered after the connected event is emitted, we need to check the status here
|
|
29
|
-
if ((plugin === null || plugin === void 0 ? void 0 : plugin.status)
|
|
29
|
+
if (CONNECTED_STATUSES.includes(plugin === null || plugin === void 0 ? void 0 : plugin.status)) setReady(true);
|
|
30
30
|
}
|
|
31
31
|
}, [isConnected, getPlugin, walletServicesPlugin]);
|
|
32
32
|
useEffect(() => {
|
|
@@ -48,9 +48,9 @@ function WalletServicesContextProvider({
|
|
|
48
48
|
}
|
|
49
49
|
return () => {
|
|
50
50
|
if (walletServicesPlugin) {
|
|
51
|
-
walletServicesPlugin.
|
|
52
|
-
walletServicesPlugin.
|
|
53
|
-
walletServicesPlugin.
|
|
51
|
+
walletServicesPlugin.removeListener(PLUGIN_EVENTS.CONNECTED, connectedListener);
|
|
52
|
+
walletServicesPlugin.removeListener(PLUGIN_EVENTS.DISCONNECTED, disconnectedListener);
|
|
53
|
+
walletServicesPlugin.removeListener(PLUGIN_EVENTS.CONNECTING, connectingListener);
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
}, [walletServicesPlugin]);
|
|
@@ -24,6 +24,7 @@ function Web3AuthInnerProvider(params) {
|
|
|
24
24
|
return new Web3Auth(web3AuthOptions, initialState);
|
|
25
25
|
}, [web3AuthOptions, initialState]);
|
|
26
26
|
const [isConnected, setIsConnected] = useState(web3Auth.status === CONNECTOR_STATUS.CONNECTED);
|
|
27
|
+
const [isAuthorized, setIsAuthorized] = useState(web3Auth.status === CONNECTOR_STATUS.AUTHORIZED);
|
|
27
28
|
const [status, setStatus] = useState(web3Auth.status);
|
|
28
29
|
const getPlugin = useCallback(name => {
|
|
29
30
|
if (!web3Auth) throw WalletInitializationError.notReady();
|
|
@@ -64,7 +65,9 @@ function Web3AuthInnerProvider(params) {
|
|
|
64
65
|
if (provider) {
|
|
65
66
|
provider.on("chainChanged", handleChainChange);
|
|
66
67
|
return () => {
|
|
67
|
-
provider
|
|
68
|
+
if (provider) {
|
|
69
|
+
provider.removeListener("chainChanged", handleChainChange);
|
|
70
|
+
}
|
|
68
71
|
};
|
|
69
72
|
}
|
|
70
73
|
}, [web3Auth, provider]);
|
|
@@ -83,9 +86,17 @@ function Web3AuthInnerProvider(params) {
|
|
|
83
86
|
setProvider(data.provider);
|
|
84
87
|
}
|
|
85
88
|
};
|
|
89
|
+
const authorizedListener = _data => {
|
|
90
|
+
setStatus(web3Auth.status);
|
|
91
|
+
if (web3Auth.status === CONNECTOR_STATUS.AUTHORIZED) {
|
|
92
|
+
setIsConnected(true);
|
|
93
|
+
setIsAuthorized(true);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
86
96
|
const disconnectedListener = () => {
|
|
87
97
|
setStatus(web3Auth.status);
|
|
88
98
|
setIsConnected(false);
|
|
99
|
+
setIsAuthorized(false);
|
|
89
100
|
setProvider(null);
|
|
90
101
|
};
|
|
91
102
|
const connectingListener = () => {
|
|
@@ -97,6 +108,7 @@ function Web3AuthInnerProvider(params) {
|
|
|
97
108
|
const rehydrationErrorListener = () => {
|
|
98
109
|
setStatus(web3Auth.status);
|
|
99
110
|
setIsConnected(false);
|
|
111
|
+
setIsAuthorized(false);
|
|
100
112
|
setProvider(null);
|
|
101
113
|
};
|
|
102
114
|
const mfaEnabledListener = isMFAEnabled => {
|
|
@@ -108,6 +120,7 @@ function Web3AuthInnerProvider(params) {
|
|
|
108
120
|
web3Auth.on(CONNECTOR_EVENTS.NOT_READY, notReadyListener);
|
|
109
121
|
web3Auth.on(CONNECTOR_EVENTS.READY, readyListener);
|
|
110
122
|
web3Auth.on(CONNECTOR_EVENTS.CONNECTED, connectedListener);
|
|
123
|
+
web3Auth.on(CONNECTOR_EVENTS.AUTHORIZED, authorizedListener);
|
|
111
124
|
web3Auth.on(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
112
125
|
web3Auth.on(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
113
126
|
web3Auth.on(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
@@ -116,14 +129,15 @@ function Web3AuthInnerProvider(params) {
|
|
|
116
129
|
}
|
|
117
130
|
return () => {
|
|
118
131
|
if (web3Auth) {
|
|
119
|
-
web3Auth.
|
|
120
|
-
web3Auth.
|
|
121
|
-
web3Auth.
|
|
122
|
-
web3Auth.
|
|
123
|
-
web3Auth.
|
|
124
|
-
web3Auth.
|
|
125
|
-
web3Auth.
|
|
126
|
-
web3Auth.
|
|
132
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.NOT_READY, notReadyListener);
|
|
133
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.READY, readyListener);
|
|
134
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.CONNECTED, connectedListener);
|
|
135
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.AUTHORIZED, authorizedListener);
|
|
136
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.DISCONNECTED, disconnectedListener);
|
|
137
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.CONNECTING, connectingListener);
|
|
138
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.ERRORED, errorListener);
|
|
139
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.REHYDRATION_ERROR, rehydrationErrorListener);
|
|
140
|
+
web3Auth.removeListener(CONNECTOR_EVENTS.MFA_ENABLED, mfaEnabledListener);
|
|
127
141
|
web3Auth.cleanup();
|
|
128
142
|
}
|
|
129
143
|
};
|
|
@@ -132,6 +146,7 @@ function Web3AuthInnerProvider(params) {
|
|
|
132
146
|
return {
|
|
133
147
|
web3Auth,
|
|
134
148
|
isConnected,
|
|
149
|
+
isAuthorized,
|
|
135
150
|
isInitialized,
|
|
136
151
|
provider,
|
|
137
152
|
status,
|
|
@@ -143,7 +158,7 @@ function Web3AuthInnerProvider(params) {
|
|
|
143
158
|
getPlugin,
|
|
144
159
|
setIsMFAEnabled
|
|
145
160
|
};
|
|
146
|
-
}, [web3Auth, isConnected, isMFAEnabled, setIsMFAEnabled, isInitialized, provider, status, getPlugin, isInitializing, initError, chainId, chainNamespace]);
|
|
161
|
+
}, [web3Auth, isConnected, isAuthorized, isMFAEnabled, setIsMFAEnabled, isInitialized, provider, status, getPlugin, isInitializing, initError, chainId, chainNamespace]);
|
|
147
162
|
return /*#__PURE__*/createElement(Web3AuthInnerContext.Provider, {
|
|
148
163
|
value
|
|
149
164
|
}, children);
|
|
@@ -4,7 +4,7 @@ import { useWeb3AuthInner } from './useWeb3AuthInner.js';
|
|
|
4
4
|
const useIdentityToken = () => {
|
|
5
5
|
const {
|
|
6
6
|
web3Auth,
|
|
7
|
-
|
|
7
|
+
isAuthorized
|
|
8
8
|
} = useWeb3AuthInner();
|
|
9
9
|
const [loading, setLoading] = useState(false);
|
|
10
10
|
const [error, setError] = useState(null);
|
|
@@ -25,10 +25,14 @@ const useIdentityToken = () => {
|
|
|
25
25
|
}
|
|
26
26
|
}, [web3Auth]);
|
|
27
27
|
useEffect(() => {
|
|
28
|
-
if (!
|
|
28
|
+
if (!web3Auth) return;
|
|
29
|
+
if (!isAuthorized && token) {
|
|
29
30
|
setToken(null);
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
if (isAuthorized && !token) {
|
|
33
|
+
setToken(web3Auth.idToken);
|
|
34
|
+
}
|
|
35
|
+
}, [isAuthorized, token, web3Auth]);
|
|
32
36
|
return {
|
|
33
37
|
loading,
|
|
34
38
|
error,
|
|
@@ -4,6 +4,7 @@ const useWeb3Auth = () => {
|
|
|
4
4
|
const {
|
|
5
5
|
initError,
|
|
6
6
|
isConnected,
|
|
7
|
+
isAuthorized,
|
|
7
8
|
isInitialized,
|
|
8
9
|
isInitializing,
|
|
9
10
|
provider,
|
|
@@ -14,6 +15,7 @@ const useWeb3Auth = () => {
|
|
|
14
15
|
return {
|
|
15
16
|
initError,
|
|
16
17
|
isConnected,
|
|
18
|
+
isAuthorized,
|
|
17
19
|
isInitialized,
|
|
18
20
|
isInitializing,
|
|
19
21
|
provider,
|
|
@@ -9,7 +9,9 @@ function BottomSheet({
|
|
|
9
9
|
isShown,
|
|
10
10
|
onClose,
|
|
11
11
|
children,
|
|
12
|
-
uiConfig
|
|
12
|
+
uiConfig,
|
|
13
|
+
sheetClassName,
|
|
14
|
+
showCloseButton = true
|
|
13
15
|
}) {
|
|
14
16
|
const {
|
|
15
17
|
borderRadiusType = "large"
|
|
@@ -32,8 +34,8 @@ function BottomSheet({
|
|
|
32
34
|
"w3a--rounded-[30px]": borderRadiusType === "large",
|
|
33
35
|
"w3a--rounded-2xl": borderRadiusType === "medium",
|
|
34
36
|
"w3a--rounded-none": borderRadiusType === "small"
|
|
35
|
-
}),
|
|
36
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
37
|
+
}, sheetClassName),
|
|
38
|
+
children: [showCloseButton && /*#__PURE__*/jsx("div", {
|
|
37
39
|
className: "w3a--absolute w3a--right-4 w3a--top-[16px] w3a--z-10 w3a--cursor-pointer",
|
|
38
40
|
children: /*#__PURE__*/jsx("svg", {
|
|
39
41
|
width: "13",
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { cn } from '../../utils.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
function toSize(value, fallback = 160) {
|
|
5
|
+
return value !== null && value !== void 0 ? value : fallback;
|
|
6
|
+
}
|
|
7
|
+
const CircularLoader = props => {
|
|
8
|
+
const {
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
thickness = 12,
|
|
12
|
+
className = "",
|
|
13
|
+
children,
|
|
14
|
+
showChildren = true,
|
|
15
|
+
trackColor = "rgba(226, 232, 240, 1)",
|
|
16
|
+
// Tailwind slate-200 equivalent
|
|
17
|
+
gradient,
|
|
18
|
+
arcSizeDeg = 36,
|
|
19
|
+
arcColors
|
|
20
|
+
} = props;
|
|
21
|
+
const w = toSize(width, 160);
|
|
22
|
+
const h = toSize(height, 160);
|
|
23
|
+
const ringMask = `radial-gradient(farthest-side, transparent calc(100% - ${thickness}px), #000 calc(100% - ${thickness}px))`;
|
|
24
|
+
function hexToRgba(hex, alpha) {
|
|
25
|
+
const normalized = hex.replace("#", "");
|
|
26
|
+
const full = normalized.length === 3 ? normalized.split("").map(c => c + c).join("") : normalized;
|
|
27
|
+
const r = parseInt(full.substring(0, 2), 16);
|
|
28
|
+
const g = parseInt(full.substring(2, 4), 16);
|
|
29
|
+
const b = parseInt(full.substring(4, 6), 16);
|
|
30
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
31
|
+
}
|
|
32
|
+
function withAlpha(color, alpha) {
|
|
33
|
+
if (!color) return color;
|
|
34
|
+
const c = color.trim().toLowerCase();
|
|
35
|
+
if (c.startsWith("#")) return hexToRgba(c, alpha);
|
|
36
|
+
if (c.startsWith("rgba(")) return color;
|
|
37
|
+
if (c.startsWith("rgb(")) {
|
|
38
|
+
const nums = c.slice(4, -1);
|
|
39
|
+
return `rgba(${nums}, ${alpha})`;
|
|
40
|
+
}
|
|
41
|
+
// Fallback: return the same color (alpha may be ignored by browser)
|
|
42
|
+
return color;
|
|
43
|
+
}
|
|
44
|
+
const arcColorGradient = gradient || (arcColors ? `radial-gradient(210.91% 85.29% at 14.56% 18.67%, ${withAlpha(arcColors[0], 0)} 9.5%, ${arcColors[1]} 41.82%, ${arcColors[1]} 64.83%, ${withAlpha(arcColors[0], 0.44)} 100%)` : "radial-gradient(210.91% 85.29% at 14.56% 18.67%, rgba(255, 98, 58, 0.00) 9.5%, #FF623A 41.82%, #FF623A 64.83%, rgba(255, 98, 58, 0.44) 100%)");
|
|
45
|
+
const wedgeMask = `conic-gradient(#000 0deg ${arcSizeDeg}deg, transparent ${arcSizeDeg}deg 360deg)`;
|
|
46
|
+
return /*#__PURE__*/jsxs("div", {
|
|
47
|
+
className: cn("w3a--relative w3a--inline-flex w3a--items-center w3a--justify-center", className),
|
|
48
|
+
style: {
|
|
49
|
+
width: w,
|
|
50
|
+
height: h
|
|
51
|
+
},
|
|
52
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
53
|
+
className: "w3a--absolute w3a--inset-0 w3a--rounded-full",
|
|
54
|
+
style: {
|
|
55
|
+
background: trackColor,
|
|
56
|
+
WebkitMaskImage: ringMask,
|
|
57
|
+
maskImage: ringMask,
|
|
58
|
+
WebkitMaskRepeat: "no-repeat",
|
|
59
|
+
maskRepeat: "no-repeat"
|
|
60
|
+
}
|
|
61
|
+
}), /*#__PURE__*/jsx("div", {
|
|
62
|
+
className: "w3a--absolute w3a--inset-0 w3a--animate-spin",
|
|
63
|
+
style: {
|
|
64
|
+
WebkitMaskImage: wedgeMask,
|
|
65
|
+
maskImage: wedgeMask,
|
|
66
|
+
WebkitMaskRepeat: "no-repeat",
|
|
67
|
+
maskRepeat: "no-repeat"
|
|
68
|
+
},
|
|
69
|
+
children: /*#__PURE__*/jsx("div", {
|
|
70
|
+
className: "w3a--absolute w3a--inset-0 w3a--rounded-full",
|
|
71
|
+
style: {
|
|
72
|
+
background: arcColorGradient,
|
|
73
|
+
WebkitMaskImage: ringMask,
|
|
74
|
+
maskImage: ringMask,
|
|
75
|
+
WebkitMaskRepeat: "no-repeat",
|
|
76
|
+
maskRepeat: "no-repeat"
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}), showChildren && children ? /*#__PURE__*/jsx("div", {
|
|
80
|
+
className: "w3a--relative",
|
|
81
|
+
children: children
|
|
82
|
+
}) : null]
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { CircularLoader as default };
|
|
@@ -41,7 +41,7 @@ const ConnectWalletChainNamespaceSelect = props => {
|
|
|
41
41
|
extension: wallet.imgExtension
|
|
42
42
|
})
|
|
43
43
|
}), /*#__PURE__*/jsx("p", {
|
|
44
|
-
className: "w3a--my-6 w3a--text-center w3a--text-sm w3a--text-app-gray-500",
|
|
44
|
+
className: "w3a--my-6 w3a--text-center w3a--text-sm w3a--text-app-gray-500 dark:w3a--text-app-gray-400",
|
|
45
45
|
children: t("modal.external.select-chain-description", {
|
|
46
46
|
wallet: wallet.displayName
|
|
47
47
|
})
|
|
@@ -70,7 +70,7 @@ const ConnectWalletChainNamespaceSelect = props => {
|
|
|
70
70
|
isButton: true,
|
|
71
71
|
extension: "svg"
|
|
72
72
|
}), /*#__PURE__*/jsx("p", {
|
|
73
|
-
className: "w3a--ml-2 w3a--text-left w3a--text-sm first-letter:w3a--capitalize",
|
|
73
|
+
className: "w3a--ml-2 w3a--text-left w3a--text-sm w3a--text-app-gray-900 first-letter:w3a--capitalize dark:w3a--text-app-gray-200",
|
|
74
74
|
children: displayName
|
|
75
75
|
})]
|
|
76
76
|
}), /*#__PURE__*/jsx("img", {
|