Skip to content

Commit

Permalink
Merge pull request #682 from walt-id/update-structure_presentation-pa…
Browse files Browse the repository at this point in the history
…rser

Update structure, initial presentation definition parser
  • Loading branch information
waltkb authored Aug 8, 2024
2 parents 4c13558 + d7cbe4f commit 9a93908
Show file tree
Hide file tree
Showing 528 changed files with 1,835 additions and 590 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ secret*

**/.kotlin

**/*.pem
**/issuer-*.pem
**/root-*.pem

# Created by https://www.toptal.com/developers/gitignore/api/xcode,swift,cocoapods
# Edit at https://www.toptal.com/developers/gitignore?templates=xcode,swift,cocoapods
Expand Down
4 changes: 2 additions & 2 deletions .run/Web wallet backend.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Web wallet backend" type="JetRunConfigurationType">
<option name="ALTERNATIVE_JRE_PATH" value="temurin-17"/>
<option name="ALTERNATIVE_JRE_PATH" value="17"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true"/>
<option name="MAIN_CLASS_NAME" value="id.walt.webwallet.MainKt"/>
<module name="waltid-identity.waltid-services.waltid-wallet-api.main"/>
Expand All @@ -11,4 +11,4 @@
<option name="Make" enabled="true"/>
</method>
</configuration>
</component>
</component>
4 changes: 2 additions & 2 deletions docker-compose/wallet-api/config/_features.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
enabledFeatures = [
"registration-defaults",
]

]
76 changes: 40 additions & 36 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,49 @@ fun getSetting(name: String) = providers.gradleProperty(name).orNull.toBoolean()
val enableAndroidBuild = getSetting("enableAndroidBuild")
val enableIosBuild = getSetting("enableIosBuild")

infix fun String.whenEnabled(setting: Boolean) = if (setting) this else null
fun String.group(vararg elements: String?) = elements.map { it?.let { "$this:$it" } }.toTypedArray()

// Build setup:

// Shorthands
val libraries = ":waltid-libraries"
val applications = ":waltid-applications"
val services = ":waltid-services"

