| Differences between
and this patch
- a/Source/WebCore/ChangeLog +107 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2018-09-08  Jiewen Tan  <jiewen_tan@apple.com>
2
3
        [WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
4
        https://bugs.webkit.org/show_bug.cgi?id=189277
5
        <rdar://problem/44115936>
6
7
        Reviewed by Chris Dumez.
8
9
        This patch aims to polish AuthenticatorManager such that:
10
        1) It is no longer a singleton. Instead, it will live with Page. It was a singleton simply because static
11
        PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable() have to access it. However, this request
12
        can be fulfilled by adding an attribute [CallWith=Document] to the IDL defination. Therefore, there is no
13
        such need. Also, the singleton is illy implemented as it owns a single IPC proxy to UI Process which means
14
        different web pages will talk to the same web page proxy. Anyway, making it live with Page should fix everything.
15
        2) Since we are now planning to support external authenticators, the manager of all authenticators will then
16
        have to live in UI Process which makes this AuthenticatorManager obsolete. Instead, rename it to AuthenticatorCoordinator.
17
        3) Rename CredentialsMessenger to AuthenticatorCoordinatorClient to tight it to WebAuthN. Also, simplify the
18
        message reply model as PublicKeyCredentialCreationOptions/PublicKeyCredentialRequestOptions =>
19
        ExceptionData/PublicKeyCredentialData for makeCredential/getAssertion operations.
20
        4) Restrict one request per time, i.e. makeCredential/getAssertion for a single page.
21
        5) Unifying makeCredentialReply/getAssertionReply/exceptionReply into requestReply for IPC. Correspondingly,
22
        unify callback and exceptionCallback into callback as well for LocalAuthenticator.
23
        6) Enhance PublicKeyCredentialCreationOptions encoding/decoding with encoder.encodeFixedLengthData/decoder.decodeFixedLengthData.
24
25
        Covered by existing tests.
26
27
        * DerivedSources.make:
28
        * Modules/credentialmanagement/CredentialsContainer.cpp:
29
        (WebCore::CredentialsContainer::get):
30
        (WebCore::CredentialsContainer::isCreate):
31
        * Modules/credentialmanagement/CredentialsContainer.h:
32
        * Modules/credentialmanagement/CredentialsMessenger.cpp: Removed.
33
        * Modules/credentialmanagement/CredentialsMessenger.h: Removed.
34
        * Modules/webauthn/AuthenticatorAssertionResponse.cpp: Removed.
35
        * Modules/webauthn/AuthenticatorAssertionResponse.h:
36
        (WebCore::AuthenticatorAssertionResponse::create):
37
        (WebCore::AuthenticatorAssertionResponse::authenticatorData const):
38
        (WebCore::AuthenticatorAssertionResponse::signature const):
39
        (WebCore::AuthenticatorAssertionResponse::userHandle const):
40
        (WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse):
41
        * Modules/webauthn/AuthenticatorAttestationResponse.cpp: Removed.
42
        * Modules/webauthn/AuthenticatorAttestationResponse.h:
43
        (WebCore::AuthenticatorAttestationResponse::create):
44
        (WebCore::AuthenticatorAttestationResponse::attestationObject const):
45
        (WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse):
46
        * Modules/webauthn/AuthenticatorCoordinator.cpp: Renamed from Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp.
47
        (WebCore::AuthenticatorCoordinatorInternal::produceClientDataJson):
48
        (WebCore::AuthenticatorCoordinatorInternal::produceClientDataJsonHash):
49
        (WebCore::AuthenticatorCoordinatorInternal::initTimeoutTimer):
50
        (WebCore::AuthenticatorCoordinatorInternal::didTimeoutTimerFire):
51
        (WebCore::AuthenticatorCoordinator::AuthenticatorCoordinator):
52
        (WebCore::AuthenticatorCoordinator::setClient):
53
        (WebCore::AuthenticatorCoordinator::create const):
54
        (WebCore::AuthenticatorCoordinator::discoverFromExternalSource const):
55
        (WebCore::AuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable const):
56
        * Modules/webauthn/AuthenticatorCoordinator.h: Renamed from Source/WebCore/Modules/webauthn/AuthenticatorManager.h.
57
        * Modules/webauthn/AuthenticatorCoordinatorClient.cpp: Added.
58
        (WebCore::AuthenticatorCoordinatorClient::~AuthenticatorCoordinatorClient):
59
        (WebCore::AuthenticatorCoordinatorClient::requestReply):
60
        (WebCore::AuthenticatorCoordinatorClient::isUserVerifyingPlatformAuthenticatorAvailableReply):
61
        (WebCore::AuthenticatorCoordinatorClient::setRequestCompletionHandler):
62
        (WebCore::AuthenticatorCoordinatorClient::addQueryCompletionHandler):
63
        * Modules/webauthn/AuthenticatorCoordinatorClient.h: Copied from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h.
64
        * Modules/webauthn/AuthenticatorResponse.cpp: Removed.
65
        * Modules/webauthn/AuthenticatorResponse.h:
66
        (WebCore::AuthenticatorResponse::AuthenticatorResponse):
67
        (WebCore::AuthenticatorResponse::clientDataJSON const):
68
        * Modules/webauthn/PublicKeyCredential.cpp:
69
        (WebCore::PublicKeyCredential::create):
70
        (WebCore::PublicKeyCredential::tryCreate):
71
        (WebCore::PublicKeyCredential::PublicKeyCredential):
72
        (WebCore::PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable):
73
        * Modules/webauthn/PublicKeyCredential.h:
74
        * Modules/webauthn/PublicKeyCredential.idl:
75
        * Modules/webauthn/PublicKeyCredentialCreationOptions.h:
76
        (WebCore::PublicKeyCredentialCreationOptions::encode const):
77
        (WebCore::PublicKeyCredentialCreationOptions::decode):
78
        * Modules/webauthn/PublicKeyCredentialData.h: Added.
79
        (WebCore::PublicKeyCredentialData::encode const):
80
        (WebCore::PublicKeyCredentialData::decode):
81
        * Modules/webauthn/cocoa/LocalAuthenticator.h:
82
        * Modules/webauthn/cocoa/LocalAuthenticator.mm:
83
        (WebCore::LocalAuthenticator::makeCredential):
84
        (WebCore::LocalAuthenticator::getAssertion):
85
        * Sources.txt:
86
        * WebCore.xcodeproj/project.pbxproj:
87
        * page/Page.cpp:
88
        * page/Page.h:
89
        (WebCore::Page::authenticatorCoordinator const):
90
        * page/PageConfiguration.cpp:
91
        * page/PageConfiguration.h:
92
        * testing/Internals.cpp:
93
        (WebCore::Internals::Internals):
94
        (WebCore::Internals::mockAuthenticatorCoordinator const):
95
        (WebCore::Internals::mockCredentialsMessenger const): Deleted.
96
        * testing/Internals.h:
97
        * testing/Internals.idl:
98
        * testing/MockAuthenticatorCoordinator.cpp: Added.
99
        (WebCore::MockAuthenticatorCoordinator::setCreationReturnBundle):
100
        (WebCore::MockAuthenticatorCoordinator::setAssertionReturnBundle):
101
        (WebCore::MockAuthenticatorCoordinator::makeCredential):
102
        (WebCore::MockAuthenticatorCoordinator::getAssertion):
103
        (WebCore::MockAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
104
        * testing/MockAuthenticatorCoordinator.h: Renamed from Source/WebCore/testing/MockCredentialsMessenger.h.
105
        * testing/MockAuthenticatorCoordinator.idl: Renamed from Source/WebCore/testing/MockCredentialsMessenger.idl.
106
        * testing/MockCredentialsMessenger.cpp: Removed.
107
1
2018-09-08  Andy Estes  <aestes@apple.com>
108
2018-09-08  Andy Estes  <aestes@apple.com>
2
109
3
        [Apple Pay] Dispatch a paymentmethodchange event when the payment method changes
110
        [Apple Pay] Dispatch a paymentmethodchange event when the payment method changes
- a/Source/WebKit/ChangeLog +40 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2018-09-08  Jiewen Tan  <jiewen_tan@apple.com>
2
3
        [WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
4
        https://bugs.webkit.org/show_bug.cgi?id=189277
5
        <rdar://problem/44115936>
6
7
        Reviewed by Chris Dumez.
8
9
        * DerivedSources.make:
10
        * SourcesCocoa.txt:
11
        * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: Removed.
12
        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp: Added.
13
        (WebKit::WebAuthenticatorCoordinatorProxy::WebAuthenticatorCoordinatorProxy):
14
        (WebKit::WebAuthenticatorCoordinatorProxy::~WebAuthenticatorCoordinatorProxy):
15
        (WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
16
        (WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
17
        (WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
18
        (WebKit::WebAuthenticatorCoordinatorProxy::requestReply):
19
        (WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailableReply):
20
        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h: Renamed from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h.
21
        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in: Renamed from Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in.
22
        * UIProcess/WebPageProxy.cpp:
23
        (WebKit::m_resetRecentCrashCountTimer):
24
        (WebKit::WebPageProxy::reattachToWebProcess):
25
        * UIProcess/WebPageProxy.h:
26
        * WebKit.xcodeproj/project.pbxproj:
27
        * WebProcess/CredentialManagement/WebCredentialsMessenger.cpp: Removed.
28
        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp: Added.
29
        (WebKit::WebAuthenticatorCoordinator::WebAuthenticatorCoordinator):
30
        (WebKit::WebAuthenticatorCoordinator::~WebAuthenticatorCoordinator):
31
        (WebKit::WebAuthenticatorCoordinator::makeCredential):
32
        (WebKit::WebAuthenticatorCoordinator::getAssertion):
33
        (WebKit::WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
34
        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h: Renamed from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h.
35
        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in: Renamed from Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in.
36
        * WebProcess/WebPage/WebPage.cpp:
37
        (WebKit::m_cpuLimit):
38
        (WebKit::m_credentialsMessenger): Deleted.
39
        * WebProcess/WebPage/WebPage.h:
40
1
2018-09-08  Tim Horton  <timothy_horton@apple.com>
41
2018-09-08  Tim Horton  <timothy_horton@apple.com>
2
42
3
        Unify most of the WebKit Objective-C API sources
43
        Unify most of the WebKit Objective-C API sources
- a/Source/WebCore/DerivedSources.make -1 / +1 lines
Lines 962-970 JS_BINDING_IDLS = \ a/Source/WebCore/DerivedSources.make_sec1
962
    $(WebCore)/testing/Internals.idl \
962
    $(WebCore)/testing/Internals.idl \
963
    $(WebCore)/testing/MallocStatistics.idl \
963
    $(WebCore)/testing/MallocStatistics.idl \
964
    $(WebCore)/testing/MemoryInfo.idl \
964
    $(WebCore)/testing/MemoryInfo.idl \
965
    $(WebCore)/testing/MockAuthenticatorCoordinator.idl \
965
    $(WebCore)/testing/MockCDMFactory.idl \
966
    $(WebCore)/testing/MockCDMFactory.idl \
966
    $(WebCore)/testing/MockContentFilterSettings.idl \
967
    $(WebCore)/testing/MockContentFilterSettings.idl \
967
    $(WebCore)/testing/MockCredentialsMessenger.idl \
968
    $(WebCore)/testing/MockPageOverlay.idl \
968
    $(WebCore)/testing/MockPageOverlay.idl \
969
    $(WebCore)/testing/MockPaymentAddress.idl \
969
    $(WebCore)/testing/MockPaymentAddress.idl \
970
    $(WebCore)/testing/MockPaymentCoordinator.idl \
970
    $(WebCore)/testing/MockPaymentCoordinator.idl \
- a/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp -6 / +5 lines
Lines 35-40 a/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp_sec1
35
#include "Document.h"
35
#include "Document.h"
36
#include "ExceptionOr.h"
36
#include "ExceptionOr.h"
37
#include "JSDOMPromiseDeferred.h"
37
#include "JSDOMPromiseDeferred.h"
38
#include "Page.h"
38
#include "SecurityOrigin.h"
39
#include "SecurityOrigin.h"
39
40
40
namespace WebCore {
41
namespace WebCore {
Lines 63-69 void CredentialsContainer::get(CredentialRequestOptions&& options, CredentialPro a/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp_sec2
63
{
64
{
64
    // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-request as of 4 August 2017
65
    // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-request as of 4 August 2017
65
    // with enhancement from 14 November 2017 Editor's Draft.
66
    // with enhancement from 14 November 2017 Editor's Draft.
66
    if (!m_document) {
67
    if (!m_document || !m_document->page()) {
67
        promise.reject(Exception { NotSupportedError });
68
        promise.reject(Exception { NotSupportedError });
68
        return;
69
        return;
69
    }
70
    }
Lines 82-89 void CredentialsContainer::get(CredentialRequestOptions&& options, CredentialPro a/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp_sec3
82
        return;
83
        return;
83
    }
84
    }
84
85
85
    // Async operations are dispatched/handled in (Web)CredentialMessenger, which exchanges messages between WebProcess and UIProcess.
86
    m_document->page()->authenticatorCoordinator().discoverFromExternalSource(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
86
    AuthenticatorManager::singleton().discoverFromExternalSource(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
87
}
87
}
88
88
89
void CredentialsContainer::store(const BasicCredential&, CredentialPromise&& promise)
89
void CredentialsContainer::store(const BasicCredential&, CredentialPromise&& promise)
Lines 95-101 void CredentialsContainer::isCreate(CredentialCreationOptions&& options, Credent a/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp_sec4
95
{
95
{
96
    // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-create as of 4 August 2017
96
    // The following implements https://www.w3.org/TR/credential-management-1/#algorithm-create as of 4 August 2017
97
    // with enhancement from 14 November 2017 Editor's Draft.
97
    // with enhancement from 14 November 2017 Editor's Draft.
98
    if (!m_document) {
98
    if (!m_document || !m_document->page()) {
99
        promise.reject(Exception { NotSupportedError });
99
        promise.reject(Exception { NotSupportedError });
100
        return;
100
        return;
101
    }
101
    }
Lines 112-119 void CredentialsContainer::isCreate(CredentialCreationOptions&& options, Credent a/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp_sec5
112
        return;
112
        return;
113
    }
113
    }
114
114
115
    // Async operations are dispatched/handled in (Web)CredentialMessenger, which exchanges messages between WebProcess and UIProcess.
115
    m_document->page()->authenticatorCoordinator().create(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
116
    AuthenticatorManager::singleton().create(m_document->securityOrigin(), options.publicKey.value(), doesHaveSameOriginAsItsAncestors(), WTFMove(options.signal), WTFMove(promise));
117
}
116
}
118
117
119
void CredentialsContainer::preventSilentAccess(DOMPromiseDeferred<void>&& promise) const
118
void CredentialsContainer::preventSilentAccess(DOMPromiseDeferred<void>&& promise) const
- a/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h -1 / +1 lines
Lines 28-34 a/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.h_sec1
28
28
29
#if ENABLE(WEB_AUTHN)
29
#if ENABLE(WEB_AUTHN)
30
30
31
#include "AuthenticatorManager.h"
31
#include "AuthenticatorCoordinator.h"
32
#include <wtf/RefCounted.h>
32
#include <wtf/RefCounted.h>
33
#include <wtf/WeakPtr.h>
33
#include <wtf/WeakPtr.h>
34
34
- a/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.cpp -109 lines
Lines 1-109 a/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "CredentialsMessenger.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
namespace WebCore {
32
33
namespace CredentialsMessengerInternal {
34
35
const uint64_t maxMessageId = 0xFFFFFFFFFFFFFF; // 56 bits
36
const size_t callBackClassifierOffset = 56;
37
38
}
39
40
void CredentialsMessenger::exceptionReply(uint64_t messageId, const ExceptionData& exception)
41
{
42
    using namespace CredentialsMessengerInternal;
43
44
    if (!(messageId >> callBackClassifierOffset ^ CallBackClassifier::Creation)) {
45
        auto handler = takeCreationCompletionHandler(messageId);
46
        handler(exception.toException());
47
        return;
48
    }
49
    if (!(messageId >> callBackClassifierOffset ^ CallBackClassifier::Request)) {
50
        auto handler = takeRequestCompletionHandler(messageId);
51
        handler(exception.toException());
52
        return;
53
    }
54
}
55
56
uint64_t CredentialsMessenger::addCreationCompletionHandler(CreationCompletionHandler&& handler)
57
{
58
    using namespace CredentialsMessengerInternal;
59
60
    uint64_t messageId = m_accumulatedMessageId++;
61
    ASSERT(messageId <= maxMessageId);
62
    messageId = messageId | CallBackClassifier::Creation << callBackClassifierOffset;
63
    auto addResult = m_pendingCreationCompletionHandlers.add(messageId, WTFMove(handler));
64
    ASSERT_UNUSED(addResult, addResult.isNewEntry);
65
    return messageId;
66
}
67
68
CreationCompletionHandler CredentialsMessenger::takeCreationCompletionHandler(uint64_t messageId)
69
{
70
    return m_pendingCreationCompletionHandlers.take(messageId);
71
}
72
73
uint64_t CredentialsMessenger::addRequestCompletionHandler(RequestCompletionHandler&& handler)
74
{
75
    using namespace CredentialsMessengerInternal;
76
77
    uint64_t messageId = m_accumulatedMessageId++;
78
    ASSERT(messageId <= maxMessageId);
79
    messageId = messageId | CallBackClassifier::Request << callBackClassifierOffset;
80
    auto addResult = m_pendingRequestCompletionHandlers.add(messageId, WTFMove(handler));
81
    ASSERT_UNUSED(addResult, addResult.isNewEntry);
82
    return messageId;
83
}
84
85
RequestCompletionHandler CredentialsMessenger::takeRequestCompletionHandler(uint64_t messageId)
86
{
87
    return m_pendingRequestCompletionHandlers.take(messageId);
88
}
89
90
uint64_t CredentialsMessenger::addQueryCompletionHandler(QueryCompletionHandler&& handler)
91
{
92
    using namespace CredentialsMessengerInternal;
93
94
    uint64_t messageId = m_accumulatedMessageId++;
95
    ASSERT(messageId < maxMessageId);
96
    messageId = messageId | CallBackClassifier::Query << callBackClassifierOffset;
97
    auto addResult = m_pendingQueryCompletionHandlers.add(messageId, WTFMove(handler));
98
    ASSERT_UNUSED(addResult, addResult.isNewEntry);
99
    return messageId;
100
}
101
102
QueryCompletionHandler CredentialsMessenger::takeQueryCompletionHandler(uint64_t messageId)
103
{
104
    return m_pendingQueryCompletionHandlers.take(messageId);
105
}
106
107
} // namespace WebCore
108
109
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h -115 lines
Lines 1-115 a/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "ExceptionData.h"
31
#include "ExceptionOr.h"
32
#include <JavaScriptCore/ArrayBuffer.h>
33
#include <wtf/CompletionHandler.h>
34
#include <wtf/HashMap.h>
35
#include <wtf/WeakPtr.h>
36
37
namespace WebCore {
38
39
class DeferredPromise;
40
41
struct PublicKeyCredentialCreationOptions;
42
struct PublicKeyCredentialRequestOptions;
43
44
struct CreationReturnBundle {
45
    CreationReturnBundle(Ref<ArrayBuffer>&& credentialId, Ref<ArrayBuffer>&& attestationObject)
46
        : credentialId(WTFMove(credentialId))
47
        , attestationObject(WTFMove(attestationObject))
48
    {
49
    }
50
51
    Ref<ArrayBuffer> credentialId;
52
    Ref<ArrayBuffer> attestationObject;
53
};
54
struct AssertionReturnBundle {
55
    AssertionReturnBundle(Ref<ArrayBuffer>&& credentialId, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, Ref<ArrayBuffer>&& userHandle)
56
        : credentialId(WTFMove(credentialId))
57
        , authenticatorData(WTFMove(authenticatorData))
58
        , signature(WTFMove(signature))
59
        , userHandle(WTFMove(userHandle))
60
    {
61
    }
62
63
    Ref<ArrayBuffer> credentialId;
64
    Ref<ArrayBuffer> authenticatorData;
65
    Ref<ArrayBuffer> signature;
66
    Ref<ArrayBuffer> userHandle;
67
};
68
69
using CreationCompletionHandler = CompletionHandler<void(ExceptionOr<CreationReturnBundle>&&)>;
70
using RequestCompletionHandler = CompletionHandler<void(ExceptionOr<AssertionReturnBundle>&&)>;
71
using QueryCompletionHandler = CompletionHandler<void(bool)>;
72
73
class CredentialsMessenger : public CanMakeWeakPtr<CredentialsMessenger> {
74
    WTF_MAKE_FAST_ALLOCATED;
75
    WTF_MAKE_NONCOPYABLE(CredentialsMessenger);
76
public:
77
    CredentialsMessenger() = default;
78
79
    // Senders.
80
    virtual void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, CreationCompletionHandler&&) = 0;
81
    virtual void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) = 0;
82
    virtual void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) = 0;
83
84
    // Receivers.
85
    WEBCORE_EXPORT void exceptionReply(uint64_t messageId, const ExceptionData&);
86
    virtual void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) = 0;
87
    virtual void getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) = 0;
88
    virtual void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool) = 0;
89
90
protected:
91
    virtual ~CredentialsMessenger() = default;
92
93
    WEBCORE_EXPORT uint64_t addCreationCompletionHandler(CreationCompletionHandler&&);
94
    WEBCORE_EXPORT CreationCompletionHandler takeCreationCompletionHandler(uint64_t);
95
    WEBCORE_EXPORT uint64_t addRequestCompletionHandler(RequestCompletionHandler&&);
96
    WEBCORE_EXPORT RequestCompletionHandler takeRequestCompletionHandler(uint64_t);
97
    WEBCORE_EXPORT uint64_t addQueryCompletionHandler(QueryCompletionHandler&&);
98
    WEBCORE_EXPORT QueryCompletionHandler takeQueryCompletionHandler(uint64_t);
99
100
private:
101
    enum CallBackClassifier : uint64_t {
102
        Creation = 0x01,
103
        Request = 0x02,
104
        Query = 0x03,
105
    };
106
    // The most significant byte is reserved as callback classifier.
107
    uint64_t m_accumulatedMessageId { 1 };
108
    HashMap<uint64_t, CreationCompletionHandler> m_pendingCreationCompletionHandlers;
109
    HashMap<uint64_t, RequestCompletionHandler> m_pendingRequestCompletionHandlers;
110
    HashMap<uint64_t, QueryCompletionHandler> m_pendingQueryCompletionHandlers;
111
};
112
113
} // namespace WebCore
114
115
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.cpp -58 lines
Lines 1-58 a/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "AuthenticatorAssertionResponse.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
namespace WebCore {
32
33
AuthenticatorAssertionResponse::AuthenticatorAssertionResponse(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& authenticatorData, RefPtr<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle)
34
    : AuthenticatorResponse(WTFMove(clientDataJSON))
35
    , m_authenticatorData(WTFMove(authenticatorData))
36
    , m_signature(WTFMove(signature))
37
    , m_userHandle(WTFMove(userHandle))
38
{
39
}
40
41
ArrayBuffer* AuthenticatorAssertionResponse::authenticatorData() const
42
{
43
    return m_authenticatorData.get();
44
}
45
46
ArrayBuffer* AuthenticatorAssertionResponse::signature() const
47
{
48
    return m_signature.get();
49
}
50
51
ArrayBuffer* AuthenticatorAssertionResponse::userHandle() const
52
{
53
    return m_userHandle.get();
54
}
55
56
} // namespace WebCore
57
58
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h -8 / +14 lines
Lines 33-57 namespace WebCore { a/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h_sec1
33
33
34
class AuthenticatorAssertionResponse : public AuthenticatorResponse {
34
class AuthenticatorAssertionResponse : public AuthenticatorResponse {
35
public:
35
public:
36
    static Ref<AuthenticatorAssertionResponse> create(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& authenticatorData, RefPtr<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle)
36
    static Ref<AuthenticatorAssertionResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, Ref<ArrayBuffer>&& userHandle)
37
    {
37
    {
38
        return adoptRef(*new AuthenticatorAssertionResponse(WTFMove(clientDataJSON), WTFMove(authenticatorData), WTFMove(signature), WTFMove(userHandle)));
38
        return adoptRef(*new AuthenticatorAssertionResponse(WTFMove(clientDataJSON), WTFMove(authenticatorData), WTFMove(signature), WTFMove(userHandle)));
39
    }
39
    }
40
40
41
    virtual ~AuthenticatorAssertionResponse() = default;
41
    virtual ~AuthenticatorAssertionResponse() = default;
42
42
43
    ArrayBuffer* authenticatorData() const;
43
    ArrayBuffer* authenticatorData() const { return m_authenticatorData.ptr(); }
44
    ArrayBuffer* signature() const;
44
    ArrayBuffer* signature() const { return m_signature.ptr(); }
45
    ArrayBuffer* userHandle() const;
45
    ArrayBuffer* userHandle() const { return m_userHandle.ptr(); }
46
46
47
private:
47
private:
48
    AuthenticatorAssertionResponse(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& authenticatorData, RefPtr<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle);
48
    AuthenticatorAssertionResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, Ref<ArrayBuffer>&& userHandle)
49
        : AuthenticatorResponse(WTFMove(clientDataJSON))
50
        , m_authenticatorData(WTFMove(authenticatorData))
51
        , m_signature(WTFMove(signature))
52
        , m_userHandle(WTFMove(userHandle))
53
    {
54
    }
49
55
50
    Type type() const final { return Type::Assertion; }
56
    Type type() const final { return Type::Assertion; }
51
57
52
    RefPtr<ArrayBuffer> m_authenticatorData;
58
    Ref<ArrayBuffer> m_authenticatorData;
53
    RefPtr<ArrayBuffer> m_signature;
59
    Ref<ArrayBuffer> m_signature;
54
    RefPtr<ArrayBuffer> m_userHandle;
60
    Ref<ArrayBuffer> m_userHandle;
55
};
61
};
56
62
57
} // namespace WebCore
63
} // namespace WebCore
- a/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp -46 lines
Lines 1-46 a/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "AuthenticatorAttestationResponse.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
namespace WebCore {
32
33
AuthenticatorAttestationResponse::AuthenticatorAttestationResponse(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& attestationObject)
34
    : AuthenticatorResponse(WTFMove(clientDataJSON))
35
    , m_attestationObject(WTFMove(attestationObject))
36
{
37
}
38
39
ArrayBuffer* AuthenticatorAttestationResponse::attestationObject() const
40
{
41
    return m_attestationObject.get();
42
}
43
44
} // namespace WebCore
45
46
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h -4 / +8 lines
Lines 33-53 namespace WebCore { a/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h_sec1
33
33
34
class AuthenticatorAttestationResponse : public AuthenticatorResponse {
34
class AuthenticatorAttestationResponse : public AuthenticatorResponse {
35
public:
35
public:
36
    static Ref<AuthenticatorAttestationResponse> create(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& attestationObject)
36
    static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject)
37
    {
37
    {
38
        return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(clientDataJSON), WTFMove(attestationObject)));
38
        return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(clientDataJSON), WTFMove(attestationObject)));
39
    }
39
    }
40
40
41
    virtual ~AuthenticatorAttestationResponse() = default;
41
    virtual ~AuthenticatorAttestationResponse() = default;
42
42
43
    ArrayBuffer* attestationObject() const;
43
    ArrayBuffer* attestationObject() const { return m_attestationObject.ptr(); }
44
44
45
private:
45
private:
46
    AuthenticatorAttestationResponse(RefPtr<ArrayBuffer>&& clientDataJSON, RefPtr<ArrayBuffer>&& attestationObject);
46
    AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject)
47
        : AuthenticatorResponse(WTFMove(clientDataJSON))
48
        , m_attestationObject(WTFMove(attestationObject))
49
    {
50
    }
47
51
48
    Type type() const final { return Type::Attestation; }
52
    Type type() const final { return Type::Attestation; }
49
53
50
    RefPtr<ArrayBuffer> m_attestationObject;
54
    Ref<ArrayBuffer> m_attestationObject;
51
};
55
};
52
56
53
} // namespace WebCore
57
} // namespace WebCore
- a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp +268 lines
Line 0 a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "AuthenticatorCoordinator.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "AbortSignal.h"
32
#include "AuthenticatorAssertionResponse.h"
33
#include "AuthenticatorAttestationResponse.h"
34
#include "AuthenticatorCoordinatorClient.h"
35
#include "JSBasicCredential.h"
36
#include "PublicKeyCredential.h"
37
#include "PublicKeyCredentialCreationOptions.h"
38
#include "PublicKeyCredentialData.h"
39
#include "PublicKeyCredentialRequestOptions.h"
40
#include "SecurityOrigin.h"
41
#include "Timer.h"
42
#include <pal/crypto/CryptoDigest.h>
43
#include <wtf/JSONValues.h>
44
#include <wtf/NeverDestroyed.h>
45
#include <wtf/text/Base64.h>
46
47
namespace WebCore {
48
49
namespace AuthenticatorCoordinatorInternal {
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("type"_s, "webauthn.create"_s);
63
        break;
64
    case ClientDataType::Get:
65
        object->setString("type"_s, "webauthn.get"_s);
66
        break;
67
    }
68
    object->setString("challenge"_s, WTF::base64URLEncode(challenge.data(), challenge.length()));
69
    object->setString("origin"_s, origin.toRawString());
70
    // FIXME: This might be platform dependent.
71
    object->setString("hashAlgorithm"_s, "SHA-256"_s);
72
73
    auto utf8JSONString = object->toJSONString().utf8();
74
    return ArrayBuffer::create(utf8JSONString.data(), utf8JSONString.length());
75
}
76
77
static Vector<uint8_t> produceClientDataJsonHash(const ArrayBuffer& clientDataJson)
78
{
79
    // FIXME: This might be platform dependent.
80
    auto crypto = PAL::CryptoDigest::create(PAL::CryptoDigest::Algorithm::SHA_256);
81
    crypto->addBytes(clientDataJson.data(), clientDataJson.byteLength());
82
    return crypto->computeHash();
83
}
84
85
// FIXME(181947): We should probably trim timeOutInMs to some max allowable number.
86
static std::unique_ptr<Timer> initTimeoutTimer(std::optional<unsigned long> timeOutInMs, const CredentialPromise& promise)
87
{
88
    if (!timeOutInMs)
89
        return nullptr;
90
91
    auto timer = std::make_unique<Timer>([promise = promise] () mutable {
92
        promise.reject(Exception { NotAllowedError, "Operation timed out."_s });
93
    });
94
    timer->startOneShot(Seconds::fromMilliseconds(*timeOutInMs));
95
    return timer;
96
}
97
98
static bool didTimeoutTimerFire(Timer* timer)
99
{
100
    if (!timer)
101
        return false;
102
    if (!timer->isActive())
103
        return true;
104
    timer->stop();
105
    return false;
106
}
107
108
} // namespace AuthenticatorCoordinatorInternal
109
110
AuthenticatorCoordinator::AuthenticatorCoordinator(std::unique_ptr<AuthenticatorCoordinatorClient>&& client)
111
    : m_client(WTFMove(client))
