@getpara/react-sdk 0.1.0 → 0.2.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 (122) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/modal/ParaModal.js +48 -17
  4. package/dist/modal/components/Account/Account.js +3 -2
  5. package/dist/modal/components/AddFunds/AddFunds.js +3 -2
  6. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +3 -2
  7. package/dist/modal/components/AuthInput/AuthInput.js +12 -5
  8. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +7 -3
  9. package/dist/modal/components/Controls/Selects.js +6 -4
  10. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +3 -2
  11. package/dist/modal/components/Hero/Hero.js +3 -2
  12. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +3 -2
  13. package/dist/modal/components/ModalContent/ModalContent.js +6 -2
  14. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +3 -2
  15. package/dist/modal/components/OAuth/OAuth.js +4 -3
  16. package/dist/modal/components/OAuth/TelegramOAuthStep.js +4 -3
  17. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +4 -3
  18. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +10 -5
  19. package/dist/modal/components/WalletCard/WalletCard.js +7 -5
  20. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +3 -2
  21. package/dist/modal/hooks/useActiveWallet.js +7 -5
  22. package/dist/modal/providers/ExternalWalletContext.js +3 -2
  23. package/dist/modal/stores/index.d.ts +0 -1
  24. package/dist/modal/stores/index.js +0 -1
  25. package/dist/modal/stores/modal/actions.js +0 -1
  26. package/dist/modal/stores/modal/useModalStore.d.ts +0 -1
  27. package/dist/modal/types/modalProps.d.ts +3 -3
  28. package/dist/provider/ParaProvider.d.ts +2 -0
  29. package/dist/provider/ParaProvider.js +16 -0
  30. package/dist/provider/actions/checkIfUserExists.d.ts +9 -0
  31. package/dist/provider/actions/checkIfUserExists.js +26 -0
  32. package/dist/provider/actions/createUser.d.ts +12 -0
  33. package/dist/provider/actions/createUser.js +30 -0
  34. package/dist/provider/actions/getAccount.d.ts +7 -0
  35. package/dist/provider/actions/getAccount.js +24 -0
  36. package/dist/provider/actions/getWallet.d.ts +5 -0
  37. package/dist/provider/actions/getWallet.js +16 -0
  38. package/dist/provider/actions/initiateLogin.d.ts +4 -0
  39. package/dist/provider/actions/initiateLogin.js +23 -0
  40. package/dist/provider/actions/keepSessionAlive.d.ts +2 -0
  41. package/dist/provider/actions/keepSessionAlive.js +23 -0
  42. package/dist/provider/actions/logout.d.ts +2 -0
  43. package/dist/provider/actions/logout.js +20 -0
  44. package/dist/provider/actions/signMessage.d.ts +8 -0
  45. package/dist/provider/actions/signMessage.js +23 -0
  46. package/dist/provider/actions/signTransaction.d.ts +8 -0
  47. package/dist/provider/actions/signTransaction.js +23 -0
  48. package/dist/provider/actions/waitForAccountCreation.d.ts +2 -0
  49. package/dist/provider/actions/waitForAccountCreation.js +24 -0
  50. package/dist/provider/actions/waitForLoginAndSetup.d.ts +6 -0
  51. package/dist/provider/actions/waitForLoginAndSetup.js +27 -0
  52. package/dist/provider/actions/waitForPasskeyAndCreateWallet.d.ts +2 -0
  53. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +24 -0
  54. package/dist/provider/hooks/index.d.ts +3 -0
  55. package/dist/provider/hooks/index.js +3 -0
  56. package/dist/provider/hooks/mutations/index.d.ts +10 -0
  57. package/dist/provider/hooks/mutations/index.js +10 -0
  58. package/dist/provider/hooks/mutations/useCheckIfUserExists.d.ts +13 -0
  59. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +23 -0
  60. package/dist/provider/hooks/mutations/useCreateUser.d.ts +13 -0
  61. package/dist/provider/hooks/mutations/useCreateUser.js +23 -0
  62. package/dist/provider/hooks/mutations/useInitiateLogin.d.ts +14 -0
  63. package/dist/provider/hooks/mutations/useInitiateLogin.js +23 -0
  64. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +12 -0
  65. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +23 -0
  66. package/dist/provider/hooks/mutations/useLogout.d.ts +12 -0
  67. package/dist/provider/hooks/mutations/useLogout.js +33 -0
  68. package/dist/provider/hooks/mutations/useSignMessage.d.ts +15 -0
  69. package/dist/provider/hooks/mutations/useSignMessage.js +33 -0
  70. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +14 -0
  71. package/dist/provider/hooks/mutations/useSignTransaction.js +33 -0
  72. package/dist/provider/hooks/mutations/useWaitForAccountCreation.d.ts +12 -0
  73. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +30 -0
  74. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.d.ts +14 -0
  75. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +30 -0
  76. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.d.ts +13 -0
  77. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +30 -0
  78. package/dist/provider/hooks/queries/index.d.ts +2 -0
  79. package/dist/provider/hooks/queries/index.js +2 -0
  80. package/dist/provider/hooks/queries/useAccount.d.ts +10 -0
  81. package/dist/provider/hooks/queries/useAccount.js +23 -0
  82. package/dist/provider/hooks/queries/useWallet.d.ts +5 -0
  83. package/dist/provider/hooks/queries/useWallet.js +24 -0
  84. package/dist/provider/hooks/utils/index.d.ts +3 -0
  85. package/dist/provider/hooks/utils/index.js +3 -0
  86. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.d.ts +3 -0
  87. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +79 -0
  88. package/dist/provider/hooks/utils/useClient.d.ts +4 -0
  89. package/dist/provider/hooks/utils/useClient.js +8 -0
  90. package/dist/provider/hooks/utils/useEventListeners.d.ts +2 -0
  91. package/dist/provider/hooks/utils/useEventListeners.js +87 -0
  92. package/dist/provider/hooks/utils/useInternalClient.d.ts +5 -0
  93. package/dist/provider/hooks/utils/useInternalClient.js +9 -0
  94. package/dist/provider/hooks/utils/useModal.d.ts +8 -0
  95. package/dist/provider/hooks/utils/useModal.js +15 -0
  96. package/dist/provider/hooks/utils/useWalletState.d.ts +14 -0
  97. package/dist/provider/hooks/utils/useWalletState.js +33 -0
  98. package/dist/provider/index.d.ts +3 -0
  99. package/dist/provider/index.js +3 -0
  100. package/dist/provider/stores/getters.d.ts +4 -0
  101. package/dist/provider/stores/getters.js +5 -0
  102. package/dist/provider/stores/slices/client.d.ts +3 -0
  103. package/dist/provider/stores/slices/client.js +4 -0
  104. package/dist/provider/stores/slices/index.d.ts +3 -0
  105. package/dist/provider/stores/slices/index.js +3 -0
  106. package/dist/provider/stores/slices/modal.d.ts +3 -0
  107. package/dist/provider/stores/slices/modal.js +4 -0
  108. package/dist/provider/stores/slices/wallet.d.ts +3 -0
  109. package/dist/provider/stores/slices/wallet.js +6 -0
  110. package/dist/provider/stores/types.d.ts +16 -0
  111. package/dist/provider/stores/types.js +1 -0
  112. package/dist/provider/stores/useStore.d.ts +12 -0
  113. package/dist/provider/stores/useStore.js +12 -0
  114. package/dist/provider/types/provider.d.ts +26 -0
  115. package/dist/provider/types/provider.js +1 -0
  116. package/dist/provider/types/query.d.ts +3 -0
  117. package/dist/provider/types/query.js +1 -0
  118. package/dist/provider/types/utils.d.ts +6 -0
  119. package/dist/provider/types/utils.js +1 -0
  120. package/dist/provider/utils/renameMutations.d.ts +2 -0
  121. package/dist/provider/utils/renameMutations.js +19 -0
  122. package/package.json +7 -5
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './modal/index.js';
2
+ export * from './provider/index.js';
2
3
  export * from '@getpara/web-sdk';
