fix: Math.random -> crypto.randomBytes

closes #2818
This commit is contained in:
Tom Moor
2021-12-05 18:42:03 -08:00
parent d9cb40ae84
commit ce2a58e83b

View File

@@ -1,3 +1,4 @@
import crypto from "crypto";
import { addMinutes, subMinutes } from "date-fns";
import fetch from "fetch-with-proxy";
import { Request } from "koa";
@@ -8,8 +9,8 @@ export class StateStore {
key = "state";
store = (req: Request, callback: () => void) => {
// Produce an 8-character random string as state
const state = Math.random().toString(36).slice(-8);
// Produce a random string as state
const state = crypto.randomBytes(8).toString("hex");
// @ts-expect-error ts-migrate(2339) FIXME: Property 'cookies' does not exist on type 'Request... Remove this comment to see the full error message
req.cookies.set(this.key, state, {