Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move

Manav Rathie6707d9fcbdb
diff --git a/web/apps/auth/src/pages/_app.tsx b/web/apps/auth/src/pages/_app.tsx
index c65139559e..9aada5ae8a 100644
--- a/web/apps/auth/src/pages/_app.tsx
+++ b/web/apps/auth/src/pages/_app.tsx
@@ -2,6 +2,7 @@ import "@fontsource-variable/inter";
import { CssBaseline } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
import { accountLogout } from "ente-accounts/services/logout";
+import type { User } from "ente-accounts/services/user";
import { clientPackageName, staticAppTitle } from "ente-base/app";
import { CustomHead } from "ente-base/components/Head";
import {
@@ -20,7 +21,6 @@ import { BaseContext, deriveBaseContext } from "ente-base/context";
import { logStartupBanner } from "ente-base/log-web";
import HTTPService from "ente-shared/network/HTTPService";
import { getData } from "ente-shared/storage/localStorage";
-import type { User } from "ente-shared/user/types";
import { t } from "i18next";
import type { AppProps } from "next/app";
import React, { useCallback, useEffect, useMemo } from "react";
diff --git a/web/apps/photos/src/components/AuthenticateUser.tsx b/web/apps/photos/src/components/AuthenticateUser.tsx
index 6ecc64af71..83f45f42b7 100644
--- a/web/apps/photos/src/components/AuthenticateUser.tsx
+++ b/web/apps/photos/src/components/AuthenticateUser.tsx
@@ -1,5 +1,6 @@
import { VerifyMasterPasswordForm } from "ente-accounts/components/VerifyMasterPasswordForm";
import { checkSessionValidity } from "ente-accounts/services/session";
+import type { KeyAttributes, User } from "ente-accounts/services/user";
import {
TitledMiniDialog,
type MiniDialogAttributes,
@@ -8,7 +9,6 @@ import type { ModalVisibilityProps } from "ente-base/components/utils/modal";
import { useBaseContext } from "ente-base/context";
import log from "ente-base/log";
import { getData } from "ente-shared/storage/localStorage";
-import type { KeyAttributes, User } from "ente-shared/user/types";
import { t } from "i18next";
import { useCallback, useEffect, useState } from "react";
diff --git a/web/apps/photos/src/pages/_app.tsx b/web/apps/photos/src/pages/_app.tsx
index cdd5849886..5824cb1890 100644
--- a/web/apps/photos/src/pages/_app.tsx
+++ b/web/apps/photos/src/pages/_app.tsx
@@ -3,6 +3,7 @@ import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
import { CssBaseline, Typography } from "@mui/material";
import { styled, ThemeProvider } from "@mui/material/styles";
import { useNotification } from "components/utils/hooks-app";
+import type { User } from "ente-accounts/services/user";
import { clientPackageName, isDesktop, staticAppTitle } from "ente-base/app";
import { CenteredRow } from "ente-base/components/containers";
import { CustomHead } from "ente-base/components/Head";
@@ -43,7 +44,6 @@ import {
getData,
isLocalStorageAndIndexedDBMismatch,
} from "ente-shared/storage/localStorage";
-import type { User } from "ente-shared/user/types";
import { t } from "i18next";
import type { AppProps } from "next/app";
import { useRouter } from "next/router";
diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.ts
index 94e60e4613..4633340226 100644
--- a/web/apps/photos/src/services/collectionService.ts
+++ b/web/apps/photos/src/services/collectionService.ts
@@ -1,3 +1,4 @@
+import type { User } from "ente-accounts/services/user";
import { encryptMetadataJSON, sharedCryptoWorker } from "ente-base/crypto";
import { ensureLocalUser } from "ente-base/local-user";
import log from "ente-base/log";
@@ -43,7 +44,6 @@ import HTTPService from "ente-shared/network/HTTPService";
import { getData } 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";
import { batch } from "ente-utils/array";
import {
changeCollectionSubType,
diff --git a/web/apps/photos/src/types/gallery/index.ts b/web/apps/photos/src/types/gallery/index.ts
index 67371e047d..bb23e2f2d3 100644
--- a/web/apps/photos/src/types/gallery/index.ts
+++ b/web/apps/photos/src/types/gallery/index.ts
@@ -1,7 +1,7 @@
import { TimeStampListItem } from "components/FileList";
import { FilesDownloadProgressAttributes } from "components/FilesDownloadProgress";
+import type { User } from "ente-accounts/services/user";
import { type SelectionContext } from "ente-new/photos/components/gallery";
-import type { User } from "ente-shared/user/types";
export interface SelectedState {
[k: number]: boolean;
diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.ts
index 7ce407387d..dbacc979e2 100644
--- a/web/apps/photos/src/utils/collection.ts
+++ b/web/apps/photos/src/utils/collection.ts
@@ -1,3 +1,4 @@
+import type { User } from "ente-accounts/services/user";
import { ensureElectron } from "ente-base/electron";
import { joinPath } from "ente-base/file-name";
import log from "ente-base/log";
@@ -30,7 +31,6 @@ import {
} from "ente-new/photos/services/files";
import { safeDirectoryName } from "ente-new/photos/utils/native-fs";
import { getData } from "ente-shared/storage/localStorage";
-import type { User } from "ente-shared/user/types";
import {
createAlbum,
removeFromCollection,
diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.ts
index 9b5d90257f..a3afa279a3 100644
--- a/web/apps/photos/src/utils/file/index.ts
+++ b/web/apps/photos/src/utils/file/index.ts
@@ -1,3 +1,4 @@
+import type { User } from "ente-accounts/services/user";
import { joinPath } from "ente-base/file-name";
import log from "ente-base/log";
import { type Electron } from "ente-base/types/ipc";
@@ -21,7 +22,6 @@ import {
} from "ente-new/photos/services/collection";
import { safeFileName } from "ente-new/photos/utils/native-fs";
import { getData } from "ente-shared/storage/localStorage";
-import type { User } from "ente-shared/user/types";
import { wait } from "ente-utils/promise";
import { t } from "i18next";
import {
diff --git a/web/packages/accounts/components/VerifyMasterPasswordForm.tsx b/web/packages/accounts/components/VerifyMasterPasswordForm.tsx
index cbd474aa01..095034e3b5 100644
--- a/web/packages/accounts/components/VerifyMasterPasswordForm.tsx
+++ b/web/packages/accounts/components/VerifyMasterPasswordForm.tsx
@@ -1,11 +1,11 @@
import { Input, TextField } from "@mui/material";
import type { SRPAttributes } from "ente-accounts/services/srp-remote";
+import type { KeyAttributes, User } from "ente-accounts/services/user";
import { LoadingButton } from "ente-base/components/mui/LoadingButton";
import { ShowHidePasswordInputAdornment } from "ente-base/components/mui/PasswordInputAdornment";
import { sharedCryptoWorker } from "ente-base/crypto";
import log from "ente-base/log";
import { CustomError } from "ente-shared/error";
-import type { KeyAttributes, User } from "ente-shared/user/types";
import { useFormik } from "formik";
import { t } from "i18next";
import { useCallback, useState } from "react";
diff --git a/web/packages/accounts/pages/change-password.tsx b/web/packages/accounts/pages/change-password.tsx
index 4be2e58531..f977ba8bdc 100644
--- a/web/packages/accounts/pages/change-password.tsx
+++ b/web/packages/accounts/pages/change-password.tsx
@@ -18,7 +18,11 @@ import {
startSRPSetup,
updateSRPAndKeys,
} from "ente-accounts/services/srp-remote";
-import type { UpdatedKey } from "ente-accounts/services/user";
+import type {
+ KeyAttributes,
+ UpdatedKey,
+ User,
+} from "ente-accounts/services/user";
import { LinkButton } from "ente-base/components/LinkButton";
import { sharedCryptoWorker } from "ente-base/crypto";
import {
@@ -28,7 +32,6 @@ import {
} from "ente-shared/crypto/helpers";
import { getData, setData } from "ente-shared/storage/localStorage";
import { getActualKey } from "ente-shared/user";
-import type { KeyAttributes, User } from "ente-shared/user/types";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
diff --git a/web/packages/accounts/pages/credentials.tsx b/web/packages/accounts/pages/credentials.tsx
index 77f4c1feec..8f95ff9559 100644
--- a/web/packages/accounts/pages/credentials.tsx
+++ b/web/packages/accounts/pages/credentials.tsx
@@ -28,6 +28,7 @@ import {
} from "ente-accounts/services/srp";
import type { SRPAttributes } from "ente-accounts/services/srp-remote";
import { getSRPAttributes } from "ente-accounts/services/srp-remote";
+import type { KeyAttributes, User } from "ente-accounts/services/user";
import { LinkButton } from "ente-base/components/LinkButton";
import { LoadingIndicator } from "ente-base/components/loaders";
import { useBaseContext } from "ente-base/context";
@@ -49,7 +50,6 @@ import {
setIsFirstLogin,
} from "ente-shared/storage/localStorage/helpers";
import { getKey, removeKey, setKey } from "ente-shared/storage/sessionStorage";
-import type { KeyAttributes, User } from "ente-shared/user/types";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useCallback, useEffect, useState } from "react";
diff --git a/web/packages/accounts/pages/generate.tsx b/web/packages/accounts/pages/generate.tsx
index 0f72c562c0..ff3411b449 100644
--- a/web/packages/accounts/pages/generate.tsx
+++ b/web/packages/accounts/pages/generate.tsx
@@ -12,6 +12,7 @@ import {
configureSRP,
generateKeyAndSRPAttributes,
} from "ente-accounts/services/srp";
+import type { KeyAttributes, User } from "ente-accounts/services/user";
import { putUserKeyAttributes } from "ente-accounts/services/user";
import { LinkButton } from "ente-base/components/LinkButton";
import { LoadingIndicator } from "ente-base/components/loaders";
@@ -27,7 +28,6 @@ import {
setJustSignedUp,
} from "ente-shared/storage/localStorage/helpers";
import { getKey } from "ente-shared/storage/sessionStorage";
-import type { KeyAttributes, User } from "ente-shared/user/types";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
diff --git a/web/packages/accounts/pages/recover.tsx b/web/packages/accounts/pages/recover.tsx
index d5f0f55577..76db2cfcf5 100644
--- a/web/packages/accounts/pages/recover.tsx
+++ b/web/packages/accounts/pages/recover.tsx
@@ -5,6 +5,7 @@ import {
} from "ente-accounts/components/layouts/centered-paper";
import { recoveryKeyB64FromMnemonic } from "ente-accounts/services/recovery-key";
import { appHomeRoute, stashRedirect } from "ente-accounts/services/redirect";
+import type { KeyAttributes, User } from "ente-accounts/services/user";
import { sendOTT } from "ente-accounts/services/user";
import { LinkButton } from "ente-base/components/LinkButton";
import {
@@ -20,7 +21,6 @@ import {
} from "ente-shared/crypto/helpers";
import { getData, setData } from "ente-shared/storage/localStorage";
import { getKey } from "ente-shared/storage/sessionStorage";
-import type { KeyAttributes, User } from "ente-shared/user/types";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
diff --git a/web/packages/accounts/pages/two-factor/verify.tsx b/web/packages/accounts/pages/two-factor/verify.tsx
index 287f987c57..dd3a0ab90b 100644
--- a/web/packages/accounts/pages/two-factor/verify.tsx
+++ b/web/packages/accounts/pages/two-factor/verify.tsx
@@ -1,10 +1,10 @@
import { Verify2FACodeForm } from "ente-accounts/components/Verify2FACodeForm";
+import type { User } from "ente-accounts/services/user";
import { verifyTwoFactor } from "ente-accounts/services/user";
import { LinkButton } from "ente-base/components/LinkButton";
import { useBaseContext } from "ente-base/context";
import { HTTPError } from "ente-base/http";
import { getData, setData, setLSUser } from "ente-shared/storage/localStorage";
-import type { User } from "ente-shared/user/types";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
diff --git a/web/packages/accounts/pages/verify.tsx b/web/packages/accounts/pages/verify.tsx
index 82e7db2f6e..521ddbd95f 100644
--- a/web/packages/accounts/pages/verify.tsx
+++ b/web/packages/accounts/pages/verify.tsx
@@ -22,6 +22,7 @@ import type {
SRPSetupAttributes,
} from "ente-accounts/services/srp-remote";
import { getSRPAttributes } from "ente-accounts/services/srp-remote";
+import type { KeyAttributes, User } from "ente-accounts/services/user";
import {
putUserKeyAttributes,
sendOTT,
@@ -44,7 +45,6 @@ import {
getLocalReferralSource,
setIsFirstLogin,
} from "ente-shared/storage/localStorage/helpers";
-import type { KeyAttributes, User } from "ente-shared/user/types";
import { t } from "i18next";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";
diff --git a/web/packages/accounts/services/recovery-key.ts b/web/packages/accounts/services/recovery-key.ts
index dcb1011337..8db572d782 100644
--- a/web/packages/accounts/services/recovery-key.ts
+++ b/web/packages/accounts/services/recovery-key.ts
@@ -1,4 +1,5 @@
import * as bip39 from "bip39";
+import type { KeyAttributes } from "ente-accounts/services/user";
import {
decryptBoxB64,
fromHex,
@@ -7,7 +8,6 @@ import {
} from "ente-base/crypto";
import { masterKeyFromSession } from "ente-base/session";
import { getData, setData } from "ente-shared/storage/localStorage";
-import type { KeyAttributes } from "ente-shared/user/types";
import { putUserRecoveryKeyAttributes } from "./user";
// Mobile client library only supports English.
diff --git a/web/packages/accounts/services/session.ts b/web/packages/accounts/services/session.ts
index 65a8a7e44d..ac6263395d 100644
--- a/web/packages/accounts/services/session.ts
+++ b/web/packages/accounts/services/session.ts
@@ -1,9 +1,9 @@
+import type { KeyAttributes } from "ente-accounts/services/user";
import { authenticatedRequestHeaders, HTTPError } from "ente-base/http";
import { ensureLocalUser, getAuthToken } from "ente-base/local-user";
import log from "ente-base/log";
import { apiURL } from "ente-base/origins";
import { getData } from "ente-shared/storage/localStorage";
-import type { KeyAttributes } from "ente-shared/user/types";
import { nullToUndefined } from "ente-utils/transform";
import { z } from "zod/v4";
import type { SRPAttributes } from "./srp-remote";
diff --git a/web/packages/accounts/services/srp.ts b/web/packages/accounts/services/srp.ts
index 30face4208..1fe485a96a 100644
--- a/web/packages/accounts/services/srp.ts
+++ b/web/packages/accounts/services/srp.ts
@@ -1,8 +1,8 @@
+import type { KeyAttributes } from "ente-accounts/services/user";
import { sharedCryptoWorker } from "ente-base/crypto";
import log from "ente-base/log";
import { generateLoginSubKey } from "ente-shared/crypto/helpers";
import { getToken } from "ente-shared/storage/localStorage/helpers";
-import type { KeyAttributes } from "ente-shared/user/types";
import { SRP, SrpClient } from "fast-srp-hap";
import { v4 as uuidv4 } from "uuid";
import {
diff --git a/web/packages/accounts/services/user.ts b/web/packages/accounts/services/user.ts
index 0577996a81..3495979bbc 100644
--- a/web/packages/accounts/services/user.ts
+++ b/web/packages/accounts/services/user.ts
@@ -6,10 +6,163 @@ import {
import { apiURL } from "ente-base/origins";
import HTTPService from "ente-shared/network/HTTPService";
import { getToken } from "ente-shared/storage/localStorage/helpers";
-import type { KeyAttributes } from "ente-shared/user/types";
import { nullToUndefined } from "ente-utils/transform";
import { z } from "zod/v4";
+export interface User {
+ id: number;
+ email: string;
+ token: string;
+ encryptedToken: string;
+ isTwoFactorEnabled: boolean;
+ twoFactorSessionID: string;
+}
+
+/**
+ * The user's various encrypted keys and their related attributes.
+ *
+ * - Attributes to derive the KEK, the (master) key encryption key.
+ * - Encrypted master key (with KEK)
+ * - Encrypted master key (with recovery key)
+ * - Encrypted recovery key (with master key).
+ * - Public key and encrypted private key (with master key).
+ *
+ * The various "key" attributes are base64 encoded representations of the
+ * underlying binary data.
+ */
+export interface KeyAttributes {
+ /**
+ * The user's master key encrypted with the key encryption key.
+ *
+ * Base 64 encoded.
+ *
+ * [Note: Key encryption key]
+ *
+ * The user's master key is encrypted with a "key encryption key" (lovingly
+ * called a "kek" sometimes).
+ *
+ * The kek itself is derived from the user's passphrase.
+ *
+ * 1. User enters passphrase on new device.
+ *
+ * 2. Client derives kek from this passphrase (using the {@link kekSalt},
+ * {@link opsLimit} and {@link memLimit} as parameters for the
+ * derivation).
+ *
+ * 3. Client use kek to decrypt the master key from {@link encryptedKey} and
+ * {@link keyDecryptionNonce}.
+ */
+ encryptedKey: string;
+ /**
+ * The nonce used during the encryption of the master key.
+ *
+ * Base 64 encoded.
+ *
+ * @see {@link encryptedKey}.
+ */
+ keyDecryptionNonce: string;
+ /**
+ * The salt used during the derivation of the kek.
+ *
+ * Base 64 encoded.
+ *
+ * See: [Note: Key encryption key].
+ */
+ kekSalt: string;
+ /**
+ * The operation limit used during the derivation of the kek.
+ *
+ * The {@link opsLimit} and {@link memLimit} are complementary parameters
+ * that define the amount of work done by the key derivation function. See
+ * the {@link deriveKey}, {@link deriveSensitiveKey} and
+ * {@link deriveInteractiveKey} functions for more detail about them.
+ *
+ * See: [Note: Key encryption key].
+ */
+ opsLimit: number;
+ /**
+ * The memory limit used during the derivation of the kek.
+ *
+ * See {@link opsLimit} for more details.
+ */
+ memLimit: number;
+ /**
+ * The user's public key (part of their public-key keypair, the other half
+ * being the {@link encryptedSecretKey}).
+ *
+ * Base 64 encoded.
+ */
+ publicKey: string;
+ /**
+ * The user's private key (part of their public-key keypair, the other half
+ * being the {@link publicKey}) encrypted with their master key.
+ *
+ * Base 64 encoded.
+ */
+ encryptedSecretKey: string;
+ /**
+ * The nonce used during the encryption of {@link encryptedSecretKey}.
+ */
+ secretKeyDecryptionNonce: string;
+ /**
+ * The user's master key after being encrypted with their recovery key.
+ *
+ * Base 64 encoded.
+ *
+ * This allows the user to recover their master key if they forget their
+ * passphrase but still have their recovery key.
+ *
+ * Note: This value doesn't change after being initially created.
+ */
+ masterKeyEncryptedWithRecoveryKey?: string;
+ /**
+ * The nonce used during the encryption of
+ * {@link masterKeyEncryptedWithRecoveryKey}.
+ *
+ * Base 64 encoded.
+ */
+ masterKeyDecryptionNonce?: string;
+ /**
+ * The user's recovery key after being encrypted with their master key.
+ *
+ * Base 64 encoded.
+ *
+ * Note: This value doesn't change after being initially created.
+ */
+ recoveryKeyEncryptedWithMasterKey?: string;
+ /**
+ * The nonce used during the encryption of
+ * {@link recoveryKeyEncryptedWithMasterKey}.
+ *
+ * Base 64 encoded.
+ */
+ recoveryKeyDecryptionNonce?: string;
+}
+
+/**
+ * Zod schema for {@link KeyAttributes}.
+ */
+export const RemoteKeyAttributes = z.object({
+ kekSalt: z.string(),
+ encryptedKey: z.string(),
+ keyDecryptionNonce: z.string(),
+ publicKey: z.string(),
+ encryptedSecretKey: z.string(),
+ secretKeyDecryptionNonce: z.string(),
+ memLimit: z.number(),
+ opsLimit: z.number(),
+ masterKeyEncryptedWithRecoveryKey: z
+ .string()
+ .nullish()
+ .transform(nullToUndefined),
+ masterKeyDecryptionNonce: z.string().nullish().transform(nullToUndefined),
+ recoveryKeyEncryptedWithMasterKey: z
+ .string()
+ .nullish()
+ .transform(nullToUndefined),
+ recoveryKeyDecryptionNonce: z.string().nullish().transform(nullToUndefined),
+});
+
export interface UserVerificationResponse {
id: number;
keyAttributes?: KeyAttributes | undefined;
@@ -117,30 +270,6 @@ export const verifyEmail = async (
return EmailOrSRPAuthorizationResponse.parse(await res.json());
};
-/**
- * Zod schema for {@link KeyAttributes}.
- */
-export const RemoteKeyAttributes = z.object({
- kekSalt: z.string(),
- encryptedKey: z.string(),
- keyDecryptionNonce: z.string(),
- publicKey: z.string(),
- encryptedSecretKey: z.string(),
- secretKeyDecryptionNonce: z.string(),
- memLimit: z.number(),
- opsLimit: z.number(),
- masterKeyEncryptedWithRecoveryKey: z
- .string()
- .nullish()
- .transform(nullToUndefined),
- masterKeyDecryptionNonce: z.string().nullish().transform(nullToUndefined),
- recoveryKeyEncryptedWithMasterKey: z
- .string()
- .nullish()
- .transform(nullToUndefined),
- recoveryKeyDecryptionNonce: z.string().nullish().transform(nullToUndefined),
-});
-
/**
* Zod schema for response from remote on a successful user verification, either
* via {@link verifyEmail} or {@link verifySRPSession}.
diff --git a/web/packages/new/photos/components/gallery/helpers.ts b/web/packages/new/photos/components/gallery/helpers.ts
index 81596bf6ef..226badae81 100644
--- a/web/packages/new/photos/components/gallery/helpers.ts
+++ b/web/packages/new/photos/components/gallery/helpers.ts
@@ -11,10 +11,10 @@
*/
import { getUserRecoveryKeyB64 } from "ente-accounts/services/recovery-key";
+import type { User } from "ente-accounts/services/user";
import log from "ente-base/log";
import type { Collection } from "ente-media/collection";
import type { FamilyData } from "ente-new/photos/services/user-details";
-import type { User } from "ente-shared/user/types";
/**
* Ensure that the keys in local storage are not malformed by verifying that the
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index c3464c7bf7..80a12f7482 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -1,3 +1,4 @@
+import type { User } from "ente-accounts/services/user";
import {
isArchivedCollection,
isPinnedCollection,
@@ -10,7 +11,6 @@ import {
createCollectionNameByID,
isHiddenCollection,
} from "ente-new/photos/services/collection";
-import type { User } from "ente-shared/user/types";
import { splitByPredicate } from "ente-utils/array";
import { t } from "i18next";
import React, { useReducer } from "react";
diff --git a/web/packages/new/photos/services/collection.ts b/web/packages/new/photos/services/collection.ts
index 25aca079b0..b4d4fbeb1f 100644
--- a/web/packages/new/photos/services/collection.ts
+++ b/web/packages/new/photos/services/collection.ts
@@ -1,10 +1,10 @@
+import type { User } from "ente-accounts/services/user";
import { encryptBoxB64 } from "ente-base/crypto";
import { authenticatedRequestHeaders, ensureOk } from "ente-base/http";
import { apiURL } from "ente-base/origins";
import { CollectionSubType, type Collection } from "ente-media/collection";
import { type EnteFile } from "ente-media/file";
import { ItemVisibility } from "ente-media/file-metadata";
-import type { User } from "ente-shared/user/types";
import { batch } from "ente-utils/array";
/**
diff --git a/web/packages/new/photos/services/export-migration.ts b/web/packages/new/photos/services/export-migration.ts
index 2dc6823a64..99fb6630c0 100644
--- a/web/packages/new/photos/services/export-migration.ts
+++ b/web/packages/new/photos/services/export-migration.ts
@@ -3,6 +3,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
+import type { User } from "ente-accounts/services/user";
import { ensureElectron } from "ente-base/electron";
import { joinPath, nameAndExtension } from "ente-base/file-name";
import log from "ente-base/log";
@@ -20,7 +21,6 @@ import {
sanitizeFilename,
} from "ente-new/photos/utils/native-fs";
import { getData } from "ente-shared/storage/localStorage";
-import type { User } from "ente-shared/user/types";
import { wait } from "ente-utils/promise";
import exportService, {
getCollectionIDFromFileUID,
diff --git a/web/packages/shared/crypto/helpers.ts b/web/packages/shared/crypto/helpers.ts
index 7cb9a5a1c8..15b4a631bd 100644
--- a/web/packages/shared/crypto/helpers.ts
+++ b/web/packages/shared/crypto/helpers.ts
@@ -1,8 +1,8 @@
+import type { KeyAttributes } from "ente-accounts/services/user";
import { sharedCryptoWorker } from "ente-base/crypto";
import { masterKeyFromSession } from "ente-base/session";
import { getData, setData, setLSUser } from "ente-shared/storage/localStorage";
import { type SessionKey, setKey } from "ente-shared/storage/sessionStorage";
-import type { KeyAttributes } from "ente-shared/user/types";
const LOGIN_SUB_KEY_LENGTH = 32;
const LOGIN_SUB_KEY_ID = 1;
diff --git a/web/packages/shared/user/types.ts b/web/packages/shared/user/types.ts
deleted file mode 100644
index c0b665a935..0000000000
--- a/web/packages/shared/user/types.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * The user's various encrypted keys and their related attributes.
- *
- * - Attributes to derive the KEK, the (master) key encryption key.
- * - Encrypted master key (with KEK)
- * - Encrypted master key (with recovery key)
- * - Encrypted recovery key (with master key).
- * - Public key and encrypted private key (with master key).
- *
- * The various "key" attributes are base64 encoded representations of the
- * underlying binary data.
- */
-export interface KeyAttributes {
- /**
- * The user's master key encrypted with the key encryption key.
- *
- * Base 64 encoded.
- *
- * [Note: Key encryption key]
- *
- * The user's master key is encrypted with a "key encryption key" (lovingly
- * called a "kek" sometimes).
- *
- * The kek itself is derived from the user's passphrase.
- *
- * 1. User enters passphrase on new device.
- *
- * 2. Client derives kek from this passphrase (using the {@link kekSalt},
- * {@link opsLimit} and {@link memLimit} as parameters for the
- * derivation).
- *
- * 3. Client use kek to decrypt the master key from {@link encryptedKey} and
- * {@link keyDecryptionNonce}.
- */
- encryptedKey: string;
- /**
- * The nonce used during the encryption of the master key.
- *
- * Base 64 encoded.
- *
- * @see {@link encryptedKey}.
- */
- keyDecryptionNonce: string;
- /**
- * The salt used during the derivation of the kek.
- *
- * Base 64 encoded.
- *
- * See: [Note: Key encryption key].
- */
- kekSalt: string;
- /**
- * The operation limit used during the derivation of the kek.
- *
- * The {@link opsLimit} and {@link memLimit} are complementary parameters
- * that define the amount of work done by the key derivation function. See
- * the {@link deriveKey}, {@link deriveSensitiveKey} and
- * {@link deriveInteractiveKey} functions for more detail about them.
- *
- * See: [Note: Key encryption key].
- */
- opsLimit: number;
- /**
- * The memory limit used during the derivation of the kek.
- *
- * See {@link opsLimit} for more details.
- */
- memLimit: number;
- /**
- * The user's public key (part of their public-key keypair, the other half
- * being the {@link encryptedSecretKey}).
- *
- * Base 64 encoded.
- */
- publicKey: string;
- /**
- * The user's private key (part of their public-key keypair, the other half
- * being the {@link publicKey}) encrypted with their master key.
- *
- * Base 64 encoded.
- */
- encryptedSecretKey: string;
- /**
- * The nonce used during the encryption of {@link encryptedSecretKey}.
- */
- secretKeyDecryptionNonce: string;
- /**
- * The user's master key after being encrypted with their recovery key.
- *
- * Base 64 encoded.
- *
- * This allows the user to recover their master key if they forget their
- * passphrase but still have their recovery key.
- *
- * Note: This value doesn't change after being initially created.
- */
- masterKeyEncryptedWithRecoveryKey?: string;
- /**
- * The nonce used during the encryption of
- * {@link masterKeyEncryptedWithRecoveryKey}.
- *
- * Base 64 encoded.
- */
- masterKeyDecryptionNonce?: string;
- /**
- * The user's recovery key after being encrypted with their master key.
- *
- * Base 64 encoded.
- *
- * Note: This value doesn't change after being initially created.
- */
- recoveryKeyEncryptedWithMasterKey?: string;
- /**
- * The nonce used during the encryption of
- * {@link recoveryKeyEncryptedWithMasterKey}.
- *
- * Base 64 encoded.
- */
- recoveryKeyDecryptionNonce?: string;
-}
-
-export interface User {
- id: number;
- email: string;
- token: string;
- encryptedToken: string;
- isTwoFactorEnabled: boolean;
- twoFactorSessionID: string;
-}