@getpara/react-sdk 1.2.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.
Files changed (143) hide show
  1. package/dist/MoonPayEmbed-GAWXP6V7.js +2 -0
  2. package/dist/MoonPayEmbed-GAWXP6V7.js.br +0 -0
  3. package/dist/MoonPayEmbed-GAWXP6V7.js.gz +0 -0
  4. package/dist/index.js +675 -5
  5. package/dist/index.js.br +0 -0
  6. package/dist/index.js.gz +0 -0
  7. package/package.json +8 -7
  8. package/dist/modal/ParaModal.js +0 -281
  9. package/dist/modal/components/Account/Account.js +0 -60
  10. package/dist/modal/components/AddFunds/AddFunds.js +0 -147
  11. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -65
  12. package/dist/modal/components/AddFunds/AddFundsDone.js +0 -26
  13. package/dist/modal/components/AddFunds/MoonPayEmbed.js +0 -2
  14. package/dist/modal/components/AddFunds/index.js +0 -3
  15. package/dist/modal/components/AuthInput/AuthInput.js +0 -221
  16. package/dist/modal/components/AuthInput/countryCodes.js +0 -40
  17. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -23
  18. package/dist/modal/components/AuthInput/phoneMasks.js +0 -247
  19. package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -21
  20. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -89
  21. package/dist/modal/components/AuthOptions/AuthOptions.js +0 -28
  22. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -7
  23. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -5
  24. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -7
  25. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -18
  26. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -17
  27. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -131
  28. package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -26
  29. package/dist/modal/components/Body/Body.js +0 -232
  30. package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -77
  31. package/dist/modal/components/ChainSwitch/config.js +0 -11
  32. package/dist/modal/components/Controls/Controls.js +0 -54
  33. package/dist/modal/components/Controls/Selects.js +0 -159
  34. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -116
  35. package/dist/modal/components/ExternalWalletStep/config.js +0 -11
  36. package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -142
  37. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -119
  38. package/dist/modal/components/Footer/Footer.js +0 -71
  39. package/dist/modal/components/Header/Header.js +0 -24
  40. package/dist/modal/components/Header/hooks/useStepTitle.js +0 -42
  41. package/dist/modal/components/Hero/Hero.js +0 -119
  42. package/dist/modal/components/IFrameStep/IFrameStep.js +0 -41
  43. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -19
  44. package/dist/modal/components/ModalContent/ModalContent.js +0 -282
  45. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
  46. package/dist/modal/components/OAuth/OAuth.js +0 -125
  47. package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -133
  48. package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -10
  49. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -72
  50. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -67
  51. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -105
  52. package/dist/modal/components/StripeComponents/StripeComponents.js +0 -78
  53. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -8
  54. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -135
  55. package/dist/modal/components/Waiting/Waiting.js +0 -6
  56. package/dist/modal/components/WalletCard/PartnerIcon.js +0 -29
  57. package/dist/modal/components/WalletCard/WalletCard.js +0 -93
  58. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -50
  59. package/dist/modal/components/common.js +0 -67
  60. package/dist/modal/components/index.js +0 -1
  61. package/dist/modal/constants/constants.js +0 -93
  62. package/dist/modal/constants/defaults.js +0 -5
  63. package/dist/modal/constants/oAuthLogos.js +0 -18
  64. package/dist/modal/hooks/useActiveWallet.js +0 -11
  65. package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -46
  66. package/dist/modal/hooks/useGoBack.js +0 -34
  67. package/dist/modal/index.js +0 -9
  68. package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -18
  69. package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -22
  70. package/dist/modal/providers/ExternalWalletContext.js +0 -253
  71. package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -12
  72. package/dist/modal/stores/externalWalletProvider/actions.js +0 -5
  73. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -13
  74. package/dist/modal/stores/index.js +0 -3
  75. package/dist/modal/stores/modal/actions.js +0 -64
  76. package/dist/modal/stores/modal/useModalStore.js +0 -41
  77. package/dist/modal/stores/para/actions.js +0 -5
  78. package/dist/modal/stores/para/useParaStore.js +0 -3
  79. package/dist/modal/stores/theme/actions.js +0 -24
  80. package/dist/modal/stores/theme/useThemeStore.js +0 -14
  81. package/dist/modal/stores/userInfo/actions.js +0 -34
  82. package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -9
  83. package/dist/modal/types/commonTypes.js +0 -1
  84. package/dist/modal/types/externalWallets.js +0 -21
  85. package/dist/modal/types/modalProps.js +0 -7
  86. package/dist/modal/utils/authLayoutHelpers.js +0 -2
  87. package/dist/modal/utils/getMailtoLink.js +0 -5
  88. package/dist/modal/utils/getTileButtonFlex.js +0 -15
  89. package/dist/modal/utils/isPasskeySupported.js +0 -10
  90. package/dist/modal/utils/openPopup.js +0 -55
  91. package/dist/modal/utils/routeMobileExternalWallet.js +0 -35
  92. package/dist/modal/utils/steps.js +0 -215
  93. package/dist/modal/utils/stringFormatters.js +0 -12
  94. package/dist/modal/utils/validateOnRampConfig.js +0 -26
  95. package/dist/provider/ParaProvider.js +0 -17
  96. package/dist/provider/actions/checkIfUserExists.js +0 -26
  97. package/dist/provider/actions/createUser.js +0 -30
  98. package/dist/provider/actions/getAccount.js +0 -24
  99. package/dist/provider/actions/getWallet.js +0 -16
  100. package/dist/provider/actions/initiateLogin.js +0 -23
  101. package/dist/provider/actions/keepSessionAlive.js +0 -23
  102. package/dist/provider/actions/logout.js +0 -20
  103. package/dist/provider/actions/signMessage.js +0 -23
  104. package/dist/provider/actions/signTransaction.js +0 -23
  105. package/dist/provider/actions/waitForAccountCreation.js +0 -24
  106. package/dist/provider/actions/waitForLoginAndSetup.js +0 -27
  107. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -24
  108. package/dist/provider/hooks/index.js +0 -3
  109. package/dist/provider/hooks/mutations/index.js +0 -10
  110. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
  111. package/dist/provider/hooks/mutations/useCreateUser.js +0 -23
  112. package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
  113. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -23
  114. package/dist/provider/hooks/mutations/useLogout.js +0 -33
  115. package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
  116. package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
  117. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
  118. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
  119. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
  120. package/dist/provider/hooks/queries/index.js +0 -2
  121. package/dist/provider/hooks/queries/useAccount.js +0 -23
  122. package/dist/provider/hooks/queries/useWallet.js +0 -24
  123. package/dist/provider/hooks/utils/index.js +0 -3
  124. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -79
  125. package/dist/provider/hooks/utils/useClient.js +0 -8
  126. package/dist/provider/hooks/utils/useEventListeners.js +0 -87
  127. package/dist/provider/hooks/utils/useInternalClient.js +0 -9
  128. package/dist/provider/hooks/utils/useModal.js +0 -15
  129. package/dist/provider/hooks/utils/useWalletState.js +0 -33
  130. package/dist/provider/index.js +0 -3
  131. package/dist/provider/stores/getters.js +0 -5
  132. package/dist/provider/stores/slices/client.js +0 -4
  133. package/dist/provider/stores/slices/index.js +0 -3
  134. package/dist/provider/stores/slices/modal.js +0 -4
  135. package/dist/provider/stores/slices/wallet.js +0 -6
  136. package/dist/provider/stores/types.js +0 -1
  137. package/dist/provider/stores/useStore.js +0 -14
  138. package/dist/provider/types/provider.js +0 -1
  139. package/dist/provider/types/query.js +0 -1
  140. package/dist/provider/types/utils.js +0 -1
  141. package/dist/provider/utils/renameMutations.js +0 -19
  142. /package/dist/{modal/css → css}/modal.css +0 -0
  143. /package/dist/{modal/public → public}/Inter-VariableFont_slnt,wght.ttf +0 -0
