[WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Sep 2018 07:59:20 +0000 (07:59 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Sep 2018 07:59:20 +0000 (07:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189277
<rdar://problem/44115936>

Reviewed by Chris Dumez.

Source/WebCore:

This patch aims to polish AuthenticatorManager such that:
1) It is no longer a singleton. Instead, it will live with Page. It was a singleton simply because static
PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable() have to access it. However, this request
can be fulfilled by adding an attribute [CallWith=Document] to the IDL defination. Therefore, there is no
such need. Also, the singleton is illy implemented as it owns a single IPC proxy to UI Process which means
different web pages will talk to the same web page proxy. Anyway, making it live with Page should fix everything.
2) Since we are now planning to support external authenticators, the manager of all authenticators will then
have to live in UI Process which makes this AuthenticatorManager obsolete. Instead, rename it to AuthenticatorCoordinator.
3) Rename CredentialsMessenger to AuthenticatorCoordinatorClient to tight it to WebAuthN. Also, simplify the
message reply model as PublicKeyCredentialCreationOptions/PublicKeyCredentialRequestOptions =>
ExceptionData/PublicKeyCredentialData for makeCredential/getAssertion operations.
4) Restrict one request per time, i.e. makeCredential/getAssertion for a single page.
5) Unifying makeCredentialReply/getAssertionReply/exceptionReply into requestReply for IPC. Correspondingly,
unify callback and exceptionCallback into callback as well for LocalAuthenticator.
6) Enhance PublicKeyCredentialCreationOptions encoding/decoding with encoder.encodeFixedLengthData/decoder.decodeFixedLengthData.

Covered by existing tests.

* DerivedSources.make:
* Modules/credentialmanagement/CredentialsContainer.cpp:
(WebCore::CredentialsContainer::get):
(WebCore::CredentialsContainer::isCreate):
* Modules/credentialmanagement/CredentialsContainer.h:
* Modules/credentialmanagement/CredentialsMessenger.cpp: Removed.
* Modules/credentialmanagement/CredentialsMessenger.h: Removed.
* Modules/webauthn/AuthenticatorAssertionResponse.cpp: Removed.
* Modules/webauthn/AuthenticatorAssertionResponse.h:
(WebCore::AuthenticatorAssertionResponse::create):
(WebCore::AuthenticatorAssertionResponse::authenticatorData const):
(WebCore::AuthenticatorAssertionResponse::signature const):
(WebCore::AuthenticatorAssertionResponse::userHandle const):
(WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse):
* Modules/webauthn/AuthenticatorAttestationResponse.cpp: Removed.
* Modules/webauthn/AuthenticatorAttestationResponse.h:
(WebCore::AuthenticatorAttestationResponse::create):
(WebCore::AuthenticatorAttestationResponse::attestationObject const):
(WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse):
* Modules/webauthn/AuthenticatorCoordinator.cpp: Renamed from Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp.
(WebCore::AuthenticatorCoordinatorInternal::produceClientDataJson):
(WebCore::AuthenticatorCoordinatorInternal::produceClientDataJsonHash):
(WebCore::AuthenticatorCoordinatorInternal::initTimeoutTimer):
(WebCore::AuthenticatorCoordinatorInternal::didTimeoutTimerFire):
(WebCore::AuthenticatorCoordinator::AuthenticatorCoordinator):
(WebCore::AuthenticatorCoordinator::setClient):
(WebCore::AuthenticatorCoordinator::create const):
(WebCore::AuthenticatorCoordinator::discoverFromExternalSource const):
(WebCore::AuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable const):
* Modules/webauthn/AuthenticatorCoordinator.h: Renamed from Source/WebCore/Modules/webauthn/AuthenticatorManager.h.
* Modules/webauthn/AuthenticatorCoordinatorClient.cpp: Added.
(WebCore::AuthenticatorCoordinatorClient::~AuthenticatorCoordinatorClient):
(WebCore::AuthenticatorCoordinatorClient::requestReply):
(WebCore::AuthenticatorCoordinatorClient::isUserVerifyingPlatformAuthenticatorAvailableReply):
(WebCore::AuthenticatorCoordinatorClient::setRequestCompletionHandler):
(WebCore::AuthenticatorCoordinatorClient::addQueryCompletionHandler):
* Modules/webauthn/AuthenticatorCoordinatorClient.h: Copied from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h.
* Modules/webauthn/AuthenticatorResponse.cpp: Removed.
* Modules/webauthn/AuthenticatorResponse.h:
(WebCore::AuthenticatorResponse::AuthenticatorResponse):
(WebCore::AuthenticatorResponse::clientDataJSON const):
* Modules/webauthn/PublicKeyCredential.cpp:
(WebCore::PublicKeyCredential::create):
(WebCore::PublicKeyCredential::tryCreate):
(WebCore::PublicKeyCredential::PublicKeyCredential):
(WebCore::PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable):
* Modules/webauthn/PublicKeyCredential.h:
* Modules/webauthn/PublicKeyCredential.idl:
* Modules/webauthn/PublicKeyCredentialCreationOptions.h:
(WebCore::PublicKeyCredentialCreationOptions::encode const):
(WebCore::PublicKeyCredentialCreationOptions::decode):
* Modules/webauthn/PublicKeyCredentialData.h: Added.
(WebCore::PublicKeyCredentialData::encode const):
(WebCore::PublicKeyCredentialData::decode):
* Modules/webauthn/cocoa/LocalAuthenticator.h:
* Modules/webauthn/cocoa/LocalAuthenticator.mm:
(WebCore::LocalAuthenticator::makeCredential):
(WebCore::LocalAuthenticator::getAssertion):
* Modules/webvr/VRStageParameters.cpp:
Add a header file to prevent linkage error.
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* page/Page.cpp:
* page/Page.h:
(WebCore::Page::authenticatorCoordinator const):
* page/PageConfiguration.cpp:
* page/PageConfiguration.h:
* testing/Internals.cpp:
(WebCore::Internals::Internals):
(WebCore::Internals::mockAuthenticatorCoordinator const):
(WebCore::Internals::mockCredentialsMessenger const): Deleted.
* testing/Internals.h:
* testing/Internals.idl:
* testing/MockAuthenticatorCoordinator.cpp: Added.
(WebCore::MockAuthenticatorCoordinator::setCreationReturnBundle):
(WebCore::MockAuthenticatorCoordinator::setAssertionReturnBundle):
(WebCore::MockAuthenticatorCoordinator::makeCredential):
(WebCore::MockAuthenticatorCoordinator::getAssertion):
(WebCore::MockAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
* testing/MockAuthenticatorCoordinator.h: Renamed from Source/WebCore/testing/MockCredentialsMessenger.h.
* testing/MockAuthenticatorCoordinator.idl: Renamed from Source/WebCore/testing/MockCredentialsMessenger.idl.
* testing/MockCredentialsMessenger.cpp: Removed.

Source/WebKit:

* DerivedSources.make:
* SourcesCocoa.txt:
* UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: Removed.
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp: Added.
(WebKit::WebAuthenticatorCoordinatorProxy::WebAuthenticatorCoordinatorProxy):
(WebKit::WebAuthenticatorCoordinatorProxy::~WebAuthenticatorCoordinatorProxy):
(WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
(WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
(WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
(WebKit::WebAuthenticatorCoordinatorProxy::requestReply):
(WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailableReply):
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h: Renamed from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h.
* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in: Renamed from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in.
* UIProcess/WebPageProxy.cpp:
(WebKit::m_resetRecentCrashCountTimer):
(WebKit::WebPageProxy::reattachToWebProcess):
* UIProcess/WebPageProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/CredentialManagement/WebCredentialsMessenger.cpp: Removed.
* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp: Added.
(WebKit::WebAuthenticatorCoordinator::WebAuthenticatorCoordinator):
(WebKit::WebAuthenticatorCoordinator::~WebAuthenticatorCoordinator):
(WebKit::WebAuthenticatorCoordinator::makeCredential):
(WebKit::WebAuthenticatorCoordinator::getAssertion):
(WebKit::WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h: Renamed from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h.
* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in: Renamed from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_cpuLimit):
(WebKit::m_credentialsMessenger): Deleted.
* WebProcess/WebPage/WebPage.h:

Tools:

* TestWebKitAPI/Tests/ios/LocalAuthenticator.mm:
(TestWebKitAPI::TEST):

LayoutTests:

* http/wpt/credential-management/credentialscontainer-store-basics.https.html:
* http/wpt/webauthn/idl.https.html:
* http/wpt/webauthn/public-key-credential-create-failure.https.html:
* http/wpt/webauthn/public-key-credential-create-success.https.html:
* http/wpt/webauthn/public-key-credential-get-failure.https.html:
* http/wpt/webauthn/public-key-credential-get-success.https.html:
* http/wpt/webauthn/public-key-is-user-verifying-platform-authenticator-available.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235888 268f45cc-cd09-0410-ab3c-d52691b4dbfc

63 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/credential-management/credentialscontainer-store-basics.https.html
LayoutTests/http/wpt/webauthn/idl.https.html
LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html
LayoutTests/http/wpt/webauthn/public-key-credential-create-success.https.html
LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html
LayoutTests/http/wpt/webauthn/public-key-credential-get-success.https.html
LayoutTests/http/wpt/webauthn/public-key-is-user-verifying-platform-authenticator-available.html
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp
Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h
Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.cpp [deleted file]
Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.cpp [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h
Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h
Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp [moved from Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp with 79% similarity]
Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h [moved from Source/WebCore/Modules/webauthn/AuthenticatorManager.h with 84% similarity]
Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.cpp [new file with mode: 0644]
Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h [new file with mode: 0644]
Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp [deleted file]
Source/WebCore/Modules/webauthn/AuthenticatorResponse.h
Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp
Source/WebCore/Modules/webauthn/PublicKeyCredential.h
Source/WebCore/Modules/webauthn/PublicKeyCredential.idl
Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h
Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h [new file with mode: 0644]
Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h
Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm
Source/WebCore/Modules/webvr/VRStageParameters.cpp
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/PageConfiguration.cpp
Source/WebCore/page/PageConfiguration.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebCore/testing/MockAuthenticatorCoordinator.cpp [new file with mode: 0644]
Source/WebCore/testing/MockAuthenticatorCoordinator.h [moved from Source/WebCore/testing/MockCredentialsMessenger.h with 68% similarity]
Source/WebCore/testing/MockAuthenticatorCoordinator.idl [moved from Source/WebCore/testing/MockCredentialsMessenger.idl with 97% similarity]
Source/WebCore/testing/MockCredentialsMessenger.cpp [deleted file]
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources.make
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp [deleted file]
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp [new file with mode: 0644]
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h [moved from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h with 70% similarity]
Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in [moved from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in with 83% similarity]
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp [deleted file]
Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp [new file with mode: 0644]
Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h [moved from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h with 71% similarity]
Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in [moved from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in with 78% similarity]
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm

index 083fd48..544e553 100644 (file)
@@ -1,3 +1,19 @@
+2018-09-11  Jiewen Tan  <jiewen_tan@apple.com>
+
+        [WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=189277
+        <rdar://problem/44115936>
+
+        Reviewed by Chris Dumez.
+
+        * http/wpt/credential-management/credentialscontainer-store-basics.https.html:
+        * http/wpt/webauthn/idl.https.html:
+        * http/wpt/webauthn/public-key-credential-create-failure.https.html:
+        * http/wpt/webauthn/public-key-credential-create-success.https.html:
+        * http/wpt/webauthn/public-key-credential-get-failure.https.html:
+        * http/wpt/webauthn/public-key-credential-get-success.https.html:
+        * http/wpt/webauthn/public-key-is-user-verifying-platform-authenticator-available.html:
+
 2018-09-10  Michael Saboff  <msaboff@apple.com>
 
         Test262 failure with Named Capture Groups - using a reference before the group is defined
index 1988825..2369135 100644 (file)
@@ -42,7 +42,7 @@
             }
         };
         // A mock attestation object
-        internals.mockCredentialsMessenger.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
+        internals.mockAuthenticatorCoordinator.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
         const credential = await navigator.credentials.create(options);
 
         return promise_rejects(t, "NotSupportedError",
index 9c2c7f3..ce71885 100644 (file)
@@ -52,7 +52,7 @@ promise_test(async () => {
         }
     };
     // A mock attestation object
-    internals.mockCredentialsMessenger.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
+    internals.mockAuthenticatorCoordinator.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
     createdCredential = await navigator.credentials.create(creationOptions);
 
 
@@ -62,7 +62,7 @@ promise_test(async () => {
         }
     };
     // A mock assertion return bundle.
-    internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
+    internals.mockAuthenticatorCoordinator.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
     requestedCredential = await navigator.credentials.get(requestOptions);
 
     idlArray.add_objects({"PublicKeyCredential": ["createdCredential"], "AuthenticatorAttestationResponse": ["createdCredential.response"], "AuthenticatorAssertionResponse": ["requestedCredential.response"]});
index bb5548c..45077a3 100644 (file)
@@ -20,7 +20,7 @@
                 timeout: 0,
             }
         };
-        internals.mockCredentialsMessenger.setDidTimeOut();
+        internals.mockAuthenticatorCoordinator.setDidTimeOut();
 
         return promise_rejects(t, "NotAllowedError",
             navigator.credentials.create(options));
@@ -82,7 +82,7 @@
                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
             }
         };
-        internals.mockCredentialsMessenger.setDidUserCancel();
+        internals.mockAuthenticatorCoordinator.setDidUserCancel();
 
         return promise_rejects(t, "NotAllowedError",
             navigator.credentials.create(options));
index ab4fcc0..69968c3 100644 (file)
@@ -20,7 +20,7 @@
             }
         };
         // A mock attestation object
-        internals.mockCredentialsMessenger.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
+        internals.mockAuthenticatorCoordinator.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
 
         return navigator.credentials.create(options).then(function(credential) {
                 assert_equals(credential.id, 'AA');
index 512bb2d..0d4c045 100644 (file)
@@ -11,7 +11,7 @@
                 timeout: 0,
             }
         };
-        internals.mockCredentialsMessenger.setDidTimeOut();
+        internals.mockAuthenticatorCoordinator.setDidTimeOut();
 
         return promise_rejects(t, "NotAllowedError",
             navigator.credentials.get(options));
@@ -35,7 +35,7 @@
                 allowCredentials: [{ type: "public-key", id: asciiToUint8Array("123456") }],
             }
         };
-        internals.mockCredentialsMessenger.setDidUserCancel();
+        internals.mockAuthenticatorCoordinator.setDidUserCancel();
 
         return promise_rejects(t, "NotAllowedError",
             navigator.credentials.get(options));
index 2e5ec88..f3fd156 100644 (file)
@@ -12,7 +12,7 @@
             }
         };
         // A mock assertion return bundle.
