Skip to content

Commit 0a02df2

Browse files
committed
Did 3 things:
1. Fixed #1 2. Updated dependencies 3. Dynamically generate protocol identifier in the Digital Credentails response
1 parent 610db54 commit 0a02df2

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

app/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ dependencies {
4848
implementation(libs.ktor.serialization.kotlinx.json)
4949
implementation(libs.androidx.lifecycle.viewmodel.compose)
5050
implementation(libs.androidx.registry.digitalcredentials.mdoc)
51-
implementation(libs.androidx.registry.digitalcredentials.preview)
5251
implementation(libs.androidx.registry.provider)
5352
implementation(libs.androidx.credentials)
5453
implementation(libs.play.services.identity.credentials)

app/src/main/java/com/credman/cmwallet/getcred/GetCredentialActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fun createOpenID4VPResponse(
6969
sdJwtVc.present(
7070
claims,
7171
nonce = openId4VPRequest.nonce,
72-
clientId = openId4VPRequest.clientId
72+
aud = openId4VPRequest.getSdJwtKbAud(origin)
7373
)
7474
)
7575
}
@@ -129,7 +129,7 @@ fun createOpenID4VPResponse(
129129
authenticationTitle = authenticationTitle,
130130
authenticationSubtitle = authenticationSubtitle,
131131
responseJsonModern = JSONObject().apply {
132-
put("protocol", "openid4vp")
132+
put("protocol", openId4VPRequest.protocolIdentifier)
133133
put("data", JSONObject(response))
134134
}.toString()
135135
)

app/src/main/java/com/credman/cmwallet/openid4vp/OpenId4VP.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class OpenId4VP(
2323
val protocolIdentifier: String = "openid4vp",
2424
) {
2525

26+
fun getSdJwtKbAud(origin: String) = when (protocolIdentifier) {
27+
in IDENTIFIERS_1_0 -> "origin:$origin"
28+
IDENTIFIER_DRAFT_24 -> clientId
29+
else -> throw UnsupportedOperationException("Unsupported protocol idenfitier $protocolIdentifier")
30+
}
31+
2632
val nonce: String
2733

2834
val dcqlQuery: JSONObject

app/src/main/java/com/credman/cmwallet/sdjwt/SdJwt.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class SdJwt(
4040
fun present(
4141
claimSets: JSONArray?, // If null, match all
4242
nonce: String,
43-
clientId: String
43+
aud: String,
4444
): String {
4545
val sdJwtComponents = mutableListOf(issuerJwt)
4646
if (claimSets == null) {
@@ -90,7 +90,7 @@ class SdJwt(
9090
}
9191
val kbPayload = buildJsonObject {
9292
put("iat", Instant.now().epochSecond)
93-
put("aud", clientId)
93+
put("aud", aud)
9494
put("nonce", nonce)
9595
put("sd_hash", digest)
9696
}

gradle/libs.versions.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref =
2222
androidx-credentials = { module = "androidx.credentials:credentials" }
2323
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose" }
2424
androidx-registry-digitalcredentials-mdoc = { module = "androidx.credentials.registry:registry-digitalcredentials-mdoc", version.ref = "registryDigitalcredentialsMdoc" }
25-
androidx-registry-digitalcredentials-preview = { module = "androidx.credentials.registry:registry-digitalcredentials-preview", version.ref = "registryDigitalcredentialsMdoc" }
2625
androidx-registry-provider = { module = "androidx.credentials.registry:registry-provider", version.ref = "registryDigitalcredentialsMdoc" }
2726
androidx-registry-provider-play-services = { module = "androidx.credentials.registry:registry-provider-play-services", version.ref = "registryDigitalcredentialsMdoc" }
2827
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "roomRuntime" }

0 commit comments

Comments
 (0)