mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
Implements a browser-based WebAuthn fallback for biometric key creation and authentication, improving reliability of Touch ID prompts on macOS, especially when Electron's embedded WebAuthn flow fails. Integrates helper flows, IPC, and UI feedback to guide users through the browser prompt and ensure cross-platform consistency.
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { useCallback } from "react";
|
|
import { netcattyBridge } from "../../infrastructure/services/netcattyBridge";
|
|
|
|
export const useWebAuthnBackend = () => {
|
|
const hasBrowserWebAuthn = useCallback(() => {
|
|
return !!netcattyBridge.get()?.webauthnCreateCredentialInBrowser;
|
|
}, []);
|
|
|
|
const createCredentialInBrowser = useCallback(
|
|
async (options: WebAuthnBrowserCreateOptions) => {
|
|
const bridge = netcattyBridge.get();
|
|
if (!bridge?.webauthnCreateCredentialInBrowser) {
|
|
throw new Error("webauthnCreateCredentialInBrowser unavailable");
|
|
}
|
|
return bridge.webauthnCreateCredentialInBrowser(options);
|
|
},
|
|
[],
|
|
);
|
|
|
|
const getAssertionInBrowser = useCallback(
|
|
async (options: WebAuthnBrowserGetOptions) => {
|
|
const bridge = netcattyBridge.get();
|
|
if (!bridge?.webauthnGetAssertionInBrowser) {
|
|
throw new Error("webauthnGetAssertionInBrowser unavailable");
|
|
}
|
|
return bridge.webauthnGetAssertionInBrowser(options);
|
|
},
|
|
[],
|
|
);
|
|
|
|
return { hasBrowserWebAuthn, createCredentialInBrowser, getAssertionInBrowser };
|
|
};
|
|
|