Skip to content

Commit

Permalink
Revert "Check DOMException error name instead of error message"
Browse files Browse the repository at this point in the history
This reverts commit 7437de8.
  • Loading branch information
renkelvin committed Apr 17, 2024
1 parent be96f50 commit d838690
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
21 changes: 3 additions & 18 deletions packages/auth/src/core/strategies/passkey.test.ts
Expand Up @@ -96,12 +96,7 @@ describe('passkey', async () => {
}
sinon
.stub(navigator.credentials, 'get')
.throws(
new DOMException(
'The operation either timed out or was not allowed.',
'NotAllowedError'
)
);
.throws(new Error('The operation either timed out or was not allowed.'));

sinon.stub(navigator.credentials, 'create').resolves(mockCredential);

Expand Down Expand Up @@ -171,12 +166,7 @@ describe('passkey', async () => {
}
sinon
.stub(navigator.credentials, 'get')
.throws(
new DOMException(
'The operation either timed out or was not allowed.',
'NotAllowedError'
)
);
.throws(new Error('The operation either timed out or was not allowed.'));

mockEndpoint(Endpoint.START_PASSKEY_SIGNIN, {
credentialRequestOptions: {
Expand Down Expand Up @@ -253,12 +243,7 @@ describe('passkey', async () => {
}
sinon
.stub(navigator.credentials, 'create')
.throws(
new DOMException(
'The operation either timed out or was not allowed.',
'NotAllowedError'
)
);
.throws(new Error('The operation either timed out or was not allowed.'));

mockEndpoint(Endpoint.START_PASSKEY_ENROLLMENT, {
credentialCreationOptions: {
Expand Down
6 changes: 3 additions & 3 deletions packages/auth/src/core/strategies/passkey.ts
Expand Up @@ -42,7 +42,8 @@ import { UserCredentialImpl } from '../user/user_credential_impl';
import { signInAnonymously } from './anonymous';

const DEFAULT_PASSKEY_ACCOUNT_NAME = 'Unnamed account (Web)';
const PASSKEY_LOOK_UP_ERROR_NAME = 'NotAllowedError';
const PASSKEY_LOOK_UP_ERROR_MESSAGE =
'The operation either timed out or was not allowed.';

/**
* Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user.
Expand Down Expand Up @@ -93,8 +94,7 @@ export async function signInWithPasskey(
return userCredential;
} catch (error) {
if (
error instanceof DOMException &&
error.name === PASSKEY_LOOK_UP_ERROR_NAME &&
(error as Error).message.includes(PASSKEY_LOOK_UP_ERROR_MESSAGE) &&
!manualSignUp
) {
// If the user is not signed up, sign them up anonymously
Expand Down

0 comments on commit d838690

Please sign in to comment.