@getpara/react-sdk 1.12.0 → 2.0.0-alpha.10
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/cli/cli.mjs +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/modal/ParaModal.js +211 -313
- package/dist/modal/components/Account/Account.js +73 -16
- package/dist/modal/components/AddFunds/AddFunds.js +5 -6
- package/dist/modal/components/AddFunds/AddFundsAsset.js +15 -13
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +16 -10
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +2 -2
- package/dist/modal/components/AddFunds/AddFundsContext.js +20 -14
- package/dist/modal/components/AddFunds/AddFundsDone.js +10 -4
- package/dist/modal/components/AddFunds/AddFundsProvider.js +11 -7
- package/dist/modal/components/AddFunds/AddFundsReceive.js +17 -13
- package/dist/modal/components/AddFunds/AddFundsSettings.js +10 -6
- package/dist/modal/components/AddFunds/common.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
- package/dist/modal/components/AuthInput/AuthInput.js +70 -91
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +4 -4
- package/dist/modal/components/AuthMainStep/AuthMainStep.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +20 -7
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.d.ts +4 -3
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +54 -10
- package/dist/modal/components/AuthOptions/AuthOptions.d.ts +4 -3
- package/dist/modal/components/AuthOptions/AuthOptions.js +35 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.d.ts +5 -1
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +9 -4
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -3
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +25 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +34 -72
- package/dist/modal/components/Body/Body.d.ts +4 -3
- package/dist/modal/components/Body/Body.js +27 -10
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +5 -4
- package/dist/modal/components/Controls/Controls.js +5 -2
- package/dist/modal/components/Controls/Selects.d.ts +1 -1
- package/dist/modal/components/Controls/Selects.js +30 -25
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +10 -6
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +7 -69
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +7 -6
- package/dist/modal/components/Footer/Footer.d.ts +1 -1
- package/dist/modal/components/Footer/Footer.js +6 -4
- package/dist/modal/components/Header/hooks/useStepTitle.js +7 -3
- package/dist/modal/components/Hero/Hero.js +5 -5
- package/dist/modal/components/IFrameStep/IFrameStep.js +8 -4
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +7 -4
- package/dist/modal/components/ModalContent/ModalContent.js +14 -243
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -57
- package/dist/modal/components/OAuth/OAuth.d.ts +2 -2
- package/dist/modal/components/OAuth/OAuth.js +11 -85
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +11 -60
- package/dist/modal/components/OnRampComponents/AddingFunds.js +1 -1
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +10 -4
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +23 -32
- package/dist/modal/components/StripeComponents/StripeComponents.js +1 -1
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +5 -2
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +44 -60
- package/dist/modal/components/WalletCard/WalletCard.d.ts +5 -5
- package/dist/modal/components/WalletCard/WalletCard.js +8 -7
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +33 -12
- package/dist/modal/components/common.d.ts +5 -5
- package/dist/modal/components/common.js +10 -4
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/oAuthLogos.d.ts +3 -3
- package/dist/modal/hooks/useGoBack.js +6 -5
- package/dist/modal/index.d.ts +0 -3
- package/dist/modal/index.js +1 -5
- package/dist/modal/stores/index.d.ts +0 -2
- package/dist/modal/stores/index.js +0 -2
- package/dist/modal/stores/modal/actions.js +69 -16
- package/dist/modal/stores/modal/useModalStore.d.ts +26 -22
- package/dist/modal/stores/modal/useModalStore.js +9 -13
- package/dist/modal/types/commonTypes.d.ts +0 -52
- package/dist/modal/types/modalProps.d.ts +8 -32
- package/dist/modal/utils/authInputHelpers.d.ts +7 -0
- package/dist/modal/utils/authInputHelpers.js +38 -0
- package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
- package/dist/modal/{components/AuthInput → utils}/countryCodes.js +6 -3
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
- package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
- package/dist/modal/utils/isPasskeySupported.js +15 -0
- package/dist/modal/utils/openPopup.d.ts +2 -2
- package/dist/modal/utils/openPopup.js +2 -2
- package/dist/modal/utils/steps.d.ts +6 -0
- package/dist/modal/utils/steps.js +15 -0
- package/dist/provider/ParaProvider.d.ts +3 -1
- package/dist/provider/ParaProvider.js +69 -8
- package/dist/provider/actions/getAccount.d.ts +26 -8
- package/dist/provider/actions/getAccount.js +42 -14
- package/dist/provider/actions/getWallet.d.ts +3 -3
- package/dist/provider/actions/index.d.ts +27 -0
- package/dist/provider/actions/index.js +59 -0
- package/dist/provider/actions/utils.d.ts +3 -0
- package/dist/provider/actions/utils.js +15 -0
- package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
- package/dist/provider/components/CosmosWalletWrapper.js +34 -0
- package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
- package/dist/provider/components/EvmWalletWrapper.js +34 -0
- package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
- package/dist/provider/components/ExternalWalletWrapper.js +139 -0
- package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
- package/dist/provider/components/SolanaWalletWrapper.js +36 -0
- package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
- package/dist/provider/external/getParaCosmosConnector.js +22 -0
- package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
- package/dist/provider/external/getParaEvmConnector.js +22 -0
- package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
- package/dist/provider/external/getParaSolanaConnector.js +22 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +18 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +21 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +14 -0
- package/dist/provider/hooks/mutations/index.d.ts +27 -11
- package/dist/provider/hooks/mutations/index.js +54 -17
- package/dist/provider/hooks/mutations/utils.d.ts +5 -0
- package/dist/provider/hooks/mutations/utils.js +59 -0
- package/dist/provider/hooks/queries/useAccount.d.ts +1 -7
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +1 -2
- package/dist/provider/hooks/queries/useWalletBalance.js +40 -11
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +5 -5
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/hooks/utils/useEventListeners.js +100 -56
- package/dist/provider/hooks/utils/useWalletState.d.ts +5 -4
- package/dist/provider/hooks/utils/useWalletState.js +24 -9
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.js +1 -0
- package/dist/provider/providers/AuthProvider.d.ts +35 -0
- package/dist/provider/providers/AuthProvider.js +498 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.js +66 -0
- package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/EvmExternalWalletProvider.js +74 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +76 -0
- package/dist/{modal/providers/ExternalWalletContext.js → provider/providers/ExternalWalletProvider.js} +146 -112
- package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.js +66 -0
- package/dist/provider/stores/getters.d.ts +3 -3
- package/dist/provider/stores/setters.d.ts +1 -0
- package/dist/provider/stores/setters.js +7 -0
- package/dist/provider/stores/slices/config.d.ts +3 -0
- package/dist/provider/stores/slices/config.js +9 -0
- package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
- package/dist/provider/stores/slices/externalWallets.js +40 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/slices/index.js +1 -0
- package/dist/provider/stores/slices/modal.js +11 -4
- package/dist/provider/stores/types.d.ts +50 -4
- package/dist/provider/stores/useStore.js +4 -3
- package/dist/provider/types/externalWalletProviders.d.ts +12 -0
- package/dist/provider/types/externalWalletProviders.js +1 -0
- package/dist/provider/types/provider.d.ts +126 -17
- package/dist/provider/types/utils.d.ts +20 -0
- package/dist/provider/utils/constants.js +3 -4
- package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
- package/dist/provider/utils/paraConfigTypeGuards.js +13 -0
- package/dist/provider/utils/renameMutations.d.ts +3 -0
- package/dist/provider/utils/renameMutations.js +5 -3
- package/package.json +20 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
- package/dist/modal/hooks/useActiveWallet.d.ts +0 -1
- package/dist/modal/hooks/useActiveWallet.js +0 -15
- package/dist/modal/hooks/useCreateAccount.d.ts +0 -6
- package/dist/modal/hooks/useCreateAccount.js +0 -77
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
- package/dist/modal/hooks/useSetLoginURLs.d.ts +0 -8
- package/dist/modal/hooks/useSetLoginURLs.js +0 -49
- package/dist/modal/hooks/useWalletBalance.d.ts +0 -4
- package/dist/modal/hooks/useWalletBalance.js +0 -49
- package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +0 -42
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -38
- package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +0 -46
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -55
- package/dist/modal/providers/ExternalWalletContext.d.ts +0 -92
- package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +0 -32
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -32
- package/dist/modal/stores/externalWalletProvider/actions.d.ts +0 -3
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +0 -22
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -21
- package/dist/modal/stores/theme/actions.d.ts +0 -3
- package/dist/modal/stores/theme/actions.js +0 -28
- package/dist/modal/stores/theme/useThemeStore.d.ts +0 -20
- package/dist/modal/stores/theme/useThemeStore.js +0 -21
- package/dist/modal/stores/userInfo/actions.d.ts +0 -3
- package/dist/modal/stores/userInfo/actions.js +0 -30
- package/dist/modal/stores/userInfo/useUserInfoStore.d.ts +0 -19
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
- package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createGuestWallets.d.ts +0 -2
- package/dist/provider/actions/createGuestWallets.js +0 -13
- package/dist/provider/actions/createUser.d.ts +0 -12
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getWalletBalance.d.ts +0 -2
- package/dist/provider/actions/getWalletBalance.js +0 -14
- package/dist/provider/actions/initiateLogin.d.ts +0 -4
- package/dist/provider/actions/initiateLogin.js +0 -20
- package/dist/provider/actions/keepSessionAlive.d.ts +0 -2
- package/dist/provider/actions/keepSessionAlive.js +0 -20
- package/dist/provider/actions/logout.d.ts +0 -2
- package/dist/provider/actions/logout.js +0 -17
- package/dist/provider/actions/signMessage.d.ts +0 -8
- package/dist/provider/actions/signMessage.js +0 -20
- package/dist/provider/actions/signTransaction.d.ts +0 -8
- package/dist/provider/actions/signTransaction.js +0 -20
- package/dist/provider/actions/waitForAccountCreation.d.ts +0 -2
- package/dist/provider/actions/waitForAccountCreation.js +0 -21
- package/dist/provider/actions/waitForLoginAndSetup.d.ts +0 -6
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +0 -2
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
- package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +0 -15
- package/dist/provider/hooks/mutations/useCreateGuestWallets.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
- package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +0 -14
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +0 -12
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
- package/dist/provider/hooks/mutations/useLogout.d.ts +0 -12
- package/dist/provider/hooks/mutations/useLogout.js +0 -30
- package/dist/provider/hooks/mutations/useSignMessage.d.ts +0 -15
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -39
- package/dist/provider/hooks/mutations/useSignTransaction.d.ts +0 -14
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -39
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +0 -12
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +0 -14
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +0 -13
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- /package/dist/modal/{components/AuthInput → utils}/countryCodes.d.ts +0 -0
|
@@ -2,5 +2,5 @@ interface AuthInputProps {
|
|
|
2
2
|
disableEmailLogin?: boolean;
|
|
3
3
|
disablePhoneLogin?: boolean;
|
|
4
4
|
}
|
|
5
|
-
export declare const AuthInput: ({ disableEmailLogin, disablePhoneLogin }: AuthInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const AuthInput: ({ disableEmailLogin, disablePhoneLogin }: AuthInputProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
6
|
export {};
|
|
@@ -12,44 +12,46 @@ import {
|
|
|
12
12
|
CpslSpinner,
|
|
13
13
|
CpslText
|
|
14
14
|
} from "@getpara/react-components";
|
|
15
|
-
import { useRef, useState } from "react";
|
|
15
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
16
16
|
import styled from "styled-components";
|
|
17
|
-
import countryCodes from "
|
|
18
|
-
import {
|
|
19
|
-
import { EMAIL_REGEX, MOBILE_SIZE } from "../../constants/constants.js";
|
|
17
|
+
import countryCodes from "../../utils/countryCodes.js";
|
|
18
|
+
import { MOBILE_SIZE } from "../../constants/constants.js";
|
|
20
19
|
import { useDropdownPosition } from "./hooks/useDropdownPosition.js";
|
|
21
|
-
import { ModalStep } from "../../utils/steps.js";
|
|
22
20
|
import { defaultPhoneMask, phoneMasks } from "./phoneMasks.js";
|
|
23
|
-
import { AuthMethod } from "@getpara/web-sdk";
|
|
24
21
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
25
|
-
import
|
|
22
|
+
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
23
|
+
import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
|
|
24
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
25
|
+
import { isCcMatch, validateAuth } from "../../utils/authInputHelpers.js";
|
|
26
26
|
const DEFAULT_COUNTRY = { label: "United States", value: "+1", selectedLabel: "US", icon: "US" };
|
|
27
|
-
function isCcMatch(countryCode, option) {
|
|
28
|
-
return countryCode === "+1" ? option.selectedLabel === "US" : option.value === countryCode;
|
|
29
|
-
}
|
|
30
27
|
const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
31
|
-
var _a, _b;
|
|
28
|
+
var _a, _b, _c;
|
|
32
29
|
const inputRef = useRef(null);
|
|
33
30
|
const { dropdownMaxHeight, dropdownWidth } = useDropdownPosition(inputRef);
|
|
31
|
+
const defaultAuthIdentifier = useStore((state) => {
|
|
32
|
+
var _a2;
|
|
33
|
+
return (_a2 = state.modalConfig) == null ? void 0 : _a2.defaultAuthIdentifier;
|
|
34
|
+
});
|
|
34
35
|
const para = useInternalClient();
|
|
35
|
-
const
|
|
36
|
-
const authInfo =
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
36
|
+
const { signUpOrLogIn, isSignUpOrLogInPending } = useAuthActions();
|
|
37
|
+
const authInfo = para.authInfo;
|
|
38
|
+
const [storedNationalNumber, storedCountryCode] = useMemo(() => {
|
|
39
|
+
if ((authInfo == null ? void 0 : authInfo.authType) !== "phone") {
|
|
40
|
+
return [void 0, void 0];
|
|
41
|
+
}
|
|
42
|
+
const parsed = parsePhoneNumberFromString(authInfo.identifier);
|
|
43
|
+
return [parsed == null ? void 0 : parsed.nationalNumber, parsed == null ? void 0 : parsed.countryCallingCode];
|
|
44
|
+
}, [authInfo == null ? void 0 : authInfo.authType, authInfo == null ? void 0 : authInfo.identifier]);
|
|
45
|
+
const [countryCode, setCountryCode] = useState(storedCountryCode != null ? storedCountryCode : "+1");
|
|
44
46
|
const [identifier, setIdentifier] = useState(
|
|
45
47
|
(() => {
|
|
46
|
-
if (!authInfo || ["telegram", "farcaster"].includes(authInfo.authType)) {
|
|
48
|
+
if (!(authInfo == null ? void 0 : authInfo.authType) || ["telegram", "farcaster", "externalWallet"].includes(authInfo == null ? void 0 : authInfo.authType)) {
|
|
47
49
|
return "";
|
|
48
50
|
}
|
|
49
51
|
if (authInfo.authType !== "phone") {
|
|
50
52
|
return authInfo.identifier;
|
|
51
53
|
}
|
|
52
|
-
return
|
|
54
|
+
return storedNationalNumber != null ? storedNationalNumber : "";
|
|
53
55
|
})()
|
|
54
56
|
);
|
|
55
57
|
const [identifierType, setIdentifierType] = useState(
|
|
@@ -58,9 +60,28 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
58
60
|
const [matchedCountryCode, setMatchedCountryCode] = useState(
|
|
59
61
|
(_a = countryCodes.find((option) => isCcMatch(countryCode, option))) != null ? _a : DEFAULT_COUNTRY
|
|
60
62
|
);
|
|
61
|
-
const [isLoggingIn, setIsLoggingIn] = useState(false);
|
|
62
63
|
const [error, setError] = useState("");
|
|
64
|
+
const [isPending, setIsPending] = useState(isSignUpOrLogInPending);
|
|
63
65
|
const [search, setSearch] = useState("");
|
|
66
|
+
const setCountryCodes = (countyCodeInput) => {
|
|
67
|
+
setCountryCode(countyCodeInput.value);
|
|
68
|
+
setMatchedCountryCode(countyCodeInput);
|
|
69
|
+
};
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (defaultAuthIdentifier && !authInfo) {
|
|
72
|
+
const number = parsePhoneNumberFromString(defaultAuthIdentifier);
|
|
73
|
+
if (number) {
|
|
74
|
+
const countryCode2 = `+${number.countryCallingCode}`;
|
|
75
|
+
const countryCodeInputMatch = countryCodes.find((option) => isCcMatch(countryCode2, option));
|
|
76
|
+
if (countryCodeInputMatch) {
|
|
77
|
+
setCountryCodes(countryCodeInputMatch);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
handleIdentifierInput({
|
|
81
|
+
detail: { value: number ? number.nationalNumber : defaultAuthIdentifier }
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}, [authInfo]);
|
|
64
85
|
const isEmail = identifierType === "email";
|
|
65
86
|
const isPhone = identifierType === "phone";
|
|
66
87
|
const isUnknown = !identifierType;
|
|
@@ -71,13 +92,13 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
71
92
|
setSearch(ev.detail);
|
|
72
93
|
};
|
|
73
94
|
const handleIdentifierInput = (ev) => {
|
|
74
|
-
|
|
95
|
+
var _a2;
|
|
96
|
+
const newIdentifier = (_a2 = ev.detail.value) != null ? _a2 : "";
|
|
75
97
|
let isNewPhone = false, isNewEmail = false;
|
|
76
98
|
if (!disablePhoneLogin) {
|
|
77
99
|
const countryCodeInputMatch = countryCodes.find((option) => isCcMatch(newIdentifier, option));
|
|
78
100
|
if (countryCodeInputMatch) {
|
|
79
|
-
|
|
80
|
-
setMatchedCountryCode(countryCodeInputMatch);
|
|
101
|
+
setCountryCodes(countryCodeInputMatch);
|
|
81
102
|
setIdentifierType("phone");
|
|
82
103
|
setIdentifier("");
|
|
83
104
|
return;
|
|
@@ -92,70 +113,28 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
92
113
|
};
|
|
93
114
|
const handleCountryCodeInput = (ev) => {
|
|
94
115
|
const matchedCountryCode2 = countryCodes.find((code) => code.selectedLabel === ev.detail);
|
|
95
|
-
|
|
96
|
-
|
|
116
|
+
if (matchedCountryCode2) {
|
|
117
|
+
setCountryCodes(matchedCountryCode2);
|
|
118
|
+
}
|
|
97
119
|
};
|
|
98
|
-
const
|
|
120
|
+
const onSubmit = () => __async(void 0, null, function* () {
|
|
99
121
|
setError("");
|
|
100
|
-
if (isUnknown) {
|
|
101
|
-
setError("Please enter a valid email or phone number!");
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
122
|
let auth;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
yield para.logout();
|
|
111
|
-
auth = { email: identifier };
|
|
112
|
-
setAuthInfo(auth);
|
|
113
|
-
const userExists = yield para.checkIfUserExists({ email: identifier });
|
|
114
|
-
if (userExists) {
|
|
115
|
-
const supportedAuthMethods = yield para.initiateUserLoginV2(auth);
|
|
116
|
-
const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY) ? yield para.getUserBiometricLocationHints() : [];
|
|
117
|
-
yield setLoginURLs({ supportedAuthMethods, authType: "email" });
|
|
118
|
-
setFlow("login");
|
|
119
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
120
|
-
setBiometricLocationHints(biometricLocationHints);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
yield para.createUser(auth);
|
|
124
|
-
setFlow("signUp");
|
|
125
|
-
setStep(ModalStep.VERIFICATIONS);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (isPhone) {
|
|
129
|
-
yield para.logout();
|
|
130
|
-
let userExists = false;
|
|
131
|
-
try {
|
|
132
|
-
userExists = yield para.checkIfUserExistsByPhone({ phone: identifier, countryCode });
|
|
133
|
-
} catch (error2) {
|
|
134
|
-
setError("Please enter a valid phone number!");
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
auth = { phone: identifier, countryCode };
|
|
138
|
-
setAuthInfo(auth);
|
|
139
|
-
if (userExists) {
|
|
140
|
-
const supportedAuthMethods = yield para.initiateUserLoginV2(auth);
|
|
141
|
-
const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY) ? yield para.getUserBiometricLocationHints() : [];
|
|
142
|
-
yield setLoginURLs({ supportedAuthMethods, authType: "phone" });
|
|
143
|
-
setFlow("login");
|
|
144
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
145
|
-
setBiometricLocationHints(biometricLocationHints);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
yield para.createUserByPhone(auth);
|
|
149
|
-
setFlow("signUp");
|
|
150
|
-
setStep(ModalStep.VERIFICATIONS);
|
|
151
|
-
return;
|
|
123
|
+
try {
|
|
124
|
+
auth = validateAuth(identifier, countryCode, identifierType);
|
|
125
|
+
signUpOrLogIn(auth);
|
|
126
|
+
} catch (err) {
|
|
127
|
+
setError(err.message);
|
|
152
128
|
}
|
|
153
129
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (isSignUpOrLogInPending) {
|
|
132
|
+
setIsPending(true);
|
|
133
|
+
}
|
|
134
|
+
}, [isSignUpOrLogInPending]);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
setIsPending(false);
|
|
137
|
+
}, [error]);
|
|
159
138
|
if (disableEmailLogin && disablePhoneLogin) {
|
|
160
139
|
return null;
|
|
161
140
|
}
|
|
@@ -164,7 +143,7 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
164
143
|
{
|
|
165
144
|
onSubmit: (e) => __async(void 0, null, function* () {
|
|
166
145
|
e.preventDefault();
|
|
167
|
-
|
|
146
|
+
onSubmit();
|
|
168
147
|
}),
|
|
169
148
|
children: /* @__PURE__ */ jsxs(
|
|
170
149
|
StyledInput,
|
|
@@ -178,14 +157,14 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
178
157
|
autofocus: true,
|
|
179
158
|
inputMode: "email",
|
|
180
159
|
onKeyDown: (e) => __async(void 0, null, function* () {
|
|
181
|
-
return e.key === "Enter" &&
|
|
160
|
+
return e.key === "Enter" && onSubmit();
|
|
182
161
|
}),
|
|
183
162
|
contrastText: true,
|
|
184
163
|
isPhone,
|
|
185
|
-
mask: identifierType === "phone" ? (
|
|
164
|
+
mask: identifierType === "phone" ? (_c = phoneMasks[(_b = matchedCountryCode.selectedLabel) != null ? _b : ""]) != null ? _c : defaultPhoneMask : void 0,
|
|
186
165
|
enterkeyhint: "go",
|
|
187
166
|
noAutoDisable: true,
|
|
188
|
-
disabled:
|
|
167
|
+
disabled: isPending,
|
|
189
168
|
"data-testid": "auth-input",
|
|
190
169
|
children: [
|
|
191
170
|
/* @__PURE__ */ jsxs(IconContainer, { slot: "start", children: [
|
|
@@ -200,7 +179,7 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
200
179
|
autoWidth: true,
|
|
201
180
|
dropdownMaxHeight,
|
|
202
181
|
anchorElId: "authInput",
|
|
203
|
-
$width: dropdownWidth,
|
|
182
|
+
$width: dropdownWidth != null ? dropdownWidth : 0,
|
|
204
183
|
showSearch: true,
|
|
205
184
|
searchPlaceholder: "Search Countries",
|
|
206
185
|
onCpslSearchChange: handleSearchInput,
|
|
@@ -218,7 +197,7 @@ const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
|
218
197
|
}
|
|
219
198
|
)
|
|
220
199
|
] }),
|
|
221
|
-
identifier && /* @__PURE__ */ jsx(CpslButton, { slot: "end", size: "small", fullWidth: true, disabled:
|
|
200
|
+
identifier && /* @__PURE__ */ jsx(CpslButton, { slot: "end", size: "small", fullWidth: true, disabled: isPending, onClick: onSubmit, children: isPending ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsx(CpslIcon, { icon: "arrowNarrow" }) })
|
|
222
201
|
]
|
|
223
202
|
},
|
|
224
203
|
"email"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MutableRefObject } from 'react';
|
|
2
|
-
export declare const useDropdownPosition: (inputRef: MutableRefObject<HTMLCpslInputElement | HTMLDivElement>) => {
|
|
3
|
-
dropdownMaxHeight: number;
|
|
4
|
-
dropdownWidth: number;
|
|
5
|
-
mobileAnchor: number;
|
|
2
|
+
export declare const useDropdownPosition: (inputRef: MutableRefObject<HTMLCpslInputElement | HTMLDivElement | null>) => {
|
|
3
|
+
dropdownMaxHeight: number | undefined;
|
|
4
|
+
dropdownWidth: number | undefined;
|
|
5
|
+
mobileAnchor: number | undefined;
|
|
6
6
|
resize: () => void;
|
|
7
7
|
};
|
|
@@ -6,15 +6,15 @@ const useDropdownPosition = (inputRef) => {
|
|
|
6
6
|
const [dropdownWidth, setDropdownWidth] = useState();
|
|
7
7
|
const [mobileAnchor, setMobileAnchor] = useState();
|
|
8
8
|
const resize = () => {
|
|
9
|
-
var _a, _b, _c;
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
10
|
if (typeof window !== "undefined") {
|
|
11
11
|
const newMaxHeight = Math.max(
|
|
12
|
-
window.innerHeight - ((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.getBoundingClientRect().bottom) - 20,
|
|
12
|
+
window.innerHeight - ((_b = (_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.getBoundingClientRect().bottom) != null ? _b : 0) - 20,
|
|
13
13
|
window.innerHeight * 0.25
|
|
14
14
|
);
|
|
15
15
|
setDropdownMaxHeight(newMaxHeight);
|
|
16
|
-
setDropdownWidth((
|
|
17
|
-
setMobileAnchor((
|
|
16
|
+
setDropdownWidth((_c = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _c.getBoundingClientRect().width);
|
|
17
|
+
setMobileAnchor((_d = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _d.getBoundingClientRect().height);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
if (inputRef.current && !dropdownMaxHeight) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TOAuthMethod } from '@getpara/web-sdk';
|
|
2
2
|
interface AuthMainStepProps {
|
|
3
|
-
oAuthMethods?:
|
|
3
|
+
oAuthMethods?: TOAuthMethod[];
|
|
4
4
|
disableEmailLogin: boolean;
|
|
5
5
|
disablePhoneLogin: boolean;
|
|
6
|
+
isGuestModeEnabled?: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare const AuthMainStep: ({ oAuthMethods, disableEmailLogin, disablePhoneLogin }: AuthMainStepProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const AuthMainStep: ({ oAuthMethods, disableEmailLogin, disablePhoneLogin, isGuestModeEnabled, }: AuthMainStepProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -2,15 +2,27 @@
|
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import styled from "styled-components";
|
|
5
|
-
import { useThemeStore } from "../../stores/theme/useThemeStore.js";
|
|
6
5
|
import { AuthMainStepContent } from "./AuthMainStepContent.js";
|
|
7
6
|
import { CenteredText } from "../common.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
8
|
+
import { useModalStore } from "../../stores/index.js";
|
|
9
|
+
const AuthMainStep = ({
|
|
10
|
+
oAuthMethods,
|
|
11
|
+
disableEmailLogin,
|
|
12
|
+
disablePhoneLogin,
|
|
13
|
+
isGuestModeEnabled = false
|
|
14
|
+
}) => {
|
|
15
|
+
const authLayout = useModalStore((state) => state.authLayout);
|
|
16
|
+
const embeddedModal = useStore((state) => {
|
|
17
|
+
var _a;
|
|
18
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.embeddedModal;
|
|
19
|
+
});
|
|
20
|
+
const logo = useStore((state) => {
|
|
21
|
+
var _a;
|
|
22
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.logo;
|
|
23
|
+
});
|
|
24
|
+
const appName = useStore((state) => state.appName);
|
|
25
|
+
const firstLayoutType = authLayout == null ? void 0 : authLayout[0].split(":")[0];
|
|
14
26
|
const heading = firstLayoutType === "AUTH" ? "Sign Up or Login" : "Connect Wallet";
|
|
15
27
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
16
28
|
logo && /* @__PURE__ */ jsx(Logo, { src: logo, alt: `${appName ? `${appName} -` : ""}logo` }),
|
|
@@ -20,6 +32,7 @@ const AuthMainStep = ({ oAuthMethods, disableEmailLogin, disablePhoneLogin }) =>
|
|
|
20
32
|
{
|
|
21
33
|
disableEmailLogin,
|
|
22
34
|
disablePhoneLogin,
|
|
35
|
+
isGuestModeEnabled,
|
|
23
36
|
oAuthMethods
|
|
24
37
|
}
|
|
25
38
|
)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TOAuthMethod } from '@getpara/web-sdk';
|
|
2
2
|
interface AuthMainStepContentProps {
|
|
3
|
-
oAuthMethods?:
|
|
3
|
+
oAuthMethods?: TOAuthMethod[];
|
|
4
4
|
disableEmailLogin: boolean;
|
|
5
5
|
disablePhoneLogin: boolean;
|
|
6
|
+
isGuestModeEnabled?: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare const AuthMainStepContent: ({ oAuthMethods, disableEmailLogin, disablePhoneLogin }: AuthMainStepContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const AuthMainStepContent: ({ oAuthMethods, disableEmailLogin, disablePhoneLogin, isGuestModeEnabled, }: AuthMainStepContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -4,19 +4,33 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
import { Fragment as Fragment2, useMemo } from "react";
|
|
5
5
|
import { CpslButton, CpslDivider, CpslIconGroup } from "@getpara/react-components";
|
|
6
6
|
import styled from "styled-components";
|
|
7
|
-
import { useExternalWallets } from "../../providers/ExternalWalletContext.js";
|
|
8
7
|
import { ExternalWallets } from "../ExternalWallets/ExternalWallets.js";
|
|
9
|
-
import { useModalStore
|
|
8
|
+
import { useModalStore } from "../../stores/index.js";
|
|
10
9
|
import { ModalStep } from "../../utils/steps.js";
|
|
11
10
|
import { AuthLayout } from "../../types/modalProps.js";
|
|
12
11
|
import { brandedOAuthLogos, oAuthLogos } from "../../constants/oAuthLogos.js";
|
|
13
12
|
import { AuthOptions } from "../AuthOptions/AuthOptions.js";
|
|
14
|
-
|
|
13
|
+
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
14
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
15
|
+
import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
|
|
16
|
+
import { useAccount } from "../../../provider/index.js";
|
|
17
|
+
const AuthMainStepContent = ({
|
|
18
|
+
oAuthMethods,
|
|
19
|
+
disableEmailLogin,
|
|
20
|
+
disablePhoneLogin,
|
|
21
|
+
isGuestModeEnabled = false
|
|
22
|
+
}) => {
|
|
15
23
|
const { wallets } = useExternalWallets();
|
|
16
|
-
const
|
|
24
|
+
const { createGuestWallets } = useAuthActions();
|
|
25
|
+
const { data: account } = useAccount();
|
|
26
|
+
const authLayout = useModalStore((state) => state.authLayout);
|
|
17
27
|
const setStep = useModalStore((state) => state.setStep);
|
|
18
|
-
const oAuthLogoVariant =
|
|
19
|
-
const isDark =
|
|
28
|
+
const oAuthLogoVariant = useStore((state) => state.oAuthLogoVariant);
|
|
29
|
+
const isDark = useStore((state) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
return ((_b = (_a = state.modalConfig) == null ? void 0 : _a.theme) == null ? void 0 : _b.mode) === "dark";
|
|
32
|
+
});
|
|
33
|
+
const isGuestMode = (account == null ? void 0 : account.isConnected) && account.isGuestMode;
|
|
20
34
|
const useBrandedLogos = oAuthLogoVariant === "default";
|
|
21
35
|
const useDarkLogos = useBrandedLogos ? isDark : oAuthLogoVariant !== "dark";
|
|
22
36
|
const handleCondensedAuthClick = () => {
|
|
@@ -27,7 +41,7 @@ const AuthMainStepContent = ({ oAuthMethods, disableEmailLogin, disablePhoneLogi
|
|
|
27
41
|
};
|
|
28
42
|
const Content = useMemo(() => {
|
|
29
43
|
const methods = [];
|
|
30
|
-
authLayout.forEach((layout) => {
|
|
44
|
+
authLayout == null ? void 0 : authLayout.forEach((layout) => {
|
|
31
45
|
switch (layout) {
|
|
32
46
|
case AuthLayout.AUTH_FULL: {
|
|
33
47
|
methods.push([
|
|
@@ -36,7 +50,8 @@ const AuthMainStepContent = ({ oAuthMethods, disableEmailLogin, disablePhoneLogi
|
|
|
36
50
|
{
|
|
37
51
|
oAuthMethods,
|
|
38
52
|
disableEmailLogin,
|
|
39
|
-
disablePhoneLogin
|
|
53
|
+
disablePhoneLogin,
|
|
54
|
+
isGuestModeEnabled
|
|
40
55
|
},
|
|
41
56
|
"authFull"
|
|
42
57
|
),
|
|
@@ -85,8 +100,22 @@ const AuthMainStepContent = ({ oAuthMethods, disableEmailLogin, disablePhoneLogi
|
|
|
85
100
|
reactNode,
|
|
86
101
|
methods.length > 1 && index < methods.length - 1 && /* @__PURE__ */ jsx(CpslDivider, { children: "or" }, "or")
|
|
87
102
|
] }, key)) });
|
|
88
|
-
}, [oAuthMethods, disableEmailLogin, disablePhoneLogin, wallets, authLayout]);
|
|
89
|
-
return /* @__PURE__ */
|
|
103
|
+
}, [oAuthMethods, disableEmailLogin, disablePhoneLogin, isGuestModeEnabled, wallets, authLayout]);
|
|
104
|
+
return /* @__PURE__ */ jsxs(Container, { "data-testid": "main-auth-step-content", children: [
|
|
105
|
+
Content,
|
|
106
|
+
isGuestModeEnabled && !isGuestMode && /* @__PURE__ */ jsx(
|
|
107
|
+
GuestMode,
|
|
108
|
+
{
|
|
109
|
+
href: "#",
|
|
110
|
+
isDark,
|
|
111
|
+
onClick: (e) => {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
createGuestWallets();
|
|
114
|
+
},
|
|
115
|
+
children: "Continue as Guest"
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
] });
|
|
90
119
|
};
|
|
91
120
|
const Container = styled.div`
|
|
92
121
|
display: flex;
|
|
@@ -108,6 +137,21 @@ const CondensedButton = styled(CpslButton)`
|
|
|
108
137
|
max-height: 50px;
|
|
109
138
|
}
|
|
110
139
|
`;
|
|
140
|
+
const GuestMode = styled.a`
|
|
141
|
+
display: flex;
|
|
142
|
+
justify-content: center;
|
|
143
|
+
align-items: center;
|
|
144
|
+
width: 100%;
|
|
145
|
+
height: 50px;
|
|
146
|
+
color: ${({ isDark }) => isDark ? "white" : "black"};
|
|
147
|
+
text-decoration: underline;
|
|
148
|
+
font-size: 16px;
|
|
149
|
+
font-weight: 500;
|
|
150
|
+
|
|
151
|
+
&:hover {
|
|
152
|
+
text-decoration: underline;
|
|
153
|
+
}
|
|
154
|
+
`;
|
|
111
155
|
export {
|
|
112
156
|
AuthMainStepContent
|
|
113
157
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TOAuthMethod } from '@getpara/web-sdk';
|
|
2
2
|
interface AuthOptionsProps {
|
|
3
|
-
oAuthMethods?:
|
|
3
|
+
oAuthMethods?: TOAuthMethod[];
|
|
4
4
|
disableEmailLogin: boolean;
|
|
5
5
|
disablePhoneLogin: boolean;
|
|
6
|
+
isGuestModeEnabled: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare const AuthOptions: ({ oAuthMethods, disableEmailLogin, disablePhoneLogin }: AuthOptionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const AuthOptions: ({ oAuthMethods, disableEmailLogin, disablePhoneLogin, isGuestModeEnabled, }: AuthOptionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import styled from "styled-components";
|
|
6
6
|
import { OAuth } from "../OAuth/OAuth.js";
|
|
7
7
|
import { AuthInput } from "../AuthInput/AuthInput.js";
|
|
8
|
-
import { useExternalWallets } from "
|
|
8
|
+
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
9
9
|
import { useModalStore } from "../../stores/index.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import { CpslIcon } from "@getpara/react-components";
|
|
11
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
12
|
+
const AuthOptions = ({
|
|
13
|
+
oAuthMethods,
|
|
14
|
+
disableEmailLogin,
|
|
15
|
+
disablePhoneLogin,
|
|
16
|
+
isGuestModeEnabled = false
|
|
17
|
+
}) => {
|
|
12
18
|
const { wallets } = useExternalWallets();
|
|
13
|
-
const
|
|
19
|
+
const isDark = useStore((state) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return ((_b = (_a = state.modalConfig) == null ? void 0 : _a.theme) == null ? void 0 : _b.mode) === "dark";
|
|
22
|
+
});
|
|
23
|
+
const guestAddFundsTab = useModalStore((state) => state.guestAddFundsTab);
|
|
14
24
|
const Content = useMemo(() => {
|
|
15
25
|
const Methods = [];
|
|
16
26
|
if (!!(oAuthMethods == null ? void 0 : oAuthMethods.length)) {
|
|
@@ -20,14 +30,32 @@ const AuthOptions = ({ oAuthMethods, disableEmailLogin, disablePhoneLogin }) =>
|
|
|
20
30
|
Methods.push(/* @__PURE__ */ jsx(AuthInput, { disableEmailLogin, disablePhoneLogin }, "input"));
|
|
21
31
|
}
|
|
22
32
|
return /* @__PURE__ */ jsx(Fragment, { children: Methods });
|
|
23
|
-
}, [
|
|
24
|
-
return /* @__PURE__ */
|
|
33
|
+
}, [oAuthMethods, disableEmailLogin, disablePhoneLogin, isGuestModeEnabled, wallets]);
|
|
34
|
+
return /* @__PURE__ */ jsxs(Container, { children: [
|
|
35
|
+
guestAddFundsTab && /* @__PURE__ */ jsxs(CompleteAccountSetup, { isDark, children: [
|
|
36
|
+
/* @__PURE__ */ jsx(CpslIcon, { icon: "stars02", size: "16px" }),
|
|
37
|
+
"Complete account setup to",
|
|
38
|
+
" ",
|
|
39
|
+
guestAddFundsTab === "BUY" ? "buy assets" : guestAddFundsTab === "WITHDRAW" ? "sell assets" : "continue",
|
|
40
|
+
"."
|
|
41
|
+
] }),
|
|
42
|
+
Content
|
|
43
|
+
] });
|
|
25
44
|
};
|
|
26
45
|
const Container = styled.div`
|
|
27
46
|
display: flex;
|
|
28
47
|
flex-direction: column;
|
|
29
48
|
gap: 8px;
|
|
30
49
|
`;
|
|
50
|
+
const CompleteAccountSetup = styled.div`
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
gap: 4px;
|
|
55
|
+
color: ${({ isDark }) => isDark ? "white" : "black"};
|
|
56
|
+
font-weight: 500;
|
|
57
|
+
font-size: 14px;
|
|
58
|
+
`;
|
|
31
59
|
export {
|
|
32
60
|
AuthOptions
|
|
33
61
|
};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
type Props = {
|
|
2
|
+
isGuestMode?: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare const AwaitingWalletCreationStep: ({ isGuestMode }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export {};
|
|
@@ -5,11 +5,16 @@ import { CpslIcon, CpslInfoBox, CpslText } from "@getpara/react-components";
|
|
|
5
5
|
import { InfoBoxContent, InfoBoxHeader, StepContainer } from "../common.js";
|
|
6
6
|
import { useEffect, useRef, useState } from "react";
|
|
7
7
|
import { Waiting } from "../Waiting/Waiting.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { useStore } from "../../../provider/stores/useStore.js";
|
|
9
|
+
import { useAccount } from "../../../provider/index.js";
|
|
10
|
+
const AwaitingWalletCreationStep = ({ isGuestMode = false }) => {
|
|
11
|
+
const hideWallets = useStore((state) => {
|
|
12
|
+
var _a;
|
|
13
|
+
return (_a = state.modalConfig) == null ? void 0 : _a.hideWallets;
|
|
14
|
+
});
|
|
11
15
|
const [showInfoBox, setShowInfoBox] = useState(false);
|
|
12
16
|
const showInfoBoxTimeout = useRef();
|
|
17
|
+
const { data: account } = useAccount();
|
|
13
18
|
useEffect(() => {
|
|
14
19
|
if (typeof window !== "undefined") {
|
|
15
20
|
showInfoBoxTimeout.current = window.setTimeout(() => {
|
|
@@ -22,7 +27,7 @@ const AwaitingWalletCreationStep = () => {
|
|
|
22
27
|
/* @__PURE__ */ jsx(
|
|
23
28
|
Waiting,
|
|
24
29
|
{
|
|
25
|
-
heading: hideWallets ? "Creating Your Account" : "Creating Your Wallet",
|
|
30
|
+
heading: isGuestMode ? "Creating Guest Account" : (account == null ? void 0 : account.isGuestMode) ? hideWallets ? "Linking Guest Account" : "Linking Guest Wallet" : hideWallets ? "Creating Your Account" : "Creating Your Wallet",
|
|
26
31
|
subheading: "This should only take a couple of seconds."
|
|
27
32
|
}
|
|
28
33
|
),
|