112
{
113
}
114
115
void AuthenticatorCoordinator::setClient(std::unique_ptr<AuthenticatorCoordinatorClient>&& client)
116
{
117
    m_client = WTFMove(client);
118
}
119
120
void AuthenticatorCoordinator::create(const SecurityOrigin& callerOrigin, const PublicKeyCredentialCreationOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
121
{
122
    using namespace AuthenticatorCoordinatorInternal;
123
124
    // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.
125
    // FIXME: Extensions are not supported yet. Skip Step 11-12.
126
    // Step 1, 3, 16 are handled by the caller.
127
    // Step 2.
128
    if (!sameOriginWithAncestors) {
129
        promise.reject(Exception { NotAllowedError, "The origin of the document is not the same as its ancestors."_s });
130
        return;
131
    }
132
133
    // Step 4 & 17.
134
    std::unique_ptr<Timer> timeoutTimer = initTimeoutTimer(options.timeout, promise);
135
136
    // Step 5-7.
137
    // FIXME(181950): We lack fundamental support from SecurityOrigin to determine if a host is a valid domain or not.
138
    // Step 6 is therefore skipped. Also, we lack the support to determine whether a domain is a registrable
139
    // domain suffix of another domain. Hence restrict the comparison to equal in Step 7.
140
    if (!options.rp.id.isEmpty() && callerOrigin.host() != options.rp.id) {
141
        promise.reject(Exception { SecurityError, "The origin of the document is not a registrable domain suffix of the provided RP ID."_s });
142
        return;
143
    }
144
    if (options.rp.id.isEmpty())
145
        options.rp.id = callerOrigin.host();
146
147
    // Step 8-10.
148
    // Most of the jobs are done by bindings. However, we can't know if the JSValue of options.pubKeyCredParams
149
    // is empty or not. Return NotSupportedError as long as it is empty.
150
    if (options.pubKeyCredParams.isEmpty()) {
151
        promise.reject(Exception { NotSupportedError, "No desired properties of the to be created credential are provided."_s });
152
        return;
153
    }
154
155
    // Step 13-15.
156
    auto clientDataJson = produceClientDataJson(ClientDataType::Create, options.challenge, callerOrigin);
157
    auto clientDataJsonHash = produceClientDataJsonHash(clientDataJson);
158
159
    // Step 18-21.
160
    // Only platform attachments will be supported at this stage. Assuming one authenticator per device.
161
    // Also, resident keys, user verifications and direct attestation are enforced at this tage.
162
    // For better performance, transports of options.excludeCredentials are checked in LocalAuthenticator.
163
    if (!m_client)  {
164
        promise.reject(Exception { UnknownError, "Unknown internal error."_s });
165
        return;
166
    }
167
168
    auto completionHandler = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), timeoutTimer = WTFMove(timeoutTimer), abortSignal = WTFMove(abortSignal)] (const WebCore::PublicKeyCredentialData& data, const WebCore::ExceptionData& exception) mutable {
169
        if (didTimeoutTimerFire(timeoutTimer.get()))
170
            return;
171
        if (abortSignal && abortSignal->aborted()) {
172
            promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s });
173
            return;
174
        }
175
176
        data.clientDataJSON = WTFMove(clientDataJson);
177
        if (auto publicKeyCredential = PublicKeyCredential::tryCreate(data)) {
178
            promise.resolve(publicKeyCredential.get());
179
            return;
180
        }
181
        ASSERT(!exception.message.isNull());
182
        promise.reject(exception.toException());
183
    };
184
    // Async operations are dispatched and handled in the messenger.
185
    m_client->makeCredential(clientDataJsonHash, options, WTFMove(completionHandler));
186
}
187
188
void AuthenticatorCoordinator::discoverFromExternalSource(const SecurityOrigin& callerOrigin, const PublicKeyCredentialRequestOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
189
{
190
    using namespace AuthenticatorCoordinatorInternal;
191
192
    // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.
193
    // FIXME: Extensions are not supported yet. Skip Step 8-9.
194
    // Step 1, 3, 13 are handled by the caller.
195
    // Step 2.
196
    if (!sameOriginWithAncestors) {
197
        promise.reject(Exception { NotAllowedError, "The origin of the document is not the same as its ancestors."_s });
198
        return;
199
    }
200
201
    // Step 4 & 16.
202
    std::unique_ptr<Timer> timeoutTimer = initTimeoutTimer(options.timeout, promise);
203
204
    // Step 5-7.
205
    // FIXME(181950): We lack fundamental support from SecurityOrigin to determine if a host is a valid domain or not.
206
    // Step 6 is therefore skipped. Also, we lack the support to determine whether a domain is a registrable
207
    // domain suffix of another domain. Hence restrict the comparison to equal in Step 7.
208
    if (!options.rpId.isEmpty() && callerOrigin.host() != options.rpId) {
209
        promise.reject(Exception { SecurityError, "The origin of the document is not a registrable domain suffix of the provided RP ID."_s });
210
        return;
211
    }
212
    if (options.rpId.isEmpty())
213
        options.rpId = callerOrigin.host();
214
215
    // Step 10-12.
216
    auto clientDataJson = produceClientDataJson(ClientDataType::Get, options.challenge, callerOrigin);
217
    auto clientDataJsonHash = produceClientDataJsonHash(clientDataJson);
218
219
    // Step 14-15, 17-19.
220
    // Only platform attachments will be supported at this stage. Assuming one authenticator per device.
221
    // Also, resident keys, user verifications and direct attestation are enforced at this tage.
222
    // For better performance, filtering of options.allowCredentials is done in LocalAuthenticator.
223
    if (!m_client)  {
224
        promise.reject(Exception { UnknownError, "Unknown internal error."_s });
225
        return;
226
    }
227
228
    auto completionHandler = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), timeoutTimer = WTFMove(timeoutTimer), abortSignal = WTFMove(abortSignal)] (const WebCore::PublicKeyCredentialData& data, const WebCore::ExceptionData& exception) mutable {
229
        if (didTimeoutTimerFire(timeoutTimer.get()))
230
            return;
231
        if (abortSignal && abortSignal->aborted()) {
232
            promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s });
233
            return;
234
        }
235
236
        data.clientDataJSON = WTFMove(clientDataJson);
237
        if (auto publicKeyCredential = PublicKeyCredential::tryCreate(data)) {
238
            promise.resolve(publicKeyCredential.get());
239
            return;
240
        }
241
        ASSERT(!exception.message.isNull());
242
        promise.reject(exception.toException());
243
    };
244
    // Async operations are dispatched and handled in the messenger.
245
    m_client->getAssertion(clientDataJsonHash, options, WTFMove(completionHandler));
246
}
247
248
void AuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&& promise) const
249
{
250
    // The following implements https://www.w3.org/TR/webauthn/#isUserVerifyingPlatformAuthenticatorAvailable
251
    // as of 5 December 2017.
252
    if (!m_client)  {
253
        promise.reject(Exception { UnknownError, "Unknown internal error."_s });
254
        return;
255
    }
256
257
    // FIXME(182767): We should consider more on the assessment of the return value. Right now, we return true/false
258
    // immediately according to platform specific procedures.
259
    auto completionHandler = [promise = WTFMove(promise)] (bool result) mutable {
260
        promise.resolve(result);
261
    };
262
    // Async operation are dispatched and handled in the messenger.
263
    m_client->isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(completionHandler));
264
}
265
266
} // namespace WebCore
267
268
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h +65 lines
Line 0 a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "JSDOMPromiseDeferred.h"
31
#include <wtf/Forward.h>
32
#include <wtf/Noncopyable.h>
33
34
namespace WebCore {
35
36
class AbortSignal;
37
class AuthenticatorCoordinatorClient;
38
class BasicCredential;
39
class SecurityOrigin;
40
41
struct PublicKeyCredentialCreationOptions;
42
struct PublicKeyCredentialRequestOptions;
43
44
using CredentialPromise = DOMPromiseDeferred<IDLNullable<IDLInterface<BasicCredential>>>;
45
46
class AuthenticatorCoordinator {
47
    WTF_MAKE_NONCOPYABLE(AuthenticatorCoordinator);
48
public:
49
    WEBCORE_EXPORT explicit AuthenticatorCoordinator(std::unique_ptr<AuthenticatorCoordinatorClient>&&);
50
    WEBCORE_EXPORT void setClient(std::unique_ptr<AuthenticatorCoordinatorClient>&&);
51
52
    // The following methods implement static methods of PublicKeyCredential.
53
    void create(const SecurityOrigin&, const PublicKeyCredentialCreationOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, CredentialPromise&&) const;
54
    void discoverFromExternalSource(const SecurityOrigin&, const PublicKeyCredentialRequestOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, CredentialPromise&&) const;
55
    void isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&&) const;
56
57
private:
58
    AuthenticatorCoordinator() = default;
59
60
    std::unique_ptr<AuthenticatorCoordinatorClient> m_client;
61
};
62
63
} // namespace WebCore
64
65
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.cpp +76 lines
Line 0 a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "AuthenticatorCoordinatorClient.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "PublicKeyCredentialData.h"
32
33
namespace WebCore {
34
35
AuthenticatorCoordinatorClient::~AuthenticatorCoordinatorClient()
36
{
37
    // Just to call handlers to avoid any assertion failures.
38
    if (m_pendingCompletionHandler)
39
        m_pendingCompletionHandler({ }, { NotAllowedError, "Operation timed out."_s });
40
    for (auto itr = m_pendingQueryCompletionHandlers.begin(); itr !=  m_pendingQueryCompletionHandlers.end(); ++itr)
41
        itr->value(false);
42
}
43
44
void AuthenticatorCoordinatorClient::requestReply(const WebCore::PublicKeyCredentialData& data, const WebCore::ExceptionData& exception)
45
{
46
    m_pendingCompletionHandler(data, exception);
47
}
48
49
void AuthenticatorCoordinatorClient::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
50
{
51
    auto handler = m_pendingQueryCompletionHandlers.take(messageId);
52
    handler(result);
53
}
54
55
bool AuthenticatorCoordinatorClient::setRequestCompletionHandler(RequestCompletionHandler&& handler)
56
{
57
    if (m_pendingCompletionHandler) {
58
        handler({ }, { NotAllowedError, "A request is pending."_s });
59
        return false;
60
    }
61
62
    m_pendingCompletionHandler = WTFMove(handler);
63
    return true;
64
}
65
66
uint64_t AuthenticatorCoordinatorClient::addQueryCompletionHandler(QueryCompletionHandler&& handler)
67
{
68
    uint64_t messageId = m_accumulatedMessageId++;
69
    auto addResult = m_pendingQueryCompletionHandlers.add(messageId, WTFMove(handler));
70
    ASSERT_UNUSED(addResult, addResult.isNewEntry);
71
    return messageId;
72
}
73
74
} // namespace WebCore
75
76
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h +76 lines
Line 0 a/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "ExceptionData.h"
31
#include <wtf/CompletionHandler.h>
32
#include <wtf/HashMap.h>
33
#include <wtf/WeakPtr.h>
34
35
namespace WebCore {
36
37
class DeferredPromise;
38
39
struct PublicKeyCredentialCreationOptions;
40
struct PublicKeyCredentialData;
41
struct PublicKeyCredentialRequestOptions;
42
43
using RequestCompletionHandler = CompletionHandler<void(const WebCore::PublicKeyCredentialData&, const WebCore::ExceptionData&)>;
44
using QueryCompletionHandler = CompletionHandler<void(bool)>;
45
46
class WEBCORE_EXPORT AuthenticatorCoordinatorClient : public CanMakeWeakPtr<AuthenticatorCoordinatorClient> {
47
    WTF_MAKE_FAST_ALLOCATED;
48
    WTF_MAKE_NONCOPYABLE(AuthenticatorCoordinatorClient);
49
public:
50
    AuthenticatorCoordinatorClient() = default;
51
    virtual ~AuthenticatorCoordinatorClient();
52
53
    // Senders.
54
    virtual void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&&) = 0;
55
    virtual void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) = 0;
56
    virtual void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) = 0;
57
58
    // Receivers.
59
    void requestReply(const WebCore::PublicKeyCredentialData&, const WebCore::ExceptionData&);
60
    void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool);
61
62
protected:
63
    // Only one request is allowed at one time. It returns false whenever there is an existing pending request.
64
    // And invokes the provided handler with NotAllowedError.
65
    bool setRequestCompletionHandler(RequestCompletionHandler&&);
66
    uint64_t addQueryCompletionHandler(QueryCompletionHandler&&);
67
68
private:
69
    RequestCompletionHandler m_pendingCompletionHandler;
70
    uint64_t m_accumulatedMessageId { 1 };
71
    HashMap<uint64_t, QueryCompletionHandler> m_pendingQueryCompletionHandlers;
72
};
73
74
} // namespace WebCore
75
76
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp -267 lines
Lines 1-267 a/Source/WebCore/Modules/webauthn/AuthenticatorManager.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "AuthenticatorManager.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "AbortSignal.h"
32
#include "AuthenticatorAssertionResponse.h"
33
#include "AuthenticatorAttestationResponse.h"
34
#include "CredentialsMessenger.h"
35
#include "JSBasicCredential.h"
36
#include "PublicKeyCredential.h"
37
#include "PublicKeyCredentialCreationOptions.h"
38
#include "PublicKeyCredentialRequestOptions.h"
39
#include "SecurityOrigin.h"
40
#include "Timer.h"
41
#include <pal/crypto/CryptoDigest.h>
42
#include <wtf/JSONValues.h>
43
#include <wtf/NeverDestroyed.h>
44
#include <wtf/text/Base64.h>
45
46
namespace WebCore {
47
48
namespace AuthenticatorManagerInternal {
49
50
enum class ClientDataType {
51
    Create,
52
    Get
53
};
54
55
// FIXME(181948): Add token binding ID and extensions.
56
static Ref<ArrayBuffer> produceClientDataJson(ClientDataType type, const BufferSource& challenge, const SecurityOrigin& origin)
57
{
58
    auto object = JSON::Object::create();
59
    switch (type) {
60
    case ClientDataType::Create:
61
        object->setString("type"_s, "webauthn.create"_s);
62
        break;
63
    case ClientDataType::Get:
64
        object->setString("type"_s, "webauthn.get"_s);
65
        break;
66
    }
67
    object->setString("challenge"_s, WTF::base64URLEncode(challenge.data(), challenge.length()));
68
    object->setString("origin"_s, origin.toRawString());
69
    // FIXME: This might be platform dependent.
70
    object->setString("hashAlgorithm"_s, "SHA-256"_s);
71
72
    auto utf8JSONString = object->toJSONString().utf8();
73
    return ArrayBuffer::create(utf8JSONString.data(), utf8JSONString.length());
74
}
75
76
static Vector<uint8_t> produceClientDataJsonHash(const ArrayBuffer& clientDataJson)
77
{
78
    // FIXME: This might be platform dependent.
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
// FIXME(181947): We should probably trim timeOutInMs to some max allowable number.
85
static std::unique_ptr<Timer> initTimeoutTimer(std::optional<unsigned long> timeOutInMs, const CredentialPromise& promise)
86
{
87
    if (!timeOutInMs)
88
        return nullptr;
89
90
    auto timer = std::make_unique<Timer>([promise = promise] () mutable {
91
        promise.reject(Exception { NotAllowedError, "Operation timed out."_s });
92
    });
93
    timer->startOneShot(Seconds::fromMilliseconds(*timeOutInMs));
94
    return timer;
95
}
96
97
static bool didTimeoutTimerFire(Timer* timer)
98
{
99
    if (!timer)
100
        return false;
101
    if (!timer->isActive())
102
        return true;
103
    timer->stop();
104
    return false;
105
}
106
107
} // namespace AuthenticatorManagerInternal
108
109
AuthenticatorManager& AuthenticatorManager::singleton()
110
{
111
    ASSERT(isMainThread());
112
    static NeverDestroyed<AuthenticatorManager> authenticator;
113
    return authenticator;
114
}
115
116
void AuthenticatorManager::setMessenger(CredentialsMessenger& messenger)
117
{
118
    m_messenger = makeWeakPtr(messenger);
119
}
120
121
void AuthenticatorManager::create(const SecurityOrigin& callerOrigin, const PublicKeyCredentialCreationOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
122
{
123
    using namespace AuthenticatorManagerInternal;
124
125
    // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.
126
    // FIXME: Extensions are not supported yet. Skip Step 11-12.
127
    // Step 1, 3, 16 are handled by the caller.
128
    // Step 2.
129
    if (!sameOriginWithAncestors) {
130
        promise.reject(Exception { NotAllowedError, "The origin of the document is not the same as its ancestors."_s });
131
        return;
132
    }
133
134
    // Step 4 & 17.
135
    std::unique_ptr<Timer> timeoutTimer = initTimeoutTimer(options.timeout, promise);
136
137
    // Step 5-7.
138
    // FIXME(181950): We lack fundamental support from SecurityOrigin to determine if a host is a valid domain or not.
139
    // Step 6 is therefore skipped. Also, we lack the support to determine whether a domain is a registrable
140
    // domain suffix of another domain. Hence restrict the comparison to equal in Step 7.
141
    if (!options.rp.id.isEmpty() && callerOrigin.host() != options.rp.id) {
142
        promise.reject(Exception { SecurityError, "The origin of the document is not a registrable domain suffix of the provided RP ID."_s });
143
        return;
144
    }
145
    if (options.rp.id.isEmpty())
146
        options.rp.id = callerOrigin.host();
147
148
    // Step 8-10.
149
    // Most of the jobs are done by bindings. However, we can't know if the JSValue of options.pubKeyCredParams
150
    // is empty or not. Return NotSupportedError as long as it is empty.
151
    if (options.pubKeyCredParams.isEmpty()) {
152
        promise.reject(Exception { NotSupportedError, "No desired properties of the to be created credential are provided."_s });
153
        return;
154
    }
155
156
    // Step 13-15.
157
    auto clientDataJson = produceClientDataJson(ClientDataType::Create, options.challenge, callerOrigin);
158
    auto clientDataJsonHash = produceClientDataJsonHash(clientDataJson);
159
160
    // Step 18-21.
161
    // Only platform attachments will be supported at this stage. Assuming one authenticator per device.
162
    // Also, resident keys, user verifications and direct attestation are enforced at this tage.
163
    // For better performance, transports of options.excludeCredentials are checked in LocalAuthenticator.
164
    if (!m_messenger)  {
165
        promise.reject(Exception { UnknownError, "Unknown internal error."_s });
166
        return;
167
    }
168
169
    auto completionHandler = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), timeoutTimer = WTFMove(timeoutTimer), abortSignal = WTFMove(abortSignal)] (ExceptionOr<CreationReturnBundle>&& result) mutable {
170
        if (didTimeoutTimerFire(timeoutTimer.get()))
171
            return;
172
        if (abortSignal && abortSignal->aborted()) {
173
            promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s });
174
            return;
175
        }
176
        if (result.hasException()) {
177
            promise.reject(result.exception());
178
            return;
179
        }
180
181
        auto bundle = result.releaseReturnValue();
182
        promise.resolve(PublicKeyCredential::create(WTFMove(bundle.credentialId), AuthenticatorAttestationResponse::create(WTFMove(clientDataJson), ArrayBuffer::create(WTFMove(bundle.attestationObject)))).ptr());
183
    };
184
    // Async operations are dispatched and handled in the messenger.
185
    m_messenger->makeCredential(clientDataJsonHash, options, WTFMove(completionHandler));
186
}
187
188
void AuthenticatorManager::discoverFromExternalSource(const SecurityOrigin& callerOrigin, const PublicKeyCredentialRequestOptions& options, bool sameOriginWithAncestors, RefPtr<AbortSignal>&& abortSignal, CredentialPromise&& promise) const
189
{
190
    using namespace AuthenticatorManagerInternal;
191
192
    // The following implements https://www.w3.org/TR/webauthn/#createCredential as of 5 December 2017.
193
    // FIXME: Extensions are not supported yet. Skip Step 8-9.
194
    // Step 1, 3, 13 are handled by the caller.
195
    // Step 2.
196
    if (!sameOriginWithAncestors) {
197
        promise.reject(Exception { NotAllowedError, "The origin of the document is not the same as its ancestors."_s });
198
        return;
199
    }
200
201
    // Step 4 & 16.
202
    std::unique_ptr<Timer> timeoutTimer = initTimeoutTimer(options.timeout, promise);
203
204
    // Step 5-7.
205
    // FIXME(181950): We lack fundamental support from SecurityOrigin to determine if a host is a valid domain or not.
206
    // Step 6 is therefore skipped. Also, we lack the support to determine whether a domain is a registrable
207
    // domain suffix of another domain. Hence restrict the comparison to equal in Step 7.
208
    if (!options.rpId.isEmpty() && callerOrigin.host() != options.rpId) {
209
        promise.reject(Exception { SecurityError, "The origin of the document is not a registrable domain suffix of the provided RP ID."_s });
210
        return;
211
    }
212
    if (options.rpId.isEmpty())
213
        options.rpId = callerOrigin.host();
214
215
    // Step 10-12.
216
    auto clientDataJson = produceClientDataJson(ClientDataType::Get, options.challenge, callerOrigin);
217
    auto clientDataJsonHash = produceClientDataJsonHash(clientDataJson);
218
219
    // Step 14-15, 17-19.
220
    // Only platform attachments will be supported at this stage. Assuming one authenticator per device.
221
    // Also, resident keys, user verifications and direct attestation are enforced at this tage.
222
    // For better performance, filtering of options.allowCredentials is done in LocalAuthenticator.
223
    if (!m_messenger)  {
224
        promise.reject(Exception { UnknownError, "Unknown internal error."_s });
225
        return;
226
    }
227
228
    auto completionHandler = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), timeoutTimer = WTFMove(timeoutTimer), abortSignal = WTFMove(abortSignal)] (ExceptionOr<AssertionReturnBundle>&& result) mutable {
229
        if (didTimeoutTimerFire(timeoutTimer.get()))
230
            return;
231
        if (abortSignal && abortSignal->aborted()) {
232
            promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s });
233
            return;
234
        }
235
        if (result.hasException()) {
236
            promise.reject(result.exception());
237
            return;
238
        }
239
240
        auto bundle = result.releaseReturnValue();
241
        promise.resolve(PublicKeyCredential::create(WTFMove(bundle.credentialId), AuthenticatorAssertionResponse::create(WTFMove(clientDataJson), WTFMove(bundle.authenticatorData), WTFMove(bundle.signature), WTFMove(bundle.userHandle))).ptr());
242
    };
243
    // Async operations are dispatched and handled in the messenger.
244
    m_messenger->getAssertion(clientDataJsonHash, options, WTFMove(completionHandler));
245
}
246
247
void AuthenticatorManager::isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&& promise) const
248
{
249
    // The following implements https://www.w3.org/TR/webauthn/#isUserVerifyingPlatformAuthenticatorAvailable
250
    // as of 5 December 2017.
251
    if (!m_messenger)  {
252
        promise.reject(Exception { UnknownError, "Unknown internal error."_s });
253
        return;
254
    }
255
256
    // FIXME(182767): We should consider more on the assessment of the return value. Right now, we return true/false
257
    // immediately according to platform specific procedures.
258
    auto completionHandler = [promise = WTFMove(promise)] (bool result) mutable {
259
        promise.resolve(result);
260
    };
261
    // Async operation are dispatched and handled in the messenger.
262
    m_messenger->isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(completionHandler));
263
}
264
265
} // namespace WebCore
266
267
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorManager.h -67 lines
Lines 1-67 a/Source/WebCore/Modules/webauthn/AuthenticatorManager.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "JSDOMPromiseDeferred.h"
31
#include <wtf/Forward.h>
32
#include <wtf/Noncopyable.h>
33
#include <wtf/WeakPtr.h>
34
35
namespace WebCore {
36
37
class AbortSignal;
38
class BasicCredential;
39
class CredentialsMessenger;
40
class SecurityOrigin;
41
42
struct PublicKeyCredentialCreationOptions;
43
struct PublicKeyCredentialRequestOptions;
44
45
using CredentialPromise = DOMPromiseDeferred<IDLNullable<IDLInterface<BasicCredential>>>;
46
47
class AuthenticatorManager {
48
    WTF_MAKE_NONCOPYABLE(AuthenticatorManager);
49
    friend class NeverDestroyed<AuthenticatorManager>;
50
public:
51
    WEBCORE_EXPORT static AuthenticatorManager& singleton();
52
    WEBCORE_EXPORT void setMessenger(CredentialsMessenger&);
53
54
    // The following methods implement static methods of PublicKeyCredential.
55
    void create(const SecurityOrigin&, const PublicKeyCredentialCreationOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, CredentialPromise&&) const;
56
    void discoverFromExternalSource(const SecurityOrigin&, const PublicKeyCredentialRequestOptions&, bool sameOriginWithAncestors, RefPtr<AbortSignal>&&, CredentialPromise&&) const;
57
    void isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&&) const;
58
59
private:
60
    AuthenticatorManager() = default;
61
62
    WeakPtr<CredentialsMessenger> m_messenger;
63
};
64
65
} // namespace WebCore
66
67
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp -45 lines
Lines 1-45 a/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "AuthenticatorResponse.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
namespace WebCore {
32
33
AuthenticatorResponse::AuthenticatorResponse(RefPtr<ArrayBuffer>&& clientDataJSON)
34
    : m_clientDataJSON(WTFMove(clientDataJSON))
35
{
36
}
37
38
ArrayBuffer* AuthenticatorResponse::clientDataJSON() const
39
{
40
    return m_clientDataJSON.get();
41
}
42
43
} // namespace WebCore
44
45
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h -3 / +6 lines
Lines 40-54 public: a/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h_sec1
40
        Attestation
40
        Attestation
41
    };
41
    };
42
42
43
    explicit AuthenticatorResponse(RefPtr<ArrayBuffer>&&);
43
    explicit AuthenticatorResponse(Ref<ArrayBuffer>&& clientDataJSON)
44
        : m_clientDataJSON(WTFMove(clientDataJSON))
45
    {
46
    }
44
    virtual ~AuthenticatorResponse() = default;
47
    virtual ~AuthenticatorResponse() = default;
45
48
46
    virtual Type type() const = 0;
49
    virtual Type type() const = 0;
47
50
48
    ArrayBuffer* clientDataJSON() const;
51
    ArrayBuffer* clientDataJSON() const { return m_clientDataJSON.ptr(); }
49
52
50
private:
53
private:
51
    RefPtr<ArrayBuffer> m_clientDataJSON;
54
    Ref<ArrayBuffer> m_clientDataJSON;
52
};
55
};
53
56
54
} // namespace WebCore
57
} // namespace WebCore
- a/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp -4 / +30 lines
Lines 28-40 a/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp_sec1
28
28
29
#if ENABLE(WEB_AUTHN)
29
#if ENABLE(WEB_AUTHN)
30
30
31
#include "AuthenticatorManager.h"
31
#include "AuthenticatorCoordinator.h"
32
#include "Document.h"
32
#include "JSDOMPromiseDeferred.h"
33
#include "JSDOMPromiseDeferred.h"
34
#include "Page.h"
35
#include "PublicKeyCredentialData.h"
33
#include <wtf/text/Base64.h>
36
#include <wtf/text/Base64.h>
34
37
35
namespace WebCore {
38
namespace WebCore {
36
39
37
PublicKeyCredential::PublicKeyCredential(RefPtr<ArrayBuffer>&& id, RefPtr<AuthenticatorResponse>&& response)
40
Ref<PublicKeyCredential> PublicKeyCredential::create(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&& response)
41
{
42
    return adoptRef(*new PublicKeyCredential(WTFMove(id), WTFMove(response)));
43
}
44
45
RefPtr<PublicKeyCredential> PublicKeyCredential::tryCreate(const PublicKeyCredentialData& data)
46
{
47
    if (!data.rawId || !data.clientDataJSON)
48
        return nullptr;
49
50
    if (data.isAuthenticatorAttestationResponse) {
51
        if (!data.attestationObject)
52
            return nullptr;
53
54
        return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAttestationResponse::create(data.clientDataJSON.releaseNonNull(), data.attestationObject.releaseNonNull())));
55
    }
56
57
    if (!data.authenticatorData || !data.signature || !data.userHandle)
58
        return nullptr;
59
60
    return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAssertionResponse::create(data.clientDataJSON.releaseNonNull(), data.authenticatorData.releaseNonNull(), data.signature.releaseNonNull(), data.userHandle.releaseNonNull())));
61
}
62
63
PublicKeyCredential::PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&& response)
38
    : BasicCredential(WTF::base64URLEncode(id->data(), id->byteLength()), Type::PublicKey, Discovery::Remote)
64
    : BasicCredential(WTF::base64URLEncode(id->data(), id->byteLength()), Type::PublicKey, Discovery::Remote)
39
    , m_rawId(WTFMove(id))
65
    , m_rawId(WTFMove(id))
40
    , m_response(WTFMove(response))
66
    , m_response(WTFMove(response))
Lines 46-54 ExceptionOr<bool> PublicKeyCredential::getClientExtensionResults() const a/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp_sec2
46
    return Exception { NotSupportedError };
72
    return Exception { NotSupportedError };
47
}
73
}
48
74
49
void PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&& promise)
75
void PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable(Document& document, DOMPromiseDeferred<IDLBoolean>&& promise)
50
{
76
{
51
    AuthenticatorManager::singleton().isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(promise));
77
    document.page()->authenticatorCoordinator().isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(promise));
