swap
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
||||
groupFilesByCollectionID,
|
||||
sortFiles,
|
||||
} from "ente-new/photos/services/files";
|
||||
import { getPublicKey } from "ente-new/photos/services/user";
|
||||
import HTTPService from "ente-shared/network/HTTPService";
|
||||
import { getData } from "ente-shared/storage/localStorage";
|
||||
import { getToken } from "ente-shared/storage/localStorage/helpers";
|
||||
@@ -48,7 +49,6 @@ import {
|
||||
isQuickLinkCollection,
|
||||
isValidMoveTarget,
|
||||
} from "utils/collection";
|
||||
import { getPublicKey } from "./userService";
|
||||
|
||||
const UNCATEGORIZED_COLLECTION_NAME = "Uncategorized";
|
||||
export const HIDDEN_COLLECTION_NAME = ".hidden";
|
||||
|
||||
@@ -4,17 +4,6 @@ import type { UserDetails } from "ente-new/photos/services/user-details";
|
||||
import HTTPService from "ente-shared/network/HTTPService";
|
||||
import { getToken } from "ente-shared/storage/localStorage/helpers";
|
||||
|
||||
export const getPublicKey = async (email: string) => {
|
||||
const token = getToken();
|
||||
|
||||
const resp = await HTTPService.get(
|
||||
await apiURL("/users/public-key"),
|
||||
{ email },
|
||||
{ "X-Auth-Token": token },
|
||||
);
|
||||
return resp.data.publicKey;
|
||||
};
|
||||
|
||||
export const getUserDetailsV2 = async (): Promise<UserDetails> => {
|
||||
try {
|
||||
const token = getToken();
|
||||
|
||||
@@ -3,6 +3,23 @@ import { apiURL } from "ente-base/origins";
|
||||
import { nullToUndefined } from "ente-utils/transform";
|
||||
import { z } from "zod";
|
||||
|
||||
/**
|
||||
* Fetch the public key from remote for the user (if any) who has registered
|
||||
* with remote with the given {@link email}.
|
||||
*
|
||||
* @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()}`, {
|
||||
headers: await authenticatedRequestHeaders(),
|
||||
});
|
||||
ensureOk(res);
|
||||
return z.object({ publicKey: z.string() }).parse(await res.json())
|
||||
.publicKey;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch the two-factor status (whether or not it is enabled) from remote.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user