Fix: Resolve type incompatibility errors in sessionCrypto.ts

This commit is contained in:
LC mac
2026-01-29 23:24:57 +08:00
parent 6bbfe665cd
commit c1b1f566df

View File

@@ -88,7 +88,7 @@ export async function encryptJsonToBlob<T>(data: T): Promise<EncryptedBlob> {
const ciphertext = await window.crypto.subtle.encrypt( const ciphertext = await window.crypto.subtle.encrypt(
{ {
name: KEY_ALGORITHM, name: KEY_ALGORITHM,
iv: iv as Uint8Array, iv: new Uint8Array(iv),
}, },
sessionKey, sessionKey,
plaintext, plaintext,
@@ -121,10 +121,10 @@ export async function decryptBlobToJson<T>(blob: EncryptedBlob): Promise<T> {
const decrypted = await window.crypto.subtle.decrypt( const decrypted = await window.crypto.subtle.decrypt(
{ {
name: KEY_ALGORITHM, name: KEY_ALGORITHM,
iv: iv, iv: new Uint8Array(iv),
}, },
sessionKey, sessionKey,
ciphertext, new Uint8Array(ciphertext),
); );
const jsonString = new TextDecoder().decode(decrypted); const jsonString = new TextDecoder().decode(decrypted);