Move
This commit is contained in:
@@ -3,18 +3,74 @@ import { apiURL } from "@/base/origins";
|
||||
import { ApiError, CustomError } from "@ente/shared/error";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import { HttpStatusCode } from "axios";
|
||||
import type {
|
||||
CompleteSRPSetupRequest,
|
||||
CompleteSRPSetupResponse,
|
||||
CreateSRPSessionResponse,
|
||||
GetSRPAttributesResponse,
|
||||
SRPAttributes,
|
||||
SRPVerificationResponse,
|
||||
SetupSRPRequest,
|
||||
SetupSRPResponse,
|
||||
UpdateSRPAndKeysRequest,
|
||||
UpdateSRPAndKeysResponse,
|
||||
} from "../types/srp";
|
||||
import type { UpdatedKey, UserVerificationResponse } from "../types/user";
|
||||
|
||||
export interface SRPAttributes {
|
||||
srpUserID: string;
|
||||
srpSalt: string;
|
||||
memLimit: number;
|
||||
opsLimit: number;
|
||||
kekSalt: string;
|
||||
isEmailMFAEnabled: boolean;
|
||||
}
|
||||
|
||||
export interface GetSRPAttributesResponse {
|
||||
attributes: SRPAttributes;
|
||||
}
|
||||
|
||||
export interface SRPSetupAttributes {
|
||||
srpSalt: string;
|
||||
srpVerifier: string;
|
||||
srpUserID: string;
|
||||
loginSubKey: string;
|
||||
}
|
||||
|
||||
export interface SetupSRPRequest {
|
||||
srpUserID: string;
|
||||
srpSalt: string;
|
||||
srpVerifier: string;
|
||||
srpA: string;
|
||||
}
|
||||
|
||||
export interface SetupSRPResponse {
|
||||
setupID: string;
|
||||
srpB: string;
|
||||
}
|
||||
|
||||
export interface CompleteSRPSetupRequest {
|
||||
setupID: string;
|
||||
srpM1: string;
|
||||
}
|
||||
|
||||
export interface CompleteSRPSetupResponse {
|
||||
setupID: string;
|
||||
srpM2: string;
|
||||
}
|
||||
|
||||
export interface CreateSRPSessionResponse {
|
||||
sessionID: string;
|
||||
srpB: string;
|
||||
}
|
||||
|
||||
export interface SRPVerificationResponse extends UserVerificationResponse {
|
||||
srpM2: string;
|
||||
}
|
||||
|
||||
export interface UpdateSRPAndKeysRequest {
|
||||
srpM1: string;
|
||||
setupID: string;
|
||||
updatedKeyAttr: UpdatedKey;
|
||||
/**
|
||||
* If true (default), then all existing sessions for the user will be
|
||||
* invalidated.
|
||||
*/
|
||||
logOutOtherDevices?: boolean;
|
||||
}
|
||||
|
||||
export interface UpdateSRPAndKeysResponse {
|
||||
srpM2: string;
|
||||
setupID: string;
|
||||
}
|
||||
|
||||
export const getSRPAttributes = async (
|
||||
email: string,
|
||||
|
||||
@@ -39,6 +39,7 @@ import { Stack } from "@mui/material";
|
||||
import { t } from "i18next";
|
||||
import { useRouter } from "next/router";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import type { SRPAttributes } from "../api/srp";
|
||||
import { getSRPAttributes } from "../api/srp";
|
||||
import {
|
||||
LoginFlowFormFooter,
|
||||
@@ -63,7 +64,6 @@ import {
|
||||
loginViaSRP,
|
||||
} from "../services/srp";
|
||||
import type { PageProps } from "../types/page";
|
||||
import type { SRPAttributes } from "../types/srp";
|
||||
|
||||
const Page: React.FC<PageProps> = ({ appContext }) => {
|
||||
const { logout, showNavBar, showMiniDialog } = appContext;
|
||||
|
||||
@@ -29,6 +29,7 @@ import { t } from "i18next";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Trans } from "react-i18next";
|
||||
import type { SRPAttributes, SRPSetupAttributes } from "../api/srp";
|
||||
import { getSRPAttributes } from "../api/srp";
|
||||
import { putAttributes, sendOtt, verifyOtt } from "../api/user";
|
||||
import {
|
||||
@@ -43,7 +44,6 @@ import {
|
||||
import { stashedRedirect, unstashRedirect } from "../services/redirect";
|
||||
import { configureSRP } from "../services/srp";
|
||||
import type { PageProps } from "../types/page";
|
||||
import type { SRPAttributes, SRPSetupAttributes } from "../types/srp";
|
||||
|
||||
const Page: React.FC<PageProps> = ({ appContext }) => {
|
||||
const { logout, showNavBar, showMiniDialog } = appContext;
|
||||
|
||||
@@ -4,8 +4,8 @@ import { apiURL } from "@/base/origins";
|
||||
import { ensure } from "@/utils/ensure";
|
||||
import { getData, LS_KEYS } from "@ente/shared/storage/localStorage";
|
||||
import type { KeyAttributes } from "@ente/shared/user/types";
|
||||
import type { SRPAttributes } from "../api/srp";
|
||||
import { getSRPAttributes } from "../api/srp";
|
||||
import type { SRPAttributes } from "../types/srp";
|
||||
|
||||
type SessionValidity =
|
||||
| { status: "invalid" }
|
||||
|
||||
@@ -5,13 +5,13 @@ import { generateLoginSubKey } from "@ente/shared/crypto/helpers";
|
||||
import { getToken } from "@ente/shared/storage/localStorage/helpers";
|
||||
import { SRP, SrpClient } from "fast-srp-hap";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import type { SRPAttributes, SRPSetupAttributes } from "../api/srp";
|
||||
import {
|
||||
completeSRPSetup,
|
||||
createSRPSession,
|
||||
startSRPSetup,
|
||||
verifySRPSession,
|
||||
} from "../api/srp";
|
||||
import type { SRPAttributes, SRPSetupAttributes } from "../types/srp";
|
||||
import { convertBase64ToBuffer, convertBufferToBase64 } from "../utils";
|
||||
|
||||
const SRP_PARAMS = SRP.params["4096"];
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
import type { UpdatedKey, UserVerificationResponse } from "./user";
|
||||
|
||||
export interface SRPAttributes {
|
||||
srpUserID: string;
|
||||
srpSalt: string;
|
||||
memLimit: number;
|
||||
opsLimit: number;
|
||||
kekSalt: string;
|
||||
isEmailMFAEnabled: boolean;
|
||||
}
|
||||
|
||||
export interface GetSRPAttributesResponse {
|
||||
attributes: SRPAttributes;
|
||||
}
|
||||
|
||||
export interface SRPSetupAttributes {
|
||||
srpSalt: string;
|
||||
srpVerifier: string;
|
||||
srpUserID: string;
|
||||
loginSubKey: string;
|
||||
}
|
||||
|
||||
export interface SetupSRPRequest {
|
||||
srpUserID: string;
|
||||
srpSalt: string;
|
||||
srpVerifier: string;
|
||||
srpA: string;
|
||||
}
|
||||
|
||||
export interface SetupSRPResponse {
|
||||
setupID: string;
|
||||
srpB: string;
|
||||
}
|
||||
|
||||
export interface CompleteSRPSetupRequest {
|
||||
setupID: string;
|
||||
srpM1: string;
|
||||
}
|
||||
|
||||
export interface CompleteSRPSetupResponse {
|
||||
setupID: string;
|
||||
srpM2: string;
|
||||
}
|
||||
|
||||
export interface CreateSRPSessionResponse {
|
||||
sessionID: string;
|
||||
srpB: string;
|
||||
}
|
||||
|
||||
export interface SRPVerificationResponse extends UserVerificationResponse {
|
||||
srpM2: string;
|
||||
}
|
||||
|
||||
export interface UpdateSRPAndKeysRequest {
|
||||
srpM1: string;
|
||||
setupID: string;
|
||||
updatedKeyAttr: UpdatedKey;
|
||||
/**
|
||||
* If true (default), then all existing sessions for the user will be
|
||||
* invalidated.
|
||||
*/
|
||||
logOutOtherDevices?: boolean;
|
||||
}
|
||||
|
||||
export interface UpdateSRPAndKeysResponse {
|
||||
srpM2: string;
|
||||
setupID: string;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { sharedCryptoWorker } from "@/base/crypto";
|
||||
import { generateLoginSubKey } from "@ente/shared/crypto/helpers";
|
||||
import type { KeyAttributes } from "@ente/shared/user/types";
|
||||
import type { SRPSetupAttributes } from "../api/srp";
|
||||
import { generateSRPSetupAttributes } from "../services/srp";
|
||||
import type { SRPSetupAttributes } from "../types/srp";
|
||||
|
||||
export async function generateKeyAndSRPAttributes(passphrase: string): Promise<{
|
||||
keyAttributes: KeyAttributes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SRPAttributes } from "@/accounts/types/srp";
|
||||
import type { SRPAttributes } from "@/accounts/api/srp";
|
||||
import { sharedCryptoWorker } from "@/base/crypto";
|
||||
import log from "@/base/log";
|
||||
import { Input, type ButtonProps } from "@mui/material";
|
||||
|
||||
Reference in New Issue
Block a user