-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
2245 lines (2223 loc) · 89.7 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>
Credential Handler API 1.0
</title>
<meta charset='utf-8'>
<script src='https://www.w3.org/Tools/respec/respec-w3c-common' class=
'remove'></script>
<script src="./common.js" class="remove"></script>
<!-- <script src='utils.js' class='remove'></script> -->
<script class='remove'>
var respecConfig = {
github: "https://github.com/w3c-ccg/credential-handler-api/",
shortName: "credential-handler",
edDraftURI: "https://w3c-ccg.github.io/credential-handler-api/",
specStatus: "CG-DRAFT",
editors: [
{ name: "Dave Longley",
url: "https://github.com/dlongley",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com"
},
{ name: "Manu Sporny",
url: "https://manu.sporny.org",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com"
},
],
authors: [
{ name: "Dave Longley",
url: "https://github.com/dlongley",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com"
},
{ name: "Manu Sporny",
url: "https://manu.sporny.org",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com"
},
],
//license: "w3c-software-doc",
wg: "Credentials Community Group",
wgURI: "https://www.w3.org/community/credentials/",
//wgPatentURI: "https://www.w3.org/2004/01/pp-impl/83744/status",
testSuiteURI: "https://w3c-test.org/credential-handler-api/",
issueBase: "https://github.com/w3c-ccg/credential-handler-api/issues/",
githubAPI: "https://api.github.com/repos/w3c-ccg/credential-handler-api",
};
</script>
<style>
dt { margin-top: 0.75em; }
table { margin-top: 0.75em; border-collapse:collapse; border-style:hidden hidden none hidden }
table thead { border-bottom:solid }
table tbody th:first-child { border-left:solid }
table td, table th { border-left:solid; border-right:solid; border-bottom:solid thin; vertical-align:top; padding:0.2em }
li { margin-top: 0.5em; margin-bottom: 0.5em;}
</style>
</head>
<body>
<section id='abstract'>
<p>
<a data-cite="credential-management-1">Credential Management Level 1</a>
describes an imperative API enabling a website to request a user’s
credentials from a user agent, and to help the user agent correctly
store user credentials for future use. User agents implementing that
API prompt the user to select a way to handle a credential request,
after which the user agent returns a credential to the originating
site. This specification defines capabilities that enable third-party
Web applications to handle credential requests and storage.
</p>
</section>
<section id='sotd'>
<p>
The Credentials Community Group maintains <a href=
"https://github.com/w3c-ccg/credential-handler-api/issues">a list of
all bug reports that the group has not yet addressed</a>. 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>
The mission of the Credentials Community Group is to explore the
creation, storage, presentation, verification, and user control of
credentials. Its focus is placed on a verifiable credential (a set of
claims) created by an issuer about a subject: a person, group, or
thing. It seeks solutions inclusive of approaches such as:
self-sovereign identity; presentation of proofs by the bearer; data
minimization; and centralized, federated, and decentralized registry and
identity systems. Therefore, the Credentials Community Group presents
a specification that extends the
<a data-cite="credential-management-1">Credential Management Level 1</a>
API to allow users to designate trusted third party Web applications
as handlers for credential requests and credential storage.
</p>
<p>
A <dfn>credential repository</dfn> is a Web application that can
handle credential requests and credential storage on behalf of the
user. This specification defines a number of new Web platform features
to handle credential requests and credential storage:
</p>
<ul>
<li>An origin-based permission to handle credential request and
credential store events.
</li>
<li>A flexible new <a>Credential</a> (of [[!credential-management-1]])
<a>WebCredential</a>.
</li>
<li>A credential request event type (<a>CredentialRequestEvent</a>) and
a credential store event type (<a>CredentialStoreEvent</a>). A
<dfn>credential handler</dfn> is an event handler for
<a>CredentialRequestEvent</a> and <a>CredentialStoreEvent</a>.
</li>
<li>An extension to the service worker registration interface
(<a>CredentialManager</a>) to manage the definition, display, and user
selection of <a>CredentialHint</a>s.
</li>
<li>A mechanism to respond to CredentialRequestEvent and
CredentialStoreEvent.
</li>
</ul>
<p>
This specification does not address how software built with
operating-system specific mechanisms (e.g., "native mobile apps")
handle credential requests and credential storage.
</p>
</section>
<section id='conformance'>
<p>
This specification defines one class of products:
</p>
<dl>
<dt>
<dfn>Conforming user agent</dfn>
</dt>
<dd>
<p>
A <a>user agent</a> MUST behave as described in this specification
to be considered conformant. In this specification, <dfn>user
agent</dfn> means a <em>Web browser or other interactive user
agent</em> as defined in [[!HTML5]].
</p>
<p>
User agents MAY implement algorithms given in this specification in
any way desired, so long as the end result is indistinguishable
from the result that would be obtained by the specification's
algorithms.
</p>
<p>
A conforming Credential Handler API user agent MUST also be a
<em>conforming implementation</em> of the IDL fragments of this
specification, as described in the “Web IDL” specification.
[[!WEBIDL-LS]]
</p>
<aside class="note">
This specification uses both the terms "conforming user agent(s)"
and "user agent(s)" to refer to this product class.
</aside>
</dd>
</dl>
</section>
<section id="model">
<h2>
Overview of Handling Credential Request and Storage
</h2>
<p>
In this document we envision the following flow for a credential
request:
</p>
<ol>
<li>An origin requests permission from the user to handle credential
request and storage for a set of supported credential types. For
example, a user visiting a digital wallet provider site may be prompted
to register a credential handler from that origin. The origin
establishes the scope of the permission but the origin's capabilities
may evolve without requiring additional user consent.
</li>
<li>
<a>Credential handler</a>s are defined in <a>service worker</a> code.
</li>
<li>During service worker registration, the <a>CredentialManager</a> is
used to set:
<ul>
<li>A list of <a data-lt="CredentialHint.enabledTypes">enabled
WebCredential types</a>.
</li>
<li>[Optionally] the conditions under which the handler supports a
given WebCredential type; these <a data-lt=
"CredentialHint.match">match</a> play a role in matching
computations.
</li>
<li>Information used in the display of <a data-lt=
"CredentialManager.hints">hints</a> supported by the
credential handler.
</li>
</ul>
</li>
<li>There are two entry points for interaction with a credential
handler: when a relying party (aka <dfn>verifier</dfn>) calls the
[[credential-management-1]] method <a>get()</a> (e.g., when the user
pushes a button on a page that requires identity attributes or
authentication) with <a>WebCredentialRequestOptions</a> and
when an <dfn>issuer</dfn> calls the [[credential-management-1]] method
<a>store()</a> (e.g., when the user pushes a button to receive a
credential) with a WebCredential. In both of these cases, the
user agent computes a list of candidate credential hints, comparing
the WebCredential types accepted by the relying party with those
supported by registered credential handlers. For WebCredential types
that support additional filtering, the relying party's specific request
and the match information from each credential hint is compared as part
of determining whether there is compatibility.
</li>
<li>The user agent displays a set of choices to the user: the
registered <a data-lt="CredentialManager.hints">hints</a> of
the candidate credential handlers. The user agent displays these choices
using information (labels and icons) provided at registration or
otherwise available from the Web app.
</li>
<li>When the user selects a <a data-lt=
"CredentialManager.hints">hint</a>, the user agent
<a>fires</a> a <a>CredentialRequestEvent</a> (cf. the <a>user
interaction task source</a>) or a <a>CredentialStoreEvent</a> (depending
on the method called) in the service worker whose <a data-lt=
"ServiceWorkerRegistration.credentialManager">CredentialManager</a> the
hint was registered with. The <a>CredentialRequestEvent</a> includes
the CredentialRequestOptions (defined in [[!credential-management-1]]),
including credential-type-specific options, as well as additional
information (e.g., origin and selected hint).
</li>
<li>Once activated, the credential handler performs whatever steps are
necessary to <a href="#handling-a-credential-request">handle the
credential request</a> or
<a href="#handling-credential-storage">handle credential storage</a>,
and return an appropriate WebCredential to the relying party or issuer.
If interaction with the user is necessary, the <a>credential handler</a>
can open a context-specific window for that purpose.
</li>
<li>The user agent receives a response asynchronously once the
credential handler has finished handling the request. The response
is a WebCredential or null if the request was denied.
</li>
</ol>
<p class="issue" title=
"Which party is responsible for signing Verifiable Profiles?"
data-number="1">
The origin information of the relying party may be blinded when
received via a CredentialRequestEvent.
</p>
<p class="note">
An origin may implement a credential repository with more than one
service worker and therefore multiple <a>credential handler</a>s may
be registered per origin. The handler that is invoked is determined by
the selection made by the user of a
<a data-lt="CredentialManager.hints">credential hint</a>. The
<a>service worker</a> which stored the <a data-lt=
"CredentialManager.hints">credential hint</a> with its
<a data-lt=
"ServiceWorkerRegistration.credentialManager">CredentialManager</a>
is the one that will be invoked.
</p>
<section class="informative" id="handling-a-credential-request">
<h2>
Handling a Credential Request
</h2>
<p>
The logic of a credential handler is driven by the WebCredential
types that it supports. Some WebCredential types may require
very little processing on the part of the credential handler other
than retrieving a WebCredential from its storage and returning it
as a response.
</p>
<p>
In contrast, some Web Credential types, such as
<a>VerifiableProfile</a> include a custom query parameter that
must be understood and processed by the credential handler in order
for it to return an appropriate WebCredential in response. This
may involve presenting a user interface to allow the user to make
selections. In some cases, a credential handler may need to generate
a WebCredential dynamically with the assistance of an issuer or
blinding service. It may also need to generate a zero knowledge proof
or use some other privacy enhancing cryptographic method.
</p>
<p>
Therefore, handling a credential request may include numerous
interactions: with the user through a new contextual window or other
APIs (such as [[!WebCryptoAPI]]) or with other services and origins
through web requests or other means.
</p>
<p>
Once a WebCredential is returned to the relying party website, it is
its job to perform whatever verification is appropriate for its type.
</p>
<p>
This specification does not address the activities that occur
between the credential handler accepting the
<a>CredentialRequestEvent</a> and the credential handler returning a
response. All of the activities which may be required to configure
the credential handler and handle the credential request are left to
the implementation of the credential handler, including:
</p>
<ul>
<li>how the user establishes an account with an origin that provides
credential services.
</li>
<li>how an origin authenticates a user.
</li>
<li>how communication takes place between the credential repository
server and the credential repository Web application, or between a
credential repository origin and other parties.
</li>
</ul>
<p>
Thus, an origin will rely on many other Web technologies defined
elsewhere for lifecycle management, security, user authentication,
user interaction, and so on.
</p>
</section>
<section class="informative" id="handling-credential-storage">
<h2>
Handling Credential Storage
</h2>
<p>
The logic of a credential handler is driven by the WebCredential
types that it supports. Some WebCredential types may require
very little processing on the part of the credential handler other
than storing the WebCredential in a database and returning it
as a response.
</p>
<p>
In contrast, some Web Credential types, such as
<a>VerifiableProfile</a> may include multiple sub-credentials whereby
the user may only elect to store some subset of them, through the use
of a user interface provided by the credential handler.
</p>
<p>
Handling credential storage may include numerous interactions: with
the user through a new contextual window or other APIs (such as
[[!WebCryptoAPI]]) or with other services and origins through web
requests or other means.
</p>
<p>
The WebCredential that is returned to the issuer website provides
information on what was stored by the credential handler, enabling
the issuer website to take whatever next actions are appropriate.
</p>
<p>
This specification does not address the activities that occur
between the credential handler accepting the
<a>CredentialStoreEvent</a> and the credential handler returning a
response. All of the activities which may be required to configure
the credential handler and handle credential storage are
left to the implementation of the credential handler, including:
</p>
<ul>
<li>how the user establishes an account with an origin that provides
credential services.
</li>
<li>how an origin authenticates a user.
</li>
<li>how communication takes place between the credential repository
server and the credential repository Web application, or between a
credential repository origin and other parties.
</li>
</ul>
<p>
Thus, an origin will rely on many other Web technologies defined
elsewhere for lifecycle management, security, user authentication,
user interaction, and so on.
</p>
</section>
<section class="informative">
<h2>
Structure of a Web Credential Repository
</h2>
<figure>
<img alt=
"Architecture of a (Web) credential repository as defined in this specification."
src="web-repository-architecture.png">
<figcaption>
A Web credential repository is associated with an origin.
Credential handlers respond to <a>CredentialRequestEvent</a>s and
<a>CredentialStoreEvent</a>s. <a>CredentialManager</a>s
manage the definition, display, and user selection of
<a>CredentialHint</a>s. A <a>CredentialHint</a> supports one
or more WebCredential types.
</figcaption>
</figure>
</section>
<section class="informative">
<h2>
Relation to Other Types of Credential Repositories
</h2>
<p>
This specification does not address how third-party mobile credential
repository apps interact (through proprietary mechanisms) with user
agents, or how user agents themselves provide simple credential
repository functionality.
</p>
<figure>
<img alt=
"Different types of credential repositories. Credential Handler API
is for Web apps."
src="credential-repository-types.png">
<figcaption>
Credential Handler API enables Web apps to handle credential
management. Other types of credential repository apps may use other
(proprietary) mechanisms.
</figcaption>
</figure>
</section>
</section>
<section id="registration">
<h2>
Registration
</h2>
<section data-dfn-for="ServiceWorkerRegistration" data-link-for=
"ServiceWorkerRegistration">
<h2>
Extension to the <code>ServiceWorkerRegistration</code> interface
</h2>
<p>
This specification extends the <a>ServiceWorkerRegistration</a>
interface with the addition of a <dfn>credentialManager</dfn>
attribute.
</p>
<pre class="idl">
partial interface ServiceWorkerRegistration {
readonly attribute CredentialManager credentialManager;
};
</pre>
</section>
<section data-dfn-for="CredentialManager" data-link-for="CredentialManager">
<h2>
<dfn>CredentialManager</dfn> interface
</h2>
<pre class="idl">
[SecureContext, Exposed=(Window,Worker)]
interface CredentialManager {
[SameObject] readonly attribute CredentialHints hints;
[Exposed=Window] static Promise<PermissionState> requestPermission();
};
</pre>
<p>
The <a>CredentialManager</a> is used by <a>credential repositories</a>
to manage their associated hints and supported WebCredential types.
</p>
<section>
<h2>
<dfn>hints</dfn> attribute
</h2>
<p>
This attribute allows manipulation of credential hints associated
with a service worker (and therefore its credential handler). To be
a candidate credential handler, a handler must have at least one
registered credential hint to present to the user. That instrument
needs to match the WebCredential types and type-specific query
information specified by the credential request.
</p>
</section>
<section>
<h2>
<dfn>requestPermission()</dfn> method
</h2>
<p class="note">
The user agent is NOT REQUIRED to prompt the user to grant
permission to the origin for each new supported WebCredential
type or new credential hint.
</p>
<p>
When called, this method executes the following steps:
</p>
<ol>
<li>Let <var>p</var> be a new promise.
</li>
<li>Return <var>p</var> and perform the remaining steps in
parallel:
</li>
<li>Let <var>permission</var> be the result of running
<a data-cite="!permissions#dfn-retrieve-the-permission-state">retrieve
the permission state algorithm</a> of the permission associated
with <a>credential handler</a>'s <a>origin</a>.
</li>
<li>If <var>permission</var> is "prompt", ask the user whether
allowing adding new credential hints for the <a data-cite=
"!HTML#current-settings-object">current settings object</a>'s
origin is acceptable. If it is, set <var>permission</var> to
"granted", and "denied" otherwise.
</li>
<li>Resolve <var>p</var> with <var>permission</var>.
</li>
</ol>
</section>
</section>
<section data-dfn-for="CredentialHints" data-link-for=
"CredentialHints">
<h2>
<dfn>CredentialHints</dfn> interface
</h2>
<pre class="idl">
[SecureContext, Exposed=(Window,Worker)]
interface CredentialHints {
Promise<boolean> delete(DOMString hintKey);
Promise<CredentialHint> get(DOMString hintKey);
Promise<sequence<DOMString>> keys();
Promise<boolean> has(DOMString hintKey);
Promise<void> set(DOMString hintKey, CredentialHint hint);
Promise<void> clear();
};
</pre>
<p>
The <a>CredentialHints</a> interface represents a collection of
credential hints, each uniquely identified by a <dfn>hintKey</dfn>.
The <var>hintKey</var> identifier will be passed to the credential
handler to indicate the <a>CredentialHint</a> selected by the user. A
<a>CredentialHint</a> is associated with a context or aspect of the
user for which they store certain credentials, similar to a digital
version of a physical wallet.
</p>
<section>
<h2>
<dfn>delete()</dfn> method
</h2>
<p>
When called, this method executes the following steps:
</p>
<ol>
<li>Let <var>p</var> be a new promise.
</li>
<li>Return <var>p</var> and perform the remaining steps in
parallel:
</li>
<li>If the collection contains a <a>CredentialHint</a> with a
matching <var>hintKey</var>, remove it from the collection
and resolve <var>p</var> with <b>true</b>.
</li>
<li>Otherwise, resolve <var>p</var> with <b>false</b>.
</li>
</ol>
</section>
<section>
<h2>
<dfn>get()</dfn> method
</h2>
<p>
When called, this method executes the following steps:
</p>
<ol>
<li>Let <var>p</var> be a new promise.
</li>
<li>Return <var>p</var> and perform the remaining steps in
parallel:
</li>
<li>If the collection contains a <a>CredentialHint</a> with a
matching <var>hintKey</var>, resolve <var>p</var> with that
<a>CredentialHint</a>.
</li>
<li>Otherwise, reject <var>p</var> with a <a>DOMException</a> whose
value is "<a>NotFoundError</a>".
</li>
</ol>
</section>
<section>
<h2>
<dfn>keys()</dfn> method
</h2>
<p>
When called, this method executes the following steps:
</p>
<ol>
<li>Let <var>p</var> be a new promise.
</li>
<li>Return <var>p</var> and perform the remaining steps in
parallel:
</li>
<li>Resolve <var>p</var> with a <dfn>Sequence</dfn> that contains
all the <var>hintKey</var>s for the <a>CredentialHint</a>s
contained in the collection, in original insertion order.
</li>
</ol>
</section>
<section>
<h2>
<dfn>has()</dfn> method
</h2>
<p>
When called, this method executes the following steps:
</p>
<ol>
<li>Let <var>p</var> be a new promise.
</li>
<li>Return <var>p</var> and perform the remaining steps in
parallel:
</li>
<li>If the collection contains a <a>CredentialHint</a> with a
matching <var>hintKey</var>, resolve <var>p</var> with
<b>true</b>.
</li>
<li>Otherwise, resolve <var>p</var> with <b>false</b>.
</li>
</ol>
</section>
<section>
<h2>
<dfn>set()</dfn> method
</h2>
<p>
When called, this method executes the following steps:
</p>
<ol>
<li>Let <var>permission</var> be the result of running
<a data-cite="!permissions#dfn-retrieve-the-permission-state">retrieving
the permission state</a> of the permission associated with
<a>credential handler</a>'s <a>origin</a>.
</li>
<li>If <var>permission</var> is not "granted", then return a
<a>Promise</a> rejected with a <a>NotAllowedError</a>.
</li>
<li>If the <a data-lt="CredentialHint.icons">icons</a> member of
<var>hint</var> is present, then:
<ol>
<li>Let <var>convertedIcons</var> be the result of running the
<a>convert image objects</a> algorithm passing
<var>hint</var>.<a data-lt=
"CredentialHint.icons">icons</a> as the argument.
</li>
<li>If the <var>convertedIcons</var> is an empty
<a>Sequence</a>, then return a <a>Promise</a> rejected with a
<a>TypeError</a>.
</li>
<li>Set <var>hint</var>.<a data-lt=
"CredentialHint.icons">icons</a> to
<var>convertedIcons</var>.
</li>
</ol>
</li>
<li>Let <var>p</var> be a new promise.
</li>
<li>Return <var>p</var> and perform the remaining steps in
parallel:
</li>
<li>If the <a data-lt="CredentialHint.icons">icons</a> member of
<var>hint</var> is present, then for each <var>icon</var> in
<var>hint</var>.<a data-lt="CredentialHint.icons">icons</a>:
<ol>
<li>If the user agent wants to display the <var>icon</var>,
then:
<ol>
<li>Let <var>fetchedImage</var> be the result of running
the <a data-cite=
"!appmanifest#fetching-image-objects">fetching image
object</a> passing <var>icon</var> as the argument.
</li>
<li>Set <var>icon</var>.<a>[[\fetchedImage]]</a> to
<var>fetchedImage</var>.
</li>
</ol>
</li>
</ol>
</li>
<li>If the collection contains a <a>CredentialHint</a> with a
matching <var>hintKey</var>, replace it with the
<a>CredentialHint</a> in <var>hint</var>.
</li>
<li>Otherwise, insert the <a>CredentialHint</a> in
<var>hint</var> as a new member of the collection and associate
it with the key <var>hintKey</var>.
</li>
<li>Resolve <var>p</var>.
</li>
</ol>
</section>
<section>
<h2>
<dfn>clear()</dfn> method
</h2>
<p>
When called, this method executes the following steps:
</p>
<ol>
<li>Let <var>p</var> be a new promise.
</li>
<li>Return <var>p</var> and perform the remaining steps in
parallel:
</li>
<li>Remove all <a>CredentialHint</a>s from the collection and
resolve <var>p</var>.
</li>
</ol>
</section>
<section data-dfn-for="CredentialHint" data-link-for=
"CredentialHint">
<h2>
<dfn>CredentialHint</dfn> dictionary
</h2>
<pre class="idl">
dictionary CredentialHint {
required DOMString name;
sequence<ImageObject> icons;
sequence<DOMString> enabledTypes;
object match;
};
</pre>
<dl>
<dt>
<dfn>name</dfn> member
</dt>
<dd>
The <a>name</a> member is a string that represents the label for
this <a>CredentialHint</a> as it is usually displayed to the
user.
</dd>
<dt>
<dfn>icons</dfn> member
</dt>
<dd>
The <a>icons</a> member is an array of image objects that can
serve as iconic representations of the credential hint when
presented to the user for selection.
</dd>
<dt>
<dfn>enabledTypes</dfn> member
</dt>
<dd>
The <a>enabledTypes</a> member is a list of one or more
<a>WebCredential types</a> of the <a>WebCredential types</a>
supported by this hint.
</dd>
<dt>
<dfn>match</dfn> member
</dt>
<dd>
The <a>match</a> member is a list of WebCredential-type-specific
information that, if present in a credential request or
credential storage request, must match in order for this
credential hint to be considered compatible. For example, for the
<a>VerifiableProfile</a> WebCredential type, this object may
consist of an object with one field <a>VerifiableProfile</a>
that has a value that is another object with one field <a>id</a>
with a string value that is an identifier for an entity for which
VerifiableProfiles may be constructed or stored.
</dd>
</dl>
</section>
<section data-dfn-for="ImageObject" data-link-for="ImageObject">
<h2>
<dfn>ImageObject</dfn> dictionary
</h2>
<pre class="idl">
dictionary ImageObject {
required USVString src;
DOMString sizes;
DOMString type;
};
</pre>
<dl>
<dt>
<dfn>src</dfn> member
</dt>
<dd>
The <a>src</a> member is used to specify the <a>ImageObject</a>'s
source. It is a URL from which the user agent can fetch the
image’s data.
</dd>
<dt>
<dfn>sizes</dfn> member
</dt>
<dd>
The <a>sizes</a> member is used to specify the
<a>ImageObject</a>'s sizes. It follows the spec of sizes member
in <a data-cite="!HTML#the-link-element">HTML link element</a>,
which is a string consisting of an <a data-cite=
"!HTML#unordered-set-of-unique-space-separated-tokens">unordered
set of unique space-separated tokens</a> which are <a data-cite=
"!HTML#ascii-case-insensitive">ASCII case-insensitive</a> that
represents the dimensions of an image. Each keyword is either an
<a data-cite="!HTML#ascii-case-insensitive">ASCII
case-insensitive</a> match for the string "any", or a value that
consists of two valid non-negative integers that do not have a
leading U+0030 DIGIT ZERO (0) character and that are separated by
a single U+0078 LATIN SMALL LETTER X or U+0058 LATIN CAPITAL
LETTER X character. The keywords represent icon sizes in raw
pixels (as opposed to CSS pixels). When multiple image objects
are available, a user agent MAY use the value to decide which
icon is most suitable for a display context (and ignore any that
are inappropriate). The parsing steps for the <a>sizes</a> member
MUST follow <a data-cite="!HTML#attr-link-sizes">the parsing
steps for HTML link element sizes attribute</a>.
</dd>
<dt>
<dfn>type</dfn> member
</dt>
<dd>
The <a>type</a> member is used to specify the
<a>ImageObject</a>'s MIME type. It is a hint as to the media type
of the image. The purpose of this member is to allow a user agent
to ignore images of media types it does not support.
</dd>
</dl>
</section>
<section>
<h2>
<dfn>Convert image objects</dfn>
</h2>
<p>
When this algorithm with <var>inputImages</var> parameter is
invoked, the user agent must run the following steps:
</p>
<ol class="algorithm">
<li>Let <var>outputImages</var> be an empty <a>Sequence</a> of <a>
ImageObject</a>.
</li>
<li>For each <var>image</var> in <var>inputImages</var>:
<ol>
<li>If <var>image</var>.<a data-lt="ImageObject.type">type</a>
is not a <a data-cite="#valid-mime-type">valid MIME type</a> or
the value of type is not a supported media format, then return
an empty <a>Sequence</a> of <a>ImageObject</a>.
</li>
<li>If <var>image</var>.<a data-lt=
"ImageObject.sizes">sizes</a> is not a <a data-lt=
"ImageObject.sizes">valid value</a>, then return an empty
<a>Sequence</a> of <a>ImageObject</a>.
</li>
<li>Let <var>url</var> be the result of parsing
<var>image</var>.<a data-lt="ImageObject.src">src</a> with the
<a data-cite="!HTML#context-object">context object</a>'s
<a data-cite="!HTML#relevant-settings-object">relevant settings
object</a>'s <a data-cite="!HTML#api-base-url">API base
URL</a>.
</li>
<li>If <var>url</var> is failure, then return an empty
<a>Sequence</a> of <a>ImageObject</a>.
</li>
<li>If <var>url</var>'s <a data-cite=
"!HTML#concept-url-scheme">scheme</a> is not "https", then
return an empty <a>Sequence</a> of <a>ImageObject</a>.
</li>
<li>Set <var>image</var>.<a data-lt="ImageObject.src">src</a>
to <var>url</var>.
</li>
<li>Append <var>image</var> to <var>outputImages</var>
</li>
</ol>
</li>
<li>Return <var>outputImages</var>.
</li>
</ol>
<p>
According to the step 2.3, it is also possible to use the relative
url for <var>image</var>.<a data-lt="ImageObject.src">src</a>. The
following examples illustrate how relative URL resolution works in
different execution contexts.
</p>
<pre class="example html" title=
"Resolving the relative URL of image.src in window context.">
<-- In this example, code is located in https://www.example.com/wallet/index.html -->
<script>
const hintKey = "c8126178-3bba-4d09-8f00-0771bcfd3b11";
const { registration } = await navigator.serviceWorker.register("/register/sw.js");
await registration.credentialManager.credentialHints.set({
hintKey,
{
name: "My social account: [email protected]",
enabledTypes: ["VerifiableProfile"],
icons: [{
src: "icon/lowres.webp",
sizes: "48x48",
type: "image/webp"
}],
match: {
VerifiableProfile: {
id: 'did:method1:1234-1234-1234-1234'
}
}
});
const { storedHint } =
await registration.credentialManager.credentialHints.get(hintKey);
// storedHint.icons[0].src == "https://www.example.com/wallet/icon/lowres.webp";
</script>
</pre>
<pre class="example js" title=
"Resolving the relative URL of image.src in service worker context.">
// In this example, code is located in https://www.example.com/register/sw.js
const hintKey = "c8126178-3bba-4d09-8f00-0771bcfd3b11";
await self.registration.credentialManager.credentialHints.set({
hintKey,
{
name: "My social account: [email protected]",
enabledTypes: ["VerifiableProfile"],
icons: [{
src: "../wallet/icon/lowres.webp",
sizes: "48x48",
type: "image/webp"
}],
match: {
VerifiableProfile: {
id: 'did:method1:1234-1234-1234-1234'
}
}
});
const { storedHint } =
await registration.credentialManager.credentialHints.get(hintKey);
// storedHint.icons[0].src == "https://www.example.com/wallet/icon/lowres.webp";
</pre>
</section>
<section id="register-example" class="informative">
<h2>
Registration Example
</h2>
<p>
The following example shows how to register a credential handler:
</p>
<pre class="example js" title="Credential Handler Registration">
button.addEventListener("click", async() => {
if (!window.CredentialManager) {
return; // not supported, so bail out.
}
const result = await CredentialManager.requestPermission();
if (result !== "granted") {
return;
}
const { registration } =
await navigator.serviceWorker.register('/sw.js');
// Excellent, we got it! Let's now set up the user's hints.
await addInstruments(registration);
}, { once: true });
function addHints(registration) {
return Promise.all([
registration.credentialManager.hints.set(
"dc2de27a-ca5e-4fbd-883e-b6ded6c69d4f",
{
name: "My social account: [email protected]",
enabledTypes: ["VerifiableProfile"],
icons: [{
src: "icon/lowres.webp",
sizes: "48x48",
type: "image/webp"
}],
match: {
VerifiableProfile: {
id: 'did:method1:1234-1234-1234-1234'
}
}
}),
registration.credentialManager.hints.set(
"c8126178-3bba-4d09-8f00-0771bcfd3b11",
{
name: "My business account: [email protected]",
enabledTypes: ["VerifiableProfile"],
match: {
VerifiableProfile: {
id: 'did:method1:1234-1234-1234-1235'
}
}
}),
registration.credentialManager.hints.set(
"new-hint",
{
name: "Add a new identity",
enabledTypes: ["VerifiableProfile"]
}),
]);
};
</pre>
</section>
</section>
</section>
<section id="hint-display-ordering">
<h2>
Origin and Hint Display for Selection
</h2>
<!-- TODO continue here -->
<p>
TODO: define matching algorithm here
</p>
<p>
After applying the matching algorithm, the user agent displays the
matching credential hints for the user to make a selection. This
specification includes a limited number of display requirements; most