-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.html
More file actions
1436 lines (1309 loc) · 47.1 KB
/
index.html
File metadata and controls
1436 lines (1309 loc) · 47.1 KB
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 Credential Rendering Methods v1.0</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 class="remove" src="https://w3c.github.io/vc-data-integrity/common.js"></script>
<script class="remove" src="https://cdn.jsdelivr.net/gh/w3c/respec-mermaid@1.2.0/dist/main.js"></script>
<script type="text/javascript" class="remove">
var respecConfig = {
// specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
specStatus: "ED",
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "vc-render-method",
group: "vc",
// if you wish the publication date to be other than today, set this
//publishDate: "2025-10-30",
// 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",
// if there a publicly available Editor's Draft, this is the link
edDraftURI: "https://w3c.github.io/vc-render-method/",
//latestVersion: "https://www.w3.org/community/reports/credentials/CG-FINAL-vc-render-method-20250831/",
// if this is a LCWD, uncomment and set the end of its review period
// lcEnd: "2009-08-05",
// if you want to have extra CSS, append them to this list
// it is recommended that the respec.css stylesheet be kept
//extraCSS: ["spec.css", "prettify.css"],
// editors, add as many as you like
// only "name" is required
editors: [{
name: "Dmitri Zagidulin",
url: "https://www.linkedin.com/in/dzagidulin/",
company: "MIT Digital Credentials Consortium",
companyURL: "https://digitalcredentials.mit.edu/",
w3cid: 86708
}, {
name: "Manu Sporny",
url: "https://www.linkedin.com/in/manusporny/",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
w3cid: 41758
}, {
name: "Patrick St. Louis",
url: "https://www.linkedin.com/in/patrick-stlouis/",
company: "Open Security and Identity",
companyURL: "https://opsecid.ca/",
w3cid: 162334
}, {
name: "Hendry POH",
url: "https://www.linkedin.com/in/hendrypoh/",
company: "Infocomm Media Development Authority of Singapore",
companyURL: "https://www.imda.gov.sg/",
w3cid: 145713
}, {
name: "Isaac KOH",
url: "https://www.linkedin.com/in/isaackoh89/",
company: "Infocomm Media Development Authority of Singapore",
companyURL: "https://www.imda.gov.sg/",
w3cid: 159564
}],
authors: [{
name: "Manu Sporny", url: "https://www.linkedin.com/in/manusporny/",
company: "Digital Bazaar", companyURL: "https://digitalbazaar.com/",
w3cid: 41758
}, {
name: "Dmitri Zagidulin",
url: "https://www.linkedin.com/in/dzagidulin/",
company: "MIT Digital Credentials Consortium",
companyURL: "https://digitalcredentials.mit.edu/",
w3cid: 86708
}, {
name: "Calvin Cheng",
url: "https://linkedin.com/in/cxcheng/",
company: "Government Technology Agency of Singapore",
companyURL: "https://www.tech.gov.sg/",
w3cid: 145985
}, {
name: "Kyle Huang Junyuan",
url: "https://www.linkedin.com/in/kyle-huang-junyuan/",
company: "Government Technology Agency of Singapore",
companyURL: "https://www.tech.gov.sg/",
w3cid: 145894
}, {
name: "Patrick St. Louis",
url: "https://www.linkedin.com/in/patrick-stlouis/",
company: "Open Security and Identity",
companyURL: "https://opsecid.ca/",
w3cid: 162334
}],
github: "https://github.com/w3c/vc-render-method/",
// 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 neighbourhood
// Team Contact.
// wgPatentURI: "",
maxTocLevel: 4,
preProcess: [ respecMermaid.createFigures ],
/*
alternateFormats: [ {uri: "diff-20111214.html", label: "diff to previous version"} ],
*/
localBiblio: {
ENTRY: {
title: "Example Title",
href: "https://website.example/document",
},
},
lint: {"no-unused-dfns": false},
postProcess: [],
xref: ["INFRA", "VC-DATA-MODEL-2.0", "CID"]
};
</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;
}
code a[href] {
color: inherit;
border-bottom: none;
}
code a[href]:hover {
border-bottom: 1px solid #c63501;
}
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: 75%;
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 an <em>extension mechanism</em> for the
Verifiable Credential Data Model, that can be used to represent a
Verifiable Credential through a visual, auditory, or haptic medium. It covers
rendering a Verifiable Credential to a physical document, digital image,
screen reader, or braille output.
</p>
</section>
<section id="sotd">
<p>
This is an experimental specification and is undergoing regular revisions. It is
not fit for production deployment.
</p>
</section>
<section>
<h2>Introduction</h2>
<p>
Rendering methods can be used when the [=issuer=] has a specific way that
they want to express a [=verifiable credential=] to an observer through
a visual, auditory, or haptic mechanism. For example, an [=issuer=] of an
employee badge credential might want to include rich imagery of their corporate
logo and specific placement of employee information in specific areas of the
badge. They might also want to provide an audio read out of the important
aspects of the badge for individuals that have accessibility needs related
to their eyesight.
</p>
<section id="terminology">
<h3>Terminology</h3>
<div data-include="https://w3c.github.io/vc-data-model/terms.html"></div>
</section>
<section id="conformance">
<p>
A <dfn>conforming render method</dfn> is any concrete expression of the data
model that complies with the normative statements in this specification.
Specifically, all relevant normative statements in Sections
<a href="#data-model"></a> and <a href="#algorithms"></a>
of this document MUST be enforced.
</p>
<p>
A <dfn class="lint-ignore">conforming processor</dfn> is any algorithm realized
as software and/or hardware that generates or consumes a
[=conforming render method=]. Conforming processors MUST produce errors when
non-conforming documents are consumed.
</p>
<p>
This document also contains examples that contain JSON and JSON-LD content. Some
of these examples contain characters that are invalid JSON, such as inline
comments (`//`) and the use of ellipsis (`...`) to denote
information that adds little value to the example. Implementers are cautioned to
remove this content if they desire to use the information as valid JSON or
JSON-LD.
</p>
</section>
</section>
<section>
<h2>Data Model</h2>
<p>
The following sections outline the data model that is used by this specification
for rendering methods
</p>
<section>
<h3>The `renderMethod` Property</h3>
<p>
The `renderMethod` property is a
<a href="https://www.w3.org/TR/vc-data-model-2.0/#reserved-extension-points">
reserved extension point</a> in the Verifiable Credentials Data Model
specification [[VC-DATA-MODEL-2.0]]. An [=issuer=] can utilize this
property in a [=verifiable credential=] to express one or more preferred
render methods.
</p>
<dl>
<dt><var>renderMethod</var></dt>
<dd>
The value of the `renderMethod` property MUST specify one or
more rendering methods that can be used by software to express the
[=verifiable credential=] using a visual, auditory, or haptic mechanism. Each
`renderMethod` value MUST specify its `type`, for example,
`TemplateRenderMethod`. The precise contents of each rendering
hint is determined by the specific `renderMethod` `type`
definition.
</dd>
</dl>
</section>
<section>
<h4>TemplateRenderMethod</h4>
<p>
When an [=issuer=] desires to specify template-based rendering instructions
for a [=verifiable credential=], they MAY add a `renderMethod` property that uses
the data model described below.
</p>
<table class="simple">
<thead>
<tr>
<th style="white-space: nowrap">Property</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>
An OPTIONAL [=string=] that follows the [[[URL]]] and, when fetched,
dereferences to a render template.
</td>
</tr>
<tr>
<td>type</td>
<td>
A REQUIRED [=string=] that MUST be the value `TemplateRenderMethod`.
</td>
</tr>
<tr>
<td>renderSuite</td>
<td>
A REQUIRED [=string=] that identifies the algorithms that are used for
generating the concrete rendering.
</td>
</tr>
<tr>
<td>name</td>
<td>
An OPTIONAL human-readable [=string=] that can be displayed to provide a hint to
the type of rendering that will be performed. This property might be used in a
graphical interface that enables an individual to select between multiple
presentation modes.
</td>
</tr>
<tr>
<td>description</td>
<td>
An OPTIONAL human-readable [=string=] that provides a more involved description
than `name` of when the particular rendering might be useful.
</td>
</tr>
<tr>
<td>renderProperty</td>
<td>
An OPTIONAL [=list=] of [=string=] values that each conform to the
[[[RFC6901]]] syntax that specifies which properties from the [=verifiable
credential=] are exposed when using this specific render method. If
`renderProperty` is not provided, the entire [=verifiable credential=] is
presumed to be shared when the render method is used.
</td>
</tr>
<tr>
<td>template</td>
<td>
An OPTIONAL [=URL=] or [=ordered map|map=] that provides or refers to the
template that will be used to perform the rendering. If the value is a [=URL=],
it MAY be a `data:` URL [[RFC2397]] containing the template code. If the value
is a [=ordered map|map=], it MUST conform to the following rules:
<table class="simple">
<thead>
<tr>
<th style="white-space: nowrap">Property</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>
An REQUIRED [=string=] that follows the [[[URL]]] and, when fetched,
dereferences to a template such as an SVG or PDF file.
</td>
</tr>
<tr>
<td>mediaType</td>
<td>
A RECOMMENDED [=string=] that identifies the media type for the `id` value
as specified in [[[RFC6838]]].
</td>
</tr>
<tr>
<td>digestMultibase</td>
<td>
An OPTIONAL multibase-encoded Multihash of the template file. The multibase
value MUST be `u` (base64url-nopad) and the multihash value MUST be SHA-2 with
256-bits of output (`0x12`).
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>digestMultibase</td>
<td>
An OPTIONAL multibase-encoded Multihash of the render method referenced if `id`
is specified. The multibase value MUST be `u` (base64url-nopad) and the multihash
value MUST be SHA-2 with 256-bits of output (`0x12`).
</td>
</tr>
</tbody>
</table>
<p>
The data model shown above is expressed in a [=verifiable credential=]
in the example below.
</p>
<pre class="example nohighlight"
title="Usage of the render property by an issuer">
{
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://www.w3.org/ns/credentials/examples/v2",
"https://w3id.org/vc/render-method/v1"
],
"id": "http://example.edu/credentials/3732",
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"issuer": "https://example.edu/issuers/14",
"validFrom": "2010-01-01T19:23:24Z",
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts"
}
},
<span class="highlight">"renderMethod": {
"type": "TemplateRenderMethod",
"renderSuite": "svg-mustache",
"template": {
"id": "https://example.edu/credential-templates/BachelorDegree",
"mediaType": "image/svg+xml",
"digestMultibase": "zQmerWC85Wg6wFl9znFCwYxApG270iEu5h6JqWAPdhyxz2dR",
"renderProperty": [
"/issuer", "/validFrom", "/credentialSubject/degree/name"
]
}
}
</span>
}
</pre>
<p>
In the example above, the [=issuer=] has provided a Mustache-based SVG rendering
template for a Bachelor's degree that will be filled in with specific
information from the [=verifiable credential=] listed in `renderProperty`.
</p>
<section>
<h3>The `svg-mustache` Render Suite</h3>
<p>
The `svg-mustache` render suite uses the Mustache templating language to
modify an SVG file, which is then used to render a visual representation
of the [=verifiable credential=].
</p>
<p>
In the example below, a fully embedded SVG file is used as the rendering
template.
</p>
<pre class="example nohighlight"
title="Basic usage of the svg-mustache render suite">
{
<span class="comment">...</span>
"renderMethod": {
"type": "TemplateRenderMethod",
"renderSuite": "svg-mustache",
<span class="comment">// the SVG file is embedded in the VC</span>
"template": "data:image/svg+xml;base64,Qjei89...3jZpW"
}
}
</pre>
<p>
The next example links to the SVG file on the Web and secures it against
modification by using the `digestMultibase` property.
</p>
<pre class="example nohighlight"
title="A remotely hosted SVG file for an SVG render template">
{
<span class="comment">...</span>
"renderMethod": {
"type": "TemplateRenderMethod",
"renderSuite": "svg-mustache",
"template": {
<span class="comment">// this SVG file is fetched from the Web</span>
"id": "https://degree.example/credential-templates/bachelors",
"mediaType": "image/svg+xml",
"digestMultibase": "zQmerWC85Wg6wFl9znFCwYxApG270iEu5h6JqWAPdhyxz2dR"
}
}
</pre>
<p>
The next example links to the rendering template on the Web and secures it
using the `digestMultibase` property:
</p>
<pre class="example nohighlight"
title="A remotely hosted SVG render method">
{
<span class="comment">...</span>
"renderMethod": {
<span class="comment">// this render method is fetched from the Web</span>
"id": "https://degrees.example/bachelors-svg.jsonld",
"mediaType": "application/ld+json",
"type": "TemplateRenderMethod",
"renderSuite": "svg-mustache",
"digestMultibase": "zQmG270iEu5h6JqWAPdhyxz2dRerWC85Wg6wFl9znFCwYxAp"
}
</pre>
</section>
<section>
<h3>The `pdf-mustache` Render Suite</h3>
<p>
The `pdf-mustache` render suite uses the Mustache templating language to
modify a PDF file, which is then used to render a visual representation
of the [=verifiable credential=].
</p>
<p>
In the example below, a fully embedded PDF file is used as the rendering
template.
</p>
<pre class="example nohighlight"
title="Basic usage of the pdf-mustache render suite">
{
<span class="comment">...</span>
"renderMethod": {
"type": "TemplateRenderMethod",
"renderSuite": "pdf-mustache",
<span class="comment">// this PDF file is embedded in the VC</span>
"template": "data:application/pdf;base64,k309SK...pwK83b"
}
}
</pre>
<p>
The next example links to the PDF file on the Web and secures it against
modification by using the `digestMultibase` property.
</p>
<pre class="example nohighlight"
title="Remotely hosted PDF file for a PDF rendering template">
{
<span class="comment">...</span>
"renderMethod": {
"type": "TemplateRenderMethod",
"renderSuite": "pdf-mustache",
"template": {
<span class="comment">// this PDF file is fetched from the Web</span>
"id": "https://degree.example/bachelors.pdf",
"mediaType": "application/pdf",
"digestMultibase": "zQmznFCwYxApG270iEu5h6JqWAPdhyxz2dRerWC85Wg6wFl9"
}
}
</pre>
<p>
The next example links to the rendering template on the Web and secures it
using the `digestMultibase` property:
</p>
<pre class="example nohighlight"
title="Remotely hosted PDF rendering template">
{
<span class="comment">...</span>
"renderMethod": {
<span class="comment">// this render method is fetched from the Web</span>
"id": "https://degrees.example/bachelors-pdf.jsonld",
"type": "TemplateRenderMethod",
"renderSuite": "pdf-mustache",
"digestMultibase": "zQmEu5h6JqWAPdhyxmz2dRerWC85Wg6wFl9znFCwYxApG270"
}
</pre>
</section>
<section>
<h3>The `nfc` Render Suite</h3>
<p>
The `nfc` render suite transmits a binary payload representing the
[=verifiable credential=] over a wireless NFC connection.
</p>
<p>
In the example below, a fully embedded NFC payload is used as the rendering
template, which only discloses the barcode identifier associated with the
credential.
</p>
<pre class="example nohighlight"
title="Usage of the nfc render suite">
{
<span class="comment">...</span>
"renderMethod": {
"type": "TemplateRenderMethod",
"renderSuite": "nfc",
"name": "Tap to send",
<span class="comment">// the NFC payload is embedded</span>
"template": "data:application/octet-stream;base64,2QZkpQGDG...G8XJWnROcY4Biw",
<span class="comment">// only the barcode is transmitted over NFC</span>
"renderProperty": ["/credentialSubject/barcode"]
}
<span class="comment">...</span>
}
</pre>
</section>
<section>
<h3>The `html` Render Suite</h3>
<p>
The `html` render suite allows template authors to provide an HTML template
to render a [=verifiable credential=]. The HTML can be referenced remotely or
via a `data:` URL as the value of either `template` or `template.id` (when
the value of `template` is an object). JavaScript within the HTML fragment is
responsible for rendering the filtered [=verifiable credential=] data provided
via an HTML data block
(i.e. `<script type="application/vc"></script>`) hosted in a
sandboxed iframe alongside the HTML template.
</p>
<pre class="example"
title="Example VC using the HTML render suite">
{
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://www.w3.org/ns/credentials/examples/v2"
],
"type": [
"VerifiableCredential",
"NameCredential"
],
"issuer": {
"id": "did:example:1234",
"name": "The Issuer"
},
"credentialSubject": {
"name": "Example Name",
"notRendered": "should not appear"
},
"renderMethod": {
"type": "TemplateRenderMethod",
"renderSuite": "html",
"renderProperty": [
"/issuer/name",
"/credentialSubject/name"
],
"template": {
"id": "https://test.example/credential-templates/NameCredential.html",
"mediaType": "text/html",
"digestMultibase": "zQmerWC85Wg6wFl9znFCwYxApG270iEu5h6JqWAPdhyxz2dR"
},
"outputPreference": {
"mode": [
"visual"
],
"mediaType": "application/html",
"style": {
"width": "800px",
"height": "800px"
}
}
}
}
</pre>
<p>
Implementations MUST provide an environment that allows for JavaScript to safely
render the HTML template using the filtered [=verifiable credential=] data. The
following terminology is used to describe this environment:
</p>
<dl>
<dt><dfn>host page</dfn></dt>
<dd>
Provides the secure environment for rendering the HTML template.
</dd>
<dt><dfn>template code</dfn></dt>
<dd>
The HTML fragment provided within or remotely referenced by the
Render Method.
</dd>
<dt><dfn>wrapper code</dfn></dt>
<dd>
Code that wraps the HTML template to provide additional security
restrictions and communication with the [=host page=].
</dd>
</dl>
<p>
At minimum, the environment MUST prevent navigation, loading of external
content, and access to the [=host page=] in order to prevent tracking and other
privacy harms.
</p>
<p>
Browser based implementations, for example, can provide such an environment
using a combination of Content Security Policy [[CSP3]] restrictions on a
[=host page=], sandboxing of an `iframe` hosting the HTML template, and wrapper
code that wraps the HTML template to add additional CSP restrictions and
provides ready and error event communication with the [=host page=].
</p>
<figure>
<pre class="diagram mermaid">
graph TD
subgraph Wallet's VC Rendering HTML
direction LR
A(VC) -- selectively disclosed --> B{VC subset datablock}
subgraph "iframe[srcdoc] wrapper code"
B{VC subset datablock}
C[HTML/CSS/JS template from renderMethod]
end
C[HTML/CSS/JS template from renderMethod] --> D[renderMethodReady]
end
</pre>
<figcaption>
Communication between the [=host page=] and the iframe + [=wrapper code=]
</figcaption>
</figure>
<h4>Host Page</h4>
<p>
The [=host page=] (typically a Wallet or [=verifiable credential=] renderer) MUST
prevent the HTML template from navigating the top-level browsing context,
accessing external content, accessing the [=host page=], and loading any remote
content.
</p>
<p>
If a [=host page=] is used, the following rules apply:
</p>
<ul>
<li>
The Content Security Policy (CSP) restrictions MUST include `frame-src 'none'`.
This forces the use of `srcdoc` instead of `src` for iframes, which prevents
the browser from loading the HTML template. In turn, this forces the
[=host page=] code to preload remotely referenced template code and check the
response against the related `digestMultibase` value prior to injecting the
template into the [=wrapper code=].
</li>
<li>
`sandbox="allow-scripts"` MUST be set on the `iframe` hosting the
HTML template to prevent navigation and top-level access.
</li>
</ul>
<pre class="example" title="Minimal Host Page"
data-include="_includes/minimal-host-page.html"
data-include-format="text">
</pre>
<h5>Template Code</h5>
<p>
The HTML [=template code=] referenced by the `template` property in the
`renderMethod` MUST be an HTML fragment that contains the HTML, CSS,
and JavaScript necessary to render the [=verifiable credential=]. The
[=template code=] MUST NOT include any `<html>`, `<head>`, or `<body>` tags,
as these will be provided by the [=wrapper code=].
</p>
<pre class="example" title="Example HTML Template Fragment"
data-include="_includes/template-fragment.html"
data-include-format="text">
</pre>
<h5>Wrapper Code</h5>
<p>
The template HTML fragment MUST be wrapped in [=wrapper code=]
that provides the data block containing the partial [=verifiable credential=]
and adds an additional CSP policies to prevent navigation and external
content loading. Specifically, the [=wrapper code=] MUST add the following CSP
restrictions of `default-src data: 'unsafe-inline'` to prevent any
network requests from being made by the [=template code=].
</p>
<pre class="example"
title="Wrapper Code to wrap template and credential in iframe[srcdoc]"
data-include="_includes/wrapper-code.html"
data-include-format="text">
</pre>
<p>
To complete the setup, the [=host page=] MUST inject the [=wrapper code=] (once populated
with the [=verifiable credential=] and the [=template code=]) into the iframe's `srcdoc`
attribute which will run any JavaScript contained in the [=wrapper code=] and [=template code=].
</p>
<pre class="example"
title="Combined Wrapper Code with Template and Credential"
data-include="_includes/combined.html" data-include-format="text">
</pre>
<h5>Ready and Error Events</h5>
<p>
The iframe created in the [=wrapper code=] MUST provide a communication channel to
allow the template to notify the [=host page=] when rendering is complete or if
there was an error during rendering. This can be accomplished using the
`postMessage` API with a `MessageChannel` setup by the [=wrapper code=].
</p>
<p>
The JavaScript shown below would be added to the above [=host page=] to add an
`onload` event to the iframe which sets up the `MessageChannel`. The [=host page=]
also creates a `Promise` that resolves when a `ready` message is received from
the [=wrapper code=] or rejects when an `error` message is received. The [=wrapper code=]
also provides a `window.renderMethodReady` method for use by the template to
notify the [=host page=] that rendering is complete or send back an error message.
</p>
<pre class="example"
title="Additions to the Host Page to setup MessageChannel"
data-include="_includes/message-channel-setup.js"
data-include-format="text">
</pre>
<pre class="example"
title="Wrapper Code additions to connect the MessageChannel and create `renderMethodReady`"
data-include="_includes/render-method-ready-setup.js"
data-include-format="text">
</pre>
<p>
With this setup, the template JavaScript can call `window.renderMethodReady()`
to notify the [=host page=] that rendering is complete or call
`window.renderMethodReady(new Error("error message"))` to notify the [=host page=]
of an error.
</p>
<h3>Algorithms</h3>
<p>
The following sections outline the algorithms that are used by the `html` render
suite to safely render the HTML template. Alternative algorithms MAY be used
as long as the security and privacy outcomes as well as the output is the same.
</p>
<h4>Host Page</h4>
<p>
The [=host page=] MUST create an `iframe` element to host the HTML template. The
[=host page=] MUST set the `sandbox` attribute on the `iframe` to
`allow-scripts` to prevent navigation and top-level access.
</p>
<ol class="algorithm">
<li>
Let `vc` be the [=verifiable credential=] to be rendered.
</li>
<li>
Let `renderMethod` be the chosen `renderMethod` property in `vc` where
`renderMethod.type` is `TemplateRenderMethod` and
`renderMethod.renderSuite` is `html`.
</li>
<li>
If `renderMethod.template` is a [=string=], then let `template` be the value of
`renderMethod.template`.
</li>
<li>
If `renderMethod.template` is a [=map=], then let `template` be the result of
fetching the URL in `renderMethod.template.id`.
</li>
</ol>
<p>
The [=host page=] MUST filter the [=verifiable credential=] `vc` to only include
the properties specified in `renderMethod.renderProperty`, if it is present. If
`renderMethod.renderProperty` is not present, the entire [=verifiable credential=] is
used.
</p>
<p>
This filtering MUST be done by applying the `selectJsonLd` algorithm defined in
<a href="https://www.w3.org/TR/vc-di-ecdsa/#selectjsonld">Section 3.4.13 selectJsonLd</a>
of the Data Integrity ECDSA Cryptosuites v1.0 specification [[VC-DI-ECDSA]] to
the JSON Pointer [[RFC6901]] values present in `renderMethod.renderProperty`.
</p>
<p>
The [=host page=] MUST create the [=wrapper code=] by embedding the filtered
[=verifiable credential=] and the HTML template into the [=wrapper code=] template
defined above.
</p>
<ol class="algorithm">
<li>
Let `wrapperCode` be an HTML Document with `<meta http-equiv="Content-Security-Policy"
content="default-src data: 'unsafe-inline'">` in the `<head>`.
</li>
<li>
Let `datablock` be an HTML Data Block with a `type` of `application/vc`.
</li>
<li>
Set the contents of `datablock` to be the filtered [=verifiable credential=]
in stringified JSON format.
</li>
<li>
Insert `datablock` into the `<head>` of `wrapperCode`.
</li>
<li>
Insert the value of `template` into the `<body>` of `wrapperCode`.
</li>
</ol>
<p>
The [=host page=] MUST set the `srcdoc` attribute of the `iframe`
to the resulting [=wrapper code=].
</p>
<ol class="algorithm">
<li>
Set the `srcdoc` attribute of the `iframe` to the stringified HTML of
`wrapperCode`.
</li>
</ol>
<p>
The [=host page=] MUST setup a communication channel with the [=wrapper code=] to
receive `ready` and `error` messages as described above.
</p>
<ol class="algorithm">
<li>
Let `renderPromise` be a new `Promise` that:
<ol class="algorithm">
<li>
On `resolve`, can be used to display the `iframe` to the user.
</li>
<li>
On `reject`, display the error message to the user.
</li>
</ol>
</li>
<li>
In the `onload` event of the `iframe`:
<ol class="algorithm">
<li>
Let `channel` be a new `MessageChannel`.
</li>
<li>
Create and start a new `port1` listener on `channel` that listens for a `ready`
message from the code in `template` now injected into the `iframe` via
`wrapperCode`.
</li>
<li>
In the `port1` listener, if a `ready` message is received, resolve `renderPromise`.
If an `error` message is received, reject `renderPromise` with the error
message.
</li>
<li>
Use `postMessage` to send `port2` of `channel` to the `iframe` content window.
</li>
</ol>
</li>
</ol>
<p>
The [=host page=] SHOULD use the `renderPromise` to determine when rendering is
complete or if there was an error during rendering.
</p>
<h4>Wrapper Code</h4>
<p>
The [=wrapper code=] MUST setup to receive communication from the [=host page=] via the
`MessageChannel` and provide the `window.renderMethodReady` method for use by
the [=template code=].
</p>
<ol class="algorithm">
<li>
In the `window.onload` event...
<ol class="algorithm">
<li>
Let `port` be the `MessagePort` received from the [=host page=] via the