import type { EncryptionPrivateKey } from '../../../domain/keypair.js' import { importJWK, compactDecrypt } from 'jose' import { ENCRYPTION_KEYPAIR_ALGORITHM } from './algorithm.js' export async function decrypt( privateJwk: EncryptionPrivateKey, encryptedContent: string, ) { const privateKey = await importJWK(privateJwk, ENCRYPTION_KEYPAIR_ALGORITHM) const decryptedContent = await compactDecrypt(encryptedContent, privateKey) return new TextDecoder().decode(decryptedContent.plaintext) }