UNPKG

@dvsa/appdev-api-common

Version:

Utils library for common API functionality

25 lines (24 loc) 1 kB
import { type JWTPayload } from "jose"; export declare class JwtAuthoriser { private readonly clientIds; private readonly tenantId; private static readonly ENV; private static readonly tokenExpiryEnvExclusionList; private static readonly DEFAULT_TENANT; private static readonly MICROSOFT_LOGIN_BASE_URL; private static readonly jwksByTenant; /** * Create a new instance of the JwtAuthoriser class * @param clientIds - the client id(s) to validate the token against - can take a single string value or a comma-separated list in a string * @param tenantId - the tenant id to validate the token against */ constructor(clientIds?: string | null, tenantId?: string | null); private static getTenantSegment; private static getJwks; /** * Validate a JWT and return the decoded payload * @param {string} token - the JWT token to validate * @returns {Promise<JWTPayload>} */ verify(token: string): Promise<JWTPayload>; }