Skip to content

Commit

Permalink
fix: fix error type exports
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Aug 18, 2022
1 parent 3db4273 commit abebb0c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
28 changes: 0 additions & 28 deletions src/errors.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -49,7 +51,6 @@ export {
transformPresentationInput,
normalizeCredential,
normalizePresentation,
VC_JWT_ERROR,
}

export {
Expand Down
29 changes: 28 additions & 1 deletion src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit abebb0c

Please sign in to comment.