diff --git a/src/main/kotlin/id/walt/rest/core/DidController.kt b/src/main/kotlin/id/walt/rest/core/DidController.kt index 98c6b588..9da55d45 100644 --- a/src/main/kotlin/id/walt/rest/core/DidController.kt +++ b/src/main/kotlin/id/walt/rest/core/DidController.kt @@ -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 } diff --git a/src/main/kotlin/id/walt/rest/core/requests/did/CreateDidRequest.kt b/src/main/kotlin/id/walt/rest/core/requests/did/CreateDidRequest.kt index 62c6e2f0..0f5e4a16 100644 --- a/src/main/kotlin/id/walt/rest/core/requests/did/CreateDidRequest.kt +++ b/src/main/kotlin/id/walt/rest/core/requests/did/CreateDidRequest.kt @@ -29,7 +29,7 @@ class CreateDidRequestMethodAdapter : TypeAdapter { @Serializable class KeyCreateDidRequest( override val keyAlias: String? = null, - val isJwk: Boolean = false, + val useJwkJcsPub: Boolean = false, ) : CreateDidRequest("key") @Serializable class WebCreateDidRequest( diff --git a/src/main/kotlin/id/walt/services/did/DidOptions.kt b/src/main/kotlin/id/walt/services/did/DidOptions.kt index 2fbfaee0..d0dd40da 100644 --- a/src/main/kotlin/id/walt/services/did/DidOptions.kt +++ b/src/main/kotlin/id/walt/services/did/DidOptions.kt @@ -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() diff --git a/src/main/kotlin/id/walt/services/did/factories/DidKeyFactory.kt b/src/main/kotlin/id/walt/services/did/factories/DidKeyFactory.kt index 107040d5..f85fcd64 100644 --- a/src/main/kotlin/id/walt/services/did/factories/DidKeyFactory.kt +++ b/src/main/kotlin/id/walt/services/did/factories/DidKeyFactory.kt @@ -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)) diff --git a/src/test/kotlin/id/walt/services/did/DidKeyCreationTest.kt b/src/test/kotlin/id/walt/services/did/DidKeyCreationTest.kt index ed441eb2..7387a9ce 100644 --- a/src/test/kotlin/id/walt/services/did/DidKeyCreationTest.kt +++ b/src/test/kotlin/id/walt/services/did/DidKeyCreationTest.kt @@ -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" } }) diff --git a/src/test/kotlin/id/walt/services/did/DidServiceTest.kt b/src/test/kotlin/id/walt/services/did/DidServiceTest.kt index 19419dba..0da1057f 100644 --- a/src/test/kotlin/id/walt/services/did/DidServiceTest.kt +++ b/src/test/kotlin/id/walt/services/did/DidServiceTest.kt @@ -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