@getpara/react-sdk 1.6.1-dev.0 → 1.7.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 (155) hide show
  1. package/dist/{modal/components/AddFunds/MoonPayEmbed.js → MoonPayEmbed-Q2HP2BFI.js} +3 -1
  2. package/dist/MoonPayEmbed-Q2HP2BFI.js.br +0 -0
  3. package/dist/MoonPayEmbed-Q2HP2BFI.js.gz +0 -0
  4. package/dist/chunk-MMUBH76A.js.br +0 -0
  5. package/dist/chunk-MMUBH76A.js.gz +0 -0
  6. package/dist/index.js +6657 -6
  7. package/dist/index.js.br +0 -0
  8. package/dist/index.js.gz +0 -0
  9. package/dist/modal/components/ExternalWalletVerificationStep/ExternalWalletVerificationStep.d.ts +1 -0
  10. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.d.ts +2 -1
  11. package/dist/modal/components/common.d.ts +4 -0
  12. package/dist/modal/index.d.ts +1 -0
  13. package/dist/modal/providers/CosmosExternalWalletContextStub.d.ts +13 -0
  14. package/dist/modal/providers/EvmExternalWalletContextStub.d.ts +11 -0
  15. package/dist/modal/providers/ExternalWalletContext.d.ts +15 -1
  16. package/dist/modal/providers/SolanaExternalWalletContextStub.d.ts +11 -0
  17. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.d.ts +2 -0
  18. package/dist/modal/types/commonTypes.d.ts +12 -2
  19. package/dist/modal/types/externalWallets.d.ts +2 -0
  20. package/dist/modal/types/modalProps.d.ts +6 -0
  21. package/dist/modal/utils/steps.d.ts +2 -0
  22. package/dist/provider/utils/constants.d.ts +5 -0
  23. package/package.json +5 -5
  24. package/dist/modal/ParaModal.js +0 -337
  25. package/dist/modal/components/Account/Account.js +0 -69
  26. package/dist/modal/components/AddFunds/AddFunds.js +0 -220
  27. package/dist/modal/components/AddFunds/AddFundsAwaiting.js +0 -72
  28. package/dist/modal/components/AddFunds/AddFundsDone.js +0 -43
  29. package/dist/modal/components/AddFunds/index.js +0 -4
  30. package/dist/modal/components/AuthInput/AuthInput.js +0 -283
  31. package/dist/modal/components/AuthInput/countryCodes.js +0 -42
  32. package/dist/modal/components/AuthInput/hooks/useDropdownPosition.js +0 -33
  33. package/dist/modal/components/AuthInput/phoneMasks.js +0 -253
  34. package/dist/modal/components/AuthMainStep/AuthMainStep.js +0 -37
  35. package/dist/modal/components/AuthMainStep/AuthMainStepContent.js +0 -113
  36. package/dist/modal/components/AuthOptions/AuthOptions.js +0 -33
  37. package/dist/modal/components/AwaitingBiometricsStep/AwaitingBiometricsStep.js +0 -18
  38. package/dist/modal/components/AwaitingOAuthStep/AwaitingOAuthStep.js +0 -10
  39. package/dist/modal/components/AwaitingPasswordStep/AwaitingPasswordStep.js +0 -18
  40. package/dist/modal/components/AwaitingWalletCreationStep/AwaitingWalletCreationStep.js +0 -44
  41. package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +0 -52
  42. package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +0 -93
  43. package/dist/modal/components/Body/AnimatedHeightWrapper.js +0 -29
  44. package/dist/modal/components/Body/Body.js +0 -304
  45. package/dist/modal/components/ChainSwitch/ChainSwitch.js +0 -94
  46. package/dist/modal/components/ChainSwitch/config.js +0 -17
  47. package/dist/modal/components/Controls/Controls.js +0 -74
  48. package/dist/modal/components/Controls/Selects.js +0 -213
  49. package/dist/modal/components/ExternalWalletStep/ExternalWalletStep.js +0 -151
  50. package/dist/modal/components/ExternalWalletStep/config.js +0 -17
  51. package/dist/modal/components/ExternalWallets/ExternalWallets.js +0 -172
  52. package/dist/modal/components/ExternalWalletsWrapper/ExternalWalletsWrapper.js +0 -123
  53. package/dist/modal/components/Footer/Footer.js +0 -93
  54. package/dist/modal/components/Header/Header.js +0 -43
  55. package/dist/modal/components/Header/hooks/useStepTitle.js +0 -50
  56. package/dist/modal/components/Hero/Hero.js +0 -122
  57. package/dist/modal/components/IFrameStep/IFrameStep.js +0 -55
  58. package/dist/modal/components/LoginDoneStep/LoginDoneStep.js +0 -28
  59. package/dist/modal/components/ModalContent/ModalContent.js +0 -310
  60. package/dist/modal/components/OAuth/FarcasterOAuthStep.js +0 -81
  61. package/dist/modal/components/OAuth/OAuth.js +0 -153
  62. package/dist/modal/components/OAuth/TelegramOAuthStep.js +0 -139
  63. package/dist/modal/components/OnRampComponents/AddingFunds.js +0 -23
  64. package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +0 -77
  65. package/dist/modal/components/RecoverySecretStep/RecoverySecretStep.js +0 -101
  66. package/dist/modal/components/Setup2FAStep/Setup2FAStep.js +0 -141
  67. package/dist/modal/components/StripeComponents/StripeComponents.js +0 -88
  68. package/dist/modal/components/TwoFactorDoneStep/TwoFactorDoneStep.js +0 -24
  69. package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +0 -159
  70. package/dist/modal/components/Waiting/Waiting.js +0 -17
  71. package/dist/modal/components/WalletCard/PartnerIcon.js +0 -34
  72. package/dist/modal/components/WalletCard/WalletCard.js +0 -127
  73. package/dist/modal/components/WalletCreationDoneStep/WalletCreationDoneStep.js +0 -52
  74. package/dist/modal/components/common.js +0 -83
  75. package/dist/modal/components/index.js +0 -2
  76. package/dist/modal/constants/constants.js +0 -111
  77. package/dist/modal/constants/defaults.js +0 -10
  78. package/dist/modal/constants/oAuthLogos.js +0 -24
  79. package/dist/modal/hooks/useActiveWallet.js +0 -15
  80. package/dist/modal/hooks/useCreateAccount.js +0 -72
  81. package/dist/modal/hooks/useEmbeddedExternalConnection.js +0 -39
  82. package/dist/modal/hooks/useGoBack.js +0 -35
  83. package/dist/modal/hooks/useSetLoginURLs.js +0 -45
  84. package/dist/modal/index.js +0 -32
  85. package/dist/modal/providers/CosmosExternalWalletContextStub.js +0 -34
  86. package/dist/modal/providers/EvmExternalWalletContextStub.js +0 -38
  87. package/dist/modal/providers/ExternalWalletContext.js +0 -275
  88. package/dist/modal/providers/SolanaExternalWalletContextStub.js +0 -19
  89. package/dist/modal/stores/externalWalletProvider/actions.js +0 -10
  90. package/dist/modal/stores/externalWalletProvider/useExternalWalletProviderStore.js +0 -20
  91. package/dist/modal/stores/index.js +0 -4
  92. package/dist/modal/stores/modal/actions.js +0 -70
  93. package/dist/modal/stores/modal/useModalStore.js +0 -65
  94. package/dist/modal/stores/theme/actions.js +0 -28
  95. package/dist/modal/stores/theme/useThemeStore.js +0 -21
  96. package/dist/modal/stores/userInfo/actions.js +0 -30
  97. package/dist/modal/stores/userInfo/useUserInfoStore.js +0 -17
  98. package/dist/modal/types/commonTypes.js +0 -1
  99. package/dist/modal/types/externalWallets.js +0 -31
  100. package/dist/modal/types/modalProps.js +0 -12
  101. package/dist/modal/utils/authLayoutHelpers.js +0 -8
  102. package/dist/modal/utils/getMailtoLink.js +0 -10
  103. package/dist/modal/utils/getTileButtonFlex.js +0 -20
  104. package/dist/modal/utils/openPopup.js +0 -60
  105. package/dist/modal/utils/routeMobileExternalWallet.js +0 -31
  106. package/dist/modal/utils/steps.js +0 -228
  107. package/dist/modal/utils/stringFormatters.js +0 -14
  108. package/dist/modal/utils/validateOnRampConfig.js +0 -32
  109. package/dist/provider/ParaProvider.js +0 -22
  110. package/dist/provider/actions/checkIfUserExists.js +0 -21
  111. package/dist/provider/actions/createUser.js +0 -26
  112. package/dist/provider/actions/getAccount.js +0 -22
  113. package/dist/provider/actions/getWallet.js +0 -14
  114. package/dist/provider/actions/initiateLogin.js +0 -20
  115. package/dist/provider/actions/keepSessionAlive.js +0 -20
  116. package/dist/provider/actions/logout.js +0 -17
  117. package/dist/provider/actions/signMessage.js +0 -20
  118. package/dist/provider/actions/signTransaction.js +0 -20
  119. package/dist/provider/actions/waitForAccountCreation.js +0 -21
  120. package/dist/provider/actions/waitForLoginAndSetup.js +0 -24
  121. package/dist/provider/actions/waitForPasskeyAndCreateWallet.js +0 -21
  122. package/dist/provider/hooks/index.js +0 -4
  123. package/dist/provider/hooks/mutations/index.js +0 -24
  124. package/dist/provider/hooks/mutations/useCheckIfUserExists.js +0 -23
  125. package/dist/provider/hooks/mutations/useCreateUser.js +0 -20
  126. package/dist/provider/hooks/mutations/useInitiateLogin.js +0 -23
  127. package/dist/provider/hooks/mutations/useKeepSessionAlive.js +0 -20
  128. package/dist/provider/hooks/mutations/useLogout.js +0 -30
  129. package/dist/provider/hooks/mutations/useSignMessage.js +0 -33
  130. package/dist/provider/hooks/mutations/useSignTransaction.js +0 -33
  131. package/dist/provider/hooks/mutations/useWaitForAccountCreation.js +0 -30
  132. package/dist/provider/hooks/mutations/useWaitForLoginAndSetup.js +0 -30
  133. package/dist/provider/hooks/mutations/useWaitForPasskeyAndCreateWallet.js +0 -30
  134. package/dist/provider/hooks/queries/index.js +0 -8
  135. package/dist/provider/hooks/queries/useAccount.js +0 -21
  136. package/dist/provider/hooks/queries/useWallet.js +0 -22
  137. package/dist/provider/hooks/utils/index.js +0 -10
  138. package/dist/provider/hooks/utils/useAutoSessionKeepAlive.js +0 -74
  139. package/dist/provider/hooks/utils/useClient.js +0 -10
  140. package/dist/provider/hooks/utils/useEventListeners.js +0 -105
  141. package/dist/provider/hooks/utils/useInternalClient.js +0 -10
  142. package/dist/provider/hooks/utils/useModal.js +0 -17
  143. package/dist/provider/hooks/utils/useWalletState.js +0 -33
  144. package/dist/provider/index.js +0 -8
  145. package/dist/provider/stores/getters.js +0 -13
  146. package/dist/provider/stores/slices/client.js +0 -9
  147. package/dist/provider/stores/slices/index.js +0 -4
  148. package/dist/provider/stores/slices/modal.js +0 -9
  149. package/dist/provider/stores/slices/wallet.js +0 -11
  150. package/dist/provider/stores/types.js +0 -1
  151. package/dist/provider/stores/useStore.js +0 -27
  152. package/dist/provider/types/provider.js +0 -1
  153. package/dist/provider/types/query.js +0 -1
  154. package/dist/provider/types/utils.js +0 -1
  155. package/dist/provider/utils/renameMutations.js +0 -16