@@ -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
- };
@@ -1,72 +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 { useState } from 'react';
12
- import { ON_RAMP_PROVIDERS } from '../../constants/constants.js';
13
- import styled from 'styled-components';
14
- import { CpslButton, CpslIcon, CpslSpinner, CpslText } from '@getpara/react-components';
15
- import { motion } from 'framer-motion';
16
- export const OnRampProviderButton = ({ config, index, onClick: _onClick }) => {
17
- const [isLoading, setIsLoading] = useState(false);
18
- const provider = config.providers[index];
19
- const { feeLower, feeUpper, name, icon, backgroundColors } = ON_RAMP_PROVIDERS[provider];
20
- const feeString = `Fee ${feeLower}% - ${feeUpper}%`;
21
- const onClick = () => __awaiter(void 0, void 0, void 0, function* () {
22
- setIsLoading(true);
23
- yield _onClick();
24
- setIsLoading(false);
25
- });
26
- return (_jsx(StyledButton, { "$gradientColors": backgroundColors, fullWidth: true, onClick: onClick, children: _jsxs(Container, { "$backgroundColor": backgroundColors[1], children: [_jsx(IconContainer, { children: _jsx(CpslIcon, { icon: icon }) }), _jsxs(ProviderInfoContainer, { children: [_jsx(Text, { variant: "bodyL", weight: "medium", children: name }), _jsx(ProviderInfoInnerContainer, { children: _jsx(Text, { variant: "bodyXS", weight: "medium", children: feeString }) })] }), isLoading ? _jsx(CpslSpinner, { size: 16 }) : _jsx(Chevron, { icon: "chevronUp" })] }) }));
27
- };
28
- const StyledButton = styled(CpslButton) `
29
- width: 100%;
30
- --button-primary-background-color: ${({ $gradientColors }) => `linear-gradient(90deg, ${$gradientColors[0]} 0%, ${$gradientColors[1]} 100%)`};
31
- --button-primary-hover-background-color: ${({ $gradientColors }) => `linear-gradient(90deg, ${$gradientColors[0]} 0%, ${$gradientColors[0]} 100%)`};
32
- --button-primary-active-background-color: ${({ $gradientColors }) => `linear-gradient(90deg, ${$gradientColors[0]} 0%, ${$gradientColors[0]} 100%)`};
33
- `;
34
- const Container = styled(motion.div) `
35
- display: flex;
36
- gap: 8px;
37
- flex: 1;
38
- align-items: center;
39
-
40
- & cpsl-spinner {
41
- --background-color: ${({ $backgroundColor }) => `${$backgroundColor}`};
42
- }
43
- `;
44
- const ProviderInfoContainer = styled.div `
45
- flex: 1;
46
- display: flex;
47
- flex-direction: column;
48
- align-items: start;
49
- gap: 2px;
50
- `;
51
- const ProviderInfoInnerContainer = styled.div `
52
- display: flex;
53
- gap: 16px;
54
- `;
55
- const IconContainer = styled.span `
56
- display: flex;
57
- align-items: center;
58
- justify-content: center;
59
- background-color: #fff;
60
- border-radius: 100%;
61
- height: 48px;
62
- width: 48px;
63
- `;
64
- const Text = styled(CpslText) `
65
- &::part(text-element) {
66
- color: #fff;
67
- }
68
- `;
69
- const Chevron = styled(CpslIcon) `
70
- transform: rotate(90deg);
71
- --icon-color: #fff;
72
- `;
@@ -1,67 +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 { CpslButton, CpslText } from '@getpara/react-components';
12
- import { useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
13
- import { ModalStep } from '../../utils/steps.js';
14
- import { Heading, InnerStepContainer, StepContainer, StyledCpslTileButton } from '../common.js';
15
- import { styled } from 'styled-components';
16
- import { useCopyToClipboard } from '@getpara/react-common';
17
- import { getMailtoLink } from '../../utils/getMailtoLink.js';
18
- import { useState } from 'react';
19
- export const SaveRecoverySecret = ({ email, value, onComplete, }) => {
20
- const [isSecretSaved, setIsSecretSaved] = useState(false);
21
- const [isCopied, copy] = useCopyToClipboard();
22
- const onCopy = () => {
23
- copy(value);
24
- setIsSecretSaved(true);
25
- };
26
- const onDownload = () => {
27
- const element = document.createElement('a');
28
- const file = new Blob([value], { type: 'text/plain' });
29
- element.href = URL.createObjectURL(file);
30
- element.download = 'recovery.txt';
31
- document.body.appendChild(element); // Required for this to work in FireFox
32
- element.click();
33
- setIsSecretSaved(true);
34
- };
35
- const onEmail = () => {
36
- window.open(getMailtoLink(email, value), '_self');
37
- setIsSecretSaved(true);
38
- };
39
- return (_jsxs(_Fragment, { children: [_jsxs(InnerStepContainer, { children: [_jsx(Heading, { variant: "headingXS", weight: "semiBold", children: "Save your Recovery Secret" }), _jsxs(ButtonContainer, { children: [_jsx(ActionButton, { icon: "download", onClick: onDownload, children: _jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Download" }) }), _jsx(ActionButton, { icon: isCopied ? 'check' : 'copy', onClick: onCopy, children: _jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: isCopied ? 'Copied!' : 'Copy' }) }), _jsx(ActionButton, { icon: "send", onClick: onEmail, children: _jsx(CpslText, { variant: "bodyXS", color: "secondary", weight: "medium", children: "Email" }) })] })] }), _jsx(InnerStepContainer, { children: _jsx(CpslButton, { fullWidth: true, onClick: onComplete, disabled: !isSecretSaved, children: !isSecretSaved ? 'Choose an option above to continue' : 'I’ve saved my recovery secret' }) })] }));
40
- };
41
- export const RecoverySecretStep = () => {
42
- const hideWallets = useThemeStore(state => state.hideWallets);
43
- const setStep = useModalStore(state => state.setStep);
44
- const authInfo = useUserInfoStore(state => state.getAuthInfo());
45
- const recoveryShare = useUserInfoStore(state => state.recoveryShare);
46
- const backupDecryptionKey = JSON.parse(recoveryShare || '{}').backupDecryptionKey;
47
- const onComplete = () => __awaiter(void 0, void 0, void 0, function* () {
48
- setStep(ModalStep.WALLET_CREATION_DONE);
49
- });
50
- return (_jsxs(StepContainer, { children: [_jsxs(InnerStepContainer, { children: [_jsx(Heading, { variant: "headingS", weight: "bold", children: hideWallets ? "Don't lose access" : "Don't lose your wallet" }), _jsxs(InlineText, { variant: "bodyS", color: "secondary", weight: "medium", children: ["Your", ' ', _jsx(InlineText, { variant: "bodyS", weight: "medium", children: "Recovery Secret" }), ' ', "ensures you will be able to regain access to your ", hideWallets ? 'account' : 'wallet', " if you lose your Passkey or Password."] })] }), _jsx(SaveRecoverySecret, { email: (authInfo === null || authInfo === void 0 ? void 0 : authInfo.authType) === 'email' ? authInfo.identifier : undefined, value: backupDecryptionKey, onComplete: onComplete })] }));
51
- };
52
- const ActionButton = styled(StyledCpslTileButton) `
53
- flex: 1;
54
-
55
- --button-icon-color: var(--cpsl-color-text-primary);
56
- `;
57
- const ButtonContainer = styled.div `
58
- display: flex;
59
- align-items: center;
60
- justify-content: center;
61
- gap: 8px;
62
- width: 100%;
63
- `;
64
- const InlineText = styled(CpslText) `
65
- text-align: center;
66
- display: inline-block;
67
- `;
@@ -1,105 +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 { CpslButton, CpslCodeInput, CpslDivider, CpslIcon, CpslQrCode, CpslSpinner, CpslText, } from '@getpara/react-components';
12
- import { useEffect, useRef, useState } from 'react';
13
- import { useModalStore } from '../../stores/index.js';
14
- import { Heading, QRContainer, FilledDisabledInput, StepContainer, InnerStepContainer } from '../common.js';
15
- import { ModalStep } from '../../utils/steps.js';
16
- import { styled } from 'styled-components';
17
- import { useCopyToClipboard } from '@getpara/react-common';
18
- import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
19
- export const Setup2FAStep = ({ onClose }) => {
20
- const isLogin = useModalStore(state => state.isLogin());
21
- const setStep = useModalStore(state => state.setStep);
22
- const para = useInternalClient();
23
- const isVerifying = useModalStore(state => state.step === ModalStep.VERIFY_2FA);
24
- const [copied, copy] = useCopyToClipboard();
25
- const inputRef = useRef(null);
26
- const [qrCodeValue, setQrCodeValue] = useState(null);
27
- const [code, setCode] = useState('');
28
- const [codeError, setCodeError] = useState('');
29
- const [isVerifyingCode, setIsVerifyingCode] = useState(false);
30
- const params = qrCodeValue ? new URL(qrCodeValue).searchParams : undefined;
31
- const secret = params === null || params === void 0 ? void 0 : params.get('secret');
32
- useEffect(() => {
33
- function fetchOtpAuthUrl() {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- try {
36
- const { uri } = yield para.setup2FA();
37
- setQrCodeValue(uri);
38
- }
39
- catch (error) {
40
- console.error('Error fetching OTPAuth URL:', error);
41
- }
42
- });
43
- }
44
- fetchOtpAuthUrl();
45
- }, []);
46
- useEffect(() => {
47
- // Using a small timeout here to ensure the input is mounted before attempting focus
48
- setTimeout(() => {
49
- var _a, _b, _c;
50
- (_c = (_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.shadowRoot.querySelectorAll('input')) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.focus();
51
- }, 10);
52
- }, [isVerifying]);
53
- useEffect(() => {
54
- if (code.length === 6) {
55
- handleSubmitCode();
56
- }
57
- }, [code]);
58
- const handleNext = () => {
59
- setStep(ModalStep.VERIFY_2FA);
60
- };
61
- const handleSkip = () => {
62
- if (isLogin) {
63
- setStep(ModalStep.LOGIN_DONE);
64
- }
65
- else {
66
- onClose();
67
- }
68
- };
69
- const handleCodeInput = (e) => {
70
- if (codeError) {
71
- setCodeError('');
72
- }
73
- setCode(e.detail.value.trim());
74
- };
75
- const handleSubmitCode = () => __awaiter(void 0, void 0, void 0, function* () {
76
- setIsVerifyingCode(true);
77
- if (code.length === 6 && /^\d+$/.test(code)) {
78
- try {
79
- yield para.enable2FA({ verificationCode: code });
80
- setStep(ModalStep.TWO_FACTOR_DONE);
81
- }
82
- catch (e) {
83
- setCodeError('Incorrect Code');
84
- }
85
- }
86
- else {
87
- setCodeError('Incorrect Code');
88
- }
89
- setIsVerifyingCode(false);
90
- });
91
- const handleCopy = () => {
92
- copy(secret);
93
- };
94
- return (_jsxs(StepContainer, { children: [_jsxs(InnerStepContainer, { children: [_jsx(Heading, { variant: "headingS", weight: "bold", children: "Turn on Two-Factor authentication" }), isVerifying && (_jsx(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Please enter the code from your authenticator app." }))] }), _jsx(InnerStepContainer, { children: isVerifying ? (_jsx(_Fragment, { children: isVerifyingCode ? (_jsx(CpslSpinner, {})) : (_jsx("form", { onSubmit: (e) => __awaiter(void 0, void 0, void 0, function* () {
95
- e.preventDefault();
96
- yield handleSubmitCode();
97
- }), children: _jsx(StyledCodeInput, { ref: inputRef, code: code, onCpslInput: handleCodeInput, errorText: codeError, length: 6, onKeyDown: (e) => __awaiter(void 0, void 0, void 0, function* () { return e.key === 'Enter' && (yield handleSubmitCode()); }) }) })) })) : (_jsxs(_Fragment, { children: [_jsx(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: "Scan with your preferred authenticator app." }), _jsx(QRContainer, { children: !qrCodeValue ? _jsx(CpslSpinner, { size: 100 }) : _jsx(CpslQrCode, { url: qrCodeValue }) })] })) }), !isVerifying && (_jsxs(_Fragment, { children: [_jsx(InnerStepContainer, { children: _jsx(CpslDivider, { children: "or enter the code manually" }) }), _jsx(InnerStepContainer, { children: _jsx(FilledDisabledInput, { disabled: true, value: secret, noAutoDisable: true, children: _jsx(CpslButton, { slot: "end", variant: "ghost", onClick: handleCopy, children: _jsx(CpslIcon, { icon: copied ? 'check' : 'copy' }) }) }) }), _jsxs(InnerStepContainer, { children: [_jsx(CpslButton, { fullWidth: true, onClick: handleNext, children: "Continue" }), _jsx(SkipButton, { variant: "ghost", onClick: handleSkip, children: "Skip" })] })] }))] }));
98
- };
99
- const StyledCodeInput = styled(CpslCodeInput) `
100
- align-self: center;
101
- `;
102
- const SkipButton = styled(CpslButton) `
103
- margin-top: 8px;
104
- text-decoration: underline;
105
- `;
@@ -1,78 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import React from 'react';
14
- export const STRIPE_PUBLISHABLE_KEY = 'pk_live_51MvquNGrzDeP5yP9EgVSMBPQbrbg0oHDjPIIXypePd0jzOFjbadyfO7wBKLHhUtbKIUiEUVC3YYcTJyAmJ8xA7JE00T2UDfYKz';
15
- export const STRIPE_PUBLISHABLE_KEY_TEST = 'pk_test_51MvquNGrzDeP5yP98WgPaAUgQ50I3OpfPhVfiLO47FBHepJnZRPO62IzZY2uxT5ovhSS10RwcTcnaVil1mcJOzIi00dHapODdS';
16
- const CryptoElementsContext = React.createContext(null);
17
- CryptoElementsContext.displayName = 'CryptoElementsContext';
18
- export const CryptoElements = ({ stripeOnramp, children }) => {
19
- const [ctx, setContext] = React.useState(() => ({
20
- onramp: null,
21
- }));
22
- React.useEffect(() => {
23
- let isMounted = true;
24
- Promise.resolve(stripeOnramp).then(onramp => {
25
- if (onramp && isMounted) {
26
- setContext(ctx => (ctx.onramp ? ctx : { onramp }));
27
- }
28
- });
29
- return () => {
30
- isMounted = false;
31
- };
32
- }, [stripeOnramp]);
33
- return _jsx(CryptoElementsContext.Provider, { value: ctx, children: children });
34
- };
35
- // React hook to get StripeOnramp from context
36
- export const useStripeOnramp = () => {
37
- const context = React.useContext(CryptoElementsContext);
38
- return context === null || context === void 0 ? void 0 : context.onramp;
39
- };
40
- // React element to render Onramp UI
41
- const useOnrampSessionListener = (type, session, callback) => {
42
- React.useEffect(() => {
43
- if (session && callback) {
44
- const listener = e => callback(e.payload);
45
- session.addEventListener(type, listener);
46
- return () => {
47
- session.removeEventListener(type, listener);
48
- };
49
- }
50
- return () => { };
51
- }, [session, callback, type]);
52
- };
53
- export const OnrampElement = (_a) => {
54
- var { clientSecret, appearance, onReady = () => { }, onSessionChange } = _a, props = __rest(_a, ["clientSecret", "appearance", "onReady", "onSessionChange"]);
55
- const stripeOnramp = useStripeOnramp();
56
- const onrampElementRef = React.useRef(null);
57
- const [session, setSession] = React.useState();
58
- const appearanceJSON = JSON.stringify(appearance);
59
- React.useEffect(() => {
60
- const containerRef = onrampElementRef.current;
61
- if (containerRef) {
62
- // NB: ideally we want to be able to hot swap/update onramp iframe
63
- // This currently results a flash if one needs to mint a new session when they need to udpate fixed transaction details
64
- containerRef.innerHTML = '';
65
- if (clientSecret && stripeOnramp) {
66
- setSession(stripeOnramp
67
- .createSession({
68
- clientSecret,
69
- appearance: { theme: appearance },
70
- })
71
- .mount(containerRef));
72
- }
73
- }
74
- }, [appearanceJSON, clientSecret, stripeOnramp]);
75
- useOnrampSessionListener('onramp_ui_loaded', session, onReady);
76
- useOnrampSessionListener('onramp_session_updated', session, onSessionChange);
77
- return _jsx("div", Object.assign({}, props, { ref: onrampElementRef }));
78
- };
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CpslButton, CpslText } from '@getpara/react-components';
3
- import { Heading, StepContainer, InnerStepContainer, HeroIcon } from '../common.js';
4
- import { useThemeStore } from '../../stores/index.js';
5
- export const TwoFactorDoneStep = ({ onClose }) => {
6
- const hideWallets = useThemeStore(state => state.hideWallets);
7
- return (_jsxs(StepContainer, { children: [_jsx(HeroIcon, { icon: "checkCircleFilled" }), _jsxs(InnerStepContainer, { children: [_jsx(Heading, { variant: "headingXS", weight: "semiBold", children: "Success" }), _jsxs(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: ["Your ", hideWallets ? 'account' : 'wallet', " is now protected by 2FA"] })] }), _jsx(CpslButton, { fullWidth: true, onClick: onClose, children: "Done" })] }));
8
- };