Skip to content

Commit 6efca20

Browse files
committed
security check
1 parent 49a4ac8 commit 6efca20

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/api/users.ts

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

36-
function generateRandomSHA256Hash(encoding: string = "hex"): string {
37-
if (!["base64", "base64url", "hex", "binary"].includes(encoding)) {
38-
throw new Error("Invalid encoding");
39-
}
36+
function generateRandomSHA256Hash(): string {
37+
// should we be using crypto.randomBytes instead of crypto.pseudoRandomBytes?
4038
return crypto
4139
.createHash("sha256")
42-
.update(crypto.randomBytes(32))
43-
.digest(eval("encoding"));
40+
.update(crypto.pseudoRandomBytes(32))
41+
.digest("hex");
4442
}

0 commit comments

Comments
 (0)