diff --git a/packages/cli/src/commands/dids.ts b/packages/cli/src/commands/dids.ts index 8fa50166..e574b68f 100644 --- a/packages/cli/src/commands/dids.ts +++ b/packages/cli/src/commands/dids.ts @@ -3,6 +3,7 @@ import inquirer from 'inquirer'; import axios from 'axios'; import {IWallet} from '@docknetwork/wallet-sdk-core/lib/types'; import {createDIDProvider} from '@docknetwork/wallet-sdk-core/src/did-provider'; +import {relayService} from '@docknetwork/wallet-sdk-wasm/lib/services/relay-service'; import {getWallet} from '../helpers'; const didsCommand = new Command('dids').description('list, create'); @@ -40,4 +41,25 @@ didsCommand console.log(did); }); +/** + * Resolve a DIDComm message + * Ex.: didcomm://https://relay.dock.io/read/659ed4b1655cf81a6a35e140' + */ +didsCommand + .command('resolve-message') + .option('-m, --message ', 'Message to be resolved') + .description('Resolve didcomm message') + .action(async ({ message }) => { + const wallet: IWallet = await getWallet(); + const didProvider = createDIDProvider({wallet}); + const keyPairDocs = await didProvider.getDIDKeyPairs(); + + const messsage = await relayService.resolveDidcommMessage({ + message, + keyPairDocs, + }); + + console.log(messsage); + }); + export {didsCommand}; diff --git a/packages/relay-service/src/index.js b/packages/relay-service/src/index.js index a045e0df..f94722c8 100644 --- a/packages/relay-service/src/index.js +++ b/packages/relay-service/src/index.js @@ -232,7 +232,12 @@ export async function resolveDidcommMessage({keyPairDocs, message}) { didCommRecipients.find(did => did.indexOf(doc.controller) > -1), ); - assert(!!keyPairDoc, `keyPairDoc not found for did ${message.to}`); + assert( + !!keyPairDoc, + `keyPairDoc not found for recipients ${JSON.stringify( + didCommRecipients, + )}`, + ); const keyAgreementKey = await getDerivedAgreementKey(keyPairDoc); result = await didcommDecrypt(jwe, keyAgreementKey); }