Skip to content

Commit

Permalink
Pass item to legacyDecrypt without explicitly casting param type
Browse files Browse the repository at this point in the history
  • Loading branch information
kedskeds committed Jan 22, 2024
1 parent ea9a6e7 commit 16fddff
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main/LibsodiumEncryptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@ export class LibsodiumEncryptor implements Encryptor {
}

decrypt<T, K extends keyof T>(params: DecryptParams<T, K> | LegacyDecryptParams<T,K>): DecryptResult<T> {
const { encryptedItem, nonce, dataKey } = params
const encryptedFields = (params as DecryptParams<T, K>).encryptedFields

if (!encryptedFields) {
return this.legacyDecrypt(params as LegacyDecryptParams<T, K>)
if (!('encryptedFields' in params)) {
return this.legacyDecrypt(params)
}

const { encryptedItem, nonce, dataKey, encryptedFields } = params
const decryptionKey = this.deriveKey(dataKey, KeyType.ENCRYPTION)

const jsonBytes = crypto_secretbox_open_easy(encryptedFields, nonce, decryptionKey)
Expand Down

0 comments on commit 16fddff

Please sign in to comment.