52
}
78
}
53
79
54
} // namespace WebCore
80
} // namespace WebCore
- a/Source/WebCore/Modules/webauthn/PublicKeyCredential.h -10 / +11 lines
Lines 36-63 a/Source/WebCore/Modules/webauthn/PublicKeyCredential.h_sec1
36
namespace WebCore {
36
namespace WebCore {
37
37
38
class AuthenticatorResponse;
38
class AuthenticatorResponse;
39
class Document;
40
41
struct PublicKeyCredentialData;
39
42
40
class PublicKeyCredential final : public BasicCredential {
43
class PublicKeyCredential final : public BasicCredential {
41
public:
44
public:
42
    static Ref<PublicKeyCredential> create(RefPtr<ArrayBuffer>&& id, RefPtr<AuthenticatorResponse>&& response)
45
    static Ref<PublicKeyCredential> create(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&&);
43
    {
46
    static RefPtr<PublicKeyCredential> tryCreate(const PublicKeyCredentialData&);
44
        return adoptRef(*new PublicKeyCredential(WTFMove(id), WTFMove(response)));
45
    }
46
47
47
    ArrayBuffer* rawId() const { return m_rawId.get(); }
48
    ArrayBuffer* rawId() const { return m_rawId.ptr(); }
48
    AuthenticatorResponse* response() const { return m_response.get(); }
49
    AuthenticatorResponse* response() const { return m_response.ptr(); }
49
    // Not support yet. Always throws.
50
    // Not support yet. Always throws.
50
    ExceptionOr<bool> getClientExtensionResults() const;
51
    ExceptionOr<bool> getClientExtensionResults() const;
51
52
52
    static void isUserVerifyingPlatformAuthenticatorAvailable(DOMPromiseDeferred<IDLBoolean>&&);
53
    static void isUserVerifyingPlatformAuthenticatorAvailable(Document&, DOMPromiseDeferred<IDLBoolean>&&);
53
54
54
private:
55
private:
55
    PublicKeyCredential(RefPtr<ArrayBuffer>&& id, RefPtr<AuthenticatorResponse>&&);
56
    PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&&);
56
57
57
    Type credentialType() const final { return Type::PublicKey; }
58
    Type credentialType() const final { return Type::PublicKey; }
58
59
59
    RefPtr<ArrayBuffer> m_rawId;
60
    Ref<ArrayBuffer> m_rawId;
60
    RefPtr<AuthenticatorResponse> m_response;
61
    Ref<AuthenticatorResponse> m_response;
61
};
62
};
62
63
63
} // namespace WebCore
64
} // namespace WebCore
- a/Source/WebCore/Modules/webauthn/PublicKeyCredential.idl -1 / +1 lines
Lines 35-39 typedef boolean AuthenticationExtensions; a/Source/WebCore/Modules/webauthn/PublicKeyCredential.idl_sec1
35
    [SameObject] readonly attribute AuthenticatorResponse response;
35
    [SameObject] readonly attribute AuthenticatorResponse response;
36
    [MayThrowException] AuthenticationExtensions getClientExtensionResults();
36
    [MayThrowException] AuthenticationExtensions getClientExtensionResults();
37
37
38
    static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
38
    [CallWith=Document] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
39
};
39
};
- a/Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h -4 / +11 lines
Lines 94-102 template<class Encoder> a/Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h_sec1
94
void PublicKeyCredentialCreationOptions::encode(Encoder& encoder) const
94
void PublicKeyCredentialCreationOptions::encode(Encoder& encoder) const
95
{
95
{
96
    encoder << rp.id << rp.name << rp.icon;
96
    encoder << rp.id << rp.name << rp.icon;
97
    Vector<uint8_t> idVector;
97
    encoder << static_cast<uint64_t>(user.id.length());
98
    idVector.append(user.id.data(), user.id.length());
98
    encoder.encodeFixedLengthData(user.id.data(), user.id.length(), 1);
99
    encoder << idVector << user.displayName << user.name << user.icon << pubKeyCredParams << excludeCredentials;
99
    encoder << user.displayName << user.name << user.icon << pubKeyCredParams << excludeCredentials;
100
}
100
}
101
101
102
template<class Decoder>
102
template<class Decoder>
Lines 109-116 std::optional<PublicKeyCredentialCreationOptions> PublicKeyCredentialCreationOpt a/Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h_sec2
109
        return std::nullopt;
109
        return std::nullopt;
110
    if (!decoder.decode(result.rp.icon))
110
    if (!decoder.decode(result.rp.icon))
111
        return std::nullopt;
111
        return std::nullopt;
112
    if (!decoder.decode(result.user.idVector))
112
113
    std::optional<uint64_t> userIdLength;
114
    decoder >> userIdLength;
115
    if (!userIdLength)
116
        return std::nullopt;
117
    result.user.idVector.reserveCapacity(userIdLength.value());
118
    if (!decoder.decodeFixedLengthData(result.user.idVector.data(), userIdLength.value(), 1))
113
        return std::nullopt;
119
        return std::nullopt;
120
114
    if (!decoder.decode(result.user.displayName))
121
    if (!decoder.decode(result.user.displayName))
115
        return std::nullopt;
122
        return std::nullopt;
116
    if (!decoder.decode(result.user.name))
123
    if (!decoder.decode(result.user.name))
- a/Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h +144 lines
Line 0 a/Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include <JavaScriptCore/ArrayBuffer.h>
31
#include <wtf/Forward.h>
32
33
namespace WebCore {
34
35
class AuthenticatorResponse;
36
37
struct PublicKeyCredentialData {
38
    mutable RefPtr<ArrayBuffer> rawId;
39
40
    // AuthenticatorResponse
41
    bool isAuthenticatorAttestationResponse;
42
    mutable RefPtr<ArrayBuffer> clientDataJSON;
43
44
    // AuthenticatorAttestationResponse
45
    mutable RefPtr<ArrayBuffer> attestationObject;
46
47
    // AuthenticatorAssertionResponse
48
    mutable RefPtr<ArrayBuffer> authenticatorData;
49
    mutable RefPtr<ArrayBuffer> signature;
50
    mutable RefPtr<ArrayBuffer> userHandle;
51
52
    template<class Encoder> void encode(Encoder&) const;
53
    template<class Decoder> static std::optional<PublicKeyCredentialData> decode(Decoder&);
54
};
55
56
// Noted: clientDataJSON is never encoded or decoded as it is never sent across different processes.
57
template<class Encoder>
58
void PublicKeyCredentialData::encode(Encoder& encoder) const
59
{
60
    encoder << static_cast<uint64_t>(rawId->byteLength());
61
    encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(rawId->data()), rawId->byteLength(), 1);
62
63
    encoder << isAuthenticatorAttestationResponse;
64
65
    if (isAuthenticatorAttestationResponse) {
66
        encoder << static_cast<uint64_t>(attestationObject->byteLength());
67
        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(attestationObject->data()), attestationObject->byteLength(), 1);
68
        return;
69
    }
70
71
    encoder << static_cast<uint64_t>(authenticatorData->byteLength());
72
    encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(authenticatorData->data()), authenticatorData->byteLength(), 1);
73
    encoder << static_cast<uint64_t>(signature->byteLength());
74
    encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(signature->data()), signature->byteLength(), 1);
75
    encoder << static_cast<uint64_t>(userHandle->byteLength());
76
    encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(userHandle->data()), userHandle->byteLength(), 1);
77
}
78
79
template<class Decoder>
80
std::optional<PublicKeyCredentialData> PublicKeyCredentialData::decode(Decoder& decoder)
81
{
82
    PublicKeyCredentialData result;
83
84
    std::optional<uint64_t> rawIdLength;
85
    decoder >> rawIdLength;
86
    if (!rawIdLength)
87
        return std::nullopt;
88
89
    result.rawId = ArrayBuffer::create(rawIdLength.value(), sizeof(uint8_t));
90
    if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.rawId->data()), rawIdLength.value(), 1))
91
        return std::nullopt;
92
93
    std::optional<bool> isAuthenticatorAttestationResponse;
94
    decoder >> isAuthenticatorAttestationResponse;
95
    if (!isAuthenticatorAttestationResponse)
96
        return std::nullopt;
97
    result.isAuthenticatorAttestationResponse = isAuthenticatorAttestationResponse.value();
98
99
    if (result.isAuthenticatorAttestationResponse) {
100
        std::optional<uint64_t> attestationObjectLength;
101
        decoder >> attestationObjectLength;
102
        if (!attestationObjectLength)
103
            return std::nullopt;
104
105
        result.attestationObject = ArrayBuffer::create(attestationObjectLength.value(), sizeof(uint8_t));
106
        if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.attestationObject->data()), attestationObjectLength.value(), 1))
107
            return std::nullopt;
108
109
        return result;
110
    }
111
112
    std::optional<uint64_t> authenticatorDataLength;
113
    decoder >> authenticatorDataLength;
114
    if (!authenticatorDataLength)
115
        return std::nullopt;
116
117
    result.authenticatorData = ArrayBuffer::create(authenticatorDataLength.value(), sizeof(uint8_t));
118
    if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.authenticatorData->data()), authenticatorDataLength.value(), 1))
119
        return std::nullopt;
120
121
    std::optional<uint64_t> signatureLength;
122
    decoder >> signatureLength;
123
    if (!signatureLength)
124
        return std::nullopt;
125
126
    result.signature = ArrayBuffer::create(signatureLength.value(), sizeof(uint8_t));
127
    if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.signature->data()), signatureLength.value(), 1))
128
        return std::nullopt;
129
130
    std::optional<uint64_t> userHandleLength;
131
    decoder >> userHandleLength;
132
    if (!userHandleLength)
133
        return std::nullopt;
134
135
    result.userHandle = ArrayBuffer::create(userHandleLength.value(), sizeof(uint8_t));
136
    if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(result.userHandle->data()), userHandleLength.value(), 1))
137
        return std::nullopt;
138
139
    return result;
140
}
141
    
142
} // namespace WebCore
143
144
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h -5 / +4 lines
Lines 35-45 namespace WebCore { a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h_sec1
35
35
36
struct ExceptionData;
36
struct ExceptionData;
37
struct PublicKeyCredentialCreationOptions;
37
struct PublicKeyCredentialCreationOptions;
38
struct PublicKeyCredentialData;
38
struct PublicKeyCredentialRequestOptions;
39
struct PublicKeyCredentialRequestOptions;
39
40
40
using CreationCallback = Function<void(const Vector<uint8_t>&, const Vector<uint8_t>&)>;
41
using Callback = Function<void(Variant<PublicKeyCredentialData, ExceptionData>&&)>;
41
using RequestCallback = Function<void(const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&)>;
42
using ExceptionCallback = Function<void(const WebCore::ExceptionData&)>;
43
42
44
typedef void (^CompletionBlock)(SecKeyRef _Nullable referenceKey, NSArray * _Nullable certificates, NSError * _Nullable error);
43
typedef void (^CompletionBlock)(SecKeyRef _Nullable referenceKey, NSArray * _Nullable certificates, NSError * _Nullable error);
45
44
Lines 50-57 public: a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h_sec2
50
    LocalAuthenticator();
49
    LocalAuthenticator();
51
    virtual ~LocalAuthenticator() = default;
50
    virtual ~LocalAuthenticator() = default;
52
51
53
    void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, CreationCallback&&, ExceptionCallback&&);
52
    void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, Callback&&);
54
    void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCallback&&, ExceptionCallback&&);
53
    void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, Callback&&);
55
    bool isAvailable() const;
54
    bool isAvailable() const;
56
55
57
protected:
56
protected:
- a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm -29 / +30 lines
Lines 32-37 a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec1
32
#import "COSEConstants.h"
32
#import "COSEConstants.h"
33
#import "ExceptionData.h"
33
#import "ExceptionData.h"
34
#import "PublicKeyCredentialCreationOptions.h"
34
#import "PublicKeyCredentialCreationOptions.h"
35
#import "PublicKeyCredentialData.h"
35
#import "PublicKeyCredentialRequestOptions.h"
36
#import "PublicKeyCredentialRequestOptions.h"
36
#import <Security/SecItem.h>
37
#import <Security/SecItem.h>
37
#import <pal/crypto/CryptoDigest.h>
38
#import <pal/crypto/CryptoDigest.h>
Lines 115-121 LocalAuthenticator::LocalAuthenticator() a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec2
115
    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessCredentials));
116
    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessCredentials));
116
}
117
}
117
118
118
void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions& options, CreationCallback&& callback, ExceptionCallback&& exceptionCallback)
119
void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions& options, Callback&& callback)
119
{
120
{
120
    using namespace LocalAuthenticatorInternal;
121
    using namespace LocalAuthenticatorInternal;
121
122
Lines 124-130 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec3
124
    ASSERT_UNUSED(hash, hash == hash);
125
    ASSERT_UNUSED(hash, hash == hash);
125
    ASSERT_UNUSED(options, !options.rp.id.isEmpty());
126
    ASSERT_UNUSED(options, !options.rp.id.isEmpty());
126
    ASSERT_UNUSED(callback, callback);
127
    ASSERT_UNUSED(callback, callback);
127
    exceptionCallback({ NotAllowedError, "No avaliable authenticators."_s });
128
    callback(ExceptionData { NotAllowedError, "No avaliable authenticators."_s });
128
#else
129
#else
129
    // The following implements https://www.w3.org/TR/webauthn/#op-make-cred as of 5 December 2017.
130
    // The following implements https://www.w3.org/TR/webauthn/#op-make-cred as of 5 December 2017.
130
    // Skip Step 4-5 as requireResidentKey and requireUserVerification are enforced.
131
    // Skip Step 4-5 as requireResidentKey and requireUserVerification are enforced.
Lines 139-145 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec4
139
        }
140
        }
140
    }
141
    }
141
    if (!canFullfillPubKeyCredParams) {
142
    if (!canFullfillPubKeyCredParams) {
142
        exceptionCallback({ NotSupportedError, "The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters."_s });
143
        callback(ExceptionData { NotSupportedError, "The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters."_s });
143
        return;
144
        return;
144
    }
145
    }
145
146
Lines 158-164 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec5
158
        OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &attributesArrayRef);
159
        OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &attributesArrayRef);
159
        if (status && status != errSecItemNotFound) {
160
        if (status && status != errSecItemNotFound) {
160
            LOG_ERROR("Couldn't query Keychain: %d", status);
161
            LOG_ERROR("Couldn't query Keychain: %d", status);
161
            exceptionCallback({ UnknownError, "Unknown internal error."_s });
162
            callback(ExceptionData { UnknownError, "Unknown internal error."_s });
162
            return;
163
            return;
163
        }
164
        }
164
        auto retainAttributesArray = adoptCF(attributesArrayRef);
165
        auto retainAttributesArray = adoptCF(attributesArrayRef);
Lines 166-172 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec6
166
        for (NSDictionary *nsAttributes in (NSArray *)attributesArrayRef) {
167
        for (NSDictionary *nsAttributes in (NSArray *)attributesArrayRef) {
167
            NSData *nsCredentialId = nsAttributes[(id)kSecAttrApplicationLabel];
168
            NSData *nsCredentialId = nsAttributes[(id)kSecAttrApplicationLabel];
168
            if (excludeCredentialIds.contains(String(reinterpret_cast<const char*>(nsCredentialId.bytes), nsCredentialId.length))) {
169
            if (excludeCredentialIds.contains(String(reinterpret_cast<const char*>(nsCredentialId.bytes), nsCredentialId.length))) {
169
                exceptionCallback({ NotAllowedError, "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator."_s });
170
                callback(ExceptionData { NotAllowedError, "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator."_s });
170
                return;
171
                return;
171
            }
172
            }
172
        }
173
        }
Lines 180-196 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec7
180
    if (![context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
181
    if (![context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
181
        LOG_ERROR("Couldn't evaluate authentication with biometrics policy: %@", error);
182
        LOG_ERROR("Couldn't evaluate authentication with biometrics policy: %@", error);
182
        // FIXME(182767)
183
        // FIXME(182767)
183
        exceptionCallback({ NotAllowedError, "No avaliable authenticators."_s });
184
        callback(ExceptionData { NotAllowedError, "No avaliable authenticators."_s });
184
        return;
185
        return;
185
    }
186
    }
186
187
187
    NSString *reason = [NSString stringWithFormat:@"Allow %@ to create a public key credential for %@", (id)options.rp.id, (id)options.user.name];
188
    NSString *reason = [NSString stringWithFormat:@"Allow %@ to create a public key credential for %@", (id)options.rp.id, (id)options.user.name];
188
    // FIXME(183534): Optimize the following nested callbacks and threading.
189
    // FIXME(183534): Optimize the following nested callbacks and threading.
189
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reason reply:BlockPtr<void(BOOL, NSError *)>::fromCallable([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), options = crossThreadCopy(options), hash] (BOOL success, NSError *error) mutable {
190
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reason reply:BlockPtr<void(BOOL, NSError *)>::fromCallable([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), options = crossThreadCopy(options), hash] (BOOL success, NSError *error) mutable {
190
        ASSERT(!isMainThread());
191
        ASSERT(!isMainThread());
191
        if (!success || error) {
192
        if (!success || error) {
192
            LOG_ERROR("Couldn't authenticate with biometrics: %@", error);
193
            LOG_ERROR("Couldn't authenticate with biometrics: %@", error);
193
            exceptionCallback({ NotAllowedError, "Couldn't get user consent."_s });
194
            callback(ExceptionData { NotAllowedError, "Couldn't get user consent."_s });
194
            return;
195
            return;
195
        }
196
        }
196
197
Lines 205-211 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec8
205
        OSStatus status = SecItemDelete((__bridge CFDictionaryRef)deleteQuery);
206
        OSStatus status = SecItemDelete((__bridge CFDictionaryRef)deleteQuery);
206
        if (status && status != errSecItemNotFound) {
207
        if (status && status != errSecItemNotFound) {
207
            LOG_ERROR("Couldn't detele older credential: %d", status);
208
            LOG_ERROR("Couldn't detele older credential: %d", status);
208
            exceptionCallback({ UnknownError, "Unknown internal error."_s });
209
            callback(ExceptionData { UnknownError, "Unknown internal error."_s });
209
            return;
210
            return;
210
        }
211
        }
211
212
Lines 213-223 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec9
213
        // FIXME(183534)
214
        // FIXME(183534)
214
        if (!weakThis)
215
        if (!weakThis)
215
            return;
216
            return;
216
        weakThis->issueClientCertificate(options.rp.id, options.user.name, hash, BlockPtr<void(SecKeyRef, NSArray *, NSError *)>::fromCallable([callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), options = crossThreadCopy(options)] (_Nullable SecKeyRef privateKey, NSArray * _Nullable certificates, NSError * _Nullable error) {
217
        weakThis->issueClientCertificate(options.rp.id, options.user.name, hash, BlockPtr<void(SecKeyRef, NSArray *, NSError *)>::fromCallable([callback = WTFMove(callback), options = crossThreadCopy(options)] (_Nullable SecKeyRef privateKey, NSArray * _Nullable certificates, NSError * _Nullable error) {
217
            ASSERT(!isMainThread());
218
            ASSERT(!isMainThread());
218
            if (error) {
219
            if (error) {
219
                LOG_ERROR("Couldn't attest: %@", error);
220
                LOG_ERROR("Couldn't attest: %@", error);
220
                exceptionCallback({ UnknownError, "Unknown internal error."_s });
221
                callback(ExceptionData { UnknownError, "Unknown internal error."_s });
221
                return;
222
                return;
222
            }
223
            }
223
            // Attestation Certificate and Attestation Issuing CA
224
            // Attestation Certificate and Attestation Issuing CA
Lines 250-256 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec10
250
                OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)credentialIdQuery, &attributesRef);
251
                OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)credentialIdQuery, &attributesRef);
251
                if (status) {
252
                if (status) {
252
                    LOG_ERROR("Couldn't get Credential ID: %d", status);
253
                    LOG_ERROR("Couldn't get Credential ID: %d", status);
253
                    exceptionCallback({ UnknownError, "Unknown internal error."_s });
254
                    callback(ExceptionData { UnknownError, "Unknown internal error."_s });
254
                    return;
255
                    return;
255
                }
256
                }
256
                auto retainAttributes = adoptCF(attributesRef);
257
                auto retainAttributes = adoptCF(attributesRef);
Lines 271-277 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec11
271
                status = SecItemUpdate((__bridge CFDictionaryRef)updateQuery, (__bridge CFDictionaryRef)updateParams);
272
                status = SecItemUpdate((__bridge CFDictionaryRef)updateQuery, (__bridge CFDictionaryRef)updateParams);
272
                if (status) {
273
                if (status) {
273
                    LOG_ERROR("Couldn't update the Keychain item: %d", status);
274
                    LOG_ERROR("Couldn't update the Keychain item: %d", status);
274
                    exceptionCallback({ UnknownError, "Unknown internal error."_s });
275
                    callback(ExceptionData { UnknownError, "Unknown internal error."_s });
275
                    return;
276
                    return;
276
                }
277
                }
277
            }
278
            }
Lines 304-310 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec12
304
                    auto retainError = adoptCF(errorRef);
305
                    auto retainError = adoptCF(errorRef);
305
                    if (errorRef) {
306
                    if (errorRef) {
306
                        LOG_ERROR("Couldn't export the public key: %@", (NSError*)errorRef);
307
                        LOG_ERROR("Couldn't export the public key: %@", (NSError*)errorRef);
307
                        exceptionCallback({ UnknownError, "Unknown internal error."_s });
308
                        callback(ExceptionData { UnknownError, "Unknown internal error."_s });
308
                        return;
309
                        return;
309
                    }
310
                    }
310
                    ASSERT(((NSData *)publicKeyDataRef.get()).length == (1 + 2 * ES256KeySizeInBytes)); // 04 | X | Y
311
                    ASSERT(((NSData *)publicKeyDataRef.get()).length == (1 + 2 * ES256KeySizeInBytes)); // 04 | X | Y
Lines 325-331 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec13
325
                auto cosePublicKey = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(publicKeyMap)));
326
                auto cosePublicKey = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(publicKeyMap)));
326
                if (!cosePublicKey) {
327
                if (!cosePublicKey) {
327
                    LOG_ERROR("Couldn't encode the public key into COSE binaries.");
328
                    LOG_ERROR("Couldn't encode the public key into COSE binaries.");
328
                    exceptionCallback({ UnknownError, "Unknown internal error."_s });
329
                    callback(ExceptionData { UnknownError, "Unknown internal error."_s });
329
                    return;
330
                    return;
330
                }
331
                }
331
                attestedCredentialData.appendVector(cosePublicKey.value());
332
                attestedCredentialData.appendVector(cosePublicKey.value());
Lines 347-353 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec14
347
                    auto retainError = adoptCF(errorRef);
348
                    auto retainError = adoptCF(errorRef);
348
                    if (errorRef) {
349
                    if (errorRef) {
349
                        LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
350
                        LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
350
                        exceptionCallback({ UnknownError, "Unknown internal error."_s });
351
                        callback(ExceptionData { UnknownError, "Unknown internal error."_s });
351
                        return;
352
                        return;
352
                    }
353
                    }
353
                    auto nsSignature = (NSData *)signatureRef.get();
354
                    auto nsSignature = (NSData *)signatureRef.get();
Lines 374-390 void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec15
374
            auto attestationObject = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(attestationObjectMap)));
375
            auto attestationObject = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(attestationObjectMap)));
375
            if (!attestationObject) {
376
            if (!attestationObject) {
376
                LOG_ERROR("Couldn't encode the attestation object.");
377
                LOG_ERROR("Couldn't encode the attestation object.");
377
                exceptionCallback({ UnknownError, "Unknown internal error."_s });
378
                callback(ExceptionData { UnknownError, "Unknown internal error."_s });
378
                return;
379
                return;
379
            }
380
            }
380
381
381
            callback(credentialId, attestationObject.value());
382
            callback(PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), true, nullptr, ArrayBuffer::create(attestationObject.value().data(), attestationObject.value().size()), nullptr, nullptr, nullptr });
382
        }).get());
383
        }).get());
383
    }).get()];
384
    }).get()];
384
#endif // !PLATFORM(IOS)
385
#endif // !PLATFORM(IOS)
385
}
386
}
386
387
387
void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, RequestCallback&& callback, ExceptionCallback&& exceptionCallback)
388
void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions& options, Callback&& callback)
388
{
389
{
389
    using namespace LocalAuthenticatorInternal;
390
    using namespace LocalAuthenticatorInternal;
390
391
Lines 393-399 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec16
393
    ASSERT_UNUSED(hash, hash == hash);
394
    ASSERT_UNUSED(hash, hash == hash);
394
    ASSERT_UNUSED(options, !options.rpId.isEmpty());
395
    ASSERT_UNUSED(options, !options.rpId.isEmpty());
395
    ASSERT_UNUSED(callback, callback);
396
    ASSERT_UNUSED(callback, callback);
396
    exceptionCallback({ NotAllowedError, "No avaliable authenticators."_s });
397
    callback(ExceptionData { NotAllowedError, "No avaliable authenticators."_s });
397
#else
398
#else
398
    // The following implements https://www.w3.org/TR/webauthn/#op-get-assertion as of 5 December 2017.
399
    // The following implements https://www.w3.org/TR/webauthn/#op-get-assertion as of 5 December 2017.
399
    // Skip Step 2 as requireUserVerification is enforced.
400
    // Skip Step 2 as requireUserVerification is enforced.
Lines 402-408 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec17
402
    // Step 3-5. Unlike the spec, if an allow list is provided and there is no intersection between existing ones and the allow list, we always return NotAllowedError.
403
    // Step 3-5. Unlike the spec, if an allow list is provided and there is no intersection between existing ones and the allow list, we always return NotAllowedError.
403
    HashSet<String> allowCredentialIds = produceHashSet(options.allowCredentials);
404
    HashSet<String> allowCredentialIds = produceHashSet(options.allowCredentials);
404
    if (!options.allowCredentials.isEmpty() && allowCredentialIds.isEmpty()) {
405
    if (!options.allowCredentials.isEmpty() && allowCredentialIds.isEmpty()) {
405
        exceptionCallback({ NotAllowedError, "No matched credentials are found in the platform attached authenticator."_s });
406
        callback(ExceptionData { NotAllowedError, "No matched credentials are found in the platform attached authenticator."_s });
406
        return;
407
        return;
407
    }
408
    }
408
409
Lines 418-424 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec18
418
    OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &attributesArrayRef);
419
    OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &attributesArrayRef);
419
    if (status && status != errSecItemNotFound) {
420
    if (status && status != errSecItemNotFound) {
420
        LOG_ERROR("Couldn't query Keychain: %d", status);
421
        LOG_ERROR("Couldn't query Keychain: %d", status);
421
        exceptionCallback({ UnknownError, "Unknown internal error."_s });
422
        callback(ExceptionData { UnknownError, "Unknown internal error."_s });
422
        return;
423
        return;
423
    }
424
    }
424
    auto retainAttributesArray = adoptCF(attributesArrayRef);
425
    auto retainAttributesArray = adoptCF(attributesArrayRef);
Lines 436-442 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec19
436
        intersectedCredentialsAttributes = result;
437
        intersectedCredentialsAttributes = result;
437
    }
438
    }
438
    if (!intersectedCredentialsAttributes.count) {
439
    if (!intersectedCredentialsAttributes.count) {
439
        exceptionCallback({ NotAllowedError, "No matched credentials are found in the platform attached authenticator."_s });
440
        callback(ExceptionData { NotAllowedError, "No matched credentials are found in the platform attached authenticator."_s });
440
        return;
441
        return;
441
    }
442
    }
442
443
Lines 452-458 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec20
452
        auto retainContext = adoptNS(context);
453
        auto retainContext = adoptNS(context);
453
        LOG_ERROR("Couldn't evaluate authentication with biometrics policy: %@", error);
454
        LOG_ERROR("Couldn't evaluate authentication with biometrics policy: %@", error);
454
        // FIXME(182767)
455
        // FIXME(182767)
455
        exceptionCallback({ NotAllowedError, "No avaliable authenticators."_s });
456
        callback(ExceptionData { NotAllowedError, "No avaliable authenticators."_s });
456
        return;
457
        return;
457
    }
458
    }
458
459
Lines 462-472 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec21
462
    Vector<uint8_t> userhandle;
463
    Vector<uint8_t> userhandle;
463
    NSData *nsUserhandle = selectedCredentialAttributes[(id)kSecAttrApplicationTag];
464
    NSData *nsUserhandle = selectedCredentialAttributes[(id)kSecAttrApplicationTag];
464
    userhandle.append(reinterpret_cast<const uint8_t*>(nsUserhandle.bytes), nsUserhandle.length);
465
    userhandle.append(reinterpret_cast<const uint8_t*>(nsUserhandle.bytes), nsUserhandle.length);
465
    auto reply = BlockPtr<void(BOOL, NSError *)>::fromCallable([callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), rpId = options.rpId.isolatedCopy(), hash, credentialId = WTFMove(credentialId), userhandle = WTFMove(userhandle), context = adoptNS(context)] (BOOL success, NSError *error) mutable {
466
    auto reply = BlockPtr<void(BOOL, NSError *)>::fromCallable([callback = WTFMove(callback), rpId = options.rpId.isolatedCopy(), hash, credentialId = WTFMove(credentialId), userhandle = WTFMove(userhandle), context = adoptNS(context)] (BOOL success, NSError *error) mutable {
466
        ASSERT(!isMainThread());
467
        ASSERT(!isMainThread());
467
        if (!success || error) {
468
        if (!success || error) {
468
            LOG_ERROR("Couldn't authenticate with biometrics: %@", error);
469
            LOG_ERROR("Couldn't authenticate with biometrics: %@", error);
469
            exceptionCallback({ NotAllowedError, "Couldn't get user consent."_s });
470
            callback(ExceptionData { NotAllowedError, "Couldn't get user consent."_s });
470
            return;
471
            return;
471
        }
472
        }
472
473
Lines 490-496 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec22
490
            OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &privateKeyRef);
491
            OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &privateKeyRef);
491
            if (status) {
492
            if (status) {
492
                LOG_ERROR("Couldn't get the private key reference: %d", status);
493
                LOG_ERROR("Couldn't get the private key reference: %d", status);
493
                exceptionCallback({ UnknownError, "Unknown internal error."_s });
494
                callback(ExceptionData { UnknownError, "Unknown internal error."_s });
494
                return;
495
                return;
495
            }
496
            }
496
            auto privateKey = adoptCF(privateKeyRef);
497
            auto privateKey = adoptCF(privateKeyRef);
Lines 504-510 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec23
504
            auto retainError = adoptCF(errorRef);
505
            auto retainError = adoptCF(errorRef);
505
            if (errorRef) {
506
            if (errorRef) {
506
                LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
507
                LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
507
                exceptionCallback({ UnknownError, "Unknown internal error."_s });
508
                callback(ExceptionData { UnknownError, "Unknown internal error."_s });
508
                return;
509
                return;
509
            }
510
            }
510
            auto nsSignature = (NSData *)signatureRef.get();
511
            auto nsSignature = (NSData *)signatureRef.get();
Lines 512-518 void LocalAuthenticator::getAssertion(const Vector<uint8_t>& hash, const PublicK a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm_sec24
512
        }
513
        }
513
514
514
        // Step 13.
515
        // Step 13.
515
        callback(credentialId, authData, signature, userhandle);
