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
This commit is contained in:
J3vb
2026-04-05 19:37:00 +02:00
parent 6e4a007b91
commit e2f8858019
4 changed files with 7 additions and 22 deletions
+4 -8
View File
@@ -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<ArrayBuffer>;
]);
// 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<ArrayBuffer>;
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<CryptoKeyPair> {
return crypto.subtle.generateKey({ name: "ECDH", namedCurve: ECDH_CURVE }, true, [
"deriveBits",
]) as Promise<CryptoKeyPair>;
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<ArrayBuffer> {
} catch {
throw new Error("E2EE: invalid base64 input");
}
const bytes = new Uint8Array(binary.length) as Uint8Array<ArrayBuffer>;
const bytes = new Uint8Array(binary.length);
for (let i = 0; i < binary.length; i++) {
bytes[i] = binary.charCodeAt(i);
}
+1 -1
View File
@@ -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 {
+2 -1
View File
@@ -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)
}
}
-12
View File
@@ -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 {