Documents for @litert/jwt / Validators/Subject / JwtSubjectValidator
Class: JwtSubjectValidator
Defined in: src/lib/Validators/Subject.ts:71
The validator to check if the sub claim is allowed.
Example
ts
import * as LibJwt from '@litert/jwt';
const info = LibJwt.parse(token);
const validator = new LibJwt.JwtSubjectValidator({
allowlist: [
'trusted-subject',
/^https://trusted\.domain/.+$/,
(sub: string) => sub.endsWith('@trusted.com'),
],
});
validator.validate(info);Implements
Constructors
Constructor
new JwtSubjectValidator(
opts):JwtSubjectValidator
Defined in: src/lib/Validators/Subject.ts:81
Parameters
opts
Returns
JwtSubjectValidator
Properties
name
readonlyname:string
Defined in: src/lib/Validators/Subject.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/Subject.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.