516
        callback(PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), false, nullptr, nullptr, ArrayBuffer::create(authData.data(), authData.size()), ArrayBuffer::create(signature.data(), signature.size()), ArrayBuffer::create(userhandle.data(), userhandle.size()) });
516
    });
517
    });
517
518
518
    // FIXME(183533): Use userhandle instead of username due to the stated Keychain limitations.
519
    // FIXME(183533): Use userhandle instead of username due to the stated Keychain limitations.
- a/Source/WebCore/Sources.txt -5 / +2 lines
Lines 45-51 Modules/cache/WorkerGlobalScopeCaches.cpp a/Source/WebCore/Sources.txt_sec1
45
45
46
Modules/credentialmanagement/BasicCredential.cpp
46
Modules/credentialmanagement/BasicCredential.cpp
47
Modules/credentialmanagement/CredentialsContainer.cpp
47
Modules/credentialmanagement/CredentialsContainer.cpp
48
Modules/credentialmanagement/CredentialsMessenger.cpp
49
Modules/credentialmanagement/NavigatorCredentials.cpp
48
Modules/credentialmanagement/NavigatorCredentials.cpp
50
49
51
Modules/entriesapi/ErrorCallback.cpp
50
Modules/entriesapi/ErrorCallback.cpp
Lines 247-256 Modules/webaudio/WaveShaperDSPKernel.cpp a/Source/WebCore/Sources.txt_sec2
247
Modules/webaudio/WaveShaperNode.cpp
246
Modules/webaudio/WaveShaperNode.cpp
248
Modules/webaudio/WaveShaperProcessor.cpp
247
Modules/webaudio/WaveShaperProcessor.cpp
249
248
250
Modules/webauthn/AuthenticatorAssertionResponse.cpp
249
Modules/webauthn/AuthenticatorCoordinator.cpp
251
Modules/webauthn/AuthenticatorAttestationResponse.cpp
250
Modules/webauthn/AuthenticatorCoordinatorClient.cpp
252
Modules/webauthn/AuthenticatorManager.cpp
253
Modules/webauthn/AuthenticatorResponse.cpp
254
Modules/webauthn/PublicKeyCredential.cpp
251
Modules/webauthn/PublicKeyCredential.cpp
255
Modules/webauthn/cbor/CBORReader.cpp
252
Modules/webauthn/cbor/CBORReader.cpp
256
Modules/webauthn/cbor/CBORValue.cpp
253
Modules/webauthn/cbor/CBORValue.cpp
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj -38 / +36 lines
Lines 1754-1760 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
1754
		57303C222009AF0300355965 /* JSAuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C212009AEF600355965 /* JSAuthenticatorAttestationResponse.h */; };
1754
		57303C222009AF0300355965 /* JSAuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C212009AEF600355965 /* JSAuthenticatorAttestationResponse.h */; };
1755
		57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; };
1755
		57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; };
1756
		57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */; };
1756
		57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */; };
1757
		57303C4620105D2F00355965 /* AuthenticatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
1757
		57303C4620105D2F00355965 /* AuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
1758
		573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; };
1758
		573489391DAC6B6E00DC0667 /* CryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */; };
1759
		5739E12F1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */; };
1759
		5739E12F1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */; };
1760
		574F55E0204F3ACE002948C6 /* LocalAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 574F55DE204F3744002948C6 /* LocalAuthenticator.h */; settings = {ATTRIBUTES = (Private, ); }; };
1760
		574F55E0204F3ACE002948C6 /* LocalAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 574F55DE204F3744002948C6 /* LocalAuthenticator.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 1764-1774 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
1764
		5750A9821E6A150800705C4A /* JSEcKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9801E6A150800705C4A /* JSEcKeyParams.h */; };
1764
		5750A9821E6A150800705C4A /* JSEcKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9801E6A150800705C4A /* JSEcKeyParams.h */; };
1765
		5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; };
1765
		5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; };
1766
		5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; };
1766
		5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; };
1767
		5760827220215A5500116678 /* CredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* CredentialsMessenger.h */; settings = {ATTRIBUTES = (Private, ); }; };
1767
		5760827220215A5500116678 /* AuthenticatorCoordinatorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
1768
		5760827A2024EA5C00116678 /* MockCredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760827820244DAB00116678 /* MockCredentialsMessenger.h */; };
1768
		5760827A2024EA5C00116678 /* MockAuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */; };
1769
		5760827B2024ED2900116678 /* MockCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */; };
1769
		5760827B2024ED2900116678 /* MockAuthenticatorCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */; };
1770
		5760828620256AFA00116678 /* JSMockCredentialsMessenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082822025679700116678 /* JSMockCredentialsMessenger.h */; };
1771
		5760828820256AFD00116678 /* JSMockCredentialsMessenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 576082812025679600116678 /* JSMockCredentialsMessenger.cpp */; };
1772
		5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; };
1770
		5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; };
1773
		576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; };
1771
		576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; };
1774
		576814451E70CB1F00E77754 /* JSAesKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814431E70CB1000E77754 /* JSAesKeyParams.h */; };
1772
		576814451E70CB1F00E77754 /* JSAesKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814431E70CB1000E77754 /* JSAesKeyParams.h */; };
Lines 1784-1795 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
1784
		57B5F7F91E5BE84000F34F90 /* CryptoAlgorithmAES_GCM.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F7F71E5BE84000F34F90 /* CryptoAlgorithmAES_GCM.h */; };
1782
		57B5F7F91E5BE84000F34F90 /* CryptoAlgorithmAES_GCM.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F7F71E5BE84000F34F90 /* CryptoAlgorithmAES_GCM.h */; };
1785
		57B5F8091E5D1A9800F34F90 /* CryptoAlgorithmAesGcmParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F8081E5D1A9800F34F90 /* CryptoAlgorithmAesGcmParams.h */; };
1783
		57B5F8091E5D1A9800F34F90 /* CryptoAlgorithmAesGcmParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F8081E5D1A9800F34F90 /* CryptoAlgorithmAesGcmParams.h */; };
1786
		57B5F8101E5E2A4E00F34F90 /* JSAesGcmParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F80B1E5D22DA00F34F90 /* JSAesGcmParams.h */; };
1784
		57B5F8101E5E2A4E00F34F90 /* JSAesGcmParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B5F80B1E5D22DA00F34F90 /* JSAesGcmParams.h */; };
1787
		57C7A68C1E56967500C67D71 /* BasicCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57C7A68B1E56967500C67D71 /* BasicCredential.h */; };
1785
		57C7A68C1E56967500C67D71 /* BasicCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57C7A68B1E56967500C67D71 /* BasicCredential.h */; settings = {ATTRIBUTES = (Private, ); }; };
1788
		57C7A69F1E57917800C67D71 /* JSBasicCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57C7A69D1E57910D00C67D71 /* JSBasicCredential.h */; };
1786
		57C7A69F1E57917800C67D71 /* JSBasicCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57C7A69D1E57910D00C67D71 /* JSBasicCredential.h */; };
1789
		57D0018D1DD5413200ED19D9 /* JSCryptoKeyUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D0018C1DD5413200ED19D9 /* JSCryptoKeyUsage.h */; };
1787
		57D0018D1DD5413200ED19D9 /* JSCryptoKeyUsage.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D0018C1DD5413200ED19D9 /* JSCryptoKeyUsage.h */; };
1790
		57D846281FE8960500CA3682 /* NavigatorCredentials.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846261FE895F800CA3682 /* NavigatorCredentials.h */; };
1788
		57D846281FE8960500CA3682 /* NavigatorCredentials.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846261FE895F800CA3682 /* NavigatorCredentials.h */; };
1791
		57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */; };
1789
		57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */; settings = {ATTRIBUTES = (Private, ); }; };
1792
		57D846351FEAFCD300CA3682 /* JSPublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */; };
1790
		57D846351FEAFCD300CA3682 /* JSPublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */; };
1791
		57DCED672140775B0016B847 /* JSMockAuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */; };
1792
		57DCED69214077640016B847 /* JSMockAuthenticatorCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */; };
1793
		57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */; settings = {ATTRIBUTES = (Private, ); }; };
1793
		57E1E5A31E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5A11E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h */; };
1794
		57E1E5A31E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5A11E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h */; };
1794
		57E1E5A71E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5A61E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h */; };
1795
		57E1E5A71E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5A61E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h */; };
1795
		57E1E5AD1E8DD09B00EE37C9 /* JSAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5AB1E8DD09B00EE37C9 /* JSAesCtrParams.h */; };
1796
		57E1E5AD1E8DD09B00EE37C9 /* JSAesCtrParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 57E1E5AB1E8DD09B00EE37C9 /* JSAesCtrParams.h */; };
Lines 8458-8464 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
8458
		57303BBE2006E00400355965 /* CBORReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORReader.cpp; sourceTree = "<group>"; };
8459
		57303BBE2006E00400355965 /* CBORReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CBORReader.cpp; sourceTree = "<group>"; };
8459
		57303BBF2006E00C00355965 /* CBORReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBORReader.h; sourceTree = "<group>"; };
8460
		57303BBF2006E00C00355965 /* CBORReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBORReader.h; sourceTree = "<group>"; };
8460
		57303BCF20087A8300355965 /* AuthenticatorResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorResponse.h; sourceTree = "<group>"; };
8461
		57303BCF20087A8300355965 /* AuthenticatorResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorResponse.h; sourceTree = "<group>"; };
8461
		57303BD020087A8300355965 /* AuthenticatorResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorResponse.cpp; sourceTree = "<group>"; };
8462
		57303BD120087A8300355965 /* AuthenticatorResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorResponse.idl; sourceTree = "<group>"; };
8462
		57303BD120087A8300355965 /* AuthenticatorResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorResponse.idl; sourceTree = "<group>"; };
8463
		57303BDD20095B2600355965 /* JSAuthenticatorResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorResponse.h; sourceTree = "<group>"; };
8463
		57303BDD20095B2600355965 /* JSAuthenticatorResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorResponse.h; sourceTree = "<group>"; };
8464
		57303BDE20095B2700355965 /* JSAuthenticatorResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponse.cpp; sourceTree = "<group>"; };
8464
		57303BDE20095B2700355965 /* JSAuthenticatorResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponse.cpp; sourceTree = "<group>"; };
Lines 8479-8495 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
8479
		57303C132009A25700355965 /* JSPublicKeyCredentialCreationOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredentialCreationOptions.h; sourceTree = "<group>"; };
8479
		57303C132009A25700355965 /* JSPublicKeyCredentialCreationOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredentialCreationOptions.h; sourceTree = "<group>"; };
8480
		57303C142009A25700355965 /* JSPublicKeyCredentialCreationOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredentialCreationOptions.cpp; sourceTree = "<group>"; };
8480
		57303C142009A25700355965 /* JSPublicKeyCredentialCreationOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredentialCreationOptions.cpp; sourceTree = "<group>"; };
8481
		57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorAttestationResponse.h; sourceTree = "<group>"; };
8481
		57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorAttestationResponse.h; sourceTree = "<group>"; };
8482
		57303C1C2009A98600355965 /* AuthenticatorAttestationResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAttestationResponse.cpp; sourceTree = "<group>"; };
8483
		57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorAttestationResponse.idl; sourceTree = "<group>"; };
8482
		57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorAttestationResponse.idl; sourceTree = "<group>"; };
8484
		57303C202009AEF500355965 /* JSAuthenticatorAttestationResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorAttestationResponse.cpp; sourceTree = "<group>"; };
8483
		57303C202009AEF500355965 /* JSAuthenticatorAttestationResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorAttestationResponse.cpp; sourceTree = "<group>"; };
8485
		57303C212009AEF600355965 /* JSAuthenticatorAttestationResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorAttestationResponse.h; sourceTree = "<group>"; };
8484
		57303C212009AEF600355965 /* JSAuthenticatorAttestationResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorAttestationResponse.h; sourceTree = "<group>"; };
8486
		57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorAssertionResponse.h; sourceTree = "<group>"; };
8485
		57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorAssertionResponse.h; sourceTree = "<group>"; };
8487
		57303C282009B2FC00355965 /* AuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; };
8488
		57303C292009B2FC00355965 /* AuthenticatorAssertionResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorAssertionResponse.idl; sourceTree = "<group>"; };
8486
		57303C292009B2FC00355965 /* AuthenticatorAssertionResponse.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorAssertionResponse.idl; sourceTree = "<group>"; };
8489
		57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorAssertionResponse.h; sourceTree = "<group>"; };
8487
		57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAuthenticatorAssertionResponse.h; sourceTree = "<group>"; };
8490
		57303C2E2009B7DA00355965 /* JSAuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; };
8488
		57303C2E2009B7DA00355965 /* JSAuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; };
8491
		57303C4320105B3D00355965 /* AuthenticatorManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorManager.h; sourceTree = "<group>"; };
8489
		57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorCoordinator.h; sourceTree = "<group>"; };
8492
		57303C4420105B3D00355965 /* AuthenticatorManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorManager.cpp; sourceTree = "<group>"; };
8490
		57303C4420105B3D00355965 /* AuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
8493
		573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmParameters.h; sourceTree = "<group>"; };
8491
		573489381DAC6B6D00DC0667 /* CryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmParameters.h; sourceTree = "<group>"; };
8494
		5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoAlgorithmParameters.h; sourceTree = "<group>"; };
8492
		5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoAlgorithmParameters.h; sourceTree = "<group>"; };
8495
		5739E1301DAC7FD100E14383 /* JSCryptoAlgorithmParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoAlgorithmParameters.cpp; sourceTree = "<group>"; };
8493
		5739E1301DAC7FD100E14383 /* JSCryptoAlgorithmParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoAlgorithmParameters.cpp; sourceTree = "<group>"; };
Lines 8512-8524 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
8512
		5754719A1ECE5D2A00DD63B2 /* JSRsaPssParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaPssParams.cpp; sourceTree = "<group>"; };
8510
		5754719A1ECE5D2A00DD63B2 /* JSRsaPssParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaPssParams.cpp; sourceTree = "<group>"; };
8513
		5760824F20118D8D00116678 /* JSBasicCredentialCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBasicCredentialCustom.cpp; sourceTree = "<group>"; };
8511
		5760824F20118D8D00116678 /* JSBasicCredentialCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBasicCredentialCustom.cpp; sourceTree = "<group>"; };
8514
		576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; };
8512
		576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; };
8515
		576082702021513F00116678 /* CredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CredentialsMessenger.h; sourceTree = "<group>"; };
8513
		576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorCoordinatorClient.h; sourceTree = "<group>"; };
8516
		5760827820244DAB00116678 /* MockCredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockCredentialsMessenger.h; sourceTree = "<group>"; };
8514
		5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockAuthenticatorCoordinator.h; sourceTree = "<group>"; };
8517
		5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockCredentialsMessenger.cpp; sourceTree = "<group>"; };
8515
		5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockAuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
8518
		57608280202556F400116678 /* MockCredentialsMessenger.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockCredentialsMessenger.idl; sourceTree = "<group>"; };
8516
		57608280202556F400116678 /* MockAuthenticatorCoordinator.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockAuthenticatorCoordinator.idl; sourceTree = "<group>"; };
8519
		576082812025679600116678 /* JSMockCredentialsMessenger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockCredentialsMessenger.cpp; sourceTree = "<group>"; };
8517
		57608293202BA95300116678 /* AuthenticatorCoordinatorClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorCoordinatorClient.cpp; sourceTree = "<group>"; };
8520
		576082822025679700116678 /* JSMockCredentialsMessenger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockCredentialsMessenger.h; sourceTree = "<group>"; };
8521
		57608293202BA95300116678 /* CredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CredentialsMessenger.cpp; sourceTree = "<group>"; };
8522
		576814281E6F98AD00E77754 /* EcdhKeyDeriveParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = EcdhKeyDeriveParams.idl; sourceTree = "<group>"; };
8518
		576814281E6F98AD00E77754 /* EcdhKeyDeriveParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = EcdhKeyDeriveParams.idl; sourceTree = "<group>"; };
8523
		576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmEcdhKeyDeriveParams.h; sourceTree = "<group>"; };
8519
		576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmEcdhKeyDeriveParams.h; sourceTree = "<group>"; };
8524
		576814341E6FE3E800E77754 /* CryptoAlgorithmECDHMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmECDHMac.cpp; sourceTree = "<group>"; };
8520
		576814341E6FE3E800E77754 /* CryptoAlgorithmECDHMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmECDHMac.cpp; sourceTree = "<group>"; };
Lines 8572-8577 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec7
8572
		57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PublicKeyCredential.idl; sourceTree = "<group>"; };
8568
		57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PublicKeyCredential.idl; sourceTree = "<group>"; };
8573
		57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredential.h; sourceTree = "<group>"; };
8569
		57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredential.h; sourceTree = "<group>"; };
8574
		57D846311FEAFC2F00CA3682 /* JSPublicKeyCredential.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredential.cpp; sourceTree = "<group>"; };
8570
		57D846311FEAFC2F00CA3682 /* JSPublicKeyCredential.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredential.cpp; sourceTree = "<group>"; };
8571
		57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockAuthenticatorCoordinator.h; sourceTree = "<group>"; };
8572
		57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockAuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
8573
		57DCED72214305F00016B847 /* PublicKeyCredentialData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PublicKeyCredentialData.h; sourceTree = "<group>"; };
8575
		57E1E5A01E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_CTR.cpp; sourceTree = "<group>"; };
8574
		57E1E5A01E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_CTR.cpp; sourceTree = "<group>"; };
8576
		57E1E5A11E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAES_CTR.h; sourceTree = "<group>"; };
8575
		57E1E5A11E8C91B500EE37C9 /* CryptoAlgorithmAES_CTR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAES_CTR.h; sourceTree = "<group>"; };
8577
		57E1E5A61E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesCtrParams.h; sourceTree = "<group>"; };
8576
		57E1E5A61E8DBD3E00EE37C9 /* CryptoAlgorithmAesCtrParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesCtrParams.h; sourceTree = "<group>"; };
Lines 16919-16924 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec8
16919
				A7BE7EDE14C9175A0014489D /* MallocStatistics.idl */,
16918
				A7BE7EDE14C9175A0014489D /* MallocStatistics.idl */,
16920
				CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
16919
				CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
16921
				CD5393CC175DCCE600C07123 /* MemoryInfo.idl */,
16920
				CD5393CC175DCCE600C07123 /* MemoryInfo.idl */,
16921
				5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */,
16922
				5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */,
16923
				57608280202556F400116678 /* MockAuthenticatorCoordinator.idl */,
16922
				CDF4B7211E03BF8100E235A2 /* MockCDMFactory.cpp */,
16924
				CDF4B7211E03BF8100E235A2 /* MockCDMFactory.cpp */,
16923
				CDF4B7221E03BF8100E235A2 /* MockCDMFactory.h */,
16925
				CDF4B7221E03BF8100E235A2 /* MockCDMFactory.h */,
16924
				CDF4B71F1E03BF6F00E235A2 /* MockCDMFactory.idl */,
16926
				CDF4B71F1E03BF6F00E235A2 /* MockCDMFactory.idl */,
Lines 16927-16935 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec9
16927
				A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */,
16929
				A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */,
16928
				A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */,
16930
				A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */,
16929
				A19AEA1C1AAA7C4900B52B25 /* MockContentFilterSettings.idl */,
16931
				A19AEA1C1AAA7C4900B52B25 /* MockContentFilterSettings.idl */,
16930
				5760827920244DAC00116678 /* MockCredentialsMessenger.cpp */,
16931
				5760827820244DAB00116678 /* MockCredentialsMessenger.h */,
16932
				57608280202556F400116678 /* MockCredentialsMessenger.idl */,
16933
				51058AD71D679257009A538C /* MockGamepad.cpp */,
16932
				51058AD71D679257009A538C /* MockGamepad.cpp */,
16934
				51058AD81D679257009A538C /* MockGamepad.h */,
16933
				51058AD81D679257009A538C /* MockGamepad.h */,
16935
				51058AD91D679257009A538C /* MockGamepadProvider.cpp */,
16934
				51058AD91D679257009A538C /* MockGamepadProvider.cpp */,
Lines 16976-16987 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec10
16976
				A7B4EA6914C9348400C8F5BF /* JSMallocStatistics.h */,
16975
				A7B4EA6914C9348400C8F5BF /* JSMallocStatistics.h */,
16977
				CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */,
16976
				CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */,
16978
				CD5393D2175E018600C07123 /* JSMemoryInfo.h */,
16977
				CD5393D2175E018600C07123 /* JSMemoryInfo.h */,
16978
				57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */,
16979
				57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */,
16979
				CDF4B72D1E03CA4A00E235A2 /* JSMockCDMFactory.cpp */,
16980
				CDF4B72D1E03CA4A00E235A2 /* JSMockCDMFactory.cpp */,
16980
				CDF4B72E1E03CA4A00E235A2 /* JSMockCDMFactory.h */,
16981
				CDF4B72E1E03CA4A00E235A2 /* JSMockCDMFactory.h */,
16981
				A19AEA1D1AAA806E00B52B25 /* JSMockContentFilterSettings.cpp */,
16982
				A19AEA1D1AAA806E00B52B25 /* JSMockContentFilterSettings.cpp */,
16982
				A19AEA1E1AAA806E00B52B25 /* JSMockContentFilterSettings.h */,
16983
				A19AEA1E1AAA806E00B52B25 /* JSMockContentFilterSettings.h */,
16983
				576082812025679600116678 /* JSMockCredentialsMessenger.cpp */,
16984
				576082822025679700116678 /* JSMockCredentialsMessenger.h */,
16985
				2D6F3E921C1F85550061DBD4 /* JSMockPageOverlay.cpp */,
16984
				2D6F3E921C1F85550061DBD4 /* JSMockPageOverlay.cpp */,
16986
				2D6F3E931C1F85550061DBD4 /* JSMockPageOverlay.h */,
16985
				2D6F3E931C1F85550061DBD4 /* JSMockPageOverlay.h */,
16987
				A146D3201F99CA3E00D29196 /* JSMockPaymentAddress.cpp */,
16986
				A146D3201F99CA3E00D29196 /* JSMockPaymentAddress.cpp */,
Lines 18710-18717 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec11
18710
				77D510181ED7159900DA4C87 /* CredentialsContainer.cpp */,
18709
				77D510181ED7159900DA4C87 /* CredentialsContainer.cpp */,
18711
				77D510161ED6021B00DA4C87 /* CredentialsContainer.h */,
18710
				77D510161ED6021B00DA4C87 /* CredentialsContainer.h */,
18712
				57D846291FE99F6300CA3682 /* CredentialsContainer.idl */,
18711
				57D846291FE99F6300CA3682 /* CredentialsContainer.idl */,
18713
				57608293202BA95300116678 /* CredentialsMessenger.cpp */,
18714
				576082702021513F00116678 /* CredentialsMessenger.h */,
18715
				57D846241FE895F500CA3682 /* NavigatorCredentials.cpp */,
18712
				57D846241FE895F500CA3682 /* NavigatorCredentials.cpp */,
18716
				57D846261FE895F800CA3682 /* NavigatorCredentials.h */,
18713
				57D846261FE895F800CA3682 /* NavigatorCredentials.h */,
18717
				57D846251FE895F600CA3682 /* NavigatorCredentials.idl */,
18714
				57D846251FE895F600CA3682 /* NavigatorCredentials.idl */,
Lines 18741-18755 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec12
18741
			children = (
18738
			children = (
18742
				57303BB32006C6ED00355965 /* cbor */,
18739
				57303BB32006C6ED00355965 /* cbor */,
18743
				574F55DD204F3744002948C6 /* cocoa */,
18740
				574F55DD204F3744002948C6 /* cocoa */,
18744
				57303C282009B2FC00355965 /* AuthenticatorAssertionResponse.cpp */,
18745
				57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */,
18741
				57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */,
18746
				57303C292009B2FC00355965 /* AuthenticatorAssertionResponse.idl */,
18742
				57303C292009B2FC00355965 /* AuthenticatorAssertionResponse.idl */,
18747
				57303C1C2009A98600355965 /* AuthenticatorAttestationResponse.cpp */,
18748
				57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */,
18743
				57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */,
18749
				57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */,
18744
				57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */,
18750
				57303C4420105B3D00355965 /* AuthenticatorManager.cpp */,
18745
				57303C4420105B3D00355965 /* AuthenticatorCoordinator.cpp */,
18751
				57303C4320105B3D00355965 /* AuthenticatorManager.h */,
18746
				57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */,
18752
				57303BD020087A8300355965 /* AuthenticatorResponse.cpp */,
18747
				57608293202BA95300116678 /* AuthenticatorCoordinatorClient.cpp */,
18748
				576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */,
18753
				57303BCF20087A8300355965 /* AuthenticatorResponse.h */,
18749
				57303BCF20087A8300355965 /* AuthenticatorResponse.h */,
18754
				57303BD120087A8300355965 /* AuthenticatorResponse.idl */,
18750
				57303BD120087A8300355965 /* AuthenticatorResponse.idl */,
18755
				574F55DC204F3732002948C6 /* COSEConstants.h */,
18751
				574F55DC204F3732002948C6 /* COSEConstants.h */,
Lines 18758-18763 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec13
18758
				57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */,
18754
				57D8462D1FEAF68F00CA3682 /* PublicKeyCredential.idl */,
18759
				57303BE62009747A00355965 /* PublicKeyCredentialCreationOptions.h */,
18755
				57303BE62009747A00355965 /* PublicKeyCredentialCreationOptions.h */,
18760
				57303BE82009747A00355965 /* PublicKeyCredentialCreationOptions.idl */,
18756
				57303BE82009747A00355965 /* PublicKeyCredentialCreationOptions.idl */,
18757
				57DCED72214305F00016B847 /* PublicKeyCredentialData.h */,
18761
				57303BEC200980BF00355965 /* PublicKeyCredentialDescriptor.h */,
18758
				57303BEC200980BF00355965 /* PublicKeyCredentialDescriptor.h */,
18762
				57303BEE200980BF00355965 /* PublicKeyCredentialDescriptor.idl */,
18759
				57303BEE200980BF00355965 /* PublicKeyCredentialDescriptor.idl */,
18763
				57303C06200998F800355965 /* PublicKeyCredentialRequestOptions.h */,
18760
				57303C06200998F800355965 /* PublicKeyCredentialRequestOptions.h */,
Lines 26998-27015 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec14
26998
				53ED3FDF167A88E7006762E6 /* JSInternalSettingsGenerated.h in Headers */,
26995
				53ED3FDF167A88E7006762E6 /* JSInternalSettingsGenerated.h in Headers */,
26999
				A740B59514C935AB00A77FA4 /* JSMallocStatistics.h in Headers */,
26996
				A740B59514C935AB00A77FA4 /* JSMallocStatistics.h in Headers */,
27000
				CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */,
26997
				CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */,
26998
				57DCED672140775B0016B847 /* JSMockAuthenticatorCoordinator.h in Headers */,
27001
				538EC9331F99B9F7004D22A8 /* JSMockCDMFactory.h in Headers */,
26999
				538EC9331F99B9F7004D22A8 /* JSMockCDMFactory.h in Headers */,
27002
				A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */,
27000
				A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */,
27003
				5760828620256AFA00116678 /* JSMockCredentialsMessenger.h in Headers */,
27004
				538EC9341F99B9F7004D22A8 /* JSMockPageOverlay.h in Headers */,
27001
				538EC9341F99B9F7004D22A8 /* JSMockPageOverlay.h in Headers */,
27005
				A146D3231F99D0EF00D29196 /* JSMockPaymentAddress.h in Headers */,
27002
				A146D3231F99D0EF00D29196 /* JSMockPaymentAddress.h in Headers */,
27006
				A146D31B1F99BCFB00D29196 /* JSMockPaymentCoordinator.h in Headers */,
27003
				A146D31B1F99BCFB00D29196 /* JSMockPaymentCoordinator.h in Headers */,
27007
				427DA71E13735DFA007C57FB /* JSServiceWorkerInternals.h in Headers */,
27004
				427DA71E13735DFA007C57FB /* JSServiceWorkerInternals.h in Headers */,
27008
				EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
27005
				EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
27009
				CDC26B41160A8CCE0026757B /* LegacyMockCDM.h in Headers */,
27006
				CDC26B41160A8CCE0026757B /* LegacyMockCDM.h in Headers */,
27007
				5760827A2024EA5C00116678 /* MockAuthenticatorCoordinator.h in Headers */,
27010
				A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
27008
				A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
27011
				A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
27009
				A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
27012
				5760827A2024EA5C00116678 /* MockCredentialsMessenger.h in Headers */,
27013
				51058ADC1D6792C1009A538C /* MockGamepad.h in Headers */,
27010
				51058ADC1D6792C1009A538C /* MockGamepad.h in Headers */,
27014
				51058ADE1D6792C1009A538C /* MockGamepadProvider.h in Headers */,
27011
				51058ADE1D6792C1009A538C /* MockGamepadProvider.h in Headers */,
27015
				4157EBFB1E3AB67F00AC9FE9 /* MockLibWebRTCPeerConnection.h in Headers */,
27012
				4157EBFB1E3AB67F00AC9FE9 /* MockLibWebRTCPeerConnection.h in Headers */,
Lines 27199-27205 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec15
27199
				514C764C0CE9234E007EF3CD /* AuthenticationMac.h in Headers */,
27196
				514C764C0CE9234E007EF3CD /* AuthenticationMac.h in Headers */,
27200
				57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */,
27197
				57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */,
27201
				57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */,
27198
				57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */,
27202
				57303C4620105D2F00355965 /* AuthenticatorManager.h in Headers */,
27199
				57303C4620105D2F00355965 /* AuthenticatorCoordinator.h in Headers */,
27200
				5760827220215A5500116678 /* AuthenticatorCoordinatorClient.h in Headers */,
27203
				57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */,
27201
				57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */,
27204
				A501920E132EBF2E008BFE55 /* Autocapitalize.h in Headers */,
27202
				A501920E132EBF2E008BFE55 /* Autocapitalize.h in Headers */,
27205
				A5A7AA43132F0ECC00D3A3C2 /* AutocapitalizeTypes.h in Headers */,
27203
				A5A7AA43132F0ECC00D3A3C2 /* AutocapitalizeTypes.h in Headers */,
Lines 27464-27470 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec16
27464
				77D5100D1ED5E29500DA4C87 /* CredentialCreationOptions.h in Headers */,
27462
				77D5100D1ED5E29500DA4C87 /* CredentialCreationOptions.h in Headers */,
27465
				77D5100B1ED5E28800DA4C87 /* CredentialRequestOptions.h in Headers */,
27463
				77D5100B1ED5E28800DA4C87 /* CredentialRequestOptions.h in Headers */,
27466
				77D510171ED6022200DA4C87 /* CredentialsContainer.h in Headers */,
27464
				77D510171ED6022200DA4C87 /* CredentialsContainer.h in Headers */,
27467
				5760827220215A5500116678 /* CredentialsMessenger.h in Headers */,
27468
				51A052331058774F00CC9E95 /* CredentialStorage.h in Headers */,
27465
				51A052331058774F00CC9E95 /* CredentialStorage.h in Headers */,
27469
				2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */,
27466
				2D481F02146B5C5500AA7834 /* CrossfadeGeneratedImage.h in Headers */,
27470
				E1C416120F6562FD0092D2FB /* CrossOriginAccessControl.h in Headers */,
27467
				E1C416120F6562FD0092D2FB /* CrossOriginAccessControl.h in Headers */,
Lines 29795-29800 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec17
29795
				FF945ECC161F7F3600971BC8 /* PseudoElement.h in Headers */,
29792
				FF945ECC161F7F3600971BC8 /* PseudoElement.h in Headers */,
29796
				57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */,
29793
				57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */,
29797
				57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */,
29794
				57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */,
29795
				57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */,
29798
				57303BEF200980C600355965 /* PublicKeyCredentialDescriptor.h in Headers */,
29796
				57303BEF200980C600355965 /* PublicKeyCredentialDescriptor.h in Headers */,
29799
				57303C0A20099BAD00355965 /* PublicKeyCredentialRequestOptions.h in Headers */,
29797
				57303C0A20099BAD00355965 /* PublicKeyCredentialRequestOptions.h in Headers */,
29800
				57303BEB20097F4000355965 /* PublicKeyCredentialType.h in Headers */,
29798
				57303BEB20097F4000355965 /* PublicKeyCredentialType.h in Headers */,
Lines 31408-31426 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec18
31408
				53ED3FDE167A88E7006762E6 /* JSInternalSettingsGenerated.cpp in Sources */,
31406
				53ED3FDE167A88E7006762E6 /* JSInternalSettingsGenerated.cpp in Sources */,
31409
				538EC9321F99B9F7004D22A8 /* JSMallocStatistics.cpp in Sources */,
31407
				538EC9321F99B9F7004D22A8 /* JSMallocStatistics.cpp in Sources */,
31410
				CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */,
31408
				CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */,
31409
				57DCED69214077640016B847 /* JSMockAuthenticatorCoordinator.cpp in Sources */,
31411
				CDF4B7321E03D06000E235A2 /* JSMockCDMFactory.cpp in Sources */,
31410
				CDF4B7321E03D06000E235A2 /* JSMockCDMFactory.cpp in Sources */,
31412
				A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
31411
				A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
31413
				5760828820256AFD00116678 /* JSMockCredentialsMessenger.cpp in Sources */,
31414
				2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */,
31412
				2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */,
31415
				A146D3221F99D0EC00D29196 /* JSMockPaymentAddress.cpp in Sources */,
31413
				A146D3221F99D0EC00D29196 /* JSMockPaymentAddress.cpp in Sources */,
31416
				A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */,
31414
				A146D31A1F99BCF800D29196 /* JSMockPaymentCoordinator.cpp in Sources */,
31417
				427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */,
31415
				427DA71D13735DFA007C57FB /* JSServiceWorkerInternals.cpp in Sources */,
31418
				EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
31416
				EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
31419
				CDC26B40160A8CC60026757B /* LegacyMockCDM.cpp in Sources */,
31417
				CDC26B40160A8CC60026757B /* LegacyMockCDM.cpp in Sources */,
31418
				5760827B2024ED2900116678 /* MockAuthenticatorCoordinator.cpp in Sources */,
31420
				CDF4B7311E03D00700E235A2 /* MockCDMFactory.cpp in Sources */,
31419
				CDF4B7311E03D00700E235A2 /* MockCDMFactory.cpp in Sources */,
31421
				A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */,
31420
				A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */,
31422
				A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */,
31421
				A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */,
31423
				5760827B2024ED2900116678 /* MockCredentialsMessenger.cpp in Sources */,
31424
				51058ADB1D6792C1009A538C /* MockGamepad.cpp in Sources */,
31422
				51058ADB1D6792C1009A538C /* MockGamepad.cpp in Sources */,
31425
				51058ADD1D6792C1009A538C /* MockGamepadProvider.cpp in Sources */,
31423
				51058ADD1D6792C1009A538C /* MockGamepadProvider.cpp in Sources */,
31426
				4157EBFA1E3AB67900AC9FE9 /* MockLibWebRTCPeerConnection.cpp in Sources */,
31424
				4157EBFA1E3AB67900AC9FE9 /* MockLibWebRTCPeerConnection.cpp in Sources */,
- a/Source/WebCore/page/Page.cpp +4 lines
Lines 24-29 a/Source/WebCore/page/Page.cpp_sec1
24
#include "AlternativeTextClient.h"
24
#include "AlternativeTextClient.h"
25
#include "ApplicationCacheStorage.h"
25
#include "ApplicationCacheStorage.h"
26
#include "ApplicationStateChangeListener.h"
26
#include "ApplicationStateChangeListener.h"
27
#include "AuthenticatorCoordinator.h"
27
#include "BackForwardClient.h"
28
#include "BackForwardClient.h"
28
#include "BackForwardController.h"
29
#include "BackForwardController.h"
29
#include "CSSAnimationController.h"
30
#include "CSSAnimationController.h"
Lines 255-260 Page::Page(PageConfiguration&& pageConfiguration) a/Source/WebCore/page/Page.cpp_sec2
255
#if ENABLE(APPLE_PAY)
256
#if ENABLE(APPLE_PAY)
256
    , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*pageConfiguration.paymentCoordinatorClient))
