openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
267 stars 200 forks source link

ACA-Py OOB invitation not accepted by Credo #2040

Closed nodlesh closed 1 month ago

nodlesh commented 1 month ago

I've got an ACA-Py agent that created an OOB invitation. I cannot get that invitation to be successfully process by Credo in oob/receiveInvitation. This is the invitation,

{
        "@type": "https://didcomm.org/out-of-band/1.1/invitation",
        "@id": "b457aaf1-9870-48f3-ac43-eeb6ed59ce7f",
        "label": "aca-py.Bob",
        "handshake_protocols": [
            "https://didcomm.org/didexchange/1.0"
        ],
        "services": [
            {
                "id": "#inline",
                "type": "did-communication",
                "recipientKeys": [
                    "did:key:z6MksYLeLLcGuHUcewRgo8Zzm8xapPGoUiRaMm6CdiPA77QB#z6MksYLeLLcGuHUcewRgo8Zzm8xapPGoUiRaMm6CdiPA77QB"
                ],
                "serviceEndpoint": "http://host.docker.internal:9031"
            }
        ]
    }

Initially I would get errors that the recioientKeys and serviceEndpoint were missing. I moved them out of the services section and that seemed to clear up those errors. However, now I get that the type isn't valid.

error: {
    name: 'ClassValidationError',
    message: 'ConnectionInvitationMessage: Failed to validate class.\n' +
      'An instance of ConnectionInvitationMessage has failed the validation:\n' +
      ' - property type has failed the following constraints: type does not match the expected message type (only minor version may be lower) \n',
    status: 500,

How can I get this ACA-Py OOB invitation to be accepted by Credo?

TimoGlastra commented 1 month ago

What method are you using to accept the oob invitation? I think the invitation is directly transformed into a ConnectionInvitationMessage. Usually we use agent.oob.receiveInvitationFromUrl which handles the different invitation types. If you only have the json you need to look at the @type and based on that you need to either parse it to ConnectionInvitationMessage or OutOfBandInvitation

nodlesh commented 1 month ago

Thanks for the reply. I am using the agent.oob.receiveInvitation method. Yes, all the reference code that I've found uses the agent.oob.receiveInvitationFromUrl. I have it working now. I didn't notice the other JsonTransformer method that does the OutOfBandInvitation

On a related note. I expected the state to come back as something like invitation-received, but it comes back as request-sent instead. I'd expect that to happen if I called oob.accept-invitation. Has credo jumped the gun here and already sent the request or is the state incorrect?