@mezo-org/passport 0.4.0-dev.4 → 0.4.0-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/auth.d.ts +36 -59
- package/dist/src/api/auth.d.ts.map +1 -1
- package/dist/src/api/auth.js +21 -49
- package/dist/src/api/auth.js.map +1 -1
- package/dist/src/api/client.d.ts +24 -0
- package/dist/src/api/client.d.ts.map +1 -0
- package/dist/src/api/client.js +54 -0
- package/dist/src/api/client.js.map +1 -0
- package/dist/src/api/fetch-error.d.ts +5 -0
- package/dist/src/api/fetch-error.d.ts.map +1 -0
- package/dist/src/api/fetch-error.js +8 -0
- package/dist/src/api/fetch-error.js.map +1 -0
- package/dist/src/api/index.d.ts +3 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +3 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/portal.d.ts +32 -0
- package/dist/src/api/portal.d.ts.map +1 -0
- package/dist/src/api/portal.js +23 -0
- package/dist/src/api/portal.js.map +1 -0
- package/dist/src/assets/DefaultAvatar.d.ts +5 -0
- package/dist/src/assets/DefaultAvatar.d.ts.map +1 -0
- package/dist/src/assets/DefaultAvatar.js +21 -0
- package/dist/src/assets/DefaultAvatar.js.map +1 -0
- package/dist/src/components/Dropdown/AccountAddress.d.ts +8 -0
- package/dist/src/components/Dropdown/AccountAddress.d.ts.map +1 -0
- package/dist/src/components/Dropdown/AccountAddress.js +58 -0
- package/dist/src/components/Dropdown/AccountAddress.js.map +1 -0
- package/dist/src/components/Dropdown/AccountAssets.d.ts +14 -0
- package/dist/src/components/Dropdown/AccountAssets.d.ts.map +1 -0
- package/dist/src/components/Dropdown/AccountAssets.js +44 -0
- package/dist/src/components/Dropdown/AccountAssets.js.map +1 -0
- package/dist/src/components/Dropdown/AccountBalance.d.ts +7 -0
- package/dist/src/components/Dropdown/AccountBalance.d.ts.map +1 -0
- package/dist/src/components/Dropdown/AccountBalance.js +18 -0
- package/dist/src/components/Dropdown/AccountBalance.js.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js +30 -0
- package/dist/src/components/Dropdown/ConnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Content.d.ts +8 -0
- package/dist/src/components/Dropdown/Content.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Content.js +65 -0
- package/dist/src/components/Dropdown/Content.js.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +7 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +1 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js +13 -0
- package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +18 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts.map +1 -0
- package/dist/src/components/Dropdown/Dropdown.js +42 -0
- package/dist/src/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts +8 -0
- package/dist/src/components/Dropdown/WelcomeBlock.d.ts.map +1 -0
- package/dist/src/components/Dropdown/WelcomeBlock.js +44 -0
- package/dist/src/components/Dropdown/WelcomeBlock.js.map +1 -0
- package/dist/src/components/Dropdown/index.d.ts +3 -0
- package/dist/src/components/Dropdown/index.d.ts.map +1 -0
- package/dist/src/components/Dropdown/index.js +2 -0
- package/dist/src/components/Dropdown/index.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/hooks/constants.d.ts +1 -0
- package/dist/src/hooks/constants.d.ts.map +1 -1
- package/dist/src/hooks/constants.js +1 -0
- package/dist/src/hooks/constants.js.map +1 -1
- package/dist/src/hooks/index.d.ts +1 -1
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +1 -1
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAssetsUSDConversion.d.ts +8 -0
- package/dist/src/hooks/useAssetsUSDConversion.d.ts.map +1 -0
- package/dist/src/hooks/useAssetsUSDConversion.js +21 -0
- package/dist/src/hooks/useAssetsUSDConversion.js.map +1 -0
- package/dist/src/hooks/useAuthApiClient.d.ts +1 -1
- package/dist/src/hooks/useAuthApiClient.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +73 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js +70 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -0
- package/dist/src/hooks/useCreateAccount.d.ts +23 -173
- package/dist/src/hooks/useCreateAccount.d.ts.map +1 -1
- package/dist/src/hooks/useCreateAccount.js +7 -4
- package/dist/src/hooks/useCreateAccount.js.map +1 -1
- package/dist/src/hooks/useCreateSession.d.ts +12 -101
- package/dist/src/hooks/useCreateSession.d.ts.map +1 -1
- package/dist/src/hooks/useCreateSession.js +10 -8
- package/dist/src/hooks/useCreateSession.js.map +1 -1
- package/dist/src/hooks/useDropdownData.d.ts +44 -0
- package/dist/src/hooks/useDropdownData.d.ts.map +1 -0
- package/dist/src/hooks/useDropdownData.js +73 -0
- package/dist/src/hooks/useDropdownData.js.map +1 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.d.ts.map +1 -1
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js +1 -0
- package/dist/src/hooks/useEnsureNoSessionAndFetchNonce.js.map +1 -1
- package/dist/src/hooks/useGetAccountByAddress.d.ts +2 -2
- package/dist/src/hooks/useGetAccountByAddress.d.ts.map +1 -1
- package/dist/src/hooks/useGetAccountByMezoId.d.ts +2 -2
- package/dist/src/hooks/useGetAccountByMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.d.ts +16 -2
- package/dist/src/hooks/useGetCurrentAccount.d.ts.map +1 -1
- package/dist/src/hooks/useGetCurrentAccount.js +25 -3
- package/dist/src/hooks/useGetCurrentAccount.js.map +1 -1
- package/dist/src/hooks/useGetSession.d.ts +1 -1
- package/dist/src/hooks/useGetSession.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.d.ts +15 -175
- package/dist/src/hooks/useLinkAccount.d.ts.map +1 -1
- package/dist/src/hooks/useLinkAccount.js +7 -4
- package/dist/src/hooks/useLinkAccount.js.map +1 -1
- package/dist/src/hooks/usePortalApiClient.d.ts +2 -0
- package/dist/src/hooks/usePortalApiClient.d.ts.map +1 -0
- package/dist/src/hooks/usePortalApiClient.js +6 -0
- package/dist/src/hooks/usePortalApiClient.js.map +1 -0
- package/dist/src/hooks/useSignInWithDiscord.d.ts +12 -100
- package/dist/src/hooks/useSignInWithDiscord.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithDiscord.js +6 -3
- package/dist/src/hooks/useSignInWithDiscord.js.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.d.ts +12 -100
- package/dist/src/hooks/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.js +6 -34
- package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
- package/dist/src/hooks/useSignOut.d.ts +12 -28
- package/dist/src/hooks/useSignOut.d.ts.map +1 -1
- package/dist/src/hooks/useSignOut.js +7 -4
- package/dist/src/hooks/useSignOut.js.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +73 -0
- package/dist/src/hooks/useSignUpWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useSignUpWithWallet.js +11 -0
- package/dist/src/hooks/useSignUpWithWallet.js.map +1 -0
- package/dist/src/hooks/useUpdateMezoId.d.ts +30 -136
- package/dist/src/hooks/useUpdateMezoId.d.ts.map +1 -1
- package/dist/src/hooks/useUpdateMezoId.js +7 -4
- package/dist/src/hooks/useUpdateMezoId.js.map +1 -1
- package/dist/src/hooks/useWalletAccount.d.ts +12 -0
- package/dist/src/hooks/useWalletAccount.d.ts.map +1 -0
- package/dist/src/hooks/useWalletAccount.js +25 -0
- package/dist/src/hooks/useWalletAccount.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/provider.d.ts +10 -13
- package/dist/src/provider.d.ts.map +1 -1
- package/dist/src/provider.js +11 -20
- package/dist/src/provider.js.map +1 -1
- package/dist/src/utils/address.d.ts +15 -0
- package/dist/src/utils/address.d.ts.map +1 -0
- package/dist/src/utils/address.js +35 -0
- package/dist/src/utils/address.js.map +1 -0
- package/dist/src/utils/address.test.d.ts +2 -0
- package/dist/src/utils/address.test.d.ts.map +1 -0
- package/dist/src/utils/address.test.js +37 -0
- package/dist/src/utils/address.test.js.map +1 -0
- package/dist/src/utils/cryptoAssets.d.ts +28 -0
- package/dist/src/utils/cryptoAssets.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.js +73 -0
- package/dist/src/utils/cryptoAssets.js.map +1 -0
- package/dist/src/utils/cryptoAssets.test.d.ts +2 -0
- package/dist/src/utils/cryptoAssets.test.d.ts.map +1 -0
- package/dist/src/utils/cryptoAssets.test.js +49 -0
- package/dist/src/utils/cryptoAssets.test.js.map +1 -0
- package/dist/src/utils/currency.d.ts +14 -0
- package/dist/src/utils/currency.d.ts.map +1 -0
- package/dist/src/utils/currency.js +27 -0
- package/dist/src/utils/currency.js.map +1 -0
- package/dist/src/utils/currency.test.d.ts +2 -0
- package/dist/src/utils/currency.test.d.ts.map +1 -0
- package/dist/src/utils/currency.test.js +34 -0
- package/dist/src/utils/currency.test.js.map +1 -0
- package/dist/src/utils/numbers.d.ts +43 -0
- package/dist/src/utils/numbers.d.ts.map +1 -0
- package/dist/src/utils/numbers.js +81 -0
- package/dist/src/utils/numbers.js.map +1 -0
- package/dist/src/utils/numbers.test.d.ts +2 -0
- package/dist/src/utils/numbers.test.d.ts.map +1 -0
- package/dist/src/utils/numbers.test.js +68 -0
- package/dist/src/utils/numbers.test.js.map +1 -0
- package/package.json +9 -3
- package/src/api/auth.ts +72 -129
- package/src/api/client.ts +78 -0
- package/src/api/fetch-error.ts +8 -0
- package/src/api/index.ts +2 -0
- package/src/api/portal.ts +56 -0
- package/src/assets/DefaultAvatar.tsx +74 -0
- package/src/components/Dropdown/AccountAddress.tsx +111 -0
- package/src/components/Dropdown/AccountAssets.tsx +110 -0
- package/src/components/Dropdown/AccountBalance.tsx +38 -0
- package/src/components/Dropdown/ConnectedTrigger.tsx +56 -0
- package/src/components/Dropdown/Content.tsx +142 -0
- package/src/components/Dropdown/DisconnectedTrigger.tsx +35 -0
- package/src/components/Dropdown/Dropdown.tsx +81 -0
- package/src/components/Dropdown/README.md +46 -0
- package/src/components/Dropdown/WelcomeBlock.tsx +92 -0
- package/src/components/Dropdown/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/hooks/constants.ts +1 -0
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useAssetsUSDConversion.ts +31 -0
- package/src/hooks/useAuthenticateWithWallet.ts +105 -0
- package/src/hooks/useCreateAccount.ts +19 -5
- package/src/hooks/useCreateSession.ts +22 -9
- package/src/hooks/useDropdownData.ts +130 -0
- package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +1 -0
- package/src/hooks/useGetAccountByAddress.ts +2 -2
- package/src/hooks/useGetAccountByMezoId.ts +2 -2
- package/src/hooks/useGetCurrentAccount.ts +46 -6
- package/src/hooks/useGetSession.ts +1 -1
- package/src/hooks/useLinkAccount.ts +18 -5
- package/src/hooks/usePortalApiClient.ts +6 -0
- package/src/hooks/useSignInWithDiscord.ts +14 -5
- package/src/hooks/useSignInWithWallet.ts +14 -42
- package/src/hooks/useSignOut.ts +18 -4
- package/src/hooks/useSignUpWithWallet.ts +21 -0
- package/src/hooks/useUpdateMezoId.ts +19 -4
- package/src/hooks/useWalletAccount.ts +41 -0
- package/src/index.ts +1 -0
- package/src/provider.ts +30 -37
- package/src/utils/address.test.ts +44 -0
- package/src/utils/address.ts +43 -0
- package/src/utils/cryptoAssets.test.ts +59 -0
- package/src/utils/cryptoAssets.ts +93 -0
- package/src/utils/currency.test.ts +38 -0
- package/src/utils/currency.ts +32 -0
- package/src/utils/numbers.test.ts +89 -0
- package/src/utils/numbers.ts +110 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { MutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { Session } from "../api";
|
|
3
|
+
declare function useAuthenticateWithWallet(shouldCreateAccount?: boolean, mutationOptions?: Omit<MutationOptions<Session>, "mutationFn" | "mutationKey">): {
|
|
4
|
+
data: undefined;
|
|
5
|
+
variables: undefined;
|
|
6
|
+
error: null;
|
|
7
|
+
isError: false;
|
|
8
|
+
isIdle: true;
|
|
9
|
+
isPending: false;
|
|
10
|
+
isSuccess: false;
|
|
11
|
+
status: "idle";
|
|
12
|
+
reset: () => void;
|
|
13
|
+
context: unknown;
|
|
14
|
+
failureCount: number;
|
|
15
|
+
failureReason: Error | null;
|
|
16
|
+
isPaused: boolean;
|
|
17
|
+
submittedAt: number;
|
|
18
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
19
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
20
|
+
} | {
|
|
21
|
+
data: undefined;
|
|
22
|
+
variables: void;
|
|
23
|
+
error: null;
|
|
24
|
+
isError: false;
|
|
25
|
+
isIdle: false;
|
|
26
|
+
isPending: true;
|
|
27
|
+
isSuccess: false;
|
|
28
|
+
status: "pending";
|
|
29
|
+
reset: () => void;
|
|
30
|
+
context: unknown;
|
|
31
|
+
failureCount: number;
|
|
32
|
+
failureReason: Error | null;
|
|
33
|
+
isPaused: boolean;
|
|
34
|
+
submittedAt: number;
|
|
35
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
36
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
37
|
+
} | {
|
|
38
|
+
data: undefined;
|
|
39
|
+
error: Error;
|
|
40
|
+
variables: void;
|
|
41
|
+
isError: true;
|
|
42
|
+
isIdle: false;
|
|
43
|
+
isPending: false;
|
|
44
|
+
isSuccess: false;
|
|
45
|
+
status: "error";
|
|
46
|
+
reset: () => void;
|
|
47
|
+
context: unknown;
|
|
48
|
+
failureCount: number;
|
|
49
|
+
failureReason: Error | null;
|
|
50
|
+
isPaused: boolean;
|
|
51
|
+
submittedAt: number;
|
|
52
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
53
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
54
|
+
} | {
|
|
55
|
+
data: Session;
|
|
56
|
+
error: null;
|
|
57
|
+
variables: void;
|
|
58
|
+
isError: false;
|
|
59
|
+
isIdle: false;
|
|
60
|
+
isPending: false;
|
|
61
|
+
isSuccess: true;
|
|
62
|
+
status: "success";
|
|
63
|
+
reset: () => void;
|
|
64
|
+
context: unknown;
|
|
65
|
+
failureCount: number;
|
|
66
|
+
failureReason: Error | null;
|
|
67
|
+
isPaused: boolean;
|
|
68
|
+
submittedAt: number;
|
|
69
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<Session, Error, void, unknown>;
|
|
70
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Session, Error, void, unknown>;
|
|
71
|
+
};
|
|
72
|
+
export { useAuthenticateWithWallet };
|
|
73
|
+
//# sourceMappingURL=useAuthenticateWithWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAA;AAOpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAGrC,iBAAS,yBAAyB,CAChC,mBAAmB,UAAQ,EAC3B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,OAAO,CAAC,EACxB,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqFP;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useSignMessage } from "wagmi";
|
|
2
|
+
import { useBitcoinAccount } from "@mezo-org/orangekit";
|
|
3
|
+
import { useMutation } from "@tanstack/react-query";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { useCreateAccount } from "./useCreateAccount";
|
|
6
|
+
import { useCreateSession } from "./useCreateSession";
|
|
7
|
+
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
|
|
8
|
+
import { createSignInWithWalletMessage } from "../utils/siww";
|
|
9
|
+
import { useGetAccountByAddress } from "./useGetAccountByAddress";
|
|
10
|
+
import useWalletAccount from "./useWalletAccount";
|
|
11
|
+
function useAuthenticateWithWallet(shouldCreateAccount = false, mutationOptions = {}) {
|
|
12
|
+
const { address, chainId, connector, networkFamily } = useWalletAccount();
|
|
13
|
+
const { btcAddress } = useBitcoinAccount();
|
|
14
|
+
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
|
|
15
|
+
const { createSessionAsync } = useCreateSession();
|
|
16
|
+
const { createAccountAsync } = useCreateAccount();
|
|
17
|
+
const { signMessageAsync } = useSignMessage();
|
|
18
|
+
const walletAddress = useMemo(() => (connector?.type === "orangekit" ? btcAddress : address), [btcAddress, address, connector]);
|
|
19
|
+
const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, { enabled: false, retry: false });
|
|
20
|
+
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
21
|
+
mutationFn: async () => {
|
|
22
|
+
if (!address) {
|
|
23
|
+
throw new Error("Sign in error: Wallet not connected!");
|
|
24
|
+
}
|
|
25
|
+
const nonce = await ensureNoSessionAndFetchNonce();
|
|
26
|
+
const messageResult = createSignInWithWalletMessage(btcAddress || address, nonce, networkFamily, chainId);
|
|
27
|
+
const signatureResult = await signMessageAsync({
|
|
28
|
+
message: messageResult,
|
|
29
|
+
connector,
|
|
30
|
+
});
|
|
31
|
+
if (shouldCreateAccount) {
|
|
32
|
+
const getAccountByAddressResult = await getAccountByAddress();
|
|
33
|
+
if (getAccountByAddressResult.data) {
|
|
34
|
+
throw new Error("Wallet authentication failed: Account creation failed. Account already exists.");
|
|
35
|
+
}
|
|
36
|
+
if (getAccountByAddressResult.error) {
|
|
37
|
+
throw new Error(`Wallet authentication failed: Account creation failed. Could not verify if account already exists: ${getAccountByAddressResult.error}`);
|
|
38
|
+
}
|
|
39
|
+
// Fetch was successful, but no account was found
|
|
40
|
+
try {
|
|
41
|
+
const createAccountResult = await createAccountAsync({
|
|
42
|
+
type: "wallet",
|
|
43
|
+
message: messageResult,
|
|
44
|
+
signature: signatureResult,
|
|
45
|
+
});
|
|
46
|
+
if (!createAccountResult) {
|
|
47
|
+
throw new Error("Failed to create new account");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Wallet authentication failed: Account creation failed: ${error}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return (await createSessionAsync({
|
|
55
|
+
type: "wallet",
|
|
56
|
+
message: messageResult,
|
|
57
|
+
signature: signatureResult,
|
|
58
|
+
}));
|
|
59
|
+
// ^ By passing type: "wallet" we know for sure the return type is Session
|
|
60
|
+
},
|
|
61
|
+
...mutationOptions,
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
authenticateWithWallet: mutate,
|
|
65
|
+
authenticateWithWalletAsync: mutateAsync,
|
|
66
|
+
...signInMutationRestParameters,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export { useAuthenticateWithWallet };
|
|
70
|
+
//# sourceMappingURL=useAuthenticateWithWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuthenticateWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { MutationOptions, DefaultError } from "@tanstack/react-query";
|
|
2
|
+
import type { CreateAccountRequest, CreateAccountResponse } from "../api";
|
|
3
|
+
export declare function useCreateAccount(mutationOptions?: Omit<MutationOptions<CreateAccountResponse, DefaultError, CreateAccountRequest>, "mutationFn" | "mutationKey">): {
|
|
2
4
|
data: undefined;
|
|
3
5
|
variables: undefined;
|
|
4
6
|
error: null;
|
|
@@ -16,52 +18,16 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
|
|
|
16
18
|
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
17
19
|
mezoId: string;
|
|
18
20
|
hasModifiedMezoId: boolean;
|
|
19
|
-
linkedAccounts: import("../api
|
|
20
|
-
|
|
21
|
-
id: string;
|
|
22
|
-
app_metadata: {
|
|
23
|
-
provider: "wallet" | "discord" | "email";
|
|
24
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
25
|
-
};
|
|
26
|
-
user_metadata: {
|
|
27
|
-
mezoId?: string | undefined;
|
|
28
|
-
btcAddress: string;
|
|
29
|
-
evmAddress: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
}, Error, {
|
|
33
|
-
type: "wallet";
|
|
34
|
-
message: string;
|
|
35
|
-
signature: string;
|
|
36
|
-
}, unknown>;
|
|
21
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
22
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
37
23
|
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
38
24
|
mezoId: string;
|
|
39
25
|
hasModifiedMezoId: boolean;
|
|
40
|
-
linkedAccounts: import("../api
|
|
41
|
-
|
|
42
|
-
id: string;
|
|
43
|
-
app_metadata: {
|
|
44
|
-
provider: "wallet" | "discord" | "email";
|
|
45
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
46
|
-
};
|
|
47
|
-
user_metadata: {
|
|
48
|
-
mezoId?: string | undefined;
|
|
49
|
-
btcAddress: string;
|
|
50
|
-
evmAddress: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
}, Error, {
|
|
54
|
-
type: "wallet";
|
|
55
|
-
message: string;
|
|
56
|
-
signature: string;
|
|
57
|
-
}, unknown>;
|
|
26
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
27
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
58
28
|
} | {
|
|
59
29
|
data: undefined;
|
|
60
|
-
variables:
|
|
61
|
-
type: "wallet";
|
|
62
|
-
message: string;
|
|
63
|
-
signature: string;
|
|
64
|
-
};
|
|
30
|
+
variables: CreateAccountRequest;
|
|
65
31
|
error: null;
|
|
66
32
|
isError: false;
|
|
67
33
|
isIdle: false;
|
|
@@ -77,53 +43,17 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
|
|
|
77
43
|
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
78
44
|
mezoId: string;
|
|
79
45
|
hasModifiedMezoId: boolean;
|
|
80
|
-
linkedAccounts: import("../api
|
|
81
|
-
|
|
82
|
-
id: string;
|
|
83
|
-
app_metadata: {
|
|
84
|
-
provider: "wallet" | "discord" | "email";
|
|
85
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
86
|
-
};
|
|
87
|
-
user_metadata: {
|
|
88
|
-
mezoId?: string | undefined;
|
|
89
|
-
btcAddress: string;
|
|
90
|
-
evmAddress: string;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
}, Error, {
|
|
94
|
-
type: "wallet";
|
|
95
|
-
message: string;
|
|
96
|
-
signature: string;
|
|
97
|
-
}, unknown>;
|
|
46
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
47
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
98
48
|
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
99
49
|
mezoId: string;
|
|
100
50
|
hasModifiedMezoId: boolean;
|
|
101
|
-
linkedAccounts: import("../api
|
|
102
|
-
|
|
103
|
-
id: string;
|
|
104
|
-
app_metadata: {
|
|
105
|
-
provider: "wallet" | "discord" | "email";
|
|
106
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
107
|
-
};
|
|
108
|
-
user_metadata: {
|
|
109
|
-
mezoId?: string | undefined;
|
|
110
|
-
btcAddress: string;
|
|
111
|
-
evmAddress: string;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
}, Error, {
|
|
115
|
-
type: "wallet";
|
|
116
|
-
message: string;
|
|
117
|
-
signature: string;
|
|
118
|
-
}, unknown>;
|
|
51
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
52
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
119
53
|
} | {
|
|
120
54
|
data: undefined;
|
|
121
55
|
error: Error;
|
|
122
|
-
variables:
|
|
123
|
-
type: "wallet";
|
|
124
|
-
message: string;
|
|
125
|
-
signature: string;
|
|
126
|
-
};
|
|
56
|
+
variables: CreateAccountRequest;
|
|
127
57
|
isError: true;
|
|
128
58
|
isIdle: false;
|
|
129
59
|
isPending: false;
|
|
@@ -138,69 +68,21 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
|
|
|
138
68
|
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
139
69
|
mezoId: string;
|
|
140
70
|
hasModifiedMezoId: boolean;
|
|
141
|
-
linkedAccounts: import("../api
|
|
142
|
-
|
|
143
|
-
id: string;
|
|
144
|
-
app_metadata: {
|
|
145
|
-
provider: "wallet" | "discord" | "email";
|
|
146
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
147
|
-
};
|
|
148
|
-
user_metadata: {
|
|
149
|
-
mezoId?: string | undefined;
|
|
150
|
-
btcAddress: string;
|
|
151
|
-
evmAddress: string;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
}, Error, {
|
|
155
|
-
type: "wallet";
|
|
156
|
-
message: string;
|
|
157
|
-
signature: string;
|
|
158
|
-
}, unknown>;
|
|
71
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
72
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
159
73
|
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
160
74
|
mezoId: string;
|
|
161
75
|
hasModifiedMezoId: boolean;
|
|
162
|
-
linkedAccounts: import("../api
|
|
163
|
-
|
|
164
|
-
id: string;
|
|
165
|
-
app_metadata: {
|
|
166
|
-
provider: "wallet" | "discord" | "email";
|
|
167
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
168
|
-
};
|
|
169
|
-
user_metadata: {
|
|
170
|
-
mezoId?: string | undefined;
|
|
171
|
-
btcAddress: string;
|
|
172
|
-
evmAddress: string;
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
}, Error, {
|
|
176
|
-
type: "wallet";
|
|
177
|
-
message: string;
|
|
178
|
-
signature: string;
|
|
179
|
-
}, unknown>;
|
|
76
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
77
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
180
78
|
} | {
|
|
181
79
|
data: {
|
|
182
80
|
mezoId: string;
|
|
183
81
|
hasModifiedMezoId: boolean;
|
|
184
|
-
linkedAccounts: import("../api
|
|
185
|
-
authUser: {
|
|
186
|
-
id: string;
|
|
187
|
-
app_metadata: {
|
|
188
|
-
provider: "wallet" | "discord" | "email";
|
|
189
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
190
|
-
};
|
|
191
|
-
user_metadata: {
|
|
192
|
-
mezoId?: string | undefined;
|
|
193
|
-
btcAddress: string;
|
|
194
|
-
evmAddress: string;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
82
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
197
83
|
};
|
|
198
84
|
error: null;
|
|
199
|
-
variables:
|
|
200
|
-
type: "wallet";
|
|
201
|
-
message: string;
|
|
202
|
-
signature: string;
|
|
203
|
-
};
|
|
85
|
+
variables: CreateAccountRequest;
|
|
204
86
|
isError: false;
|
|
205
87
|
isIdle: false;
|
|
206
88
|
isPending: false;
|
|
@@ -215,44 +97,12 @@ export declare function useCreateAccount(useMutationOptions?: {}): {
|
|
|
215
97
|
createAccount: import("@tanstack/react-query").UseMutateFunction<{
|
|
216
98
|
mezoId: string;
|
|
217
99
|
hasModifiedMezoId: boolean;
|
|
218
|
-
linkedAccounts: import("../api
|
|
219
|
-
|
|
220
|
-
id: string;
|
|
221
|
-
app_metadata: {
|
|
222
|
-
provider: "wallet" | "discord" | "email";
|
|
223
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
224
|
-
};
|
|
225
|
-
user_metadata: {
|
|
226
|
-
mezoId?: string | undefined;
|
|
227
|
-
btcAddress: string;
|
|
228
|
-
evmAddress: string;
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
}, Error, {
|
|
232
|
-
type: "wallet";
|
|
233
|
-
message: string;
|
|
234
|
-
signature: string;
|
|
235
|
-
}, unknown>;
|
|
100
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
101
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
236
102
|
createAccountAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
237
103
|
mezoId: string;
|
|
238
104
|
hasModifiedMezoId: boolean;
|
|
239
|
-
linkedAccounts: import("../api
|
|
240
|
-
|
|
241
|
-
id: string;
|
|
242
|
-
app_metadata: {
|
|
243
|
-
provider: "wallet" | "discord" | "email";
|
|
244
|
-
providers: ("wallet" | "discord" | "email")[];
|
|
245
|
-
};
|
|
246
|
-
user_metadata: {
|
|
247
|
-
mezoId?: string | undefined;
|
|
248
|
-
btcAddress: string;
|
|
249
|
-
evmAddress: string;
|
|
250
|
-
};
|
|
251
|
-
};
|
|
252
|
-
}, Error, {
|
|
253
|
-
type: "wallet";
|
|
254
|
-
message: string;
|
|
255
|
-
signature: string;
|
|
256
|
-
}, unknown>;
|
|
105
|
+
linkedAccounts: import("../api").LinkedAccount[];
|
|
106
|
+
}, Error, CreateAccountRequest, unknown>;
|
|
257
107
|
};
|
|
258
108
|
//# sourceMappingURL=useCreateAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCreateAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAEzE,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBP"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
1
|
+
import { useQueryClient, useMutation, } from "@tanstack/react-query";
|
|
2
2
|
import { useAuthApiClient } from "./useAuthApiClient";
|
|
3
3
|
import { QUERY_KEYS } from "./constants";
|
|
4
|
-
export function useCreateAccount(
|
|
4
|
+
export function useCreateAccount(mutationOptions = {}) {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
6
|
const authApiClient = useAuthApiClient();
|
|
7
|
+
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
7
8
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
8
9
|
mutationFn: (createAccountRequest) => authApiClient.createAccount(createAccountRequest),
|
|
9
|
-
onSuccess: () => {
|
|
10
|
+
onSuccess: (data, variables, context) => {
|
|
10
11
|
queryClient.resetQueries({
|
|
11
12
|
queryKey: [QUERY_KEYS.ACCOUNT],
|
|
12
13
|
});
|
|
14
|
+
if (customOnSuccess)
|
|
15
|
+
customOnSuccess(data, variables, context);
|
|
13
16
|
},
|
|
14
|
-
...
|
|
17
|
+
...restMutationOptions,
|
|
15
18
|
});
|
|
16
19
|
return { createAccount: mutate, createAccountAsync: mutateAsync, ...rest };
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateAccount.js","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useCreateAccount.js","sourceRoot":"","sources":["../../../src/hooks/useCreateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,UAAU,gBAAgB,CAC9B,kBAGI,EAAE;IAEN,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IAExC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,mBAAmB,EAAE,GAAG,eAAe,CAAA;IAE9E,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,CAAC;QACnD,UAAU,EAAE,CAAC,oBAA0C,EAAE,EAAE,CACzD,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC;QACnD,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACtC,WAAW,CAAC,YAAY,CAAC;gBACvB,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;aAC/B,CAAC,CAAA;YAEF,IAAI,eAAe;gBAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC5E,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MutationOptions, DefaultError } from "@tanstack/react-query";
|
|
2
|
+
import type { CreateSessionRequest, CreateSessionResponse } from "../api";
|
|
2
3
|
/**
|
|
3
4
|
* This hook is not exposed for external consumers. For creating session they
|
|
4
5
|
* should use `useSignIn` hook related to the authentication method.
|
|
5
6
|
*/
|
|
6
|
-
export declare function useCreateSession(
|
|
7
|
+
export declare function useCreateSession(mutationOptions?: Omit<MutationOptions<CreateSessionResponse, DefaultError, CreateSessionRequest>, "mutationFn" | "mutationKey">): {
|
|
7
8
|
data: undefined;
|
|
8
9
|
variables: undefined;
|
|
9
10
|
error: null;
|
|
@@ -18,28 +19,8 @@ export declare function useCreateSession(useMutationOptions?: {}): {
|
|
|
18
19
|
failureReason: Error | null;
|
|
19
20
|
isPaused: boolean;
|
|
20
21
|
submittedAt: number;
|
|
21
|
-
createSession: import("@tanstack/react-query").UseMutateFunction<
|
|
22
|
-
|
|
23
|
-
expiresAt: number;
|
|
24
|
-
sessionLinks: {
|
|
25
|
-
_links: {
|
|
26
|
-
account: "/session/account";
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
} | {
|
|
30
|
-
redirectTo: string;
|
|
31
|
-
}, Error, CreateSessionRequest, unknown>;
|
|
32
|
-
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
33
|
-
expiresIn: number;
|
|
34
|
-
expiresAt: number;
|
|
35
|
-
sessionLinks: {
|
|
36
|
-
_links: {
|
|
37
|
-
account: "/session/account";
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
} | {
|
|
41
|
-
redirectTo: string;
|
|
42
|
-
}, Error, CreateSessionRequest, unknown>;
|
|
22
|
+
createSession: import("@tanstack/react-query").UseMutateFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
23
|
+
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
43
24
|
} | {
|
|
44
25
|
data: undefined;
|
|
45
26
|
variables: CreateSessionRequest;
|
|
@@ -55,28 +36,8 @@ export declare function useCreateSession(useMutationOptions?: {}): {
|
|
|
55
36
|
failureReason: Error | null;
|
|
56
37
|
isPaused: boolean;
|
|
57
38
|
submittedAt: number;
|
|
58
|
-
createSession: import("@tanstack/react-query").UseMutateFunction<
|
|
59
|
-
|
|
60
|
-
expiresAt: number;
|
|
61
|
-
sessionLinks: {
|
|
62
|
-
_links: {
|
|
63
|
-
account: "/session/account";
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
} | {
|
|
67
|
-
redirectTo: string;
|
|
68
|
-
}, Error, CreateSessionRequest, unknown>;
|
|
69
|
-
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
70
|
-
expiresIn: number;
|
|
71
|
-
expiresAt: number;
|
|
72
|
-
sessionLinks: {
|
|
73
|
-
_links: {
|
|
74
|
-
account: "/session/account";
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
} | {
|
|
78
|
-
redirectTo: string;
|
|
79
|
-
}, Error, CreateSessionRequest, unknown>;
|
|
39
|
+
createSession: import("@tanstack/react-query").UseMutateFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
40
|
+
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
80
41
|
} | {
|
|
81
42
|
data: undefined;
|
|
82
43
|
error: Error;
|
|
@@ -92,40 +53,10 @@ export declare function useCreateSession(useMutationOptions?: {}): {
|
|
|
92
53
|
failureReason: Error | null;
|
|
93
54
|
isPaused: boolean;
|
|
94
55
|
submittedAt: number;
|
|
95
|
-
createSession: import("@tanstack/react-query").UseMutateFunction<
|
|
96
|
-
|
|
97
|
-
expiresAt: number;
|
|
98
|
-
sessionLinks: {
|
|
99
|
-
_links: {
|
|
100
|
-
account: "/session/account";
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
} | {
|
|
104
|
-
redirectTo: string;
|
|
105
|
-
}, Error, CreateSessionRequest, unknown>;
|
|
106
|
-
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
107
|
-
expiresIn: number;
|
|
108
|
-
expiresAt: number;
|
|
109
|
-
sessionLinks: {
|
|
110
|
-
_links: {
|
|
111
|
-
account: "/session/account";
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
} | {
|
|
115
|
-
redirectTo: string;
|
|
116
|
-
}, Error, CreateSessionRequest, unknown>;
|
|
56
|
+
createSession: import("@tanstack/react-query").UseMutateFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
57
|
+
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
117
58
|
} | {
|
|
118
|
-
data:
|
|
119
|
-
expiresIn: number;
|
|
120
|
-
expiresAt: number;
|
|
121
|
-
sessionLinks: {
|
|
122
|
-
_links: {
|
|
123
|
-
account: "/session/account";
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
} | {
|
|
127
|
-
redirectTo: string;
|
|
128
|
-
};
|
|
59
|
+
data: CreateSessionResponse;
|
|
129
60
|
error: null;
|
|
130
61
|
variables: CreateSessionRequest;
|
|
131
62
|
isError: false;
|
|
@@ -139,27 +70,7 @@ export declare function useCreateSession(useMutationOptions?: {}): {
|
|
|
139
70
|
failureReason: Error | null;
|
|
140
71
|
isPaused: boolean;
|
|
141
72
|
submittedAt: number;
|
|
142
|
-
createSession: import("@tanstack/react-query").UseMutateFunction<
|
|
143
|
-
|
|
144
|
-
expiresAt: number;
|
|
145
|
-
sessionLinks: {
|
|
146
|
-
_links: {
|
|
147
|
-
account: "/session/account";
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
} | {
|
|
151
|
-
redirectTo: string;
|
|
152
|
-
}, Error, CreateSessionRequest, unknown>;
|
|
153
|
-
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
154
|
-
expiresIn: number;
|
|
155
|
-
expiresAt: number;
|
|
156
|
-
sessionLinks: {
|
|
157
|
-
_links: {
|
|
158
|
-
account: "/session/account";
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
} | {
|
|
162
|
-
redirectTo: string;
|
|
163
|
-
}, Error, CreateSessionRequest, unknown>;
|
|
73
|
+
createSession: import("@tanstack/react-query").UseMutateFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
74
|
+
createSessionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<CreateSessionResponse, Error, CreateSessionRequest, unknown>;
|
|
164
75
|
};
|
|
165
76
|
//# sourceMappingURL=useCreateSession.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateSession.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateSession.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCreateSession.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCreateSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EACf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAA;AAGzE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,qBAAqB,EAAE,YAAY,EAAE,oBAAoB,CAAC,EAC1E,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBP"}
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
1
|
+
import { useQueryClient, useMutation, } from "@tanstack/react-query";
|
|
2
2
|
import { useAuthApiClient } from "./useAuthApiClient";
|
|
3
3
|
import { QUERY_KEYS } from "./constants";
|
|
4
4
|
/**
|
|
5
5
|
* This hook is not exposed for external consumers. For creating session they
|
|
6
6
|
* should use `useSignIn` hook related to the authentication method.
|
|
7
7
|
*/
|
|
8
|
-
export function useCreateSession(
|
|
8
|
+
export function useCreateSession(mutationOptions = {}) {
|
|
9
9
|
const queryClient = useQueryClient();
|
|
10
10
|
const authApiClient = useAuthApiClient();
|
|
11
|
+
const { onSuccess: customOnSuccess, ...restMutationOptions } = mutationOptions;
|
|
11
12
|
const { mutate, mutateAsync, ...rest } = useMutation({
|
|
12
13
|
mutationFn: (createSessionRequest) => authApiClient.createSession(createSessionRequest),
|
|
13
|
-
onSuccess: () => {
|
|
14
|
-
// Since `getSession` query also has code in
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// queries
|
|
14
|
+
onSuccess: (data, variables, context) => {
|
|
15
|
+
// Since `getSession` query also has code in its query keys we can't set
|
|
16
|
+
// query data for a specific query, because we don't know if the code was
|
|
17
|
+
// used or not. Because of that we just reset all getSession queries
|
|
18
18
|
queryClient.resetQueries({ queryKey: [QUERY_KEYS.SESSION] });
|
|
19
19
|
queryClient.resetQueries({
|
|
20
20
|
queryKey: [QUERY_KEYS.ACCOUNT, QUERY_KEYS.CURRENT],
|
|
21
21
|
});
|
|
22
|
+
if (customOnSuccess)
|
|
23
|
+
customOnSuccess(data, variables, context);
|
|
22
24
|
},
|
|
23
|
-
...
|
|
25
|
+
...restMutationOptions,
|
|
24
26
|
});
|
|
25
27
|
return { createSession: mutate, createSessionAsync: mutateAsync, ...rest };
|
|
26
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateSession.js","sourceRoot":"","sources":["../../../src/hooks/useCreateSession.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useCreateSession.js","sourceRoot":"","sources":["../../../src/hooks/useCreateSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,kBAGI,EAAE;IAEN,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IAExC,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,mBAAmB,EAAE,GAAG,eAAe,CAAA;IAE9E,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,CAAC;QACnD,UAAU,EAAE,CAAC,oBAA0C,EAAE,EAAE,CACzD,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC;QACnD,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACtC,wEAAwE;YACxE,yEAAyE;YACzE,oEAAoE;YACpE,WAAW,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC5D,WAAW,CAAC,YAAY,CAAC;gBACvB,QAAQ,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;aACnD,CAAC,CAAA;YAEF,IAAI,eAAe;gBAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;QACD,GAAG,mBAAmB;KACvB,CAAC,CAAA;IAEF,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAA;AAC5E,CAAC"}
|