257
    , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*pageConfiguration.paymentCoordinatorClient))
257
#endif
258
#endif
259
#if ENABLE(WEB_AUTHN)
260
    , m_authenticatorCoordinator(makeUniqueRef<AuthenticatorCoordinator>(WTFMove(pageConfiguration.authenticatorCoordinatorClient)))
261
#endif
258
#if ENABLE(APPLICATION_MANIFEST)
262
#if ENABLE(APPLICATION_MANIFEST)
259
    , m_applicationManifest(pageConfiguration.applicationManifest)
263
    , m_applicationManifest(pageConfiguration.applicationManifest)
260
#endif
264
#endif
- a/Source/WebCore/page/Page.h +9 lines
Lines 76-81 class IDBConnectionToServer; a/Source/WebCore/page/Page.h_sec1
76
76
77
class AlternativeTextClient;
77
class AlternativeTextClient;
78
class ApplicationCacheStorage;
78
class ApplicationCacheStorage;
79
class AuthenticatorCoordinator;
79
class BackForwardController;
80
class BackForwardController;
80
class BackForwardClient;
81
class BackForwardClient;
81
class CacheStorageProvider;
82
class CacheStorageProvider;
Lines 410-415 public: a/Source/WebCore/page/Page.h_sec2
410
    WEBCORE_EXPORT void setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&&);
411
    WEBCORE_EXPORT void setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&&);
411
#endif
412
#endif
412
413
414
#if ENABLE(WEB_AUTHN)
415
    AuthenticatorCoordinator& authenticatorCoordinator() { return m_authenticatorCoordinator.get(); }
416
#endif
417
413
#if ENABLE(APPLICATION_MANIFEST)
418
#if ENABLE(APPLICATION_MANIFEST)
414
    const std::optional<ApplicationManifest>& applicationManifest() const { return m_applicationManifest; }
419
    const std::optional<ApplicationManifest>& applicationManifest() const { return m_applicationManifest; }
415
#endif
420
#endif
Lines 901-906 private: a/Source/WebCore/page/Page.h_sec3
901
    std::unique_ptr<PaymentCoordinator> m_paymentCoordinator;
906
    std::unique_ptr<PaymentCoordinator> m_paymentCoordinator;
902
#endif
907
#endif
903
908
909
#if ENABLE(WEB_AUTHN)
910
    UniqueRef<AuthenticatorCoordinator> m_authenticatorCoordinator;
911
#endif
912
904
#if ENABLE(APPLICATION_MANIFEST)
913
#if ENABLE(APPLICATION_MANIFEST)
905
    std::optional<ApplicationManifest> m_applicationManifest;
914
    std::optional<ApplicationManifest> m_applicationManifest;
906
#endif
915
#endif
- a/Source/WebCore/page/PageConfiguration.cpp +4 lines
Lines 42-47 a/Source/WebCore/page/PageConfiguration.cpp_sec1
42
#include "VisitedLinkStore.h"
42
#include "VisitedLinkStore.h"
43
#include "WebGLStateTracker.h"
43
#include "WebGLStateTracker.h"
44
44
45
#if ENABLE(WEB_AUTHN)
46
#include "AuthenticatorCoordinatorClient.h"
47
#endif
48
45
namespace WebCore {
49
namespace WebCore {
46
50
47
PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider)
51
PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider)
- a/Source/WebCore/page/PageConfiguration.h +5 lines
Lines 38-43 namespace WebCore { a/Source/WebCore/page/PageConfiguration.h_sec1
38
38
39
class AlternativeTextClient;
39
class AlternativeTextClient;
40
class ApplicationCacheStorage;
40
class ApplicationCacheStorage;
41
class AuthenticatorCoordinatorClient;
41
class BackForwardClient;
42
class BackForwardClient;
42
class CacheStorageProvider;
43
class CacheStorageProvider;
43
class ChromeClient;
44
class ChromeClient;
Lines 80-85 public: a/Source/WebCore/page/PageConfiguration.h_sec2
80
    PaymentCoordinatorClient* paymentCoordinatorClient { nullptr };
81
    PaymentCoordinatorClient* paymentCoordinatorClient { nullptr };
81
#endif
82
#endif
82
83
84
#if ENABLE(WEB_AUTHN)
85
    std::unique_ptr<AuthenticatorCoordinatorClient> authenticatorCoordinatorClient;
86
#endif
87
83
#if ENABLE(APPLICATION_MANIFEST)
88
#if ENABLE(APPLICATION_MANIFEST)
84
    std::optional<ApplicationManifest> applicationManifest;
89
    std::optional<ApplicationManifest> applicationManifest;
85
#endif
90
#endif
- a/Source/WebCore/testing/Internals.cpp -6 / +9 lines
Lines 267-274 a/Source/WebCore/testing/Internals.cpp_sec1
267
#endif
267
#endif
268
268
269
#if ENABLE(WEB_AUTHN)
269
#if ENABLE(WEB_AUTHN)
270
#include "AuthenticatorManager.h"
270
#include "AuthenticatorCoordinator.h"
271
#include "MockCredentialsMessenger.h"
271
#include "MockAuthenticatorCoordinator.h"
272
#endif
272
#endif
273
273
274
using JSC::CallData;
274
using JSC::CallData;
Lines 549-556 Internals::Internals(Document& document) a/Source/WebCore/testing/Internals.cpp_sec2
549
#endif
549
#endif
550
550
551
#if ENABLE(WEB_AUTHN)
551
#if ENABLE(WEB_AUTHN)
552
    m_mockCredentialsMessenger = std::make_unique<MockCredentialsMessenger>(*this);
552
    if (document.page()) {
553
    AuthenticatorManager::singleton().setMessenger(*m_mockCredentialsMessenger);
553
        auto mockAuthenticatorCoordinator = std::make_unique<MockAuthenticatorCoordinator>();
554
        m_mockAuthenticatorCoordinator = makeWeakPtr(mockAuthenticatorCoordinator.get());
555
        document.page()->authenticatorCoordinator().setClient(WTFMove(mockAuthenticatorCoordinator));
556
    }
554
#endif
557
#endif
555
}
558
}
556
559
Lines 4620-4628 MockPaymentCoordinator& Internals::mockPaymentCoordinator() const a/Source/WebCore/testing/Internals.cpp_sec3
4620
#endif
4623
#endif
4621
4624
4622
#if ENABLE(WEB_AUTHN)
4625
#if ENABLE(WEB_AUTHN)
4623
MockCredentialsMessenger& Internals::mockCredentialsMessenger() const
4626
MockAuthenticatorCoordinator& Internals::mockAuthenticatorCoordinator() const
4624
{
4627
{
4625
    return *m_mockCredentialsMessenger;
4628
    return *m_mockAuthenticatorCoordinator;
4626
}
4629
}
4627
#endif
4630
#endif
4628
4631
- a/Source/WebCore/testing/Internals.h -3 / +3 lines
Lines 77-83 class MediaStreamTrack; a/Source/WebCore/testing/Internals.h_sec1
77
class MemoryInfo;
77
class MemoryInfo;
78
class MockCDMFactory;
78
class MockCDMFactory;
79
class MockContentFilterSettings;
79
class MockContentFilterSettings;
80
class MockCredentialsMessenger;
80
class MockAuthenticatorCoordinator;
81
class MockPageOverlay;
81
class MockPageOverlay;
82
class MockPaymentCoordinator;
82
class MockPaymentCoordinator;
83
class NodeList;
83
class NodeList;
Lines 697-703 public: a/Source/WebCore/testing/Internals.h_sec2
697
    void testIncomingSyncIPCMessageWhileWaitingForSyncReply();
697
    void testIncomingSyncIPCMessageWhileWaitingForSyncReply();
698
698
699
#if ENABLE(WEB_AUTHN)
699
#if ENABLE(WEB_AUTHN)
700
    MockCredentialsMessenger& mockCredentialsMessenger() const;
700
    MockAuthenticatorCoordinator& mockAuthenticatorCoordinator() const;
701
#endif
701
#endif
702
702
703
    bool isSystemPreviewLink(Element&) const;
703
    bool isSystemPreviewLink(Element&) const;
Lines 763-769 private: a/Source/WebCore/testing/Internals.h_sec3
763
#endif
763
#endif
764
764
765
#if ENABLE(WEB_AUTHN)
765
#if ENABLE(WEB_AUTHN)
766
    std::unique_ptr<MockCredentialsMessenger> m_mockCredentialsMessenger;
766
    WeakPtr<MockAuthenticatorCoordinator> m_mockAuthenticatorCoordinator;
767
#endif
767
#endif
768
};
768
};
769
769
- a/Source/WebCore/testing/Internals.idl -1 / +1 lines
Lines 646-652 enum CompositingPolicy { a/Source/WebCore/testing/Internals.idl_sec1
646
    [EnabledAtRuntime=WebAnimations] void pauseTimeline(AnimationTimeline timeline);
646
    [EnabledAtRuntime=WebAnimations] void pauseTimeline(AnimationTimeline timeline);
647
    [EnabledAtRuntime=WebAnimations] void setTimelineCurrentTime(AnimationTimeline timeline, double currentTime);
647
    [EnabledAtRuntime=WebAnimations] void setTimelineCurrentTime(AnimationTimeline timeline, double currentTime);
648
    [Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator;
648
    [Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator;
649
    [Conditional=WEB_AUTHN] readonly attribute MockCredentialsMessenger mockCredentialsMessenger;
649
    [Conditional=WEB_AUTHN] readonly attribute MockAuthenticatorCoordinator mockAuthenticatorCoordinator;
650
650
651
    boolean isSystemPreviewLink(Element element);
651
    boolean isSystemPreviewLink(Element element);
652
    boolean isSystemPreviewImage(Element element);
652
    boolean isSystemPreviewImage(Element element);
- a/Source/WebCore/testing/MockAuthenticatorCoordinator.cpp +115 lines
Line 0 a/Source/WebCore/testing/MockAuthenticatorCoordinator.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "MockAuthenticatorCoordinator.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "Internals.h"
32
#include <WebCore/PublicKeyCredentialData.h>
33
#include <wtf/Vector.h>
34
35
namespace WebCore {
36
37
void MockAuthenticatorCoordinator::setCreationReturnBundle(const BufferSource& credentialId, const BufferSource& attestationObject)
38
{
39
    ASSERT(!m_credentialId && !m_attestationObject);
40
    m_credentialId = ArrayBuffer::create(credentialId.data(), credentialId.length());
41
    m_attestationObject = ArrayBuffer::create(attestationObject.data(), attestationObject.length());
42
}
43
44
void MockAuthenticatorCoordinator::setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle)
45
{
46
    ASSERT(!m_credentialId && !m_authenticatorData && !m_signature && !m_userHandle);
47
    m_credentialId = ArrayBuffer::create(credentialId.data(), credentialId.length());
48
    m_authenticatorData = ArrayBuffer::create(authenticatorData.data(), authenticatorData.length());
49
    m_signature = ArrayBuffer::create(signature.data(), signature.length());
50
    m_userHandle = ArrayBuffer::create(userHandle.data(), userHandle.length());
51
}
52
53
void MockAuthenticatorCoordinator::makeCredential(const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&& handler)
54
{
55
    if (!setRequestCompletionHandler(WTFMove(handler)))
56
        return;
57
58
    if (m_didTimeOut) {
59
        m_didTimeOut = false;
60
        return;
61
    }
62
    if (m_didUserCancel) {
63
        m_didUserCancel = false;
64
        requestReply({ }, { NotAllowedError, "User cancelled."_s });
65
        return;
66
    }
67
    if (m_credentialId) {
68
        ASSERT(m_attestationObject);
69
        requestReply(PublicKeyCredentialData { WTFMove(m_credentialId), true, nullptr, WTFMove(m_attestationObject), nullptr, nullptr, nullptr }, { });
70
        m_credentialId = nullptr;
71
        m_attestationObject = nullptr;
72
        return;
73
    }
74
    ASSERT_NOT_REACHED();
75
}
76
77
void MockAuthenticatorCoordinator::getAssertion(const Vector<uint8_t>&, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&& handler)
78
{
79
    if (!setRequestCompletionHandler(WTFMove(handler)))
80
        return;
81
82
    if (m_didTimeOut) {
83
        m_didTimeOut = false;
84
        return;
85
    }
86
    if (m_didUserCancel) {
87
        m_didUserCancel = false;
88
        requestReply({ }, { NotAllowedError, "User cancelled."_s });
89
        return;
90
    }
91
    if (m_credentialId) {
92
        ASSERT(m_authenticatorData && m_signature && m_userHandle);
93
        requestReply(PublicKeyCredentialData { WTFMove(m_credentialId), false, nullptr, nullptr, WTFMove(m_authenticatorData), WTFMove(m_signature), WTFMove(m_userHandle) }, { });
94
        m_credentialId = nullptr;
95
        m_authenticatorData = nullptr;
96
        m_signature = nullptr;
97
        m_userHandle = nullptr;
98
        return;
99
    }
100
    ASSERT_NOT_REACHED();
101
}
102
103
void MockAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&& handler)
104
{
105
    auto messageId = addQueryCompletionHandler(WTFMove(handler));
106
    if (m_didUserVerifyingPlatformAuthenticatorPresent) {
107
        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, true);
108
        m_didUserVerifyingPlatformAuthenticatorPresent = false;
109
    } else
110
        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, false);
111
}
112
113
} // namespace WebCore
114
115
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/testing/MockAuthenticatorCoordinator.h +68 lines
Line 0 a/Source/WebCore/testing/MockAuthenticatorCoordinator.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "AuthenticatorCoordinatorClient.h"
31
#include "BufferSource.h"
32
#include <wtf/Forward.h>
33
34
namespace WebCore {
35
36
class Internals;
37
38
class MockAuthenticatorCoordinator final : public AuthenticatorCoordinatorClient {
39
public:
40
    void setDidTimeOut() { m_didTimeOut = true; }
41
    void setDidUserCancel() { m_didUserCancel = true; }
42
    void setDidUserVerifyingPlatformAuthenticatorPresent() { m_didUserVerifyingPlatformAuthenticatorPresent = true; }
43
    void setCreationReturnBundle(const BufferSource& credentialId, const BufferSource& attestationObject);
44
    void setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle);
45
46
    // RefCounted is required for JS wrapper. Therefore, fake them to compile.
47
    void ref() const { }
48
    void deref() const { }
49
50
private:
51
    void makeCredential(const Vector<uint8_t>& hash, const PublicKeyCredentialCreationOptions&, RequestCompletionHandler&&) final;
52
    void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) final;
53
    void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) final;
54
55
    // All following fields are disposable.
56
    bool m_didTimeOut { false };
57
    bool m_didUserCancel { false };
58
    bool m_didUserVerifyingPlatformAuthenticatorPresent { false };
59
    RefPtr<ArrayBuffer> m_credentialId;
60
    RefPtr<ArrayBuffer> m_attestationObject;
61
    RefPtr<ArrayBuffer> m_authenticatorData;
62
    RefPtr<ArrayBuffer> m_signature;
63
    RefPtr<ArrayBuffer> m_userHandle;
64
};
65
66
} // namespace WebCore
67
68
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/testing/MockAuthenticatorCoordinator.idl +35 lines
Line 0 a/Source/WebCore/testing/MockAuthenticatorCoordinator.idl_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
[
27
    Conditional=WEB_AUTHN,
28
    NoInterfaceObject,
29
] interface MockAuthenticatorCoordinator {
30
    void setDidTimeOut();
31
    void setDidUserCancel();
32
    void setDidUserVerifyingPlatformAuthenticatorPresent();
33
    void setCreationReturnBundle(BufferSource credentialId, BufferSource attestationObject);
34
    void setAssertionReturnBundle(BufferSource credentialId, BufferSource authenticatorData, BufferSource signature, BufferSource userHandle);
35
};
- a/Source/WebCore/testing/MockCredentialsMessenger.cpp -152 lines
Lines 1-152 a/Source/WebCore/testing/MockCredentialsMessenger.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "MockCredentialsMessenger.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "Internals.h"
32
#include <wtf/Vector.h>
33
34
namespace WebCore {
35
36
MockCredentialsMessenger::MockCredentialsMessenger(Internals& internals)
37
    : m_internals(internals)
38
{
39
}
40
41
MockCredentialsMessenger::~MockCredentialsMessenger()
42
{
43
    // Have no effects to original promises. Just to call handlers to avoid any assertion failures.
44
    for (auto messageId : m_timeOutMessageIds)
45
        exceptionReply(messageId, ExceptionData { NotAllowedError, "Operation timed out."_s });
46
}
47
48
void MockCredentialsMessenger::setCreationReturnBundle(const BufferSource& credentialId, const BufferSource& attestationObject)
49
{
50
    ASSERT(m_credentialId.isEmpty() && m_attestationObject.isEmpty());
51
    m_credentialId.append(credentialId.data(), credentialId.length());
52
    m_attestationObject.append(attestationObject.data(), attestationObject.length());
53
}
54
55
void MockCredentialsMessenger::setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle)
56
{
57
    ASSERT(m_credentialId.isEmpty() && m_authenticatorData.isEmpty() && m_signature.isEmpty() && m_userHandle.isEmpty());
58
    m_credentialId.append(credentialId.data(), credentialId.length());
59
    m_authenticatorData.append(authenticatorData.data(), authenticatorData.length());
60
    m_signature.append(signature.data(), signature.length());
61
    m_userHandle.append(userHandle.data(), userHandle.length());
62
}
63
64
void MockCredentialsMessenger::ref()
65
{
66
    m_internals.ref();
67
}
68
69
void MockCredentialsMessenger::deref()
70
{
71
    m_internals.deref();
72
}
73
74
void MockCredentialsMessenger::makeCredential(const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, CreationCompletionHandler&& handler)
75
{
76
    auto messageId = addCreationCompletionHandler(WTFMove(handler));
77
    if (m_didTimeOut) {
78
        m_didTimeOut = false;
79
        m_timeOutMessageIds.append(messageId);
80
        return;
81
    }
82
    if (m_didUserCancel) {
83
        m_didUserCancel = false;
84
        exceptionReply(messageId, ExceptionData { NotAllowedError, "User cancelled."_s });
85
        return;
86
    }
87
    if (!m_credentialId.isEmpty()) {
88
        ASSERT(!m_attestationObject.isEmpty());
89
        makeCredentialReply(messageId, m_credentialId, m_attestationObject);
90
        m_credentialId.clear();
91
        m_attestationObject.clear();
92
        return;
93
    }
94
    ASSERT_NOT_REACHED();
95
}
96
97
void MockCredentialsMessenger::getAssertion(const Vector<uint8_t>&, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&& handler)
98
{
99
    auto messageId = addRequestCompletionHandler(WTFMove(handler));
100
    if (m_didTimeOut) {
101
        m_didTimeOut = false;
102
        m_timeOutMessageIds.append(messageId);
103
        return;
104
    }
105
    if (m_didUserCancel) {
106
        m_didUserCancel = false;
107
        exceptionReply(messageId, ExceptionData { NotAllowedError, "User cancelled."_s });
108
        return;
109
    }
110
    if (!m_credentialId.isEmpty()) {
111
        ASSERT(!m_authenticatorData.isEmpty() && !m_signature.isEmpty() && !m_userHandle.isEmpty());
112
        getAssertionReply(messageId, m_credentialId, m_authenticatorData, m_signature, m_userHandle);
113
        m_credentialId.clear();
114
        m_authenticatorData.clear();
115
        m_signature.clear();
116
        m_userHandle.clear();
117
        return;
118
    }
119
    ASSERT_NOT_REACHED();
120
}
121
122
void MockCredentialsMessenger::isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&& handler)
123
{
124
    auto messageId = addQueryCompletionHandler(WTFMove(handler));
125
    if (m_didUserVerifyingPlatformAuthenticatorPresent) {
126
        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, true);
127
        m_didUserVerifyingPlatformAuthenticatorPresent = false;
128
    } else
129
        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, false);
130
}
131
132
void MockCredentialsMessenger::makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject)
133
{
134
    auto handler = takeCreationCompletionHandler(messageId);
135
    handler(CreationReturnBundle(ArrayBuffer::create(credentialId.data(), credentialId.size()), ArrayBuffer::create(attestationObject.data(), attestationObject.size())));
136
}
137
138
void MockCredentialsMessenger::getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle)
139
{
140
    auto handler = takeRequestCompletionHandler(messageId);
141
    handler(AssertionReturnBundle(ArrayBuffer::create(credentialId.data(), credentialId.size()), ArrayBuffer::create(authenticatorData.data(), authenticatorData.size()), ArrayBuffer::create(signature.data(), signature.size()), ArrayBuffer::create(userHandle.data(), userHandle.size())));
142
}
143
144
void MockCredentialsMessenger::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
145
{
146
    auto handler = takeQueryCompletionHandler(messageId);
147
    handler(result);
148
}
149
150
} // namespace WebCore
151
152
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/testing/MockCredentialsMessenger.h -77 lines
Lines 1-77 a/Source/WebCore/testing/MockCredentialsMessenger.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "BufferSource.h"
31
#include "CredentialsMessenger.h"
32
#include <wtf/Forward.h>
33
34
namespace WebCore {
35
36
class Internals;
37
38
class MockCredentialsMessenger final : public CredentialsMessenger {
39
public:
40
    explicit MockCredentialsMessenger(Internals&);
41
    ~MockCredentialsMessenger();
42
43
    void setDidTimeOut() { m_didTimeOut = true; }
44
    void setDidUserCancel() { m_didUserCancel = true; }
45
    void setDidUserVerifyingPlatformAuthenticatorPresent() { m_didUserVerifyingPlatformAuthenticatorPresent = true; }
46
    void setCreationReturnBundle(const BufferSource& credentialId, const BufferSource& attestationObject);
47
    void setAssertionReturnBundle(const BufferSource& credentialId, const BufferSource& authenticatorData, const BufferSource& signature, const BufferSource& userHandle);
48
49
    void ref();
50
    void deref();
51
52
private:
53
    void makeCredential(const Vector<uint8_t>&, const PublicKeyCredentialCreationOptions&, CreationCompletionHandler&&) final;
54
    void getAssertion(const Vector<uint8_t>& hash, const PublicKeyCredentialRequestOptions&, RequestCompletionHandler&&) final;
55
    void isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&&) final;
56
    void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) final;
57
    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;
58
    void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool) final;
59
60
    Internals& m_internals;
61
    // All following fields are disposable.
62
    bool m_didTimeOut { false };
63
    bool m_didUserCancel { false };
64
    bool m_didUserVerifyingPlatformAuthenticatorPresent { false };
65
    Vector<uint8_t> m_attestationObject;
66
    Vector<uint8_t> m_credentialId; // Overlapped between CreationReturnBundle and AssertionReturnBundle.
67
    Vector<uint8_t> m_authenticatorData;
68
    Vector<uint8_t> m_signature;
69
    Vector<uint8_t> m_userHandle;
70
71
    // To clean up completion handlers.
72
    Vector<uint64_t> m_timeOutMessageIds;
73
};
74
75
} // namespace WebCore
76
77
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebCore/testing/MockCredentialsMessenger.idl -35 lines
Lines 1-35 a/Source/WebCore/testing/MockCredentialsMessenger.idl_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
[
27
    Conditional=WEB_AUTHN,
28
    NoInterfaceObject,
29
] interface MockCredentialsMessenger {
30
    void setDidTimeOut();
31
    void setDidUserCancel();
32
    void setDidUserVerifyingPlatformAuthenticatorPresent();
33
    void setCreationReturnBundle(BufferSource credentialId, BufferSource attestationObject);
34
    void setAssertionReturnBundle(BufferSource credentialId, BufferSource authenticatorData, BufferSource signature, BufferSource userHandle);
35
};
- a/Source/WebKit/DerivedSources.make -4 / +4 lines
Lines 43-49 VPATH = \ a/Source/WebKit/DerivedSources.make_sec1
43
    $(WebKit2)/WebProcess/ApplicationCache \
43
    $(WebKit2)/WebProcess/ApplicationCache \
44
    $(WebKit2)/WebProcess/Automation \
44
    $(WebKit2)/WebProcess/Automation \
45
    $(WebKit2)/WebProcess/Cache \
45
    $(WebKit2)/WebProcess/Cache \
46
    $(WebKit2)/WebProcess/CredentialManagement \
47
    $(WebKit2)/WebProcess/Databases/IndexedDB \
46
    $(WebKit2)/WebProcess/Databases/IndexedDB \
48
    $(WebKit2)/WebProcess/FullScreen \
47
    $(WebKit2)/WebProcess/FullScreen \
49
    $(WebKit2)/WebProcess/Geolocation \
48
    $(WebKit2)/WebProcess/Geolocation \
Lines 58-63 VPATH = \ a/Source/WebKit/DerivedSources.make_sec2
58
    $(WebKit2)/WebProcess/ResourceCache \
57
    $(WebKit2)/WebProcess/ResourceCache \
