-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2023 lines (1880 loc) · 84.9 KB
/
index.html
File metadata and controls
2023 lines (1880 loc) · 84.9 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 lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ISO 18013-7 Verifier Tester</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<style>
:root {
--bg: #0d1117;
--bg2: #161b22;
--bg3: #21262d;
--bg4: #30363d;
--border: #30363d;
--border2: #484f58;
--text: #e6edf3;
--text2: #8b949e;
--text3: #6e7681;
--accent: #58a6ff;
--accent2: #1f6feb;
--green: #3fb950;
--green-bg: #0d1f0e;
--amber: #d29922;
--amber-bg: #1f1a0e;
--red: #f85149;
--red-bg: #1f0d0d;
--purple: #a371f7;
--purple-bg: #170f2a;
--teal: #39d353;
--mono: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
--sans: -apple-system, 'Segoe UI', sans-serif;
--radius: 6px;
--radius-lg: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
background: var(--bg);
color: var(--text);
font-family: var(--sans);
font-size: 14px;
line-height: 1.6;
min-height: 100vh;
}
/* ── Layout ── */
header {
border-bottom: 1px solid var(--border);
padding: 16px 24px;
display: flex;
align-items: center;
gap: 12px;
position: sticky;
top: 0;
background: var(--bg);
z-index: 100;
}
header .logo {
display: flex; align-items: center; gap: 8px;
}
header .logo svg { width: 22px; height: 22px; }
header h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
header .version {
font-size: 11px; background: var(--bg3); border: 1px solid var(--border);
padding: 2px 7px; border-radius: 20px; color: var(--text2);
margin-left: 4px;
}
header .spacer { flex: 1; }
header .status-dot {
width: 8px; height: 8px; border-radius: 50%; background: var(--green);
box-shadow: 0 0 6px var(--green);
animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:.4 } }
header .status-label { font-size: 12px; color: var(--text2); }
main {
display: grid;
grid-template-columns: 340px 1fr;
gap: 0;
height: calc(100vh - 57px);
}
/* ── Sidebar ── */
aside {
border-right: 1px solid var(--border);
overflow-y: auto;
padding: 20px 16px;
display: flex;
flex-direction: column;
gap: 20px;
}
.section-label {
font-size: 10px;
font-weight: 700;
letter-spacing: 1.2px;
text-transform: uppercase;
color: var(--text3);
margin-bottom: 10px;
}
/* ── Forms ── */
label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
input[type=text], input[type=url], textarea, select {
width: 100%; background: var(--bg3); border: 1px solid var(--border);
color: var(--text); border-radius: var(--radius); padding: 7px 10px;
font-size: 13px; font-family: inherit; outline: none;
transition: border-color .15s;
}
input[type=text]:focus, input[type=url]:focus, textarea:focus, select:focus {
border-color: var(--accent2);
}
textarea { resize: vertical; font-family: var(--mono); font-size: 12px; }
/* ── Checkboxes ── */
.checkbox-grid {
display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
}
.checkbox-item {
display: flex; align-items: center; gap: 6px;
padding: 5px 8px; border-radius: var(--radius);
background: var(--bg3); border: 1px solid var(--border);
cursor: pointer; transition: border-color .15s;
}
.checkbox-item:hover { border-color: var(--border2); }
.checkbox-item input[type=checkbox] {
width: 13px; height: 13px; accent-color: var(--accent); cursor: pointer;
}
.checkbox-item span { font-size: 11px; font-family: var(--mono); color: var(--text2); }
.checkbox-item.checked { border-color: var(--accent2); background: #0d1f35; }
.checkbox-item.checked span { color: var(--accent); }
/* ── Buttons ── */
.btn {
display: inline-flex; align-items: center; gap: 6px;
padding: 7px 14px; border-radius: var(--radius);
border: 1px solid var(--border2); background: var(--bg3);
color: var(--text); font-size: 13px; font-weight: 500;
cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--bg4); border-color: var(--text3); }
.btn:active { transform: scale(0.98); }
.btn.primary {
background: var(--accent2); border-color: var(--accent2); color: #fff;
font-weight: 600; width: 100%; justify-content: center;
}
.btn.primary:hover { background: #388bfd; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red-bg); }
/* ── Main content ── */
.content {
overflow-y: auto;
display: flex;
flex-direction: column;
}
/* ── Tabs ── */
.tabs {
border-bottom: 1px solid var(--border);
display: flex;
gap: 0;
padding: 0 20px;
position: sticky; top: 0;
background: var(--bg);
z-index: 10;
}
.tab {
padding: 12px 16px; font-size: 13px; font-weight: 500;
color: var(--text2); cursor: pointer; border-bottom: 2px solid transparent;
transition: all .15s; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
/* ── Tab panels ── */
.tab-panel { display: none; flex: 1; padding: 20px; }
.tab-panel.active { display: flex; flex-direction: column; gap: 16px; }
/* ── Cards ── */
.card {
background: var(--bg2); border: 1px solid var(--border);
border-radius: var(--radius-lg); overflow: hidden;
}
.card-header {
padding: 12px 16px; border-bottom: 1px solid var(--border);
display: flex; align-items: center; gap: 8px;
background: var(--bg3);
}
.card-header h3 { font-size: 13px; font-weight: 600; flex: 1; }
.card-body { padding: 16px; }
/* ── QR ── */
#qr-container {
display: flex; flex-direction: column; align-items: center; gap: 16px;
padding: 24px;
}
#qr-box {
background: #fff; padding: 16px; border-radius: 8px;
min-width: 200px; min-height: 200px;
display: flex; align-items: center; justify-content: center;
}
#qr-box .placeholder {
color: #999; font-size: 13px; text-align: center;
}
.uri-display {
background: var(--bg3); border: 1px solid var(--border);
border-radius: var(--radius); padding: 10px 12px;
font-family: var(--mono); font-size: 11px; color: var(--text2);
word-break: break-all; width: 100%; position: relative;
}
.copy-btn {
position: absolute; top: 6px; right: 6px;
}
/* ── CBOR Inspector ── */
.cbor-tree {
font-family: var(--mono); font-size: 12px; line-height: 1.8;
overflow-x: auto;
}
.cbor-key { color: #79c0ff; }
.cbor-str { color: #a5d6ff; }
.cbor-bytes { color: #ffa657; }
.cbor-num { color: #79c0ff; }
.cbor-bool { color: var(--purple); }
.cbor-tag { color: var(--text3); }
.cbor-indent { padding-left: 18px; border-left: 1px solid var(--border); margin-left: 4px; }
/* ── Response panel ── */
.response-meta {
display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
margin-bottom: 14px;
}
.meta-card {
background: var(--bg3); border: 1px solid var(--border);
border-radius: var(--radius); padding: 10px 12px;
}
.meta-card .label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 3px; }
.meta-card .value { font-size: 20px; font-weight: 600; }
.meta-card .value.ok { color: var(--green); }
.meta-card .value.warn { color: var(--amber); }
.meta-card .value.err { color: var(--red); }
.field-table { width: 100%; border-collapse: collapse; }
.field-table th {
text-align: left; font-size: 11px; color: var(--text3);
font-weight: 500; padding: 6px 10px; border-bottom: 1px solid var(--border);
}
.field-table td {
padding: 7px 10px; border-bottom: 1px solid var(--border);
font-size: 12px; vertical-align: top;
}
.field-table tr:last-child td { border-bottom: none; }
.field-table td:first-child { font-family: var(--mono); color: var(--accent); font-size: 11px; }
.field-table td:nth-child(2) { color: var(--text2); }
.field-table td:last-child { color: var(--text); word-break: break-all; }
.badge {
display: inline-block; font-size: 10px; font-weight: 600;
padding: 2px 7px; border-radius: 20px;
letter-spacing: .4px;
}
.badge.ok { background: var(--green-bg); color: var(--green); border: 1px solid #1a4a1e; }
.badge.warn { background: var(--amber-bg); color: var(--amber); border: 1px solid #3d2e0a; }
.badge.err { background: var(--red-bg); color: var(--red); border: 1px solid #3d1515; }
.badge.info { background: #0d1f35; color: var(--accent); border: 1px solid #1a3a5e; }
/* ── Hex dump ── */
.hex-dump {
font-family: var(--mono); font-size: 11px; line-height: 1.8;
color: var(--text2); overflow-x: auto; white-space: pre;
background: var(--bg3); border-radius: var(--radius);
padding: 12px; max-height: 320px; overflow-y: auto;
}
.hex-dump .addr { color: var(--text3); margin-right: 12px; }
.hex-dump .hex { color: #ffa657; }
.hex-dump .ascii { color: var(--text2); margin-left: 12px; }
/* ── Log ── */
.log {
font-family: var(--mono); font-size: 12px; line-height: 1.8;
background: var(--bg); border: 1px solid var(--border);
border-radius: var(--radius); padding: 12px;
max-height: 200px; overflow-y: auto; color: var(--text2);
}
.log-line { display: flex; gap: 10px; }
.log-line .ts { color: var(--text3); flex-shrink: 0; font-size: 11px; margin-top: 1px; }
.log-line.info .msg { color: var(--text); }
.log-line.ok .msg { color: var(--green); }
.log-line.err .msg { color: var(--red); }
.log-line.warn .msg { color: var(--amber); }
/* ── Misc ── */
.empty-state {
text-align: center; padding: 40px 20px; color: var(--text3);
}
.empty-state .icon { font-size: 32px; margin-bottom: 10px; }
.empty-state p { font-size: 13px; }
details > summary {
cursor: pointer; list-style: none; color: var(--text2);
font-size: 12px; padding: 4px 0;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▸ '; color: var(--text3); }
details[open] > summary::before { content: '▾ '; }
.toggle-row {
display: flex; align-items: center; justify-content: space-between;
font-size: 12px; color: var(--text2); padding: 4px 0;
}
.toggle { display: flex; align-items: center; gap: 4px; }
input[type=checkbox].toggle-cb { accent-color: var(--accent); width: 14px; height: 14px; }
.divider { border: none; border-top: 1px solid var(--border); }
.gap-sm { display: flex; flex-direction: column; gap: 8px; }
.nonce-display {
font-family: var(--mono); font-size: 11px; color: var(--text3);
background: var(--bg3); border: 1px solid var(--border);
padding: 4px 8px; border-radius: var(--radius);
display: flex; align-items: center; justify-content: space-between;
}
@media (max-width: 900px) {
main { grid-template-columns: 1fr; }
aside { border-right: none; border-bottom: 1px solid var(--border); max-height: 50vh; }
main { height: auto; }
}
</style>
</head>
<body>
<header>
<div class="logo">
<svg viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="1" y="1" width="20" height="20" rx="4" stroke="#58a6ff" stroke-width="1.5"/>
<rect x="5" y="5" width="5" height="5" fill="#58a6ff"/>
<rect x="12" y="5" width="5" height="5" fill="#58a6ff"/>
<rect x="5" y="12" width="5" height="5" fill="#58a6ff"/>
<rect x="12" y="12" width="5" height="5" fill="#30363d"/>
</svg>
<h1>mdoc Verifier Tester</h1>
<span class="version">ISO 18013-7 / 23220</span>
</div>
<div class="spacer"></div>
<div class="status-dot" id="status-dot"></div>
<span class="status-label" id="status-label">ready</span>
</header>
<div id="endpoint-bar" style="
border-bottom:1px solid var(--border);
background:var(--bg2);
padding:8px 24px;
display:flex;
align-items:center;
gap:10px;
font-size:12px;
">
<span style="color:var(--text3);white-space:nowrap;font-size:11px;font-weight:600;letter-spacing:.6px;text-transform:uppercase">Endpoint</span>
<div style="position:relative;flex:1;max-width:560px">
<span style="position:absolute;left:9px;top:50%;transform:translateY(-50%);color:var(--text3);font-size:11px;pointer-events:none;font-family:var(--mono)">POST</span>
<input type="url" id="endpoint-bar-url" value=""
style="padding-left:44px;height:30px;font-family:var(--mono);font-size:12px;width:100%"
placeholder="https://your-server.example.com/mdoc/request"
oninput="syncEndpointUrl(this.value)">
</div>
<button class="btn sm" onclick="testEndpoint()" id="test-endpoint-btn">Test ↗</button>
<div id="endpoint-status" style="font-size:11px;color:var(--text3)">not tested</div>
</div>
<main>
<!-- ── Sidebar: Request Config ── -->
<aside>
<div>
<div class="section-label">Presentation Request</div>
<div class="gap-sm">
<div>
<label>Protocol</label>
<select id="protocol-mode">
<option value="mdoc">URI scheme / QR (existing demo)</option>
<option value="annex_c">Digital Credentials API / Annex C</option>
</select>
</div>
<div>
<label id="request-url-label">Request URL (request_url)</label>
<input type="url" id="request-url" value="" placeholder="https://..."
oninput="document.getElementById('endpoint-bar-url').value=this.value; document.getElementById('endpoint-status').textContent='not tested'; document.getElementById('endpoint-status').style.color='var(--text3)'">
</div>
<div>
<label>Verifier ID</label>
<input type="text" id="verifier-id" value="urn:example:verifier">
</div>
<div id="doc-type-wrap">
<label>Doc Type</label>
<select id="doc-type">
<option value="org.iso.23220.photoid.1">org.iso.23220.photoid.1</option>
<option value="org.iso.18013.5.1.mDL">org.iso.18013.5.1.mDL</option>
<option value="custom">Custom…</option>
</select>
</div>
<div id="custom-doctype-row" style="display:none">
<label>Custom docType</label>
<input type="text" id="custom-doc-type" placeholder="org.example.credential.1">
</div>
</div>
</div>
<hr class="divider">
<div>
<div class="section-label">Namespace: org.iso.23220.1</div>
<div class="checkbox-grid" id="photoid-elements">
<!-- injected by JS -->
</div>
<div style="margin-top:10px">
<label>Custom PhotoID attributes</label>
<input type="text" id="custom-photoid-attributes" placeholder="employee_id, access_level">
</div>
</div>
<div>
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:8px">
<div class="section-label" style="margin:0">Namespace: org.iso.18013.5.1</div>
<label style="display:flex;align-items:center;gap:5px;cursor:pointer;margin:0">
<input type="checkbox" id="include-mdl" style="accent-color:var(--accent)"> <span style="font-size:11px;color:var(--text2)">Include</span>
</label>
</div>
<div class="checkbox-grid" id="mdl-elements" style="opacity:.4;pointer-events:none">
<!-- injected by JS -->
</div>
<div style="margin-top:10px">
<label>Custom mDL attributes</label>
<input type="text" id="custom-mdl-attributes" placeholder="restrictions_code, endorsements" disabled>
</div>
</div>
<div>
<div class="section-label">Custom Namespace</div>
<div class="gap-sm">
<div>
<label>Namespace</label>
<input type="text" id="custom-namespace" placeholder="org.example.employee.1">
</div>
<div>
<label>Attributes</label>
<input type="text" id="custom-namespace-attributes" placeholder="employee_id, department">
</div>
</div>
</div>
<hr class="divider">
<div>
<div class="section-label">Nonce</div>
<div class="nonce-display" id="nonce-display">
<span id="nonce-val" style="overflow:hidden;text-overflow:ellipsis;max-width:220px;white-space:nowrap">—</span>
<button class="btn sm" onclick="regenerateNonce()">↺</button>
</div>
</div>
<button class="btn primary" id="generate-btn" onclick="generateRequest()">
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M3.5 2h-1A.5.5 0 0 0 2 2.5v1A.5.5 0 0 0 2.5 4h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm5 0h-1A.5.5 0 0 0 7 2.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1A.5.5 0 0 0 8.5 2zm5 0h-1a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zM3.5 7h-1a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1A.5.5 0 0 0 3.5 7zm5 0h-1A.5.5 0 0 0 7 7.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1A.5.5 0 0 0 8.5 7zm5 0h-1a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zM3.5 12h-1a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm5 0h-1a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5zm5 0h-1a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5z"/></svg>
Generate DeviceRequest
</button>
</aside>
<!-- ── Main content ── -->
<div class="content">
<div class="tabs">
<div class="tab active" onclick="switchTab('qr')">QR / Deep Link</div>
<div class="tab" onclick="switchTab('cbor')">CBOR Inspector</div>
<div class="tab" onclick="switchTab('log')">Log</div>
</div>
<!-- Tab: QR -->
<div class="tab-panel active" id="tab-qr">
<div class="card">
<div class="card-header">
<h3 id="transport-card-title">ReaderEngagement QR Code</h3>
<button class="btn sm" id="download-qr-btn" onclick="downloadQR()" style="display:none">↓ PNG</button>
<button class="btn sm" id="copy-uri-btn" onclick="copyCurrentTransportValue()" style="display:none">Copy URI</button>
</div>
<div id="qr-container">
<div id="qr-box">
<div class="placeholder">Generate a request<br>to see QR code</div>
</div>
<div id="mdoc-uri-panel" style="display:none;width:100%">
<div style="font-size:11px;color:var(--text3);margin-bottom:6px;" id="transport-value-label">mdoc:// URI (ISO 18013-7 §8.3.3.1.2)</div>
<div class="uri-display" id="uri-display"></div>
<div style="margin-top:12px;display:flex;gap:8px;flex-wrap:wrap">
<a id="open-deeplink" href="#" class="btn sm" onclick="openDeeplink(event)">
Open on this device ↗
</a>
<button class="btn sm" id="launch-dcapi-btn" onclick="launchStoredAnnexCRequest()" style="display:none">
Present From This Device
</button>
<button class="btn sm" onclick="copyCurrentTransportValue()" id="copy-transport-inline-btn">Copy URI</button>
<button class="btn sm" onclick="generateRequest()">↺ Regenerate</button>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header"><h3>Request Summary</h3></div>
<div class="card-body" id="request-summary">
<div class="empty-state">
<div class="icon">⬡</div>
<p>No request generated yet</p>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<h3>Wallet Response</h3>
<span id="wallet-response-badge" class="badge info">idle</span>
</div>
<div class="card-body" id="wallet-response-panel">
<div class="empty-state">
<div class="icon">⇄</div>
<p>Generate a request to start watching for the wallet response</p>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<h3>Annex C Debug</h3>
<span id="annexc-debug-badge" class="badge info">idle</span>
</div>
<div class="card-body" id="annexc-debug-panel">
<div class="empty-state">
<div class="icon">⌁</div>
<p>Generate an Annex C request to capture environment and request diagnostics</p>
</div>
</div>
</div>
</div>
<!-- Tab: CBOR Inspector -->
<div class="tab-panel" id="tab-cbor">
<div class="card">
<div class="card-header">
<h3>CBOR Encoder / Decoder</h3>
<div style="display:flex;gap:6px;">
<button class="btn sm" onclick="loadCurrentRequest()">Load Current Request</button>
<button class="btn sm" onclick="clearCbor()">Clear</button>
</div>
</div>
<div class="card-body">
<div class="gap-sm">
<div>
<label>Hex / Base64 Input (paste any CBOR-encoded payload)</label>
<textarea id="cbor-input" rows="4" placeholder="a50068312e3120... or pQBoMS4xIA=="></textarea>
</div>
<div style="display:flex;gap:6px">
<button class="btn" onclick="decodeCbor()">Decode ↓</button>
<button class="btn" onclick="encodeCborFromJson()">Encode from JSON ↑</button>
</div>
<div>
<label>Decoded Tree</label>
<div class="card" style="padding:12px;min-height:80px">
<div class="cbor-tree" id="cbor-tree"><span style="color:var(--text3)">—</span></div>
</div>
</div>
<div>
<label>JSON representation</label>
<textarea id="cbor-json-out" rows="6" readonly style="color:var(--text2)"></textarea>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header"><h3>Hex Dump</h3></div>
<div class="card-body">
<div class="hex-dump" id="hex-dump-output">—</div>
</div>
</div>
</div>
<!-- Tab: Log -->
<div class="tab-panel" id="tab-log">
<div class="card">
<div class="card-header">
<h3>Session Log</h3>
<button class="btn sm danger" onclick="clearLog()">Clear</button>
</div>
<div class="card-body">
<div class="log" id="log-panel"></div>
</div>
</div>
<div class="card" id="session-state-card">
<div class="card-header"><h3>Session State (ephemeral)</h3></div>
<div class="card-body">
<table class="field-table" id="session-table">
<thead><tr><th>field</th><th style="width:100%">value</th></tr></thead>
<tbody id="session-tbody"></tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<script>
// ════════════════════════════════════════════════════════════
// CBOR implementation (minimal, no deps)
// ════════════════════════════════════════════════════════════
const CBOR = (() => {
function encode(val) {
const parts = [];
function w(v) { parts.push(v); }
function encodeVal(v) {
if (v === null || v === undefined) { w(new Uint8Array([0xf6])); return; }
if (typeof v === 'boolean') { w(new Uint8Array([v ? 0xf5 : 0xf4])); return; }
if (typeof v === 'number') {
if (Number.isInteger(v) && v >= 0 && v <= 0xffffffff) {
w(encodeUint(0, v));
} else if (Number.isInteger(v) && v < 0) {
w(encodeUint(1, -v - 1));
} else {
const buf = new ArrayBuffer(9); const dv = new DataView(buf);
dv.setUint8(0, 0xfb); dv.setFloat64(1, v); w(new Uint8Array(buf));
}
return;
}
if (typeof v === 'bigint') {
if (v >= 0n) w(encodeUint(0, Number(v)));
else w(encodeUint(1, Number(-v - 1n)));
return;
}
if (typeof v === 'string') {
const bytes = new TextEncoder().encode(v);
w(encodeUint(3, bytes.length)); w(bytes); return;
}
if (v instanceof Uint8Array) {
w(encodeUint(2, v.length)); w(v); return;
}
if (Array.isArray(v)) {
w(encodeUint(4, v.length));
v.forEach(encodeVal); return;
}
if (v instanceof Map) {
w(encodeUint(5, v.size));
v.forEach((val, key) => { encodeVal(key); encodeVal(val); }); return;
}
if (typeof v === 'object') {
const keys = Object.keys(v);
w(encodeUint(5, keys.length));
keys.forEach(k => { encodeVal(k); encodeVal(v[k]); }); return;
}
}
function encodeUint(major, val) {
const m = major << 5;
if (val <= 23) return new Uint8Array([m | val]);
if (val <= 0xff) return new Uint8Array([m | 24, val]);
if (val <= 0xffff) { const b = new ArrayBuffer(3); const dv = new DataView(b); dv.setUint8(0, m | 25); dv.setUint16(1, val); return new Uint8Array(b); }
if (val <= 0xffffffff) { const b = new ArrayBuffer(5); const dv = new DataView(b); dv.setUint8(0, m | 26); dv.setUint32(1, val); return new Uint8Array(b); }
const b = new ArrayBuffer(9); const dv = new DataView(b); dv.setUint8(0, m | 27); dv.setBigUint64(1, BigInt(val)); return new Uint8Array(b);
}
encodeVal(val);
const total = parts.reduce((a, b) => a + b.length, 0);
const out = new Uint8Array(total); let off = 0;
parts.forEach(p => { out.set(p, off); off += p.length; });
return out;
}
function decode(buf) {
const dv = new DataView(buf instanceof ArrayBuffer ? buf : buf.buffer, buf.byteOffset, buf.byteLength);
let pos = 0;
function read() {
const b = dv.getUint8(pos++);
const major = b >> 5, add = b & 0x1f;
let len;
if (add <= 23) len = add;
else if (add === 24) { len = dv.getUint8(pos++); }
else if (add === 25) { len = dv.getUint16(pos); pos += 2; }
else if (add === 26) { len = dv.getUint32(pos); pos += 4; }
else if (add === 27) { len = Number(dv.getBigUint64(pos)); pos += 8; }
else if (add === 31) len = Infinity;
if (major === 0) return len;
if (major === 1) return -1 - len;
if (major === 2) {
const bytes = new Uint8Array(buf instanceof ArrayBuffer ? buf : buf.buffer, buf.byteOffset + pos, len);
pos += len; return bytes;
}
if (major === 3) {
const bytes = new Uint8Array(buf instanceof ArrayBuffer ? buf : buf.buffer, buf.byteOffset + pos, len);
pos += len; return new TextDecoder().decode(bytes);
}
if (major === 4) {
if (len === Infinity) {
const arr = [];
while (true) { const b2 = dv.getUint8(pos); if (b2 === 0xff) { pos++; break; } arr.push(read()); } return arr;
}
const arr = []; for (let i = 0; i < len; i++) arr.push(read()); return arr;
}
if (major === 5) {
if (len === Infinity) {
const map = new Map();
while (true) { const b2 = dv.getUint8(pos); if (b2 === 0xff) { pos++; break; } map.set(read(), read()); } return map;
}
const map = new Map(); for (let i = 0; i < len; i++) map.set(read(), read());
return map;
}
if (major === 6) { return { _tag: len, _val: read() }; }
if (major === 7) {
if (len === 20) return false; if (len === 21) return true;
if (len === 22) return null; if (len === 23) return undefined;
if (add === 25) { pos += 2; return NaN; }
if (add === 26) { const f = dv.getFloat32(pos); pos += 4; return f; }
if (add === 27) { const f = dv.getFloat64(pos); pos += 8; return f; }
return undefined;
}
}
return read();
}
return { encode, decode };
})();
// ════════════════════════════════════════════════════════════
// State
// ════════════════════════════════════════════════════════════
let state = {
nonce: null,
readerPrivKey: null,
readerPubKey: null,
readerEngagementBytes: null,
deviceRequestPayload: null,
mdocUri: null,
sessionNonce: null,
sessionId: null,
sessionStatusTimer: null,
activeProtocol: 'mdoc',
transportValue: null,
annexCDeviceRequestB64: null,
annexCRequestPayload: null,
annexCDebug: null,
};
let qrInstance = null;
// ════════════════════════════════════════════════════════════
// Element definitions
// ════════════════════════════════════════════════════════════
const PHOTOID_ELEMENTS = ['portrait','family_name','given_name','birth_date','issue_date','expiry_date','issuing_country','document_number','age_over_18','age_in_years','age_birth_year'];
const MDL_ELEMENTS = ['family_name','given_name','birth_date','issuing_country','portrait','driving_privileges'];
// ════════════════════════════════════════════════════════════
// Init
// ════════════════════════════════════════════════════════════
function init() {
const defaultRequestUrl = `${window.location.origin}/mdoc/request`;
document.getElementById('request-url').value = defaultRequestUrl;
document.getElementById('endpoint-bar-url').value = defaultRequestUrl;
buildCheckboxes('photoid-elements', PHOTOID_ELEMENTS, ['portrait','family_name','given_name','birth_date','age_over_18']);
buildCheckboxes('mdl-elements', MDL_ELEMENTS, ['family_name','given_name','birth_date','issuing_country']);
regenerateNonce();
document.getElementById('include-mdl').addEventListener('change', e => {
const mdl = document.getElementById('mdl-elements');
mdl.style.opacity = e.target.checked ? '1' : '.4';
mdl.style.pointerEvents = e.target.checked ? 'auto' : 'none';
document.getElementById('custom-mdl-attributes').disabled = !e.target.checked;
});
document.getElementById('doc-type').addEventListener('change', e => {
document.getElementById('custom-doctype-row').style.display = e.target.value === 'custom' ? 'block' : 'none';
});
document.getElementById('protocol-mode').addEventListener('change', e => {
state.activeProtocol = e.target.value;
updateProtocolModeUi();
});
log('info', 'ISO 18013-7 Verifier Tester initialised (in-browser crypto)');
log('info', 'Ephemeral key pair will be generated on each DeviceRequest');
updateSessionTable();
updateProtocolModeUi();
}
function buildCheckboxes(containerId, elements, defaultChecked) {
const container = document.getElementById(containerId);
elements.forEach(el => {
const div = document.createElement('div');
div.className = 'checkbox-item' + (defaultChecked.includes(el) ? ' checked' : '');
div.innerHTML = `<input type="checkbox" ${defaultChecked.includes(el) ? 'checked' : ''}><span>${el}</span>`;
const cb = div.querySelector('input');
cb.addEventListener('change', () => {
div.classList.toggle('checked', cb.checked);
});
container.appendChild(div);
});
}
function getCheckedElements(containerId) {
const checks = document.querySelectorAll(`#${containerId} input[type=checkbox]`);
const result = {};
checks.forEach(c => { if (c.checked) result[c.nextElementSibling.textContent] = false; });
return result;
}
function parseCustomAttributes(raw) {
return Array.from(
new Set(
raw
.split(/[,\n]/)
.map(value => value.trim())
.filter(Boolean)
)
);
}
// ════════════════════════════════════════════════════════════
// Nonce
// ════════════════════════════════════════════════════════════
function regenerateNonce() {
state.nonce = crypto.getRandomValues(new Uint8Array(16));
const hex = Array.from(state.nonce).map(b => b.toString(16).padStart(2,'0')).join('');
document.getElementById('nonce-val').textContent = hex;
log('info', `Nonce regenerated: ${hex.slice(0,16)}…`);
}
function updateProtocolModeUi() {
const mode = document.getElementById('protocol-mode').value;
state.activeProtocol = mode;
const isAnnexC = mode === 'annex_c';
document.getElementById('request-url-label').textContent = isAnnexC ? 'Response endpoint (generated by backend)' : 'Request URL (request_url)';
document.getElementById('request-url').placeholder = isAnnexC ? 'Generated after session creation' : 'https://...';
document.getElementById('request-url').readOnly = isAnnexC;
document.getElementById('transport-card-title').textContent = isAnnexC ? 'Digital Credentials API Request' : 'ReaderEngagement QR Code';
document.getElementById('generate-btn').lastChild.textContent = isAnnexC ? ' Generate Annex C Request' : ' Generate DeviceRequest';
document.getElementById('doc-type-wrap').style.opacity = isAnnexC ? '.6' : '1';
document.getElementById('doc-type').disabled = isAnnexC;
document.getElementById('custom-doctype-row').style.display = !isAnnexC && document.getElementById('doc-type').value === 'custom' ? 'block' : 'none';
document.getElementById('include-mdl').disabled = isAnnexC;
document.getElementById('custom-mdl-attributes').disabled = isAnnexC || !document.getElementById('include-mdl').checked;
document.getElementById('mdl-elements').style.opacity = isAnnexC ? '.2' : (document.getElementById('include-mdl').checked ? '1' : '.4');
document.getElementById('mdl-elements').style.pointerEvents = isAnnexC ? 'none' : (document.getElementById('include-mdl').checked ? 'auto' : 'none');
if (isAnnexC) {
document.getElementById('request-url').value = '';
document.getElementById('endpoint-bar-url').value = `${window.location.origin}/dc/session`;
} else {
document.getElementById('request-url').value = `${window.location.origin}/mdoc/request`;
document.getElementById('endpoint-bar-url').value = `${window.location.origin}/mdoc/request`;
}
document.getElementById('endpoint-status').textContent = 'not tested';
document.getElementById('endpoint-status').style.color = 'var(--text3)';
resetTransportPanel(isAnnexC);
}
function resetTransportPanel(isAnnexC) {
stopSessionPolling();
state.sessionId = null;
state.transportValue = null;
state.annexCDeviceRequestB64 = null;
state.annexCRequestPayload = null;
state.annexCDebug = null;
state.mdocUri = null;
const qrBox = document.getElementById('qr-box');
qrBox.innerHTML = isAnnexC
? '<div class="placeholder">Generate a request<br>to see Annex C payload</div>'
: '<div class="placeholder">Generate a request<br>to see QR code</div>';
document.getElementById('mdoc-uri-panel').style.display = 'none';
document.getElementById('download-qr-btn').style.display = 'none';
document.getElementById('copy-uri-btn').style.display = 'none';
document.getElementById('open-deeplink').style.display = isAnnexC ? 'none' : 'inline-flex';
document.getElementById('launch-dcapi-btn').style.display = 'none';
document.getElementById('copy-transport-inline-btn').textContent = isAnnexC ? 'Copy Request JSON' : 'Copy URI';
document.getElementById('copy-uri-btn').textContent = isAnnexC ? 'Copy Request JSON' : 'Copy URI';
document.getElementById('transport-value-label').textContent = isAnnexC
? 'Digital Credentials API request object'
: 'mdoc:// URI (ISO 18013-7 §8.3.3.1.2)';
setWalletResponseState('idle', isAnnexC
? 'Generate a request to start watching for a Digital Credentials API response.'
: 'Generate a request to start watching for the wallet response.');
renderAnnexCDebug();
}
function canUseDigitalCredentialsApi() {
return typeof window.DigitalCredential !== 'undefined'
&& typeof navigator.credentials?.get === 'function';
}
function allowsMdocProtocol() {
if (typeof window.DigitalCredential === 'undefined') return false;
if (typeof window.DigitalCredential.userAgentAllowsProtocol !== 'function') return true;
try {
return window.DigitalCredential.userAgentAllowsProtocol('org-iso-mdoc');
} catch (_err) {
return false;
}
}
function currentAnnexCEnvironment() {
let protocolAllowed = null;
let allowsError = null;
if (typeof window.DigitalCredential !== 'undefined' && typeof window.DigitalCredential.userAgentAllowsProtocol === 'function') {
try {
protocolAllowed = window.DigitalCredential.userAgentAllowsProtocol('org-iso-mdoc');
} catch (err) {
allowsError = err && typeof err.message === 'string' ? err.message : String(err);
}
}
return {
timestamp: new Date().toISOString(),
origin: window.location.origin,
href: window.location.href,
userAgent: navigator.userAgent,
platform: navigator.platform || '',
language: navigator.language || '',
languages: navigator.languages || [],
secureContext: window.isSecureContext,
digitalCredentialPresent: typeof window.DigitalCredential !== 'undefined',
credentialsGetPresent: typeof navigator.credentials?.get === 'function',
userAgentAllowsProtocolPresent: typeof window.DigitalCredential?.userAgentAllowsProtocol === 'function',
orgIsoMdocAllowed: protocolAllowed,
orgIsoMdocAllowedError: allowsError,
};
}
function updateAnnexCDebug(patch = {}, phase = null) {
const existing = state.annexCDebug || {};
state.annexCDebug = {
...existing,
...patch,
environment: {
...(existing.environment || {}),
...currentAnnexCEnvironment(),
...(patch.environment || {}),
},
};
if (phase) {
state.annexCDebug.phase = phase;
}
renderAnnexCDebug();
}
function renderAnnexCDebug() {
const badge = document.getElementById('annexc-debug-badge');
const panel = document.getElementById('annexc-debug-panel');
const debug = state.annexCDebug;
if (!debug) {
badge.className = 'badge info';
badge.textContent = 'idle';
panel.innerHTML = `
<div class="empty-state">
<div class="icon">⌁</div>
<p>Generate an Annex C request to capture environment and request diagnostics</p>
</div>
`;
return;
}
const phase = debug.phase || 'captured';
badge.className = debug.lastError ? 'badge err' : 'badge info';
badge.textContent = phase;
const sections = [
['Environment', debug.environment],
['Session', debug.session],
['Selected Claims', debug.selection],
['Request Payload', debug.requestPayload],
['Last DC API Result', debug.lastResult],
['Last Error', debug.lastError],
].filter(([, value]) => value && (!(typeof value === 'object') || Object.keys(value).length));
panel.innerHTML = sections.map(([title, value]) => `
<div class="gap-sm" style="margin-bottom:14px">
<div style="font-size:11px;color:var(--text3);text-transform:uppercase;letter-spacing:.5px">${escHtml(title)}</div>
<div class="uri-display" style="max-height:220px;overflow:auto;white-space:pre-wrap">${escHtml(safeJsonStringify(value))}</div>
</div>
`).join('') || `
<div class="empty-state">
<div class="icon">⌁</div>
<p>No Annex C diagnostics captured yet</p>
</div>
`;
}
function normalizeDigitalCredentialPayload(credential) {
if (!credential || typeof credential !== 'object') {
throw new Error('Browser returned an empty Digital Credential response');
}
if (credential.data && typeof credential.data === 'object') {
if (typeof credential.data.response === 'string') {
return credential;
}
if (typeof credential.data.enc === 'string' && typeof credential.data.cipherText === 'string') {
return credential;
}
}
if (typeof credential.response === 'string') {
return {
protocol: credential.protocol || 'org-iso-mdoc',
data: {