This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ async function verifying(publicKey, alg, signature, data) {
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
}
function pemToBinary(pem) {
return decodeBase64(pem.replace(/-+(BEGIN|END).*/g, "").replace(/\s/g, ""));
return decodeBase64(pem.replace(/-+(BEGIN|END).*?-+/g, "").replace(/\s/g, ""));
}
async function importPrivateKey(key, alg) {
if (!crypto.subtle || !crypto.subtle.importKey) {
+12 -6
View File
@@ -70,14 +70,20 @@ var verify = async (token, publicKey, algOrOptions) => {
throw new JwtAlgorithmMismatch(alg, header.alg);
}
const now = Math.floor(Date.now() / 1e3);
if (nbf && payload.nbf && payload.nbf > now) {
throw new JwtTokenNotBefore(token);
if (nbf && payload.nbf !== void 0) {
if (typeof payload.nbf !== "number" || !Number.isFinite(payload.nbf) || payload.nbf > now) {
throw new JwtTokenNotBefore(token);
}
}
if (exp && payload.exp && payload.exp <= now) {
throw new JwtTokenExpired(token);
if (exp && payload.exp !== void 0) {
if (typeof payload.exp !== "number" || !Number.isFinite(payload.exp) || payload.exp <= now) {
throw new JwtTokenExpired(token);
}
}
if (iat && payload.iat && now < payload.iat) {
throw new JwtTokenIssuedAt(now, payload.iat);
if (iat && payload.iat !== void 0) {
if (typeof payload.iat !== "number" || !Number.isFinite(payload.iat) || now < payload.iat) {
throw new JwtTokenIssuedAt(now, payload.iat);
}
}
if (iss) {
if (!payload.iss) {