fix(core): serialise attachment file mutations, atomic writes, reject svg
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f58ba4cdc
commit
4acb368c87
4 files changed
+157
-43
No files matched your search
@@ -23,4 +23,17 @@ describe("crypto", () => {
|
||||
await expect(decryptJson("k", "garbage")).rejects.toBeInstanceOf(CryptoError);
|
||||
await expect(decryptJson("k", "v2.AA==.AA==")).rejects.toBeInstanceOf(CryptoError);
|
||||
});
|
||||
|
||||
test("IV decodes to 12 bytes", async () => {
|
||||
const blob = await encryptJson("k", { a: 1 });
|
||||
expect(Buffer.from(blob.split(".")[1]!, "base64")).toHaveLength(12);
|
||||
});
|
||||
|
||||
test("flipping a ciphertext byte throws CryptoError", async () => {
|
||||
const [v, iv, ct] = (await encryptJson("k", { a: 1 })).split(".");
|
||||
const bytes = Buffer.from(ct!, "base64");
|
||||
bytes[0] = bytes[0]! ^ 0xff;
|
||||
const tampered = `${v}.${iv}.${bytes.toString("base64")}`;
|
||||
await expect(decryptJson("k", tampered)).rejects.toBeInstanceOf(CryptoError);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user