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

Problem with error message on parsing a previously accepted OOB invitation #1869

Open
jorgefl0 opened this issue May 16, 2024 · 5 comments
Open

Comments

@jorgefl0
Copy link

We observe that the function call await agent.oob.parseInvitation(invitationUrl) returns an incorrect error message in the scenario when the input OOB invitation has previously been accepted

The error message observed is

h: InvitationUrl is invalid. It needs to contain one, and only one, of the following parameters: `oob`, `c_i` or `d_m`, or be valid shortened URL

Our Credo implementation is currently on v0.5.3

@jorgefl0 jorgefl0 changed the title Problem with error message on parsing a previously accepter OOB invitation Problem with error message on parsing a previously accepted OOB invitation May 16, 2024
@jorgefl0
Copy link
Author

It seems like parseInvitation may be concerned with the state of the OOB invitation currently, when perhaps it should be left to the implementer? The scenario for us is a shortened OOB url that we would like to serialize to a valid JSON document.

@TimoGlastra
Copy link
Contributor

Hey @jorgefl0, are you sure the shortened invitation is still valid after it has been accepted?

In e.g. Paradym we invalidate a shortened url that has been accepted, as it can't be used anymore

@jorgefl0
Copy link
Author

Ok, if im reading the implementation correctly, the OOB is being fetched from short URL

Are you saying that Paradym returns an error which in turn results in the error message?

The point of this issue is that it is not clear from the error message content that the error occurs because the OOB has already been accepted. It suggests there is a syntax error with the URL and not an issue with the state of the invitation.

It isnt obvious that the interpretation of the error below that the OOB is invalid because its already been accepted.

h: InvitationUrl is invalid. It needs to contain one, and only one, of the following parameters: `oob`, `c_i` or `d_m`, or be valid shortened URL

Currently, our alternate approach to determining if an OOB invitation has already been accepted is to parse the invitation, resolve the public did from the services[] array and call agent.connections.findByInvitationDid(invitationDid) to fetch any existing connections already in 'completed` state

@TimoGlastra
Copy link
Contributor

I agree it's not very clear. The "or be valid shortened URL" should indicate that it's not also not a valid shortened URL.

Maybe we should store the URL of the invitation so you can also query in the wallet whether an URL has already been accepted. Currently it's not possible to know that if the invitation cannot be fetched anymore, as that contains the data needed to check that.

So basically how the parsing logic works:

  • try to extract c_i, oob or d_m parameters from query
  • else try to fetch the url and either parse the JSON response, or the location header.

What would you expect the error message to look like? It's quite common to invalidate invitation URLs. What is your specific use case with checking if it has already been accepted? If you create a new invitation, receive that in the agent with reuseConnection true it will allow you to reuse the connection, maybe that's something that you can use as an alternative approach?

@jorgefl0
Copy link
Author

Ok, maybe I'm being naive about the semantic meaning of parseInvitation. We just need a way to return the invitation JSON given an invitation URL. We don't care anything about the state of the invitation. We do care in other scenarios such as when calling agent.oob.receiveInvitationFromUrl(invitationUrl) or agent.oob.receiveInvitation(invitation) where we would expect an error if the invitation has already been processed.

But to your suggestion, having the invitation URL stored would allow us to query for OOB records using the URL as query parameter agent.oob.findAllByQuery(query)

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

2 participants