π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Retain leading slash
Manav Rathi9241c2e59558
diff --git a/web/apps/accounts/src/services/passkey.ts b/web/apps/accounts/src/services/passkey.tsindex 12aeb485df..b8c1ec3e56 100644--- a/web/apps/accounts/src/services/passkey.ts+++ b/web/apps/accounts/src/services/passkey.ts@@ -58,7 +58,7 @@ const GetPasskeysResponse = z.object({* has no passkeys.*/export const getPasskeys = async (token: string) => {- const url = await apiURL("passkeys");+ const url = await apiURL("/passkeys");const res = await fetch(url, {headers: accountsAuthenticatedRequestHeaders(token),});@@ -82,7 +82,7 @@ export const renamePasskey = async (name: string,) => {const params = new URLSearchParams({ friendlyName: name });- const url = await apiURL(`passkeys/${id}`);+ const url = await apiURL(`/passkeys/${id}`);const res = await fetch(`${url}?${params.toString()}`, {method: "PATCH",headers: accountsAuthenticatedRequestHeaders(token),@@ -98,7 +98,7 @@ export const renamePasskey = async (* @param id The `id` of the existing passkey to delete.*/export const deletePasskey = async (token: string, id: string) => {- const url = await apiURL(`passkeys/${id}`);+ const url = await apiURL(`/passkeys/${id}`);const res = await fetch(url, {method: "DELETE",headers: accountsAuthenticatedRequestHeaders(token),@@ -149,7 +149,7 @@ interface BeginPasskeyRegistrationResponse {}const beginPasskeyRegistration = async (token: string) => {- const url = await apiURL("passkeys/registration/begin");+ const url = await apiURL("/passkeys/registration/begin");const res = await fetch(url, {method: "POST",headers: accountsAuthenticatedRequestHeaders(token),@@ -293,7 +293,7 @@ const finishPasskeyRegistration = async ({const transports = attestationResponse.getTransports();const params = new URLSearchParams({ friendlyName, sessionID });- const url = await apiURL("passkeys/registration/finish");+ const url = await apiURL("/passkeys/registration/finish");const res = await fetch(`${url}?${params.toString()}`, {method: "POST",headers: accountsAuthenticatedRequestHeaders(token),@@ -414,7 +414,7 @@ export const passkeySessionAlreadyClaimedErrorMessage =export const beginPasskeyAuthentication = async (passkeySessionID: string,): Promise<BeginPasskeyAuthenticationResponse> => {- const url = await apiURL("users/two-factor/passkeys/begin");+ const url = await apiURL("/users/two-factor/passkeys/begin");const res = await fetch(url, {method: "POST",body: JSON.stringify({ sessionID: passkeySessionID }),@@ -504,7 +504,7 @@ export const finishPasskeyAuthentication = async ({ceremonySessionID,clientPackage,});- const url = await apiURL("users/two-factor/passkeys/finish");+ const url = await apiURL("/users/two-factor/passkeys/finish");const res = await fetch(`${url}?${params.toString()}`, {method: "POST",headers: {diff --git a/web/packages/accounts/api/srp.ts b/web/packages/accounts/api/srp.tsindex 068f1732fd..f6c773d9cc 100644--- a/web/packages/accounts/api/srp.ts+++ b/web/packages/accounts/api/srp.ts@@ -21,7 +21,7 @@ export const getSRPAttributes = async (): Promise<SRPAttributes | null> => {try {const resp = await HTTPService.get(- await apiURL("users/srp/attributes"),+ await apiURL("/users/srp/attributes"),{email,},@@ -39,7 +39,7 @@ export const startSRPSetup = async (): Promise<SetupSRPResponse> => {try {const resp = await HTTPService.post(- await apiURL("users/srp/setup"),+ await apiURL("/users/srp/setup"),setupSRPRequest,undefined,{@@ -60,7 +60,7 @@ export const completeSRPSetup = async () => {try {const resp = await HTTPService.post(- await apiURL("users/srp/complete"),+ await apiURL("/users/srp/complete"),completeSRPSetupRequest,undefined,{@@ -77,7 +77,7 @@ export const completeSRPSetup = async (export const createSRPSession = async (srpUserID: string, srpA: string) => {try {const resp = await HTTPService.post(- await apiURL("users/srp/create-session"),+ await apiURL("/users/srp/create-session"),{srpUserID,srpA,@@ -97,7 +97,7 @@ export const verifySRPSession = async () => {try {const resp = await HTTPService.post(- await apiURL("users/srp/verify-session"),+ await apiURL("/users/srp/verify-session"),{sessionID,srpUserID,@@ -125,7 +125,7 @@ export const updateSRPAndKeys = async (): Promise<UpdateSRPAndKeysResponse> => {try {const resp = await HTTPService.post(- await apiURL("users/srp/update"),+ await apiURL("/users/srp/update"),updateSRPAndKeyRequest,undefined,{diff --git a/web/packages/accounts/api/user.ts b/web/packages/accounts/api/user.tsindex ec04dd28d3..30106ad873 100644--- a/web/packages/accounts/api/user.ts+++ b/web/packages/accounts/api/user.ts@@ -15,7 +15,7 @@ import type { KeyAttributes } from "@ente/shared/user/types";import { HttpStatusCode } from "axios";export const sendOtt = async (appName: AppName, email: string) => {- return HTTPService.post(await apiURL("users/ott"), {+ return HTTPService.post(await apiURL("/users/ott"), {email,client: appName == "auth" ? "totp" : "web",});@@ -27,7 +27,7 @@ export const verifyOtt = async (referral: string,) => {const cleanedReferral = `web:${referral?.trim() || ""}`;- return HTTPService.post(await apiURL("users/verify-email"), {+ return HTTPService.post(await apiURL("/users/verify-email"), {email,ott,source: cleanedReferral,@@ -39,7 +39,7 @@ export const putAttributes = async (keyAttributes: KeyAttributes,) =>HTTPService.put(- await apiURL("users/attributes"),+ await apiURL("/users/attributes"),{ keyAttributes },undefined,{@@ -50,7 +50,7 @@ export const putAttributes = async (export const logout = async () => {try {const token = getToken();- await HTTPService.post(await apiURL("users/logout"), null, undefined, {+ await HTTPService.post(await apiURL("/users/logout"), null, undefined, {"X-Auth-Token": token,});} catch (e) {diff --git a/web/packages/accounts/services/passkey.ts b/web/packages/accounts/services/passkey.tsindex 84453b6b47..772b463772 100644--- a/web/packages/accounts/services/passkey.ts+++ b/web/packages/accounts/services/passkey.ts@@ -139,7 +139,7 @@ export const isPasskeyRecoveryEnabled = async () => {const token = getToken();const resp = await HTTPService.get(- await apiURL("users/two-factor/recovery-status"),+ await apiURL("/users/two-factor/recovery-status"),{},{"X-Auth-Token": token,@@ -166,7 +166,7 @@ const configurePasskeyRecovery = async (const token = getToken();const resp = await HTTPService.post(- await apiURL("users/two-factor/passkeys/configure-recovery"),+ await apiURL("/users/two-factor/passkeys/configure-recovery"),{secret,userSecretCipher,@@ -196,7 +196,7 @@ const getAccountsToken = async () => {const token = getToken();const resp = await HTTPService.get(- await apiURL("users/accounts-token"),+ await apiURL("/users/accounts-token"),undefined,{"X-Auth-Token": token,@@ -234,7 +234,7 @@ export const passkeySessionExpiredErrorMessage = "Passkey session has expired";export const checkPasskeyVerificationStatus = async (sessionID: string,): Promise<TwoFactorAuthorizationResponse | undefined> => {- const url = await apiURL("users/two-factor/passkeys/get-token");+ const url = await apiURL("/users/two-factor/passkeys/get-token");const params = new URLSearchParams({ sessionID });const res = await fetch(`${url}?${params.toString()}`, {headers: clientPackageHeaderIfPresent(),diff --git a/web/packages/accounts/services/session.ts b/web/packages/accounts/services/session.tsindex 65493cdb26..d82f12ebd9 100644--- a/web/packages/accounts/services/session.ts+++ b/web/packages/accounts/services/session.ts@@ -62,7 +62,7 @@ type SessionValidity =* subsequently.*/export const checkSessionValidity = async (): Promise<SessionValidity> => {- const url = await apiURL("users/session-validity/v2");+ const url = await apiURL("/users/session-validity/v2");const res = await fetch(url, {headers: authenticatedRequestHeaders(),});diff --git a/web/packages/new/photos/services/embedding.ts b/web/packages/new/photos/services/embedding.tsindex 64f21268c0..9492a47e11 100644--- a/web/packages/new/photos/services/embedding.ts+++ b/web/packages/new/photos/services/embedding.ts@@ -166,7 +166,7 @@ const getEmbeddingsDiff = async (sinceTime: `${sinceTime}`,limit: `${diffLimit}`,});- const url = await apiURL("embeddings/diff");+ const url = await apiURL("/embeddings/diff");const res = await fetch(`${url}?${params.toString()}`, {headers: authenticatedRequestHeaders(),});diff --git a/web/packages/new/photos/services/feature-flags.ts b/web/packages/new/photos/services/feature-flags.tsindex a29dc87506..97969d1a41 100644--- a/web/packages/new/photos/services/feature-flags.ts+++ b/web/packages/new/photos/services/feature-flags.ts@@ -65,7 +65,7 @@ const fetchAndSaveFeatureFlags = () =>.then(saveFlagJSONString);const fetchFeatureFlags = async () => {- const url = await apiURL("remote-store/feature-flags");+ const url = await apiURL("/remote-store/feature-flags");const res = await fetch(url, {headers: authenticatedRequestHeaders(),});diff --git a/web/packages/next/origins.ts b/web/packages/next/origins.tsindex 45b8149890..c4b860c641 100644--- a/web/packages/next/origins.ts+++ b/web/packages/next/origins.ts@@ -17,12 +17,12 @@ export const apiOrigin = async () =>* This avoids us having to create a temporary variable or otherwise complicate* the call sites since async functions cannot be used inside template literals.*- * @returns The equivalent of `${await apiOrigin()}/pathEtc`+ * @param path The URL path usually, but can be anything that needs to be+ * suffixed to the origin. It must begin with a "/".+ *+ * @returns path prefixed by {@link apiOrigin}.*/-export const apiURL = async (pathEtc: string) => {- const origin = await apiOrigin();- return `${origin}/${pathEtc}`;-};+export const apiURL = async (path: string) => (await apiOrigin()) + path;/*** Return the overridden API origin, if one is defined by either (in prioritydiff --git a/web/packages/shared/network/cast.ts b/web/packages/shared/network/cast.tsindex 551d2ad3e3..c5d0ddef90 100644--- a/web/packages/shared/network/cast.ts+++ b/web/packages/shared/network/cast.ts@@ -11,7 +11,7 @@ class CastGateway {let resp;try {resp = await HTTPService.get(- await apiURL(`cast/cast-data/${code}`),+ await apiURL(`/cast/cast-data/${code}`),);} catch (e) {log.error("failed to getCastData", e);@@ -24,7 +24,7 @@ class CastGateway {try {const token = getToken();await HTTPService.delete(- await apiURL("cast/revoke-all-tokens"),+ await apiURL("/cast/revoke-all-tokens"),undefined,undefined,{@@ -42,7 +42,7 @@ class CastGateway {try {const token = getToken();resp = await HTTPService.get(- await apiURL(`cast/device-info/${code}`),+ await apiURL(`/cast/device-info/${code}`),undefined,{"X-Auth-Token": token,@@ -59,7 +59,7 @@ class CastGateway {}public async registerDevice(publicKey: string): Promise<string> {- const resp = await HTTPService.post(await apiURL("cast/device-info"), {+ const resp = await HTTPService.post(await apiURL("/cast/device-info"), {publicKey: publicKey,});return resp.data.deviceCode;@@ -73,7 +73,7 @@ class CastGateway {) {const token = getToken();await HTTPService.post(- await apiURL("cast/cast-data"),+ await apiURL("/cast/cast-data"),{deviceCode: `${code}`,encPayload: castPayload,