From a9edcead06fb1bfeddce6f0c560f1493c5dc81d7 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 22 May 2025 17:25:50 +0530 Subject: [PATCH 1/3] [desktop] Don't add version to x-client-package --- web/packages/base/app.ts | 27 +++++++++++++++---- web/packages/new/photos/services/ml/worker.ts | 6 ++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/web/packages/base/app.ts b/web/packages/base/app.ts index 74b891a9c0..18f5100244 100644 --- a/web/packages/base/app.ts +++ b/web/packages/base/app.ts @@ -62,8 +62,7 @@ export const staticAppTitle = { /** * Client "package names" for our app. * - * The package name is used as the (a) "X-Client-Package" header in API - * requests, and (b) as the identifier in inline user agent strings in payloads. + * The package name is used as the "X-Client-Package" header in API requests. * * In cases where this code works for both a web and a desktop app for the same * app (currently only photos), this will be the platform specific package name. @@ -72,9 +71,7 @@ export const clientPackageName = (() => { if (isDesktop) { if (appName != "photos") throw new Error(`Unsupported desktop appName ${appName}`); - if (!desktopAppVersion) - throw new Error(`desktopAppVersion is not defined`); - return `io.ente.photos.desktop/${desktopAppVersion}`; + return `io.ente.photos.desktop`; } return { accounts: "io.ente.accounts.web", @@ -83,3 +80,23 @@ export const clientPackageName = (() => { photos: "io.ente.photos.web", }[appName]; })(); + +/** + * The client package name, augmented with the client version where applicable. + * + * This string is used as the "client identifier" in payloads (e.g. ML data + * generated by a client). + * + * For the desktop app, it will be client package name and version. Otherwise, + * it'll just be the same as {@link clientPackageName}. + */ +export const clientIdentifier = (() => { + if (isDesktop) { + if (appName != "photos") + throw new Error(`Unsupported desktop appName ${appName}`); + if (!desktopAppVersion) + throw new Error(`desktopAppVersion is not defined`); + return `io.ente.photos.desktop/${desktopAppVersion}`; + } + return clientPackageName; +})(); diff --git a/web/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.ts index 7ddaeeb659..28ecbd09a8 100644 --- a/web/packages/new/photos/services/ml/worker.ts +++ b/web/packages/new/photos/services/ml/worker.ts @@ -1,5 +1,5 @@ import { expose, wrap } from "comlink"; -import { clientPackageName } from "ente-base/app"; +import { clientIdentifier } from "ente-base/app"; import { assertionFailed } from "ente-base/assert"; import { isHTTP4xxError, isHTTPErrorWithStatus } from "ente-base/http"; import log from "ente-base/log"; @@ -590,13 +590,13 @@ const index = async ( const remoteFaceIndex = existingRemoteFaceIndex ?? { version: faceIndexingVersion, - client: clientPackageName, + client: clientIdentifier, ...faceIndex, }; const remoteCLIPIndex = existingRemoteCLIPIndex ?? { version: clipIndexingVersion, - client: clientPackageName, + client: clientIdentifier, ...clipIndex, }; From 1c2b8061dcc4daaa15a7eea3a34412b256b3772b Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 22 May 2025 17:41:46 +0530 Subject: [PATCH 2/3] Include "X-Client-Version" where applicable --- web/packages/base/http.ts | 3 +++ web/packages/base/next.config.base.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/packages/base/http.ts b/web/packages/base/http.ts index 38bb447608..e21b6f97c6 100644 --- a/web/packages/base/http.ts +++ b/web/packages/base/http.ts @@ -1,3 +1,4 @@ +import { desktopAppVersion, isDesktop } from "ente-base/app"; import { wait } from "ente-utils/promise"; import { z } from "zod"; import { clientPackageName } from "./app"; @@ -14,6 +15,7 @@ import log from "./log"; export const authenticatedRequestHeaders = async () => ({ "X-Auth-Token": await ensureAuthToken(), "X-Client-Package": clientPackageName, + ...(isDesktop ? { "X-Client-Version": desktopAppVersion } : {}), }); /** @@ -25,6 +27,7 @@ export const authenticatedRequestHeaders = async () => ({ */ export const publicRequestHeaders = () => ({ "X-Client-Package": clientPackageName, + ...(isDesktop ? { "X-Client-Version": desktopAppVersion } : {}), }); /** diff --git a/web/packages/base/next.config.base.js b/web/packages/base/next.config.base.js index 5bb855f792..8afb699564 100644 --- a/web/packages/base/next.config.base.js +++ b/web/packages/base/next.config.base.js @@ -64,7 +64,7 @@ const isDesktop = process.env._ENTE_IS_DESKTOP ? "1" : ""; /** * When we're running within the desktop app, also extract the version of the - * desktop app for use in our "X-Client-Package" string. + * desktop app for use in our "X-Client-Version" string. * * > The web app has continuous deployments, and doesn't have versions. */ From 3572c4328dae43652692c77d63271243be397024 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 22 May 2025 17:46:08 +0530 Subject: [PATCH 3/3] str --- web/packages/base/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/packages/base/app.ts b/web/packages/base/app.ts index 18f5100244..e330e41a83 100644 --- a/web/packages/base/app.ts +++ b/web/packages/base/app.ts @@ -71,7 +71,7 @@ export const clientPackageName = (() => { if (isDesktop) { if (appName != "photos") throw new Error(`Unsupported desktop appName ${appName}`); - return `io.ente.photos.desktop`; + return "io.ente.photos.desktop"; } return { accounts: "io.ente.accounts.web",