Skip to content

Commit

Permalink
Digital Credentials API: IdentityRequestProvider is now called Digita…
Browse files Browse the repository at this point in the history
…lCredentialRequest

https://bugs.webkit.org/show_bug.cgi?id=279932
rdar://136714198

Reviewed by Abrar Rahman Protyasha and Alex Christensen.

Rename IdentityRequestProvider to DigitalCredentialRequest and related classes.
Also update the tests and the IDL file to use `.requests` instead of `.providers`.

See spec change:
WICG/digital-credentials#165

* LayoutTests/http/wpt/identity/identitycredentialscontainer-get-basics.https.html:
* LayoutTests/http/wpt/identity/identitycredentialscontainer-get-hidden.https.html:
* LayoutTests/http/wpt/identity/idl.https.html:
* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/allow-attribute.https.html:
* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/dc-types.ts:
* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/disabled-by-permissions-policy.https.sub-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/identity-get.tentative.https-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/identity-get.tentative.https.html:
* LayoutTests/imported/w3c/web-platform-tests/digital-credentials/support/helper.js:
(export.makeGetOptions):
(makeDigitalCredentialRequest):
(makeIdentityRequestProvider): Deleted.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/digital-credentials/disabled-by-permissions-policy.https.sub-expected.txt:
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/digital-credentials/identity-get.tentative.https-expected.txt:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Modules/identity/DigitalCredentialRequest.h: Renamed from Source/WebCore/Modules/identity/IdentityRequestProvider.h.
* Source/WebCore/Modules/identity/DigitalCredentialRequest.idl: Renamed from Source/WebCore/Modules/identity/IdentityRequestProvider.idl.
* Source/WebCore/Modules/identity/DigitalCredentialRequestOptions.h:
* Source/WebCore/Modules/identity/DigitalCredentialRequestOptions.idl:
* Source/WebCore/Modules/identity/IdentityCredentialsContainer.cpp:
(WebCore::IdentityCredentialsContainer::get):
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/288717@main
  • Loading branch information
marcoscaceres committed Jan 10, 2025
1 parent ca99c16 commit f4b9434
Show file tree
Hide file tree
Showing 24 changed files with 74 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@
await promise_rejects_js(
t,
TypeError,
navigator.identity.get({ digital: { providers: [] } }),
"navigator.identity.get() with an empty list of providers"
navigator.identity.get({ digital: { requests: [] } }),
"navigator.identity.get() with an empty list of requests"
);

await test_driver.bless();
await promise_rejects_js(
t,
TypeError,
navigator.identity.get({
digital: { providers: [{ protocol: "bogus protocol", request: {} }] },
digital: { requests: [{ protocol: "bogus protocol", request: {} }] },
}),
"navigator.identity.get() with a provider with unknown protocol"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

const p = navigator.identity.get({
digital: {
providers: [],
requests: [],
},
mediation: "required",
});
Expand Down
4 changes: 2 additions & 2 deletions LayoutTests/http/wpt/identity/idl.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
};

dictionary DigitalCredentialRequestOptions {
sequence<IdentityRequestProvider> providers;
sequence<DigitalCredentialRequest> requests;
};

