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

input-output-hk / atala-prism-building-blocks / 8907531204

01 May 2024 09:05AM UTC coverage: 49.271% (-0.3%) from 49.553%
8907531204

push

web-flow
ci: fix scala-steward after moving repo to hyperledger (#993)

7 of 29 new or added lines in 3 files covered. (24.14%)

256 existing lines in 78 files now uncovered.

7295 of 14806 relevant lines covered (49.27%)

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.core.model.did.w3c
5
import sttp.tapir.Schema
6
import sttp.tapir.Schema.annotations.{description, encodedExample}
7
import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonEncoder, JsonDecoder}
8
import org.hyperledger.identus.castor.controller.http.DIDDocument.annotations
9
import scala.language.implicitConversions
10

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

29
object DIDDocument {
UNCOV
30

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

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

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

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

65
  // TODO: support embedded public key
66
  private def toPublicKeyRef(publicKeyReprOrRef: w3c.PublicKeyReprOrRef): String = {
×
67
    publicKeyReprOrRef match {
68
      case s: String => s
×
69
      case pk        => throw Exception("Embedded public key is not yet supported by PRISM DID.")
×
70
    }
71
  }
72
}
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