Skip to content

Commit

Permalink
fix check on vc posted to issue endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Oct 21, 2024
1 parent a86995e commit 755dc4f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ async function callService (endpoint, body) {
return data
}

function isNotValidVC(unSignedVC) {

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 !unSignedVC || !Object.keys(unSignedVC).length || !unSignedVC.credentialSubject
}

export async function build (opts = {}) {
const {
enableStatusService,
Expand Down Expand Up @@ -88,10 +92,10 @@ export async function build (opts = {}) {
const authHeader = req.headers.authorization
const body = req.body
const unSignedVC = body.credential ? body.credential : body

422

Check failure on line 95 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Expected indentation of 8 spaces but found 4

Check failure on line 95 in src/app.js

View workflow job for this annotation

GitHub Actions / lint (16.x)

Expected an assignment or function call and instead saw an expression
await verifyAuthHeader(authHeader, tenantName)
// NOTE: we throw the error here which will then be caught by middleware errorhandler
if (!unSignedVC || !Object.keys(unSignedVC).length) throw new IssuingException(400, 'A verifiable credential must be provided in the body')
if (isNotValidVC(unSignedVC)) throw new IssuingException(422, 'A verifiable credential must be provided in the body')
const vcWithStatus = enableStatusService
? await callService(`http://${statusService}/credentials/status/allocate`, unSignedVC)
: unSignedVC
Expand Down

0 comments on commit 755dc4f

Please sign in to comment.