openwallet-foundation / credo-ts

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

Invitation from aca-py agent with aca-py mediator between #230

Closed papkie closed 3 years ago

papkie commented 3 years ago

Hey.

I'm trying to make a connection (from https://github.com/hyperledger/aries-mobile-agent-react-native) with another agent with a mediator between. I can connect from react native app (using code from this repo) to aca-py mediator, but had to move the invitation to another server (/invitation path does not exist in aca-py admin). I don't know if it's good, but it works.

The issue is when I want to connect with another aca-py agent with mediator between. When I try to receive invitation on mobile I'm getting message in react native app:

New Connection Record
{
    "_didDoc":
    {
        "@context": "https://w3id.org/did/v1",
        "authentication":
        [
            [
                undefined
            ]
        ],
        "id": "Cv5XNG6AW7bQNSz49M3a8h",
        "publicKey":
        [
            [
                undefined
            ]
        ],
        "service":
        [
            [
                undefined
            ]
        ]
    },
    "_invitation":
    {
        "@id": "859fec9e-ad20-4fe1-bc5b-2585e52636cc",
        "@type": "https://didcomm.org/connections/1.0/invitation",
        "label": "label",
        "recipientKeys":
        [
            "G9JytRnX8tx6uSetjPyYuSkwwVrDFm23LB8GGK7ifB4k"
        ],
        "routingKeys":
        [
            "8zNjW3SZt9Tc94dmHjpGdm5qGL8EFQNPMXVCHqJR88ff"
        ],
        "serviceEndpoint": "http://x:3006/"
    },
    "_theirDidDoc": undefined,
    "alias": undefined,
    "autoAcceptConnection": true,
    "createdAt": 1618056938615,
    "did": "Cv5XNG6AW7bQNSz49M3a8h",
    "endpoint": undefined,
    "id": "d12851bc-f05c-46af-8c7a-721023b1a960",
    "role": "INVITEE",
    "state": "requested",
    "tags":
    {
        "invitationKey": "G9JytRnX8tx6uSetjPyYuSkwwVrDFm23LB8GGK7ifB4k",
        "verkey": "7VfLb6mWcLz3apc3Z1dQxcytAghm4E4c2iKppVYdLXB3"
    },
    "theirDid": undefined,
    "type": "ConnectionRecord",
    "verkey": "7VfLb6mWcLz3apc3Z1dQxcytAghm4E4c2iKppVYdLXB3"
}

But I'm getting an error on edge agent (mediator looks good - it shows messages regarding forwarded messages):

2021-04-10 07:17:57,143 aries_cloudagent.core.conductor WARNING Cannot queue message for delivery, no supported transport

Invitation created by edge agent looks like this:

{
  "connection_id": "1281a500-aa9b-49ba-b8b8-7dba030772ba",
  "invitation": {
    "@type": "https://didcomm.org/connections/1.0/invitation",
    "@id": "16be3a5c-4cc7-4c2f-a182-6defe6665930",
    "recipientKeys": [
      "4hxjdd6u3iHyi9WnPfesh9nDvwAKmGZiskw1NiriWMNr"
    ],
    "label": "Edge",
    "serviceEndpoint": "http://x:3006/",
    "routingKeys": [
      "8zNjW3SZt9Tc94dmHjpGdm5qGL8EFQNPMXVCHqJR88ff"
    ]
  },
  "invitation_url": "http://x:3006/?c_i=invitation base 64"
}

I copy invitation url, then paste it to qr generator and scan it.

Mediator config:

aca-py start --wallet-type indy \
--seed 00000000000000000000000001Mediat \
--wallet-key mediatorkey \
--wallet-name mediator \
--label "Mediator" \
--open-mediation \
--genesis-url http://genesishost/genesis \
--inbound-transport http 0.0.0.0 3006 \
--inbound-transport ws 0.0.0.0 3008 \
--outbound-transport http \
--outbound-transport ws \
--admin 0.0.0.0 3007 \
--admin-insecure-mode --auto-accept-invites --auto-accept-requests --auto-ping-connection \
--log-level info \
-e http://x:3006/ \
--emit-new-didcomm-prefix 

Edge agent config:

aca-py start --wallet-type indy \
--seed 00000000000000000000000001Issuer \
--wallet-key issuerkey \
--wallet-name issuer \
--label "Edge" \
--inbound-transport http 0.0.0.0 3001 \
--inbound-transport ws 0.0.0.0 3003 \
--outbound-transport http \
--outbound-transport ws \
-e http://x:3001/ \
--admin 0.0.0.0 3002 \
--admin-insecure-mode --auto-accept-invites --auto-accept-requests --auto-ping-connection \
--log-level debug \
--genesis-url http://genesishost/genesis \
--emit-new-didcomm-prefix 

