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y2VjNTQiLCJhZGRyZXNzIix7InN0cmVldF9hZGRyZXNzIjoiMTIzIE1haW4gU3QiLCJsb2NhbGl0eSI6IkFueXRvd24iLCJyZWdpb24iOiJBbnlzdGF0ZSIsImNvdW50cnkiOiJVUyJ9XQ~WyIwNzBlZjYyNy05NTAyLTRkMTYtYTNjYi1lNTAwZTViOTk0YWIiLCJiaXJ0aGRhdGUiLCIxOTQwLTAxLTAxIl0~' ,
93
+ } ;
94
+
85
95
// This is the expected output SD-JWT based on the presentation definition defined below
86
96
const decodedSdJwtVcWithDisclosuresRemoved = {
87
97
// 3 disclosures not included
@@ -159,6 +169,96 @@ function getPresentationDefinitionV2(): PresentationDefinitionV2 {
159
169
} ;
160
170
}
161
171
172
+ function getPresentationDefinitionV2_with_enum ( ) : PresentationDefinitionV2 {
173
+ return {
174
+ id : '32f54163-7166-48f1-93d8-ff217bdb0653' ,
175
+ name : 'Conference Entry Requirements' ,
176
+ purpose : 'We can only allow people associated with Washington State business representatives into conference areas' ,
177
+ format : {
178
+ 'vc+sd-jwt' : { } ,
179
+ } ,
180
+ input_descriptors : [
181
+ {
182
+ id : 'wa_driver_license' ,
183
+ name : 'Washington State Business License' ,
184
+ purpose : 'We can only allow licensed Washington State business representatives into the WA Business Conference' ,
185
+ constraints : {
186
+ limit_disclosure : 'required' ,
187
+ fields : [
188
+ {
189
+ path : [ '$.vct' ] ,
190
+ filter : {
191
+ type : 'string' ,
192
+ enum : [ 'https://example.bmi.bund.de/credential/pid/1.0' , 'urn:eu.europa.ec.eudi:pid:1' ] ,
193
+ } ,
194
+ } ,
195
+ ] ,
196
+ } ,
197
+ } ,
198
+ ] ,
199
+ } ;
200
+ }
201
+
202
+ function getPresentationDefinitionV2_const_new_pid ( ) : PresentationDefinitionV2 {
203
+ return {
204
+ id : '32f54163-7166-48f1-93d8-ff217bdb0653' ,
205
+ name : 'Conference Entry Requirements' ,
206
+ purpose : 'We can only allow people associated with Washington State business representatives into conference areas' ,
207
+ format : {
208
+ 'vc+sd-jwt' : { } ,
209
+ } ,
210
+ input_descriptors : [
211
+ {
212
+ id : 'wa_driver_license' ,
213
+ name : 'Washington State Business License' ,
214
+ purpose : 'We can only allow licensed Washington State business representatives into the WA Business Conference' ,
215
+ constraints : {
216
+ limit_disclosure : 'required' ,
217
+ fields : [
218
+ {
219
+ path : [ '$.vct' ] ,
220
+ filter : {
221
+ type : 'string' ,
222
+ const : 'https://example.bmi.bund.de/credential/pid/1.0' ,
223
+ } ,
224
+ } ,
225
+ ] ,
226
+ } ,
227
+ } ,
228
+ ] ,
229
+ } ;
230
+ }
231
+
232
+ function getPresentationDefinitionV2_const_old_pid ( ) : PresentationDefinitionV2 {
233
+ return {
234
+ id : '32f54163-7166-48f1-93d8-ff217bdb0653' ,
235
+ name : 'Conference Entry Requirements' ,
236
+ purpose : 'We can only allow people associated with Washington State business representatives into conference areas' ,
237
+ format : {
238
+ 'vc+sd-jwt' : { } ,
239
+ } ,
240
+ input_descriptors : [
241
+ {
242
+ id : 'wa_driver_license' ,
243
+ name : 'Washington State Business License' ,
244
+ purpose : 'We can only allow licensed Washington State business representatives into the WA Business Conference' ,
245
+ constraints : {
246
+ limit_disclosure : 'required' ,
247
+ fields : [
248
+ {
249
+ path : [ '$.vct' ] ,
250
+ filter : {
251
+ type : 'string' ,
252
+ const : 'urn:eu.europa.ec.eudi:pid:1' ,
253
+ } ,
254
+ } ,
255
+ ] ,
256
+ } ,
257
+ } ,
258
+ ] ,
259
+ } ;
260
+ }
261
+
162
262
// TODO:
163
263
// - evaluateSubmission / submissionFrom
164
264
// - correctly set up KB-JWT payload and sign this in the presentation callback
@@ -309,4 +409,64 @@ describe('evaluate', () => {
309
409
value : presentationResult . presentationSubmission ,
310
410
} ) ;
311
411
} ) ;
412
+
413
+ it ( 'selectFrom with vc+sd-jwt format compact - enum new PID format' , async ( ) => {
414
+ const result = pex . selectFrom ( getPresentationDefinitionV2_with_enum ( ) , [ decodedSdJwtVcNewPid . compactSdJwtVc ] ) ;
415
+ expect ( result . errors ?. length ) . toEqual ( 0 ) ;
416
+ expect ( result . matches ) . toEqual ( [
417
+ {
418
+ name : 'Washington State Business License' ,
419
+ rule : 'all' ,
420
+ vc_path : [ '$.verifiableCredential[0]' ] ,
421
+ type : SubmissionRequirementMatchType . InputDescriptor ,
422
+ id : 'wa_driver_license' ,
423
+ } ,
424
+ ] ) ;
425
+ expect ( result . areRequiredCredentialsPresent ) . toBe ( 'info' ) ;
426
+ } ) ;
427
+
428
+ it ( 'selectFrom with vc+sd-jwt format compact - enum old PID format' , async ( ) => {
429
+ const result = pex . selectFrom ( getPresentationDefinitionV2_with_enum ( ) , [ decodedSdJwtVcOldPid . compactSdJwtVc ] ) ;
430
+ expect ( result . errors ?. length ) . toEqual ( 0 ) ;
431
+ expect ( result . matches ) . toEqual ( [
432
+ {
433
+ name : 'Washington State Business License' ,
434
+ rule : 'all' ,
435
+ vc_path : [ '$.verifiableCredential[0]' ] ,
436
+ type : SubmissionRequirementMatchType . InputDescriptor ,
437
+ id : 'wa_driver_license' ,
438
+ } ,
439
+ ] ) ;
440
+ expect ( result . areRequiredCredentialsPresent ) . toBe ( 'info' ) ;
441
+ } ) ;
442
+
443
+ it ( 'selectFrom with vc+sd-jwt format compact - const new PID format' , async ( ) => {
444
+ const result = pex . selectFrom ( getPresentationDefinitionV2_const_new_pid ( ) , [ decodedSdJwtVcNewPid . compactSdJwtVc ] ) ;
445
+ expect ( result . errors ?. length ) . toEqual ( 0 ) ;
446
+ expect ( result . matches ) . toEqual ( [
447
+ {
448
+ name : 'Washington State Business License' ,
449
+ rule : 'all' ,
450
+ vc_path : [ '$.verifiableCredential[0]' ] ,
451
+ type : SubmissionRequirementMatchType . InputDescriptor ,
452
+ id : 'wa_driver_license' ,
453
+ } ,
454
+ ] ) ;
455
+ expect ( result . areRequiredCredentialsPresent ) . toBe ( 'info' ) ;
456
+ } ) ;
457
+
458
+ it ( 'selectFrom with vc+sd-jwt format compact - const old PID format' , async ( ) => {
459
+ const result = pex . selectFrom ( getPresentationDefinitionV2_const_old_pid ( ) , [ decodedSdJwtVcOldPid . compactSdJwtVc ] ) ;
460
+ expect ( result . errors ?. length ) . toEqual ( 0 ) ;
461
+ expect ( result . matches ) . toEqual ( [
462
+ {
463
+ name : 'Washington State Business License' ,
464
+ rule : 'all' ,
465
+ vc_path : [ '$.verifiableCredential[0]' ] ,
466
+ type : SubmissionRequirementMatchType . InputDescriptor ,
467
+ id : 'wa_driver_license' ,
468
+ } ,
469
+ ] ) ;
470
+ expect ( result . areRequiredCredentialsPresent ) . toBe ( 'info' ) ;
471
+ } ) ;
312
472
} ) ;
0 commit comments