π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update web to TypeScript 6
Manav Rathia887831b2c3f
diff --git a/desktop/src/main/services/ffmpeg.ts b/desktop/src/main/services/ffmpeg.tsindex f64a721a05..bb7914486b 100644--- a/desktop/src/main/services/ffmpeg.ts+++ b/desktop/src/main/services/ffmpeg.ts@@ -31,7 +31,7 @@ export const ffmpegExec = async (command: FFmpegCommand,pathOrZipItem: string | ZipItem,outputFileExtension: string,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>withInputFile(pathOrZipItem, async (worker, inputFilePath) => {const outputFilePath = await makeTempFilePath(outputFileExtension);try {diff --git a/desktop/src/main/services/image.ts b/desktop/src/main/services/image.tsindex 0ac99299eb..102d7339e2 100644--- a/desktop/src/main/services/image.ts+++ b/desktop/src/main/services/image.ts@@ -10,7 +10,9 @@ import {makeTempFilePath,} from "../utils/temp";-export const convertToJPEG = async (imageData: Uint8Array) => {+export const convertToJPEG = async (+ imageData: Uint8Array,+): Promise<Uint8Array<ArrayBuffer>> => {const inputFilePath = await makeTempFilePath();const outputFilePath = await makeTempFilePath("jpeg");@@ -19,7 +21,7 @@ export const convertToJPEG = async (imageData: Uint8Array) => {try {await fs.writeFile(inputFilePath, imageData);await execAsync(command);- return new Uint8Array(await fs.readFile(outputFilePath));+ return await fs.readFile(outputFilePath);} finally {await deleteTempFileIgnoringErrors(inputFilePath);await deleteTempFileIgnoringErrors(outputFilePath);@@ -64,7 +66,7 @@ export const generateImageThumbnail = async (pathOrZipItem: string | ZipItem,maxDimension: number,maxSize: number,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {const {path: inputFilePath,isFileTemporary: isInputFileTemporary,@@ -85,10 +87,10 @@ export const generateImageThumbnail = async (try {await writeToTemporaryInputFile();- let thumbnail: Uint8Array;+ let thumbnail: Uint8Array<ArrayBuffer>;do {await execAsync(command);- thumbnail = new Uint8Array(await fs.readFile(outputFilePath));+ thumbnail = await fs.readFile(outputFilePath);quality -= 10;command = generateImageThumbnailCommand(inputFilePath,diff --git a/desktop/src/preload.ts b/desktop/src/preload.tsindex adb3252293..308d172e9c 100644--- a/desktop/src/preload.ts+++ b/desktop/src/preload.ts@@ -230,14 +230,16 @@ const fsStatMtime = (path: string) => ipcRenderer.invoke("fsStatMtime", path);// - Conversion-const convertToJPEG = (imageData: Uint8Array) =>+const convertToJPEG = (+ imageData: Uint8Array,+): Promise<Uint8Array<ArrayBuffer>> =>ipcRenderer.invoke("convertToJPEG", imageData);const generateImageThumbnail = (pathOrZipItem: string | ZipItem,maxDimension: number,maxSize: number,-) =>+): Promise<Uint8Array<ArrayBuffer>> =>ipcRenderer.invoke("generateImageThumbnail",pathOrZipItem,@@ -249,7 +251,7 @@ const ffmpegExec = (command: FFmpegCommand,pathOrZipItem: string | ZipItem,outputFileExtension: string,-) =>+): Promise<Uint8Array<ArrayBuffer>> =>ipcRenderer.invoke("ffmpegExec",command,diff --git a/web/apps/accounts/tsconfig.json b/web/apps/accounts/tsconfig.jsonindex cd371d81f7..5ca285a32d 100644--- a/web/apps/accounts/tsconfig.json+++ b/web/apps/accounts/tsconfig.json@@ -8,6 +8,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/apps/albums/package.json b/web/apps/albums/package.jsonindex 69e0d25b4c..3667686157 100644--- a/web/apps/albums/package.json+++ b/web/apps/albums/package.json@@ -26,7 +26,7 @@"get-user-locale": "3.0.0","heic-convert": "2.1.0","hls-video-element": "1.5.11",- "i18next": "25.10.10",+ "i18next": "26.3.1","i18next-resources-to-backend": "1.2.1","idb": "8.0.3","jszip": "3.10.1",diff --git a/web/apps/albums/src/public-album/download/services/download-manager.ts b/web/apps/albums/src/public-album/download/services/download-manager.tsindex 8d7c7319e1..a61ae529f7 100644--- a/web/apps/albums/src/public-album/download/services/download-manager.ts+++ b/web/apps/albums/src/public-album/download/services/download-manager.ts@@ -290,7 +290,10 @@ class DownloadManager {* can return `undefined` iff the thumbnail is not already cached, and* {@link cachedOnly} is set to `true`.*/- async thumbnailData(file: EnteFile, cachedOnly = false) {+ async thumbnailData(+ file: EnteFile,+ cachedOnly = false,+ ): Promise<Uint8Array<ArrayBuffer> | undefined> {await this.initThumbnailCacheIfNeeded();const key = file.id.toString();diff --git a/web/apps/albums/src/public-album/media/processing/ffmpeg/index.ts b/web/apps/albums/src/public-album/media/processing/ffmpeg/index.tsindex 21bf4d3f86..7d0389d9d7 100644--- a/web/apps/albums/src/public-album/media/processing/ffmpeg/index.ts+++ b/web/apps/albums/src/public-album/media/processing/ffmpeg/index.ts@@ -19,8 +19,10 @@ export const generateVideoThumbnailWeb = async (blob: Blob) =>);const _generateVideoThumbnail = async (- thumbnailAtTime: (seekTime: number) => Promise<Uint8Array>,-) => {+ thumbnailAtTime: (+ seekTime: number,+ ) => Promise<Uint8Array<ArrayBuffer>>,+): Promise<Uint8Array<ArrayBuffer>> => {try {return await thumbnailAtTime(1);} catch {@@ -141,7 +143,9 @@ export const determineVideoDuration = async (uploadItem: File,): Promise<number> => determineVideoDurationWeb(uploadItem);-export const convertToMP4 = async (blob: Blob): Promise<Blob | Uint8Array> => {+export const convertToMP4 = async (+ blob: Blob,+): Promise<Blob | Uint8Array<ArrayBuffer>> => {const command = [ffmpegPathPlaceholder,"-i",diff --git a/web/apps/albums/src/public-album/media/processing/ffmpeg/web.ts b/web/apps/albums/src/public-album/media/processing/ffmpeg/web.tsindex 7340896423..965aa2d931 100644--- a/web/apps/albums/src/public-album/media/processing/ffmpeg/web.ts+++ b/web/apps/albums/src/public-album/media/processing/ffmpeg/web.ts@@ -1,4 +1,5 @@import { FFFSType, FFmpeg } from "@ffmpeg/ffmpeg";+import { ensureArrayBufferBacked } from "ente-base/bytes";import { joinPath } from "ente-base/file-name";import { newID } from "ente-base/id";import log from "ente-base/log";@@ -16,7 +17,7 @@ type FFmpegCommand = string[] | { default: string[]; hdr: string[] };let _ffmpeg: Promise<FFmpeg> | undefined;/** Queue of in-flight requests. */-const _ffmpegTaskQueue = new PromiseQueue<Uint8Array | number>();+const _ffmpegTaskQueue = new PromiseQueue<Uint8Array<ArrayBuffer> | number>();/*** Return the shared {@link FFmpeg} instance, lazily creating and loading it if@@ -52,7 +53,7 @@ export const ffmpegExecWeb = async (command: FFmpegCommand,blob: Blob,outputFileExtension: string,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {const ffmpeg = await ffmpegLazy();// Interleaving multiple ffmpeg.execs causes errors like//@@ -61,7 +62,7 @@ export const ffmpegExecWeb = async (// So serialize them using a promise queue.return _ffmpegTaskQueue.add(() =>ffmpegExec(ffmpeg, command, outputFileExtension, blob),- ) as Promise<Uint8Array>;+ ) as Promise<Uint8Array<ArrayBuffer>>;};/**@@ -88,7 +89,7 @@ const ffmpegExec = async (command: FFmpegCommand,outputFileExtension: string,blob: Blob,-) => {+): Promise<Uint8Array<ArrayBuffer>> => {const outputSuffix = outputFileExtension ? "." + outputFileExtension : "";const outputPath = newID("out_") + outputSuffix;@@ -130,7 +131,7 @@ const ffmpegExec = async (const ms = Date.now() - startTime;log.debug(() => `[wasm] ffmpeg ${cmd.join(" ")} (${ms} ms)`);- return result;+ return ensureArrayBufferBacked(result);} finally {try {await ffmpeg.deleteFile(outputPath);diff --git a/web/apps/albums/src/public-album/media/thumbnails/thumbnail-manager.ts b/web/apps/albums/src/public-album/media/thumbnails/thumbnail-manager.tsindex d055076f07..481d013180 100644--- a/web/apps/albums/src/public-album/media/thumbnails/thumbnail-manager.ts+++ b/web/apps/albums/src/public-album/media/thumbnails/thumbnail-manager.ts@@ -74,7 +74,10 @@ class ThumbnailManager {return thumb;}- async thumbnailData(file: EnteFile, cachedOnly = false) {+ async thumbnailData(+ file: EnteFile,+ cachedOnly = false,+ ): Promise<Uint8Array<ArrayBuffer> | undefined> {await this.initThumbnailCacheIfNeeded();const key = file.id.toString();diff --git a/web/apps/albums/src/public-album/media/video/preview.ts b/web/apps/albums/src/public-album/media/video/preview.tsindex a79c55d630..9a1d5e0d10 100644--- a/web/apps/albums/src/public-album/media/video/preview.ts+++ b/web/apps/albums/src/public-album/media/video/preview.ts@@ -84,7 +84,7 @@ const decryptPlaylistJSON = async (return PlaylistJSON.parse(JSON.parse(jsonString));};-const gunzip = async (data: Uint8Array) =>+const gunzip = async (data: Uint8Array<ArrayBuffer>) =>await new Response(new Blob([data]).stream().pipeThrough(new DecompressionStream("gzip")),).text();diff --git a/web/apps/albums/src/public-album/upload/pipeline/remote.ts b/web/apps/albums/src/public-album/upload/pipeline/remote.tsindex 3a6f7ae4f5..486bb0b852 100644--- a/web/apps/albums/src/public-album/upload/pipeline/remote.ts+++ b/web/apps/albums/src/public-album/upload/pipeline/remote.ts@@ -133,7 +133,7 @@ interface PutPartOptions {export const putFile = async (fileUploadURL: string,- fileData: Uint8Array,+ fileData: Uint8Array<ArrayBuffer>,retrier: HTTPRequestRetrier,options?: PutFileOptions,) =>@@ -155,7 +155,7 @@ export const putFile = async (*/export const putFileViaWorker = async (fileUploadURL: string,- fileData: Uint8Array,+ fileData: Uint8Array<ArrayBuffer>,retrier: HTTPRequestRetrier,options?: PutFileOptions,) =>@@ -193,7 +193,7 @@ export const putFileViaWorker = async (*/export const putFilePart = async (partUploadURL: string,- partData: Uint8Array,+ partData: Uint8Array<ArrayBuffer>,retrier: HTTPRequestRetrier,options?: PutPartOptions,) => {@@ -217,7 +217,7 @@ export const putFilePart = async (*/export const putFilePartViaWorker = async (partUploadURL: string,- partData: Uint8Array,+ partData: Uint8Array<ArrayBuffer>,retrier: HTTPRequestRetrier,options?: PutPartOptions,) => {diff --git a/web/apps/albums/src/public-album/upload/pipeline/thumbnail.ts b/web/apps/albums/src/public-album/upload/pipeline/thumbnail.tsindex 03223331d9..7386de5f51 100644--- a/web/apps/albums/src/public-album/upload/pipeline/thumbnail.ts+++ b/web/apps/albums/src/public-album/upload/pipeline/thumbnail.ts@@ -46,7 +46,7 @@ const canvasThumbnailGenerationTimeout = 30 * 1000;export const generateThumbnailWeb = async (blob: Blob,fileTypeInfo: FileTypeInfo,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>fileTypeInfo.fileType == FileType.image? await generateImageThumbnailWeb(blob, fileTypeInfo): await generateVideoThumbnailWeb(blob);@@ -96,7 +96,9 @@ const generateImageThumbnailUsingCanvas = async (blob: Blob) => {return await compressedJPEGData(canvas);};-const compressedJPEGData = async (canvas: HTMLCanvasElement) => {+const compressedJPEGData = async (+ canvas: HTMLCanvasElement,+): Promise<Uint8Array<ArrayBuffer>> => {let blob: Blob | undefined | null;let prevSize = Number.MAX_SAFE_INTEGER;let quality = 0.7;@@ -172,7 +174,7 @@ export const generateVideoThumbnailUsingCanvas = async (blob: Blob) => {* A fallback, black, thumbnail for use in cases where thumbnail generation* fails.*/-export const fallbackThumbnail = () =>+export const fallbackThumbnail = (): Uint8Array<ArrayBuffer> =>Uint8Array.from(atob(blackThumbnailB64), (c) => c.charCodeAt(0));const blackThumbnailB64 =diff --git a/web/apps/albums/src/public-album/upload/pipeline/upload-service.ts b/web/apps/albums/src/public-album/upload/pipeline/upload-service.tsindex 6abba0495e..295dff5583 100644--- a/web/apps/albums/src/public-album/upload/pipeline/upload-service.ts+++ b/web/apps/albums/src/public-album/upload/pipeline/upload-service.ts@@ -242,9 +242,9 @@ export interface UploadAsset {}interface ThumbnailedFile {- fileStreamOrData: FileStream | Uint8Array;+ fileStreamOrData: FileStream | Uint8Array<ArrayBuffer>;/** The JPEG data of the generated thumbnail */- thumbnail: Uint8Array;+ thumbnail: Uint8Array<ArrayBuffer>;/*** `true` if this is a fallback (all black) thumbnail we're returning since* thumbnail generation failed for some reason.@@ -267,7 +267,7 @@ interface EncryptedFileStream {* be smaller since a file would rarely align exactly to a* {@link streamEncryptionChunkSize} multiple).*/- stream: ReadableStream<Uint8Array>;+ stream: ReadableStream<Uint8Array<ArrayBuffer>>;/*** Number of chunks {@link stream} will emit, each* {@link streamEncryptionChunkSize} sized (except the last one).@@ -281,14 +281,17 @@ interface EncryptedFilePieces {* the decryption header that was used during encryption (base64 string).*/file: {- encryptedData: Uint8Array | EncryptedFileStream;+ encryptedData: Uint8Array<ArrayBuffer> | EncryptedFileStream;decryptionHeader: string;};/*** The encrypted contents of the file's thumbnail (as bytes), and the* decryption header that was used during encryption (base64 string).*/- thumbnail: { encryptedData: Uint8Array; decryptionHeader: string };+ thumbnail: {+ encryptedData: Uint8Array<ArrayBuffer>;+ decryptionHeader: string;+ };/*** The encrypted contents of the file's metadata (as a base64 string), and* the decryption header that was used during encryption (base64 string).@@ -910,7 +913,9 @@ const readImageOrVideoDetails = async (uploadItem: UploadItem) => {* size of the stream will be reasonable enough to be read in its entirety* without us running out of memory.*/-const readEntireStream = async (stream: ReadableStream) =>+const readEntireStream = async (+ stream: ReadableStream,+): Promise<Uint8Array<ArrayBuffer>> =>new Uint8Array(await new Response(stream).arrayBuffer());interface ExtractAssetMetadataResult {@@ -1232,7 +1237,7 @@ const readLivePhoto = async (// This is a reasonable behaviour since the videos corresponding to live// photos are only a couple of seconds long (we've already done a pre-flight// check during areLivePhotoAssets to ensure their size is small).- const fileOrData = async (sd: FileStream | Uint8Array) => {+ const fileOrData = async (sd: FileStream | Uint8Array<ArrayBuffer>) => {const fos = async ({ file, stream }: FileStream) =>file ? file : await readEntireStream(stream);return sd instanceof Uint8Array ? sd : fos(sd);@@ -1275,7 +1280,7 @@ const augmentWithThumbnail = async (fileTypeInfo: FileTypeInfo,fileStream: FileStream,): Promise<ThumbnailedFile> => {- let thumbnail: Uint8Array | undefined;+ let thumbnail: Uint8Array<ArrayBuffer> | undefined;let hasStaticThumbnail = false;try {@@ -1401,7 +1406,7 @@ const encryptFileStream = async (.pullState: undefined;const ref = { pullCount: 1 };- const encryptedFileStream = new ReadableStream({+ const encryptedFileStream = new ReadableStream<Uint8Array<ArrayBuffer>>({async pull(controller) {const { value, done } = await fileStreamReader.read();if (done) {@@ -1633,7 +1638,7 @@ const uploadStreamUsingMultipart = async ();// Public album uploads always request metadata-aware multipart URLs, so we// first materialize each part to compute its checksum.- const parts: Uint8Array[] = [];+ const parts: Uint8Array<ArrayBuffer>[] = [];const partMd5s: string[] = [];let fileSize = 0;while (true) {diff --git a/web/apps/albums/tsconfig.json b/web/apps/albums/tsconfig.jsonindex cc1ac8b35d..bf093f1c55 100644--- a/web/apps/albums/tsconfig.json+++ b/web/apps/albums/tsconfig.json@@ -8,6 +8,7 @@"include": ["../../packages/base/components/utils/mui-theme.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","next-env.d.ts","src/**/*.js","src/**/*.ts",diff --git a/web/apps/auth/package.json b/web/apps/auth/package.jsonindex 00313cd5d2..e561031ccc 100644--- a/web/apps/auth/package.json+++ b/web/apps/auth/package.json@@ -3,10 +3,10 @@"version": "0.0.0","private": true,"dependencies": {+ "@noble/hashes": "2.2.0","ente-accounts": "*","ente-base": "*",- "jssha": "3.3.1",- "otpauth": "9.2.4"+ "otpauth": "9.5.1"},"devDependencies": {"ente-build-config": "*"diff --git a/web/apps/auth/src/services/steam.ts b/web/apps/auth/src/services/steam.tsindex 3c4a8a9827..8b761f1780 100644--- a/web/apps/auth/src/services/steam.ts+++ b/web/apps/auth/src/services/steam.ts@@ -1,4 +1,5 @@-import jsSHA from "jssha";+import { hmac } from "@noble/hashes/hmac.js";+import { sha1 } from "@noble/hashes/legacy.js";import { Secret } from "otpauth";/**@@ -28,7 +29,7 @@ export class Steam {const counter = Math.floor(timestamp / 1000 / this.period);// Same as regular HOTP, but algorithm is fixed to SHA-1.- const digest = sha1HMACDigest(this.secret.buffer, uintToArray(counter));+ const digest = hmac(sha1, this.secret.bytes, uintToArray(counter));// Same calculation as regular HOTP.const offset = digest[digest.length - 1]! & 15;@@ -61,14 +62,3 @@ const uintToArray = (n: number): Uint8Array => {}return result;};--// We don't necessarily need a dependency on `jssha`, we could use SubtleCrypto-// here too. However, SubtleCrypto has an async interface, and we already have a-// transitive dependency on `jssha` via `otpauth`, so just using it here doesn't-// increase our bundle size any further.-const sha1HMACDigest = (key: ArrayBuffer, message: Uint8Array) => {- const hmac = new jsSHA("SHA-1", "UINT8ARRAY");- hmac.setHMACKey(key, "ARRAYBUFFER");- hmac.update(message);- return hmac.getHMAC("UINT8ARRAY");-};diff --git a/web/apps/auth/tsconfig.json b/web/apps/auth/tsconfig.jsonindex cd371d81f7..5ca285a32d 100644--- a/web/apps/auth/tsconfig.json+++ b/web/apps/auth/tsconfig.json@@ -8,6 +8,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/apps/cast/tsconfig.json b/web/apps/cast/tsconfig.jsonindex cd371d81f7..5ca285a32d 100644--- a/web/apps/cast/tsconfig.json+++ b/web/apps/cast/tsconfig.json@@ -8,6 +8,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/apps/embed/tsconfig.json b/web/apps/embed/tsconfig.jsonindex 6360403f00..1663f8b80e 100644--- a/web/apps/embed/tsconfig.json+++ b/web/apps/embed/tsconfig.json@@ -10,7 +10,8 @@"**/*.tsx","**/*.js","../../packages/base/components/utils/mui-theme.d.ts",- "../../packages/base/global-electron.d.ts"+ "../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts"],"exclude": ["node_modules", "out", ".next", ".next-desktop"]}diff --git a/web/apps/ensu/src/services/base64.ts b/web/apps/ensu/src/services/base64.tsindex b601d5ea5d..a8d9c910e0 100644--- a/web/apps/ensu/src/services/base64.ts+++ b/web/apps/ensu/src/services/base64.ts@@ -20,7 +20,7 @@ export const bytesToBase64 = (bytes: Uint8Array): string => {};/** Convert a base64 string to bytes. */-export const base64ToBytes = (b64: string): Uint8Array => {+export const base64ToBytes = (b64: string): Uint8Array<ArrayBuffer> => {const binary = atob(b64);const bytes = new Uint8Array(binary.length);for (let i = 0; i < binary.length; i++) {diff --git a/web/apps/ensu/src/services/chat/attachments.ts b/web/apps/ensu/src/services/chat/attachments.tsindex 0ef8cb81a5..b1e38a5d7f 100644--- a/web/apps/ensu/src/services/chat/attachments.ts+++ b/web/apps/ensu/src/services/chat/attachments.ts@@ -36,7 +36,7 @@ export const encryptAttachmentBytes = async (bytes: Uint8Array,chatKeyB64: string,sessionUuid: string,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {await ensureCryptoInit();const wasm = await enteWasm();const derivedKeyB64 = await deriveAttachmentKeyB64(chatKeyB64, sessionUuid);@@ -58,7 +58,7 @@ export const decryptAttachmentBytes = async (encrypted: Uint8Array,chatKeyB64: string,sessionUuid: string,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {if (encrypted.length < BLOB_HEADER_BYTES) {throw new Error("Invalid attachment blob length");}diff --git a/web/apps/ensu/src/services/chat/store.ts b/web/apps/ensu/src/services/chat/store.tsindex f73fe3e834..0f073b58ac 100644--- a/web/apps/ensu/src/services/chat/store.ts+++ b/web/apps/ensu/src/services/chat/store.ts@@ -70,7 +70,7 @@ interface StoredMessage {interface StoredAttachmentBytes {id: string;- data: Uint8Array;+ data: Uint8Array<ArrayBuffer>;}interface ChatDbSchema {@@ -1465,7 +1465,10 @@ const attachmentPath = async (id: string) => {return join(dir, id);};-export const writeAttachmentBytes = async (id: string, data: Uint8Array) => {+export const writeAttachmentBytes = async (+ id: string,+ data: Uint8Array<ArrayBuffer>,+) => {if (isTauriRuntime()) {const { writeFile } = await import("@tauri-apps/plugin-fs");const path = await attachmentPath(id);@@ -1487,7 +1490,9 @@ export const storeEncryptedAttachmentBytes = async (await writeAttachmentBytes(id, encrypted);};-export const readAttachmentBytes = async (id: string): Promise<Uint8Array> => {+export const readAttachmentBytes = async (+ id: string,+): Promise<Uint8Array<ArrayBuffer>> => {if (isTauriRuntime()) {const { readFile } = await import("@tauri-apps/plugin-fs");const path = await attachmentPath(id);@@ -1508,7 +1513,7 @@ export const readDecryptedAttachmentBytes = async (id: string,chatKey: string,sessionUuid: string,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {const encrypted = await readAttachmentBytes(id);try {return await decryptAttachmentBytes(encrypted, chatKey, sessionUuid);diff --git a/web/apps/ensu/src/services/chat/sync.ts b/web/apps/ensu/src/services/chat/sync.tsindex c5dfec5eb5..16fc15ef87 100644--- a/web/apps/ensu/src/services/chat/sync.ts+++ b/web/apps/ensu/src/services/chat/sync.ts@@ -957,7 +957,7 @@ const ensureAttachmentEncryptedForUpload = async (attachmentId: string,sessionUuid: string,chatKey: string,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {const bytes = await readAttachmentBytes(attachmentId);try {diff --git a/web/apps/ensu/tsconfig.json b/web/apps/ensu/tsconfig.jsonindex 2c346b502f..fca5cc709f 100644--- a/web/apps/ensu/tsconfig.json+++ b/web/apps/ensu/tsconfig.json@@ -11,6 +11,7 @@"next-env.d.ts","next.config.mjs","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"],"exclude": ["node_modules", "out", ".next", ".next-desktop"]diff --git a/web/apps/legacy/package.json b/web/apps/legacy/package.jsonindex b9f79223e2..149eb8903e 100644--- a/web/apps/legacy/package.json+++ b/web/apps/legacy/package.json@@ -8,7 +8,7 @@"ente-base": "*","ente-wasm": "*","pdfjs-dist": "5.7.284",- "qr": "0.5.5",+ "qr": "0.6.0","zod": "4.4.3"},"devDependencies": {diff --git a/web/apps/legacy/tsconfig.json b/web/apps/legacy/tsconfig.jsonindex fba3378737..91a164a1ba 100644--- a/web/apps/legacy/tsconfig.json+++ b/web/apps/legacy/tsconfig.json@@ -8,6 +8,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/apps/locker/src/services/crypto.ts b/web/apps/locker/src/services/crypto.tsindex a6f5e76879..168554ed47 100644--- a/web/apps/locker/src/services/crypto.ts+++ b/web/apps/locker/src/services/crypto.ts@@ -9,6 +9,7 @@* handled by the Rust/WASM module.*/+import { ensureArrayBufferBacked } from "ente-base/bytes";import type {EncryptedBlob,EncryptedBox,@@ -53,7 +54,7 @@ const toB64String = (v: Uint8Array | string): string => {/*** Convert a base64 string to bytes.*/-const fromB64String = (b64: string): Uint8Array => {+const fromB64String = (b64: string): Uint8Array<ArrayBuffer> => {const binary = atob(b64);const bytes = new Uint8Array(binary.length);for (let i = 0; i < binary.length; i++) {@@ -215,7 +216,10 @@ export { fromB64String, toB64String };export interface StreamEncryptorHandle {key: string;decryptionHeader: string;- encryptChunk: (data: Uint8Array, isFinal: boolean) => Promise<Uint8Array>;+ encryptChunk: (+ data: Uint8Array,+ isFinal: boolean,+ ) => Promise<Uint8Array<ArrayBuffer>>;free: () => void;}@@ -235,7 +239,11 @@ export const createStreamEncryptor =key: encryptor.key,decryptionHeader: encryptor.decryption_header,encryptChunk: (data: Uint8Array, isFinal: boolean) =>- Promise.resolve(encryptor.encrypt_chunk(data, isFinal)),+ Promise.resolve(+ ensureArrayBufferBacked(+ encryptor.encrypt_chunk(data, isFinal),+ ),+ ),free: () => encryptor.free(),};};@@ -318,7 +326,8 @@ export const bytesToB64 = (bytes: Uint8Array): string => toB64String(bytes);/*** Convert a base64 string to Uint8Array.*/-export const b64ToBytes = (b64: string): Uint8Array => fromB64String(b64);+export const b64ToBytes = (b64: string): Uint8Array<ArrayBuffer> =>+ fromB64String(b64);export const decryptStreamBytes = async (file: EncryptedFile,diff --git a/web/apps/locker/src/services/remote-uploads.ts b/web/apps/locker/src/services/remote-uploads.tsindex 604658d093..7d2be54c28 100644--- a/web/apps/locker/src/services/remote-uploads.ts+++ b/web/apps/locker/src/services/remote-uploads.ts@@ -122,7 +122,7 @@ const fetchMultipartUploadURLs = async ({const putFileToS3 = async (url: string,- data: Uint8Array,+ data: Uint8Array<ArrayBuffer>,contentMd5: string,onProgress?: (progress: { loaded: number; total?: number }) => void,): Promise<void> => {@@ -156,7 +156,7 @@ const putFileToS3 = async (};const uploadSingleObject = async (- data: Uint8Array,+ data: Uint8Array<ArrayBuffer>,contentMd5: string,onProgress?: (progress: { loaded: number; total?: number }) => void,): Promise<string> => {@@ -179,7 +179,7 @@ const uploadSingleObject = async (const putFilePartToS3 = async (url: string,- data: Uint8Array,+ data: Uint8Array<ArrayBuffer>,contentMd5: string,onProgress?: (progress: { loaded: number; total?: number }) => void,): Promise<string> => {@@ -255,7 +255,7 @@ const completeMultipartUpload = async ();};-const mergeUint8Arrays = (chunks: Uint8Array[]): Uint8Array => {+const mergeUint8Arrays = (chunks: Uint8Array[]): Uint8Array<ArrayBuffer> => {const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);const merged = new Uint8Array(totalLength);let offset = 0;@@ -321,9 +321,9 @@ export const uploadLockerFileWithDeps = async <TCollectionRecord>(try {if (plaintextChunkCount >= MULTIPART_CHUNKS_PER_PART) {- const parts: Uint8Array[] = [];+ const parts: Uint8Array<ArrayBuffer>[] = [];const partMd5s: string[] = [];- let pendingEncryptedChunks: Uint8Array[] = [];+ let pendingEncryptedChunks: Uint8Array<ArrayBuffer>[] = [];for (let chunkIndex = 0;@@ -397,7 +397,7 @@ export const uploadLockerFileWithDeps = async <TCollectionRecord>();encryptedFileObjectKey = multipartUpload.objectKey;} else {- const encryptedChunks: Uint8Array[] = [];+ const encryptedChunks: Uint8Array<ArrayBuffer>[] = [];for (let chunkIndex = 0;diff --git a/web/apps/locker/tsconfig.json b/web/apps/locker/tsconfig.jsonindex cd371d81f7..5ca285a32d 100644--- a/web/apps/locker/tsconfig.json+++ b/web/apps/locker/tsconfig.json@@ -8,6 +8,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/apps/memories/tsconfig.json b/web/apps/memories/tsconfig.jsonindex 43ed1b0cff..590308e22f 100644--- a/web/apps/memories/tsconfig.json+++ b/web/apps/memories/tsconfig.json@@ -4,6 +4,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/apps/paste/tsconfig.json b/web/apps/paste/tsconfig.jsonindex f6be56cfbf..4593077a02 100644--- a/web/apps/paste/tsconfig.json+++ b/web/apps/paste/tsconfig.json@@ -5,6 +5,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/apps/photos/tsconfig.json b/web/apps/photos/tsconfig.jsonindex 6360403f00..1663f8b80e 100644--- a/web/apps/photos/tsconfig.json+++ b/web/apps/photos/tsconfig.json@@ -10,7 +10,8 @@"**/*.tsx","**/*.js","../../packages/base/components/utils/mui-theme.d.ts",- "../../packages/base/global-electron.d.ts"+ "../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts"],"exclude": ["node_modules", "out", ".next", ".next-desktop"]}diff --git a/web/apps/share/src/services/collection-share.ts b/web/apps/share/src/services/collection-share.tsindex 2dc638f4ac..65f396bbdc 100644--- a/web/apps/share/src/services/collection-share.ts+++ b/web/apps/share/src/services/collection-share.ts@@ -360,7 +360,7 @@ export const downloadPublicCollectionFile = async (const totalHeader = response.headers.get("content-length");const total = totalHeader ? Number.parseInt(totalHeader, 10) : null;- let encryptedData: Uint8Array;+ let encryptedData: Uint8Array<ArrayBuffer>;if (response.body) {const reader = response.body.getReader();const chunks: Uint8Array[] = [];@@ -393,7 +393,7 @@ export const downloadPublicCollectionFile = async (fileKey,);- const blob = new Blob([new Uint8Array(decryptedData)]);+ const blob = new Blob([decryptedData]);const blobUrl = URL.createObjectURL(blob);const anchor = document.createElement("a");anchor.href = blobUrl;diff --git a/web/apps/share/src/services/file-share.ts b/web/apps/share/src/services/file-share.tsindex bf7066e3c5..6cdc2bc499 100644--- a/web/apps/share/src/services/file-share.ts+++ b/web/apps/share/src/services/file-share.ts@@ -455,7 +455,7 @@ export const downloadFile = async (const encryptedData = new Uint8Array(await response.arrayBuffer());- let decryptedData: Uint8Array;+ let decryptedData: Uint8Array<ArrayBuffer>;if (fileDecryptionHeader) {// Modern format: Decrypt the file using the decryption header@@ -475,7 +475,7 @@ export const downloadFile = async (}// Create a blob from the decrypted data- const blob = new Blob([new Uint8Array(decryptedData)]);+ const blob = new Blob([decryptedData]);// Create download linkconst blobUrl = URL.createObjectURL(blob);diff --git a/web/apps/share/tsconfig.json b/web/apps/share/tsconfig.jsonindex cd371d81f7..5ca285a32d 100644--- a/web/apps/share/tsconfig.json+++ b/web/apps/share/tsconfig.json@@ -8,6 +8,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/apps/twoof3/package.json b/web/apps/twoof3/package.jsonindex 2eb48fdb1e..f748576b71 100644--- a/web/apps/twoof3/package.json+++ b/web/apps/twoof3/package.json@@ -5,7 +5,7 @@"dependencies": {"@fontsource/space-grotesk": "5.2.10","ente-base": "*",- "qr": "0.5.5"+ "qr": "0.6.0"},"devDependencies": {"ente-build-config": "*"diff --git a/web/apps/twoof3/src/features/twoof3/utils/qrCode.ts b/web/apps/twoof3/src/features/twoof3/utils/qrCode.tsindex ec0612973f..a31d1cf255 100644--- a/web/apps/twoof3/src/features/twoof3/utils/qrCode.ts+++ b/web/apps/twoof3/src/features/twoof3/utils/qrCode.ts@@ -49,7 +49,7 @@ const isFinderModule = (x: number, y: number, size: number) => {export const createQrSvgData = (value: string): QrSvgData | null => {try {- const qr = encodeQR(value, "raw", { border: 0, ecc: "medium" });+ const qr = encodeQR(value, "raw", { border: 1, ecc: "medium" });const modules: QrModule[] = [];for (let y = 0; y < qr.length; y++) {diff --git a/web/apps/twoof3/tsconfig.json b/web/apps/twoof3/tsconfig.jsonindex f6be56cfbf..4593077a02 100644--- a/web/apps/twoof3/tsconfig.json+++ b/web/apps/twoof3/tsconfig.json@@ -5,6 +5,7 @@"src","next-env.d.ts","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/docs/dependencies.md b/web/docs/dependencies.mdindex f8fac7b676..f4c84824de 100644--- a/web/docs/dependencies.md+++ b/web/docs/dependencies.md@@ -170,12 +170,12 @@ Inter Variable (with support for weights 100 - 90) is used as the primary font,- [otpauth](https://github.com/hectorm/otpauth) is used for the generation of the actual OTP from the user's TOTP/HOTP secret.-- However, otpauth doesn't support steam OTPs. For these, we need to compute the SHA-1, and we use the same library, `jssha` that `otpauth` uses since it is already part of our bundle (transitively).+- However, otpauth doesn't support steam OTPs. For these, we need to compute the SHA-1, and we use `@noble/hashes`, the same hash library that `otpauth` uses.## Pinned-- `otpauth` is pinned to 9.2.4 since subsequent versions changed the underlying hash library, which requires a change in the steam OTP generation code.-- `react-dropzone` is pinned to the 14.2.10, the last version in the 14.2 series, since if we use 14.3 onwards (I tested till 14.3.5) then we are unable to get back a path from the file by using the `webUtils.getPathForFile` function provided by Electron. See: https://github.com/react-dropzone/react-dropzone/issues/1411- `@stripe/stripe-js` is pinned to the latest 1.x (it works as it is currently, migrating to newer major versions requires headspace since it _might_ also require museum changes).++- `base-x` is pinned to 5.0.1 via the root `overrides` field because it is pulled in transitively by `bs58`, and 5.0.0 is affected by [CVE-2025-27611](https://github.com/advisories/GHSA-xq7p-g2vc-g82p).diff --git a/web/package-lock.json b/web/package-lock.jsonindex 49ef0ac3ad..295ef58d57 100644--- a/web/package-lock.json+++ b/web/package-lock.json@@ -15,7 +15,7 @@"concurrently": "9.2.1","eslint": "9.39.4","prettier": "3.6.2",- "typescript": "5.8.3"+ "typescript": "6.0.3"}},"apps/accounts": {@@ -54,7 +54,7 @@"get-user-locale": "3.0.0","heic-convert": "2.1.0","hls-video-element": "1.5.11",- "i18next": "25.10.10",+ "i18next": "26.3.1","i18next-resources-to-backend": "1.2.1","idb": "8.0.3","jszip": "3.10.1",@@ -107,15 +107,27 @@"apps/auth": {"version": "0.0.0","dependencies": {+ "@noble/hashes": "2.2.0","ente-accounts": "*","ente-base": "*",- "jssha": "3.3.1",- "otpauth": "9.2.4"+ "otpauth": "9.5.1"},"devDependencies": {"ente-build-config": "*"}},+ "apps/auth/node_modules/@noble/hashes": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.2.0.tgz",+ "integrity": "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg==",+ "license": "MIT",+ "engines": {+ "node": ">= 20.19.0"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },"apps/cast": {"version": "0.0.0","dependencies": {@@ -187,7 +199,7 @@"ente-base": "*","ente-wasm": "*","pdfjs-dist": "5.7.284",- "qr": "0.5.5",+ "qr": "0.6.0","zod": "4.4.3"},"devDependencies": {@@ -311,7 +323,7 @@"dependencies": {"@fontsource/space-grotesk": "5.2.10","ente-base": "*",- "qr": "0.5.5"+ "qr": "0.6.0"},"devDependencies": {"ente-build-config": "*"@@ -6463,9 +6475,9 @@}},"node_modules/i18next": {- "version": "25.10.10",- "resolved": "https://registry.npmjs.org/i18next/-/i18next-25.10.10.tgz",- "integrity": "sha512-cqUW2Z3EkRx7NqSyywjkgCLK7KLCL6IFVFcONG7nVYIJ3ekZ1/N5jUsihHV6Bq37NfhgtczxJcxduELtjTwkuQ==",+ "version": "26.3.1",+ "resolved": "https://registry.npmjs.org/i18next/-/i18next-26.3.1.tgz",+ "integrity": "sha512-txQqd5EULsqEh9OJqRH15aCaOuy/nLJyhw5EHCSKLKJE1aBbb3Zve2+uQIxgWhPm1QqUQoWyQBm2kfmmIrzkcQ==","funding": [{"type": "individual",@@ -6481,9 +6493,6 @@}],"license": "MIT",- "dependencies": {- "@babel/runtime": "^7.29.2"- },"peerDependencies": {"typescript": "^5 || ^6"},@@ -7174,15 +7183,6 @@"node": ">=6"}},- "node_modules/jssha": {- "version": "3.3.1",- "resolved": "https://registry.npmjs.org/jssha/-/jssha-3.3.1.tgz",- "integrity": "sha512-VCMZj12FCFMQYcFLPRm/0lOBbLi8uM2BhXPTqw3U4YAfs4AZfiApOoBLoN8cQE60Z50m1MYMTQVCfgF/KaCVhQ==",- "license": "BSD-3-Clause",- "engines": {- "node": "*"- }- },"node_modules/jsx-ast-utils": {"version": "3.3.5","resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz",@@ -8675,17 +8675,29 @@}},"node_modules/otpauth": {- "version": "9.2.4",- "resolved": "https://registry.npmjs.org/otpauth/-/otpauth-9.2.4.tgz",- "integrity": "sha512-t0Nioq2Up2ZaT5AbpXZLTjrsNtLc/g/rVSaEThmKLErAuT9mrnAKJryiPOKc3rCH+3ycWBgKpRHYn+DHqfaPiQ==",+ "version": "9.5.1",+ "resolved": "https://registry.npmjs.org/otpauth/-/otpauth-9.5.1.tgz",+ "integrity": "sha512-fJmDAHc8wImfqqqOXIlBvT1dEKrZK0Cmb2VEgScpNTolCz0PHh6ExUZGv4sLtOsWNaHCQlD+rRqaPgnoxFoZjQ==","license": "MIT","dependencies": {- "jssha": "~3.3.1"+ "@noble/hashes": "2.2.0"},"funding": {"url": "https://github.com/hectorm/otpauth?sponsor=1"}},+ "node_modules/otpauth/node_modules/@noble/hashes": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.2.0.tgz",+ "integrity": "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg==",+ "license": "MIT",+ "engines": {+ "node": ">= 20.19.0"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },"node_modules/own-keys": {"version": "1.0.1","resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz",@@ -9085,9 +9097,9 @@}},"node_modules/qr": {- "version": "0.5.5",- "resolved": "https://registry.npmjs.org/qr/-/qr-0.5.5.tgz",- "integrity": "sha512-iQBvKj7MRKO+co+MY0IZpyLO+ezvttxsmV86WywrgPuAmgBkv0pytyi03wourniSoPgzffeBW6cBgIkpqcvjTg==",+ "version": "0.6.0",+ "resolved": "https://registry.npmjs.org/qr/-/qr-0.6.0.tgz",+ "integrity": "sha512-P23VoX7SipHALdiIYG+D+LT/6n22dNKwV92FAb3d+Nlki/5WisSsfLt0UDFz2XEBtuwrECTznvu+chKKFCSYhA==","license": "(MIT OR Apache-2.0)","engines": {"node": ">= 20.19.0"@@ -10556,9 +10568,9 @@}},"node_modules/typescript": {- "version": "5.8.3",- "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",- "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",+ "version": "6.0.3",+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",+ "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==","devOptional": true,"license": "Apache-2.0","bin": {@@ -11429,7 +11441,7 @@"ente-utils": "*","formik": "2.4.9","get-user-locale": "3.0.0",- "i18next": "25.10.10",+ "i18next": "26.3.1","i18next-resources-to-backend": "1.2.1","idb": "8.0.3","libsodium-wrappers-sumo": "0.7.15",@@ -11442,6 +11454,7 @@},"devDependencies": {"@types/libsodium-wrappers-sumo": "0.7.8",+ "@types/node": "24.12.4","@types/react": "19.2.16","@types/react-dom": "19.2.3","ente-build-config": "*"@@ -11474,7 +11487,7 @@"prettier": "3.6.2","prettier-plugin-organize-imports": "4.3.0","prettier-plugin-packagejson": "2.5.22",- "typescript": "5.8.3",+ "typescript": "6.0.3","typescript-eslint": "8.60.1"}},diff --git a/web/package.json b/web/package.jsonindex 1ca3caebd6..734b803dfb 100644--- a/web/package.json+++ b/web/package.json@@ -51,7 +51,7 @@"concurrently": "9.2.1","eslint": "9.39.4","prettier": "3.6.2",- "typescript": "5.8.3"+ "typescript": "6.0.3"},"packageManager": "[email protected]"}diff --git a/web/packages/accounts-rs/tsconfig.json b/web/packages/accounts-rs/tsconfig.jsonindex 15dcfedc2b..5ec0ea7522 100644--- a/web/packages/accounts-rs/tsconfig.json+++ b/web/packages/accounts-rs/tsconfig.json@@ -3,6 +3,8 @@"include": [".","../base/global-electron.d.ts",+ "../base/global-css.d.ts",+ "../base/globals.d.ts","../base/components/utils/mui-theme.d.ts"]}diff --git a/web/packages/accounts/tsconfig.json b/web/packages/accounts/tsconfig.jsonindex 15dcfedc2b..5ec0ea7522 100644--- a/web/packages/accounts/tsconfig.json+++ b/web/packages/accounts/tsconfig.json@@ -3,6 +3,8 @@"include": [".","../base/global-electron.d.ts",+ "../base/global-css.d.ts",+ "../base/globals.d.ts","../base/components/utils/mui-theme.d.ts"]}diff --git a/web/packages/base/bytes.ts b/web/packages/base/bytes.tsnew file mode 100644index 0000000000..a701b2f62f--- /dev/null+++ b/web/packages/base/bytes.ts@@ -0,0 +1,12 @@+export const isArrayBufferBacked = (+ bytes: Uint8Array,+): bytes is Uint8Array<ArrayBuffer> => bytes.buffer instanceof ArrayBuffer;++/**+ * Return {@link bytes} when it is backed by an {@link ArrayBuffer}; otherwise+ * copy it into a new {@link Uint8Array} with an {@link ArrayBuffer} backing.+ */+export const ensureArrayBufferBacked = (+ bytes: Uint8Array,+): Uint8Array<ArrayBuffer> =>+ isArrayBufferBacked(bytes) ? bytes : new Uint8Array(bytes);diff --git a/web/packages/base/crypto/index.ts b/web/packages/base/crypto/index.tsindex f66272a864..dc629ec727 100644--- a/web/packages/base/crypto/index.ts+++ b/web/packages/base/crypto/index.ts@@ -323,7 +323,7 @@ export const encryptStreamChunk = (data: Uint8Array,state: SodiumStateAddress,isFinalChunk: boolean,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>inWorker()? libsodium.encryptStreamChunk(data, state, isFinalChunk): sharedWorker().then((w) =>@@ -349,7 +349,7 @@ export const decryptBox = (export const decryptBoxBytes = (box: EncryptedBox,key: BytesOrB64,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>inWorker()? libsodium.decryptBoxBytes(box, key): sharedWorker().then((w) => w.decryptBoxBytes(box, key));@@ -373,7 +373,7 @@ export const decryptBlob = (export const decryptBlobBytes = (blob: EncryptedBlob,key: BytesOrB64,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>inWorker()? libsodium.decryptBlobBytes(blob, key): sharedWorker().then((w) => w.decryptBlobBytes(blob, key));@@ -384,7 +384,7 @@ export const decryptBlobBytes = (export const decryptStreamBytes = (file: EncryptedFile,key: BytesOrB64,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>inWorker()? libsodium.decryptStreamBytes(file, key): sharedWorker().then((w) => w.decryptStreamBytes(file, key));@@ -409,7 +409,7 @@ export const initChunkDecryption = (export const decryptStreamChunk = (data: Uint8Array,state: SodiumStateAddress,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>inWorker()? libsodium.decryptStreamChunk(data, state): sharedWorker().then((w) => w.decryptStreamChunk(data, state));diff --git a/web/packages/base/crypto/libsodium.ts b/web/packages/base/crypto/libsodium.tsindex e6cd7218cb..5df176e3e6 100644--- a/web/packages/base/crypto/libsodium.ts+++ b/web/packages/base/crypto/libsodium.ts@@ -8,6 +8,7 @@** To see where this code fits, see [Note: Crypto code hierarchy].*/+import { ensureArrayBufferBacked } from "ente-base/bytes";import { mergeUint8Arrays } from "ente-utils/array";import sodium from "libsodium-wrappers-sumo";import {@@ -42,9 +43,13 @@ export const toB64 = async (input: Uint8Array) => {** This is the converse of {@link toBase64}.*/-export const fromB64 = async (input: string): Promise<Uint8Array> => {+export const fromB64 = async (+ input: string,+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;- return sodium.from_base64(input, sodium.base64_variants.ORIGINAL);+ return ensureArrayBufferBacked(+ sodium.from_base64(input, sodium.base64_variants.ORIGINAL),+ );};/**@@ -83,9 +88,13 @@ export const toB64URLSafeNoPadding = async (input: Uint8Array) => {* This is the converse of {@link toB64URLSafeNoPadding}, and does not expect* its input string's length to be a an integer multiple of 4.*/-export const fromB64URLSafeNoPadding = async (input: string) => {+export const fromB64URLSafeNoPadding = async (+ input: string,+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;- return sodium.from_base64(input, sodium.base64_variants.URLSAFE_NO_PADDING);+ return ensureArrayBufferBacked(+ sodium.from_base64(input, sodium.base64_variants.URLSAFE_NO_PADDING),+ );};/**@@ -304,7 +313,10 @@ export const encryptBlobBytes = async (null,sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL,);- return { encryptedData: pushResult, decryptionHeader: header };+ return {+ encryptedData: ensureArrayBufferBacked(pushResult),+ decryptionHeader: ensureArrayBufferBacked(header),+ };};/**@@ -446,16 +458,18 @@ export const encryptStreamChunk = async (data: Uint8Array,pushState: SodiumStateAddress,isFinalChunk: boolean,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;const tag = isFinalChunk? sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL: sodium.crypto_secretstream_xchacha20poly1305_TAG_MESSAGE;- return sodium.crypto_secretstream_xchacha20poly1305_push(- pushState,- data,- null,- tag,+ return ensureArrayBufferBacked(+ sodium.crypto_secretstream_xchacha20poly1305_push(+ pushState,+ data,+ null,+ tag,+ ),);};@@ -465,12 +479,14 @@ export const encryptStreamChunk = async (export const decryptBoxBytes = async ({ encryptedData, nonce }: EncryptedBox,key: BytesOrB64,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;- return sodium.crypto_secretbox_open_easy(- await bytes(encryptedData),- await bytes(nonce),- await bytes(key),+ return ensureArrayBufferBacked(+ sodium.crypto_secretbox_open_easy(+ await bytes(encryptedData),+ await bytes(nonce),+ await bytes(key),+ ),);};@@ -488,7 +504,7 @@ export const decryptBox = (export const decryptBlobBytes = async ({ encryptedData, decryptionHeader }: EncryptedBlob,key: BytesOrB64,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;const pullState = sodium.crypto_secretstream_xchacha20poly1305_init_pull(await bytes(decryptionHeader),@@ -499,7 +515,7 @@ export const decryptBlobBytes = async (await bytes(encryptedData),null,);- return pullResult.message;+ return ensureArrayBufferBacked(pullResult.message);};/**@@ -533,7 +549,7 @@ export const decryptMetadataJSON = async (export const decryptStreamBytes = async ({ encryptedData, decryptionHeader }: EncryptedFile,key: BytesOrB64,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;const pullState = sodium.crypto_secretstream_xchacha20poly1305_init_pull(await fromB64(decryptionHeader),@@ -603,13 +619,13 @@ export const initChunkDecryption = async (export const decryptStreamChunk = async (data: Uint8Array,pullState: SodiumStateAddress,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;const pullResult = sodium.crypto_secretstream_xchacha20poly1305_pull(pullState,data,);- return pullResult.message;+ return ensureArrayBufferBacked(pullResult.message);};/**@@ -718,12 +734,14 @@ export const boxSeal = async (data: string, publicKey: string) => {export const boxSealOpenBytes = async (encryptedData: string,{ publicKey, privateKey }: KeyPair,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;- return sodium.crypto_box_seal_open(- await fromB64(encryptedData),- await fromB64(publicKey),- await fromB64(privateKey),+ return ensureArrayBufferBacked(+ sodium.crypto_box_seal_open(+ await fromB64(encryptedData),+ await fromB64(publicKey),+ await fromB64(privateKey),+ ),);};@@ -906,12 +924,14 @@ export const deriveSubKeyBytes = async (subKeyLength: number,subKeyID: number,context: string,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {await sodium.ready;- return sodium.crypto_kdf_derive_from_key(- subKeyLength,- subKeyID,- context,- await bytes(key),+ return ensureArrayBufferBacked(+ sodium.crypto_kdf_derive_from_key(+ subKeyLength,+ subKeyID,+ context,+ await bytes(key),+ ),);};diff --git a/web/packages/base/crypto/types.ts b/web/packages/base/crypto/types.tsindex 8b82a2aef8..55dfe7a79b 100644--- a/web/packages/base/crypto/types.ts+++ b/web/packages/base/crypto/types.ts@@ -113,7 +113,7 @@ export interface EncryptedBlobBytes {/*** The encrypted data.*/- encryptedData: Uint8Array;+ encryptedData: Uint8Array<ArrayBuffer>;/*** The decryption header.*@@ -121,7 +121,7 @@ export interface EncryptedBlobBytes {* it effectively contains a random nonce generated by libsodium. It does* not need to be secret, but it is required to decrypt the data.*/- decryptionHeader: Uint8Array;+ decryptionHeader: Uint8Array<ArrayBuffer>;}/**@@ -156,7 +156,7 @@ export interface EncryptedFile {/*** The encrypted data.*/- encryptedData: Uint8Array;+ encryptedData: Uint8Array<ArrayBuffer>;/*** A base64 string containing the decryption header.*diff --git a/web/packages/base/global-css.d.ts b/web/packages/base/global-css.d.tsnew file mode 100644index 0000000000..4de207533f--- /dev/null+++ b/web/packages/base/global-css.d.ts@@ -0,0 +1,3 @@+declare module "*.css";+declare module "@fontsource/*";+declare module "@fontsource-variable/*";diff --git a/web/packages/base/globals.d.ts b/web/packages/base/globals.d.tsnew file mode 100644index 0000000000..9771668de2--- /dev/null+++ b/web/packages/base/globals.d.ts@@ -0,0 +1,21 @@+interface ErrorConstructor {+ /**+ * V8 stack trace hook available in Chromium-derived browsers and Electron.+ */+ captureStackTrace?(targetObject: object, constructorOpt?: unknown): void;+}++/**+ * Build-time `process.env.*` replacements available to our browser bundles.+ */+declare const process: {+ readonly env: {+ readonly NODE_ENV: "development" | "production" | "test";+ readonly NEXT_PUBLIC_ENTE_ENDPOINT?: string;+ readonly NEXT_PUBLIC_ENTE_TRACE?: string;+ readonly appName: string;+ readonly desktopAppVersion?: string;+ readonly gitSHA?: string;+ readonly isDesktop: "" | "1";+ };+};diff --git a/web/packages/base/package.json b/web/packages/base/package.jsonindex eaf1dd9db2..b85ae3442d 100644--- a/web/packages/base/package.json+++ b/web/packages/base/package.json@@ -12,7 +12,7 @@"ente-utils": "*","formik": "2.4.9","get-user-locale": "3.0.0",- "i18next": "25.10.10",+ "i18next": "26.3.1","i18next-resources-to-backend": "1.2.1","idb": "8.0.3","libsodium-wrappers-sumo": "0.7.15",@@ -25,6 +25,7 @@},"devDependencies": {"@types/libsodium-wrappers-sumo": "0.7.8",+ "@types/node": "24.12.4","@types/react": "19.2.16","@types/react-dom": "19.2.3","ente-build-config": "*"diff --git a/web/packages/base/tsconfig.json b/web/packages/base/tsconfig.jsonindex 15dcfedc2b..5ec0ea7522 100644--- a/web/packages/base/tsconfig.json+++ b/web/packages/base/tsconfig.json@@ -3,6 +3,8 @@"include": [".","../base/global-electron.d.ts",+ "../base/global-css.d.ts",+ "../base/globals.d.ts","../base/components/utils/mui-theme.d.ts"]}diff --git a/web/packages/base/types/ipc.ts b/web/packages/base/types/ipc.tsindex b24b9164b8..3d85a53619 100644--- a/web/packages/base/types/ipc.ts+++ b/web/packages/base/types/ipc.ts@@ -403,7 +403,9 @@ export interface Electron {** @returns JPEG data of the converted image.*/- convertToJPEG: (imageData: Uint8Array) => Promise<Uint8Array>;+ convertToJPEG: (+ imageData: Uint8Array,+ ) => Promise<Uint8Array<ArrayBuffer>>;/*** Generate a JPEG thumbnail for the given image.@@ -427,7 +429,7 @@ export interface Electron {pathOrZipItem: string | ZipItem,maxDimension: number,maxSize: number,- ) => Promise<Uint8Array>;+ ) => Promise<Uint8Array<ArrayBuffer>>;/*** Execute a FFmpeg {@link command} on the given {@link pathOrZipItem}.@@ -462,7 +464,7 @@ export interface Electron {command: FFmpegCommand,pathOrZipItem: string | ZipItem,outputFileExtension: string,- ) => Promise<Uint8Array>;+ ) => Promise<Uint8Array<ArrayBuffer>>;/*** Determine the duration (in seconds) of the video present atdiff --git a/web/packages/build-config/package.json b/web/packages/build-config/package.jsonindex 16bb8ff71f..b657da0eb7 100644--- a/web/packages/build-config/package.json+++ b/web/packages/build-config/package.json@@ -12,7 +12,7 @@"prettier": "3.6.2","prettier-plugin-organize-imports": "4.3.0","prettier-plugin-packagejson": "2.5.22",- "typescript": "5.8.3",+ "typescript": "6.0.3","typescript-eslint": "8.60.1"}}diff --git a/web/packages/build-config/tsconfig-typecheck.json b/web/packages/build-config/tsconfig-typecheck.jsonindex 98af7e3ff0..3cb6d75d58 100644--- a/web/packages/build-config/tsconfig-typecheck.json+++ b/web/packages/build-config/tsconfig-typecheck.json@@ -4,6 +4,8 @@"compilerOptions": {/* We use TypeScript (tsc) as a type checker, not as a build tool */"noEmit": true,+ /* baseUrl remains supported in TS 6; migrate it before TS 7. */+ "ignoreDeprecations": "6.0",/** Tell TypeScript which all things it can assume that our targetdiff --git a/web/packages/contacts/index.ts b/web/packages/contacts/index.tsindex fc703ba73b..957653a460 100644--- a/web/packages/contacts/index.ts+++ b/web/packages/contacts/index.ts@@ -3,6 +3,7 @@ import { getUserRecoveryKey } from "ente-accounts-rs/services/recovery-key";import { masterKeyFromSession } from "ente-accounts-rs/services/session-storage";import { ensureLocalUser } from "ente-accounts-rs/services/user";import { clientPackageName, desktopAppVersion, isDesktop } from "ente-base/app";+import { ensureArrayBufferBacked } from "ente-base/bytes";import log from "ente-base/log";import { apiOrigin } from "ente-base/origins";import { savedAuthToken } from "ente-base/token";@@ -820,7 +821,9 @@ const ensureProfilePictureLoaded = async (contactID: string) => {) {return;}- const blob = new Blob([bytes], { type: inferImageMimeType(bytes) });+ const blob = new Blob([ensureArrayBufferBacked(bytes)], {+ type: inferImageMimeType(bytes),+ });const url = URL.createObjectURL(blob);cleanupAvatarURL(contactID);state.avatarURLByContactID.set(contactID, url);diff --git a/web/packages/contacts/tsconfig.json b/web/packages/contacts/tsconfig.jsonindex 73f42a78cb..c9f1eaef17 100644--- a/web/packages/contacts/tsconfig.json+++ b/web/packages/contacts/tsconfig.json@@ -7,6 +7,8 @@"include": [".","../base/global-electron.d.ts",+ "../base/global-css.d.ts",+ "../base/globals.d.ts","../base/components/utils/mui-theme.d.ts"]}diff --git a/web/packages/gallery/services/convert.ts b/web/packages/gallery/services/convert.tsindex 5568f7d19b..4830098ac6 100644--- a/web/packages/gallery/services/convert.ts+++ b/web/packages/gallery/services/convert.ts@@ -248,7 +248,6 @@ export const playableVideoURL = async (if (isDesktop &&file.metadata.fileType == FileType.livePhoto &&- // eslint-disable-next-line @typescript-eslint/no-deprecatednavigator.platform.startsWith("Linux")) {shouldConvert = true;diff --git a/web/packages/gallery/services/download.ts b/web/packages/gallery/services/download.tsindex 94562ca150..c48074fc1e 100644--- a/web/packages/gallery/services/download.ts+++ b/web/packages/gallery/services/download.ts@@ -310,7 +310,10 @@ class DownloadManager {* can return `undefined` iff the thumbnail is not already cached, and* {@link cachedOnly} is set to `true`.*/- async thumbnailData(file: EnteFile, cachedOnly = false) {+ async thumbnailData(+ file: EnteFile,+ cachedOnly = false,+ ): Promise<Uint8Array<ArrayBuffer> | undefined> {await this.initThumbnailCacheIfNeeded();const key = file.id.toString();diff --git a/web/packages/gallery/services/ffmpeg/index.ts b/web/packages/gallery/services/ffmpeg/index.tsindex 8c7817ee4e..f0024e2a4b 100644--- a/web/packages/gallery/services/ffmpeg/index.ts+++ b/web/packages/gallery/services/ffmpeg/index.ts@@ -41,8 +41,10 @@ export const generateVideoThumbnailWeb = async (blob: Blob) =>);const _generateVideoThumbnail = async (- thumbnailAtTime: (seekTime: number) => Promise<Uint8Array>,-) => {+ thumbnailAtTime: (+ seekTime: number,+ ) => Promise<Uint8Array<ArrayBuffer>>,+): Promise<Uint8Array<ArrayBuffer>> => {try {// Try generating thumbnail at seekTime 1 second.return await thumbnailAtTime(1);@@ -295,7 +297,9 @@ export const determineVideoDuration = async (** @returns The mp4 video blob.*/-export const convertToMP4 = async (blob: Blob): Promise<Blob | Uint8Array> => {+export const convertToMP4 = async (+ blob: Blob,+): Promise<Blob | Uint8Array<ArrayBuffer>> => {const electron = globalThis.electron;if (electron) {return convertToMP4Native(electron, blob);diff --git a/web/packages/gallery/services/ffmpeg/web.ts b/web/packages/gallery/services/ffmpeg/web.tsindex 51c47ed430..06ce7e4e31 100644--- a/web/packages/gallery/services/ffmpeg/web.ts+++ b/web/packages/gallery/services/ffmpeg/web.ts@@ -1,4 +1,5 @@import { FFFSType, FFmpeg } from "@ffmpeg/ffmpeg";+import { ensureArrayBufferBacked } from "ente-base/bytes";import { joinPath } from "ente-base/file-name";import { newID } from "ente-base/id";import log from "ente-base/log";@@ -15,7 +16,7 @@ import {let _ffmpeg: Promise<FFmpeg> | undefined;/** Queue of in-flight requests. */-const _ffmpegTaskQueue = new PromiseQueue<Uint8Array | number>();+const _ffmpegTaskQueue = new PromiseQueue<Uint8Array<ArrayBuffer> | number>();/*** Return the shared {@link FFmpeg} instance, lazily creating and loading it if@@ -57,7 +58,7 @@ export const ffmpegExecWeb = async (command: FFmpegCommand,blob: Blob,outputFileExtension: string,-): Promise<Uint8Array> => {+): Promise<Uint8Array<ArrayBuffer>> => {const ffmpeg = await ffmpegLazy();// Interleaving multiple ffmpeg.execs causes errors like//@@ -66,7 +67,7 @@ export const ffmpegExecWeb = async (// So serialize them using a promise queue.return _ffmpegTaskQueue.add(() =>ffmpegExec(ffmpeg, command, outputFileExtension, blob),- ) as Promise<Uint8Array>;+ ) as Promise<Uint8Array<ArrayBuffer>>;};/**@@ -93,7 +94,7 @@ const ffmpegExec = async (command: FFmpegCommand,outputFileExtension: string,blob: Blob,-) => {+): Promise<Uint8Array<ArrayBuffer>> => {const outputSuffix = outputFileExtension ? "." + outputFileExtension : "";const outputPath = newID("out_") + outputSuffix;@@ -135,7 +136,7 @@ const ffmpegExec = async (const ms = Date.now() - startTime;log.debug(() => `[wasm] ffmpeg ${cmd.join(" ")} (${ms} ms)`);- return result;+ return ensureArrayBufferBacked(result);} finally {try {await ffmpeg.deleteFile(outputPath);diff --git a/web/packages/gallery/services/upload/remote.ts b/web/packages/gallery/services/upload/remote.tsindex c211f8f59f..a88767b69a 100644--- a/web/packages/gallery/services/upload/remote.ts+++ b/web/packages/gallery/services/upload/remote.ts@@ -262,7 +262,7 @@ interface PutPartOptions {export const putFile = async (fileUploadURL: string,- fileData: Uint8Array,+ fileData: Uint8Array<ArrayBuffer>,retrier: HTTPRequestRetrier,options?: PutFileOptions,) =>@@ -284,7 +284,7 @@ export const putFile = async (*/export const putFileViaWorker = async (fileUploadURL: string,- fileData: Uint8Array,+ fileData: Uint8Array<ArrayBuffer>,retrier: HTTPRequestRetrier,options?: PutFileOptions,) =>@@ -322,7 +322,7 @@ export const putFileViaWorker = async (*/export const putFilePart = async (partUploadURL: string,- partData: Uint8Array,+ partData: Uint8Array<ArrayBuffer>,retrier: HTTPRequestRetrier,options?: PutPartOptions,) => {@@ -346,7 +346,7 @@ export const putFilePart = async (*/export const putFilePartViaWorker = async (partUploadURL: string,- partData: Uint8Array,+ partData: Uint8Array<ArrayBuffer>,retrier: HTTPRequestRetrier,options?: PutPartOptions,) => {diff --git a/web/packages/gallery/services/upload/thumbnail.ts b/web/packages/gallery/services/upload/thumbnail.tsindex c7c645bb36..67e5df36af 100644--- a/web/packages/gallery/services/upload/thumbnail.ts+++ b/web/packages/gallery/services/upload/thumbnail.ts@@ -51,7 +51,7 @@ const canvasThumbnailGenerationTimeout = 30 * 1000;export const generateThumbnailWeb = async (blob: Blob,fileTypeInfo: FileTypeInfo,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>fileTypeInfo.fileType == FileType.image? await generateImageThumbnailWeb(blob, fileTypeInfo): await generateVideoThumbnailWeb(blob);@@ -101,7 +101,9 @@ const generateImageThumbnailUsingCanvas = async (blob: Blob) => {return await compressedJPEGData(canvas);};-const compressedJPEGData = async (canvas: HTMLCanvasElement) => {+const compressedJPEGData = async (+ canvas: HTMLCanvasElement,+): Promise<Uint8Array<ArrayBuffer>> => {let blob: Blob | undefined | null;let prevSize = Number.MAX_SAFE_INTEGER;let quality = 0.7;@@ -193,7 +195,7 @@ export const generateThumbnailNative = async (electron: Electron,fsUploadItem: FileSystemUploadItem,fileTypeInfo: FileTypeInfo,-): Promise<Uint8Array> =>+): Promise<Uint8Array<ArrayBuffer>> =>fileTypeInfo.fileType == FileType.image? await electron.generateImageThumbnail(toPathOrZipEntry(fsUploadItem),@@ -206,7 +208,7 @@ export const generateThumbnailNative = async (* A fallback, black, thumbnail for use in cases where thumbnail generation* fails.*/-export const fallbackThumbnail = () =>+export const fallbackThumbnail = (): Uint8Array<ArrayBuffer> =>Uint8Array.from(atob(blackThumbnailB64), (c) => c.charCodeAt(0));const blackThumbnailB64 =diff --git a/web/packages/gallery/services/upload/upload-service.ts b/web/packages/gallery/services/upload/upload-service.tsindex b575bff735..2a444aa383 100644--- a/web/packages/gallery/services/upload/upload-service.ts+++ b/web/packages/gallery/services/upload/upload-service.ts@@ -335,9 +335,9 @@ export interface UploadAsset {}interface ThumbnailedFile {- fileStreamOrData: FileStream | Uint8Array;+ fileStreamOrData: FileStream | Uint8Array<ArrayBuffer>;/** The JPEG data of the generated thumbnail */- thumbnail: Uint8Array;+ thumbnail: Uint8Array<ArrayBuffer>;/*** `true` if this is a fallback (all black) thumbnail we're returning since* thumbnail generation failed for some reason.@@ -360,7 +360,7 @@ interface EncryptedFileStream {* be smaller since a file would rarely align exactly to a* {@link streamEncryptionChunkSize} multiple).*/- stream: ReadableStream<Uint8Array>;+ stream: ReadableStream<Uint8Array<ArrayBuffer>>;/*** Number of chunks {@link stream} will emit, each* {@link streamEncryptionChunkSize} sized (except the last one).@@ -374,14 +374,17 @@ interface EncryptedFilePieces {* the decryption header that was used during encryption (base64 string).*/file: {- encryptedData: Uint8Array | EncryptedFileStream;+ encryptedData: Uint8Array<ArrayBuffer> | EncryptedFileStream;decryptionHeader: string;};/*** The encrypted contents of the file's thumbnail (as bytes), and the* decryption header that was used during encryption (base64 string).*/- thumbnail: { encryptedData: Uint8Array; decryptionHeader: string };+ thumbnail: {+ encryptedData: Uint8Array<ArrayBuffer>;+ decryptionHeader: string;+ };/*** The encrypted contents of the file's metadata (as a base64 string), and* the decryption header that was used during encryption (base64 string).@@ -1117,7 +1120,9 @@ const readImageOrVideoDetails = async (uploadItem: UploadItem) => {* size of the stream will be reasonable enough to be read in its entirety* without us running out of memory.*/-const readEntireStream = async (stream: ReadableStream) =>+const readEntireStream = async (+ stream: ReadableStream,+): Promise<Uint8Array<ArrayBuffer>> =>new Uint8Array(await new Response(stream).arrayBuffer());interface ExtractAssetMetadataResult {@@ -1458,7 +1463,7 @@ const readLivePhoto = async (// This is a reasonable behaviour since the videos corresponding to live// photos are only a couple of seconds long (we've already done a pre-flight// check during areLivePhotoAssets to ensure their size is small).- const fileOrData = async (sd: FileStream | Uint8Array) => {+ const fileOrData = async (sd: FileStream | Uint8Array<ArrayBuffer>) => {const fos = async ({ file, stream }: FileStream) =>file ? file : await readEntireStream(stream);return sd instanceof Uint8Array ? sd : fos(sd);@@ -1501,8 +1506,8 @@ const augmentWithThumbnail = async (fileTypeInfo: FileTypeInfo,fileStream: FileStream,): Promise<ThumbnailedFile> => {- let fileData: Uint8Array | undefined;- let thumbnail: Uint8Array | undefined;+ let fileData: Uint8Array<ArrayBuffer> | undefined;+ let thumbnail: Uint8Array<ArrayBuffer> | undefined;let hasStaticThumbnail = false;const electron = globalThis.electron;@@ -1684,7 +1689,7 @@ const encryptFileStream = async (.pullState: undefined;const ref = { pullCount: 1 };- const encryptedFileStream = new ReadableStream({+ const encryptedFileStream = new ReadableStream<Uint8Array<ArrayBuffer>>({async pull(controller) {const { value, done } = await fileStreamReader.read();if (done) {@@ -1920,7 +1925,7 @@ const uploadStreamUsingMultipart = async ();if (shouldSendPartChecksums) {- const parts: Uint8Array[] = [];+ const parts: Uint8Array<ArrayBuffer>[] = [];const partMd5s: string[] = [];let fileSize = 0;while (true) {diff --git a/web/packages/gallery/tsconfig.json b/web/packages/gallery/tsconfig.jsonindex 7ce1c3fadc..d3cfa85bec 100644--- a/web/packages/gallery/tsconfig.json+++ b/web/packages/gallery/tsconfig.json@@ -3,6 +3,8 @@"include": [".","../../packages/base/global-electron.d.ts",+ "../../packages/base/global-css.d.ts",+ "../../packages/base/globals.d.ts","../../packages/base/components/utils/mui-theme.d.ts"]}diff --git a/web/packages/media/live-photo.ts b/web/packages/media/live-photo.tsindex 4830e23bd5..35baac80d6 100644--- a/web/packages/media/live-photo.ts+++ b/web/packages/media/live-photo.ts@@ -1,3 +1,4 @@+import { ensureArrayBufferBacked } from "ente-base/bytes";import {fileNameFromComponents,lowercaseExtension,@@ -55,9 +56,9 @@ export const potentialFileTypeFromExtension = (*/interface LivePhoto {imageFileName: string;- imageData: Uint8Array;+ imageData: Uint8Array<ArrayBuffer>;videoFileName: string;- videoData: Uint8Array;+ videoData: Uint8Array<ArrayBuffer>;}/**@@ -80,7 +81,7 @@ export const decodeLivePhoto = async (zipBlob: Blob,): Promise<LivePhoto> => {let imageFileName, videoFileName: string | undefined;- let imageData, videoData: Uint8Array | undefined;+ let imageData, videoData: Uint8Array<ArrayBuffer> | undefined;const [name] = nameAndExtension(fileName);const zip = await JSZip.loadAsync(zipBlob, { createFolders: true });@@ -89,11 +90,13 @@ export const decodeLivePhoto = async (if (zipFileName.startsWith("image")) {const [, imageExt] = nameAndExtension(zipFileName);imageFileName = fileNameFromComponents([name, imageExt]);- imageData = await zip.files[zipFileName]?.async("uint8array");+ const bytes = await zip.files[zipFileName]?.async("uint8array");+ imageData = bytes && ensureArrayBufferBacked(bytes);} else if (zipFileName.startsWith("video")) {const [, videoExt] = nameAndExtension(zipFileName);videoFileName = fileNameFromComponents([name, videoExt]);- videoData = await zip.files[zipFileName]?.async("uint8array");+ const bytes = await zip.files[zipFileName]?.async("uint8array");+ videoData = bytes && ensureArrayBufferBacked(bytes);}}@@ -131,12 +134,14 @@ export const encodeLivePhoto = async ({imageFileOrData,videoFileName,videoFileOrData,-}: EncodeLivePhotoInput) => {+}: EncodeLivePhotoInput): Promise<Uint8Array<ArrayBuffer>> => {const [, imageExt] = nameAndExtension(imageFileName);const [, videoExt] = nameAndExtension(videoFileName);const zip = new JSZip();zip.file(fileNameFromComponents(["image", imageExt]), imageFileOrData);zip.file(fileNameFromComponents(["video", videoExt]), videoFileOrData);- return await zip.generateAsync({ type: "uint8array" });+ return ensureArrayBufferBacked(+ await zip.generateAsync({ type: "uint8array" }),+ );};diff --git a/web/packages/new/photos/services/user-entity/remote.ts b/web/packages/new/photos/services/user-entity/remote.tsindex dd685e1bff..e543d97213 100644--- a/web/packages/new/photos/services/user-entity/remote.ts+++ b/web/packages/new/photos/services/user-entity/remote.ts@@ -57,7 +57,7 @@ export interface UserEntityChange {** This will not be present for entities that have been deleted on remote.*/- data: Uint8Array | undefined;+ data: Uint8Array<ArrayBuffer> | undefined;/*** Epoch microseconds denoting when this entity was last changed (created or* updated or deleted).diff --git a/web/packages/new/photos/utils/gzip.ts b/web/packages/new/photos/utils/gzip.tsindex a5731bfcc2..ece2c0d8ef 100644--- a/web/packages/new/photos/utils/gzip.ts+++ b/web/packages/new/photos/utils/gzip.ts@@ -7,7 +7,9 @@* can directly use a ReadableStream, then then data -> stream -> data round* trip is unnecessary.*/-export const gzip = async (string: string) => {+export const gzip = async (+ string: string,+): Promise<Uint8Array<ArrayBuffer>> => {const compressedStream = new Blob([string]).stream()// This code only runs on the desktop app currently, so we can rely on@@ -20,7 +22,7 @@ export const gzip = async (string: string) => {* Decompress the given "gzip" compressed {@link data} and return the resultant* string. See {@link gzip} for the reverse operation.*/-export const gunzip = async (data: Uint8Array) => {+export const gunzip = async (data: Uint8Array<ArrayBuffer>) => {const decompressedStream = new Blob([data]).stream()// This code only runs on the desktop app currently, so we can rely ondiff --git a/web/packages/new/tsconfig.json b/web/packages/new/tsconfig.jsonindex 73f42a78cb..c9f1eaef17 100644--- a/web/packages/new/tsconfig.json+++ b/web/packages/new/tsconfig.json@@ -7,6 +7,8 @@"include": [".","../base/global-electron.d.ts",+ "../base/global-css.d.ts",+ "../base/globals.d.ts","../base/components/utils/mui-theme.d.ts"]}diff --git a/web/packages/utils/array.ts b/web/packages/utils/array.tsindex dbdc214bb7..e6137bb3dd 100644--- a/web/packages/utils/array.ts+++ b/web/packages/utils/array.ts@@ -66,7 +66,7 @@ export const firstNonEmpty = (** @param as An array of {@link Uint8Array}.*/-export const mergeUint8Arrays = (as: Uint8Array[]): Uint8Array => {+export const mergeUint8Arrays = (as: Uint8Array[]): Uint8Array<ArrayBuffer> => {// A longer but better performing replacement of//// new Uint8Array(as.reduce((acc, x) => acc.concat(...x), []))