3
4
  export type { Theme } from '@getpara/react-components';
4
5
  import ParaWeb from '@getpara/web-sdk';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './modal/index.js';
2
+ export * from './provider/index.js';
2
3
  export * from '@getpara/web-sdk';
3
4
  import ParaWeb from '@getpara/web-sdk';
4
5
  export default ParaWeb;
@@ -22,20 +22,47 @@ import { jsx as _jsx } from "react/jsx-runtime";
22
22
  import { CpslAuthModal, defineCustomElements, generateTheme } from '@getpara/react-components';
23
23
  import { ModalContent } from './components/index.js';
24
24
  import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
25
- import { useParaStore, useModalStore, useUserInfoStore, useThemeStore } from './stores/index.js';
25
+ import { useModalStore, useUserInfoStore, useThemeStore } from './stores/index.js';
26
26
  import { ModalStep, RESET_TO_ACCOUNT_STEPS, RESET_TO_AUTH_STEPS } from './utils/steps.js';
27
27
  import { AuthLayout } from './types/modalProps.js';
28
28
  import { DEFAULTS } from './constants/defaults.js';
29
29
  import { useGoBack } from './hooks/useGoBack.js';
30
- import { CURRENT_WALLET_IDS_CHANGE_EVENT, EXTERNAL_WALLET_CHANGE_EVENT } from '@getpara/web-sdk';
30
+ import { ParaEvent } from '@getpara/web-sdk';
31
31
  import { ExternalWalletsWrapper } from './components/ExternalWalletsWrapper/ExternalWalletsWrapper.js';
32
32
  import styled from 'styled-components';
33
33
  import { useExternalWallets } from './providers/ExternalWalletContext.js';
34
34
  import { hasEmbeddedAuth, hasExternalWallet } from './utils/authLayoutHelpers.js';
35
+ import { useModal, useWalletState } from '../provider/index.js';
36
+ import { useStore } from '../provider/stores/useStore.js';
37
+ import { useInternalClient } from '../provider/hooks/utils/useInternalClient.js';
35
38
  defineCustomElements();
