UNPKG

@sphereon/oid4vci-common

Version:

OpenID 4 Verifiable Credential Issuance Common Types

31 lines (27 loc) 968 B
export enum TokenErrorResponse { invalid_request = 'invalid_request', invalid_grant = 'invalid_grant', invalid_client = 'invalid_client', // this code has been added only in v1_0-11, but I've added this to the common interface. @nklomp is this ok? invalid_scope = 'invalid_scope', invalid_dpop_proof = 'invalid_dpop_proof', } export class TokenError extends Error { private readonly _statusCode: number; private readonly _responseError: TokenErrorResponse; constructor(statusCode: number, responseError: TokenErrorResponse, message: string) { super(message); this._statusCode = statusCode; this._responseError = responseError; // 👇️ because we are extending a built-in class Object.setPrototypeOf(this, TokenError.prototype); } get statusCode(): number { return this._statusCode; } get responseError(): TokenErrorResponse { return this._responseError; } getDescription() { return this.message; } }