val baseModules = listOf(
"$libraries:waltid-crypto",
"$libraries:waltid-did",
"$libraries:waltid-verifiable-credentials",
"$libraries:waltid-mdoc-credentials",
"$libraries:waltid-sdjwt",
val modules = listOf(
* "$libraries:crypto".group(
"waltid-crypto",
"waltid-crypto-oci",
"waltid-crypto-android" whenEnabled enableAndroidBuild,
"waltid-crypto-ios" whenEnabled enableIosBuild,
"waltid-target-ios" whenEnabled enableIosBuild,
"waltid-target-ios:implementation" whenEnabled enableIosBuild,
),

* "$libraries:credentials".group(
"waltid-verifiable-credentials",
"waltid-mdoc-credentials",
"waltid-dif-presentation-exchange"
),

* "$libraries:protocols".group(
"waltid-openid4vc"
),

* "$libraries:sdjwt".group(
"waltid-sdjwt",
"waltid-sdjwt-ios" whenEnabled enableIosBuild,
),

/*
* "$libraries:util".group(
"waltid-reporting"
),
*/

// Protocols
"$libraries:waltid-openid4vc",
"$libraries:waltid-did",
"$libraries:waltid-java-compat",

// Service commons
"$services:waltid-service-commons",
Expand All @@ -35,36 +62,13 @@ val baseModules = listOf(
// CLI
"$applications:waltid-cli",

// Reporting
"$libraries:waltid-reporting",

// OCI extension for waltid-crypto
"$libraries:waltid-crypto-oci",
"$libraries:waltid-credentials-base",

"$libraries:waltid-java-compat"
)

val androidModules = listOf(
":waltid-libraries:waltid-crypto-android",
":waltid-applications:waltid-android"
)

val iosModules = listOf(
"$libraries:waltid-crypto-ios",
"$libraries:waltid-sdjwt-ios",
"$libraries:waltid-target-ios",
"$libraries:waltid-target-ios:implementation",
"$applications:waltid-openid4vc-ios-testApp",
"$applications:waltid-openid4vc-ios-testApp:shared"
)

val enabledModules = ArrayList<String>(baseModules)
":waltid-applications:waltid-android" whenEnabled enableAndroidBuild,

if (enableAndroidBuild) enabledModules.addAll(androidModules)
if (enableIosBuild) enabledModules.addAll(iosModules)
"$applications:waltid-openid4vc-ios-testApp" whenEnabled enableIosBuild,
"$applications:waltid-openid4vc-ios-testApp:shared" whenEnabled enableIosBuild
).filterNotNull()

include(*enabledModules.toTypedArray())
include(*modules.toTypedArray())

pluginManagement {
repositories {
Expand Down
6 changes: 3 additions & 3 deletions waltid-applications/waltid-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ android {

dependencies {
// walt.id
api(project(":waltid-libraries:waltid-crypto-android"))
api(project(":waltid-libraries:crypto:waltid-crypto-android"))

api(project(":waltid-libraries:waltid-did"))
api(project(":waltid-libraries:waltid-verifiable-credentials"))
api(project(":waltid-libraries:waltid-sdjwt"))
api(project(":waltid-libraries:credentials:waltid-verifiable-credentials"))
api(project(":waltid-libraries:sdjwt:waltid-sdjwt"))

// JSON
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
Expand Down
8 changes: 4 additions & 4 deletions waltid-applications/waltid-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api(project(":waltid-libraries:waltid-crypto"))
api(project(":waltid-libraries:crypto:waltid-crypto"))
api(project(":waltid-libraries:waltid-did"))
api(project(":waltid-libraries:waltid-verifiable-credentials"))
api(project(":waltid-libraries:waltid-sdjwt"))
api(project(":waltid-libraries:waltid-openid4vc"))
api(project(":waltid-libraries:credentials:waltid-verifiable-credentials"))
api(project(":waltid-libraries:sdjwt:waltid-sdjwt"))
api(project(":waltid-libraries:protocols:waltid-openid4vc"))

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0")
Expand Down
2 changes: 1 addition & 1 deletion waltid-applications/waltid-crypto-ios-testApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ target 'waltid.crypto.ios.testApp' do

# Pods for waltid.crypto.ios.testApp
# in order to find the artifact run :waltid-crypto-ios:podPublishDebugXCFramework
pod 'waltid_crypto_ios', :path => '../../waltid-libraries/waltid-crypto-ios/build/cocoapods/publish/debug/waltid_crypto_ios.podspec'
pod 'waltid_crypto_ios', :path => '../../waltid-libraries/crypto/waltid-crypto-ios/build/cocoapods/publish/debug/waltid_crypto_ios.podspec'


end
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ kotlin {
version = "2.4.0"
}
}

sourceSets {
commonMain.dependencies {
implementation(project(":waltid-libraries:waltid-sdjwt"))
implementation(project(":waltid-libraries:sdjwt:waltid-sdjwt"))
implementation(project(":waltid-libraries:waltid-did"))
implementation(project(":waltid-libraries:waltid-openid4vc"))
implementation(project(":waltid-libraries:waltid-verifiable-credentials"))
implementation(project(":waltid-libraries:protocols:waltid-openid4vc"))
implementation(project(":waltid-libraries:credentials:waltid-verifiable-credentials"))
}
commonTest.dependencies {

Expand All @@ -41,9 +41,9 @@ kotlin {
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
dependencies {
implementation(project(":waltid-libraries:waltid-crypto-ios"))
implementation(project(":waltid-libraries:crypto:waltid-crypto-ios"))
implementation("io.ktor:ktor-client-darwin:2.3.12")
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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.4.3"
// id("love.forte.plugin.suspend-transform") version "2.0.20-Beta1-0.9.2"
id("com.github.ben-manes.versions")
}

group = "id.walt.dif-presentation-exchange"

repositories {
mavenCentral()
}

kotlin {
jvmToolchain(17)

jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
withJava()
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
}

js(IR) {
moduleName = "presentation-exchange"
nodejs {
generateTypeScriptDefinitions()
}
binaries.library()
}

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

implementation(project(":waltid-libraries:credentials:waltid-verifiable-credentials"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
//implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1")
}
}
val jvmTest by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
implementation("org.slf4j:slf4j-simple:2.0.13")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package id.walt.presentationexchange

import kotlinx.serialization.*
import kotlinx.serialization.json.*

@Serializable
data class PresentationDefinition(
val id: String,
val name: String? = null,
val purpose: String? = null,
val format: JsonObject? = null,
val frame: Map<String, JsonElement>? = null,
@SerialName("submission_requirements")
val submissionRequirements: List<SubmissionRequirement>? = null,
@SerialName("input_descriptors")
val inputDescriptors: List<InputDescriptor>
) {
@Serializable
data class InputDescriptor(
val id: String,
val name: String? = null,
val purpose: String? = null,
val format: JsonElement? = null,
val group: List<String>? = null,
val constraints: Constraints
) {
@Suppress("EnumEntryName")
enum class Directive {
required,
preferred,
disallowed
}

@Serializable
data class Constraints(
@SerialName("limit_disclosure")
val limitDisclosure: Directive? = null,
val statuses: Statuses? = null,
val fields: List<Field>? = null,
@SerialName("subject_is_issuer")
val subjectIsIssuer: String? = null,
@SerialName("is_holder")
val isHolder: List<Subject>? = null,
@SerialName("same_subject")
val sameSubject: List<Subject>? = null
) {


@Serializable
data class Statuses(
val active: StatusDirective? = null,
val suspended: StatusDirective? = null,
val revoked: StatusDirective? = null
)

@Serializable
data class Field(
val id: String? = null,
val optional: Boolean? = null,
val path: List<String>,
val purpose: String? = null,
val name: String? = null,
@SerialName("intent_to_retain")
val intentToRetain: Boolean? = null,
val filter: JsonElement? = null,
val predicate: String? = null
)

@Serializable
data class Subject(
@SerialName("field_id")
val fieldId: List<String>,
val directive: Directive
)

@Serializable
data class StatusDirective(
val type: List<String>,
val directive: Directive,
) {
init {
check(type.isNotEmpty())
}
}
}
}
}
Loading

0 comments on commit 9a93908

Please sign in to comment.