-        internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
+        internals.mockAuthenticatorCoordinator.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
 
         return navigator.credentials.get(options).then(function(credential) {
             assert_equals(credential.id, 'AA');
index da8e534..181d33a 100644 (file)
@@ -4,7 +4,7 @@
 <script src="/resources/testharnessreport.js"></script>
 <script>
     promise_test(function(t) {
-        internals.mockCredentialsMessenger;
+        internals.mockAuthenticatorCoordinator;
 
         return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable().then(function(result) {
             assert_equals(result, false);
@@ -12,7 +12,7 @@
     }, "PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() without any available authenticators.");
 
     promise_test(function(t) {
-        internals.mockCredentialsMessenger.setDidUserVerifyingPlatformAuthenticatorPresent();
+        internals.mockAuthenticatorCoordinator.setDidUserVerifyingPlatformAuthenticatorPresent();
 
         return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable().then(function(result) {
             assert_equals(result, true);
index 9e45e3e..0df3430 100644 (file)
@@ -1,3 +1,112 @@
+2018-09-11  Jiewen Tan  <jiewen_tan@apple.com>
+
+        [WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=189277
+        <rdar://problem/44115936>
+
+        Reviewed by Chris Dumez.
+
+        This patch aims to polish AuthenticatorManager such that:
+        1) It is no longer a singleton. Instead, it will live with Page. It was a singleton simply because static
+        PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable() have to access it. However, this request
+        can be fulfilled by adding an attribute [CallWith=Document] to the IDL defination. Therefore, there is no
+        such need. Also, the singleton is illy implemented as it owns a single IPC proxy to UI Process which means
+        different web pages will talk to the same web page proxy. Anyway, making it live with Page should fix everything.
+        2) Since we are now planning to support external authenticators, the manager of all authenticators will then
+        have to live in UI Process which makes this AuthenticatorManager obsolete. Instead, rename it to AuthenticatorCoordinator.
+        3) Rename CredentialsMessenger to AuthenticatorCoordinatorClient to tight it to WebAuthN. Also, simplify the
+        message reply model as PublicKeyCredentialCreationOptions/PublicKeyCredentialRequestOptions =>
+        ExceptionData/PublicKeyCredentialData for makeCredential/getAssertion operations.
+        4) Restrict one request per time, i.e. makeCredential/getAssertion for a single page.
+        5) Unifying makeCredentialReply/getAssertionReply/exceptionReply into requestReply for IPC. Correspondingly,
+        unify callback and exceptionCallback into callback as well for LocalAuthenticator.
+        6) Enhance PublicKeyCredentialCreationOptions encoding/decoding with encoder.encodeFixedLengthData/decoder.decodeFixedLengthData.
+
+        Covered by existing tests.
+
+        * DerivedSources.make:
+        * Modules/credentialmanagement/CredentialsContainer.cpp:
+        (WebCore::CredentialsContainer::get):
+        (WebCore::CredentialsContainer::isCreate):
+        * Modules/credentialmanagement/CredentialsContainer.h:
+        * Modules/credentialmanagement/CredentialsMessenger.cpp: Removed.
+        * Modules/credentialmanagement/CredentialsMessenger.h: Removed.
+        * Modules/webauthn/AuthenticatorAssertionResponse.cpp: Removed.
+        * Modules/webauthn/AuthenticatorAssertionResponse.h:
+        (WebCore::AuthenticatorAssertionResponse::create):
+        (WebCore::AuthenticatorAssertionResponse::authenticatorData const):
+        (WebCore::AuthenticatorAssertionResponse::signature const):
+        (WebCore::AuthenticatorAssertionResponse::userHandle const):
+        (WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse):
+        * Modules/webauthn/AuthenticatorAttestationResponse.cpp: Removed.
+        * Modules/webauthn/AuthenticatorAttestationResponse.h:
+        (WebCore::AuthenticatorAttestationResponse::create):
+        (WebCore::AuthenticatorAttestationResponse::attestationObject const):
+        (WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse):
+        * Modules/webauthn/AuthenticatorCoordinator.cpp: Renamed from Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp.
+        (WebCore::AuthenticatorCoordinatorInternal::produceClientDataJson):
+        (WebCore::AuthenticatorCoordinatorInternal::produceClientDataJsonHash):
+        (WebCore::AuthenticatorCoordinatorInternal::initTimeoutTimer):
+        (WebCore::AuthenticatorCoordinatorInternal::didTimeoutTimerFire):
+        (WebCore::AuthenticatorCoordinator::AuthenticatorCoordinator):
+        (WebCore::AuthenticatorCoordinator::setClient):
+        (WebCore::AuthenticatorCoordinator::create const):
+        (WebCore::AuthenticatorCoordinator::discoverFromExternalSource const):
+        (WebCore::AuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable const):
+        * Modules/webauthn/AuthenticatorCoordinator.h: Renamed from Source/WebCore/Modules/webauthn/AuthenticatorManager.h.
+        * Modules/webauthn/AuthenticatorCoordinatorClient.cpp: Added.
+        (WebCore::AuthenticatorCoordinatorClient::~AuthenticatorCoordinatorClient):
+        (WebCore::AuthenticatorCoordinatorClient::requestReply):
+        (WebCore::AuthenticatorCoordinatorClient::isUserVerifyingPlatformAuthenticatorAvailableReply):
+        (WebCore::AuthenticatorCoordinatorClient::setRequestCompletionHandler):
+        (WebCore::AuthenticatorCoordinatorClient::addQueryCompletionHandler):
+        * Modules/webauthn/AuthenticatorCoordinatorClient.h: Copied from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h.
+        * Modules/webauthn/AuthenticatorResponse.cpp: Removed.
+        * Modules/webauthn/AuthenticatorResponse.h:
+        (WebCore::AuthenticatorResponse::AuthenticatorResponse):
+        (WebCore::AuthenticatorResponse::clientDataJSON const):
+        * Modules/webauthn/PublicKeyCredential.cpp:
+        (WebCore::PublicKeyCredential::create):
+        (WebCore::PublicKeyCredential::tryCreate):
+        (WebCore::PublicKeyCredential::PublicKeyCredential):
+        (WebCore::PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable):
+        * Modules/webauthn/PublicKeyCredential.h:
+        * Modules/webauthn/PublicKeyCredential.idl:
+        * Modules/webauthn/PublicKeyCredentialCreationOptions.h:
+        (WebCore::PublicKeyCredentialCreationOptions::encode const):
+        (WebCore::PublicKeyCredentialCreationOptions::decode):
+        * Modules/webauthn/PublicKeyCredentialData.h: Added.
+        (WebCore::PublicKeyCredentialData::encode const):
+        (WebCore::PublicKeyCredentialData::decode):
+        * Modules/webauthn/cocoa/LocalAuthenticator.h:
+        * Modules/webauthn/cocoa/LocalAuthenticator.mm:
+        (WebCore::LocalAuthenticator::makeCredential):
+        (WebCore::LocalAuthenticator::getAssertion):
+        * Modules/webvr/VRStageParameters.cpp:
+        Add a header file to prevent linkage error.
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * page/Page.cpp:
+        * page/Page.h:
+        (WebCore::Page::authenticatorCoordinator const):
+        * page/PageConfiguration.cpp:
+        * page/PageConfiguration.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::Internals):
+        (WebCore::Internals::mockAuthenticatorCoordinator const):
+        (WebCore::Internals::mockCredentialsMessenger const): Deleted.
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        * testing/MockAuthenticatorCoordinator.cpp: Added.
+        (WebCore::MockAuthenticatorCoordinator::setCreationReturnBundle):
+        (WebCore::MockAuthenticatorCoordinator::setAssertionReturnBundle):
+        (WebCore::MockAuthenticatorCoordinator::makeCredential):
+        (WebCore::MockAuthenticatorCoordinator::getAssertion):
+        (WebCore::MockAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
+        * testing/MockAuthenticatorCoordinator.h: Renamed from Source/WebCore/testing/MockCredentialsMessenger.h.
+        * testing/MockAuthenticatorCoordinator.idl: Renamed from Source/WebCore/testing/MockCredentialsMessenger.idl.
+        * testing/MockCredentialsMessenger.cpp: Removed.
+
 2018-09-10  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Remove unused needsDestruction class variables from HashTraits
index d23648c..5db3014 100644 (file)
@@ -962,9 +962,9 @@ JS_BINDING_IDLS = \
     $(WebCore)/testing/Internals.idl \
     $(WebCore)/testing/MallocStatistics.idl \
     $(WebCore)/testing/MemoryInfo.idl \
+    $(WebCore)/testing/MockAuthenticatorCoordinator.idl \
     $(WebCore)/testing/MockCDMFactory.idl \
     $(WebCore)/testing/MockContentFilterSettings.idl \
-    $(WebCore)/testing/MockCredentialsMessenger.idl \
     $(WebCore)/testing/MockPageOverlay.idl \
     $(WebCore)/testing/MockPaymentAddress.idl \
     $(WebCore)/testing/MockPaymentCoordinator.idl \
index 14707ae..cb2760c 100644 (file)
@@ -35,6 +35,7 @@
 #include "Document.h"
 #include "ExceptionOr.h"
 #include "JSDOMPromiseDeferred.h"
+#include "Page.h"
 #include "SecurityOrigin.h"
 
 namespace WebCore {
@@ -63,7 +64,7 @@ void CredentialsContainer::get(CredentialRequestOptions&& options, CredentialPro
 {
     // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-request as of 4 August 2017
     // with enhancement from 14 November 2017 Editor's Draft.
-    if (!m_document) {
+    if (!m_document || !m_document->page()) {
         promise.reject(Exception { NotSupportedError });
         return;
     }
@@ -82,8 +83,7 @@ void CredentialsContainer::get(CredentialRequestOptions&& options, CredentialPro
         return;
     }
 
-    // Async operations are dispatched/handled in (Web)CredentialMessenger, which exchanges messages between WebProcess and UIProcess.
-    AuthenticatorManager::singleton().discoverFromExternalSource(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
+    m_document->page()->authenticatorCoordinator().discoverFromExternalSource(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
 }
 
 void CredentialsContainer::store(const BasicCredential&, CredentialPromise&& promise)
@@ -95,7 +95,7 @@ void CredentialsContainer::isCreate(CredentialCreationOptions&& options, Credent
 {
     // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-create as of 4 August 2017
     // with enhancement from 14 November 2017 Editor's Draft.
-    if (!m_document) {
+    if (!m_document || !m_document->page()) {
         promise.reject(Exception { NotSupportedError });
         return;
     }
@@ -112,8 +112,7 @@ void CredentialsContainer::isCreate(CredentialCreationOptions&& options, Credent
         return;
     }
 
-    // Async operations are dispatched/handled in (Web)CredentialMessenger, which exchanges messages between WebProcess and UIProcess.
-    AuthenticatorManager::singleton().create(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
+    m_document->page()->authenticatorCoordinator().create(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
 }
 
 void CredentialsContainer::preventSilentAccess(DOMPromiseDeferred<void>&& promise) const
index 2d5b38b..4e1bb4e 100644 (file)
@@ -28,7 +28,7 @@
 
 #if ENABLE(WEB_AUTHN)
 
-#include "AuthenticatorManager.h"
+#include "AuthenticatorCoordinator.h"
 #include <wtf/RefCounted.h>
 #include <wtf/WeakPtr.h>
 
diff --git a/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.cpp b/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.cpp
deleted file mode 100644 (file)
index b46bd07..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CredentialsMessenger.h"
-
-#if ENABLE(WEB_AUTHN)
-
-namespace WebCore {
-
-namespace CredentialsMessengerInternal {
-
-const uint64_t maxMessageId = 0xFFFFFFFFFFFFFF; // 56 bits
-const size_t callBackClassifierOffset = 56;
-
-}
-
-void CredentialsMessenger::exceptionReply(uint64_t messageId, const ExceptionData& exception)
-{
-    using namespace CredentialsMessengerInternal;
-
-    if (!(messageId >> callBackClassifierOffset ^ CallBackClassifier::Creation)) {
-        auto handler = takeCreationCompletionHandler(messageId);
-        handler(exception.toException());
-        return;
-    }
-    if (!(messageId >> callBackClassifierOffset ^ CallBackClassifier::Request)) {
-        auto handler = takeRequestCompletionHandler(messageId);
-        handler(exception.toException());
-        return;
-    }
-}
-
-uint64_t CredentialsMessenger::addCreationCompletionHandler(CreationCompletionHandler&& handler)
-{
-    using namespace CredentialsMessengerInternal;
-
-    uint64_t messageId = m_accumulatedMessageId++;
-    ASSERT(messageId <= maxMessageId);
-    messageId = messageId | CallBackClassifier::Creation << callBackClassifierOffset;
-    auto addResult = m_pendingCreationCompletionHandlers.add(messageId, WTFMove(handler));
-    ASSERT_UNUSED(addResult, addResult.isNewEntry);
-    return messageId;
-}
-
-CreationCompletionHandler CredentialsMessenger::takeCreationCompletionHandler(uint64_t messageId)
-{
-    return m_pendingCreationCompletionHandlers.take(messageId);
-}
-
-uint64_t CredentialsMessenger::addRequestCompletionHandler(RequestCompletionHandler&& handler)
-{
-    using namespace CredentialsMessengerInternal;
-
-    uint64_t messageId = m_accumulatedMessageId++;
-    ASSERT(messageId <= maxMessageId);
-    messageId = messageId | CallBackClassifier::Request << callBackClassifierOffset;
-    auto addResult = m_pendingRequestCompletionHandlers.add(messageId, WTFMove(handler));
-    ASSERT_UNUSED(addResult, addResult.isNewEntry);
-    return messageId;
-}
-
-RequestCompletionHandler CredentialsMessenger::takeRequestCompletionHandler(uint64_t messageId)
-{
-    return m_pendingRequestCompletionHandlers.take(messageId);
-}
-
-uint64_t CredentialsMessenger::addQueryCompletionHandler(QueryCompletionHandler&& handler)
-{
-    using namespace CredentialsMessengerInternal;
-
-    uint64_t messageId = m_accumulatedMessageId++;
-    ASSERT(messageId < maxMessageId);
-    messageId = messageId | CallBackClassifier::Query << callBackClassifierOffset;
-    auto addResult = m_pendingQueryCompletionHandlers.add(messageId, WTFMove(handler));
-    ASSERT_UNUSED(addResult, addResult.isNewEntry);
-    return messageId;
-}
-
-QueryCompletionHandler CredentialsMessenger::takeQueryCompletionHandler(uint64_t messageId)
-{
-    return m_pendingQueryCompletionHandlers.take(messageId);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUTHN)
diff --git a/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h b/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h
deleted file mode 100644 (file)
index f28af95..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(WEB_AUTHN)
-
-#include "ExceptionData.h"
-#include "ExceptionOr.h"
-#include <JavaScriptCore/ArrayBuffer.h>
-#include <wtf/CompletionHandler.h>
-#include <wtf/HashMap.h>
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-class DeferredPromise;
-
-struct PublicKeyCredentialCreationOptions;
-struct PublicKeyCredentialRequestOptions;
-
-struct CreationReturnBundle {
-    CreationReturnBundle(Ref<ArrayBuffer>&& credentialId, Ref<ArrayBuffer>&& attestationObject)
-        : credentialId(WTFMove(credentialId))
-        , attestationObject(WTFMove(attestationObject))
-    {
-    }
-
-    Ref<ArrayBuffer> credentialId;
-    Ref<ArrayBuffer> attestationObject;
-};
-struct AssertionReturnBundle {
-    AssertionReturnBundle(Ref<ArrayBuffer>&& credentialId, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, Ref<ArrayBuffer>&& userHandle)
-        : credentialId(WTFMove(credentialId))
-        , authenticatorData(WTFMove(authenticatorData))
-        , signature(WTFMove(signature))
-        , userHandle(WTFMove(userHandle))
-    {
-    }
-
-    Ref<ArrayBuffer> credentialId;
-    Ref<ArrayBuffer> authenticatorData;
-    Ref<ArrayBuffer> signature;
-    Ref<ArrayBuffer> userHandle;
-};
-
-using CreationCompletionHandler = CompletionHandler<void(ExceptionOr<CreationReturnBundle>&&)>;
-using RequestCompletionHandler = CompletionHandler<void(ExceptionOr<AssertionReturnBundle>&&)>;
-using QueryCompletionHandler = CompletionHandler<void(bool)>;
-
-class CredentialsMessenger : public CanMakeWeakPtr<CredentialsMessenger> {
-    WTF_MAKE_FAST_ALLOCATED;
-    WTF_MAKE_NONCOPYABLE(CredentialsMessenger);
-public:
-    CredentialsMessenger() = default;
-
-    // Senders.
-    virtual void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, CreationCompletionHandler&&) = 0;
-    virtual void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) = 0;
-    virtual void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) = 0;
-
-    // Receivers.
-    WEBCORE_EXPORT void exceptionReply(uint64_t messageId, const ExceptionData&);
-    virtual void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) = 0;
-    virtual void getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) = 0;
-    virtual void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool) = 0;
-
-protected:
-    virtual ~CredentialsMessenger() = default;
-
-    WEBCORE_EXPORT uint64_t addCreationCompletionHandler(CreationCompletionHandler&&);
-    WEBCORE_EXPORT CreationCompletionHandler takeCreationCompletionHandler(uint64_t);
-    WEBCORE_EXPORT uint64_t addRequestCompletionHandler(RequestCompletionHandler&&);
-    WEBCORE_EXPORT RequestCompletionHandler takeRequestCompletionHandler(uint64_t);
-    WEBCORE_EXPORT uint64_t addQueryCompletionHandler(QueryCompletionHandler&&);
-    WEBCORE_EXPORT QueryCompletionHandler takeQueryCompletionHandler(uint64_t);
-
-private:
-    enum CallBackClassifier : uint64_t {
-        Creation = 0x01,
-        Request = 0x02,
-        Query = 0x03,
-    };
-    // The most significant byte is reserved as callback classifier.
-    uint64_t m_accumulatedMessageId { 1 };
-    HashMap<uint64_t, CreationCompletionHandler> m_pendingCreationCompletionHandlers;
-    HashMap<uint64_t, RequestCompletionHandler> m_pendingRequestCompletionHandlers;
-    HashMap<uint64_t, QueryCompletionHandler> m_pendingQueryCompletionHandlers;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUTHN)
diff --git a/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.cpp b/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.cpp
deleted file mode 100644 (file)
index 332a2cb..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AuthenticatorAssertionResponse.h"
-
-#if ENABLE(WEB_AUTHN)
-
-namespace WebCore {
-
-AuthenticatorAssertionResponse::AuthenticatorAssertionResponse(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& authenticatorData, RefPtr<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle)
-    : AuthenticatorResponse(WTFMove(clientDataJSON))
-    , m_authenticatorData(WTFMove(authenticatorData))
-    , m_signature(WTFMove(signature))
-    , m_userHandle(WTFMove(userHandle))
-{
-}
-
-ArrayBuffer* AuthenticatorAssertionResponse::authenticatorData() const
-{
-    return m_authenticatorData.get();
-}
-
-ArrayBuffer* AuthenticatorAssertionResponse::signature() const
-{
-    return m_signature.get();
-}
-
-ArrayBuffer* AuthenticatorAssertionResponse::userHandle() const
-{
-    return m_userHandle.get();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUTHN)
index 4451f25..cf28c1a 100644 (file)
@@ -33,25 +33,31 @@ namespace WebCore {
 
 class AuthenticatorAssertionResponse : public AuthenticatorResponse {
 public:
-    static Ref<AuthenticatorAssertionResponse> create(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& authenticatorData, RefPtr<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle)
+    static Ref<AuthenticatorAssertionResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, Ref<ArrayBuffer>&& userHandle)
     {
         return adoptRef(*new AuthenticatorAssertionResponse(WTFMove(clientDataJSON), WTFMove(authenticatorData), WTFMove(signature), WTFMove(userHandle)));
     }
 
     virtual ~AuthenticatorAssertionResponse() = default;
 
-    ArrayBuffer* authenticatorData() const;
-    ArrayBuffer* signature() const;
-    ArrayBuffer* userHandle() const;
+    ArrayBuffer* authenticatorData() const { return m_authenticatorData.ptr(); }
+    ArrayBuffer* signature() const { return m_signature.ptr(); }
+    ArrayBuffer* userHandle() const { return m_userHandle.ptr(); }
 
 private:
-    AuthenticatorAssertionResponse(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& authenticatorData, RefPtr<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle);
+    AuthenticatorAssertionResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, Ref<ArrayBuffer>&& userHandle)
+        : AuthenticatorResponse(WTFMove(clientDataJSON))
+        , m_authenticatorData(WTFMove(authenticatorData))
+        , m_signature(WTFMove(signature))
+        , m_userHandle(WTFMove(userHandle))
+    {
+    }
 
     Type type() const final { return Type::Assertion; }
 
-    RefPtr<ArrayBuffer> m_authenticatorData;
-    RefPtr<ArrayBuffer> m_signature;
-    RefPtr<ArrayBuffer> m_userHandle;
+    Ref<ArrayBuffer> m_authenticatorData;
+    Ref<ArrayBuffer> m_signature;
+    Ref<ArrayBuffer> m_userHandle;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp b/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp
deleted file mode 100644 (file)
index 8f06c43..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AuthenticatorAttestationResponse.h"
-
-#if ENABLE(WEB_AUTHN)
-
-namespace WebCore {
-
-AuthenticatorAttestationResponse::AuthenticatorAttestationResponse(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& attestationObject)
-    : AuthenticatorResponse(WTFMove(clientDataJSON))
-    , m_attestationObject(WTFMove(attestationObject))
-{
-}
-
-ArrayBuffer* AuthenticatorAttestationResponse::attestationObject() const
-{
-    return m_attestationObject.get();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUTHN)
index 480707b..0537d97 100644 (file)
@@ -33,21 +33,25 @@ namespace WebCore {
 
 class AuthenticatorAttestationResponse : public AuthenticatorResponse {
 public:
-    static Ref<AuthenticatorAttestationResponse> create(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& attestationObject)
+    static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject)
     {
         return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(clientDataJSON), WTFMove(attestationObject)));
     }
 
     virtual ~AuthenticatorAttestationResponse() = default;
 
-    ArrayBuffer* attestationObject() const;
+    ArrayBuffer* attestationObject() const { return m_attestationObject.ptr(); }
 
 private:
-    AuthenticatorAttestationResponse(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& attestationObject);
+    AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject)
+        : AuthenticatorResponse(WTFMove(clientDataJSON))
+        , m_attestationObject(WTFMove(attestationObject))
+    {
+    }
 
     Type type() const final { return Type::Attestation; }
 
-    RefPtr<ArrayBuffer> m_attestationObject;
+    Ref<ArrayBuffer> m_attestationObject;
 };
 
 } // namespace WebCore
  */
 
 #include "config.h"
-#include "AuthenticatorManager.h"
+#include "AuthenticatorCoordinator.h"
 
 #if ENABLE(WEB_AUTHN)
 
 #include "AbortSignal.h"
 #include "AuthenticatorAssertionResponse.h"
 #include "AuthenticatorAttestationResponse.h"
-#include "CredentialsMessenger.h"
+#include "AuthenticatorCoordinatorClient.h"
 #include "JSBasicCredential.h"
 #include "PublicKeyCredential.h"
 #include "PublicKeyCredentialCreationOptions.h"
+#include "PublicKeyCredentialData.h"
 #include "PublicKeyCredentialRequestOptions.h"
 #include "SecurityOrigin.h"
 #include "Timer.h"
@@ -45,7 +46,7 @@
 
 namespace WebCore {
 
-namespace AuthenticatorManagerInternal {
+namespace AuthenticatorCoordinatorInternal {
 
 enum class ClientDataType {
     Create,
@@ -104,23 +105,21 @@ static bool didTimeoutTimerFire(Timer* timer)
     return false;
 }
 
-} // namespace AuthenticatorManagerInternal
+} // namespace AuthenticatorCoordinatorInternal
 
-AuthenticatorManager& AuthenticatorManager::singleton()
+AuthenticatorCoordinator::AuthenticatorCoordinator(std::unique_ptr<AuthenticatorCoordinatorClient>&& client)
+    : m_client(WTFMove(client))
 {
-    ASSERT(isMainThread());
-    static NeverDestroyed<AuthenticatorManager> authenticator;
-    return authenticator;
 }
 
-void AuthenticatorManager::setMessenger(CredentialsMessenger& messenger)
+void AuthenticatorCoordinator::setClient(std::unique_ptr<AuthenticatorCoordinatorClient>&& client)
 {
-    m_messenger = makeWeakPtr(messenger);
+    m_client = WTFMove(client);
 }
 
-void AuthenticatorManager::create(const SecurityOrigin& callerOrigin, const PublicKeyCredentialCreationOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
+void AuthenticatorCoordinator::create(const SecurityOrigin& callerOrigin, const PublicKeyCredentialCreationOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
 {
-    using namespace AuthenticatorManagerInternal;
+    using namespace AuthenticatorCoordinatorInternal;
 
     // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.
     // FIXME: Extensions are not supported yet. Skip Step 11-12.
@@ -161,33 +160,34 @@ void AuthenticatorManager::create(const SecurityOrigin& callerOrigin, const Publ
     // Only platform attachments will be supported at this stage. Assuming one authenticator per device.
     // Also, resident keys, user verifications and direct attestation are enforced at this tage.
     // For better performance, transports of options.excludeCredentials are checked in LocalAuthenticator.
-    if (!m_messenger)  {
+    if (!m_client)  {
         promise.reject(Exception { UnknownError, "Unknown internal error."_s });
         return;
     }
 
-    auto completionHandler = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), timeoutTimer = WTFMove(timeoutTimer), abortSignal = WTFMove(abortSignal)] (ExceptionOr<CreationReturnBundle>&& result) mutable {
+    auto completionHandler = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), timeoutTimer = WTFMove(timeoutTimer), abortSignal = WTFMove(abortSignal)] (const WebCore::PublicKeyCredentialData& data, const WebCore::ExceptionData& exception) mutable {
         if (didTimeoutTimerFire(timeoutTimer.get()))
             return;
         if (abortSignal && abortSignal->aborted()) {
             promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s });
             return;
         }
-        if (result.hasException()) {
-            promise.reject(result.exception());
+
+        data.clientDataJSON = WTFMove(clientDataJson);
+        if (auto publicKeyCredential = PublicKeyCredential::tryCreate(data)) {
+            promise.resolve(publicKeyCredential.get());
             return;
         }
-
-        auto bundle = result.releaseReturnValue();
-        promise.resolve(PublicKeyCredential::create(WTFMove(bundle.credentialId), AuthenticatorAttestationResponse::create(WTFMove(clientDataJson), ArrayBuffer::create(WTFMove(bundle.attestationObject)))).ptr());
+        ASSERT(!exception.message.isNull());
+        promise.reject(exception.toException());
     };
     // Async operations are dispatched and handled in the messenger.
-    m_messenger->makeCredential(clientDataJsonHash, options, WTFMove(completionHandler));
+    m_client->makeCredential(clientDataJsonHash, options, WTFMove(completionHandler));
 }
 
-void AuthenticatorManager::discoverFromExternalSource(const SecurityOrigin& callerOrigin, const PublicKeyCredentialRequestOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
+void AuthenticatorCoordinator::discoverFromExternalSource(const SecurityOrigin& callerOrigin, const PublicKeyCredentialRequestOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
 {
-    using namespace AuthenticatorManagerInternal;
+    using namespace AuthenticatorCoordinatorInternal;
 
     // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.
     // FIXME: Extensions are not supported yet. Skip Step 8-9.
@@ -220,35 +220,36 @@ void AuthenticatorManager::discoverFromExternalSource(const SecurityOrigin& call
     // Only platform attachments will be supported at this stage. Assuming one authenticator per device.
     // Also, resident keys, user verifications and direct attestation are enforced at this tage.
     // For better performance, filtering of options.allowCredentials is done in LocalAuthenticator.
-    if (!m_messenger)  {
+    if (!m_client)  {
         promise.reject(Exception { UnknownError, "Unknown internal error."_s });
         return;
     }
 
-    auto completionHandler = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), timeoutTimer = WTFMove(timeoutTimer), abortSignal = WTFMove(abortSignal)] (ExceptionOr<AssertionReturnBundle>&& result) mutable {
+    auto completionHandler = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), timeoutTimer = WTFMove(timeoutTimer), abortSignal = WTFMove(abortSignal)] (const WebCore::PublicKeyCredentialData& data, const WebCore::ExceptionData& exception) mutable {
         if (didTimeoutTimerFire(timeoutTimer.get()))
             return;
         if (abortSignal && abortSignal->aborted()) {
             promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s });
             return;
         }
-        if (result.hasException()) {
-            promise.reject(result.exception());
+
+        data.clientDataJSON = WTFMove(clientDataJson);
+        if (auto publicKeyCredential = PublicKeyCredential::tryCreate(data)) {
+            promise.resolve(publicKeyCredential.get());
             return;
         }
-
-        auto bundle = result.releaseReturnValue();
-        promise.resolve(PublicKeyCredential::create(WTFMove(bundle.credentialId), AuthenticatorAssertionResponse::create(WTFMove(clientDataJson), WTFMove(bundle.authenticatorData), WTFMove(bundle.signature), WTFMove(bundle.userHandle))).ptr());
+        ASSERT(!exception.message.isNull());
+        promise.reject(exception.toException());
     };
     // Async operations are dispatched and handled in the messenger.
-    m_messenger->getAssertion(clientDataJsonHash, options, WTFMove(completionHandler));
+    m_client->getAssertion(clientDataJsonHash, options, WTFMove(completionHandler));
 }
 
-void AuthenticatorManager::isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&& promise) const
+void AuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&& promise) const
 {
     // The following implements https://www.w3.org/TR/webauthn/#isUserVerifyingPlatformAuthenticatorAvailable
     // as of 5 December 2017.
-    if (!m_messenger)  {
+    if (!m_client)  {
         promise.reject(Exception { UnknownError, "Unknown internal error."_s });
         return;
     }
@@ -259,7 +260,7 @@ void AuthenticatorManager::isUserVerifyingPlatformAuthenticatorAvailable(DOMProm
         promise.resolve(result);
     };
     // Async operation are dispatched and handled in the messenger.
-    m_messenger->isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(completionHandler));
+    m_client->isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(completionHandler));
 }
 
 } // namespace WebCore
 #include "JSDOMPromiseDeferred.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
 class AbortSignal;
+class AuthenticatorCoordinatorClient;
 class BasicCredential;
-class CredentialsMessenger;
 class SecurityOrigin;
 
 struct PublicKeyCredentialCreationOptions;
@@ -44,12 +43,11 @@ struct PublicKeyCredentialRequestOptions;
 
 using CredentialPromise = DOMPromiseDeferred<IDLNullable<IDLInterface<BasicCredential>>>;
 
-class AuthenticatorManager {
-    WTF_MAKE_NONCOPYABLE(AuthenticatorManager);
-    friend class NeverDestroyed<AuthenticatorManager>;
+class AuthenticatorCoordinator {
+    WTF_MAKE_NONCOPYABLE(AuthenticatorCoordinator);
 public:
-    WEBCORE_EXPORT static AuthenticatorManager& singleton();
-    WEBCORE_EXPORT void setMessenger(CredentialsMessenger&);
+    WEBCORE_EXPORT explicit AuthenticatorCoordinator(std::unique_ptr<AuthenticatorCoordinatorClient>&&);
+    WEBCORE_EXPORT void setClient(std::unique_ptr<AuthenticatorCoordinatorClient>&&);
 
     // The following methods implement static methods of PublicKeyCredential.
     void create(const SecurityOrigin&, const PublicKeyCredentialCreationOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, CredentialPromise&&) const;
@@ -57,9 +55,9 @@ public:
     void isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&&) const;
 
 private:
-    AuthenticatorManager() = default;
+    AuthenticatorCoordinator() = default;
 
-    WeakPtr<CredentialsMessenger> m_messenger;
+    std::unique_ptr<AuthenticatorCoordinatorClient> m_client;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.cpp b/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.cpp
new file mode 100644 (file)
index 0000000..c0c80ca
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AuthenticatorCoordinatorClient.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include "PublicKeyCredentialData.h"
+
+namespace WebCore {
+
+AuthenticatorCoordinatorClient::~AuthenticatorCoordinatorClient()
+{
+    // Just to call handlers to avoid any assertion failures.
+    if (m_pendingCompletionHandler)
+        m_pendingCompletionHandler({ }, { NotAllowedError, "Operation timed out."_s });
+    for (auto itr = m_pendingQueryCompletionHandlers.begin(); itr !=  m_pendingQueryCompletionHandlers.end(); ++itr)
+        itr->value(false);
+}
+
+void AuthenticatorCoordinatorClient::requestReply(const WebCore::PublicKeyCredentialData& data, const WebCore::ExceptionData& exception)
+{
+    m_pendingCompletionHandler(data, exception);
+}
+
+void AuthenticatorCoordinatorClient::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
+{
+    auto handler = m_pendingQueryCompletionHandlers.take(messageId);
+    handler(result);
+}
+
+bool AuthenticatorCoordinatorClient::setRequestCompletionHandler(RequestCompletionHandler&& handler)
+{
+    if (m_pendingCompletionHandler) {
+        handler({ }, { NotAllowedError, "A request is pending."_s });
+        return false;
+    }
+
+    m_pendingCompletionHandler = WTFMove(handler);
+    return true;
+}
+
+uint64_t AuthenticatorCoordinatorClient::addQueryCompletionHandler(QueryCompletionHandler&& handler)
+{
+    uint64_t messageId = m_accumulatedMessageId++;
+    auto addResult = m_pendingQueryCompletionHandlers.add(messageId, WTFMove(handler));
+    ASSERT_UNUSED(addResult, addResult.isNewEntry);
+    return messageId;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUTHN)
diff --git a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h b/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h
new file mode 100644 (file)
index 0000000..eba3d91
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUTHN)
+
+#include "ExceptionData.h"
+#include <wtf/CompletionHandler.h>
+#include <wtf/HashMap.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class DeferredPromise;
+
+struct PublicKeyCredentialCreationOptions;
+struct PublicKeyCredentialData;
+struct PublicKeyCredentialRequestOptions;
+
+using RequestCompletionHandler = CompletionHandler<void(const WebCore::PublicKeyCredentialData&, const WebCore::ExceptionData&)>;
+using QueryCompletionHandler = CompletionHandler<void(bool)>;
+
+class WEBCORE_EXPORT AuthenticatorCoordinatorClient : public CanMakeWeakPtr<AuthenticatorCoordinatorClient> {
+    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_NONCOPYABLE(AuthenticatorCoordinatorClient);
+public:
+    AuthenticatorCoordinatorClient() = default;
+    virtual ~AuthenticatorCoordinatorClient();
+
+    // Senders.
+    virtual void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&&) = 0;
+    virtual void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) = 0;
+    virtual void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) = 0;
+
+    // Receivers.
+    void requestReply(const WebCore::PublicKeyCredentialData&, const WebCore::ExceptionData&);
+    void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool);
+
+protected:
+    // Only one request is allowed at one time. It returns false whenever there is an existing pending request.
+    // And invokes the provided handler with NotAllowedError.
+    bool setRequestCompletionHandler(RequestCompletionHandler&&);
+    uint64_t addQueryCompletionHandler(QueryCompletionHandler&&);
+
+private:
+    RequestCompletionHandler m_pendingCompletionHandler;
+    uint64_t m_accumulatedMessageId { 1 };
+    HashMap<uint64_t, QueryCompletionHandler> m_pendingQueryCompletionHandlers;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUTHN)
diff --git a/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp b/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp
deleted file mode 100644 (file)
index db8f094..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AuthenticatorResponse.h"
-
-#if ENABLE(WEB_AUTHN)
-
-namespace WebCore {
-
-AuthenticatorResponse::AuthenticatorResponse(RefPtr<ArrayBuffer>&& clientDataJSON)
-    : m_clientDataJSON(WTFMove(clientDataJSON))
-{
-}
-
-ArrayBuffer* AuthenticatorResponse::clientDataJSON() const
-{
-    return m_clientDataJSON.get();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUTHN)
index 5528c03..cb7e07e 100644 (file)
@@ -40,15 +40,18 @@ public:
         Attestation
     };
 
