Change the structure

This commit is contained in:
2025-11-23 21:33:09 +03:00
Unverified
parent 0f4256edad
commit 7d254b5658
36 changed files with 1261 additions and 184 deletions
+6 -8
View File
@@ -1,9 +1,7 @@
import { getAuthToken } from "@/core/api/account";
import api from "@/core/api";
import type { CallSignalingMessage, WrappedSessionKeyPayload } from "@/core/types";
import { getIceServers as fetchIceServers } from "@/core/api/webrtc";
import { request } from "@/core/websocket";
import { wrapCallSessionKeyForRecipient, unwrapCallSessionKeyFromSender, rotateCallSessionKey } from "./encryption";
import { fetchUserPublicKey } from "@/core/api/dm";
import { importAesGcmKey } from "@/utils/crypto/symmetric";
import E2EEWorker from "./e2eeWorker?worker";
import { delay } from "@/utils/utils";
@@ -100,9 +98,9 @@ export class WebRTCCall {
*/
private async getIceServers(): Promise<RTCIceServer[]> {
try {
const token = getAuthToken();
const token = api.user.auth.getAuthToken();
if (!token) throw new Error("No auth token");
const data = await fetchIceServers(token);
const data = await api.calls.iceServers(token);
return data.iceServers || [];
} catch (error) {
console.warn("Failed to fetch ICE servers:", error);
@@ -774,7 +772,7 @@ async function sendSignalingMessage(message: CallSignalingMessage) {
type: "call_signaling",
credentials: {
scheme: "Bearer",
credentials: getAuthToken()!
credentials: api.user.auth.getAuthToken()!
},
data: message
});
@@ -857,7 +855,7 @@ export async function sendCallSessionKey(userId: number, sessionKeyHash: string)
export async function sendWrappedCallSessionKey(userId: number, sessionKey: Uint8Array, sessionKeyHash: string): Promise<void> {
try {
const recipientPublicKey = await fetchUserPublicKey(userId, getAuthToken()!);
const recipientPublicKey = await api.chats.dm.fetchUserPublicKey(userId, api.user.auth.getAuthToken()!);
if (!recipientPublicKey) {
console.warn("No recipient public key for", userId);
return;
@@ -892,7 +890,7 @@ export async function receiveWrappedSessionKey(
sessionKeyHash?: string
): Promise<void> {
try {
const senderPublicKey = await fetchUserPublicKey(fromUserId, getAuthToken()!);
const senderPublicKey = await api.chats.dm.fetchUserPublicKey(fromUserId, api.user.auth.getAuthToken()!);
if (!senderPublicKey) {
console.error("Failed to get sender public key");
return;