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

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

24 Apr 2024 03:50PM UTC coverage: 31.67% (-0.2%) from 31.912%
8819479157

push

web-flow
feat: key management for Ed25519 and X25519 (#966)

Signed-off-by: Pat Losoponkul <pat.losoponkul@iohk.io>

110 of 385 new or added lines in 22 files covered. (28.57%)

464 existing lines in 120 files now uncovered.

4666 of 14733 relevant lines covered (31.67%)

0.32 hits per line

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

54.55
/castor/lib/core/src/main/scala/io/iohk/atala/castor/core/model/did/DID.scala
1
package io.iohk.atala.castor.core.model.did
2

3
import scala.util.matching.Regex
4

5
opaque type DIDMethod = String
6

7
object DIDMethod {
8

1✔
9
  private val DID_METHOD_REGEX: Regex = """^[a-z0-9]+$""".r
10

11
  extension (method: DIDMethod) {
×
12
    def toString: String = method
13
  }
14

1✔
15
  def fromStringUnsafe(s: String): DIDMethod = s
16

1✔
17
  def fromString(s: String): Either[String, DIDMethod] =
18
    DID_METHOD_REGEX
×
19
      .findFirstMatchIn(s)
×
20
      .toRight(s"The DID method $s does not conform to the syntax")
1✔
21
      .map(_ => s)
22

23
}
24

25
opaque type DIDMethodSpecificId = String
26

27
object DIDMethodSpecificId {
28

29
  private val DID_METHOD_ID_REGEX: Regex =
1✔
30
    """^(([A-Za-z0-9_\-\.]|(%[0-9A-F]{2}))*:)*([A-Za-z0-9_\-\.]|(%[0-9A-F]{2}))+$""".r
31

32
  extension (id: DIDMethodSpecificId) {
×
33
    def toString: String = id
34
  }
35

1✔
36
  def fromStringUnsafe(s: String): DIDMethodSpecificId = s
37

1✔
38
  def fromString(s: String): Either[String, DIDMethodSpecificId] =
39
    DID_METHOD_ID_REGEX
×
40
      .findFirstMatchIn(s)
×
41
      .toRight(s"The DID method specific id $s does not conform to the syntax")
1✔
42
      .map(_ => s)
43

44
}
45

46
final case class DID(
47
    method: DIDMethod,
48
    methodSpecificId: DIDMethodSpecificId
49
) {
1✔
50
  override def toString: String = s"did:$method:$methodSpecificId"
51
}
52

53
object DID {
1✔
54
  def fromString(s: String): Either[String, DID] = {
1✔
55
    for {
×
56
      _ <- Either.cond(s.startsWith("did:"), (), "DID syntax must start with 'did:' prefix")
×
57
      methodRaw = s.drop("did:".length).takeWhile(_ != ':')
×
UNCOV
58
      methodSpecificIdRaw = s.drop("did:".length).dropWhile(_ != ':').drop(1)
×
59
      method <- DIDMethod.fromString(methodRaw)
1✔
60
      methodSpecificId <- DIDMethodSpecificId.fromString(methodSpecificIdRaw)
61
    } yield DID(method, methodSpecificId)
62
  }
63
}
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