36
- export const ParaModal = forwardRef((_a, ref) => {
37
- var { para: _para, isOpen, theme, appName, logo, disableEmailLogin = false, disablePhoneLogin = false, oAuthMethods, bareModal = false, className, currentStepOverride, externalWallets, authLayout = [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL], embeddedModal, onModalStepChange, hideWallets = false, onClose } = _a, rest = __rest(_a, ["para", "isOpen", "theme", "appName", "logo", "disableEmailLogin", "disablePhoneLogin", "oAuthMethods", "bareModal", "className", "currentStepOverride", "externalWallets", "authLayout", "embeddedModal", "onModalStepChange", "hideWallets", "onClose"]);
38
- const para = _para;
39
+ export const ParaModal = forwardRef((_a) => {
40
+ var { para, isOpen } = _a, rest = __rest(_a, ["para", "isOpen"]);
41
+ const [isInitialized, setIsInitialized] = useState(false);
42
+ const setClient = useStore(state => state.setClient);
43
+ const client = useStore(state => state.client);
44
+ const { closeModal, openModal } = useModal();
45
+ useEffect(() => {
46
+ if (!client) {
47
+ setClient(para);
48
+ }
49
+ setIsInitialized(true);
50
+ }, []);
51
+ useEffect(() => {
52
+ if (!isOpen) {
53
+ closeModal();
54
+ }
55
+ if (isOpen) {
56
+ openModal();
57
+ }
58
+ }, [isOpen]);
59
+ if (!isInitialized) {
60
+ return null;
61
+ }
62
+ return _jsx(ParaModalInner, Object.assign({ para: para }, rest));
63
+ });
64
+ const ParaModalInner = forwardRef((_a, ref) => {
65
+ var { theme, appName, logo, disableEmailLogin = false, disablePhoneLogin = false, oAuthMethods, bareModal = false, className, currentStepOverride, externalWallets, authLayout = [AuthLayout.AUTH_FULL, AuthLayout.EXTERNAL_FULL], embeddedModal, onModalStepChange, hideWallets = false, onClose } = _a, rest = __rest(_a, ["theme", "appName", "logo", "disableEmailLogin", "disablePhoneLogin", "oAuthMethods", "bareModal", "className", "currentStepOverride", "externalWallets", "authLayout", "embeddedModal", "onModalStepChange", "hideWallets", "onClose"]);
39
66
  const modalContentRef = useRef(null);
40
67
  const updateThemeState = useThemeStore(state => state.updateState);
41
68
  const setWebAuthURLForLogin = useModalStore(state => state.setWebAuthURLForLogin);
@@ -44,7 +71,6 @@ export const ParaModal = forwardRef((_a, ref) => {
44
71
  const currentStep = useModalStore(state => state.step);
45
72
  const setOnModalStepChange = useModalStore(state => state.setOnModalStepChange);
46
73
  const setStep = useModalStore(state => state.setStep);
47
- const setPara = useParaStore(state => state.setPara);
48
74
  const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
49
75
  const hasPreviousStep = useModalStore(state => state.hasPreviousStep());
50
76
  const setFlow = useModalStore(state => state.setFlow);
@@ -55,8 +81,10 @@ export const ParaModal = forwardRef((_a, ref) => {
55
81
  const resetModalState = useModalStore(state => state.resetState);
56
82
  const resetUserInfoState = useUserInfoStore(state => state.resetState);
57
83
  const setRecoveryShare = useUserInfoStore(state => state.setRecoveryShare);
58
- const [activeWallet, setActiveWallet] = useModalStore(state => [state.activeWallet, state.setActiveWallet]);
59
84
  const { disconnectExternalWallet } = useExternalWallets();
85
+ const { isOpen, closeModal } = useModal();
86
+ const para = useInternalClient();
87
+ const { selectedWallet, setSelectedWallet } = useWalletState();
60
88
  const [isModalMounted, setIsModalMounted] = useState(false);
61
89
  const [isInit, setIsInit] = useState(false);
62
90
  useImperativeHandle(ref, () => {
@@ -97,7 +125,7 @@ export const ParaModal = forwardRef((_a, ref) => {
97
125
  }
98
126
  // Disconnect external wallets if the user is not longer logged in
99
127
  yield disconnectExternalWallet();
100
- setActiveWallet([undefined, undefined]);
128
+ setSelectedWallet({ id: undefined, type: undefined });
101
129
  setIsFullyLoggedIn(false);
102
130
  }
103
131
  switch (true) {
@@ -159,7 +187,6 @@ export const ParaModal = forwardRef((_a, ref) => {
159
187
  useEffect(() => {
160
188
  if (para) {
161
189
  initModal();
162
- setPara(para);
163
190
  if (bareModal) {
164
191
  setIsModalMounted(true);
165
192
  }
@@ -175,23 +202,27 @@ export const ParaModal = forwardRef((_a, ref) => {
175
202
  }
176
203
  }, [isOpen]);
177
204
  const updateActiveWallet = () => {
178
- if (!activeWallet[0] || !para.findWallet(activeWallet[0])) {
205
+ if (!(selectedWallet === null || selectedWallet === void 0 ? void 0 : selectedWallet.id) || !para.findWallet(selectedWallet === null || selectedWallet === void 0 ? void 0 : selectedWallet.id)) {
179
206
  const defaultWallet = para.findWallet(undefined, undefined, { forbidPregen: true });
180
- defaultWallet && setActiveWallet([defaultWallet.id, defaultWallet.type]);
207
+ setSelectedWallet({ id: defaultWallet === null || defaultWallet === void 0 ? void 0 : defaultWallet.id, type: defaultWallet === null || defaultWallet === void 0 ? void 0 : defaultWallet.type });
181
208
  }
182
209
  };
183
210
  useEffect(() => {
184
- setPara(para);
185
211
  updateActiveWallet();
186
212
  }, [para]);
187
213
  useEffect(() => {
188
- window.addEventListener(CURRENT_WALLET_IDS_CHANGE_EVENT, updateActiveWallet);
189
- window.addEventListener(EXTERNAL_WALLET_CHANGE_EVENT, updateActiveWallet);
214
+ // TODO: remove this redundant listener once we force the use of the ParaProvider
215
+ window.addEventListener(ParaEvent.WALLETS_CHANGE_EVENT, updateActiveWallet);
216
+ window.addEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, updateActiveWallet);
190
217
  return () => {
191
- window.removeEventListener(CURRENT_WALLET_IDS_CHANGE_EVENT, updateActiveWallet);
192
- window.removeEventListener(EXTERNAL_WALLET_CHANGE_EVENT, updateActiveWallet);
218
+ window.removeEventListener(ParaEvent.WALLETS_CHANGE_EVENT, updateActiveWallet);
219
+ window.removeEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, updateActiveWallet);
193
220
  };
194
221
  }, []);
222
+ const handleClose = () => {
223
+ closeModal();
224
+ onClose === null || onClose === void 0 ? void 0 : onClose();
225
+ };
195
226
  const handleModalEntering = () => {
196
227
  setIsModalMounted(true);
197
228
  };
@@ -233,7 +264,7 @@ export const ParaModal = forwardRef((_a, ref) => {
233
264
  }
234
265
  return null;
235
266
  }
236
- return (_jsx(ExternalWalletsWrapper, { wallets: externalWallets, children: _jsx(StyledAuthModal, { enterTransitionDuration: DEFAULTS.ANIMATION_DURATION, exitTransitionDuration: DEFAULTS.ANIMATION_DURATION, open: isOpen, onCpslModalExited: handleModalExited, onCpslModalEntering: handleModalEntering, onCpslModalRequestClose: onClose, noOverlay: bareModal, className: className, "data-testid": "modal", "$embeddedModal": embeddedModal, children: isModalMounted && ((isInit && embeddedModal) || !embeddedModal) && (_jsx(ModalContent, Object.assign({ oAuthMethods: oAuthMethods, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin, onClose: onClose }, rest))) }) }));
267
+ return (_jsx(ExternalWalletsWrapper, { wallets: externalWallets, children: _jsx(StyledAuthModal, { enterTransitionDuration: DEFAULTS.ANIMATION_DURATION, exitTransitionDuration: DEFAULTS.ANIMATION_DURATION, open: isOpen, onCpslModalExited: handleModalExited, onCpslModalEntering: handleModalEntering, onCpslModalRequestClose: handleClose, noOverlay: bareModal, className: className, "data-testid": "modal", "$embeddedModal": embeddedModal, children: isModalMounted && ((isInit && embeddedModal) || !embeddedModal) && (_jsx(ModalContent, Object.assign({ oAuthMethods: oAuthMethods, disableEmailLogin: disableEmailLogin, disablePhoneLogin: disablePhoneLogin, onClose: handleClose }, rest))) }) }));
237
268
  });
238
269
  const StyledAuthModal = styled(CpslAuthModal) `
239
270
  ${({ $embeddedModal }) => $embeddedModal &&
@@ -11,16 +11,17 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
11
11
  import styled from 'styled-components';
12
12
  import { InnerStepContainer, StepContainer, StyledCpslTileButton } from '../common.js';
13
13
  import { CpslButton, CpslIcon, CpslSpinner, CpslText } from '@getpara/react-components';
14
- import { useParaStore, useModalStore, useThemeStore } from '../../stores/index.js';
14
+ import { useModalStore, useThemeStore } from '../../stores/index.js';
15
15
  import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
16
16
  import { useState } from 'react';
17
17
  import { ModalStep } from '../../utils/steps.js';
18
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
18
19
  export const Account = ({ onClose }) => {
19
20
  const onRampConfig = useModalStore(state => state.onRampConfig);
20
21
  const setStep = useModalStore(state => state.setStep);
21
- const para = useParaStore(state => state.para);
22
22
  const hideWallets = useThemeStore(state => state.hideWallets);
23
23
  const { disconnectExternalWallet } = useExternalWallets();
24
+ const para = useInternalClient();
24
25
  const [isDisconnecting, setIsDisconnecting] = useState(false);
25
26
  const isOnRampLoaded = !!onRampConfig;
26
27
  const handleBuyClick = () => {
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
11
11
  import { EnabledFlow, getOnRampAssets, getOnRampNetworks, OnRampProvider, OnRampPurchaseType, toAssetInfoArray, WalletType, } from '@getpara/web-sdk';
12
12
  import { CenteredText, FilledDisabledInput, Heading, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
13
13
  import { CpslButton, CpslDivider, CpslIcon, CpslIdenticon, CpslQrCode, CpslSpinner, CpslTab, CpslTabs, CpslText, } from '@getpara/react-components';
14
- import { useParaStore, useModalStore, useThemeStore } from '../../stores/index.js';
14
+ import { useModalStore, useThemeStore } from '../../stores/index.js';
15
15
  import { useEffect, useMemo } from 'react';
16
16
  import { OnRampProviderButton } from '../OnRampComponents/OnRampProviderButton.js';
17
17
  import { isMobile } from '@getpara/web-sdk';
@@ -22,6 +22,7 @@ import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
22
22
  import { getNetworkFromChainId, getNetworkOrMainNetEquivalent, useCopyToClipboard } from '@getpara/react-common';
23
23
  import { formatNetworkList } from '../../utils/stringFormatters.js';
24
24
  import styled from 'styled-components';
25
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
25
26
  const TABS = [
26
27
  [EnabledFlow.BUY, 'isBuyEnabled', 'creditCard', 'Buy'],
27
28
  [EnabledFlow.RECEIVE, 'isReceiveEnabled', 'qrCode', 'Receive'],
@@ -34,7 +35,7 @@ const GENERIC_WALLET = {
34
35
  };
35
36
  export const AddFunds = () => {
36
37
  const [isCopied, copy] = useCopyToClipboard();
37
- const para = useParaStore(state => state.para);
38
+ const para = useInternalClient();
38
39
  const appName = useThemeStore(state => state.appName);
39
40
  const onRampConfig = useModalStore(state => state.onRampConfig);
40
41
  const hideWallets = useThemeStore(state => state.hideWallets);
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { StepContainer } from '../common.js';
3
3
  import { OnRampProvider } from '@getpara/web-sdk';
4
- import { useParaStore, useModalStore, useThemeStore } from '../../stores/index.js';
4
+ import { useModalStore, useThemeStore } from '../../stores/index.js';
5
5
  import { lazy, useEffect, useMemo, useState } from 'react';
6
6
  import { ModalStep } from '../../utils/steps.js';
7
7
  import { RampEmbed, StripeEmbed } from '@getpara/react-common';
8
8
  import styled from 'styled-components';
9
9
  import { useGoBack } from '../../hooks/useGoBack.js';
10
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
10
11
  const STEPS = {
11
12
  CANCELLED: ModalStep.ADD_FUNDS_FAILURE,
12
13
  FINISHED: ModalStep.ADD_FUNDS_SUCCESS,
@@ -17,7 +18,7 @@ export const AddFundsAwaiting = () => {
17
18
  const onRampConfig = useModalStore(state => state.onRampConfig);
18
19
  const onRampPurchase = useModalStore(state => state.onRampPurchase);
19
20
  const setOnRampPurchase = useModalStore(state => state.setOnRampPurchase);
20
- const para = useParaStore(state => state.para);
21
+ const para = useInternalClient();
21
22
  const appName = useThemeStore(state => state.appName);
22
23
  const isDark = useThemeStore(state => state.isDark);
23
24
  const [MoonPayEmbed, setMoonPayEmbed] = useState(null);
@@ -12,18 +12,19 @@ import { CpslButton, CpslIcon, CpslInput, CpslSelect, CpslSelectItem, CpslSpinne
12
12
  import { useRef, useState } from 'react';
13
13
  import styled from 'styled-components';
14
14
  import countryCodes from './countryCodes.js';
15
- import { useParaStore, useModalStore, useUserInfoStore } from '../../stores/index.js';
15
+ import { useModalStore, useUserInfoStore } from '../../stores/index.js';
16
16
  import { EMAIL_REGEX, MOBILE_SIZE } from '../../constants/constants.js';
17
17
  import { useDropdownPosition } from './hooks/useDropdownPosition.js';
18
18
  import { ModalStep } from '../../utils/steps.js';
19
19
  import { defaultPhoneMask, phoneMasks } from './phoneMasks.js';
20
20
  import { AuthMethod } from '@getpara/web-sdk';
21
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
21
22
  const DEFAULT_COUNTRY = { label: 'United States', value: '+1', selectedLabel: 'US', icon: 'US' };
22
23
  export const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
23
24
  var _a;
24
25
  const inputRef = useRef(null);
25
26
  const { dropdownMaxHeight, dropdownWidth } = useDropdownPosition(inputRef);
26
- const para = useParaStore(state => state.para);
27
+ const para = useInternalClient();
27
28
  const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
28
29
  const authInfo = useUserInfoStore(state => state.getAuthInfo());
29
30
  const setFlow = useModalStore(state => state.setFlow);
@@ -93,11 +94,12 @@ export const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
93
94
  setError('Please enter a valid email!');
94
95
  return;
95
96
  }
96
- // Logout to ensure cleared Para state but preserve pregen wallets
97
+ // Logout to ensure cleared Capsule state but preserve pregen wallets
98
+ // TODO: migrate to hook once we force the use of the CapsuleProvider
97
99
  yield para.logout();
98
100
  auth = { email: identifier };
99
101
  setAuthInfo(auth);
100
- const userExists = yield para.checkIfUserExists(identifier);
102
+ const userExists = yield para.checkIfUserExists({ email: identifier });
101
103
  if (userExists) {
102
104
  const supportedAuthMethods = yield para.initiateUserLoginV2(auth);
103
105
  const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
@@ -109,16 +111,19 @@ export const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
109
111
  setBiometricLocationHints(biometricLocationHints);
110
112
  return;
111
113
  }
114
+ // TODO: migrate to hook once we force the use of the CapsuleProvider
112
115
  yield para.createUser(auth);
113
116
  setFlow('signUp');
114
117
  setStep(ModalStep.VERIFICATIONS);
115
118
  return;
116
119
  }
117
120
  if (isPhone) {
121
+ // Logout to ensure cleared Capsule state but preserve pregen wallets
122
+ // TODO: migrate to hook once we force the use of the CapsuleProvider
118
123
  yield para.logout();
119
124
  let userExists = false;
120
125
  try {
121
- userExists = yield para.checkIfUserExistsByPhone(identifier, countryCode);
126
+ userExists = yield para.checkIfUserExistsByPhone({ phone: identifier, countryCode });
122
127
  }
123
128
  catch (error) {
124
129
  setError('Please enter a valid phone number!');
@@ -127,6 +132,7 @@ export const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
127
132
  auth = { phone: identifier, countryCode };
128
133
  setAuthInfo(auth);
129
134
  if (userExists) {
135
+ // TODO: migrate to hook once we force the use of the CapsuleProvider
130
136
  const supportedAuthMethods = yield para.initiateUserLoginV2(auth);
131
137
  const biometricLocationHints = supportedAuthMethods.has(AuthMethod.PASSKEY)
132
138
  ? yield para.getUserBiometricLocationHints()
@@ -137,6 +143,7 @@ export const AuthInput = ({ disableEmailLogin, disablePhoneLogin }) => {
137
143
  setBiometricLocationHints(biometricLocationHints);
138
144
  return;
139
145
  }
146
+ // TODO: migrate to hook once we force the use of the CapsuleProvider
140
147
  yield para.createUserByPhone(auth);
141
148
  setFlow('signUp');
142
149
  setStep(ModalStep.VERIFICATIONS);
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
11
  import { CpslButton, CpslDivider, CpslIcon } from '@getpara/react-components';
12
12
  import { useEffect, useMemo, useState } from 'react';
13
- import { useParaStore, useModalStore, useUserInfoStore } from '../../stores/index.js';
13
+ import { useModalStore, useUserInfoStore } from '../../stores/index.js';
14
14
  import { ModalStep } from '../../utils/steps.js';
15
15
  import { Heading, StepContainer, InnerStepContainer } from '../common.js';
16
16
  import { openPopup } from '../../utils/openPopup.js';
@@ -18,6 +18,7 @@ import styled from 'styled-components';
18
18
  import { AuthMethod, getPublicKeyHex } from '@getpara/web-sdk';
19
19
  import { isPasskeySupported } from '../../utils/isPasskeySupported.js';
20
20
  import { formatBiometricHints, KnownDevices, UserIdentifier } from '@getpara/react-common';
21
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
21
22
  export const BiometricLoginStep = () => {
22
23
  const popupWindow = useModalStore(state => state.popupWindow);
23
24
  const supportedAuthMethods = useModalStore(state => state.supportedAuthMethods);
@@ -26,7 +27,7 @@ export const BiometricLoginStep = () => {
26
27
  const setStep = useModalStore(state => state.setStep);
27
28
  const setPopupWindow = useModalStore(state => state.setPopupWindow);
28
29
  const biometricLocationHints = useModalStore(state => state.biometricLocationHints);
29
- const para = useParaStore(state => state.para);
30
+ const para = useInternalClient();
30
31
  const authInfo = useUserInfoStore(state => state.getAuthInfo());
31
32
  const setWebAuthURLForLogin = useModalStore(state => state.setWebAuthURLForLogin);
32
33
  const setPasswordUrlForLogin = useModalStore(state => state.setPasswordUrlForLogin);
@@ -47,6 +48,9 @@ export const BiometricLoginStep = () => {
47
48
  if (!para.isEmail && !para.isPhone && !para.isFarcaster && !para.isTelegram) {
48
49
  return;
49
50
  }
51
+ if (!para.loginEncryptionKeyPair) {
52
+ return;
53
+ }
50
54
  const authType = para.isEmail ? 'email' : para.isPhone ? 'phone' : para.isFarcaster ? 'farcaster' : 'telegram';
51
55
  const res = yield para.touchSession();
52
56
  const webAuthUrlForLogin = (supportedAuthMethods === null || supportedAuthMethods === void 0 ? void 0 : supportedAuthMethods.has) && supportedAuthMethods.has(AuthMethod.PASSKEY)
@@ -91,7 +95,7 @@ export const BiometricLoginStep = () => {
91
95
  });
92
96
  }
93
97
  setLinks();
94
- }, [supportedAuthMethods]);
98
+ }, [supportedAuthMethods, para]);
95
99
  const handlePasskeyClick = () => {
96
100
  if (!!popupWindow) {
97
101
  return;
@@ -11,12 +11,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { CpslIdenticon, CpslSelect, CpslSelectItem, CpslText } from '@getpara/react-components';
12
12
  import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
13
13
  import styled from 'styled-components';
14
- import { useParaStore, useModalStore, useThemeStore } from '../../stores/index.js';
14
+ import { useThemeStore } from '../../stores/index.js';
15
15
  import { truncateAddress, WalletType } from '@getpara/web-sdk';
16
16
  import { useEffect, useRef } from 'react';
17
17
  import { useDropdownPosition } from '../AuthInput/hooks/useDropdownPosition.js';
18
18
  import { MOBILE_SIZE } from '../../constants/constants.js';
19
19
  import { useActiveWallet } from '../../hooks/useActiveWallet.js';
20
+ import { useWalletState } from '../../../provider/index.js';
21
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
20
22
  const getValue = (id, type) => {
21
23
  return id && type ? `${id}~${type}` : undefined;
22
24
  };
@@ -56,10 +58,10 @@ function getName(para, { type, isExternal, name, isMenu = false, hideWallets = f
56
58
  }
57
59
  export const AccountSelect = () => {
58
60
  const hideWallets = useThemeStore(state => state.hideWallets);
59
- const para = useParaStore(state => state.para);
61
+ const para = useInternalClient();
60
62
  const containerRef = useRef(null);
61
63
  const { dropdownMaxHeight, dropdownWidth, mobileAnchor, resize } = useDropdownPosition(containerRef);
62
- const setActiveWallet = useModalStore(state => state.setActiveWallet);
64
+ const { setSelectedWallet } = useWalletState();
63
65
  const activeWallet = useActiveWallet();
64
66
  const ActiveWalletNode = activeWallet ? (_jsxs(FlexRow, { slot: "selected-item", children: [_jsx(CpslIdenticon, { variant: "avatar", size: "14px", hash: para.getIdenticonHash(activeWallet.id, activeWallet.type) }), _jsx(WalletName, { variant: "bodyXS", color: "contrast", children: getName(para, Object.assign(Object.assign({}, activeWallet), { hideWallets })) }), !hideWallets && (_jsx(CpslText, { variant: "bodyXS", color: "secondary", children: para.getDisplayAddress(activeWallet.id, { truncate: true, addressType: activeWallet.type }) }))] })) : null;
65
67
  useEffect(() => {
@@ -69,7 +71,7 @@ export const AccountSelect = () => {
69
71
  }, [activeWallet, para.availableWallets, dropdownMaxHeight]);
70
72
  return (_jsx(Container, { children: _jsx(SelectContainer, { ref: containerRef, id: "addressInputContainer", children: para.availableWallets.length > 1 ? (_jsxs(StyledSelect, { selectedValue: getValue(activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.id, activeWallet === null || activeWallet === void 0 ? void 0 : activeWallet.type), onCpslSelectValueChange: e => {
71
73
  const [id, type] = e.detail.split('~');
72
- setActiveWallet([id, type]);
74
+ setSelectedWallet({ id, type: type });
73
75
  }, showFormattedSelectedItem: true, placeholder: "Choose wallet...", anchorElId: "addressInputContainer", dropdownMaxHeight: dropdownMaxHeight, "$width": dropdownWidth, "$top": mobileAnchor + 16 + 1, autoWidth: true, selectedItemVariant: "bodyXS", children: [activeWallet && ActiveWalletNode, para.availableWallets.map(({ address, name: _name, id, type, isExternal }) => {
74
76
  const key = getValue(id, type);
75
77
  const name = _name !== null && _name !== void 0 ? _name : getName(para, { type, isExternal, isMenu: true, hideWallets });
@@ -14,10 +14,11 @@ import { EvmExternalWalletContext, EvmExternalWalletProvider, } from '../../prov
14
14
  import { CosmosWallet, EvmWallet, SolanaWallet } from '../../types/externalWallets.js';
15
15
  import { SolanaExternalWalletContext, SolanaExternalWalletProvider, } from '../../providers/SolanaExternalWalletContextStub.js';
16
16
  import { CosmosExternalWalletContext, CosmosExternalWalletProvider, } from '../../providers/CosmosExternalWalletContextStub.js';
17
- import { useParaStore, useModalStore, useUserInfoStore } from '../../stores/index.js';
17
+ import { useModalStore, useUserInfoStore } from '../../stores/index.js';
18
18
  import { useExternalWalletProviderStore } from '../../stores/externalWalletProvider/useExternalWalletProviderStore.js';
19
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
19
20
  export const ExternalWalletsWrapper = ({ children, wallets }) => {
20
- const para = useParaStore(state => state.para);
21
+ const para = useInternalClient();
21
22
  const resetModalState = useModalStore(state => state.resetState);
22
23
  const resetUserInfoState = useUserInfoStore(state => state.resetState);
23
24
  const StoredEvmProvider = useExternalWalletProviderStore(state => state.EvmProvider);
@@ -2,12 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { CpslHero, CpslIcon, CpslIdenticon } from '@getpara/react-components';
3
3
  import styled from 'styled-components';
4
4
  import { ModalStep } from '../../utils/steps.js';
5
- import { useParaStore, useModalStore } from '../../stores/index.js';
5
+ import { useModalStore } from '../../stores/index.js';
6
6
  import { useExternalWallets } from '../../providers/ExternalWalletContext.js';
7
7
  import { NETWORK_NOT_SUPPORTED_ERROR } from '../../constants/constants.js';
8
8
  import { useEffect, useState } from 'react';
9
9
  import { isMobile } from '@getpara/web-sdk';
10
10
  import { useActiveWallet } from '../../hooks/useActiveWallet.js';
11
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
11
12
  const getStepConfig = ({ externalWalletError, }) => {
12
13
  var _a;
13
14
  return ({
@@ -38,7 +39,7 @@ const getStepConfig = ({ externalWalletError, }) => {
38
39
  });
39
40
  };
40
41
  export const Hero = () => {
41
- const para = useParaStore(state => state.para);
42
+ const para = useInternalClient();
42
43
  const { wallet: connector, walletDisplayHelpers, avatar } = useExternalWallets();
43
44
  const step = useModalStore(state => state.step);
44
45
  const externalWalletError = useModalStore(state => state.externalWalletError);
@@ -2,10 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect } from 'react';
3
3
  import { Heading, HeroIcon, StepContainer } from '../common.js';
4
4
  import { ExternalWalletCard, WalletCard, WalletCards } from '../WalletCard/WalletCard.js';
5
- import { useParaStore, useThemeStore } from '../../stores/index.js';
5
+ import { useThemeStore } from '../../stores/index.js';
6
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
6
7
  export const LoginDoneStep = ({ onClose }) => {
7
8
  var _a;
8
- const para = useParaStore(state => state.para);
9
+ const para = useInternalClient();
9
10
  const hideWallets = useThemeStore(state => state.hideWallets);
10
11
  useEffect(() => {
11
12
  setTimeout(() => {
@@ -10,13 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
12
12
  import { entityToWallet, OnRampProvider, OnRampAsset, Network, EnabledFlow, } from '@getpara/web-sdk';
13
- import { useParaStore, useModalStore, useUserInfoStore } from '../../stores/index.js';
13
+ import { useModalStore, useUserInfoStore } from '../../stores/index.js';
14
14
  import { ModalStep } from '../../utils/steps.js';
15
15
  import { Body } from '../Body/Body.js';
16
16
  import { Footer } from '../Footer/Footer.js';
17
17
  import { DEFAULTS } from '../../constants/defaults.js';
18
18
  import { useGoBack } from '../../hooks/useGoBack.js';
19
19
  import { openPopup } from '../../utils/openPopup.js';
20
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
20
21
  import { useEmbeddedExternalConnection } from '../../hooks/useEmbeddedExternalConnection.js';
21
22
  function isRampConfig(config) {
22
23
  return 'hostApiKey' in config;
@@ -39,7 +40,7 @@ const AssetMap = {
39
40
  ETHEREUM: OnRampAsset.ETHEREUM,
40
41
  };
41
42
  export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFactorAuthEnabled = false, recoverySecretStepEnabled = false, oAuthMethods, disableEmailLogin, disablePhoneLogin, onClose, onRampTestMode, loginTransitionOverride, createWalletOverride, }, ref) => {
42
- const para = useParaStore(state => state.para);
43
+ const para = useInternalClient();
43
44
  const currentStep = useModalStore(state => state.step);
44
45
  const webAuthURLForLogin = useModalStore(state => state.webAuthURLForLogin);
45
46
  const webAuthURLForCreate = useModalStore(state => state.webAuthURLForCreate);
@@ -86,6 +87,7 @@ export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFa
86
87
  });
87
88
  function awaitLoginTransition() {
88
89
  return __awaiter(this, void 0, void 0, function* () {
90
+ // TODO: migrate to useWaitForLoginAndSetup hook once we force the use of the CapsuleProvider
89
91
  const { isComplete, isError, needsWallet } = yield para.waitForLoginAndSetup({ popupWindow });
90
92
  setPopupWindow(undefined);
91
93
  if (isError) {
@@ -114,6 +116,7 @@ export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFa
114
116
  }
115
117
  function awaitWalletCreationTransition() {
116
118
  return __awaiter(this, void 0, void 0, function* () {
119
+ // TODO: migrate to useWaitForAccountCreation hook once we force the use of the ParaProvider
117
120
  const isComplete = yield para.waitForAccountCreation();
118
121
  if (isComplete) {
119
122
  setWebAuthURLForCreate('');
@@ -132,6 +135,7 @@ export const ModalContent = forwardRef(({ onRampConfig: propsOnRampConfig, twoFa
132
135
  setWalletCreationInProgress(true);
133
136
  let recoverySecret, walletIds;
134
137
  if (!createWalletOverride) {
138
+ // TODO: migrate to useWaitForPasskeyAndCreateWallet hook once we force the use of the ParaProvider
135
139
  const created = yield para.waitForPasskeyAndCreateWallet();
136
140
  recoverySecret = created.recoverySecret;
137
141
  walletIds = created.walletIds;
@@ -11,9 +11,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
11
11
  import { useEffect, useState } from 'react';
12
12
  import { CpslButton, CpslIcon, CpslQrCode, CpslSpinner, CpslText } from '@getpara/react-components';
13
13
  import { CenteredText, Heading, InnerStepContainer, QRContainer, StepContainer } from '../common.js';
14
- import { useParaStore, useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
14
+ import { useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
15
15
  import { ModalStep } from '../../utils/steps.js';
16
16
  import { AuthMethod, isMobile } from '@getpara/web-sdk';
17
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
17
18
  const FarcasterOAuthStep = () => {
18
19
  const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
19
20
  const setStep = useModalStore(state => state.setStep);
@@ -23,7 +24,7 @@ const FarcasterOAuthStep = () => {
23
24
  const isIFrameReady = useModalStore(state => state.isIFrameReady);
24
25
  const setSupportedAuthMethods = useModalStore(state => state.setSupportedAuthMethods);
25
26
  const setBiometricLocationHints = useModalStore(state => state.setBiometricLocationHints);
26
- const para = useParaStore(state => state.para);
27
+ const para = useInternalClient();
27
28
  const setFlow = useModalStore(state => state.setFlow);
28
29
  const farcasterConnectUri = useModalStore(state => state.farcasterConnectUri);
29
30
  const setFarcasterConnectUri = useModalStore(state => state.setFarcasterConnectUri);
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { AuthMethod, OAuthMethod } from '@getpara/web-sdk';
12
12
  import { styled } from 'styled-components';
13
- import { useParaStore, useModalStore, useUserInfoStore } from '../../stores/index.js';
13
+ import { useModalStore, useUserInfoStore } from '../../stores/index.js';
14
14
  import { ModalStep } from '../../utils/steps.js';
15
15
  import { openPopup } from '../../utils/openPopup.js';
16
16
  import { useThemeStore } from '../../stores/theme/useThemeStore.js';
@@ -20,12 +20,13 @@ import { brandedOAuthLogos, oAuthLogos } from '../../constants/oAuthLogos.js';
20
20
  import { useEffect } from 'react';
21
21
  import { routeMobileExternalWallet } from '../../utils/routeMobileExternalWallet.js';
22
22
  import { useGoBack } from '../../hooks/useGoBack.js';
23
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
23
24
  const HAS_MORE_LENGTH = 3;
24
25
  export const OAuth = ({ methods }) => {
25
26
  const goBack = useGoBack();
26
27
  const oAuthLogoVariant = useThemeStore(state => state.oAuthLogoVariant);
27
28
  const isDark = useThemeStore(state => state.isDark);
28
- const para = useParaStore(state => state.para);
29
+ const para = useInternalClient();
29
30
  const popupWindow = useModalStore(state => state.popupWindow);
30
31
  const setFlow = useModalStore(state => state.setFlow);
31
32
  const setStep = useModalStore(state => state.setStep);
@@ -68,7 +69,7 @@ export const OAuth = ({ methods }) => {
68
69
  break;
69
70
  default: {
70
71
  setStep(ModalStep.AWAITING_OAUTH);
71
- const oAuthURL = yield para.getOAuthURL(method);
72
+ const oAuthURL = yield para.getOAuthURL({ method });
72
73
  const oAuthWindow = openPopup(oAuthURL, `${method}AuthPopup`, 'OAUTH');
73
74
  setPopupWindow(oAuthWindow);
74
75
  const { email, isError, userExists } = yield para.waitForOAuth({ popupWindow: oAuthWindow });
@@ -9,15 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { AuthMethod, OAuthMethod } from '@getpara/web-sdk';
12
- import { useParaStore, useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
12
+ import { useModalStore, useThemeStore, useUserInfoStore } from '../../stores/index.js';
13
13
  import styled from 'styled-components';
14
14
  import { useEffect, useRef, useState } from 'react';
15
15
  import { HeroSpinner } from '@getpara/react-common';
16
16
  import { ModalStep } from '../../utils/steps.js';
17
17
  import { CpslSpinner } from '@getpara/react-components';
18
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
18
19
  export function TelegramOAuthStep() {
19
20
  const iframe = useRef();
20
- const para = useParaStore(state => state.para);
21
+ const para = useInternalClient();
21
22
  const setFlow = useModalStore(state => state.setFlow);
22
23
  const setStep = useModalStore(state => state.setStep);
23
24
  const setAuthInfo = useUserInfoStore(state => state.setAuthInfo);
@@ -43,7 +44,7 @@ export function TelegramOAuthStep() {
43
44
  }, [shouldRouteToStep, isIFrameReady]);
44
45
  useEffect(() => {
45
46
  if (!url) {
46
- para.getOAuthURL(OAuthMethod.TELEGRAM).then(url => {
47
+ para.getOAuthURL({ method: OAuthMethod.TELEGRAM }).then(url => {
47
48
  setUrl(url);
48
49
  });
49
50
  }
@@ -10,15 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
11
  import { CpslButton, CpslCodeInput, CpslDivider, CpslIcon, CpslQrCode, CpslSpinner, CpslText, } from '@getpara/react-components';
12
12
  import { useEffect, useRef, useState } from 'react';
13
- import { useParaStore, useModalStore } from '../../stores/index.js';
13
+ import { useModalStore } from '../../stores/index.js';
14
14
  import { Heading, QRContainer, FilledDisabledInput, StepContainer, InnerStepContainer } from '../common.js';
15
15
  import { ModalStep } from '../../utils/steps.js';
16
16
  import { styled } from 'styled-components';
17
17
  import { useCopyToClipboard } from '@getpara/react-common';
18
+ import { useInternalClient } from '../../../provider/hooks/utils/useInternalClient.js';
18
19
  export const Setup2FAStep = ({ onClose }) => {
19
20
  const isLogin = useModalStore(state => state.isLogin());
20
21
  const setStep = useModalStore(state => state.setStep);
21
- const para = useParaStore(state => state.para);
22
+ const para = useInternalClient();
22
23
  const isVerifying = useModalStore(state => state.step === ModalStep.VERIFY_2FA);
23
24
  const [copied, copy] = useCopyToClipboard();
24
25
  const inputRef = useRef(null);
@@ -75,7 +76,7 @@ export const Setup2FAStep = ({ onClose }) => {
75
76
  setIsVerifyingCode(true);
76
77
  if (code.length === 6 && /^\d+$/.test(code)) {
77
78
  try {
78
- yield para.enable2FA(code);
79
+ yield para.enable2FA({ verificationCode: code });
79
80
  setStep(ModalStep.TWO_FACTOR_DONE);
80
81
  }
81
82
  catch (e) {