-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
1085 lines (964 loc) · 34.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Verifiable Presentation Request v2024</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
<!--
=== NOTA BENE ===
For the three scripts below, if your spec resides on dev.w3 you can check them
out in the same tree and use relative links so that they'll work offline,
-->
<script src='https://www.w3.org/Tools/respec/respec-w3c' class='remove'></script>
<script src="./common.js" class="remove"></script>
<script type="text/javascript" class="remove">
var respecConfig = {
// specification status (e.g., WD, LCWD, NOTE, etc.). If in doubt use ED.
specStatus: "CG-DRAFT",
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "vp-request-spec",
// subtitle for the spec
subtitle: "A data model for requesting presenations of verifiable credentials",
// if you wish the publication date to be other than today, set this
//publishDate: "",
//crEnd: "",
//prEnd: "",
//implementationReportURI: "",
// if there is a previously published draft, uncomment this and set its YYYY-MM-DD date
// and its maturity status
// previousPublishDate: "1977-03-15",
// previousMaturity: "WD",
// extend the bibliography entries
doJsonLd: true,
github: "https://github.com/w3c-ccg/vp-request-spec/",
includePermalinks: false,
// if there a publicly available Editor's Draft, this is the link
edDraftURI: "https://w3c-ccg.github.io/vp-request-spec/",
// if this is a LCWD, uncomment and set the end of its review period
// lcEnd: "2009-08-05",
// editors, add as many as you like
// only "name" is required
editors: [
{ name: "Dave Longley", url: "https://github.com/dlongley",
company: "Digital Bazaar", companyURL: "https://digitalbazaar.com/"},
{ name: "Mike Varley",
company: "Secure Key", companyURL: "https://securekey.com/"},
{ name: "Dmitri Zagidulin", url: "https://www.linkedin.com/in/dzagidulin/",
company: "Digital Bazaar", companyURL: "https://digitalbazaar.com/"}
],
// authors, add as many as you like.
// This is optional, uncomment if you have authors as well as editors.
// only "name" is required. Same format as editors.
authors: [
// { name: "Dave Longley", url: "https://digitalbazaar.com/",
// company: "Digital Bazaar", companyURL: "https://digitalbazaar.com/"},
// { name: "Manu Sporny", url: "https://digitalbazaar.com/",
// company: "Digital Bazaar", companyURL: "https://digitalbazaar.com/" }
],
// name of the WG
wg: "W3C Credentials Community Group",
group: "credentials",
// URI of the public WG page
wgURI: "https://w3c-ccg.github.io/",
// name (with the @w3c.org) of the public mailing to which comments are due
wgPublicList: "public-credentials",
lint: {"no-unused-dfns": false},
postProcess: [restrictRefs],
xref: ["INFRA", "MIMESNIFF", "VC-DATA-MODEL-2.0"],
otherLinks: [{
key: "Related Specifications",
data: [{
value: "The Verifiable Credentials Data Model v2.0",
href: "https://www.w3.org/TR/VC-DATA-MODEL-2.0/"
}, {
value: "The Edwards Digital Signature Algorithm Cryptosuites v1.0",
href: "https://www.w3.org/TR/vc-di-eddsa/"
}, {
value: "The Elliptic Curve Digital Signature Algorithm Cryptosuites v1.0",
href: "https://www.w3.org/TR/vc-di-ecdsa/"
}, {
value: "The BBS Digital Signature Algorithm Cryptosuites v1.0",
href: "https://www.w3.org/TR/vc-di-bbs/"
}]
}],
// URI of the patent status for this WG, for Rec-track documents
// !!!! IMPORTANT !!!!
// This is important for Rec-track documents, do not copy a patent URI from a random
// document unless you know what you're doing. If in doubt ask your friendly neighborhood
// Team Contact.
wgPatentURI: "https://www.w3.org/2004/01/pp-impl/98922/status",
maxTocLevel: 2,
inlineCSS: true
};
</script>
<style>
code {
color: rgb(199, 73, 0);
font-weight: bold;
}
pre {
overflow-x: auto;
white-space: pre-wrap;
}
pre .highlight {
font-weight: bold;
color: Green;
}
pre .subject {
font-weight: bold;
color: RoyalBlue;
}
pre .property {
font-weight: bold;
color: DarkGoldenrod;
}
pre .comment {
font-weight: bold;
color: SteelBlue;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
ol.algorithm { counter-reset:numsection; list-style-type: none; }
ol.algorithm li { margin: 0.5em 0; }
ol.algorithm li:before { font-weight: bold; counter-increment: numsection; content: counters(numsection, ".") ") "; }
table.simple {
border-collapse: collapse;
margin: 25px 0;
min-width: 400px;
border: 1px solid #dddddd;
}
table.simple thead tr {
background-color: #005a9c;
color: #ffffff;
text-align: left;
}
table.simple th,
table.simple td {
padding: 12px 15px;
vertical-align: top;
text-align: left;
}
table.simple tbody tr {
border-bottom: 1px solid #dddddd;
}
table.simple tbody tr:nth-of-type(even) {
background-color: #00000008;
}
table.simple tbody tr:last-of-type {
border-bottom: 2px solid #005a9c;
}
</style>
</head>
<body>
<section id='abstract'>
<p>
This specification describes a declarative JSON-based query language used by
applications to perform requests from wallets and agents. The results of the
requests are always wrapped in a Verifiable Presentation.
</p>
</section>
<section id='sotd'>
<p>
This draft highlights some of the pending issues that are still to be discussed
in the community group. No decision has been taken on the outcome of these
issues including whether they are valid. Pull requests with proposed
specification text for outstanding issues are strongly encouraged.
</p>
</section>
<section class="informative">
<h2>Introduction</h2>
<p>
When working with Verifiable Credentials, Decentralized Identifier (DID) based
Authentication, and Authorization Capabilities, a client application often needs
to request credential-related objects from a wallet or agent. This document
presents a specification that describes the format of those requests.
</p>
<p>
Note: This specification is unstable at present, and only reflects an effort to
get initial interop working, for incubation and implementation experience.
Additionally, the intention is to align this spec and the query format to
fit into/work with other protocols/messaging formats such as DIDComm.
</p>
<section class="informative">
<h2>Overview</h2>
<p>
To make a request for one or more objects wrapped in a Verifiable Presentation,
a client constructs a JSON request describing one or more queries that
it wishes to perform from the receiver.
</p>
<pre class="example nohighlight" title="A sample query">
{
query: [{
type: 'APopularQueryType',
// query details ...
}, {
type: 'AnotherQueryType',
// query details ...
}],
// Challenge that will be digitally signed in the authentication proof
// that will be attached to the VerifiablePresentation response
challenge, // Required
recipients: [
// an optional key agreement key for encrypting the response if
// this is supported
],
interact: {
// an optional set of mechanisms that can be used to respond to the query
"service": [{
// a service that can be used to respond to the query where the service
// might be an HTTP endpoint, bluetooth location, or P2P protocol
}]
}
}
</pre>
</section>
<section id="conformance">
</section>
<section>
<h2>Terminology</h2>
<p>
This specification relies on terminology defined in [[[VC-DATA-MODEL-2.0]]].
This section defines additional terms used in this specification. A link to
these terms is included whenever they appear in this specification.
</p>
<dl class="termlist definitions" data-sort="ascending">
<dt><dfn class="export">presentation request</dfn></dt>
<dd>
A request made by a [=verifier=] for a [=presentation=] by the [=holder=].
</dd>
</section>
</section>
<section class="normative">
<h2>Query and Response Types</h2>
<p>
The <dfn>query type</dfn> serves as the main extension point mechanism for
requests for data in the presentation. While this document defines several
common query types, all query objects are of the following form:
</p>
<dl>
<dt>query</dt>
<dd>
A REQUIRED property that specifies the information requested by the
[=verifier=]. The value MUST be one or more [=maps=] where each [=map=] MUST
define a `type` property with an associated [=string=] value.
</dd>
<dt><dfn class="export">challenge</dfn></dt>
<dd>
An OPTIONAL, unique [=string=] that is provided by a [=verifier=] to a
[=holder=] during a specific [=presentation request=]. The [=holder=] includes
the data in a [=verifiable presentation=] to the [=verifier=] to protect against
<a data-cite="?VC-DATA-MODEL-2.0#replay-attack">replay attacks</a>.
</dd>
<dt><dfn class="export">domain</dfn></dt>
<dd>
An OPTIONAL [=string=] that is provided by a [=verifier=] to a [=holder=] during
a [=presentation request=]. The [=holder=] checks to ensure that the data is
associated with the domain, such as a website domain, that they are interacting
with, and if it is, includes the data in a [=verifiable presentation=]. A domain
is used to ensure that the [=holder=] limits their [=verifiable presentation=]
to a specific [=verifier=] in order to protect against
<a data-cite="?VC-DATA-MODEL-2.0#replay-attack">replay attacks</a>.
</dd>
</dl>
<section>
<h3>Query By Example</h3>
<p>
The "query by example" credential query format is designed to enable developers
to easily request the [=claims=] that they need to perform a particular business
process from one or more [=verifiable credentials=]. The query can also
specify other information, such as one or more [=issuers=] that are trusted by
the [=verifier=].
</p>
<pre class="example nohighlight" title="A Query By Example query">
{
"query": [
{
"type": "QueryByExample",
"credentialQuery": [
{
// One or more example query entries
"required": false, // (Optional) Defaults to 'true' if omitted
// (Optional) Reason for requesting this credential that
// may be shown to a user by their wallet software
"reason": "We need you to prove your eligibility to work.",
"example": {
"@context": ["https://www.w3.org/2018/credentials/v1", "https://w3id.org/citizenship/v1"],
"type": "PermanentResidentCard",
// (Optional) You can request a specific subject id
"credentialSubject": {
"id": "...",
"name": "..."
},
// (Optional) Specify only credentials of a particular schema
"credentialSchema": {
"id": "urn:foo:1234",
"type": "SomeType"
}
},
// (Optional) Specify credentials from a particular issuer only
"trustedIssuer": [
{
"required": true,
"issuer": "urn:some:required:issuer"
}
]
}
]
},
{
// Another example query
"type": "AnotherQueryType"
// ...
}
],
"challenge": "3182bdea-63d9-11ea-b6de-3b7c1404d57f",
// the domain that will be digitally signed in the authentication
// proof that will be attached to the VerifiablePresentation
// response, identifying the recipient
"domain": "jobs.example.com"
}
</pre>
</section>
<section>
<h3>DID Authentication</h3>
<p>
This section defines how a <a>verifier</a> can request that a
<a>holder</a> perform Decentralized Identifier-based Authentication
[[?DID-CORE]]. In its simplest form, the authentication protocol is comprised
of a challenge by the <a>verifier</a> and a response by a <a>holder</a>:
</p>
<pre class="example" title="A DID Authentication request">
{
"query": [{
"type": "DIDAuthentication",
"acceptedMethods": [{"method": "example"}]
}],
"challenge": "99612b24-63d9-11ea-b99f-4f66f3e4f81a",
"domain": "example.com"
}
</pre>
<p>
The DID Authentication request above specifies that the <a>verifier</a> would
like the <a>holder</a> to demonstrate control over a DID by generating a
digital signature over the provided challenge. The <a>holder</a> might respond
by providing the following response:
</p>
<pre class="example" title="A DID Authentication response">
{
"@context": ["https://www.w3.org/ns/credentials/v2"],
"type": "VerifiablePresentation",
"holder": "did:example:12345",
"proof": {
"type": "DataIntegrityProof",
"cryptosuite": "eddsa-rdfc-2022",
"verificationMethod": "did:example:12345#key-1",
"challenge": "99612b24-63d9-11ea-b99f-4f66f3e4f81a",
"domain": "example.com",
"created": "2024-02-25T14:58:42Z",
"proofPurpose": "authentication",
"proofValue": "z3FXQjecWufY46...UAUL5n2Brbx"
}
}
</pre>
<p class="issue">
The DID Authentication examples shown in this document use a new proof type
called `DataIntegrityProof` which is currently under development in the
<a href="https://www.w3.org/2017/vc/WG/">W3C Verifiable Credentials Working
Group</a>.
</p>
<section>
<h3>The DID Authentication Query Format</h3>
<p>
The DID Authentication query format enables a <a>verifier</a> to request that
a <a>holder</a> authenticate in specific ways. A DID Authentication query MUST
be of the following form:
</p>
<table class="simple">
<tr>
<th>Property</th>
<th>Description</th>
</tr>
<tr>
<td>type</td>
<td>
a REQUIRED string value that MUST be set to <code>DIDAuthentication</code>.
</td>
</tr>
<tr>
<td>acceptedMethods</td>
<td>
An optional array of objects that expresses the <a>verifier</a> would accept
any DID Method listed. Each object in the array MUST contain a property called
`method` with a value that is a DID Method name, and MAY contain other
properties that are specific to the DID Method. Valid example values
include: <code>[{"method": "key"}]</code> and
<code>[{"method": "key"}, {"method": "web"}]</code>.
</td>
</tr>
<tr>
<td>acceptedCryptosuites</td>
<td>
An optional array of objects that conveys the cryptography suites that MUST be
used by the <a>holder</a> to generate a cryptographic proof. Each object in the
array MUST contain a property called `cryptosuite` with a value that is a
cryptosuite name, and MAY contain other properties that are specific to the
cryptosuite. Valid example values include:
<code>[{"cryptosuite": "eddsa-rdfc-2022"}]</code> and
<code>[{"cryptosuite": "ecdsa-rdfc-2019"}, {"cryptosuite": "bbs-2023"}]</code>.
</td>
</tr>
</table>
<p>
The following example demonstrates that the <a>verifier</a> would like the
<a>holder</a> to use the DID Web method and a data integrity ECDSA
cryptography suite to authenticate over the established communication channel,
such as the Credential Handler API (CHAPI):
</p>
<pre class="example"
title="A DID Authentication request using did:web and ecdsa-rdfc-2019">
{
"query": [{
"type": "DIDAuthentication",
"acceptedMethods": [{"method": "key"}],
"acceptedCryptosuites": [{"cryptosuite": "ecdsa-rdfc-2019"}]
}],
"challenge": "99612b24-63d9-11ea-b99f-4f66f3e4f81a",
"domain": "example.com"
}
</pre>
<p>
The next example demonstrates that the <a>verifier</a> would like the
<a>holder</a> to use either the DID Key or DID Web method, and the standard
EdDSA data integrity cryptography suite, and optionally also include a
cryptographic proof that they are capable of performing a data integrity BBS
proof, and authenticate over a different communication channel, in this case
using a Verifiable Credential API HTTP endpoint:
</p>
<pre class="example" title="A complex DID Authentication request">
{
"query": [{
"type": "DIDAuthentication",
"acceptedMethods": [{"method": "key"}, {"method": "web"}],
"acceptedCryptosuites": [{"cryptosuite": "ecdsa-rdfc-2019"}]
}, {
"type": "DIDAuthentication",
"required": false,
"acceptedMethods": [{"method": "key"}, {"method": "web"}],
"acceptedCryptosuites": [{"cryptosuite": "bbs-2023"}]
}],
"challenge": "zLEwtBYgQVNR4tyeo",
"domain": "didauth.example",
"interact": {
"service": [{
"type": "UnmediatedHttpPresentationService2021",
"serviceEndpoint": "https://didauth.example/exchanges/zYRo25k7G2UVWkrNt"
}]
}
}
</pre>
</section>
<section>
<h3>The DID Authentication Response Format</h3>
<p>
The DID Authentication response format enables a <a>holder</a> to
provide the information requested by the <a>verifier</a>. A DID Authentication
response MUST be a <a>verifiable presentation</a> of the following form:
</p>
<table class="simple">
<tr>
<th>Property</th>
<th>Description</th>
</tr>
<tr>
<td>type</td>
<td>
a REQUIRED string value that MUST be set to <code>VerifiablePresentation</code>.
</td>
</tr>
<tr>
<td>holder</td>
<td>
a REQUIRED string value that MUST be set to a specific DID that is of the
type that was requested in the DID Authentication query.
</td>
</tr>
<tr>
<td>proof</td>
<td>
a REQUIRED value that MUST be one or more specific digital proof types that
were requested in the DID Authentication query. Each proof object MUST
include the `domain` and `challenge` values that were provided in the DID
Authentication query. <a>Holder</a> implementations MUST ensure that the `domain` specified
by the <a>verifier</a> matches the domain used for the current channel of
communication.
</td>
</tr>
</table>
<p class="advisement">
It is vital that a <a>holder</a> implementation check the `domain` provided by the
`verifier` against the domain used for the current channel of communication. If
this is not done, a dishonest <a>verifier</a> could then replay the message
to a domain that is not their own. For example, a dishonest <a>verifier</a>
operating from the `evil.example` domain could retrieve a challenge from your
bank, specify a domain value of `yourbank.example`, and then replay
your response to your bank to get access to your financial accounts. This
attack is mitigated as long as implementations ensure that the appropriate
domain is used when generating the <a>verifiable presentation</a>.
</p>
<p>
The example below demonstrates a simple DID Authentication response.
</p>
<pre class="example"
title="A DID Authentication response using did:key">
{
"@context": ["https://www.w3.org/ns/credentials/v2"],
"type": "VerifiablePresentation",
"holder": "did:example:12345",
"proof": {
"type": "DataIntegrityProof",
"cryptosuite": "eddsa-rdfc-2022",
"verificationMethod": "did:example:12345#key-1",
"challenge": "99612b24-63d9-11ea-b99f-4f66f3e4f81a",
"domain": "example.com",
"created": "2024-02-25T14:58:42Z",
"proofPurpose": "authentication",
"proofValue": "z3FXQjecWufY46...UAUL5n2Brbx"
}
}
</pre>
</section>
<section>
<h3>Authorization Capability Request</h3>
<p>
This query type would be included in a request to ask for Authorization
Capabilities or "zcaps" in the Verifiable Presentation.
</p>
<pre class="example nohighlight" title="A zCap Request query">
{
query: [{
type: 'ZcapQuery',
capabilityQuery: [{
referenceId: `a-memorable-name`,
allowedAction: ['read', 'write'],
invoker: 'did:key:1234',
delegator: 'did:key:1234'
invocationTarget: {
type: 'urn:edv:documents'
}
}, {
referenceId: `another-memorable-name`,
allowedAction: 'sign',
invoker: 'did:key:1234',
delegator: 'did:key:1234',
invocationTarget: {
type: 'Ed25519VerificationKey2018',
proofPurpose: 'assertionMethod'
}
}],
challenge: '111112b24-63d9-11ea-b99f-4f66f3e4f81a'
}]
}
</pre>
</section>
</section>
<section>
<h3>Logical Operations in Queries</h3>
<p>
In Verifiable Presentation Requests, the structuring and retrieval of
information rely on the use of logical operations. "AND" and "OR" operations
play crucial roles in defining the path to desired data.
</p>
<section>
<h3>Top-Level Queries ("AND" Operation)</h3>
<p>
At the top-most level of the request structure, different types of queries are
expected to be processed as "AND" operations. Each query is a unique condition
that needs to be met to fulfill the request. This means, each query listed in
the top-level array is an independent requirement.
</p>
<p>
In this example, there are two queries: `APopularQueryType` and
`AnotherQueryType`. The "AND" operation here indicates that both these conditions
need to be met in order to fulfill the request.
</p>
<pre class="example" title="Multiple credentials requested at once using top-level queries">
{
"query": [
// "and"
{
"type": 'APopularQueryType',
// query details ...
},
// "and"
{
"type": 'AnotherQueryType',
// query details ...
}
]
}
</pre>
</section>
<section>
<h3>Nested Queries ("OR" Operation)</h3>
<p>
Within a specific query type, an "OR" operation can be defined. This operation
indicates that one or more of the nested conditions needs to be met. When
all credentialQuery objects are optional, they are interpreted as "OR"
operations within their context. This enables flexible and forgiving data
retrieval where optional conditions can refine the results when possible, but
their absence will not halt the process.
</p>
<p>
In this `QueryByExample` type, we have a `credentialQuery` array where all
queries are optional. The "OR" operation suggests that fulfilling any one of the
listed conditions within `credentialQuery` will enhance the results, but is not
a requirement for the request to be valid or fulfilled. If none of the optional
`credentialQuery` conditions are met, the request will still proceed with the
other conditions outside the `credentialQuery` scope, which are interpreted with
an "AND" operation.
</p>
<pre class="example" title="">
{
"query": [
// "and"
{
"type": "QueryByExample",
"credentialQuery": [
// "or"
{
"required": false,
...
},
// "or"
{
"required": false,
...
},
]
},
// "and"
{ ... }
]
}
</pre>
</section>
</section>
</section>
<section class="normative">
<h2>Interaction Types</h2>
<p>
The <dfn>interaction type</dfn> serves as the main extension point mechanism for
ways of responding to a query.
</p>
<section>
<h3>Mediated Presentation</h3>
<p>
A mediated presentation service requires the use of an out-of-band
interface, for example, a person using a Web browser.
</p>
<pre class="example nohighlight" title="A mediated presentation service that uses a Web browser">
...
"interact": {
"service": [{
"type": "MediatedBrowserPresentationService2021",
"serviceEndpoint": "https://degree.example/fill-out-forms?session=123456"
}]
}
...
</pre>
</section>
<section>
<h3>OIDC Credential Provider</h3>
<p>
A mediated presentation service that utilizes the Open ID Connect Credential
Provider interaction mechanism.
</p>
<pre class="example nohighlight" title="A mediated presentation service that uses the OpenID Connect Credential Provider protocol">
...
"interact": {
"service": [{
"type": "OpenIdConnectCredentialProviderService2021",
"serviceEndpoint": "https://degree.example/authorize?response_type=code&scope=openid%20openid_credential&client_id=s6BhdRkqt3&state=af0ifjsldkj&redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb&credential_format=w3cvc-jsonld"
}]
}
...
</pre>
</section>
<section>
<h3>DIDCommv2 Presentation</h3>
<p>
A mediated presentation service that utilizes the DIDCommv2 interaction
mechanism.
</p>
<pre class="example nohighlight" title="A mediated presentation service that uses the DIDComm v2 Messaging protocol">
...
"interact": {
"service": [{
"id": "did:example:123456789abcdefghi#didcomm-1",
"type": "DIDCommMessaging",
"serviceEndpoint": {
"uri": "http://example.com/path",
"accept": [
"didcomm/v2",
"didcomm/aip2;env=rfc587"
],
"routingKeys": ["did:example:somemediator#somekey"]
}
}]
}
...
</pre>
</section>
<section>
<h3>Unmediated Presentation</h3>
<p>
An unmediated presentation service requires no out-of-band interfaces,
enabling fully-automated presentation processing.
</p>
<pre class="example nohighlight" title="An unmediated presentation service that utilizes HTTP">
...
"interact": {
"service": [{
"type": "UnmediatedHttpPresentationService2021",
"serviceEndpoint": "https://degree.example/active-flows/123456"
}]
}
...
</pre>
</section>
</section>
<section class="normative">
<h2>Usage Scenarios</h2>
<p>
This request query format is intended to be used in a variety of protocols and
usage scenarios.
</p>
<section class="informative">
<h3>Browser - Credential Handler API (CHAPI)</h3>
<p>
The <a href="https://w3c-ccg.github.io/credential-handler-api/">Credential
Handler API (CHAPI)</a> specification enables in-browser Javascript applications
to communicate with wallet providers for the purpose of issuing Verifiable
Credentials and requesting Verifiable Presentations. Interested implementers are
encouraged to look at the <a
href="https://github.com/digitalbazaar/credential-handler-polyfill">Credential
Handler Polyfill</a> repository for further discussion and examples.
</p>
<p>
CHAPI is an extension of the
<a href="https://www.w3.org/TR/credential-management-1/">Credential
Management API</a>, and includes the following:
<ul>
<li><code>navigator.credentials.get(request)</code></li>
<li><code>navigator.credentials.store(request)</code></li>
</ul>
</p>
<p>
A VerifiablePresentation is used to both store or present VerifiableCredentials.
When storing a VerifiableCredential, the VerifiablePresentation does not need to
be signed.
</p>
<section class="informative">
<h4>WebCredential</h4>
<p>
CHAPI provides a single derived class, the <code>WebCredential</code> that forms
the basis for any sort of credential data that is provided over the Web, i.e.,
via a "Credential Handler" that a origin has registered in the user's browser
when the user visited that origin's website. Note that CHAPI provides an
optional <code>recommendedHandlerOrigins</code> feature for any credential
storage request to allow a Relying Party (aka issuer) to suggest one or more
digital wallets to help the user store the credential. This is particularly
helpful if the user has no wallet yet. The listed origins must have a
`manifest.json` file with a valid `credential_handler` entry in order to
be used by CHAPI.
</p>
<pre class="example nohighlight" title="Creating a WebCredential instance.">
// optionally include `recommendedHandlerOrigins` so the user can choose an
// applicable wallet if they don't have one yet:
const options = {
recommendedHandlerOrigins: [
'https://wallet.example'
]
};
const webCredential = new WebCredential('VerifiablePresentation', {
'@context': 'https://www.w3.org/2018/credentials/v1',
...presentation,
options
});
</pre>
</section>
<section class="informative">
<h4>Requesting and Storing Credentials</h4>
<p>
Using CHAPI, a web application can <code>get()</code> and <code>store()</code>
credentials without knowing anything about the user's wallet. This is
intentional; for privacy reasons, the client app must not be able to query any
information (without user consent) about which wallets or credential handlers a
user may have installed (otherwise, fingerprinting and other attacks would be
possible).
</p>
<h4>get()</h4>
<p>
A web app (a Relying Party or verifier) can request a credential using
<code>credentials.get()</code> during a user gesture event, for example when
the user pushes a button on a page that requires identity attributes or
authentication. Note that CHAPI provides an optional
<code>recommendedHandlerOrigins</code> feature for any credential
request (not specific or restricted to VPR) to allow a Relying Party
(aka verifier) to suggest one or more digital wallets to help the user
complete the request. This is particularly helpful if the user has no
wallet yet. The listed origins must have a
`manifest.json` file with a valid `credential_handler` entry in order to
be used by CHAPI.
</p>
<pre class="example nohighlight" title="Example get() request.">
const credentialQuery = {
web: {
VerifiablePresentation: {
query: {
type: 'QueryByExample',
credentialQuery: {
// an optional reason for requesting this credential that
// may be shown to a user by their wallet software
reason: 'We need you to prove your eligibility to work.',
example: {
'@context': [
'https://www.w3.org/2018/credentials/v1',
'https://w3id.org/citizenship/v1'
],
type: 'PermanentResidentCard'
}
}
},
// a 128-bit randomly generated value encoded as a string (use a UUID);
// it will be digitally signed in the authentication proof
// that will be attached to the VerifiablePresentation response
challenge: '3182bdea-63d9-11ea-b6de-3b7c1404d57f',
// the domain that must be digitally signed in the authentication
// proof that will be attached to the VerifiablePresentation
// response, identifying the recipient
domain: 'jobs.example.com'
},
// optionally include credential handler origins to recommend to
// the user if they have no wallet or may want to choose one
// the RP recommends; this is an optional CHAPI feature, it is not
// specific to VPR
recommendedHandlerOrigins: [
'https://wallet.example'
]
}
};
const webCredential = await navigator.credentials.get(credentialQuery);
if(!webCredential) {
console.log('no presentation received');
}
// Response:
null // if the user cancels
// or a WebCredential with these attributes/values:
{
"type": "web",
"dataType": "VerifiablePresentation",
"data": {
// Verifiable Presentation goes here, containing the credentials
// that the user agreed to share
}
}
const {data: presentation} = webCredential;
// send `presentation` to server for forwarding to verifier API
</pre>
<pre class="example nohighlight" title="Example interact request.">
// requesting DID Authentication that can be performed at the given `interact`
// service endpoint; the endpoint may respond to the DID Authentication
// response with another VPR or a VP with credentials
const credentialQuery = {
web: {
VerifiablePresentation: {
query: {
"type": "DIDAuthentication",
"acceptedMethods": [{"method": "example"}]
},
challenge: '3182bdea-63d9-11ea-b6de-3b7c1404d57f',
domain: 'jobs.example.com',
interact: {
service: [{
type: "UnmediatedPresentationService2021",
serviceEndpoint: "https://example.edu/exchangers/z238348134/exchanges/z872347234"
}]
}
},
// optionally include credential handler origins to recommend to
// the user if they have no wallet or may want to choose one
// the RP recommends; this is an optional CHAPI feature, it is not
// specific to VPR
recommendedHandlerOrigins: [
'https://wallet.example'
]
}