Skip to content

Commit

Permalink
Return DID resolution document from mock DID resolver.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Mar 18, 2024
1 parent d3006eb commit 98cd5aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/documentLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ async function _resolve({didResolver, didUrl}) {
`${didResolver.url}/${encodeURIComponent(did)}`;
const data = await httpClientHandler.get({url});

if(data?.id !== did) {
if(data?.didDocument?.id !== did) {
throw new Error(`DID document for DID "${did}" not found.`);
}

// FIXME: perform DID document validation
// FIXME: handle URL query param / services
const didDocument = data;
const {didDocument} = data;

// if a fragment was found use the fragment to dereference a subnode
// in the did doc
Expand Down
2 changes: 0 additions & 2 deletions test/mocha/40-did-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ describe('did resolver option', () => {
});
} catch(e) {
error = e;
console.log('error', error.message);
}
//process.exit(1);
assertNoError(error);
should.exist(result.data.verified);
result.data.verified.should.be.a('boolean');
Expand Down
11 changes: 9 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ bedrock.events.on('bedrock-express.configure.routes', async app => {
app.get('/1.0/identifiers/:did', asyncHandler(async (req, res) => {
const {did: url} = req.params;
// resolve via did-io
const document = await didIo.get({url});
res.json(document);
const didDocument = await didIo.get({url});
res.json({
'@context': 'https://w3id.org/did-resolution/v1',
didDocument,
didDocumentMetadata: {},
didResolutionMetadata: {
contentType: 'application/did+ld+json'
}
});
}));
});

Expand Down

0 comments on commit 98cd5aa

Please sign in to comment.