diff --git a/excalidraw-app/App.tsx b/excalidraw-app/App.tsx index e1ef5919cb91..47dca65c9991 100644 --- a/excalidraw-app/App.tsx +++ b/excalidraw-app/App.tsx @@ -1155,9 +1155,7 @@ interface ExcalidrawAppProps { const meetingDetails = { sessionId: "example-session-id", roomJid: "example-room-jid", - jwt: "example-jwt", - jid: "example-jid", - token: "token" + jwt: "example-jwt" } const ExcalidrawApp = (props?: ExcalidrawAppProps) => { diff --git a/excalidraw-app/collab/Collab.tsx b/excalidraw-app/collab/Collab.tsx index 0768c1de6446..668a6515c5c6 100644 --- a/excalidraw-app/collab/Collab.tsx +++ b/excalidraw-app/collab/Collab.tsx @@ -490,7 +490,7 @@ class Collab extends PureComponent { // Initializing storage backend if storageBackendUrl & jwt are provided const { storageBackendUrl , meetingDetails } = this.props; // Session Id is required to initialize the storage backend - if (storageBackendUrl && meetingDetails?.sessionId && meetingDetails.token) { + if (storageBackendUrl && meetingDetails?.sessionId && meetingDetails.jwt) { try { initializeBackend(storageBackendUrl, meetingDetails); } catch (error: any) { diff --git a/excalidraw-app/data/storage.ts b/excalidraw-app/data/storage.ts index e9cd728a4ed5..641a4e3a88cd 100644 --- a/excalidraw-app/data/storage.ts +++ b/excalidraw-app/data/storage.ts @@ -41,7 +41,7 @@ let backendApi: { baseUrl: string; apiPrefix: string } | null = null; let meetingDetailsCache: IMeetingDetails | null = null; // Cache for meeting details -// Initialize backend configuration with storageBackendUrl & meetingDetails (Token comes from meetingDetails) +// Initialize backend configuration with storageBackendUrl & meetingDetails export const initializeBackend = (storageBackendUrl?: string, meetingDetails?: IMeetingDetails) => { backendApi = { baseUrl: storageBackendUrl || BACKEND_CONFIG.baseUrl, @@ -60,8 +60,8 @@ const _getBackendApi = () => { return backendApi; }; -const _getToken = () => { - return meetingDetailsCache?.token; +const _getJwt = () => { + return meetingDetailsCache?.jwt; }; const _getMeetingDetails = (): IMeetingDetails | null => { @@ -77,14 +77,14 @@ const apiCall = async (endpoint: string, options: RequestInit = {}) => { const api = _getBackendApi(); const url = `${api.baseUrl}${api.apiPrefix}${endpoint}`; - // Adding token to headers if available + // Adding jwt to headers if available const headers: Record = { ...options.headers as Record, }; - const token = _getToken(); - if (token) { - headers['Authorization'] = `Bearer ${token}`; + const jwt = _getJwt(); + if (jwt) { + headers['Authorization'] = `Bearer ${jwt}`; } const response = await fetch(url, { @@ -135,9 +135,9 @@ const uploadFilesWithMulter = async (prefix: string, files: { id: FileId; buffer formData.append('file', blob, id); const headers: Record = {}; - const token = _getToken(); - if (token) { - headers['Authorization'] = `Bearer ${token}`; + const jwt = _getJwt(); + if (jwt) { + headers['Authorization'] = `Bearer ${jwt}`; } const response = await fetch(url, { @@ -174,7 +174,7 @@ const uploadFilesWithMulter = async (prefix: string, files: { id: FileId; buffer // Helper function to download files const downloadFilesFromBackend = async (prefix: string, fileIds: readonly FileId[]) => { - + // Early return if no files to download if (!fileIds || fileIds.length === 0) { return { loadedFiles: [], erroredFiles: [] }; @@ -191,16 +191,16 @@ const downloadFilesFromBackend = async (prefix: string, fileIds: readonly FileId const erroredFiles: FileId[] = []; const headers: Record = {}; - const token = _getToken(); - if (token) { - headers['Authorization'] = `Bearer ${token}`; + const jwt = _getJwt(); + if (jwt) { + headers['Authorization'] = `Bearer ${jwt}`; } await Promise.all( [...new Set(fileIds)].map(async (id) => { try { const encodedFileId = encodeURIComponent(`${prefix}/${id}`); - const url = `${baseUrl}/sessions/${meetingDetails.sessionId}/files/${encodedFileId}`; + const url = `${baseUrl}/download/${encodedFileId}`; const response = await fetch(url, { method: 'GET', headers, diff --git a/packages/excalidraw/collab/Collab.tsx b/packages/excalidraw/collab/Collab.tsx index 59b28290ccce..69b5ea8c1d3e 100644 --- a/packages/excalidraw/collab/Collab.tsx +++ b/packages/excalidraw/collab/Collab.tsx @@ -498,13 +498,13 @@ class Collab extends PureComponent { // Initialize storage backend if storageBackendUrl & jwt are provided const { storageBackendUrl, meetingDetails } = this.props; - if (storageBackendUrl && meetingDetails?.sessionId && meetingDetails.token) { + if (storageBackendUrl && meetingDetails?.sessionId && meetingDetails.jwt) { try { if (!meetingDetails.sessionId) { console.warn("Missing sessionId in whiteboard"); } - if (!meetingDetails.token) { - console.warn("Missing token in whiteboard"); + if (!meetingDetails.jwt) { + console.warn("Missing jwt in whiteboard"); } initializeBackend(storageBackendUrl, meetingDetails); } catch (error: any) { diff --git a/packages/excalidraw/types.ts b/packages/excalidraw/types.ts index 3dd7fe09b847..5baf8b2ff25f 100644 --- a/packages/excalidraw/types.ts +++ b/packages/excalidraw/types.ts @@ -609,8 +609,6 @@ export interface IMeetingDetails { sessionId: string; roomJid: string; jwt: string; - jid: string; - token?: string; } export type SceneData = {