Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove unnecessary JSON wrapper from anon name encryption

Anand Baburajan526b13ef7241
diff --git a/web/packages/new/albums/services/public-reaction.ts b/web/packages/new/albums/services/public-reaction.ts
index 01b78d73a2..6a25c05da5 100644
--- a/web/packages/new/albums/services/public-reaction.ts
+++ b/web/packages/new/albums/services/public-reaction.ts
@@ -111,7 +111,7 @@ export const createAnonIdentity = async (
): Promise<AnonIdentity> => {
// Encrypt the user name using the collection key
const { encryptedData: cipher, nonce } = await encryptBox(
- new TextEncoder().encode(JSON.stringify({ userName })),
+ new TextEncoder().encode(userName),
collectionKey,
);
@@ -398,12 +398,11 @@ export const getPublicAnonProfiles = async (
{ encryptedData: profile.cipher, nonce: profile.nonce },
collectionKey,
);
- const decryptedStr = new TextDecoder().decode(
+ const userName = new TextDecoder().decode(
Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),
);
- const data = JSON.parse(decryptedStr) as { userName?: string };
- if (data.userName) {
- anonUserNames.set(profile.anonUserID, data.userName);
+ if (userName) {
+ anonUserNames.set(profile.anonUserID, userName);
}
} catch {
// Skip profiles that fail to decrypt
diff --git a/web/packages/new/photos/services/social.ts b/web/packages/new/photos/services/social.ts
index 96276cb0fa..6a38f19cea 100644
--- a/web/packages/new/photos/services/social.ts
+++ b/web/packages/new/photos/services/social.ts
@@ -253,12 +253,11 @@ export const getAnonProfiles = async (
{ encryptedData: profile.cipher, nonce: profile.nonce },
collectionKey,
);
- const decryptedStr = new TextDecoder().decode(
+ const userName = new TextDecoder().decode(
Uint8Array.from(atob(decryptedB64), (c) => c.charCodeAt(0)),
);
- const data = JSON.parse(decryptedStr) as { userName?: string };
- if (data.userName) {
- anonUserNames.set(profile.anonUserID, data.userName);
+ if (userName) {
+ anonUserNames.set(profile.anonUserID, userName);
}
} catch {
// Skip profiles that fail to decrypt