-    explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
+    explicit AuthenticatorResponse(Ref<ArrayBuffer>&& clientDataJSON)
+        : m_clientDataJSON(WTFMove(clientDataJSON))
+    {
+    }
     virtual ~AuthenticatorResponse() = default;
 
     virtual Type type() const = 0;
 
-    ArrayBuffer* clientDataJSON() const;
+    ArrayBuffer* clientDataJSON() const { return m_clientDataJSON.ptr(); }
 
 private:
-    RefPtr<ArrayBuffer> m_clientDataJSON;
+    Ref<ArrayBuffer> m_clientDataJSON;
 };
 
 } // namespace WebCore
index 112f40a..21f700c 100644 (file)
 
 #if ENABLE(WEB_AUTHN)
 
-#include "AuthenticatorManager.h"
+#include "AuthenticatorCoordinator.h"
+#include "Document.h"
 #include "JSDOMPromiseDeferred.h"
+#include "Page.h"
+#include "PublicKeyCredentialData.h"
 #include <wtf/text/Base64.h>
 
 namespace WebCore {
 
-PublicKeyCredential::PublicKeyCredential(RefPtr<ArrayBuffer>&& id, RefPtr<AuthenticatorResponse>&& response)
+Ref<PublicKeyCredential> PublicKeyCredential::create(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&& response)
+{
+    return adoptRef(*new PublicKeyCredential(WTFMove(id), WTFMove(response)));
+}
+
+RefPtr<PublicKeyCredential> PublicKeyCredential::tryCreate(const PublicKeyCredentialData& data)
+{
+    if (!data.rawId || !data.clientDataJSON)
+        return nullptr;
+
+    if (data.isAuthenticatorAttestationResponse) {
+        if (!data.attestationObject)
+            return nullptr;
+
+        return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAttestationResponse::create(data.clientDataJSON.releaseNonNull(), data.attestationObject.releaseNonNull())));
+    }
+
+    if (!data.authenticatorData || !data.signature || !data.userHandle)
+        return nullptr;
+
+    return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAssertionResponse::create(data.clientDataJSON.releaseNonNull(), data.authenticatorData.releaseNonNull(), data.signature.releaseNonNull(), data.userHandle.releaseNonNull())));
+}
+
+PublicKeyCredential::PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&& response)
     : BasicCredential(WTF::base64URLEncode(id->data(), id->byteLength()), Type::PublicKey, Discovery::Remote)
     , m_rawId(WTFMove(id))
     , m_response(WTFMove(response))
@@ -46,9 +72,9 @@ ExceptionOr<bool> PublicKeyCredential::getClientExtensionResults() const
     return Exception { NotSupportedError };
 }
 
-void PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&& promise)
+void PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable(Document& document, DOMPromiseDeferred<IDLBoolean>&& promise)
 {
-    AuthenticatorManager::singleton().isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(promise));
+    document.page()->authenticatorCoordinator().isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(promise));
 }
 
 } // namespace WebCore
index fdedc58..30fce42 100644 (file)
 namespace WebCore {
 
 class AuthenticatorResponse;
+class Document;
+
+struct PublicKeyCredentialData;
 
 class PublicKeyCredential final : public BasicCredential {
 public:
-    static Ref<PublicKeyCredential> create(RefPtr<ArrayBuffer>&& id, RefPtr<AuthenticatorResponse>&& response)
-    {
-        return adoptRef(*new PublicKeyCredential(WTFMove(id), WTFMove(response)));
-    }
+    static Ref<PublicKeyCredential> create(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&&);
+    static RefPtr<PublicKeyCredential> tryCreate(const PublicKeyCredentialData&);
 
-    ArrayBuffer* rawId() const { return m_rawId.get(); }
-    AuthenticatorResponse* response() const { return m_response.get(); }
+    ArrayBuffer* rawId() const { return m_rawId.ptr(); }
+    AuthenticatorResponse* response() const { return m_response.ptr(); }
     // Not support yet. Always throws.
     ExceptionOr<bool> getClientExtensionResults() const;
 
-    static void isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&&);
+    static void isUserVerifyingPlatformAuthenticatorAvailable(Document&, DOMPromiseDeferred<IDLBoolean>&&);
 
 private:
-    PublicKeyCredential(RefPtr<ArrayBuffer>&& id, RefPtr<AuthenticatorResponse>&&);
+    PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&&);
 
     Type credentialType() const final { return Type::PublicKey; }
 
-    RefPtr<ArrayBuffer> m_rawId;
-    RefPtr<AuthenticatorResponse> m_response;
+    Ref<ArrayBuffer> m_rawId;
+    Ref<AuthenticatorResponse> m_response;
 };
 
 } // namespace WebCore
index 77b1b72..d51f06d 100644 (file)
@@ -35,5 +35,5 @@ typedef boolean AuthenticationExtensions;
     [SameObject] readonly attribute AuthenticatorResponse response;
     [MayThrowException] AuthenticationExtensions getClientExtensionResults();
 
-    static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
+    [CallWith=Document] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
 };
index 760e8fd..341397c 100644 (file)
@@ -94,9 +94,9 @@ template<class Encoder>
 void PublicKeyCredentialCreationOptions::encode(Encoder& encoder) const
 {
     encoder << rp.id << rp.name << rp.icon;
-    Vector<uint8_t> idVector;
-    idVector.append(user.id.data(), user.id.length());
-    encoder << idVector << user.displayName << user.name << user.icon << pubKeyCredParams << excludeCredentials;
+    encoder << static_cast<uint64_t>(user.id.length());
+    encoder.encodeFixedLengthData(user.id.data(), user.id.length(), 1);
+    encoder << user.displayName << user.name << user.icon << pubKeyCredParams << excludeCredentials;
 }
 
 template<class Decoder>
@@ -109,8 +109,15 @@ std::optional<PublicKeyCredentialCreationOptions> PublicKeyCredentialCreationOpt
         return std::nullopt;
     if (!decoder.decode(result.rp.icon))
         return std::nullopt;
-    if (!decoder.decode(result.user.idVector))
+
+    std::optional<uint64_t> userIdLength;
+    decoder >> userIdLength;
+    if (!userIdLength)
+        return std::nullopt;
+    result.user.idVector.reserveCapacity(userIdLength.value());
+    if (!decoder.decodeFixedLengthData(result.user.idVector.data(), userIdLength.value(), 1))
         return std::nullopt;
+
     if (!decoder.decode(result.user.displayName))
         return std::nullopt;
     if (!decoder.decode(result.user.name))
diff --git a/Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h b/Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h
new file mode 100644 (file)
index 0000000..229fb87
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUTHN)
+
+#include <JavaScriptCore/ArrayBuffer.h>
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class AuthenticatorResponse;
+
+struct PublicKeyCredentialData {
+    mutable RefPtr<ArrayBuffer> rawId;
+
+    // AuthenticatorResponse
+    bool isAuthenticatorAttestationResponse;
+    mutable RefPtr<ArrayBuffer> clientDataJSON;
+
+    // AuthenticatorAttestationResponse
+    mutable RefPtr<ArrayBuffer> attestationObject;
+
+    // AuthenticatorAssertionResponse
+    mutable RefPtr<ArrayBuffer> authenticatorData;
+    mutable RefPtr<ArrayBuffer> signature;
+    mutable RefPtr<ArrayBuffer> userHandle;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static std::optional<PublicKeyCredentialData> decode(Decoder&);
+};
+
+// Noted: clientDataJSON is never encoded or decoded as it is never sent across different processes.
+template<class Encoder>
+void PublicKeyCredentialData::encode(Encoder& encoder) const
+{
+    encoder << static_cast<uint64_t>(rawId->byteLength());
+    encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(rawId->data()), rawId->byteLength(), 1);
+
+    encoder << isAuthenticatorAttestationResponse;
+
+    if (isAuthenticatorAttestationResponse) {
+        encoder << static_cast<uint64_t>(attestationObject->byteLength());
+        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(attestationObject->data()), attestationObject->byteLength(), 1);
+        return;
+    }
+
+    encoder << static_cast<uint64_t>(authenticatorData->byteLength());
+    encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(authenticatorData->data()), authenticatorData->byteLength(), 1);
+    encoder << static_cast<uint64_t>(signature->byteLength());
+    encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(signature->data()), signature->byteLength(), 1);
+    encoder << static_cast<uint64_t>(userHandle->byteLength());
+    encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(userHandle->data()), userHandle->byteLength(), 1);
+}
+
+template<class Decoder>
+std::optional<PublicKeyCredentialData> PublicKeyCredentialData::decode(Decoder& decoder)
+{
+    PublicKeyCredentialData result;
+
+    std::optional<uint64_t> rawIdLength;
+    decoder >> rawIdLength;
+    if (!rawIdLength)
+        return std::nullopt;
+
+    result.rawId = ArrayBuffer::create(rawIdLength.value(), sizeof(uint8_t));
+    if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.rawId->data()), rawIdLength.value(), 1))
+        return std::nullopt;
+
+    std::optional<bool> isAuthenticatorAttestationResponse;
+    decoder >> isAuthenticatorAttestationResponse;
+    if (!isAuthenticatorAttestationResponse)
+        return std::nullopt;
+    result.isAuthenticatorAttestationResponse = isAuthenticatorAttestationResponse.value();
+
+    if (result.isAuthenticatorAttestationResponse) {
+        std::optional<uint64_t> attestationObjectLength;
+        decoder >> attestationObjectLength;
+        if (!attestationObjectLength)
+            return std::nullopt;
+
+        result.attestationObject = ArrayBuffer::create(attestationObjectLength.value(), sizeof(uint8_t));
+        if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.attestationObject->data()), attestationObjectLength.value(), 1))
+            return std::nullopt;
+
+        return result;
+    }
+
+    std::optional<uint64_t> authenticatorDataLength;
+    decoder >> authenticatorDataLength;
+    if (!authenticatorDataLength)
+        return std::nullopt;
+
+    result.authenticatorData = ArrayBuffer::create(authenticatorDataLength.value(), sizeof(uint8_t));
+    if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.authenticatorData->data()), authenticatorDataLength.value(), 1))
+        return std::nullopt;
+
+    std::optional<uint64_t> signatureLength;
+    decoder >> signatureLength;
+    if (!signatureLength)
+        return std::nullopt;
+
+    result.signature = ArrayBuffer::create(signatureLength.value(), sizeof(uint8_t));
+    if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.signature->data()), signatureLength.value(), 1))
+        return std::nullopt;
+
+    std::optional<uint64_t> userHandleLength;
+    decoder >> userHandleLength;
+    if (!userHandleLength)
+        return std::nullopt;
+
+    result.userHandle = ArrayBuffer::create(userHandleLength.value(), sizeof(uint8_t));
+    if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.userHandle->data()), userHandleLength.value(), 1))
+        return std::nullopt;
+
+    return result;
+}
+    
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUTHN)
index 2ae4035..25c46bc 100644 (file)
@@ -35,11 +35,10 @@ namespace WebCore {
 
 struct ExceptionData;
 struct PublicKeyCredentialCreationOptions;
+struct PublicKeyCredentialData;
 struct PublicKeyCredentialRequestOptions;
 
-using CreationCallback = Function<void(const Vector<uint8_t>&, const Vector<uint8_t>&)>;
-using RequestCallback = Function<void(const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&)>;
-using ExceptionCallback = Function<void(const WebCore::ExceptionData&)>;
+using Callback = Function<void(Variant<PublicKeyCredentialData, ExceptionData>&&)>;
 
 typedef void (^CompletionBlock)(SecKeyRef _Nullable referenceKey, NSArray * _Nullable certificates, NSError * _Nullable error);
 
@@ -50,8 +49,8 @@ public:
     LocalAuthenticator();
     virtual ~LocalAuthenticator() = default;
 
-    void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, CreationCallback&&, ExceptionCallback&&);
-    void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCallback&&, ExceptionCallback&&);
+    void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, Callback&&);
+    void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, Callback&&);
     bool isAvailable() const;
 
 protected:
index 40c8631..965d1f2 100644 (file)
@@ -32,6 +32,7 @@
 #import "COSEConstants.h"
 #import "ExceptionData.h"
 #import "PublicKeyCredentialCreationOptions.h"
+#import "PublicKeyCredentialData.h"
 #import "PublicKeyCredentialRequestOptions.h"
 #import <Security/SecItem.h>
 #import <pal/crypto/CryptoDigest.h>
@@ -115,7 +116,7 @@ LocalAuthenticator::LocalAuthenticator()
     RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessCredentials));
 }
 
