mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
jsonwebtoken: Allow audience to be verified with regular expressions
See https://github.com/auth0/node-jsonwebtoken/pull/398
This commit is contained in:
parent
abe95f396c
commit
9f6f861222
2
types/jsonwebtoken/index.d.ts
vendored
2
types/jsonwebtoken/index.d.ts
vendored
@ -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[];
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user