Skip to content

Commit 0b950fe

Browse files
committed
security changes
1 parent da84c10 commit 0b950fe

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/api/users.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,12 @@ export async function handlerUsersGet(req: Request, res: Response, user: User) {
3333
respondWithJSON(res, 200, user);
3434
}
3535

36-
function generateRandomSHA256Hash(): string {
36+
function generateRandomSHA256Hash(encoding: string = "hex"): string {
37+
if (!["base64", "base64url", "hex", "binary"].includes(encoding)) {
38+
throw new Error("Invalid encoding");
39+
}
3740
return crypto
3841
.createHash("sha256")
3942
.update(crypto.randomBytes(32))
40-
.digest("hex");
41-
}
42-
43-
// notely-dev-1: is this still used?
44-
export function isValidEmail(email: string): boolean {
45-
const emailExpression =
46-
/^([a-zA-Z0-9_])+(([a-zA-Z0-9])+)+([a-zA-Z0-9]{2,4})+$/;
47-
48-
return emailExpression.test(email);
43+
.digest(eval("encoding"));
4944
}

0 commit comments

Comments
 (0)