Documents for @litert/jwt / Validators/Audience / JwtAudienceValidator
Class: JwtAudienceValidator
Defined in: src/lib/Validators/Audience.ts:71
The validator to check if the aud claim is allowed.
Example
ts
import * as LibJwt from '@litert/jwt';
const info = LibJwt.parse(token);
const validator = new LibJwt.JwtAudienceValidator({
allowlist: [
'trusted-audience',
/^https://trusted\.domain/.+$/,
(aud: string) => aud.endsWith('@trusted.com'),
],
});
validator.validate(info);Implements
Constructors
Constructor
new JwtAudienceValidator(
opts):JwtAudienceValidator
Defined in: src/lib/Validators/Audience.ts:81
Parameters
opts
Returns
JwtAudienceValidator
Properties
name
readonlyname:string
Defined in: src/lib/Validators/Audience.ts:73
The name of the validator.
When using with the JwtVerifier class, this name can be used to identify which validator failed.
Implementation of
Methods
validate()
validate(
parsed):void
Defined in: src/lib/Validators/Audience.ts:99
Validate the provided parse result of a JWT, checking if the JWT is valid.
Parameters
parsed
Returns
void
Throws
If validation failed or an error occurred inside.