File tree 2 files changed +6
-5
lines changed
node/src/main/scala/io/iohk/atala/prism/node/identity
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,12 @@ object Did {
9
9
val DID_SCHEME : String = " did"
10
10
11
11
def fromString (didStr : String ): Did = {
12
- // https://www.w3.org/TR/did-core/#did-syntax
13
- val didPattern = " did:([A-Za-z0-9]+):((?:[a-zA-Z0-9._-]|%[0-9A-Fa-f]{2})+)" .r
12
+ // https://www.w3.org/TR/did-core/#did-syntax plus encoded state that is prism specific
13
+ val didPattern = " did:([A-Za-z0-9]+):((?:[a-zA-Z0-9._-]|%[0-9A-Fa-f]{2})+)(?::([a-zA-Z0-9_-]+))? " .r
14
14
didStr match {
15
- case didPattern(methodName, methodSpecificId) =>
16
- Did (DidMethod .fromString(methodName), DidMethodSpecificId .fromString(methodSpecificId))
15
+ case didPattern(methodName, methodSpecificId, encodedState) =>
16
+ val methodSpecificIdWithState = Option (encodedState).fold(methodSpecificId)(encodedState => s " $methodSpecificId: $encodedState" )
17
+ Did (DidMethod .fromString(methodName), DidMethodSpecificId .fromString(methodSpecificIdWithState))
17
18
case _ => throw new IllegalArgumentException (s " Invalid DID format: $didStr" )
18
19
}
19
20
}
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ object PrismDid {
125
125
longFormMatchGroups match {
126
126
case Some (groups) =>
127
127
val List (stateHashHex, encodedStateBase64, _* ) = groups
128
- require(longFormMatchGroups .size == 2 , " Invalid long form Prism DID" )
128
+ require(groups .size == 2 , " Invalid long form Prism DID" )
129
129
val stateHash = Sha256Hash .fromHex(stateHashHex)
130
130
val encodedState = Base64Utils .decodeURL(encodedStateBase64)
131
131
val atalaOperation = decodeState(stateHash, encodedState)
You can’t perform that action at this time.
0 commit comments