Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/4.1.1 #105

Merged
merged 3 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
path = conventions-vclib/gradle-conventions-plugin
url = https://github.com/a-sit-plus/gradle-conventions-plugin.git
[submodule "kmp-crypto"]
path = kmp-crypto
url = https://github.com/a-sit-plus/kmp-crypto.git
path = signum
url = https://github.com/a-sit-plus/signum.git
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

Release 4.1.1 (Bugfix Release):
* correctly configure and name JSON serializer:
* `jsonSerializer` -> `vckJsonSerializer`
* revert to explicit serializer configuration
* Introduce `jsonSerializer` and `cborSerilaizer` with deprecation annotation for easier migration in projects consuming VC-K
* rename kmp-crypto submodule to signum an update all references
* this changes the identifier in the version catalog!

Release 4.1.0:
* Rebrand
* Project name: _KMM VC Library_ -> VC-K
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Notable features for multiplatform are:

Some parts for increased multiplatform support have been extracted into separate repositories:
- Reimplementation of Kotlin's [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/) called [KmmResult](https://github.com/a-sit-plus/kmmresult) for easy use from Swift code (since inline classes are [not supported](https://kotlinlang.org/docs/native-objc-interop.html#unsupported)).
- Several crypto datatypes including an ASN.1 parser and encoder called [kmp-crypto](https://github.com/a-sit-plus/kmp-crypto).
- Several crypto datatypes including an ASN.1 parser and encoder called [Signum](https://github.com/a-sit-plus/signum).

The main entry point for applications is an instance of `HolderAgent`, `VerifierAgent` or `IssuerAgent`, according to the nomenclature from the [W3C VC Data Model](https://w3c.github.io/vc-data-model/).

Expand Down
23 changes: 11 additions & 12 deletions conventions-vclib/src/main/kotlin/VcLibConventions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.utils.named


val Project.kmpCryptoVersionCatalog: VersionCatalog
get() = extensions.getByType<VersionCatalogsExtension>().named("kmpCrypto")
val Project.signumVersionCatalog: VersionCatalog
get() = extensions.getByType<VersionCatalogsExtension>().named("signum")

inline fun Project.commonApiDependencies(): List<String> {
project.AspVersions.versions["kmpcrypto"] = VcLibVersions.kmpcrypto
project.AspVersions.versions["signum"] = VcLibVersions.signum
project.AspVersions.versions["jsonpath"] = VcLibVersions.jsonpath
project.AspVersions.versions["okio"] = kmpCryptoVersionCatalog.findVersion("okio").get().toString()
project.AspVersions.versions["okio"] = signumVersionCatalog.findVersion("okio").get().toString()
project.AspVersions.versions["encoding"] = "2.2.1"


return listOf(
coroutines(),
serialization("json"),
serialization("cbor"),
addDependency("at.asitplus.signum:indispensable", "kmpcrypto"), //for iOS Export
addDependency("at.asitplus.signum:indispensable-cosef", "kmpcrypto"),
addDependency("at.asitplus.signum:indispensable-josef", "kmpcrypto"),
addDependency("at.asitplus.signum:indispensable", "signum"), //for iOS Export
addDependency("at.asitplus.signum:indispensable-cosef", "signum"),
addDependency("at.asitplus.signum:indispensable-josef", "signum"),
addDependency("at.asitplus:jsonpath4k", "jsonpath"),
datetime(),
addDependency("com.squareup.okio:okio", "okio"),
Expand All @@ -56,11 +55,11 @@ inline fun KotlinDependencyHandler.commonImplementationDependencies() {

fun Project.commonIosExports() = arrayOf(
datetime(),
"com.ionspin.kotlin:bignum:${kmpCryptoVersionCatalog.findVersion("bignum").get()}",
"com.ionspin.kotlin:bignum:${signumVersionCatalog.findVersion("bignum").get()}",
kmmresult(),
"at.asitplus.signum:indispensable:${VcLibVersions.kmpcrypto}",
"at.asitplus.signum:indispensable-cosef:${VcLibVersions.kmpcrypto}",
"at.asitplus.signum:indispensable-josef:${VcLibVersions.kmpcrypto}",
"at.asitplus.signum:indispensable:${VcLibVersions.signum}",
"at.asitplus.signum:indispensable-cosef:${VcLibVersions.signum}",
"at.asitplus.signum:indispensable-josef:${VcLibVersions.signum}",
"at.asitplus:jsonpath4k:${VcLibVersions.jsonpath}",
"io.matthewnelson.encoding:core:${AspVersions.versions["encoding"]}",
"io.matthewnelson.encoding:base16:${AspVersions.versions["encoding"]}",
Expand Down
2 changes: 1 addition & 1 deletion conventions-vclib/src/main/kotlin/VcLibVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object VcLibVersions {
private fun versionOf(dependency: String) = versions[dependency] as String

val uuid get() = versionOf("uuid")
val kmpcrypto get() = versionOf("kmpCrypto")
val signum get() = versionOf("signum")
val jsonpath get() = versionOf("jsonpath")
val eupidcredential get() = versionOf("eupid")
val mdl get() = versionOf("mdl")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kmpCrypto=3.6.0
signum=3.6.0
uuid=0.8.1
jsonpath=2.2.0
jvm.json=20230618
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.stability.nowarn=true
kotlin.native.ignoreDisabledTargets=true

artifactVersion = 4.1.0
artifactVersion = 4.1.1
jdk.version=17


8 changes: 4 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ pluginManagement {
}

if (System.getProperty("publishing.excludeIncludedBuilds") != "true") {
includeBuild("kmp-crypto") {
includeBuild("signum") {
dependencySubstitution {
substitute(module("at.asitplus.signum:indispensable")).using(project(":indispensable"))
substitute(module("at.asitplus.signum:indispensable-josef")).using(project(":indispensable-josef"))
substitute(module("at.asitplus.signum:indispensable-cosef")).using(project(":indispensable-cosef"))
}
}
} else logger.lifecycle("Excluding KMP Crypto from this build")
} else logger.lifecycle("Excluding Signum from this build")

rootProject.name = "vc-k"
include(":vck")
Expand All @@ -40,8 +40,8 @@ dependencyResolutionManagement {

fun versionOf(dependency: String) = versions[dependency] as String

create("kmpCrypto") {
from("at.asitplus.signum:indispensable-versionCatalog:${versionOf("kmpCrypto")}")
create("signum") {
from("at.asitplus.signum:indispensable-versionCatalog:${versionOf("signum")}")
}
}
}
4 changes: 2 additions & 2 deletions vck-aries/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ kotlin {

jvmMain {
dependencies {
implementation(kmpCrypto.bcpkix.jdk18on)
implementation(signum.bcpkix.jdk18on)
}
}
jvmTest {
dependencies {
implementation(kmpCrypto.jose)
implementation(signum.jose)
implementation("org.json:json:${VcLibVersions.Jvm.json}")
}
}
Expand Down
4 changes: 2 additions & 2 deletions vck-openid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ kotlin {

jvmMain {
dependencies {
implementation(kmpCrypto.bcpkix.jdk18on)
implementation(signum.bcpkix.jdk18on)
}
}

jvmTest {
dependencies {
implementation(kmpCrypto.jose)
implementation(signum.jose)
implementation("org.json:json:${VcLibVersions.Jvm.json}")
}
}
Expand Down
4 changes: 2 additions & 2 deletions vck/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ kotlin {

jvmMain {
dependencies {
implementation(kmpCrypto.bcpkix.jdk18on)
implementation(signum.bcpkix.jdk18on)
}
}
jvmTest {
dependencies {
implementation(kmpCrypto.jose)
implementation(signum.jose)
implementation("org.json:json:${VcLibVersions.Jvm.json}")
implementation("com.authlete:cbor:${VcLibVersions.Jvm.`authlete-cbor`}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ object CredentialToJsonConverter {
is SubjectCredentialStore.StoreEntry.Vc -> {
buildJsonObject {
put("type", JsonPrimitive(credential.scheme.vcType))
jsonSerializer.encodeToJsonElement(credential.vc.vc.credentialSubject).jsonObject.entries.forEach {
vckJsonSerializer.encodeToJsonElement(credential.vc.vc.credentialSubject).jsonObject.entries.forEach {
put(it.key, it.value)
}
// TODO: Remove the rest here when there is a clear specification on how to encode vc credentials
// This may actually depend on the presentation context, so more information may be required
put("vc", buildJsonArray {
add(jsonSerializer.encodeToJsonElement(credential.vc.vc.credentialSubject))
add(vckJsonSerializer.encodeToJsonElement(credential.vc.vc.credentialSubject))
})
}
}
Expand Down
11 changes: 9 additions & 2 deletions vck/src/commonMain/kotlin/at/asitplus/wallet/lib/data/Json.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ internal object JsonCredentialSerializer {

}

val jsonSerializer by lazy {
Json(from = at.asitplus.signum.indispensable.josef.io.joseCompliantSerializer) {
@Deprecated("use vckJsonSerializer", replaceWith = ReplaceWith("vckJsonSerializer"))
val jsonSerializer get() = vckJsonSerializer

val vckJsonSerializer by lazy {
Json {
prettyPrint = false
encodeDefaults = false
classDiscriminator = "type"
ignoreUnknownKeys = true
serializersModule = SerializersModule {
polymorphic(CredentialSubject::class) {
subclass(AtomicAttribute2023::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class KeyBindingJws(
val sdHash: ByteArray,
) {

fun serialize() = jsonSerializer.encodeToString(this)
fun serialize() = vckJsonSerializer.encodeToString(this)

override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand All @@ -50,7 +50,7 @@ data class KeyBindingJws(

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<KeyBindingJws>(it)
vckJsonSerializer.decodeFromString<KeyBindingJws>(it)
}.wrap()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data class SelectiveDisclosureItem(
val claimValue: Any,
) {

fun serialize() = jsonSerializer.encodeToString(this)
fun serialize() = vckJsonSerializer.encodeToString(this)

/**
* Creates a disclosure, as described in section 5.2 of
Expand Down Expand Up @@ -60,7 +60,7 @@ data class SelectiveDisclosureItem(

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<SelectiveDisclosureItem>(it)
vckJsonSerializer.decodeFromString<SelectiveDisclosureItem>(it)
}.wrap()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ data class VerifiableCredentialJws(
val jwtId: String
) {

fun serialize() = jsonSerializer.encodeToString(this)
fun serialize() = vckJsonSerializer.encodeToString(this)

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<VerifiableCredentialJws>(it)
vckJsonSerializer.decodeFromString<VerifiableCredentialJws>(it)
}.wrap()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ data class VerifiableCredentialSdJwt(
val confirmationKey: JsonWebKey? = null,
) {

fun serialize() = jsonSerializer.encodeToString(this)
fun serialize() = vckJsonSerializer.encodeToString(this)

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<VerifiableCredentialSdJwt>(it)
vckJsonSerializer.decodeFromString<VerifiableCredentialSdJwt>(it)
}.wrap()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ data class VerifiablePresentationJws(
val jwtId: String
) {

fun serialize() = jsonSerializer.encodeToString(this)
fun serialize() = vckJsonSerializer.encodeToString(this)

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<VerifiablePresentationJws>(it)
vckJsonSerializer.decodeFromString<VerifiablePresentationJws>(it)
}.wrap()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package at.asitplus.wallet.lib.data.dif

import at.asitplus.KmmResult.Companion.wrap
import at.asitplus.wallet.lib.data.jsonSerializer
import at.asitplus.wallet.lib.data.vckJsonSerializer
import com.benasher44.uuid.uuid4
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down Expand Up @@ -31,11 +31,11 @@ data class PresentationDefinition(
formats: FormatHolder
) : this(id = uuid4().toString(), inputDescriptors = inputDescriptors, formats = formats)

fun serialize() = jsonSerializer.encodeToString(this)
fun serialize() = vckJsonSerializer.encodeToString(this)

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<PresentationDefinition>(it)
vckJsonSerializer.decodeFromString<PresentationDefinition>(it)
}.wrap()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package at.asitplus.wallet.lib.iso

import at.asitplus.KmmResult.Companion.wrap
import at.asitplus.wallet.lib.data.jsonSerializer
import at.asitplus.wallet.lib.data.vckJsonSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
Expand All @@ -19,7 +19,7 @@ data class ServerRequest(
val docRequests: Array<ServerItemsRequest>,
) {

fun serialize() = jsonSerializer.encodeToString(this)
fun serialize() = vckJsonSerializer.encodeToString(this)

override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand All @@ -39,7 +39,7 @@ data class ServerRequest(

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<ServerRequest>(it)
vckJsonSerializer.decodeFromString<ServerRequest>(it)
}.wrap()
}
}
Expand Down Expand Up @@ -72,7 +72,7 @@ data class ServerResponse(
@SerialName("documentErrors")
val documentErrors: Map<String, Int>? = null,
) {
fun serialize() = jsonSerializer.encodeToString(this)
fun serialize() = vckJsonSerializer.encodeToString(this)

override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand All @@ -94,7 +94,7 @@ data class ServerResponse(

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<ServerResponse>(it)
vckJsonSerializer.decodeFromString<ServerResponse>(it)
}.wrap()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ internal object CborCredentialSerializer {
}
}

@Deprecated("use vckCborSerializer instead", replaceWith = ReplaceWith("vckCborSerializer"))
val cborSerializer get() = vckCborSerializer

@OptIn(ExperimentalSerializationApi::class)
val vckCborSerializer by lazy {
Cbor(from = at.asitplus.signum.indispensable.cosef.io.coseCompliantSerializer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import at.asitplus.signum.indispensable.josef.JwsSigned
import at.asitplus.wallet.lib.agent.CryptoService
import at.asitplus.wallet.lib.agent.DefaultCryptoService
import at.asitplus.wallet.lib.agent.RandomKeyPairAdapter
import at.asitplus.wallet.lib.data.jsonSerializer
import at.asitplus.wallet.lib.data.vckJsonSerializer
import com.benasher44.uuid.uuid4
import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.nulls.shouldNotBeNull
Expand Down Expand Up @@ -57,7 +57,7 @@ class JwsServiceTest : FreeSpec({
}

"signed object can be verified" {
val stringPayload = jsonSerializer.encodeToString(randomPayload)
val stringPayload = vckJsonSerializer.encodeToString(randomPayload)
val signed =
jwsService.createSignedJwt(JwsContentTypeConstants.JWT, stringPayload.encodeToByteArray()).getOrThrow()
signed.shouldNotBeNull()
Expand Down Expand Up @@ -107,7 +107,7 @@ class JwsServiceTest : FreeSpec({
}

"encrypted object can be decrypted" {
val stringPayload = jsonSerializer.encodeToString(randomPayload)
val stringPayload = vckJsonSerializer.encodeToString(randomPayload)
val encrypted = jwsService.encryptJweObject(
JwsContentTypeConstants.DIDCOMM_ENCRYPTED_JSON,
stringPayload.encodeToByteArray(),
Expand Down
Loading
Loading