mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 04:21:13 +10:00
* feat(EE): MFA implementation for enterprise edition - Add TOTP-based two-factor authentication - Add backup codes support - Add MFA enforcement at workspace level - Add MFA setup and challenge UI pages - Support MFA for login and password reset flows - Add MFA validation for secure pages * fix types * remove unused object * sync * remove unused type * sync * refactor: rename MFA enabled field to is_enabled * sync
62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
import api from "@/lib/api-client";
|
|
import {
|
|
MfaBackupCodesResponse,
|
|
MfaDisableRequest,
|
|
MfaEnableRequest,
|
|
MfaEnableResponse,
|
|
MfaSetupRequest,
|
|
MfaSetupResponse,
|
|
MfaStatusResponse,
|
|
MfaAccessValidationResponse,
|
|
} from "@/ee/mfa";
|
|
|
|
export async function getMfaStatus(): Promise<MfaStatusResponse> {
|
|
const req = await api.post("/mfa/status");
|
|
return req.data;
|
|
}
|
|
|
|
export async function setupMfa(
|
|
data: MfaSetupRequest,
|
|
): Promise<MfaSetupResponse> {
|
|
const req = await api.post<MfaSetupResponse>("/mfa/setup", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function enableMfa(
|
|
data: MfaEnableRequest,
|
|
): Promise<MfaEnableResponse> {
|
|
const req = await api.post<MfaEnableResponse>("/mfa/enable", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function disableMfa(
|
|
data: MfaDisableRequest,
|
|
): Promise<{ success: boolean }> {
|
|
const req = await api.post<{ success: boolean }>("/mfa/disable", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function regenerateBackupCodes(data: {
|
|
confirmPassword: string;
|
|
}): Promise<MfaBackupCodesResponse> {
|
|
const req = await api.post<MfaBackupCodesResponse>(
|
|
"/mfa/generate-backup-codes",
|
|
data,
|
|
);
|
|
return req.data;
|
|
}
|
|
|
|
export async function verifyMfa(code: string): Promise<any> {
|
|
const req = await api.post("/mfa/verify", { code });
|
|
return req.data;
|
|
}
|
|
|
|
export async function validateMfaAccess(): Promise<MfaAccessValidationResponse> {
|
|
try {
|
|
const res = await api.post("/mfa/validate-access");
|
|
return res.data;
|
|
} catch {
|
|
return { valid: false };
|
|
}
|
|
}
|