@mezo-org/passport 0.4.0-dev.4 → 0.4.0-dev.5
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/hooks/index.d.ts +1 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/index.js +1 -0
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts +163 -0
- package/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -0
- package/dist/src/hooks/useAuthenticateWithWallet.js +58 -0
- package/dist/src/hooks/useAuthenticateWithWallet.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/useSignInWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useSignInWithWallet.js +5 -33
- package/dist/src/hooks/useSignInWithWallet.js.map +1 -1
- package/dist/src/hooks/useSignUpWithWallet.d.ts +161 -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/package.json +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useAuthenticateWithWallet.ts +81 -0
- package/src/hooks/useEnsureNoSessionAndFetchNonce.ts +1 -0
- package/src/hooks/useSignInWithWallet.ts +6 -41
- package/src/hooks/useSignUpWithWallet.ts +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA"}
|
package/dist/src/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,kDAAkD,EAClD,4BAA4B,EAC5B,oDAAoD,GACrD,MAAM,qBAAqB,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
declare function useAuthenticateWithWallet({ signUp, }?: {
|
|
2
|
+
signUp?: boolean;
|
|
3
|
+
}): {
|
|
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<{
|
|
19
|
+
expiresIn: number;
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
sessionLinks: {
|
|
22
|
+
_links: {
|
|
23
|
+
account: "/session/account";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
redirectTo: string;
|
|
28
|
+
}, Error, void, unknown>;
|
|
29
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
30
|
+
expiresIn: number;
|
|
31
|
+
expiresAt: number;
|
|
32
|
+
sessionLinks: {
|
|
33
|
+
_links: {
|
|
34
|
+
account: "/session/account";
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
redirectTo: string;
|
|
39
|
+
}, Error, void, unknown>;
|
|
40
|
+
} | {
|
|
41
|
+
data: undefined;
|
|
42
|
+
variables: void;
|
|
43
|
+
error: null;
|
|
44
|
+
isError: false;
|
|
45
|
+
isIdle: false;
|
|
46
|
+
isPending: true;
|
|
47
|
+
isSuccess: false;
|
|
48
|
+
status: "pending";
|
|
49
|
+
reset: () => void;
|
|
50
|
+
context: unknown;
|
|
51
|
+
failureCount: number;
|
|
52
|
+
failureReason: Error | null;
|
|
53
|
+
isPaused: boolean;
|
|
54
|
+
submittedAt: number;
|
|
55
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
|
|
56
|
+
expiresIn: number;
|
|
57
|
+
expiresAt: number;
|
|
58
|
+
sessionLinks: {
|
|
59
|
+
_links: {
|
|
60
|
+
account: "/session/account";
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
redirectTo: string;
|
|
65
|
+
}, Error, void, unknown>;
|
|
66
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
67
|
+
expiresIn: number;
|
|
68
|
+
expiresAt: number;
|
|
69
|
+
sessionLinks: {
|
|
70
|
+
_links: {
|
|
71
|
+
account: "/session/account";
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
} | {
|
|
75
|
+
redirectTo: string;
|
|
76
|
+
}, Error, void, unknown>;
|
|
77
|
+
} | {
|
|
78
|
+
data: undefined;
|
|
79
|
+
error: Error;
|
|
80
|
+
variables: void;
|
|
81
|
+
isError: true;
|
|
82
|
+
isIdle: false;
|
|
83
|
+
isPending: false;
|
|
84
|
+
isSuccess: false;
|
|
85
|
+
status: "error";
|
|
86
|
+
reset: () => void;
|
|
87
|
+
context: unknown;
|
|
88
|
+
failureCount: number;
|
|
89
|
+
failureReason: Error | null;
|
|
90
|
+
isPaused: boolean;
|
|
91
|
+
submittedAt: number;
|
|
92
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
|
|
93
|
+
expiresIn: number;
|
|
94
|
+
expiresAt: number;
|
|
95
|
+
sessionLinks: {
|
|
96
|
+
_links: {
|
|
97
|
+
account: "/session/account";
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
} | {
|
|
101
|
+
redirectTo: string;
|
|
102
|
+
}, Error, void, unknown>;
|
|
103
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
104
|
+
expiresIn: number;
|
|
105
|
+
expiresAt: number;
|
|
106
|
+
sessionLinks: {
|
|
107
|
+
_links: {
|
|
108
|
+
account: "/session/account";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
} | {
|
|
112
|
+
redirectTo: string;
|
|
113
|
+
}, Error, void, unknown>;
|
|
114
|
+
} | {
|
|
115
|
+
data: {
|
|
116
|
+
expiresIn: number;
|
|
117
|
+
expiresAt: number;
|
|
118
|
+
sessionLinks: {
|
|
119
|
+
_links: {
|
|
120
|
+
account: "/session/account";
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
} | {
|
|
124
|
+
redirectTo: string;
|
|
125
|
+
};
|
|
126
|
+
error: null;
|
|
127
|
+
variables: void;
|
|
128
|
+
isError: false;
|
|
129
|
+
isIdle: false;
|
|
130
|
+
isPending: false;
|
|
131
|
+
isSuccess: true;
|
|
132
|
+
status: "success";
|
|
133
|
+
reset: () => void;
|
|
134
|
+
context: unknown;
|
|
135
|
+
failureCount: number;
|
|
136
|
+
failureReason: Error | null;
|
|
137
|
+
isPaused: boolean;
|
|
138
|
+
submittedAt: number;
|
|
139
|
+
authenticateWithWallet: import("@tanstack/react-query").UseMutateFunction<{
|
|
140
|
+
expiresIn: number;
|
|
141
|
+
expiresAt: number;
|
|
142
|
+
sessionLinks: {
|
|
143
|
+
_links: {
|
|
144
|
+
account: "/session/account";
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
} | {
|
|
148
|
+
redirectTo: string;
|
|
149
|
+
}, Error, void, unknown>;
|
|
150
|
+
authenticateWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
151
|
+
expiresIn: number;
|
|
152
|
+
expiresAt: number;
|
|
153
|
+
sessionLinks: {
|
|
154
|
+
_links: {
|
|
155
|
+
account: "/session/account";
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
} | {
|
|
159
|
+
redirectTo: string;
|
|
160
|
+
}, Error, void, unknown>;
|
|
161
|
+
};
|
|
162
|
+
export { useAuthenticateWithWallet };
|
|
163
|
+
//# sourceMappingURL=useAuthenticateWithWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAUA,iBAAS,yBAAyB,CAAC,EACjC,MAAc,GACf,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkE3B;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useAccount, 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
|
+
function useAuthenticateWithWallet({ signUp = false, } = {}) {
|
|
11
|
+
const { chainId, address, connector } = useAccount();
|
|
12
|
+
const { btcAddress } = useBitcoinAccount();
|
|
13
|
+
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
|
|
14
|
+
const { createSessionAsync } = useCreateSession();
|
|
15
|
+
const { createAccountAsync } = useCreateAccount();
|
|
16
|
+
const { signMessageAsync } = useSignMessage();
|
|
17
|
+
const walletAddress = useMemo(() => (connector?.type === "orangekit" ? btcAddress : address), [btcAddress, address, connector]);
|
|
18
|
+
const { refetch: getAccountByAddress } = useGetAccountByAddress(walletAddress, { enabled: false, retry: false });
|
|
19
|
+
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
20
|
+
mutationFn: async () => {
|
|
21
|
+
if (!address) {
|
|
22
|
+
throw new Error("Sign in error: Wallet not connected!");
|
|
23
|
+
}
|
|
24
|
+
const nonce = await ensureNoSessionAndFetchNonce();
|
|
25
|
+
const networkFamily = btcAddress ? "bitcoin" : "evm";
|
|
26
|
+
const messageResult = createSignInWithWalletMessage(btcAddress ? btcAddress : address, nonce, networkFamily, chainId);
|
|
27
|
+
const signatureResult = await signMessageAsync({
|
|
28
|
+
message: messageResult,
|
|
29
|
+
connector,
|
|
30
|
+
});
|
|
31
|
+
if (signUp) {
|
|
32
|
+
const getAcountByAddressResult = await getAccountByAddress();
|
|
33
|
+
if (!getAcountByAddressResult.data) {
|
|
34
|
+
const createAccountResult = await createAccountAsync({
|
|
35
|
+
type: "wallet",
|
|
36
|
+
message: messageResult,
|
|
37
|
+
signature: signatureResult,
|
|
38
|
+
});
|
|
39
|
+
if (!createAccountResult) {
|
|
40
|
+
throw new Error("Sign in error: Failed to create new account");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return createSessionAsync({
|
|
45
|
+
type: "wallet",
|
|
46
|
+
message: messageResult,
|
|
47
|
+
signature: signatureResult,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
authenticateWithWallet: mutate,
|
|
53
|
+
authenticateWithWalletAsync: mutateAsync,
|
|
54
|
+
...signInMutationRestParameters,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export { useAuthenticateWithWallet };
|
|
58
|
+
//# 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEnsureNoSessionAndFetchNonce.d.ts","sourceRoot":"","sources":["../../../src/hooks/useEnsureNoSessionAndFetchNonce.ts"],"names":[],"mappings":"AAIA,iBAAS,+BAA+B;;
|
|
1
|
+
{"version":3,"file":"useEnsureNoSessionAndFetchNonce.d.ts","sourceRoot":"","sources":["../../../src/hooks/useEnsureNoSessionAndFetchNonce.ts"],"names":[],"mappings":"AAIA,iBAAS,+BAA+B;;EAuCvC;AAED,OAAO,EAAE,+BAA+B,EAAE,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { useSignOut } from "./useSignOut";
|
|
|
4
4
|
function useEnsureNoSessionAndFetchNonce() {
|
|
5
5
|
const { refetch: getSession } = useGetSession(undefined, {
|
|
6
6
|
enabled: false,
|
|
7
|
+
retry: false,
|
|
7
8
|
});
|
|
8
9
|
const { signOutAsync } = useSignOut();
|
|
9
10
|
const getAndValidateSession = useCallback(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEnsureNoSessionAndFetchNonce.js","sourceRoot":"","sources":["../../../src/hooks/useEnsureNoSessionAndFetchNonce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,SAAS,+BAA+B;IACtC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,SAAS,EAAE;QACvD,OAAO,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"useEnsureNoSessionAndFetchNonce.js","sourceRoot":"","sources":["../../../src/hooks/useEnsureNoSessionAndFetchNonce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,SAAS,+BAA+B;IACtC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,SAAS,EAAE;QACvD,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK;KACb,CAAC,CAAA;IACF,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,EAAE,CAAA;IAErC,MAAM,qBAAqB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACnD,MAAM,gBAAgB,GAAG,MAAM,UAAU,EAAE,CAAA;QAE3C,2EAA2E;QAC3E,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,uDAAuD,gBAAgB,CAAC,KAAK,EAAE,CAChF,CAAA;QACH,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAA;QACH,CAAC;QAED,OAAO,gBAAgB,CAAC,IAAI,CAAA;IAC9B,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;IAEhB,MAAM,4BAA4B,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC1D,IAAI,gBAAgB,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAEpD,IAAI,CAAC,CAAC,OAAO,IAAI,gBAAgB,CAAC,EAAE,CAAC;YACnC,mDAAmD;YACnD,MAAM,YAAY,EAAE,CAAA;YACpB,qEAAqE;YACrE,gBAAgB,GAAG,CAAC,MAAM,qBAAqB,EAAE,CAAsB,CAAA;QACzE,CAAC;QAED,OAAO,gBAAgB,CAAC,KAAK,CAAA;IAC/B,CAAC,EAAE,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC,CAAA;IAEzC,OAAO,EAAE,4BAA4B,EAAE,CAAA;AACzC,CAAC;AAED,OAAO,EAAE,+BAA+B,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignInWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSignInWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"AAEA,iBAAS,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS3B;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,38 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useBitcoinAccount } from "@mezo-org/orangekit";
|
|
3
|
-
import { useMutation } from "@tanstack/react-query";
|
|
4
|
-
import { useCreateSession } from "./useCreateSession";
|
|
5
|
-
import { createSignInWithWalletMessage } from "../utils/siww";
|
|
6
|
-
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
|
|
1
|
+
import { useAuthenticateWithWallet } from "./useAuthenticateWithWallet";
|
|
7
2
|
function useSignInWithWallet() {
|
|
8
|
-
const {
|
|
9
|
-
const { btcAddress } = useBitcoinAccount();
|
|
10
|
-
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
|
|
11
|
-
const { createSessionAsync } = useCreateSession();
|
|
12
|
-
const { signMessageAsync } = useSignMessage();
|
|
13
|
-
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
14
|
-
mutationFn: async () => {
|
|
15
|
-
if (!address) {
|
|
16
|
-
throw new Error("Sign in error: Wallet not connected!");
|
|
17
|
-
}
|
|
18
|
-
const nonce = await ensureNoSessionAndFetchNonce();
|
|
19
|
-
const networkFamily = btcAddress ? "bitcoin" : "evm";
|
|
20
|
-
const messageResult = createSignInWithWalletMessage(btcAddress ? btcAddress : address, nonce, networkFamily, chainId);
|
|
21
|
-
const signatureResult = await signMessageAsync({
|
|
22
|
-
message: messageResult,
|
|
23
|
-
connector,
|
|
24
|
-
});
|
|
25
|
-
return createSessionAsync({
|
|
26
|
-
type: "wallet",
|
|
27
|
-
message: messageResult,
|
|
28
|
-
signature: signatureResult,
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
});
|
|
3
|
+
const { authenticateWithWallet, authenticateWithWalletAsync, ...rest } = useAuthenticateWithWallet();
|
|
32
4
|
return {
|
|
33
|
-
signInWithWallet:
|
|
34
|
-
signInWithWalletAsync:
|
|
35
|
-
...
|
|
5
|
+
signInWithWallet: authenticateWithWallet,
|
|
6
|
+
signInWithWalletAsync: authenticateWithWalletAsync,
|
|
7
|
+
...rest,
|
|
36
8
|
};
|
|
37
9
|
}
|
|
38
10
|
export { useSignInWithWallet };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignInWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSignInWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useSignInWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAEvE,SAAS,mBAAmB;IAC1B,MAAM,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,GAAG,IAAI,EAAE,GACpE,yBAAyB,EAAE,CAAA;IAE7B,OAAO;QACL,gBAAgB,EAAE,sBAAsB;QACxC,qBAAqB,EAAE,2BAA2B;QAClD,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
declare function useSignUpWithWallet(): {
|
|
2
|
+
data: undefined;
|
|
3
|
+
variables: undefined;
|
|
4
|
+
error: null;
|
|
5
|
+
isError: false;
|
|
6
|
+
isIdle: true;
|
|
7
|
+
isPending: false;
|
|
8
|
+
isSuccess: false;
|
|
9
|
+
status: "idle";
|
|
10
|
+
reset: () => void;
|
|
11
|
+
context: unknown;
|
|
12
|
+
failureCount: number;
|
|
13
|
+
failureReason: Error | null;
|
|
14
|
+
isPaused: boolean;
|
|
15
|
+
submittedAt: number;
|
|
16
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<{
|
|
17
|
+
expiresIn: number;
|
|
18
|
+
expiresAt: number;
|
|
19
|
+
sessionLinks: {
|
|
20
|
+
_links: {
|
|
21
|
+
account: "/session/account";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
redirectTo: string;
|
|
26
|
+
}, Error, void, unknown>;
|
|
27
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
28
|
+
expiresIn: number;
|
|
29
|
+
expiresAt: number;
|
|
30
|
+
sessionLinks: {
|
|
31
|
+
_links: {
|
|
32
|
+
account: "/session/account";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
redirectTo: string;
|
|
37
|
+
}, Error, void, unknown>;
|
|
38
|
+
} | {
|
|
39
|
+
data: undefined;
|
|
40
|
+
variables: void;
|
|
41
|
+
error: null;
|
|
42
|
+
isError: false;
|
|
43
|
+
isIdle: false;
|
|
44
|
+
isPending: true;
|
|
45
|
+
isSuccess: false;
|
|
46
|
+
status: "pending";
|
|
47
|
+
reset: () => void;
|
|
48
|
+
context: unknown;
|
|
49
|
+
failureCount: number;
|
|
50
|
+
failureReason: Error | null;
|
|
51
|
+
isPaused: boolean;
|
|
52
|
+
submittedAt: number;
|
|
53
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<{
|
|
54
|
+
expiresIn: number;
|
|
55
|
+
expiresAt: number;
|
|
56
|
+
sessionLinks: {
|
|
57
|
+
_links: {
|
|
58
|
+
account: "/session/account";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
redirectTo: string;
|
|
63
|
+
}, Error, void, unknown>;
|
|
64
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
65
|
+
expiresIn: number;
|
|
66
|
+
expiresAt: number;
|
|
67
|
+
sessionLinks: {
|
|
68
|
+
_links: {
|
|
69
|
+
account: "/session/account";
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
redirectTo: string;
|
|
74
|
+
}, Error, void, unknown>;
|
|
75
|
+
} | {
|
|
76
|
+
data: undefined;
|
|
77
|
+
error: Error;
|
|
78
|
+
variables: void;
|
|
79
|
+
isError: true;
|
|
80
|
+
isIdle: false;
|
|
81
|
+
isPending: false;
|
|
82
|
+
isSuccess: false;
|
|
83
|
+
status: "error";
|
|
84
|
+
reset: () => void;
|
|
85
|
+
context: unknown;
|
|
86
|
+
failureCount: number;
|
|
87
|
+
failureReason: Error | null;
|
|
88
|
+
isPaused: boolean;
|
|
89
|
+
submittedAt: number;
|
|
90
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<{
|
|
91
|
+
expiresIn: number;
|
|
92
|
+
expiresAt: number;
|
|
93
|
+
sessionLinks: {
|
|
94
|
+
_links: {
|
|
95
|
+
account: "/session/account";
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
} | {
|
|
99
|
+
redirectTo: string;
|
|
100
|
+
}, Error, void, unknown>;
|
|
101
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
102
|
+
expiresIn: number;
|
|
103
|
+
expiresAt: number;
|
|
104
|
+
sessionLinks: {
|
|
105
|
+
_links: {
|
|
106
|
+
account: "/session/account";
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
} | {
|
|
110
|
+
redirectTo: string;
|
|
111
|
+
}, Error, void, unknown>;
|
|
112
|
+
} | {
|
|
113
|
+
data: {
|
|
114
|
+
expiresIn: number;
|
|
115
|
+
expiresAt: number;
|
|
116
|
+
sessionLinks: {
|
|
117
|
+
_links: {
|
|
118
|
+
account: "/session/account";
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
} | {
|
|
122
|
+
redirectTo: string;
|
|
123
|
+
};
|
|
124
|
+
error: null;
|
|
125
|
+
variables: void;
|
|
126
|
+
isError: false;
|
|
127
|
+
isIdle: false;
|
|
128
|
+
isPending: false;
|
|
129
|
+
isSuccess: true;
|
|
130
|
+
status: "success";
|
|
131
|
+
reset: () => void;
|
|
132
|
+
context: unknown;
|
|
133
|
+
failureCount: number;
|
|
134
|
+
failureReason: Error | null;
|
|
135
|
+
isPaused: boolean;
|
|
136
|
+
submittedAt: number;
|
|
137
|
+
signUpWithWallet: import("@tanstack/react-query").UseMutateFunction<{
|
|
138
|
+
expiresIn: number;
|
|
139
|
+
expiresAt: number;
|
|
140
|
+
sessionLinks: {
|
|
141
|
+
_links: {
|
|
142
|
+
account: "/session/account";
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
} | {
|
|
146
|
+
redirectTo: string;
|
|
147
|
+
}, Error, void, unknown>;
|
|
148
|
+
signUpWithWalletAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
149
|
+
expiresIn: number;
|
|
150
|
+
expiresAt: number;
|
|
151
|
+
sessionLinks: {
|
|
152
|
+
_links: {
|
|
153
|
+
account: "/session/account";
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
} | {
|
|
157
|
+
redirectTo: string;
|
|
158
|
+
}, Error, void, unknown>;
|
|
159
|
+
};
|
|
160
|
+
export { useSignUpWithWallet };
|
|
161
|
+
//# sourceMappingURL=useSignUpWithWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignUpWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSignUpWithWallet.ts"],"names":[],"mappings":"AAEA,iBAAS,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS3B;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useAuthenticateWithWallet } from "./useAuthenticateWithWallet";
|
|
2
|
+
function useSignUpWithWallet() {
|
|
3
|
+
const { authenticateWithWallet, authenticateWithWalletAsync, ...rest } = useAuthenticateWithWallet({ signUp: true });
|
|
4
|
+
return {
|
|
5
|
+
signUpWithWallet: authenticateWithWallet,
|
|
6
|
+
signUpWithWalletAsync: authenticateWithWalletAsync,
|
|
7
|
+
...rest,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export { useSignUpWithWallet };
|
|
11
|
+
//# sourceMappingURL=useSignUpWithWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSignUpWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useSignUpWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAEvE,SAAS,mBAAmB;IAC1B,MAAM,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,GAAG,IAAI,EAAE,GACpE,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAE7C,OAAO;QACL,gBAAgB,EAAE,sBAAsB;QACxC,qBAAqB,EAAE,2BAA2B;QAClD,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
package/package.json
CHANGED
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useAccount, 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
|
+
|
|
11
|
+
function useAuthenticateWithWallet({
|
|
12
|
+
signUp = false,
|
|
13
|
+
}: { signUp?: boolean } = {}) {
|
|
14
|
+
const { chainId, address, connector } = useAccount()
|
|
15
|
+
const { btcAddress } = useBitcoinAccount()
|
|
16
|
+
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce()
|
|
17
|
+
const { createSessionAsync } = useCreateSession()
|
|
18
|
+
const { createAccountAsync } = useCreateAccount()
|
|
19
|
+
const { signMessageAsync } = useSignMessage()
|
|
20
|
+
const walletAddress = useMemo(
|
|
21
|
+
() => (connector?.type === "orangekit" ? btcAddress : address),
|
|
22
|
+
[btcAddress, address, connector],
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const { refetch: getAccountByAddress } = useGetAccountByAddress(
|
|
26
|
+
walletAddress,
|
|
27
|
+
{ enabled: false, retry: false },
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
31
|
+
mutationFn: async () => {
|
|
32
|
+
if (!address) {
|
|
33
|
+
throw new Error("Sign in error: Wallet not connected!")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const nonce = await ensureNoSessionAndFetchNonce()
|
|
37
|
+
|
|
38
|
+
const networkFamily = btcAddress ? "bitcoin" : "evm"
|
|
39
|
+
const messageResult = createSignInWithWalletMessage(
|
|
40
|
+
btcAddress ? btcAddress! : address!,
|
|
41
|
+
nonce,
|
|
42
|
+
networkFamily,
|
|
43
|
+
chainId,
|
|
44
|
+
)
|
|
45
|
+
const signatureResult = await signMessageAsync({
|
|
46
|
+
message: messageResult,
|
|
47
|
+
connector,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
if (signUp) {
|
|
51
|
+
const getAcountByAddressResult = await getAccountByAddress()
|
|
52
|
+
|
|
53
|
+
if (!getAcountByAddressResult.data) {
|
|
54
|
+
const createAccountResult = await createAccountAsync({
|
|
55
|
+
type: "wallet",
|
|
56
|
+
message: messageResult,
|
|
57
|
+
signature: signatureResult,
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
if (!createAccountResult) {
|
|
61
|
+
throw new Error("Sign in error: Failed to create new account")
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return createSessionAsync({
|
|
67
|
+
type: "wallet",
|
|
68
|
+
message: messageResult,
|
|
69
|
+
signature: signatureResult,
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
authenticateWithWallet: mutate,
|
|
76
|
+
authenticateWithWalletAsync: mutateAsync,
|
|
77
|
+
...signInMutationRestParameters,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { useAuthenticateWithWallet }
|
|
@@ -1,48 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useBitcoinAccount } from "@mezo-org/orangekit"
|
|
3
|
-
import { useMutation } from "@tanstack/react-query"
|
|
4
|
-
import { useCreateSession } from "./useCreateSession"
|
|
5
|
-
import { createSignInWithWalletMessage } from "../utils/siww"
|
|
6
|
-
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce"
|
|
1
|
+
import { useAuthenticateWithWallet } from "./useAuthenticateWithWallet"
|
|
7
2
|
|
|
8
3
|
function useSignInWithWallet() {
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce()
|
|
12
|
-
const { createSessionAsync } = useCreateSession()
|
|
13
|
-
const { signMessageAsync } = useSignMessage()
|
|
14
|
-
|
|
15
|
-
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
16
|
-
mutationFn: async () => {
|
|
17
|
-
if (!address) {
|
|
18
|
-
throw new Error("Sign in error: Wallet not connected!")
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const nonce = await ensureNoSessionAndFetchNonce()
|
|
22
|
-
|
|
23
|
-
const networkFamily = btcAddress ? "bitcoin" : "evm"
|
|
24
|
-
const messageResult = createSignInWithWalletMessage(
|
|
25
|
-
btcAddress ? btcAddress! : address!,
|
|
26
|
-
nonce,
|
|
27
|
-
networkFamily,
|
|
28
|
-
chainId,
|
|
29
|
-
)
|
|
30
|
-
const signatureResult = await signMessageAsync({
|
|
31
|
-
message: messageResult,
|
|
32
|
-
connector,
|
|
33
|
-
})
|
|
34
|
-
return createSessionAsync({
|
|
35
|
-
type: "wallet",
|
|
36
|
-
message: messageResult,
|
|
37
|
-
signature: signatureResult,
|
|
38
|
-
})
|
|
39
|
-
},
|
|
40
|
-
})
|
|
4
|
+
const { authenticateWithWallet, authenticateWithWalletAsync, ...rest } =
|
|
5
|
+
useAuthenticateWithWallet()
|
|
41
6
|
|
|
42
7
|
return {
|
|
43
|
-
signInWithWallet:
|
|
44
|
-
signInWithWalletAsync:
|
|
45
|
-
...
|
|
8
|
+
signInWithWallet: authenticateWithWallet,
|
|
9
|
+
signInWithWalletAsync: authenticateWithWalletAsync,
|
|
10
|
+
...rest,
|
|
46
11
|
}
|
|
47
12
|
}
|
|
48
13
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useAuthenticateWithWallet } from "./useAuthenticateWithWallet"
|
|
2
|
+
|
|
3
|
+
function useSignUpWithWallet() {
|
|
4
|
+
const { authenticateWithWallet, authenticateWithWalletAsync, ...rest } =
|
|
5
|
+
useAuthenticateWithWallet({ signUp: true })
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
signUpWithWallet: authenticateWithWallet,
|
|
9
|
+
signUpWithWalletAsync: authenticateWithWalletAsync,
|
|
10
|
+
...rest,
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { useSignUpWithWallet }
|