Skip to content

Commit

Permalink
add handling for notFound status list
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Jan 19, 2025
1 parent 8fde1f0 commit 37e4fbb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
24 changes: 21 additions & 3 deletions src/Verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ const suite = [ed25519Suite, eddsaSuite]
checkStatus
});

processAnyStatusError({verificationResponse, statusResult: verificationResponse.statusResult});

// remove things we don't need from the result or that are duplicated elsewhere
delete verificationResponse.results
delete verificationResponse.statusResult
delete verificationResponse.verified

verificationResponse.isFatal = false
verificationResponse.credential = credential

verificationResponse.isFatal = false

if (verificationResponse.error) {
if (verificationResponse.error.log) {
// move the log out of the error to the response, since it
Expand Down Expand Up @@ -74,7 +76,7 @@ const suite = [ed25519Suite, eddsaSuite]
}

function buildFatalErrorObject(fatalErrorMessage: string, name: string, credential: Credential, stackTrace: string | null): VerificationResponse {
return { credential, isFatal: true, errors: [{ name, message: fatalErrorMessage, isFatal: true, ...stackTrace ? { stackTrace } : null }] }
return { credential, isFatal: true, errors: [{ name, message: fatalErrorMessage, ...stackTrace ? { stackTrace } : null }] }
}

function checkForFatalErrors(credential: Credential): VerificationResponse | null {
Expand Down Expand Up @@ -114,6 +116,22 @@ function checkForFatalErrors(credential: Credential): VerificationResponse | nul
return null
}

function processAnyStatusError( {verificationResponse, statusResult} :{
verificationResponse: VerificationResponse,
statusResult: any
}) : void
{
if (statusResult?.error?.cause?.message?.startsWith('NotFoundError')) {
const statusStep = {
"id": "revocation_status",
"error": {
name: 'status_list_not_found',
message: statusResult.error.cause.message
}
};
(verificationResponse.log ??= []).push(statusStep)
}
}

// import { purposes } from '@digitalcredentials/jsonld-signatures';
// import { VerifiablePresentation, PresentationError } from './types/presentation';
Expand Down
3 changes: 1 addition & 2 deletions src/test-fixtures/expectedResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const expectedResult = {
errors: [
{
name: 'error name goes here, e.g., no_proof',
message: 'error message goes here',
isFatal: true
message: 'error message goes here'
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions src/types/result.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

export interface VerificationError {
"message": string,
"isFatal": boolean,
"name"?: string,
stackTrace?: string
"stackTrace"?: string
}

export interface VerificationStep {
"id": string,
"valid": boolean,
"valid"?: boolean,
"foundInRegistries"?: string[],
"registriesNotLoaded"?: RegistriesNotLoaded[]
"registriesNotLoaded"?: RegistriesNotLoaded[],
"error"?: VerificationError
}

export interface VerificationResponse {
Expand Down

0 comments on commit 37e4fbb

Please sign in to comment.