1
1
import type { CorbadoConnectPasskeyListConfig } from '@corbado/types' ;
2
2
import type { ConnectError , Passkey } from '@corbado/web-core' ;
3
3
import { ConnectErrorType } from '@corbado/web-core' ;
4
- import { ExcludeCredentialsMatchError , PasskeyChallengeCancelledError } from '@corbado/web-core' ;
5
4
import log from 'loglevel' ;
6
5
import React , { useEffect , useRef , useState } from 'react' ;
7
6
@@ -96,7 +95,7 @@ const PasskeyListScreen = () => {
96
95
97
96
const deletePasskeyRes = await getConnectService ( ) . manageDelete ( deleteToken , credentialsId ) ;
98
97
if ( deletePasskeyRes . err ) {
99
- return handleSituation ( PasskeyListSituationCode . CboApiNotAvailableDuringDelete ) ;
98
+ return handleSituation ( PasskeyListSituationCode . CboApiNotAvailableDuringDelete , deletePasskeyRes . val ) ;
100
99
}
101
100
102
101
await getPasskeyList ( config , true ) ;
@@ -120,7 +119,7 @@ const PasskeyListScreen = () => {
120
119
const loadedMs = Date . now ( ) ;
121
120
const startAppendRes = await getConnectService ( ) . startAppend ( appendToken , loadedMs , undefined , true ) ;
122
121
if ( startAppendRes . err ) {
123
- return handleSituation ( PasskeyListSituationCode . CboApiNotAvailablePreAuthenticator ) ;
122
+ return handleSituation ( PasskeyListSituationCode . CboApiNotAvailablePreAuthenticator , startAppendRes . val ) ;
124
123
}
125
124
126
125
if ( ! startAppendRes . val . attestationOptions ) {
@@ -133,15 +132,15 @@ const PasskeyListScreen = () => {
133
132
134
133
const res = await getConnectService ( ) . completeAppend ( startAppendRes . val . attestationOptions ) ;
135
134
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 ) ;
138
137
}
139
138
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 ) ;
142
141
}
143
142
144
- return handleSituation ( PasskeyListSituationCode . CboApiNotAvailablePostAuthenticator ) ;
143
+ return handleSituation ( PasskeyListSituationCode . CboApiNotAvailablePostAuthenticator , res . val ) ;
145
144
}
146
145
147
146
log . debug ( 'get passkey list' ) ;
@@ -164,7 +163,7 @@ const PasskeyListScreen = () => {
164
163
165
164
const passkeyList = await getConnectService ( ) . manageList ( listTokenRes , triggerSignalAllAccepted ) ;
166
165
if ( passkeyList . err ) {
167
- return handleSituation ( PasskeyListSituationCode . CboApiNotAvailableDuringInitialLoad ) ;
166
+ return handleSituation ( PasskeyListSituationCode . CboApiNotAvailableDuringInitialLoad , passkeyList . val ) ;
168
167
}
169
168
170
169
console . log ( 'passkeyList' , passkeyList . val . passkeys ) ;
0 commit comments