peer-did-resolver
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -32,4 +32,3 @@ import { resolve } from '@aviarytech/did-peer'; | ||
} | ||
// TODO: this excludes the use of query params | ||
const docIdMatchesDid = (didDocument === null || didDocument === void 0 ? void 0 : didDocument.id) === did; | ||
const docIdMatchesDid = didDocument?.id === parsed.did; | ||
if (!docIdMatchesDid) { | ||
@@ -41,3 +40,3 @@ err = 'resolver_error: DID document id does not match requested did'; | ||
} while (false); | ||
const contentType = typeof (didDocument === null || didDocument === void 0 ? void 0 : didDocument['@context']) !== 'undefined' ? 'application/did+ld+json' : 'application/did+json'; | ||
const contentType = typeof didDocument?.['@context'] !== 'undefined' ? 'application/did+ld+json' : 'application/did+json'; | ||
if (err) { | ||
@@ -44,0 +43,0 @@ return { |
{ | ||
"name": "peer-did-resolver", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Resolve DID documents for did:peer", | ||
"type": "module", | ||
"source": "src/resolver.ts", | ||
"main": "./lib/resolver.js", | ||
"types": "./lib/resolver.d.ts", | ||
@@ -26,4 +25,4 @@ "files": [ | ||
"dependencies": { | ||
"@aviarytech/did-peer": "^0.0.19", | ||
"did-resolver": "^4.0.0" | ||
"@aviarytech/did-peer": "^0.0.22", | ||
"did-resolver": "^4.1.0" | ||
}, | ||
@@ -51,3 +50,5 @@ "scripts": { | ||
], | ||
"transformIgnorePatterns": ["/node_modules/@aviarytech/peer-did"] | ||
"transformIgnorePatterns": [ | ||
"/node_modules/@aviarytech/peer-did" | ||
] | ||
}, | ||
@@ -54,0 +55,0 @@ "devDependencies": { |
@@ -1,57 +0,5 @@ | ||
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.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V', | ||
], | ||
keyAgreement: [ | ||
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ#6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud', | ||
], | ||
capabilityInvocation: [ | ||
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDEiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MSJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfQ#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V', | ||
], | ||
capabilityDelegation: [ | ||
'did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.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 | ||
@@ -63,8 +11,94 @@ | ||
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(validResponse) | ||
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.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') | ||
}) | ||
}) |
@@ -35,4 +35,3 @@ import { DIDDocument, DIDResolutionResult, DIDResolver, ParsedDID } from 'did-resolver' | ||
// TODO: this excludes the use of query params | ||
const docIdMatchesDid = didDocument?.id === did | ||
const docIdMatchesDid = didDocument?.id === parsed.did | ||
if (!docIdMatchesDid) { | ||
@@ -39,0 +38,0 @@ err = 'resolver_error: DID document id does not match requested did' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
221
25850
+ Added@aviarytech/did-peer@0.0.22(transitive)
- Removed@aviarytech/did-peer@0.0.19(transitive)
Updated@aviarytech/did-peer@^0.0.22
Updateddid-resolver@^4.1.0