Skip to content

Commit 2d3c11f

Browse files
committed
feat: send [ENCRYPTED] placeholders for title/content to server while storing actual encrypted data separately
1 parent c4ddceb commit 2d3c11f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/lib/api/api.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,14 @@ class ClerkEncryptedApiService {
225225

226226
const encryptedData = await this.encryptNoteForApi(title, content);
227227

228+
// CHANGE #1: Add [ENCRYPTED] placeholders
228229
const apiNote = await this.request<ApiNote>('/notes', {
229230
method: 'POST',
230231
body: JSON.stringify({
231232
...noteData,
232-
...encryptedData,
233+
title: '[ENCRYPTED]', // Server will store this placeholder
234+
content: '[ENCRYPTED]', // Server will store this placeholder
235+
...encryptedData, // This includes encryptedTitle, encryptedContent, iv, salt
233236
}),
234237
});
235238

@@ -257,9 +260,13 @@ class ClerkEncryptedApiService {
257260
const newContent = updates.content ?? currentNote.content;
258261

259262
const encrypted = await this.encryptNoteForApi(newTitle, newContent);
263+
264+
// CHANGE #2: Add [ENCRYPTED] placeholders
260265
encryptedUpdates = {
261266
...updates,
262-
...encrypted,
267+
title: '[ENCRYPTED]', // Server will store this placeholder
268+
content: '[ENCRYPTED]', // Server will store this placeholder
269+
...encrypted, // This includes encryptedTitle, encryptedContent, iv, salt
263270
};
264271
}
265272

src/lib/encryption/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// src/lib/encryption/constants.ts
12
export const ENCRYPTION_CONFIG = {
23
ALGORITHM: 'AES-GCM' as const,
34
KEY_LENGTH: 256,

0 commit comments

Comments
 (0)