• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperledger / identus-cloud-agent / 10793991050

10 Sep 2024 01:56PM CUT coverage: 48.504% (-4.5%) from 52.962%
10793991050

push

web-flow
build: sbt and plugins dependency update (#1337)

Signed-off-by: Hyperledger Bot <hyperledger-bot@hyperledger.org>
Signed-off-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>
Co-authored-by: Hyperledger Bot <hyperledger-bot@hyperledger.org>
Co-authored-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>

7406 of 15269 relevant lines covered (48.5%)

0.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/controller/http/DIDDocument.scala
1
package org.hyperledger.identus.castor.controller.http
2

3
import org.hyperledger.identus.api.http.Annotation
4
import org.hyperledger.identus.castor.controller.http.DIDDocument.annotations
5
import org.hyperledger.identus.castor.core.model.did.w3c
6
import sttp.tapir.Schema
7
import sttp.tapir.Schema.annotations.{description, encodedExample}
8
import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder}
9

10
import scala.language.implicitConversions
11

12
@description("A W3C compliant Prism DID document representation.")
×
13
final case class DIDDocument(
14
    `@context`: Seq[Context],
15
    @description(annotations.id.description)
×
16
    @encodedExample(annotations.id.example)
×
17
    id: String,
18
    @description(annotations.controller.description)
×
19
    @encodedExample(annotations.controller.example)
×
20
    controller: Option[String] = None,
×
21
    verificationMethod: Option[Seq[VerificationMethod]] = None,
×
22
    authentication: Option[Seq[String]] = None,
×
23
    assertionMethod: Option[Seq[String]] = None,
×
24
    keyAgreement: Option[Seq[String]] = None,
×
25
    capabilityInvocation: Option[Seq[String]] = None,
×
26
    capabilityDelegation: Option[Seq[String]] = None,
×
27
    service: Option[Seq[Service]] = None
×
28
)
29

30
object DIDDocument {
31

×
32
  object annotations {
33
    object id
×
34
        extends Annotation[String](
×
35
          description = """[DID subject](https://www.w3.org/TR/did-core/#did-subject).
×
36
              |The value must match the DID that was given to the resolver.""".stripMargin,
×
37
          example = "did:prism:4a5b5cf0a513e83b598bbea25cd6196746747f361a73ef77068268bc9bd732ff"
38
        )
39

40
    object controller
41
        extends Annotation[String](
×
42
          description = "[DID controller](https://www.w3.org/TR/did-core/#did-controller)",
43
          example = "did:prism:4a5b5cf0a513e83b598bbea25cd6196746747f361a73ef77068268bc9bd732ff"
44
        )
45
  }
46

47
  given encoder: JsonEncoder[DIDDocument] = DeriveJsonEncoder.gen[DIDDocument]
×
48
  given decoder: JsonDecoder[DIDDocument] = DeriveJsonDecoder.gen[DIDDocument]
×
49
  given schema: Schema[DIDDocument] = Schema.derived
×
50

51
  given Conversion[w3c.DIDDocumentRepr, DIDDocument] = (didDocument: w3c.DIDDocumentRepr) => {
52
    DIDDocument(
53
      `@context` = didDocument.context.map(Context(_)),
×
54
      id = didDocument.id,
55
      controller = Some(didDocument.controller),
56
      verificationMethod = Some(didDocument.verificationMethod.map(i => i)),
×
57
      authentication = Some(didDocument.authentication.map(toPublicKeyRef)),
×
58
      assertionMethod = Some(didDocument.assertionMethod.map(toPublicKeyRef)),
×
59
      keyAgreement = Some(didDocument.keyAgreement.map(toPublicKeyRef)),
×
60
      capabilityInvocation = Some(didDocument.capabilityInvocation.map(toPublicKeyRef)),
×
61
      capabilityDelegation = Some(didDocument.capabilityDelegation.map(toPublicKeyRef)),
×
62
      service = Some(didDocument.service.map(i => i))
×
63
    )
64
  }
65

66
  // TODO: support embedded public key
67
  private def toPublicKeyRef(publicKeyReprOrRef: w3c.PublicKeyReprOrRef): String = {
×
68
    publicKeyReprOrRef match {
69
      case s: String => s
×
70
      case pk        => throw Exception("Embedded public key is not yet supported by PRISM DID.")
×
71
    }
72
  }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc