Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use did io did method web #44

Merged
merged 17 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ jobs:
cd test
npm run coverage-ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: ./test/coverage/lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added
- Add support for using a configured external DID resolver.
- Add support for `did:web` DIDs via `@bedrock/did-io@10.3`.

## 19.1.0 - 2024-01-25

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@bedrock/credentials-context": "digitalbazaar/bedrock-credentials-context#update-vc-2.0",
"@bedrock/data-integrity-context": "^3.0.0",
"@bedrock/did-context": "^5.0.0",
"@bedrock/did-io": "^10.2.0",
"@bedrock/did-io": "^10.3.1",
"@bedrock/express": "^8.0.0",
"@bedrock/https-agent": "^4.0.0",
"@bedrock/jsonld-document-loader": "^4.0.0",
Expand Down
36 changes: 36 additions & 0 deletions test/dids/did.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/suites/ed25519-2020/v1",
"https://w3id.org/security/suites/x25519-2020/v1"
],
"id": "did:web:localhost%3A18443:test:dids",
"verificationMethod": [
{
"id": "did:web:localhost%3A18443:test:dids#z6Mkpw72M9suPCBv48X2Xj4YKZJH9W7wzEK1aS6JioKSo89C",
"type": "Ed25519VerificationKey2020",
"controller": "did:web:localhost%3A18443:test:dids",
"publicKeyMultibase": "z6Mkpw72M9suPCBv48X2Xj4YKZJH9W7wzEK1aS6JioKSo89C"
}
],
"authentication": [
"did:web:localhost%3A18443:test:dids#z6Mkpw72M9suPCBv48X2Xj4YKZJH9W7wzEK1aS6JioKSo89C"
],
"assertionMethod": [
"did:web:localhost%3A18443:test:dids#z6Mkpw72M9suPCBv48X2Xj4YKZJH9W7wzEK1aS6JioKSo89C"
],
"capabilityDelegation": [
"did:web:localhost%3A18443:test:dids#z6Mkpw72M9suPCBv48X2Xj4YKZJH9W7wzEK1aS6JioKSo89C"
],
"capabilityInvocation": [
"did:web:localhost%3A18443:test:dids#z6Mkpw72M9suPCBv48X2Xj4YKZJH9W7wzEK1aS6JioKSo89C"
],
"keyAgreement": [
{
"id": "did:web:localhost%3A18443:test:dids#z6LSgxJr5q1pwHPbiK7u8Pw1GvnfMTZSMxkhaorQ1aJYWFz3",
"type": "X25519KeyAgreementKey2020",
"controller": "did:web:localhost%3A18443:test:dids",
"publicKeyMultibase": "z6LSgxJr5q1pwHPbiK7u8Pw1GvnfMTZSMxkhaorQ1aJYWFz3"
}
]
}
2 changes: 2 additions & 0 deletions test/mocha/20-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ describe('verify APIs', () => {
});
describe('/credentials/verify', () => {
for(const mockCredential of mockCredentials) {
const {method} = helpers.getDidParts({did: mockCredential.issuer});
let description;
const {type, cryptosuite} = mockCredential.proof;
if(cryptosuite) {
Expand All @@ -142,6 +143,7 @@ describe('verify APIs', () => {
} else {
description = `${type}`;
}
description += `, DID method ${method}`;
describe(description, () => {
it('verifies a valid credential', async () => {
let verifiableCredential = klona(mockCredential);
Expand Down
6 changes: 6 additions & 0 deletions test/mocha/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,9 @@ export function getEcdsaAlgorithms({credential, presentation} = {}) {
});
return ecdsaAlgorithms;
}

export function getDidParts({did}) {
const [scheme, method] = did.split(':');
return {scheme, method};
}

38 changes: 38 additions & 0 deletions test/mocha/mock-credentials.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,43 @@
"proofPurpose": "assertionMethod",
"proofValue": "u2V0ChVhQpIG4b4ni5uDIKxlcy3v3js8_WDlx5gzRjmeeWa7ccZK_ESQpl3RcZqAaJZbJ7nx_bJBOqB4M1bOGp3qwAJr05oK1HFMhncG3NbKrEyU1FLFYQNSIf99sYrhBO2-bzePIlQ3kBOQgZMDS0s6Yesm7xwDGARcLYG-B8tNT-H8S3QrvEGCC4N5weXS4Cl9O57HvpPpYYJhmyQEoE1p8UkTiz_3z__DCvl9WxkINmwGTzugpT4nnn8_nQS7RhLU1TuUSrp3HKwl0USAQ549RoaXspdyVhrlQKUE5BQTHfMpyeMkejYEdKVywg4ZCAzDO9RQ_ZiYffFggEI3BjXvthokbuctwUceWVFdgiBdrIGDOq33NCqRbkFiCbS9pc3N1YW5jZURhdGVnL2lzc3Vlcg"
}
}, {
"@context": [
"https://www.w3.org/2018/credentials/v1",
{
"ex": "https://example.org/examples#",
"schema": "http://schema.org/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"BachelorDegree": "ex:BachelorDegree",
"UniversityDegreeCredential": "ex:UniversityDegreeCredential",
"degree": "ex:degree",
"name": {
"@id": "schema:name",
"@type": "rdf:HTML"
}
},
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "http://example.gov/credentials/3732",
"type": [
"VerifiableCredential",
"UniversityDegreeCredential"
],
"issuer": "did:web:localhost%3A18443:test:dids",
"issuanceDate": "2010-01-01T19:23:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts"
}
},
"proof": {
"type": "Ed25519Signature2020",
"created": "2022-12-21T21:41:44Z",
"verificationMethod": "did:web:localhost%3A18443:test:dids#z6Mkpw72M9suPCBv48X2Xj4YKZJH9W7wzEK1aS6JioKSo89C",
"proofPurpose": "assertionMethod",
"proofValue": "z26MCLaXjGqELnz5yVuxGW4NZnP4V4ubYGSLhRNhRrY9fW7jRGHjWKPnDus5LW4JJHVetLaT6xn8E22ffgsG2uFx7"
}
}
]
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@bedrock/credentials-context": "digitalbazaar/bedrock-credentials-context#update-vc-2.0",
"@bedrock/data-integrity-context": "^3.0.0",
"@bedrock/did-context": "^5.0.0",
"@bedrock/did-io": "^10.1.0",
"@bedrock/did-io": "^10.3.1",
"@bedrock/edv-storage": "^18.0.0",
"@bedrock/express": "^8.0.0",
"@bedrock/https-agent": "^4.0.0",
Expand Down
5 changes: 4 additions & 1 deletion test/test.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2012-2024 Digital Bazaar, Inc. All rights reserved.
*/
import {config} from '@bedrock/core';
import {fileURLToPath} from 'node:url';
Expand Down Expand Up @@ -38,3 +38,6 @@ config['app-identity'].seeds.services['vc-verifier'] = {

// use local KMS for testing
config['service-agent'].kms.baseUrl = 'https://localhost:18443/kms';

// set up express to serve `did:web` DID documents
config.express.static.push({route: '/test/dids', path: './dids'});
Loading