81 lines
3.1 KiB
C++
81 lines
3.1 KiB
C++
#pragma once
|
|
#include "pch.h"
|
|
#include <winrt/Microsoft.UI.Xaml.h>
|
|
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
|
#include <App.xaml.h>
|
|
#include <MainWindow.xaml.h>
|
|
#include <MainPage.xaml.h>
|
|
|
|
constexpr wchar_t c_pluginName[] = L"Contoso Passkey Manager";
|
|
constexpr wchar_t c_pluginRpId[] = L"contoso.com";
|
|
|
|
/* The AAGUID is a unique identifier for the FIDO authenticator model.
|
|
*'AAGUID' maybe used to fetch information about the authenticator from the FIDO Metadata Service and other sources.
|
|
* Refer: https://fidoalliance.org/metadata/
|
|
*/
|
|
constexpr char c_pluginAaguid[] = "########-####-####-####-############";
|
|
static_assert(c_pluginAaguid[1] != '#', "Please replace the ##### above with your AAGUID or a value you generated by running guidgen");
|
|
|
|
/* Generate a GUID using guidgen and replace below and in Package.appxmanifest file */
|
|
constexpr wchar_t c_pluginClsid[] = L"{########-####-####-####-############}";
|
|
static_assert(c_pluginClsid[1] != '#', "Please replace the ##### above with a GUID you generated by running guidgen");
|
|
|
|
|
|
constexpr wchar_t c_pluginSigningKeyName[] = L"TestAppPluginIdKey";
|
|
constexpr wchar_t c_pluginRegistryPath[] = L"Software\\Contoso\\PasskeyManager";
|
|
constexpr wchar_t c_windowsPluginRequestSigningKeyRegKeyName[] = L"RequestSigningKeyBlob";
|
|
constexpr wchar_t c_windowsPluginVaultLockedRegKeyName[] = L"VaultLocked";
|
|
constexpr wchar_t c_windowsPluginSilentOperationRegKeyName[] = L"SilentOperation";
|
|
constexpr wchar_t c_windowsPluginDBUpdateInd[] = L"SilentOperation";
|
|
|
|
namespace winrt::PasskeyManager::implementation
|
|
{
|
|
class PluginRegistrationManager
|
|
{
|
|
public:
|
|
static PluginRegistrationManager& getInstance()
|
|
{
|
|
static PluginRegistrationManager instance;
|
|
return instance;
|
|
}
|
|
|
|
// Initialize function which calls GetPluginState to check if the plugin is already registered
|
|
HRESULT Initialize();
|
|
|
|
HRESULT RegisterPlugin();
|
|
HRESULT UnregisterPlugin();
|
|
|
|
HRESULT RefreshPluginState();
|
|
|
|
bool IsPluginRegistered() const
|
|
{
|
|
return m_pluginRegistered;
|
|
}
|
|
|
|
EXPERIMENTAL_PLUGIN_AUTHENTICATOR_STATE GetPluginState() const
|
|
{
|
|
return m_pluginState;
|
|
}
|
|
|
|
private:
|
|
EXPERIMENTAL_PLUGIN_AUTHENTICATOR_STATE m_pluginState;
|
|
bool m_initialized = false;
|
|
bool m_pluginRegistered = false;
|
|
wil::unique_hmodule m_webAuthnDll;
|
|
|
|
PluginRegistrationManager();
|
|
~PluginRegistrationManager();
|
|
PluginRegistrationManager(const PluginRegistrationManager&) = delete;
|
|
PluginRegistrationManager& operator=(const PluginRegistrationManager&) = delete;
|
|
|
|
void UpdatePasskeyOperationStatusText(hstring const& statusText)
|
|
{
|
|
com_ptr<App> curApp = winrt::Microsoft::UI::Xaml::Application::Current().as<App>();
|
|
curApp->GetDispatcherQueue().TryEnqueue([curApp, statusText]()
|
|
{
|
|
curApp->m_window.Content().try_as<Microsoft::UI::Xaml::Controls::Frame>().Content().try_as<MainPage>()->UpdatePasskeyOperationStatusText(statusText);
|
|
});
|
|
}
|
|
};
|
|
};
|