Merge pull request #505 from mchangrh/tokenValidateRegex

add fast fails for local and gumroad license keys
This commit is contained in:
Ajay Ramachandran
2022-09-24 21:09:16 -04:00
committed by GitHub

View File

@@ -18,6 +18,12 @@ export async function verifyTokenRequest(req: VerifyTokenRequest, res: Response)
if (!licenseKey) {
return res.status(400).send("Invalid request");
}
const licenseRegex = new RegExp(/[a-zA-Z0-9]{40}|[A-Z0-9-]{35}/);
if (!licenseRegex.test(licenseKey)) {
return res.status(200).send({
allowed: false
});
}
const tokens = (await privateDB.prepare("get", `SELECT "accessToken", "refreshToken", "expiresIn" from "oauthLicenseKeys" WHERE "licenseKey" = ?`
, [licenseKey])) as {accessToken: string, refreshToken: string, expiresIn: number};