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 }); }); };