Skip to content

Implement DCQL module #1023

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

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ val modules = listOfNotNull(
"waltid-digital-credentials",
"waltid-mdoc-credentials",
"waltid-dif-definitions-parser",
"waltid-dcql",
"waltid-verification-policies"
),

Expand Down
7 changes: 7 additions & 0 deletions waltid-libraries/credentials/waltid-dcql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# waltid-dcql

As per section 6 of the OpenID4VP
specification: https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-digital-credentials-query-l

DCQL (Digital Credentials Query Language) is the successor matching format to [Presentation Definition](https://identity.foundation/presentation-exchange/#presentation-definition) objects.

138 changes: 138 additions & 0 deletions waltid-libraries/credentials/waltid-dcql/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("maven-publish")
id("dev.petuska.npm.publish") version "3.5.2"
// id("love.forte.plugin.suspend-transform")
id("com.github.ben-manes.versions")
}

group = "id.walt.dcql"

repositories {
mavenCentral()
}

kotlin {
jvmToolchain(17)

fun getSetting(name: String) = providers.gradleProperty(name).orNull.toBoolean()
//val enableAndroidBuild = getSetting("enableAndroidBuild")
val enableIosBuild = getSetting("enableIosBuild")

jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
}

js(IR) {
outputModuleName = "dcql"
nodejs {
generateTypeScriptDefinitions()
}
binaries.library()
}

if (enableIosBuild) {
iosArm64()
iosSimulatorArm64()
}

sourceSets {
val commonMain by getting {
dependencies {
// JSON
//implementation("com.eygraber:jsonpathkt-kotlinx:3.0.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
//implementation("io.github.optimumcode:json-schema-validator:0.4.0")

// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")

// Logging
implementation("io.github.oshai:kotlin-logging:7.0.5")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmTest by getting {
dependencies {
implementation("org.slf4j:slf4j-simple:2.0.16")
}
}

if (enableIosBuild) {
val iosArm64Main by getting
val iosSimulatorArm64Main by getting

val iosMain by creating {
dependsOn(commonMain)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}

val iosArm64Test by getting
val iosSimulatorArm64Test by getting

val iosTest by creating {
dependsOn(commonTest)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
}
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["kotlin"])
pom {
name.set("walt.id DIF Definitions Parser")
description.set(
"""
Kotlin/Java library for DIF definitions parsing
""".trimIndent()
)
url.set("https://walt.id")

licenses {
license {
name.set("Apache License 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}

developers {
developer {
id.set("walt.id")
name.set("walt.id")
email.set("[email protected]")
}
}
}
}
}

repositories {
maven {
url = uri(if (version.toString().endsWith("SNAPSHOT")) uri("https://maven.waltid.dev/snapshots") else uri("https://maven.waltid.dev/releases"))
credentials {
username = System.getenv("MAVEN_USERNAME") ?: File("$rootDir/secret_maven_username.txt").let { if (it.isFile) it.readLines().first() else "" }
password = System.getenv("MAVEN_PASSWORD") ?: File("$rootDir/secret_maven_password.txt").let { if (it.isFile) it.readLines().first() else "" }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package id.walt.dcql

import kotlinx.serialization.json.JsonObject

/**
* Interface representing a credential held by the wallet.
* Implementations will vary based on actual credential storage.
*/
interface Credential {
val id: String // Wallet's internal unique ID for this credential
val format: String // Matches CredentialQuery.format
val data: JsonObject // The actual credential data (claims, etc.)
// val issuer: String? // Issuer identifier (for trusted_authorities check)
// Add other relevant properties like issuanceDate, expirationDate, etc. if needed
}

/**
* A sample concrete implementation for testing purposes.
*/
data class SampleCredential(
override val id: String,
override val format: String,
override val data: JsonObject,
// override val issuer: String? = null,
) : Credential
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package id.walt.dcql

// Custom exception for match failures
class DcqlMatchException(message: String) : Exception(message)
Loading