-void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions& options, CreationCallback&& callback, ExceptionCallback&& exceptionCallback)
+void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions& options, Callback&& callback)
 {
     using namespace LocalAuthenticatorInternal;
 
@@ -124,7 +125,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
     ASSERT_UNUSED(hash, hash == hash);
     ASSERT_UNUSED(options, !options.rp.id.isEmpty());
     ASSERT_UNUSED(callback, callback);
-    exceptionCallback({ NotAllowedError, "No avaliable authenticators."_s });
+    callback(ExceptionData { NotAllowedError, "No avaliable authenticators."_s });
 #else
     // The following implements https://www.w3.org/TR/webauthn/#op-make-cred as of 5 December 2017.
     // Skip Step 4-5 as requireResidentKey and requireUserVerification are enforced.
@@ -139,7 +140,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
         }
     }
     if (!canFullfillPubKeyCredParams) {
-        exceptionCallback({ NotSupportedError, "The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters."_s });
+        callback(ExceptionData { NotSupportedError, "The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters."_s });
         return;
     }
 
@@ -158,7 +159,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
         OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &attributesArrayRef);
         if (status && status != errSecItemNotFound) {
             LOG_ERROR("Couldn't query Keychain: %d", status);
-            exceptionCallback({ UnknownError, "Unknown internal error."_s });
+            callback(ExceptionData { UnknownError, "Unknown internal error."_s });
             return;
         }
         auto retainAttributesArray = adoptCF(attributesArrayRef);
@@ -166,7 +167,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
         for (NSDictionary *nsAttributes in (NSArray *)attributesArrayRef) {
             NSData *nsCredentialId = nsAttributes[(id)kSecAttrApplicationLabel];
             if (excludeCredentialIds.contains(String(reinterpret_cast<const char*>(nsCredentialId.bytes), nsCredentialId.length))) {
-                exceptionCallback({ NotAllowedError, "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator."_s });
+                callback(ExceptionData { NotAllowedError, "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator."_s });
                 return;
             }
         }
@@ -180,17 +181,17 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
     if (![context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
         LOG_ERROR("Couldn't evaluate authentication with biometrics policy: %@", error);
         // FIXME(182767)
-        exceptionCallback({ NotAllowedError, "No avaliable authenticators."_s });
+        callback(ExceptionData { NotAllowedError, "No avaliable authenticators."_s });
         return;
     }
 
     NSString *reason = [NSString stringWithFormat:@"Allow %@ to create a public key credential for %@", (id)options.rp.id, (id)options.user.name];
     // FIXME(183534): Optimize the following nested callbacks and threading.
-    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reason reply:BlockPtr<void(BOOL, NSError *)>::fromCallable([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), options = crossThreadCopy(options), hash] (BOOL success, NSError *error) mutable {
+    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reason reply:BlockPtr<void(BOOL, NSError *)>::fromCallable([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), options = crossThreadCopy(options), hash] (BOOL success, NSError *error) mutable {
         ASSERT(!isMainThread());
         if (!success || error) {
             LOG_ERROR("Couldn't authenticate with biometrics: %@", error);
-            exceptionCallback({ NotAllowedError, "Couldn't get user consent."_s });
+            callback(ExceptionData { NotAllowedError, "Couldn't get user consent."_s });
             return;
         }
 
@@ -205,7 +206,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
         OSStatus status = SecItemDelete((__bridge CFDictionaryRef)deleteQuery);
         if (status && status != errSecItemNotFound) {
             LOG_ERROR("Couldn't detele older credential: %d", status);
-            exceptionCallback({ UnknownError, "Unknown internal error."_s });
+            callback(ExceptionData { UnknownError, "Unknown internal error."_s });
             return;
         }
 
@@ -213,11 +214,11 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
         // FIXME(183534)
         if (!weakThis)
             return;
-        weakThis->issueClientCertificate(options.rp.id, options.user.name, hash, BlockPtr<void(SecKeyRef, NSArray *, NSError *)>::fromCallable([callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), options = crossThreadCopy(options)] (_Nullable SecKeyRef privateKey, NSArray * _Nullable certificates, NSError * _Nullable error) {
+        weakThis->issueClientCertificate(options.rp.id, options.user.name, hash, BlockPtr<void(SecKeyRef, NSArray *, NSError *)>::fromCallable([callback = WTFMove(callback), options = crossThreadCopy(options)] (_Nullable SecKeyRef privateKey, NSArray * _Nullable certificates, NSError * _Nullable error) {
             ASSERT(!isMainThread());
             if (error) {
                 LOG_ERROR("Couldn't attest: %@", error);
-                exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                 return;
             }
             // Attestation Certificate and Attestation Issuing CA
@@ -250,7 +251,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
                 OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)credentialIdQuery, &attributesRef);
                 if (status) {
                     LOG_ERROR("Couldn't get Credential ID: %d", status);
-                    exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                    callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                     return;
                 }
                 auto retainAttributes = adoptCF(attributesRef);
@@ -271,7 +272,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
                 status = SecItemUpdate((__bridge CFDictionaryRef)updateQuery, (__bridge CFDictionaryRef)updateParams);
                 if (status) {
                     LOG_ERROR("Couldn't update the Keychain item: %d", status);
-                    exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                    callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                     return;
                 }
             }
@@ -304,7 +305,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
                     auto retainError = adoptCF(errorRef);
                     if (errorRef) {
                         LOG_ERROR("Couldn't export the public key: %@", (NSError*)errorRef);
-                        exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                        callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                         return;
                     }
                     ASSERT(((NSData *)publicKeyDataRef.get()).length == (1 + 2 * ES256KeySizeInBytes)); // 04 | X | Y
@@ -325,7 +326,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
                 auto cosePublicKey = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(publicKeyMap)));
                 if (!cosePublicKey) {
                     LOG_ERROR("Couldn't encode the public key into COSE binaries.");
-                    exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                    callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                     return;
                 }
                 attestedCredentialData.appendVector(cosePublicKey.value());
@@ -347,7 +348,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
                     auto retainError = adoptCF(errorRef);
                     if (errorRef) {
                         LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
-                        exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                        callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                         return;
                     }
                     auto nsSignature = (NSData *)signatureRef.get();
@@ -374,17 +375,17 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi
             auto attestationObject = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(attestationObjectMap)));
             if (!attestationObject) {
                 LOG_ERROR("Couldn't encode the attestation object.");
-                exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                 return;
             }
 
-            callback(credentialId, attestationObject.value());
+            callback(PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), true, nullptr, ArrayBuffer::create(attestationObject.value().data(), attestationObject.value().size()), nullptr, nullptr, nullptr });
         }).get());
     }).get()];
 #endif // !PLATFORM(IOS)
 }
 
-void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, RequestCallback&& callback, ExceptionCallback&& exceptionCallback)
+void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, Callback&& callback)
 {
     using namespace LocalAuthenticatorInternal;
 
@@ -393,7 +394,7 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
     ASSERT_UNUSED(hash, hash == hash);
     ASSERT_UNUSED(options, !options.rpId.isEmpty());
     ASSERT_UNUSED(callback, callback);
-    exceptionCallback({ NotAllowedError, "No avaliable authenticators."_s });
+    callback(ExceptionData { NotAllowedError, "No avaliable authenticators."_s });
 #else
     // The following implements https://www.w3.org/TR/webauthn/#op-get-assertion as of 5 December 2017.
     // Skip Step 2 as requireUserVerification is enforced.
@@ -402,7 +403,7 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
     // Step 3-5. Unlike the spec, if an allow list is provided and there is no intersection between existing ones and the allow list, we always return NotAllowedError.
     HashSet<String> allowCredentialIds = produceHashSet(options.allowCredentials);
     if (!options.allowCredentials.isEmpty() && allowCredentialIds.isEmpty()) {
-        exceptionCallback({ NotAllowedError, "No matched credentials are found in the platform attached authenticator."_s });
+        callback(ExceptionData { NotAllowedError, "No matched credentials are found in the platform attached authenticator."_s });
         return;
     }
 
@@ -418,7 +419,7 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
     OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &attributesArrayRef);
     if (status && status != errSecItemNotFound) {
         LOG_ERROR("Couldn't query Keychain: %d", status);
-        exceptionCallback({ UnknownError, "Unknown internal error."_s });
+        callback(ExceptionData { UnknownError, "Unknown internal error."_s });
         return;
     }
     auto retainAttributesArray = adoptCF(attributesArrayRef);
@@ -436,7 +437,7 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
         intersectedCredentialsAttributes = result;
     }
     if (!intersectedCredentialsAttributes.count) {
-        exceptionCallback({ NotAllowedError, "No matched credentials are found in the platform attached authenticator."_s });
+        callback(ExceptionData { NotAllowedError, "No matched credentials are found in the platform attached authenticator."_s });
         return;
     }
 
@@ -452,7 +453,7 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
         auto retainContext = adoptNS(context);
         LOG_ERROR("Couldn't evaluate authentication with biometrics policy: %@", error);
         // FIXME(182767)
-        exceptionCallback({ NotAllowedError, "No avaliable authenticators."_s });
+        callback(ExceptionData { NotAllowedError, "No avaliable authenticators."_s });
         return;
     }
 
@@ -462,11 +463,11 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
     Vector<uint8_t> userhandle;
     NSData *nsUserhandle = selectedCredentialAttributes[(id)kSecAttrApplicationTag];
     userhandle.append(reinterpret_cast<const uint8_t*>(nsUserhandle.bytes), nsUserhandle.length);
-    auto reply = BlockPtr<void(BOOL, NSError *)>::fromCallable([callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), rpId = options.rpId.isolatedCopy(), hash, credentialId = WTFMove(credentialId), userhandle = WTFMove(userhandle), context = adoptNS(context)] (BOOL success, NSError *error) mutable {
+    auto reply = BlockPtr<void(BOOL, NSError *)>::fromCallable([callback = WTFMove(callback), rpId = options.rpId.isolatedCopy(), hash, credentialId = WTFMove(credentialId), userhandle = WTFMove(userhandle), context = adoptNS(context)] (BOOL success, NSError *error) mutable {
         ASSERT(!isMainThread());
         if (!success || error) {
             LOG_ERROR("Couldn't authenticate with biometrics: %@", error);
-            exceptionCallback({ NotAllowedError, "Couldn't get user consent."_s });
+            callback(ExceptionData { NotAllowedError, "Couldn't get user consent."_s });
             return;
         }
 
@@ -490,7 +491,7 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
             OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &privateKeyRef);
             if (status) {
                 LOG_ERROR("Couldn't get the private key reference: %d", status);
-                exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                 return;
             }
             auto privateKey = adoptCF(privateKeyRef);
@@ -504,7 +505,7 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
             auto retainError = adoptCF(errorRef);
             if (errorRef) {
                 LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
-                exceptionCallback({ UnknownError, "Unknown internal error."_s });
+                callback(ExceptionData { UnknownError, "Unknown internal error."_s });
                 return;
             }
             auto nsSignature = (NSData *)signatureRef.get();
@@ -512,7 +513,7 @@ void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK
         }
 
         // Step 13.
-        callback(credentialId, authData, signature, userhandle);
+        callback(PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), false, nullptr, nullptr, ArrayBuffer::create(authData.data(), authData.size()), ArrayBuffer::create(signature.data(), signature.size()), ArrayBuffer::create(userhandle.data(), userhandle.size()) });
     });
 
     // FIXME(183533): Use userhandle instead of username due to the stated Keychain limitations.
index 85c5afa..3e5e4bd 100644 (file)
@@ -27,6 +27,7 @@
 #include "VRStageParameters.h"
 
 #include <JavaScriptCore/GenericTypedArrayViewInlines.h>
+#include <JavaScriptCore/HeapInlines.h>
 #include <JavaScriptCore/JSGenericTypedArrayViewInlines.h>
 
 namespace WebCore {
index 7801b30..e708db4 100644 (file)
@@ -45,7 +45,6 @@ Modules/cache/WorkerGlobalScopeCaches.cpp
 
 Modules/credentialmanagement/BasicCredential.cpp
 Modules/credentialmanagement/CredentialsContainer.cpp
-Modules/credentialmanagement/CredentialsMessenger.cpp
 Modules/credentialmanagement/NavigatorCredentials.cpp
 
 Modules/entriesapi/ErrorCallback.cpp
@@ -247,10 +246,8 @@ Modules/webaudio/WaveShaperDSPKernel.cpp
 Modules/webaudio/WaveShaperNode.cpp
 Modules/webaudio/WaveShaperProcessor.cpp
 
-Modules/webauthn/AuthenticatorAssertionResponse.cpp
-Modules/webauthn/AuthenticatorAttestationResponse.cpp
-Modules/webauthn/AuthenticatorManager.cpp
-Modules/webauthn/AuthenticatorResponse.cpp
+Modules/webauthn/AuthenticatorCoordinator.cpp
+Modules/webauthn/AuthenticatorCoordinatorClient.cpp
 Modules/webauthn/PublicKeyCredential.cpp
 Modules/webauthn/cbor/CBORReader.cpp
 Modules/webauthn/cbor/CBORValue.cpp
index f40f41e..1e63243 100644 (file)
                57303C222009AF0300355965 /* JSAuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C212009AEF600355965 /* JSAuthenticatorAttestationResponse.h */; };
                57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; };
                57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */; };
-               57303C4620105D2F00355965 /* AuthenticatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               57303C4620105D2F00355965 /* AuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; };
                5739E12F1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */; };
                574F55E0204F3ACE002948C6 /* LocalAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 574F55DE204F3744002948C6 /* LocalAuthenticator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5750A9821E6A150800705C4A /* JSEcKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9801E6A150800705C4A /* JSEcKeyParams.h */; };
                5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; };
                5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; };
-               5760827220215A5500116678 /* CredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* CredentialsMessenger.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               5760827A2024EA5C00116678 /* MockCredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760827820244DAB00116678 /* MockCredentialsMessenger.h */; };
-               5760827B2024ED2900116678 /* MockCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */; };
-               5760828620256AFA00116678 /* JSMockCredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082822025679700116678 /* JSMockCredentialsMessenger.h */; };
-               5760828820256AFD00116678 /* JSMockCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 576082812025679600116678 /* JSMockCredentialsMessenger.cpp */; };
+               5760827220215A5500116678 /* AuthenticatorCoordinatorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               5760827A2024EA5C00116678 /* MockAuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */; };
+               5760827B2024ED2900116678 /* MockAuthenticatorCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */; };
                5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; };
                576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; };
                576814451E70CB1F00E77754 /* JSAesKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814431E70CB1000E77754 /* JSAesKeyParams.h */; };
                57B5F7F91E5BE84000F34F90 /* CryptoAlgorithmAES_GCM.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F7F71E5BE84000F34F90 /* CryptoAlgorithmAES_GCM.h */; };
                57B5F8091E5D1A9800F34F90 /* CryptoAlgorithmAesGcmParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F8081E5D1A9800F34F90 /* CryptoAlgorithmAesGcmParams.h */; };
                57B5F8101E5E2A4E00F34F90 /* JSAesGcmParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F80B1E5D22DA00F34F90 /* JSAesGcmParams.h */; };
-               57C7A68C1E56967500C67D71 /* BasicCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57C7A68B1E56967500C67D71 /* BasicCredential.h */; };
+               57C7A68C1E56967500C67D71 /* BasicCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57C7A68B1E56967500C67D71 /* BasicCredential.h */; settings = {ATTRIBUTES = (Private, ); }; };
                57C7A69F1E57917800C67D71 /* JSBasicCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57C7A69D1E57910D00C67D71 /* JSBasicCredential.h */; };
                57D0018D1DD5413200ED19D9 /* JSCryptoKeyUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D0018C1DD5413200ED19D9 /* JSCryptoKeyUsage.h */; };
                57D846281FE8960500CA3682 /* NavigatorCredentials.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846261FE895F800CA3682 /* NavigatorCredentials.h */; };
-               57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */; };
+               57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */; settings = {ATTRIBUTES = (Private, ); }; };
                57D846351FEAFCD300CA3682 /* JSPublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */; };
+               57DCED672140775B0016B847 /* JSMockAuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */; };
+               57DCED69214077640016B847 /* JSMockAuthenticatorCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */; };
+               57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                57E1E5A31E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5A11E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h */; };
                57E1E5A71E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5A61E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h */; };
                57E1E5AD1E8DD09B00EE37C9 /* JSAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5AB1E8DD09B00EE37C9 /* JSAesCtrParams.h */; };
                57303BBE2006E00400355965 /* CBORReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORReader.cpp; sourceTree = "<group>"; };
                57303BBF2006E00C00355965 /* CBORReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBORReader.h; sourceTree = "<group>"; };
                57303BCF20087A8300355965 /* AuthenticatorResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorResponse.h; sourceTree = "<group>"; };
-               57303BD020087A8300355965 /* AuthenticatorResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorResponse.cpp; sourceTree = "<group>"; };
                57303BD120087A8300355965 /* AuthenticatorResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorResponse.idl; sourceTree = "<group>"; };
                57303BDD20095B2600355965 /* JSAuthenticatorResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorResponse.h; sourceTree = "<group>"; };
                57303BDE20095B2700355965 /* JSAuthenticatorResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponse.cpp; sourceTree = "<group>"; };
                57303C132009A25700355965 /* JSPublicKeyCredentialCreationOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredentialCreationOptions.h; sourceTree = "<group>"; };
                57303C142009A25700355965 /* JSPublicKeyCredentialCreationOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredentialCreationOptions.cpp; sourceTree = "<group>"; };
                57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorAttestationResponse.h; sourceTree = "<group>"; };
-               57303C1C2009A98600355965 /* AuthenticatorAttestationResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAttestationResponse.cpp; sourceTree = "<group>"; };
                57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorAttestationResponse.idl; sourceTree = "<group>"; };
                57303C202009AEF500355965 /* JSAuthenticatorAttestationResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorAttestationResponse.cpp; sourceTree = "<group>"; };
                57303C212009AEF600355965 /* JSAuthenticatorAttestationResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorAttestationResponse.h; sourceTree = "<group>"; };
                57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorAssertionResponse.h; sourceTree = "<group>"; };
-               57303C282009B2FC00355965 /* AuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; };
                57303C292009B2FC00355965 /* AuthenticatorAssertionResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorAssertionResponse.idl; sourceTree = "<group>"; };
                57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorAssertionResponse.h; sourceTree = "<group>"; };
                57303C2E2009B7DA00355965 /* JSAuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; };
-               57303C4320105B3D00355965 /* AuthenticatorManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorManager.h; sourceTree = "<group>"; };
-               57303C4420105B3D00355965 /* AuthenticatorManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorManager.cpp; sourceTree = "<group>"; };
+               57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorCoordinator.h; sourceTree = "<group>"; };
+               57303C4420105B3D00355965 /* AuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
                573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmParameters.h; sourceTree = "<group>"; };
                5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoAlgorithmParameters.h; sourceTree = "<group>"; };
                5739E1301DAC7FD100E14383 /* JSCryptoAlgorithmParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoAlgorithmParameters.cpp; sourceTree = "<group>"; };
                5754719A1ECE5D2A00DD63B2 /* JSRsaPssParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaPssParams.cpp; sourceTree = "<group>"; };
                5760824F20118D8D00116678 /* JSBasicCredentialCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBasicCredentialCustom.cpp; sourceTree = "<group>"; };
                576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; };
-               576082702021513F00116678 /* CredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CredentialsMessenger.h; sourceTree = "<group>"; };
-               5760827820244DAB00116678 /* MockCredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockCredentialsMessenger.h; sourceTree = "<group>"; };
-               5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockCredentialsMessenger.cpp; sourceTree = "<group>"; };
-               57608280202556F400116678 /* MockCredentialsMessenger.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockCredentialsMessenger.idl; sourceTree = "<group>"; };
-               576082812025679600116678 /* JSMockCredentialsMessenger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockCredentialsMessenger.cpp; sourceTree = "<group>"; };
-               576082822025679700116678 /* JSMockCredentialsMessenger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockCredentialsMessenger.h; sourceTree = "<group>"; };
-               57608293202BA95300116678 /* CredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CredentialsMessenger.cpp; sourceTree = "<group>"; };
+               576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorCoordinatorClient.h; sourceTree = "<group>"; };
+               5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockAuthenticatorCoordinator.h; sourceTree = "<group>"; };
+               5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockAuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
+               57608280202556F400116678 /* MockAuthenticatorCoordinator.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockAuthenticatorCoordinator.idl; sourceTree = "<group>"; };
+               57608293202BA95300116678 /* AuthenticatorCoordinatorClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorCoordinatorClient.cpp; sourceTree = "<group>"; };
                576814281E6F98AD00E77754 /* EcdhKeyDeriveParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = EcdhKeyDeriveParams.idl; sourceTree = "<group>"; };
                576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmEcdhKeyDeriveParams.h; sourceTree = "<group>"; };
                576814341E6FE3E800E77754 /* CryptoAlgorithmECDHMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmECDHMac.cpp; sourceTree = "<group>"; };
                57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PublicKeyCredential.idl; sourceTree = "<group>"; };
                57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredential.h; sourceTree = "<group>"; };
                57D846311FEAFC2F00CA3682 /* JSPublicKeyCredential.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredential.cpp; sourceTree = "<group>"; };
+               57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockAuthenticatorCoordinator.h; sourceTree = "<group>"; };
+               57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockAuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
+               57DCED72214305F00016B847 /* PublicKeyCredentialData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PublicKeyCredentialData.h; sourceTree = "<group>"; };
                57E1E5A01E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_CTR.cpp; sourceTree = "<group>"; };
                57E1E5A11E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAES_CTR.h; sourceTree = "<group>"; };
                57E1E5A61E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesCtrParams.h; sourceTree = "<group>"; };
                                A7BE7EDE14C9175A0014489D /* MallocStatistics.idl */,
                                CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
                                CD5393CC175DCCE600C07123 /* MemoryInfo.idl */,
