Skip to content

Commit ccff17c

Browse files
committed
Fix new error handling in passkey-list
1 parent 047a34e commit ccff17c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Diff for: packages/connect-react/src/components/passkeyList/PasskeyListScreen.tsx

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { CorbadoConnectPasskeyListConfig } from '@corbado/types';
22
import type { ConnectError, Passkey } from '@corbado/web-core';
33
import { ConnectErrorType } from '@corbado/web-core';
4-
import { ExcludeCredentialsMatchError, PasskeyChallengeCancelledError } from '@corbado/web-core';
54
import log from 'loglevel';
65
import React, { useEffect, useRef, useState } from 'react';
76

@@ -96,7 +95,7 @@ const PasskeyListScreen = () => {
9695

9796
const deletePasskeyRes = await getConnectService().manageDelete(deleteToken, credentialsId);
9897
if (deletePasskeyRes.err) {
99-
return handleSituation(PasskeyListSituationCode.CboApiNotAvailableDuringDelete);
98+
return handleSituation(PasskeyListSituationCode.CboApiNotAvailableDuringDelete, deletePasskeyRes.val);
10099
}
101100

102101
await getPasskeyList(config, true);
@@ -120,7 +119,7 @@ const PasskeyListScreen = () => {
120119
const loadedMs = Date.now();
121120
const startAppendRes = await getConnectService().startAppend(appendToken, loadedMs, undefined, true);
122121
if (startAppendRes.err) {
123-
return handleSituation(PasskeyListSituationCode.CboApiNotAvailablePreAuthenticator);
122+
return handleSituation(PasskeyListSituationCode.CboApiNotAvailablePreAuthenticator, startAppendRes.val);
124123
}
125124

126125
if (!startAppendRes.val.attestationOptions) {
@@ -133,15 +132,15 @@ const PasskeyListScreen = () => {
133132

134133
const res = await getConnectService().completeAppend(startAppendRes.val.attestationOptions);
135134
if (res.err) {
136-
if (res.val instanceof PasskeyChallengeCancelledError) {
137-
return handleSituation(PasskeyListSituationCode.ClientPasskeyOperationCancelled);
135+
if (res.val.type === ConnectErrorType.Cancel) {
136+
return handleSituation(PasskeyListSituationCode.ClientPasskeyOperationCancelled, res.val);
138137
}
139138

140-
if (res.val instanceof ExcludeCredentialsMatchError) {
141-
return handleSituation(PasskeyListSituationCode.ClientExcludeCredentialsMatch);
139+
if (res.val.type === ConnectErrorType.ExcludeCredentialsMatch) {
140+
return handleSituation(PasskeyListSituationCode.ClientExcludeCredentialsMatch, res.val);
142141
}
143142

144-
return handleSituation(PasskeyListSituationCode.CboApiNotAvailablePostAuthenticator);
143+
return handleSituation(PasskeyListSituationCode.CboApiNotAvailablePostAuthenticator, res.val);
145144
}
146145

147146
log.debug('get passkey list');
@@ -164,7 +163,7 @@ const PasskeyListScreen = () => {
164163

165164
const passkeyList = await getConnectService().manageList(listTokenRes, triggerSignalAllAccepted);
166165
if (passkeyList.err) {
167-
return handleSituation(PasskeyListSituationCode.CboApiNotAvailableDuringInitialLoad);
166+
return handleSituation(PasskeyListSituationCode.CboApiNotAvailableDuringInitialLoad, passkeyList.val);
168167
}
169168

170169
console.log('passkeyList', passkeyList.val.passkeys);

0 commit comments

Comments
 (0)