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:
Ruben Talstra 2025-02-15 23:04:26 +01:00
parent 18d019d8b3
commit 94d32906f1
No known key found for this signature in database
GPG key ID: 2A5A7174A60F3BEA
11 changed files with 343 additions and 189 deletions

View file

@ -483,14 +483,17 @@ export const tMessageSchema = z.object({
thread_id: z.string().optional(),
/* frontend components */
iconURL: z.string().nullable().optional(),
iv: z.string().nullable().optional(),
authTag: z.string().nullable().optional(),
encryptedKey: z.string().nullable().optional(),
});
export type TAttachmentMetadata = { messageId: string; toolCallId: string };
export type TAttachment =
| (TFile & TAttachmentMetadata)
| (Pick<TFile, 'filename' | 'filepath' | 'conversationId'> & {
expiresAt: number;
} & TAttachmentMetadata);
expiresAt: number;
} & TAttachmentMetadata);
export type TMessage = z.input<typeof tMessageSchema> & {
children?: TMessage[];
@ -780,11 +783,11 @@ export const googleSchema = tConversationSchema
}));
/**
* TODO: Map the following fields:
- presence_penalty -> presencePenalty
- frequency_penalty -> frequencyPenalty
- stop -> stopSequences
*/
* TODO: Map the following fields:
- presence_penalty -> presencePenalty
- frequency_penalty -> frequencyPenalty
- stop -> stopSequences
*/
export const googleGenConfigSchema = z
.object({
maxOutputTokens: coerceNumber.optional(),

View file

@ -41,11 +41,11 @@ export type TEndpointOption = {
export type TPayload = Partial<TMessage> &
Partial<TEndpointOption> & {
isContinued: boolean;
conversationId: string | null;
messages?: TMessages;
isTemporary: boolean;
};
isContinued: boolean;
conversationId: string | null;
messages?: TMessages;
isTemporary: boolean;
};
export type TSubmission = {
artifacts?: string;
@ -111,10 +111,6 @@ export type TUser = {
plugins?: string[];
createdAt: string;
updatedAt: string;
encryptionPublicKey?: string;
encryptedPrivateKey?: string; // Encrypted as a Base64 string
encryptionSalt?: string; // Base64 encoded salt used for PBKDF2
encryptionIV?: string; // Base64 encoded IV for AES-GCM
};
export type TGetConversationsResponse = {
@ -482,10 +478,10 @@ export type TBannerResponse = TBanner | null;
* Request type for updating user encryption keys.
*/
export type UpdateUserEncryptionRequest = {
encryptionPublicKey: string;
encryptedPrivateKey: string;
encryptionSalt: string;
encryptionIV: string;
encryptionPublicKey: string | null;
encryptedPrivateKey: string | null;
encryptionSalt: string | null;
encryptionIV: string | null;
};
/**