hyperledger / aries-framework-swift

A Swift framework for Aries.
Apache License 2.0
17 stars 6 forks source link

OOB invitation with credential-offer attachment failed. #12

Closed kukgini closed 1 year ago

kukgini commented 1 year ago

When AF.Swift accepts an OOB invitation including credential-offer from Aca-Py, the credential-request message comes to Aca-Py, but Aca-Py gives the following error.

acapy_1     | 2022-12-20 08:55:11,355 aries_cloudagent.core.conductor ERROR Exception in message handler:
acapy_1     | Traceback (most recent call last):
acapy_1     |   File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/asyncio/tasks.py", line 180, in _step
acapy_1     |     result = coro.send(None)
acapy_1     |   File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/site-packages/aries_cloudagent/core/dispatcher.py", line 209, in handle_message
acapy_1     |     await handler(context, responder)
acapy_1     |   File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/site-packages/aries_cloudagent/protocols/issue_credential/v1_0/handlers/credential_request_handler.py", line 58, in handle
acapy_1     |     context.message, context.connection_record, oob_record
acapy_1     |   File "/home/indy/.pyenv/versions/3.6.13/lib/python3.6/site-packages/aries_cloudagent/protocols/issue_credential/v1_0/manager.py", line 548, in receive_request
acapy_1     |     ) from None
acapy_1     | aries_cloudagent.protocols.issue_credential.v1_0.manager.CredentialManagerError: Indy issue credential format can't start from credential request

used Invitation Url was: out-of-band-invitation.txt

and the incomming credential-request message was:

{"@type":"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/issue-credential/1.0/request-credential","@id":"92D217E6-F575-4112-9B5B-FBA2F9D4C2D1","~transport":{"return_route":"all"},"~thread":{"thid":"3747d7b3-d0c7-4fc3-81c7-9cadc16293cf"},"requests~attach":[{"@id":"libindy-cred-request-0","mime-type":"application/json","data":{"base64":"eyJwcm92ZXJfZGlkIjoiV0RHWFphUkRUZ2NGQ3dVMjdkOHVtQSIsImNyZWRfZGVmX2lkIjoiU1hZRTNpQlNXckY4amg1N200eWhnYTozOkNMOjYyMDM5NDoyMDIyLjEyLjEzIiwiYmxpbmRlZF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TgzODIwMzEwNzE3NjA5Mzk3MzM4ODk3NTA0MDU4NjgiLCJtX2NhcHMiOnsibWFzdGVyX3NlY3JldCI6IjI0NTIwMzAyNDc5NDA1OTMwNzc4MzEwNzM4NjI2MzMyMjc1NjYxODEyOTAyNTkzNjY3NTgxMDMxNTE2MzQ1MjM0OTQxNTYxNDc5MTk3Mzg1MzM0MDcyOTAyMDY0NTY4MTQyMzc4OTQ0ODEyMTQ4MDM2MjEyMDE0MDEzMTA2MDAyMzU2NzU2ODczNzQwMDI1NTc3MjM5NDYxMzcwNDQ3MzA5NjYzMjgxNTQ1MzEwMDg1MTMzIn0sInJfY2FwcyI6e319LCJub25jZSI6IjEwNDY2Mzc4NDQxMzA1ODg0Mjg2ODMwNTUifQ==
conanoc commented 1 year ago

Maybe this is the ACA-Py issue the same as AFJ's: https://github.com/hyperledger/aries-framework-javascript/issues/1129

kukgini commented 1 year ago

Maybe it's a bug because pthid is missing. When using aca-py as a holder, the credential-request is processed well. it seems to be the difference is pthid in the ~thread decorator. I am attaching an example of a payload that can be handled.

{"@type":"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/issue-credential/1.0/request-credential","@id":"eef9d40d-0cad-4e52-9042-38d452e64998","~thread":{"thid":"484c50bf-956d-4fb1-b165-1bd01820a660","pthid":"cfcb01af-ef8b-4243-a9e1-d5896ebbdfca"},"requests~attach":[{"@id":"libindy-cred-request-0","mime-type":"application/json","data":{"base64":"eyJwcm92ZXJfZGlkIjogIlR1dFRGWlM1Sno2SjFuOGo1NlhtNU4iLCAiY3JlZF9kZWZfaWQiOiAiU1hZRTNpQlNXckY4amg1N200eWhnYTozOkNMOjY1NjU0OTpkZWZhdWx0IiwgImJsaW5kZWRfbXMiOiB7InUiOiAiMzA1NTgyMzcxNjAyMTEzNTIxNTQ4OTE1OTc1NTQxODQzODY5MTg5Mzg3NTg2NzY5NzYxMTEyMDY2NzU2MzgwNzI4ODYwMjY5MDY1NDY5ODcyNDQyOTgxODQwOTI2MTA2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MTEyMDA0Njc2MDQ3OTc5ODExNjE3MzA2MTY4MDQ0MTI4MTg2MTYzMDQ2MDg3Njk2NDY0NTQ0NjEzNjQ3NjI3Njk4OTA2MzUzMDc4MDU1NDc1NTY3NTQxMzU2MDQwOTQzNTIyNzU5NzY3NDk2MDMwOTYzMDU2MDEwOTE0MTg5MyJ9LCAicl9jYXBzIjoge319LCAibm9uY2UiOiAiOTc5NTY1MjQwNzg1OTMxNDE2ODI2ODEifQ=="}
conanoc commented 1 year ago

You are right. I failed to include the parent thread ID in the message. The OOB spec requires this: https://github.com/hyperledger/aries-rfcs/blob/main/features/0434-outofband/README.md#correlating-responses-to-out-of-band-messages

Can you provide guidance on creating an OOB message with a credential offer attachment in ACA-py? In the case of AFJ, I've created a sample app for this. https://github.com/hyperledger/aries-framework-swift/tree/main/AriesFramework/AriesFrameworkTests/javascript

kukgini commented 1 year ago

Of course. here is steps to build OOB invitation with offer attachment.

STEP 0. Setup, set the following environment variables when starting aca-py so that it can respond to ~transport decorator.

ACAPY_AUTO_ACCEPT_REQUESTS=true
ACAPY_AUTO_RESPOND_CREDENTIAL_REQUEST=true

STEP 1. setup schema POST {{issuerAdminUrl}}/schemas

{
  "schema_name": "<schema name>",
  "schema_version": "<schema version in semver style>",
  "attributes": ["<attribute name>", ... ]
}

STEP 2. setup credential definition POST {{issuerAdminUrl}}/credential-definitions

{
  "schema_id": "<schema id from STEP 1's response>",
  "support_revocation": false,
  "tag": "default"
}

STEP 3. create credential offering POST {{issuerAdminUrl}}/issue-credential/create-offer

{
  "comment": "oob issuance test",
  "cred_def_id": "<cred_def_id from STEP 2's response>",
  "credential_preview": {
    "@type": "issue-credential/1.0/credential-preview",
    "attributes": [
      { "mime-type": "text/plain", "name": "<attribute-name>", "value": "<attribute-value>" },
      ...
    ]
  }
}

STEP 4. create out of band invitation POST {{issuerAdminUrl}}/out-of-band/create-invitation

{
  "alias": "<whatever you want>",
  "handshake_protocols": [
    "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0"
  ],
  "attachments": [
    {
      "id": "<credential_exchange_id from STEP 3's response>",
      "type": "credential-offer"
    }
  ]
}