+                               5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */,
+                               5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */,
+                               57608280202556F400116678 /* MockAuthenticatorCoordinator.idl */,
                                CDF4B7211E03BF8100E235A2 /* MockCDMFactory.cpp */,
                                CDF4B7221E03BF8100E235A2 /* MockCDMFactory.h */,
                                CDF4B71F1E03BF6F00E235A2 /* MockCDMFactory.idl */,
                                A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */,
                                A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */,
                                A19AEA1C1AAA7C4900B52B25 /* MockContentFilterSettings.idl */,
-                               5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */,
-                               5760827820244DAB00116678 /* MockCredentialsMessenger.h */,
-                               57608280202556F400116678 /* MockCredentialsMessenger.idl */,
                                51058AD71D679257009A538C /* MockGamepad.cpp */,
                                51058AD81D679257009A538C /* MockGamepad.h */,
                                51058AD91D679257009A538C /* MockGamepadProvider.cpp */,
                                A7B4EA6914C9348400C8F5BF /* JSMallocStatistics.h */,
                                CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */,
                                CD5393D2175E018600C07123 /* JSMemoryInfo.h */,
+                               57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */,
+                               57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */,
                                CDF4B72D1E03CA4A00E235A2 /* JSMockCDMFactory.cpp */,
                                CDF4B72E1E03CA4A00E235A2 /* JSMockCDMFactory.h */,
                                A19AEA1D1AAA806E00B52B25 /* JSMockContentFilterSettings.cpp */,
                                A19AEA1E1AAA806E00B52B25 /* JSMockContentFilterSettings.h */,
-                               576082812025679600116678 /* JSMockCredentialsMessenger.cpp */,
-                               576082822025679700116678 /* JSMockCredentialsMessenger.h */,
                                2D6F3E921C1F85550061DBD4 /* JSMockPageOverlay.cpp */,
                                2D6F3E931C1F85550061DBD4 /* JSMockPageOverlay.h */,
                                A146D3201F99CA3E00D29196 /* JSMockPaymentAddress.cpp */,
                                77D510181ED7159900DA4C87 /* CredentialsContainer.cpp */,
                                77D510161ED6021B00DA4C87 /* CredentialsContainer.h */,
                                57D846291FE99F6300CA3682 /* CredentialsContainer.idl */,
-                               57608293202BA95300116678 /* CredentialsMessenger.cpp */,
-                               576082702021513F00116678 /* CredentialsMessenger.h */,
                                57D846241FE895F500CA3682 /* NavigatorCredentials.cpp */,
                                57D846261FE895F800CA3682 /* NavigatorCredentials.h */,
                                57D846251FE895F600CA3682 /* NavigatorCredentials.idl */,
                        children = (
                                57303BB32006C6ED00355965 /* cbor */,
                                574F55DD204F3744002948C6 /* cocoa */,
-                               57303C282009B2FC00355965 /* AuthenticatorAssertionResponse.cpp */,
                                57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */,
                                57303C292009B2FC00355965 /* AuthenticatorAssertionResponse.idl */,
-                               57303C1C2009A98600355965 /* AuthenticatorAttestationResponse.cpp */,
                                57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */,
                                57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */,
-                               57303C4420105B3D00355965 /* AuthenticatorManager.cpp */,
-                               57303C4320105B3D00355965 /* AuthenticatorManager.h */,
-                               57303BD020087A8300355965 /* AuthenticatorResponse.cpp */,
+                               57303C4420105B3D00355965 /* AuthenticatorCoordinator.cpp */,
+                               57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */,
+                               57608293202BA95300116678 /* AuthenticatorCoordinatorClient.cpp */,
+                               576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */,
                                57303BCF20087A8300355965 /* AuthenticatorResponse.h */,
                                57303BD120087A8300355965 /* AuthenticatorResponse.idl */,
                                574F55DC204F3732002948C6 /* COSEConstants.h */,
                                57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */,
                                57303BE62009747A00355965 /* PublicKeyCredentialCreationOptions.h */,
                                57303BE82009747A00355965 /* PublicKeyCredentialCreationOptions.idl */,
+                               57DCED72214305F00016B847 /* PublicKeyCredentialData.h */,
                                57303BEC200980BF00355965 /* PublicKeyCredentialDescriptor.h */,
                                57303BEE200980BF00355965 /* PublicKeyCredentialDescriptor.idl */,
                                57303C06200998F800355965 /* PublicKeyCredentialRequestOptions.h */,
                                53ED3FDF167A88E7006762E6 /* JSInternalSettingsGenerated.h in Headers */,
                                A740B59514C935AB00A77FA4 /* JSMallocStatistics.h in Headers */,
                                CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */,
+                               57DCED672140775B0016B847 /* JSMockAuthenticatorCoordinator.h in Headers */,
                                538EC9331F99B9F7004D22A8 /* JSMockCDMFactory.h in Headers */,
                                A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */,
-                               5760828620256AFA00116678 /* JSMockCredentialsMessenger.h in Headers */,
                                538EC9341F99B9F7004D22A8 /* JSMockPageOverlay.h in Headers */,
                                A146D3231F99D0EF00D29196 /* JSMockPaymentAddress.h in Headers */,
                                A146D31B1F99BCFB00D29196 /* JSMockPaymentCoordinator.h in Headers */,
                                427DA71E13735DFA007C57FB /* JSServiceWorkerInternals.h in Headers */,
                                EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
                                CDC26B41160A8CCE0026757B /* LegacyMockCDM.h in Headers */,
+                               5760827A2024EA5C00116678 /* MockAuthenticatorCoordinator.h in Headers */,
                                A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
                                A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
-                               5760827A2024EA5C00116678 /* MockCredentialsMessenger.h in Headers */,
                                51058ADC1D6792C1009A538C /* MockGamepad.h in Headers */,
                                51058ADE1D6792C1009A538C /* MockGamepadProvider.h in Headers */,
                                4157EBFB1E3AB67F00AC9FE9 /* MockLibWebRTCPeerConnection.h in Headers */,
                                514C764C0CE9234E007EF3CD /* AuthenticationMac.h in Headers */,
                                57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */,
                                57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */,
-                               57303C4620105D2F00355965 /* AuthenticatorManager.h in Headers */,
+                               57303C4620105D2F00355965 /* AuthenticatorCoordinator.h in Headers */,
+                               5760827220215A5500116678 /* AuthenticatorCoordinatorClient.h in Headers */,
                                57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */,
                                A501920E132EBF2E008BFE55 /* Autocapitalize.h in Headers */,
                                A5A7AA43132F0ECC00D3A3C2 /* AutocapitalizeTypes.h in Headers */,
                                77D5100D1ED5E29500DA4C87 /* CredentialCreationOptions.h in Headers */,
                                77D5100B1ED5E28800DA4C87 /* CredentialRequestOptions.h in Headers */,
                                77D510171ED6022200DA4C87 /* CredentialsContainer.h in Headers */,
-                               5760827220215A5500116678 /* CredentialsMessenger.h in Headers */,
                                51A052331058774F00CC9E95 /* CredentialStorage.h in Headers */,
                                2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */,
                                E1C416120F6562FD0092D2FB /* CrossOriginAccessControl.h in Headers */,
                                FF945ECC161F7F3600971BC8 /* PseudoElement.h in Headers */,
                                57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */,
                                57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */,
+                               57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */,
                                57303BEF200980C600355965 /* PublicKeyCredentialDescriptor.h in Headers */,
                                57303C0A20099BAD00355965 /* PublicKeyCredentialRequestOptions.h in Headers */,
                                57303BEB20097F4000355965 /* PublicKeyCredentialType.h in Headers */,
                                53ED3FDE167A88E7006762E6 /* JSInternalSettingsGenerated.cpp in Sources */,
                                538EC9321F99B9F7004D22A8 /* JSMallocStatistics.cpp in Sources */,
                                CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */,
+                               57DCED69214077640016B847 /* JSMockAuthenticatorCoordinator.cpp in Sources */,
                                CDF4B7321E03D06000E235A2 /* JSMockCDMFactory.cpp in Sources */,
                                A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
-                               5760828820256AFD00116678 /* JSMockCredentialsMessenger.cpp in Sources */,
                                2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */,
                                A146D3221F99D0EC00D29196 /* JSMockPaymentAddress.cpp in Sources */,
                                A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */,
                                427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */,
                                EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
                                CDC26B40160A8CC60026757B /* LegacyMockCDM.cpp in Sources */,
+                               5760827B2024ED2900116678 /* MockAuthenticatorCoordinator.cpp in Sources */,
                                CDF4B7311E03D00700E235A2 /* MockCDMFactory.cpp in Sources */,
                                A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */,
                                A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */,
-                               5760827B2024ED2900116678 /* MockCredentialsMessenger.cpp in Sources */,
                                51058ADB1D6792C1009A538C /* MockGamepad.cpp in Sources */,
                                51058ADD1D6792C1009A538C /* MockGamepadProvider.cpp in Sources */,
                                4157EBFA1E3AB67900AC9FE9 /* MockLibWebRTCPeerConnection.cpp in Sources */,
index 344607b..f3ac345 100644 (file)
@@ -24,6 +24,7 @@
 #include "AlternativeTextClient.h"
 #include "ApplicationCacheStorage.h"
 #include "ApplicationStateChangeListener.h"
+#include "AuthenticatorCoordinator.h"
 #include "BackForwardClient.h"
 #include "BackForwardController.h"
 #include "CSSAnimationController.h"
@@ -255,6 +256,9 @@ Page::Page(PageConfiguration&& pageConfiguration)
 #if ENABLE(APPLE_PAY)
     , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*pageConfiguration.paymentCoordinatorClient))
 #endif
+#if ENABLE(WEB_AUTHN)
+    , m_authenticatorCoordinator(makeUniqueRef<AuthenticatorCoordinator>(WTFMove(pageConfiguration.authenticatorCoordinatorClient)))
+#endif
 #if ENABLE(APPLICATION_MANIFEST)
     , m_applicationManifest(pageConfiguration.applicationManifest)
 #endif
index dba4f0f..a78cca4 100644 (file)
@@ -76,6 +76,7 @@ class IDBConnectionToServer;
 
 class AlternativeTextClient;
 class ApplicationCacheStorage;
+class AuthenticatorCoordinator;
 class BackForwardController;
 class BackForwardClient;
 class CacheStorageProvider;
@@ -410,6 +411,10 @@ public:
     WEBCORE_EXPORT void setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&&);
 #endif
 
+#if ENABLE(WEB_AUTHN)
+    AuthenticatorCoordinator& authenticatorCoordinator() { return m_authenticatorCoordinator.get(); }
+#endif
+
 #if ENABLE(APPLICATION_MANIFEST)
     const std::optional<ApplicationManifest>& applicationManifest() const { return m_applicationManifest; }
 #endif
@@ -901,6 +906,10 @@ private:
     std::unique_ptr<PaymentCoordinator> m_paymentCoordinator;
 #endif
 
+#if ENABLE(WEB_AUTHN)
+    UniqueRef<AuthenticatorCoordinator> m_authenticatorCoordinator;
+#endif
+
 #if ENABLE(APPLICATION_MANIFEST)
     std::optional<ApplicationManifest> m_applicationManifest;
 #endif
index cd4005b..14c9915 100644 (file)
 #include "VisitedLinkStore.h"
 #include "WebGLStateTracker.h"
 
+#if ENABLE(WEB_AUTHN)
+#include "AuthenticatorCoordinatorClient.h"
+#endif
+
 namespace WebCore {
 
 PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider)
index 3a73457..60bdec7 100644 (file)
@@ -38,6 +38,7 @@ namespace WebCore {
 
 class AlternativeTextClient;
 class ApplicationCacheStorage;
+class AuthenticatorCoordinatorClient;
 class BackForwardClient;
 class CacheStorageProvider;
 class ChromeClient;
@@ -80,6 +81,10 @@ public:
     PaymentCoordinatorClient* paymentCoordinatorClient { nullptr };
 #endif
 
+#if ENABLE(WEB_AUTHN)
+    std::unique_ptr<AuthenticatorCoordinatorClient> authenticatorCoordinatorClient;
+#endif
+
 #if ENABLE(APPLICATION_MANIFEST)
     std::optional<ApplicationManifest> applicationManifest;
 #endif
index f75ab24..80d5bd8 100644 (file)
 #endif
 
 #if ENABLE(WEB_AUTHN)
-#include "AuthenticatorManager.h"
-#include "MockCredentialsMessenger.h"
+#include "AuthenticatorCoordinator.h"
+#include "MockAuthenticatorCoordinator.h"
 #endif
 
 using JSC::CallData;
@@ -549,8 +549,11 @@ Internals::Internals(Document& document)
 #endif
 
 #if ENABLE(WEB_AUTHN)
-    m_mockCredentialsMessenger = std::make_unique<MockCredentialsMessenger>(*this);
-    AuthenticatorManager::singleton().setMessenger(*m_mockCredentialsMessenger);
+    if (document.page()) {
+        auto mockAuthenticatorCoordinator = std::make_unique<MockAuthenticatorCoordinator>();
+        m_mockAuthenticatorCoordinator = makeWeakPtr(mockAuthenticatorCoordinator.get());
+        document.page()->authenticatorCoordinator().setClient(WTFMove(mockAuthenticatorCoordinator));
+    }
 #endif
 }
 
@@ -4620,9 +4623,9 @@ MockPaymentCoordinator& Internals::mockPaymentCoordinator() const
 #endif
 
 #if ENABLE(WEB_AUTHN)
-MockCredentialsMessenger& Internals::mockCredentialsMessenger() const
+MockAuthenticatorCoordinator& Internals::mockAuthenticatorCoordinator() const
 {
-    return *m_mockCredentialsMessenger;
+    return *m_mockAuthenticatorCoordinator;
 }
 #endif
 
index b4a50ba..2417ee8 100644 (file)
@@ -77,7 +77,7 @@ class MediaStreamTrack;
 class MemoryInfo;
 class MockCDMFactory;
 class MockContentFilterSettings;
-class MockCredentialsMessenger;
+class MockAuthenticatorCoordinator;
 class MockPageOverlay;
 class MockPaymentCoordinator;
 class NodeList;
@@ -697,7 +697,7 @@ public:
     void testIncomingSyncIPCMessageWhileWaitingForSyncReply();
 
 #if ENABLE(WEB_AUTHN)
-    MockCredentialsMessenger& mockCredentialsMessenger() const;
+    MockAuthenticatorCoordinator& mockAuthenticatorCoordinator() const;
 #endif
 
     bool isSystemPreviewLink(Element&) const;
@@ -763,7 +763,7 @@ private:
 #endif
 
 #if ENABLE(WEB_AUTHN)
-    std::unique_ptr<MockCredentialsMessenger> m_mockCredentialsMessenger;
+    WeakPtr<MockAuthenticatorCoordinator> m_mockAuthenticatorCoordinator;
 #endif
 };
 
index 078846e..2184fd2 100644 (file)
@@ -646,7 +646,7 @@ enum CompositingPolicy {
     [EnabledAtRuntime=WebAnimations] void pauseTimeline(AnimationTimeline timeline);
     [EnabledAtRuntime=WebAnimations] void setTimelineCurrentTime(AnimationTimeline timeline, double currentTime);
     [Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator;
-    [Conditional=WEB_AUTHN] readonly attribute MockCredentialsMessenger mockCredentialsMessenger;
+    [Conditional=WEB_AUTHN] readonly attribute MockAuthenticatorCoordinator mockAuthenticatorCoordinator;
 
     boolean isSystemPreviewLink(Element element);
     boolean isSystemPreviewImage(Element element);
diff --git a/Source/WebCore/testing/MockAuthenticatorCoordinator.cpp b/Source/WebCore/testing/MockAuthenticatorCoordinator.cpp
new file mode 100644 (file)
index 0000000..cd7d69a
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MockAuthenticatorCoordinator.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include "Internals.h"
+#include <WebCore/PublicKeyCredentialData.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+void MockAuthenticatorCoordinator::setCreationReturnBundle(const BufferSource& credentialId, const BufferSource& attestationObject)
+{
+    ASSERT(!m_credentialId && !m_attestationObject);
+    m_credentialId = ArrayBuffer::create(credentialId.data(), credentialId.length());
+    m_attestationObject = ArrayBuffer::create(attestationObject.data(), attestationObject.length());
+}
+
+void MockAuthenticatorCoordinator::setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle)
+{
+    ASSERT(!m_credentialId && !m_authenticatorData && !m_signature && !m_userHandle);
+    m_credentialId = ArrayBuffer::create(credentialId.data(), credentialId.length());
+    m_authenticatorData = ArrayBuffer::create(authenticatorData.data(), authenticatorData.length());
+    m_signature = ArrayBuffer::create(signature.data(), signature.length());
+    m_userHandle = ArrayBuffer::create(userHandle.data(), userHandle.length());
+}
+
+void MockAuthenticatorCoordinator::makeCredential(const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&& handler)
+{
+    if (!setRequestCompletionHandler(WTFMove(handler)))
+        return;
+
+    if (m_didTimeOut) {
+        m_didTimeOut = false;
+        return;
+    }
+    if (m_didUserCancel) {
+        m_didUserCancel = false;
+        requestReply({ }, { NotAllowedError, "User cancelled."_s });
+        return;
+    }
+    if (m_credentialId) {
+        ASSERT(m_attestationObject);
+        requestReply(PublicKeyCredentialData { WTFMove(m_credentialId), true, nullptr, WTFMove(m_attestationObject), nullptr, nullptr, nullptr }, { });
+        m_credentialId = nullptr;
+        m_attestationObject = nullptr;
+        return;
+    }
+    ASSERT_NOT_REACHED();
+}
+
+void MockAuthenticatorCoordinator::getAssertion(const Vector<uint8_t>&, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&& handler)
+{
+    if (!setRequestCompletionHandler(WTFMove(handler)))
+        return;
+
+    if (m_didTimeOut) {
+        m_didTimeOut = false;
+        return;
+    }
+    if (m_didUserCancel) {
+        m_didUserCancel = false;
+        requestReply({ }, { NotAllowedError, "User cancelled."_s });
+        return;
+    }
+    if (m_credentialId) {
+        ASSERT(m_authenticatorData && m_signature && m_userHandle);
+        requestReply(PublicKeyCredentialData { WTFMove(m_credentialId), false, nullptr, nullptr, WTFMove(m_authenticatorData), WTFMove(m_signature), WTFMove(m_userHandle) }, { });
+        m_credentialId = nullptr;
+        m_authenticatorData = nullptr;
+        m_signature = nullptr;
+        m_userHandle = nullptr;
+        return;
+    }
+    ASSERT_NOT_REACHED();
+}
+
+void MockAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&& handler)
+{
+    auto messageId = addQueryCompletionHandler(WTFMove(handler));
+    if (m_didUserVerifyingPlatformAuthenticatorPresent) {
+        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, true);
+        m_didUserVerifyingPlatformAuthenticatorPresent = false;
+    } else
+        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, false);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUTHN)
 
 #if ENABLE(WEB_AUTHN)
 
+#include "AuthenticatorCoordinatorClient.h"
 #include "BufferSource.h"
-#include "CredentialsMessenger.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
 
 class Internals;
 
-class MockCredentialsMessenger final : public CredentialsMessenger {
+class MockAuthenticatorCoordinator final : public AuthenticatorCoordinatorClient {
 public:
-    explicit MockCredentialsMessenger(Internals&);
-    ~MockCredentialsMessenger();
-
     void setDidTimeOut() { m_didTimeOut = true; }
     void setDidUserCancel() { m_didUserCancel = true; }
     void setDidUserVerifyingPlatformAuthenticatorPresent() { m_didUserVerifyingPlatformAuthenticatorPresent = true; }
     void setCreationReturnBundle(const BufferSource& credentialId, const BufferSource& attestationObject);
     void setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle);
 
-    void ref();
-    void deref();
+    // RefCounted is required for JS wrapper. Therefore, fake them to compile.
+    void ref() const { }
+    void deref() const { }
 
 private:
-    void makeCredential(const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, CreationCompletionHandler&&) final;
+    void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&&) final;
     void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) final;
     void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) final;
-    void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) final;
-    void getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) final;
-    void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool) final;
 
-    Internals& m_internals;
     // All following fields are disposable.
     bool m_didTimeOut { false };
     bool m_didUserCancel { false };
     bool m_didUserVerifyingPlatformAuthenticatorPresent { false };
