@atala/prism-wallet-sdk / Exports / BasicMediatorHandler
Class: BasicMediatorHandler
A basic implementation of our MediatorHandler Interface which is mainly used to establish mediation and get new messages using the mediation and pickup didcomm v2 protocols
BasicMediatorHandler
Implements
Table of contents
Constructors
Properties
Methods
- achieveMediation
- bootRegisteredMediator
- listenUnreadMessages
- pickupUnreadMessages
- registerMessagesAsRead
- updateKeyListWithDIDs
- fromMediator
Constructors
constructor
• new BasicMediatorHandler(mediatorDID
, mercury
, store
): BasicMediatorHandler
Creates an instance of BasicMediatorHandler.
Parameters
Name | Type |
---|---|
mediatorDID | DID |
mercury | Mercury |
store | MediatorStore |
Returns
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:41
Properties
mediator
• Optional
mediator: Mediator
Optional instance of the mediator so that if the mediation was already established and recorded we don't need to mediate again with the same mediator
Implementation of
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:31
mediatorDID
• mediatorDID: DID
Implementation of
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:42
mercury
• mercury: Mercury
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:43
store
• store: MediatorStore
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:44
Methods
achieveMediation
▸ achieveMediation(host
): Promise
<Mediator
>
Asyncronously achieve mediation by specifying the HOST DID, this will exchange the mediation protocol messages between the user and the mediator until established
Parameters
Name | Type |
---|---|
host | DID |
Returns
Promise
<Mediator
>
Async
Implementation of
MediatorHandler.achieveMediation
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:96
bootRegisteredMediator
▸ bootRegisteredMediator(): Promise
<undefined
| Mediator
>
Will asyncronously fetch the first mediator stored in database and set it as default mediator.
Returns
Promise
<undefined
| Mediator
>
Async
Implementation of
MediatorHandler.bootRegisteredMediator
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:77
listenUnreadMessages
▸ listenUnreadMessages(signal
, serviceEndpointUri
, onMessage
): void
Asyncronously create a websocket connection with the mediator Establish a websocket connection and activate the live-mode with the mediator and also listen for incomming unread messages with existing protocols.
Parameters
Name | Type |
---|---|
signal | AbortSignal |
serviceEndpointUri | string |
onMessage | (messages : { attachmentId : string ; message : Message }[]) => void | Promise <void > |
Returns
void
Async
Implementation of
MediatorHandler.listenUnreadMessages
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:196
pickupUnreadMessages
▸ pickupUnreadMessages(limit
): Promise
<{ attachmentId
: string
; message
: Message
}[]>
Asyncronously pickup unread messages from the mediator if new messages are found, because the messages from in form of attachments inside the pickup response we need to parse those and return the user a list of messages it can read and decode, this is done inside the pickup runner.
Parameters
Name | Type |
---|---|
limit | number |
Returns
Promise
<{ attachmentId
: string
; message
: Message
}[]>
Async
Implementation of
MediatorHandler.pickupUnreadMessages
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:166
registerMessagesAsRead
▸ registerMessagesAsRead(ids
): Promise
<void
>
Asyncronously notify the current mediator that one or multiple message ID's have been read (or stored)
Parameters
Name | Type |
---|---|
ids | string [] |
Returns
Promise
<void
>
Async
Implementation of
MediatorHandler.registerMessagesAsRead
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:251
updateKeyListWithDIDs
▸ updateKeyListWithDIDs(dids
): Promise
<void
>
Asyncronously update the mediator with the new keyList, used during the mediation process or during DID Rotation
Parameters
Name | Type |
---|---|
dids | DID [] |
Returns
Promise
<void
>
Async
Implementation of
MediatorHandler.updateKeyListWithDIDs
Defined in
src/edge-agent/mediator/BasicMediatorHandler.ts:145
fromMediator
▸ fromMediator(mediator
, mercury
, store
): BasicMediatorHandler
Secondary constructor for BasicMediation Handler, to instanciate if from an existing Mediator instance.
Parameters
Name | Type |
---|---|
mediator | Mediator |
mercury | Mercury |
store | MediatorStore |
Returns
Static