59
    $(WebKit2)/WebProcess/Storage \
58
    $(WebKit2)/WebProcess/Storage \
60
    $(WebKit2)/WebProcess/UserContent \
59
    $(WebKit2)/WebProcess/UserContent \
60
    $(WebKit2)/WebProcess/WebAuthentication \
61
    $(WebKit2)/WebProcess/WebCoreSupport \
61
    $(WebKit2)/WebProcess/WebCoreSupport \
62
    $(WebKit2)/WebProcess/WebPage \
62
    $(WebKit2)/WebProcess/WebPage \
63
    $(WebKit2)/WebProcess/WebPage/RemoteLayerTree \
63
    $(WebKit2)/WebProcess/WebPage/RemoteLayerTree \
Lines 69-75 VPATH = \ a/Source/WebKit/DerivedSources.make_sec3
69
    $(WebKit2)/UIProcess/ApplePay \
69
    $(WebKit2)/UIProcess/ApplePay \
70
    $(WebKit2)/UIProcess/Automation \
70
    $(WebKit2)/UIProcess/Automation \
71
    $(WebKit2)/UIProcess/Cocoa \
71
    $(WebKit2)/UIProcess/Cocoa \
72
    $(WebKit2)/UIProcess/CredentialManagement \
73
    $(WebKit2)/UIProcess/Databases \
72
    $(WebKit2)/UIProcess/Databases \
74
    $(WebKit2)/UIProcess/Downloads \
73
    $(WebKit2)/UIProcess/Downloads \
75
    $(WebKit2)/UIProcess/MediaStream \
74
    $(WebKit2)/UIProcess/MediaStream \
Lines 80-85 VPATH = \ a/Source/WebKit/DerivedSources.make_sec4
80
    $(WebKit2)/UIProcess/RemoteLayerTree \
79
    $(WebKit2)/UIProcess/RemoteLayerTree \
81
    $(WebKit2)/UIProcess/Storage \
80
    $(WebKit2)/UIProcess/Storage \
82
    $(WebKit2)/UIProcess/UserContent \
81
    $(WebKit2)/UIProcess/UserContent \
82
    $(WebKit2)/UIProcess/WebAuthentication \
83
    $(WebKit2)/UIProcess/WebStorage \
83
    $(WebKit2)/UIProcess/WebStorage \
84
    $(WebKit2)/UIProcess/mac \
84
    $(WebKit2)/UIProcess/mac \
85
    $(WebKit2)/UIProcess/ios \
85
    $(WebKit2)/UIProcess/ios \
Lines 149-156 MESSAGE_RECEIVERS = \ a/Source/WebKit/DerivedSources.make_sec5
149
    WebConnection \
149
    WebConnection \
150
    WebCookieManager \
150
    WebCookieManager \
151
    WebCookieManagerProxy \
151
    WebCookieManagerProxy \
152
    WebCredentialsMessenger \
152
    WebAuthenticatorCoordinator \
153
    WebCredentialsMessengerProxy \
153
    WebAuthenticatorCoordinatorProxy \
154
    WebFullScreenManager \
154
    WebFullScreenManager \
155
    WebFullScreenManagerProxy \
155
    WebFullScreenManagerProxy \
156
    WebGeolocationManager \
156
    WebGeolocationManager \
- a/Source/WebKit/SourcesCocoa.txt -4 / +4 lines
Lines 344-351 UIProcess/Cocoa/WebViewImpl.mm a/Source/WebKit/SourcesCocoa.txt_sec1
344
UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
344
UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
345
UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
345
UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
346
346
347
UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp
348
349
UIProcess/Gamepad/cocoa/UIGamepadProviderCocoa.mm
347
UIProcess/Gamepad/cocoa/UIGamepadProviderCocoa.mm
350
UIProcess/Gamepad/ios/UIGamepadProviderIOS.mm
348
UIProcess/Gamepad/ios/UIGamepadProviderIOS.mm
351
UIProcess/Gamepad/mac/UIGamepadProviderMac.mm
349
UIProcess/Gamepad/mac/UIGamepadProviderMac.mm
Lines 456-461 UIProcess/RemoteLayerTree/RemoteLayerTreeScrollingPerformanceData.mm a/Source/WebKit/SourcesCocoa.txt_sec2
456
UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
454
UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
457
UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp
455
UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp
458
456
457
UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp
458
459
UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
459
UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
460
460
461
UIProcess/WebStorage/StorageManager.cpp
461
UIProcess/WebStorage/StorageManager.cpp
Lines 464-471 UIProcess/WebStorage/ios/LocalStorageDatabaseTrackerIOS.mm a/Source/WebKit/SourcesCocoa.txt_sec3
464
464
465
WebProcess/ApplePay/WebPaymentCoordinator.cpp
465
WebProcess/ApplePay/WebPaymentCoordinator.cpp
466
466
467
WebProcess/CredentialManagement/WebCredentialsMessenger.cpp
468
469
WebProcess/cocoa/PlaybackSessionManager.mm
467
WebProcess/cocoa/PlaybackSessionManager.mm
470
WebProcess/cocoa/UserMediaCaptureManager.cpp
468
WebProcess/cocoa/UserMediaCaptureManager.cpp
471
WebProcess/cocoa/VideoFullscreenManager.mm
469
WebProcess/cocoa/VideoFullscreenManager.mm
Lines 510-515 WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm a/Source/WebKit/SourcesCocoa.txt_sec4
510
WebProcess/Plugins/PDF/PDFPluginPasswordField.mm
508
WebProcess/Plugins/PDF/PDFPluginPasswordField.mm
511
WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
509
WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
512
510
511
WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp
512
513
WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp
513
WebProcess/WebCoreSupport/WebDataListSuggestionPicker.cpp
514
WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp
514
WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp
515
WebProcess/WebCoreSupport/WebValidationMessageClient.cpp
515
WebProcess/WebCoreSupport/WebValidationMessageClient.cpp
- a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp -125 lines
Lines 1-125 a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "WebCredentialsMessengerProxy.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "WebCredentialsMessengerMessages.h"
32
#include "WebCredentialsMessengerProxyMessages.h"
33
#include "WebPageProxy.h"
34
#include "WebProcessProxy.h"
35
#include <WebCore/ExceptionData.h>
36
#include <WebCore/LocalAuthenticator.h>
37
38
namespace WebKit {
39
40
WebCredentialsMessengerProxy::WebCredentialsMessengerProxy(WebPageProxy& webPageProxy)
41
    : m_webPageProxy(webPageProxy)
42
{
43
    m_webPageProxy.process().addMessageReceiver(Messages::WebCredentialsMessengerProxy::messageReceiverName(), m_webPageProxy.pageID(), *this);
44
    m_authenticator = std::make_unique<WebCore::LocalAuthenticator>();
45
}
46
47
WebCredentialsMessengerProxy::~WebCredentialsMessengerProxy()
48
{
49
    m_webPageProxy.process().removeMessageReceiver(Messages::WebCredentialsMessengerProxy::messageReceiverName(), m_webPageProxy.pageID());
50
}
51
52
void WebCredentialsMessengerProxy::makeCredential(uint64_t messageId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options)
53
{
54
    // FIXME(182767)
55
    if (!m_authenticator) {
56
        exceptionReply(messageId, { WebCore::NotAllowedError, "No avaliable authenticators."_s });
57
        return;
58
    }
59
    // FIXME(183534): Weak pointers doesn't work in another thread because of race condition.
60
    // FIXME(183534): Unify callbacks.
61
    auto weakThis = makeWeakPtr(*this);
62
    auto callback = [weakThis, messageId] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) {
63
        if (!weakThis)
64
            return;
65
        weakThis->makeCredentialReply(messageId, credentialId, attestationObject);
66
    };
67
    auto exceptionCallback = [weakThis, messageId] (const WebCore::ExceptionData& exception) {
68
        if (!weakThis)
69
            return;
70
        weakThis->exceptionReply(messageId, exception);
71
    };
72
    m_authenticator->makeCredential(hash, options, WTFMove(callback), WTFMove(exceptionCallback));
73
}
74
75
void WebCredentialsMessengerProxy::getAssertion(uint64_t messageId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options)
76
{
77
    // FIXME(182767)
78
    if (!m_authenticator)
79
        exceptionReply(messageId, { WebCore::NotAllowedError, "No avaliable authenticators."_s });
80
    // FIXME(183534): Weak pointers doesn't work in another thread because of race condition.
81
    // FIXME(183534): Unify callbacks.
82
    auto weakThis = makeWeakPtr(*this);
83
    auto callback = [weakThis, messageId] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) {
84
        if (weakThis)
85
            weakThis->getAssertionReply(messageId, credentialId, authenticatorData, signature, userHandle);
86
    };
87
    auto exceptionCallback = [weakThis, messageId] (const WebCore::ExceptionData& exception) {
88
        if (weakThis)
89
            weakThis->exceptionReply(messageId, exception);
90
    };
91
    m_authenticator->getAssertion(hash, options, WTFMove(callback), WTFMove(exceptionCallback));
92
}
93
94
void WebCredentialsMessengerProxy::isUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId)
95
{
96
    if (!m_authenticator) {
97
        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, false);
98
        return;
99
    }
100
    isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, m_authenticator->isAvailable());
101
}
102
103
void WebCredentialsMessengerProxy::exceptionReply(uint64_t messageId, const WebCore::ExceptionData& exception)
104
{
105
    m_webPageProxy.send(Messages::WebCredentialsMessenger::ExceptionReply(messageId, exception));
106
}
107
108
void WebCredentialsMessengerProxy::makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject)
109
{
110
    m_webPageProxy.send(Messages::WebCredentialsMessenger::MakeCredentialReply(messageId, credentialId, attestationObject));
111
}
112
113
void WebCredentialsMessengerProxy::getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle)
114
{
115
    m_webPageProxy.send(Messages::WebCredentialsMessenger::GetAssertionReply(messageId, credentialId, authenticatorData, signature, userHandle));
116
}
117
118
void WebCredentialsMessengerProxy::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
119
{
120
    m_webPageProxy.send(Messages::WebCredentialsMessenger::IsUserVerifyingPlatformAuthenticatorAvailableReply(messageId, result));
121
}
122
123
} // namespace WebKit
124
125
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h -74 lines
Lines 1-74 a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "MessageReceiver.h"
31
#include <wtf/Forward.h>
32
#include <wtf/Noncopyable.h>
33
#include <wtf/WeakPtr.h>
34
35
namespace WebCore {
36
class LocalAuthenticator;
37
38
struct ExceptionData;
39
struct PublicKeyCredentialCreationOptions;
40
struct PublicKeyCredentialRequestOptions;
41
}
42
43
namespace WebKit {
44
45
class WebPageProxy;
46
47
class WebCredentialsMessengerProxy : private IPC::MessageReceiver, public CanMakeWeakPtr<WebCredentialsMessengerProxy> {
48
    WTF_MAKE_NONCOPYABLE(WebCredentialsMessengerProxy);
49
public:
50
    explicit WebCredentialsMessengerProxy(WebPageProxy&);
51
    ~WebCredentialsMessengerProxy();
52
53
private:
54
    // IPC::MessageReceiver.
55
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
56
57
    // Receivers.
58
    void makeCredential(uint64_t messageId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions&);
59
    void getAssertion(uint64_t messageId, const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&);
60
    void isUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId);
61
62
    // Senders.
63
    void exceptionReply(uint64_t messageId, const WebCore::ExceptionData&);
64
    void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject);
65
    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);
66
    void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool);
67
68
    WebPageProxy& m_webPageProxy;
69
    std::unique_ptr<WebCore::LocalAuthenticator> m_authenticator;
70
};
71
72
} // namespace WebKit
73
74
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in -34 lines
Lines 1-34 a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.messages.in_sec1
1
# Copyright (C) 2018 Apple Inc. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
5
# are met:
6
# 1. Redistributions of source code must retain the above copyright
7
#    notice, this list of conditions and the following disclaimer.
8
# 2. Redistributions in binary form must reproduce the above copyright
9
#    notice, this list of conditions and the following disclaimer in the
10
#    documentation and/or other materials provided with the distribution.
11
#
12
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22
# THE POSSIBILITY OF SUCH DAMAGE.
23
#/
24
25
#if ENABLE(WEB_AUTHN)
26
27
messages -> WebCredentialsMessengerProxy {
28
29
    MakeCredential(uint64_t messageId, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options);
30
    GetAssertion(uint64_t messageId, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options);
31
    IsUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId);
32
}
33
34
#endif
- a/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp +114 lines
Line 0 a/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "WebAuthenticatorCoordinatorProxy.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "WebAuthenticatorCoordinatorMessages.h"
32
#include "WebAuthenticatorCoordinatorProxyMessages.h"
33
#include "WebPageProxy.h"
34
#include "WebProcessProxy.h"
35
#include <WebCore/ExceptionData.h>
36
#include <WebCore/LocalAuthenticator.h>
37
#include <WebCore/PublicKeyCredentialData.h>
38
39
namespace WebKit {
40
41
WebAuthenticatorCoordinatorProxy::WebAuthenticatorCoordinatorProxy(WebPageProxy& webPageProxy)
42
    : m_webPageProxy(webPageProxy)
43
{
44
    m_webPageProxy.process().addMessageReceiver(Messages::WebAuthenticatorCoordinatorProxy::messageReceiverName(), m_webPageProxy.pageID(), *this);
45
    m_authenticator = std::make_unique<WebCore::LocalAuthenticator>();
46
}
47
48
WebAuthenticatorCoordinatorProxy::~WebAuthenticatorCoordinatorProxy()
49
{
50
    m_webPageProxy.process().removeMessageReceiver(Messages::WebAuthenticatorCoordinatorProxy::messageReceiverName(), m_webPageProxy.pageID());
51
}
52
53
void WebAuthenticatorCoordinatorProxy::makeCredential(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options)
54
{
55
    // FIXME(182767)
56
    if (!m_authenticator) {
57
        requestReply({ }, { WebCore::NotAllowedError, "No avaliable authenticators."_s });
58
        return;
59
    }
60
    // FIXME(183534): Weak pointers doesn't work in another thread because of race condition.
61
    auto callback = [weakThis = makeWeakPtr(*this)] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
62
        if (!weakThis)
63
            return;
64
65
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
66
            weakThis->requestReply(data, { });
67
        }, [&](const  WebCore::ExceptionData& exception) {
68
            weakThis->requestReply({ }, exception);
69
        });
70
    };
71
    m_authenticator->makeCredential(hash, options, WTFMove(callback));
72
}
73
74
void WebAuthenticatorCoordinatorProxy::getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options)
75
{
76
    // FIXME(182767)
77
    if (!m_authenticator)
78
        requestReply({ }, { WebCore::NotAllowedError, "No avaliable authenticators."_s });
79
    // FIXME(183534): Weak pointers doesn't work in another thread because of race condition.
80
    auto callback = [weakThis = makeWeakPtr(*this)] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
81
        if (!weakThis)
82
            return;
83
84
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
85
            weakThis->requestReply(data, { });
86
        }, [&](const  WebCore::ExceptionData& exception) {
87
            weakThis->requestReply({ }, exception);
88
        });
89
    };
90
    m_authenticator->getAssertion(hash, options, WTFMove(callback));
91
}
92
93
void WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId)
94
{
95
    if (!m_authenticator) {
96
        isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, false);
97
        return;
98
    }
99
    isUserVerifyingPlatformAuthenticatorAvailableReply(messageId, m_authenticator->isAvailable());
100
}
101
102
void WebAuthenticatorCoordinatorProxy::requestReply(const WebCore::PublicKeyCredentialData& data, const WebCore::ExceptionData& exception)
103
{
104
    m_webPageProxy.send(Messages::WebAuthenticatorCoordinator::RequestReply(data, exception));
105
}
106
107
void WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
108
{
109
    m_webPageProxy.send(Messages::WebAuthenticatorCoordinator::IsUserVerifyingPlatformAuthenticatorAvailableReply(messageId, result));
110
}
111
112
} // namespace WebKit
113
114
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h +73 lines
Line 0 a/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "MessageReceiver.h"
31
#include <wtf/Forward.h>
32
#include <wtf/Noncopyable.h>
33
#include <wtf/WeakPtr.h>
34
35
namespace WebCore {
36
class LocalAuthenticator;
37
38
struct ExceptionData;
39
struct PublicKeyCredentialCreationOptions;
40
struct PublicKeyCredentialData;
41
struct PublicKeyCredentialRequestOptions;
42
}
43
44
namespace WebKit {
45
46
class WebPageProxy;
47
48
class WebAuthenticatorCoordinatorProxy : private IPC::MessageReceiver, public CanMakeWeakPtr<WebAuthenticatorCoordinatorProxy> {
49
    WTF_MAKE_NONCOPYABLE(WebAuthenticatorCoordinatorProxy);
50
public:
51
    explicit WebAuthenticatorCoordinatorProxy(WebPageProxy&);
52
    ~WebAuthenticatorCoordinatorProxy();
53
54
private:
55
    // IPC::MessageReceiver.
56
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
57
58
    // Receivers.
59
    void makeCredential(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions&);
60
    void getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&);
61
    void isUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId);
62
63
    // Senders.
64
    void requestReply(const WebCore::PublicKeyCredentialData&, const WebCore::ExceptionData&);
65
    void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool);
66
67
    WebPageProxy& m_webPageProxy;
68
    std::unique_ptr<WebCore::LocalAuthenticator> m_authenticator;
69
};
70
71
} // namespace WebKit
72
73
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in +34 lines
Line 0 a/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in_sec1
1
# Copyright (C) 2018 Apple Inc. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
5
# are met:
6
# 1. Redistributions of source code must retain the above copyright
7
#    notice, this list of conditions and the following disclaimer.
8
# 2. Redistributions in binary form must reproduce the above copyright
9
#    notice, this list of conditions and the following disclaimer in the
10
#    documentation and/or other materials provided with the distribution.
11
#
12
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22
# THE POSSIBILITY OF SUCH DAMAGE.
23
#/
24
25
#if ENABLE(WEB_AUTHN)
26
27
messages -> WebAuthenticatorCoordinatorProxy {
28
29
    MakeCredential(Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options);
30
    GetAssertion(Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options);
31
    IsUserVerifyingPlatformAuthenticatorAvailable(uint64_t messageId);
32
}
33
34
#endif
- a/Source/WebKit/UIProcess/WebPageProxy.cpp -3 / +3 lines
Lines 211-217 a/Source/WebKit/UIProcess/WebPageProxy.cpp_sec1
211
#endif
211
#endif
212
212
213
#if ENABLE(WEB_AUTHN)
213
#if ENABLE(WEB_AUTHN)
214
#include "WebCredentialsMessengerProxy.h"
214
#include "WebAuthenticatorCoordinatorProxy.h"
215
#endif
215
#endif
216
216
217
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
217
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
Lines 461-467 WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin a/Source/WebKit/UIProcess/WebPageProxy.cpp_sec2
461
#endif
461
#endif
462
462
463
#if ENABLE(WEB_AUTHN)
463
#if ENABLE(WEB_AUTHN)
464
    m_credentialsMessenger = std::make_unique<WebCredentialsMessengerProxy>(*this);
464
    m_credentialsMessenger = std::make_unique<WebAuthenticatorCoordinatorProxy>(*this);
465
#endif
465
#endif
466
466
467
    m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
467
    m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
Lines 779-785 void WebPageProxy::reattachToWebProcess(Ref<WebProcessProxy>&& process, API::Nav a/Source/WebKit/UIProcess/WebPageProxy.cpp_sec3
779
#endif
779
#endif
780
780
781
#if ENABLE(WEB_AUTHN)
781
#if ENABLE(WEB_AUTHN)
782
    m_credentialsMessenger = std::make_unique<WebCredentialsMessengerProxy>(*this);
782
    m_credentialsMessenger = std::make_unique<WebAuthenticatorCoordinatorProxy>(*this);
783
#endif
783
#endif
784
784
785
    initializeWebPage();
785
    initializeWebPage();
- a/Source/WebKit/UIProcess/WebPageProxy.h -2 / +2 lines
Lines 236-242 class WebFullScreenManagerProxy; a/Source/WebKit/UIProcess/WebPageProxy.h_sec1
236
class PlaybackSessionManagerProxy;
236
class PlaybackSessionManagerProxy;
237
class WebNavigationState;
237
class WebNavigationState;
238
class VideoFullscreenManagerProxy;
238
class VideoFullscreenManagerProxy;
239
class WebCredentialsMessengerProxy;
239
class WebAuthenticatorCoordinatorProxy;
240
class WebKeyboardEvent;
240
class WebKeyboardEvent;
241
class WebURLSchemeHandler;
241
class WebURLSchemeHandler;
242
class WebMouseEvent;
242
class WebMouseEvent;
Lines 1917-1923 private: a/Source/WebKit/UIProcess/WebPageProxy.h_sec2
1917
#endif
1917
#endif
1918
1918
1919
#if ENABLE(WEB_AUTHN)
1919
#if ENABLE(WEB_AUTHN)
1920
    std::unique_ptr<WebCredentialsMessengerProxy> m_credentialsMessenger;
1920
    std::unique_ptr<WebAuthenticatorCoordinatorProxy> m_credentialsMessenger;
1921
#endif
1921
#endif
1922
1922
1923
    CallbackMap m_callbacks;
1923
    CallbackMap m_callbacks;
- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj -34 / +34 lines
Lines 1028-1038 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec1
1028
		53BA47D11DC2EF5E004DF4AD /* NetworkDataTaskBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */; };
1028
		53BA47D11DC2EF5E004DF4AD /* NetworkDataTaskBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 539EB5471DC2EE40009D48CF /* NetworkDataTaskBlob.h */; };
1029
		53DEA3661DDE423100E82648 /* json.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 53DEA3651DDE422E00E82648 /* json.hpp */; };
1029
		53DEA3661DDE423100E82648 /* json.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 53DEA3651DDE422E00E82648 /* json.hpp */; };
1030
		570AB8F320AE3BD700B8BE87 /* SecKeyProxyStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 570AB8F220AE3BD700B8BE87 /* SecKeyProxyStore.h */; };
1030
		570AB8F320AE3BD700B8BE87 /* SecKeyProxyStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 570AB8F220AE3BD700B8BE87 /* SecKeyProxyStore.h */; };
1031
		5760829C202D2C3C00116678 /* WebCredentialsMessengerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */; };
1032
		5760829D202D2C4000116678 /* WebCredentialsMessengerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */; };
1033
		5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */; };
1034
		5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */; };
1035
		57B4B46020B504AC00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B4B45E20B504AB00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h */; };
1031
		57B4B46020B504AC00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B4B45E20B504AB00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h */; };
1032
		57DCED6E2142EE5E0016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57DCED6B2142EAE20016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp */; };
1033
		57DCED6F2142EE630016B847 /* WebAuthenticatorCoordinatorMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED6A2142EAE20016B847 /* WebAuthenticatorCoordinatorMessages.h */; };
1034
		57DCED702142EE680016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57DCED6C2142EAF90016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp */; };
1035
		57DCED712142EE6C0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED6D2142EAFA0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h */; };
1036
		5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */; };
1036
		5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */; };
1037
		5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */; };
1037
		5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */; };
1038
		5C1426ED1C23F80900D41183 /* NetworkProcessCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */; };
1038
		5C1426ED1C23F80900D41183 /* NetworkProcessCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */; };
Lines 3368-3385 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec2
3368
		570AB90320B2541C00B8BE87 /* SecKeyProxyStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SecKeyProxyStore.mm; sourceTree = "<group>"; };
3368
		570AB90320B2541C00B8BE87 /* SecKeyProxyStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SecKeyProxyStore.mm; sourceTree = "<group>"; };
3369
		575075A720AB763600693EA9 /* WebCredentialMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCredentialMac.mm; sourceTree = "<group>"; };
3369
		575075A720AB763600693EA9 /* WebCredentialMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCredentialMac.mm; sourceTree = "<group>"; };
3370
		5750F32A2032D4E500389347 /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; };
3370
		5750F32A2032D4E500389347 /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; };
3371
		5760828B2029854200116678 /* WebCredentialsMessenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessenger.h; sourceTree = "<group>"; };
3371
		5760828B2029854200116678 /* WebAuthenticatorCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAuthenticatorCoordinator.h; sourceTree = "<group>"; };
3372
		5760828C2029854200116678 /* WebCredentialsMessenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessenger.cpp; sourceTree = "<group>"; };
3372
		5760828C2029854200116678 /* WebAuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
3373
		5760828D202987E600116678 /* WebCredentialsMessenger.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCredentialsMessenger.messages.in; sourceTree = "<group>"; };
3373
		5760828D202987E600116678 /* WebAuthenticatorCoordinator.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebAuthenticatorCoordinator.messages.in; sourceTree = "<group>"; };
3374
		5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerMessages.h; sourceTree = "<group>"; };
3374
		57608295202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAuthenticatorCoordinatorProxy.h; sourceTree = "<group>"; };
3375
		5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerMessageReceiver.cpp; sourceTree = "<group>"; };
3375
		57608296202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticatorCoordinatorProxy.cpp; sourceTree = "<group>"; };
3376
		57608295202BD8BA00116678 /* WebCredentialsMessengerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerProxy.h; sourceTree = "<group>"; };
3376
		57608299202BDAE200116678 /* WebAuthenticatorCoordinatorProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebAuthenticatorCoordinatorProxy.messages.in; sourceTree = "<group>"; };
3377
		57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerProxy.cpp; sourceTree = "<group>"; };
3378
		57608299202BDAE200116678 /* WebCredentialsMessengerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCredentialsMessengerProxy.messages.in; sourceTree = "<group>"; };
3379
		5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCredentialsMessengerProxyMessageReceiver.cpp; sourceTree = "<group>"; };
3380
		5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCredentialsMessengerProxyMessages.h; sourceTree = "<group>"; };
3381
		57B4B45D20B504AB00D4AD79 /* AuthenticationManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AuthenticationManagerCocoa.mm; path = Authentication/cocoa/AuthenticationManagerCocoa.mm; sourceTree = "<group>"; };
3377
		57B4B45D20B504AB00D4AD79 /* AuthenticationManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AuthenticationManagerCocoa.mm; path = Authentication/cocoa/AuthenticationManagerCocoa.mm; sourceTree = "<group>"; };
3382
		57B4B45E20B504AB00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClientCertificateAuthenticationXPCConstants.h; path = Authentication/cocoa/ClientCertificateAuthenticationXPCConstants.h; sourceTree = "<group>"; };
3378
		57B4B45E20B504AB00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClientCertificateAuthenticationXPCConstants.h; path = Authentication/cocoa/ClientCertificateAuthenticationXPCConstants.h; sourceTree = "<group>"; };
3379
		57DCED6A2142EAE20016B847 /* WebAuthenticatorCoordinatorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAuthenticatorCoordinatorMessages.h; sourceTree = "<group>"; };
3380
		57DCED6B2142EAE20016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticatorCoordinatorMessageReceiver.cpp; sourceTree = "<group>"; };
3381
		57DCED6C2142EAF90016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAuthenticatorCoordinatorProxyMessageReceiver.cpp; sourceTree = "<group>"; };
3382
		57DCED6D2142EAFA0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAuthenticatorCoordinatorProxyMessages.h; sourceTree = "<group>"; };
3383
		5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
3383
		5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
3384
		5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketStreamMessages.h; sourceTree = "<group>"; };
3384
		5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkSocketStreamMessages.h; sourceTree = "<group>"; };
3385
		5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
3385
		5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketStreamMessageReceiver.cpp; sourceTree = "<group>"; };
Lines 6721-6744 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec3
6721
			name = Frameworks;
6721
			name = Frameworks;
6722
			sourceTree = "<group>";
6722
			sourceTree = "<group>";
6723
		};
6723
		};
6724
		5760828A202984C900116678 /* CredentialManagement */ = {
6724
		5760828A202984C900116678 /* WebAuthentication */ = {
6725
			isa = PBXGroup;
6725
			isa = PBXGroup;
6726
			children = (
6726
			children = (
6727
				5760828C2029854200116678 /* WebCredentialsMessenger.cpp */,
6727
				5760828C2029854200116678 /* WebAuthenticatorCoordinator.cpp */,
6728
				5760828B2029854200116678 /* WebCredentialsMessenger.h */,
6728
				5760828B2029854200116678 /* WebAuthenticatorCoordinator.h */,
6729
				5760828D202987E600116678 /* WebCredentialsMessenger.messages.in */,
6729
				5760828D202987E600116678 /* WebAuthenticatorCoordinator.messages.in */,
6730
			);
6730
			);
6731
			path = CredentialManagement;
6731
			path = WebAuthentication;
6732
			sourceTree = "<group>";
6732
			sourceTree = "<group>";
6733
		};
6733
		};
6734
		57608294202BD84900116678 /* CredentialManagement */ = {
6734
		57608294202BD84900116678 /* WebAuthentication */ = {
6735
			isa = PBXGroup;
6735
			isa = PBXGroup;
6736
			children = (
6736
			children = (
6737
				57608296202BD8BA00116678 /* WebCredentialsMessengerProxy.cpp */,
6737
				57608296202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.cpp */,
6738
				57608295202BD8BA00116678 /* WebCredentialsMessengerProxy.h */,
6738
				57608295202BD8BA00116678 /* WebAuthenticatorCoordinatorProxy.h */,
6739
				57608299202BDAE200116678 /* WebCredentialsMessengerProxy.messages.in */,
6739
				57608299202BDAE200116678 /* WebAuthenticatorCoordinatorProxy.messages.in */,
6740
			);
6740
			);
6741
			path = CredentialManagement;
6741
			path = WebAuthentication;
6742
			sourceTree = "<group>";
6742
			sourceTree = "<group>";
6743
		};
6743
		};
