From ffc388c5a692a5b35ba3aea6770382ac5d230cc4 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Thu, 28 Sep 2023 08:17:00 -0700 Subject: Visibly warn when we can encourage positive change --- packages/browser/src/methods/startRegistration.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'packages/browser/src') diff --git a/packages/browser/src/methods/startRegistration.ts b/packages/browser/src/methods/startRegistration.ts index 9f4a104..2ad3089 100644 --- a/packages/browser/src/methods/startRegistration.ts +++ b/packages/browser/src/methods/startRegistration.ts @@ -70,7 +70,7 @@ export async function startRegistration( try { responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm(); } catch (error) { - // pass + warnOnBrokenImplementation('getPublicKeyAlgorithm()', error as Error); } } @@ -82,7 +82,7 @@ export async function startRegistration( responsePublicKey = bufferToBase64URLString(_publicKey); } } catch (error) { - // pass + warnOnBrokenImplementation('getPublicKey()', error as Error); } } @@ -94,7 +94,7 @@ export async function startRegistration( response.getAuthenticatorData(), ); } catch (error) { - // pass + warnOnBrokenImplementation('getAuthenticatorData()', error as Error); } } @@ -116,3 +116,14 @@ export async function startRegistration( ), }; } + +/** + * Visibly warn when we detect an issue related to a passkey provider intercepting WebAuthn API + * calls + */ +function warnOnBrokenImplementation(methodName: string, cause: Error): void { + console.warn( + `The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.\n`, + cause, + ); +} -- cgit v1.2.3 From bddfabb5c5331f5c172ead16851f0611997b12b6 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Thu, 28 Sep 2023 08:17:08 -0700 Subject: Silenec warnings during tests --- packages/browser/src/setupTests.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/browser/src') diff --git a/packages/browser/src/setupTests.ts b/packages/browser/src/setupTests.ts index 2ac528a..db41d57 100644 --- a/packages/browser/src/setupTests.ts +++ b/packages/browser/src/setupTests.ts @@ -2,6 +2,7 @@ // jest.spyOn(console, 'log').mockImplementation(); // jest.spyOn(console, 'debug').mockImplementation(); // jest.spyOn(console, 'error').mockImplementation(); +jest.spyOn(console, 'warn').mockImplementation(); /** * JSDom doesn't seem to support `credentials`, so let's define them here so we can mock their -- cgit v1.2.3