Skip to content

Commit 13d1709

Browse files
committed
Digital Credentials: implement userAgentAllowsProtocol()
rdar://153776127 https://bugs.webkit.org/show_bug.cgi?id=294352 Reviewed by Anne van Kesteren. This implements the userAgentAllowsProtocol() method, which allows user agents to indicate whether they support a given protocol for digital credentials. This is useful for sites to determine if they can request a digital credential with a specific protocol. Spec: https://w3c-fedid.github.io/digital-credentials/#dom-digitalcredential-useragentallowsprotocol WebKit only supports the "org-iso-mdoc" protocol, so this method returns true only for that protocol. Imports relevent Web Platform Tests. Upstream commit: web-platform-tests/wpt@c7fd2ce Canonical link: https://commits.webkit.org/296786@main
1 parent ba42b51 commit 13d1709

11 files changed

Lines changed: 52 additions & 4 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
PASS Check that the user agent knows about the ISO-18013 Mobile Document protocol.
23
PASS Conversion to ISO-18013 Mobile Document Request.
34
PASS Validation of ISO-18013 Mobile Document Request.
45

LayoutTests/http/wpt/identity/formats/ISO18013/mobiledocument.https.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@
1717
assert_equals(document.visibilityState, "visible", "should be visible");
1818
});
1919

20+
promise_test(async ()=>{
21+
assert_true(
22+
DigitalCredential.userAgentAllowsProtocol("org-iso-mdoc"),
23+
"Check that the user agent allows the ISO-18013 Mobile Document protocol."
24+
);
25+
assert_false(
26+
DigitalCredential.userAgentAllowsProtocol(""),
27+
"Check that the user agent does not allow an empty protocol."
28+
);
29+
assert_false(
30+
DigitalCredential.userAgentAllowsProtocol("org-iso-mdoc-unknown"),
31+
"Check that the user agent does not allow an unknown protocol."
32+
);
33+
}, "Check that the user agent knows about the ISO-18013 Mobile Document protocol.");
34+
2035
promise_test(async (t) => {
2136
const invalidData = [
2237
"",

LayoutTests/http/wpt/identity/idl.https-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ PASS DigitalCredential interface: existence and properties of interface prototyp
8282
PASS DigitalCredential interface: existence and properties of interface prototype object's @@unscopables property
8383
PASS DigitalCredential interface: attribute protocol
8484
PASS DigitalCredential interface: attribute data
85+
PASS DigitalCredential interface: operation userAgentAllowsProtocol(DOMString)
8586

LayoutTests/http/wpt/identity/idl.https.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
interface DigitalCredential : Credential {
2222
readonly attribute DOMString protocol;
2323
readonly attribute Uint8Array data;
24+
static boolean userAgentAllowsProtocol(DOMString protocol);
2425
};
2526
</script>
2627
<script>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
spec: https://github.com/wicg/digital-credentials
1+
spec: https://github.com/w3c-fedid/digital-credentials/
22
suggested_reviewers:
33
- marcoscaceres
44
- samuelgoto
55
- tplooker
66
- pkotwicz
77
- mohamedamir
8+
- timcappalli

LayoutTests/imported/w3c/web-platform-tests/digital-credentials/dc-types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ export type CredentialMediationRequirement =
88
| "silent";
99

1010
/**
11-
* @see https://wicg.github.io/digital-credentials/#dom-digitalcredentialrequest
11+
* @see https://w3c-fedid.github.io/digital-credentials/#dom-digitalcredentialrequest
1212
*/
1313
export interface DigitalCredentialGetRequest {
1414
protocol: string;
1515
data: object;
1616
}
1717

1818
/**
19-
* @see https://wicg.github.io/digital-credentials/#dom-digitalcredentialrequestoptions
19+
* @see https://w3c-fedid.github.io/digital-credentials/#dom-digitalcredentialrequestoptions
2020
*/
2121
export interface DigitalCredentialRequestOptions {
2222
/**
@@ -26,7 +26,7 @@ export interface DigitalCredentialRequestOptions {
2626
}
2727

2828
/**
29-
* @see https://wicg.github.io/digital-credentials/#extensions-to-credentialrequestoptions
29+
* @see https://w3c-fedid.github.io/digital-credentials/#extensions-to-credentialrequestoptions
3030
*/
3131
export interface CredentialRequestOptions {
3232
digital: DigitalCredentialRequestOptions;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
PASS User agent does not allow invalid protocol identifiers.
3+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<title>Tests for DigitalCredential's userAgentAllowsProtocol() static method.</title>
3+
<link rel="help" href="https://github.com/w3c-fedid/digital-credentials/pull/221" />
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
7+
<body></body>
8+
<script type="module">
9+
10+
const invalidIdentifiers = ["", " ", "a b", "a,b", "AB", "a.B", "a.b", " foo-bar", " foo-bar ", "foo-bar ", "fooBar"];
11+
12+
promise_test(async (t) => {
13+
for (const invalidIdentifier of invalidIdentifiers) {
14+
const result = DigitalCredential.userAgentAllowsProtocol(invalidIdentifier);
15+
assert_equals(result, false, `Incorrect result for ${invalidIdentifier}.`);
16+
}
17+
}, "User agent does not allow invalid protocol identifiers.");
18+
19+
</script>

LayoutTests/imported/w3c/web-platform-tests/digital-credentials/w3c-import.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ List of files:
2222
/LayoutTests/imported/w3c/web-platform-tests/digital-credentials/create.tentative.https.html
2323
/LayoutTests/imported/w3c/web-platform-tests/digital-credentials/dc-types.ts
2424
/LayoutTests/imported/w3c/web-platform-tests/digital-credentials/default-permissions-policy.https.sub.html
25+
/LayoutTests/imported/w3c/web-platform-tests/digital-credentials/digital-credential-user-agent-allows-protocol.https.html
2526
/LayoutTests/imported/w3c/web-platform-tests/digital-credentials/digital-credentials-static-methods.tentative.https.html
2627
/LayoutTests/imported/w3c/web-platform-tests/digital-credentials/enabled-on-self-origin-by-permissions-policy.https.sub.html
2728
/LayoutTests/imported/w3c/web-platform-tests/digital-credentials/enabled-on-self-origin-by-permissions-policy.https.sub.html.headers

Source/WebCore/Modules/identity/DigitalCredential.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ class DigitalCredential final : public BasicCredential {
6666

6767
static void discoverFromExternalSource(const Document&, CredentialPromise&&, CredentialRequestOptions&&);
6868

69+
static bool userAgentAllowsProtocol(const String& protocol)
70+
{
71+
return protocol == "org-iso-mdoc"_s;
72+
}
73+
6974
private:
7075
DigitalCredential(JSC::Strong<JSC::JSObject>&&, IdentityCredentialProtocol);
7176

0 commit comments

Comments
 (0)