-    Vector<uint8_t> m_attestationObject;
-    Vector<uint8_t> m_credentialId; // Overlapped between CreationReturnBundle and AssertionReturnBundle.
-    Vector<uint8_t> m_authenticatorData;
-    Vector<uint8_t> m_signature;
-    Vector<uint8_t> m_userHandle;
-
-    // To clean up completion handlers.
-    Vector<uint64_t> m_timeOutMessageIds;
+    RefPtr<ArrayBuffer> m_credentialId;
+    RefPtr<ArrayBuffer> m_attestationObject;
+    RefPtr<ArrayBuffer> m_authenticatorData;
+    RefPtr<ArrayBuffer> m_signature;
+    RefPtr<ArrayBuffer> m_userHandle;
 };
 
 } // namespace WebCore
@@ -26,7 +26,7 @@
 [
     Conditional=WEB_AUTHN,
     NoInterfaceObject,
-] interface MockCredentialsMessenger {
+] interface MockAuthenticatorCoordinator {
     void setDidTimeOut();
     void setDidUserCancel();
     void setDidUserVerifyingPlatformAuthenticatorPresent();
diff --git a/Source/WebCore/testing/MockCredentialsMessenger.cpp b/Source/WebCore/testing/MockCredentialsMessenger.cpp
deleted file mode 100644 (file)
index 102e33b..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MockCredentialsMessenger.h"
-
-#if ENABLE(WEB_AUTHN)
-
-#include "Internals.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-MockCredentialsMessenger::MockCredentialsMessenger(Internals& internals)
-    : m_internals(internals)
-{
-}
-
-MockCredentialsMessenger::~MockCredentialsMessenger()
-{
-    // Have no effects to original promises. Just to call handlers to avoid any assertion failures.
-    for (auto messageId : m_timeOutMessageIds)
-        exceptionReply(messageId, ExceptionData { NotAllowedError, "Operation timed out."_s });
-}
-
-void MockCredentialsMessenger::setCreationReturnBundle(const BufferSource& credentialId, const BufferSource& attestationObject)
-{
-    ASSERT(m_credentialId.isEmpty() && m_attestationObject.isEmpty());
-    m_credentialId.append(credentialId.data(), credentialId.length());
-    m_attestationObject.append(attestationObject.data(), attestationObject.length());
-}
-
-void MockCredentialsMessenger::setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle)
-{
-    ASSERT(m_credentialId.isEmpty() && m_authenticatorData.isEmpty() && m_signature.isEmpty() && m_userHandle.isEmpty());
-    m_credentialId.append(credentialId.data(), credentialId.length());
-    m_authenticatorData.append(authenticatorData.data(), authenticatorData.length());
-    m_signature.append(signature.data(), signature.length());
-    m_userHandle.append(userHandle.data(), userHandle.length());
-}
-
-void MockCredentialsMessenger::ref()
-{
-    m_internals.ref();
-}
-
-void MockCredentialsMessenger::deref()
-{
-    m_internals.deref();
-}
-
-void MockCredentialsMessenger::makeCredential(const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, CreationCompletionHandler&& handler)
-{
-    auto messageId = addCreationCompletionHandler(WTFMove(handler));
-    if (m_didTimeOut) {
-        m_didTimeOut = false;
-        m_timeOutMessageIds.append(messageId);
-        return;
-    }
-    if (m_didUserCancel) {
-        m_didUserCancel = false;
-        exceptionReply(messageId, ExceptionData { NotAllowedError, "User cancelled."_s });
-        return;
-    }
-    if (!m_credentialId.isEmpty()) {
-        ASSERT(!m_attestationObject.isEmpty());
-        makeCredentialReply(messageId, m_credentialId, m_attestationObject);
-        m_credentialId.clear();
-        m_attestationObject.clear();
-        return;
-    }
-    ASSERT_NOT_REACHED();
-}
-
-void MockCredentialsMessenger::getAssertion(const Vector<uint8_t>&, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&& handler)
-{
-    auto messageId = addRequestCompletionHandler(WTFMove(handler));
-    if (m_didTimeOut) {
-        m_didTimeOut = false;
-        m_timeOutMessageIds.append(messageId);
-        return;
-    }
-    if (m_didUserCancel) {
-        m_didUserCancel = false;
-        exceptionReply(messageId, ExceptionData { NotAllowedError, "User cancelled."_s });
-        return;
-    }
-    if (!m_credentialId.isEmpty()) {
-        ASSERT(!m_authenticatorData.isEmpty() && !m_signature.isEmpty() && !m_userHandle.isEmpty());
-        getAssertionReply(messageId, m_credentialId, m_authenticatorData, m_signature, m_userHandle);
-        m_credentialId.clear();
-        m_authenticatorData.clear();
-        m_signature.clear();
-        m_userHandle.clear();
-        return;
-    }
-    ASSERT_NOT_REACHED();
-}
-
-void MockCredentialsMessenger::isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&& handler)
-{
-    auto messageId = addQueryCompletionHandler(WTFMove(handler));
-    if (m_didUserVerifyingPlatformAuthenticatorPresent) {
-        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, true);
-        m_didUserVerifyingPlatformAuthenticatorPresent = false;
-    } else
-        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, false);
-}
-
-void MockCredentialsMessenger::makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject)
-{
-    auto handler = takeCreationCompletionHandler(messageId);
-    handler(CreationReturnBundle(ArrayBuffer::create(credentialId.data(), credentialId.size()), ArrayBuffer::create(attestationObject.data(), attestationObject.size())));
-}
-
-void MockCredentialsMessenger::getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle)
-{
-    auto handler = takeRequestCompletionHandler(messageId);
-    handler(AssertionReturnBundle(ArrayBuffer::create(credentialId.data(), credentialId.size()), ArrayBuffer::create(authenticatorData.data(), authenticatorData.size()), ArrayBuffer::create(signature.data(), signature.size()), ArrayBuffer::create(userHandle.data(), userHandle.size())));
-}
-
-void MockCredentialsMessenger::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
-{
-    auto handler = takeQueryCompletionHandler(messageId);
-    handler(result);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUTHN)
index 8798d93..203f40a 100644 (file)
@@ -1,3 +1,43 @@
+2018-09-11  Jiewen Tan  <jiewen_tan@apple.com>
+
+        [WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=189277
+        <rdar://problem/44115936>
+
+        Reviewed by Chris Dumez.
+
+        * DerivedSources.make:
+        * SourcesCocoa.txt:
+        * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: Removed.
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp: Added.
+        (WebKit::WebAuthenticatorCoordinatorProxy::WebAuthenticatorCoordinatorProxy):
+        (WebKit::WebAuthenticatorCoordinatorProxy::~WebAuthenticatorCoordinatorProxy):
+        (WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
+        (WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
+        (WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
+        (WebKit::WebAuthenticatorCoordinatorProxy::requestReply):
+        (WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailableReply):
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h: Renamed from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h.
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in: Renamed from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::m_resetRecentCrashCountTimer):
+        (WebKit::WebPageProxy::reattachToWebProcess):
+        * UIProcess/WebPageProxy.h:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/CredentialManagement/WebCredentialsMessenger.cpp: Removed.
+        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp: Added.
+        (WebKit::WebAuthenticatorCoordinator::WebAuthenticatorCoordinator):
+        (WebKit::WebAuthenticatorCoordinator::~WebAuthenticatorCoordinator):
+        (WebKit::WebAuthenticatorCoordinator::makeCredential):
+        (WebKit::WebAuthenticatorCoordinator::getAssertion):
+        (WebKit::WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
+        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h: Renamed from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h.
+        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in: Renamed from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_cpuLimit):
+        (WebKit::m_credentialsMessenger): Deleted.
+        * WebProcess/WebPage/WebPage.h:
+
 2018-09-10  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, fix ProcessSwap API tests after r235867.
index 1e4cc51..bdec283 100644 (file)
@@ -43,7 +43,6 @@ VPATH = \
     $(WebKit2)/WebProcess/ApplicationCache \
     $(WebKit2)/WebProcess/Automation \
     $(WebKit2)/WebProcess/Cache \
-    $(WebKit2)/WebProcess/CredentialManagement \
     $(WebKit2)/WebProcess/Databases/IndexedDB \
     $(WebKit2)/WebProcess/FullScreen \
     $(WebKit2)/WebProcess/Geolocation \
@@ -58,6 +57,7 @@ VPATH = \
     $(WebKit2)/WebProcess/ResourceCache \
     $(WebKit2)/WebProcess/Storage \
     $(WebKit2)/WebProcess/UserContent \
+    $(WebKit2)/WebProcess/WebAuthentication \
     $(WebKit2)/WebProcess/WebCoreSupport \
     $(WebKit2)/WebProcess/WebPage \
     $(WebKit2)/WebProcess/WebPage/RemoteLayerTree \
@@ -69,7 +69,6 @@ VPATH = \
     $(WebKit2)/UIProcess/ApplePay \
     $(WebKit2)/UIProcess/Automation \
     $(WebKit2)/UIProcess/Cocoa \
-    $(WebKit2)/UIProcess/CredentialManagement \
     $(WebKit2)/UIProcess/Databases \
     $(WebKit2)/UIProcess/Downloads \
     $(WebKit2)/UIProcess/MediaStream \
@@ -80,6 +79,7 @@ VPATH = \
     $(WebKit2)/UIProcess/RemoteLayerTree \
     $(WebKit2)/UIProcess/Storage \
     $(WebKit2)/UIProcess/UserContent \
+    $(WebKit2)/UIProcess/WebAuthentication \
     $(WebKit2)/UIProcess/WebStorage \
     $(WebKit2)/UIProcess/mac \
     $(WebKit2)/UIProcess/ios \
@@ -149,8 +149,8 @@ MESSAGE_RECEIVERS = \
     WebConnection \
     WebCookieManager \
     WebCookieManagerProxy \
-    WebCredentialsMessenger \
-    WebCredentialsMessengerProxy \
+    WebAuthenticatorCoordinator \
+    WebAuthenticatorCoordinatorProxy \
     WebFullScreenManager \
     WebFullScreenManagerProxy \
     WebGeolocationManager \
index 026da52..16d07ba 100644 (file)
@@ -344,8 +344,6 @@ UIProcess/Cocoa/WebViewImpl.mm
 UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
 UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
 
-UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp
-
 UIProcess/Gamepad/cocoa/UIGamepadProviderCocoa.mm
 UIProcess/Gamepad/ios/UIGamepadProviderIOS.mm
 UIProcess/Gamepad/mac/UIGamepadProviderMac.mm
@@ -456,6 +454,8 @@ UIProcess/RemoteLayerTree/RemoteLayerTreeScrollingPerformanceData.mm
 UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
 UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp
 
+UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp
+
 UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
 
 UIProcess/WebStorage/StorageManager.cpp
@@ -464,8 +464,6 @@ UIProcess/WebStorage/ios/LocalStorageDatabaseTrackerIOS.mm
 
 WebProcess/ApplePay/WebPaymentCoordinator.cpp
 
-WebProcess/CredentialManagement/WebCredentialsMessenger.cpp
-
 WebProcess/cocoa/PlaybackSessionManager.mm
 WebProcess/cocoa/UserMediaCaptureManager.cpp
 WebProcess/cocoa/VideoFullscreenManager.mm
@@ -510,6 +508,8 @@ WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm
 WebProcess/Plugins/PDF/PDFPluginPasswordField.mm
 WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
 
+WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp
+
 WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp
 WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp
 WebProcess/WebCoreSupport/WebValidationMessageClient.cpp
diff --git a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp b/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp
deleted file mode 100644 (file)
index 9cbcfbf..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebCredentialsMessengerProxy.h"
-
-#if ENABLE(WEB_AUTHN)
-
-#include "WebCredentialsMessengerMessages.h"
-#include "WebCredentialsMessengerProxyMessages.h"
-#include "WebPageProxy.h"
-#include "WebProcessProxy.h"
-#include <WebCore/ExceptionData.h>
-#include <WebCore/LocalAuthenticator.h>
-
-namespace WebKit {
-
-WebCredentialsMessengerProxy::WebCredentialsMessengerProxy(WebPageProxy& webPageProxy)
-    : m_webPageProxy(webPageProxy)
-{
-    m_webPageProxy.process().addMessageReceiver(Messages::WebCredentialsMessengerProxy::messageReceiverName(), m_webPageProxy.pageID(), *this);
-    m_authenticator = std::make_unique<WebCore::LocalAuthenticator>();
-}
-
-WebCredentialsMessengerProxy::~WebCredentialsMessengerProxy()
-{
-    m_webPageProxy.process().removeMessageReceiver(Messages::WebCredentialsMessengerProxy::messageReceiverName(), m_webPageProxy.pageID());
-}
-
-void WebCredentialsMessengerProxy::makeCredential(uint64_t messageId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options)
-{
-    // FIXME(182767)
-    if (!m_authenticator) {
-        exceptionReply(messageId, { WebCore::NotAllowedError, "No avaliable authenticators."_s });
-        return;
-    }
-    // FIXME(183534): Weak pointers doesn't work in another thread because of race condition.
-    // FIXME(183534): Unify callbacks.
-    auto weakThis = makeWeakPtr(*this);
-    auto callback = [weakThis, messageId] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) {
-        if (!weakThis)
-            return;
-        weakThis->makeCredentialReply(messageId, credentialId, attestationObject);
-    };
-    auto exceptionCallback = [weakThis, messageId] (const WebCore::ExceptionData& exception) {
-        if (!weakThis)
-            return;
-        weakThis->exceptionReply(messageId, exception);
-    };
-    m_authenticator->makeCredential(hash, options, WTFMove(callback), WTFMove(exceptionCallback));
-}
-
-void WebCredentialsMessengerProxy::getAssertion(uint64_t messageId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options)
-{
-    // FIXME(182767)
-    if (!m_authenticator)
-        exceptionReply(messageId, { WebCore::NotAllowedError, "No avaliable authenticators."_s });
-    // FIXME(183534): Weak pointers doesn't work in another thread because of race condition.
-    // FIXME(183534): Unify callbacks.
-    auto weakThis = makeWeakPtr(*this);
-    auto callback = [weakThis, messageId] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) {
-        if (weakThis)
-            weakThis->getAssertionReply(messageId, credentialId, authenticatorData, signature, userHandle);
-    };
-    auto exceptionCallback = [weakThis, messageId] (const WebCore::ExceptionData& exception) {
-        if (weakThis)
-            weakThis->exceptionReply(messageId, exception);
-    };
-    m_authenticator->getAssertion(hash, options, WTFMove(callback), WTFMove(exceptionCallback));
-}
-
-void WebCredentialsMessengerProxy::isUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId)
-{
-    if (!m_authenticator) {
-        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, false);
-        return;
-    }
-    isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, m_authenticator->isAvailable());
-}
-
-void WebCredentialsMessengerProxy::exceptionReply(uint64_t messageId, const WebCore::ExceptionData& exception)
-{
-    m_webPageProxy.send(Messages::WebCredentialsMessenger::ExceptionReply(messageId, exception));
-}
-
-void WebCredentialsMessengerProxy::makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject)
-{
-    m_webPageProxy.send(Messages::WebCredentialsMessenger::MakeCredentialReply(messageId, credentialId, attestationObject));
-}
-
-void WebCredentialsMessengerProxy::getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle)
-{
-    m_webPageProxy.send(Messages::WebCredentialsMessenger::GetAssertionReply(messageId, credentialId, authenticatorData, signature, userHandle));
-}
-
-void WebCredentialsMessengerProxy::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
-{
-    m_webPageProxy.send(Messages::WebCredentialsMessenger::IsUserVerifyingPlatformAuthenticatorAvailableReply(messageId, result));
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(WEB_AUTHN)
diff --git a/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp b/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp
new file mode 100644 (file)
index 0000000..1223948
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAuthenticatorCoordinatorProxy.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include "WebAuthenticatorCoordinatorMessages.h"
+#include "WebAuthenticatorCoordinatorProxyMessages.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include <WebCore/ExceptionData.h>
+#include <WebCore/LocalAuthenticator.h>
+#include <WebCore/PublicKeyCredentialData.h>
+
+namespace WebKit {
+
+WebAuthenticatorCoordinatorProxy::WebAuthenticatorCoordinatorProxy(WebPageProxy& webPageProxy)
+    : m_webPageProxy(webPageProxy)
+{
+    m_webPageProxy.process().addMessageReceiver(Messages::WebAuthenticatorCoordinatorProxy::messageReceiverName(), m_webPageProxy.pageID(), *this);
+    m_authenticator = std::make_unique<WebCore::LocalAuthenticator>();
+}
+
+WebAuthenticatorCoordinatorProxy::~WebAuthenticatorCoordinatorProxy()
+{
+    m_webPageProxy.process().removeMessageReceiver(Messages::WebAuthenticatorCoordinatorProxy::messageReceiverName(), m_webPageProxy.pageID());
+}
+
+void WebAuthenticatorCoordinatorProxy::makeCredential(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options)
+{
+    // FIXME(182767)
+    if (!m_authenticator) {
+        requestReply({ }, { WebCore::NotAllowedError, "No avaliable authenticators."_s });
+        return;
+    }
+    // FIXME(183534): Weak pointers doesn't work in another thread because of race condition.
+    auto callback = [weakThis = makeWeakPtr(*this)] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        if (!weakThis)
+            return;
+
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
+            weakThis->requestReply(data, { });
+        }, [&](const  WebCore::ExceptionData& exception) {
+            weakThis->requestReply({ }, exception);
+        });
+    };
+    m_authenticator->makeCredential(hash, options, WTFMove(callback));
+}
+
+void WebAuthenticatorCoordinatorProxy::getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options)
+{
+    // FIXME(182767)
+    if (!m_authenticator)
+        requestReply({ }, { WebCore::NotAllowedError, "No avaliable authenticators."_s });
+    // FIXME(183534): Weak pointers doesn't work in another thread because of race condition.
+    auto callback = [weakThis = makeWeakPtr(*this)] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        if (!weakThis)
+            return;
+
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
+            weakThis->requestReply(data, { });
+        }, [&](const  WebCore::ExceptionData& exception) {
+            weakThis->requestReply({ }, exception);
+        });
+    };
+    m_authenticator->getAssertion(hash, options, WTFMove(callback));
+}
+
+void WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId)
+{
+    if (!m_authenticator) {
+        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, false);
+        return;
+    }
+    isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, m_authenticator->isAvailable());
+}
+
+void WebAuthenticatorCoordinatorProxy::requestReply(const WebCore::PublicKeyCredentialData& data, const WebCore::ExceptionData& exception)
+{
+    m_webPageProxy.send(Messages::WebAuthenticatorCoordinator::RequestReply(data, exception));
+}
+
+void WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
+{
+    m_webPageProxy.send(Messages::WebAuthenticatorCoordinator::IsUserVerifyingPlatformAuthenticatorAvailableReply(messageId, result));
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)
@@ -37,6 +37,7 @@ class LocalAuthenticator;
 
 struct ExceptionData;
 struct PublicKeyCredentialCreationOptions;
+struct PublicKeyCredentialData;
 struct PublicKeyCredentialRequestOptions;
 }
 
@@ -44,25 +45,23 @@ namespace WebKit {
 
 class WebPageProxy;
 
-class WebCredentialsMessengerProxy : private IPC::MessageReceiver, public CanMakeWeakPtr<WebCredentialsMessengerProxy> {
-    WTF_MAKE_NONCOPYABLE(WebCredentialsMessengerProxy);
+class WebAuthenticatorCoordinatorProxy : private IPC::MessageReceiver, public CanMakeWeakPtr<WebAuthenticatorCoordinatorProxy> {
+    WTF_MAKE_NONCOPYABLE(WebAuthenticatorCoordinatorProxy);
 public:
-    explicit WebCredentialsMessengerProxy(WebPageProxy&);
-    ~WebCredentialsMessengerProxy();
+    explicit WebAuthenticatorCoordinatorProxy(WebPageProxy&);
+    ~WebAuthenticatorCoordinatorProxy();
 
 private:
     // IPC::MessageReceiver.
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
     // Receivers.
-    void makeCredential(uint64_t messageId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions&);
-    void getAssertion(uint64_t messageId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&);
+    void makeCredential(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions&);
+    void getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&);
     void isUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId);
 
     // Senders.
-    void exceptionReply(uint64_t messageId, const WebCore::ExceptionData&);
-    void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject);
-    void getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle);
+    void requestReply(const WebCore::PublicKeyCredentialData&, const WebCore::ExceptionData&);
     void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool);
 
     WebPageProxy& m_webPageProxy;
 
 #if ENABLE(WEB_AUTHN)
 
-messages -> WebCredentialsMessengerProxy {
+messages -> WebAuthenticatorCoordinatorProxy {
 
-    MakeCredential(uint64_t messageId, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options);
-    GetAssertion(uint64_t messageId, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options);
+    MakeCredential(Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options);
+    GetAssertion(Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options);
     IsUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId);
 }
 
index e28310b..01b1bbb 100644 (file)
 #endif
 
 #if ENABLE(WEB_AUTHN)
-#include "WebCredentialsMessengerProxy.h"
+#include "WebAuthenticatorCoordinatorProxy.h"
 #endif
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
@@ -461,7 +461,7 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
 #endif
 
 #if ENABLE(WEB_AUTHN)
-    m_credentialsMessenger = std::make_unique<WebCredentialsMessengerProxy>(*this);
+    m_credentialsMessenger = std::make_unique<WebAuthenticatorCoordinatorProxy>(*this);
 #endif
 
     m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
