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

fix(deps): bump @aviarytech/did-peer to 0.0.22 #4

Merged
merged 1 commit into from
Jan 22, 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
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ on:
- 'master'
jobs:
build-test-publish:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}

- name: "Setup node with cache"
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
cache: 'yarn'

- run: yarn install --frozen-lockfile
- run: yarn run build

- name: "Setup git coordinates"
run: |
git config user.name uport-automation-bot
git config user.email [email protected]
git config user.name ${{ secrets.GH_USER }}
git config user.email ${{ secrets.GH_EMAIL }}

- name: "Run semantic-release"
env:
GH_TOKEN: ${{secrets.GH_TOKEN}}
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/alpha'
run: yarn run release
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ name: Build and Test NODE
on: [pull_request, workflow_dispatch, push]
jobs:
build-test:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
matrix:
version: [ 18 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Setup node with cache"
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 14
node-version: ${{ matrix.version }}
cache: 'yarn'

- run: yarn install --frozen-lockfile
Expand All @@ -23,3 +26,4 @@ jobs:
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion example/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"did-resolver": "4.0.1",
"did-resolver": "4.1.0",
"peer-did-resolver": "../../",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"url": "[email protected]:veramolabs/peer-did-resolver.git"
},
"dependencies": {
"@aviarytech/did-peer": "^0.0.19",
"did-resolver": "^4.0.0"
"@aviarytech/did-peer": "^0.0.22",
"did-resolver": "^4.1.0"
},
"scripts": {
"test": "jest",
Expand Down
146 changes: 90 additions & 56 deletions src/__tests__/resolver.test.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,103 @@
import { Resolver, DIDDocument, Resolvable } from 'did-resolver'
import { DIDDocument, Resolvable, Resolver } from 'did-resolver'
import { getResolver } from '../resolver'

describe('web did resolver', () => {
const did: string =
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ'

const validResponse: DIDDocument = {
'@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:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ',
verificationMethod: [
{
id: 'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
type: 'Ed25519VerificationKey2020',
controller:
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ',
publicKeyMultibase: 'z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
},
{
id: 'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ#6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud',
type: 'X25519KeyAgreementKey2020',
controller:
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ',
publicKeyMultibase: 'z6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud',
},
],
authentication: [
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
],
assertionMethod: [
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYq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v22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
],
service: [
{
id: '#didcommmessaging-0',
type: 'DIDCommMessaging',
serviceEndpoint: 'https://example.com/endpoint1',
routingKeys: ['did:example:somemediator#somekey1'],
accept: ['didcomm/v2', 'didcomm/aip2;env=rfc587'],
},
],
}

describe('did:peer resolver', () => {
let didResolver: Resolvable

beforeAll(async () => {
didResolver = new Resolver(getResolver())
})

it('resolves document', async () => {
it('resolves simple document with num_algo=0', async () => {
expect.assertions(2)
const did = 'did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V'
const result = await didResolver.resolve(did)
expect(result.didDocument).toEqual({
'@context': ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/suites/ed25519-2020/v1'],
id: did,
verificationMethod: [
{
id: 'did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
type: 'Ed25519VerificationKey2020',
controller: 'did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
publicKeyMultibase: 'z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
},
],
authentication: [
'did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
],
assertionMethod: [
'did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
],
capabilityInvocation: [
'did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
],
capabilityDelegation: [
'did:peer:0z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
],
})
expect(result.didResolutionMetadata.contentType).toEqual('application/did+ld+json')
})

it('resolves simple document with num_algo=2', async () => {
expect.assertions(2)
const did =
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ'
const result = await didResolver.resolve(did)
expect(result.didDocument).toEqual({
'@context': ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/multikey/v1', { '@base': did }],
id: did,
verificationMethod: [
{
id: '#key-2',
type: 'Multikey',
controller: did,
publicKeyMultibase: 'z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V',
},
{
id: '#key-1',
type: 'Multikey',
controller: did,
publicKeyMultibase: 'z6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud',
},
],
keyAgreement: ['#key-1'],
authentication: ['#key-2'],
assertionMethod: ['#key-2'],
service: [
{
id: '#service',
type: 'DIDCommMessaging',
serviceEndpoint: 'https://example.com/endpoint1',
routingKeys: ['did:example:somemediator#somekey1'],
accept: ['didcomm/v2', 'didcomm/aip2;env=rfc587'],
},
],
})
expect(result.didResolutionMetadata.contentType).toEqual('application/did+ld+json')
})

it('resolves document with num_algo=2 and multiple service endpoints', async () => {
expect.assertions(2)
const did =
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDIiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MiJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ'
const result = await didResolver.resolve(did)
expect(result.didDocument).toEqual(validResponse)
expect(result.didDocument.service).toEqual([
{
id: '#service',
type: 'DIDCommMessaging',
serviceEndpoint: 'https://example.com/endpoint1',
routingKeys: ['did:example:somemediator#somekey1'],
accept: ['didcomm/v2', 'didcomm/aip2;env=rfc587'],
},
{
id: '#service-1',
type: 'DIDCommMessaging',
serviceEndpoint: 'https://example.com/endpoint2',
routingKeys: ['did:example:somemediator#somekey2'],
accept: ['didcomm/v2', 'didcomm/aip2;env=rfc587'],
},
])
expect(result.didResolutionMetadata.contentType).toEqual('application/did+ld+json')
})
})
3 changes: 1 addition & 2 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export function getResolver(): Record<string, DIDResolver> {
break
}

// TODO: this excludes the use of query params
const docIdMatchesDid = didDocument?.id === did
const docIdMatchesDid = didDocument?.id === parsed.did
if (!docIdMatchesDid) {
err = 'resolver_error: DID document id does not match requested did'
// break // uncomment this when adding more checks
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2018",
"target": "ES2022",
"module": "esnext",
"lib": [
"dom",
Expand Down
25 changes: 9 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"@jridgewell/gen-mapping" "^0.1.0"
"@jridgewell/trace-mapping" "^0.3.9"

"@aviarytech/did-peer@^0.0.19":
version "0.0.19"
resolved "https://registry.yarnpkg.com/@aviarytech/did-peer/-/did-peer-0.0.19.tgz#5ac20d37d762f05be7a502826cb0fbb6cd319180"
integrity sha512-koSwVi++RIVWgYoNHHFZ95ouVqCNlLvqDfJfThOwExkZ2YSoRW/EFXeXFe33Gm7wR9gwTgoZXgi71hHO9d5RVQ==
"@aviarytech/did-peer@^0.0.22":
version "0.0.22"
resolved "https://registry.yarnpkg.com/@aviarytech/did-peer/-/did-peer-0.0.22.tgz#d0c15062c37fc6bf2720d31dbbf9eb23e09c2435"
integrity sha512-BdA7L9wpYNLf1c3d0yB92aoj1AUWE10p408VZ4IJXfavb/oNxALZRRRJTcvMdrd5P2XXQsP5+x4bXfO24iRURg==
dependencies:
buffer "^6.0.3"

Expand Down Expand Up @@ -3984,13 +3984,6 @@ cosmiconfig@^7.0.0:
path-type "^4.0.0"
yaml "^1.10.0"

cross-fetch@^3.1.5:
version "3.1.5"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f"
integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==
dependencies:
node-fetch "2.6.7"

cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
Expand Down Expand Up @@ -4207,10 +4200,10 @@ dezalgo@^1.0.0:
asap "^2.0.0"
wrappy "1"

did-resolver@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-4.0.0.tgz#fc8f657b4cd7f44c2921051fb046599fbe7d4b31"
integrity sha512-/roxrDr9EnAmLs+s9T+8+gcpilMo+IkeytcsGO7dcxvTmVJ+0Rt60HtV8o0UXHhGBo0Q+paMH/0ffXz1rqGFYg==
did-resolver@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-4.1.0.tgz#740852083c4fd5bf9729d528eca5d105aff45eb6"
integrity sha512-S6fWHvCXkZg2IhS4RcVHxwuyVejPR7c+a4Go0xbQ9ps5kILa8viiYQgrM4gfTyeTjJ0ekgJH9gk/BawTpmkbZA==

diff-sequences@^29.0.0:
version "29.0.0"
Expand Down Expand Up @@ -6719,7 +6712,7 @@ node-emoji@^1.11.0:
dependencies:
lodash "^4.17.21"

node-fetch@2.6.7, node-fetch@^2.6.7:
node-fetch@^2.6.7:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
Expand Down
Loading