Skip to content

Commit

Permalink
Merge pull request #147 from a-sit-plus/feature/rqesModule
Browse files Browse the repository at this point in the history
Feature/rqes module
  • Loading branch information
n0900 authored Oct 31, 2024
2 parents 68037af + 8ef01d2 commit de1588b
Show file tree
Hide file tree
Showing 97 changed files with 1,374 additions and 743 deletions.
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# Changelog

tbd
- New Class `SignatureRequestFrom` to handle signature requests by reference
- Rename `AuthenticationRequestParser` to `RequestParser`
- `RequestParser` can now handle `SignatureRequestFrom`
- New `Initializer` object in `vck-openid` which needs to be called at the start of the project if artifact is used
- New artifacts `rqes-data-classes` and `vck-rqes` which allow handling of remote signature requests as described by the draft of POTENTIAL use-case 5 which is based on the CSC API v2.0.0.2
- To use `vck-rqes` the new `Initializer` object in `vck-rqes` which needs to be called at the start of the project if artifact is used
- It fully overrides and replaces the effect of the initializer in `vck-openid`
- Change class `InputDescriptor` to `DifInputDescriptor` which now implements new interface `InputDescriptor`
- New class `QesInputDescriptor` implements `InputDescriptor`
- Refactor sealed class `AuthorizationDetails` to interface
- Refactor subclass `OpenIdCredential` to class `OpenIdAuthorizationDetails` which implements `AuthrorizationDetails`
- Refactor subclass `CSCCredential` to class `CscAuthorizationDetails` which implements `AuthorizationDetails`
- New Interface `RequestParameters`
- Remove RQES components from `AuthenticationRequestParameters`
- New class `CscAuthenticationRequestParameters` which now holds the RQES components
- New class `SignatureRequestParameters` and `SignatureRequestParametersFrom`
- Refactor `AuthenticationRequestParser` to open class `RequestParser`
- New class `ExtendedRequestParser` used to also parse `SignatureRequestParametersFrom`

Release 5.1.0:
- Drop ARIES protocol implementation, and the `vck-aries` artifact
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ Other libraries implementing credential schemes may call `LibraryInitializer.reg

For the OpenID protocol family, issuing is implemented using [OpenID for Verifiable Credential Issuance](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html), see `WalletService` and `CredentialIssuer`. Presentation of credentials is implemented using [Self-Issued OpenID Provider v2](https://openid.net/specs/openid-connect-self-issued-v2-1_0.html), supporting [OpenID for Verifiable Presentations](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html), see `OidcSiopVerifier` and `OidcSiopWallet`.

## Usage
The library is made up of three artifact which build on each other.
- In order to use `vck-openid` please call `Initializer.initOpenIdModule()` at the start of your project.
- In order to use `vck-rqes` please call `Initializer.initRqesModule()` at the start of your project. This initializer fully overrides `Initializer.initOpenIdModule()` which does not need to be called if `vck-rqes` is used.

## Limitations

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package at.asitplus.dif

import com.benasher44.uuid.uuid4
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* Data class for
* [DIF Presentation Exchange v2.1.1](https://identity.foundation/presentation-exchange/spec/v2.1.1/#term:presentation-definition)
*/
@Serializable
data class DifInputDescriptor(
@SerialName("id")
override val id: String,
@SerialName("group")
override val group: String? = null,
@SerialName("name")
override val name: String? = null,
@SerialName("purpose")
override val purpose: String? = null,
@SerialName("format")
override val format: FormatHolder? = null,
@SerialName("constraints")
override val constraints: Constraint? = null,
) : InputDescriptor {
constructor(name: String, constraints: Constraint? = null) : this(
id = uuid4().toString(),
name = name,
constraints = constraints,
)
}
Original file line number Diff line number Diff line change
@@ -1,65 +1,10 @@
@file:UseSerializers(InputDescriptorSerializer::class)

package at.asitplus.dif

import at.asitplus.dif.rqes.serializers.Base64URLTransactionDataSerializer
import at.asitplus.dif.rqes.collection_entries.TransactionData
import com.benasher44.uuid.uuid4
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers

@Serializable(with = InputDescriptorSerializer::class)
sealed interface InputDescriptor {
interface InputDescriptor {
val id: String
val group: String?
val name: String?
val purpose: String?
val format: FormatHolder?
val constraints: Constraint?
}

/**
* Data class for
* [DIF Presentation Exchange v2.1.1](https://identity.foundation/presentation-exchange/spec/v2.1.1/#term:presentation-definition)
*/
@Serializable
data class DifInputDescriptor(
@SerialName("id")
override val id: String,
@SerialName("group")
override val group: String? = null,
@SerialName("name")
override val name: String? = null,
@SerialName("purpose")
override val purpose: String? = null,
@SerialName("format")
override val format: FormatHolder? = null,
@SerialName("constraints")
override val constraints: Constraint? = null,
) : InputDescriptor {
constructor(name: String, constraints: Constraint? = null) : this(
id = uuid4().toString(),
name = name,
constraints = constraints,
)
}

@Serializable
data class QesInputDescriptor(
@SerialName("id")
override val id: String,
@SerialName("group")
override val group: String? = null,
@SerialName("name")
override val name: String? = null,
@SerialName("purpose")
override val purpose: String? = null,
@SerialName("format")
override val format: FormatHolder? = null,
@SerialName("constraints")
override val constraints: Constraint? = null,
@SerialName("transaction_data")
val transactionData: List<@Serializable(Base64URLTransactionDataSerializer::class) TransactionData>,
) : InputDescriptor

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package at.asitplus.dif

import kotlinx.serialization.json.Json

val jsonSerializer by lazy {
val ddcJsonSerializer by lazy {
Json {
prettyPrint = false
encodeDefaults = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ data class PresentationDefinition(
formats: FormatHolder
) : this(id = uuid4().toString(), inputDescriptors = inputDescriptors, formats = formats)

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

companion object {
fun deserialize(it: String) = kotlin.runCatching {
jsonSerializer.decodeFromString<PresentationDefinition>(it)
ddcJsonSerializer.decodeFromString<PresentationDefinition>(it)
}.wrap()
}
}
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion openid-data-classes/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ kotlin {
commonMain {
dependencies {
api(project(":dif-data-classes"))
implementation(project.napier())
implementation(ktor("http"))
implementation(napier())
api("at.asitplus.signum:indispensable:${VcLibVersions.signum}")
api("at.asitplus.signum:indispensable-cosef:${VcLibVersions.signum}")
api("at.asitplus.signum:indispensable-josef:${VcLibVersions.signum}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package at.asitplus.wallet.lib.oidc
package at.asitplus.openid


import at.asitplus.catching
import at.asitplus.dif.rqes.serializers.UrlSerializer
import at.asitplus.openid.AuthenticationRequestParameters
import at.asitplus.openid.JwsSignedSerializer
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString


@Serializable
sealed class AuthenticationRequestParametersFrom : RequestParametersFrom {

fun serialize(): String = jsonSerializer.encodeToString(this)
fun serialize(): String = odcJsonSerializer.encodeToString(this)

companion object {
fun deserialize(input: String) =
catching { jsonSerializer.decodeFromString<AuthenticationRequestParametersFrom>(input) }
catching { odcJsonSerializer.decodeFromString<AuthenticationRequestParametersFrom>(input) }
}

abstract override val parameters: AuthenticationRequestParameters
Expand Down
Loading

0 comments on commit de1588b

Please sign in to comment.