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

feat: didcomm messaging using did:ethr #744

Merged
merged 6 commits into from
Nov 11, 2021
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
5 changes: 5 additions & 0 deletions __tests__/initial.migration.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* This suite runs through a few agent operations using data that was created before
* TypeORM migrations were available (before Veramo 3.0.0)
*/

import { createAgent, TAgent, IDIDManager, IResolver, IKeyManager, IDataStore } from '../packages/core/src'
import { DIDResolverPlugin } from '../packages/did-resolver/src'
import { EthrDIDProvider } from '../packages/did-provider-ethr/src'
Expand Down
36 changes: 32 additions & 4 deletions __tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* This runs a suite of ./shared tests using an agent configured for local operations,
* using a SQLite db for storage of credentials, presentations, messages as well as keys and DIDs.
*
* This suite also runs a ganache local blockchain to run through some examples of DIDComm using did:ethr identifiers.
*/

import {
createAgent,
TAgent,
Expand Down Expand Up @@ -41,6 +48,7 @@ import {
import { createConnection, Connection } from 'typeorm'

import { FakeDidProvider, FakeDidResolver } from './utils/fake-did'
import { createGanacheProvider } from './utils/ganache-provider'
import { Resolver } from 'did-resolver'
import { getResolver as ethrDidResolver } from 'ethr-did-resolver'
import { getResolver as webDidResolver } from 'web-did-resolver'
Expand All @@ -57,10 +65,11 @@ import saveClaims from './shared/saveClaims'
import documentationExamples from './shared/documentationExamples'
import keyManager from './shared/keyManager'
import didManager from './shared/didManager'
import didComm from './shared/didcomm'
import didCommPacking from './shared/didCommPacking'
import messageHandler from './shared/messageHandler'
import didDiscovery from './shared/didDiscovery'
import dbInitOptions from './shared/dbInitOptions'
import didCommWithEthrDidFlow from './shared/didCommWithEthrDidFlow'

const infuraProjectId = '3586660d179141e3801c3895de1c2eba'
const secretKey = '29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c'
Expand All @@ -81,7 +90,7 @@ let dbConnection: Promise<Connection>
let databaseFile: string

const setup = async (options?: IAgentOptions): Promise<boolean> => {
databaseFile = options?.context?.databaseFile || 'local-database.sqlite'
databaseFile = options?.context?.databaseFile || `./tmp/local-database-${Math.random().toPrecision(5)}.sqlite`
dbConnection = createConnection({
name: options?.context?.['dbName'] || 'test',
type: 'sqlite',
Expand All @@ -95,6 +104,8 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
...options?.context?.dbConnectionOptions,
})

const { provider, registry } = await createGanacheProvider()

agent = createAgent<
IDIDManager &
IKeyManager &
Expand Down Expand Up @@ -142,6 +153,12 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
rpcUrl: 'https://arbitrum-rinkeby.infura.io/v3/' + infuraProjectId,
registry: '0x8f54f62CA28D481c3C30b1914b52ef935C1dF820',
}),
'did:ethr:ganache': new EthrDIDProvider({
defaultKms: 'local',
network: 1337,
web3Provider: provider,
registry,
}),
'did:web': new WebDIDProvider({
defaultKms: 'local',
}),
Expand All @@ -153,7 +170,17 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDResolverPlugin({
resolver: new Resolver({
...ethrDidResolver({ infuraProjectId }),
...ethrDidResolver({
infuraProjectId,
networks: [
{
name: 'ganache',
chainId: 1337,
provider,
registry,
},
],
}),
...webDidResolver(),
...getDidKeyResolver(),
...new FakeDidResolver(() => agent).getDidFakeResolver(),
Expand Down Expand Up @@ -210,7 +237,8 @@ describe('Local integration tests', () => {
keyManager(testContext)
didManager(testContext)
messageHandler(testContext)
didComm(testContext)
didCommPacking(testContext)
didDiscovery(testContext)
dbInitOptions(testContext)
didCommWithEthrDidFlow(testContext)
})
11 changes: 8 additions & 3 deletions __tests__/localMemoryStoreAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* This runs a suite of ./shared tests using an agent configured for local operations,
* using a SQLite db for storage of credentials and an in-memory store for keys and DIDs.
*
*/
import {
createAgent,
TAgent,
Expand Down Expand Up @@ -45,10 +50,10 @@ import saveClaims from './shared/saveClaims'
import documentationExamples from './shared/documentationExamples'
import keyManager from './shared/keyManager'
import didManager from './shared/didManager'
import didComm from './shared/didcomm'
import didCommPacking from './shared/didCommPacking'
import messageHandler from './shared/messageHandler'

const databaseFile = 'local-database2.sqlite'
const databaseFile = `./tmp/local-database2-${Math.random().toPrecision(5)}.sqlite`
const infuraProjectId = '3586660d179141e3801c3895de1c2eba'

let agent: TAgent<
Expand Down Expand Up @@ -187,5 +192,5 @@ describe('Local in-memory integration tests', () => {
keyManager(testContext)
didManager(testContext)
messageHandler(testContext)
didComm(testContext)
didCommPacking(testContext)
})
17 changes: 12 additions & 5 deletions __tests__/restAgent.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* This runs a suite of ./shared tests using an agent configured for remote operations.
* There is a local agent that only uses @veramo/remove-client and a remote agent that provides the actual functionality.
*
* This suite also runs a messaging server to run through some examples of DIDComm using did:fake identifiers.
* See didWithFakeDidFlow() for more details.
*/
import 'cross-fetch/polyfill'
import {
Agent,
Expand Down Expand Up @@ -62,12 +69,12 @@ import webDidFlow from './shared/webDidFlow'
import documentationExamples from './shared/documentationExamples'
import keyManager from './shared/keyManager'
import didManager from './shared/didManager'
import didComm from './shared/didcomm'
import didCommRemote from './shared/didcommRemote'
import didCommPacking from './shared/didCommPacking'
import didWithFakeDidFlow from './shared/didCommWithFakeDidFlow'
import messageHandler from './shared/messageHandler'
import didDiscovery from './shared/didDiscovery'

const databaseFile = 'rest-database.sqlite'
const databaseFile = `./tmp/rest-database-${Math.random().toPrecision(5)}.sqlite`
const infuraProjectId = '3586660d179141e3801c3895de1c2eba'
const secretKey = '29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c'
const port = 3002
Expand Down Expand Up @@ -234,7 +241,7 @@ describe('REST integration tests', () => {
keyManager(testContext)
didManager(testContext)
messageHandler(testContext)
didComm(testContext)
didCommRemote(testContext)
didCommPacking(testContext)
didWithFakeDidFlow(testContext)
didDiscovery(testContext)
})
File renamed without changes.
Loading