Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: connectionless credential offer #207

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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
Loading