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: exporting didcomm mediator utils #1181

Merged
merged 2 commits into from
Jun 5, 2023
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
4 changes: 2 additions & 2 deletions packages/core/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class Agent implements IAgent {
* @public
*/
async execute<P = any, R = any>(method: string, args: P): Promise<R> {
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]) {
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,34 @@ const debug = Debug('veramo:did-comm:coordinate-mediation-message-handler')

type IContext = IAgentContext<IDIDManager & IKeyManager & IDIDComm & IDataStore>

/**
* @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,
Expand All @@ -28,6 +52,9 @@ export function createMediateRequestMessage(
}
}

/**
* @beta This API may change without a BREAKING CHANGE notice.
*/
export function createMediateGrantMessage(
recipientDidUrl: string,
mediatorDidUrl: string,
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/did-comm/src/protocols/index.ts
Original file line number Diff line number Diff line change
@@ -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"
Loading