Move
This commit is contained in:
@@ -2,14 +2,12 @@ import log from "@/next/log";
|
||||
import ComlinkCryptoWorker from "@ente/shared/crypto";
|
||||
import { ApiError, CustomError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import { getActualKey } from "@ente/shared/user";
|
||||
import { HttpStatusCode } from "axios";
|
||||
import { codeFromURIString, type Code } from "services/code";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
export const getAuthCodes = async (): Promise<Code[]> => {
|
||||
const masterKey = await getActualKey();
|
||||
try {
|
||||
@@ -83,7 +81,7 @@ interface AuthKey {
|
||||
export const getAuthKey = async (): Promise<AuthKey> => {
|
||||
try {
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/authenticator/key`,
|
||||
`${apiOrigin()}/authenticator/key`,
|
||||
{},
|
||||
{
|
||||
"X-Auth-Token": getToken(),
|
||||
@@ -110,7 +108,7 @@ export const getDiff = async (
|
||||
): Promise<AuthEntity[]> => {
|
||||
try {
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/authenticator/entity/diff`,
|
||||
`${apiOrigin()}/authenticator/entity/diff`,
|
||||
{
|
||||
sinceTime,
|
||||
limit,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import log from "@/next/log";
|
||||
import { apiOrigin, paymentsAppOrigin } from "@/next/origins";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint, getPaymentsURL } from "@ente/shared/network/api";
|
||||
import {
|
||||
LS_KEYS,
|
||||
removeData,
|
||||
@@ -12,8 +12,6 @@ import isElectron from "is-electron";
|
||||
import { Plan, Subscription } from "types/billing";
|
||||
import { getPaymentToken } from "./userService";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
enum PaymentActionType {
|
||||
Buy = "buy",
|
||||
Update = "update",
|
||||
@@ -36,11 +34,11 @@ class billingService {
|
||||
let response;
|
||||
if (!token) {
|
||||
response = await HTTPService.get(
|
||||
`${ENDPOINT}/billing/plans/v2`,
|
||||
`${apiOrigin()}/billing/plans/v2`,
|
||||
);
|
||||
} else {
|
||||
response = await HTTPService.get(
|
||||
`${ENDPOINT}/billing/user-plans`,
|
||||
`${apiOrigin()}/billing/user-plans`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": getToken(),
|
||||
@@ -56,7 +54,7 @@ class billingService {
|
||||
public async syncSubscription() {
|
||||
try {
|
||||
const response = await HTTPService.get(
|
||||
`${ENDPOINT}/billing/subscription`,
|
||||
`${apiOrigin()}/billing/subscription`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": getToken(),
|
||||
@@ -100,7 +98,7 @@ class billingService {
|
||||
public async cancelSubscription() {
|
||||
try {
|
||||
const response = await HTTPService.post(
|
||||
`${ENDPOINT}/billing/stripe/cancel-subscription`,
|
||||
`${apiOrigin()}/billing/stripe/cancel-subscription`,
|
||||
null,
|
||||
null,
|
||||
{
|
||||
@@ -118,7 +116,7 @@ class billingService {
|
||||
public async activateSubscription() {
|
||||
try {
|
||||
const response = await HTTPService.post(
|
||||
`${ENDPOINT}/billing/stripe/activate-subscription`,
|
||||
`${apiOrigin()}/billing/stripe/activate-subscription`,
|
||||
null,
|
||||
null,
|
||||
{
|
||||
@@ -142,7 +140,7 @@ class billingService {
|
||||
return;
|
||||
}
|
||||
const response = await HTTPService.post(
|
||||
`${ENDPOINT}/billing/verify-subscription`,
|
||||
`${apiOrigin()}/billing/verify-subscription`,
|
||||
{
|
||||
paymentProvider: "stripe",
|
||||
productID: null,
|
||||
@@ -167,9 +165,14 @@ class billingService {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await HTTPService.delete(`${ENDPOINT}/family/leave`, null, null, {
|
||||
"X-Auth-Token": getToken(),
|
||||
});
|
||||
await HTTPService.delete(
|
||||
`${apiOrigin()}/family/leave`,
|
||||
null,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": getToken(),
|
||||
},
|
||||
);
|
||||
removeData(LS_KEYS.FAMILY_DATA);
|
||||
} catch (e) {
|
||||
log.error("/family/leave failed", e);
|
||||
@@ -184,7 +187,7 @@ class billingService {
|
||||
) {
|
||||
try {
|
||||
const redirectURL = this.getRedirectURL();
|
||||
window.location.href = `${getPaymentsURL()}?productID=${productID}&paymentToken=${paymentToken}&action=${action}&redirectURL=${redirectURL}`;
|
||||
window.location.href = `${paymentsAppOrigin()}?productID=${productID}&paymentToken=${paymentToken}&action=${action}&redirectURL=${redirectURL}`;
|
||||
} catch (e) {
|
||||
log.error("unable to get payments url", e);
|
||||
throw e;
|
||||
@@ -195,7 +198,7 @@ class billingService {
|
||||
try {
|
||||
const redirectURL = this.getRedirectURL();
|
||||
const response = await HTTPService.get(
|
||||
`${ENDPOINT}/billing/stripe/customer-portal`,
|
||||
`${apiOrigin()}/billing/stripe/customer-portal`,
|
||||
{ redirectURL },
|
||||
{
|
||||
"X-Auth-Token": getToken(),
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import localForage from "@ente/shared/storage/localForage";
|
||||
import { getData, LS_KEYS } from "@ente/shared/storage/localStorage";
|
||||
|
||||
import log from "@/next/log";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import ComlinkCryptoWorker from "@ente/shared/crypto";
|
||||
import { CustomError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import localForage from "@ente/shared/storage/localForage";
|
||||
import { getData, LS_KEYS } from "@ente/shared/storage/localStorage";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import { getActualKey } from "@ente/shared/user";
|
||||
import type { User } from "@ente/shared/user/types";
|
||||
@@ -77,7 +76,6 @@ import {
|
||||
import { getLocalFiles } from "./fileService";
|
||||
import { getPublicKey } from "./userService";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
const COLLECTION_TABLE = "collections";
|
||||
const COLLECTION_UPDATION_TIME = "collection-updation-time";
|
||||
const HIDDEN_COLLECTION_IDS = "hidden-collection-ids";
|
||||
@@ -183,7 +181,7 @@ const getCollections = async (
|
||||
): Promise<Collection[]> => {
|
||||
try {
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/collections/v2`,
|
||||
`${apiOrigin()}/collections/v2`,
|
||||
{
|
||||
sinceTime,
|
||||
},
|
||||
@@ -330,7 +328,7 @@ export const getCollection = async (
|
||||
return;
|
||||
}
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/collections/${collectionID}`,
|
||||
`${apiOrigin()}/collections/${collectionID}`,
|
||||
null,
|
||||
{ "X-Auth-Token": token },
|
||||
);
|
||||
@@ -474,7 +472,7 @@ const postCollection = async (
|
||||
): Promise<EncryptedCollection> => {
|
||||
try {
|
||||
const response = await HTTPService.post(
|
||||
`${ENDPOINT}/collections`,
|
||||
`${apiOrigin()}/collections`,
|
||||
collectionData,
|
||||
null,
|
||||
{ "X-Auth-Token": token },
|
||||
@@ -529,7 +527,7 @@ export const addToCollection = async (
|
||||
files: fileKeysEncryptedWithNewCollection,
|
||||
};
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/collections/add-files`,
|
||||
`${apiOrigin()}/collections/add-files`,
|
||||
requestBody,
|
||||
null,
|
||||
{
|
||||
@@ -559,7 +557,7 @@ export const restoreToCollection = async (
|
||||
files: fileKeysEncryptedWithNewCollection,
|
||||
};
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/collections/restore-files`,
|
||||
`${apiOrigin()}/collections/restore-files`,
|
||||
requestBody,
|
||||
null,
|
||||
{
|
||||
@@ -590,7 +588,7 @@ export const moveToCollection = async (
|
||||
files: fileKeysEncryptedWithNewCollection,
|
||||
};
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/collections/move-files`,
|
||||
`${apiOrigin()}/collections/move-files`,
|
||||
requestBody,
|
||||
null,
|
||||
{
|
||||
@@ -736,7 +734,7 @@ export const removeNonUserFiles = async (
|
||||
};
|
||||
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/collections/v3/remove-files`,
|
||||
`${apiOrigin()}/collections/v3/remove-files`,
|
||||
request,
|
||||
null,
|
||||
{ "X-Auth-Token": token },
|
||||
@@ -763,7 +761,7 @@ export const deleteCollection = async (
|
||||
const token = getToken();
|
||||
|
||||
await HTTPService.delete(
|
||||
`${ENDPOINT}/collections/v3/${collectionID}`,
|
||||
`${apiOrigin()}/collections/v3/${collectionID}`,
|
||||
null,
|
||||
{ collectionID, keepFiles },
|
||||
{ "X-Auth-Token": token },
|
||||
@@ -779,7 +777,7 @@ export const leaveSharedAlbum = async (collectionID: number) => {
|
||||
const token = getToken();
|
||||
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/collections/leave/${collectionID}`,
|
||||
`${apiOrigin()}/collections/leave/${collectionID}`,
|
||||
null,
|
||||
null,
|
||||
{ "X-Auth-Token": token },
|
||||
@@ -817,7 +815,7 @@ export const updateCollectionMagicMetadata = async (
|
||||
};
|
||||
|
||||
await HTTPService.put(
|
||||
`${ENDPOINT}/collections/magic-metadata`,
|
||||
`${apiOrigin()}/collections/magic-metadata`,
|
||||
reqBody,
|
||||
null,
|
||||
{
|
||||
@@ -861,7 +859,7 @@ export const updateSharedCollectionMagicMetadata = async (
|
||||
};
|
||||
|
||||
await HTTPService.put(
|
||||
`${ENDPOINT}/collections/sharee-magic-metadata`,
|
||||
`${apiOrigin()}/collections/sharee-magic-metadata`,
|
||||
reqBody,
|
||||
null,
|
||||
{
|
||||
@@ -905,7 +903,7 @@ export const updatePublicCollectionMagicMetadata = async (
|
||||
};
|
||||
|
||||
await HTTPService.put(
|
||||
`${ENDPOINT}/collections/public-magic-metadata`,
|
||||
`${apiOrigin()}/collections/public-magic-metadata`,
|
||||
reqBody,
|
||||
null,
|
||||
{
|
||||
@@ -940,7 +938,7 @@ export const renameCollection = async (
|
||||
nameDecryptionNonce,
|
||||
};
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/collections/rename`,
|
||||
`${apiOrigin()}/collections/rename`,
|
||||
collectionRenameRequest,
|
||||
null,
|
||||
{
|
||||
@@ -969,7 +967,7 @@ export const shareCollection = async (
|
||||
encryptedKey,
|
||||
};
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/collections/share`,
|
||||
`${apiOrigin()}/collections/share`,
|
||||
shareCollectionRequest,
|
||||
null,
|
||||
{
|
||||
@@ -993,7 +991,7 @@ export const unshareCollection = async (
|
||||
email: withUserEmail,
|
||||
};
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/collections/unshare`,
|
||||
`${apiOrigin()}/collections/unshare`,
|
||||
shareCollectionRequest,
|
||||
null,
|
||||
{
|
||||
@@ -1015,7 +1013,7 @@ export const createShareableURL = async (collection: Collection) => {
|
||||
collectionID: collection.id,
|
||||
};
|
||||
const resp = await HTTPService.post(
|
||||
`${ENDPOINT}/collections/share-url`,
|
||||
`${apiOrigin()}/collections/share-url`,
|
||||
createPublicAccessTokenRequest,
|
||||
null,
|
||||
{
|
||||
@@ -1036,7 +1034,7 @@ export const deleteShareableURL = async (collection: Collection) => {
|
||||
return null;
|
||||
}
|
||||
await HTTPService.delete(
|
||||
`${ENDPOINT}/collections/share-url/${collection.id}`,
|
||||
`${apiOrigin()}/collections/share-url/${collection.id}`,
|
||||
null,
|
||||
null,
|
||||
{
|
||||
@@ -1058,7 +1056,7 @@ export const updateShareableURL = async (
|
||||
return null;
|
||||
}
|
||||
const res = await HTTPService.put(
|
||||
`${ENDPOINT}/collections/share-url`,
|
||||
`${apiOrigin()}/collections/share-url`,
|
||||
request,
|
||||
null,
|
||||
{
|
||||
|
||||
@@ -3,12 +3,10 @@ import { FILE_TYPE } from "@/media/file-type";
|
||||
import type { Metadata } from "@/media/types/file";
|
||||
import log from "@/next/log";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import { EnteFile } from "types/file";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
interface DuplicatesResponse {
|
||||
duplicates: Array<{
|
||||
fileIDs: number[];
|
||||
@@ -148,7 +146,7 @@ function groupDupesByFileHashes(dupe: Duplicate) {
|
||||
async function fetchDuplicateFileIDs() {
|
||||
try {
|
||||
const response = await HTTPService.get(
|
||||
`${ENDPOINT}/files/duplicates`,
|
||||
`${apiOrigin()}/files/duplicates`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": getToken(),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { inWorker } from "@/next/env";
|
||||
import log from "@/next/log";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import { workerBridge } from "@/next/worker/worker-bridge";
|
||||
import ComlinkCryptoWorker from "@ente/shared/crypto";
|
||||
import { CustomError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import localForage from "@ente/shared/storage/localForage";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import type {
|
||||
@@ -285,7 +285,7 @@ export const getEmbeddingsDiff = async (
|
||||
return;
|
||||
}
|
||||
const response = await HTTPService.get(
|
||||
`${getEndpoint()}/embeddings/diff`,
|
||||
`${apiOrigin()}/embeddings/diff`,
|
||||
{
|
||||
sinceTime,
|
||||
limit: DIFF_LIMIT,
|
||||
@@ -314,7 +314,7 @@ export const putEmbedding = async (
|
||||
throw Error(CustomError.TOKEN_MISSING);
|
||||
}
|
||||
const resp = await HTTPService.put(
|
||||
`${getEndpoint()}/embeddings`,
|
||||
`${apiOrigin()}/embeddings`,
|
||||
putEmbeddingReq,
|
||||
null,
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import log from "@/next/log";
|
||||
import ComlinkCryptoWorker from "@ente/shared/crypto";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import localForage from "@ente/shared/storage/localForage";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import { getActualKey } from "@ente/shared/user";
|
||||
@@ -15,8 +15,6 @@ import {
|
||||
} from "types/entity";
|
||||
import { getLatestVersionEntities } from "utils/entity";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
const DIFF_LIMIT = 500;
|
||||
|
||||
const ENTITY_TABLES: Record<EntityType, string> = {
|
||||
@@ -60,7 +58,7 @@ const getEntityKey = async (type: EntityType) => {
|
||||
return;
|
||||
}
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/user-entity/key`,
|
||||
`${apiOrigin()}/user-entity/key`,
|
||||
{
|
||||
type,
|
||||
},
|
||||
@@ -175,7 +173,7 @@ const getEntityDiff = async (
|
||||
return;
|
||||
}
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/user-entity/entity/diff`,
|
||||
`${apiOrigin()}/user-entity/entity/diff`,
|
||||
{
|
||||
sinceTime: time,
|
||||
type,
|
||||
|
||||
@@ -2,7 +2,7 @@ import log from "@/next/log";
|
||||
import ComlinkCryptoWorker from "@ente/shared/crypto";
|
||||
import { Events, eventBus } from "@ente/shared/events";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import localForage from "@ente/shared/storage/localForage";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import { REQUEST_BATCH_SIZE } from "constants/api";
|
||||
@@ -28,7 +28,6 @@ import {
|
||||
setCollectionLastSyncTime,
|
||||
} from "./collectionService";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
const FILES_TABLE = "files";
|
||||
const HIDDEN_FILES_TABLE = "hidden-files";
|
||||
|
||||
@@ -118,7 +117,7 @@ export const getFiles = async (
|
||||
break;
|
||||
}
|
||||
resp = await HTTPService.get(
|
||||
`${ENDPOINT}/collections/v2/diff`,
|
||||
`${apiOrigin()}/collections/v2/diff`,
|
||||
{
|
||||
collectionID: collection.id,
|
||||
sinceTime: time,
|
||||
@@ -187,7 +186,7 @@ export const trashFiles = async (filesToTrash: EnteFile[]) => {
|
||||
})),
|
||||
};
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/files/trash`,
|
||||
`${apiOrigin()}/files/trash`,
|
||||
trashRequest,
|
||||
null,
|
||||
{
|
||||
@@ -211,7 +210,7 @@ export const deleteFromTrash = async (filesToDelete: number[]) => {
|
||||
|
||||
for (const batch of batchedFilesToDelete) {
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/trash/delete`,
|
||||
`${apiOrigin()}/trash/delete`,
|
||||
{ fileIDs: batch },
|
||||
null,
|
||||
{
|
||||
@@ -253,7 +252,7 @@ export const updateFileMagicMetadata = async (
|
||||
},
|
||||
});
|
||||
}
|
||||
await HTTPService.put(`${ENDPOINT}/files/magic-metadata`, reqBody, null, {
|
||||
await HTTPService.put(`${apiOrigin()}/files/magic-metadata`, reqBody, null, {
|
||||
"X-Auth-Token": token,
|
||||
});
|
||||
return fileWithUpdatedMagicMetadataList.map(
|
||||
@@ -296,7 +295,7 @@ export const updateFilePublicMagicMetadata = async (
|
||||
});
|
||||
}
|
||||
await HTTPService.put(
|
||||
`${ENDPOINT}/files/public-magic-metadata`,
|
||||
`${apiOrigin()}/files/public-magic-metadata`,
|
||||
reqBody,
|
||||
null,
|
||||
{
|
||||
|
||||
@@ -2,14 +2,13 @@ import log from "@/next/log";
|
||||
import ComlinkCryptoWorker from "@ente/shared/crypto";
|
||||
import { CustomError, parseSharingErrorCodes } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import localForage from "@ente/shared/storage/localForage";
|
||||
import { Collection, CollectionPublicMagicMetadata } from "types/collection";
|
||||
import { EncryptedEnteFile, EnteFile } from "types/file";
|
||||
import { LocalSavedPublicCollectionFiles } from "types/publicCollection";
|
||||
import { decryptFile, mergeMetadata, sortFiles } from "utils/file";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
const PUBLIC_COLLECTION_FILES_TABLE = "public-collection-files";
|
||||
const PUBLIC_COLLECTIONS_TABLE = "public-collections";
|
||||
const PUBLIC_REFERRAL_CODE = "public-referral-code";
|
||||
@@ -253,7 +252,7 @@ const getPublicFiles = async (
|
||||
break;
|
||||
}
|
||||
resp = await HTTPService.get(
|
||||
`${ENDPOINT}/public-collection/diff`,
|
||||
`${apiOrigin()}/public-collection/diff`,
|
||||
{
|
||||
sinceTime: time,
|
||||
},
|
||||
@@ -308,7 +307,7 @@ export const getPublicCollection = async (
|
||||
return;
|
||||
}
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/public-collection/info`,
|
||||
`${apiOrigin()}/public-collection/info`,
|
||||
null,
|
||||
{ "Cache-Control": "no-cache", "X-Auth-Access-Token": token },
|
||||
);
|
||||
@@ -358,7 +357,7 @@ export const verifyPublicCollectionPassword = async (
|
||||
): Promise<string> => {
|
||||
try {
|
||||
const resp = await HTTPService.post(
|
||||
`${ENDPOINT}/public-collection/verify-password`,
|
||||
`${apiOrigin()}/public-collection/verify-password`,
|
||||
{ passHash: passwordHash },
|
||||
null,
|
||||
{ "Cache-Control": "no-cache", "X-Auth-Access-Token": token },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import log from "@/next/log";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import localForage from "@ente/shared/storage/localForage";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import { Collection } from "types/collection";
|
||||
@@ -14,8 +14,6 @@ const TRASH = "file-trash";
|
||||
const TRASH_TIME = "trash-time";
|
||||
const DELETED_COLLECTION = "deleted-collection";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
async function getLocalTrash() {
|
||||
const trash = (await localForage.getItem<Trash>(TRASH)) || [];
|
||||
return trash;
|
||||
@@ -91,7 +89,7 @@ export const updateTrash = async (
|
||||
break;
|
||||
}
|
||||
resp = await HTTPService.get(
|
||||
`${ENDPOINT}/trash/v2/diff`,
|
||||
`${apiOrigin()}/trash/v2/diff`,
|
||||
{
|
||||
sinceTime: time,
|
||||
},
|
||||
@@ -160,7 +158,7 @@ export const emptyTrash = async () => {
|
||||
const lastUpdatedAt = await getLastSyncTime();
|
||||
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/trash/empty`,
|
||||
`${apiOrigin()}/trash/empty`,
|
||||
{ lastUpdatedAt },
|
||||
null,
|
||||
{
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import log from "@/next/log";
|
||||
import { CustomError, handleUploadError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import { EnteFile } from "types/file";
|
||||
import { retryHTTPCall } from "./uploadHttpClient";
|
||||
import { MultipartUploadURLs, UploadFile, UploadURL } from "./uploadService";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
const MAX_URL_REQUESTS = 50;
|
||||
|
||||
class PublicUploadHttpClient {
|
||||
@@ -25,7 +23,7 @@ class PublicUploadHttpClient {
|
||||
const response = await retryHTTPCall(
|
||||
() =>
|
||||
HTTPService.post(
|
||||
`${ENDPOINT}/public-collection/file`,
|
||||
`${apiOrigin()}/public-collection/file`,
|
||||
uploadFile,
|
||||
null,
|
||||
{
|
||||
@@ -57,7 +55,7 @@ class PublicUploadHttpClient {
|
||||
throw Error(CustomError.TOKEN_MISSING);
|
||||
}
|
||||
this.uploadURLFetchInProgress = HTTPService.get(
|
||||
`${ENDPOINT}/public-collection/upload-urls`,
|
||||
`${apiOrigin()}/public-collection/upload-urls`,
|
||||
{
|
||||
count: Math.min(MAX_URL_REQUESTS, count * 2),
|
||||
},
|
||||
@@ -93,7 +91,7 @@ class PublicUploadHttpClient {
|
||||
throw Error(CustomError.TOKEN_MISSING);
|
||||
}
|
||||
const response = await HTTPService.get(
|
||||
`${ENDPOINT}/public-collection/multipart-upload-urls`,
|
||||
`${apiOrigin()}/public-collection/multipart-upload-urls`,
|
||||
{
|
||||
count,
|
||||
},
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import log from "@/next/log";
|
||||
import { apiOrigin, uploaderOrigin } from "@/next/origins";
|
||||
import { wait } from "@/utils/promise";
|
||||
import { CustomError, handleUploadError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint, uploaderOrigin } from "@ente/shared/network/api";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import { EnteFile } from "types/file";
|
||||
import { MultipartUploadURLs, UploadFile, UploadURL } from "./uploadService";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
const MAX_URL_REQUESTS = 50;
|
||||
|
||||
class UploadHttpClient {
|
||||
@@ -22,7 +20,7 @@ class UploadHttpClient {
|
||||
}
|
||||
const response = await retryHTTPCall(
|
||||
() =>
|
||||
HTTPService.post(`${ENDPOINT}/files`, uploadFile, null, {
|
||||
HTTPService.post(`${apiOrigin()}/files`, uploadFile, null, {
|
||||
"X-Auth-Token": token,
|
||||
}),
|
||||
handleUploadError,
|
||||
@@ -43,7 +41,7 @@ class UploadHttpClient {
|
||||
return;
|
||||
}
|
||||
this.uploadURLFetchInProgress = HTTPService.get(
|
||||
`${ENDPOINT}/files/upload-urls`,
|
||||
`${apiOrigin()}/files/upload-urls`,
|
||||
{
|
||||
count: Math.min(MAX_URL_REQUESTS, count * 2),
|
||||
},
|
||||
@@ -73,7 +71,7 @@ class UploadHttpClient {
|
||||
return;
|
||||
}
|
||||
const response = await HTTPService.get(
|
||||
`${ENDPOINT}/files/multipart-upload-urls`,
|
||||
`${apiOrigin()}/files/multipart-upload-urls`,
|
||||
{
|
||||
count,
|
||||
},
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import log from "@/next/log";
|
||||
import { apiOrigin, customAPIOrigin, familyAppOrigin } from "@/next/origins";
|
||||
import { putAttributes } from "@ente/accounts/api/user";
|
||||
import { ApiError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import {
|
||||
customAPIOrigin,
|
||||
getEndpoint,
|
||||
getFamilyPortalURL,
|
||||
} from "@ente/shared/network/api";
|
||||
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
|
||||
import {
|
||||
getToken,
|
||||
@@ -21,15 +17,13 @@ import {
|
||||
} from "types/user";
|
||||
import { getLocalFamilyData, isPartOfFamily } from "utils/user/family";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
const HAS_SET_KEYS = "hasSetKeys";
|
||||
|
||||
export const getPublicKey = async (email: string) => {
|
||||
const token = getToken();
|
||||
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/users/public-key`,
|
||||
`${apiOrigin()}/users/public-key`,
|
||||
{ email },
|
||||
{
|
||||
"X-Auth-Token": token,
|
||||
@@ -42,7 +36,7 @@ export const getPaymentToken = async () => {
|
||||
const token = getToken();
|
||||
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/users/payment-token`,
|
||||
`${apiOrigin()}/users/payment-token`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": token,
|
||||
@@ -56,7 +50,7 @@ export const getFamiliesToken = async () => {
|
||||
const token = getToken();
|
||||
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/users/families-token`,
|
||||
`${apiOrigin()}/users/families-token`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": token,
|
||||
@@ -74,7 +68,7 @@ export const getRoadmapRedirectURL = async () => {
|
||||
const token = getToken();
|
||||
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/users/roadmap/v2`,
|
||||
`${apiOrigin()}/users/roadmap/v2`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": token,
|
||||
@@ -90,7 +84,7 @@ export const getRoadmapRedirectURL = async () => {
|
||||
export const isTokenValid = async (token: string) => {
|
||||
try {
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/users/session-validity/v2`,
|
||||
`${apiOrigin()}/users/session-validity/v2`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": token,
|
||||
@@ -129,7 +123,7 @@ export const isTokenValid = async (token: string) => {
|
||||
|
||||
export const getTwoFactorStatus = async () => {
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/users/two-factor/status`,
|
||||
`${apiOrigin()}/users/two-factor/status`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": getToken(),
|
||||
@@ -143,7 +137,7 @@ export const getUserDetailsV2 = async (): Promise<UserDetails> => {
|
||||
const token = getToken();
|
||||
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/users/details/v2`,
|
||||
`${apiOrigin()}/users/details/v2`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": token,
|
||||
@@ -160,7 +154,7 @@ export const getFamilyPortalRedirectURL = async () => {
|
||||
try {
|
||||
const jwtToken = await getFamiliesToken();
|
||||
const isFamilyCreated = isPartOfFamily(getLocalFamilyData());
|
||||
return `${getFamilyPortalURL()}?token=${jwtToken}&isFamilyCreated=${isFamilyCreated}&redirectURL=${
|
||||
return `${familyAppOrigin()}?token=${jwtToken}&isFamilyCreated=${isFamilyCreated}&redirectURL=${
|
||||
window.location.origin
|
||||
}/gallery`;
|
||||
} catch (e) {
|
||||
@@ -174,7 +168,7 @@ export const getAccountDeleteChallenge = async () => {
|
||||
const token = getToken();
|
||||
|
||||
const resp = await HTTPService.get(
|
||||
`${ENDPOINT}/users/delete-challenge`,
|
||||
`${apiOrigin()}/users/delete-challenge`,
|
||||
null,
|
||||
{
|
||||
"X-Auth-Token": token,
|
||||
@@ -199,7 +193,7 @@ export const deleteAccount = async (
|
||||
}
|
||||
|
||||
await HTTPService.delete(
|
||||
`${ENDPOINT}/users/delete`,
|
||||
`${apiOrigin()}/users/delete`,
|
||||
{ challenge, reason, feedback },
|
||||
null,
|
||||
{
|
||||
@@ -217,7 +211,7 @@ export const getFaceSearchEnabledStatus = async () => {
|
||||
const token = getToken();
|
||||
const resp: AxiosResponse<GetRemoteStoreValueResponse> =
|
||||
await HTTPService.get(
|
||||
`${ENDPOINT}/remote-store`,
|
||||
`${apiOrigin()}/remote-store`,
|
||||
{
|
||||
key: "faceSearchEnabled",
|
||||
defaultValue: false,
|
||||
@@ -237,7 +231,7 @@ export const updateFaceSearchEnabledStatus = async (newStatus: boolean) => {
|
||||
try {
|
||||
const token = getToken();
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/remote-store/update`,
|
||||
`${apiOrigin()}/remote-store/update`,
|
||||
{
|
||||
key: "faceSearchEnabled",
|
||||
value: newStatus.toString(),
|
||||
@@ -268,7 +262,7 @@ export const getMapEnabledStatus = async () => {
|
||||
const token = getToken();
|
||||
const resp: AxiosResponse<GetRemoteStoreValueResponse> =
|
||||
await HTTPService.get(
|
||||
`${ENDPOINT}/remote-store`,
|
||||
`${apiOrigin()}/remote-store`,
|
||||
{
|
||||
key: "mapEnabled",
|
||||
defaultValue: false,
|
||||
@@ -288,7 +282,7 @@ export const updateMapEnabledStatus = async (newStatus: boolean) => {
|
||||
try {
|
||||
const token = getToken();
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/remote-store/update`,
|
||||
`${apiOrigin()}/remote-store/update`,
|
||||
{
|
||||
key: "mapEnabled",
|
||||
value: newStatus.toString(),
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import log from "@/next/log";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import type {
|
||||
CompleteSRPSetupRequest,
|
||||
CompleteSRPSetupResponse,
|
||||
@@ -15,17 +13,19 @@ import type {
|
||||
UpdateSRPAndKeysResponse,
|
||||
} from "@ente/accounts/types/srp";
|
||||
import { ApiError, CustomError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { HttpStatusCode } from "axios";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
export const getSRPAttributes = async (
|
||||
email: string,
|
||||
): Promise<SRPAttributes | null> => {
|
||||
try {
|
||||
const resp = await HTTPService.get(`${ENDPOINT}/users/srp/attributes`, {
|
||||
email,
|
||||
});
|
||||
const resp = await HTTPService.get(
|
||||
`${apiOrigin()}/users/srp/attributes`,
|
||||
{
|
||||
email,
|
||||
},
|
||||
);
|
||||
return (resp.data as GetSRPAttributesResponse).attributes;
|
||||
} catch (e) {
|
||||
log.error("failed to get SRP attributes", e);
|
||||
@@ -39,7 +39,7 @@ export const startSRPSetup = async (
|
||||
): Promise<SetupSRPResponse> => {
|
||||
try {
|
||||
const resp = await HTTPService.post(
|
||||
`${ENDPOINT}/users/srp/setup`,
|
||||
`${apiOrigin()}/users/srp/setup`,
|
||||
setupSRPRequest,
|
||||
undefined,
|
||||
{
|
||||
@@ -60,7 +60,7 @@ export const completeSRPSetup = async (
|
||||
) => {
|
||||
try {
|
||||
const resp = await HTTPService.post(
|
||||
`${ENDPOINT}/users/srp/complete`,
|
||||
`${apiOrigin()}/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(
|
||||
`${ENDPOINT}/users/srp/create-session`,
|
||||
`${apiOrigin()}/users/srp/create-session`,
|
||||
{
|
||||
srpUserID,
|
||||
srpA,
|
||||
@@ -97,7 +97,7 @@ export const verifySRPSession = async (
|
||||
) => {
|
||||
try {
|
||||
const resp = await HTTPService.post(
|
||||
`${ENDPOINT}/users/srp/verify-session`,
|
||||
`${apiOrigin()}/users/srp/verify-session`,
|
||||
{
|
||||
sessionID,
|
||||
srpUserID,
|
||||
@@ -125,7 +125,7 @@ export const updateSRPAndKeys = async (
|
||||
): Promise<UpdateSRPAndKeysResponse> => {
|
||||
try {
|
||||
const resp = await HTTPService.post(
|
||||
`${ENDPOINT}/users/srp/update`,
|
||||
`${apiOrigin()}/users/srp/update`,
|
||||
updateSRPAndKeyRequest,
|
||||
undefined,
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
import type { AppName } from "@/next/types/app";
|
||||
import type {
|
||||
RecoveryKey,
|
||||
@@ -9,15 +10,12 @@ import type {
|
||||
import type { B64EncryptionResult } from "@ente/shared/crypto/types";
|
||||
import { ApiError, CustomError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { getEndpoint } from "@ente/shared/network/api";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import type { KeyAttributes } from "@ente/shared/user/types";
|
||||
import { HttpStatusCode } from "axios";
|
||||
|
||||
const ENDPOINT = getEndpoint();
|
||||
|
||||
export const sendOtt = (appName: AppName, email: string) => {
|
||||
return HTTPService.post(`${ENDPOINT}/users/ott`, {
|
||||
return HTTPService.post(`${apiOrigin()}/users/ott`, {
|
||||
email,
|
||||
client: appName == "auth" ? "totp" : "web",
|
||||
});
|
||||
@@ -25,7 +23,7 @@ export const sendOtt = (appName: AppName, email: string) => {
|
||||
|
||||
export const verifyOtt = (email: string, ott: string, referral: string) => {
|
||||
const cleanedReferral = `web:${referral?.trim() || ""}`;
|
||||
return HTTPService.post(`${ENDPOINT}/users/verify-email`, {
|
||||
return HTTPService.post(`${apiOrigin()}/users/verify-email`, {
|
||||
email,
|
||||
ott,
|
||||
source: cleanedReferral,
|
||||
@@ -34,7 +32,7 @@ export const verifyOtt = (email: string, ott: string, referral: string) => {
|
||||
|
||||
export const putAttributes = (token: string, keyAttributes: KeyAttributes) =>
|
||||
HTTPService.put(
|
||||
`${ENDPOINT}/users/attributes`,
|
||||
`${apiOrigin()}/users/attributes`,
|
||||
{ keyAttributes },
|
||||
undefined,
|
||||
{
|
||||
@@ -45,7 +43,7 @@ export const putAttributes = (token: string, keyAttributes: KeyAttributes) =>
|
||||
export const logout = async () => {
|
||||
try {
|
||||
const token = getToken();
|
||||
await HTTPService.post(`${ENDPOINT}/users/logout`, null, undefined, {
|
||||
await HTTPService.post(`${apiOrigin()}/users/logout`, null, undefined, {
|
||||
"X-Auth-Token": token,
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -65,10 +63,13 @@ export const logout = async () => {
|
||||
};
|
||||
|
||||
export const verifyTwoFactor = async (code: string, sessionID: string) => {
|
||||
const resp = await HTTPService.post(`${ENDPOINT}/users/two-factor/verify`, {
|
||||
code,
|
||||
sessionID,
|
||||
});
|
||||
const resp = await HTTPService.post(
|
||||
`${apiOrigin()}/users/two-factor/verify`,
|
||||
{
|
||||
code,
|
||||
sessionID,
|
||||
},
|
||||
);
|
||||
return resp.data as UserVerificationResponse;
|
||||
};
|
||||
|
||||
@@ -79,10 +80,13 @@ export const recoverTwoFactor = async (
|
||||
sessionID: string,
|
||||
twoFactorType: TwoFactorType,
|
||||
) => {
|
||||
const resp = await HTTPService.get(`${ENDPOINT}/users/two-factor/recover`, {
|
||||
sessionID,
|
||||
twoFactorType,
|
||||
});
|
||||
const resp = await HTTPService.get(
|
||||
`${apiOrigin()}/users/two-factor/recover`,
|
||||
{
|
||||
sessionID,
|
||||
twoFactorType,
|
||||
},
|
||||
);
|
||||
return resp.data as TwoFactorRecoveryResponse;
|
||||
};
|
||||
|
||||
@@ -91,17 +95,20 @@ export const removeTwoFactor = async (
|
||||
secret: string,
|
||||
twoFactorType: TwoFactorType,
|
||||
) => {
|
||||
const resp = await HTTPService.post(`${ENDPOINT}/users/two-factor/remove`, {
|
||||
sessionID,
|
||||
secret,
|
||||
twoFactorType,
|
||||
});
|
||||
const resp = await HTTPService.post(
|
||||
`${apiOrigin()}/users/two-factor/remove`,
|
||||
{
|
||||
sessionID,
|
||||
secret,
|
||||
twoFactorType,
|
||||
},
|
||||
);
|
||||
return resp.data as TwoFactorVerificationResponse;
|
||||
};
|
||||
|
||||
export const changeEmail = async (email: string, ott: string) => {
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/users/change-email`,
|
||||
`${apiOrigin()}/users/change-email`,
|
||||
{
|
||||
email,
|
||||
ott,
|
||||
@@ -114,7 +121,7 @@ export const changeEmail = async (email: string, ott: string) => {
|
||||
};
|
||||
|
||||
export const sendOTTForEmailChange = async (email: string) => {
|
||||
await HTTPService.post(`${ENDPOINT}/users/ott`, {
|
||||
await HTTPService.post(`${apiOrigin()}/users/ott`, {
|
||||
email,
|
||||
client: "web",
|
||||
purpose: "change",
|
||||
@@ -123,7 +130,7 @@ export const sendOTTForEmailChange = async (email: string) => {
|
||||
|
||||
export const setupTwoFactor = async () => {
|
||||
const resp = await HTTPService.post(
|
||||
`${ENDPOINT}/users/two-factor/setup`,
|
||||
`${apiOrigin()}/users/two-factor/setup`,
|
||||
null,
|
||||
undefined,
|
||||
{
|
||||
@@ -138,7 +145,7 @@ export const enableTwoFactor = async (
|
||||
recoveryEncryptedTwoFactorSecret: B64EncryptionResult,
|
||||
) => {
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/users/two-factor/enable`,
|
||||
`${apiOrigin()}/users/two-factor/enable`,
|
||||
{
|
||||
code,
|
||||
encryptedTwoFactorSecret:
|
||||
@@ -154,13 +161,18 @@ export const enableTwoFactor = async (
|
||||
};
|
||||
|
||||
export const setRecoveryKey = (token: string, recoveryKey: RecoveryKey) =>
|
||||
HTTPService.put(`${ENDPOINT}/users/recovery-key`, recoveryKey, undefined, {
|
||||
"X-Auth-Token": token,
|
||||
});
|
||||
HTTPService.put(
|
||||
`${apiOrigin()}/users/recovery-key`,
|
||||
recoveryKey,
|
||||
undefined,
|
||||
{
|
||||
"X-Auth-Token": token,
|
||||
},
|
||||
);
|
||||
|
||||
export const disableTwoFactor = async () => {
|
||||
await HTTPService.post(
|
||||
`${ENDPOINT}/users/two-factor/disable`,
|
||||
`${apiOrigin()}/users/two-factor/disable`,
|
||||
null,
|
||||
undefined,
|
||||
{
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
import { nullToUndefined } from "@/utils/transform";
|
||||
|
||||
/**
|
||||
* Return the origin (scheme, host, port triple) that should be used for making
|
||||
* API requests to museum.
|
||||
*
|
||||
* This defaults to {@link defaultAPIOrigin}, but can be overridden when self
|
||||
* hosting or developing by setting the `NEXT_PUBLIC_ENTE_ENDPOINT` environment
|
||||
* variable.
|
||||
*/
|
||||
export const apiOrigin = () => customAPIOrigin() ?? defaultAPIOrigin;
|
||||
|
||||
/**
|
||||
* Return the overridden API origin, if one is defined by either (in priority
|
||||
* order):
|
||||
*
|
||||
* - Setting the custom server on the landing page (See: [Note: Configuring
|
||||
* custom server]); or by
|
||||
*
|
||||
* - Setting the `NEXT_PUBLIC_ENTE_ENDPOINT` environment variable.
|
||||
*
|
||||
* Otherwise return undefined.
|
||||
*/
|
||||
export const customAPIOrigin = () =>
|
||||
nullToUndefined(localStorage.getItem("apiOrigin")) ??
|
||||
process.env.NEXT_PUBLIC_ENTE_ENDPOINT ??
|
||||
undefined;
|
||||
|
||||
/**
|
||||
* Default value of {@link apiOrigin}: "https://api.ente.io", Ente's production
|
||||
* API servers.
|
||||
*/
|
||||
export const defaultAPIOrigin = "https://api.ente.io";
|
||||
|
||||
/** Deprecated, use {@link apiOrigin} instead. */
|
||||
export const getEndpoint = apiOrigin;
|
||||
|
||||
/**
|
||||
* Return the origin that should be used for uploading files.
|
||||
*
|
||||
* This defaults to `https://uploader.ente.io`, serviced by a Cloudflare worker
|
||||
* (see infra/workers/uploader). But if a {@link customAPIOrigin} is set then
|
||||
* this value is set to the {@link customAPIOrigin} itself, effectively
|
||||
* bypassing the Cloudflare worker for non-Ente deployments.
|
||||
*/
|
||||
export const uploaderOrigin = () =>
|
||||
customAPIOrigin() ?? "https://uploader.ente.io";
|
||||
|
||||
/**
|
||||
* Return the URL of the Ente Accounts app.
|
||||
*
|
||||
* Defaults to our production instance, "https://accounts.ente.io", but can be
|
||||
* overridden by setting the `NEXT_PUBLIC_ENTE_ACCOUNTS_URL` environment
|
||||
* variable.
|
||||
*/
|
||||
export const accountsAppURL = () =>
|
||||
process.env.NEXT_PUBLIC_ENTE_ACCOUNTS_URL ?? `https://accounts.ente.io`;
|
||||
|
||||
export const getAlbumsURL = () => {
|
||||
const albumsURL = process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT;
|
||||
if (albumsURL) {
|
||||
return albumsURL;
|
||||
}
|
||||
return `https://albums.ente.io`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the URL for the family dashboard which can be used to create or manage
|
||||
* family plans.
|
||||
*/
|
||||
export const getFamilyPortalURL = () => {
|
||||
const familyURL = process.env.NEXT_PUBLIC_ENTE_FAMILY_URL;
|
||||
if (familyURL) {
|
||||
return familyURL;
|
||||
}
|
||||
return `https://family.ente.io`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the URL for the host that handles payment related functionality.
|
||||
*/
|
||||
export const getPaymentsURL = () => {
|
||||
const paymentsURL = process.env.NEXT_PUBLIC_ENTE_PAYMENTS_URL;
|
||||
if (paymentsURL) {
|
||||
return paymentsURL;
|
||||
}
|
||||
return `https://payments.ente.io`;
|
||||
};
|
||||
@@ -2,7 +2,7 @@ import log from "@/next/log";
|
||||
import { ApiError } from "../error";
|
||||
import { getToken } from "../storage/localStorage/helpers";
|
||||
import HTTPService from "./HTTPService";
|
||||
import { getEndpoint } from "./api";
|
||||
import { apiOrigin } from "@/next/origins";
|
||||
|
||||
class CastGateway {
|
||||
constructor() {}
|
||||
|
||||
Reference in New Issue
Block a user