Implement centralized Signal Protocol init

This commit is contained in:
2025-12-03 20:40:36 +03:00
Unverified
parent 4b5de53900
commit c5d5cdf9d2
19 changed files with 1023 additions and 111 deletions
+17 -1
View File
@@ -36,6 +36,9 @@ export async function uploadSessions(sessions: SessionData[], token: string): Pr
* Fetch all encrypted Signal Protocol sessions from the server
*/
export async function fetchSessions(token: string): Promise<SessionData[]> {
console.log("[Session API] Fetching sessions from server...");
console.log("[Session API] URL:", `${API_BASE_URL}/crypto/signal/sessions`);
const headers = getAuthHeaders(token, true);
const res = await fetch(`${API_BASE_URL}/crypto/signal/sessions`, {
@@ -43,11 +46,24 @@ export async function fetchSessions(token: string): Promise<SessionData[]> {
headers
});
console.log("[Session API] Response status:", res.status, res.statusText);
if (!res.ok) {
throw new Error(`Failed to fetch sessions: ${res.statusText}`);
const errorText = await res.text().catch(() => "Unknown error");
console.error("[Session API] Failed to fetch sessions:", {
status: res.status,
statusText: res.statusText,
errorText
});
throw new Error(`Failed to fetch sessions: ${res.status} ${res.statusText}`);
}
const data = await res.json();
console.log("[Session API] Response data:", {
hasSessions: !!data.sessions,
sessionCount: data.sessions?.length || 0
});
return data.sessions || [];
}