Skip to content

Commit

Permalink
fix: check handshake protocols array is not empty (#1948)
Browse files Browse the repository at this point in the history
Signed-off-by: Ariel Gentile <gentilester@gmail.com>
  • Loading branch information
genaris authored Jul 17, 2024
1 parent a5235e7 commit 15d0a54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/pink-icons-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@credo-ts/core': patch
---

Treat an empty received handshake_protocols array as undefined
6 changes: 3 additions & 3 deletions packages/core/src/modules/oob/OutOfBandApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ export class OutOfBandApi {

await this.outOfBandService.updateState(this.agentContext, outOfBandRecord, OutOfBandState.PrepareResponse)

if (handshakeProtocols) {
if (handshakeProtocols && handshakeProtocols.length > 0) {
this.logger.debug('Out of band message contains handshake protocols.')

let connectionRecord
Expand All @@ -557,7 +557,7 @@ export class OutOfBandApi {
`Connection already exists and reuse is enabled. Reusing an existing connection with ID ${existingConnection.id}.`
)

if (!messages) {
if (!messages || messages?.length === 0) {
this.logger.debug('Out of band message does not contain any request messages.')
const isHandshakeReuseSuccessful = await this.handleHandshakeReuse(outOfBandRecord, existingConnection)

Expand Down Expand Up @@ -594,7 +594,7 @@ export class OutOfBandApi {
})
}

if (messages) {
if (messages && messages.length > 0) {
this.logger.debug('Out of band message contains request messages.')
if (connectionRecord.isReady) {
await this.emitWithConnection(outOfBandRecord, connectionRecord, messages)
Expand Down

0 comments on commit 15d0a54

Please sign in to comment.