forked from openwallet-foundation/credo-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from TimoGlastra/0211-2
refactor: mediator recipient cleanup
- Loading branch information
Showing
19 changed files
with
261 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import type { AgentConfig } from '../../../agent/AgentConfig' | ||
import type { Handler, HandlerInboundMessage } from '../../../agent/Handler' | ||
import type { MediatorService } from '../services/MediatorService' | ||
|
||
import { createOutboundMessage } from '../../../agent/helpers' | ||
import { AriesFrameworkError } from '../../../error' | ||
import { MediationRequestMessage } from '../messages/MediationRequestMessage' | ||
|
||
export class MediationRequestHandler implements Handler { | ||
private mediatorService: MediatorService | ||
private agentConfig: AgentConfig | ||
public supportedMessages = [MediationRequestMessage] | ||
|
||
public constructor(mediatorService: MediatorService) { | ||
public constructor(mediatorService: MediatorService, agentConfig: AgentConfig) { | ||
this.mediatorService = mediatorService | ||
this.agentConfig = agentConfig | ||
} | ||
|
||
public async handle(messageContext: HandlerInboundMessage<MediationRequestHandler>) { | ||
if (!messageContext.connection) { | ||
throw new Error(`Connection for verkey ${messageContext.recipientVerkey} not found!`) | ||
throw new AriesFrameworkError(`Connection for verkey ${messageContext.recipientVerkey} not found!`) | ||
} | ||
|
||
return await this.mediatorService.processMediationRequest(messageContext) | ||
const mediationRecord = await this.mediatorService.processMediationRequest(messageContext) | ||
|
||
if (this.agentConfig.autoAcceptMediationRequests) { | ||
const { message } = await this.mediatorService.createGrantMediationMessage(mediationRecord) | ||
return createOutboundMessage(messageContext.connection, message) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.