mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
refactor: fully working E2EE
small issue to fix. when full response is received it replaces the text with the text from the DB. and then the decryption is not yet implement.
This commit is contained in:
parent
18d019d8b3
commit
94d32906f1
11 changed files with 343 additions and 189 deletions
|
|
@ -167,17 +167,20 @@ const updateUserEncryptionController = async (req, res) => {
|
|||
try {
|
||||
const { encryptionPublicKey, encryptedPrivateKey, encryptionSalt, encryptionIV } = req.body;
|
||||
|
||||
// Validate required parameters
|
||||
if (!encryptionPublicKey || !encryptedPrivateKey || !encryptionSalt || !encryptionIV) {
|
||||
// Allow disabling encryption by passing null for all fields.
|
||||
const allNull = encryptionPublicKey === null && encryptedPrivateKey === null && encryptionSalt === null && encryptionIV === null;
|
||||
const allPresent = encryptionPublicKey && encryptedPrivateKey && encryptionSalt && encryptionIV;
|
||||
|
||||
if (!allNull && !allPresent) {
|
||||
return res.status(400).json({ message: 'Missing encryption parameters.' });
|
||||
}
|
||||
|
||||
// Use the helper function to update the user.
|
||||
// Update the user record with the provided encryption parameters (or null to disable)
|
||||
const updatedUser = await updateUser(req.user.id, {
|
||||
encryptionPublicKey,
|
||||
encryptedPrivateKey,
|
||||
encryptionSalt,
|
||||
encryptionIV,
|
||||
encryptionPublicKey: encryptionPublicKey || null,
|
||||
encryptedPrivateKey: encryptedPrivateKey || null,
|
||||
encryptionSalt: encryptionSalt || null,
|
||||
encryptionIV: encryptionIV || null,
|
||||
});
|
||||
|
||||
if (!updatedUser) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue