UNPKG

cose-kit

Version:

This is an early prototype of a RFC8152 COSE library for node.js.

149 lines (148 loc) 3.64 kB
import { KeyLike } from "jose"; /** * A generic Error that all other COSE specific Error subclasses extend. * * @example Checking thrown error is a COSE one * * ```js * if (err instanceof cose.errors.COSEError) { * // ... * } * ``` */ export declare class COSEError extends Error { /** A unique error code for the particular error subclass. */ static get code(): string; /** A unique error code for the particular error subclass. */ code: string; constructor(message?: string); } /** * An error subclass thrown when a JOSE Algorithm is not allowed per developer preference. * * @example Checking thrown error is this one using a stable error code * * ```js * if (err.code === 'ERR_COSE_ALG_NOT_ALLOWED') { * // ... * } * ``` * * @example Checking thrown error is this one using `instanceof` * * ```js * if (err instanceof jose.errors.JOSEAlgNotAllowed) { * // ... * } * ``` */ export declare class COSEAlgNotAllowed extends COSEError { static get code(): 'ERR_COSE_ALG_NOT_ALLOWED'; code: string; } /** * An error subclass thrown when a particular feature or algorithm is not supported by this * implementation or JOSE in general. * * @example Checking thrown error is this one using a stable error code * * ```js * if (err.code === 'ERR_COSE_NOT_SUPPORTED') { * // ... * } * ``` * * @example Checking thrown error is this one using `instanceof` * * ```js * if (err instanceof jose.errors.JOSENotSupported) { * // ... * } * ``` */ export declare class COSENotSupported extends COSEError { static get code(): 'ERR_COSE_NOT_SUPPORTED'; code: string; } /** * An error subclass thrown when a JWKS is invalid. * * @example Checking thrown error is this one using a stable error code * * ```js * if (err.code === 'ERR_JWKS_INVALID') { * // ... * } * ``` * * @example Checking thrown error is this one using `instanceof` * * ```js * if (err instanceof jose.errors.JWKSInvalid) { * // ... * } * ``` */ export declare class JWKSInvalid extends COSEError { static get code(): 'ERR_JWKS_INVALID'; code: string; } /** * An error subclass thrown when no keys match from a JWKS. * * @example Checking thrown error is this one using a stable error code * * ```js * if (err.code === 'ERR_JWKS_NO_MATCHING_KEY') { * // ... * } * ``` * * @example Checking thrown error is this one using `instanceof` * * ```js * if (err instanceof jose.errors.JWKSNoMatchingKey) { * // ... * } * ``` */ export declare class JWKSNoMatchingKey extends COSEError { static get code(): 'ERR_JWKS_NO_MATCHING_KEY'; code: string; message: string; } /** * An error subclass thrown when multiple keys match from a JWKS. * * @example Checking thrown error is this one using a stable error code * * ```js * if (err.code === 'ERR_JWKS_MULTIPLE_MATCHING_KEYS') { * // ... * } * ``` * * @example Checking thrown error is this one using `instanceof` * * ```js * if (err instanceof jose.errors.JWKSMultipleMatchingKeys) { * // ... * } * ``` */ export declare class JWKSMultipleMatchingKeys extends COSEError { /** @ignore */ [Symbol.asyncIterator]: () => AsyncIterableIterator<KeyLike>; static get code(): 'ERR_JWKS_MULTIPLE_MATCHING_KEYS'; code: string; message: string; } export declare class X509NoMatchingCertificate extends COSEError { static get code(): 'ERR_X509_NO_MATCHING_CERTIFICATE'; code: string; message: string; } export declare class X509InvalidCertificateChain extends COSEError { static get code(): 'ERR_X509_INVALID_CERTIFICATE_CHAIN'; code: string; }