Skip to content

Commit

Permalink
feat(deps): bump ethr-did-resolver to 9.1.0 and adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Nov 8, 2023
1 parent 6f9e75f commit e61640d
Show file tree
Hide file tree
Showing 7 changed files with 853 additions and 1,421 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ The following DID methods are supported:

* [ethr](https://github.com/decentralized-identity/ethr-did-resolver)
* [web](https://github.com/decentralized-identity/web-did-resolver)
* [nacl](https://github.com/uport-project/nacl-did) (DEPRECATED, please use `did:key` instead)
* [ens](https://github.com/veramolabs/ens-did-resolver)

## Curl Tests
Expand All @@ -29,7 +28,6 @@ then run queries
```
curl -X GET http://localhost:8081/1.0/identifiers/did:web:did.actor:alice
curl -X GET http://localhost:8081/1.0/identifiers/did:ethr:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736
curl -X GET http://localhost:8081/1.0/identifiers/did:nacl:Md8JiMIwsapml_FtQ2ngnGftNP5UmVCAUuhnLyAsPxI
```

## Example DIDs
Expand All @@ -38,11 +36,9 @@ curl -X GET http://localhost:8081/1.0/identifiers/did:nacl:Md8JiMIwsapml_FtQ2ngn
* `did:ethr:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71`
* `did:ethr:mainnet:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736`
* `did:ethr:goerli:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736`
* `did:ethr:rsk:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736`
* `did:ethr:0x1:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736`
* `did:ethr:0x5:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736`
* `did:ethr:0x1e:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736`
* `did:ethr:ewc:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736`
* `did:web:pulsar.veramo.io`
* `did:web:did.actor:alice`
* `did:nacl:Md8JiMIwsapml_FtQ2ngnGftNP5UmVCAUuhnLyAsPxI`
* `did:ens:vitalik.eth`
25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,28 @@
},
"license": "Apache-2.0",
"dependencies": {
"did-resolver": "^4.0.1",
"ens-did-resolver": "^1.0.0",
"ethr-did-resolver": "^9.0.0",
"did-resolver": "^4.1.0",
"ens-did-resolver": "^1.0.4",
"ethr-did-resolver": "^9.1.0",
"express": "^4.18.2",
"express-actuator": "^1.8.4",
"nacl-did": "^1.0.1",
"peer-did-resolver": "^1.0.1",
"plc-did-resolver": "^1.0.0",
"web-did-resolver": "^2.0.21"
"web-did-resolver": "^2.0.27"
},
"devDependencies": {
"@jest/globals": "^29.4.3",
"@jest/globals": "29.7.0",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/commit-analyzer": "11.0.0",
"@semantic-release/commit-analyzer": "11.1.0",
"@semantic-release/exec": "6.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "9.2.1",
"@semantic-release/npm": "11.0.0",
"@semantic-release/release-notes-generator": "12.0.0",
"cross-env": "^7.0.3",
"@semantic-release/github": "9.2.2",
"@semantic-release/npm": "11.0.1",
"@semantic-release/release-notes-generator": "12.1.0",
"cross-env": "7.0.3",
"jest": "29.7.0",
"prettier": "^3.0.0",
"semantic-release": "22.0.5",
"prettier": "3.0.3",
"semantic-release": "22.0.7",
"supertest": "6.3.3"
},
"jest": {
Expand Down
65 changes: 34 additions & 31 deletions src/__tests__/ethr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('did:ethr driver', () => {
'@context': [
'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/suites/secp256k1recovery-2020/v2',
'https://w3id.org/security/v3-unstable',
],
authentication: ['did:ethr:0xdca7ef03e98e0dc2b855be647c39abe984fcf21b#controller'],
assertionMethod: ['did:ethr:0xdca7ef03e98e0dc2b855be647c39abe984fcf21b#controller'],
Expand Down Expand Up @@ -65,6 +66,7 @@ describe('did:ethr driver', () => {
'@context': [
'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/suites/secp256k1recovery-2020/v2',
'https://w3id.org/security/v3-unstable',
],
id: 'did:ethr:0x26bf14321004e770e7a8b080b7a526d8eed8b388',
verificationMethod: [
Expand Down Expand Up @@ -95,6 +97,7 @@ describe('did:ethr driver', () => {
'@context': [
'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/suites/secp256k1recovery-2020/v2',
'https://w3id.org/security/v3-unstable',
],
authentication: [
'did:ethr:0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71#controller',
Expand Down Expand Up @@ -153,47 +156,47 @@ describe('did:ethr driver', () => {
expect(response.body.didDocument).toHaveProperty('verificationMethod')
})

it('did:ethr:rsk:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
// it('did:ethr:rsk:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
// expect.assertions(1)
// const did = 'did:ethr:rsk:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
// const response = await request(app).get(`/1.0/identifiers/${did}`)
// expect(response.body.didDocument).toHaveProperty('verificationMethod')
// })

// it('did:ethr:0x1e:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
// expect.assertions(1)
// const did = 'did:ethr:0x1e:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
// const response = await request(app).get(`/1.0/identifiers/${did}`)
// expect(response.body.didDocument).toHaveProperty('verificationMethod')
// })

it('did:ethr:matic:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
expect.assertions(1)
const did = 'did:ethr:rsk:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
const did = 'did:ethr:matic:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
const response = await request(app).get(`/1.0/identifiers/${did}`)
expect(response.body.didDocument).toHaveProperty('verificationMethod')
})

it('did:ethr:0x1e:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
it('did:ethr:0x89:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
expect.assertions(1)
const did = 'did:ethr:0x1e:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
const did = 'did:ethr:0x89:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
const response = await request(app).get(`/1.0/identifiers/${did}`)
expect(response.body.didDocument).toHaveProperty('verificationMethod')
})

// it('did:ethr:matic:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
// expect.assertions(1)
// const did = 'did:ethr:matic:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
// const response = await request(app).get(`/1.0/identifiers/${did}`)
// expect(response.body.didDocument).toHaveProperty('verificationMethod')
// })
//
// it('did:ethr:0x89:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
// expect.assertions(1)
// const did = 'did:ethr:0x89:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
// const response = await request(app).get(`/1.0/identifiers/${did}`)
// expect(response.body.didDocument).toHaveProperty('verificationMethod')
// })
//
// it('did:ethr:maticmum:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
// expect.assertions(1)
// const did = 'did:ethr:maticmum:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
// const response = await request(app).get(`/1.0/identifiers/${did}`)
// expect(response.body.didDocument).toHaveProperty('verificationMethod')
// })
//
// it('did:ethr:0x13881:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
// expect.assertions(1)
// const did = 'did:ethr:0x13881:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
// const response = await request(app).get(`/1.0/identifiers/${did}`)
// expect(response.body.didDocument).toHaveProperty('verificationMethod')
// })
it.skip('did:ethr:maticmum:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
expect.assertions(1)
const did = 'did:ethr:maticmum:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
const response = await request(app).get(`/1.0/identifiers/${did}`)
expect(response.body.didDocument).toHaveProperty('verificationMethod')
})

it.skip('did:ethr:0x13881:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
expect.assertions(1)
const did = 'did:ethr:0x13881:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736'
const response = await request(app).get(`/1.0/identifiers/${did}`)
expect(response.body.didDocument).toHaveProperty('verificationMethod')
})

it('did:ethr:0x03c401:0x3b0BC51Ab9De1e5B7B6E34E5b960285805C41736', async () => {
expect.assertions(1)
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/legacy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import app from '../app.js'
import request from 'supertest'

describe('uport-did-driver responds with did doc for', () => {
it('responds with didResolutionResult for did:nacl:Md8JiMIwsapml_FtQ2ngnGftNP5UmVCAUuhnLyAsPxI', async () => {
it.skip('responds with didResolutionResult for did:nacl:Md8JiMIwsapml_FtQ2ngnGftNP5UmVCAUuhnLyAsPxI', async () => {
expect.assertions(5)
const did = 'did:nacl:Md8JiMIwsapml_FtQ2ngnGftNP5UmVCAUuhnLyAsPxI'
const response = await request(app).get(`/1.0/identifiers/${did}`)
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/peer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import request from 'supertest'
describe('did:peer driver', () => {
it('responds with didResolutionResult for "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ"', async () => {
expect.assertions(5)
const did = 'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ'
const did =
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ'
const response = await request(app).get(`/1.0/identifiers/${did}`)
expect(response.status).toBe(200)
expect(response.body).toHaveProperty('didDocument')
Expand Down
56 changes: 24 additions & 32 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ens from 'ens-did-resolver'
import { getResolver as getWebResolver } from 'web-did-resolver'
import { getResolver as getPeerResolver } from 'peer-did-resolver'
import { getResolver as getPlcResolver } from 'plc-did-resolver'
import nacl from 'nacl-did'
import express from 'express'
import actuator from 'express-actuator'

Expand All @@ -19,7 +18,7 @@ const infuraId = 'ec9c99d75b834bac8dd4bfacad8cfdf7'
const providerConfig = {
infuraProjectId: infuraId,
networks: [
{ name: 'rsk', chainId: 30, rpcUrl: 'https://did.rsk.co:4444' },
// { name: 'rsk', chainId: 30, rpcUrl: 'https://did.rsk.co:4444' },
{
chainId: '0x03c401',
rpcUrl: 'https://rpc.tau1.artis.network',
Expand All @@ -36,39 +35,32 @@ const providerConfig = {
rpcUrl: 'https://rpc.energyweb.org',
registry: '0xE29672f34e92b56C9169f9D485fFc8b9A136BCE4',
},
// {
// name: 'matic',
// chainId: 137,
// rpcUrl: 'https://rpc-mainnet.matic.network'
// },
// {
// name: 'maticmum',
// chainId: 80001,
// rpcUrl: 'https://rpc-mumbai.matic.today'
// }
{
name: 'matic',
chainId: 137,
rpcUrl: 'https://polygon-rpc.com/',
},
// {
// name: 'maticmum',
// chainId: 80001,
// rpcUrl: 'https://rpc-mumbai.matic.today',
// },
],
}

const resolver = new Resolver(
{
...ethr.getResolver(providerConfig),
...ens.getResolver({
networks: [
{ name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/e471b8639c314004ae67ec0078f70102' },
{ rpcUrl: 'https://mainnet.infura.io/v3/e471b8639c314004ae67ec0078f70102' },
],
}),
...getWebResolver(),
...getPeerResolver(),
...getPlcResolver(),
// ...get3IDResolver(ceramic)
},
{
legacyResolvers: {
nacl: nacl.resolver,
},
},
)
const resolver = new Resolver({
...ethr.getResolver(providerConfig),
...ens.getResolver({
networks: [
{ name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/e471b8639c314004ae67ec0078f70102' },
{ rpcUrl: 'https://mainnet.infura.io/v3/e471b8639c314004ae67ec0078f70102' },
],
}),
...getWebResolver(),
...getPeerResolver(),
...getPlcResolver(),
// ...get3IDResolver(ceramic)
})

const app = express()

Expand Down
Loading

0 comments on commit e61640d

Please sign in to comment.