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

Check if message has structure of packed message before trying to unpack #550

Closed
TimoGlastra opened this issue Nov 25, 2021 · 0 comments
Closed

Comments

@TimoGlastra
Copy link
Contributor

TimoGlastra commented Nov 25, 2021

Some agents return errors as the HTTP response when something went wrong. We try to unpack all received messages which can result in weird errors:

 ERROR  ERROR: error while unpacking message {
  "error": {},
  "packedMessage": {
    "error": "Unhandled exception: Couldn't locate a message handler for type https://didcomm.org/issue-credential/1.0/ack",
    "errorType": "AriesFrameworkException"
  },
  "errorMessage": "Error unpacking message"
}

We should try to see if the received message has the structure of a packed message (correct JWE keys) before trying to unpack. We could throw a dedicated error if the structure is not a JWE and notfiy the framework user we received an error message from the other agent

Relevant HTTP code: https://github.com/hyperledger/aries-framework-javascript/blob/main/packages/core/src/transport/HttpOutboundTransport.ts#L78-L81

Encrypted message structure: https://github.com/hyperledger/aries-framework-javascript/blob/main/packages/core/src/types.ts#L15

function A(message: any): message is EncryptedMessage {
  return message.protected
}

Example encrypted message:

    {
      protected: 'eyJlbmMiOiJ4Y2hhY2hhMjBwb2x5MTMwNV9pZXRmIiwidHlwIjoiSldNLzEuMCIsImFsZyI6IkF1dGhjcnlwdCIsInJlY2lwaWVudHMiOlt7ImVuY3J5cHRlZF9rZXkiOiJNYUNKa3B1YzltZWxnblEtUk8teWtsQWRBWWxzY21GdFEzd1hjZ3R0R0dlSmVsZDBEc2pmTUpSWUtYUDA0cTQ2IiwiaGVhZGVyIjp7ImtpZCI6IkJid2ZCaDZ3bWdZUnJ1TlozZXhFelk2RXBLS2g4cGNob211eDJQUjg5bURlIiwiaXYiOiJOWVJGb0xoUG1EZlFhQ3czUzQ2RmM5M1lucWhDUnhKbiIsInNlbmRlciI6IkRIQ0lsdE5tcEgwRlRrd3NuVGNSWXgwZmYzTHBQTlF6VG1jbUdhRW83aGU5d19ERkFmemNTWFdhOEFnNzRHVEpfdnBpNWtzQkQ3MWYwYjI2VF9mVHBfV2FscTBlWUhmeTE4ZEszejhUTkJFQURpZ1VPWi1wR21pV3FrUT0ifX1dfQ==',
      iv: 'KNezOOt7JJtuU2q1',
      ciphertext: 'mwRMpVg9wkF4rIZcBeWLcc0fWhs=',
      tag: '0yW0Lx8-vWevj3if91R06g=='
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants