Update web-app/src/lib/completion.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
cf62729cd0
commit
38bdfd51ba
@ -175,10 +175,13 @@ export const sendCompletion = async (
|
||||
try {
|
||||
const bytes = CryptoJS.AES.decrypt(encryptedKey, key)
|
||||
const decryptedKey = bytes.toString(CryptoJS.enc.Utf8)
|
||||
return decryptedKey || encryptedKey // Return original if decryption fails
|
||||
if (!decryptedKey) {
|
||||
throw new Error('Failed to decrypt API key: result is empty')
|
||||
}
|
||||
return decryptedKey
|
||||
} catch (error) {
|
||||
console.warn('Failed to decrypt API key, using original value:', error)
|
||||
return encryptedKey
|
||||
console.warn('Failed to decrypt API key:', error)
|
||||
throw new Error('Failed to decrypt API key')
|
||||
}
|
||||
}
|
||||
if (!secretKey) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user