6744
		57B4B45C20B5048B00D4AD79 /* cocoa */ = {
6744
		57B4B45C20B5048B00D4AD79 /* cocoa */ = {
Lines 7033-7039 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec4
7033
				1C0A19431C8FF1A800FE0EBB /* Automation */,
7033
				1C0A19431C8FF1A800FE0EBB /* Automation */,
7034
				41D129D81F3D101400D15E47 /* Cache */,
7034
				41D129D81F3D101400D15E47 /* Cache */,
7035
				7C6E70F818B2D47E00F24E2E /* cocoa */,
7035
				7C6E70F818B2D47E00F24E2E /* cocoa */,
7036
				5760828A202984C900116678 /* CredentialManagement */,
7037
				512A9754180DF9270039A149 /* Databases */,
7036
				512A9754180DF9270039A149 /* Databases */,
7038
				BCACC43B16B24C5D00B6E092 /* EntryPoint */,
7037
				BCACC43B16B24C5D00B6E092 /* EntryPoint */,
7039
				E170876D16D6CA7200F99226 /* FileAPI */,
7038
				E170876D16D6CA7200F99226 /* FileAPI */,
Lines 7048-7053 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec5
7048
				1A6FB7AA11E64B4900DB1371 /* Plugins */,
7047
				1A6FB7AA11E64B4900DB1371 /* Plugins */,
7049
				5118E9981F295259003EF9F5 /* Storage */,
7048
				5118E9981F295259003EF9F5 /* Storage */,
7050
				1AAF08AA1926930B00B6390C /* UserContent */,
7049
				1AAF08AA1926930B00B6390C /* UserContent */,
7050
				5760828A202984C900116678 /* WebAuthentication */,
7051
				BC032D5D10F437220058C15A /* WebCoreSupport */,
7051
				BC032D5D10F437220058C15A /* WebCoreSupport */,
7052
				BC032D5E10F4372B0058C15A /* WebPage */,
7052
				BC032D5E10F4372B0058C15A /* WebPage */,
7053
				1AAC4DDE16B1CBF6009425E3 /* WebStorage */,
7053
				1AAC4DDE16B1CBF6009425E3 /* WebStorage */,
Lines 7193-7199 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec6
7193
				512F588D12A8836F00629530 /* Authentication */,
7193
				512F588D12A8836F00629530 /* Authentication */,
7194
				9955A6E81C79809000EB6A93 /* Automation */,
7194
				9955A6E81C79809000EB6A93 /* Automation */,
7195
				1ABC3DF21899E415004F0626 /* Cocoa */,
7195
				1ABC3DF21899E415004F0626 /* Cocoa */,
7196
				57608294202BD84900116678 /* CredentialManagement */,
7197
				1AB7D4C71288AA9A00CFD08C /* Downloads */,
7196
				1AB7D4C71288AA9A00CFD08C /* Downloads */,
7198
				515BE17B1D54EF5A00DD7C68 /* Gamepad */,
7197
				515BE17B1D54EF5A00DD7C68 /* Gamepad */,
7199
				2DA944A81884E9AB00ED86DB /* ios */,
7198
				2DA944A81884E9AB00ED86DB /* ios */,
Lines 7205-7210 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec7
7205
				2D1551A91F5A9B420006E3FE /* RemoteLayerTree */,
7204
				2D1551A91F5A9B420006E3FE /* RemoteLayerTree */,
7206
				517DD5BB180DA7C40081660B /* Storage */,
7205
				517DD5BB180DA7C40081660B /* Storage */,
7207
				1AAF089E192681AC00B6390C /* UserContent */,
7206
				1AAF089E192681AC00B6390C /* UserContent */,
7207
				57608294202BD84900116678 /* WebAuthentication */,
7208
				1A53C2A31A325691004E8C70 /* WebsiteData */,
7208
				1A53C2A31A325691004E8C70 /* WebsiteData */,
7209
				1A44B95816B73F8C00B7BBD8 /* WebStorage */,
7209
				1A44B95816B73F8C00B7BBD8 /* WebStorage */,
7210
				7CD102D91866770600ED429D /* AutoCorrectionCallback.h */,
7210
				7CD102D91866770600ED429D /* AutoCorrectionCallback.h */,
Lines 8344-8349 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec8
8344
				1A60224B18C16B9F00C3E8C9 /* VisitedLinkStoreMessages.h */,
8344
				1A60224B18C16B9F00C3E8C9 /* VisitedLinkStoreMessages.h */,
8345
				1A8E7D3A18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp */,
8345
				1A8E7D3A18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp */,
8346
				1A8E7D3B18C15149005A702A /* VisitedLinkTableControllerMessages.h */,
8346
				1A8E7D3B18C15149005A702A /* VisitedLinkTableControllerMessages.h */,
8347
				57DCED6B2142EAE20016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp */,
8348
				57DCED6A2142EAE20016B847 /* WebAuthenticatorCoordinatorMessages.h */,
8349
				57DCED6C2142EAF90016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp */,
8350
				57DCED6D2142EAFA0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h */,
8347
				1C0A19551C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp */,
8351
				1C0A19551C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp */,
8348
				1C0A19561C90068F00FE0EBB /* WebAutomationSessionMessages.h */,
8352
				1C0A19561C90068F00FE0EBB /* WebAutomationSessionMessages.h */,
8349
				1C0A19511C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp */,
8353
				1C0A19511C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp */,
Lines 8356-8365 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec9
8356
				330934441315B9220097A7BC /* WebCookieManagerMessages.h */,
8360
				330934441315B9220097A7BC /* WebCookieManagerMessages.h */,
8357
				330934451315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp */,
8361
				330934451315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp */,
8358
				330934461315B9220097A7BC /* WebCookieManagerProxyMessages.h */,
8362
				330934461315B9220097A7BC /* WebCookieManagerProxyMessages.h */,
8359
				5760829020298FBD00116678 /* WebCredentialsMessengerMessageReceiver.cpp */,
8360
				5760828F20298FBD00116678 /* WebCredentialsMessengerMessages.h */,
8361
				5760829A202BEE5A00116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp */,
8362
				5760829B202BEE5A00116678 /* WebCredentialsMessengerProxyMessages.h */,
8363
				CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */,
8363
				CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */,
8364
				CD73BA49131ACD8E00EEDED2 /* WebFullScreenManagerMessages.h */,
8364
				CD73BA49131ACD8E00EEDED2 /* WebFullScreenManagerMessages.h */,
8365
				CD73BA45131ACC8800EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp */,
8365
				CD73BA45131ACC8800EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp */,
Lines 9223-9228 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec10
9223
				1AF4CEF018BC481800BC2D34 /* VisitedLinkTableController.h in Headers */,
9223
				1AF4CEF018BC481800BC2D34 /* VisitedLinkTableController.h in Headers */,
9224
				1A8E7D3D18C15149005A702A /* VisitedLinkTableControllerMessages.h in Headers */,
9224
				1A8E7D3D18C15149005A702A /* VisitedLinkTableControllerMessages.h in Headers */,
9225
				CEDA12E3152CD1B300D9E08D /* WebAlternativeTextClient.h in Headers */,
9225
				CEDA12E3152CD1B300D9E08D /* WebAlternativeTextClient.h in Headers */,
9226
				57DCED6F2142EE630016B847 /* WebAuthenticatorCoordinatorMessages.h in Headers */,
9227
				57DCED712142EE6C0016B847 /* WebAuthenticatorCoordinatorProxyMessages.h in Headers */,
9226
				9955A6EC1C7980C200EB6A93 /* WebAutomationSession.h in Headers */,
9228
				9955A6EC1C7980C200EB6A93 /* WebAutomationSession.h in Headers */,
9227
				99C3AE2D1DADA6AD00AF5C16 /* WebAutomationSessionMacros.h in Headers */,
9229
				99C3AE2D1DADA6AD00AF5C16 /* WebAutomationSessionMacros.h in Headers */,
9228
				1C0A19581C90068F00FE0EBB /* WebAutomationSessionMessages.h in Headers */,
9230
				1C0A19581C90068F00FE0EBB /* WebAutomationSessionMessages.h in Headers */,
Lines 9263-9270 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec11
9263
				3309344A1315B9220097A7BC /* WebCookieManagerProxyMessages.h in Headers */,
9265
				3309344A1315B9220097A7BC /* WebCookieManagerProxyMessages.h in Headers */,
9264
				BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
9266
				BC1DD7B2114DC396005ADAF3 /* WebCoreArgumentCoders.h in Headers */,
9265
				512F589B12A8838800629530 /* WebCredential.h in Headers */,
9267
				512F589B12A8838800629530 /* WebCredential.h in Headers */,
9266
				5760829D202D2C4000116678 /* WebCredentialsMessengerMessages.h in Headers */,
9267
				5760829F202D2C4600116678 /* WebCredentialsMessengerProxyMessages.h in Headers */,
9268
				1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */,
9268
				1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */,
9269
				E52CF55220A35C3A00DADA27 /* WebDataListSuggestionPicker.h in Headers */,
9269
				E52CF55220A35C3A00DADA27 /* WebDataListSuggestionPicker.h in Headers */,
9270
				E568B91F20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h in Headers */,
9270
				E568B91F20A3AB2F00E3C856 /* WebDataListSuggestionsDropdown.h in Headers */,
Lines 10900-10905 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec12
10900
				2684055218B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp in Sources */,
10900
				2684055218B86ED60022C38B /* ViewUpdateDispatcherMessageReceiver.cpp in Sources */,
10901
				1A60224C18C16B9F00C3E8C9 /* VisitedLinkStoreMessageReceiver.cpp in Sources */,
10901
				1A60224C18C16B9F00C3E8C9 /* VisitedLinkStoreMessageReceiver.cpp in Sources */,
10902
				1A8E7D3C18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp in Sources */,
10902
				1A8E7D3C18C15149005A702A /* VisitedLinkTableControllerMessageReceiver.cpp in Sources */,
10903
				57DCED6E2142EE5E0016B847 /* WebAuthenticatorCoordinatorMessageReceiver.cpp in Sources */,
10904
				57DCED702142EE680016B847 /* WebAuthenticatorCoordinatorProxyMessageReceiver.cpp in Sources */,
10903
				1C0A19571C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp in Sources */,
10905
				1C0A19571C90068F00FE0EBB /* WebAutomationSessionMessageReceiver.cpp in Sources */,
10904
				1C0A19531C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp in Sources */,
10906
				1C0A19531C8FFDFB00FE0EBB /* WebAutomationSessionProxyMessageReceiver.cpp in Sources */,
10905
				517CF0E3163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp in Sources */,
10907
				517CF0E3163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp in Sources */,
Lines 10907-10914 a/Source/WebKit/WebKit.xcodeproj/project.pbxproj_sec13
10907
				330934471315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp in Sources */,
10909
				330934471315B9220097A7BC /* WebCookieManagerMessageReceiver.cpp in Sources */,
10908
				330934491315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp in Sources */,
10910
				330934491315B9220097A7BC /* WebCookieManagerProxyMessageReceiver.cpp in Sources */,
10909
				2D92A788212B6AB100F493FD /* WebCoreArgumentCoders.cpp in Sources */,
10911
				2D92A788212B6AB100F493FD /* WebCoreArgumentCoders.cpp in Sources */,
10910
				5760829C202D2C3C00116678 /* WebCredentialsMessengerMessageReceiver.cpp in Sources */,
10911
				5760829E202D2C4300116678 /* WebCredentialsMessengerProxyMessageReceiver.cpp in Sources */,
10912
				2D92A789212B6AB100F493FD /* WebEvent.cpp in Sources */,
10912
				2D92A789212B6AB100F493FD /* WebEvent.cpp in Sources */,
10913
				CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */,
10913
				CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */,
10914
				CD73BA47131ACC9A00EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp in Sources */,
10914
				CD73BA47131ACC9A00EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp in Sources */,
- a/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp -90 lines
Lines 1-90 a/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "WebCredentialsMessenger.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "WebCredentialsMessengerMessages.h"
32
#include "WebCredentialsMessengerProxyMessages.h"
33
#include "WebPage.h"
34
#include "WebProcess.h"
35
#include <WebCore/PublicKeyCredentialCreationOptions.h>
36
#include <WebCore/PublicKeyCredentialRequestOptions.h>
37
38
namespace WebKit {
39
40
WebCredentialsMessenger::WebCredentialsMessenger(WebPage& webPage)
41
    : m_webPage(webPage)
42
{
43
    WebProcess::singleton().addMessageReceiver(Messages::WebCredentialsMessenger::messageReceiverName(), m_webPage.pageID(), *this);
44
}
45
46
WebCredentialsMessenger::~WebCredentialsMessenger()
47
{
48
    WebProcess::singleton().removeMessageReceiver(*this);
49
}
50
51
void WebCredentialsMessenger::makeCredential(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options, WebCore::CreationCompletionHandler&& handler)
52
{
53
    auto messageId = addCreationCompletionHandler(WTFMove(handler));
54
    m_webPage.send(Messages::WebCredentialsMessengerProxy::MakeCredential(messageId, hash, options));
55
}
56
57
void WebCredentialsMessenger::getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options, WebCore::RequestCompletionHandler&& handler)
58
{
59
    auto messageId = addRequestCompletionHandler(WTFMove(handler));
60
    m_webPage.send(Messages::WebCredentialsMessengerProxy::GetAssertion(messageId, hash, options));
61
}
62
63
void WebCredentialsMessenger::isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&& handler)
64
{
65
    auto messageId = addQueryCompletionHandler(WTFMove(handler));
66
    m_webPage.send(Messages::WebCredentialsMessengerProxy::IsUserVerifyingPlatformAuthenticatorAvailable(messageId));
67
}
68
69
void WebCredentialsMessenger::makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject)
70
{
71
    auto handler = takeCreationCompletionHandler(messageId);
72
    handler(WebCore::CreationReturnBundle(ArrayBuffer::create(credentialId.data(), credentialId.size()), ArrayBuffer::create(attestationObject.data(), attestationObject.size())));
73
}
74
75
void WebCredentialsMessenger::getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle)
76
{
77
    auto handler = takeRequestCompletionHandler(messageId);
78
    handler(WebCore::AssertionReturnBundle(ArrayBuffer::create(credentialId.data(), credentialId.size()), ArrayBuffer::create(authenticatorData.data(), authenticatorData.size()), ArrayBuffer::create(signature.data(), signature.size()), ArrayBuffer::create(userHandle.data(), userHandle.size())));
79
}
80
81
void WebCredentialsMessenger::isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result)
82
{
83
    auto handler = takeQueryCompletionHandler(messageId);
84
    handler(result);
85
}
86
87
88
} // namespace WebKit
89
90
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h -62 lines
Lines 1-62 a/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "MessageReceiver.h"
31
#include <WebCore/CredentialsMessenger.h>
32
33
namespace WebKit {
34
35
class WebPage;
36
37
class WebCredentialsMessenger final : public WebCore::CredentialsMessenger, private IPC::MessageReceiver {
38
public:
39
    explicit WebCredentialsMessenger(WebPage&);
40
    ~WebCredentialsMessenger();
41
42
private:
43
    // WebCore::CredentialsMessenger
44
    // Senders.
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
    void isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&&) final;
48
49
    // Receivers.
50
    void makeCredentialReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) final;
51
    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;
52
    void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool) final;
53
54
    // IPC::MessageReceiver.
55
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
56
57
    WebPage& m_webPage;
58
};
59
60
} // namespace WebKit
61
62
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in -35 lines
Lines 1-35 a/Source/WebKit/WebProcess/CredentialManagement/WebCredentialsMessenger.messages.in_sec1
1
# Copyright (C) 2018 Apple Inc. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
5
# are met:
6
# 1. Redistributions of source code must retain the above copyright
7
#    notice, this list of conditions and the following disclaimer.
8
# 2. Redistributions in binary form must reproduce the above copyright
9
#    notice, this list of conditions and the following disclaimer in the
10
#    documentation and/or other materials provided with the distribution.
11
#
12
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22
# THE POSSIBILITY OF SUCH DAMAGE.
23
#/
24
25
#if ENABLE(WEB_AUTHN)
26
27
messages -> WebCredentialsMessenger {
28
29
    ExceptionReply(uint64_t messageId, struct WebCore::ExceptionData exception);
30
    MakeCredentialReply(uint64_t messageId, Vector<uint8_t> credentialId, Vector<uint8_t> attestationObject);
31
    GetAssertionReply(uint64_t messageId, Vector<uint8_t> credentialId, Vector<uint8_t> authenticatorData, Vector<uint8_t> signature, Vector<uint8_t> userHandle);
32
    IsUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result);
33
}
34
35
#endif
- a/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp +75 lines
Line 0 a/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "WebAuthenticatorCoordinator.h"
28
29
#if ENABLE(WEB_AUTHN)
30
31
#include "WebAuthenticatorCoordinatorMessages.h"
32
#include "WebAuthenticatorCoordinatorProxyMessages.h"
33
#include "WebPage.h"
34
#include "WebProcess.h"
35
#include <WebCore/PublicKeyCredentialCreationOptions.h>
36
#include <WebCore/PublicKeyCredentialRequestOptions.h>
37
38
namespace WebKit {
39
40
WebAuthenticatorCoordinator::WebAuthenticatorCoordinator(WebPage& webPage)
41
    : m_webPage(webPage)
42
{
43
    WebProcess::singleton().addMessageReceiver(Messages::WebAuthenticatorCoordinator::messageReceiverName(), m_webPage.pageID(), *this);
44
}
45
46
WebAuthenticatorCoordinator::~WebAuthenticatorCoordinator()
47
{
48
    WebProcess::singleton().removeMessageReceiver(*this);
49
}
50
51
void WebAuthenticatorCoordinator::makeCredential(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialCreationOptions& options, WebCore::RequestCompletionHandler&& handler)
52
{
53
    if (!setRequestCompletionHandler(WTFMove(handler)))
54
        return;
55
56
    m_webPage.send(Messages::WebAuthenticatorCoordinatorProxy::MakeCredential(hash, options));
57
}
58
59
void WebAuthenticatorCoordinator::getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions& options, WebCore::RequestCompletionHandler&& handler)
60
{
61
    if (!setRequestCompletionHandler(WTFMove(handler)))
62
        return;
63
64
    m_webPage.send(Messages::WebAuthenticatorCoordinatorProxy::GetAssertion(hash, options));
65
}
66
67
void WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&& handler)
68
{
69
    auto messageId = addQueryCompletionHandler(WTFMove(handler));
70
    m_webPage.send(Messages::WebAuthenticatorCoordinatorProxy::IsUserVerifyingPlatformAuthenticatorAvailable(messageId));
71
}
72
73
} // namespace WebKit
74
75
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h +57 lines
Line 0 a/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEB_AUTHN)
29
30
#include "MessageReceiver.h"
31
#include <WebCore/AuthenticatorCoordinatorClient.h>
32
33
namespace WebKit {
34
35
class WebPage;
36
37
class WebAuthenticatorCoordinator final : public WebCore::AuthenticatorCoordinatorClient, private IPC::MessageReceiver {
38
public:
39
    explicit WebAuthenticatorCoordinator(WebPage&);
40
    ~WebAuthenticatorCoordinator();
41
42
private:
43
    // WebCore::AuthenticatorCoordinatorClient
44
    // Senders.
45
    void makeCredential(const Vector<uint8_t>&, const WebCore::PublicKeyCredentialCreationOptions&, WebCore::RequestCompletionHandler&&) final;
46
    void getAssertion(const Vector<uint8_t>& hash, const WebCore::PublicKeyCredentialRequestOptions&, WebCore::RequestCompletionHandler&&) final;
47
    void isUserVerifyingPlatformAuthenticatorAvailable(WebCore::QueryCompletionHandler&&) final;
48
49
    // IPC::MessageReceiver.
50
    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
51
52
    WebPage& m_webPage;
53
};
54
55
} // namespace WebKit
56
57
#endif // ENABLE(WEB_AUTHN)
- a/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in +33 lines
Line 0 a/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.messages.in_sec1
1
# Copyright (C) 2018 Apple Inc. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
5
# are met:
6
# 1. Redistributions of source code must retain the above copyright
7
#    notice, this list of conditions and the following disclaimer.
8
# 2. Redistributions in binary form must reproduce the above copyright
9
#    notice, this list of conditions and the following disclaimer in the
10
#    documentation and/or other materials provided with the distribution.
11
#
12
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22
# THE POSSIBILITY OF SUCH DAMAGE.
23
#/
24
25
#if ENABLE(WEB_AUTHN)
26
27
messages -> WebAuthenticatorCoordinator {
28
29
    RequestReply(struct WebCore::PublicKeyCredentialData data, struct WebCore::ExceptionData exception);
30
    IsUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool result);
31
}
32
33
#endif
- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp -9 / +6 lines
Lines 278-285 a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec1
278
#endif
278
#endif
279
279
280
#if ENABLE(WEB_AUTHN)
280
#if ENABLE(WEB_AUTHN)
281
#include "WebCredentialsMessenger.h"
281
#include "WebAuthenticatorCoordinator.h"
282
#include <WebCore/AuthenticatorManager.h>
282
#include <WebCore/AuthenticatorCoordinator.h>
283
#endif
283
#endif
284
284
285
namespace WebKit {
285
namespace WebKit {
Lines 392-400 WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters) a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec2
392
    , m_userInterfaceLayoutDirection(parameters.userInterfaceLayoutDirection)
392
    , m_userInterfaceLayoutDirection(parameters.userInterfaceLayoutDirection)
393
    , m_overrideContentSecurityPolicy { parameters.overrideContentSecurityPolicy }
393
    , m_overrideContentSecurityPolicy { parameters.overrideContentSecurityPolicy }
394
    , m_cpuLimit(parameters.cpuLimit)
394
    , m_cpuLimit(parameters.cpuLimit)
395
#if ENABLE(WEB_AUTHN)
396
    , m_credentialsMessenger(std::make_unique<WebCredentialsMessenger>(*this))
397
#endif
398
{
395
{
399
    ASSERT(m_pageID);
396
    ASSERT(m_pageID);
400
397
Lines 448-453 WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters) a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec3
448
    pageConfiguration.paymentCoordinatorClient = new WebPaymentCoordinator(*this);
445
    pageConfiguration.paymentCoordinatorClient = new WebPaymentCoordinator(*this);
449
#endif
446
#endif
450
447
448
#if ENABLE(WEB_AUTHN)
449
    pageConfiguration.authenticatorCoordinatorClient = std::make_unique<WebAuthenticatorCoordinator>(*this);
450
#endif
451
451
#if ENABLE(APPLICATION_MANIFEST)
452
#if ENABLE(APPLICATION_MANIFEST)
452
    pageConfiguration.applicationManifest = parameters.applicationManifest;
453
    pageConfiguration.applicationManifest = parameters.applicationManifest;
453
#endif
454
#endif
Lines 605-614 WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters) a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec4
605
#endif
606
#endif
606
#endif
607
#endif
607
608
608
#if ENABLE(WEB_AUTHN)
609
    WebCore::AuthenticatorManager::singleton().setMessenger(*m_credentialsMessenger);
610
#endif
611
612
    for (auto iterator : parameters.urlSchemeHandlers)
609
    for (auto iterator : parameters.urlSchemeHandlers)
613
        registerURLSchemeHandler(iterator.value, iterator.key);
610
        registerURLSchemeHandler(iterator.value, iterator.key);
614
611
- a/Source/WebKit/WebProcess/WebPage/WebPage.h -5 lines
Lines 226-232 class WebUserContentController; a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec1
226
class VideoFullscreenManager;
226
class VideoFullscreenManager;
227
class WebWheelEvent;
227
class WebWheelEvent;
228
class WebTouchEvent;
228
class WebTouchEvent;
229
class WebCredentialsMessenger;
230
class RemoteLayerTreeTransaction;
229
class RemoteLayerTreeTransaction;
231
230
232
enum class DeviceAccessState;
231
enum class DeviceAccessState;
Lines 1735-1744 private: a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec2
1735
    HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap;
1734
    HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap;
1736
#endif
1735
#endif
1737
1736
1738
#if ENABLE(WEB_AUTHN)
1739
    std::unique_ptr<WebCredentialsMessenger> m_credentialsMessenger;
1740
#endif
1741
1742
    bool m_isSuspended { false };
1737
    bool m_isSuspended { false };
1743
};
1738
};
1744
1739
- a/Tools/ChangeLog +11 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2018-09-08  Jiewen Tan  <jiewen_tan@apple.com>
2
3
        [WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
4
        https://bugs.webkit.org/show_bug.cgi?id=189277
5
        <rdar://problem/44115936>
6
7
        Reviewed by Chris Dumez.
8
9
        * TestWebKitAPI/Tests/ios/LocalAuthenticator.mm:
10
        (TestWebKitAPI::TEST):
11
1
2018-09-02  Darin Adler  <darin@apple.com>
12
2018-09-02  Darin Adler  <darin@apple.com>
2
13
3
        [Cocoa] Turn on ARC for WebKitTestRunner
14
        [Cocoa] Turn on ARC for WebKitTestRunner
- a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm -249 / +277 lines
Lines 38-43 a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec1
38
#import <WebCore/ExceptionData.h>
38
#import <WebCore/ExceptionData.h>
39
#import <WebCore/LocalAuthenticator.h>
39
#import <WebCore/LocalAuthenticator.h>
40
#import <WebCore/PublicKeyCredentialCreationOptions.h>
40
#import <WebCore/PublicKeyCredentialCreationOptions.h>
41
#import <WebCore/PublicKeyCredentialData.h>
41
#import <WebCore/PublicKeyCredentialRequestOptions.h>
42
#import <WebCore/PublicKeyCredentialRequestOptions.h>
42
#import <wtf/BlockPtr.h>
43
#import <wtf/BlockPtr.h>
43
#import <wtf/text/Base64.h>
44
#import <wtf/text/Base64.h>
Lines 266-281 TEST(LocalAuthenticator, MakeCredentialNotSupportedPubKeyCredParams) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec2
266
267
267
    bool done = false;
268
    bool done = false;
268
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
269
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
269
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
270
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
270
        EXPECT_FALSE(true);
271
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
271
        done = true;
272
            EXPECT_FALSE(true);
272
    };
273
            done = true;
273
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
274
        }, [&](const  WebCore::ExceptionData& exception) {
274
        EXPECT_EQ(WebCore::NotSupportedError, exception.code);
275
            EXPECT_EQ(WebCore::NotSupportedError, exception.code);
275
        EXPECT_STREQ("The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters.", exception.message.ascii().data());
276
            EXPECT_STREQ("The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters.", exception.message.ascii().data());
276
        done = true;
277
            done = true;
278
        });
277
    };
279
    };
278
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
280
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
279
281
280
    TestWebKitAPI::Util::run(&done);
282
    TestWebKitAPI::Util::run(&done);
281
}
283
}
Lines 294-311 TEST(LocalAuthenticator, MakeCredentialExcludeCredentialsMatch) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec3
294
296
295
    bool done = false;
297
    bool done = false;
296
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
298
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
297
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
299
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
298
        EXPECT_FALSE(true);
300
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
299
        cleanUpKeychain();
301
            EXPECT_FALSE(true);
300
        done = true;
302
            cleanUpKeychain();
301
    };
303
            done = true;
302
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
304
        }, [&](const  WebCore::ExceptionData& exception) {
303
        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
305
            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
304
        EXPECT_STREQ("At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.", exception.message.ascii().data());
306
            EXPECT_STREQ("At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.", exception.message.ascii().data());
305
        cleanUpKeychain();
307
            cleanUpKeychain();
306
        done = true;
308
            done = true;
309
        });
307
    };
310
    };
308
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
311
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
309
312
310
    TestWebKitAPI::Util::run(&done);
313
    TestWebKitAPI::Util::run(&done);
311
}
314
}
Lines 319-334 TEST(LocalAuthenticator, MakeCredentialBiometricsNotEnrolled) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec4
319
322
320
    bool done = false;
323
    bool done = false;
321
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
324
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
322
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
325
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
323
        EXPECT_FALSE(true);
326
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
324
        done = true;
327
            EXPECT_FALSE(true);
325
    };
328
            done = true;
326
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
329
        }, [&](const  WebCore::ExceptionData& exception) {
327
        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
330
            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
328
        EXPECT_STREQ("No avaliable authenticators.", exception.message.ascii().data());
331
            EXPECT_STREQ("No avaliable authenticators.", exception.message.ascii().data());
329
        done = true;
332
            done = true;
333
        });
330
    };
334
    };
331
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
335
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
332
336
333
    TestWebKitAPI::Util::run(&done);
337
    TestWebKitAPI::Util::run(&done);
334
}
338
}
Lines 343-358 TEST(LocalAuthenticator, MakeCredentialBiometricsNotAuthenticated) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec5
343
347
344
    bool done = false;
348
    bool done = false;
345
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
349
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
346
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
350
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
347
        EXPECT_FALSE(true);
351
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
348
        done = true;
352
            EXPECT_FALSE(true);
349
    };
353
            done = true;
350
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
354
        }, [&](const  WebCore::ExceptionData& exception) {
351
        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
355
            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
352
        EXPECT_STREQ("Couldn't get user consent.", exception.message.ascii().data());
356
            EXPECT_STREQ("Couldn't get user consent.", exception.message.ascii().data());
353
        done = true;
357
            done = true;
358
        });
354
    };
359
    };
355
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
360
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
356
361
357
    TestWebKitAPI::Util::run(&done);
362
    TestWebKitAPI::Util::run(&done);
358
}
363
}
Lines 368-383 TEST(LocalAuthenticator, MakeCredentialNotAttestated) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec6
368
    bool done = false;
373
    bool done = false;
369
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
374
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
370
    authenticator->setFailureFlag();
375
    authenticator->setFailureFlag();
371
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
376
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
372
        EXPECT_FALSE(true);
377
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
373
        done = true;
378
            EXPECT_FALSE(true);
374
    };
379
            done = true;
375
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
380
        }, [&](const  WebCore::ExceptionData& exception) {
376
        EXPECT_EQ(WebCore::UnknownError, exception.code);
381
            EXPECT_EQ(WebCore::UnknownError, exception.code);
377
        EXPECT_STREQ("Unknown internal error.", exception.message.ascii().data());
382
            EXPECT_STREQ("Unknown internal error.", exception.message.ascii().data());
378
        done = true;
383
            done = true;
384
        });
379
    };
385
    };
380
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
386
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
381
387
382
    TestWebKitAPI::Util::run(&done);
388
    TestWebKitAPI::Util::run(&done);
383
}
389
}
Lines 399-420 TEST(LocalAuthenticator, MakeCredentialDeleteOlderCredenital) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec7
399
    bool done = false;
405
    bool done = false;
400
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
406
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
401
    authenticator->setFailureFlag();
407
    authenticator->setFailureFlag();
402
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&) {
408
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
403
        EXPECT_FALSE(true);
409
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
404
        done = true;
410
            EXPECT_FALSE(true);
405
    };
411
            done = true;
406
    auto exceptionCallback = [&done] (const WebCore::ExceptionData&) mutable {
412
        }, [&](const  WebCore::ExceptionData& exception) {
407
        NSDictionary *query = @{
413
            NSDictionary *query = @{
408
            (id)kSecClass: (id)kSecClassKey,
414
                (id)kSecClass: (id)kSecClassKey,
409
            (id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
415
                (id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
410
            (id)kSecAttrLabel: testRpId,
416
                (id)kSecAttrLabel: testRpId,
411
            (id)kSecAttrApplicationTag: [NSData dataWithBytes:testUserhandle length:sizeof(testUserhandle)],
417
                (id)kSecAttrApplicationTag: [NSData dataWithBytes:testUserhandle length:sizeof(testUserhandle)],
412
        };
418
            };
413
        OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
419
            OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
414
        EXPECT_EQ(errSecItemNotFound, status);
420
            EXPECT_EQ(errSecItemNotFound, status);
415
        done = true;
421
            done = true;
422
        });
416
    };
