Changeset 228444 in webkit


Ignore:
Timestamp:
Feb 13, 2018 5:34:21 PM (6 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting
https://bugs.webkit.org/show_bug.cgi?id=181946
<rdar://problem/37258262>

Reviewed by Chris Dumez.

Source/WebCore:

This patch changes the original async model from a work queue to IPC between WebProcess
and UIProcess. Since all authenticator operations must be handled in the UIProcess due
to sandboxing, this message passing IPC async model then surpasses the original multi
threading model. To cooperate that, a CredentialsMessenger class is then created and
all task dispatching code is moved thre.

As an improvement over existing code, static functions from PublicKeyCredential are
moved to AuthenticatorManager. AuthenticatorManager is made as a singleton such that
when static functions are called, they could reach the CredentialsMessenger to interact
with UIProccess. CredentialsMessenger and AuthenticatorManager are separated so later
on when other Credential types are created, they can reuse the same IPC messenger.

What's more, a mock CredentialsMessenger is then created to mock behaviors of UIProcess
for testing purpose.

Covered by existing tests.

  • DerivedSources.make:
  • Modules/credentialmanagement/BasicCredential.h:
  • Modules/credentialmanagement/CredentialsContainer.cpp:

(WebCore::CredentialsContainer::CredentialsContainer):
(WebCore::CredentialsContainer::doesHaveSameOriginAsItsAncestors):
(WebCore::CredentialsContainer::get):
(WebCore::CredentialsContainer::isCreate):
(WebCore::CredentialsContainer::PendingPromise::PendingPromise): Deleted.
(WebCore::CredentialsContainer::dispatchTask): Deleted.

  • Modules/credentialmanagement/CredentialsContainer.h:

(WebCore::CredentialsContainer::PendingPromise::create): Deleted.

  • Modules/credentialmanagement/CredentialsMessenger.cpp: Added.

(WebCore::CredentialsMessenger::exceptionReply):
(WebCore::CredentialsMessenger::addCreationCompletionHandler):
(WebCore::CredentialsMessenger::takeCreationCompletionHandler):
(WebCore::CredentialsMessenger::addRequestCompletionHandler):
(WebCore::CredentialsMessenger::takeRequestCompletionHandler):
(WebCore::CredentialsMessenger::addQueryCompletionHandler):
(WebCore::CredentialsMessenger::takeQueryCompletionHandler):
(WebCore::getIdFromAttestationObject):

  • Modules/credentialmanagement/CredentialsMessenger.h: Added.

(WebCore::CreationReturnBundle::CreationReturnBundle):
(WebCore::AssertionReturnBundle::AssertionReturnBundle):
(WebCore::CredentialsMessenger::weakPtrFactory const):

  • Modules/webauthn/Authenticator.cpp: Removed.
  • Modules/webauthn/Authenticator.h: Removed.
  • Modules/webauthn/AuthenticatorManager.cpp: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp.

(WebCore::AuthenticatorManagerInternal::produceClientDataJson):
(WebCore::AuthenticatorManagerInternal::produceClientDataJsonHash):
(WebCore::AuthenticatorManagerInternal::initTimer):
(WebCore::AuthenticatorManagerInternal::didTimerFire):
(WebCore::AuthenticatorManager::singleton):
(WebCore::AuthenticatorManager::setMessenger):
(WebCore::AuthenticatorManager::create const):
(WebCore::AuthenticatorManager::discoverFromExternalSource const):

  • Modules/webauthn/AuthenticatorManager.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
  • Modules/webauthn/AuthenticatorResponse.h:
  • Modules/webauthn/PublicKeyCredential.cpp:

(WebCore::PublicKeyCredentialInternal::produceClientDataJson): Deleted.
(WebCore::PublicKeyCredentialInternal::produceClientDataJsonHash): Deleted.
(WebCore::PublicKeyCredentialInternal::getIdFromAttestationObject): Deleted.
(WebCore::PublicKeyCredential::collectFromCredentialStore): Deleted.
(WebCore::PublicKeyCredential::discoverFromExternalSource): Deleted.
(WebCore::PublicKeyCredential::store): Deleted.
(WebCore::PublicKeyCredential::create): Deleted.
(WebCore::PublicKeyCredential::rawId const): Deleted.
(WebCore::PublicKeyCredential::response const): Deleted.

  • Modules/webauthn/PublicKeyCredential.h:
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • testing/Internals.cpp:

(WebCore::Internals::Internals):
(WebCore::Internals::mockCredentialsMessenger const):

  • testing/Internals.h:
  • testing/Internals.idl:
  • testing/MockCredentialsMessenger.cpp: Added.

(WebCore::MockCredentialsMessenger::setAttestationObject):
(WebCore::MockCredentialsMessenger::setAssertionReturnBundle):
(WebCore::MockCredentialsMessenger::makeCredential):
(WebCore::MockCredentialsMessenger::getAssertion):
(WebCore::MockCredentialsMessenger::makeCredentialReply):
(WebCore::MockCredentialsMessenger::getAssertionReply):

  • testing/MockCredentialsMessenger.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
  • testing/MockCredentialsMessenger.idl: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.

Source/WebKit:

Dummy WebCredentialsMessenger and WebCredentialsMessengerProxy are crafted to establish
a message exchange channel between UIProcess and WebProcess.

  • DerivedSources.make:
  • UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.

(WebKit::WebCredentialsMessengerProxy::WebCredentialsMessengerProxy):
(WebKit::WebCredentialsMessengerProxy::~WebCredentialsMessengerProxy):
(WebKit::WebCredentialsMessengerProxy::makeCredential):
(WebKit::WebCredentialsMessengerProxy::getAssertion):

  • UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
  • UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in: Added.
  • UIProcess/WebPageProxy.cpp:

(WebKit::m_configurationPreferenceValues):
(WebKit::WebPageProxy::reattachToWebProcess):

  • UIProcess/WebPageProxy.h:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/CredentialManagement/WebCredentialsMessenger.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.

(WebKit::WebCredentialsMessenger::WebCredentialsMessenger):
(WebKit::WebCredentialsMessenger::~WebCredentialsMessenger):
(WebKit::WebCredentialsMessenger::makeCredential):
(WebKit::WebCredentialsMessenger::getAssertion):
(WebKit::WebCredentialsMessenger::makeCredentialReply):
(WebKit::WebCredentialsMessenger::getAssertionReply):

  • WebProcess/CredentialManagement/WebCredentialsMessenger.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
  • WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in: Added.
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::m_credentialsMessenger):
(WebKit::m_cpuLimit): Deleted.

  • WebProcess/WebPage/WebPage.h:

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/resources/util.js:
Location:
trunk
Files:
8 added
2 deleted
29 edited
7 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r228435 r228444  
     12018-02-13  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting
     4        https://bugs.webkit.org/show_bug.cgi?id=181946
     5        <rdar://problem/37258262>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * http/wpt/credential-management/credentialscontainer-store-basics.https.html:
     10        * http/wpt/webauthn/idl.https.html:
     11        * http/wpt/webauthn/public-key-credential-create-failure.https.html:
     12        * http/wpt/webauthn/public-key-credential-create-success.https.html:
     13        * http/wpt/webauthn/public-key-credential-get-failure.https.html:
     14        * http/wpt/webauthn/public-key-credential-get-success.https.html:
     15        * http/wpt/webauthn/resources/util.js:
     16
    1172018-02-13  Antti Koivisto  <antti@apple.com>
    218
  • trunk/LayoutTests/http/wpt/credential-management/credentialscontainer-store-basics.https.html

    r227589 r228444  
    1010            chars.push(str.charCodeAt(i));
    1111        return new Uint8Array(chars);
     12    }
     13    function hexStringToUint8Array(hexString)
     14    {
     15        if (hexString.length % 2 != 0)
     16            throw "Invalid hexString";
     17        var arrayBuffer = new Uint8Array(hexString.length / 2);
     18
     19        for (var i = 0; i < hexString.length; i += 2) {
     20            var byteValue = parseInt(hexString.substr(i, 2), 16);
     21            if (byteValue == NaN)
     22                throw "Invalid hexString";
     23            arrayBuffer[i/2] = byteValue;
     24        }
     25
     26        return arrayBuffer;
    1227    }
    1328
     
    2742            }
    2843        };
     44        // A mock attestation object
     45        internals.mockCredentialsMessenger.setAttestationObject(hexStringToUint8Array('000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff'));
     46        const credential = await navigator.credentials.create(options);
    2947
    30         const credential = await navigator.credentials.create(options);
    3148        return promise_rejects(t, "NotSupportedError",
    3249            navigator.credentials.store(credential));
  • trunk/LayoutTests/http/wpt/webauthn/idl.https.html

    r227589 r228444  
    5050        }
    5151    };
     52    // A mock attestation object
     53    internals.mockCredentialsMessenger.setAttestationObject(hexStringToUint8Array('000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff'));
    5254    createdCredential = await navigator.credentials.create(creationOptions);
    5355
     
    5860        }
    5961    };
     62    // A mock assertion return bundle.
     63    internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
    6064    requestedCredential = await navigator.credentials.get(requestOptions);
    6165
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html

    r227382 r228444  
    2121            }
    2222        };
     23        internals.mockCredentialsMessenger.setDidTimeOut();
     24
    2325        return promise_rejects(t, "NotAllowedError",
    2426            navigator.credentials.create(options));
     
    6567    }, "PublicKeyCredential's [[create]] with an empty pubKeyCredParams");
    6668
    67     // This test is targeting to the dummy authenticator, which always cancel the operation
    68     // when user.displayName = "John".
    6969    promise_test(function(t) {
    7070        const options = {
     
    8383            }
    8484        };
     85        internals.mockCredentialsMessenger.setDidUserCancel();
     86
    8587        return promise_rejects(t, "NotAllowedError",
    8688            navigator.credentials.create(options));
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success.https.html

    r227589 r228444  
    55<script src="./resources/util.js"></script>
    66<script>
    7     // The following test is specifically tuned for current dummy authenticator.
    87    promise_test(function(t) {
    98        const options = {
     
    2120            }
    2221        };
     22        // A mock attestation object
     23        internals.mockCredentialsMessenger.setAttestationObject(hexStringToUint8Array('000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff'));
    2324
    2425        return navigator.credentials.create(options).then(function(credential) {
     
    2728                assert_equals(bytesToHexString(credential.rawId), 'ff');
    2829                assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.create","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}');
    29                 // This field is completely fake 0x00*43 | 0x0001ff | SHA-256 hash of the clientDataJSON
    30                 assert_equals(bytesToHexString(credential.response.attestationObject), '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff3374b98316b38046727a770b8e95c4580a292b9e2f4bb44a250a5402d6d3783a');
     30                assert_equals(bytesToHexString(credential.response.attestationObject), '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ff');
    3131                try {
    3232                    assert_throws("NotSupportedError", credential.getClientExtensionResults());
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html

    r227589 r228444  
    1212            }
    1313        };
     14        internals.mockCredentialsMessenger.setDidTimeOut();
     15
    1416        return promise_rejects(t, "NotAllowedError",
    1517            navigator.credentials.get(options));
     
    2729    }, "PublicKeyCredential's [[get]] with a mismatched RP ID");
    2830
    29     // This test is targeting to the dummy authenticator, which always cancel the operation
    30     // when allowCredentials is not empty.
    3131    promise_test(function(t) {
    3232        const options = {
     
    3636            }
    3737        };
     38        internals.mockCredentialsMessenger.setDidUserCancel();
     39
    3840        return promise_rejects(t, "NotAllowedError",
    3941            navigator.credentials.get(options));
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-success.https.html

    r227589 r228444  
    1212            }
    1313        };
     14        // A mock assertion return bundle.
     15        internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
    1416
    1517        return navigator.credentials.get(options).then(function(credential) {
    16             const clientDataJsonHash = '577cc24b64b3dd011c61a8efb240aee7e77acc3c144d6dfbe097c6a208bb6d49';
    17 
    18             assert_equals(credential.id, 'V3zCS2Sz3QEcYajvskCu5-d6zDwUTW374JfGogi7bUk');
     18            assert_equals(credential.id, 'AA');
    1919            assert_equals(credential.type, 'public-key');
    20             assert_equals(bytesToHexString(credential.rawId), clientDataJsonHash);
     20            assert_equals(bytesToHexString(credential.rawId), '00');
    2121            assert_equals(bytesToASCIIString(credential.response.clientDataJSON), '{"type":"webauthn.get","challenge":"MTIzNDU2","origin":"https://localhost:9443","hashAlgorithm":"SHA-256"}');
    22             // This field is completely fake 0x00*43 | 0x0001ff | SHA-256 hash of the clientDataJSON
    23             assert_equals(bytesToHexString(credential.response.authenticatorData), clientDataJsonHash);
    24             assert_equals(bytesToHexString(credential.response.signature), clientDataJsonHash);
    25             assert_equals(bytesToHexString(credential.response.userHandle), clientDataJsonHash);
     22            assert_equals(bytesToHexString(credential.response.authenticatorData), '01');
     23            assert_equals(bytesToHexString(credential.response.signature), '02');
     24            assert_equals(bytesToHexString(credential.response.userHandle), '03');
    2625            try {
    2726                assert_throws("NotSupportedError", credential.getClientExtensionResults());
  • trunk/LayoutTests/http/wpt/webauthn/resources/util.js

    r227382 r228444  
    4444    }
    4545};
     46
     47function hexStringToUint8Array(hexString)
     48{
     49    if (hexString.length % 2 != 0)
     50        throw "Invalid hexString";
     51    var arrayBuffer = new Uint8Array(hexString.length / 2);
     52
     53    for (var i = 0; i < hexString.length; i += 2) {
     54        var byteValue = parseInt(hexString.substr(i, 2), 16);
     55        if (byteValue == NaN)
     56            throw "Invalid hexString";
     57        arrayBuffer[i/2] = byteValue;
     58    }
     59
     60    return arrayBuffer;
     61}
  • trunk/LayoutTests/imported/w3c/web-platform-tests/credential-management/credentialscontainer-create-basics.https-expected.txt

    r227007 r228444  
    22PASS navigator.credentials.create() with no argument.
    33PASS navigator.credentials.create() with empty argument.
    4 FAIL navigator.credentials.create() with valid PasswordCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
    5 FAIL navigator.credentials.create() with valid HTMLFormElement promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
    6 FAIL navigator.credentials.create() with bogus password data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
    7 FAIL navigator.credentials.create() with valid FederatedCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
    8 FAIL navigator.credentials.create() with bogus federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
     4FAIL navigator.credentials.create() with valid PasswordCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported."
     5FAIL navigator.credentials.create() with valid HTMLFormElement promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported."
     6FAIL navigator.credentials.create() with bogus password data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
     7FAIL navigator.credentials.create() with valid FederatedCredentialData promise_test: Unhandled rejection with value: object "NotSupportedError: Only PublicKeyCredential is supported."
     8FAIL navigator.credentials.create() with bogus federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
    99PASS navigator.credentials.create() with bogus publicKey data
    1010FAIL navigator.credentials.create() returns PublicKeyCredential promise_test: Unhandled rejection with value: object "TypeError: Member PublicKeyCredentialCreationOptions.pubKeyCredParams is required and must be an instance of sequence"
    1111PASS navigator.credentials.create() with both PasswordCredentialData and FederatedCredentialData
    12 FAIL navigator.credentials.create() with bogus password and federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
     12FAIL navigator.credentials.create() with bogus password and federated data assert_throws: function "function () { throw e }" threw object "NotSupportedError: Only PublicKeyCredential is supported." ("NotSupportedError") expected object "TypeError" ("TypeError")
    1313PASS navigator.credentials.create() with bogus federated and publicKey data
    1414PASS navigator.credentials.create() with bogus password and publicKey data
  • trunk/Source/WebCore/ChangeLog

    r228441 r228444  
     12018-02-13  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting
     4        https://bugs.webkit.org/show_bug.cgi?id=181946
     5        <rdar://problem/37258262>
     6
     7        Reviewed by Chris Dumez.
     8
     9        This patch changes the original async model from a work queue to IPC between WebProcess
     10        and UIProcess. Since all authenticator operations must be handled in the UIProcess due
     11        to sandboxing, this message passing IPC async model then surpasses the original multi
     12        threading model. To cooperate that, a CredentialsMessenger class is then created and
     13        all task dispatching code is moved thre.
     14
     15        As an improvement over existing code, static functions from PublicKeyCredential are
     16        moved to AuthenticatorManager. AuthenticatorManager is made as a singleton such that
     17        when static functions are called, they could reach the CredentialsMessenger to interact
     18        with UIProccess. CredentialsMessenger and AuthenticatorManager are separated so later
     19        on when other Credential types are created, they can reuse the same IPC messenger.
     20
     21        What's more, a mock CredentialsMessenger is then created to mock behaviors of UIProcess
     22        for testing purpose.
     23
     24        Covered by existing tests.
     25
     26        * DerivedSources.make:
     27        * Modules/credentialmanagement/BasicCredential.h:
     28        * Modules/credentialmanagement/CredentialsContainer.cpp:
     29        (WebCore::CredentialsContainer::CredentialsContainer):
     30        (WebCore::CredentialsContainer::doesHaveSameOriginAsItsAncestors):
     31        (WebCore::CredentialsContainer::get):
     32        (WebCore::CredentialsContainer::isCreate):
     33        (WebCore::CredentialsContainer::PendingPromise::PendingPromise): Deleted.
     34        (WebCore::CredentialsContainer::dispatchTask): Deleted.
     35        * Modules/credentialmanagement/CredentialsContainer.h:
     36        (WebCore::CredentialsContainer::PendingPromise::create): Deleted.
     37        * Modules/credentialmanagement/CredentialsMessenger.cpp: Added.
     38        (WebCore::CredentialsMessenger::exceptionReply):
     39        (WebCore::CredentialsMessenger::addCreationCompletionHandler):
     40        (WebCore::CredentialsMessenger::takeCreationCompletionHandler):
     41        (WebCore::CredentialsMessenger::addRequestCompletionHandler):
     42        (WebCore::CredentialsMessenger::takeRequestCompletionHandler):
     43        (WebCore::CredentialsMessenger::addQueryCompletionHandler):
     44        (WebCore::CredentialsMessenger::takeQueryCompletionHandler):
     45        (WebCore::getIdFromAttestationObject):
     46        * Modules/credentialmanagement/CredentialsMessenger.h: Added.
     47        (WebCore::CreationReturnBundle::CreationReturnBundle):
     48        (WebCore::AssertionReturnBundle::AssertionReturnBundle):
     49        (WebCore::CredentialsMessenger::weakPtrFactory const):
     50        * Modules/webauthn/Authenticator.cpp: Removed.
     51        * Modules/webauthn/Authenticator.h: Removed.
     52        * Modules/webauthn/AuthenticatorManager.cpp: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp.
     53        (WebCore::AuthenticatorManagerInternal::produceClientDataJson):
     54        (WebCore::AuthenticatorManagerInternal::produceClientDataJsonHash):
     55        (WebCore::AuthenticatorManagerInternal::initTimer):
     56        (WebCore::AuthenticatorManagerInternal::didTimerFire):
     57        (WebCore::AuthenticatorManager::singleton):
     58        (WebCore::AuthenticatorManager::setMessenger):
     59        (WebCore::AuthenticatorManager::create const):
     60        (WebCore::AuthenticatorManager::discoverFromExternalSource const):
     61        * Modules/webauthn/AuthenticatorManager.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
     62        * Modules/webauthn/AuthenticatorResponse.h:
     63        * Modules/webauthn/PublicKeyCredential.cpp:
     64        (WebCore::PublicKeyCredentialInternal::produceClientDataJson): Deleted.
     65        (WebCore::PublicKeyCredentialInternal::produceClientDataJsonHash): Deleted.
     66        (WebCore::PublicKeyCredentialInternal::getIdFromAttestationObject): Deleted.
     67        (WebCore::PublicKeyCredential::collectFromCredentialStore): Deleted.
     68        (WebCore::PublicKeyCredential::discoverFromExternalSource): Deleted.
     69        (WebCore::PublicKeyCredential::store): Deleted.
     70        (WebCore::PublicKeyCredential::create): Deleted.
     71        (WebCore::PublicKeyCredential::rawId const): Deleted.
     72        (WebCore::PublicKeyCredential::response const): Deleted.
     73        * Modules/webauthn/PublicKeyCredential.h:
     74        * Sources.txt:
     75        * WebCore.xcodeproj/project.pbxproj:
     76        * testing/Internals.cpp:
     77        (WebCore::Internals::Internals):
     78        (WebCore::Internals::mockCredentialsMessenger const):
     79        * testing/Internals.h:
     80        * testing/Internals.idl:
     81        * testing/MockCredentialsMessenger.cpp: Added.
     82        (WebCore::MockCredentialsMessenger::setAttestationObject):
     83        (WebCore::MockCredentialsMessenger::setAssertionReturnBundle):
     84        (WebCore::MockCredentialsMessenger::makeCredential):
     85        (WebCore::MockCredentialsMessenger::getAssertion):
     86        (WebCore::MockCredentialsMessenger::makeCredentialReply):
     87        (WebCore::MockCredentialsMessenger::getAssertionReply):
     88        * testing/MockCredentialsMessenger.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
     89        * testing/MockCredentialsMessenger.idl: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
     90
    1912018-02-13  Zalan Bujtas  <zalan@apple.com>
    292
  • trunk/Source/WebCore/DerivedSources.make

    r228427 r228444  
    948948    $(WebCore)/testing/MockCDMFactory.idl \
    949949    $(WebCore)/testing/MockContentFilterSettings.idl \
     950    $(WebCore)/testing/MockCredentialsMessenger.idl \
    950951    $(WebCore)/testing/MockPageOverlay.idl \
    951952    $(WebCore)/testing/MockPaymentAddress.idl \
  • trunk/Source/WebCore/Modules/credentialmanagement/BasicCredential.h

    r227764 r228444  
    2828#if ENABLE(WEB_AUTHN)
    2929
    30 #include <wtf/ThreadSafeRefCounted.h>
     30#include <wtf/RefCounted.h>
    3131#include <wtf/TypeCasts.h>
    3232#include <wtf/text/WTFString.h>
     
    3434namespace WebCore {
    3535
    36 class BasicCredential : public ThreadSafeRefCounted<BasicCredential> {
     36class BasicCredential : public RefCounted<BasicCredential> {
    3737public:
    3838    enum class Type {
  • trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp

    r227764 r228444  
    3131
    3232#include "AbortSignal.h"
     33#include "AuthenticatorManager.h"
    3334#include "CredentialCreationOptions.h"
    3435#include "CredentialRequestOptions.h"
    3536#include "Document.h"
    3637#include "ExceptionOr.h"
    37 #include "JSBasicCredential.h"
    38 #include "PublicKeyCredential.h"
     38#include "JSDOMPromiseDeferred.h"
    3939#include "SecurityOrigin.h"
    40 #include <wtf/MainThread.h>
    4140
    4241namespace WebCore {
    4342
    44 CredentialsContainer::PendingPromise::PendingPromise(Ref<DeferredPromise>&& promise, std::unique_ptr<Timer>&& timer)
    45     : promise(WTFMove(promise))
    46     , timer(WTFMove(timer))
     43CredentialsContainer::CredentialsContainer(WeakPtr<Document>&& document)
     44    : m_document(WTFMove(document))
    4745{
    4846}
    4947
    50 CredentialsContainer::PendingPromise::PendingPromise(Ref<DeferredPromise>&& promise)
    51     : promise(WTFMove(promise))
    52 {
    53 }
    54 
    55 CredentialsContainer::CredentialsContainer(WeakPtr<Document>&& document)
    56     : m_document(WTFMove(document))
    57     , m_workQueue(WorkQueue::create("com.apple.WebKit.CredentialQueue"))
    58 {
    59 }
    60 
    61 // The following implements https://w3c.github.io/webappsec-credential-management/#same-origin-with-its-ancestors
    62 // as of 14 November 2017.
    6348bool CredentialsContainer::doesHaveSameOriginAsItsAncestors()
    6449{
     50    // The following implements https://w3c.github.io/webappsec-credential-management/#same-origin-with-its-ancestors
     51    // as of 14 November 2017.
    6552    if (!m_document)
    6653        return false;
     
    7461}
    7562
    76 // FIXME(181946): Since the underlying authenticator model is not clear at this moment, the timer is moved to CredentialsContainer such that
    77 // timer can stay with main thread and therefore can easily time out activities on the work queue.
    78 // FIXME(181945): The usages of AbortSignal are also moved here for the very same reason. Also the AbortSignal is kind of bogus at this moment
    79 // since it doesn't support observers (or other means) to trigger the actual abort action. Enhancement to AbortSignal is needed.
    80 template<typename OperationType>
    81 void CredentialsContainer::dispatchTask(OperationType&& operation, Ref<DeferredPromise>&& promise, std::optional<unsigned long> timeOutInMs)
    82 {
    83     ASSERT(isMainThread());
    84     if (!m_document)
    85         return;
    86 
    87     auto* promiseIndex = promise.ptr();
    88     auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
    89     // FIXME(181947): We should probably trim timeOutInMs to some max allowable number.
    90     if (timeOutInMs) {
    91         auto pendingPromise = PendingPromise::create(WTFMove(promise), std::make_unique<Timer>([promiseIndex, weakThis] () {
    92             ASSERT(isMainThread());
    93             if (weakThis) {
    94                 // A lock should not be needed as all callbacks are executed in the main thread.
    95                 if (auto promise = weakThis->m_pendingPromises.take(promiseIndex))
    96                     promise.value()->promise->reject(Exception { NotAllowedError });
    97             }
    98         }));
    99         pendingPromise->timer->startOneShot(Seconds(timeOutInMs.value() / 1000.0));
    100         m_pendingPromises.add(promiseIndex, WTFMove(pendingPromise));
    101     } else
    102         m_pendingPromises.add(promiseIndex, PendingPromise::create(WTFMove(promise)));
    103 
    104     auto task = [promiseIndex, weakThis, origin = m_document->securityOrigin().isolatedCopy(), isSameOriginWithItsAncestors = doesHaveSameOriginAsItsAncestors(), operation = WTFMove(operation)] () {
    105         auto result = operation(origin, isSameOriginWithItsAncestors);
    106         callOnMainThread([promiseIndex, weakThis, result = WTFMove(result)] () mutable {
    107             if (weakThis) {
    108                 // A lock should not be needed as all callbacks are executed in the main thread.
    109                 if (auto promise = weakThis->m_pendingPromises.take(promiseIndex)) {
    110                     if (result.hasException())
    111                         promise.value()->promise->reject(result.releaseException());
    112                     else
    113                         promise.value()->promise->resolve<IDLNullable<IDLInterface<BasicCredential>>>(result.returnValue().get());
    114                 }
    115             }
    116         });
    117     };
    118     m_workQueue->dispatch(WTFMove(task));
    119 }
    120 
    12163void CredentialsContainer::get(CredentialRequestOptions&& options, Ref<DeferredPromise>&& promise)
    12264{
    12365    // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-request as of 4 August 2017
    12466    // with enhancement from 14 November 2017 Editor's Draft.
    125     // FIXME: Optional options are passed with no contents. It should be std::optional.
    126     if ((!options.signal && !options.publicKey) || !m_document) {
     67    if (!m_document) {
    12768        promise->reject(Exception { NotSupportedError });
    12869        return;
    12970    }
    13071    if (options.signal && options.signal->aborted()) {
    131         promise->reject(Exception { AbortError });
     72        promise->reject(Exception { AbortError, ASCIILiteral("Aborted by AbortSignal.") });
    13273        return;
    13374    }
     
    13980    // be requested from [[discoverFromExternalSource]].
    14081    if (!options.publicKey) {
    141         promise->reject(Exception { NotSupportedError });
     82        promise->reject(Exception { NotSupportedError, ASCIILiteral("Only PublicKeyCredential is supported.") });
    14283        return;
    14384    }
    14485
    145     auto timeout = options.publicKey->timeout;
    146     auto operation = [options = WTFMove(options.publicKey.value())] (const SecurityOrigin& origin, bool isSameOriginWithItsAncestors) {
    147         return PublicKeyCredential::discoverFromExternalSource(origin, options, isSameOriginWithItsAncestors);
    148     };
    149     dispatchTask(WTFMove(operation), WTFMove(promise), timeout);
     86    // Async operations are dispatched/handled in (Web)CredentialMessenger, which exchanges messages between WebProcess and UIProcess.
     87    AuthenticatorManager::singleton().discoverFromExternalSource(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
    15088}
    15189
    15290void CredentialsContainer::store(const BasicCredential&, Ref<DeferredPromise>&& promise)
    15391{
    154     promise->reject(Exception { NotSupportedError });
     92    promise->reject(Exception { NotSupportedError, ASCIILiteral("Not implemented.") });
    15593}
    15694
     
    15997    // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-create as of 4 August 2017
    16098    // with enhancement from 14 November 2017 Editor's Draft.
    161     // FIXME: Optional options are passed with no contents. It should be std::optional.
    162     if ((!options.signal && !options.publicKey) || !m_document) {
     99    if (!m_document) {
    163100        promise->reject(Exception { NotSupportedError });
    164101        return;
    165102    }
    166103    if (options.signal && options.signal->aborted()) {
    167         promise->reject(Exception { AbortError });
     104        promise->reject(Exception { AbortError, ASCIILiteral("Aborted by AbortSignal.") });
    168105        return;
    169106    }
     
    171108    ASSERT(m_document->isSecureContext());
    172109
    173     // Step 3-4. Shortcut as we only support one kind of credentials.
     110    // Step 3-7. Shortcut as we only support one kind of credentials.
    174111    if (!options.publicKey) {
    175         promise->reject(Exception { NotSupportedError });
     112        promise->reject(Exception { NotSupportedError, ASCIILiteral("Only PublicKeyCredential is supported.") });
    176113        return;
    177114    }
    178115
    179     auto timeout = options.publicKey->timeout;
    180     // Step 5-7.
    181     auto operation = [options = WTFMove(options.publicKey.value())] (const SecurityOrigin& origin, bool isSameOriginWithItsAncestors) {
    182         // Shortcut as well.
    183         return PublicKeyCredential::create(origin, options, isSameOriginWithItsAncestors);
    184     };
    185     dispatchTask(WTFMove(operation), WTFMove(promise), timeout);
     116    // Async operations are dispatched/handled in (Web)CredentialMessenger, which exchanges messages between WebProcess and UIProcess.
     117    AuthenticatorManager::singleton().create(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
    186118}
    187119
    188120void CredentialsContainer::preventSilentAccess(Ref<DeferredPromise>&& promise) const
    189121{
    190     promise->reject(Exception { NotSupportedError });
     122    promise->reject(Exception { NotSupportedError, ASCIILiteral("Not implemented.") });
    191123}
    192124
  • trunk/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h

    r227764 r228444  
    2929#if ENABLE(WEB_AUTHN)
    3030
    31 #include "JSDOMPromiseDeferred.h"
    32 #include "Timer.h"
    33 #include <wtf/Function.h>
    3431#include <wtf/RefCounted.h>
    3532#include <wtf/WeakPtr.h>
    36 #include <wtf/WorkQueue.h>
    3733
    3834namespace WebCore {
    3935
    4036class BasicCredential;
     37class DeferredPromise;
    4138class Document;
    4239
     
    6057
    6158    bool doesHaveSameOriginAsItsAncestors();
    62     template<typename OperationType>
    63     void dispatchTask(OperationType&&, Ref<DeferredPromise>&&, std::optional<unsigned long> timeOutInMs = std::nullopt);
    6459
    6560    WeakPtr<Document> m_document;
    66     Ref<WorkQueue> m_workQueue;
    67     WeakPtrFactory<CredentialsContainer> m_weakPtrFactory;
    68 
    69     // Bundle promise and timer, such that the timer can
    70     // times out the corresponding promsie.
    71     struct PendingPromise : public RefCounted<PendingPromise> {
    72         static Ref<PendingPromise> create(Ref<DeferredPromise>&& promise, std::unique_ptr<Timer>&& timer)
    73         {
    74             return adoptRef(*new PendingPromise(WTFMove(promise), WTFMove(timer)));
    75         }
    76         static Ref<PendingPromise> create(Ref<DeferredPromise>&& promise)
    77         {
    78             return adoptRef(*new PendingPromise(WTFMove(promise)));
    79         }
    80 
    81     private:
    82         PendingPromise(Ref<DeferredPromise>&&, std::unique_ptr<Timer>&&);
    83         PendingPromise(Ref<DeferredPromise>&&);
    84 
    85     public:
    86         Ref<DeferredPromise> promise;
    87         std::unique_ptr<Timer> timer;
    88     };
    89     HashMap<DeferredPromise*, Ref<PendingPromise>> m_pendingPromises;
    9061};
    9162
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorManager.h

    r228442 r228444  
    2828#if ENABLE(WEB_AUTHN)
    2929
    30 #include <JavaScriptCore/ArrayBuffer.h>
    31 #include <wtf/ThreadSafeRefCounted.h>
    32 #include <wtf/TypeCasts.h>
     30#include <wtf/Forward.h>
     31#include <wtf/Noncopyable.h>
     32#include <wtf/WeakPtr.h>
    3333
    3434namespace WebCore {
    3535
    36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {
     36class AbortSignal;
     37class CredentialsMessenger;
     38class DeferredPromise;
     39class SecurityOrigin;
     40
     41struct PublicKeyCredentialCreationOptions;
     42struct PublicKeyCredentialRequestOptions;
     43
     44class AuthenticatorManager {
     45    WTF_MAKE_NONCOPYABLE(AuthenticatorManager);
     46    friend class NeverDestroyed<AuthenticatorManager>;
    3747public:
    38     enum class Type {
    39         Assertion,
    40         Attestation
    41     };
     48    WEBCORE_EXPORT static AuthenticatorManager& singleton();
     49    WEBCORE_EXPORT void setMessenger(CredentialsMessenger&);
    4250
    43     explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
    44     virtual ~AuthenticatorResponse() = default;
    45 
    46     virtual Type type() const = 0;
    47 
    48     ArrayBuffer* clientDataJSON() const;
     51    // The following methods implement static methods of PublicKeyCredential.
     52    void create(const SecurityOrigin&, const PublicKeyCredentialCreationOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, Ref<DeferredPromise>&&) const;
     53    void discoverFromExternalSource(const SecurityOrigin&, const PublicKeyCredentialRequestOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, Ref<DeferredPromise>&&) const;
    4954
    5055private:
    51     RefPtr<ArrayBuffer> m_clientDataJSON;
     56    AuthenticatorManager() = default;
     57
     58    WeakPtr<CredentialsMessenger> m_messenger;
    5259};
    5360
    5461} // namespace WebCore
    5562
    56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \
    57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
    58     static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \
    59 SPECIALIZE_TYPE_TRAITS_END()
    60 
    6163#endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h

    r228218 r228444  
    2929
    3030#include <JavaScriptCore/ArrayBuffer.h>
    31 #include <wtf/ThreadSafeRefCounted.h>
     31#include <wtf/RefCounted.h>
    3232#include <wtf/TypeCasts.h>
    3333
    3434namespace WebCore {
    3535
    36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {
     36class AuthenticatorResponse : public RefCounted<AuthenticatorResponse> {
    3737public:
    3838    enum class Type {
  • trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp

    r227764 r228444  
    2929#if ENABLE(WEB_AUTHN)
    3030
    31 #include "Authenticator.h"
    32 #include "AuthenticatorResponse.h"
    3331#include "JSDOMPromiseDeferred.h"
    34 #include "PublicKeyCredentialCreationOptions.h"
    35 #include "PublicKeyCredentialRequestOptions.h"
    36 #include "SecurityOrigin.h"
    37 #include <pal/crypto/CryptoDigest.h>
    38 #include <wtf/CurrentTime.h>
    39 #include <wtf/JSONValues.h>
    4032#include <wtf/text/Base64.h>
    4133
    4234namespace WebCore {
    43 
    44 namespace PublicKeyCredentialInternal {
    45 
    46 // The layout of attestation object: https://www.w3.org/TR/webauthn/#attestation-object as of 5 December 2017.
    47 // Here is a summary before CredentialID in the layout. All lengths are fixed.
    48 // RP ID hash (32) || FLAGS (1) || COUNTER (4) || AAGUID (16) || L (2) || CREDENTIAL ID (?) || ...
    49 static constexpr size_t CredentialIdLengthOffset = 43;
    50 
    51 enum class ClientDataType {
    52     Create,
    53     Get
    54 };
    55 
    56 // FIXME(181948): Add token binding ID and extensions.
    57 static Ref<ArrayBuffer> produceClientDataJson(ClientDataType type, const BufferSource& challenge, const SecurityOrigin& origin)
    58 {
    59     auto object = JSON::Object::create();
    60     switch (type) {
    61     case ClientDataType::Create:
    62         object->setString(ASCIILiteral("type"), ASCIILiteral("webauthn.create"));
    63         break;
    64     case ClientDataType::Get:
    65         object->setString(ASCIILiteral("type"), ASCIILiteral("webauthn.get"));
    66         break;
    67     }
    68     object->setString(ASCIILiteral("challenge"), WTF::base64URLEncode(challenge.data(), challenge.length()));
    69     object->setString(ASCIILiteral("origin"), origin.toRawString());
    70     // FIXME: This might be platform dependent.
    71     object->setString(ASCIILiteral("hashAlgorithm"), ASCIILiteral("SHA-256"));
    72 
    73     auto utf8JSONString = object->toJSONString().utf8();
    74     return ArrayBuffer::create(utf8JSONString.data(), utf8JSONString.length());
    75 }
    76 
    77 static Vector<uint8_t> produceClientDataJsonHash(const Ref<ArrayBuffer>& clientDataJson)
    78 {
    79     auto crypto = PAL::CryptoDigest::create(PAL::CryptoDigest::Algorithm::SHA_256);
    80     crypto->addBytes(clientDataJson->data(), clientDataJson->byteLength());
    81     return crypto->computeHash();
    82 }
    83 
    84 static RefPtr<ArrayBuffer> getIdFromAttestationObject(const Vector<uint8_t>& attestationObject)
    85 {
    86     // The byte length of L is 2.
    87     if (attestationObject.size() < CredentialIdLengthOffset + 2)
    88         return nullptr;
    89     size_t length = (attestationObject[CredentialIdLengthOffset] << 8) + attestationObject[CredentialIdLengthOffset + 1];
    90     if (attestationObject.size() < CredentialIdLengthOffset + 2 + length)
    91         return nullptr;
    92     return ArrayBuffer::create(attestationObject.data() + CredentialIdLengthOffset + 2, length);
    93 }
    94 
    95 } // namespace PublicKeyCredentialInternal
    9635
    9736PublicKeyCredential::PublicKeyCredential(RefPtr<ArrayBuffer>&& id, RefPtr<AuthenticatorResponse>&& response)
     
    10039    , m_response(WTFMove(response))
    10140{
    102 }
    103 
    104 Vector<Ref<BasicCredential>> PublicKeyCredential::collectFromCredentialStore(PublicKeyCredentialRequestOptions&&, bool)
    105 {
    106     return { };
    107 }
    108 
    109 ExceptionOr<RefPtr<BasicCredential>> PublicKeyCredential::discoverFromExternalSource(const SecurityOrigin& callerOrigin, const PublicKeyCredentialRequestOptions& options, bool sameOriginWithAncestors)
    110 {
    111     using namespace PublicKeyCredentialInternal;
    112 
    113     // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.
    114     // FIXME: Extensions are not supported yet. Skip Step 8-9.
    115     // Step 1, 3-4, 13, 16 are handled by the caller, including options sanitizing, timer and abort signal.
    116     // Step 2.
    117     if (!sameOriginWithAncestors)
    118         return Exception { NotAllowedError };
    119 
    120     // Step 5-7.
    121     // FIXME(181950): We lack fundamental support from SecurityOrigin to determine if a host is a valid domain or not.
    122     // Step 6 is therefore skipped. Also, we lack the support to determine whether a domain is a registrable
    123     // domain suffix of another domain. Hence restrict the comparison to equal in Step 7.
    124     if (!options.rpId.isEmpty() && !(callerOrigin.host() == options.rpId))
    125         return Exception { SecurityError };
    126     if (options.rpId.isEmpty())
    127         options.rpId = callerOrigin.host();
    128 
    129     // Step 10-12.
    130     auto clientDataJson = produceClientDataJson(ClientDataType::Get, options.challenge, callerOrigin);
    131     auto clientDataJsonHash = produceClientDataJsonHash(clientDataJson);
    132 
    133     // Step 14-15, 17-19.
    134     // Only platform attachments will be supported at this stage. Assuming one authenticator per device.
    135     // Also, resident keys, user verifications and direct attestation are enforced at this tage.
    136     // For better performance, no filtering is done here regarding to options.excludeCredentials.
    137     // What's more, user cancellations effectively means NotAllowedError. Therefore, the below call
    138     // will only returns either an exception or a PublicKeyCredential ref.
    139     // FIXME(181946): The following operation might need to perform async.
    140     auto result = Authenticator::singleton().getAssertion(options.rpId, clientDataJsonHash, options.allowCredentials);
    141     if (result.hasException())
    142         return result.releaseException();
    143 
    144     auto bundle = result.releaseReturnValue();
    145     return ExceptionOr<RefPtr<BasicCredential>>(PublicKeyCredential::create(WTFMove(bundle.credentialID), AuthenticatorAssertionResponse::create(WTFMove(clientDataJson), WTFMove(bundle.authenticatorData), WTFMove(bundle.signature), WTFMove(bundle.userHandle))));
    146 }
    147 
    148 RefPtr<BasicCredential> PublicKeyCredential::store(RefPtr<BasicCredential>&&, bool)
    149 {
    150     return nullptr;
    151 }
    152 
    153 ExceptionOr<RefPtr<BasicCredential>> PublicKeyCredential::create(const SecurityOrigin& callerOrigin, const PublicKeyCredentialCreationOptions& options, bool sameOriginWithAncestors)
    154 {
    155     using namespace PublicKeyCredentialInternal;
    156 
    157     // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.
    158     // FIXME: Extensions are not supported yet. Skip Step 11-12.
    159     // Step 1, 3-4, 16-17 are handled by the caller, including options sanitizing, timer and abort signal.
    160     // Step 2.
    161     if (!sameOriginWithAncestors)
    162         return Exception { NotAllowedError };
    163 
    164     // Step 5-7.
    165     // FIXME(181950): We lack fundamental support from SecurityOrigin to determine if a host is a valid domain or not.
    166     // Step 6 is therefore skipped. Also, we lack the support to determine whether a domain is a registrable
    167     // domain suffix of another domain. Hence restrict the comparison to equal in Step 7.
    168     if (!options.rp.id.isEmpty() && !(callerOrigin.host() == options.rp.id))
    169         return Exception { SecurityError };
    170     if (options.rp.id.isEmpty())
    171         options.rp.id = callerOrigin.host();
    172 
    173     // Step 8-10.
    174     // Most of the jobs are done by bindings. However, we can't know if the JSValue of options.pubKeyCredParams
    175     // is empty or not. Return NotSupportedError as long as it is empty.
    176     if (options.pubKeyCredParams.isEmpty())
    177         return Exception { NotSupportedError };
    178 
    179     // Step 13-15.
    180     auto clientDataJson = produceClientDataJson(ClientDataType::Create, options.challenge, callerOrigin);
    181     auto clientDataJsonHash = produceClientDataJsonHash(clientDataJson);
    182 
    183     // Step 18-21.
    184     // Only platform attachments will be supported at this stage. Assuming one authenticator per device.
    185     // Also, resident keys, user verifications and direct attestation are enforced at this tage.
    186     // For better performance, no filtering is done here regarding to options.excludeCredentials.
    187     // What's more, user cancellations effectively means NotAllowedError. Therefore, the below call
    188     // will only returns either an exception or a PublicKeyCredential ref.
    189     // FIXME(181946): The following operation might need to perform async.
    190     auto result = Authenticator::singleton().makeCredential(clientDataJsonHash, options.rp, options.user, options.pubKeyCredParams, options.excludeCredentials);
    191     if (result.hasException())
    192         return result.releaseException();
    193 
    194     auto attestationObject = result.releaseReturnValue();
    195     return ExceptionOr<RefPtr<BasicCredential>>(PublicKeyCredential::create(getIdFromAttestationObject(attestationObject), AuthenticatorAttestationResponse::create(WTFMove(clientDataJson), ArrayBuffer::create(attestationObject.data(), attestationObject.size()))));
    196 }
    197 
    198 ArrayBuffer* PublicKeyCredential::rawId() const
    199 {
    200     return m_rawId.get();
    201 }
    202 
    203 AuthenticatorResponse* PublicKeyCredential::response() const
    204 {
    205     return m_response.get();
    20641}
    20742
  • trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.h

    r228218 r228444  
    3737class AuthenticatorResponse;
    3838class DeferredPromise;
    39 class SecurityOrigin;
    40 
    41 struct PublicKeyCredentialCreationOptions;
    42 struct PublicKeyCredentialRequestOptions;
    4339
    4440class PublicKeyCredential final : public BasicCredential {
     
    4945    }
    5046
    51     static Vector<Ref<BasicCredential>> collectFromCredentialStore(PublicKeyCredentialRequestOptions&&, bool);
    52     static ExceptionOr<RefPtr<BasicCredential>> discoverFromExternalSource(const SecurityOrigin&, const PublicKeyCredentialRequestOptions&, bool sameOriginWithAncestors);
    53     static RefPtr<BasicCredential> store(RefPtr<BasicCredential>&&, bool);
    54     static ExceptionOr<RefPtr<BasicCredential>> create(const SecurityOrigin&, const PublicKeyCredentialCreationOptions&, bool sameOriginWithAncestors);
    55 
    56     ArrayBuffer* rawId() const;
    57     AuthenticatorResponse* response() const;
     47    ArrayBuffer* rawId() const { return m_rawId.get(); }
     48    AuthenticatorResponse* response() const { return m_response.get(); }
    5849    // Not support yet. Always throws.
    5950    ExceptionOr<bool> getClientExtensionResults() const;
  • trunk/Source/WebCore/Sources.txt

    r228427 r228444  
    4646Modules/credentialmanagement/BasicCredential.cpp
    4747Modules/credentialmanagement/CredentialsContainer.cpp
     48Modules/credentialmanagement/CredentialsMessenger.cpp
    4849Modules/credentialmanagement/NavigatorCredentials.cpp
    4950
     
    245246Modules/webaudio/WaveShaperProcessor.cpp
    246247
    247 Modules/webauthn/Authenticator.cpp
    248248Modules/webauthn/AuthenticatorAssertionResponse.cpp
    249249Modules/webauthn/AuthenticatorAttestationResponse.cpp
     250Modules/webauthn/AuthenticatorManager.cpp
    250251Modules/webauthn/AuthenticatorResponse.cpp
    251252Modules/webauthn/PublicKeyCredential.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r228427 r228444  
    16631663                57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; };
    16641664                57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */; };
    1665                 57303C4620105D2F00355965 /* Authenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* Authenticator.h */; };
     1665                57303C4620105D2F00355965 /* AuthenticatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
    16661666                573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; };
    16671667                5739E12F1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */; };
     
    16711671                5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; };
    16721672                5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; };
     1673                5760827220215A5500116678 /* CredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* CredentialsMessenger.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1674                5760827A2024EA5C00116678 /* MockCredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760827820244DAB00116678 /* MockCredentialsMessenger.h */; };
     1675                5760827B2024ED2900116678 /* MockCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */; };
     1676                5760828620256AFA00116678 /* JSMockCredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082822025679700116678 /* JSMockCredentialsMessenger.h */; };
     1677                5760828820256AFD00116678 /* JSMockCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 576082812025679600116678 /* JSMockCredentialsMessenger.cpp */; };
    16731678                5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; };
    16741679                576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; };
     
    82408245                57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorAssertionResponse.h; sourceTree = "<group>"; };
    82418246                57303C2E2009B7DA00355965 /* JSAuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; };
    8242                 57303C4320105B3D00355965 /* Authenticator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Authenticator.h; sourceTree = "<group>"; };
    8243                 57303C4420105B3D00355965 /* Authenticator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Authenticator.cpp; sourceTree = "<group>"; };
     8247                57303C4320105B3D00355965 /* AuthenticatorManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorManager.h; sourceTree = "<group>"; };
     8248                57303C4420105B3D00355965 /* AuthenticatorManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorManager.cpp; sourceTree = "<group>"; };
    82448249                573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmParameters.h; sourceTree = "<group>"; };
    82458250                5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoAlgorithmParameters.h; sourceTree = "<group>"; };
     
    82608265                5760824F20118D8D00116678 /* JSBasicCredentialCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBasicCredentialCustom.cpp; sourceTree = "<group>"; };
    82618266                576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; };
     8267                576082702021513F00116678 /* CredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CredentialsMessenger.h; sourceTree = "<group>"; };
     8268                5760827820244DAB00116678 /* MockCredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockCredentialsMessenger.h; sourceTree = "<group>"; };
     8269                5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockCredentialsMessenger.cpp; sourceTree = "<group>"; };
     8270                57608280202556F400116678 /* MockCredentialsMessenger.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockCredentialsMessenger.idl; sourceTree = "<group>"; };
     8271                576082812025679600116678 /* JSMockCredentialsMessenger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockCredentialsMessenger.cpp; sourceTree = "<group>"; };
     8272                576082822025679700116678 /* JSMockCredentialsMessenger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockCredentialsMessenger.h; sourceTree = "<group>"; };
     8273                57608293202BA95300116678 /* CredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CredentialsMessenger.cpp; sourceTree = "<group>"; };
    82628274                576814281E6F98AD00E77754 /* EcdhKeyDeriveParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = EcdhKeyDeriveParams.idl; sourceTree = "<group>"; };
    82638275                576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmEcdhKeyDeriveParams.h; sourceTree = "<group>"; };
     
    1648916501                                A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */,
    1649016502                                A19AEA1C1AAA7C4900B52B25 /* MockContentFilterSettings.idl */,
     16503                                5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */,
     16504                                5760827820244DAB00116678 /* MockCredentialsMessenger.h */,
     16505                                57608280202556F400116678 /* MockCredentialsMessenger.idl */,
    1649116506                                51058AD71D679257009A538C /* MockGamepad.cpp */,
    1649216507                                51058AD81D679257009A538C /* MockGamepad.h */,
     
    1653916554                                A19AEA1D1AAA806E00B52B25 /* JSMockContentFilterSettings.cpp */,
    1654016555                                A19AEA1E1AAA806E00B52B25 /* JSMockContentFilterSettings.h */,
     16556                                576082812025679600116678 /* JSMockCredentialsMessenger.cpp */,
     16557                                576082822025679700116678 /* JSMockCredentialsMessenger.h */,
    1654116558                                2D6F3E921C1F85550061DBD4 /* JSMockPageOverlay.cpp */,
    1654216559                                2D6F3E931C1F85550061DBD4 /* JSMockPageOverlay.h */,
     
    1819718214                                77D510161ED6021B00DA4C87 /* CredentialsContainer.h */,
    1819818215                                57D846291FE99F6300CA3682 /* CredentialsContainer.idl */,
     18216                                57608293202BA95300116678 /* CredentialsMessenger.cpp */,
     18217                                576082702021513F00116678 /* CredentialsMessenger.h */,
    1819918218                                57D846241FE895F500CA3682 /* NavigatorCredentials.cpp */,
    1820018219                                57D846261FE895F800CA3682 /* NavigatorCredentials.h */,
     
    1822518244                        children = (
    1822618245                                57303BB32006C6ED00355965 /* cbor */,
    18227                                 57303C4420105B3D00355965 /* Authenticator.cpp */,
    18228                                 57303C4320105B3D00355965 /* Authenticator.h */,
    1822918246                                57303C282009B2FC00355965 /* AuthenticatorAssertionResponse.cpp */,
    1823018247                                57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */,
     
    1823318250                                57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */,
    1823418251                                57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */,
     18252                                57303C4420105B3D00355965 /* AuthenticatorManager.cpp */,
     18253                                57303C4320105B3D00355965 /* AuthenticatorManager.h */,
    1823518254                                57303BD020087A8300355965 /* AuthenticatorResponse.cpp */,
    1823618255                                57303BCF20087A8300355965 /* AuthenticatorResponse.h */,
     
    2637726396                                538EC9331F99B9F7004D22A8 /* JSMockCDMFactory.h in Headers */,
    2637826397                                A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */,
     26398                                5760828620256AFA00116678 /* JSMockCredentialsMessenger.h in Headers */,
    2637926399                                538EC9341F99B9F7004D22A8 /* JSMockPageOverlay.h in Headers */,
    2638026400                                A146D3231F99D0EF00D29196 /* JSMockPaymentAddress.h in Headers */,
     
    2638526405                                A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
    2638626406                                A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
     26407                                5760827A2024EA5C00116678 /* MockCredentialsMessenger.h in Headers */,
    2638726408                                51058ADC1D6792C1009A538C /* MockGamepad.h in Headers */,
    2638826409                                51058ADE1D6792C1009A538C /* MockGamepadProvider.h in Headers */,
     
    2656526586                                E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */,
    2656626587                                514C764C0CE9234E007EF3CD /* AuthenticationMac.h in Headers */,
    26567                                 57303C4620105D2F00355965 /* Authenticator.h in Headers */,
    2656826588                                57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */,
    2656926589                                57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */,
     26590                                57303C4620105D2F00355965 /* AuthenticatorManager.h in Headers */,
    2657026591                                57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */,
    2657126592                                A501920E132EBF2E008BFE55 /* Autocapitalize.h in Headers */,
     
    2682526846                                77D5100B1ED5E28800DA4C87 /* CredentialRequestOptions.h in Headers */,
    2682626847                                77D510171ED6022200DA4C87 /* CredentialsContainer.h in Headers */,
     26848                                5760827220215A5500116678 /* CredentialsMessenger.h in Headers */,
    2682726849                                51A052331058774F00CC9E95 /* CredentialStorage.h in Headers */,
    2682826850                                2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */,
     
    3070330725                                CDF4B7321E03D06000E235A2 /* JSMockCDMFactory.cpp in Sources */,
    3070430726                                A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
     30727                                5760828820256AFD00116678 /* JSMockCredentialsMessenger.cpp in Sources */,
    3070530728                                2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */,
    3070630729                                A146D3221F99D0EC00D29196 /* JSMockPaymentAddress.cpp in Sources */,
     
    3071230735                                A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */,
    3071330736                                A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */,
     30737                                5760827B2024ED2900116678 /* MockCredentialsMessenger.cpp in Sources */,
    3071430738                                51058ADB1D6792C1009A538C /* MockGamepad.cpp in Sources */,
    3071530739                                51058ADD1D6792C1009A538C /* MockGamepadProvider.cpp in Sources */,
  • trunk/Source/WebCore/testing/Internals.cpp

    r228260 r228444  
    260260#endif
    261261
     262#if ENABLE(WEB_AUTHN)
     263#include "AuthenticatorManager.h"
     264#include "MockCredentialsMessenger.h"
     265#endif
     266
    262267using JSC::CallData;
    263268using JSC::CallType;
     
    526531        frame->mainFrame().setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*m_mockPaymentCoordinator));
    527532    }
     533#endif
     534
     535#if ENABLE(WEB_AUTHN)
     536    m_mockCredentialsMessenger = std::make_unique<MockCredentialsMessenger>(*this);
     537    AuthenticatorManager::singleton().setMessenger(*m_mockCredentialsMessenger);
    528538#endif
    529539}
     
    43764386#endif
    43774387
     4388#if ENABLE(WEB_AUTHN)
     4389MockCredentialsMessenger& Internals::mockCredentialsMessenger() const
     4390{
     4391    return *m_mockCredentialsMessenger;
     4392}
     4393#endif
     4394
    43784395} // namespace WebCore
  • trunk/Source/WebCore/testing/Internals.h

    r228218 r228444  
    7272class MockCDMFactory;
    7373class MockContentFilterSettings;
     74class MockCredentialsMessenger;
    7475class MockPageOverlay;
    7576class MockPaymentCoordinator;
     
    644645    void testIncomingSyncIPCMessageWhileWaitingForSyncReply();
    645646
     647#if ENABLE(WEB_AUTHN)
     648    MockCredentialsMessenger& mockCredentialsMessenger() const;
     649#endif
     650
    646651private:
    647652    explicit Internals(Document&);
     
    669674    MockPaymentCoordinator* m_mockPaymentCoordinator { nullptr };
    670675#endif
     676
     677#if ENABLE(WEB_AUTHN)
     678    std::unique_ptr<MockCredentialsMessenger> m_mockCredentialsMessenger;
     679#endif
    671680};
    672681
  • trunk/Source/WebCore/testing/Internals.idl

    r227936 r228444  
    581581    [EnabledAtRuntime=WebAnimations] void setTimelineCurrentTime(AnimationTimeline timeline, double currentTime);
    582582    [Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator;
    583 };
     583    [Conditional=WEB_AUTHN] readonly attribute MockCredentialsMessenger mockCredentialsMessenger;
     584};
  • trunk/Source/WebCore/testing/MockCredentialsMessenger.h

    r228442 r228444  
    2828#if ENABLE(WEB_AUTHN)
    2929
    30 #include <JavaScriptCore/ArrayBuffer.h>
    31 #include <wtf/ThreadSafeRefCounted.h>
    32 #include <wtf/TypeCasts.h>
     30#include "BufferSource.h"
     31#include "CredentialsMessenger.h"
     32#include <wtf/Forward.h>
    3333
    3434namespace WebCore {
    3535
    36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {
     36class Internals;
     37
     38class MockCredentialsMessenger final : public CredentialsMessenger {
    3739public:
    38     enum class Type {
    39         Assertion,
    40         Attestation
    41     };
     40    MockCredentialsMessenger(Internals&);
    4241
    43     explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
    44     virtual ~AuthenticatorResponse() = default;
     42    void setDidTimeOut() { m_didTimeOut = true; }
     43    void setDidUserCancel() { m_didUserCancel = true; }
     44    void setAttestationObject(const BufferSource&);
     45    void setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle);
    4546
    46     virtual Type type() const = 0;
    47 
    48     ArrayBuffer* clientDataJSON() const;
     47    void ref();
     48    void deref();
    4949
    5050private:
    51     RefPtr<ArrayBuffer> m_clientDataJSON;
     51    void makeCredential(const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, CreationCompletionHandler&&) final;
     52    void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) final;
     53    void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>&) final;
     54    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;
     55
     56    Internals& m_internals;
     57    // All following fields are disposable.
     58    bool m_didTimeOut { false };
     59    bool m_didUserCancel { false };
     60    Vector<uint8_t> m_attestationObject;
     61    Vector<uint8_t> m_credentialId;
     62    Vector<uint8_t> m_authenticatorData;
     63    Vector<uint8_t> m_signature;
     64    Vector<uint8_t> m_userHandle;
    5265};
    5366
    5467} // namespace WebCore
    5568
    56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \
    57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
    58     static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \
    59 SPECIALIZE_TYPE_TRAITS_END()
    60 
    6169#endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebCore/testing/MockCredentialsMessenger.idl

    r228442 r228444  
    2424 */
    2525
    26 #pragma once
    27 
    28 #if ENABLE(WEB_AUTHN)
    29 
    30 #include <JavaScriptCore/ArrayBuffer.h>
    31 #include <wtf/ThreadSafeRefCounted.h>
    32 #include <wtf/TypeCasts.h>
    33 
    34 namespace WebCore {
    35 
    36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {
    37 public:
    38     enum class Type {
    39         Assertion,
    40         Attestation
    41     };
    42 
    43     explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
    44     virtual ~AuthenticatorResponse() = default;
    45 
    46     virtual Type type() const = 0;
    47 
    48     ArrayBuffer* clientDataJSON() const;
    49 
    50 private:
    51     RefPtr<ArrayBuffer> m_clientDataJSON;
     26[
     27    Conditional=WEB_AUTHN,
     28    NoInterfaceObject,
     29] interface MockCredentialsMessenger {
     30    void setDidTimeOut();
     31    void setDidUserCancel();
     32    void setAttestationObject(BufferSource attestationObject);
     33    void setAssertionReturnBundle(BufferSource credentialId, BufferSource authenticatorData, BufferSource signature, BufferSource userHandle);
    5234};
    53 
    54 } // namespace WebCore
    55 
    56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \
    57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
    58     static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \
    59 SPECIALIZE_TYPE_TRAITS_END()
    60 
    61 #endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebKit/ChangeLog

    r228442 r228444  
     12018-02-13  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting
     4        https://bugs.webkit.org/show_bug.cgi?id=181946
     5        <rdar://problem/37258262>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Dummy WebCredentialsMessenger and WebCredentialsMessengerProxy are crafted to establish
     10        a message exchange channel between UIProcess and WebProcess.
     11
     12        * DerivedSources.make:
     13        * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
     14        (WebKit::WebCredentialsMessengerProxy::WebCredentialsMessengerProxy):
     15        (WebKit::WebCredentialsMessengerProxy::~WebCredentialsMessengerProxy):
     16        (WebKit::WebCredentialsMessengerProxy::makeCredential):
     17        (WebKit::WebCredentialsMessengerProxy::getAssertion):
     18        * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
     19        * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in: Added.
     20        * UIProcess/WebPageProxy.cpp:
     21        (WebKit::m_configurationPreferenceValues):
     22        (WebKit::WebPageProxy::reattachToWebProcess):
     23        * UIProcess/WebPageProxy.h:
     24        * WebKit.xcodeproj/project.pbxproj:
     25        * WebProcess/CredentialManagement/WebCredentialsMessenger.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
     26        (WebKit::WebCredentialsMessenger::WebCredentialsMessenger):
     27        (WebKit::WebCredentialsMessenger::~WebCredentialsMessenger):
     28        (WebKit::WebCredentialsMessenger::makeCredential):
     29        (WebKit::WebCredentialsMessenger::getAssertion):
     30        (WebKit::WebCredentialsMessenger::makeCredentialReply):
     31        (WebKit::WebCredentialsMessenger::getAssertionReply):
     32        * WebProcess/CredentialManagement/WebCredentialsMessenger.h: Copied from Source/WebCore/Modules/webauthn/AuthenticatorResponse.h.
     33        * WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in: Added.
     34        * WebProcess/WebPage/WebPage.cpp:
     35        (WebKit::m_credentialsMessenger):
     36        (WebKit::m_cpuLimit): Deleted.
     37        * WebProcess/WebPage/WebPage.h:
     38
    1392018-02-13  Youenn Fablet  <youenn@apple.com>
    240
  • trunk/Source/WebKit/DerivedSources.make

    r227939 r228444  
    4444    $(WebKit2)/WebProcess/Cache \
    4545    $(WebKit2)/WebProcess/Cookies \
     46    $(WebKit2)/WebProcess/CredentialManagement \
    4647    $(WebKit2)/WebProcess/Databases/IndexedDB \
    4748    $(WebKit2)/WebProcess/FullScreen \
     
    6970    $(WebKit2)/UIProcess/Automation \
    7071    $(WebKit2)/UIProcess/Cocoa \
     72    $(WebKit2)/UIProcess/CredentialManagement \
    7173    $(WebKit2)/UIProcess/Databases \
    7274    $(WebKit2)/UIProcess/Downloads \
     
    146148    WebCookieManager \
    147149    WebCookieManagerProxy \
     150    WebCredentialsMessenger \
     151    WebCredentialsMessengerProxy \
    148152    WebFullScreenManager \
    149153    WebFullScreenManagerProxy \
  • trunk/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp

    r228442 r228444  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "WebCredentialsMessengerProxy.h"
    2728
    2829#if ENABLE(WEB_AUTHN)
    2930
    30 #include <JavaScriptCore/ArrayBuffer.h>
    31 #include <wtf/ThreadSafeRefCounted.h>
    32 #include <wtf/TypeCasts.h>
     31#include "WebCredentialsMessengerMessages.h"
     32#include "WebCredentialsMessengerProxyMessages.h"
     33#include "WebPageProxy.h"
     34#include "WebProcessProxy.h"
    3335
    34 namespace WebCore {
     36namespace WebKit {
    3537
    36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {
    37 public:
    38     enum class Type {
    39         Assertion,
    40         Attestation
    41     };
     38WebCredentialsMessengerProxy::WebCredentialsMessengerProxy(WebPageProxy& webPageProxy)
     39    : m_webPageProxy(webPageProxy)
     40{
     41    m_webPageProxy.process().addMessageReceiver(Messages::WebCredentialsMessengerProxy::messageReceiverName(), m_webPageProxy.pageID(), *this);
     42}
    4243
    43     explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
    44     virtual ~AuthenticatorResponse() = default;
     44WebCredentialsMessengerProxy::~WebCredentialsMessengerProxy()
     45{
     46    m_webPageProxy.process().removeMessageReceiver(Messages::WebCredentialsMessengerProxy::messageReceiverName(), m_webPageProxy.pageID());
     47}
    4548
    46     virtual Type type() const = 0;
     49void WebCredentialsMessengerProxy::makeCredential(uint64_t)
     50{
     51}
    4752
    48     ArrayBuffer* clientDataJSON() const;
     53void WebCredentialsMessengerProxy::getAssertion(uint64_t)
     54{
     55}
    4956
    50 private:
    51     RefPtr<ArrayBuffer> m_clientDataJSON;
    52 };
    53 
    54 } // namespace WebCore
    55 
    56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \
    57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
    58     static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \
    59 SPECIALIZE_TYPE_TRAITS_END()
     57} // namespace WebKit
    6058
    6159#endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h

    r228442 r228444  
    2828#if ENABLE(WEB_AUTHN)
    2929
    30 #include <JavaScriptCore/ArrayBuffer.h>
    31 #include <wtf/ThreadSafeRefCounted.h>
    32 #include <wtf/TypeCasts.h>
     30#include "MessageReceiver.h"
    3331
    34 namespace WebCore {
     32namespace WebKit {
    3533
    36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {
     34class WebPageProxy;
     35
     36class WebCredentialsMessengerProxy : private IPC::MessageReceiver {
    3737public:
    38     enum class Type {
    39         Assertion,
    40         Attestation
    41     };
    42 
    43     explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
    44     virtual ~AuthenticatorResponse() = default;
    45 
    46     virtual Type type() const = 0;
    47 
    48     ArrayBuffer* clientDataJSON() const;
     38    explicit WebCredentialsMessengerProxy(WebPageProxy&);
     39    ~WebCredentialsMessengerProxy();
    4940
    5041private:
    51     RefPtr<ArrayBuffer> m_clientDataJSON;
     42    // IPC::MessageReceiver.
     43    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
     44
     45    // Receivers.
     46    void makeCredential(uint64_t messageId);
     47    void getAssertion(uint64_t messageId);
     48
     49    WebPageProxy& m_webPageProxy;
    5250};
    5351
    54 } // namespace WebCore
    55 
    56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \
    57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
    58     static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \
    59 SPECIALIZE_TYPE_TRAITS_END()
     52} // namespace WebKit
    6053
    6154#endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r228194 r228444  
    196196#endif
    197197
     198#if ENABLE(WEB_AUTHN)
     199#include "WebCredentialsMessengerProxy.h"
     200#endif
     201
    198202// This controls what strategy we use for mouse wheel coalescing.
    199203#define MERGE_WHEEL_EVENTS 1
     
    409413#endif
    410414
     415#if ENABLE(WEB_AUTHN)
     416    m_credentialsMessenger = std::make_unique<WebCredentialsMessengerProxy>(*this);
     417#endif
     418
    411419    m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
    412420
     
    660668#if ENABLE(APPLE_PAY)
    661669    m_paymentCoordinator = std::make_unique<WebPaymentCoordinatorProxy>(*this);
     670#endif
     671
     672#if ENABLE(WEB_AUTHN)
     673    m_credentialsMessenger = std::make_unique<WebCredentialsMessengerProxy>(*this);
    662674#endif
    663675
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r227984 r228444  
    218218class WebNavigationState;
    219219class VideoFullscreenManagerProxy;
     220class WebCredentialsMessengerProxy;
    220221class WebKeyboardEvent;
    221222class WebURLSchemeHandler;
     
    17871788#endif
    17881789
     1790#if ENABLE(WEB_AUTHN)
     1791    std::unique_ptr<WebCredentialsMessengerProxy> m_credentialsMessenger;
     1792#endif
     1793
    17891794    CallbackMap m_callbacks;
    17901795    HashSet<CallbackID> m_loadDependentStringCallbackIDs;
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r228393 r228444  
    12101210                53BA47D11DC2EF5E004DF4AD /* NetworkDataTaskBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */; };
    12111211                53DEA3661DDE423100E82648 /* json.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 53DEA3651DDE422E00E82648 /* json.hpp */; };
     1212                5760828E2029895E00116678 /* WebCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760828C2029854200116678 /* WebCredentialsMessenger.cpp */; };
     1213                57608298202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */; };
     1214                5760829C202D2C3C00116678 /* WebCredentialsMessengerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */; };
     1215                5760829D202D2C4000116678 /* WebCredentialsMessengerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */; };
     1216                5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */; };
     1217                5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */; };
    12121218                5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */; };
    12131219                5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */; };
     
    36313637                539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkDataTaskBlob.h; path = NetworkProcess/NetworkDataTaskBlob.h; sourceTree = "<group>"; };
    36323638                53DEA3651DDE422E00E82648 /* json.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = json.hpp; path = NetworkProcess/capture/json.hpp; sourceTree = "<group>"; };
     3639                5760828B2029854200116678 /* WebCredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessenger.h; sourceTree = "<group>"; };
     3640                5760828C2029854200116678 /* WebCredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessenger.cpp; sourceTree = "<group>"; };
     3641                5760828D202987E600116678 /* WebCredentialsMessenger.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCredentialsMessenger.messages.in; sourceTree = "<group>"; };
     3642                5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerMessages.h; sourceTree = "<group>"; };
     3643                5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerMessageReceiver.cpp; sourceTree = "<group>"; };
     3644                57608295202BD8BA00116678 /* WebCredentialsMessengerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerProxy.h; sourceTree = "<group>"; };
     3645                57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerProxy.cpp; sourceTree = "<group>"; };
     3646                57608299202BDAE200116678 /* WebCredentialsMessengerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCredentialsMessengerProxy.messages.in; sourceTree = "<group>"; };
     3647                5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerProxyMessageReceiver.cpp; sourceTree = "<group>"; };
     3648                5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerProxyMessages.h; sourceTree = "<group>"; };
    36333649                5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
    36343650                5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketStreamMessages.h; sourceTree = "<group>"; };
     
    66836699                        sourceTree = "<group>";
    66846700                };
     6701                5760828A202984C900116678 /* CredentialManagement */ = {
     6702                        isa = PBXGroup;
     6703                        children = (
     6704                                5760828C2029854200116678 /* WebCredentialsMessenger.cpp */,
     6705                                5760828B2029854200116678 /* WebCredentialsMessenger.h */,
     6706                                5760828D202987E600116678 /* WebCredentialsMessenger.messages.in */,
     6707                        );
     6708                        path = CredentialManagement;
     6709                        sourceTree = "<group>";
     6710                };
     6711                57608294202BD84900116678 /* CredentialManagement */ = {
     6712                        isa = PBXGroup;
     6713                        children = (
     6714                                57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */,
     6715                                57608295202BD8BA00116678 /* WebCredentialsMessengerProxy.h */,
     6716                                57608299202BDAE200116678 /* WebCredentialsMessengerProxy.messages.in */,
     6717                        );
     6718                        path = CredentialManagement;
     6719                        sourceTree = "<group>";
     6720                };
    66856721                5C1426F11C23F81700D41183 /* Downloads */ = {
    66866722                        isa = PBXGroup;
     
    69426978                                7C6E70F818B2D47E00F24E2E /* cocoa */,
    69436979                                3309344B1315B93A0097A7BC /* Cookies */,
     6980                                5760828A202984C900116678 /* CredentialManagement */,
    69446981                                512A9754180DF9270039A149 /* Databases */,
    69456982                                BCACC43B16B24C5D00B6E092 /* EntryPoint */,
     
    70997136                                9955A6E81C79809000EB6A93 /* Automation */,
    71007137                                1ABC3DF21899E415004F0626 /* Cocoa */,
     7138                                57608294202BD84900116678 /* CredentialManagement */,
    71017139                                1AB7D4C71288AA9A00CFD08C /* Downloads */,
    71027140                                515BE17B1D54EF5A00DD7C68 /* Gamepad */,
     
    82468284                                330934451315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp */,
    82478285                                330934461315B9220097A7BC /* WebCookieManagerProxyMessages.h */,
     8286                                5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */,
     8287                                5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */,
     8288                                5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */,
     8289                                5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */,
    82488290                                CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */,
    82498291                                CD73BA49131ACD8E00EEDED2 /* WebFullScreenManagerMessages.h */,
     
    91169158                                BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
    91179159                                512F589B12A8838800629530 /* WebCredential.h in Headers */,
     9160                                5760829D202D2C4000116678 /* WebCredentialsMessengerMessages.h in Headers */,
     9161                                5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */,
    91189162                                1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */,
    91199163                                CD19A26E1A13E834008D650E /* WebDiagnosticLoggingClient.h in Headers */,
     
    1080210846                                BCE23263122C6CF300D5C35A /* WebCoreArgumentCodersMac.mm in Sources */,
    1080310847                                512F589A12A8838800629530 /* WebCredential.cpp in Sources */,
     10848                                5760828E2029895E00116678 /* WebCredentialsMessenger.cpp in Sources */,
     10849                                5760829C202D2C3C00116678 /* WebCredentialsMessengerMessageReceiver.cpp in Sources */,
     10850                                57608298202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp in Sources */,
     10851                                5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */,
    1080410852                                1AA83F6C1A5B63FF00026EC6 /* WebDatabaseProvider.cpp in Sources */,
    1080510853                                CD19A26D1A13E82A008D650E /* WebDiagnosticLoggingClient.cpp in Sources */,
  • trunk/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp

    r228442 r228444  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "WebCredentialsMessenger.h"
    2728
    2829#if ENABLE(WEB_AUTHN)
    2930
    30 #include <JavaScriptCore/ArrayBuffer.h>
    31 #include <wtf/ThreadSafeRefCounted.h>
    32 #include <wtf/TypeCasts.h>
     31#include "WebCredentialsMessengerMessages.h"
     32#include "WebCredentialsMessengerProxyMessages.h"
     33#include "WebPage.h"
     34#include "WebProcess.h"
    3335
    34 namespace WebCore {
     36namespace WebKit {
    3537
    36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {
    37 public:
    38     enum class Type {
    39         Assertion,
    40         Attestation
    41     };
     38WebCredentialsMessenger::WebCredentialsMessenger(WebPage& webPage)
     39    : m_webPage(webPage)
     40{
     41    WebProcess::singleton().addMessageReceiver(Messages::WebCredentialsMessenger::messageReceiverName(), m_webPage.pageID(), *this);
     42}
    4243
    43     explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
    44     virtual ~AuthenticatorResponse() = default;
     44WebCredentialsMessenger::~WebCredentialsMessenger()
     45{
     46    WebProcess::singleton().removeMessageReceiver(*this);
     47}
    4548
    46     virtual Type type() const = 0;
     49void WebCredentialsMessenger::makeCredential(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::CreationCompletionHandler&&)
     50{
     51}
    4752
    48     ArrayBuffer* clientDataJSON() const;
     53void WebCredentialsMessenger::getAssertion(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::RequestCompletionHandler&&)
     54{
     55}
    4956
    50 private:
    51     RefPtr<ArrayBuffer> m_clientDataJSON;
    52 };
     57void WebCredentialsMessenger::makeCredentialReply(uint64_t messageId, const Vector<uint8_t>&)
     58{
     59}
    5360
    54 } // namespace WebCore
     61void 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)
     62{
     63}
    5564
    56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \
    57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
    58     static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \
    59 SPECIALIZE_TYPE_TRAITS_END()
     65} // namespace WebKit
    6066
    6167#endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h

    r228442 r228444  
    2828#if ENABLE(WEB_AUTHN)
    2929
    30 #include <JavaScriptCore/ArrayBuffer.h>
    31 #include <wtf/ThreadSafeRefCounted.h>
    32 #include <wtf/TypeCasts.h>
     30#include "MessageReceiver.h"
     31#include <WebCore/CredentialsMessenger.h>
    3332
    34 namespace WebCore {
     33namespace WebKit {
    3534
    36 class AuthenticatorResponse : public ThreadSafeRefCounted<AuthenticatorResponse> {
     35class WebPage;
     36
     37class WebCredentialsMessenger final : public WebCore::CredentialsMessenger, private IPC::MessageReceiver {
    3738public:
    38     enum class Type {
    39         Assertion,
    40         Attestation
    41     };
    42 
    43     explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
    44     virtual ~AuthenticatorResponse() = default;
    45 
    46     virtual Type type() const = 0;
    47 
    48     ArrayBuffer* clientDataJSON() const;
     39    explicit WebCredentialsMessenger(WebPage&);
     40    ~WebCredentialsMessenger();
    4941
    5042private:
    51     RefPtr<ArrayBuffer> m_clientDataJSON;
     43    // WebCore::CredentialsMessenger
     44    // sender
     45    void makeCredential(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::CreationCompletionHandler&&) final;
     46    void getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::RequestCompletionHandler&&) final;
     47
     48    // receiver
     49    void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>&) final;
     50    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;
     51
     52    // IPC::MessageReceiver.
     53    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
     54
     55    WebPage& m_webPage;
    5256};
    5357
    54 } // namespace WebCore
    55 
    56 #define SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(ToClassName, Type) \
    57 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
    58     static bool isType(const WebCore::AuthenticatorResponse& response) { return response.type() == WebCore::Type; } \
    59 SPECIALIZE_TYPE_TRAITS_END()
     58} // namespace WebKit
    6059
    6160#endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r228351 r228444  
    261261#endif
    262262
     263#if ENABLE(WEB_AUTHN)
     264#include "WebCredentialsMessenger.h"
     265#include <WebCore/AuthenticatorManager.h>
     266#endif
     267
    263268using namespace JSC;
    264269using namespace WebCore;
     
    371376    , m_overrideContentSecurityPolicy { parameters.overrideContentSecurityPolicy }
    372377    , m_cpuLimit(parameters.cpuLimit)
     378#if ENABLE(WEB_AUTHN)
     379    , m_credentialsMessenger(std::make_unique<WebCredentialsMessenger>(*this))
     380#endif
    373381{
    374382    ASSERT(m_pageID);
     
    579587        enableEnumeratingAllNetworkInterfaces();
    580588#endif
     589#endif
     590
     591#if ENABLE(WEB_AUTHN)
     592    WebCore::AuthenticatorManager::singleton().setMessenger(*m_credentialsMessenger);
    581593#endif
    582594
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r227984 r228444  
    212212class WebWheelEvent;
    213213class WebTouchEvent;
     214class WebCredentialsMessenger;
    214215class RemoteLayerTreeTransaction;
    215216
     
    16871688    HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap;
    16881689#endif
     1690
     1691#if ENABLE(WEB_AUTHN)
     1692    std::unique_ptr<WebCredentialsMessenger> m_credentialsMessenger;
     1693#endif
     1694
    16891695};
    16901696
Note: See TracChangeset for help on using the changeset viewer.