Skip to content

armgit / ente

Public Imported from GitHub
0

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

Reuse

Manav Rathib081537a2c63
diff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.ts
index 56ca6870b7..6bdd023965 100644
--- a/web/packages/base/crypto/libsodium.ts
+++ b/web/packages/base/crypto/libsodium.ts
@@ -783,19 +783,22 @@ export const deriveSensitiveKey = async (passphrase: string, salt: string) => {
}
}
throw new Error("Failed to derive key: Memory limit exceeded");
-}
+};
/**
* A variant of {@link deriveSensitiveKey} for deriving an alternative key with
* parameters suitable for interactive use.
*/
-export const deriveInteractiveKey = async (passphrase: string, salt: string) => {
+export const deriveInteractiveKey = async (
+ passphrase: string,
+ salt: string,
+) => {
const opsLimit = sodium.crypto_pwhash_OPSLIMIT_INTERACTIVE;
const memLimit = sodium.crypto_pwhash_MEMLIMIT_INTERACTIVE;
const key = await deriveKey(passphrase, salt, opsLimit, memLimit);
return { key, opsLimit, memLimit };
-}
+};
export async function generateEncryptionKey() {
await sodium.ready;
diff --git a/web/packages/base/crypto/worker.ts b/web/packages/base/crypto/worker.ts
index ed279697e3..0aefeaf77c 100644
--- a/web/packages/base/crypto/worker.ts
+++ b/web/packages/base/crypto/worker.ts
@@ -54,7 +54,6 @@ export class CryptoWorker {
return libsodium.completeChunkHashing(hashState);
}
-
async decryptB64(data: string, nonce: string, key: string) {
return libsodium.decryptB64(data, nonce, key);
}
diff --git a/web/packages/gallery/services/download.ts b/web/packages/gallery/services/download.ts
index 0b1fb67fb8..20864eb977 100644
--- a/web/packages/gallery/services/download.ts
+++ b/web/packages/gallery/services/download.ts
@@ -7,9 +7,11 @@ import {
initChunkDecryption,
} from "@/base/crypto";
import {
+ authenticatedPublicAlbumsRequestHeaders,
authenticatedRequestHeaders,
publicRequestHeaders,
retryEnsuringHTTPOk,
+ type PublicAlbumsCredentials,
} from "@/base/http";
import { ensureAuthToken } from "@/base/local-user";
import log from "@/base/log";
@@ -21,7 +23,6 @@ import {
import type { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import { decodeLivePhoto } from "@/media/live-photo";
-import { type PublicAlbumsCredentials }from "@/base/http";
export interface LivePhotoSourceURL {
image: () => Promise<string | undefined>;
@@ -690,13 +691,14 @@ const photos_downloadFile = async (file: EnteFile): Promise<Response> => {
*/
const publicAlbums_downloadThumbnail = async (
file: EnteFile,
- { accessToken, accessTokenJWT }: PublicAlbumsCredentials,
+ credentials: PublicAlbumsCredentials,
) => {
const customOrigin = await customAPIOrigin();
const getThumbnail = async () => {
if (customOrigin) {
// See: [Note: Passing credentials for self-hosted file fetches]
+ const { accessToken, accessTokenJWT } = credentials;
const params = new URLSearchParams({
accessToken,
...(accessTokenJWT ? { accessTokenJWT } : {}),
@@ -711,13 +713,8 @@ const publicAlbums_downloadThumbnail = async (
return fetch(
`https://public-albums.ente.io/preview/?fileID=${file.id}`,
{
- headers: {
- ...publicRequestHeaders(),
- "X-Auth-Access-Token": accessToken,
- ...(accessTokenJWT
- ? { "X-Auth-Access-Token-JWT": accessTokenJWT }
- : {}),
- },
+ headers:
+ authenticatedPublicAlbumsRequestHeaders(credentials),
},
);
}
@@ -729,13 +726,14 @@ const publicAlbums_downloadThumbnail = async (
const publicAlbums_downloadFile = async (
file: EnteFile,
- { accessToken, accessTokenJWT }: PublicAlbumsCredentials,
+ credentials: PublicAlbumsCredentials,
) => {
const customOrigin = await customAPIOrigin();
- // See: [Note: Passing credentials for self-hosted file fetches]
const getFile = () => {
if (customOrigin) {
+ // See: [Note: Passing credentials for self-hosted file fetches]
+ const { accessToken, accessTokenJWT } = credentials;
const params = new URLSearchParams({
accessToken,
...(accessTokenJWT ? { accessTokenJWT } : {}),
@@ -747,13 +745,8 @@ const publicAlbums_downloadFile = async (
return fetch(
`https://public-albums.ente.io/download/?fileID=${file.id}`,
{
- headers: {
- ...publicRequestHeaders(),
- "X-Auth-Access-Token": accessToken,
- ...(accessTokenJWT
- ? { "X-Auth-Access-Token-JWT": accessTokenJWT }
- : {}),
- },
+ headers:
+ authenticatedPublicAlbumsRequestHeaders(credentials),
},
);
}