dictionary IdentityRequestProvider {
dictionary DigitalCredentialRequest {
required DOMString protocol;
required object request;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
const options = {
digital: {
// Results in TypeError when allowed, NotAllowedError when disallowed
providers: [],
requests: [],
},
mediation: "required",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export type CredentialMediationRequirement =
| "silent";

/**
* @see https://wicg.github.io/digital-credentials/#dom-identityrequestprovider
* @see https://wicg.github.io/digital-credentials/#the-digitalcredentialrequest-dictionary
*/
export interface IdentityRequestProvider {
export interface DigitalCredentialRequest {
protocol: string;
data: object;
}
Expand All @@ -18,9 +18,9 @@ export interface IdentityRequestProvider {
*/
export interface DigitalCredentialRequestOptions {
/**
* The list of identity request providers
* The list of identity requests.
*/
providers: IdentityRequestProvider[] | any;
requests: DigitalCredentialRequest[] | any;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


FAIL Permissions-Policy header digital-credentials-get=() disallows the top-level document. promise_rejects_dom: function "function() { throw e }" threw object "TypeError: At least one provider must be specified." that is not a DOMException NotAllowedError: property "code" is equal to undefined, expected 0
FAIL Permissions-Policy header digital-credentials-get=() disallows the top-level document. promise_rejects_dom: function "function() { throw e }" threw object "TypeError: At least one request must present." that is not a DOMException NotAllowedError: property "code" is equal to undefined, expected 0
FAIL Permissions-Policy header digital-credentials-get=() disallows same-origin iframes. assert_false: Digital Credential API expected false got true
FAIL Header-set policy is overridden in cross-origin iframe using allow attribute. assert_true: Digital Credential API expected true got false
FAIL Setting digital-credentials-get=(self) disallows the API in same-origin iframes. assert_false: Digital Credential API expected false got true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@


PASS Calling navigator.identity.get() without an digital member same origin.
PASS navigator.identity.get() API rejects if there are no providers.
PASS navigator.identity.get() API rejects if there are no providers for same-origin iframe.
FAIL navigator.identity.get() API rejects if there are no providers in cross-origin iframe. assert_equals: expected "TypeError" but got "DOMException"
PASS navigator.identity.get() API rejects if there are no requests.
PASS navigator.identity.get() API rejects if there are no requests for same-origin iframe.
FAIL navigator.identity.get() API rejects if there are no requests in cross-origin iframe. assert_equals: expected "TypeError" but got "DOMException"
PASS navigator.identity.get() promise is rejected if called with an aborted signal.
PASS navigator.identity.get() promise is rejected if called with an aborted signal in same-origin iframe.
PASS navigator.identity.get() promise is rejected if called with an aborted signal in cross-origin iframe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,38 @@
}, "Calling navigator.identity.get() without an digital member same origin.");

promise_test(async (t) => {
for (const provider of [undefined, []]) {
const options = makeGetOptions(provider);
for (const request of [undefined, []]) {
const options = makeGetOptions(request);
await test_driver.bless("user activation");
await promise_rejects_js(t, TypeError, navigator.identity.get(options));
}
}, "navigator.identity.get() API rejects if there are no providers.");
}, "navigator.identity.get() API rejects if there are no requests.");

promise_test(async (t) => {
iframeSameOrigin.focus();
const { contentWindow: iframeWindow } = iframeSameOrigin;
for (const provider of [undefined, []]) {
const options = makeGetOptions(provider);
for (const request of [undefined, []]) {
const options = makeGetOptions(request);
await test_driver.bless("user activation");
await promise_rejects_js(
t,
iframeWindow.TypeError,
iframeWindow.navigator.identity.get(options)
);
}
}, "navigator.identity.get() API rejects if there are no providers for same-origin iframe.");
}, "navigator.identity.get() API rejects if there are no requests for same-origin iframe.");

promise_test(async (t) => {
iframeCrossOrigin.focus();
for (const provider of [undefined, []]) {
const options = makeGetOptions(provider);
for (const request of [undefined, []]) {
const options = makeGetOptions(request);
const result = await sendMessage(iframeCrossOrigin, {
action: "get",
options,
});
assert_equals(result.constructor, "TypeError");
}
}, "navigator.identity.get() API rejects if there are no providers in cross-origin iframe.");
}, "navigator.identity.get() API rejects if there are no requests in cross-origin iframe.");

promise_test(async (t) => {
const abortController = new AbortController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,63 @@
// Import the types from the TypeScript file
/**
* @typedef {import('../dc-types').ProviderType} ProviderType
* @typedef {import('../dc-types').IdentityRequestProvider} IdentityRequestProvider
* @typedef {import('../dc-types').DigitalCredentialRequest} DigitalCredentialRequest
* @typedef {import('../dc-types').DigitalCredentialRequestOptions} DigitalCredentialRequestOptions
* @typedef {import('../dc-types').CredentialRequestOptions} CredentialRequestOptions
* @typedef {import('../dc-types').SendMessageData} SendMessageData
*/
/**
* @param {ProviderType | ProviderType[]} [providersToUse=["default"]]
* @param {ProviderType | ProviderType[]} [requestsToUse=["default"]]
* @param {CredentialMediationRequirement} [mediation="required"]
* @returns {CredentialRequestOptions}
*/
export function makeGetOptions(providersToUse = ["default"], mediation = "required") {
if (typeof providersToUse === "string") {
if (providersToUse === "default" || providersToUse === "openid4vp"){
return makeGetOptions([providersToUse]);
export function makeGetOptions(
requestsToUse = ["default"],
mediation = "required"
) {
if (typeof requestsToUse === "string") {
if (requestsToUse === "default" || requestsToUse === "openid4vp") {
return makeGetOptions([requestsToUse]);
}
}
if (!Array.isArray(providersToUse) || !providersToUse?.length) {
return { digital: { providers: providersToUse }, mediation };
if (!Array.isArray(requestsToUse) || !requestsToUse?.length) {
return { digital: { requests: requestsToUse }, mediation };
}
const providers = [];
for (const provider of providersToUse) {
switch (provider) {
const requests = [];
for (const request of requestsToUse) {
switch (request) {
case "openid4vp":
providers.push(makeOID4VPDict());
requests.push(makeOID4VPDict());
break;
case "default":
providers.push(makeIdentityRequestProvider(undefined, undefined));
requests.push(makeDigitalCredentialRequest(undefined, undefined));
break;
default:
throw new Error(`Unknown provider type: ${provider}`);
throw new Error(`Unknown request type: ${request}`);
}
}
return { digital: { providers }, mediation };
return { digital: { requests }, mediation };
}
/**
*
* @param {string} protocol
* @param {object} data
* @returns {IdentityRequestProvider}
* @returns {DigitalCredentialRequest}
*/
function makeIdentityRequestProvider(protocol = "protocol", data = {}) {
function makeDigitalCredentialRequest(protocol = "protocol", data = {}) {
return {
protocol,
data,
};
}

/**
* Representation of a digital identity object with an OpenID4VP provider.
* Representation of a digital identity object with an OpenID4VP request.
*
* @returns {IdentityRequestProvider}
* @returns {DigitalCredentialRequest}
**/
function makeOID4VPDict() {
return makeIdentityRequestProvider("openid4vp", {
return makeDigitalCredentialRequest("openid4vp", {
// Canonical example of an OpenID4VP request coming soon.
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


FAIL Permissions-Policy header digital-credentials-get=() disallows the top-level document. promise_rejects_dom: function "function() { throw e }" threw object "TypeError: At least one provider must be specified." that is not a DOMException NotAllowedError: property "code" is equal to undefined, expected 0
FAIL Permissions-Policy header digital-credentials-get=() disallows the top-level document. promise_rejects_dom: function "function() { throw e }" threw object "TypeError: At least one request must present." that is not a DOMException NotAllowedError: property "code" is equal to undefined, expected 0
FAIL Permissions-Policy header digital-credentials-get=() disallows same-origin iframes. assert_false: Digital Credential API expected false got true
FAIL Header-set policy is overridden in cross-origin iframe using allow attribute. assert_true: Digital Credential API expected true got false
PASS Setting digital-credentials-get=(self) disallows the API in same-origin iframes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@


PASS Calling navigator.identity.get() without an digital member same origin.
PASS navigator.identity.get() API rejects if there are no providers.
FAIL navigator.identity.get() API rejects if there are no providers for same-origin iframe. promise_rejects_js: function "function() { throw e }" threw object "NotAllowedError: The document is not focused." ("NotAllowedError") expected instance of function "function TypeError() {
PASS navigator.identity.get() API rejects if there are no requests.
FAIL navigator.identity.get() API rejects if there are no requests for same-origin iframe. promise_rejects_js: function "function() { throw e }" threw object "NotAllowedError: The document is not focused." ("NotAllowedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL navigator.identity.get() API rejects if there are no providers in cross-origin iframe. assert_equals: expected "TypeError" but got "DOMException"
FAIL navigator.identity.get() API rejects if there are no requests in cross-origin iframe. assert_equals: expected "TypeError" but got "DOMException"
PASS navigator.identity.get() promise is rejected if called with an aborted signal.
PASS navigator.identity.get() promise is rejected if called with an aborted signal in same-origin iframe.
PASS navigator.identity.get() promise is rejected if called with an aborted signal in cross-origin iframe.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ set(WebCore_NON_SVG_IDL_FILES
Modules/highlight/HighlightRegistry.idl

Modules/identity/DigitalCredential.idl
Modules/identity/DigitalCredentialRequest.idl
Modules/identity/DigitalCredentialRequestOptions.idl
Modules/identity/IdentityCredentialProtocol.idl
Modules/identity/IdentityRequestProvider.idl
Modules/identity/Navigator+Identity.idl
Modules/identity/OpenID4VPRequest.idl

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/DerivedSources-input.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,9 @@ $(PROJECT_DIR)/Modules/geolocation/PositionOptions.idl
$(PROJECT_DIR)/Modules/highlight/Highlight.idl
$(PROJECT_DIR)/Modules/highlight/HighlightRegistry.idl
$(PROJECT_DIR)/Modules/identity/DigitalCredential.idl
$(PROJECT_DIR)/Modules/identity/DigitalCredentialRequest.idl
$(PROJECT_DIR)/Modules/identity/DigitalCredentialRequestOptions.idl
$(PROJECT_DIR)/Modules/identity/IdentityCredentialProtocol.idl
$(PROJECT_DIR)/Modules/identity/IdentityRequestProvider.idl
$(PROJECT_DIR)/Modules/identity/Navigator+Identity.idl
$(PROJECT_DIR)/Modules/identity/OpenID4VPRequest.idl
$(PROJECT_DIR)/Modules/indexeddb/IDBCursor.idl
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/DerivedSources-output.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionPermissi
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionPermissionState.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDigitalCredential.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDigitalCredential.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDigitalCredentialRequest.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDigitalCredentialRequest.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDigitalCredentialRequestOptions.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDigitalCredentialRequestOptions.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDistanceModelType.cpp
Expand Down Expand Up @@ -1691,8 +1693,6 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIIRFilterOptions.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIIRFilterOptions.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIdentityCredentialProtocol.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIdentityCredentialProtocol.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIdentityRequestProvider.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIdentityRequestProvider.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIdleDeadline.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIdleDeadline.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSIdleRequestCallback.cpp
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/DerivedSources.make
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ JS_BINDING_IDLS := \
$(WebCore)/Modules/highlight/HighlightRegistry.idl \
$(WebCore)/Modules/highlight/Highlight.idl \
$(WebCore)/Modules/identity/DigitalCredential.idl \
$(WebCore)/Modules/identity/DigitalCredentialRequest.idl \
$(WebCore)/Modules/identity/DigitalCredentialRequestOptions.idl \
$(WebCore)/Modules/identity/OpenID4VPRequest.idl \
$(WebCore)/Modules/identity/IdentityCredentialProtocol.idl \
$(WebCore)/Modules/identity/IdentityRequestProvider.idl \
$(WebCore)/Modules/identity/Navigator+Identity.idl \
$(WebCore)/Modules/indexeddb/IDBCursor.idl \
$(WebCore)/Modules/indexeddb/IDBCursorDirection.idl \
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/Headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS

Modules/identity/CredentialRequestCoordinator.h
Modules/identity/CredentialRequestCoordinatorClient.h
Modules/identity/DigitalCredentialRequest.h
Modules/identity/DigitalCredentialRequestOptions.h
Modules/identity/IdentityCredentialsContainer.h
Modules/identity/IdentityRequestProvider.h
Modules/identity/OpenID4VPRequest.h

Modules/indexeddb/IDBActiveDOMObject.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace WebCore {

struct IdentityRequestProvider {
struct DigitalCredentialRequest {
IdentityCredentialProtocol protocol;
OpenID4VPRequest data;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

dictionary IdentityRequestProvider {
dictionary DigitalCredentialRequest {
required IdentityCredentialProtocol protocol;
required OpenID4VPRequest data;
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@

#pragma once

#include "IdentityRequestProvider.h"
#include "DigitalCredentialRequest.h"
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>

namespace WebCore {

struct IdentityRequestProvider;
struct DigitalCredentialRequest;

struct DigitalCredentialRequestOptions {
Vector<IdentityRequestProvider> providers;
Vector<DigitalCredentialRequest> requests;
};

} // namespace WebCore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
*/

dictionary DigitalCredentialRequestOptions {
required sequence<IdentityRequestProvider> providers;
required sequence<DigitalCredentialRequest> requests;
};
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ void IdentityCredentialsContainer::get(CredentialRequestOptions&& options, Crede
return;
}

if (options.digital->providers.isEmpty()) {
promise.reject(Exception { ExceptionCode::TypeError, "At least one provider must be specified."_s });
if (options.digital->requests.isEmpty()) {
promise.reject(Exception { ExceptionCode::TypeError, "At least one request must present."_s });
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3746,6 +3746,7 @@ JSDeviceMotionEvent.cpp
JSDeviceOrientationEvent.cpp
JSDeviceOrientationOrMotionPermissionState.cpp
JSDigitalCredential.cpp
JSDigitalCredentialRequest.cpp
JSDigitalCredentialRequestOptions.cpp
JSDistanceModelType.cpp
JSDocument.cpp
Expand Down Expand Up @@ -4101,7 +4102,6 @@ JSIDBTransactionDurability.cpp
JSIDBTransactionMode.cpp
JSIDBVersionChangeEvent.cpp
JSIdentityCredentialProtocol.cpp
JSIdentityRequestProvider.cpp
JSIdleDeadline.cpp
JSIdleRequestCallback.cpp
JSIdleRequestOptions.cpp
Expand Down
Loading

0 comments on commit f4b9434

Please sign in to comment.