@@ -1,24 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../chunk-MMUBH76A.js";
5
- const waitForLoginAndSetup = (para, args) => __async(void 0, null, function* () {
6
- if (!para) {
7
- throw new Error("no para instance");
8
- }
9
- if (!args) {
10
- throw new Error("no valid args passed to waitForLoginAndSetup");
11
- }
12
- try {
13
- const resp = yield para.waitForLoginAndSetup(args);
14
- if (resp.isError) {
15
- throw new Error("error during waitForLoginAndSetup");
16
- }
17
- return resp;
18
- } catch (e) {
19
- throw new Error(e);
20
- }
21
- });
22
- export {
23
- waitForLoginAndSetup
24
- };
@@ -1,21 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../chunk-MMUBH76A.js";
5
- const waitForPasskeyAndCreateWallet = (para) => __async(void 0, null, function* () {
6
- if (!para) {
7
- throw new Error("no para instance");
8
- }
9
- try {
10
- const resp = yield para.waitForPasskeyAndCreateWallet();
11
- if (!resp) {
12
- throw new Error("error during waitForAccountCreation");
13
- }
14
- return resp;
15
- } catch (e) {
16
- throw new Error(e);
17
- }
18
- });
19
- export {
20
- waitForPasskeyAndCreateWallet
21
- };
@@ -1,4 +0,0 @@
1
- "use client";
2
- export * from "./utils/index.js";
3
- export * from "./queries/index.js";
4
- export * from "./mutations/index.js";
@@ -1,24 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useWaitForLoginAndSetup } from "./useWaitForLoginAndSetup.js";
4
- import { useWaitForAccountCreation } from "./useWaitForAccountCreation.js";
5
- import { useWaitForPasskeyAndCreateWallet } from "./useWaitForPasskeyAndCreateWallet.js";
6
- import { useCreateUser } from "./useCreateUser.js";
7
- import { useCheckIfUserExists } from "./useCheckIfUserExists.js";
8
- import { useInitiateLogin } from "./useInitiateLogin.js";
9
- import { useLogout } from "./useLogout.js";
10
- import { useKeepSessionAlive } from "./useKeepSessionAlive.js";
11
- import { useSignMessage } from "./useSignMessage.js";
12
- import { useSignTransaction } from "./useSignTransaction.js";
13
- export {
14
- useCheckIfUserExists,
15
- useCreateUser,
16
- useInitiateLogin,
17
- useKeepSessionAlive,
18
- useLogout,
19
- useSignMessage,
20
- useSignTransaction,
21
- useWaitForAccountCreation,
22
- useWaitForLoginAndSetup,
23
- useWaitForPasskeyAndCreateWallet
24
- };
@@ -1,23 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { checkIfUserExists } from "../../actions/checkIfUserExists.js";
8
- import { renameMutations } from "../../utils/renameMutations.js";
9
- const useCheckIfUserExists = () => {
10
- const client = useClient();
11
- const mutation = useMutation({
12
- mutationFn: (args) => __async(void 0, null, function* () {
13
- return yield checkIfUserExists(client, args);
14
- })
15
- });
16
- return renameMutations(
17
- mutation,
18
- "checkIfUserExists"
19
- );
20
- };
21
- export {
22
- useCheckIfUserExists
23
- };
@@ -1,20 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { createUser } from "../../actions/createUser.js";
8
- import { renameMutations } from "../../utils/renameMutations.js";
9
- const useCreateUser = () => {
10
- const client = useClient();
11
- const mutation = useMutation({
12
- mutationFn: (args) => __async(void 0, null, function* () {
13
- return yield createUser(client, args);
14
- })
15
- });
16
- return renameMutations(mutation, "createUser");
17
- };
18
- export {
19
- useCreateUser
20
- };
@@ -1,23 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { initiateLogin } from "../../actions/initiateLogin.js";
8
- import { renameMutations } from "../../utils/renameMutations.js";
9
- const useInitiateLogin = () => {
10
- const client = useClient();
11
- const mutation = useMutation({
12
- mutationFn: (args) => __async(void 0, null, function* () {
13
- return yield initiateLogin(client, args);
14
- })
15
- });
16
- return renameMutations(
17
- mutation,
18
- "initiateLogin"
19
- );
20
- };
21
- export {
22
- useInitiateLogin
23
- };
@@ -1,20 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { keepSessionAlive } from "../../actions/keepSessionAlive.js";
8
- import { renameMutations } from "../../utils/renameMutations.js";
9
- const useKeepSessionAlive = () => {
10
- const client = useClient();
11
- const mutation = useMutation({
12
- mutationFn: () => __async(void 0, null, function* () {
13
- return yield keepSessionAlive(client);
14
- })
15
- });
16
- return renameMutations(mutation, "keepSessionAlive");
17
- };
18
- export {
19
- useKeepSessionAlive
20
- };
@@ -1,30 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { logout } from "../../actions/logout.js";
8
- import { useStore } from "../../stores/useStore.js";
9
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
10
- import { WALLET_BASE_KEY } from "../queries/useWallet.js";
11
- import { renameMutations } from "../../utils/renameMutations.js";
12
- const useLogout = () => {
13
- const client = useClient();
14
- const queryClient = useQueryClient();
15
- const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
16
- const mutation = useMutation({
17
- mutationFn: () => __async(void 0, null, function* () {
18
- return yield logout(client);
19
- }),
20
- onSettled: () => __async(void 0, null, function* () {
21
- yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
22
- yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
23
- clearSelectedWallet();
24
- })
25
- });
26
- return renameMutations(mutation, "logout");
27
- };
28
- export {
29
- useLogout
30
- };
@@ -1,33 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "../../../chunk-MMUBH76A.js";
7
- import { useMutation } from "@tanstack/react-query";
8
- import { useClient, useWallet } from "../index.js";
9
- import { signMessage } from "../../actions/signMessage.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- const useSignMessage = () => {
12
- const client = useClient();
13
- const { data: wallet } = useWallet();
14
- const mutation = useMutation({
15
- mutationFn: (args) => __async(void 0, null, function* () {
16
- let walletId = args == null ? void 0 : args.walletId;
17
- if (!walletId) {
18
- walletId = wallet == null ? void 0 : wallet.id;
19
- }
20
- if (!walletId) {
21
- throw Error("no wallet id found");
22
- }
23
- return yield signMessage(client, __spreadProps(__spreadValues({}, args), { walletId }));
24
- })
25
- });
26
- return renameMutations(
27
- mutation,
28
- "signMessage"
29
- );
30
- };
31
- export {
32
- useSignMessage
33
- };
@@ -1,33 +0,0 @@
1
- "use client";
2
- import {
3
- __async,
4
- __spreadProps,
5
- __spreadValues
6
- } from "../../../chunk-MMUBH76A.js";
7
- import { useMutation } from "@tanstack/react-query";
8
- import { useClient, useWallet } from "../index.js";
9
- import { signTransaction } from "../../actions/signTransaction.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- const useSignTransaction = () => {
12
- const client = useClient();
13
- const { data: wallet } = useWallet();
14
- const mutation = useMutation({
15
- mutationFn: (args) => __async(void 0, null, function* () {
16
- let walletId = args == null ? void 0 : args.walletId;
17
- if (!walletId) {
18
- walletId = wallet == null ? void 0 : wallet.id;
19
- }
20
- if (!walletId) {
21
- throw Error("no wallet id found");
22
- }
23
- return yield signTransaction(client, __spreadProps(__spreadValues({}, args), { walletId }));
24
- })
25
- });
26
- return renameMutations(
27
- mutation,
28
- "signTransaction"
29
- );
30
- };
31
- export {
32
- useSignTransaction
33
- };
@@ -1,30 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { waitForAccountCreation } from "../../actions/waitForAccountCreation.js";
8
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
9
- import { WALLET_BASE_KEY } from "../queries/useWallet.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- const useWaitForAccountCreation = () => {
12
- const client = useClient();
13
- const queryClient = useQueryClient();
14
- const mutation = useMutation({
15
- mutationFn: () => __async(void 0, null, function* () {
16
- return yield waitForAccountCreation(client);
17
- }),
18
- onSettled: () => __async(void 0, null, function* () {
19
- yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
20
- yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
21
- })
22
- });
23
- return renameMutations(
24
- mutation,
25
- "waitForAccountCreation"
26
- );
27
- };
28
- export {
29
- useWaitForAccountCreation
30
- };
@@ -1,30 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { waitForLoginAndSetup } from "../../actions/waitForLoginAndSetup.js";
8
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
9
- import { WALLET_BASE_KEY } from "../queries/useWallet.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- const useWaitForLoginAndSetup = () => {
12
- const client = useClient();
13
- const queryClient = useQueryClient();
14
- const mutation = useMutation({
15
- mutationFn: (args) => __async(void 0, null, function* () {
16
- return yield waitForLoginAndSetup(client, args);
17
- }),
18
- onSettled: () => __async(void 0, null, function* () {
19
- yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
20
- yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
21
- })
22
- });
23
- return renameMutations(
24
- mutation,
25
- "waitForLoginAndSetup"
26
- );
27
- };
28
- export {
29
- useWaitForLoginAndSetup
30
- };
@@ -1,30 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { waitForPasskeyAndCreateWallet } from "../../actions/waitForPasskeyAndCreateWallet.js";
8
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
9
- import { WALLET_BASE_KEY } from "../queries/useWallet.js";
10
- import { renameMutations } from "../../utils/renameMutations.js";
11
- const useWaitForPasskeyAndCreateWallet = () => {
12
- const client = useClient();
13
- const queryClient = useQueryClient();
14
- const mutation = useMutation({
15
- mutationFn: () => __async(void 0, null, function* () {
16
- return yield waitForPasskeyAndCreateWallet(client);
17
- }),
18
- onSettled: () => __async(void 0, null, function* () {
19
- yield queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
20
- yield queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
21
- })
22
- });
23
- return renameMutations(
24
- mutation,
25
- "waitForPasskeyAndCreateWallet"
26
- );
27
- };
28
- export {
29
- useWaitForPasskeyAndCreateWallet
30
- };
@@ -1,8 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useAccount } from "./useAccount.js";
4
- import { useWallet } from "./useWallet.js";
5
- export {
6
- useAccount,
7
- useWallet
8
- };
@@ -1,21 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useQuery } from "@tanstack/react-query";
6
- import { useClient } from "../index.js";
7
- import { getAccount } from "../../actions/getAccount.js";
8
- const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
9
- const useAccount = () => {
10
- const client = useClient();
11
- return useQuery({
12
- queryKey: [ACCOUNT_BASE_KEY, client == null ? void 0 : client.getUserId()],
13
- queryFn: () => __async(void 0, null, function* () {
14
- return yield getAccount(client);
15
- })
16
- });
17
- };
18
- export {
19
- ACCOUNT_BASE_KEY,
20
- useAccount
21
- };
@@ -1,22 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useQuery } from "@tanstack/react-query";
6
- import { useClient, useWalletState } from "../index.js";
7
- import { getWallet } from "../../actions/getWallet.js";
8
- const WALLET_BASE_KEY = "PARA_WALLET";
9
- const useWallet = () => {
10
- const client = useClient();
11
- const { selectedWallet } = useWalletState();
12
- return useQuery({
13
- queryKey: [WALLET_BASE_KEY, client == null ? void 0 : client.getUserId(), selectedWallet.id, selectedWallet.type],
14
- queryFn: () => __async(void 0, null, function* () {
15
- return yield getWallet(client, selectedWallet);
16
- })
17
- });
18
- };
19
- export {
20
- WALLET_BASE_KEY,
21
- useWallet
22
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useClient } from "./useClient.js";
4
- import { useModal } from "./useModal.js";
5
- import { useWalletState } from "./useWalletState.js";
6
- export {
7
- useClient,
8
- useModal,
9
- useWalletState
10
- };
@@ -1,74 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../../../chunk-MMUBH76A.js";
5
- import { useEffect, useRef } from "react";
6
- import { useAccount, useKeepSessionAlive, useLogout } from "../index.js";
7
- import { useInternalClient } from "./useInternalClient.js";
8
- const SESSION_CHECK_INTERVAL = 6e4;
9
- const SESSION_REFRESH_THRESHOLD = 3e5;
10
- const useAutoSessionKeepAlive = ({ disabled }) => {
11
- const client = useInternalClient();
12
- const { data: account } = useAccount();
13
- const { logoutAsync } = useLogout();
14
- const { keepSessionAliveAsync } = useKeepSessionAlive();
15
- const sessionCheckInterval = useRef(null);
16
- useEffect(() => {
17
- if (!client || disabled) {
18
- clearSessionMonitoring();
19
- return;
20
- }
21
- if ((account == null ? void 0 : account.isConnected) && !client.isUsingExternalWallet()) {
22
- setupSessionMonitoring();
23
- } else {
24
- clearSessionMonitoring();
25
- }
26
- return () => clearSessionMonitoring();
27
- }, [client, account, disabled]);
28
- const getSessionExpiry = () => __async(void 0, null, function* () {
29
- try {
30
- const sessionCookie = yield client.retrieveSessionCookie();
31
- if (!sessionCookie) return null;
32
- const expiresMatch = sessionCookie.match(/Expires=([^;]+)/);
33
- return expiresMatch ? new Date(expiresMatch[1]) : null;
34
- } catch (err) {
35
- return null;
36
- }
37
- });
38
- const setupSessionMonitoring = () => {
39
- clearSessionMonitoring();
40
- sessionCheckInterval.current = setInterval(() => __async(void 0, null, function* () {
41
- const expiry = yield getSessionExpiry();
42
- if (!expiry) {
43
- yield logoutAsync();
44
- clearSessionMonitoring();
45
- return;
46
- }
47
- const timeUntilExpiry = expiry.getTime() - Date.now();
48
- if (timeUntilExpiry <= 0) {
49
- yield logoutAsync();
50
- clearSessionMonitoring();
51
- return;
52
- }
53
- if (timeUntilExpiry <= SESSION_REFRESH_THRESHOLD) {
54
- try {
55
- yield keepSessionAliveAsync();
56
- setupSessionMonitoring();
57
- } catch (err) {
58
- console.error("Failed to keep session alive:", err);
59
- yield logoutAsync();
60
- clearSessionMonitoring();
61
- }
62
- return;
63
- }
64
- }), SESSION_CHECK_INTERVAL);
65
- };
66
- const clearSessionMonitoring = () => {
67
- if (sessionCheckInterval.current) {
68
- clearInterval(sessionCheckInterval.current);
69
- }
70
- };
71
- };
72
- export {
73
- useAutoSessionKeepAlive
74
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useStore } from "../../stores/useStore.js";
4
- const useClient = () => {
5
- const client = useStore((state) => state.client);
6
- return client;
7
- };
8
- export {
9
- useClient
10
- };
@@ -1,105 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useQueryClient } from "@tanstack/react-query";
4
- import { useEffect } from "react";
5
- import { useClient, useWalletState } from "../index.js";
6
- import {
7
- ParaEvent
8
- } from "@getpara/web-sdk";
9
- import { ACCOUNT_BASE_KEY } from "../queries/useAccount.js";
10
- import { useStore } from "../../stores/useStore.js";
11
- import { WALLET_BASE_KEY } from "../../hooks/queries/useWallet.js";
12
- const useEventListeners = ({
13
- onLogin,
14
- onLogout,
15
- onAccountSetup,
16
- onAccountCreation,
17
- onSignMessage,
18
- onSignTransaction,
19
- onWalletCreated,
20
- onPregenWalletClaimed,
21
- onExternalWalletChange,
22
- onWalletsChange
23
- } = {}) => {
24
- const queryClient = useQueryClient();
25
- const client = useClient();
26
- const clearSelectedWallet = useStore((state) => state.clearSelectedWallet);
27
- const { selectedWallet, setSelectedWallet } = useWalletState();
28
- const loginListener = (event) => {
29
- loginOrSetupListener();
30
- onLogin == null ? void 0 : onLogin(event);
31
- };
32
- const accountSetupListener = (event) => {
33
- loginOrSetupListener();
34
- onAccountSetup == null ? void 0 : onAccountSetup(event);
35
- };
36
- const loginOrSetupListener = () => {
37
- queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
38
- queryClient.invalidateQueries({ queryKey: [WALLET_BASE_KEY], exact: false });
39
- };
40
- const accountCreationListener = (event) => {
41
- onAccountCreation == null ? void 0 : onAccountCreation(event);
42
- };
43
- const logoutListener = (event) => {
44
- queryClient.invalidateQueries({ queryKey: [ACCOUNT_BASE_KEY], exact: false });
45
- clearSelectedWallet();
46
- onLogout == null ? void 0 : onLogout(event);
47
- };
48
- const signMessageListener = (event) => {
49
- onSignMessage == null ? void 0 : onSignMessage(event);
50
- };
51
- const signTransactionListener = (event) => {
52
- onSignTransaction == null ? void 0 : onSignTransaction(event);
53
- };
54
- const walletChangeListener = (event) => {
55
- updateSelectedWallet();
56
- onWalletsChange == null ? void 0 : onWalletsChange(event);
57
- };
58
- const externalWalletChangeListener = (event) => {
59
- updateSelectedWallet();
60
- onExternalWalletChange == null ? void 0 : onExternalWalletChange(event);
61
- };
62
- const walletCreatedListener = (event) => {
63
- onWalletCreated == null ? void 0 : onWalletCreated(event);
64
- };
65
- const pregenWalletClaimedListener = (event) => {
66
- onPregenWalletClaimed == null ? void 0 : onPregenWalletClaimed(event);
67
- };
68
- const updateSelectedWallet = () => {
69
- if (!client) {
70
- clearSelectedWallet();
71
- return;
72
- }
73
- if (!(selectedWallet == null ? void 0 : selectedWallet.id) || !client.findWallet(selectedWallet == null ? void 0 : selectedWallet.id)) {
74
- const defaultWallet = client.findWallet(void 0, void 0, { forbidPregen: true });
75
- setSelectedWallet({ id: defaultWallet == null ? void 0 : defaultWallet.id, type: defaultWallet == null ? void 0 : defaultWallet.type });
76
- }
77
- };
78
- useEffect(() => {
79
- window.addEventListener(ParaEvent.LOGIN_EVENT, loginListener);
80
- window.addEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
81
- window.addEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
82
- window.addEventListener(ParaEvent.LOGOUT_EVENT, logoutListener);
83
- window.addEventListener(ParaEvent.SIGN_MESSAGE_EVENT, signMessageListener);
84
- window.addEventListener(ParaEvent.SIGN_TRANSACTION_EVENT, signTransactionListener);
85
- window.addEventListener(ParaEvent.WALLETS_CHANGE_EVENT, walletChangeListener);
86
- window.addEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
87
- window.addEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
88
- window.addEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
89
- return () => {
90
- window.removeEventListener(ParaEvent.LOGIN_EVENT, loginListener);
91
- window.removeEventListener(ParaEvent.ACCOUNT_SETUP_EVENT, accountSetupListener);
92
- window.removeEventListener(ParaEvent.ACCOUNT_CREATION_EVENT, accountCreationListener);
93
- window.removeEventListener(ParaEvent.LOGOUT_EVENT, logoutListener);
94
- window.removeEventListener(ParaEvent.SIGN_MESSAGE_EVENT, signMessageListener);
95
- window.removeEventListener(ParaEvent.SIGN_TRANSACTION_EVENT, signTransactionListener);
96
- window.removeEventListener(ParaEvent.WALLETS_CHANGE_EVENT, walletChangeListener);
97
- window.removeEventListener(ParaEvent.EXTERNAL_WALLET_CHANGE_EVENT, externalWalletChangeListener);
98
- window.removeEventListener(ParaEvent.WALLET_CREATED, walletCreatedListener);
99
- window.removeEventListener(ParaEvent.PREGEN_WALLET_CLAIMED, pregenWalletClaimedListener);
100
- };
101
- }, [client]);
102
- };
103
- export {
104
- useEventListeners
105
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useStore } from "../../stores/useStore.js";
4
- const useInternalClient = () => {
5
- const client = useStore((state) => state.client);
6
- return client;
7
- };
8
- export {
9
- useInternalClient
10
- };
@@ -1,17 +0,0 @@
1
- "use client";
2
- import "../../../chunk-MMUBH76A.js";
3
- import { useStore } from "../../stores/useStore.js";
4
- const useModal = () => {
5
- const isOpen = useStore((state) => state.isOpen);
6
- const setIsOpen = useStore((state) => state.setIsOpen);
7
- const openModal = () => {
8
- setIsOpen(true);
9
- };
10
- const closeModal = () => {
11
- setIsOpen(false);
12
- };
13
- return { isOpen, openModal, closeModal };
14
- };
15
- export {
16
- useModal
17
- };