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(cli): veramo discover did -q alice #600

Merged
merged 1 commit into from
Jul 6, 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
9 changes: 9 additions & 0 deletions packages/cli/default/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ constants:
- didManagerAddService
- didManagerRemoveService
- resolveDid
- discoverDid
- dataStoreGetMessage
- dataStoreSaveMessage
- dataStoreGetVerifiableCredential
Expand Down Expand Up @@ -266,6 +267,13 @@ didManager:
$args:
- defaultKms: local

didDiscovery:
$require: '@veramo/did-discovery#DIDDiscovery'
$args:
- providers:
- $require: '@veramo/did-manager#AliasDiscoveryProvider'
- $require: '@veramo/data-store#ProfileDiscoveryProvider'

# Agent
agent:
$require: '@veramo/core#Agent'
Expand All @@ -275,6 +283,7 @@ agent:
- $ref: /keyManager
- $ref: /didManager
- $ref: /didResolver
- $ref: /didDiscovery
- $ref: /messageHandler
- $require: '@veramo/did-comm#DIDComm'
- $require: '@veramo/credential-w3c#CredentialIssuer'
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"scripts": {
"build": "tsc",
"watch": "tsc -b --watch",
"update-veramo-next": "yarn add @veramo/core@next @veramo/remote-client@next @veramo/remote-server@next @veramo/did-provider-key@next @veramo/did-resolver@next @veramo/did-jwt@next @veramo/credential-w3c@next @veramo/did-provider-ethr@next @veramo/did-provider-web@next @veramo/did-comm@next @veramo/kms-local@next @veramo/selective-disclosure@next @veramo/data-store@next @veramo/key-manager@next @veramo/message-handler@next @veramo/did-manager@next @veramo/url-handler@next",
"update-veramo-latest": "yarn add @veramo/core@latest @veramo/remote-client@latest @veramo/remote-server@latest @veramo/did-provider-key@latest @veramo/did-resolver@latest @veramo/did-jwt@latest @veramo/credential-w3c@latest @veramo/did-provider-ethr@latest @veramo/did-provider-web@latest @veramo/did-comm@latest @veramo/kms-local@latest @veramo/selective-disclosure@latest @veramo/data-store@latest @veramo/key-manager@latest @veramo/message-handler@latest @veramo/did-manager@latest @veramo/url-handler@latest"
"update-veramo-next": "yarn add @veramo/core@next @veramo/discovery@next @veramo/remote-client@next @veramo/remote-server@next @veramo/did-provider-key@next @veramo/did-resolver@next @veramo/did-jwt@next @veramo/credential-w3c@next @veramo/did-provider-ethr@next @veramo/did-provider-web@next @veramo/did-comm@next @veramo/kms-local@next @veramo/selective-disclosure@next @veramo/data-store@next @veramo/key-manager@next @veramo/message-handler@next @veramo/did-manager@next @veramo/url-handler@next",
"update-veramo-latest": "yarn add @veramo/core@latest @veramo/discovery@latest @veramo/remote-client@latest @veramo/remote-server@latest @veramo/did-provider-key@latest @veramo/did-resolver@latest @veramo/did-jwt@latest @veramo/credential-w3c@latest @veramo/did-provider-ethr@latest @veramo/did-provider-web@latest @veramo/did-comm@latest @veramo/kms-local@latest @veramo/selective-disclosure@latest @veramo/data-store@latest @veramo/key-manager@latest @veramo/message-handler@latest @veramo/did-manager@latest @veramo/url-handler@latest"
},
"dependencies": {
"@microsoft/api-extractor": "7.17.1",
Expand All @@ -22,6 +22,7 @@
"@veramo/credential-w3c": "^1.2.0",
"@veramo/data-store": "^1.2.0",
"@veramo/did-comm": "^1.2.0",
"@veramo/did-discovery": "^1.2.0",
"@veramo/did-jwt": "^1.2.0",
"@veramo/did-manager": "^1.2.0",
"@veramo/did-provider-ethr": "^1.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import './presentation'
import './explore'
import './sdr'
import './message'
import './discover'
import './version'
import './execute'
import './server'
Expand Down
33 changes: 33 additions & 0 deletions packages/cli/src/discover.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { getAgent } from './setup'
import program from 'commander'
import { printTable } from 'console-table-printer'

const discover = program.command('discover').description('Discovery')

discover
.command('did')
.description('did discovery')
.option('-q, --query <string>', 'Query string')

.action(async (cmd) => {
const agent = getAgent(program.opts().config)

const response = await agent.discoverDid({ query: cmd.query })
const list: any = []

response.results.forEach(r => {
r.matches.forEach(m => {
list.push({
provider: r.provider,
did: m.did
})
})
})

if (list.length > 0) {
printTable(list)
} else {
console.log('No dids discovered')
}
})

5 changes: 4 additions & 1 deletion packages/cli/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { ICredentialIssuer } from '@veramo/credential-w3c'
import { ISelectiveDisclosure } from '@veramo/selective-disclosure'
import { IDIDComm } from '@veramo/did-comm'
import { IDataStoreORM } from '@veramo/data-store'
import { IDIDDiscovery } from '@veramo/did-discovery'

const fs = require('fs')
import { createAgentFromConfig } from './lib/agentCreator'

Expand Down Expand Up @@ -32,7 +34,8 @@ export type EnabledInterfaces = IDIDManager &
IMessageHandler &
IDIDComm &
ICredentialIssuer &
ISelectiveDisclosure
ISelectiveDisclosure &
IDIDDiscovery

export type ConfiguredAgent = TAgent<EnabledInterfaces>

Expand Down
1 change: 1 addition & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{ "path": "../credential-w3c" },
{ "path": "../data-store" },
{ "path": "../did-comm" },
{ "path": "../did-discovery" },
{ "path": "../did-jwt" },
{ "path": "../did-manager" },
{ "path": "../did-provider-ethr" },
Expand Down