Skip to content

armgit / ente

Public Imported from GitHub
0

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

Conv

Manav Rathi78b9ce16743e
diff --git a/web/apps/accounts/src/services/passkey.ts b/web/apps/accounts/src/services/passkey.ts
index 84e9751453..6814880e6d 100644
--- a/web/apps/accounts/src/services/passkey.ts
+++ b/web/apps/accounts/src/services/passkey.ts
@@ -77,9 +77,8 @@ export const renamePasskey = async (
id: string,
name: string,
) => {
- const params = new URLSearchParams({ friendlyName: name });
- const url = await apiURL(`/passkeys/${id}`);
- const res = await fetch(`${url}?${params.toString()}`, {
+ const url = await apiURL(`/passkeys/${id}`, { friendlyName: name });
+ const res = await fetch(url, {
method: "PATCH",
headers: accountsAuthenticatedRequestHeaders(token),
});
@@ -284,9 +283,11 @@ const finishPasskeyRegistration = async ({
);
const transports = attestationResponse.getTransports();
- const params = new URLSearchParams({ friendlyName, sessionID });
- const url = await apiURL("/passkeys/registration/finish");
- const res = await fetch(`${url}?${params.toString()}`, {
+ const url = await apiURL("/passkeys/registration/finish", {
+ friendlyName,
+ sessionID,
+ });
+ const res = await fetch(url, {
method: "POST",
headers: accountsAuthenticatedRequestHeaders(token),
body: JSON.stringify({
diff --git a/web/apps/auth/src/services/remote.ts b/web/apps/auth/src/services/remote.ts
index cdb73f62df..81a3233d51 100644
--- a/web/apps/auth/src/services/remote.ts
+++ b/web/apps/auth/src/services/remote.ts
@@ -178,14 +178,13 @@ export const authenticatorEntityDiff = async (
let timeOffset: number | undefined = undefined;
while (true) {
- const params = new URLSearchParams({
- sinceTime: `${sinceTime}`,
- limit: `${batchSize}`,
- });
- const url = await apiURL("/authenticator/entity/diff");
- const res = await fetch(`${url}?${params.toString()}`, {
- headers: await authenticatedRequestHeaders(),
- });
+ const res = await fetch(
+ await apiURL("/authenticator/entity/diff", {
+ sinceTime,
+ limit: batchSize,
+ }),
+ { headers: await authenticatedRequestHeaders() },
+ );
ensureOk(res);
const { diff, timestamp } = AuthenticatorEntityDiffResponse.parse(
diff --git a/web/packages/accounts/services/passkey.ts b/web/packages/accounts/services/passkey.ts
index 70410ff639..1f9100bd9c 100644
--- a/web/packages/accounts/services/passkey.ts
+++ b/web/packages/accounts/services/passkey.ts
@@ -213,11 +213,10 @@ 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 params = new URLSearchParams({ sessionID });
- const res = await fetch(`${url}?${params.toString()}`, {
- headers: publicRequestHeaders(),
- });
+ const res = await fetch(
+ await apiURL("/users/two-factor/passkeys/get-token", { sessionID }),
+ { headers: publicRequestHeaders() },
+ );
if (!res.ok) {
if (res.status == 404 || res.status == 410)
throw new Error(passkeySessionExpiredErrorMessage);
diff --git a/web/packages/gallery/services/upload/remote.ts b/web/packages/gallery/services/upload/remote.ts
index 22c62569d2..d5eb0859ae 100644
--- a/web/packages/gallery/services/upload/remote.ts
+++ b/web/packages/gallery/services/upload/remote.ts
@@ -44,7 +44,7 @@ const ObjectUploadURLResponse = z.object({ urls: ObjectUploadURL.array() });
* will refer to the uploaded object after it has been uploaded.
*/
export const fetchUploadURLs = async (countHint: number) => {
- const count = Math.min(50, countHint * 2).toString();
+ const count = Math.min(50, countHint * 2);
const res = await fetch(await apiURL("/files/upload-urls", { count }), {
headers: await authenticatedRequestHeaders(),
});
@@ -59,7 +59,7 @@ export const fetchPublicAlbumsUploadURLs = async (
countHint: number,
credentials: PublicAlbumsCredentials,
) => {
- const count = Math.min(50, countHint * 2).toString();
+ const count = Math.min(50, countHint * 2);
const res = await fetch(
await apiURL("/public-collection/upload-urls", { count }),
{ headers: authenticatedPublicAlbumsRequestHeaders(credentials) },
@@ -111,7 +111,7 @@ const MultipartUploadURLsResponse = z.object({ urls: MultipartUploadURLs });
* for uploading each part, a completion URL, and the final object key.
*/
export const fetchMultipartUploadURLs = async (uploadPartCount: number) => {
- const count = uploadPartCount.toString();
+ const count = uploadPartCount;
const res = await fetch(
await apiURL("/files/multipart-upload-urls", { count }),
{ headers: await authenticatedRequestHeaders() },
@@ -127,7 +127,7 @@ export const fetchPublicAlbumsMultipartUploadURLs = async (
uploadPartCount: number,
credentials: PublicAlbumsCredentials,
) => {
- const count = uploadPartCount.toString();
+ const count = uploadPartCount;
const res = await fetch(
await apiURL("/public-collection/multipart-upload-urls", { count }),
{ headers: authenticatedPublicAlbumsRequestHeaders(credentials) },
diff --git a/web/packages/new/photos/services/remote-store.ts b/web/packages/new/photos/services/remote-store.ts
index f6d4e8ecdc..5a6ec610ce 100644
--- a/web/packages/new/photos/services/remote-store.ts
+++ b/web/packages/new/photos/services/remote-store.ts
@@ -40,11 +40,10 @@ export const fetchFeatureFlags = async () => {
* If the key is not present in the remote store, return {@link defaultValue}.
*/
export const getRemoteValue = async (key: string, defaultValue: string) => {
- const url = await apiURL("/remote-store");
- const params = new URLSearchParams({ key, defaultValue });
- const res = await fetch(`${url}?${params.toString()}`, {
- headers: await authenticatedRequestHeaders(),
- });
+ const res = await fetch(
+ await apiURL("/remote-store", { key, defaultValue }),
+ { headers: await authenticatedRequestHeaders() },
+ );
ensureOk(res);
return GetRemoteStoreResponse.parse(await res.json())?.value;
};
diff --git a/web/packages/new/photos/services/user-details.ts b/web/packages/new/photos/services/user-details.ts
index a8b2392438..4bdd7743e3 100644
--- a/web/packages/new/photos/services/user-details.ts
+++ b/web/packages/new/photos/services/user-details.ts
@@ -406,11 +406,10 @@ const getPaymentToken = async () => {
*/
export const redirectToCustomerPortal = async () => {
const redirectURL = paymentCompletionRedirectURL();
- const url = await apiURL("/billing/stripe/customer-portal");
- const params = new URLSearchParams({ redirectURL });
- const res = await fetch(`${url}?${params.toString()}`, {
- headers: await authenticatedRequestHeaders(),
- });
+ const res = await fetch(
+ await apiURL("/billing/stripe/customer-portal", { redirectURL }),
+ { headers: await authenticatedRequestHeaders() },
+ );
ensureOk(res);
const portal = z.object({ url: z.string() }).parse(await res.json());
window.location.href = portal.url;
diff --git a/web/packages/new/photos/services/user-entity/remote.ts b/web/packages/new/photos/services/user-entity/remote.ts
index 6b4192e4ff..3be5264716 100644
--- a/web/packages/new/photos/services/user-entity/remote.ts
+++ b/web/packages/new/photos/services/user-entity/remote.ts
@@ -134,15 +134,14 @@ export const userEntityDiff = async (
const decrypt = (encryptedData: string, decryptionHeader: string) =>
decryptBlobBytes({ encryptedData, decryptionHeader }, entityKey);
- const params = new URLSearchParams({
- type,
- sinceTime: sinceTime.toString(),
- limit: defaultDiffLimit.toString(),
- });
- const url = await apiURL("/user-entity/entity/diff");
- const res = await fetch(`${url}?${params.toString()}`, {
- headers: await authenticatedRequestHeaders(),
- });
+ const res = await fetch(
+ await apiURL("/user-entity/entity/diff", {
+ type,
+ sinceTime,
+ limit: defaultDiffLimit,
+ }),
+ { headers: await authenticatedRequestHeaders() },
+ );
ensureOk(res);
const diff = z
.object({ diff: z.array(RemoteUserEntityChange) })
@@ -237,9 +236,7 @@ export type RemoteUserEntityKey = z.infer<typeof RemoteUserEntityKey>;
export const getUserEntityKey = async (
type: EntityType,
): Promise<RemoteUserEntityKey | undefined> => {
- const params = new URLSearchParams({ type });
- const url = await apiURL("/user-entity/key");
- const res = await fetch(`${url}?${params.toString()}`, {
+ const res = await fetch(await apiURL("/user-entity/key", { type }), {
headers: await authenticatedRequestHeaders(),
});
if (!res.ok) {
diff --git a/web/packages/new/photos/services/user.ts b/web/packages/new/photos/services/user.ts
index bd8634dce7..3f88a0d48e 100644
--- a/web/packages/new/photos/services/user.ts
+++ b/web/packages/new/photos/services/user.ts
@@ -27,9 +27,7 @@ export const ensureUserKeyPair = async (): Promise<KeyPair> => {
* @returns the base64 encoded public key of the user with {@link email}.
*/
export const getPublicKey = async (email: string) => {
- const params = new URLSearchParams({ email });
- const url = await apiURL("/users/public-key");
- const res = await fetch(`${url}?${params.toString()}`, {
+ const res = await fetch(await apiURL("/users/public-key", { email }), {
headers: await authenticatedRequestHeaders(),
});
ensureOk(res);