@@ -779,7 +779,7 @@ void WebPageProxy::reattachToWebProcess(Ref<WebProcessProxy>&& process, API::Nav
 #endif
 
 #if ENABLE(WEB_AUTHN)
-    m_credentialsMessenger = std::make_unique<WebCredentialsMessengerProxy>(*this);
+    m_credentialsMessenger = std::make_unique<WebAuthenticatorCoordinatorProxy>(*this);
 #endif
 
     initializeWebPage();
index a98fd72..41933a1 100644 (file)
@@ -236,7 +236,7 @@ class WebFullScreenManagerProxy;
 class PlaybackSessionManagerProxy;
 class WebNavigationState;
 class VideoFullscreenManagerProxy;
-class WebCredentialsMessengerProxy;
+class WebAuthenticatorCoordinatorProxy;
 class WebKeyboardEvent;
 class WebURLSchemeHandler;
 class WebMouseEvent;
@@ -1917,7 +1917,7 @@ private:
 #endif
 
 #if ENABLE(WEB_AUTHN)
-    std::unique_ptr<WebCredentialsMessengerProxy> m_credentialsMessenger;
+    std::unique_ptr<WebAuthenticatorCoordinatorProxy> m_credentialsMessenger;
 #endif
 
     CallbackMap m_callbacks;
index 19ca35d..7a46bf5 100644 (file)
                53BA47D11DC2EF5E004DF4AD /* NetworkDataTaskBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */; };
                53DEA3661DDE423100E82648 /* json.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 53DEA3651DDE422E00E82648 /* json.hpp */; };
                570AB8F320AE3BD700B8BE87 /* SecKeyProxyStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 570AB8F220AE3BD700B8BE87 /* SecKeyProxyStore.h */; };
-               5760829C202D2C3C00116678 /* WebCredentialsMessengerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */; };
-               5760829D202D2C4000116678 /* WebCredentialsMessengerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */; };
-               5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */; };
-               5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */; };
                57B4B46020B504AC00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B4B45E20B504AB00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h */; };
+               57DCED6E2142EE5E0016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57DCED6B2142EAE20016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp */; };
+               57DCED6F2142EE630016B847 /* WebAuthenticatorCoordinatorMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED6A2142EAE20016B847 /* WebAuthenticatorCoordinatorMessages.h */; };
+               57DCED702142EE680016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57DCED6C2142EAF90016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp */; };
+               57DCED712142EE6C0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED6D2142EAFA0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h */; };
                5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */; };
                5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */; };
                5C1426ED1C23F80900D41183 /* NetworkProcessCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */; };
                570AB90320B2541C00B8BE87 /* SecKeyProxyStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SecKeyProxyStore.mm; sourceTree = "<group>"; };
                575075A720AB763600693EA9 /* WebCredentialMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCredentialMac.mm; sourceTree = "<group>"; };
                5750F32A2032D4E500389347 /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; };
-               5760828B2029854200116678 /* WebCredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessenger.h; sourceTree = "<group>"; };
-               5760828C2029854200116678 /* WebCredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessenger.cpp; sourceTree = "<group>"; };
-               5760828D202987E600116678 /* WebCredentialsMessenger.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCredentialsMessenger.messages.in; sourceTree = "<group>"; };
-               5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerMessages.h; sourceTree = "<group>"; };
-               5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerMessageReceiver.cpp; sourceTree = "<group>"; };
-               57608295202BD8BA00116678 /* WebCredentialsMessengerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerProxy.h; sourceTree = "<group>"; };
-               57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerProxy.cpp; sourceTree = "<group>"; };
-               57608299202BDAE200116678 /* WebCredentialsMessengerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCredentialsMessengerProxy.messages.in; sourceTree = "<group>"; };
-               5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerProxyMessageReceiver.cpp; sourceTree = "<group>"; };
-               5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerProxyMessages.h; sourceTree = "<group>"; };
+               5760828B2029854200116678 /* WebAuthenticatorCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAuthenticatorCoordinator.h; sourceTree = "<group>"; };
+               5760828C2029854200116678 /* WebAuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
+               5760828D202987E600116678 /* WebAuthenticatorCoordinator.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebAuthenticatorCoordinator.messages.in; sourceTree = "<group>"; };
+               57608295202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAuthenticatorCoordinatorProxy.h; sourceTree = "<group>"; };
+               57608296202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticatorCoordinatorProxy.cpp; sourceTree = "<group>"; };
+               57608299202BDAE200116678 /* WebAuthenticatorCoordinatorProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebAuthenticatorCoordinatorProxy.messages.in; sourceTree = "<group>"; };
                57B4B45D20B504AB00D4AD79 /* AuthenticationManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AuthenticationManagerCocoa.mm; path = Authentication/cocoa/AuthenticationManagerCocoa.mm; sourceTree = "<group>"; };
                57B4B45E20B504AB00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClientCertificateAuthenticationXPCConstants.h; path = Authentication/cocoa/ClientCertificateAuthenticationXPCConstants.h; sourceTree = "<group>"; };
+               57DCED6A2142EAE20016B847 /* WebAuthenticatorCoordinatorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAuthenticatorCoordinatorMessages.h; sourceTree = "<group>"; };
+               57DCED6B2142EAE20016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticatorCoordinatorMessageReceiver.cpp; sourceTree = "<group>"; };
+               57DCED6C2142EAF90016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticatorCoordinatorProxyMessageReceiver.cpp; sourceTree = "<group>"; };
+               57DCED6D2142EAFA0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAuthenticatorCoordinatorProxyMessages.h; sourceTree = "<group>"; };
                5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
                5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketStreamMessages.h; sourceTree = "<group>"; };
                5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
                        name = Frameworks;
                        sourceTree = "<group>";
                };
-               5760828A202984C900116678 /* CredentialManagement */ = {
+               5760828A202984C900116678 /* WebAuthentication */ = {
                        isa = PBXGroup;
                        children = (
-                               5760828C2029854200116678 /* WebCredentialsMessenger.cpp */,
-                               5760828B2029854200116678 /* WebCredentialsMessenger.h */,
-                               5760828D202987E600116678 /* WebCredentialsMessenger.messages.in */,
+                               5760828C2029854200116678 /* WebAuthenticatorCoordinator.cpp */,
+                               5760828B2029854200116678 /* WebAuthenticatorCoordinator.h */,
+                               5760828D202987E600116678 /* WebAuthenticatorCoordinator.messages.in */,
                        );
-                       path = CredentialManagement;
+                       path = WebAuthentication;
                        sourceTree = "<group>";
                };
-               57608294202BD84900116678 /* CredentialManagement */ = {
+               57608294202BD84900116678 /* WebAuthentication */ = {
                        isa = PBXGroup;
                        children = (
-                               57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */,
-                               57608295202BD8BA00116678 /* WebCredentialsMessengerProxy.h */,
-                               57608299202BDAE200116678 /* WebCredentialsMessengerProxy.messages.in */,
+                               57608296202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.cpp */,
+                               57608295202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.h */,
+                               57608299202BDAE200116678 /* WebAuthenticatorCoordinatorProxy.messages.in */,
                        );
-                       path = CredentialManagement;
+                       path = WebAuthentication;
                        sourceTree = "<group>";
                };
                57B4B45C20B5048B00D4AD79 /* cocoa */ = {
                                1C0A19431C8FF1A800FE0EBB /* Automation */,
                                41D129D81F3D101400D15E47 /* Cache */,
                                7C6E70F818B2D47E00F24E2E /* cocoa */,
-                               5760828A202984C900116678 /* CredentialManagement */,
                                512A9754180DF9270039A149 /* Databases */,
                                BCACC43B16B24C5D00B6E092 /* EntryPoint */,
                                E170876D16D6CA7200F99226 /* FileAPI */,
                                1A6FB7AA11E64B4900DB1371 /* Plugins */,
                                5118E9981F295259003EF9F5 /* Storage */,
                                1AAF08AA1926930B00B6390C /* UserContent */,
+                               5760828A202984C900116678 /* WebAuthentication */,
                                BC032D5D10F437220058C15A /* WebCoreSupport */,
                                BC032D5E10F4372B0058C15A /* WebPage */,
                                1AAC4DDE16B1CBF6009425E3 /* WebStorage */,
                                512F588D12A8836F00629530 /* Authentication */,
                                9955A6E81C79809000EB6A93 /* Automation */,
                                1ABC3DF21899E415004F0626 /* Cocoa */,
-                               57608294202BD84900116678 /* CredentialManagement */,
                                1AB7D4C71288AA9A00CFD08C /* Downloads */,
                                515BE17B1D54EF5A00DD7C68 /* Gamepad */,
                                2DA944A81884E9AB00ED86DB /* ios */,
                                2D1551A91F5A9B420006E3FE /* RemoteLayerTree */,
                                517DD5BB180DA7C40081660B /* Storage */,
                                1AAF089E192681AC00B6390C /* UserContent */,
+                               57608294202BD84900116678 /* WebAuthentication */,
                                1A53C2A31A325691004E8C70 /* WebsiteData */,
                                1A44B95816B73F8C00B7BBD8 /* WebStorage */,
                                7CD102D91866770600ED429D /* AutoCorrectionCallback.h */,
                                1A60224B18C16B9F00C3E8C9 /* VisitedLinkStoreMessages.h */,
                                1A8E7D3A18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp */,
                                1A8E7D3B18C15149005A702A /* VisitedLinkTableControllerMessages.h */,
+                               57DCED6B2142EAE20016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp */,
+                               57DCED6A2142EAE20016B847 /* WebAuthenticatorCoordinatorMessages.h */,
+                               57DCED6C2142EAF90016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp */,
+                               57DCED6D2142EAFA0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h */,
                                1C0A19551C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp */,
                                1C0A19561C90068F00FE0EBB /* WebAutomationSessionMessages.h */,
                                1C0A19511C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp */,
                                330934441315B9220097A7BC /* WebCookieManagerMessages.h */,
                                330934451315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp */,
                                330934461315B9220097A7BC /* WebCookieManagerProxyMessages.h */,
-                               5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */,
-                               5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */,
-                               5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */,
-                               5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */,
                                CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */,
                                CD73BA49131ACD8E00EEDED2 /* WebFullScreenManagerMessages.h */,
                                CD73BA45131ACC8800EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp */,
                                1AF4CEF018BC481800BC2D34 /* VisitedLinkTableController.h in Headers */,
                                1A8E7D3D18C15149005A702A /* VisitedLinkTableControllerMessages.h in Headers */,
                                CEDA12E3152CD1B300D9E08D /* WebAlternativeTextClient.h in Headers */,
+                               57DCED6F2142EE630016B847 /* WebAuthenticatorCoordinatorMessages.h in Headers */,
+                               57DCED712142EE6C0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h in Headers */,
                                9955A6EC1C7980C200EB6A93 /* WebAutomationSession.h in Headers */,
                                99C3AE2D1DADA6AD00AF5C16 /* WebAutomationSessionMacros.h in Headers */,
                                1C0A19581C90068F00FE0EBB /* WebAutomationSessionMessages.h in Headers */,
                                3309344A1315B9220097A7BC /* WebCookieManagerProxyMessages.h in Headers */,
                                BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
                                512F589B12A8838800629530 /* WebCredential.h in Headers */,
-                               5760829D202D2C4000116678 /* WebCredentialsMessengerMessages.h in Headers */,
-                               5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */,
                                1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */,
                                E52CF55220A35C3A00DADA27 /* WebDataListSuggestionPicker.h in Headers */,
                                E568B91F20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h in Headers */,
                                2684055218B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp in Sources */,
                                1A60224C18C16B9F00C3E8C9 /* VisitedLinkStoreMessageReceiver.cpp in Sources */,
                                1A8E7D3C18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp in Sources */,
+                               57DCED6E2142EE5E0016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp in Sources */,
+                               57DCED702142EE680016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp in Sources */,
                                1C0A19571C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp in Sources */,
                                1C0A19531C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp in Sources */,
                                517CF0E3163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp in Sources */,
                                330934471315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp in Sources */,
                                330934491315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp in Sources */,
                                2D92A788212B6AB100F493FD /* WebCoreArgumentCoders.cpp in Sources */,
-                               5760829C202D2C3C00116678 /* WebCredentialsMessengerMessageReceiver.cpp in Sources */,
-                               5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */,
                                2D92A789212B6AB100F493FD /* WebEvent.cpp in Sources */,
                                CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */,
                                CD73BA47131ACC9A00EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp in Sources */,
diff --git a/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp b/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp
deleted file mode 100644 (file)
index 2279d7e..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebCredentialsMessenger.h"
-
-#if ENABLE(WEB_AUTHN)
-
-#include "WebCredentialsMessengerMessages.h"
-#include "WebCredentialsMessengerProxyMessages.h"
-#include "WebPage.h"
-#include "WebProcess.h"
-#include <WebCore/PublicKeyCredentialCreationOptions.h>
-#include <WebCore/PublicKeyCredentialRequestOptions.h>
-
-namespace WebKit {
-
-WebCredentialsMessenger::WebCredentialsMessenger(WebPage& webPage)
-    : m_webPage(webPage)
-{
-    WebProcess::singleton().addMessageReceiver(Messages::WebCredentialsMessenger::messageReceiverName(), m_webPage.pageID(), *this);
-}
-
-WebCredentialsMessenger::~WebCredentialsMessenger()
-{
-    WebProcess::singleton().removeMessageReceiver(*this);
-}
-
-void WebCredentialsMessenger::makeCredential(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options, WebCore::CreationCompletionHandler&& handler)
-{
-    auto messageId = addCreationCompletionHandler(WTFMove(handler));
-    m_webPage.send(Messages::WebCredentialsMessengerProxy::MakeCredential(messageId, hash, options));
-}
-
-void WebCredentialsMessenger::getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options, WebCore::RequestCompletionHandler&& handler)
-{
-    auto messageId = addRequestCompletionHandler(WTFMove(handler));
-    m_webPage.send(Messages::WebCredentialsMessengerProxy::GetAssertion(messageId, hash, options));
-}
-
-void WebCredentialsMessenger::isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&& handler)
-{
-    auto messageId = addQueryCompletionHandler(WTFMove(handler));
-    m_webPage.send(Messages::WebCredentialsMessengerProxy::IsUserVerifyingPlatformAuthenticatorAvailable(messageId));
-}
-
-void WebCredentialsMessenger::makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject)
-{
-    auto handler = takeCreationCompletionHandler(messageId);
-    handler(WebCore::CreationReturnBundle(ArrayBuffer::create(credentialId.data(), credentialId.size()), ArrayBuffer::create(attestationObject.data(), attestationObject.size())));
-}
-
-void WebCredentialsMessenger::getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle)
-{
-    auto handler = takeRequestCompletionHandler(messageId);
-    handler(WebCore::AssertionReturnBundle(ArrayBuffer::create(credentialId.data(), credentialId.size()), ArrayBuffer::create(authenticatorData.data(), authenticatorData.size()), ArrayBuffer::create(signature.data(), signature.size()), ArrayBuffer::create(userHandle.data(), userHandle.size())));
-}
-
-void WebCredentialsMessenger::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
-{
-    auto handler = takeQueryCompletionHandler(messageId);
-    handler(result);
-}
-
-
-} // namespace WebKit
-
-#endif // ENABLE(WEB_AUTHN)
diff --git a/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp b/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp
new file mode 100644 (file)
index 0000000..90ba4c5
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAuthenticatorCoordinator.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include "WebAuthenticatorCoordinatorMessages.h"
+#include "WebAuthenticatorCoordinatorProxyMessages.h"
+#include "WebPage.h"
+#include "WebProcess.h"
+#include <WebCore/PublicKeyCredentialCreationOptions.h>
+#include <WebCore/PublicKeyCredentialRequestOptions.h>
+
+namespace WebKit {
+
+WebAuthenticatorCoordinator::WebAuthenticatorCoordinator(WebPage& webPage)
+    : m_webPage(webPage)
+{
+    WebProcess::singleton().addMessageReceiver(Messages::WebAuthenticatorCoordinator::messageReceiverName(), m_webPage.pageID(), *this);
+}
+
+WebAuthenticatorCoordinator::~WebAuthenticatorCoordinator()
+{
+    WebProcess::singleton().removeMessageReceiver(*this);
+}
+
+void WebAuthenticatorCoordinator::makeCredential(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options, WebCore::RequestCompletionHandler&& handler)
+{
+    if (!setRequestCompletionHandler(WTFMove(handler)))
+        return;
+
+    m_webPage.send(Messages::WebAuthenticatorCoordinatorProxy::MakeCredential(hash, options));
+}
+
+void WebAuthenticatorCoordinator::getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options, WebCore::RequestCompletionHandler&& handler)
+{
+    if (!setRequestCompletionHandler(WTFMove(handler)))
+        return;
+
+    m_webPage.send(Messages::WebAuthenticatorCoordinatorProxy::GetAssertion(hash, options));
+}
+
+void WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&& handler)
+{
+    auto messageId = addQueryCompletionHandler(WTFMove(handler));
+    m_webPage.send(Messages::WebAuthenticatorCoordinatorProxy::IsUserVerifyingPlatformAuthenticatorAvailable(messageId));
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(WEB_AUTHN)
 #if ENABLE(WEB_AUTHN)
 
 #include "MessageReceiver.h"
-#include <WebCore/CredentialsMessenger.h>
+#include <WebCore/AuthenticatorCoordinatorClient.h>
 
 namespace WebKit {
 
 class WebPage;
 
-class WebCredentialsMessenger final : public WebCore::CredentialsMessenger, private IPC::MessageReceiver {
+class WebAuthenticatorCoordinator final : public WebCore::AuthenticatorCoordinatorClient, private IPC::MessageReceiver {
 public:
-    explicit WebCredentialsMessenger(WebPage&);
-    ~WebCredentialsMessenger();
+    explicit WebAuthenticatorCoordinator(WebPage&);
+    ~WebAuthenticatorCoordinator();
 
 private:
-    // WebCore::CredentialsMessenger
+    // WebCore::AuthenticatorCoordinatorClient
     // Senders.
-    void makeCredential(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::CreationCompletionHandler&&) final;
+    void makeCredential(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::RequestCompletionHandler&&) final;
     void getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::RequestCompletionHandler&&) final;
     void isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&&) final;
 
-    // Receivers.
-    void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) final;
-    void getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) final;
-    void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool) final;
-
     // IPC::MessageReceiver.
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
 
 #if ENABLE(WEB_AUTHN)
 
-messages -> WebCredentialsMessenger {
+messages -> WebAuthenticatorCoordinator {
 
-    ExceptionReply(uint64_t messageId, struct WebCore::ExceptionData exception);
-    MakeCredentialReply(uint64_t messageId, Vector<uint8_t> credentialId, Vector<uint8_t> attestationObject);
-    GetAssertionReply(uint64_t messageId, Vector<uint8_t> credentialId, Vector<uint8_t> authenticatorData, Vector<uint8_t> signature, Vector<uint8_t> userHandle);
+    RequestReply(struct WebCore::PublicKeyCredentialData data, struct WebCore::ExceptionData exception);
     IsUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result);
 }
 
index b634cf5..e5a3df6 100644 (file)
 #endif
 
 #if ENABLE(WEB_AUTHN)
-#include "WebCredentialsMessenger.h"
-#include <WebCore/AuthenticatorManager.h>
+#include "WebAuthenticatorCoordinator.h"
+#include <WebCore/AuthenticatorCoordinator.h>
 #endif
 
 namespace WebKit {
@@ -392,9 +392,6 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
     , m_userInterfaceLayoutDirection(parameters.userInterfaceLayoutDirection)
     , m_overrideContentSecurityPolicy { parameters.overrideContentSecurityPolicy }
     , m_cpuLimit(parameters.cpuLimit)
-#if ENABLE(WEB_AUTHN)
-    , m_credentialsMessenger(std::make_unique<WebCredentialsMessenger>(*this))
-#endif
 {
     ASSERT(m_pageID);
 
@@ -448,6 +445,10 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
     pageConfiguration.paymentCoordinatorClient = new WebPaymentCoordinator(*this);
 #endif
 
+#if ENABLE(WEB_AUTHN)
+    pageConfiguration.authenticatorCoordinatorClient = std::make_unique<WebAuthenticatorCoordinator>(*this);
+#endif
+
 #if ENABLE(APPLICATION_MANIFEST)
     pageConfiguration.applicationManifest = parameters.applicationManifest;
 #endif
@@ -605,10 +606,6 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
 #endif
 #endif
 
-#if ENABLE(WEB_AUTHN)
-    WebCore::AuthenticatorManager::singleton().setMessenger(*m_credentialsMessenger);
-#endif
-
     for (auto iterator : parameters.urlSchemeHandlers)
         registerURLSchemeHandler(iterator.value, iterator.key);
 
index 7b27e75..7af9993 100644 (file)
@@ -227,7 +227,6 @@ class WebUserContentController;
 class VideoFullscreenManager;
 class WebWheelEvent;
 class WebTouchEvent;
-class WebCredentialsMessenger;
 class RemoteLayerTreeTransaction;
 
 enum class DeviceAccessState;
@@ -1736,10 +1735,6 @@ private:
     HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap;
 #endif
 
-#if ENABLE(WEB_AUTHN)
-    std::unique_ptr<WebCredentialsMessenger> m_credentialsMessenger;
-#endif
-
     bool m_isSuspended { false };
 };
 
index 7a17965..4d16474 100644 (file)
@@ -1,3 +1,14 @@
+2018-09-11  Jiewen Tan  <jiewen_tan@apple.com>
+
+        [WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
+        https://bugs.webkit.org/show_bug.cgi?id=189277
+        <rdar://problem/44115936>
+
+        Reviewed by Chris Dumez.
+
+        * TestWebKitAPI/Tests/ios/LocalAuthenticator.mm:
+        (TestWebKitAPI::TEST):
+
 2018-09-10  Michael Saboff  <msaboff@apple.com>
 
         Test262 failure with Named Capture Groups - using a reference before the group is defined
index 855b14f..cd63d73 100644 (file)
@@ -38,6 +38,7 @@
 #import <WebCore/ExceptionData.h>
 #import <WebCore/LocalAuthenticator.h>
 #import <WebCore/PublicKeyCredentialCreationOptions.h>
+#import <WebCore/PublicKeyCredentialData.h>
 #import <WebCore/PublicKeyCredentialRequestOptions.h>
 #import <wtf/BlockPtr.h>
 #import <wtf/text/Base64.h>
@@ -266,16 +267,17 @@ TEST(LocalAuthenticator, MakeCredentialNotSupportedPubKeyCredParams)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotSupportedError, exception.code);
-        EXPECT_STREQ("The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters.", exception.message.ascii().data());
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotSupportedError, exception.code);
+            EXPECT_STREQ("The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters.", exception.message.ascii().data());
+            done = true;
+        });
     };