Mobile config:

      const agentConfig = new AgentConfig({
        mediatorUrl: Config.MEDIATOR_URL,
        label: 'Holder',
        walletConfig: {id: 'holder-wallet'},
        walletCredentials: {key: 'holderkey'},
        autoAcceptConnections: true,
        genesisPath,
        logger: new ConsoleLogger(LogLevel.debug),
        indy,
      })

Has anyone experienced an issue like this?

burdettadam commented 3 years ago

Hi @papkie, I helped work on the mediator code and would like to help. Could you post more error logs, nothing is jumping out with the current details.

TimoGlastra commented 3 years ago

Whoops I missed your message @papkie! I think the problem here is that you're trying to connect to an ACA-Py mediator. We don't fully support the mediator coordination protocol yet which means we can't request mediation from ACA-Py....

I believe @JamesKEbert is working on this, but until then you can only use an aries framework javascript mediator inside the mobile agent

papkie commented 3 years ago

@burdettadam I have investigated it a bit more later, and it's probably the issue with aca-py agent. I'm getting message related to unsupported batch pickup type: aries_cloudagent.core.dispatcher ERROR Message parsing failed: Unrecognized message type https://didcomm.org/messagepickup/1.0/batch-pickup, sending problem report on aca-py agent

Whoops I missed your message @papkie! I think the problem here is that you're trying to connect to an ACA-Py mediator. We don't fully support the mediator coordination protocol yet which means we can't request mediation from ACA-Py....

I believe @JamesKEbert is working on this, but until then you can only use an aries framework javascript mediator inside the mobile agent

Understood, thank you!

icc-romeu commented 3 years ago

Sadly, batch-pickup is not implemented in ACA-py. ACA-py uses websockets for mediation. Currently, they are being implemented in AFJ #218

I have used a workaround for this. You can use AFJ mediator instead of ACA-py mediator. Then you can connect to ACA-py agent using that mediator.

papkie commented 3 years ago

@icc-romeu

I have tried to use AFJ as a mediator (using the script in samples/mediator.ts). I use samples/mediator.ts code to set up the mediator.

Edge agent (mobile one, javascript) has no issues connecting to it, but there is an issue with connecting this mediator to the ACA-Py edge client. I'm trying to receive the invitation created by the mediator (AFJ - on /invitation path) on the ACA-Py edge client. ACA-Py sends a request with an empty body to /msg endpoint, so AFJ is not able to handle it.

When I try to receive an invitation created by ACA-Py on Javascript mediator, AFJ throws UnhandledPromiseRejectionWarning: Error: Trying to save the message without theirKey! error.

Do you have some example code somewhere?

If not, I'll just wait for WS support.

icc-romeu commented 3 years ago

Maybe I do not understand what you are trying to do @papkie but you do not need to connect ACA-py to the mediator. The process on should be:

Connect from the mobile AFJ to the AFJ mediator via the invitation. This works as you say. Connect from the mobile AFJ to the ACA-py using an ACA-py invitation. When the ACA-py starts it shows you an invitation URL. That's the one you should use once the mobile is setup with the mediator. AFJ will handle the connection with ACA-py and it will respond to your mediator instead of the mobile.

papkie commented 3 years ago

Maybe I do not understand what you are trying to do @papkie but you do not need to connect ACA-py to the mediator. The process on should be:

Connect from the mobile AFJ to the AFJ mediator via the invitation. This works as you say. Connect from the mobile AFJ to the ACA-py using an ACA-py invitation. When the ACA-py starts it shows you an invitation URL. That's the one you should use once the mobile is setup with the mediator. AFJ will handle the connection with ACA-py and it will respond to your mediator instead of the mobile.

Thanks, I have tried this scenario, unfortunately, it didn't work. I see there is mediation protocol implementation in progress, so I'll wait for that, thank you anyway!

darapich92 commented 1 year ago

Hi @icc-romeu, it has been two years and I think Aries Mobile agent has progress alots. so, it is possible to connect Aries Mobile Agent React Native to Mediator of ACA-Py? Currently, I cannot connect Aries Mobile Agent with Mediator of ACA-Py because Aries Mobile Agent sent the did:peer to Mediator of ACA-Py while ACA-Py accepts only Indy DID.

PenguinTaro commented 1 year ago

I believe, you can connect Aries bifold and Aca-py mediator. Because I did it last month . I follow this link to get my mediator up and running "https://github.com/hyperledger/aries-mediator-service". Try for yourself and see if it works

