Skip to content

Commit 629e2e9

Browse files
authored
Catch more cancels during passkey login (#549)
1 parent 71fc755 commit 629e2e9

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

packages/connect-react/src/components/login/LoginErrorScreenSoft.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const LoginErrorScreenSoft = ({ previousAssertionOptions }: Props) => {
4444

4545
const resFinish = await getConnectService().loginContinue(resStart.val);
4646
if (resFinish.err) {
47-
if (resFinish.val.type === ConnectErrorType.Cancel) {
47+
if (resFinish.val.type === ConnectErrorType.Cancel || resFinish.val.type === ConnectErrorType.Untyped) {
4848
return handleSituation(
4949
LoginSituationCode.ClientPasskeyOperationCancelled,
5050
resFinish.val,

packages/connect-react/src/components/login/LoginHybridScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const LoginHybridScreen = (resStart: ConnectLoginStartRsp) => {
2424
setLoading(true);
2525
const res = await getConnectService().loginContinue(resStart);
2626
if (res.err) {
27-
if (res.val.type === ConnectErrorType.Cancel) {
27+
if (res.val.type === ConnectErrorType.Cancel || res.val.type === ConnectErrorType.Untyped) {
2828
return handleSituation(LoginSituationCode.ClientPasskeyOperationCancelled, res.val);
2929
}
3030

packages/connect-react/src/components/login/LoginInitScreen.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const LoginInitScreen: FC<Props> = ({ showFallback = false }) => {
103103

104104
const res = await getConnectService().loginInit(ac);
105105
if (res.err) {
106-
if (res.val.type === ConnectErrorType.Cancel) {
106+
if (res.val.type === ConnectErrorType.Cancel || res.val.type === ConnectErrorType.Untyped) {
107107
return;
108108
}
109109

@@ -163,7 +163,7 @@ const LoginInitScreen: FC<Props> = ({ showFallback = false }) => {
163163

164164
if (res.err) {
165165
// if a user cancel during CUI, she can try again
166-
if (res.val.type === ConnectErrorType.Cancel) {
166+
if (res.val.type === ConnectErrorType.Cancel || res.val.type === ConnectErrorType.Untyped) {
167167
return handleSituation(LoginSituationCode.ClientPasskeyConditionalOperationCancelled, res.val);
168168
}
169169

@@ -230,7 +230,7 @@ const LoginInitScreen: FC<Props> = ({ showFallback = false }) => {
230230
const res = await getConnectService().loginContinue(resStart.val);
231231
if (res.err) {
232232
setIdentifierBasedLoading(false);
233-
if (res.val.type === ConnectErrorType.Cancel) {
233+
if (res.val.type === ConnectErrorType.Cancel || res.val.type === ConnectErrorType.Untyped) {
234234
return handleSituation(
235235
LoginSituationCode.ClientPasskeyOperationCancelled,
236236
res.val,

packages/connect-react/src/components/login/LoginPasskeyReLoginScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const LoginPasskeyReLoginScreen = () => {
4949

5050
const resFinish = await getConnectService().loginContinue(resStart.val);
5151
if (resFinish.err) {
52-
if (resFinish.val.type === ConnectErrorType.Cancel) {
52+
if (resFinish.val.type === ConnectErrorType.Cancel || resFinish.val.type === ConnectErrorType.Untyped) {
5353
return handleSituation(LoginSituationCode.ClientPasskeyOperationCancelled, resFinish.val);
5454
}
5555

packages/connect-react/src/components/passkeyList/PasskeyListScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ const PasskeyListScreen = () => {
188188
case PasskeyListSituationCode.ClientExcludeCredentialsMatch:
189189
setAppendLoading(false);
190190
void getConnectService().recordEventAppendCredentialExistsError(
191-
attestationOptions ?? '',
192191
`${messageCode} ${error?.track()}`,
192+
attestationOptions ?? '',
193193
);
194194
show(<AlreadyExistingModal hide={hide} />);
195195
break;

packages/web-core/src/utils/errors/connectErrors.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export enum ConnectErrorType {
99
SecurityError,
1010
ExcludeCredentialsMatch,
1111
RaceTimeout,
12+
Untyped,
1213
}
1314

1415
export class ConnectError {
@@ -68,7 +69,7 @@ export class ConnectError {
6869
case 'InvalidStateError':
6970
return new ConnectError(ConnectErrorType.ExcludeCredentialsMatch, e.message, runtime);
7071
default:
71-
return new ConnectError(ConnectErrorType.InvalidState, e.message, runtime);
72+
return new ConnectError(ConnectErrorType.Untyped, e.message, runtime);
7273
}
7374
}
7475

@@ -77,9 +78,9 @@ export class ConnectError {
7778
return new ConnectError(ConnectErrorType.Cancel, e.message);
7879
}
7980

80-
return new ConnectError(ConnectErrorType.InvalidState, e.message);
81+
return new ConnectError(ConnectErrorType.Untyped, e.message);
8182
}
8283

83-
return new ConnectError(ConnectErrorType.InvalidState, `unknown ${e}`);
84+
return new ConnectError(ConnectErrorType.Untyped, `unknown ${e}`);
8485
}
8586
}

0 commit comments

Comments
 (0)