update default location for encryption key
This commit is contained in:
parent
8c694e7987
commit
44294d0067
|
|
@ -428,7 +428,17 @@ export const getEnvironmentVariable = (name: string): string | undefined => {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
const getEncryptionKeyFilePath = (): string => {
|
const getEncryptionKeyFilePath = (): string => {
|
||||||
const checkPaths = [path.join(getUserHome(), '.flowise', 'encryption.key')]
|
const checkPaths = [
|
||||||
|
path.join(__dirname, '..', '..', 'encryption.key'),
|
||||||
|
path.join(__dirname, '..', '..', 'server', 'encryption.key'),
|
||||||
|
path.join(__dirname, '..', '..', '..', 'encryption.key'),
|
||||||
|
path.join(__dirname, '..', '..', '..', 'server', 'encryption.key'),
|
||||||
|
path.join(__dirname, '..', '..', '..', '..', 'encryption.key'),
|
||||||
|
path.join(__dirname, '..', '..', '..', '..', 'server', 'encryption.key'),
|
||||||
|
path.join(__dirname, '..', '..', '..', '..', '..', 'encryption.key'),
|
||||||
|
path.join(__dirname, '..', '..', '..', '..', '..', 'server', 'encryption.key'),
|
||||||
|
path.join(getUserHome(), '.flowise', 'encryption.key')
|
||||||
|
]
|
||||||
for (const checkPath of checkPaths) {
|
for (const checkPath of checkPaths) {
|
||||||
if (fs.existsSync(checkPath)) {
|
if (fs.existsSync(checkPath)) {
|
||||||
return checkPath
|
return checkPath
|
||||||
|
|
@ -437,7 +447,7 @@ const getEncryptionKeyFilePath = (): string => {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const getEncryptionKeyPath = (): string => {
|
export const getEncryptionKeyPath = (): string => {
|
||||||
return process.env.SECRETKEY_PATH ? path.join(process.env.SECRETKEY_PATH, 'encryption.key') : getEncryptionKeyFilePath()
|
return process.env.SECRETKEY_PATH ? path.join(process.env.SECRETKEY_PATH, 'encryption.key') : getEncryptionKeyFilePath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import {
|
||||||
convertChatHistoryToText,
|
convertChatHistoryToText,
|
||||||
getInputVariables,
|
getInputVariables,
|
||||||
handleEscapeCharacters,
|
handleEscapeCharacters,
|
||||||
|
getEncryptionKeyPath,
|
||||||
ICommonObject,
|
ICommonObject,
|
||||||
IDatabaseEntity,
|
IDatabaseEntity,
|
||||||
IMessage
|
IMessage
|
||||||
|
|
@ -852,16 +853,6 @@ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNod
|
||||||
return isChatOrLLMsExist && isValidChainOrAgent && !isOutputParserExist
|
return isChatOrLLMsExist && isValidChainOrAgent && !isOutputParserExist
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path of encryption key
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
export const getEncryptionKeyPath = (): string => {
|
|
||||||
return process.env.SECRETKEY_PATH
|
|
||||||
? path.join(process.env.SECRETKEY_PATH, 'encryption.key')
|
|
||||||
: path.join(getUserHome(), '.flowise', 'encryption.key')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an encryption key
|
* Generate an encryption key
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
|
@ -882,7 +873,8 @@ export const getEncryptionKey = async (): Promise<string> => {
|
||||||
return await fs.promises.readFile(getEncryptionKeyPath(), 'utf8')
|
return await fs.promises.readFile(getEncryptionKeyPath(), 'utf8')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const encryptKey = generateEncryptKey()
|
const encryptKey = generateEncryptKey()
|
||||||
await fs.promises.writeFile(getEncryptionKeyPath(), encryptKey)
|
const defaultLocation = path.join(getUserHome(), '.flowise', 'encryption.key')
|
||||||
|
await fs.promises.writeFile(defaultLocation, encryptKey)
|
||||||
return encryptKey
|
return encryptKey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue