@@ -44,16 +44,19 @@ export default function reportError(error: unknown, hint?: Parameters<typeof cap
4444 return classification ;
4545}
4646
47- const passkeyCancelledMessages = new Set ( [
48- "The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1001.)" ,
49- "The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1004.)" ,
50- "The operation couldn’t be completed. Device must be unlocked to perform request." ,
51- "UserCancelled" ,
52- ] ) ;
53- const passkeyKnownMessages = new Set ( [
54- ...passkeyCancelledMessages ,
55- "The operation couldn’t be completed. Stolen Device Protection is enabled and biometry is required." ,
56- ] ) ;
47+ const passkeyCancelledCodes = new Set ( [ "ERR_USER_CANCELLED" , "ERR_PASSKEY_REQUEST_FAILED" ] ) ;
48+ const passkeyCancelledPatterns = [
49+ / c o m \. a p p l e \. A u t h e n t i c a t i o n S e r v i c e s \. A u t h o r i z a t i o n E r r o r \D + \b 1 0 0 1 \b / i,
50+ / c o m \. a p p l e \. A u t h e n t i c a t i o n S e r v i c e s \. A u t h o r i z a t i o n E r r o r \D + \b 1 0 0 4 \b / i,
51+ / ^ U s e r C a n c e l l e d $ / ,
52+ ] ;
53+ const passkeyKnownCodes = new Set ( [ ...passkeyCancelledCodes , "ERR_PENDING_PASSKEY_REQUEST" ] ) ;
54+ const passkeyKnownPatterns = [
55+ ...passkeyCancelledPatterns ,
56+ / c o m \. a p p l e \. A u t h e n t i c a t i o n S e r v i c e s \. A u t h o r i z a t i o n E r r o r / i,
57+ / B i o m e t r i c s m u s t b e e n a b l e d / ,
58+ / T h e r e i s a l r e a d y a p e n d i n g p a s s k e y r e q u e s t / ,
59+ ] ;
5760const authPrefixes = [ "androidx.credentials.exceptions.domerrors.NotAllowedError" ] ;
5861const networkTypes = [
5962 [ "ConnectionLost" , / n e t w o r k c o n n e c t i o n w a s l o s t / i] ,
@@ -109,13 +112,14 @@ function parseError(error: unknown) {
109112function classify ( { code, message, name, reason, revert, status } : ParsedError ) {
110113 const passkeyNotAllowed =
111114 name === "NotAllowedError" || ( message !== undefined && authPrefixes . some ( ( prefix ) => message . startsWith ( prefix ) ) ) ;
112- const passkeyCancelled = message !== undefined && passkeyCancelledMessages . has ( message ) ;
115+ const passkeyCancelled =
116+ ( code !== undefined && passkeyCancelledCodes . has ( code ) ) ||
117+ ( message !== undefined && passkeyCancelledPatterns . some ( ( pattern ) => pattern . test ( message ) ) ) ;
113118 const passkeyKnown =
114- message !== undefined &&
115- ( passkeyKnownMessages . has ( message ) ||
116- message . includes ( "Biometrics must be enabled" ) ||
117- message . includes ( "There is already a pending passkey request" ) ||
118- authPrefixes . some ( ( prefix ) => message . startsWith ( prefix ) ) ) ;
119+ ( code !== undefined && passkeyKnownCodes . has ( code ) ) ||
120+ ( message !== undefined &&
121+ ( passkeyKnownPatterns . some ( ( pattern ) => pattern . test ( message ) ) ||
122+ authPrefixes . some ( ( prefix ) => message . startsWith ( prefix ) ) ) ) ;
119123 const passkeyWarning = passkeyKnown && ! passkeyCancelled && ! passkeyNotAllowed ;
120124 const biometric = code === "ERR_BIOMETRIC" ;
121125 const walletRejected = status === "4001" || status === "5000" ;
0 commit comments