mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 03:32:37 +00:00
78e32a3b9f
* Core - Add DevToolsClient Issue #3165 * DevTools Client - Add Network domain class - Add hand written class to get a better sense of how the code should be structured. - Improve exception handling * Devtools - First draft of devtools protocol methods (generated) Not complete yet * Devtools - Simple method execution working * DevTools - Add .Net Style cased property names to response objects - Use internal field and datacontract attributes * DevTools - Improve mapping * DevTools - Strongly typed enums * DevTools Client - Generated from active browser instance (M84) * Devtools Client - Extract IDevToolsClient interface for testability Improve xml doc comments * DevTools Client - Improve error handling * DevTools Client - Improve enum conversion * Revert to older c# syntax * DevTools Client - Fix failing tests * Devtools Client - Add SetCookie Tests * DevTools Client - Add Capture SyncContext by default - Add option to capture the SyncContext - Add option to provide custom SyncContext (can just pass in UI SyncContext and all continuations will happen there). - Fix bug in ExecuteDevToolsMethodAsync sending the command twice when exeucted on the CEF UI thread * Devtools Client - Add missing file reference The problem with developing with the .Net Core project where files are automatically included is you forget to include them in the regular csproj file. * Devtools Client - Add CanCanEmulate Test case * DevTools Client - Add AddScriptToEvaluateOnNewDocumentAsync test * DevTools Client - OnDevToolsEvent only parse data if event handler != null * DevTools Client - GetDevToolsClient remove ThrowExceptionIfDisposed/ThrowExceptionIfBrowserNotInitialized calls Those methods were removed as the GetBrowser call handles the checks for us. * DevTools Client - Improve error handling * DevTools Client - Update xml doc comments * DevTools Client - Add validation method (partial) Add ability to manually add validation logic * DevTools Client - Comment out failing test Was working when targeting M84, now with M85 it fails. The mapping appears to be correct, will need to investigate further * OffScreen Example - Remove test code
173 lines
9.2 KiB
C#
173 lines
9.2 KiB
C#
// Copyright © 2020 The CefSharp Authors. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
namespace CefSharp.DevTools.WebAuthn
|
|
{
|
|
using System.Linq;
|
|
|
|
/// <summary>
|
|
/// This domain allows configuring virtual authenticators to test the WebAuthn
|
|
/// API.
|
|
/// </summary>
|
|
public partial class WebAuthn : DevToolsDomainBase
|
|
{
|
|
private CefSharp.DevTools.IDevToolsClient _client;
|
|
public WebAuthn(CefSharp.DevTools.IDevToolsClient client)
|
|
{
|
|
_client = (client);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enable the WebAuthn domain and start intercepting credential storage and
|
|
/// retrieval with a virtual authenticator.
|
|
/// </summary>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> EnableAsync()
|
|
{
|
|
System.Collections.Generic.Dictionary<string, object> dict = null;
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.enable", dict);
|
|
return methodResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Disable the WebAuthn domain.
|
|
/// </summary>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> DisableAsync()
|
|
{
|
|
System.Collections.Generic.Dictionary<string, object> dict = null;
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.disable", dict);
|
|
return methodResult;
|
|
}
|
|
|
|
partial void ValidateAddVirtualAuthenticator(CefSharp.DevTools.WebAuthn.VirtualAuthenticatorOptions options);
|
|
/// <summary>
|
|
/// Creates and adds a virtual authenticator.
|
|
/// </summary>
|
|
/// <param name = "options">options</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<AddVirtualAuthenticatorResponse></returns>
|
|
public async System.Threading.Tasks.Task<AddVirtualAuthenticatorResponse> AddVirtualAuthenticatorAsync(CefSharp.DevTools.WebAuthn.VirtualAuthenticatorOptions options)
|
|
{
|
|
ValidateAddVirtualAuthenticator(options);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("options", options.ToDictionary());
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.addVirtualAuthenticator", dict);
|
|
return methodResult.DeserializeJson<AddVirtualAuthenticatorResponse>();
|
|
}
|
|
|
|
partial void ValidateRemoveVirtualAuthenticator(string authenticatorId);
|
|
/// <summary>
|
|
/// Removes the given authenticator.
|
|
/// </summary>
|
|
/// <param name = "authenticatorId">authenticatorId</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> RemoveVirtualAuthenticatorAsync(string authenticatorId)
|
|
{
|
|
ValidateRemoveVirtualAuthenticator(authenticatorId);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("authenticatorId", authenticatorId);
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.removeVirtualAuthenticator", dict);
|
|
return methodResult;
|
|
}
|
|
|
|
partial void ValidateAddCredential(string authenticatorId, CefSharp.DevTools.WebAuthn.Credential credential);
|
|
/// <summary>
|
|
/// Adds the credential to the specified authenticator.
|
|
/// </summary>
|
|
/// <param name = "authenticatorId">authenticatorId</param>
|
|
/// <param name = "credential">credential</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> AddCredentialAsync(string authenticatorId, CefSharp.DevTools.WebAuthn.Credential credential)
|
|
{
|
|
ValidateAddCredential(authenticatorId, credential);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("authenticatorId", authenticatorId);
|
|
dict.Add("credential", credential.ToDictionary());
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.addCredential", dict);
|
|
return methodResult;
|
|
}
|
|
|
|
partial void ValidateGetCredential(string authenticatorId, byte[] credentialId);
|
|
/// <summary>
|
|
/// Returns a single credential stored in the given virtual authenticator that
|
|
/// matches the credential ID.
|
|
/// </summary>
|
|
/// <param name = "authenticatorId">authenticatorId</param>
|
|
/// <param name = "credentialId">credentialId</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<GetCredentialResponse></returns>
|
|
public async System.Threading.Tasks.Task<GetCredentialResponse> GetCredentialAsync(string authenticatorId, byte[] credentialId)
|
|
{
|
|
ValidateGetCredential(authenticatorId, credentialId);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("authenticatorId", authenticatorId);
|
|
dict.Add("credentialId", ToBase64String(credentialId));
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.getCredential", dict);
|
|
return methodResult.DeserializeJson<GetCredentialResponse>();
|
|
}
|
|
|
|
partial void ValidateGetCredentials(string authenticatorId);
|
|
/// <summary>
|
|
/// Returns all the credentials stored in the given virtual authenticator.
|
|
/// </summary>
|
|
/// <param name = "authenticatorId">authenticatorId</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<GetCredentialsResponse></returns>
|
|
public async System.Threading.Tasks.Task<GetCredentialsResponse> GetCredentialsAsync(string authenticatorId)
|
|
{
|
|
ValidateGetCredentials(authenticatorId);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("authenticatorId", authenticatorId);
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.getCredentials", dict);
|
|
return methodResult.DeserializeJson<GetCredentialsResponse>();
|
|
}
|
|
|
|
partial void ValidateRemoveCredential(string authenticatorId, byte[] credentialId);
|
|
/// <summary>
|
|
/// Removes a credential from the authenticator.
|
|
/// </summary>
|
|
/// <param name = "authenticatorId">authenticatorId</param>
|
|
/// <param name = "credentialId">credentialId</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> RemoveCredentialAsync(string authenticatorId, byte[] credentialId)
|
|
{
|
|
ValidateRemoveCredential(authenticatorId, credentialId);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("authenticatorId", authenticatorId);
|
|
dict.Add("credentialId", ToBase64String(credentialId));
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.removeCredential", dict);
|
|
return methodResult;
|
|
}
|
|
|
|
partial void ValidateClearCredentials(string authenticatorId);
|
|
/// <summary>
|
|
/// Clears all the credentials from the specified device.
|
|
/// </summary>
|
|
/// <param name = "authenticatorId">authenticatorId</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> ClearCredentialsAsync(string authenticatorId)
|
|
{
|
|
ValidateClearCredentials(authenticatorId);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("authenticatorId", authenticatorId);
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.clearCredentials", dict);
|
|
return methodResult;
|
|
}
|
|
|
|
partial void ValidateSetUserVerified(string authenticatorId, bool isUserVerified);
|
|
/// <summary>
|
|
/// Sets whether User Verification succeeds or fails for an authenticator.
|
|
/// The default is true.
|
|
/// </summary>
|
|
/// <param name = "authenticatorId">authenticatorId</param>
|
|
/// <param name = "isUserVerified">isUserVerified</param>
|
|
/// <returns>returns System.Threading.Tasks.Task<DevToolsMethodResponse></returns>
|
|
public async System.Threading.Tasks.Task<DevToolsMethodResponse> SetUserVerifiedAsync(string authenticatorId, bool isUserVerified)
|
|
{
|
|
ValidateSetUserVerified(authenticatorId, isUserVerified);
|
|
var dict = new System.Collections.Generic.Dictionary<string, object>();
|
|
dict.Add("authenticatorId", authenticatorId);
|
|
dict.Add("isUserVerified", isUserVerified);
|
|
var methodResult = await _client.ExecuteDevToolsMethodAsync("WebAuthn.setUserVerified", dict);
|
|
return methodResult;
|
|
}
|
|
}
|
|
} |