TimoGlastra commented 1 year ago

@darapich92 you need to make sure to not use the did exchange protocol. You can either use connection invitations in the ACA-Py mediator, or use out of band invitations where the handshake_protocols does not include the did exchange protocol

darapich92 commented 1 year ago

Hi @PenguinTaro, thank you very much. I will note it down. @TimoGlastra, thanks for your answer. I tried to use https://didcomm.org/connections/1.0 in the handshake_protocols in the out-of-band in the mediator of ACA-Py, my message sent from Edge Agent (React native) was undelivered.

image
icc-romeu commented 1 year ago

Hi @icc-romeu, it has been two years and I think Aries Mobile agent has progress alots. so, it is possible to connect Aries Mobile Agent React Native to Mediator of ACA-Py? Currently, I cannot connect Aries Mobile Agent with Mediator of ACA-Py because Aries Mobile Agent sent the did:peer to Mediator of ACA-Py while ACA-Py accepts only Indy DID.

Sorry for the late reply.

I have been trying myself and I'm in the same point as you, no luck

TimoGlastra commented 1 year ago

Can you provide me with a reproduction? Having the message be undelivered can be because of a number of reasons, and I'd need to dig into it a bit more

icc-romeu commented 1 year ago

Sorry @TimoGlastra I was wrong. Mediation does work. What does not work is pickup protocol. So nothing to do with this.

 DEBUG  DEBUG: Agent received message
 INFO  INFO: Received message with type 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/notification/1.0/problem-report', recipient key z6MkmQpVr4xD2a5TejpDZv2zAfPgHQRM2DnjRN3cM8PtehJG and sender key z6MkgUYKsfH7WYYH3FEwUcKFsyN4T7mCDNEaWkzNEo61aagZ {
  "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/notification/1.0/problem-report",
  "@id": "287a87ed-450f-4cba-b587-74167981102c",
  "~thread": {
    "thid": "8123f295-7666-4091-ab8e-e32387e08142"
  },
  "description": {
    "en": "Unrecognized message type https://didcomm.org/messagepickup/2.0/status-request",
    "code": "message-parse-failure"
  }
}
 ERROR  ERROR: Failed to process message {
  "error": {
    "name": "AriesFrameworkError",
    "message": "Not sending problem report in response to problem report: No message class found for message type \"https://didcomm.org/notification/1.0/problem-report\"",
TimoGlastra commented 1 year ago

Okay, thanks for clarifying. Are you using the pickup plugin for the ACA-Py mediator? https://github.com/Indicio-tech/acapy-plugin-pickup

Also, if you're mostly looking for a mediator for development, you can also use the docker image from this repo: https://github.com/animo/animo-mediator

icc-romeu commented 1 year ago

Okay, thanks for clarifying. Are you using the pickup plugin for the ACA-Py mediator? https://github.com/Indicio-tech/acapy-plugin-pickup

Also, if you're mostly looking for a mediator for development, you can also use the docker image from this repo: https://github.com/animo/animo-mediator

WOOOPS! Maybe that's the issue 😅 We will check, thank you!

darapich92 commented 1 year ago

Hi @TimoGlastra, thank you for your answer and now, I can connect Aries Mobile agent with the aca-py. I have a new problem when accepting the new credential from issuer because mobile agent cannot verify the DID of credential issuer.

TRACE: Retrieved 0 responses from ledgers for did 'So9SHrrNXBDDTBrDcRTt1P'

I think it is worked if aries mobile agent can connect to von-network for verifying DID of Issuer. Do you know how to overcome this problem? thank you very much!

TimoGlastra commented 1 year ago

Are you using a customer ledger? In that case you need to add it to the ledgers.json in bifold

darapich92 commented 1 year ago

@TimoGlastra, Yes i use the customized ledger. so I need to modify ledgers.json in the configs/ledgers/indy. thank you for your information!

darapich92 commented 1 year ago

Hi @TimoGlastra, after configuring ledgers.json, the aries mobile can capture the client_ip and port of nodes. but after the executing await this.wallet.initialize(walletConfig) in the initialize() function of BaseAgent.js, my Aries mobile keep spinning and pop up the message Undefined is not a function. Before I configure the ledger, it works properly. Could you give me any suggestion about this problem? thank you very much!

TimoGlastra commented 1 year ago

Can you share the config for your ledger?

darapich92 commented 1 year ago

Hi @TimoGlastra, I found the problem. i deleted some code because I want to have only one genesis that's the reason that it was stuck. I tried to have multiple genesis and it works now. thank you very much for your help!