Skip to content

Commit

Permalink
Add FIXMEs for implementing ProblemDetails return values.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Dec 15, 2024
1 parent 6969a7e commit 445f296
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
34 changes: 26 additions & 8 deletions lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ export async function addRoutes({app, service} = {}) {
asyncHandler(async (req, res) => {
const {config} = req.serviceObject;

const {
options = {},
verifiableCredential: credential,
} = req.body;

let response;
try {
const {
options = {},
verifiableCredential: credential,
} = req.body;

const {checks} = options;
_validateChecks({checks});
const result = await verifyCredential({config, credential, checks});
response = _createResponse({credential, result, checks});
response = _createResponse({options, credential, result, checks});
} catch(e) {
response = _createResponse({error: e});
response = _createResponse({options, error: e});
}

if(response.verified) {
Expand Down Expand Up @@ -185,7 +185,25 @@ function _validateChecks({checks}) {
}
}

function _createResponse({credential, result, challengeUses, error, checks}) {
function _createResponse({
options, credential, result, challengeUses, error, checks

Check failure on line 189 in lib/http.js

View workflow job for this annotation

GitHub Actions / lint (20.x)

'options' is defined but never used
}) {
// FIXME: return these additional fields:
/*
{
"verified": false,
"document": verifiableCredential,
"mediaType": "application/vc",
"controller": issuer,
"controllerDocument": didDocument,
// FIXME: return only if `options.returnProblemDetails`
"warnings": [ProblemDetails],
"errors": [ProblemDetails]
// FIXME: return only if `options.returnCredential`
"credential": <credential w/o proof>
}
*/

result = result || {verified: false, error};

let response;
Expand Down
12 changes: 12 additions & 0 deletions schemas/bedrock-vc-verifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ export function verifyCredentialBody() {
envelopedVerifiableCredential
]
}
// FIXME: add `returnCredential`
// FIXME: add `returnProblemDetails`
/*
{
"verified": false,
"document": verifiableCredential,
"mediaType": "application/vc",
"controller": issuer,
"controllerDocument": didDocument,
"warnings": [ProblemDetails],
"errors": [ProblemDetails]
}*/
}
};
}
Expand Down

0 comments on commit 445f296

Please sign in to comment.