Skip to content

Commit f02bab6

Browse files
authored
Properly handle path-based claims. (#1026)
Other changes: - Use "JSON-Based" instead of "W3C VC" or "VC" since that's a lot more accurate and also in line with what OpenID Foundation standards are doing. This includes renaming a bunch of types, methods, params, and comments. - Also register for `TYPE_DIGITAL_CREDENTIAL` to make things work with X-device presentment in Chrome. - Add unit tests in `DigitalCredentialsPresentmentTest` for mDL and SD-JWT VC presentment using OpenID4VP draft 24. This is just the beginning, we'll add a lot more tests once we integrate the new DCQL library. Test: ./gradlew check && ./gradlew connectedCheck Test: New unit tests and all unit tests pass. Test: Manually tested with own and 3rd party verifiers. Signed-off-by: David Zeuthen <zeuthen@google.com>
1 parent dfb783d commit f02bab6

File tree

42 files changed

+801
-504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+801
-504
lines changed

multipaz-compose/src/commonMain/kotlin/org/multipaz/compose/claim/RenderClaimValue.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import androidx.compose.ui.unit.Dp
1313
import androidx.compose.ui.unit.dp
1414
import org.multipaz.claim.Claim
1515
import org.multipaz.claim.MdocClaim
16-
import org.multipaz.claim.VcClaim
16+
import org.multipaz.claim.JsonClaim
1717
import org.multipaz.documenttype.DocumentAttributeType
1818
import org.multipaz.util.fromBase64Url
1919
import kotlinx.datetime.TimeZone
@@ -45,7 +45,7 @@ fun RenderClaimValue(
4545
if (claim.attribute?.type == DocumentAttributeType.Picture) {
4646
val bytes = when (claim) {
4747
is MdocClaim -> claim.value.asBstr
48-
is VcClaim -> claim.value.jsonPrimitive.content.fromBase64Url()
48+
is JsonClaim -> claim.value.jsonPrimitive.content.fromBase64Url()
4949
}
5050
val img = decodeImage(bytes)
5151
Image(

multipaz-doctypes/src/commonMain/kotlin/org/multipaz/documenttype/knowntypes/EUCertificateOfResidence.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object EUCertificateOfResidence {
2424
fun getDocumentType(): DocumentType {
2525
return DocumentType.Builder("EU Certificate of Residency")
2626
.addMdocDocumentType(DOCTYPE)
27-
.addVcDocumentType(vct = VCT, keyBound = true)
27+
.addJsonDocumentType(type = VCT, keyBound = true)
2828
.addAttribute(
2929
DocumentAttributeType.String,
3030
"family_name",
@@ -268,7 +268,7 @@ object EUCertificateOfResidence {
268268
"age_over_18" to false,
269269
)
270270
),
271-
vcClaims = listOf("age_over_18")
271+
jsonClaims = listOf("age_over_18")
272272
)
273273
.addSampleRequest(
274274
id = "mandatory",
@@ -285,7 +285,7 @@ object EUCertificateOfResidence {
285285
"issuing_country" to false
286286
)
287287
),
288-
vcClaims = listOf(
288+
jsonClaims = listOf(
289289
"family_name",
290290
"given_name",
291291
"birth_date",
@@ -302,7 +302,7 @@ object EUCertificateOfResidence {
302302
mdocDataElements = mapOf(
303303
NAMESPACE to mapOf()
304304
),
305-
vcClaims = listOf()
305+
jsonClaims = listOf()
306306
)
307307
.build()
308308
}

multipaz-doctypes/src/commonMain/kotlin/org/multipaz/documenttype/knowntypes/EUPersonalID.kt

Lines changed: 60 additions & 68 deletions
Large diffs are not rendered by default.

multipaz-doctypes/src/commonMain/kotlin/org/multipaz/documenttype/knowntypes/GermanPersonalID.kt

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
package org.multipaz.documenttype.knowntypes
22

3-
import org.multipaz.cbor.CborArray
4-
import org.multipaz.cbor.toDataItem
5-
import org.multipaz.cbor.toDataItemFullDate
63
import org.multipaz.documenttype.DocumentAttributeType
74
import org.multipaz.documenttype.DocumentType
85
import org.multipaz.documenttype.Icon
9-
import kotlinx.datetime.LocalDate
106
import kotlinx.serialization.json.JsonPrimitive
117
import kotlinx.serialization.json.buildJsonArray
12-
import kotlinx.serialization.json.buildJsonObject
138

149
/**
1510
* Object containing the metadata of the German ID Document Type.
@@ -26,64 +21,64 @@ object GermanPersonalID {
2621
*/
2722
fun getDocumentType(): DocumentType {
2823
return DocumentType.Builder("German Personal ID")
29-
.addVcDocumentType(vct = EUPID_VCT, keyBound = true)
30-
.addVcAttribute(
24+
.addJsonDocumentType(type = EUPID_VCT, keyBound = true)
25+
.addJsonAttribute(
3126
DocumentAttributeType.String,
3227
"family_name",
3328
"Family Name",
3429
"Current last name(s), surname(s), or primary identifier of the PID holder",
3530
Icon.PERSON,
3631
JsonPrimitive(SampleData.FAMILY_NAME)
3732
)
38-
.addVcAttribute(
33+
.addJsonAttribute(
3934
DocumentAttributeType.String,
4035
"given_name",
4136
"Given Names",
4237
"Current first name(s), other name(s), or secondary identifier of the PID holder",
4338
Icon.PERSON,
4439
JsonPrimitive(SampleData.GIVEN_NAME)
4540
)
46-
.addVcAttribute(
41+
.addJsonAttribute(
4742
DocumentAttributeType.Date,
4843
"birthdate",
4944
"Date of Birth",
5045
"Day, month, and year on which the PID holder was born. If unknown, approximate date of birth.",
5146
Icon.TODAY,
5247
JsonPrimitive(SampleData.BIRTH_DATE)
5348
)
54-
.addVcAttribute(
49+
.addJsonAttribute(
5550
DocumentAttributeType.Number,
5651
"age_in_years",
5752
"Age in Years",
5853
"The age of the PID holder in years",
5954
Icon.TODAY,
6055
JsonPrimitive(SampleData.AGE_IN_YEARS)
6156
)
62-
.addVcAttribute(
57+
.addJsonAttribute(
6358
DocumentAttributeType.Number,
6459
"age_birth_year",
6560
"Year of Birth",
6661
"The year when the PID holder was born",
6762
Icon.TODAY,
6863
JsonPrimitive(SampleData.AGE_BIRTH_YEAR)
6964
)
70-
.addVcAttribute(
65+
.addJsonAttribute(
7166
DocumentAttributeType.Boolean,
7267
"12",
7368
"Older Than 12",
7469
"Age over 12?",
7570
Icon.TODAY,
7671
JsonPrimitive(SampleData.AGE_OVER)
7772
)
78-
.addVcAttribute(
73+
.addJsonAttribute(
7974
DocumentAttributeType.Boolean,
8075
"14",
8176
"Older Than 14",
8277
"Age over 14?",
8378
Icon.TODAY,
8479
JsonPrimitive(SampleData.AGE_OVER)
8580
)
86-
.addVcAttribute(
81+
.addJsonAttribute(
8782
DocumentAttributeType.Boolean,
8883
"16",
8984
"Older Than 16",
@@ -92,111 +87,111 @@ object GermanPersonalID {
9287
JsonPrimitive(SampleData.AGE_OVER_16)
9388
)
9489
// TODO: nest in age_equal_or_over object
95-
.addVcAttribute(
90+
.addJsonAttribute(
9691
DocumentAttributeType.Boolean,
9792
"18",
9893
"Older Than 18",
9994
"Age over 18?",
10095
Icon.TODAY,
10196
JsonPrimitive(SampleData.AGE_OVER_18)
10297
)
103-
.addVcAttribute(
98+
.addJsonAttribute(
10499
DocumentAttributeType.Boolean,
105100
"21",
106101
"Older Than 21",
107102
"Age over 21?",
108103
Icon.TODAY,
109104
JsonPrimitive(SampleData.AGE_OVER_21)
110105
)
111-
.addVcAttribute(
106+
.addJsonAttribute(
112107
DocumentAttributeType.Boolean,
113108
"65",
114109
"Older Than 65",
115110
"Age over 65?",
116111
Icon.TODAY,
117112
JsonPrimitive(SampleData.AGE_OVER_65)
118113
)
119-
.addVcAttribute(
114+
.addJsonAttribute(
120115
DocumentAttributeType.String,
121116
"birth_family_name",
122117
"Family Name at Birth",
123118
"Last name(s), surname(s), or primary identifier of the PID holder at birth",
124119
Icon.PERSON,
125120
JsonPrimitive(SampleData.FAMILY_NAME_BIRTH)
126121
)
127-
.addVcAttribute(
122+
.addJsonAttribute(
128123
DocumentAttributeType.String,
129124
"birth_place",
130125
"Place of Birth",
131126
"Country and municipality or state/province where the PID holder was born",
132127
Icon.PLACE,
133128
JsonPrimitive(SampleData.BIRTH_PLACE)
134129
)
135-
.addVcAttribute(
130+
.addJsonAttribute(
136131
DocumentAttributeType.StringOptions(Options.COUNTRY_ISO_3166_1_ALPHA_2),
137132
"birth_country",
138133
"Country of Birth",
139134
"The country where the PID User was born, as an Alpha-2 country code as specified in ISO 3166-1",
140135
Icon.PLACE,
141136
JsonPrimitive(SampleData.BIRTH_COUNTRY)
142137
)
143-
.addVcAttribute(
138+
.addJsonAttribute(
144139
DocumentAttributeType.String,
145140
"birth_state",
146141
"State of Birth",
147142
"The state, province, district, or local area where the PID User was born",
148143
Icon.PLACE,
149144
JsonPrimitive(SampleData.BIRTH_STATE)
150145
)
151-
.addVcAttribute(
146+
.addJsonAttribute(
152147
DocumentAttributeType.String,
153148
"birth_city",
154149
"City of Birth",
155150
"The municipality, city, town, or village where the PID User was born",
156151
Icon.PLACE,
157152
JsonPrimitive(SampleData.BIRTH_CITY)
158153
)
159-
.addVcAttribute(
154+
.addJsonAttribute(
160155
DocumentAttributeType.String,
161156
"street_address",
162157
"Resident Address",
163158
"The full address of the place where the PID holder currently resides and/or may be contacted (street/house number, municipality etc.)",
164159
Icon.PLACE,
165160
JsonPrimitive(SampleData.RESIDENT_ADDRESS)
166161
)
167-
.addVcAttribute(
162+
.addJsonAttribute(
168163
DocumentAttributeType.String,
169164
"locality",
170165
"Resident City",
171166
"The city where the PID holder currently resides",
172167
Icon.PLACE,
173168
JsonPrimitive(SampleData.RESIDENT_CITY)
174169
)
175-
.addVcAttribute(
170+
.addJsonAttribute(
176171
DocumentAttributeType.StringOptions(Options.COUNTRY_ISO_3166_1_ALPHA_2),
177172
"country",
178173
"Resident Country",
179174
"The country where the PID User currently resides, as an Alpha-2 country code as specified in ISO 3166-1",
180175
Icon.PLACE,
181176
JsonPrimitive(SampleData.RESIDENT_COUNTRY)
182177
)
183-
.addVcAttribute(
178+
.addJsonAttribute(
184179
DocumentAttributeType.String,
185180
"postal_code",
186181
"Resident Postal Code",
187182
"The postal code of the place where the PID holder currently resides",
188183
Icon.PLACE,
189184
JsonPrimitive(SampleData.RESIDENT_POSTAL_CODE)
190185
)
191-
.addVcAttribute(
186+
.addJsonAttribute(
192187
DocumentAttributeType.IntegerOptions(Options.SEX_ISO_IEC_5218),
193188
"gender",
194189
"Gender",
195190
"PID holder’s gender",
196191
Icon.EMERGENCY,
197192
JsonPrimitive(SampleData.SEX_ISO218)
198193
)
199-
.addVcAttribute(
194+
.addJsonAttribute(
200195
DocumentAttributeType.ComplexType,
201196
"nationalities",
202197
"Nationality",
@@ -206,23 +201,23 @@ object GermanPersonalID {
206201
add(JsonPrimitive(SampleData.NATIONALITY))
207202
}
208203
)
209-
.addVcAttribute(
204+
.addJsonAttribute(
210205
DocumentAttributeType.Date,
211206
"issuance_date",
212207
"Date of Issue",
213208
"Date (and possibly time) when the PID was issued.",
214209
Icon.DATE_RANGE,
215210
JsonPrimitive(SampleData.ISSUE_DATE)
216211
)
217-
.addVcAttribute(
212+
.addJsonAttribute(
218213
DocumentAttributeType.Date,
219214
"expiry_date",
220215
"Date of Expiry",
221216
"Date (and possibly time) when the PID will expire.",
222217
Icon.CALENDAR_CLOCK,
223218
JsonPrimitive(SampleData.EXPIRY_DATE)
224219
)
225-
.addVcAttribute(
220+
.addJsonAttribute(
226221
DocumentAttributeType.String,
227222
"issuing_authority",
228223
"Issuing Authority",
@@ -232,23 +227,23 @@ object GermanPersonalID {
232227
Icon.ACCOUNT_BALANCE,
233228
JsonPrimitive(SampleData.ISSUING_AUTHORITY_EU_PID)
234229
)
235-
.addVcAttribute(
230+
.addJsonAttribute(
236231
DocumentAttributeType.String,
237232
"document_number",
238233
"Document Number",
239234
"A number for the PID, assigned by the PID Provider.",
240235
Icon.NUMBERS,
241236
JsonPrimitive(SampleData.DOCUMENT_NUMBER)
242237
)
243-
.addVcAttribute(
238+
.addJsonAttribute(
244239
DocumentAttributeType.String,
245240
"administrative_number",
246241
"Administrative Number",
247242
"A number assigned by the PID Provider for audit control or other purposes.",
248243
Icon.NUMBERS,
249244
JsonPrimitive(SampleData.ADMINISTRATIVE_NUMBER)
250245
)
251-
.addVcAttribute(
246+
.addJsonAttribute(
252247
DocumentAttributeType.String,
253248
"issuing_jurisdiction",
254249
"Issuing Jurisdiction",
@@ -258,7 +253,7 @@ object GermanPersonalID {
258253
Icon.ACCOUNT_BALANCE,
259254
JsonPrimitive(SampleData.ISSUING_JURISDICTION)
260255
)
261-
.addVcAttribute(
256+
.addJsonAttribute(
262257
DocumentAttributeType.StringOptions(Options.COUNTRY_ISO_3166_1_ALPHA_2),
263258
"issuing_country",
264259
"Issuing Country",
@@ -270,12 +265,12 @@ object GermanPersonalID {
270265
.addSampleRequest(
271266
id = "age_over_18",
272267
displayName = "Age Over 18",
273-
vcClaims = listOf("18")
268+
jsonClaims = listOf("18")
274269
)
275270
.addSampleRequest(
276271
id = "mandatory",
277272
displayName = "Mandatory Data Elements",
278-
vcClaims = listOf(
273+
jsonClaims = listOf(
279274
"family_name",
280275
"given_name",
281276
"birthdate",
@@ -289,7 +284,7 @@ object GermanPersonalID {
289284
.addSampleRequest(
290285
id = "full",
291286
displayName = "All Data Elements",
292-
vcClaims = listOf()
287+
jsonClaims = listOf()
293288
)
294289
.build()
295290
}

0 commit comments

Comments
 (0)