From 9b982f575aeae9c7985464e47de9f677a3ff3adc Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Wed, 24 Jun 2026 03:59:34 +0530 Subject: [PATCH] fix(tools):use authenticated tool requests --- surfsense_web/components/tool-ui/generate-resume.tsx | 2 +- surfsense_web/components/tool-ui/podcast/player.tsx | 2 +- surfsense_web/components/tool-ui/sandbox-execute.tsx | 7 ++++--- .../video-presentation/generate-video-presentation.tsx | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/surfsense_web/components/tool-ui/generate-resume.tsx b/surfsense_web/components/tool-ui/generate-resume.tsx index 9147d4199..3d87d2fb9 100644 --- a/surfsense_web/components/tool-ui/generate-resume.tsx +++ b/surfsense_web/components/tool-ui/generate-resume.tsx @@ -12,7 +12,7 @@ import { TextShimmerLoader } from "@/components/prompt-kit/loader"; import { Button } from "@/components/ui/button"; import { useMediaQuery } from "@/hooks/use-media-query"; import { baseApiService } from "@/lib/apis/base-api.service"; -import { getAuthHeaders } from "@/lib/auth-utils"; +import { getAuthHeaders } from "@/lib/auth-fetch"; import { buildBackendUrl } from "@/lib/env-config"; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( diff --git a/surfsense_web/components/tool-ui/podcast/player.tsx b/surfsense_web/components/tool-ui/podcast/player.tsx index ac00b6780..4bc5984f9 100644 --- a/surfsense_web/components/tool-ui/podcast/player.tsx +++ b/surfsense_web/components/tool-ui/podcast/player.tsx @@ -13,7 +13,7 @@ import { } from "@/components/ui/accordion"; import { baseApiService } from "@/lib/apis/base-api.service"; import { podcastsApiService } from "@/lib/apis/podcasts-api.service"; -import { authenticatedFetch } from "@/lib/auth-utils"; +import { authenticatedFetch } from "@/lib/auth-fetch"; import { buildBackendUrl } from "@/lib/env-config"; import { speakerLabel } from "./schema"; diff --git a/surfsense_web/components/tool-ui/sandbox-execute.tsx b/surfsense_web/components/tool-ui/sandbox-execute.tsx index a7633d0ec..535968908 100644 --- a/surfsense_web/components/tool-ui/sandbox-execute.tsx +++ b/surfsense_web/components/tool-ui/sandbox-execute.tsx @@ -16,7 +16,7 @@ import { z } from "zod"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"; -import { getBearerToken } from "@/lib/auth-utils"; +import { getDesktopAccessToken } from "@/lib/auth-fetch"; import { buildBackendUrl } from "@/lib/env-config"; import { cn } from "@/lib/utils"; @@ -157,12 +157,13 @@ function truncateCommand(command: string, maxLen = 80): string { // ============================================================================ async function downloadSandboxFile(threadId: string, filePath: string, fileName: string) { - const token = getBearerToken(); + const token = await getDesktopAccessToken(); const url = buildBackendUrl(`/api/v1/threads/${threadId}/sandbox/download`, { path: filePath, }); const res = await fetch(url, { - headers: { Authorization: `Bearer ${token || ""}` }, + headers: token ? { Authorization: `Bearer ${token}` } : undefined, + credentials: "include", }); if (!res.ok) { throw new Error(`Download failed: ${res.statusText}`); diff --git a/surfsense_web/components/tool-ui/video-presentation/generate-video-presentation.tsx b/surfsense_web/components/tool-ui/video-presentation/generate-video-presentation.tsx index 9f2115073..5816d9616 100644 --- a/surfsense_web/components/tool-ui/video-presentation/generate-video-presentation.tsx +++ b/surfsense_web/components/tool-ui/video-presentation/generate-video-presentation.tsx @@ -9,7 +9,7 @@ import { z } from "zod"; import { TextShimmerLoader } from "@/components/prompt-kit/loader"; import { Button } from "@/components/ui/button"; import { baseApiService } from "@/lib/apis/base-api.service"; -import { authenticatedFetch } from "@/lib/auth-utils"; +import { authenticatedFetch } from "@/lib/auth-fetch"; import { buildBackendUrl } from "@/lib/env-config"; import { compileCheck, compileToComponent } from "@/lib/remotion/compile-check"; import { FPS } from "@/lib/remotion/constants";