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

fix(core)!: do not request ping res for connection #527

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
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ export class ConnectionsModule {
* @returns connection record
*/
public async acceptResponse(connectionId: string): Promise<ConnectionRecord> {
const { message, connectionRecord: connectionRecord } = await this.connectionService.createTrustPing(connectionId)
const { message, connectionRecord: connectionRecord } = await this.connectionService.createTrustPing(connectionId, {
responseRequested: false,
})

const outbound = createOutboundMessage(connectionRecord, message)
await this.messageSender.sendMessage(outbound)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ConnectionResponseHandler implements Handler {
// In AATH we have a separate step to send the ping. So for now we'll only do it
// if auto accept is enable
if (connection.autoAcceptConnection ?? this.agentConfig.autoAcceptConnections) {
const { message } = await this.connectionService.createTrustPing(connection.id)
const { message } = await this.connectionService.createTrustPing(connection.id, { responseRequested: false })
return createOutboundMessage(connection, message)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,25 @@ export class ConnectionService {
/**
* Create a trust ping message for the connection with the specified connection id.
*
* By default a trust ping message should elicit a response. If this is not desired the
* `config.responseRequested` property can be set to `false`.
*
* @param connectionId the id of the connection for which to create a trust ping message
* @param config the config for the trust ping message
* @returns outbound message containing trust ping message
*/
public async createTrustPing(connectionId: string): Promise<ConnectionProtocolMsgReturnType<TrustPingMessage>> {
public async createTrustPing(
connectionId: string,
config: { responseRequested?: boolean; comment?: string } = {}
): Promise<ConnectionProtocolMsgReturnType<TrustPingMessage>> {
const connectionRecord = await this.connectionRepository.getById(connectionId)

connectionRecord.assertState([ConnectionState.Responded, ConnectionState.Complete])

// TODO:
// - create ack message
// - allow for options
// - maybe this shouldn't be in the connection service?
const trustPing = new TrustPingMessage({})
const trustPing = new TrustPingMessage(config)

await this.updateState(connectionRecord, ConnectionState.Complete)

Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/modules/routing/RecipientModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export class RecipientModule {
}

private async openMediationWebSocket(mediator: MediationRecord) {
const { message, connectionRecord } = await this.connectionService.createTrustPing(mediator.connectionId)
const { message, connectionRecord } = await this.connectionService.createTrustPing(mediator.connectionId, {
responseRequested: false,
})

const websocketSchemes = ['ws', 'wss']
const hasWebSocketTransport = connectionRecord.theirDidDoc?.didCommServices?.some((s) =>
Expand Down