Skip to content

Commit

Permalink
feat: connectionless credential offer (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianIOHK authored Sep 19, 2024
1 parent e967a21 commit fce300e
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 98 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.hyperledger.identus.walletsdk.edgeagent.models

import org.hyperledger.identus.walletsdk.domain.models.AttachmentDescriptor

data class ConnectionlessMessageData(
val messageId: String,
val messageBody: String,
val attachmentDescriptor: AttachmentDescriptor,
val messageThid: String,
val messageFrom: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ constructor(
val name: String,
val value: String,
@SerialName("media_type")
val mediaType: String?
val mediaType: String? = null
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand

import kotlinx.serialization.Serializable
import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.OfferCredential
import java.util.*

/**
* Represents a connectionless credential offer.
*/
@Serializable
data class ConnectionlessCredentialOffer(
val offerCredential: OfferCredential
) : InvitationType()
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand

import kotlinx.serialization.Serializable
import org.hyperledger.identus.walletsdk.edgeagent.protocols.proofOfPresentation.RequestPresentation

@Serializable
data class ConnectionlessRequestPresentation(
val requestPresentation: RequestPresentation
) : InvitationType()
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class PickupRunner(message: Message, private val mercury: Mercury) {
*/
enum class PickupResponseType(val type: String) {
STATUS("status"),
DELIVERY("delivery")
DELIVERY("delivery"),
PROBLEM_REPORT("problem_report")
}

/**
Expand Down Expand Up @@ -60,6 +61,10 @@ class PickupRunner(message: Message, private val mercury: Mercury) {
this.message = PickupResponse(PickupResponseType.DELIVERY, message)
}

ProtocolType.ProblemReport.value -> {
this.message = PickupResponse(PickupResponseType.PROBLEM_REPORT, message)
}

else -> {
throw EdgeAgentError.InvalidMessageType(
type = message.piuri,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch
import org.hyperledger.identus.walletsdk.domain.models.DIDPair
import org.hyperledger.identus.walletsdk.edgeagent.EdgeAgentError
import org.hyperledger.identus.walletsdk.edgeagent.protocols.issueCredential.OfferCredential
import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.ConnectionlessCredentialOffer
import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.ConnectionlessRequestPresentation
import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.OutOfBandInvitation
import org.hyperledger.identus.walletsdk.edgeagent.protocols.outOfBand.PrismOnboardingInvitation
import org.hyperledger.identus.walletsdk.sampleapp.Sdk
Expand Down Expand Up @@ -46,6 +49,21 @@ class ContactsViewModel(application: Application) : AndroidViewModel(application
agent.acceptInvitation(invitation)
}

is ConnectionlessCredentialOffer -> {
val offer = OfferCredential.fromMessage(invitation.offerCredential.makeMessage())
val subjectDID = agent.createNewPrismDID()
val request =
agent.prepareRequestCredentialWithIssuer(
subjectDID,
offer
)
agent.sendMessage(request.makeMessage())
}

is ConnectionlessRequestPresentation -> {
agent.pluto.storeMessage(invitation.requestPresentation.makeMessage())
}

else -> {
throw EdgeAgentError.UnknownInvitationTypeError(invitation.toString())
}
Expand Down

0 comments on commit fce300e

Please sign in to comment.