Skip to content

Commit

Permalink
fix: mediator db not storing the orignal value for protected header (#15
Browse files Browse the repository at this point in the history
)

fix: meadiator db bson implicits to store the orginal
  • Loading branch information
mineme0110 authored Jun 19, 2023
1 parent 25728b6 commit bd119f1
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,23 @@ given BSONReader[IV] with {

given BSONWriter[Base64Obj[ProtectedHeader]] with {
import Base64Obj.*
def writeTry(obj: Base64Obj[ProtectedHeader]): Try[BSONValue] = Try(BSONString(obj.base64url))
def writeTry(obj: Base64Obj[ProtectedHeader]): Try[BSONValue] = {
val protectedHeader: String = (obj.obj, obj.original) match {
case (_, Some(op)) => op.urlBase64
case (p, None) => obj.base64url
}
Try(BSONString(protectedHeader))
}
}
given BSONReader[Base64Obj[ProtectedHeader]] with {
def readTry(bson: BSONValue): Try[Base64Obj[ProtectedHeader]] =
bson
.asTry[String]
.flatMap{v =>
.flatMap { v =>
s""""$v"""".fromJson[Base64Obj[ProtectedHeader]] match // TODO with a new methods from ScalaDid
case Left(value) => Failure(RuntimeException(value))
case Right(value) => Try(value)
}
}
}

given BSONWriter[Base64] with {
Expand Down

0 comments on commit bd119f1

Please sign in to comment.