From 40ca0a95e337b59e58f736c2be2b45c25bd0b8b6 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Thu, 1 Jun 2023 14:58:27 +0300 Subject: [PATCH 1/2] feat: exporting didcomm mediation utils --- .../coordinate-mediation-message-handler.ts | 61 +++++++++++++++++++ packages/did-comm/src/protocols/index.ts | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/packages/did-comm/src/protocols/coordinate-mediation-message-handler.ts b/packages/did-comm/src/protocols/coordinate-mediation-message-handler.ts index 7c93bf117..e903bb392 100644 --- a/packages/did-comm/src/protocols/coordinate-mediation-message-handler.ts +++ b/packages/did-comm/src/protocols/coordinate-mediation-message-handler.ts @@ -9,10 +9,34 @@ const debug = Debug('veramo:did-comm:coordinate-mediation-message-handler') type IContext = IAgentContext +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ export const MEDIATE_REQUEST_MESSAGE_TYPE = 'https://didcomm.org/coordinate-mediation/2.0/mediate-request' + +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ export const MEDIATE_GRANT_MESSAGE_TYPE = 'https://didcomm.org/coordinate-mediation/2.0/mediate-grant' + +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ export const MEDIATE_DENY_MESSAGE_TYPE = 'https://didcomm.org/coordinate-mediation/2.0/mediate-deny' +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ +export const STATUS_REQUEST_MESSAGE_TYPE = 'https://didcomm.org/messagepickup/3.0/status-request' + +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ +export const DELIVERY_REQUEST_MESSAGE_TYPE = 'https://didcomm.org/messagepickup/3.0/delivery-request' + +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ export function createMediateRequestMessage( recipientDidUrl: string, mediatorDidUrl: string, @@ -28,6 +52,9 @@ export function createMediateRequestMessage( } } +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ export function createMediateGrantMessage( recipientDidUrl: string, mediatorDidUrl: string, @@ -46,6 +73,40 @@ export function createMediateGrantMessage( } } +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ +export function createStatusRequestMessage( + recipientDidUrl: string, + mediatorDidUrl: string, +): IDIDCommMessage { + return { + id: v4(), + type: STATUS_REQUEST_MESSAGE_TYPE, + to: mediatorDidUrl, + from: recipientDidUrl, + return_route: 'all', + body: {}, + } +} + +/** + * @beta This API may change without a BREAKING CHANGE notice. + */ +export function createDeliveryRequestMessage( + recipientDidUrl: string, + mediatorDidUrl: string, +): IDIDCommMessage { + return { + id: v4(), + type: DELIVERY_REQUEST_MESSAGE_TYPE, + to: mediatorDidUrl, + from: recipientDidUrl, + return_route: 'all', + body: { limit: 2 }, + } +} + /** * A plugin for the {@link @veramo/message-handler#MessageHandler} that handles Mediator Coordinator messages for the mediator role. * @beta This API may change without a BREAKING CHANGE notice. diff --git a/packages/did-comm/src/protocols/index.ts b/packages/did-comm/src/protocols/index.ts index a0a7f8303..f88bae505 100644 --- a/packages/did-comm/src/protocols/index.ts +++ b/packages/did-comm/src/protocols/index.ts @@ -1,4 +1,4 @@ export { TrustPingMessageHandler } from './trust-ping-message-handler.js' -export { CoordinateMediationMediatorMessageHandler, CoordinateMediationRecipientMessageHandler } from "./coordinate-mediation-message-handler.js" +export * from "./coordinate-mediation-message-handler.js" export { RoutingMessageHandler } from "./routing-message-handler.js" export { PickupMediatorMessageHandler, PickupRecipientMessageHandler } from "./messagepickup-message-handler.js" \ No newline at end of file From 3b0b8b8f3f5bea361b3d86aba02f88c4d4e7d4fb Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Thu, 1 Jun 2023 14:59:34 +0300 Subject: [PATCH 2/2] feat: better agent debug message format --- packages/core/src/agent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/agent.ts b/packages/core/src/agent.ts index 0c7cf8432..0fef7860b 100644 --- a/packages/core/src/agent.ts +++ b/packages/core/src/agent.ts @@ -173,7 +173,7 @@ export class Agent implements IAgent { * @public */ async execute

(method: string, args: P): Promise { - Debug('veramo:agent:' + method)('%o', args) + Debug('veramo:agent:' + method)('%s %o', 'arg', args) if (!this.methods[method]) throw Error('Method not available: ' + method) const _args = args || {} if (this.schemaValidation && this.schema.components.methods[method]) { @@ -183,7 +183,7 @@ export class Agent implements IAgent { if (this.schemaValidation && this.schema.components.methods[method]) { validateReturnType(method, result, this.schema) } - Debug('veramo:agent:' + method + ':result')('%o', result) + Debug('veramo:agent:' + method)('%s %o', 'res', result) return result }