@getpara/react-sdk 1.8.0 → 2.0.0-alpha.3
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/components/AddFunds/MoonPayEmbed.js → MoonPayEmbed-Q2HP2BFI.js} +3 -1
- package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
- package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
- package/dist/chunk-MMUBH76A.js.br +0 -0
- package/dist/chunk-MMUBH76A.js.gz +0 -0
- package/dist/cli/cli.mjs +40 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6499 -6
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +1 -1
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.d.ts +4 -4
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -1
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.d.ts +1 -1
- package/dist/modal/components/ChainSwitch/ChainSwitch.d.ts +1 -1
- package/dist/modal/components/Controls/Selects.d.ts +1 -1
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +1 -1
- package/dist/modal/components/Footer/Footer.d.ts +1 -1
- package/dist/modal/components/WalletCard/WalletCard.d.ts +2 -2
- package/dist/modal/components/common.d.ts +7 -7
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/index.d.ts +0 -2
- package/dist/modal/stores/index.d.ts +0 -2
- package/dist/modal/stores/modal/useModalStore.d.ts +22 -20
- package/dist/modal/types/commonTypes.d.ts +4 -9
- package/dist/modal/types/externalWallets.d.ts +0 -2
- package/dist/modal/types/modalProps.d.ts +1 -33
- package/dist/modal/utils/authLayoutHelpers.d.ts +2 -2
- package/dist/modal/utils/getTileButtonFlex.d.ts +1 -1
- package/dist/modal/utils/isPasskeySupported.d.ts +1 -0
- package/dist/modal/utils/openPopup.d.ts +2 -2
- package/dist/modal/utils/stringFormatters.d.ts +0 -1
- package/dist/provider/ParaProvider.d.ts +3 -1
- package/dist/provider/actions/getAccount.d.ts +19 -7
- package/dist/provider/actions/getWallet.d.ts +1 -1
- package/dist/provider/actions/index.d.ts +25 -0
- package/dist/provider/actions/utils.d.ts +3 -0
- package/dist/provider/components/CosmosWalletWrapper.d.ts +11 -0
- package/dist/provider/components/EvmWalletWrapper.d.ts +12 -0
- package/dist/provider/components/ExternalWalletWrapper.d.ts +8 -0
- package/dist/provider/components/SolanaWalletWrapper.d.ts +9 -0
- package/dist/provider/external/getParaCosmosConnector.d.ts +7 -0
- package/dist/provider/external/getParaEvmConnector.d.ts +7 -0
- package/dist/provider/external/getParaSolanaConnector.d.ts +7 -0
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +12 -0
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +3 -0
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +8 -0
- package/dist/provider/hooks/mutations/index.d.ts +25 -10
- package/dist/provider/hooks/mutations/utils.d.ts +4 -0
- package/dist/provider/hooks/queries/index.d.ts +0 -1
- package/dist/provider/hooks/queries/useAccount.d.ts +1 -6
- package/dist/provider/hooks/queries/useWallet.d.ts +1 -1
- package/dist/provider/hooks/utils/useWalletState.d.ts +3 -2
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/providers/AuthProvider.d.ts +31 -0
- package/dist/provider/providers/CosmosExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/EvmExternalWalletProvider.d.ts +7 -0
- package/dist/provider/providers/ExternalWalletProvider.d.ts +73 -0
- package/dist/provider/providers/SolanaExternalWalletProvider.d.ts +7 -0
- package/dist/provider/stores/getters.d.ts +3 -3
- package/dist/provider/stores/setters.d.ts +1 -0
- package/dist/provider/stores/slices/config.d.ts +3 -0
- package/dist/provider/stores/slices/externalWallets.d.ts +3 -0
- package/dist/provider/stores/slices/index.d.ts +1 -0
- package/dist/provider/stores/types.d.ts +46 -3
- package/dist/provider/types/externalWalletProviders.d.ts +12 -0
- package/dist/provider/types/provider.d.ts +119 -16
- package/dist/provider/types/utils.d.ts +16 -0
- package/dist/provider/utils/paraConfigTypeGuards.d.ts +7 -0
- package/dist/provider/utils/renameMutations.d.ts +3 -0
- package/package.json +19 -7
- package/dist/modal/ParaModal.js +0 -362
- package/dist/modal/components/Account/Account.js +0 -77
- package/dist/modal/components/AddFunds/AddFunds.js +0 -220
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -72
- package/dist/modal/components/AddFunds/AddFundsDone.js +0 -43
- package/dist/modal/components/AddFunds/index.js +0 -4
- package/dist/modal/components/AuthInput/AuthInput.js +0 -283
- package/dist/modal/components/AuthInput/countryCodes.js +0 -42
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -33
- package/dist/modal/components/AuthInput/phoneMasks.js +0 -253
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -37
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -113
- package/dist/modal/components/AuthOptions/AuthOptions.js +0 -33
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -18
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -10
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -18
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -44
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -55
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -93
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -29
- package/dist/modal/components/Body/Body.js +0 -308
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -94
- package/dist/modal/components/ChainSwitch/config.js +0 -17
- package/dist/modal/components/Controls/Controls.js +0 -74
- package/dist/modal/components/Controls/Selects.js +0 -234
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -140
- package/dist/modal/components/ExternalWalletStep/config.js +0 -17
- package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.js +0 -96
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -172
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +0 -8
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -124
- package/dist/modal/components/Footer/Footer.js +0 -93
- package/dist/modal/components/Header/Header.js +0 -43
- package/dist/modal/components/Header/hooks/useStepTitle.js +0 -50
- package/dist/modal/components/Hero/Hero.js +0 -116
- package/dist/modal/components/IFrameStep/IFrameStep.js +0 -55
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -28
- package/dist/modal/components/ModalContent/ModalContent.js +0 -324
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
- package/dist/modal/components/OAuth/OAuth.js +0 -153
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -139
- package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -23
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -77
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -101
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -141
- package/dist/modal/components/StripeComponents/StripeComponents.js +0 -88
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -24
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -159
- package/dist/modal/components/Waiting/Waiting.js +0 -17
- package/dist/modal/components/WalletCard/PartnerIcon.js +0 -34
- package/dist/modal/components/WalletCard/WalletCard.js +0 -127
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -52
- package/dist/modal/components/common.js +0 -96
- package/dist/modal/components/index.js +0 -2
- package/dist/modal/constants/constants.js +0 -111
- package/dist/modal/constants/defaults.js +0 -10
- package/dist/modal/constants/oAuthLogos.js +0 -24
- 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 -4
- package/dist/modal/hooks/useCreateAccount.js +0 -72
- package/dist/modal/hooks/useEmbeddedExternalConnection.d.ts +0 -1
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -54
- package/dist/modal/hooks/useGoBack.js +0 -42
- 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 -47
- package/dist/modal/index.js +0 -33
- 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/ExternalWalletContext.js +0 -394
- 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/index.js +0 -4
- package/dist/modal/stores/modal/actions.js +0 -70
- package/dist/modal/stores/modal/useModalStore.js +0 -65
- 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/modal/types/commonTypes.js +0 -1
- package/dist/modal/types/externalWallets.js +0 -32
- package/dist/modal/types/modalProps.js +0 -12
- package/dist/modal/utils/authLayoutHelpers.js +0 -8
- package/dist/modal/utils/getMailtoLink.js +0 -10
- package/dist/modal/utils/getTileButtonFlex.js +0 -20
- package/dist/modal/utils/openPopup.js +0 -60
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
- package/dist/modal/utils/steps.js +0 -232
- package/dist/modal/utils/stringFormatters.js +0 -19
- package/dist/modal/utils/validateOnRampConfig.js +0 -32
- package/dist/package.json +0 -6
- package/dist/provider/ParaProvider.js +0 -22
- package/dist/provider/actions/checkIfUserExists.d.ts +0 -9
- package/dist/provider/actions/checkIfUserExists.js +0 -21
- package/dist/provider/actions/createUser.d.ts +0 -12
- package/dist/provider/actions/createUser.js +0 -26
- package/dist/provider/actions/getAccount.js +0 -22
- package/dist/provider/actions/getWallet.js +0 -14
- 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/index.js +0 -4
- package/dist/provider/hooks/mutations/index.js +0 -24
- package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +0 -13
- package/dist/provider/hooks/mutations/useCheckIfUserExists.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/provider/hooks/queries/index.js +0 -10
- package/dist/provider/hooks/queries/useAccount.js +0 -21
- package/dist/provider/hooks/queries/useWallet.js +0 -22
- package/dist/provider/hooks/queries/useWalletBalance.d.ts +0 -7
- package/dist/provider/hooks/queries/useWalletBalance.js +0 -26
- package/dist/provider/hooks/utils/index.js +0 -10
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -74
- package/dist/provider/hooks/utils/useClient.js +0 -10
- package/dist/provider/hooks/utils/useEventListeners.js +0 -105
- package/dist/provider/hooks/utils/useInternalClient.js +0 -10
- package/dist/provider/hooks/utils/useModal.js +0 -17
- package/dist/provider/hooks/utils/useWalletState.js +0 -33
- package/dist/provider/index.js +0 -8
- package/dist/provider/stores/getters.js +0 -13
- package/dist/provider/stores/slices/client.js +0 -9
- package/dist/provider/stores/slices/index.js +0 -4
- package/dist/provider/stores/slices/modal.js +0 -9
- package/dist/provider/stores/slices/wallet.js +0 -13
- package/dist/provider/stores/types.js +0 -1
- package/dist/provider/stores/useStore.js +0 -27
- package/dist/provider/types/provider.js +0 -1
- package/dist/provider/types/query.js +0 -1
- package/dist/provider/types/utils.js +0 -1
- package/dist/provider/utils/constants.d.ts +0 -5
- package/dist/provider/utils/constants.js +0 -11
- package/dist/provider/utils/renameMutations.js +0 -16
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__spreadValues
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { StepContainer } from "../common.js";
|
|
7
|
-
import { OnRampProvider } from "@getpara/web-sdk";
|
|
8
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
9
|
-
import { lazy, useEffect, useMemo, useState } from "react";
|
|
10
|
-
import { ModalStep } from "../../utils/steps.js";
|
|
11
|
-
import { RampEmbed, StripeEmbed } from "@getpara/react-common";
|
|
12
|
-
import styled from "styled-components";
|
|
13
|
-
import { useGoBack } from "../../hooks/useGoBack.js";
|
|
14
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
15
|
-
const STEPS = {
|
|
16
|
-
CANCELLED: ModalStep.ADD_FUNDS_FAILURE,
|
|
17
|
-
FINISHED: ModalStep.ADD_FUNDS_SUCCESS
|
|
18
|
-
};
|
|
19
|
-
const AddFundsAwaiting = () => {
|
|
20
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
21
|
-
const goBack = useGoBack();
|
|
22
|
-
const onRampConfig = useModalStore((state) => state.onRampConfig);
|
|
23
|
-
const onRampPurchase = useModalStore((state) => state.onRampPurchase);
|
|
24
|
-
const setOnRampPurchase = useModalStore((state) => state.setOnRampPurchase);
|
|
25
|
-
const para = useInternalClient();
|
|
26
|
-
const appName = useThemeStore((state) => state.appName);
|
|
27
|
-
const isDark = useThemeStore((state) => state.isDark);
|
|
28
|
-
const [MoonPayEmbed, setMoonPayEmbed] = useState(null);
|
|
29
|
-
const props = {
|
|
30
|
-
para,
|
|
31
|
-
appName,
|
|
32
|
-
onRampConfig,
|
|
33
|
-
onRampPurchase,
|
|
34
|
-
isDark,
|
|
35
|
-
isEmbedded: true,
|
|
36
|
-
setOnRampPurchase,
|
|
37
|
-
onClose: goBack
|
|
38
|
-
};
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const _MoonPayEmbed = lazy(() => import("./MoonPayEmbed.js"));
|
|
41
|
-
setMoonPayEmbed(_MoonPayEmbed);
|
|
42
|
-
}, []);
|
|
43
|
-
const onRampEmbed = useMemo(() => {
|
|
44
|
-
if (!onRampPurchase.id) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
switch (onRampPurchase == null ? void 0 : onRampPurchase.provider) {
|
|
48
|
-
case OnRampProvider.STRIPE:
|
|
49
|
-
return /* @__PURE__ */ jsx(StripeEmbed, __spreadValues({}, props));
|
|
50
|
-
case OnRampProvider.MOONPAY:
|
|
51
|
-
return !MoonPayEmbed || typeof window === "undefined" ? null : /* @__PURE__ */ jsx(MoonPayEmbed, __spreadValues({}, props));
|
|
52
|
-
case OnRampProvider.RAMP:
|
|
53
|
-
return /* @__PURE__ */ jsx(RampEmbed, __spreadValues({ apiKey: onRampConfig.rampApiKey }, props));
|
|
54
|
-
}
|
|
55
|
-
}, [onRampPurchase == null ? void 0 : onRampPurchase.provider, MoonPayEmbed]);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
let timeoutId;
|
|
58
|
-
if ((onRampPurchase == null ? void 0 : onRampPurchase.status) && ["CANCELLED", "FINISHED"].includes(onRampPurchase.status)) {
|
|
59
|
-
timeoutId = setTimeout(() => {
|
|
60
|
-
setStep(STEPS[onRampPurchase.status]);
|
|
61
|
-
}, 5e3);
|
|
62
|
-
}
|
|
63
|
-
return () => clearTimeout(timeoutId);
|
|
64
|
-
}, [onRampPurchase == null ? void 0 : onRampPurchase.status]);
|
|
65
|
-
return /* @__PURE__ */ jsx(Container, { $wide: true, children: onRampEmbed });
|
|
66
|
-
};
|
|
67
|
-
const Container = styled(StepContainer)`
|
|
68
|
-
flex: 1;
|
|
69
|
-
`;
|
|
70
|
-
export {
|
|
71
|
-
AddFundsAwaiting
|
|
72
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../../chunk-MMUBH76A.js";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { Heading, HeroIcon, InnerStepContainer, StepContainer } from "../common.js";
|
|
5
|
-
import { useModalStore, useThemeStore } from "../../stores/index.js";
|
|
6
|
-
import { useMemo } from "react";
|
|
7
|
-
import { CpslButton, CpslText } from "@getpara/react-components";
|
|
8
|
-
import { getAddFundsStep } from "../../utils/steps.js";
|
|
9
|
-
const AddFundsDone = ({ isSuccess, onClose }) => {
|
|
10
|
-
const hideWallets = useThemeStore((state) => state.hideWallets);
|
|
11
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
12
|
-
const onRampPurchase = useModalStore((state) => state.onRampPurchase);
|
|
13
|
-
const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
|
|
14
|
-
const formatter = useMemo(() => {
|
|
15
|
-
return new Intl.NumberFormat("en-US", {
|
|
16
|
-
style: "currency",
|
|
17
|
-
currency: (onRampPurchase == null ? void 0 : onRampPurchase.fiat) || "USD"
|
|
18
|
-
});
|
|
19
|
-
}, [onRampPurchase == null ? void 0 : onRampPurchase.fiat]);
|
|
20
|
-
const heading = isSuccess ? "Transaction Successful" : "Something Went Wrong";
|
|
21
|
-
const text = isSuccess ? `${formatter.format(parseFloat(onRampPurchase == null ? void 0 : onRampPurchase.fiatQuantity))} is now available in your ${hideWallets ? "account" : "wallet"}.` : `No funds were added to your ${hideWallets ? "account" : "wallet"}.`;
|
|
22
|
-
const buttonText = isSuccess ? "Done" : "Try Again";
|
|
23
|
-
return /* @__PURE__ */ jsxs(StepContainer, { children: [
|
|
24
|
-
/* @__PURE__ */ jsx(HeroIcon, { icon: "checkCircleFilled" }),
|
|
25
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
26
|
-
/* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: heading }),
|
|
27
|
-
/* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "secondary", children: text })
|
|
28
|
-
] }),
|
|
29
|
-
/* @__PURE__ */ jsx(
|
|
30
|
-
CpslButton,
|
|
31
|
-
{
|
|
32
|
-
fullWidth: true,
|
|
33
|
-
onClick: () => {
|
|
34
|
-
isSuccess ? onClose() : setStep(getAddFundsStep(accountAddFundTab));
|
|
35
|
-
},
|
|
36
|
-
children: buttonText
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
] });
|
|
40
|
-
};
|
|
41
|
-
export {
|
|
42
|
-
AddFundsDone
|
|
43
|
-
};
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__async
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import {
|
|
7
|
-
CpslButton,
|
|
8
|
-
CpslIcon,
|
|
9
|
-
CpslInput,
|
|
10
|
-
CpslSelect,
|
|
11
|
-
CpslSelectItem,
|
|
12
|
-
CpslSpinner,
|
|
13
|
-
CpslText
|
|
14
|
-
} from "@getpara/react-components";
|
|
15
|
-
import { useRef, useState } from "react";
|
|
16
|
-
import styled from "styled-components";
|
|
17
|
-
import countryCodes from "./countryCodes.js";
|
|
18
|
-
import { useModalStore, useUserInfoStore } from "../../stores/index.js";
|
|
19
|
-
import { EMAIL_REGEX, MOBILE_SIZE } from "../../constants/constants.js";
|
|
20
|
-
import { useDropdownPosition } from "./hooks/useDropdownPosition.js";
|
|
21
|
-
import { ModalStep } from "../../utils/steps.js";
|
|
22
|
-
import { defaultPhoneMask, phoneMasks } from "./phoneMasks.js";
|
|
23
|
-
import { AuthMethod } from "@getpara/web-sdk";
|
|
24
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
25
|
-
import { useSetLoginURLs } from "../../hooks/useSetLoginURLs.js";
|
|
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
|
-
const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
|
|
31
|
-
var _a, _b;
|
|
32
|
-
const inputRef = useRef(null);
|
|
33
|
-
const { dropdownMaxHeight, dropdownWidth } = useDropdownPosition(inputRef);
|
|
34
|
-
const para = useInternalClient();
|
|
35
|
-
const setAuthInfo = useUserInfoStore((state) => state.setAuthInfo);
|
|
36
|
-
const authInfo = useUserInfoStore((state) => state.getAuthInfo());
|
|
37
|
-
const setFlow = useModalStore((state) => state.setFlow);
|
|
38
|
-
const setStep = useModalStore((state) => state.setStep);
|
|
39
|
-
const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
|
|
40
|
-
const setLoginURLs = useSetLoginURLs();
|
|
41
|
-
const [countryCode, setCountryCode] = useState(
|
|
42
|
-
(authInfo == null ? void 0 : authInfo.authType) === "phone" ? authInfo.auth.countryCode || "+1" : "+1"
|
|
43
|
-
);
|
|
44
|
-
const [identifier, setIdentifier] = useState(
|
|
45
|
-
(() => {
|
|
46
|
-
if (!authInfo || ["telegram", "farcaster"].includes(authInfo.authType)) {
|
|
47
|
-
return "";
|
|
48
|
-
}
|
|
49
|
-
if (authInfo.authType !== "phone") {
|
|
50
|
-
return authInfo.identifier;
|
|
51
|
-
}
|
|
52
|
-
return authInfo.auth.phone;
|
|
53
|
-
})()
|
|
54
|
-
);
|
|
55
|
-
const [identifierType, setIdentifierType] = useState(
|
|
56
|
-
authInfo && (authInfo.authType === "email" || authInfo.authType === "phone") ? authInfo.authType : void 0
|
|
57
|
-
);
|
|
58
|
-
const [matchedCountryCode, setMatchedCountryCode] = useState(
|
|
59
|
-
(_a = countryCodes.find((option) => isCcMatch(countryCode, option))) != null ? _a : DEFAULT_COUNTRY
|
|
60
|
-
);
|
|
61
|
-
const [isLoggingIn, setIsLoggingIn] = useState(false);
|
|
62
|
-
const [error, setError] = useState("");
|
|
63
|
-
const [search, setSearch] = useState("");
|
|
64
|
-
const isEmail = identifierType === "email";
|
|
65
|
-
const isPhone = identifierType === "phone";
|
|
66
|
-
const isUnknown = !identifierType;
|
|
67
|
-
const filteredCountryCodes = search ? countryCodes.filter(
|
|
68
|
-
(cc) => cc.selectedLabel.toLowerCase().includes(search.toLowerCase()) || cc.label.toLowerCase().includes(search.toLowerCase()) || cc.value.toLowerCase().includes(search.toLowerCase())
|
|
69
|
-
) : countryCodes;
|
|
70
|
-
const handleSearchInput = (ev) => {
|
|
71
|
-
setSearch(ev.detail);
|
|
72
|
-
};
|
|
73
|
-
const handleIdentifierInput = (ev) => {
|
|
74
|
-
const newIdentifier = ev.detail.value;
|
|
75
|
-
let isNewPhone = false, isNewEmail = false;
|
|
76
|
-
if (!disablePhoneLogin) {
|
|
77
|
-
const countryCodeInputMatch = countryCodes.find((option) => isCcMatch(newIdentifier, option));
|
|
78
|
-
if (countryCodeInputMatch) {
|
|
79
|
-
setCountryCode(countryCodeInputMatch.value);
|
|
80
|
-
setMatchedCountryCode(countryCodeInputMatch);
|
|
81
|
-
setIdentifierType("phone");
|
|
82
|
-
setIdentifier("");
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
isNewPhone = !isEmail && isPhone ? /\d+$/.test(newIdentifier) : /\d\d\d+$/.test(newIdentifier);
|
|
86
|
-
}
|
|
87
|
-
if (!disableEmailLogin) {
|
|
88
|
-
isNewEmail = /\D.*$/.test(newIdentifier);
|
|
89
|
-
}
|
|
90
|
-
setIdentifierType(isNewEmail ? "email" : isNewPhone ? "phone" : void 0);
|
|
91
|
-
setIdentifier(newIdentifier);
|
|
92
|
-
};
|
|
93
|
-
const handleCountryCodeInput = (ev) => {
|
|
94
|
-
const matchedCountryCode2 = countryCodes.find((code) => code.selectedLabel === ev.detail);
|
|
95
|
-
setCountryCode(matchedCountryCode2.value);
|
|
96
|
-
setMatchedCountryCode(matchedCountryCode2);
|
|
97
|
-
};
|
|
98
|
-
const login = () => __async(void 0, null, function* () {
|
|
99
|
-
setError("");
|
|
100
|
-
if (isUnknown) {
|
|
101
|
-
setError("Please enter a valid email or phone number!");
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
let auth;
|
|
105
|
-
if (isEmail) {
|
|
106
|
-
if (!EMAIL_REGEX.test(identifier)) {
|
|
107
|
-
setError("Please enter a valid email!");
|
|
108
|
-
return;
|
|
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;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
const handleSubmit = () => __async(void 0, null, function* () {
|
|
155
|
-
setIsLoggingIn(true);
|
|
156
|
-
yield login();
|
|
157
|
-
setIsLoggingIn(false);
|
|
158
|
-
});
|
|
159
|
-
if (disableEmailLogin && disablePhoneLogin) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
return /* @__PURE__ */ jsx(
|
|
163
|
-
"form",
|
|
164
|
-
{
|
|
165
|
-
onSubmit: (e) => __async(void 0, null, function* () {
|
|
166
|
-
e.preventDefault();
|
|
167
|
-
yield handleSubmit();
|
|
168
|
-
}),
|
|
169
|
-
children: /* @__PURE__ */ jsxs(
|
|
170
|
-
StyledInput,
|
|
171
|
-
{
|
|
172
|
-
ref: inputRef,
|
|
173
|
-
id: "authInput",
|
|
174
|
-
placeholder: isEmail || disablePhoneLogin ? "Enter email" : isPhone || disableEmailLogin ? "Enter phone" : "Enter email or phone",
|
|
175
|
-
onCpslInput: handleIdentifierInput,
|
|
176
|
-
value: identifier,
|
|
177
|
-
errorText: error,
|
|
178
|
-
autofocus: true,
|
|
179
|
-
inputMode: "email",
|
|
180
|
-
onKeyDown: (e) => __async(void 0, null, function* () {
|
|
181
|
-
return e.key === "Enter" && handleSubmit();
|
|
182
|
-
}),
|
|
183
|
-
contrastText: true,
|
|
184
|
-
isPhone,
|
|
185
|
-
mask: identifierType === "phone" ? (_b = phoneMasks[matchedCountryCode.selectedLabel]) != null ? _b : defaultPhoneMask : void 0,
|
|
186
|
-
enterkeyhint: "go",
|
|
187
|
-
noAutoDisable: true,
|
|
188
|
-
disabled: isLoggingIn,
|
|
189
|
-
"data-testid": "auth-input",
|
|
190
|
-
children: [
|
|
191
|
-
/* @__PURE__ */ jsxs(IconContainer, { slot: "start", children: [
|
|
192
|
-
!disableEmailLogin && (isUnknown || isEmail) && /* @__PURE__ */ jsx(CpslIcon, { "aria-label": "email", icon: "mail" }),
|
|
193
|
-
!disablePhoneLogin && isUnknown && /* @__PURE__ */ jsx(CpslIcon, { "aria-label": "phone", icon: "phone" }),
|
|
194
|
-
isPhone && /* @__PURE__ */ jsxs(
|
|
195
|
-
CountryCodeSelect,
|
|
196
|
-
{
|
|
197
|
-
selectedValue: matchedCountryCode.selectedLabel,
|
|
198
|
-
onCpslSelectValueChange: handleCountryCodeInput,
|
|
199
|
-
showFormattedSelectedItem: true,
|
|
200
|
-
autoWidth: true,
|
|
201
|
-
dropdownMaxHeight,
|
|
202
|
-
anchorElId: "authInput",
|
|
203
|
-
$width: dropdownWidth,
|
|
204
|
-
showSearch: true,
|
|
205
|
-
searchPlaceholder: "Search Countries",
|
|
206
|
-
onCpslSearchChange: handleSearchInput,
|
|
207
|
-
"data-testid": "country-code-select",
|
|
208
|
-
children: [
|
|
209
|
-
matchedCountryCode && /* @__PURE__ */ jsxs(SelectedItem, { slot: "selected-item", children: [
|
|
210
|
-
/* @__PURE__ */ jsx(CpslText, { children: matchedCountryCode.selectedLabel }),
|
|
211
|
-
/* @__PURE__ */ jsx(CpslText, { children: matchedCountryCode.value })
|
|
212
|
-
] }),
|
|
213
|
-
filteredCountryCodes.map((cc) => /* @__PURE__ */ jsxs(StyledSelectItem, { slot: "items", value: cc.selectedLabel, children: [
|
|
214
|
-
/* @__PURE__ */ jsx(CpslText, { children: cc.label }),
|
|
215
|
-
/* @__PURE__ */ jsx(CpslText, { children: cc.value })
|
|
216
|
-
] }, cc.selectedLabel))
|
|
217
|
-
]
|
|
218
|
-
}
|
|
219
|
-
)
|
|
220
|
-
] }),
|
|
221
|
-
identifier && /* @__PURE__ */ jsx(CpslButton, { slot: "end", size: "small", fullWidth: true, disabled: isLoggingIn, onClick: handleSubmit, children: isLoggingIn ? /* @__PURE__ */ jsx(CpslSpinner, { size: 16 }) : /* @__PURE__ */ jsx(CpslIcon, { icon: "arrowNarrow" }) })
|
|
222
|
-
]
|
|
223
|
-
},
|
|
224
|
-
"email"
|
|
225
|
-
)
|
|
226
|
-
}
|
|
227
|
-
);
|
|
228
|
-
};
|
|
229
|
-
const IconContainer = styled.div`
|
|
230
|
-
height: 100%;
|
|
231
|
-
display: flex;
|
|
232
|
-
align-items: center;
|
|
233
|
-
gap: 8px;
|
|
234
|
-
padding-right: 12px;
|
|
235
|
-
border-right: 1px solid var(--cpsl-color-background-16);
|
|
236
|
-
|
|
237
|
-
& cpsl-icon {
|
|
238
|
-
--icon-color: var(--cpsl-color-contrast);
|
|
239
|
-
}
|
|
240
|
-
`;
|
|
241
|
-
const CountryCodeSelect = styled(CpslSelect)`
|
|
242
|
-
--container-height: 100%;
|
|
243
|
-
--container-padding-start: 0px;
|
|
244
|
-
--container-padding-end: 0px;
|
|
245
|
-
--container-border-width: 0px;
|
|
246
|
-
--container-gap: 4px;
|
|
247
|
-
--container-background-color: transparent;
|
|
248
|
-
--container-box-shadow: none;
|
|
249
|
-
|
|
250
|
-
&::part(dropdown) {
|
|
251
|
-
width: ${({ $width }) => `${$width - 2}px`};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
&::part(popover) {
|
|
255
|
-
@media (max-width: ${MOBILE_SIZE}px) {
|
|
256
|
-
top: unset !important;
|
|
257
|
-
bottom: 16px;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
cpsl-auth-modal.force-mobile-media & {
|
|
261
|
-
top: unset !important;
|
|
262
|
-
bottom: 16px;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
`;
|
|
266
|
-
const StyledSelectItem = styled(CpslSelectItem)`
|
|
267
|
-
&::part(inner-container) {
|
|
268
|
-
justify-content: space-between;
|
|
269
|
-
}
|
|
270
|
-
`;
|
|
271
|
-
const SelectedItem = styled.div`
|
|
272
|
-
display: flex;
|
|
273
|
-
gap: 4px;
|
|
274
|
-
align-items: center;
|
|
275
|
-
`;
|
|
276
|
-
const StyledInput = styled(CpslInput)`
|
|
277
|
-
--container-background-color: var(--cpsl-color-background-8);
|
|
278
|
-
--input-background-color: var(--cpsl-color-background-8);
|
|
279
|
-
--container-padding-end: 8px;
|
|
280
|
-
`;
|
|
281
|
-
export {
|
|
282
|
-
AuthInput
|
|
283
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../../chunk-MMUBH76A.js";
|
|
3
|
-
import { getCountries, getCountryCallingCode } from "libphonenumber-js";
|
|
4
|
-
const excludedCountries = [
|
|
5
|
-
"AC",
|
|
6
|
-
"CG",
|
|
7
|
-
"CI",
|
|
8
|
-
"CV",
|
|
9
|
-
"GF",
|
|
10
|
-
"GP",
|
|
11
|
-
"MF",
|
|
12
|
-
"NC",
|
|
13
|
-
"PM",
|
|
14
|
-
"RE",
|
|
15
|
-
"SD",
|
|
16
|
-
"SH",
|
|
17
|
-
"SJ",
|
|
18
|
-
"TA",
|
|
19
|
-
"VA",
|
|
20
|
-
"WF",
|
|
21
|
-
"XK",
|
|
22
|
-
"YT"
|
|
23
|
-
];
|
|
24
|
-
const generateCountryCodes = () => {
|
|
25
|
-
const countries = getCountries();
|
|
26
|
-
const countryList = countries.filter((country) => !excludedCountries.includes(country)).map((country) => {
|
|
27
|
-
const countryCode = getCountryCallingCode(country);
|
|
28
|
-
const countryName = new Intl.DisplayNames(["en"], { type: "region" }).of(country);
|
|
29
|
-
return {
|
|
30
|
-
label: countryName,
|
|
31
|
-
value: `+${countryCode}`,
|
|
32
|
-
selectedLabel: country,
|
|
33
|
-
icon: country
|
|
34
|
-
};
|
|
35
|
-
}).sort((a, b) => a.label.localeCompare(b.label));
|
|
36
|
-
return countryList;
|
|
37
|
-
};
|
|
38
|
-
const countryCodes = generateCountryCodes();
|
|
39
|
-
var countryCodes_default = countryCodes;
|
|
40
|
-
export {
|
|
41
|
-
countryCodes_default as default
|
|
42
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../../../chunk-MMUBH76A.js";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
const useDropdownPosition = (inputRef) => {
|
|
5
|
-
const [dropdownMaxHeight, setDropdownMaxHeight] = useState();
|
|
6
|
-
const [dropdownWidth, setDropdownWidth] = useState();
|
|
7
|
-
const [mobileAnchor, setMobileAnchor] = useState();
|
|
8
|
-
const resize = () => {
|
|
9
|
-
var _a, _b, _c;
|
|
10
|
-
if (typeof window !== "undefined") {
|
|
11
|
-
const newMaxHeight = Math.max(
|
|
12
|
-
window.innerHeight - ((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.getBoundingClientRect().bottom) - 20,
|
|
13
|
-
window.innerHeight * 0.25
|
|
14
|
-
);
|
|
15
|
-
setDropdownMaxHeight(newMaxHeight);
|
|
16
|
-
setDropdownWidth((_b = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _b.getBoundingClientRect().width);
|
|
17
|
-
setMobileAnchor((_c = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _c.getBoundingClientRect().height);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
if (inputRef.current && !dropdownMaxHeight) {
|
|
21
|
-
resize();
|
|
22
|
-
}
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
typeof window !== "undefined" && window.addEventListener("resize", resize);
|
|
25
|
-
return () => {
|
|
26
|
-
typeof window !== "undefined" && window.removeEventListener("resize", resize);
|
|
27
|
-
};
|
|
28
|
-
}, []);
|
|
29
|
-
return { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize };
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
useDropdownPosition
|
|
33
|
-
};
|