From 1b79b15a31f37afffc19b28b9522103abcc864f5 Mon Sep 17 00:00:00 2001 From: Oleg Yakovenko Date: Mon, 15 Jul 2024 03:04:19 +0300 Subject: [PATCH] added ton_proof --- src/shared/services/auth/index.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/shared/services/auth/index.ts b/src/shared/services/auth/index.ts index 7bb9fae..f1d3fce 100644 --- a/src/shared/services/auth/index.ts +++ b/src/shared/services/auth/index.ts @@ -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 }); }); };