@getpara/react-sdk 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MoonPayEmbed-GAWXP6V7.js +2 -0
- package/dist/MoonPayEmbed-GAWXP6V7.js.br +0 -0
- package/dist/MoonPayEmbed-GAWXP6V7.js.gz +0 -0
- package/dist/index.js +675 -5
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/provider/hooks/utils/useEventListeners.d.ts +1 -1
- package/dist/provider/stores/useStore.d.ts +7 -2
- package/dist/provider/types/provider.d.ts +15 -3
- package/package.json +8 -7
- package/dist/modal/ParaModal.js +0 -281
- package/dist/modal/components/Account/Account.js +0 -60
- package/dist/modal/components/AddFunds/AddFunds.js +0 -147
- package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -65
- package/dist/modal/components/AddFunds/AddFundsDone.js +0 -26
- package/dist/modal/components/AddFunds/MoonPayEmbed.js +0 -2
- package/dist/modal/components/AddFunds/index.js +0 -3
- package/dist/modal/components/AuthInput/AuthInput.js +0 -221
- package/dist/modal/components/AuthInput/countryCodes.js +0 -40
- package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -23
- package/dist/modal/components/AuthInput/phoneMasks.js +0 -247
- package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -21
- package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -89
- package/dist/modal/components/AuthOptions/AuthOptions.js +0 -28
- package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -7
- package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -5
- package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -7
- package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -18
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -17
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -131
- package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -26
- package/dist/modal/components/Body/Body.js +0 -232
- package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -77
- package/dist/modal/components/ChainSwitch/config.js +0 -11
- package/dist/modal/components/Controls/Controls.js +0 -54
- package/dist/modal/components/Controls/Selects.js +0 -159
- package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -116
- package/dist/modal/components/ExternalWalletStep/config.js +0 -11
- package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -142
- package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -119
- package/dist/modal/components/Footer/Footer.js +0 -71
- package/dist/modal/components/Header/Header.js +0 -24
- package/dist/modal/components/Header/hooks/useStepTitle.js +0 -42
- package/dist/modal/components/Hero/Hero.js +0 -119
- package/dist/modal/components/IFrameStep/IFrameStep.js +0 -41
- package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -19
- package/dist/modal/components/ModalContent/ModalContent.js +0 -280
- package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -82
- package/dist/modal/components/OAuth/OAuth.js +0 -125
- package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -133
- package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -10
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -72
- package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -67
- package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -105
- package/dist/modal/components/StripeComponents/StripeComponents.js +0 -78
- package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -8
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -135
- package/dist/modal/components/Waiting/Waiting.js +0 -6
- package/dist/modal/components/WalletCard/PartnerIcon.js +0 -29
- package/dist/modal/components/WalletCard/WalletCard.js +0 -93
- package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -50
- package/dist/modal/components/common.js +0 -67
- package/dist/modal/components/index.js +0 -1
- package/dist/modal/constants/constants.js +0 -93
- package/dist/modal/constants/defaults.js +0 -5
- package/dist/modal/constants/oAuthLogos.js +0 -18
- package/dist/modal/hooks/useActiveWallet.js +0 -11
- package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -46
- package/dist/modal/hooks/useGoBack.js +0 -34
- package/dist/modal/index.js +0 -9
- package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -18
- package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -22
- package/dist/modal/providers/ExternalWalletContext.js +0 -253
- package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -12
- package/dist/modal/stores/externalWalletProvider/actions.js +0 -5
- package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -13
- package/dist/modal/stores/index.js +0 -3
- package/dist/modal/stores/modal/actions.js +0 -64
- package/dist/modal/stores/modal/useModalStore.js +0 -41
- package/dist/modal/stores/para/actions.js +0 -5
- package/dist/modal/stores/para/useParaStore.js +0 -3
- package/dist/modal/stores/theme/actions.js +0 -24
- package/dist/modal/stores/theme/useThemeStore.js +0 -14
- package/dist/modal/stores/userInfo/actions.js +0 -34
- package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -9
- package/dist/modal/types/commonTypes.js +0 -1
- package/dist/modal/types/externalWallets.js +0 -21
- package/dist/modal/types/modalProps.js +0 -7
- package/dist/modal/utils/authLayoutHelpers.js +0 -2
- package/dist/modal/utils/getMailtoLink.js +0 -5
- package/dist/modal/utils/getTileButtonFlex.js +0 -15
- package/dist/modal/utils/isPasskeySupported.js +0 -10
- package/dist/modal/utils/openPopup.js +0 -55
- package/dist/modal/utils/routeMobileExternalWallet.js +0 -35
- package/dist/modal/utils/steps.js +0 -215
- package/dist/modal/utils/stringFormatters.js +0 -12
- package/dist/modal/utils/validateOnRampConfig.js +0 -26
- package/dist/provider/ParaProvider.js +0 -16
- package/dist/provider/actions/checkIfUserExists.js +0 -26
- package/dist/provider/actions/createUser.js +0 -30
- package/dist/provider/actions/getAccount.js +0 -24
- package/dist/provider/actions/getWallet.js +0 -16
- package/dist/provider/actions/initiateLogin.js +0 -23
- package/dist/provider/actions/keepSessionAlive.js +0 -23
- package/dist/provider/actions/logout.js +0 -20
- package/dist/provider/actions/signMessage.js +0 -23
- package/dist/provider/actions/signTransaction.js +0 -23
- package/dist/provider/actions/waitForAccountCreation.js +0 -24
- package/dist/provider/actions/waitForLoginAndSetup.js +0 -27
- package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -24
- package/dist/provider/hooks/index.js +0 -3
- package/dist/provider/hooks/mutations/index.js +0 -10
- package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
- package/dist/provider/hooks/mutations/useCreateUser.js +0 -23
- package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
- package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -23
- package/dist/provider/hooks/mutations/useLogout.js +0 -33
- package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
- package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
- package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
- package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
- package/dist/provider/hooks/queries/index.js +0 -2
- package/dist/provider/hooks/queries/useAccount.js +0 -23
- package/dist/provider/hooks/queries/useWallet.js +0 -24
- package/dist/provider/hooks/utils/index.js +0 -3
- package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -79
- package/dist/provider/hooks/utils/useClient.js +0 -8
- package/dist/provider/hooks/utils/useEventListeners.js +0 -87
- package/dist/provider/hooks/utils/useInternalClient.js +0 -9
- package/dist/provider/hooks/utils/useModal.js +0 -15
- package/dist/provider/hooks/utils/useWalletState.js +0 -33
- package/dist/provider/index.js +0 -3
- package/dist/provider/stores/getters.js +0 -5
- package/dist/provider/stores/slices/client.js +0 -4
- package/dist/provider/stores/slices/index.js +0 -3
- package/dist/provider/stores/slices/modal.js +0 -4
- package/dist/provider/stores/slices/wallet.js +0 -6
- package/dist/provider/stores/types.js +0 -1
- package/dist/provider/stores/useStore.js +0 -12
- 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/renameMutations.js +0 -19
- /package/dist/{modal/css → css}/modal.css +0 -0
- /package/dist/{modal/public → public}/Inter-VariableFont_slnt,wght.ttf +0 -0
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
12
|
-
import { entityToWallet, OnRampProvider, OnRampAsset, Network, EnabledFlow, } from '@getpara/web-sdk';
|
|
13
|
-
import { useModalStore, useUserInfoStore } from '../../stores/index.js';
|
|
14
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
15
|
-
import { Body } from '../Body/Body.js';
|
|
16
|
-
import { Footer } from '../Footer/Footer.js';
|
|
17
|
-
import { DEFAULTS } from '../../constants/defaults.js';
|
|
18
|
-
import { useGoBack } from '../../hooks/useGoBack.js';
|
|
19
|
-
import { openPopup } from '../../utils/openPopup.js';
|
|
20
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
21
|
-
import { useEmbeddedExternalConnection } from '../../hooks/useEmbeddedExternalConnection.js';
|
|
22
|
-
function isRampConfig(config) {
|
|
23
|
-
return 'hostApiKey' in config;
|
|
24
|
-
}
|
|
25
|
-
const AssetNetworks = {
|
|
26
|
-
[OnRampAsset.SOLANA]: Network.SOLANA,
|
|
27
|
-
[OnRampAsset.ATOM]: Network.COSMOS,
|
|
28
|
-
[OnRampAsset.CELO]: Network.CELO,
|
|
29
|
-
[OnRampAsset.POLYGON]: Network.POLYGON,
|
|
30
|
-
};
|
|
31
|
-
const AssetMap = {
|
|
32
|
-
SOLANA: OnRampAsset.SOLANA,
|
|
33
|
-
SOL: OnRampAsset.SOLANA,
|
|
34
|
-
ATOM: OnRampAsset.ATOM,
|
|
35
|
-
CELO: OnRampAsset.CELO,
|
|
36
|
-
POLYGON: OnRampAsset.POLYGON,
|
|
37
|
-
MATIC: OnRampAsset.POLYGON,
|
|
38
|
-
USDC: OnRampAsset.USDC,
|
|
39
|
-
ETH: OnRampAsset.ETHEREUM,
|
|
40
|
-
ETHEREUM: OnRampAsset.ETHEREUM,
|
|
41
|
-
};
|
|
42
|
-
export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFactorAuthEnabled = false, recoverySecretStepEnabled = false, oAuthMethods, disableEmailLogin, disablePhoneLogin, onClose, onRampTestMode, loginTransitionOverride, createWalletOverride, }, ref) => {
|
|
43
|
-
const para = useInternalClient();
|
|
44
|
-
const currentStep = useModalStore(state => state.step);
|
|
45
|
-
const webAuthURLForLogin = useModalStore(state => state.webAuthURLForLogin);
|
|
46
|
-
const webAuthURLForCreate = useModalStore(state => state.webAuthURLForCreate);
|
|
47
|
-
const passwordUrlForLogin = useModalStore(state => state.passwordUrlForLogin);
|
|
48
|
-
const isLogin = useModalStore(state => state.isLogin());
|
|
49
|
-
const popupWindow = useModalStore(state => state.popupWindow);
|
|
50
|
-
const onRampConfig = useModalStore(state => state.onRampConfig);
|
|
51
|
-
const setStep = useModalStore(state => state.setStep);
|
|
52
|
-
const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
|
|
53
|
-
const setWebAuthURLForLogin = useModalStore(state => state.setWebAuthURLForLogin);
|
|
54
|
-
const setWebAuthURLForCreate = useModalStore(state => state.setWebAuthURLForCreate);
|
|
55
|
-
const setPopupWindow = useModalStore(state => state.setPopupWindow);
|
|
56
|
-
const setIFrameUrl = useModalStore(state => state.setIFrameUrl);
|
|
57
|
-
const setPasswordUrlForLogin = useModalStore(state => state.setPasswordUrlForLogin);
|
|
58
|
-
const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
|
|
59
|
-
const setOnRampConfig = useModalStore(state => state.setOnRampConfig);
|
|
60
|
-
const accountAddFundTab = useModalStore(state => state.accountAddFundTab);
|
|
61
|
-
const setAccountAddFundTab = useModalStore(state => state.setAccountAddFundTab);
|
|
62
|
-
const setRecoveryShare = useUserInfoStore(state => state.setRecoveryShare);
|
|
63
|
-
const goBack = useGoBack();
|
|
64
|
-
const loginTimeout = useRef();
|
|
65
|
-
const createAccountTimeout = useRef();
|
|
66
|
-
const [walletCreationInProgress, setWalletCreationInProgress] = useState(false);
|
|
67
|
-
const connectEmbeddedToExternalConnectors = useEmbeddedExternalConnection();
|
|
68
|
-
useImperativeHandle(ref, () => {
|
|
69
|
-
return {
|
|
70
|
-
handleModalClose() {
|
|
71
|
-
handleClose();
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}, []);
|
|
75
|
-
const is2FASetup = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
-
if (!twoFactorAuthEnabled) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
const { isSetup } = yield para.check2FAStatus();
|
|
81
|
-
return isSetup;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
console.error('An error occurred while checking 2FA:', error);
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
function awaitLoginTransition() {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
// TODO: migrate to useWaitForLoginAndSetup hook once we force the use of the CapsuleProvider
|
|
91
|
-
const { isComplete, isError, needsWallet } = yield para.waitForLoginAndSetup({ popupWindow });
|
|
92
|
-
setPopupWindow(undefined);
|
|
93
|
-
if (isError) {
|
|
94
|
-
goBack();
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (isComplete) {
|
|
98
|
-
setWebAuthURLForLogin('');
|
|
99
|
-
setPasswordUrlForLogin('');
|
|
100
|
-
setSupportedAuthMethods(new Set());
|
|
101
|
-
setBiometricLocationHints();
|
|
102
|
-
if (needsWallet) {
|
|
103
|
-
setStep(ModalStep.AWAITING_WALLET_CREATION);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
yield connectEmbeddedToExternalConnectors();
|
|
107
|
-
if (yield is2FASetup()) {
|
|
108
|
-
setStep(ModalStep.LOGIN_DONE);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
setStep(ModalStep.SETUP_2FA);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function awaitWalletCreationTransition() {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
// TODO: migrate to useWaitForAccountCreation hook once we force the use of the ParaProvider
|
|
120
|
-
const isComplete = yield para.waitForAccountCreation();
|
|
121
|
-
if (isComplete) {
|
|
122
|
-
setWebAuthURLForCreate('');
|
|
123
|
-
setIFrameUrl('');
|
|
124
|
-
setStep(ModalStep.AWAITING_WALLET_CREATION);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
// generate/claim wallet once we know it's account creation
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (currentStep !== ModalStep.AWAITING_WALLET_CREATION || walletCreationInProgress) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
function genWallet() {
|
|
134
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
setWalletCreationInProgress(true);
|
|
136
|
-
let recoverySecret, walletIds;
|
|
137
|
-
if (!createWalletOverride) {
|
|
138
|
-
// TODO: migrate to useWaitForPasskeyAndCreateWallet hook once we force the use of the ParaProvider
|
|
139
|
-
const created = yield para.waitForPasskeyAndCreateWallet();
|
|
140
|
-
recoverySecret = created.recoverySecret;
|
|
141
|
-
walletIds = created.walletIds;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
const created = yield createWalletOverride(para);
|
|
145
|
-
const fetchedWallets = (yield para.fetchWallets()).filter(wallet => !!wallet.address);
|
|
146
|
-
const newWallets = {};
|
|
147
|
-
for (const wallet of fetchedWallets) {
|
|
148
|
-
newWallets[wallet.id] = Object.assign(Object.assign({}, entityToWallet(wallet)), { signer: '' });
|
|
149
|
-
}
|
|
150
|
-
para.setWallets(newWallets);
|
|
151
|
-
recoverySecret = created.recoverySecret;
|
|
152
|
-
walletIds = created.walletIds;
|
|
153
|
-
}
|
|
154
|
-
yield para.setCurrentWalletIds(walletIds);
|
|
155
|
-
if (recoverySecretStepEnabled) {
|
|
156
|
-
setRecoveryShare(recoverySecret);
|
|
157
|
-
}
|
|
158
|
-
setWalletCreationInProgress(false);
|
|
159
|
-
if (!recoverySecret || !recoverySecretStepEnabled) {
|
|
160
|
-
setStep(ModalStep.WALLET_CREATION_DONE);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
setStep(ModalStep.SECRET);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
genWallet();
|
|
168
|
-
}, [isLogin, currentStep]);
|
|
169
|
-
function createAccountWithPassword() {
|
|
170
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
clearTimeout(createAccountTimeout.current);
|
|
172
|
-
createAccountTimeout.current = window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS);
|
|
173
|
-
setStep(ModalStep.PASSWORD_CREATION);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
function createAccountWithPasskey() {
|
|
177
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
clearTimeout(createAccountTimeout.current);
|
|
179
|
-
createAccountTimeout.current = window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS);
|
|
180
|
-
openPopup(webAuthURLForCreate, 'ParaPasskey', 'CREATE_PASSKEY');
|
|
181
|
-
setStep(ModalStep.AWAITING_BIOMETRIC_CREATION);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
// wait for login auth to do post login setup
|
|
185
|
-
useEffect(() => {
|
|
186
|
-
if (webAuthURLForLogin || passwordUrlForLogin) {
|
|
187
|
-
if (loginTransitionOverride) {
|
|
188
|
-
function loginOverride() {
|
|
189
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
yield loginTransitionOverride(para);
|
|
191
|
-
setWebAuthURLForLogin('');
|
|
192
|
-
setPasswordUrlForLogin('');
|
|
193
|
-
setBiometricLocationHints();
|
|
194
|
-
yield connectEmbeddedToExternalConnectors();
|
|
195
|
-
if (yield is2FASetup()) {
|
|
196
|
-
setStep(ModalStep.LOGIN_DONE);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
setStep(ModalStep.SETUP_2FA);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
loginOverride();
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
loginTimeout.current = window.setTimeout(awaitLoginTransition, DEFAULTS.LOGGIN_POLLING_DELAY_MS);
|
|
207
|
-
}
|
|
208
|
-
return () => {
|
|
209
|
-
window.clearTimeout(loginTimeout.current);
|
|
210
|
-
para.exitLogin();
|
|
211
|
-
};
|
|
212
|
-
}, [webAuthURLForLogin, passwordUrlForLogin, popupWindow]);
|
|
213
|
-
const handleClose = () => {
|
|
214
|
-
onClose();
|
|
215
|
-
};
|
|
216
|
-
useEffect(() => {
|
|
217
|
-
if (![ModalStep.BIOMETRIC_CREATION, ModalStep.AWAITING_BIOMETRIC_CREATION].includes(currentStep)) {
|
|
218
|
-
para.exitAccountCreation();
|
|
219
|
-
}
|
|
220
|
-
if (![ModalStep.BIOMETRIC_LOGIN, ModalStep.AWAITING_BIOMETRIC_LOGIN].includes(currentStep)) {
|
|
221
|
-
para.exitLogin();
|
|
222
|
-
}
|
|
223
|
-
if (![ModalStep.AWAITING_OAUTH, ModalStep.FARCASTER_OAUTH].includes(currentStep)) {
|
|
224
|
-
para.exitOAuth();
|
|
225
|
-
}
|
|
226
|
-
}, [currentStep]);
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
if (!onRampConfig) {
|
|
229
|
-
para.ctx.client
|
|
230
|
-
.getOnRampConfig()
|
|
231
|
-
.then(res => {
|
|
232
|
-
var _a, _b;
|
|
233
|
-
let newOnRampConfig;
|
|
234
|
-
if (!!propsOnRampConfig) {
|
|
235
|
-
const { enabledFlows, network, asset, providers, testMode } = propsOnRampConfig;
|
|
236
|
-
const rampConfig = providers.find(config => isRampConfig(config));
|
|
237
|
-
newOnRampConfig = {
|
|
238
|
-
isBuyEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.BUY),
|
|
239
|
-
isReceiveEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.RECEIVE),
|
|
240
|
-
isWithdrawEnabled: !enabledFlows || enabledFlows.some(str => EnabledFlow[str] === EnabledFlow.WITHDRAW),
|
|
241
|
-
allowedAssets: network
|
|
242
|
-
? { [Network[network]]: asset ? [AssetMap[asset]] : true }
|
|
243
|
-
: asset
|
|
244
|
-
? { [(_a = AssetNetworks[AssetMap[asset]]) !== null && _a !== void 0 ? _a : Network.ETHEREUM]: [AssetMap[asset]] }
|
|
245
|
-
: res.allowedAssets,
|
|
246
|
-
assetInfo: res.assetInfo,
|
|
247
|
-
providers: providers.map(({ id }) => OnRampProvider[id]),
|
|
248
|
-
rampApiKey: (_b = rampConfig === null || rampConfig === void 0 ? void 0 : rampConfig.hostApiKey) !== null && _b !== void 0 ? _b : res.rampApiKey,
|
|
249
|
-
testMode: testMode !== null && testMode !== void 0 ? testMode : onRampTestMode,
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
newOnRampConfig = Object.assign(Object.assign({}, res), { testMode: onRampTestMode });
|
|
254
|
-
}
|
|
255
|
-
setOnRampConfig(newOnRampConfig);
|
|
256
|
-
if (!accountAddFundTab) {
|
|
257
|
-
setAccountAddFundTab(newOnRampConfig.isBuyEnabled
|
|
258
|
-
? EnabledFlow.BUY
|
|
259
|
-
: newOnRampConfig.isReceiveEnabled
|
|
260
|
-
? EnabledFlow.RECEIVE
|
|
261
|
-
: newOnRampConfig.isWithdrawEnabled
|
|
262
|
-
? EnabledFlow.WITHDRAW
|
|
263
|
-
: undefined);
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
.catch();
|
|
267
|
-
}
|
|
268
|
-
}, []);
|
|
269
|
-
useEffect(() => {
|
|
270
|
-
if (!!onRampConfig) {
|
|
271
|
-
setOnRampConfig(Object.assign(Object.assign({}, onRampConfig), { testMode: onRampTestMode }));
|
|
272
|
-
}
|
|
273
|
-
}, [onRampTestMode]);
|
|
274
|
-
useEffect(() => {
|
|
275
|
-
return () => {
|
|
276
|
-
para.exitLoops();
|
|
277
|
-
};
|
|
278
|
-
}, []);
|
|
279
|
-
return (_jsxs(_Fragment, { children: [_jsx(Body, { oAuthMethods: oAuthMethods, twoFactorAuthEnabled: twoFactorAuthEnabled, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin, onClose: handleClose, createAccountWithPasskey: createAccountWithPasskey, createAccountWithPassword: createAccountWithPassword }), _jsx(Footer, {})] }));
|
|
280
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
-
import { useEffect, useState } from 'react';
|
|
12
|
-
import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from '@getpara/react-components';
|
|
13
|
-
import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
|
|
14
|
-
import { useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
|
|
15
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
16
|
-
import { AuthMethod, isMobile } from '@getpara/web-sdk';
|
|
17
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
18
|
-
const FarcasterOAuthStep = () => {
|
|
19
|
-
const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
|
|
20
|
-
const setStep = useModalStore(state => state.setStep);
|
|
21
|
-
const setWebAuthURLForCreate = useModalStore(state => state.setWebAuthURLForCreate);
|
|
22
|
-
const setIFrameUrl = useModalStore(state => state.setIFrameUrl);
|
|
23
|
-
const setIsIFrameReady = useModalStore(state => state.setIsIFrameReady);
|
|
24
|
-
const isIFrameReady = useModalStore(state => state.isIFrameReady);
|
|
25
|
-
const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
|
|
26
|
-
const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
|
|
27
|
-
const para = useInternalClient();
|
|
28
|
-
const setFlow = useModalStore(state => state.setFlow);
|
|
29
|
-
const farcasterConnectUri = useModalStore(state => state.farcasterConnectUri);
|
|
30
|
-
const setFarcasterConnectUri = useModalStore(state => state.setFarcasterConnectUri);
|
|
31
|
-
const theme = useThemeStore(state => state.theme);
|
|
32
|
-
const [shouldRouteToStep, setShouldRouteToStep] = useState();
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (!!shouldRouteToStep && isIFrameReady) {
|
|
35
|
-
// Using a small timeout here to fully ensure the iframe is loaded before triggering any animation
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
setStep(shouldRouteToStep);
|
|
38
|
-
}, 200);
|
|
39
|
-
}
|
|
40
|
-
}, [shouldRouteToStep, isIFrameReady]);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (farcasterConnectUri) {
|
|
43
|
-
const pollStatus = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
const { userExists, username, pfpUrl } = yield para.waitForFarcasterStatus();
|
|
45
|
-
setAuthInfo({ farcasterUsername: username, pfpUrl });
|
|
46
|
-
setStep(ModalStep.AWAITING_OAUTH);
|
|
47
|
-
if (userExists) {
|
|
48
|
-
const supportedAuthMethods = yield para.initiateUserLoginV2({ farcasterUsername: username });
|
|
49
|
-
if (supportedAuthMethods.size > 0) {
|
|
50
|
-
setSupportedAuthMethods(supportedAuthMethods);
|
|
51
|
-
const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
|
|
52
|
-
? yield para.getUserBiometricLocationHints()
|
|
53
|
-
: [];
|
|
54
|
-
setFlow('login');
|
|
55
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
56
|
-
setBiometricLocationHints(biometricLocationHints);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const supportedCreateAuthMethods = yield para.getSupportedCreateAuthMethods();
|
|
61
|
-
setIsIFrameReady(false);
|
|
62
|
-
setFlow('signUp');
|
|
63
|
-
const supportsPasskey = supportedCreateAuthMethods.has(AuthMethod.PASSKEY);
|
|
64
|
-
if (supportsPasskey) {
|
|
65
|
-
setWebAuthURLForCreate(yield para.shortenLoginLink(yield para.getSetUpBiometricsURL({ authType: 'farcaster' })));
|
|
66
|
-
setStep(ModalStep.BIOMETRIC_CREATION);
|
|
67
|
-
}
|
|
68
|
-
if (supportedCreateAuthMethods.has(AuthMethod.PASSWORD)) {
|
|
69
|
-
setIFrameUrl(yield para.shortenLoginLink(yield para.getSetupPasswordURL({ authType: 'farcaster', theme })));
|
|
70
|
-
setShouldRouteToStep(supportsPasskey ? ModalStep.BIOMETRIC_CREATION : ModalStep.PASSWORD_CREATION);
|
|
71
|
-
}
|
|
72
|
-
return;
|
|
73
|
-
});
|
|
74
|
-
pollStatus();
|
|
75
|
-
return () => {
|
|
76
|
-
setFarcasterConnectUri(undefined);
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}, [farcasterConnectUri]);
|
|
80
|
-
return (_jsx(StepContainer, { "$wide": true, children: isMobile() ? (_jsxs(InnerStepContainer, { children: [_jsx(CpslText, { weight: "medium", color: "secondary", children: `Don’t have Farcaster` }), _jsxs(CpslButton, { as: "a", href: 'https://link.warpcast.com/download-qr', target: "_blank", variant: "secondary", children: [_jsx(CpslIcon, { slot: "start", icon: "linkExternal" }), `Get Farcaster`] })] })) : (_jsxs(_Fragment, { children: [_jsx(Heading, { variant: "headingS", weight: "bold", children: "Sign in using Farcaster" }), _jsxs(InnerStepContainer, { children: [_jsx(CenteredText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan the QR code with your phone's camera to proceed." }), _jsx(QRContainer, { children: !farcasterConnectUri ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: farcasterConnectUri }) })] })] })) }));
|
|
81
|
-
};
|
|
82
|
-
export default FarcasterOAuthStep;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { AuthMethod, OAuthMethod } from '@getpara/web-sdk';
|
|
12
|
-
import { styled } from 'styled-components';
|
|
13
|
-
import { useModalStore, useUserInfoStore } from '../../stores/index.js';
|
|
14
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
15
|
-
import { openPopup } from '../../utils/openPopup.js';
|
|
16
|
-
import { useThemeStore } from '../../stores/theme/useThemeStore.js';
|
|
17
|
-
import { getTileButtonFlex } from '../../utils/getTileButtonFlex.js';
|
|
18
|
-
import { StyledCpslTileButton } from '../common.js';
|
|
19
|
-
import { brandedOAuthLogos, oAuthLogos } from '../../constants/oAuthLogos.js';
|
|
20
|
-
import { useEffect } from 'react';
|
|
21
|
-
import { routeMobileExternalWallet } from '../../utils/routeMobileExternalWallet.js';
|
|
22
|
-
import { useGoBack } from '../../hooks/useGoBack.js';
|
|
23
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
24
|
-
const HAS_MORE_LENGTH = 3;
|
|
25
|
-
export const OAuth = ({ methods }) => {
|
|
26
|
-
const goBack = useGoBack();
|
|
27
|
-
const oAuthLogoVariant = useThemeStore(state => state.oAuthLogoVariant);
|
|
28
|
-
const isDark = useThemeStore(state => state.isDark);
|
|
29
|
-
const para = useInternalClient();
|
|
30
|
-
const popupWindow = useModalStore(state => state.popupWindow);
|
|
31
|
-
const setFlow = useModalStore(state => state.setFlow);
|
|
32
|
-
const setStep = useModalStore(state => state.setStep);
|
|
33
|
-
const setPopupWindow = useModalStore(state => state.setPopupWindow);
|
|
34
|
-
const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
|
|
35
|
-
const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
|
|
36
|
-
const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
|
|
37
|
-
const setFarcasterConnectUri = useModalStore(state => state.setFarcasterConnectUri);
|
|
38
|
-
const farcasterConnectUri = useModalStore(state => state.farcasterConnectUri);
|
|
39
|
-
const showAll = useModalStore(state => state.step === ModalStep.AUTH_MORE);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
const initializeFarcaster = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
if (!methods.includes(OAuthMethod.FARCASTER)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const connectUri = yield para.getFarcasterConnectURL();
|
|
46
|
-
setFarcasterConnectUri(connectUri);
|
|
47
|
-
});
|
|
48
|
-
initializeFarcaster();
|
|
49
|
-
}, []);
|
|
50
|
-
const hasMore = methods.length > HAS_MORE_LENGTH;
|
|
51
|
-
const methodsToShow = showAll || !hasMore ? methods : methods.slice(0, HAS_MORE_LENGTH - 1);
|
|
52
|
-
const handleShowAll = () => {
|
|
53
|
-
setStep(ModalStep.AUTH_MORE);
|
|
54
|
-
};
|
|
55
|
-
const handleMethodClick = (method) => () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
if (!!popupWindow) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
switch (method) {
|
|
60
|
-
case OAuthMethod.FARCASTER:
|
|
61
|
-
if (!farcasterConnectUri) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
routeMobileExternalWallet(farcasterConnectUri);
|
|
65
|
-
setStep(ModalStep.FARCASTER_OAUTH);
|
|
66
|
-
return;
|
|
67
|
-
case OAuthMethod.TELEGRAM:
|
|
68
|
-
setStep(ModalStep.TELEGRAM_OAUTH);
|
|
69
|
-
break;
|
|
70
|
-
default: {
|
|
71
|
-
setStep(ModalStep.AWAITING_OAUTH);
|
|
72
|
-
const oAuthURL = yield para.getOAuthURL({ method });
|
|
73
|
-
const oAuthWindow = openPopup(oAuthURL, `${method}AuthPopup`, 'OAUTH');
|
|
74
|
-
setPopupWindow(oAuthWindow);
|
|
75
|
-
const { email, isError, userExists } = yield para.waitForOAuth({ popupWindow: oAuthWindow });
|
|
76
|
-
setPopupWindow(undefined);
|
|
77
|
-
if (isError) {
|
|
78
|
-
goBack();
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (!email) {
|
|
82
|
-
setStep(ModalStep.AUTH_MAIN);
|
|
83
|
-
throw new Error('email is required');
|
|
84
|
-
}
|
|
85
|
-
setAuthInfo({ email });
|
|
86
|
-
if (userExists) {
|
|
87
|
-
const supportedAuthMethods = yield para.initiateUserLoginV2({ email });
|
|
88
|
-
if (supportedAuthMethods.size === 0) {
|
|
89
|
-
setFlow('signUp');
|
|
90
|
-
setStep(ModalStep.BIOMETRIC_CREATION);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
|
|
94
|
-
? yield para.getUserBiometricLocationHints()
|
|
95
|
-
: [];
|
|
96
|
-
setFlow('login');
|
|
97
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
98
|
-
setSupportedAuthMethods(supportedAuthMethods);
|
|
99
|
-
setBiometricLocationHints(biometricLocationHints);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
yield para.createUser({ email });
|
|
104
|
-
setFlow('signUp');
|
|
105
|
-
setStep(ModalStep.VERIFICATIONS);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
const useBrandedLogos = oAuthLogoVariant === 'default';
|
|
111
|
-
const useDarkLogos = useBrandedLogos ? isDark : oAuthLogoVariant !== 'dark';
|
|
112
|
-
const showMoreButton = !showAll && hasMore;
|
|
113
|
-
return (_jsxs(OAuthContainer, { children: [methodsToShow.map((method, index) => (_jsx(OAuthButton, { "$isDark": useDarkLogos, icon: useBrandedLogos ? brandedOAuthLogos[method] : oAuthLogos[method], onClick: handleMethodClick(method), "$index": index, "$totalItems": showMoreButton ? HAS_MORE_LENGTH : methodsToShow.length }, method))), showMoreButton && (_jsx(OAuthButton, { "$isDark": useDarkLogos, icon: "moreLoginOptions", onClick: handleShowAll, "$index": HAS_MORE_LENGTH - 1, "$totalItems": HAS_MORE_LENGTH }))] }));
|
|
114
|
-
};
|
|
115
|
-
const OAuthContainer = styled.div `
|
|
116
|
-
display: flex;
|
|
117
|
-
justify-content: center;
|
|
118
|
-
gap: 8px;
|
|
119
|
-
flex-wrap: wrap;
|
|
120
|
-
`;
|
|
121
|
-
const OAuthButton = styled(StyledCpslTileButton) `
|
|
122
|
-
flex: ${({ $index, $totalItems }) => getTileButtonFlex($index, $totalItems)};
|
|
123
|
-
|
|
124
|
-
--button-icon-color: ${({ $isDark }) => ($isDark ? 'white' : 'black')};
|
|
125
|
-
`;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { AuthMethod, OAuthMethod } from '@getpara/web-sdk';
|
|
12
|
-
import { useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
|
|
13
|
-
import styled from 'styled-components';
|
|
14
|
-
import { useEffect, useRef, useState } from 'react';
|
|
15
|
-
import { HeroSpinner } from '@getpara/react-common';
|
|
16
|
-
import { ModalStep } from '../../utils/steps.js';
|
|
17
|
-
import { CpslSpinner } from '@getpara/react-components';
|
|
18
|
-
import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
|
|
19
|
-
export function TelegramOAuthStep() {
|
|
20
|
-
const iframe = useRef();
|
|
21
|
-
const para = useInternalClient();
|
|
22
|
-
const setFlow = useModalStore(state => state.setFlow);
|
|
23
|
-
const setStep = useModalStore(state => state.setStep);
|
|
24
|
-
const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
|
|
25
|
-
const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
|
|
26
|
-
const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
|
|
27
|
-
const setIFrameUrl = useModalStore(state => state.setIFrameUrl);
|
|
28
|
-
const setIsIFrameReady = useModalStore(state => state.setIsIFrameReady);
|
|
29
|
-
const isIFrameReady = useModalStore(state => state.isIFrameReady);
|
|
30
|
-
const setWebAuthURLForCreate = useModalStore(state => state.setWebAuthURLForCreate);
|
|
31
|
-
const theme = useThemeStore(state => state.theme);
|
|
32
|
-
const [url, setUrl] = useState(undefined);
|
|
33
|
-
const [isWaiting, setIsWaiting] = useState(false);
|
|
34
|
-
const [isLoaded, setIsLoaded] = useState(false);
|
|
35
|
-
const [isError, setIsError] = useState(false);
|
|
36
|
-
const [shouldRouteToStep, setShouldRouteToStep] = useState();
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (!!shouldRouteToStep && isIFrameReady) {
|
|
39
|
-
// Using a small timeout here to fully ensure the iframe is loaded before triggering any animation
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
setStep(shouldRouteToStep);
|
|
42
|
-
}, 200);
|
|
43
|
-
}
|
|
44
|
-
}, [shouldRouteToStep, isIFrameReady]);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (!url) {
|
|
47
|
-
para.getOAuthURL({ method: OAuthMethod.TELEGRAM }).then(url => {
|
|
48
|
-
setUrl(url);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, [url]);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
const updateState = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
switch (event.data.type) {
|
|
55
|
-
case 'TELEGRAM_LOGIN':
|
|
56
|
-
setIsWaiting(true);
|
|
57
|
-
setIsError(false);
|
|
58
|
-
break;
|
|
59
|
-
case 'TELEGRAM_FAILED':
|
|
60
|
-
setIsWaiting(false);
|
|
61
|
-
setIsError(true);
|
|
62
|
-
break;
|
|
63
|
-
case 'TELEGRAM_SUCCESS':
|
|
64
|
-
if (!!event.data.payload) {
|
|
65
|
-
const authObject = event.data.payload;
|
|
66
|
-
const result = yield para.verifyTelegram(authObject);
|
|
67
|
-
if (!result.isValid) {
|
|
68
|
-
setIsWaiting(false);
|
|
69
|
-
setIsError(true);
|
|
70
|
-
iframe.current && iframe.current.contentWindow.postMessage({ type: 'TELEGRAM_FAILED' }, '*');
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const { telegramUserId, isNewUser, supportedAuthMethods, biometricHints } = result;
|
|
74
|
-
setAuthInfo({
|
|
75
|
-
telegramUserId,
|
|
76
|
-
pfpUrl: authObject.photo_url,
|
|
77
|
-
displayName: authObject.username
|
|
78
|
-
? `@${authObject.username}`
|
|
79
|
-
: authObject.first_name
|
|
80
|
-
? `${authObject.first_name}${authObject.last_name ? ` ${authObject.last_name}` : ''}`
|
|
81
|
-
: `Telegram User @${telegramUserId}`,
|
|
82
|
-
});
|
|
83
|
-
if (isNewUser) {
|
|
84
|
-
const supportedCreateAuthMethods = yield para.getSupportedCreateAuthMethods();
|
|
85
|
-
setIsIFrameReady(false);
|
|
86
|
-
setFlow('signUp');
|
|
87
|
-
const supportsPasskey = supportedCreateAuthMethods.has(AuthMethod.PASSKEY);
|
|
88
|
-
if (supportsPasskey) {
|
|
89
|
-
setWebAuthURLForCreate(yield para.shortenLoginLink(yield para.getSetUpBiometricsURL({ authType: 'telegram' })));
|
|
90
|
-
setStep(ModalStep.BIOMETRIC_CREATION);
|
|
91
|
-
}
|
|
92
|
-
if (supportedCreateAuthMethods.has(AuthMethod.PASSWORD)) {
|
|
93
|
-
setIFrameUrl(yield para.shortenLoginLink(yield para.getSetupPasswordURL({ authType: 'telegram', theme })));
|
|
94
|
-
setShouldRouteToStep(supportsPasskey ? ModalStep.BIOMETRIC_CREATION : ModalStep.PASSWORD_CREATION);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
setFlow('login');
|
|
99
|
-
supportedAuthMethods && setSupportedAuthMethods(new Set(supportedAuthMethods));
|
|
100
|
-
biometricHints && setBiometricLocationHints(biometricHints);
|
|
101
|
-
setStep(ModalStep.BIOMETRIC_LOGIN);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
window === null || window === void 0 ? void 0 : window.addEventListener('message', updateState, false);
|
|
108
|
-
return () => {
|
|
109
|
-
window === null || window === void 0 ? void 0 : window.removeEventListener('message', updateState, false);
|
|
110
|
-
};
|
|
111
|
-
}, []);
|
|
112
|
-
return (_jsxs(Container, { children: [_jsx(HeroContainer, { children: _jsx(HeroSpinner, { icon: "telegramBrand", status: isWaiting ? 'loading' : isError ? 'error' : 'inactive', text: isWaiting ? 'Follow the on-screen prompts.' : isError ? 'Login Failed' : undefined }) }), url && (_jsx(IFrame, { ref: iframe, style: { display: isLoaded ? 'block' : 'none' }, src: url, onLoad: () => setIsLoaded(true) })), (!url || !isLoaded) && _jsx(CpslSpinner, {})] }));
|
|
113
|
-
}
|
|
114
|
-
const Container = styled.div `
|
|
115
|
-
display: flex;
|
|
116
|
-
flex-direction: column;
|
|
117
|
-
align-items: center;
|
|
118
|
-
justify-content: center;
|
|
119
|
-
width: 100%;
|
|
120
|
-
`;
|
|
121
|
-
const HeroContainer = styled.div `
|
|
122
|
-
display: flex;
|
|
123
|
-
min-height: 276px;
|
|
124
|
-
flex-direction: column;
|
|
125
|
-
align-items: center;
|
|
126
|
-
gap: 16px;
|
|
127
|
-
flex: 1;
|
|
128
|
-
`;
|
|
129
|
-
const IFrame = styled.iframe `
|
|
130
|
-
width: 100%;
|
|
131
|
-
height: 52px;
|
|
132
|
-
border: none;
|
|
133
|
-
`;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { OnRampPurchaseStatus } from '@getpara/web-sdk';
|
|
3
|
-
import { SpinnerContainer } from '../common.js';
|
|
4
|
-
import { ON_RAMP_PROVIDERS } from '../../constants/constants.js';
|
|
5
|
-
import { useModalStore } from '../../stores/index.js';
|
|
6
|
-
import { CpslSpinner, CpslText } from '@getpara/react-components';
|
|
7
|
-
export const AddingFunds = () => {
|
|
8
|
-
const onRampPurchase = useModalStore(state => state.onRampPurchase);
|
|
9
|
-
return (_jsxs(_Fragment, { children: [_jsx(SpinnerContainer, { children: _jsx(CpslSpinner, { size: 100 }) }), _jsxs(CpslText, { children: ["Follow the prompts presented by", ' ', OnRampPurchaseStatus ? ON_RAMP_PROVIDERS[onRampPurchase.provider].name : 'the provider', "."] })] }));
|
|
10
|
-
};
|