jsonwebtoken: Allow audience to be verified with regular expressions

See https://github.com/auth0/node-jsonwebtoken/pull/398
This commit is contained in:
Andrew Haines
2019-02-27 17:39:51 +00:00
parent abe95f396c
commit 9f6f861222
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ export interface SignOptions {
export interface VerifyOptions {
algorithms?: string[];
audience?: string | string[];
audience?: string | RegExp | Array<string | RegExp>;
clockTimestamp?: number;
clockTolerance?: number;
issuer?: string | string[];
+6
View File
@@ -101,6 +101,12 @@ cert = fs.readFileSync("public.pem"); // get public key
jwt.verify(token, cert, { audience: "urn:foo" }, (err, decoded) => {
// if audience mismatch, err == invalid audience
});
jwt.verify(token, cert, { audience: /urn:f[o]{2}/ }, (err, decoded) => {
// if audience mismatch, err == invalid audience
});
jwt.verify(token, cert, { audience: [/urn:f[o]{2}/, "urn:bar"] }, (err, decoded) => {
// if audience mismatch, err == invalid audience
});
// verify issuer
cert = fs.readFileSync("public.pem"); // get public key