From e2f88580197d3543fb2e87965d4bccce7fdff017 Mon Sep 17 00:00:00 2001 From: J3vb Date: Sun, 5 Apr 2026 19:37:00 +0200 Subject: [PATCH] fix: resolve CI lint and ESLint failures - Remove commented-out code flagged by gocritic - Use bytes.Equal instead of string conversion comparison - Remove unused buildRateLimitError function - Remove unnecessary type assertions in e2eeCrypto.ts --- Client/tauri-client/src/lib/e2eeCrypto.ts | 12 ++++-------- Server/db/role_invite_queries_test.go | 2 +- Server/ws/event_test.go | 3 ++- Server/ws/messages.go | 12 ------------ 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/Client/tauri-client/src/lib/e2eeCrypto.ts b/Client/tauri-client/src/lib/e2eeCrypto.ts index a09ff3cc..cb593edc 100644 --- a/Client/tauri-client/src/lib/e2eeCrypto.ts +++ b/Client/tauri-client/src/lib/e2eeCrypto.ts @@ -29,20 +29,16 @@ const ECDH_CURVE = "P-256"; // UTF-8 bytes of "owncord-voice-e2ee-v1" const HKDF_SALT = new Uint8Array([ 111, 119, 110, 99, 111, 114, 100, 45, 118, 111, 105, 99, 101, 45, 101, 50, 101, 101, 45, 118, 49, -]) as Uint8Array; +]); // UTF-8 bytes of "room-key-wrap" -const HKDF_INFO = new Uint8Array([ - 114, 111, 111, 109, 45, 107, 101, 121, 45, 119, 114, 97, 112, -]) as Uint8Array; +const HKDF_INFO = new Uint8Array([114, 111, 111, 109, 45, 107, 101, 121, 45, 119, 114, 97, 112]); const ROOM_KEY_BYTES = 32; // 256-bit AES key for LiveKit SFrame // ── Key pair generation ───────────────────────────────────────────────────── /** Generate an ephemeral ECDH P-256 keypair. */ export async function generateECDHKeyPair(): Promise { - return crypto.subtle.generateKey({ name: "ECDH", namedCurve: ECDH_CURVE }, true, [ - "deriveBits", - ]) as Promise; + return crypto.subtle.generateKey({ name: "ECDH", namedCurve: ECDH_CURVE }, true, ["deriveBits"]); } /** Export a CryptoKey (public) to base64 for transmission. */ @@ -183,7 +179,7 @@ function base64ToUint8(base64: string): Uint8Array { } catch { throw new Error("E2EE: invalid base64 input"); } - const bytes = new Uint8Array(binary.length) as Uint8Array; + const bytes = new Uint8Array(binary.length); for (let i = 0; i < binary.length; i++) { bytes[i] = binary.charCodeAt(i); } diff --git a/Server/db/role_invite_queries_test.go b/Server/db/role_invite_queries_test.go index 8d4c6007..24f04f66 100644 --- a/Server/db/role_invite_queries_test.go +++ b/Server/db/role_invite_queries_test.go @@ -144,7 +144,7 @@ func TestGetUserWithRole_NotFound(t *testing.T) { func TestGetUserWithRole_BoolConversions(t *testing.T) { database := newTestDB(t) - uid, _ := database.CreateUser("booluser", "hash", 4) // Member: is_default=1 + uid, _ := database.CreateUser("booluser", "hash", 4) user, role, err := database.GetUserWithRole(uid) if err != nil { diff --git a/Server/ws/event_test.go b/Server/ws/event_test.go index 4c104377..62d59245 100644 --- a/Server/ws/event_test.go +++ b/Server/ws/event_test.go @@ -1,6 +1,7 @@ package ws import ( + "bytes" "testing" ) @@ -46,7 +47,7 @@ func TestResultWithError(t *testing.T) { func TestResultWithReply(t *testing.T) { reply := []byte(`{"type":"chat_send_ok","id":"req-1"}`) r := Result{Reply: reply} - if string(r.Reply) != string(reply) { + if !bytes.Equal(r.Reply, reply) { t.Errorf("Reply = %q, want %q", r.Reply, reply) } } diff --git a/Server/ws/messages.go b/Server/ws/messages.go index 8bc5b1e4..ac316550 100644 --- a/Server/ws/messages.go +++ b/Server/ws/messages.go @@ -207,18 +207,6 @@ func buildErrorMsg(code, message string) []byte { }) } -// buildRateLimitError produces a RATE_LIMITED error with retry_after per PROTOCOL.md. -func buildRateLimitError(message string, retryAfterSeconds float64) []byte { - return buildJSON(map[string]any{ - "type": MsgTypeError, - "payload": map[string]any{ - "code": "RATE_LIMITED", - "message": message, - "retry_after": retryAfterSeconds, - }, - }) -} - // buildAuthError produces an auth_error envelope per PROTOCOL.md. // The client treats this type as non-recoverable and stops reconnecting. func buildAuthError(message string) []byte {