diff --git a/__tests__/localAgent.test.ts b/__tests__/localAgent.test.ts index 3fb8248fe..42dc80f4a 100644 --- a/__tests__/localAgent.test.ts +++ b/__tests__/localAgent.test.ts @@ -56,6 +56,7 @@ import didComm from './shared/didcomm' import messageHandler from './shared/messageHandler' import didDiscovery from './shared/didDiscovery' import { FakeDidProvider, FakeDidResolver } from './utils/fake-did' +import { DIDCommHttpTransport } from '../packages/did-comm/src/transports/transports' const databaseFile = 'local-database.sqlite' const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c' @@ -152,12 +153,13 @@ const setup = async (options?: IAgentOptions): Promise => { new SdrMessageHandler(), ], }), - new DIDComm(), + new DIDComm([new DIDCommHttpTransport()]), new CredentialIssuer(), new SelectiveDisclosure(), new DIDDiscovery({ providers: [new AliasDiscoveryProvider(), new ProfileDiscoveryProvider()], }), + ...options?.plugins || [], ], }) return true diff --git a/__tests__/localMemoryStoreAgent.test.ts b/__tests__/localMemoryStoreAgent.test.ts index 967013fff..fcefe6894 100644 --- a/__tests__/localMemoryStoreAgent.test.ts +++ b/__tests__/localMemoryStoreAgent.test.ts @@ -49,7 +49,6 @@ import { FakeDidProvider, FakeDidResolver } from './utils/fake-did' const databaseFile = 'local-database2.sqlite' const infuraProjectId = '5ffc47f65c4042ce847ef66a3fa70d4c' -const secretKey = '29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c' let agent: TAgent< IDIDManager & @@ -143,6 +142,7 @@ const setup = async (options?: IAgentOptions): Promise => { new DIDComm(), new CredentialIssuer(), new SelectiveDisclosure(), + ...options?.plugins || [], ], }) return true diff --git a/__tests__/restAgent.test.ts b/__tests__/restAgent.test.ts index 7eacc354f..ff16157a4 100644 --- a/__tests__/restAgent.test.ts +++ b/__tests__/restAgent.test.ts @@ -40,14 +40,15 @@ import { import { AgentRestClient } from '../packages/remote-client/src' import express from 'express' import { Server } from 'http' -import { AgentRouter, RequestWithAgentRouter } from '../packages/remote-server/src' +import { AgentRouter, RequestWithAgentRouter, MessagingRouter } from '../packages/remote-server/src' 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) @@ -61,6 +62,7 @@ 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 messageHandler from './shared/messageHandler' import didDiscovery from './shared/didDiscovery' @@ -146,7 +148,8 @@ const setup = async (options?: IAgentOptions): Promise => { 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).getDidFakeResolver(), }), }), @@ -160,12 +163,13 @@ const setup = async (options?: IAgentOptions): Promise => { new SdrMessageHandler(), ], }), - new DIDComm(), + new DIDComm([new DIDCommHttpTransport()]), new CredentialIssuer(), new SelectiveDisclosure(), new DIDDiscovery({ providers: [new AliasDiscoveryProvider(), new ProfileDiscoveryProvider()], }), + ...options?.plugins || [], ], }) @@ -180,6 +184,13 @@ const setup = async (options?: IAgentOptions): Promise => { return new Promise((resolve) => { const app = express() app.use(basePath, requestWithAgent, agentRouter) + app.use( + '/messaging', + requestWithAgent, + MessagingRouter({ + metaData: { type: 'DIDComm', value: 'integration test' }, + }), + ) restServer = app.listen(port, () => { resolve(true) }) @@ -205,5 +216,6 @@ describe('REST integration tests', () => { didManager(testContext) messageHandler(testContext) didComm(testContext) + didCommRemote(testContext) didDiscovery(testContext) }) diff --git a/__tests__/shared/didcommRemote.ts b/__tests__/shared/didcommRemote.ts new file mode 100644 index 000000000..1dcbc533d --- /dev/null +++ b/__tests__/shared/didcommRemote.ts @@ -0,0 +1,126 @@ +import { + TAgent, + IDIDManager, + IKeyManager, + IIdentifier, + IResolver, + IEventListener, + IAgentOptions, +} from '../../packages/core/src' +import { IDIDComm } from '../../packages/did-comm/src' + +type ConfiguredAgent = TAgent + +const DIDCommEventSniffer: IEventListener = { + eventTypes: ['DIDCommV2Message-sent', 'DIDCommV2Message-received'], + onEvent: jest.fn(), +} + +export default (testContext: { + getAgent: () => ConfiguredAgent + setup: (options?: IAgentOptions) => Promise + tearDown: () => Promise +}) => { + describe('DID comm remote', () => { + let agent: ConfiguredAgent + let sender: IIdentifier + let receiver: IIdentifier + + beforeAll(async () => { + await testContext.setup({ plugins: [DIDCommEventSniffer] }) + agent = testContext.getAgent() + + sender = await agent.didManagerImport({ + did: 'did:fake:z6MkgbqNU4uF9NKSz5BqJQ4XKVHuQZYcUZP8pXGsJC8nTHwo', + keys: [ + { + type: 'Ed25519', + kid: 'didcomm-senderKey-1', + publicKeyHex: '1fe9b397c196ab33549041b29cf93be29b9f2bdd27322f05844112fad97ff92a', + privateKeyHex: + 'b57103882f7c66512dc96777cbafbeb2d48eca1e7a867f5a17a84e9a6740f7dc1fe9b397c196ab33549041b29cf93be29b9f2bdd27322f05844112fad97ff92a', + kms: 'local', + }, + ], + services: [ + { + id: 'msg1', + type: 'DIDCommMessaging', + serviceEndpoint: 'http://localhost:3002/messaging', + }, + ], + provider: 'did:fake', + alias: 'sender', + }) + + receiver = await agent.didManagerImport({ + did: 'did:fake:z6MkrPhffVLBZpxH7xvKNyD4sRVZeZsNTWJkLdHdgWbfgNu3', + keys: [ + { + type: 'Ed25519', + kid: 'didcomm-receiverKey-1', + publicKeyHex: 'b162e405b6485eff8a57932429b192ec4de13c06813e9028a7cdadf0e2703636', + privateKeyHex: + '19ed9b6949cfd0f9a57e30f0927839a985fa699491886ebcdda6a954d869732ab162e405b6485eff8a57932429b192ec4de13c06813e9028a7cdadf0e2703636', + kms: 'local', + }, + ], + services: [ + { + id: 'msg2', + type: 'DIDCommMessaging', + serviceEndpoint: 'http://localhost:3002/messaging', + }, + ], + provider: 'did:fake', + alias: 'receiver', + }) + return true + }) + afterAll(testContext.tearDown) + + it('should send a message', async () => { + expect.assertions(3) + + const message = { + type: 'test', + to: receiver.did, + from: sender.did, + id: 'test', + body: { hello: 'world' }, + } + const packedMessage = await agent.packDIDCommMessage({ + packing: 'authcrypt', + message, + }) + const result = await agent.sendDIDCommMessage({ + messageId: '123', + packedMessage, + recipientDidUrl: receiver.did, + }) + + expect(result).toBeTruthy() + expect(DIDCommEventSniffer.onEvent).toHaveBeenCalledWith( + { data: '123', type: 'DIDCommV2Message-sent' }, + expect.anything(), + ) + // in our case, it is the same agent that is receiving the messages + expect(DIDCommEventSniffer.onEvent).toHaveBeenCalledWith( + { + data: { + message: { + body: { hello: 'world' }, + from: 'did:fake:z6MkgbqNU4uF9NKSz5BqJQ4XKVHuQZYcUZP8pXGsJC8nTHwo', + id: 'test', + to: 'did:fake:z6MkrPhffVLBZpxH7xvKNyD4sRVZeZsNTWJkLdHdgWbfgNu3', + type: 'test', + }, + metaData: { packing: 'authcrypt' }, + }, + type: 'DIDCommV2Message-received', + }, + expect.anything(), + ) + }) + }) +} diff --git a/packages/did-comm/plugin.schema.json b/packages/did-comm/plugin.schema.json index d7381d793..584ff210d 100644 --- a/packages/did-comm/plugin.schema.json +++ b/packages/did-comm/plugin.schema.json @@ -103,39 +103,22 @@ "packedMessage": { "$ref": "#/components/schemas/IPackedDIDCommMessage" }, - "returnTransport": { - "$ref": "#/components/schemas/IDIDCommTransport" + "messageId": { + "type": "string" }, - "recipientDID": { + "returnTransportId": { "type": "string" - } - }, - "required": [ - "packedMessage", - "recipientDID" - ] - }, - "IDIDCommTransport": { - "type": "object", - "properties": { - "id": { + }, + "recipientDidUrl": { "type": "string" } }, "required": [ - "id" - ] - }, - "ISendDIDCommMessageResult": { - "type": "object", - "properties": { - "sent": { - "type": "boolean" - }, - "error": { - "type": "string" - } - } + "packedMessage", + "messageId", + "recipientDidUrl" + ], + "description": "The input to the {@link DIDComm.sendDIDCommMessage } method. The provided `messageId` will be used in the emitted event to allow event/message correlation." }, "ISendMessageDIDCommAlpha1Args": { "type": "object", @@ -488,12 +471,12 @@ } }, "sendDIDCommMessage": { - "description": "TODO: add docs here", + "description": "Sends the given message to the recipient. If a return transport is provided it will be checked whether the parent thread allows reusing the route. You cannot reuse the transport if the message was forwarded from a DIDComm mediator.", "arguments": { "$ref": "#/components/schemas/ISendDIDCommMessageArgs" }, "returnType": { - "$ref": "#/components/schemas/ISendDIDCommMessageResult" + "type": "string" } }, "sendMessageDIDCommAlpha1": { diff --git a/packages/did-comm/src/action-handler.ts b/packages/did-comm/src/didcomm.ts similarity index 84% rename from packages/did-comm/src/action-handler.ts rename to packages/did-comm/src/didcomm.ts index 997a53438..24b631eeb 100644 --- a/packages/did-comm/src/action-handler.ts +++ b/packages/did-comm/src/didcomm.ts @@ -23,7 +23,7 @@ import { verifyJWS, } from 'did-jwt' import { DIDDocument, parse as parseDidUrl, VerificationMethod } from 'did-resolver' -import { schema } from './' +import { schema } from '.' import { v4 as uuidv4 } from 'uuid' import * as u8a from 'uint8arrays' import { convertPublicKeyToX25519 } from '@stablelib/ed25519' @@ -42,6 +42,7 @@ import { import Debug from 'debug' import { IDIDComm } from './types/IDIDComm' +import { DIDCommHttpTransport, IDIDCommTransport } from './transports/transports' import { DIDCommMessageMediaType, DIDCommMessagePacking, @@ -96,22 +97,17 @@ export interface IPackDIDCommMessageArgs { keyRef?: string } -export interface IDIDCommTransport { - id: string - // FIXME: TODO: other potential stuff - - // sendRawMessage(args: xyz, context: xyz) -} - +/** + * The input to the {@link DIDComm.sendDIDCommMessage} method. + * The provided `messageId` will be used in the emitted + * event to allow event/message correlation. + * @beta + */ export interface ISendDIDCommMessageArgs { packedMessage: IPackedDIDCommMessage - returnTransport?: IDIDCommTransport - recipientDID: string -} - -export interface ISendDIDCommMessageResult { - sent?: boolean - error?: string + messageId: string + returnTransportId?: string + recipientDidUrl: string } /** @@ -124,11 +120,18 @@ export interface ISendDIDCommMessageResult { * @beta */ export class DIDComm implements IAgentPlugin { + readonly transports: IDIDCommTransport[] + /** Plugin methods */ readonly methods: IDIDComm readonly schema = schema.IDIDComm - constructor() { + /** + * Constructor that takes a list of {@link IDIDCommTransport} objects. + * @param transports A list of {@link IDIDCommTransport} objects. + */ + constructor(transports: IDIDCommTransport[] = [new DIDCommHttpTransport()]) { + this.transports = transports this.methods = { sendMessageDIDCommAlpha1: this.sendMessageDIDCommAlpha1.bind(this), getDIDCommMessageMediaType: this.getDidCommMessageMediaType.bind(this), @@ -446,28 +449,78 @@ export class DIDComm implements IAgentPlugin { return { msgObj, mediaType } } + private findPreferredDIDCommService(services: any) { + // FIXME: TODO: get preferred service endpoint according to configuration; now defaulting to first service + return services[0] + } + /** {@inheritdoc IDIDComm.sendDIDCommMessage} */ async sendDIDCommMessage( args: ISendDIDCommMessageArgs, - context: IAgentContext, - ): Promise { - const { packedMessage, returnTransport, recipientDID } = args - // let transport: IDIDCommTransport - if (returnTransport) { - // FIXME: TODO: transport handling - // check if previous message was ok with reusing transport? + context: IAgentContext, + ): Promise { + const { packedMessage, returnTransportId, recipientDidUrl, messageId } = args + + if (returnTransportId) { + // FIXME: TODO: check if previous message was ok with reusing transport? // if so, retrieve transport from transport manager - // transport = this.transports.get(returnTransport.id) - } else { - // FIXME: TODO: get transport for recipientDID - // resolve(recipientDID) - // get service block - // get transport for service block + //transport = this.findDIDCommTransport(returnTransportId) + throw new Error(`not_supported: return routes not supported yet`) + } + + const result = await context.agent.resolveDid({ didUrl: `${recipientDidUrl}` }) + const err = result.didResolutionMetadata.error + const msg = result.didResolutionMetadata.message + const didDoc = result.didDocument + if (!didDoc || err) { + throw new Error( + `resolver_error: could not resolve DID document for '${recipientDidUrl}': ${err} ${msg}`, + ) + } + + const services = didDoc.service?.filter( + (service: any) => service.type === 'DIDCommMessaging', + // FIXME: TODO: only send the message if the service section either explicitly supports + // `didcomm/v2`, or no `accept` property is present. + ) + if (!services || services.length === 0) { + throw new Error( + `not_found: could not find DIDComm Messaging service in DID document for '${recipientDidUrl}'`, + ) + } + + const service = this.findPreferredDIDCommService(services) + if (!service) { + throw new Error( + `not_found: could not find preferred DIDComm Messaging service in DID document for '${recipientDidUrl}'`, + ) } - // transport.sendRawMessage(...) + // FIXME: TODO: wrap forward messages based on service entry + + const transports = this.transports.filter( + (t) => t.isServiceSupported(service) && (!returnTransportId || t.id === returnTransportId), + ) + if (!transports || transports.length < 1) { + throw new Error('not_found: no transport type found for service: ' + JSON.stringify(service)) + } + + // TODO: better strategy for selecting the transport if multiple transports apply + const transport = transports[0] + + try { + const response = await transport.send(service, packedMessage.message) + if (response.error) { + throw new Error( + `Error when sending DIDComm message through transport with id: '${transport.id}': ${response.error}`, + ) + } + } catch (e) { + throw new Error(`Cannot send DIDComm message through transport with id: '${transport.id}': ${e}`) + } - throw Error('FIXME: TODO: sendDIDCommMessage not implemented yet') + context.agent.emit('DIDCommV2Message-sent', messageId) + return transport.id } /** {@inheritdoc IDIDComm.sendMessageDIDCommAlpha1} */ diff --git a/packages/did-comm/src/index.ts b/packages/did-comm/src/index.ts index 86fb5739f..7a8712411 100644 --- a/packages/did-comm/src/index.ts +++ b/packages/did-comm/src/index.ts @@ -11,7 +11,7 @@ export { ISendMessageDIDCommAlpha1Args, IPackDIDCommMessageArgs, IUnpackDIDCommMessageArgs, -} from './action-handler' +} from './didcomm' export * from './types/message-types' export * from './types/utility-types' export * from './types/IDIDComm' diff --git a/packages/did-comm/src/message-handler.ts b/packages/did-comm/src/message-handler.ts index 09f5ed9a8..109f713f4 100644 --- a/packages/did-comm/src/message-handler.ts +++ b/packages/did-comm/src/message-handler.ts @@ -108,20 +108,18 @@ export class DIDCommMessageHandler extends AbstractMessageHandler { expires_time: expiresAt, body: data, } = unpackedMessage.message - message = { - ...message, - type, - to, - from, - id, - threadId, - createdAt, - expiresAt, - data, - } as Message + + message.type = type + message.to = to + message.from = from + message.id = id + message.threadId = threadId + message.createdAt = createdAt + message.expiresAt = expiresAt + message.data = data message.addMetaData({ type: 'didCommMetaData', value: JSON.stringify(unpackedMessage.metaData) }) - context.agent.emit('DIDCommV2Message', unpackedMessage) + context.agent.emit('DIDCommV2Message-received', unpackedMessage) return message } catch (e) { diff --git a/packages/did-comm/src/transports/transports.ts b/packages/did-comm/src/transports/transports.ts new file mode 100644 index 000000000..321aff69d --- /dev/null +++ b/packages/did-comm/src/transports/transports.ts @@ -0,0 +1,127 @@ +import 'cross-fetch/polyfill' +import { v4 as uuidv4 } from 'uuid' + +/** + * Result interface for sending DIDComm messages through + * {@link IDIDCommTransport.send}. + * @beta + */ +export interface IDIDCommTransportResult { + result?: string + error?: string +} + +/** + * Common interface for transports that can be used in the + * {@link DIDComm} module. + * @beta + */ +export interface IDIDCommTransport { + /** + * Identifier of this transport that can be used in case the + * message thread supports reusing the transport connection. + */ + id: string + + /** + * Returns `true` if this transport is suitable for the provided + * DID Document service section, otherwise `false`. + * @param service The DID Document service section + * @beta + */ + isServiceSupported(service: any): boolean + + /** + * Sends the provided raw message (without further processing) to + * the service endpoint defined in the provided DID Document service + * section. + * + * @param service The DID Document service section that contains + * a `serviceEndpoint` entry. + * @param message The message to be sent. + * @beta + */ + send(service: any, message: string): Promise +} + +/** + * Abstract implementation of {@link IDIDCommTransport}. + * @beta + */ +export abstract class AbstractDIDCommTransport implements IDIDCommTransport { + id: string + + /** + * Shared constructor that takes an optional identifier (for reusing) for + * this {@link IDIDCommTransport}. + * @param id An optional identifier for this {@link IDIDCommTransport}. + * @beta + */ + constructor(id?: string) { + this.id = id || uuidv4() + } + + /** {@inheritdoc IDIDCommTransport.isServiceSupported} */ + abstract isServiceSupported(service: any): boolean + + /** {@inheritdoc IDIDCommTransport.send} */ + abstract send(service: any, message: string): Promise +} + +/** + * Implementation of {@link IDIDCommTransport} to provide a simple + * transport based on HTTP(S) requests. + * @beta + */ +export class DIDCommHttpTransport extends AbstractDIDCommTransport { + /** + * Defines the default HTTP method to use if not specified + * in the DID Document service entry of the recipient. + */ + httpMethod: 'post' | 'get' + + /** + * Creates a new {@link DIDCommHttpTransport}. + * @param httpMethod Default HTTP method if not specified in the service + * section. + */ + constructor(httpMethod?: 'post' | 'get') { + super() + this.httpMethod = httpMethod || 'post' + } + + /** {@inheritdoc AbstractDIDCommTransport.isServiceSupported} */ + isServiceSupported(service: any) { + // FIXME: TODO: addtionally handle serviceEndpoint objects in did docs + return ( + typeof service.serviceEndpoint === 'string' && + (service.serviceEndpoint.startsWith('http://') || service.serviceEndpoint.startsWith('https://')) + ) + } + + /** {@inheritdoc AbstractDIDCommTransport.send} */ + async send(service: any, message: string): Promise { + try { + const response = await fetch(service.serviceEndpoint, { + method: this.httpMethod, + body: message, + }) + + let result + if (response.ok) { + result = { + result: 'successfully sent message: ' + response.statusText, + } + } else { + result = { + error: 'failed to send message: ' + response.statusText, + } + } + return result + } catch (e) { + return { + error: 'failed to send message: ' + e, + } + } + } +} diff --git a/packages/did-comm/src/types/IDIDComm.ts b/packages/did-comm/src/types/IDIDComm.ts index cbd475a34..5df43d34e 100644 --- a/packages/did-comm/src/types/IDIDComm.ts +++ b/packages/did-comm/src/types/IDIDComm.ts @@ -10,10 +10,9 @@ import { import { IPackDIDCommMessageArgs, ISendDIDCommMessageArgs, - ISendDIDCommMessageResult, ISendMessageDIDCommAlpha1Args, IUnpackDIDCommMessageArgs, -} from '../action-handler' +} from '../didcomm' import { DIDCommMessageMediaType, IPackedDIDCommMessage, IUnpackedDIDCommMessage } from './message-types' /** @@ -74,19 +73,24 @@ export interface IDIDComm extends IPluginMethodMap { ): Promise /** - * TODO: add docs here + * Sends the given message to the recipient. If a return transport is provided + * it will be checked whether the parent thread allows reusing the route. You cannot + * reuse the transport if the message was forwarded from a DIDComm mediator. * - * @param args - TBD - * @param context - TBD + * Emits an eventType 'DIDCommV2Message-sent' that contains the message id of + * packed DIDComm message {@link IPackedDIDCommMessage} after the message was sent. * - * @returns TBD + * @param args - An object containing the message, recipient information and optional + * information about the transport that should be used. + * @param context - This method requires an agent that also has {@link @veramo/core#IResolver} + * plugins in use. When calling this method, the `context` is supplied automatically by the framework. + * + * @returns The transport id that was used to send the message. It throws an error in case something + * went wrong. * * @beta */ - sendDIDCommMessage( - args: ISendDIDCommMessageArgs, - context: IAgentContext, - ): Promise + sendDIDCommMessage(args: ISendDIDCommMessageArgs, context: IAgentContext): Promise /** * diff --git a/packages/did-resolver/src/__tests__/integration.test.ts b/packages/did-resolver/src/__tests__/integration.test.ts index d7ca1f731..ce12c8e85 100644 --- a/packages/did-resolver/src/__tests__/integration.test.ts +++ b/packages/did-resolver/src/__tests__/integration.test.ts @@ -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) diff --git a/packages/remote-server/src/messaging-router.ts b/packages/remote-server/src/messaging-router.ts index ae4be5945..0cfd0673e 100644 --- a/packages/remote-server/src/messaging-router.ts +++ b/packages/remote-server/src/messaging-router.ts @@ -36,7 +36,6 @@ export const MessagingRouter = (options: MessagingRouterOptions): Router => { }) if (message) { - console.log('Received message', message.type, message.id) res.json({ id: message.id }) } } catch (e) {