Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebAuthn] Update getClientCapabilities to use record instead of maplike #22373

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Source/WebCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ set(WebCore_NON_SVG_IDL_FILES
Modules/webauthn/AuthenticatorResponse.idl
Modules/webauthn/AuthenticatorTransport.idl
Modules/webauthn/PublicKeyCredential.idl
Modules/webauthn/PublicKeyCredentialClientCapabilities.idl
Modules/webauthn/PublicKeyCredentialCreationOptions.idl
Modules/webauthn/PublicKeyCredentialDescriptor.idl
Modules/webauthn/PublicKeyCredentialRequestOptions.idl
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/DerivedSources-input.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,6 @@ $(PROJECT_DIR)/Modules/webauthn/AuthenticatorAttestationResponse.idl
$(PROJECT_DIR)/Modules/webauthn/AuthenticatorResponse.idl
$(PROJECT_DIR)/Modules/webauthn/AuthenticatorTransport.idl
$(PROJECT_DIR)/Modules/webauthn/PublicKeyCredential.idl
$(PROJECT_DIR)/Modules/webauthn/PublicKeyCredentialClientCapabilities.idl
$(PROJECT_DIR)/Modules/webauthn/PublicKeyCredentialCreationOptions.idl
$(PROJECT_DIR)/Modules/webauthn/PublicKeyCredentialDescriptor.idl
$(PROJECT_DIR)/Modules/webauthn/PublicKeyCredentialRequestOptions.idl
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/DerivedSources-output.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -2234,8 +2234,6 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPromiseRejectionEvent.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPromiseRejectionEvent.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredential.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredential.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredentialClientCapabilities.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredentialClientCapabilities.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredentialCreationOptions.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredentialCreationOptions.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPublicKeyCredentialDescriptor.cpp
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/DerivedSources.make
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ JS_BINDING_IDLS := \
$(WebCore)/Modules/webauthn/AuthenticatorResponse.idl \
$(WebCore)/Modules/webauthn/AuthenticatorTransport.idl \
$(WebCore)/Modules/webauthn/PublicKeyCredential.idl \
$(WebCore)/Modules/webauthn/PublicKeyCredentialClientCapabilities.idl \
$(WebCore)/Modules/webauthn/PublicKeyCredentialCreationOptions.idl \
$(WebCore)/Modules/webauthn/PublicKeyCredentialDescriptor.idl \
$(WebCore)/Modules/webauthn/PublicKeyCredentialRequestOptions.idl \
Expand Down
6 changes: 2 additions & 4 deletions Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "JSCredentialCreationOptions.h"
#include "JSCredentialRequestOptions.h"
#include "JSDOMPromiseDeferred.h"
#include "JSPublicKeyCredentialClientCapabilities.h"
#include "PublicKeyCredential.h"
#include "PublicKeyCredentialCreationOptions.h"
#include "PublicKeyCredentialRequestOptions.h"
Expand Down Expand Up @@ -311,15 +310,14 @@ void AuthenticatorCoordinator::isConditionalMediationAvailable(const Document& d
m_client->isConditionalMediationAvailable(document.securityOrigin(), WTFMove(completionHandler));
}

void AuthenticatorCoordinator::getClientCapabilities(const Document& document, DOMPromiseDeferred<IDLInterface<PublicKeyCredentialClientCapabilities>>&& promise) const
void AuthenticatorCoordinator::getClientCapabilities(const Document& document, DOMPromiseDeferred<PublicKeyCredentialClientCapabilities>&& promise) const
{
if (!m_client) {
promise.reject(Exception { ExceptionCode::UnknownError, "Unknown internal error."_s });
return;
}

auto completionHandler = [promise = WTFMove(promise)] (HashMap<String, bool>&& resultMap) mutable {
auto result = PublicKeyCredentialClientCapabilities::create(WTFMove(resultMap));
auto completionHandler = [promise = WTFMove(promise)] (const Vector<KeyValuePair<String, bool>> result) mutable {
promise.resolve(result);
};

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AbortSignal;
class AuthenticatorCoordinatorClient;
class BasicCredential;
class Document;
class PublicKeyCredentialClientCapabilities;
typedef IDLRecord<IDLDOMString, IDLBoolean> PublicKeyCredentialClientCapabilities;

struct PublicKeyCredentialCreationOptions;
struct PublicKeyCredentialRequestOptions;
Expand All @@ -68,7 +68,7 @@ class AuthenticatorCoordinator final : public CanMakeWeakPtr<AuthenticatorCoordi
void isUserVerifyingPlatformAuthenticatorAvailable(const Document&, DOMPromiseDeferred<IDLBoolean>&&) const;
void isConditionalMediationAvailable(const Document&, DOMPromiseDeferred<IDLBoolean>&&) const;

void getClientCapabilities(const Document&, DOMPromiseDeferred<IDLInterface<PublicKeyCredentialClientCapabilities>>&&) const;
void getClientCapabilities(const Document&, DOMPromiseDeferred<PublicKeyCredentialClientCapabilities>&&) const;

private:
AuthenticatorCoordinator() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct PublicKeyCredentialCreationOptions;
struct PublicKeyCredentialRequestOptions;
class SecurityOriginData;

using CapabilitiesCompletionHandler = CompletionHandler<void(HashMap<String, bool>&&)>;
using CapabilitiesCompletionHandler = CompletionHandler<void(Vector<KeyValuePair<String, bool>>&&)>;
using RequestCompletionHandler = CompletionHandler<void(WebCore::AuthenticatorResponseData&&, WebCore::AuthenticatorAttachment, WebCore::ExceptionData&&)>;
using QueryCompletionHandler = CompletionHandler<void(bool)>;

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable(Document
page->authenticatorCoordinator().isUserVerifyingPlatformAuthenticatorAvailable(document, WTFMove(promise));
}

void PublicKeyCredential::getClientCapabilities(Document& document, DOMPromiseDeferred<IDLInterface<PublicKeyCredentialClientCapabilities>>&& promise)
void PublicKeyCredential::getClientCapabilities(Document& document, DOMPromiseDeferred<IDLRecord<IDLDOMString, IDLBoolean>>&& promise)
{
if (auto* page = document.page())
page->authenticatorCoordinator().getClientCapabilities(document, WTFMove(promise));
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/Modules/webauthn/PublicKeyCredential.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace WebCore {
enum class AuthenticatorAttachment : uint8_t;
class AuthenticatorResponse;
class Document;
class PublicKeyCredentialClientCapabilities;
typedef IDLRecord<IDLDOMString, IDLBoolean> PublicKeyCredentialClientCapabilities;

struct AuthenticationExtensionsClientOutputs;

Expand All @@ -53,7 +53,7 @@ class PublicKeyCredential final : public BasicCredential {

static void isUserVerifyingPlatformAuthenticatorAvailable(Document&, DOMPromiseDeferred<IDLBoolean>&&);

static void getClientCapabilities(Document&, DOMPromiseDeferred<IDLInterface<PublicKeyCredentialClientCapabilities>>&&);
static void getClientCapabilities(Document&, DOMPromiseDeferred<PublicKeyCredentialClientCapabilities>&&);

private:
PublicKeyCredential(Ref<AuthenticatorResponse>&&);
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/Modules/webauthn/PublicKeyCredential.idl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/

typedef record<DOMString, boolean> PublicKeyCredentialClientCapabilities;

[
Conditional=WEB_AUTHN,
EnabledBySetting=WebAuthenticationEnabled,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions Source/WebCore/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ Modules/webauthn/AuthenticatorAttestationResponse.cpp
Modules/webauthn/AuthenticatorCoordinator.cpp
Modules/webauthn/AuthenticatorResponse.cpp
Modules/webauthn/PublicKeyCredential.cpp
Modules/webauthn/PublicKeyCredentialClientCapabilities.cpp
Modules/webauthn/WebAuthenticationUtils.cpp
Modules/webauthn/apdu/ApduCommand.cpp
Modules/webauthn/apdu/ApduResponse.cpp
Expand Down Expand Up @@ -4018,7 +4017,6 @@ JSProcessingInstruction.cpp
JSProgressEvent.cpp
JSPromiseRejectionEvent.cpp
JSPublicKeyCredential.cpp
JSPublicKeyCredentialClientCapabilities.cpp
JSPublicKeyCredentialCreationOptions.cpp
JSPublicKeyCredentialDescriptor.cpp
JSPublicKeyCredentialRequestOptions.cpp
Expand Down
8 changes: 0 additions & 8 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@
0D44C33E2ABA1B9F0017FB5D /* ThermalMitigationNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8EF8122A9D511F000118F8 /* ThermalMitigationNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
0DFB86682B16CC98009A0A0D /* JSCredentialMediationRequirement.h in Headers */ = {isa = PBXBuildFile; fileRef = 0DFB86642B16CC1E009A0A0D /* JSCredentialMediationRequirement.h */; };
0DFB86792B1A42CB009A0A0D /* JSPublicKeyCredentialClientCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 0DFB86742B1A4237009A0A0D /* JSPublicKeyCredentialClientCapabilities.h */; };
0DFB867A2B1A7130009A0A0D /* PublicKeyCredentialClientCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 0DFB866C2B17F4B6009A0A0D /* PublicKeyCredentialClientCapabilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
0E7058F41BC5CEDA0045A507 /* SearchPopupMenuCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E7058F31BC5CCD70045A507 /* SearchPopupMenuCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
0E9C1157291C18A400A2C2F2 /* ScreenDataOverrides.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E9C1155291BF3CC00A2C2F2 /* ScreenDataOverrides.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F03C0741884695E00A5F8CA /* SystemMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F03C0731884695E00A5F8CA /* SystemMemory.h */; };
Expand Down Expand Up @@ -7062,9 +7061,6 @@
0DD1F6F0291433EB00B79355 /* GPUCanvasContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUCanvasContext.h; sourceTree = "<group>"; };
0DFB86632B16CC1E009A0A0D /* JSCredentialMediationRequirement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSCredentialMediationRequirement.cpp; sourceTree = "<group>"; };
0DFB86642B16CC1E009A0A0D /* JSCredentialMediationRequirement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSCredentialMediationRequirement.h; sourceTree = "<group>"; };
0DFB866C2B17F4B6009A0A0D /* PublicKeyCredentialClientCapabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PublicKeyCredentialClientCapabilities.h; sourceTree = "<group>"; };
0DFB866D2B17F4C7009A0A0D /* PublicKeyCredentialClientCapabilities.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PublicKeyCredentialClientCapabilities.idl; sourceTree = "<group>"; };
0DFB866E2B1953A1009A0A0D /* PublicKeyCredentialClientCapabilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PublicKeyCredentialClientCapabilities.cpp; sourceTree = "<group>"; };
0DFB86742B1A4237009A0A0D /* JSPublicKeyCredentialClientCapabilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredentialClientCapabilities.h; sourceTree = "<group>"; };
0DFB86752B1A4237009A0A0D /* JSPublicKeyCredentialClientCapabilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredentialClientCapabilities.cpp; sourceTree = "<group>"; };
0E7058ED1BC5BC190045A507 /* SearchPopupMenuCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SearchPopupMenuCocoa.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -26213,9 +26209,6 @@
57D8462C1FEAF68F00CA3682 /* PublicKeyCredential.cpp */,
57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */,
57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */,
0DFB866E2B1953A1009A0A0D /* PublicKeyCredentialClientCapabilities.cpp */,
0DFB866C2B17F4B6009A0A0D /* PublicKeyCredentialClientCapabilities.h */,
0DFB866D2B17F4C7009A0A0D /* PublicKeyCredentialClientCapabilities.idl */,
57303BE62009747A00355965 /* PublicKeyCredentialCreationOptions.h */,
57303BE82009747A00355965 /* PublicKeyCredentialCreationOptions.idl */,
57303BEC200980BF00355965 /* PublicKeyCredentialDescriptor.h */,
Expand Down Expand Up @@ -41069,7 +41062,6 @@
E45A6C772417BA59006E4CD5 /* PseudoClassChangeInvalidation.h in Headers */,
FF945ECC161F7F3600971BC8 /* PseudoElement.h in Headers */,
57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */,
0DFB867A2B1A7130009A0A0D /* PublicKeyCredentialClientCapabilities.h in Headers */,
57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */,
57303BEF200980C600355965 /* PublicKeyCredentialDescriptor.h in Headers */,
57303C0A20099BAD00355965 /* PublicKeyCredentialRequestOptions.h in Headers */,
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/Scripts/webkit/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ def class_template_headers(template_string):
'Expected': {'headers': ['<wtf/Expected.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'HashMap': {'headers': ['<wtf/HashMap.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'HashSet': {'headers': ['<wtf/HashSet.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'KeyValuePair': {'headers': ['<wtf/KeyValuePair.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'OptionSet': {'headers': ['<wtf/OptionSet.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'Vector': {'headers': ['<wtf/Vector.h>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
'std::optional': {'headers': ['<optional>'], 'argument_coder_headers': ['"ArgumentCoders.h"']},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,21 +862,21 @@ static inline bool canCurrentProcessAccessPasskeysForRelyingParty(const WebCore:
handler(false);
}

void WebAuthenticatorCoordinatorProxy::getClientCapabilities(const WebCore::SecurityOriginData& originData, CapbilitiesCompletionHandler&& handler)
void WebAuthenticatorCoordinatorProxy::getClientCapabilities(const WebCore::SecurityOriginData& originData, CapabilitiesCompletionHandler&& handler)
{
if (![getASCWebKitSPISupportClass() respondsToSelector:@selector(getClientCapabilitiesForRelyingParty:withCompletionHandler:)]) {
HashMap<String, bool> resultMap;
handler(resultMap);
Vector<KeyValuePair<String, bool>> capabilities;
handler(WTFMove(capabilities));
return;
}

[getASCWebKitSPISupportClass() getClientCapabilitiesForRelyingParty:originData.securityOrigin()->domain() withCompletionHandler:makeBlockPtr([handler = WTFMove(handler)](NSDictionary<NSString *, NSNumber *> *result) mutable {
HashMap<String, bool> resultMap;
Vector<KeyValuePair<String, bool>> capabilities;
for (NSString *key in result)
resultMap.set(key, result[key].boolValue);
capabilities.append({ key, result[key].boolValue });

ensureOnMainRunLoop([handler = WTFMove(handler), resultMap = WTFMove(resultMap)] () mutable {
handler(resultMap);
ensureOnMainRunLoop([handler = WTFMove(handler), capabilities = WTFMove(capabilities)] () mutable {
handler(WTFMove(capabilities));
});
}).get()];
}
Expand Down
Loading