added ton_proof

This commit is contained in:
Oleg Yakovenko 2024-07-15 03:04:19 +03:00
parent 99c9f00110
commit 1b79b15a31
1 changed files with 22 additions and 1 deletions

View File

@ -7,9 +7,19 @@ export const useAuth = () => {
const WebApp = useWebApp();
console.log("👀👀👀 webapp: ", WebApp);
return useMutation(["auth"], () => {
return useMutation(["auth"], async () => {
console.log("👀👀👀 in mutation - auth");
const authV1Token = sessionStorage.getItem("auth_v1_token");
let tonProof;
if (authV1Token) {
tonProof = await WebApp.initDataUnsafe.signData({
data: authV1Token,
});
console.log("👀👀👀 tonProof: ", tonProof);
}
return request.post<{
connected_wallet: null | {
version: string;
@ -20,6 +30,17 @@ export const useAuth = () => {
auth_v1_token: string;
}>("/auth.twa", {
twa_data: WebApp.initData,
ton_proof: tonProof ? {
account: {
address: tonProof.address,
// O.: add more as needed
},
ton_proof: {
signature: tonProof.signature,
payload: tonProof.payload,
// O.: add more as needed
}
} : undefined
});
});
};