diff --git a/README.md b/README.md index df27f5f..3dd1543 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ IMPORTANT NOTE ABOUT VERSIONING: If you are using a Docker Hub image of this rep - [DID Registries](#did-registries) - [Usage](#usage) - [Allocate Status Position](#allocate-status-position) - - [Revoke](#revoke) + - [Revocation and suspension](#revocation-and-suspension) - [Versioning](#versioning) - [Logging](#logging) - [Log Levels](#log-levels) @@ -209,7 +209,7 @@ Now, your next step would be to sign this Verifiable Credential. You could pass NOTE: CURL can get a bit clunky if you want to experiment more (e.g., by changing what goes into the VC before signing), so you might consider trying [Postman](https://www.postman.com/downloads) which makes it easier to construct and send HTTP calls. -### Revoke +### Revocation and suspension Revocation and suspension are fully explained in the [Bitstring Status List](https://www.w3.org/TR/vc-bitstring-status-list/) specification and our implemenations thereof, but effectively, it amounts to POSTing an object to the revocation endpoint, like so: diff --git a/src/app.js b/src/app.js index 6e4574c..5ab94c4 100644 --- a/src/app.js +++ b/src/app.js @@ -28,7 +28,7 @@ export async function build(opts = {}) { const vc = req.body; if (!vc || !Object.keys(vc).length) { next({ - message: 'A verifiable credential must be provided in the body', + message: 'A Verifiable Credential must be provided in the body.', code: 400 }); } @@ -36,10 +36,12 @@ export async function build(opts = {}) { return res.json(vcWithStatus); } catch (e) { // We catch the async errors and pass them to the error handler. - if (!e.message) {e.message = "Error when allocating status position."} + if (!e.message) { + e.message = 'Unable to allocate status position.' + } // Note that if e contains a code property, the following spread of e will // (correctly) overwrite the 500 - next({code: 500, ...e}); + next({ code: 500, ...e }); } }); @@ -52,7 +54,7 @@ export async function build(opts = {}) { const updateRequest = req.body; if (!updateRequest || !updateRequest.credentialId || !updateRequest.credentialStatus) { next({ - message: 'A status update request must be provided in the body', + message: 'A status update request must be provided in the body.', code: 400 }); } @@ -70,10 +72,12 @@ export async function build(opts = {}) { return res.status(updateStatusResponse.code).json(updateStatusResponse); } catch (e) { // We catch the async errors and pass them to the error handler. - if (!e.message) {e.message = "Error updating credential status position."} + if (!e.message) { + e.message = 'Error updating credential status position.' + } // Note that if e contains a code property, the following spread of e will // (correctly) overwrite the 500 - next({code: 500, ...e}); + next({ code: 500, ...e }); } }); diff --git a/src/app.test.js b/src/app.test.js index bcc7bd8..897ab50 100644 --- a/src/app.test.js +++ b/src/app.test.js @@ -73,8 +73,8 @@ describe('api', () => { }); it('returns unchanged credential when status already set ', async () => { - const allocateStatus = sinon.fake.returns(getUnsignedVCWithStatus()); - const statusManagerStub = { allocateStatus }; + const allocateSupportedStatuses = sinon.fake.returns(getUnsignedVCWithStatus()); + const statusManagerStub = { allocateSupportedStatuses }; await status.initializeStatusManager(statusManagerStub); const app = await build(); diff --git a/src/test-fixtures/fixtures.js b/src/test-fixtures/fixtures.js index d6cb80f..26b93b8 100644 --- a/src/test-fixtures/fixtures.js +++ b/src/test-fixtures/fixtures.js @@ -2,7 +2,8 @@ import testVC from './testVC.js'; const validCredentialId = 'urn:uuid:951b475e-b795-43bc-ba8f-a2d01efd2eb1'; const invalidCredentialId = 'kj09ij'; -const invalidCredentialIdErrorMessage = `An error occurred in status-service-db: Unable to find credential with ID ${invalidCredentialId}`; +const invalidCredentialIdErrorMessage = 'An error occurred in status-service-db: ' + + `Unable to find credential with ID ${invalidCredentialId}`; const credentialStatus = { "id": "https://digitalcredentials.github.io/credential-status-jc-test/XA5AAK1PV4#16", diff --git a/src/test-fixtures/testVC.js b/src/test-fixtures/testVC.js index 7520204..add91e2 100644 --- a/src/test-fixtures/testVC.js +++ b/src/test-fixtures/testVC.js @@ -33,4 +33,5 @@ export default { "name": "Introduction to Wonderfullness" } } - } \ No newline at end of file + } + \ No newline at end of file diff --git a/src/test-fixtures/vc.js b/src/test-fixtures/vc.js deleted file mode 100644 index 21407f4..0000000 --- a/src/test-fixtures/vc.js +++ /dev/null @@ -1,77 +0,0 @@ -const unsignedVC = { - "@context": [ - "https://www.w3.org/ns/credentials/v2", - "https://purl.imsglobal.org/spec/ob/v3p0/context.json", - "https://w3id.org/security/suites/ed25519-2020/v1" - ], - "id": "urn:uuid:951b475e-b795-43bc-ba8f-a2d01efd2eb1", - "type": [ - "VerifiableCredential", - "OpenBadgeCredential" - ], - "issuer": { - "id": "did:key:z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC", - "type": "Profile", - "name": "Dr David Malan", - "description": "Gordon McKay Professor of the Practice of Computer Science, Harvard University", - "url": "https://cs.harvard.edu/malan/", - "image": { - "id": "https://certificates.cs50.io/static/success.jpg", - "type": "Image" - } - }, - "validFrom": "2020-01-01T00:00:00Z", - "name": "Introduction to Computer Science - CS50x", - "credentialSubject": { - "type": "AchievementSubject", - "identifier": { - "type": "IdentityObject", - "identityHash": "jc.chartrand@gmail.com", - "hashed": "false" - }, - "achievement": { - "id": "http://cs50.harvard.edu", - "type": "Achievement", - "criteria": { - "narrative": "Completion of CS50X, including ten problem sets, ten labs, and one final project." - }, - "description": "CS50 congratulates on completion of CS50x.", - "name": "Introduction to Computer Science - CS50x" - } - } -}; - -const credentialStatus = { - "id": "https://digitalcredentials.github.io/credential-status-jc-test/XA5AAK1PV4#16", - "type": "BitstringStatusListEntry", - "statusPurpose": "revocation", - "statusListIndex": 16, - "statusListCredential": "https://digitalcredentials.github.io/credential-status-jc-test/XA5AAK1PV4" -}; - - -const ed25519_2020suiteContext = "https://w3id.org/security/suites/ed25519-2020/v1"; - -const getUnsignedVC = () => JSON.parse(JSON.stringify(unsignedVC)); -const getUnsignedVCWithoutSuiteContext = () => { - const vcCopy = JSON.parse(JSON.stringify(unsignedVC)); - const index = vcCopy['@context'].indexOf(ed25519_2020suiteContext); - if (index > -1) { - vcCopy['@context'].splice(index, 1); - } - return vcCopy; -} -const getCredentialStatus = () => JSON.parse(JSON.stringify(credentialStatus)) - -const getUnsignedVCWithStatus = () => { - const unsignedVCWithStatus = getUnsignedVC(); - unsignedVCWithStatus.credentialStatus = getCredentialStatus(); - return unsignedVCWithStatus; -} - -export { - getUnsignedVC, - getUnsignedVCWithoutSuiteContext, - getCredentialStatus, - getUnsignedVCWithStatus -};