fix: remove fallback key

This commit is contained in:
Louis 2025-10-02 15:59:55 +07:00
parent 22a7547e6c
commit c63604ac55
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2
2 changed files with 10 additions and 7 deletions

View File

@ -181,9 +181,11 @@ export const sendCompletion = async (
return encryptedKey
}
}
if (!secretKey) {
throw new Error('Encryption key unavailable: cannot encrypt API key.')
}
const apiKey = provider.api_key
? decryptApiKey(provider.api_key, secretKey || 'fallback-key')
? decryptApiKey(provider.api_key, secretKey)
: (secretKey ?? '')
const tokenJS = new TokenJS({

View File

@ -536,10 +536,11 @@ function ProviderDetail() {
const secretKey = await getServiceHub()
.core()
.getAppToken()
updateObj.api_key = CryptoJS.AES.encrypt(
newValue,
secretKey || 'fallback-key'
).toString()
if (secretKey)
updateObj.api_key = CryptoJS.AES.encrypt(
newValue,
secretKey
).toString()
} else if (
settingKey === 'base-url' &&
typeof newValue === 'string'
@ -555,7 +556,7 @@ function ProviderDetail() {
)
if (deviceSettingIndex !== -1) {
(
;(
newSettings[deviceSettingIndex]
.controller_props as {
value: string