refactor(ui): improve AES-GCM decryption result handling

This commit is contained in:
Martin Braconi 2025-05-31 17:14:42 -05:00
parent a4f2346a57
commit 1793eb5396

View file

@ -206,7 +206,13 @@ watch([decryptInput, decryptSecret, decryptAlgo, decryptAesMode], async () => {
if (mode === 'GCM') {
decryptOutput.value = 'Decrypting...';
try {
decryptOutput.value = await algo.decrypt(mode, decryptInput.value, decryptSecret.value)._async();
const decryptionResult = algo.decrypt(mode, decryptInput.value, decryptSecret.value);
if (decryptionResult && typeof decryptionResult._async === 'function') {
decryptOutput.value = await decryptionResult._async();
}
else {
throw new Error('Invalid decryption result or unsupported mode.');
}
}
catch (e: any) {
decryptOutput.value = '';