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 return encryptedKey
} }
} }
if (!secretKey) {
throw new Error('Encryption key unavailable: cannot encrypt API key.')
}
const apiKey = provider.api_key const apiKey = provider.api_key
? decryptApiKey(provider.api_key, secretKey || 'fallback-key') ? decryptApiKey(provider.api_key, secretKey)
: (secretKey ?? '') : (secretKey ?? '')
const tokenJS = new TokenJS({ const tokenJS = new TokenJS({

View File

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