diff --git a/src/actions/files.ts b/src/actions/files.ts index f748a02..8bb12d9 100644 --- a/src/actions/files.ts +++ b/src/actions/files.ts @@ -213,9 +213,7 @@ export async function GetReadme(id: string | null = null): Promise< file = data.files[0]; } else { file = data.files.find((file) => file.mimeType === "text/markdown"); - if (!file) { - file = data.files.find((file) => file.mimeType === "application/vnd.google-apps.shortcut"); - } + file ??= data.files.find((file) => file.mimeType === 'application/vnd.google-apps.shortcut'); } if (!file) diff --git a/src/lib/utils.server.ts b/src/lib/utils.server.ts index 4df235d..5751725 100644 --- a/src/lib/utils.server.ts +++ b/src/lib/utils.server.ts @@ -22,7 +22,7 @@ class EncryptionService { const iv = crypto.getRandomValues(new Uint8Array(12)); const alg = { name: "AES-GCM", iv }; - const keyhash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(forceKey ? forceKey : this.key)); + const keyhash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(forceKey ?? this.key)); const encodedData = new TextEncoder().encode(data); const secretKey = await crypto.subtle.importKey("raw", keyhash, alg, false, ["encrypt"]); @@ -45,7 +45,7 @@ class EncryptionService { if (!cipherText || !iv) throw new Error("Invalid hash format."); const alg = { name: "AES-GCM", iv: new Uint8Array(Buffer.from(iv, "hex")) }; - const keyhash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(forceKey ? forceKey : this.key)); + const keyhash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(forceKey ?? this.key)); const secretKey = await crypto.subtle.importKey("raw", keyhash, alg, false, ["decrypt"]);