-    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -294,18 +296,19 @@ TEST(LocalAuthenticator, MakeCredentialExcludeCredentialsMatch)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        cleanUpKeychain();
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
-        EXPECT_STREQ("At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.", exception.message.ascii().data());
-        cleanUpKeychain();
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            cleanUpKeychain();
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
+            EXPECT_STREQ("At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.", exception.message.ascii().data());
+            cleanUpKeychain();
+            done = true;
+        });
     };
-    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -319,16 +322,17 @@ TEST(LocalAuthenticator, MakeCredentialBiometricsNotEnrolled)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
-        EXPECT_STREQ("No avaliable authenticators.", exception.message.ascii().data());
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
+            EXPECT_STREQ("No avaliable authenticators.", exception.message.ascii().data());
+            done = true;
+        });
     };
-    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -343,16 +347,17 @@ TEST(LocalAuthenticator, MakeCredentialBiometricsNotAuthenticated)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
-        EXPECT_STREQ("Couldn't get user consent.", exception.message.ascii().data());
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
+            EXPECT_STREQ("Couldn't get user consent.", exception.message.ascii().data());
+            done = true;
+        });
     };
-    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -368,16 +373,17 @@ TEST(LocalAuthenticator, MakeCredentialNotAttestated)
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
     authenticator->setFailureFlag();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::UnknownError, exception.code);
-        EXPECT_STREQ("Unknown internal error.", exception.message.ascii().data());
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::UnknownError, exception.code);
+            EXPECT_STREQ("Unknown internal error.", exception.message.ascii().data());
+            done = true;
+        });
     };
-    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -399,22 +405,23 @@ TEST(LocalAuthenticator, MakeCredentialDeleteOlderCredenital)
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
     authenticator->setFailureFlag();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData&) mutable {
-        NSDictionary *query = @{
-            (id)kSecClass: (id)kSecClassKey,
-            (id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
-            (id)kSecAttrLabel: testRpId,
-            (id)kSecAttrApplicationTag: [NSData dataWithBytes:testUserhandle length:sizeof(testUserhandle)],
-        };
-        OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
-        EXPECT_EQ(errSecItemNotFound, status);
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            NSDictionary *query = @{
+                (id)kSecClass: (id)kSecClassKey,
+                (id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
+                (id)kSecAttrLabel: testRpId,
+                (id)kSecAttrApplicationTag: [NSData dataWithBytes:testUserhandle length:sizeof(testUserhandle)],
+            };
+            OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
+            EXPECT_EQ(errSecItemNotFound, status);
+            done = true;
+        });
     };
-    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -432,103 +439,109 @@ TEST(LocalAuthenticator, MakeCredentialPassedWithSelfAttestation)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObjet) {
-        // Check Keychain
-        NSDictionary *query = @{
-            (id)kSecClass: (id)kSecClassKey,
-            (id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
-            (id)kSecAttrLabel: testRpId,
-            (id)kSecAttrApplicationLabel: adoptNS([[NSData alloc] initWithBase64EncodedString:testCredentialIdBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get(),
-            (id)kSecAttrApplicationTag: [NSData dataWithBytes:testUserhandle length:sizeof(testUserhandle)],
-        };
-        OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
-        EXPECT_FALSE(status);
-
-        // Check Credential ID
-        EXPECT_TRUE(WTF::base64Encode(credentialId.data(), credentialId.size()) == testCredentialIdBase64);
-
-        // Check Attestation Object
-        auto attestationObjectMap = cbor::CBORReader::read(attestationObjet);
-        ASSERT_TRUE(!!attestationObjectMap);
-
-        // Check Authenticator Data.
-        auto& authData = attestationObjectMap->getMap().find(cbor::CBORValue("authData"))->second.getByteString();
-        size_t pos = 0;
-        uint8_t expectedRpIdHash[] = {
-            0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e, 0x8c, 0x68,
-            0x74, 0x34, 0x17, 0x0f, 0x64, 0x76, 0x60, 0x5b,
-            0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86, 0x32, 0xc7,
-            0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d, 0x97, 0x63
-        };
-        EXPECT_FALSE(memcmp(authData.data() + pos, expectedRpIdHash, sizeof(expectedRpIdHash)));
-        pos += sizeof(expectedRpIdHash);
-
-        // FLAGS
-        EXPECT_EQ(69, authData[pos]);
-        pos++;
-
-        uint32_t counter = -1;
-        memcpy(&counter, authData.data() + pos, sizeof(uint32_t));
-        EXPECT_EQ(0u, counter);
-        pos += sizeof(uint32_t);
-
-        uint8_t expectedAAGUID[] = {
-            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-        };
-        EXPECT_FALSE(memcmp(authData.data() + pos, expectedAAGUID, sizeof(expectedAAGUID)));
-        pos += sizeof(expectedAAGUID);
-
-        uint16_t l = -1;
-        memcpy(&l, authData.data() + pos, sizeof(uint16_t));
-        EXPECT_EQ(20u, l);
-        pos += sizeof(uint16_t);
-
-        EXPECT_FALSE(memcmp(authData.data() + pos, credentialId.data(), l));
-        pos += l;
-
-        // Credential Public Key
-        // FIXME(183536): The CBOR reader doesn't support negative integer as map key. Thus we couldn't utilzie it.
-        EXPECT_STREQ("pQECAyYgASFYIDj/zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF/Qm1749IlggVBJPgqUIwfhWHJ91nb7UPH76c0+WFOzZKslPyyFse4g=", WTF::base64Encode(authData.data() + pos, authData.size() - pos).ascii().data());
-
-        // Check Self Attestation
-        EXPECT_STREQ("Apple", attestationObjectMap->getMap().find(cbor::CBORValue("fmt"))->second.getString().ascii().data());
-
-        auto& attStmt = attestationObjectMap->getMap().find(cbor::CBORValue("attStmt"))->second.getMap();
-        EXPECT_EQ(COSE::ES256, attStmt.find(cbor::CBORValue("alg"))->second.getNegative());
-
-        auto& sig = attStmt.find(cbor::CBORValue("sig"))->second.getByteString();
-        auto privateKey = getTestKey();
-        EXPECT_TRUE(SecKeyVerifySignature(SecKeyCopyPublicKey(privateKey.get()), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:authData.data() length:authData.size()], (__bridge CFDataRef)[NSData dataWithBytes:sig.data() length:sig.size()], NULL));
-
-        // Check certificates
-        auto& x5c = attStmt.find(cbor::CBORValue("x5c"))->second.getArray();
-        auto& attestationCertificateData = x5c[0].getByteString();
-        auto attestationCertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)[NSData dataWithBytes:attestationCertificateData.data() length:attestationCertificateData.size()]));
-        CFStringRef commonName = nullptr;
-        status = SecCertificateCopyCommonName(attestationCertificate.get(), &commonName);
-        auto retainCommonName = adoptCF(commonName);
-        ASSERT(!status);
-        EXPECT_STREQ("00008010-000A49A230A0213A", [(NSString *)commonName cStringUsingEncoding: NSASCIIStringEncoding]);
-
-        auto& attestationIssuingCACertificateData = x5c[1].getByteString();
-        auto attestationIssuingCACertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)[NSData dataWithBytes:attestationIssuingCACertificateData.data() length:attestationIssuingCACertificateData.size()]));
-        commonName = nullptr;
-        status = SecCertificateCopyCommonName(attestationIssuingCACertificate.get(), &commonName);
-        retainCommonName = adoptCF(commonName);
-        ASSERT(!status);
-        EXPECT_STREQ("Basic Attestation User Sub CA1", [(NSString *)commonName cStringUsingEncoding: NSASCIIStringEncoding]);
-
-        cleanUpKeychain();
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData&) mutable {
-        EXPECT_FALSE(true);
-        cleanUpKeychain();
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
+            Vector<uint8_t> credentialId;
+            credentialId.append(reinterpret_cast<uint8_t*>(data.rawId->data()), data.rawId->byteLength());
+            Vector<uint8_t> attestationObject;
+            attestationObject.append(reinterpret_cast<uint8_t*>(data.attestationObject->data()), data.attestationObject->byteLength());
+
+            // Check Keychain
+            NSDictionary *query = @{
+                (id)kSecClass: (id)kSecClassKey,
+                (id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
+                (id)kSecAttrLabel: testRpId,
+                (id)kSecAttrApplicationLabel: adoptNS([[NSData alloc] initWithBase64EncodedString:testCredentialIdBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get(),
+                (id)kSecAttrApplicationTag: [NSData dataWithBytes:testUserhandle length:sizeof(testUserhandle)],
+            };
+            OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
+            EXPECT_FALSE(status);
+
+            // Check Credential ID
+            EXPECT_TRUE(WTF::base64Encode(credentialId.data(), credentialId.size()) == testCredentialIdBase64);
+
+            // Check Attestation Object
+            auto attestationObjectMap = cbor::CBORReader::read(attestationObject);
+            ASSERT_TRUE(!!attestationObjectMap);
+
+            // Check Authenticator Data.
+            auto& authData = attestationObjectMap->getMap().find(cbor::CBORValue("authData"))->second.getByteString();
+            size_t pos = 0;
+            uint8_t expectedRpIdHash[] = {
+                0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e, 0x8c, 0x68,
+                0x74, 0x34, 0x17, 0x0f, 0x64, 0x76, 0x60, 0x5b,
+                0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86, 0x32, 0xc7,
+                0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d, 0x97, 0x63
+            };
+            EXPECT_FALSE(memcmp(authData.data() + pos, expectedRpIdHash, sizeof(expectedRpIdHash)));
+            pos += sizeof(expectedRpIdHash);
+
+            // FLAGS
+            EXPECT_EQ(69, authData[pos]);
+            pos++;
+
+            uint32_t counter = -1;
+            memcpy(&counter, authData.data() + pos, sizeof(uint32_t));
+            EXPECT_EQ(0u, counter);
+            pos += sizeof(uint32_t);
+
+            uint8_t expectedAAGUID[] = {
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+            };
+            EXPECT_FALSE(memcmp(authData.data() + pos, expectedAAGUID, sizeof(expectedAAGUID)));
+            pos += sizeof(expectedAAGUID);
+
+            uint16_t l = -1;
+            memcpy(&l, authData.data() + pos, sizeof(uint16_t));
+            EXPECT_EQ(20u, l);
+            pos += sizeof(uint16_t);
+
+            EXPECT_FALSE(memcmp(authData.data() + pos, credentialId.data(), l));
+            pos += l;
+
+            // Credential Public Key
+            // FIXME(183536): The CBOR reader doesn't support negative integer as map key. Thus we couldn't utilzie it.
+            EXPECT_STREQ("pQECAyYgASFYIDj/zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF/Qm1749IlggVBJPgqUIwfhWHJ91nb7UPH76c0+WFOzZKslPyyFse4g=", WTF::base64Encode(authData.data() + pos, authData.size() - pos).ascii().data());
+
+            // Check Self Attestation
+            EXPECT_STREQ("Apple", attestationObjectMap->getMap().find(cbor::CBORValue("fmt"))->second.getString().ascii().data());
+
+            auto& attStmt = attestationObjectMap->getMap().find(cbor::CBORValue("attStmt"))->second.getMap();
+            EXPECT_EQ(COSE::ES256, attStmt.find(cbor::CBORValue("alg"))->second.getNegative());
+
+            auto& sig = attStmt.find(cbor::CBORValue("sig"))->second.getByteString();
+            auto privateKey = getTestKey();
+            EXPECT_TRUE(SecKeyVerifySignature(SecKeyCopyPublicKey(privateKey.get()), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:authData.data() length:authData.size()], (__bridge CFDataRef)[NSData dataWithBytes:sig.data() length:sig.size()], NULL));
+
+            // Check certificates
+            auto& x5c = attStmt.find(cbor::CBORValue("x5c"))->second.getArray();
+            auto& attestationCertificateData = x5c[0].getByteString();
+            auto attestationCertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)[NSData dataWithBytes:attestationCertificateData.data() length:attestationCertificateData.size()]));
+            CFStringRef commonName = nullptr;
+            status = SecCertificateCopyCommonName(attestationCertificate.get(), &commonName);
+            auto retainCommonName = adoptCF(commonName);
+            ASSERT(!status);
+            EXPECT_STREQ("00008010-000A49A230A0213A", [(NSString *)commonName cStringUsingEncoding: NSASCIIStringEncoding]);
+
+            auto& attestationIssuingCACertificateData = x5c[1].getByteString();
+            auto attestationIssuingCACertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)[NSData dataWithBytes:attestationIssuingCACertificateData.data() length:attestationIssuingCACertificateData.size()]));
+            commonName = nullptr;
+            status = SecCertificateCopyCommonName(attestationIssuingCACertificate.get(), &commonName);
+            retainCommonName = adoptCF(commonName);
+            ASSERT(!status);
+            EXPECT_STREQ("Basic Attestation User Sub CA1", [(NSString *)commonName cStringUsingEncoding: NSASCIIStringEncoding]);
+
+            cleanUpKeychain();
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_FALSE(true);
+            cleanUpKeychain();
+            done = true;
+        });
     };
     Vector<uint8_t> hash(32);
-    authenticator->makeCredential(hash, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->makeCredential(hash, creationOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -544,16 +557,17 @@ TEST(LocalAuthenticator, GetAssertionAllowCredentialsMismatch1)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
-        EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
+            EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
+            done = true;
+        });
     };
-    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -566,16 +580,17 @@ TEST(LocalAuthenticator, GetAssertionAllowCredentialsMismatch2)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
-        EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
+            EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
+            done = true;
+        });
     };
-    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -595,18 +610,19 @@ TEST(LocalAuthenticator, GetAssertionAllowCredentialsMismatch3)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        cleanUpKeychain();
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
-        EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
-        cleanUpKeychain();
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            cleanUpKeychain();
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
+            EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
+            cleanUpKeychain();
+            done = true;
+        });
     };
-    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -622,18 +638,19 @@ TEST(LocalAuthenticator, GetAssertionBiometricsNotEnrolled)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        cleanUpKeychain();
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
-        EXPECT_STREQ("No avaliable authenticators.", exception.message.ascii().data());
-        cleanUpKeychain();
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            cleanUpKeychain();
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
+            EXPECT_STREQ("No avaliable authenticators.", exception.message.ascii().data());
+            cleanUpKeychain();
+            done = true;
+        });
     };
-    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -650,18 +667,19 @@ TEST(LocalAuthenticator, GetAssertionBiometricsNotAuthenticated)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
-        EXPECT_FALSE(true);
-        cleanUpKeychain();
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
-        EXPECT_STREQ("Couldn't get user consent.", exception.message.ascii().data());
-        cleanUpKeychain();
-        done = true;
+    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
+            EXPECT_FALSE(true);
+            cleanUpKeychain();
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
+            EXPECT_STREQ("Couldn't get user consent.", exception.message.ascii().data());
+            cleanUpKeychain();
+            done = true;
+        });
     };
-    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }
@@ -680,48 +698,58 @@ TEST(LocalAuthenticator, GetAssertionPassed)
 
     bool done = false;
     std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
-    auto callback = [&done, hash] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userhandle) {
-        // Check Credential ID
-        EXPECT_TRUE(WTF::base64Encode(credentialId.data(), credentialId.size()) == testCredentialIdBase64);
-
-        // Check Authenticator Data.
-        size_t pos = 0;
-        uint8_t expectedRpIdHash[] = {
-            0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e, 0x8c, 0x68,
-            0x74, 0x34, 0x17, 0x0f, 0x64, 0x76, 0x60, 0x5b,
-            0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86, 0x32, 0xc7,
-            0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d, 0x97, 0x63
-        };
-        EXPECT_FALSE(memcmp(authData.data() + pos, expectedRpIdHash, sizeof(expectedRpIdHash)));
-        pos += sizeof(expectedRpIdHash);
-
-        // FLAGS
-        EXPECT_EQ(5, authData[pos]);
-        pos++;
-
-        uint32_t counter = -1;
-        memcpy(&counter, authData.data() + pos, sizeof(uint32_t));
-        EXPECT_EQ(0u, counter);
-
-        // Check signature
-        auto privateKey = getTestKey();
-        Vector<uint8_t> dataToSign(authData);
-        dataToSign.appendVector(hash);
-        EXPECT_TRUE(SecKeyVerifySignature(SecKeyCopyPublicKey(privateKey.get()), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:dataToSign.data() length:dataToSign.size()], (__bridge CFDataRef)[NSData dataWithBytes:signature.data() length:signature.size()], NULL));
-
-        // Check User Handle
-        EXPECT_EQ(userhandle.size(), sizeof(testUserhandle));
-        EXPECT_FALSE(memcmp(userhandle.data(), testUserhandle, sizeof(testUserhandle)));
-
-        cleanUpKeychain();
-        done = true;
-    };
-    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
-        EXPECT_FALSE(true);
-        cleanUpKeychain();
-        done = true;
+    auto callback = [&done, hash] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
+        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
+            Vector<uint8_t> credentialId;
+            credentialId.append(reinterpret_cast<uint8_t*>(data.rawId->data()), data.rawId->byteLength());
+            Vector<uint8_t> authData;
+            authData.append(reinterpret_cast<uint8_t*>(data.authenticatorData->data()), data.authenticatorData->byteLength());
+            Vector<uint8_t> signature;
+            signature.append(reinterpret_cast<uint8_t*>(data.signature->data()), data.signature->byteLength());
+            Vector<uint8_t> userhandle;
+            userhandle.append(reinterpret_cast<uint8_t*>(data.userHandle->data()), data.userHandle->byteLength());
+
+            // Check Credential ID
+            EXPECT_TRUE(WTF::base64Encode(credentialId.data(), credentialId.size()) == testCredentialIdBase64);
+
+            // Check Authenticator Data.
+            size_t pos = 0;
+            uint8_t expectedRpIdHash[] = {
+                0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e, 0x8c, 0x68,
+                0x74, 0x34, 0x17, 0x0f, 0x64, 0x76, 0x60, 0x5b,
+                0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86, 0x32, 0xc7,
+                0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d, 0x97, 0x63
+            };
+            EXPECT_FALSE(memcmp(authData.data() + pos, expectedRpIdHash, sizeof(expectedRpIdHash)));
+            pos += sizeof(expectedRpIdHash);
+
+            // FLAGS
+            EXPECT_EQ(5, authData[pos]);
+            pos++;
+
+            uint32_t counter = -1;
+            memcpy(&counter, authData.data() + pos, sizeof(uint32_t));
+            EXPECT_EQ(0u, counter);
+
+            // Check signature
+            auto privateKey = getTestKey();
+            Vector<uint8_t> dataToSign(authData);
+            dataToSign.appendVector(hash);
+            EXPECT_TRUE(SecKeyVerifySignature(SecKeyCopyPublicKey(privateKey.get()), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:dataToSign.data() length:dataToSign.size()], (__bridge CFDataRef)[NSData dataWithBytes:signature.data() length:signature.size()], NULL));
+
+            // Check User Handle
+            EXPECT_EQ(userhandle.size(), sizeof(testUserhandle));
+            EXPECT_FALSE(memcmp(userhandle.data(), testUserhandle, sizeof(testUserhandle)));
+
+            cleanUpKeychain();
+            done = true;
+        }, [&](const  WebCore::ExceptionData& exception) {
+            EXPECT_FALSE(true);
+            cleanUpKeychain();
+            done = true;
+        });
     };
-    authenticator->getAssertion(hash, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
+    authenticator->getAssertion(hash, requestOptions, WTFMove(callback));
 
     TestWebKitAPI::Util::run(&done);
 }