hyperledger / aries-framework-swift

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

Support connection-less credential exchange and proof exchange. #112

Closed kukgini closed 5 months ago

kukgini commented 6 months ago

To solve the issue #108 If Agent receives out-of-band message with attachment without handshake protocols, It precess the attachment and send message to counter party if necessary. When It send a message, It use the service decorator in the out-of-band message. By doing this Agent supports connection-less credential exchange and proof exchange.

Second approach. unit test is not implemented yet.

kukgini commented 6 months ago

I don't understand the SwiftLint error. someone could help?

conanoc commented 6 months ago

The comment on line 1 is no longer necessary. You can remove it.

conanoc commented 5 months ago

The DCO check can be handled in this PR. There's a guide on how to do it on the "Details" page.

conanoc commented 5 months ago
    func findConnectionByMessageThreadId(message: AgentMessage) async throws -> ConnectionRecord? {
        let threadId = message.threadId
        guard let oobRecord = try await agent.outOfBandService.findByAttachmentThreadId(threadId) else {
            return nil
        }
        guard let invitationKey = try oobRecord.outOfBandInvitation.invitationKey() else {
            return nil
        }
        let connection = await agent.connectionService.findByInvitationKey(invitationKey)
        return connection
    }

We are using message.threadId to find the related oob-record here. I've checked out the oob spec again and found this: The response to an out-of-band message MUST set its ~thread.pthid equal to the @id property of the out-of-band message. And, we are assigning the pthid to all outbound messages in MessageSender according to the spec. So, we'll be able to find the oob-record by message.parentThreadId without introducing the attach_thread_id tag.

kukgini commented 5 months ago

@conanoc I didn't know that pthid in credential-request or presentation message is same as oob @id. When testing, I couldn't do that because this value was different. Are you saying that I need to set the oob @id to pthid when creating a message?

conanoc commented 5 months ago

We are assigning the pthid to all outbound messages in MessageSender: https://github.com/hyperledger/aries-framework-swift/blob/main/Sources/AriesFramework/agent/MessageSender.swift#L48 I guess the pthid of the messages(credential-request or presentation message) should be already the same as the oob id. (Note that the pthid is assigned just before the message is sent.)

kukgini commented 5 months ago

You are right. I was confused oob invitation id with oob record id.

conanoc commented 5 months ago

Good job. The strange lint errors are gone now. I don't know what happened to swiftlint. It seems like the only thing left to do is implement the testConnectionlessProofExchange() function.

conanoc commented 5 months ago

Looks good. Thanks.