Skip to content

Commit

Permalink
chore: updated did-key-create-options parameter name (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeplotean authored Jun 20, 2023
1 parent d18a7ab commit 8faa45f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/id/walt/rest/core/DidController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object DidController {
is WebCreateDidRequest -> DidWebCreateOptions(request.domain ?: "walt.id", request.path)
is EbsiCreateDidRequest -> DidEbsiCreateOptions(request.version)
is CheqdCreateDidRequest -> DidCheqdCreateOptions(request.network)
is KeyCreateDidRequest -> DidKeyCreateOptions(request.isJwk)
is KeyCreateDidRequest -> DidKeyCreateOptions(request.useJwkJcsPub)
else -> null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CreateDidRequestMethodAdapter : TypeAdapter<CreateDidRequest> {
@Serializable
class KeyCreateDidRequest(
override val keyAlias: String? = null,
val isJwk: Boolean = false,
val useJwkJcsPub: Boolean = false,
) : CreateDidRequest("key")
@Serializable
class WebCreateDidRequest(
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/id/walt/services/did/DidOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ sealed class DidOptions
data class DidWebCreateOptions(val domain: String?, val path: String? = null) : DidOptions()
data class DidEbsiCreateOptions(val version: Int) : DidOptions()
data class DidCheqdCreateOptions(val network: String) : DidOptions()
data class DidKeyCreateOptions(val isJwk: Boolean) : DidOptions()
data class DidKeyCreateOptions(val useJwkJcsPub: Boolean) : DidOptions()

data class DidEbsiResolveOptions(val isRaw: Boolean) : DidOptions()
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DidKeyFactory(
}

private fun getIdentifierComponents(key: Key, options: DidKeyCreateOptions?): IdentifierComponents =
options?.takeIf { it.isJwk }?.let {
options?.takeIf { it.useJwkJcsPub }?.let {
IdentifierComponents(JwkJcsPubMultiCodecKeyCode, getJwkPubKeyRequiredMembersBytes(key))
} ?: IdentifierComponents(getMulticodecKeyCode(key.algorithm), getPublicKeyBytesForDidKey(key))

Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/id/walt/services/did/DidKeyCreationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DidKeyCreationTest : StringSpec({
"Create jwk_jcs-pub did:key" {
val jwkPubKey = "{\"kty\":\"EC\",\"crv\":\"P-256\",\"x\":\"ngy44T1vxAT6Di4nr-UaM9K3Tlnz9pkoksDokKFkmNc\",\"y\":\"QCRfOKlSM31GTkb4JHx3nXB4G_jSPMsbdjzlkT_UpPc\"}"
val keyId = keyService.importKey(jwkPubKey)
val result = createAndLoadDid(keyId, DidKeyCreateOptions(isJwk = true))
val result = createAndLoadDid(keyId, DidKeyCreateOptions(useJwkJcsPub = true))
result.id shouldBe "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9KbsEYvdrjxMjQ4tpnje9BDBTzuNDP3knn6qLZErzd4bJ5go2CChoPjd5GAH3zpFJP5fuwSk66U5Pq6EhF4nKnHzDnznEP8fX99nZGgwbAh1o7Gj1X52Tdhf7U4KTk66xsA5r"
}
})
2 changes: 1 addition & 1 deletion src/test/kotlin/id/walt/services/did/DidServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class DidServiceTest : AnnotationSpec() {
val expectedResult = Did.decode(readWhenContent(File("src/test/resources/dids/did-key-jwk_jcs-pub.json")))!!
val jwkPubKey = "{\"kty\":\"EC\",\"crv\":\"P-256\",\"x\":\"ngy44T1vxAT6Di4nr-UaM9K3Tlnz9pkoksDokKFkmNc\",\"y\":\"QCRfOKlSM31GTkb4JHx3nXB4G_jSPMsbdjzlkT_UpPc\"}"
val keyId = keyService.importKey(jwkPubKey)
val did = DidService.create(DidMethod.key, keyId.id, DidKeyCreateOptions(isJwk = true))
val did = DidService.create(DidMethod.key, keyId.id, DidKeyCreateOptions(useJwkJcsPub = true))
// when
val result = DidService.resolve(did)
// then
Expand Down

0 comments on commit 8faa45f

Please sign in to comment.