@getpara/react-sdk 2.0.0-alpha.20 → 2.0.0-alpha.21
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/index.d.ts +0 -1
- package/dist/index.js +0 -5
- package/dist/modal/ParaModal.js +15 -5
- package/dist/modal/components/Account/Account.js +14 -8
- package/dist/modal/components/Account/AccountProfile.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfile.js +170 -0
- package/dist/modal/components/Account/AccountProfileLink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLink.js +205 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileLinkOptions.js +98 -0
- package/dist/modal/components/Account/AccountProfileUnlink.d.ts +1 -0
- package/dist/modal/components/Account/AccountProfileUnlink.js +47 -0
- package/dist/modal/components/AuthInput/AuthInput.d.ts +17 -3
- package/dist/modal/components/AuthInput/AuthInput.js +116 -101
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +2 -2
- package/dist/modal/components/AuthOptions/AuthOptions.js +26 -1
- package/dist/modal/components/Body/Body.js +21 -2
- package/dist/modal/components/Controls/Selects.js +3 -19
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.d.ts +7 -0
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +70 -39
- package/dist/modal/components/Header/hooks/useStepTitle.js +7 -1
- package/dist/modal/components/OAuth/FarcasterOAuthStep.d.ts +1 -0
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +6 -2
- package/dist/modal/components/OAuth/OAuth.js +2 -2
- package/dist/modal/components/OAuth/TelegramOAuthStep.d.ts +7 -0
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +36 -52
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.d.ts +12 -1
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +40 -23
- package/dist/modal/components/common.d.ts +18 -1
- package/dist/modal/components/common.js +86 -0
- package/dist/modal/constants/constants.d.ts +1 -1
- package/dist/modal/constants/constants.js +1 -1
- package/dist/modal/constants/oAuthLogos.d.ts +15 -6
- package/dist/modal/constants/oAuthLogos.js +148 -19
- package/dist/modal/hooks/useTelegramLogin.d.ts +12 -0
- package/dist/modal/hooks/useTelegramLogin.js +65 -0
- package/dist/modal/stores/modal/actions.js +6 -1
- package/dist/modal/stores/modal/useModalStore.d.ts +4 -3
- package/dist/modal/stores/modal/useModalStore.js +7 -2
- package/dist/modal/types/modalProps.d.ts +6 -1
- package/dist/modal/utils/authInputHelpers.d.ts +3 -5
- package/dist/modal/utils/authInputHelpers.js +23 -20
- package/dist/modal/utils/getWalletDisplayName.d.ts +5 -0
- package/dist/modal/utils/getWalletDisplayName.js +22 -0
- package/dist/modal/utils/steps.d.ts +10 -2
- package/dist/modal/utils/steps.js +18 -2
- package/dist/provider/ParaProvider.js +6 -5
- package/dist/provider/actions/index.d.ts +19 -0
- package/dist/provider/actions/index.js +47 -29
- package/dist/provider/actions/utils.d.ts +3 -2
- package/dist/provider/actions/utils.js +25 -6
- package/dist/provider/components/CosmosWalletWrapper.js +2 -2
- package/dist/provider/components/EvmWalletWrapper.js +2 -2
- package/dist/provider/components/ExternalWalletWrapper.js +2 -1
- package/dist/provider/components/SolanaWalletWrapper.js +2 -2
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.d.ts +0 -10
- package/dist/provider/external/stubs/CosmosExternalWalletContextStub.js +2 -12
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.d.ts +0 -1
- package/dist/provider/external/stubs/EvmExternalWalletContextStub.js +2 -15
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.d.ts +0 -6
- package/dist/provider/external/stubs/SolanaExternalWalletContextStub.js +2 -8
- package/dist/provider/hooks/mutations/core.d.ts +27 -0
- package/dist/provider/hooks/mutations/core.js +66 -0
- package/dist/provider/hooks/mutations/index.d.ts +3 -28
- package/dist/provider/hooks/mutations/index.js +4 -60
- package/dist/provider/hooks/mutations/useLinkAccount.d.ts +9 -0
- package/dist/provider/hooks/mutations/useLinkAccount.js +18 -0
- package/dist/provider/hooks/mutations/utils.d.ts +11 -4
- package/dist/provider/hooks/mutations/utils.js +35 -4
- package/dist/provider/hooks/queries/core.d.ts +2 -0
- package/dist/provider/hooks/queries/core.js +13 -0
- package/dist/provider/hooks/queries/index.d.ts +1 -0
- package/dist/provider/hooks/queries/index.js +1 -0
- package/dist/provider/hooks/queries/utils.d.ts +4 -0
- package/dist/provider/hooks/queries/utils.js +24 -0
- package/dist/provider/hooks/utils/useModal.d.ts +4 -1
- package/dist/provider/hooks/utils/useModal.js +12 -2
- package/dist/provider/providers/AccountLinkProvider.d.ts +42 -0
- package/dist/provider/providers/AccountLinkProvider.js +443 -0
- package/dist/provider/providers/AuthProvider.d.ts +3 -1
- package/dist/provider/providers/AuthProvider.js +8 -5
- package/dist/provider/providers/ExternalWalletProvider.d.ts +18 -32
- package/dist/provider/providers/ExternalWalletProvider.js +167 -36
- package/dist/provider/stores/slices/modal.js +3 -1
- package/dist/provider/stores/types.d.ts +2 -1
- package/dist/provider/types/utils.d.ts +25 -6
- package/dist/provider/utils/renameMutations.d.ts +2 -2
- package/package.json +8 -8
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpara/react-components";
|
|
7
7
|
import { CenteredText, ErrorContainer, ErrorIcon, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
|
|
8
|
-
import { useEffect, useMemo } from "react";
|
|
8
|
+
import { useEffect, useMemo, useState } from "react";
|
|
9
9
|
import { useModalStore } from "../../stores/index.js";
|
|
10
10
|
import { safeStyled } from "@getpara/react-common";
|
|
11
11
|
import { useCopyToClipboard } from "@getpara/react-common";
|
|
@@ -14,10 +14,65 @@ import { isMobile, isTablet } from "@getpara/web-sdk";
|
|
|
14
14
|
import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet.js";
|
|
15
15
|
import { useExternalWallets } from "../../../provider/providers/ExternalWalletProvider.js";
|
|
16
16
|
import { useStore } from "../../../provider/stores/useStore.js";
|
|
17
|
-
const
|
|
17
|
+
const ExternalWalletMobileConnect = ({
|
|
18
|
+
wallet,
|
|
19
|
+
qrUri: propsQrUri,
|
|
20
|
+
onConnectWc,
|
|
21
|
+
isSelfFetching = false
|
|
22
|
+
}) => {
|
|
23
|
+
var _a, _b;
|
|
18
24
|
const [isCopied, copy] = useCopyToClipboard();
|
|
19
|
-
const externalWalletError = useModalStore((state) => state.externalWalletError);
|
|
20
25
|
const appName = useStore((state) => state.appName);
|
|
26
|
+
const [qrUri, setQrUri] = useState(isSelfFetching ? void 0 : propsQrUri);
|
|
27
|
+
const isWalletConnect = wallet.id === "walletConnect";
|
|
28
|
+
const handleCopy = () => {
|
|
29
|
+
if (qrUri) {
|
|
30
|
+
copy(qrUri);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const fetchQrUri = () => {
|
|
35
|
+
var _a2;
|
|
36
|
+
if (!isSelfFetching) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
(_a2 = wallet.getQrUri) == null ? void 0 : _a2.call(wallet).then(setQrUri).catch();
|
|
40
|
+
};
|
|
41
|
+
fetchQrUri();
|
|
42
|
+
}, [wallet, isSelfFetching]);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
setQrUri(propsQrUri);
|
|
45
|
+
}, [propsQrUri]);
|
|
46
|
+
if (wallet.type === "SOLANA" || isMobile() && !isTablet()) {
|
|
47
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
+
wallet.type === "SOLANA" && qrUri && /* @__PURE__ */ jsx(InnerStepContainer, { children: /* @__PURE__ */ jsx(CpslText, { weight: "semiBold", color: "error", children: `Continue in the ${wallet.name} mobile app.` }) }),
|
|
49
|
+
wallet.id !== "walletConnect" && /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
50
|
+
wallet.type === "SOLANA" && qrUri && !wallet.hasIosSafariExtension || wallet.type !== "SOLANA" ? /* @__PURE__ */ jsx(CpslButton, { onClick: () => routeMobileExternalWallet(qrUri), fullWidth: true, children: "Connect Wallet" }) : /* @__PURE__ */ jsx(Text, { weight: "semiBold", children: wallet.hasIosSafariExtension ? `Please install and use the ${wallet.name} extension for iOS Safari.` : `Please navigate to ${appName} in the ${wallet.name} wallet.` }),
|
|
51
|
+
!wallet.hasIosSafariExtension && /* @__PURE__ */ jsx(Link, { href: (_a = wallet.downloadUrl) != null ? _a : "", target: "_blank", children: /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", children: [
|
|
52
|
+
`Get ${wallet.name}`,
|
|
53
|
+
/* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
|
|
54
|
+
] }) })
|
|
55
|
+
] })
|
|
56
|
+
] });
|
|
57
|
+
}
|
|
58
|
+
const GetWalletButton = /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", onClick: isWalletConnect ? onConnectWc : void 0, children: [
|
|
59
|
+
`${isWalletConnect ? "Open" : "Get"} ${wallet.name}`,
|
|
60
|
+
/* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
|
|
61
|
+
] });
|
|
62
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
63
|
+
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
64
|
+
/* @__PURE__ */ jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device" }),
|
|
65
|
+
/* @__PURE__ */ jsx(QRContainer, { children: !qrUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }),
|
|
66
|
+
/* @__PURE__ */ jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [
|
|
67
|
+
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: isCopied ? "check" : "copy" }),
|
|
68
|
+
isCopied ? "Copied" : "Copy Link"
|
|
69
|
+
] })
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ jsx(InnerStepContainer, { children: isWalletConnect ? /* @__PURE__ */ jsx(Fragment, { children: GetWalletButton }) : /* @__PURE__ */ jsx(Link, { href: (_b = wallet.downloadUrl) != null ? _b : "", target: "_blank", children: GetWalletButton }) })
|
|
72
|
+
] });
|
|
73
|
+
};
|
|
74
|
+
const ExternalWalletStep = () => {
|
|
75
|
+
const externalWalletError = useModalStore((state) => state.externalWalletError);
|
|
21
76
|
const setStep = useModalStore((state) => state.setStep);
|
|
22
77
|
const { connectExternalWallet, wallet, qrUri, walletDisplayHelpers } = useExternalWallets();
|
|
23
78
|
useEffect(() => {
|
|
@@ -28,13 +83,8 @@ const ExternalWalletStep = () => {
|
|
|
28
83
|
yield connectExternalWallet(wallet);
|
|
29
84
|
}
|
|
30
85
|
});
|
|
31
|
-
const handleCopy = () => {
|
|
32
|
-
if (qrUri) {
|
|
33
|
-
copy(qrUri);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
86
|
const Content = useMemo(() => {
|
|
37
|
-
var _a
|
|
87
|
+
var _a;
|
|
38
88
|
if (!wallet) {
|
|
39
89
|
return null;
|
|
40
90
|
}
|
|
@@ -73,36 +123,16 @@ Please choose another wallet or continue on desktop.` }) });
|
|
|
73
123
|
] });
|
|
74
124
|
}
|
|
75
125
|
if (showMobile) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
wallet
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
] });
|
|
87
|
-
}
|
|
88
|
-
const openWCModal = () => __async(void 0, null, function* () {
|
|
89
|
-
yield connectExternalWallet(wallet, true, true);
|
|
90
|
-
});
|
|
91
|
-
const GetWalletButton = /* @__PURE__ */ jsxs(ExternalButton, { variant: "secondary", onClick: isWalletConnect ? openWCModal : void 0, children: [
|
|
92
|
-
`${isWalletConnect ? "Open" : "Get"} ${wallet.name}`,
|
|
93
|
-
/* @__PURE__ */ jsx(ExternalIcon, { icon: "linkExternal" })
|
|
94
|
-
] });
|
|
95
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
-
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
97
|
-
/* @__PURE__ */ jsx(CpslText, { weight: "semiBold", children: "Scan with your mobile device" }),
|
|
98
|
-
/* @__PURE__ */ jsx(QRContainer, { children: !qrUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: qrUri, imageSrc: wallet.iconUrl }) }),
|
|
99
|
-
/* @__PURE__ */ jsxs(CpslButton, { size: "small", variant: "ghost", onClick: handleCopy, children: [
|
|
100
|
-
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: isCopied ? "check" : "copy" }),
|
|
101
|
-
isCopied ? "Copied" : "Copy Link"
|
|
102
|
-
] })
|
|
103
|
-
] }),
|
|
104
|
-
/* @__PURE__ */ jsx(InnerStepContainer, { children: isWalletConnect ? /* @__PURE__ */ jsx(Fragment, { children: GetWalletButton }) : /* @__PURE__ */ jsx(Link, { href: (_c = wallet.downloadUrl) != null ? _c : "", target: "_blank", children: GetWalletButton }) })
|
|
105
|
-
] });
|
|
126
|
+
return /* @__PURE__ */ jsx(
|
|
127
|
+
ExternalWalletMobileConnect,
|
|
128
|
+
{
|
|
129
|
+
wallet,
|
|
130
|
+
qrUri,
|
|
131
|
+
onConnectWc: (w) => __async(void 0, null, function* () {
|
|
132
|
+
yield connectExternalWallet(w, true, true);
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
);
|
|
106
136
|
}
|
|
107
137
|
}, [wallet, walletDisplayHelpers, externalWalletError, qrUri]);
|
|
108
138
|
useEffect(() => {
|
|
@@ -140,5 +170,6 @@ const Link = safeStyled.a`
|
|
|
140
170
|
text-decoration: none;
|
|
141
171
|
`;
|
|
142
172
|
export {
|
|
173
|
+
ExternalWalletMobileConnect,
|
|
143
174
|
ExternalWalletStep
|
|
144
175
|
};
|
|
@@ -5,6 +5,7 @@ import { useModalStore } from "../../../stores/modal/useModalStore.js";
|
|
|
5
5
|
import { ModalStep } from "../../../utils/steps.js";
|
|
6
6
|
import { useExternalWallets } from "../../../../provider/providers/ExternalWalletProvider.js";
|
|
7
7
|
import { useStore } from "../../../../provider/stores/useStore.js";
|
|
8
|
+
import { useAccountLinking } from "../../../../provider/providers/AccountLinkProvider.js";
|
|
8
9
|
const useStepTitle = () => {
|
|
9
10
|
const hideWallets = useStore((state) => {
|
|
10
11
|
var _a;
|
|
@@ -13,6 +14,7 @@ const useStepTitle = () => {
|
|
|
13
14
|
const isLogin = useModalStore((state) => state.isLogin());
|
|
14
15
|
const currentStep = useModalStore((state) => state.step);
|
|
15
16
|
const { chainId } = useExternalWallets();
|
|
17
|
+
const { isEnabled: isAccountLinkingEnabled } = useAccountLinking();
|
|
16
18
|
const titles = useMemo(
|
|
17
19
|
() => ({
|
|
18
20
|
[ModalStep.AUTH_MAIN]: "",
|
|
@@ -44,7 +46,11 @@ const useStepTitle = () => {
|
|
|
44
46
|
[ModalStep.ADD_FUNDS_SUCCESS]: "",
|
|
45
47
|
[ModalStep.ADD_FUNDS_FAILURE]: "",
|
|
46
48
|
[ModalStep.ACCOUNT_MAIN]: "",
|
|
47
|
-
[ModalStep.CHAIN_SWITCH]: ""
|
|
49
|
+
[ModalStep.CHAIN_SWITCH]: "",
|
|
50
|
+
[ModalStep.ACCOUNT_PROFILE]: isAccountLinkingEnabled ? "Profile" : "Settings",
|
|
51
|
+
[ModalStep.ACCOUNT_PROFILE_LIST]: "Link Account",
|
|
52
|
+
[ModalStep.ACCOUNT_PROFILE_ADD]: "Link Account",
|
|
53
|
+
[ModalStep.ACCOUNT_PROFILE_REMOVE]: "Unlink Account"
|
|
48
54
|
}),
|
|
49
55
|
[isLogin, chainId, hideWallets]
|
|
50
56
|
);
|
|
@@ -5,9 +5,9 @@ import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from "@getpar
|
|
|
5
5
|
import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from "../common.js";
|
|
6
6
|
import { useModalStore } from "../../stores/index.js";
|
|
7
7
|
import { isMobile } from "@getpara/web-sdk";
|
|
8
|
-
|
|
8
|
+
function FarcasterConnectQR() {
|
|
9
9
|
const farcasterConnectUri = useModalStore((state) => state.farcasterConnectUri);
|
|
10
|
-
return /* @__PURE__ */ jsx(
|
|
10
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isMobile() ? /* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
11
11
|
/* @__PURE__ */ jsx(CpslText, { weight: "medium", color: "secondary", children: `Don\u2019t have Farcaster` }),
|
|
12
12
|
/* @__PURE__ */ jsxs(CpslButton, { as: "a", href: "https://link.warpcast.com/download-qr", target: "_blank", variant: "secondary", children: [
|
|
13
13
|
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "linkExternal" }),
|
|
@@ -20,8 +20,12 @@ const FarcasterOAuthStep = () => {
|
|
|
20
20
|
/* @__PURE__ */ jsx(QRContainer, { children: !farcasterConnectUri ? /* @__PURE__ */ jsx(CpslSpinner, { size: 100 }) : /* @__PURE__ */ jsx(CpslQrCode, { url: farcasterConnectUri }) })
|
|
21
21
|
] })
|
|
22
22
|
] }) });
|
|
23
|
+
}
|
|
24
|
+
const FarcasterOAuthStep = () => {
|
|
25
|
+
return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsx(FarcasterConnectQR, {}) });
|
|
23
26
|
};
|
|
24
27
|
var FarcasterOAuthStep_default = FarcasterOAuthStep;
|
|
25
28
|
export {
|
|
29
|
+
FarcasterConnectQR,
|
|
26
30
|
FarcasterOAuthStep_default as default
|
|
27
31
|
};
|
|
@@ -8,7 +8,7 @@ import { useModalStore } from "../../stores/index.js";
|
|
|
8
8
|
import { ModalStep } from "../../utils/steps.js";
|
|
9
9
|
import { getTileButtonFlex } from "../../utils/getTileButtonFlex.js";
|
|
10
10
|
import { StyledCpslTileButton } from "../common.js";
|
|
11
|
-
import {
|
|
11
|
+
import { ACCOUNT_TYPES } from "../../constants/oAuthLogos.js";
|
|
12
12
|
import { useStore } from "../../../provider/stores/useStore.js";
|
|
13
13
|
import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
|
|
14
14
|
const HAS_MORE_LENGTH = 3;
|
|
@@ -44,7 +44,7 @@ const OAuth = ({ methods }) => {
|
|
|
44
44
|
OAuthButton,
|
|
45
45
|
{
|
|
46
46
|
$isDark: useDarkLogos,
|
|
47
|
-
icon: useBrandedLogos ?
|
|
47
|
+
icon: ACCOUNT_TYPES[method][useBrandedLogos ? "logoBranded" : "logo"],
|
|
48
48
|
onClick: handleMethodClick(method),
|
|
49
49
|
$index: index,
|
|
50
50
|
$totalItems: showMoreButton ? HAS_MORE_LENGTH : methodsToShow.length
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export declare function TelegramOAuthStep(): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function TelegramIFrame({ url, isLoaded, setIsLoaded, isVisible, }: {
|
|
4
|
+
url?: string;
|
|
5
|
+
isLoaded: boolean;
|
|
6
|
+
setIsLoaded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
|
+
isVisible?: boolean;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,67 +1,51 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
__async
|
|
4
|
-
} from "../../../chunk-MMUBH76A.js";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
5
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { constructUrl, getPortalBaseURL } from "@getpara/web-sdk";
|
|
7
4
|
import { safeStyled } from "@getpara/react-common";
|
|
8
|
-
import { useEffect, useRef, useState } from "react";
|
|
9
5
|
import { HeroSpinner } from "@getpara/react-common";
|
|
10
6
|
import { CpslSpinner } from "@getpara/react-components";
|
|
11
|
-
import {
|
|
7
|
+
import { useTelegramLogin } from "../../hooks/useTelegramLogin.js";
|
|
12
8
|
import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
|
|
9
|
+
import { AccountTypeIcon } from "../common.js";
|
|
10
|
+
import { useModalStore } from "../../stores/index.js";
|
|
13
11
|
function TelegramOAuthStep() {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (!url) {
|
|
23
|
-
setUrl(
|
|
24
|
-
constructUrl({
|
|
25
|
-
base: getPortalBaseURL(para.ctx, true),
|
|
26
|
-
path: "/auth/telegram"
|
|
27
|
-
})
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}, [url]);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
const updateState = (event) => __async(this, null, function* () {
|
|
33
|
-
switch (event.data.type) {
|
|
34
|
-
case "TELEGRAM_LOGIN":
|
|
35
|
-
setIsWaiting(true);
|
|
36
|
-
setIsError(false);
|
|
37
|
-
break;
|
|
38
|
-
case "TELEGRAM_FAILED":
|
|
39
|
-
setIsWaiting(false);
|
|
40
|
-
setIsError(true);
|
|
41
|
-
break;
|
|
42
|
-
case "TELEGRAM_SUCCESS":
|
|
43
|
-
if (!!event.data.payload) {
|
|
44
|
-
const authObject = event.data.payload;
|
|
45
|
-
verifyTelegram(authObject);
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
window == null ? void 0 : window.addEventListener("message", updateState, false);
|
|
51
|
-
return () => {
|
|
52
|
-
window == null ? void 0 : window.removeEventListener("message", updateState, false);
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
12
|
+
const { verifyTelegramStatus, verifyTelegram } = useAuthActions();
|
|
13
|
+
const { url, status, isLoaded, setIsLoaded } = useTelegramLogin({
|
|
14
|
+
isActive: true,
|
|
15
|
+
status: verifyTelegramStatus,
|
|
16
|
+
onSubmit: verifyTelegram
|
|
17
|
+
});
|
|
18
|
+
const isError = status === "error", isPending = status === "pending";
|
|
55
19
|
return /* @__PURE__ */ jsxs(Container, { children: [
|
|
56
20
|
/* @__PURE__ */ jsx(HeroContainer, { children: /* @__PURE__ */ jsx(
|
|
57
21
|
HeroSpinner,
|
|
58
22
|
{
|
|
59
|
-
icon: "
|
|
60
|
-
status:
|
|
61
|
-
text:
|
|
23
|
+
icon: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType: "TELEGRAM", size: "48px" }),
|
|
24
|
+
status: isPending ? "pending" : isError ? "error" : "idle",
|
|
25
|
+
text: isPending ? "Follow the on-screen prompts." : isError ? "Login Failed" : void 0
|
|
62
26
|
}
|
|
63
27
|
) }),
|
|
64
|
-
|
|
28
|
+
/* @__PURE__ */ jsx(TelegramIFrame, { url, isLoaded, setIsLoaded, isVisible: isLoaded })
|
|
29
|
+
] });
|
|
30
|
+
}
|
|
31
|
+
function TelegramIFrame({
|
|
32
|
+
url,
|
|
33
|
+
isLoaded,
|
|
34
|
+
setIsLoaded,
|
|
35
|
+
isVisible = false
|
|
36
|
+
}) {
|
|
37
|
+
const refs = useModalStore((state) => state.refs);
|
|
38
|
+
if (!url) return null;
|
|
39
|
+
return /* @__PURE__ */ jsxs(Container, { children: [
|
|
40
|
+
url && /* @__PURE__ */ jsx(
|
|
41
|
+
IFrame,
|
|
42
|
+
{
|
|
43
|
+
ref: refs.telegramIFrame,
|
|
44
|
+
style: { display: isLoaded && isVisible ? "block" : "none" },
|
|
45
|
+
src: url,
|
|
46
|
+
onLoad: () => setIsLoaded(true)
|
|
47
|
+
}
|
|
48
|
+
),
|
|
65
49
|
(!url || !isLoaded) && /* @__PURE__ */ jsx(CpslSpinner, {})
|
|
66
50
|
] });
|
|
67
51
|
}
|
|
@@ -74,7 +58,6 @@ const Container = safeStyled.div`
|
|
|
74
58
|
`;
|
|
75
59
|
const HeroContainer = safeStyled.div`
|
|
76
60
|
display: flex;
|
|
77
|
-
min-height: 276px;
|
|
78
61
|
flex-direction: column;
|
|
79
62
|
align-items: center;
|
|
80
63
|
gap: 16px;
|
|
@@ -86,5 +69,6 @@ const IFrame = safeStyled.iframe`
|
|
|
86
69
|
border: none;
|
|
87
70
|
`;
|
|
88
71
|
export {
|
|
72
|
+
TelegramIFrame,
|
|
89
73
|
TelegramOAuthStep
|
|
90
74
|
};
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { AuthInfo } from '@getpara/user-management-client';
|
|
2
|
+
import { MutationStatus } from '@tanstack/react-query';
|
|
3
|
+
type Props = {
|
|
4
|
+
authInfo: AuthInfo<'email' | 'phone'>;
|
|
5
|
+
onSubmit: (_: string) => void;
|
|
6
|
+
onResend: () => void;
|
|
7
|
+
status: MutationStatus;
|
|
8
|
+
error?: Error | string | null;
|
|
9
|
+
};
|
|
10
|
+
export declare const VerificationCode: ({ authInfo, onResend, onSubmit, status, error }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const VerificationCodeStep: () => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
export {};
|
|
@@ -8,17 +8,13 @@ import { useEffect, useRef, useState } from "react";
|
|
|
8
8
|
import { safeStyled } from "@getpara/react-common";
|
|
9
9
|
import { Heading, InnerStepContainer, StepContainer } from "../common.js";
|
|
10
10
|
import { displayPhoneNumber } from "@getpara/core-sdk";
|
|
11
|
-
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
12
11
|
import { useAuthActions } from "../../../provider/providers/AuthProvider.js";
|
|
13
12
|
import { useResendVerificationCode } from "../../../provider/index.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const authInfo = para.authInfo;
|
|
17
|
-
const { verifyNewAccount, isVerifyNewAccountPending, verifyNewAccountError } = useAuthActions();
|
|
18
|
-
const { resendVerificationCode } = useResendVerificationCode();
|
|
13
|
+
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
14
|
+
const VerificationCode = ({ authInfo, onResend, onSubmit, status, error }) => {
|
|
19
15
|
const inputRef = useRef(null);
|
|
20
16
|
const [code, setCode] = useState("");
|
|
21
|
-
const [isPending, setIsPending] = useState(
|
|
17
|
+
const [isPending, setIsPending] = useState(status === "pending");
|
|
22
18
|
const [codeError, setCodeError] = useState(null);
|
|
23
19
|
const [resendDisabled, setResendDisabled] = useState(false);
|
|
24
20
|
const isEmail = (authInfo == null ? void 0 : authInfo.authType) === "email";
|
|
@@ -35,20 +31,20 @@ const VerificationCodeStep = () => {
|
|
|
35
31
|
}
|
|
36
32
|
}, [code]);
|
|
37
33
|
useEffect(() => {
|
|
38
|
-
if (
|
|
39
|
-
setIsPending(
|
|
34
|
+
if (status === "pending") {
|
|
35
|
+
setIsPending(true);
|
|
40
36
|
}
|
|
41
|
-
}, [
|
|
37
|
+
}, [status]);
|
|
42
38
|
const handleResendClick = () => __async(void 0, null, function* () {
|
|
43
39
|
if (!resendDisabled) {
|
|
44
40
|
setResendDisabled(true);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
41
|
+
try {
|
|
42
|
+
onResend();
|
|
43
|
+
} finally {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
setResendDisabled(false);
|
|
46
|
+
}, 3e3);
|
|
47
|
+
}
|
|
52
48
|
}
|
|
53
49
|
});
|
|
54
50
|
const handleCodeInput = (e) => {
|
|
@@ -56,16 +52,16 @@ const VerificationCodeStep = () => {
|
|
|
56
52
|
};
|
|
57
53
|
const handleSubmitCode = () => __async(void 0, null, function* () {
|
|
58
54
|
if (code.length === 6 && /^\d+$/.test(code)) {
|
|
59
|
-
|
|
55
|
+
onSubmit(code);
|
|
60
56
|
} else {
|
|
61
57
|
setCodeError("Incorrect code.");
|
|
62
58
|
}
|
|
63
59
|
});
|
|
64
60
|
useEffect(() => {
|
|
65
|
-
if (!!
|
|
61
|
+
if (!!error) {
|
|
66
62
|
setIsPending(false);
|
|
67
|
-
const
|
|
68
|
-
switch (
|
|
63
|
+
const status2 = error.status;
|
|
64
|
+
switch (status2) {
|
|
69
65
|
case 429:
|
|
70
66
|
setCodeError("Too many incorrect attempts. Please try again in 10 minutes.");
|
|
71
67
|
break;
|
|
@@ -74,8 +70,8 @@ const VerificationCodeStep = () => {
|
|
|
74
70
|
break;
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
|
-
}, [
|
|
78
|
-
return /* @__PURE__ */ jsxs(
|
|
73
|
+
}, [error]);
|
|
74
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
79
75
|
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
80
76
|
/* @__PURE__ */ jsxs(Heading, { variant: "headingS", weight: "bold", children: [
|
|
81
77
|
"Verify ",
|
|
@@ -127,6 +123,26 @@ const VerificationCodeStep = () => {
|
|
|
127
123
|
] }) })
|
|
128
124
|
] });
|
|
129
125
|
};
|
|
126
|
+
const VerificationCodeStep = () => {
|
|
127
|
+
const { verifyNewAccount, verifyNewAccountStatus, verifyNewAccountError } = useAuthActions();
|
|
128
|
+
const { mutateAsync: resendVerificationCode } = useResendVerificationCode();
|
|
129
|
+
const para = useInternalClient();
|
|
130
|
+
if (!para.authInfo) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return /* @__PURE__ */ jsx(StepContainer, { $wide: true, children: /* @__PURE__ */ jsx(
|
|
134
|
+
VerificationCode,
|
|
135
|
+
{
|
|
136
|
+
authInfo: para.authInfo,
|
|
137
|
+
onSubmit: verifyNewAccount,
|
|
138
|
+
onResend: () => {
|
|
139
|
+
resendVerificationCode({ type: "SIGNUP" });
|
|
140
|
+
},
|
|
141
|
+
status: verifyNewAccountStatus,
|
|
142
|
+
error: verifyNewAccountError
|
|
143
|
+
}
|
|
144
|
+
) });
|
|
145
|
+
};
|
|
130
146
|
const StyledCodeInput = safeStyled(CpslCodeInput)`
|
|
131
147
|
align-self: center;
|
|
132
148
|
`;
|
|
@@ -139,5 +155,6 @@ const ClickableText = safeStyled(InlineText)`
|
|
|
139
155
|
display: inline-block;
|
|
140
156
|
`;
|
|
141
157
|
export {
|
|
158
|
+
VerificationCode,
|
|
142
159
|
VerificationCodeStep
|
|
143
160
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CpslInput, CpslText, CpslTileButton } from '@getpara/react-components';
|
|
2
|
-
import { Network, OnRampAsset } from '@getpara/web-sdk';
|
|
2
|
+
import { Network, OnRampAsset, TExternalWallet, TLinkedAccountType } from '@getpara/web-sdk';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
3
4
|
export declare const SpinnerContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
5
|
export declare const QRContainer: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
5
6
|
export declare const InfoBoxContent: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -40,3 +41,19 @@ export declare const ErrorContainer: import("styled-components/dist/types.js").I
|
|
|
40
41
|
export declare const ErrorIcon: import("styled-components/dist/types.js").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<any, "ref"> & import("react").RefAttributes<any>, "ref"> & {
|
|
41
42
|
ref?: ((instance: any) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<any> | null | undefined;
|
|
42
43
|
}, never>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>, keyof import("react").Component<any, {}, any>>;
|
|
44
|
+
export declare function AccountTypeIcon({ accountType, size, inset, }: {
|
|
45
|
+
accountType?: TLinkedAccountType | TExternalWallet;
|
|
46
|
+
size?: string;
|
|
47
|
+
inset?: string;
|
|
48
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
49
|
+
export declare function HeroAccountTypeIcon({ accountType }: {
|
|
50
|
+
accountType: TLinkedAccountType | TExternalWallet;
|
|
51
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare function HeroSuccessIcon(): import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export declare function GradientScroll({ height, gap, children }: PropsWithChildren<{
|
|
54
|
+
gap?: string;
|
|
55
|
+
height?: string;
|
|
56
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export declare const HeroGenericIcon: ({ accountType }: {
|
|
58
|
+
accountType: "EMAIL" | "PHONE";
|
|
59
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,6 +5,8 @@ import { CpslIcon, CpslInput, CpslSelect, CpslSelectItem, CpslText, CpslTileButt
|
|
|
5
5
|
import { safeStyled } from "@getpara/react-common";
|
|
6
6
|
import { MOBILE_SIZE, NETWORKS, ON_RAMP_ASSETS } from "../constants/constants.js";
|
|
7
7
|
import { useStore } from "../../provider/stores/useStore.js";
|
|
8
|
+
import { ACCOUNT_TYPES } from "../constants/oAuthLogos.js";
|
|
9
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
10
|
const SpinnerContainer = safeStyled.div`
|
|
9
11
|
display: flex;
|
|
10
12
|
align-items: center;
|
|
@@ -152,18 +154,102 @@ const ErrorIcon = safeStyled(CpslIcon)`
|
|
|
152
154
|
--width: 16px;
|
|
153
155
|
--icon-color: var(--cpsl-color-text-error);
|
|
154
156
|
`;
|
|
157
|
+
function AccountTypeIcon({
|
|
158
|
+
accountType,
|
|
159
|
+
size,
|
|
160
|
+
inset
|
|
161
|
+
}) {
|
|
162
|
+
var _a;
|
|
163
|
+
const isDark = useStore((state) => {
|
|
164
|
+
var _a2, _b;
|
|
165
|
+
return ((_b = (_a2 = state.modalConfig) == null ? void 0 : _a2.theme) == null ? void 0 : _b.mode) === "dark";
|
|
166
|
+
});
|
|
167
|
+
const data = accountType ? ACCOUNT_TYPES[accountType] : null;
|
|
168
|
+
return data ? /* @__PURE__ */ jsx(CpslIcon, { size, inset, icon: (_a = data.logoBranded) != null ? _a : data.logo, invert: isDark && data.isDark }) : null;
|
|
169
|
+
}
|
|
170
|
+
function HeroAccountTypeIcon({ accountType }) {
|
|
171
|
+
if (accountType === "EMAIL" || accountType === "PHONE") {
|
|
172
|
+
return /* @__PURE__ */ jsx(HeroGenericIcon, { accountType });
|
|
173
|
+
}
|
|
174
|
+
return /* @__PURE__ */ jsx(AccountTypeIcon, { accountType, size: "60px" });
|
|
175
|
+
}
|
|
176
|
+
function HeroSuccessIcon() {
|
|
177
|
+
return /* @__PURE__ */ jsx(CpslIcon, { icon: "checkCircleFilled", size: "80px", style: { ["--icon-color"]: "var(--cpsl-color-utility-green" } });
|
|
178
|
+
}
|
|
179
|
+
function GradientScroll({ height, gap, children }) {
|
|
180
|
+
const [isNotAtBottom, setIsNotAtBottom] = useState(false);
|
|
181
|
+
const [isNotAtTop, setIsNotAtTop] = useState(false);
|
|
182
|
+
const ref = useRef(null);
|
|
183
|
+
const onScroll = () => {
|
|
184
|
+
if (ref.current) {
|
|
185
|
+
const { scrollTop, scrollHeight, clientHeight } = ref.current;
|
|
186
|
+
if (height && scrollHeight <= parseInt(height)) {
|
|
187
|
+
setIsNotAtTop(false);
|
|
188
|
+
setIsNotAtBottom(false);
|
|
189
|
+
} else {
|
|
190
|
+
setIsNotAtTop(scrollTop > 30);
|
|
191
|
+
setIsNotAtBottom(scrollTop + clientHeight < scrollHeight - 30);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
onScroll();
|
|
197
|
+
}, []);
|
|
198
|
+
return /* @__PURE__ */ jsx(
|
|
199
|
+
GradientScrollContainer,
|
|
200
|
+
{
|
|
201
|
+
ref,
|
|
202
|
+
height,
|
|
203
|
+
gap,
|
|
204
|
+
isNotAtBottom,
|
|
205
|
+
isNotAtTop,
|
|
206
|
+
onScroll,
|
|
207
|
+
children: /* @__PURE__ */ jsx("div", { children })
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
const HeroGenericIcon = ({ accountType }) => {
|
|
212
|
+
return /* @__PURE__ */ jsx(Avatar, { children: /* @__PURE__ */ jsx(AccountTypeIcon, { accountType, size: "24px" }) });
|
|
213
|
+
};
|
|
214
|
+
const GradientScrollContainer = safeStyled.div`
|
|
215
|
+
max-height: ${({ height }) => height || "100%"};
|
|
216
|
+
width: 100%;
|
|
217
|
+
overflow-y: auto;
|
|
218
|
+
mask-image: ${({ isNotAtBottom, isNotAtTop }) => isNotAtBottom && isNotAtTop ? "linear-gradient(to bottom, transparent 0%, black 24px, black calc(100% - 24px), transparent 100%)" : isNotAtBottom ? "linear-gradient(to bottom, black calc(100% - 24px), transparent 100%)" : isNotAtTop ? "linear-gradient(to top, black calc(100% - 24px), transparent 100%)" : "none"};
|
|
219
|
+
|
|
220
|
+
& > div {
|
|
221
|
+
width: 100%;
|
|
222
|
+
display: flex;
|
|
223
|
+
flex-direction: column;
|
|
224
|
+
gap: ${({ gap }) => gap || "8px"};
|
|
225
|
+
}
|
|
226
|
+
`;
|
|
227
|
+
const Avatar = safeStyled.div`
|
|
228
|
+
width: 80px;
|
|
229
|
+
height: 80px;
|
|
230
|
+
border-radius: 100%;
|
|
231
|
+
display: flex;
|
|
232
|
+
align-items: center;
|
|
233
|
+
justify-content: center;
|
|
234
|
+
background-color: var(--cpsl-color-background-8);
|
|
235
|
+
`;
|
|
155
236
|
export {
|
|
237
|
+
AccountTypeIcon,
|
|
156
238
|
AssetIcon,
|
|
157
239
|
CenteredText,
|
|
158
240
|
ErrorContainer,
|
|
159
241
|
ErrorIcon,
|
|
160
242
|
FilledDisabledInput,
|
|
161
243
|
FullWidthFilledDisabledInput,
|
|
244
|
+
GradientScroll,
|
|
162
245
|
HeaderSelect,
|
|
163
246
|
HeaderSelectContainer,
|
|
164
247
|
HeaderSelectItem,
|
|
165
248
|
Heading,
|
|
249
|
+
HeroAccountTypeIcon,
|
|
250
|
+
HeroGenericIcon,
|
|
166
251
|
HeroIcon,
|
|
252
|
+
HeroSuccessIcon,
|
|
167
253
|
InfoBoxContent,
|
|
168
254
|
InfoBoxHeader,
|
|
169
255
|
InnerStepContainer,
|