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

Process OOB Invitations with requests asynchronously #2173

Open
genaris opened this issue Feb 3, 2025 · 0 comments
Open

Process OOB Invitations with requests asynchronously #2173

genaris opened this issue Feb 3, 2025 · 0 comments

Comments

@genaris
Copy link
Contributor

genaris commented Feb 3, 2025

The discussion in #2159 made me think that probably we can change the way we process requests (messages) in Out of Band invitations (e.g. flows involving proofs requests and credential issuance).

Currently, OutOfBandApi is doing, in its acceptInvitation method:

if (messages && messages.length > 0) {
        this.logger.debug('Out of band message contains request messages.')
        if (connectionRecord.isReady) {
          await this.emitWithConnection(outOfBandRecord, connectionRecord, messages)
        } else {
          // Wait until the connection is ready and then pass the messages to the agent for further processing
          this.connectionsApi
            .returnWhenIsConnected(connectionRecord.id, { timeoutMs })
            .then((connectionRecord) => this.emitWithConnection(outOfBandRecord, connectionRecord, messages))
            .catch((error) => {
              if (error instanceof EmptyError) {
                this.logger.warn(
                  `Agent unsubscribed before connection got into ${DidExchangeState.Completed} state`,
                  error
                )
              } else {
                this.logger.error('Promise waiting for the connection to be complete failed.', error)
              }
            })
        }
      }

This approach works fine in online cases where a mobile DIDComm agent scans a QR code and the user is actively waiting until the flow completes. But if network instabilities are found or if we want to enable P2P interactions I think it could be a bit more difficult to achieve.

An idea could be to emit this AgentMessageReceived event when the connection state is transitioned to DidExchangeState.Completed (we can find the messages by querying its associated OOB record) . This way we can safely allow these flows to execute asynchronously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant