From 015d4ecbd8cc7aa175669e031af8f0a2643c9324 Mon Sep 17 00:00:00 2001 From: Christopher Date: Wed, 28 Jan 2026 06:12:51 -0800 Subject: [PATCH] Add check for user DID before key verification Throws an error if the user DID is not available before attempting to verify the key on the server, preventing potential runtime errors. --- src/lib/hooks/useSodiumChat.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/hooks/useSodiumChat.ts b/src/lib/hooks/useSodiumChat.ts index e8232f0..ae5bcec 100644 --- a/src/lib/hooks/useSodiumChat.ts +++ b/src/lib/hooks/useSodiumChat.ts @@ -61,6 +61,9 @@ export function useSodiumChat() { // Verify key exists on server console.log('[Sodium] Verifying key on server...'); + if (!user.did) { + throw new Error('User DID not available'); + } const checkResponse = await fetch(`/api/chat/keys?did=${encodeURIComponent(user.did)}`); let shouldPublish = false;