423
    };
417
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
424
    authenticator->makeCredential({ }, creationOptions, WTFMove(callback));
418
425
419
    TestWebKitAPI::Util::run(&done);
426
    TestWebKitAPI::Util::run(&done);
420
}
427
}
Lines 432-534 TEST(LocalAuthenticator, MakeCredentialPassedWithSelfAttestation) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec8
432
439
433
    bool done = false;
440
    bool done = false;
434
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
441
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
435
    auto callback = [&done] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObjet) {
442
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
436
        // Check Keychain
443
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
437
        NSDictionary *query = @{
444
            Vector<uint8_t> credentialId;
438
            (id)kSecClass: (id)kSecClassKey,
445
            credentialId.append(reinterpret_cast<uint8_t*>(data.rawId->data()), data.rawId->byteLength());
439
            (id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
446
            Vector<uint8_t> attestationObject;
440
            (id)kSecAttrLabel: testRpId,
447
            attestationObject.append(reinterpret_cast<uint8_t*>(data.attestationObject->data()), data.attestationObject->byteLength());
441
            (id)kSecAttrApplicationLabel: adoptNS([[NSData alloc] initWithBase64EncodedString:testCredentialIdBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get(),
448
442
            (id)kSecAttrApplicationTag: [NSData dataWithBytes:testUserhandle length:sizeof(testUserhandle)],
449
            // Check Keychain
443
        };
450
            NSDictionary *query = @{
444
        OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
451
                (id)kSecClass: (id)kSecClassKey,
445
        EXPECT_FALSE(status);
452
                (id)kSecAttrKeyClass: (id)kSecAttrKeyClassPrivate,
446
453
                (id)kSecAttrLabel: testRpId,
447
        // Check Credential ID
454
                (id)kSecAttrApplicationLabel: adoptNS([[NSData alloc] initWithBase64EncodedString:testCredentialIdBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get(),
448
        EXPECT_TRUE(WTF::base64Encode(credentialId.data(), credentialId.size()) == testCredentialIdBase64);
455
                (id)kSecAttrApplicationTag: [NSData dataWithBytes:testUserhandle length:sizeof(testUserhandle)],
449
456
            };
450
        // Check Attestation Object
457
            OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
451
        auto attestationObjectMap = cbor::CBORReader::read(attestationObjet);
458
            EXPECT_FALSE(status);
452
        ASSERT_TRUE(!!attestationObjectMap);
459
453
460
            // Check Credential ID
454
        // Check Authenticator Data.
461
            EXPECT_TRUE(WTF::base64Encode(credentialId.data(), credentialId.size()) == testCredentialIdBase64);
455
        auto& authData = attestationObjectMap->getMap().find(cbor::CBORValue("authData"))->second.getByteString();
462
456
        size_t pos = 0;
463
            // Check Attestation Object
457
        uint8_t expectedRpIdHash[] = {
464
            auto attestationObjectMap = cbor::CBORReader::read(attestationObject);
458
            0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e, 0x8c, 0x68,
465
            ASSERT_TRUE(!!attestationObjectMap);
459
            0x74, 0x34, 0x17, 0x0f, 0x64, 0x76, 0x60, 0x5b,
466
460
            0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86, 0x32, 0xc7,
467
            // Check Authenticator Data.
461
            0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d, 0x97, 0x63
468
            auto& authData = attestationObjectMap->getMap().find(cbor::CBORValue("authData"))->second.getByteString();
462
        };
469
            size_t pos = 0;
463
        EXPECT_FALSE(memcmp(authData.data() + pos, expectedRpIdHash, sizeof(expectedRpIdHash)));
470
            uint8_t expectedRpIdHash[] = {
464
        pos += sizeof(expectedRpIdHash);
471
                0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e, 0x8c, 0x68,
465
472
                0x74, 0x34, 0x17, 0x0f, 0x64, 0x76, 0x60, 0x5b,
466
        // FLAGS
473
                0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86, 0x32, 0xc7,
467
        EXPECT_EQ(69, authData[pos]);
474
                0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d, 0x97, 0x63
468
        pos++;
475
            };
469
476
            EXPECT_FALSE(memcmp(authData.data() + pos, expectedRpIdHash, sizeof(expectedRpIdHash)));
470
        uint32_t counter = -1;
477
            pos += sizeof(expectedRpIdHash);
471
        memcpy(&counter, authData.data() + pos, sizeof(uint32_t));
478
472
        EXPECT_EQ(0u, counter);
479
            // FLAGS
473
        pos += sizeof(uint32_t);
480
            EXPECT_EQ(69, authData[pos]);
474
481
            pos++;
475
        uint8_t expectedAAGUID[] = {
482
476
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
483
            uint32_t counter = -1;
477
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
484
            memcpy(&counter, authData.data() + pos, sizeof(uint32_t));
478
        };
485
            EXPECT_EQ(0u, counter);
479
        EXPECT_FALSE(memcmp(authData.data() + pos, expectedAAGUID, sizeof(expectedAAGUID)));
486
            pos += sizeof(uint32_t);
480
        pos += sizeof(expectedAAGUID);
487
481
488
            uint8_t expectedAAGUID[] = {
482
        uint16_t l = -1;
489
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
483
        memcpy(&l, authData.data() + pos, sizeof(uint16_t));
490
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
484
        EXPECT_EQ(20u, l);
491
            };
485
        pos += sizeof(uint16_t);
492
            EXPECT_FALSE(memcmp(authData.data() + pos, expectedAAGUID, sizeof(expectedAAGUID)));
486
493
            pos += sizeof(expectedAAGUID);
487
        EXPECT_FALSE(memcmp(authData.data() + pos, credentialId.data(), l));
494
488
        pos += l;
495
            uint16_t l = -1;
489
496
            memcpy(&l, authData.data() + pos, sizeof(uint16_t));
490
        // Credential Public Key
497
            EXPECT_EQ(20u, l);
491
        // FIXME(183536): The CBOR reader doesn't support negative integer as map key. Thus we couldn't utilzie it.
498
            pos += sizeof(uint16_t);
492
        EXPECT_STREQ("pQECAyYgASFYIDj/zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF/Qm1749IlggVBJPgqUIwfhWHJ91nb7UPH76c0+WFOzZKslPyyFse4g=", WTF::base64Encode(authData.data() + pos, authData.size() - pos).ascii().data());
499
493
500
            EXPECT_FALSE(memcmp(authData.data() + pos, credentialId.data(), l));
494
        // Check Self Attestation
501
            pos += l;
495
        EXPECT_STREQ("Apple", attestationObjectMap->getMap().find(cbor::CBORValue("fmt"))->second.getString().ascii().data());
502
496
503
            // Credential Public Key
497
        auto& attStmt = attestationObjectMap->getMap().find(cbor::CBORValue("attStmt"))->second.getMap();
504
            // FIXME(183536): The CBOR reader doesn't support negative integer as map key. Thus we couldn't utilzie it.
498
        EXPECT_EQ(COSE::ES256, attStmt.find(cbor::CBORValue("alg"))->second.getNegative());
505
            EXPECT_STREQ("pQECAyYgASFYIDj/zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF/Qm1749IlggVBJPgqUIwfhWHJ91nb7UPH76c0+WFOzZKslPyyFse4g=", WTF::base64Encode(authData.data() + pos, authData.size() - pos).ascii().data());
499
506
500
        auto& sig = attStmt.find(cbor::CBORValue("sig"))->second.getByteString();
507
            // Check Self Attestation
501
        auto privateKey = getTestKey();
508
            EXPECT_STREQ("Apple", attestationObjectMap->getMap().find(cbor::CBORValue("fmt"))->second.getString().ascii().data());
502
        EXPECT_TRUE(SecKeyVerifySignature(SecKeyCopyPublicKey(privateKey.get()), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:authData.data() length:authData.size()], (__bridge CFDataRef)[NSData dataWithBytes:sig.data() length:sig.size()], NULL));
509
503
510
            auto& attStmt = attestationObjectMap->getMap().find(cbor::CBORValue("attStmt"))->second.getMap();
504
        // Check certificates
511
            EXPECT_EQ(COSE::ES256, attStmt.find(cbor::CBORValue("alg"))->second.getNegative());
505
        auto& x5c = attStmt.find(cbor::CBORValue("x5c"))->second.getArray();
512
506
        auto& attestationCertificateData = x5c[0].getByteString();
513
            auto& sig = attStmt.find(cbor::CBORValue("sig"))->second.getByteString();
507
        auto attestationCertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)[NSData dataWithBytes:attestationCertificateData.data() length:attestationCertificateData.size()]));
514
            auto privateKey = getTestKey();
508
        CFStringRef commonName = nullptr;
515
            EXPECT_TRUE(SecKeyVerifySignature(SecKeyCopyPublicKey(privateKey.get()), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:authData.data() length:authData.size()], (__bridge CFDataRef)[NSData dataWithBytes:sig.data() length:sig.size()], NULL));
509
        status = SecCertificateCopyCommonName(attestationCertificate.get(), &commonName);
516
510
        auto retainCommonName = adoptCF(commonName);
517
            // Check certificates
511
        ASSERT(!status);
518
            auto& x5c = attStmt.find(cbor::CBORValue("x5c"))->second.getArray();
512
        EXPECT_STREQ("00008010-000A49A230A0213A", [(NSString *)commonName cStringUsingEncoding: NSASCIIStringEncoding]);
519
            auto& attestationCertificateData = x5c[0].getByteString();
513
520
            auto attestationCertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)[NSData dataWithBytes:attestationCertificateData.data() length:attestationCertificateData.size()]));
514
        auto& attestationIssuingCACertificateData = x5c[1].getByteString();
521
            CFStringRef commonName = nullptr;
515
        auto attestationIssuingCACertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)[NSData dataWithBytes:attestationIssuingCACertificateData.data() length:attestationIssuingCACertificateData.size()]));
522
            status = SecCertificateCopyCommonName(attestationCertificate.get(), &commonName);
516
        commonName = nullptr;
523
            auto retainCommonName = adoptCF(commonName);
517
        status = SecCertificateCopyCommonName(attestationIssuingCACertificate.get(), &commonName);
524
            ASSERT(!status);
518
        retainCommonName = adoptCF(commonName);
525
            EXPECT_STREQ("00008010-000A49A230A0213A", [(NSString *)commonName cStringUsingEncoding: NSASCIIStringEncoding]);
519
        ASSERT(!status);
526
520
        EXPECT_STREQ("Basic Attestation User Sub CA1", [(NSString *)commonName cStringUsingEncoding: NSASCIIStringEncoding]);
527
            auto& attestationIssuingCACertificateData = x5c[1].getByteString();
521
528
            auto attestationIssuingCACertificate = adoptCF(SecCertificateCreateWithData(NULL, (__bridge CFDataRef)[NSData dataWithBytes:attestationIssuingCACertificateData.data() length:attestationIssuingCACertificateData.size()]));
522
        cleanUpKeychain();
529
            commonName = nullptr;
523
        done = true;
530
            status = SecCertificateCopyCommonName(attestationIssuingCACertificate.get(), &commonName);
524
    };
531
            retainCommonName = adoptCF(commonName);
525
    auto exceptionCallback = [&done] (const WebCore::ExceptionData&) mutable {
532
            ASSERT(!status);
526
        EXPECT_FALSE(true);
533
            EXPECT_STREQ("Basic Attestation User Sub CA1", [(NSString *)commonName cStringUsingEncoding: NSASCIIStringEncoding]);
527
        cleanUpKeychain();
534
528
        done = true;
535
            cleanUpKeychain();
536
            done = true;
537
        }, [&](const  WebCore::ExceptionData& exception) {
538
            EXPECT_FALSE(true);
539
            cleanUpKeychain();
540
            done = true;
541
        });
529
    };
542
    };
530
    Vector<uint8_t> hash(32);
543
    Vector<uint8_t> hash(32);
531
    authenticator->makeCredential(hash, creationOptions, WTFMove(callback), WTFMove(exceptionCallback));
544
    authenticator->makeCredential(hash, creationOptions, WTFMove(callback));
532
545
533
    TestWebKitAPI::Util::run(&done);
546
    TestWebKitAPI::Util::run(&done);
534
}
547
}
Lines 544-559 TEST(LocalAuthenticator, GetAssertionAllowCredentialsMismatch1) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec9
544
557
545
    bool done = false;
558
    bool done = false;
546
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
559
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
547
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
560
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
548
        EXPECT_FALSE(true);
561
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
549
        done = true;
562
            EXPECT_FALSE(true);
550
    };
563
            done = true;
551
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
564
        }, [&](const  WebCore::ExceptionData& exception) {
552
        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
565
            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
553
        EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
566
            EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
554
        done = true;
567
            done = true;
568
        });
555
    };
569
    };
556
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
570
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
557
571
558
    TestWebKitAPI::Util::run(&done);
572
    TestWebKitAPI::Util::run(&done);
559
}
573
}
Lines 566-581 TEST(LocalAuthenticator, GetAssertionAllowCredentialsMismatch2) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec10
566
580
567
    bool done = false;
581
    bool done = false;
568
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
582
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
569
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
583
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
570
        EXPECT_FALSE(true);
584
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
571
        done = true;
585
            EXPECT_FALSE(true);
572
    };
586
            done = true;
573
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
587
        }, [&](const  WebCore::ExceptionData& exception) {
574
        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
588
            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
575
        EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
589
            EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
576
        done = true;
590
            done = true;
591
        });
577
    };
592
    };
578
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
593
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
579
594
580
    TestWebKitAPI::Util::run(&done);
595
    TestWebKitAPI::Util::run(&done);
581
}
596
}
Lines 595-612 TEST(LocalAuthenticator, GetAssertionAllowCredentialsMismatch3) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec11
595
610
596
    bool done = false;
611
    bool done = false;
597
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
612
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
598
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
613
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
599
        EXPECT_FALSE(true);
614
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
600
        cleanUpKeychain();
615
            EXPECT_FALSE(true);
601
        done = true;
616
            cleanUpKeychain();
602
    };
617
            done = true;
603
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
618
        }, [&](const  WebCore::ExceptionData& exception) {
604
        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
619
            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
605
        EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
620
            EXPECT_STREQ("No matched credentials are found in the platform attached authenticator.", exception.message.ascii().data());
606
        cleanUpKeychain();
621
            cleanUpKeychain();
607
        done = true;
622
            done = true;
623
        });
608
    };
624
    };
609
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
625
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
610
626
611
    TestWebKitAPI::Util::run(&done);
627
    TestWebKitAPI::Util::run(&done);
612
}
628
}
Lines 622-639 TEST(LocalAuthenticator, GetAssertionBiometricsNotEnrolled) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec12
622
638
623
    bool done = false;
639
    bool done = false;
624
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
640
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
625
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
641
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
626
        EXPECT_FALSE(true);
642
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
627
        cleanUpKeychain();
643
            EXPECT_FALSE(true);
628
        done = true;
644
            cleanUpKeychain();
629
    };
645
            done = true;
630
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
646
        }, [&](const  WebCore::ExceptionData& exception) {
631
        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
647
            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
632
        EXPECT_STREQ("No avaliable authenticators.", exception.message.ascii().data());
648
            EXPECT_STREQ("No avaliable authenticators.", exception.message.ascii().data());
633
        cleanUpKeychain();
649
            cleanUpKeychain();
634
        done = true;
650
            done = true;
651
        });
635
    };
652
    };
636
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
653
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
637
654
638
    TestWebKitAPI::Util::run(&done);
655
    TestWebKitAPI::Util::run(&done);
639
}
656
}
Lines 650-667 TEST(LocalAuthenticator, GetAssertionBiometricsNotAuthenticated) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec13
650
667
651
    bool done = false;
668
    bool done = false;
652
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
669
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
653
    auto callback = [&done] (const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&, const Vector<uint8_t>&) {
670
    auto callback = [&done] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
654
        EXPECT_FALSE(true);
671
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData&) {
655
        cleanUpKeychain();
672
            EXPECT_FALSE(true);
656
        done = true;
673
            cleanUpKeychain();
657
    };
674
            done = true;
658
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
675
        }, [&](const  WebCore::ExceptionData& exception) {
659
        EXPECT_EQ(WebCore::NotAllowedError, exception.code);
676
            EXPECT_EQ(WebCore::NotAllowedError, exception.code);
660
        EXPECT_STREQ("Couldn't get user consent.", exception.message.ascii().data());
677
            EXPECT_STREQ("Couldn't get user consent.", exception.message.ascii().data());
661
        cleanUpKeychain();
678
            cleanUpKeychain();
662
        done = true;
679
            done = true;
680
        });
663
    };
681
    };
664
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
682
    authenticator->getAssertion({ }, requestOptions, WTFMove(callback));
665
683
666
    TestWebKitAPI::Util::run(&done);
684
    TestWebKitAPI::Util::run(&done);
667
}
685
}
Lines 680-727 TEST(LocalAuthenticator, GetAssertionPassed) a/Tools/TestWebKitAPI/Tests/ios/LocalAuthenticator.mm_sec14
680
698
681
    bool done = false;
699
    bool done = false;
682
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
700
    std::unique_ptr<TestLocalAuthenticator> authenticator = std::make_unique<TestLocalAuthenticator>();
683
    auto callback = [&done, hash] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userhandle) {
701
    auto callback = [&done, hash] (Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>&& result) {
684
        // Check Credential ID
702
        WTF::switchOn(result, [&](const WebCore::PublicKeyCredentialData& data) {
685
        EXPECT_TRUE(WTF::base64Encode(credentialId.data(), credentialId.size()) == testCredentialIdBase64);
703
            Vector<uint8_t> credentialId;
686
704
            credentialId.append(reinterpret_cast<uint8_t*>(data.rawId->data()), data.rawId->byteLength());
687
        // Check Authenticator Data.
705
            Vector<uint8_t> authData;
688
        size_t pos = 0;
706
            authData.append(reinterpret_cast<uint8_t*>(data.authenticatorData->data()), data.authenticatorData->byteLength());
689
        uint8_t expectedRpIdHash[] = {
707
            Vector<uint8_t> signature;
690
            0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e, 0x8c, 0x68,
708
            signature.append(reinterpret_cast<uint8_t*>(data.signature->data()), data.signature->byteLength());
691
            0x74, 0x34, 0x17, 0x0f, 0x64, 0x76, 0x60, 0x5b,
709
            Vector<uint8_t> userhandle;
692
            0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86, 0x32, 0xc7,
710
            userhandle.append(reinterpret_cast<uint8_t*>(data.userHandle->data()), data.userHandle->byteLength());
693
            0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d, 0x97, 0x63
711
694
        };
712
            // Check Credential ID
695
        EXPECT_FALSE(memcmp(authData.data() + pos, expectedRpIdHash, sizeof(expectedRpIdHash)));
713
            EXPECT_TRUE(WTF::base64Encode(credentialId.data(), credentialId.size()) == testCredentialIdBase64);
696
        pos += sizeof(expectedRpIdHash);
714
697
715
            // Check Authenticator Data.
698
        // FLAGS
716
            size_t pos = 0;
699
        EXPECT_EQ(5, authData[pos]);
717
            uint8_t expectedRpIdHash[] = {
700
        pos++;
718
                0x49, 0x96, 0x0d, 0xe5, 0x88, 0x0e, 0x8c, 0x68,
701
719
                0x74, 0x34, 0x17, 0x0f, 0x64, 0x76, 0x60, 0x5b,
702
        uint32_t counter = -1;
720
                0x8f, 0xe4, 0xae, 0xb9, 0xa2, 0x86, 0x32, 0xc7,
703
        memcpy(&counter, authData.data() + pos, sizeof(uint32_t));
721
                0x99, 0x5c, 0xf3, 0xba, 0x83, 0x1d, 0x97, 0x63
704
        EXPECT_EQ(0u, counter);
722
            };
705
723
            EXPECT_FALSE(memcmp(authData.data() + pos, expectedRpIdHash, sizeof(expectedRpIdHash)));
706
        // Check signature
724
            pos += sizeof(expectedRpIdHash);
707
        auto privateKey = getTestKey();
725
708
        Vector<uint8_t> dataToSign(authData);
726
            // FLAGS
709
        dataToSign.appendVector(hash);
727
            EXPECT_EQ(5, authData[pos]);
710
        EXPECT_TRUE(SecKeyVerifySignature(SecKeyCopyPublicKey(privateKey.get()), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:dataToSign.data() length:dataToSign.size()], (__bridge CFDataRef)[NSData dataWithBytes:signature.data() length:signature.size()], NULL));
728
            pos++;
711
729
712
        // Check User Handle
730
            uint32_t counter = -1;
713
        EXPECT_EQ(userhandle.size(), sizeof(testUserhandle));
731
            memcpy(&counter, authData.data() + pos, sizeof(uint32_t));
714
        EXPECT_FALSE(memcmp(userhandle.data(), testUserhandle, sizeof(testUserhandle)));
732
            EXPECT_EQ(0u, counter);
715
733
716
        cleanUpKeychain();
734
            // Check signature
717
        done = true;
735
            auto privateKey = getTestKey();
718
    };
736
            Vector<uint8_t> dataToSign(authData);
719
    auto exceptionCallback = [&done] (const WebCore::ExceptionData& exception) mutable {
737
            dataToSign.appendVector(hash);
720
        EXPECT_FALSE(true);
738
            EXPECT_TRUE(SecKeyVerifySignature(SecKeyCopyPublicKey(privateKey.get()), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:dataToSign.data() length:dataToSign.size()], (__bridge CFDataRef)[NSData dataWithBytes:signature.data() length:signature.size()], NULL));
721
        cleanUpKeychain();
739
722
        done = true;
740
            // Check User Handle
741
            EXPECT_EQ(userhandle.size(), sizeof(testUserhandle));
742
            EXPECT_FALSE(memcmp(userhandle.data(), testUserhandle, sizeof(testUserhandle)));
743
744
            cleanUpKeychain();
745
            done = true;
746
        }, [&](const  WebCore::ExceptionData& exception) {
747
            EXPECT_FALSE(true);
748
            cleanUpKeychain();
749
            done = true;
750
        });
723
    };
751
    };
724
    authenticator->getAssertion(hash, requestOptions, WTFMove(callback), WTFMove(exceptionCallback));
752
    authenticator->getAssertion(hash, requestOptions, WTFMove(callback));
725
753
726
    TestWebKitAPI::Util::run(&done);
754
    TestWebKitAPI::Util::run(&done);
727
}
755
}
- a/LayoutTests/ChangeLog +16 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2018-09-08  Jiewen Tan  <jiewen_tan@apple.com>
2
3
        [WebAuthN] Polish AuthenticatorManager and rename it to AuthenticatorCoordinator
4
        https://bugs.webkit.org/show_bug.cgi?id=189277
5
        <rdar://problem/44115936>
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/public-key-is-user-verifying-platform-authenticator-available.html:
16
1
2018-09-08  Andy Estes  <aestes@apple.com>
17
2018-09-08  Andy Estes  <aestes@apple.com>
2
18
3
        [Apple Pay] Dispatch a paymentmethodchange event when the payment method changes
19
        [Apple Pay] Dispatch a paymentmethodchange event when the payment method changes
- a/LayoutTests/http/wpt/credential-management/credentialscontainer-store-basics.https.html -1 / +1 lines
Lines 42-48 a/LayoutTests/http/wpt/credential-management/credentialscontainer-store-basics.https.html_sec1
42
            }
42
            }
43
        };
43
        };
44
        // A mock attestation object
44
        // A mock attestation object
45
        internals.mockCredentialsMessenger.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
45
        internals.mockAuthenticatorCoordinator.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
46
        const credential = await navigator.credentials.create(options);
46
        const credential = await navigator.credentials.create(options);
47
47
48
        return promise_rejects(t, "NotSupportedError",
48
        return promise_rejects(t, "NotSupportedError",
- a/LayoutTests/http/wpt/webauthn/idl.https.html -2 / +2 lines
Lines 52-58 promise_test(async () => { a/LayoutTests/http/wpt/webauthn/idl.https.html_sec1
52
        }
52
        }
53
    };
53
    };
54
    // A mock attestation object
54
    // A mock attestation object
55
    internals.mockCredentialsMessenger.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
55
    internals.mockAuthenticatorCoordinator.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
56
    createdCredential = await navigator.credentials.create(creationOptions);
56
    createdCredential = await navigator.credentials.create(creationOptions);
57
57
58
58
Lines 62-68 promise_test(async () => { a/LayoutTests/http/wpt/webauthn/idl.https.html_sec2
62
        }
62
        }
63
    };
63
    };
64
    // A mock assertion return bundle.
64
    // A mock assertion return bundle.
65
    internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
65
    internals.mockAuthenticatorCoordinator.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
66
    requestedCredential = await navigator.credentials.get(requestOptions);
66
    requestedCredential = await navigator.credentials.get(requestOptions);
67
67
68
    idlArray.add_objects({"PublicKeyCredential": ["createdCredential"], "AuthenticatorAttestationResponse": ["createdCredential.response"], "AuthenticatorAssertionResponse": ["requestedCredential.response"]});
68
    idlArray.add_objects({"PublicKeyCredential": ["createdCredential"], "AuthenticatorAttestationResponse": ["createdCredential.response"], "AuthenticatorAssertionResponse": ["requestedCredential.response"]});
- a/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html -2 / +2 lines
Lines 20-26 a/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html_sec1
20
                timeout: 0,
20
                timeout: 0,
21
            }
21
            }
22
        };
22
        };
23
        internals.mockCredentialsMessenger.setDidTimeOut();
23
        internals.mockAuthenticatorCoordinator.setDidTimeOut();
24
24
25
        return promise_rejects(t, "NotAllowedError",
25
        return promise_rejects(t, "NotAllowedError",
26
            navigator.credentials.create(options));
26
            navigator.credentials.create(options));
Lines 82-88 a/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html_sec2
82
                pubKeyCredParams: [{ type: "public-key", alg: -7 }],
82
                pubKeyCredParams: [{ type: "public-key", alg: -7 }],
83
            }
83
            }
84
        };
84
        };
85
        internals.mockCredentialsMessenger.setDidUserCancel();
85
        internals.mockAuthenticatorCoordinator.setDidUserCancel();
86
86
87
        return promise_rejects(t, "NotAllowedError",
87
        return promise_rejects(t, "NotAllowedError",
88
            navigator.credentials.create(options));
88
            navigator.credentials.create(options));
- a/LayoutTests/http/wpt/webauthn/public-key-credential-create-success.https.html -1 / +1 lines
Lines 20-26 a/LayoutTests/http/wpt/webauthn/public-key-credential-create-success.https.html_sec1
20
            }
20
            }
21
        };
21
        };
22
        // A mock attestation object
22
        // A mock attestation object
23
        internals.mockCredentialsMessenger.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
23
        internals.mockAuthenticatorCoordinator.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
24
24
25
        return navigator.credentials.create(options).then(function(credential) {
25
        return navigator.credentials.create(options).then(function(credential) {
26
                assert_equals(credential.id, 'AA');
26
                assert_equals(credential.id, 'AA');
- a/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html -2 / +2 lines
Lines 11-17 a/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html_sec1
11
                timeout: 0,
11
                timeout: 0,
12
            }
12
            }
13
        };
13
        };
14
        internals.mockCredentialsMessenger.setDidTimeOut();
14
        internals.mockAuthenticatorCoordinator.setDidTimeOut();
15
15
16
        return promise_rejects(t, "NotAllowedError",
16
        return promise_rejects(t, "NotAllowedError",
17
            navigator.credentials.get(options));
17
            navigator.credentials.get(options));
Lines 35-41 a/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html_sec2
35
                allowCredentials: [{ type: "public-key", id: asciiToUint8Array("123456") }],
35
                allowCredentials: [{ type: "public-key", id: asciiToUint8Array("123456") }],
36
            }
36
            }
37
        };
37
        };
38
        internals.mockCredentialsMessenger.setDidUserCancel();
38
        internals.mockAuthenticatorCoordinator.setDidUserCancel();
39
39
40
        return promise_rejects(t, "NotAllowedError",
40
        return promise_rejects(t, "NotAllowedError",
41
            navigator.credentials.get(options));
41
            navigator.credentials.get(options));
- a/LayoutTests/http/wpt/webauthn/public-key-credential-get-success.https.html -1 / +1 lines
Lines 12-18 a/LayoutTests/http/wpt/webauthn/public-key-credential-get-success.https.html_sec1
12
            }
12
            }
13
        };
13
        };
14
        // A mock assertion return bundle.
14
        // A mock assertion return bundle.
15
        internals.mockCredentialsMessenger.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
15
        internals.mockAuthenticatorCoordinator.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
16
16
17
        return navigator.credentials.get(options).then(function(credential) {
17
        return navigator.credentials.get(options).then(function(credential) {
18
            assert_equals(credential.id, 'AA');
18
            assert_equals(credential.id, 'AA');
- a/LayoutTests/http/wpt/webauthn/public-key-is-user-verifying-platform-authenticator-available.html -2 / +2 lines
Lines 4-10 a/LayoutTests/http/wpt/webauthn/public-key-is-user-verifying-platform-authenticator-available.html_sec1
4
<script src="/resources/testharnessreport.js"></script>
4
<script src="/resources/testharnessreport.js"></script>
5
<script>
5
<script>
6
    promise_test(function(t) {
6
    promise_test(function(t) {
7
        internals.mockCredentialsMessenger;
7
        internals.mockAuthenticatorCoordinator;
8
8
9
        return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable().then(function(result) {
9
        return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable().then(function(result) {
10
            assert_equals(result, false);
10
            assert_equals(result, false);
Lines 12-18 a/LayoutTests/http/wpt/webauthn/public-key-is-user-verifying-platform-authenticator-available.html_sec2
12
    }, "PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() without any available authenticators.");
12
    }, "PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() without any available authenticators.");
13
13
14
    promise_test(function(t) {
14
    promise_test(function(t) {
15
        internals.mockCredentialsMessenger.setDidUserVerifyingPlatformAuthenticatorPresent();
15
        internals.mockAuthenticatorCoordinator.setDidUserVerifyingPlatformAuthenticatorPresent();
16
16
17
        return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable().then(function(result) {
17
        return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable().then(function(result) {
18
            assert_equals(result, true);
18
            assert_equals(result, true);

Return to Bug 189277