diff --git a/packages/cli/default/default.yml b/packages/cli/default/default.yml index 43630dd5b..febc7989c 100644 --- a/packages/cli/default/default.yml +++ b/packages/cli/default/default.yml @@ -28,6 +28,7 @@ constants: - didManagerAddService - didManagerRemoveService - resolveDid + - discoverDid - dataStoreGetMessage - dataStoreSaveMessage - dataStoreGetVerifiableCredential @@ -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' @@ -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' diff --git a/packages/cli/package.json b/packages/cli/package.json index 14f54d1d5..901380ae4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -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", @@ -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", diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index cab6bb668..049848c7a 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -9,6 +9,7 @@ import './presentation' import './explore' import './sdr' import './message' +import './discover' import './version' import './execute' import './server' diff --git a/packages/cli/src/discover.ts b/packages/cli/src/discover.ts new file mode 100644 index 000000000..e713e9862 --- /dev/null +++ b/packages/cli/src/discover.ts @@ -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 ', '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') + } + }) + diff --git a/packages/cli/src/setup.ts b/packages/cli/src/setup.ts index 9787f3dfa..7e52d99d6 100644 --- a/packages/cli/src/setup.ts +++ b/packages/cli/src/setup.ts @@ -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' @@ -32,7 +34,8 @@ export type EnabledInterfaces = IDIDManager & IMessageHandler & IDIDComm & ICredentialIssuer & - ISelectiveDisclosure + ISelectiveDisclosure & + IDIDDiscovery export type ConfiguredAgent = TAgent diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index dde2a0e91..d6d471b89 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -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" },