Title: [284071] trunk
Revision
284071
Author
[email protected]
Date
2021-10-12 18:06:18 -0700 (Tue, 12 Oct 2021)

Log Message

Adopt platform UI for WebAuthn
https://bugs.webkit.org/show_bug.cgi?id=230906
<rdar://74659556>

Patch by Garrett Davidson <[email protected]> on 2021-10-12
Reviewed by David Kilzer.

Source/WebKit:

Switch to using the platform's UI for WebAuthn transactions, where available,
which takes precedence over the WebAuthn process.

Covered by existing tests.

* Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h:
When possible, switch to importing the umbrella header directly instead of
redeclaring the entire interface.

Also, fix an existing bug caused by the redeclaration, where the
ASCSecurityKeyPublicKeyCredentialKind enum was renamed.

* SourcesCocoa.txt:
Build the new file.

* UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
(-[_WKWebAuthenticationPanel makeCredentialWithChallenge:origin:options:completionHandler:]):
Return the full error to the delegate.

* UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.h:
* UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.mm:
Add all of the new required classes for soft linking, and sort the list.

* UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm: Added.
(WebKit::toArrayBuffer):
(WebKit::toNSData):
(WebKit::toNSString):
(WebKit::toExceptionCode):
(WebKit::toASCDescriptor):
Helper methods for converting between WK and ASC types.

(WebKit::configureRegistrationRequestContext):
(WebKit::configurationAssertionRequestContext):
Create and configure an ASCCredentialRequestContext from the provided options.

(WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
(WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
Configure and perform the request.

(WebKit::WebAuthenticatorCoordinatorProxy::performRequest):
- Create a proxy to talk to AuthenticationServicesAgent.
- Ask the proxy if we're allowed to perform the request.
  - If no, return an error.
  - If yes, create presenter and present over the web page's window.
- When the request if finished, check the kind of credential we got, and return
the relevant AuthenticatorResponseData/AuthenticatorAttachment.
- If the request was canceled or failed, `credential` will be nil and `error` will
be non-nil. In most cases, the error will be WKErrorDomain, which we can convert
directly to ExceptionData. The one exception is the user canceled the request in
the platform UI, so return the appropriate ExceptionData in that case. The final
"Operation failed." case covers anything else unexpected happening.

(WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
If +shouldUseAlternateCredentialStore is true, this is always true. Otherwise,
fall back to the old behavior.

* UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm:
(-[WKASCAuthorizationPresenterDelegate authorizationPresenter:credentialRequestedForLoginChoice:authenticatedContext:completionHandler:]):
Use the new name of the enum, unconditionally.

* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
Wrap a few methods in the new flag. When the flag is on, these methods will exist
in WebAuthenticatorCoordinatorProxy.mm.

* UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h:
New ivar and method for the platform presenter.
Make the superclass public so we can use the WeakPtr inheritance.

* UIProcess/ios/WKHoverPlatterParameters.mm:
Add some missing imports since this file got pushed off the end of
UnifiedSource47-mm.mm.

* WebKit.xcodeproj/project.pbxproj:
Add the new file.

* WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp:
When platform UI is available, prefer it over the WebAuthn process.
(WebKit::WebAuthenticatorCoordinator::makeCredential):
(WebKit::WebAuthenticatorCoordinator::getAssertion):
(WebKit::WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):

Tools:

Update the timeout test to expect NotAllowedError, which is the expected error
code when a timeout occurs, per Step 21 of the "Create a New Credential"
algorithm.

* TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (284070 => 284071)


--- trunk/Source/WebKit/ChangeLog	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/ChangeLog	2021-10-13 01:06:18 UTC (rev 284071)
@@ -1,3 +1,92 @@
+2021-10-12  Garrett Davidson  <[email protected]>
+
+        Adopt platform UI for WebAuthn
+        https://bugs.webkit.org/show_bug.cgi?id=230906
+        <rdar://74659556>
+
+        Reviewed by David Kilzer.
+
+        Switch to using the platform's UI for WebAuthn transactions, where available,
+        which takes precedence over the WebAuthn process.
+
+        Covered by existing tests.
+
+        * Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h:
+        When possible, switch to importing the umbrella header directly instead of
+        redeclaring the entire interface.
+
+        Also, fix an existing bug caused by the redeclaration, where the
+        ASCSecurityKeyPublicKeyCredentialKind enum was renamed.
+
+        * SourcesCocoa.txt:
+        Build the new file.
+
+        * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
+        (-[_WKWebAuthenticationPanel makeCredentialWithChallenge:origin:options:completionHandler:]):
+        Return the full error to the delegate.
+
+        * UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.h:
+        * UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.mm:
+        Add all of the new required classes for soft linking, and sort the list.
+
+        * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm: Added.
+        (WebKit::toArrayBuffer):
+        (WebKit::toNSData):
+        (WebKit::toNSString):
+        (WebKit::toExceptionCode):
+        (WebKit::toASCDescriptor):
+        Helper methods for converting between WK and ASC types.
+
+        (WebKit::configureRegistrationRequestContext):
+        (WebKit::configurationAssertionRequestContext):
+        Create and configure an ASCCredentialRequestContext from the provided options.
+
+        (WebKit::WebAuthenticatorCoordinatorProxy::makeCredential):
+        (WebKit::WebAuthenticatorCoordinatorProxy::getAssertion):
+        Configure and perform the request.
+
+        (WebKit::WebAuthenticatorCoordinatorProxy::performRequest):
+        - Create a proxy to talk to AuthenticationServicesAgent.
+        - Ask the proxy if we're allowed to perform the request.
+          - If no, return an error.
+          - If yes, create presenter and present over the web page's window.
+        - When the request if finished, check the kind of credential we got, and return
+        the relevant AuthenticatorResponseData/AuthenticatorAttachment.
+        - If the request was canceled or failed, `credential` will be nil and `error` will
+        be non-nil. In most cases, the error will be WKErrorDomain, which we can convert
+        directly to ExceptionData. The one exception is the user canceled the request in
+        the platform UI, so return the appropriate ExceptionData in that case. The final
+        "Operation failed." case covers anything else unexpected happening.
+
+        (WebKit::WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable):
+        If +shouldUseAlternateCredentialStore is true, this is always true. Otherwise,
+        fall back to the old behavior.
+
+        * UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm:
+        (-[WKASCAuthorizationPresenterDelegate authorizationPresenter:credentialRequestedForLoginChoice:authenticatedContext:completionHandler:]):
+        Use the new name of the enum, unconditionally.
+
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
+        Wrap a few methods in the new flag. When the flag is on, these methods will exist
+        in WebAuthenticatorCoordinatorProxy.mm.
+
+        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h:
+        New ivar and method for the platform presenter.
+        Make the superclass public so we can use the WeakPtr inheritance.
+
+        * UIProcess/ios/WKHoverPlatterParameters.mm:
+        Add some missing imports since this file got pushed off the end of
+        UnifiedSource47-mm.mm.
+
+        * WebKit.xcodeproj/project.pbxproj:
+        Add the new file.
+
+        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp:
+        When platform UI is available, prefer it over the WebAuthn process.
+        (WebKit::WebAuthenticatorCoordinator::makeCredential):
+        (WebKit::WebAuthenticatorCoordinator::getAssertion):
+        (WebKit::WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable):
+
 2021-10-12  Simon Fraser  <[email protected]>
 
         Scrolling thread animations need to commit layers on the scrolling thread

Modified: trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h (284070 => 284071)


--- trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h	2021-10-13 01:06:18 UTC (rev 284071)
@@ -25,20 +25,10 @@
 
 #pragma once
 
-#if HAVE(ASC_AUTH_UI)
+#if HAVE(UNIFIED_ASC_AUTH_UI)
+#import <AuthenticationServicesCore/AuthenticationServicesCorePrivate.h>
+#elif HAVE(ASC_AUTH_UI)
 
-// FIXME<rdar://problem/72406585>: Uncomment the headers after the SDK becomes stable.
-//#if USE(APPLE_INTERNAL_SDK)
-//
-//// FIXME(219767): Remove ASCAppleIDCredential.h.
-//#import <AuthenticationServicesCore/ASCAppleIDCredential.h>
-//#import <AuthenticationServicesCore/ASCAuthorizationPresentationContext.h>
-//#import <AuthenticationServicesCore/ASCAuthorizationPresenter.h>
-//#import <AuthenticationServicesCore/ASCPlatformPublicKeyCredentialLoginChoice.h>
-//#import <AuthenticationServicesCore/ASCSecurityKeyPublicKeyCredentialLoginChoice.h>
-//
-//#else
-
 NS_ASSUME_NONNULL_BEGIN
 
 @class LAContext;
@@ -108,10 +98,10 @@
 
 @end
 
-typedef NS_ENUM(NSInteger, ASCSecurityKeyPublicKeyCredentialLoginChoiceKind) {
-    ASCSecurityKeyPublicKeyCredentialLoginChoiceKindRegistration,
-    ASCSecurityKeyPublicKeyCredentialLoginChoiceKindAssertion,
-    ASCSecurityKeyPublicKeyCredentialLoginChoiceKindAssertionPlaceholder,
+typedef NS_ENUM(NSInteger, ASCSecurityKeyPublicKeyCredentialKind) {
+    ASCSecurityKeyPublicKeyCredentialKindRegistration,
+    ASCSecurityKeyPublicKeyCredentialKindAssertion,
+    ASCSecurityKeyPublicKeyCredentialKindAssertionPlaceholder,
 };
 
 @interface ASCPublicKeyCredentialCreationOptions : NSObject <NSSecureCoding>
@@ -136,7 +126,7 @@
 @property (nonatomic, nullable, readonly, copy) NSString *name;
 @property (nonatomic, nullable, readonly, copy) NSString *displayName;
 @property (nonatomic, nullable, readonly, copy) NSData *userHandle;
-@property (nonatomic, readonly) ASCSecurityKeyPublicKeyCredentialLoginChoiceKind loginChoiceKind;
+@property (nonatomic, readonly) ASCSecurityKeyPublicKeyCredentialKind credentialKind;
 
 + (instancetype)new NS_UNAVAILABLE;
 - (instancetype)init NS_UNAVAILABLE;

Modified: trunk/Source/WebKit/SourcesCocoa.txt (284070 => 284071)


--- trunk/Source/WebKit/SourcesCocoa.txt	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2021-10-13 01:06:18 UTC (rev 284071)
@@ -592,6 +592,7 @@
 UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm
 UIProcess/WebAuthentication/Cocoa/WKNFReaderSessionDelegate.mm
 UIProcess/WebAuthentication/Cocoa/WebAuthenticationPanelClient.mm
+UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm
 
 UIProcess/WebAuthentication/Mock/MockLocalConnection.mm
 UIProcess/WebAuthentication/Mock/MockLocalService.mm

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (284070 => 284071)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm	2021-10-13 01:06:18 UTC (rev 284071)
@@ -540,7 +540,7 @@
         WTF::switchOn(result, [&](const Ref<WebCore::AuthenticatorResponse>& response) {
             handler(wkAuthenticatorAttestationResponse(response->data(), clientDataJSON.get(), response->attachment()).get(), nil);
         }, [&](const WebCore::ExceptionData& exception) {
-            handler(nil, [NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:nil]);
+            handler(nil, [NSError errorWithDomain:WKErrorDomain code:exception.code userInfo:@{ NSLocalizedDescriptionKey: exception.message }]);
         });
     };
     _panel->handleRequest({ WTFMove(hash), [_WKWebAuthenticationPanel convertToCoreCreationOptionsWithOptions:options], nullptr, WebKit::WebAuthenticationPanelResult::Unavailable, nullptr, std::nullopt, { }, true, String(), nullptr }, WTFMove(callback));

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.h (284070 => 284071)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.h	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.h	2021-10-13 01:06:18 UTC (rev 284071)
@@ -32,14 +32,23 @@
 
 SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCWebKitSPISupport);
 
-#if HAVE(ASC_AUTH_UI)
+#if HAVE(ASC_AUTH_UI) || HAVE(UNIFIED_ASC_AUTH_UI)
 
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCAgentProxy);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCAppleIDCredential);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCAuthorizationPresentationContext);
 SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCAuthorizationPresenter);
-SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCAuthorizationPresentationContext);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCAuthorizationRemotePresenter);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCCredentialRequestContext);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCPlatformPublicKeyCredentialAssertion);
 SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCPlatformPublicKeyCredentialLoginChoice);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCPlatformPublicKeyCredentialRegistration);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCPublicKeyCredentialAssertionOptions);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCPublicKeyCredentialCreationOptions);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCPublicKeyCredentialDescriptor);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCSecurityKeyPublicKeyCredentialAssertion);
 SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCSecurityKeyPublicKeyCredentialLoginChoice);
-SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCAppleIDCredential);
-SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCPublicKeyCredentialCreationOptions);
+SOFT_LINK_CLASS_FOR_HEADER(WebKit, ASCSecurityKeyPublicKeyCredentialRegistration);
 
 SOFT_LINK_CONSTANT_FOR_HEADER(WebKit, AuthenticationServicesCore, ASCAuthorizationErrorDomain, NSErrorDomain);
 #define ASCAuthorizationErrorDomain WebKit::get_AuthenticationServicesCore_ASCAuthorizationErrorDomain()

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.mm (284070 => 284071)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.mm	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticationServicesCoreSoftLink.mm	2021-10-13 01:06:18 UTC (rev 284071)
@@ -32,14 +32,23 @@
 
 SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCWebKitSPISupport);
 
-#if HAVE(ASC_AUTH_UI)
+#if HAVE(ASC_AUTH_UI) || HAVE(UNIFIED_ASC_AUTH_UI)
 
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAgentProxy);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAppleIDCredential);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAuthorizationPresentationContext);
 SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAuthorizationPresenter);
-SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAuthorizationPresentationContext);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAuthorizationRemotePresenter);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCCredentialRequestContext);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPlatformPublicKeyCredentialAssertion);
 SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPlatformPublicKeyCredentialLoginChoice);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPlatformPublicKeyCredentialRegistration);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPublicKeyCredentialAssertionOptions);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPublicKeyCredentialCreationOptions);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPublicKeyCredentialDescriptor);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCSecurityKeyPublicKeyCredentialAssertion);
 SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCSecurityKeyPublicKeyCredentialLoginChoice);
-SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAppleIDCredential);
-SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPublicKeyCredentialCreationOptions);
+SOFT_LINK_CLASS_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCSecurityKeyPublicKeyCredentialRegistration);
 
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCAuthorizationErrorDomain, NSErrorDomain);
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebKit, AuthenticationServicesCore, ASCPINValidationResultKey, NSString*);

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm (284070 => 284071)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm	2021-10-13 01:06:18 UTC (rev 284071)
@@ -78,7 +78,7 @@
     if ([loginChoice isKindOfClass:WebKit::getASCSecurityKeyPublicKeyCredentialLoginChoiceClass()]) {
         auto *securityKeyLoginChoice = (ASCSecurityKeyPublicKeyCredentialLoginChoice *)loginChoice;
 
-        if ([securityKeyLoginChoice loginChoiceKind] == ASCSecurityKeyPublicKeyCredentialLoginChoiceKindAssertion) {
+        if ([securityKeyLoginChoice credentialKind] == ASCSecurityKeyPublicKeyCredentialKindAssertion) {
             String loginChoiceName = securityKeyLoginChoice.name;
             [self dispatchCoordinatorCallback:[loginChoiceName = WTFMove(loginChoiceName)] (WebKit::AuthenticatorPresenterCoordinator& coordinator) mutable {
                 coordinator.didSelectAssertionResponse(loginChoiceName, nil);

Added: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm (0 => 284071)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm	2021-10-13 01:06:18 UTC (rev 284071)
@@ -0,0 +1,351 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE(UNIFIED_ASC_AUTH_UI)
+
+#import "config.h"
+#import "WebAuthenticatorCoordinatorProxy.h"
+
+#import "LocalService.h"
+#import "WKError.h"
+#import "WebAuthenticationRequestData.h"
+#import "WebPageProxy.h"
+#import <AuthenticationServices/ASCOSEConstants.h>
+#import <WebCore/AuthenticatorAttachment.h>
+#import <WebCore/AuthenticatorResponseData.h>
+#import <WebCore/ExceptionData.h>
+#import <WebCore/PublicKeyCredentialCreationOptions.h>
+#import <wtf/BlockPtr.h>
+
+#import "AuthenticationServicesCoreSoftLink.h"
+
+namespace WebKit {
+using namespace WebCore;
+
+static inline Ref<ArrayBuffer> toArrayBuffer(NSData *data)
+{
+    return ArrayBuffer::create(reinterpret_cast<const uint8_t*>(data.bytes), data.length);
+}
+
+static inline RetainPtr<NSData> toNSData(const BufferSource& data)
+{
+    return adoptNS([[NSData alloc] initWithBytes:data.data() length:data.length()]);
+}
+
+static inline RetainPtr<NSData> toNSData(const Vector<uint8_t> vector)
+{
+    return adoptNS([[NSData alloc] initWithBytes:vector.data() length:vector.size()]);
+}
+
+static inline RetainPtr<NSString> toNSString(UserVerificationRequirement userVerificationRequirement)
+{
+    switch (userVerificationRequirement) {
+    case UserVerificationRequirement::Required:
+        return @"required";
+    case UserVerificationRequirement::Discouraged:
+        return @"discouraged";
+    case UserVerificationRequirement::Preferred:
+        return @"preferred";
+    }
+
+    return @"preferred";
+}
+
+static inline ExceptionCode toExceptionCode(NSInteger nsErrorCode)
+{
+    ExceptionCode exceptionCode = (ExceptionCode)nsErrorCode;
+
+    switch (exceptionCode) {
+    case IndexSizeError: FALLTHROUGH;
+    case HierarchyRequestError: FALLTHROUGH;
+    case WrongDocumentError: FALLTHROUGH;
+    case InvalidCharacterError: FALLTHROUGH;
+    case NoModificationAllowedError: FALLTHROUGH;
+    case NotFoundError: FALLTHROUGH;
+    case NotSupportedError: FALLTHROUGH;
+    case InUseAttributeError: FALLTHROUGH;
+    case InvalidStateError: FALLTHROUGH;
+    case SyntaxError: FALLTHROUGH;
+    case InvalidModificationError: FALLTHROUGH;
+    case NamespaceError: FALLTHROUGH;
+    case InvalidAccessError: FALLTHROUGH;
+    case TypeMismatchError: FALLTHROUGH;
+    case SecurityError: FALLTHROUGH;
+    case NetworkError: FALLTHROUGH;
+    case AbortError: FALLTHROUGH;
+    case URLMismatchError: FALLTHROUGH;
+    case QuotaExceededError: FALLTHROUGH;
+    case TimeoutError: FALLTHROUGH;
+    case InvalidNodeTypeError: FALLTHROUGH;
+    case DataCloneError: FALLTHROUGH;
+    case EncodingError: FALLTHROUGH;
+    case NotReadableError: FALLTHROUGH;
+    case UnknownError: FALLTHROUGH;
+    case ConstraintError: FALLTHROUGH;
+    case DataError: FALLTHROUGH;
+    case TransactionInactiveError: FALLTHROUGH;
+    case ReadonlyError: FALLTHROUGH;
+    case VersionError: FALLTHROUGH;
+    case OperationError: FALLTHROUGH;
+    case NotAllowedError: FALLTHROUGH;
+    case RangeError: FALLTHROUGH;
+    case TypeError: FALLTHROUGH;
+    case JSSyntaxError: FALLTHROUGH;
+    case StackOverflowError: FALLTHROUGH;
+    case OutOfMemoryError: FALLTHROUGH;
+    case ExistingExceptionError:
+        return exceptionCode;
+    }
+
+    return NotAllowedError;
+}
+
+static inline RetainPtr<ASCPublicKeyCredentialDescriptor> toASCDescriptor(PublicKeyCredentialDescriptor descriptor)
+{
+    RetainPtr<NSMutableArray<NSString *>> transports;
+    size_t transportCount = descriptor.transports.size();
+    if (transportCount) {
+        transports = adoptNS([[NSMutableArray alloc] initWithCapacity:transportCount]);
+
+        for (AuthenticatorTransport transport : descriptor.transports) {
+            NSString *transportString = nil;
+            switch (transport) {
+            case AuthenticatorTransport::Usb:
+                transportString = @"usb";
+                break;
+            case AuthenticatorTransport::Nfc:
+                transportString = @"nfc";
+                break;
+            case AuthenticatorTransport::Ble:
+                transportString = @"ble";
+                break;
+            case AuthenticatorTransport::Internal:
+                transportString = @"internal";
+                break;
+            }
+
+            if (transportString)
+                [transports addObject:transportString];
+        }
+    }
+
+    return adoptNS([allocASCPublicKeyCredentialDescriptorInstance() initWithCredentialID:toNSData(descriptor.idVector).get() transports:transports.get()]);
+}
+
+static RetainPtr<ASCCredentialRequestContext> configureRegistrationRequestContext(const PublicKeyCredentialCreationOptions& options)
+{
+    ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyRegistration | ASCCredentialRequestTypeSecurityKeyPublicKeyRegistration;
+
+    RetainPtr<NSString> userVerification;
+    bool shouldRequireResidentKey = false;
+    std::optional<PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria> authenticatorSelection = options.authenticatorSelection;
+    if (authenticatorSelection) {
+        std::optional<AuthenticatorAttachment> attachment = authenticatorSelection->authenticatorAttachment;
+        if (attachment == AuthenticatorAttachment::Platform)
+            requestTypes = ASCCredentialRequestTypePlatformPublicKeyRegistration;
+        else if (attachment == AuthenticatorAttachment::CrossPlatform)
+            requestTypes = ASCCredentialRequestTypeSecurityKeyPublicKeyRegistration;
+
+        userVerification = toNSString(authenticatorSelection->userVerification);
+
+        shouldRequireResidentKey = authenticatorSelection->requireResidentKey;
+    }
+
+    auto requestContext = adoptNS([allocASCCredentialRequestContextInstance() initWithRequestTypes:requestTypes]);
+    [requestContext setRelyingPartyIdentifier:options.rp.id];
+
+    auto credentialCreationOptions = adoptNS([allocASCPublicKeyCredentialCreationOptionsInstance() init]);
+
+    [credentialCreationOptions setChallenge:toNSData(options.challenge).get()];
+    [credentialCreationOptions setRelyingPartyIdentifier:options.rp.id];
+    [credentialCreationOptions setUserName:options.user.name];
+    [credentialCreationOptions setUserIdentifier:toNSData(options.user.id).get()];
+    [credentialCreationOptions setUserDisplayName:options.user.displayName];
+    [credentialCreationOptions setUserVerificationPreference:userVerification.get()];
+    [credentialCreationOptions setShouldRequireResidentKey:shouldRequireResidentKey];
+
+    RetainPtr<NSMutableArray<NSNumber *>> supportedAlgorithmIdentifiers = adoptNS([[NSMutableArray alloc] initWithCapacity:options.pubKeyCredParams.size()]);
+    for (PublicKeyCredentialCreationOptions::Parameters algorithmParameter : options.pubKeyCredParams)
+        [supportedAlgorithmIdentifiers addObject:@(algorithmParameter.alg)];
+
+    [credentialCreationOptions setSupportedAlgorithmIdentifiers:supportedAlgorithmIdentifiers.get()];
+
+    size_t excludedCredentialCount = options.excludeCredentials.size();
+    if (excludedCredentialCount) {
+        RetainPtr<NSMutableArray<ASCPublicKeyCredentialDescriptor *>> excludedCredentials = adoptNS([[NSMutableArray alloc] initWithCapacity:excludedCredentialCount]);
+
+        for (PublicKeyCredentialDescriptor descriptor : options.excludeCredentials)
+            [excludedCredentials addObject:toASCDescriptor(descriptor).get()];
+
+        [credentialCreationOptions setExcludedCredentials:excludedCredentials.get()];
+    }
+
+    if (requestTypes & ASCCredentialRequestTypePlatformPublicKeyRegistration)
+        [requestContext setPlatformKeyCredentialCreationOptions:credentialCreationOptions.get()];
+
+    if (requestTypes & ASCCredentialRequestTypeSecurityKeyPublicKeyRegistration)
+        [requestContext setSecurityKeyCredentialCreationOptions:credentialCreationOptions.get()];
+
+    return requestContext;
+}
+
+static RetainPtr<ASCCredentialRequestContext> configurationAssertionRequestContext(const PublicKeyCredentialRequestOptions& options)
+{
+    ASCCredentialRequestTypes requestTypes = ASCCredentialRequestTypePlatformPublicKeyAssertion | ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion;
+
+    RetainPtr<NSString> userVerification;
+    std::optional<AuthenticatorAttachment> attachment = options.authenticatorAttachment;
+    if (attachment == AuthenticatorAttachment::Platform)
+        requestTypes = ASCCredentialRequestTypePlatformPublicKeyAssertion;
+    else if (attachment == AuthenticatorAttachment::CrossPlatform)
+        requestTypes = ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion;
+
+    userVerification = toNSString(options.userVerification);
+
+    size_t allowedCredentialCount = options.allowCredentials.size();
+    RetainPtr<NSMutableArray<ASCPublicKeyCredentialDescriptor *>> allowedCredentials;
+    if (allowedCredentialCount) {
+        allowedCredentials = adoptNS([[NSMutableArray alloc] initWithCapacity:allowedCredentialCount]);
+
+        for (PublicKeyCredentialDescriptor descriptor : options.allowCredentials)
+            [allowedCredentials addObject:toASCDescriptor(descriptor).get()];
+    }
+
+    auto requestContext = adoptNS([allocASCCredentialRequestContextInstance() initWithRequestTypes:requestTypes]);
+    [requestContext setRelyingPartyIdentifier:options.rpId];
+
+    auto challenge = toNSData(options.challenge);
+
+    if (requestTypes & ASCCredentialRequestTypePlatformPublicKeyAssertion)
+        [requestContext setPlatformKeyCredentialAssertionOptions:[allocASCPublicKeyCredentialAssertionOptionsInstance() initWithKind:ASCPublicKeyCredentialKindPlatform relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]];
+
+    if (requestTypes & ASCCredentialRequestTypeSecurityKeyPublicKeyAssertion)
+        [requestContext setSecurityKeyCredentialAssertionOptions:[allocASCPublicKeyCredentialAssertionOptionsInstance() initWithKind:ASCPublicKeyCredentialKindSecurityKey relyingPartyIdentifier:options.rpId challenge:challenge.get() userVerificationPreference:userVerification.get() allowedCredentials:allowedCredentials.get()]];
+
+    return requestContext;
+}
+
+void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
+{
+    auto requestContext = configureRegistrationRequestContext(options);
+    performRequest(requestContext, WTFMove(handler));
+}
+
+void WebAuthenticatorCoordinatorProxy::getAssertion(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialRequestOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
+{
+    auto requestContext = configurationAssertionRequestContext(options);
+    performRequest(requestContext, WTFMove(handler));
+}
+
+void WebAuthenticatorCoordinatorProxy::performRequest(RetainPtr<ASCCredentialRequestContext> requestContext, RequestCompletionHandler&& handler)
+{
+    auto proxy = adoptNS([allocASCAgentProxyInstance() init]);
+
+    RetainPtr<NSWindow> window = m_webPageProxy.platformWindow();
+    [proxy performAuthorizationRequestsForContext:requestContext.get() withClearanceHandler:makeBlockPtr([weakThis = makeWeakPtr(*this), handler = WTFMove(handler), window = WTFMove(window)](NSXPCListenerEndpoint *daemonEnpoint, NSError *error) mutable {
+        auto protectedThis = weakThis.get();
+
+        if (!protectedThis || !daemonEnpoint) {
+            RunLoop::main().dispatch([handler = WTFMove(handler)]() mutable {
+                handler({ }, (AuthenticatorAttachment)0, ExceptionData { NotAllowedError, "Operation failed." });
+            });
+            return;
+        }
+
+        protectedThis->m_presenter = adoptNS([allocASCAuthorizationRemotePresenterInstance() init]);
+        [protectedThis->m_presenter presentWithWindow:window.get() daemonEndpoint:daemonEnpoint completionHandler:makeBlockPtr([handler = WTFMove(handler)](id <ASCCredentialProtocol> credential, NSError *error) mutable {
+            AuthenticatorResponseData response = { };
+            AuthenticatorAttachment attachment;
+            ExceptionData exceptionData = { };
+
+            if ([credential isKindOfClass:getASCPlatformPublicKeyCredentialRegistrationClass()]) {
+                attachment = AuthenticatorAttachment::Platform;
+                response.isAuthenticatorAttestationResponse = true;
+
+                ASCPlatformPublicKeyCredentialRegistration *registrationCredential = credential;
+                response.rawId = toArrayBuffer(registrationCredential.credentialID);
+                response.attestationObject = toArrayBuffer(registrationCredential.attestationObject);
+            } else if ([credential isKindOfClass:getASCSecurityKeyPublicKeyCredentialRegistrationClass()]) {
+                attachment = AuthenticatorAttachment::CrossPlatform;
+                response.isAuthenticatorAttestationResponse = true;
+
+                ASCSecurityKeyPublicKeyCredentialRegistration *registrationCredential = credential;
+                response.rawId = toArrayBuffer(registrationCredential.credentialID);
+                response.attestationObject = toArrayBuffer(registrationCredential.attestationObject);
+            } else if ([credential isKindOfClass:getASCPlatformPublicKeyCredentialAssertionClass()]) {
+                attachment = AuthenticatorAttachment::Platform;
+                response.isAuthenticatorAttestationResponse = false;
+
+                ASCPlatformPublicKeyCredentialAssertion *assertionCredential = credential;
+                response.rawId = toArrayBuffer(assertionCredential.credentialID);
+                response.authenticatorData = toArrayBuffer(assertionCredential.authenticatorData);
+                response.signature = toArrayBuffer(assertionCredential.signature);
+                response.userHandle = toArrayBuffer(assertionCredential.userHandle);
+            } else if ([credential isKindOfClass:getASCSecurityKeyPublicKeyCredentialAssertionClass()]) {
+                attachment = AuthenticatorAttachment::CrossPlatform;
+                response.isAuthenticatorAttestationResponse = false;
+
+                ASCSecurityKeyPublicKeyCredentialAssertion *assertionCredential = credential;
+                response.rawId = toArrayBuffer(assertionCredential.credentialID);
+                response.authenticatorData = toArrayBuffer(assertionCredential.authenticatorData);
+                response.signature = toArrayBuffer(assertionCredential.signature);
+                response.userHandle = toArrayBuffer(assertionCredential.userHandle);
+            } else {
+                attachment = (AuthenticatorAttachment) 0;
+                ExceptionCode exceptionCode;
+                NSString *errorMessage = nil;
+                if ([error.domain isEqualToString:WKErrorDomain]) {
+                    exceptionCode = toExceptionCode(error.code);
+                    errorMessage = error.userInfo[NSLocalizedDescriptionKey];
+                } else {
+                    exceptionCode = NotAllowedError;
+
+                    if ([error.domain isEqualToString:ASCAuthorizationErrorDomain] && error.code == ASCAuthorizationErrorUserCanceled)
+                        errorMessage = @"This request has been cancelled by the user.";
+                    else
+                        errorMessage = @"Operation failed.";
+                }
+
+                exceptionData = { exceptionCode, errorMessage };
+            }
+
+            handler(response, attachment, exceptionData);
+        }).get()];
+    }).get()];
+}
+
+void WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&& handler)
+{
+    if ([getASCWebKitSPISupportClass() shouldUseAlternateCredentialStore]) {
+        handler(true);
+        return;
+    }
+
+    handler(LocalService::isAvailable());
+}
+
+} // namespace WebKit
+
+#endif // HAVE(UNIFIED_ASC_AUTH_UI)

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp (284070 => 284071)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp	2021-10-13 01:06:18 UTC (rev 284071)
@@ -55,6 +55,7 @@
     m_webPageProxy.process().removeMessageReceiver(Messages::WebAuthenticatorCoordinatorProxy::messageReceiverName(), m_webPageProxy.webPageID());
 }
 
+#if !HAVE(UNIFIED_ASC_AUTH_UI)
 void WebAuthenticatorCoordinatorProxy::makeCredential(FrameIdentifier frameId, FrameInfoData&& frameInfo, Vector<uint8_t>&& hash, PublicKeyCredentialCreationOptions&& options, bool processingUserGesture, RequestCompletionHandler&& handler)
 {
     handleRequest({ WTFMove(hash), WTFMove(options), makeWeakPtr(m_webPageProxy), WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr }, WTFMove(handler));
@@ -64,6 +65,7 @@
 {
     handleRequest({ WTFMove(hash), WTFMove(options), makeWeakPtr(m_webPageProxy), WebAuthenticationPanelResult::Unavailable, nullptr, GlobalFrameIdentifier { m_webPageProxy.webPageID(), frameId }, WTFMove(frameInfo), processingUserGesture, String(), nullptr }, WTFMove(handler));
 }
+#endif
 
 void WebAuthenticatorCoordinatorProxy::handleRequest(WebAuthenticationRequestData&& data, RequestCompletionHandler&& handler)
 {
@@ -78,10 +80,12 @@
     m_webPageProxy.websiteDataStore().authenticatorManager().handleRequest(WTFMove(data), WTFMove(callback));
 }
 
+#if !HAVE(UNIFIED_ASC_AUTH_UI)
 void WebAuthenticatorCoordinatorProxy::isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&& handler)
 {
     handler(LocalService::isAvailable());
 }
+#endif
 
 } // namespace WebKit
 

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h (284070 => 284071)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h	2021-10-13 01:06:18 UTC (rev 284071)
@@ -41,6 +41,11 @@
 struct SecurityOriginData;
 }
 
+#if HAVE(UNIFIED_ASC_AUTH_UI)
+OBJC_CLASS ASCAuthorizationRemotePresenter;
+OBJC_CLASS ASCCredentialRequestContext;
+#endif
+
 namespace WebKit {
 
 class WebPageProxy;
@@ -48,7 +53,7 @@
 struct FrameInfoData;
 struct WebAuthenticationRequestData;
 
-class WebAuthenticatorCoordinatorProxy : private IPC::MessageReceiver {
+class WebAuthenticatorCoordinatorProxy : public IPC::MessageReceiver {
     WTF_MAKE_FAST_ALLOCATED;
     WTF_MAKE_NONCOPYABLE(WebAuthenticatorCoordinatorProxy);
 public:
@@ -70,6 +75,11 @@
     void handleRequest(WebAuthenticationRequestData&&, RequestCompletionHandler&&);
 
     WebPageProxy& m_webPageProxy;
+
+#if HAVE(UNIFIED_ASC_AUTH_UI)
+    void performRequest(RetainPtr<ASCCredentialRequestContext>, RequestCompletionHandler&&);
+    RetainPtr<ASCAuthorizationRemotePresenter> m_presenter;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/ios/WKHoverPlatterParameters.mm (284070 => 284071)


--- trunk/Source/WebKit/UIProcess/ios/WKHoverPlatterParameters.mm	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/UIProcess/ios/WKHoverPlatterParameters.mm	2021-10-13 01:06:18 UTC (rev 284071)
@@ -29,6 +29,8 @@
 #if HAVE(UIKIT_WITH_MOUSE_SUPPORT) || ENABLE(HOVER_GESTURE_RECOGNIZER)
 
 #import "PrototypeToolsSPI.h"
+#import <pal/spi/cocoa/QuartzCoreSPI.h>
+#import <wtf/RetainPtr.h>
 
 @interface PTSliderRow (WebKit)
 

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (284070 => 284071)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-13 01:06:18 UTC (rev 284071)
@@ -2528,6 +2528,7 @@
 		07E19F0923D533BA0094FFB4 /* TextTrackPrivateRemote.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextTrackPrivateRemote.h; sourceTree = "<group>"; };
 		0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
 		089C1667FE841158C02AAC07 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		0DCBF4D926E2ED3200EA0E07 /* WebAuthenticatorCoordinatorProxy.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAuthenticatorCoordinatorProxy.mm; sourceTree = "<group>"; };
 		0E97D74C200E8FF300BF6643 /* SafeBrowsingSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SafeBrowsingSPI.h; sourceTree = "<group>"; };
 		0EDE85022004E74900030560 /* WebsitePopUpPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsitePopUpPolicy.h; sourceTree = "<group>"; };
 		0F04159823C7CC720060A3E2 /* WKScrollViewMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKScrollViewMac.h; sourceTree = "<group>"; };
@@ -9341,6 +9342,7 @@
 				570DAAAD23026F5C00E8FC04 /* NfcService.mm */,
 				577FF7832346ECAA004EDFB9 /* WebAuthenticationPanelClient.h */,
 				577FF7842346ECAA004EDFB9 /* WebAuthenticationPanelClient.mm */,
+				0DCBF4D926E2ED3200EA0E07 /* WebAuthenticatorCoordinatorProxy.mm */,
 				577739932580388F0059348B /* WKASCAuthorizationPresenterDelegate.h */,
 				577739942580388F0059348B /* WKASCAuthorizationPresenterDelegate.mm */,
 				570DAAC423037F7E00E8FC04 /* WKNFReaderSessionDelegate.h */,

Modified: trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp (284070 => 284071)


--- trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp	2021-10-13 01:06:18 UTC (rev 284071)
@@ -69,7 +69,12 @@
         return;
 
     auto isProcessingUserGesture = processingUserGesture(frame, webFrame->frameID());
-    if (!RuntimeEnabledFeatures::sharedFeatures().webAuthenticationModernEnabled()) {
+#if HAVE(UNIFIED_ASC_AUTH_UI)
+    bool useWebAuthnProcess = false;
+#else
+    bool useWebAuthnProcess = RuntimeEnabledFeatures::sharedFeatures().webAuthenticationModernEnabled();
+#endif
+    if (!useWebAuthnProcess) {
         m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::MakeCredential(webFrame->frameID(), webFrame->info(), hash, options, isProcessingUserGesture), WTFMove(handler));
         return;
     }
@@ -86,7 +91,12 @@
         return;
 
     auto isProcessingUserGesture = processingUserGesture(frame, webFrame->frameID());
-    if (!RuntimeEnabledFeatures::sharedFeatures().webAuthenticationModernEnabled()) {
+#if HAVE(UNIFIED_ASC_AUTH_UI)
+    bool useWebAuthnProcess = false;
+#else
+    bool useWebAuthnProcess = RuntimeEnabledFeatures::sharedFeatures().webAuthenticationModernEnabled();
+#endif
+    if (!useWebAuthnProcess) {
         m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::GetAssertion(webFrame->frameID(), webFrame->info(), hash, options, isProcessingUserGesture), WTFMove(handler));
         return;
     }
@@ -98,7 +108,12 @@
 
 void WebAuthenticatorCoordinator::isUserVerifyingPlatformAuthenticatorAvailable(QueryCompletionHandler&& handler)
 {
-    if (!RuntimeEnabledFeatures::sharedFeatures().webAuthenticationModernEnabled()) {
+#if HAVE(UNIFIED_ASC_AUTH_UI)
+    bool useWebAuthnProcess = false;
+#else
+    bool useWebAuthnProcess = RuntimeEnabledFeatures::sharedFeatures().webAuthenticationModernEnabled();
+#endif
+    if (!useWebAuthnProcess) {
         m_webPage.sendWithAsyncReply(Messages::WebAuthenticatorCoordinatorProxy::IsUserVerifyingPlatformAuthenticatorAvailable(), WTFMove(handler));
         return;
     }

Modified: trunk/Tools/ChangeLog (284070 => 284071)


--- trunk/Tools/ChangeLog	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Tools/ChangeLog	2021-10-13 01:06:18 UTC (rev 284071)
@@ -1,3 +1,18 @@
+2021-10-12  Garrett Davidson  <[email protected]>
+
+        Adopt platform UI for WebAuthn
+        https://bugs.webkit.org/show_bug.cgi?id=230906
+        <rdar://74659556>
+
+        Reviewed by David Kilzer.
+
+        Update the timeout test to expect NotAllowedError, which is the expected error
+        code when a timeout occurs, per Step 21 of the "Create a New Credential"
+        algorithm.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
+        (TestWebKitAPI::TEST):
+
 2021-10-12  Sihui Liu  <[email protected]>
 
         Implement FileSystemSyncAccessHandle read() and write()

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (284070 => 284071)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm	2021-10-13 00:59:57 UTC (rev 284070)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm	2021-10-13 01:06:18 UTC (rev 284071)
@@ -34,6 +34,7 @@
 #import "WKWebViewConfigurationExtras.h"
 #import <LocalAuthentication/LocalAuthentication.h>
 #import <WebCore/AuthenticatorAttachment.h>
+#import <WebCore/ExceptionCode.h>
 #import <WebCore/PublicKeyCredentialCreationOptions.h>
 #import <WebCore/PublicKeyCredentialRequestOptions.h>
 #import <WebKit/WKPreferencesPrivate.h>
@@ -1830,7 +1831,7 @@
 
         EXPECT_NULL(response);
         EXPECT_EQ(error.domain, WKErrorDomain);
-        EXPECT_EQ(error.code, WKErrorUnknown);
+        EXPECT_EQ(error.code, NotAllowedError);
     }];
     Util::run(&webAuthenticationPanelRan);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to