From abebb0c2b746d9aef63434052e9cc075438100aa Mon Sep 17 00:00:00 2001 From: Mircea Nistor Date: Thu, 18 Aug 2022 21:24:03 +0200 Subject: [PATCH] fix: fix error type exports --- src/errors.ts | 28 ---------------------------- src/index.ts | 5 +++-- src/validators.ts | 29 ++++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 src/errors.ts diff --git a/src/errors.ts b/src/errors.ts deleted file mode 100644 index 99204dd..0000000 --- a/src/errors.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { JWT_ERROR } from 'did-jwt' - -/** - * Error prefixes used for known verification failure cases related to the - * {@link https://www.w3.org/TR/vc-data-model/ | Verifiable Credential data model } - */ -export const enum VC_ERROR { - /** - * Thrown when the credential or presentation being verified does not conform to the data model defined by - * {@link https://www.w3.org/TR/vc-data-model/ | the spec} - */ - SCHEMA_ERROR = 'schema_error', - - /** - * Thrown when the input is not a JWT string - */ - FORMAT_ERROR = 'format_error', - - /** - * Thrown when verifying a presentation where `challenge` and/or `domain` don't match the expected values. - */ - AUTH_ERROR = 'auth_error', -} - -/** - * Known validation or verification error prefixes. - */ -export type VC_JWT_ERROR = VC_ERROR | JWT_ERROR diff --git a/src/index.ts b/src/index.ts index d7fc486..a1d2f1e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,7 +30,9 @@ import { transformCredentialInput, transformPresentationInput, } from './converters' -import { VC_ERROR, VC_JWT_ERROR } from './errors' +import { VC_ERROR } from './validators' + +export { VC_ERROR, VC_JWT_ERROR } from './validators' export { Issuer, @@ -49,7 +51,6 @@ export { transformPresentationInput, normalizeCredential, normalizePresentation, - VC_JWT_ERROR, } export { diff --git a/src/validators.ts b/src/validators.ts index 72a2f2d..c1aa4f8 100644 --- a/src/validators.ts +++ b/src/validators.ts @@ -2,7 +2,34 @@ import { DEFAULT_CONTEXT, DEFAULT_VC_TYPE, DEFAULT_VP_TYPE, JWT_FORMAT } from '. import { JwtCredentialSubject, DateType } from './types' import { VerifiableCredential } from '.' import { asArray } from './converters' -import { VC_ERROR } from './errors' +import { JWT_ERROR } from 'did-jwt' + +/** + * Error prefixes used for known verification failure cases related to the + * {@link https://www.w3.org/TR/vc-data-model/ | Verifiable Credential data model } + */ +export const enum VC_ERROR { + /** + * Thrown when the credential or presentation being verified does not conform to the data model defined by + * {@link https://www.w3.org/TR/vc-data-model/ | the spec} + */ + SCHEMA_ERROR = 'schema_error', + + /** + * Thrown when the input is not a JWT string + */ + FORMAT_ERROR = 'format_error', + + /** + * Thrown when verifying a presentation where `challenge` and/or `domain` don't match the expected values. + */ + AUTH_ERROR = 'auth_error', +} + +/** + * Known validation or verification error prefixes. + */ +export type VC_JWT_ERROR = VC_ERROR | JWT_ERROR // eslint-disable-next-line @typescript-eslint/no-explicit-any function isDateObject(input: any): input is Date {