summary refs log tree commit diff
path: root/src/api/routes/users/@me/mfa
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 22:08:14 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 22:08:14 +1000
commit1f416b972c6aa0cd4fc43a5790da56f8da21e82c (patch)
tree8222a04cc63c595bc8b236ceeec89ed2fc2b7580 /src/api/routes/users/@me/mfa
parentFix scripts/benchmark/connections.js (diff)
downloadserver-1f416b972c6aa0cd4fc43a5790da56f8da21e82c.tar.xz
Move schemas to /src/util/schemas
Diffstat (limited to 'src/api/routes/users/@me/mfa')
-rw-r--r--src/api/routes/users/@me/mfa/codes-verification.ts8
-rw-r--r--src/api/routes/users/@me/mfa/codes.ts7
-rw-r--r--src/api/routes/users/@me/mfa/totp/disable.ts6
-rw-r--r--src/api/routes/users/@me/mfa/totp/enable.ts9
4 files changed, 4 insertions, 26 deletions
diff --git a/src/api/routes/users/@me/mfa/codes-verification.ts b/src/api/routes/users/@me/mfa/codes-verification.ts
index 09000d07..071c71fa 100644
--- a/src/api/routes/users/@me/mfa/codes-verification.ts
+++ b/src/api/routes/users/@me/mfa/codes-verification.ts
@@ -1,15 +1,9 @@
 import { Router, Request, Response } from "express";
 import { route } from "@fosscord/api";
-import { BackupCode, generateMfaBackupCodes, User } from "@fosscord/util";
+import { BackupCode, generateMfaBackupCodes, User, CodesVerificationSchema } from "@fosscord/util";
 
 const router = Router();
 
-export interface CodesVerificationSchema {
-	key: string;
-	nonce: string;
-	regenerate?: boolean;
-}
-
 router.post("/", route({ body: "CodesVerificationSchema" }), async (req: Request, res: Response) => {
 	const { key, nonce, regenerate } = req.body as CodesVerificationSchema;
 
diff --git a/src/api/routes/users/@me/mfa/codes.ts b/src/api/routes/users/@me/mfa/codes.ts
index 67bd3d5b..58466b9c 100644
--- a/src/api/routes/users/@me/mfa/codes.ts
+++ b/src/api/routes/users/@me/mfa/codes.ts
@@ -1,15 +1,10 @@
 import { Router, Request, Response } from "express";
 import { route } from "@fosscord/api";
-import { BackupCode, FieldErrors, generateMfaBackupCodes, User } from "@fosscord/util";
+import { BackupCode, FieldErrors, generateMfaBackupCodes, User, MfaCodesSchema } from "@fosscord/util";
 import bcrypt from "bcrypt";
 
 const router = Router();
 
-export interface MfaCodesSchema {
-	password: string;
-	regenerate?: boolean;
-}
-
 // TODO: This route is replaced with users/@me/mfa/codes-verification in newer clients
 
 router.post("/", route({ body: "MfaCodesSchema" }), async (req: Request, res: Response) => {
diff --git a/src/api/routes/users/@me/mfa/totp/disable.ts b/src/api/routes/users/@me/mfa/totp/disable.ts
index 2d385fda..2fe9355c 100644
--- a/src/api/routes/users/@me/mfa/totp/disable.ts
+++ b/src/api/routes/users/@me/mfa/totp/disable.ts
@@ -2,14 +2,10 @@ import { Router, Request, Response } from "express";
 import { route } from "@fosscord/api";
 import { verifyToken } from 'node-2fa';
 import { HTTPError } from "lambert-server";
-import { User, generateToken, BackupCode } from "@fosscord/util";
+import { User, generateToken, BackupCode, TotpDisableSchema } from "@fosscord/util";
 
 const router = Router();
 
-export interface TotpDisableSchema {
-	code: string;
-}
-
 router.post("/", route({ body: "TotpDisableSchema" }), async (req: Request, res: Response) => {
 	const body = req.body as TotpDisableSchema;
 
diff --git a/src/api/routes/users/@me/mfa/totp/enable.ts b/src/api/routes/users/@me/mfa/totp/enable.ts
index e4ce9ce0..adafe180 100644
--- a/src/api/routes/users/@me/mfa/totp/enable.ts
+++ b/src/api/routes/users/@me/mfa/totp/enable.ts
@@ -1,19 +1,12 @@
 import { Router, Request, Response } from "express";
-import { User, generateToken, BackupCode, generateMfaBackupCodes } from "@fosscord/util";
+import { User, generateToken, generateMfaBackupCodes, TotpEnableSchema } from "@fosscord/util";
 import { route } from "@fosscord/api";
 import bcrypt from "bcrypt";
 import { HTTPError } from "lambert-server";
 import { verifyToken } from 'node-2fa';
-import crypto from "crypto";
 
 const router = Router();
 
-export interface TotpEnableSchema {
-	password: string;
-	code?: string;
-	secret?: string;
-}
-
 router.post("/", route({ body: "TotpEnableSchema" }), async (req: Request, res: Response) => {
 	const body = req.body as TotpEnableSchema;