Skip to content

Documents for @litert/jwt / Validators/Issuer / JwtIssuerValidator

Class: JwtIssuerValidator ​

Defined in: src/lib/Validators/Issuer.ts:71

The validator to check if the iss claim is allowed.

Example ​

ts
import * as LibJwt from '@litert/jwt';
const info = LibJwt.parse(token);

const validator = new LibJwt.JwtIssuerValidator({
    allowlist: [
        'trusted-issuer',
        /^https://trusted\.domain/.+$/,
        (iss: string) => iss.endsWith('@trusted.com'),
    ],
});

validator.validate(info);

Implements ​

Constructors ​

Constructor ​

new JwtIssuerValidator(opts): JwtIssuerValidator

Defined in: src/lib/Validators/Issuer.ts:81

Parameters ​

opts ​

IIssuerValidationOptions

Returns ​

JwtIssuerValidator

Properties ​

name ​

readonly name: string

Defined in: src/lib/Validators/Issuer.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 ​

IJwtValidator.name

Methods ​

validate() ​

validate(parsed): void

Defined in: src/lib/Validators/Issuer.ts:99

Validate the provided parse result of a JWT, checking if the JWT is valid.

Parameters ​

parsed ​

IJwtParseResult

Returns ​

void

Throws ​

If validation failed or an error occurred inside.

Implementation of ​

IJwtValidator.validate