1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 06:13:38 +00:00

[PM-4704] feat: filter non-webauthn calls to credmanager apis (#6803)

This commit is contained in:
Andreas Coroiu
2023-11-06 16:42:39 +01:00
committed by GitHub
parent ffab1e31e2
commit e88d0acc8d

View File

@@ -66,6 +66,10 @@ navigator.credentials.create = async (
options?: CredentialCreationOptions, options?: CredentialCreationOptions,
abortController?: AbortController abortController?: AbortController
): Promise<Credential> => { ): Promise<Credential> => {
if (!isWebauthnCall(options)) {
return await browserCredentials.create(options);
}
const fallbackSupported = const fallbackSupported =
(options?.publicKey?.authenticatorSelection.authenticatorAttachment === "platform" && (options?.publicKey?.authenticatorSelection.authenticatorAttachment === "platform" &&
browserNativeWebauthnPlatformAuthenticatorSupport) || browserNativeWebauthnPlatformAuthenticatorSupport) ||
@@ -106,6 +110,10 @@ navigator.credentials.get = async (
options?: CredentialRequestOptions, options?: CredentialRequestOptions,
abortController?: AbortController abortController?: AbortController
): Promise<Credential> => { ): Promise<Credential> => {
if (!isWebauthnCall(options)) {
return await browserCredentials.get(options);
}
const fallbackSupported = browserNativeWebauthnSupport; const fallbackSupported = browserNativeWebauthnSupport;
try { try {
@@ -141,6 +149,10 @@ navigator.credentials.get = async (
} }
}; };
function isWebauthnCall(options?: CredentialCreationOptions | CredentialRequestOptions) {
return options && "publicKey" in options;
}
/** /**
* Wait for window to be focused. * Wait for window to be focused.
* Safari doesn't allow scripts to trigger webauthn when window is not focused. * Safari doesn't allow scripts to trigger webauthn when window is not focused.