Skip to content

Commit

Permalink
more vc-api conformance test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Oct 22, 2024
1 parent 9750713 commit 52e86f7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ async function callService (endpoint, body) {
return data
}

function isArrayOfStrings(arrayToCheck) {

Check failure on line 25 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Missing space before function parentheses
return arrayToCheck && Array.isArray(arrayToCheck) && arrayToCheck.length && arrayToCheck.every(item=> {return (item && typeof item == "string")})

Check failure on line 26 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Missing space before =>

Check failure on line 26 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Requires a space after '{'

Check failure on line 26 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Expected '===' and instead saw '=='

Check failure on line 26 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Strings must use singlequote

Check failure on line 26 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Requires a space before '}'
}

function isNotValidVC (unSignedVC) {
return !unSignedVC || !Object.keys(unSignedVC).length || !unSignedVC.credentialSubject
if (!unSignedVC) return true;

Check failure on line 30 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Extra semicolon
const isContextPropertyValid = isArrayOfStrings(unSignedVC['@context'])
const isTypePropertyValid = isArrayOfStrings(unSignedVC.type)
return ! (isContextPropertyValid && isTypePropertyValid)

Check failure on line 33 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Unexpected space after unary operator '!'

Check failure on line 33 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Trailing spaces not allowed
}

export async function build (opts = {}) {
Expand Down Expand Up @@ -94,7 +101,7 @@ export async function build (opts = {}) {
const unSignedVC = body.credential ? body.credential : body
await verifyAuthHeader(authHeader, tenantName)
// NOTE: we throw the error here which will then be caught by middleware errorhandler
if (isNotValidVC(unSignedVC)) throw new IssuingException(422, 'A verifiable credential must be provided in the body')
if (isNotValidVC(unSignedVC)) throw new IssuingException(422, 'A valid verifiable credential must be provided')
const vcWithStatus = enableStatusService
? await callService(`http://${statusService}/credentials/status/allocate`, unSignedVC)
: unSignedVC
Expand Down

0 comments on commit 52e86f7

Please sign in to comment.