credo-ts
credo-ts copied to clipboard
Problem with error message on parsing a previously accepted OOB invitation
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
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.
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
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
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,oobord_mparameters 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?
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)