Skip to content

Commit

Permalink
feat(oob): receive Invitation with timeout (#1156)
Browse files Browse the repository at this point in the history
Signed-off-by: Pritam Singh <[email protected]>
  • Loading branch information
Zzocker authored Dec 14, 2022
1 parent 1af57fd commit 9352fa5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/src/modules/oob/OutOfBandApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface ReceiveOutOfBandInvitationConfig {
autoAcceptConnection?: boolean
reuseConnection?: boolean
routing?: Routing
acceptInvitationTimeoutMs?: number
}

@injectable()
Expand Down Expand Up @@ -388,6 +389,7 @@ export class OutOfBandApi {
autoAcceptConnection,
reuseConnection,
routing,
timeoutMs: config.acceptInvitationTimeoutMs,
})
}

Expand Down Expand Up @@ -417,6 +419,7 @@ export class OutOfBandApi {
alias?: string
imageUrl?: string
routing?: Routing
timeoutMs?: number
}
) {
const outOfBandRecord = await this.outOfBandService.getById(this.agentContext, outOfBandId)
Expand All @@ -426,6 +429,7 @@ export class OutOfBandApi {
const { handshakeProtocols } = outOfBandInvitation
const services = outOfBandInvitation.getServices()
const messages = outOfBandInvitation.getRequests()
const timeoutMs = config.timeoutMs ?? 20000

const existingConnection = await this.findExistingConnection(outOfBandInvitation)

Expand Down Expand Up @@ -483,7 +487,7 @@ export class OutOfBandApi {
} else {
// Wait until the connection is ready and then pass the messages to the agent for further processing
this.connectionsApi
.returnWhenIsConnected(connectionRecord.id)
.returnWhenIsConnected(connectionRecord.id, { timeoutMs })
.then((connectionRecord) => this.emitWithConnection(connectionRecord, messages))
.catch((error) => {
if (error instanceof EmptyError) {
Expand Down

0 comments on commit 9352fa5

Please sign in to comment.