Skip to content

Commit

Permalink
fix: use http transport by default with didcomm and fix unstable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Jul 8, 2021
1 parent 67373cc commit d06824c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion __tests__/localMemoryStoreAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
new SdrMessageHandler(),
],
}),
new DIDComm([new DIDCommHttpTransport()]),
new DIDComm(),
new CredentialIssuer(),
new SelectiveDisclosure(),
],
Expand Down
10 changes: 5 additions & 5 deletions __tests__/restAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ import { Resolver } from 'did-resolver'
import { getResolver as ethrDidResolver } from 'ethr-did-resolver'
import { getResolver as webDidResolver } from 'web-did-resolver'
import { IDIDDiscovery, DIDDiscovery } from '../packages/did-discovery'
import { getUniversalResolver } from '../packages/did-resolver/src/universal-resolver'
import { FakeDidProvider, FakeDidResolver } from './utils/fake-did'

// import { getUniversalResolver } from '../packages/did-resolver/src/universal-resolver'
import { DIDCommHttpTransport } from '../packages/did-comm/src/transports/transports'
import { getDidKeyResolver } from '../packages/did-provider-key/build'
import fs from 'fs'

jest.setTimeout(30000)
Expand All @@ -64,8 +65,6 @@ import didComm from './shared/didcomm'
import didCommRemote from './shared/didcommRemote'
import messageHandler from './shared/messageHandler'
import didDiscovery from './shared/didDiscovery'
// import { getUniversalResolver } from '../packages/did-resolver/src/universal-resolver'
import { DIDCommHttpTransport } from '../packages/did-comm/src/transports/transports'

const databaseFile = 'rest-database.sqlite'
const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c'
Expand Down Expand Up @@ -149,7 +148,8 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
resolver: new Resolver({
...ethrDidResolver({ infuraProjectId }),
...webDidResolver(),
key: getUniversalResolver(), // resolve using remote resolver,
// key: getUniversalResolver(), // resolve using remote resolver... when uniresolver becomes more stable,
...getDidKeyResolver(),
...new FakeDidResolver(() => serverAgent as TAgent<IDIDManager>).getDidFakeResolver(),
}),
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/did-comm/src/didcomm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {

import Debug from 'debug'
import { IDIDComm } from './types/IDIDComm'
import { IDIDCommTransport } from './transports/transports'
import { DIDCommHttpTransport, IDIDCommTransport } from './transports/transports'
import {
DIDCommMessageMediaType,
DIDCommMessagePacking,
Expand Down Expand Up @@ -130,7 +130,7 @@ export class DIDComm implements IAgentPlugin {
* Constructor that takes a list of {@link IDIDCommTransport} objects.
* @param transports A list of {@link IDIDCommTransport} objects.
*/
constructor(transports: IDIDCommTransport[]) {
constructor(transports: IDIDCommTransport[] = [new DIDCommHttpTransport()]) {
this.transports = transports
this.methods = {
sendMessageDIDCommAlpha1: this.sendMessageDIDCommAlpha1.bind(this),
Expand Down
77 changes: 39 additions & 38 deletions packages/did-resolver/src/__tests__/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,44 +87,45 @@ describe('@veramo/did-resolver', () => {
})
})

it('should resolve did:key using uniresolver', async () => {
expect.assertions(1)
const { didDocument } = await resolverPlugin.resolveDid({
didUrl: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
})
expect(didDocument).toEqual({
'@context': ['https://w3id.org/did/v0.11'],
id: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
publicKey: [
{
id: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
type: 'Ed25519VerificationKey2018',
controller: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
publicKeyBase58: '2QTnR7atrFu3Y7S6Xmmr4hTsMaL1KDh6Mpe9MgnJugbi',
},
],
authentication: [
'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
],
assertionMethod: [
'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
],
capabilityDelegation: [
'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
],
capabilityInvocation: [
'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
],
keyAgreement: [
{
id: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6LSbgq3GejX88eiAYWmZ9EiddS3GaXodvm8MJJyEH7bqXgz',
type: 'X25519KeyAgreementKey2019',
controller: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
publicKeyBase58: '1eskLvf2fvy5A912VimK3DZRRzgwKayUKbHjpU589vE',
},
],
})
})
//// Uniresolver is too unstable
// it('should resolve did:key using uniresolver', async () => {
// expect.assertions(1)
// const { didDocument } = await resolverPlugin.resolveDid({
// didUrl: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// })
// expect(didDocument).toEqual({
// '@context': ['https://w3id.org/did/v0.11'],
// id: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// publicKey: [
// {
// id: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// type: 'Ed25519VerificationKey2018',
// controller: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// publicKeyBase58: '2QTnR7atrFu3Y7S6Xmmr4hTsMaL1KDh6Mpe9MgnJugbi',
// },
// ],
// authentication: [
// 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// ],
// assertionMethod: [
// 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// ],
// capabilityDelegation: [
// 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// ],
// capabilityInvocation: [
// 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// ],
// keyAgreement: [
// {
// id: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6#z6LSbgq3GejX88eiAYWmZ9EiddS3GaXodvm8MJJyEH7bqXgz',
// type: 'X25519KeyAgreementKey2019',
// controller: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6',
// publicKeyBase58: '1eskLvf2fvy5A912VimK3DZRRzgwKayUKbHjpU589vE',
// },
// ],
// })
// })

it('should fail predictably when unsupported method is resolved', async () => {
expect.assertions(1)
Expand Down

0 comments on commit d06824c

Please sign in to comment.