Skip to content

Commit

Permalink
feat(agent): add mediation grant message
Browse files Browse the repository at this point in the history
Fixes ATL-3022
  • Loading branch information
goncalo-frade-iohk committed Jan 27, 2023
1 parent 617640c commit d53119c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.iohk.atala.prism.walletsdk.prismagent.protocols

import io.iohk.atala.prism.apollo.uuid.UUID
import io.iohk.atala.prism.domain.models.Message
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json

sealed class MediationProtocolError : Throwable() {
class InvalidMediationGrantError : MediationProtocolError()
}

class MediationGrant {
@Serializable
data class Body(var routingDid: String)

var id: String
var type = ProtocolType.DidcommMediationGrant.value
var body: Body

constructor(
id: String = UUID.randomUUID4().toString(),
body: Body
) {
this.id = id
this.body = body
}

constructor(fromMessage: Message) {
if (fromMessage.piuri != ProtocolType.DidcommMediationGrant.value) {
throw MediationProtocolError.InvalidMediationGrantError()
}
this.id = fromMessage.id
this.body = Json.decodeFromString(fromMessage.body)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import io.iohk.atala.prism.apollo.uuid.UUID
import io.iohk.atala.prism.domain.models.DID
import io.iohk.atala.prism.domain.models.Message

class MediationRequest(
sealed class MediationRequest(
val id: String,
val type: String = ProtocolType.DidcommMediationRequest.value,
val from: DID,
Expand Down

This file was deleted.

0 comments on commit d53119c

Please sign in to comment.