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 {
|
try {
|
||||||
const bytes = CryptoJS.AES.decrypt(encryptedKey, key)
|
const bytes = CryptoJS.AES.decrypt(encryptedKey, key)
|
||||||
const decryptedKey = bytes.toString(CryptoJS.enc.Utf8)
|
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) {
|
} catch (error) {
|
||||||
console.warn('Failed to decrypt API key, using original value:', error)
|
console.warn('Failed to decrypt API key:', error)
|
||||||
return encryptedKey
|
throw new Error('Failed to decrypt API key')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!secretKey) {
|
if (!secretKey) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user