Commit d4dc54e
authored
feat: improve error handling (#762)
* Added error code constants for both platforms.
* Enhanced exception to support error codes
- Added additional overloads to simplify usage.
- Removed need for reThrowOnError (and "Wrapped error: " prefix).
* Removed instances of overwriting the real error.
* Applied correct error codes.
* Added mapping of various BiometricPrompt error codes.
* Added some consistency with Android when an unknown error occurs.
* Removed E_SUPPORTED_BIOMETRY_ERROR error code.
* Renamed CryptoFailedException to KeychainException.
* Made default error code E_UNKNOWN_ERROR.
* Removed CRYPTO_FAILED error code.
* Removed INTERNAL_ERROR error code.
* Improved error code mapping.
* Removed need for E_KEYCHAIN_DUPLICATE_ITEM.
* Removed E_INTERACTIVE_MODE_UNAVAILABLE error.
* Removed KEYCHAIN_INTERACTION_NOT_ALLOWED to IOS_INTERACTION_NOT_ALLOWED.
* Split up some biometric error codes.
* Consolidated error info.
* Removed unnecessary cases.
* Fixed case where rejectWithError could be called with no error.
* Fixed use of wrong error.
* Simplified logic.
* Added support for mapping LocalAuthentication errors.
* Omit extra iOS cancel code until further investigation.
* Moved to generic canceled error code.
* Improved function name.
* Avoid defaulting to unknown errors.
* Correct error code and formatting.
* Fixed mapping of unhandled LA error codes.
* Consolidated E_AUTH_UNKNOWN_ERROR & E_AUTH_FAILED into E_AUTH_ERROR (renamed from E_BIOMETRIC_ERROR).
* Aligned TS enums.
* Default to E_INTERNAL_ERROR when custom errors are thrown.
* More improvements to error codes.
* Removed need for ANDROID_USER_NOT_AUTHENTICATED.
* Refactored & aligned error codes.
* Removed need for E_BIOMETRIC_INSUFFICIENT_SPACE and BIOMETRIC_UNABLE_TO_PROCESS.
* Improved error code names.
* Improved message.
* Fixed iOS build errors.
* Removed AUTH_PERMISSION_DENIED.
* Aligned format of error messages.
* Renamed enum to ERROR_CODE.
* Removed reformatting of unknown errors.
* Consolidated configuration errors.
* Renamed KEY_PERMANENTLY_INVALIDATED to AUTH_INVALIDATED.
* Minor refactor.
* Consolidated E_UNKNOWN_ERROR into E_INTERNAL_ERROR.
* Fixed logic when can't authenticate.
* Wrapped error messages.
* Added documentation alongside error codes.
* Fixed build error.1 parent a057429 commit d4dc54e
File tree
13 files changed
+442
-138
lines changed- android/src/main/java/com/oblador/keychain
- cipherStorage
- exceptions
- resultHandler
- ios/RNKeychainManager
- src
13 files changed
+442
-138
lines changedLines changed: 55 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
102 | 112 | | |
103 | 113 | | |
104 | 114 | | |
| |||
200 | 210 | | |
201 | 211 | | |
202 | 212 | | |
203 | | - | |
204 | | - | |
| 213 | + | |
| 214 | + | |
205 | 215 | | |
206 | | - | |
| 216 | + | |
207 | 217 | | |
208 | 218 | | |
209 | | - | |
| 219 | + | |
210 | 220 | | |
211 | 221 | | |
212 | 222 | | |
| |||
224 | 234 | | |
225 | 235 | | |
226 | 236 | | |
227 | | - | |
| 237 | + | |
228 | 238 | | |
229 | 239 | | |
230 | 240 | | |
| |||
269 | 279 | | |
270 | 280 | | |
271 | 281 | | |
272 | | - | |
273 | | - | |
| 282 | + | |
| 283 | + | |
274 | 284 | | |
275 | | - | |
| 285 | + | |
276 | 286 | | |
277 | 287 | | |
278 | | - | |
| 288 | + | |
279 | 289 | | |
280 | 290 | | |
281 | 291 | | |
| |||
287 | 297 | | |
288 | 298 | | |
289 | 299 | | |
290 | | - | |
| 300 | + | |
291 | 301 | | |
292 | 302 | | |
293 | 303 | | |
| |||
329 | 339 | | |
330 | 340 | | |
331 | 341 | | |
332 | | - | |
| 342 | + | |
333 | 343 | | |
334 | 344 | | |
335 | | - | |
| 345 | + | |
336 | 346 | | |
337 | 347 | | |
338 | 348 | | |
| |||
397 | 407 | | |
398 | 408 | | |
399 | 409 | | |
400 | | - | |
| 410 | + | |
401 | 411 | | |
402 | 412 | | |
403 | 413 | | |
| |||
417 | 427 | | |
418 | 428 | | |
419 | 429 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | 430 | | |
424 | 431 | | |
425 | | - | |
| 432 | + | |
426 | 433 | | |
427 | 434 | | |
428 | 435 | | |
| |||
442 | 449 | | |
443 | 450 | | |
444 | 451 | | |
445 | | - | |
| 452 | + | |
446 | 453 | | |
447 | 454 | | |
448 | 455 | | |
| |||
472 | 479 | | |
473 | 480 | | |
474 | 481 | | |
475 | | - | |
| 482 | + | |
476 | 483 | | |
477 | 484 | | |
478 | 485 | | |
| |||
487 | 494 | | |
488 | 495 | | |
489 | 496 | | |
490 | | - | |
491 | | - | |
492 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
493 | 503 | | |
494 | 504 | | |
495 | 505 | | |
496 | 506 | | |
497 | 507 | | |
498 | | - | |
| 508 | + | |
499 | 509 | | |
500 | 510 | | |
501 | 511 | | |
| |||
506 | 516 | | |
507 | 517 | | |
508 | 518 | | |
509 | | - | |
510 | | - | |
511 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
512 | 525 | | |
513 | 526 | | |
514 | 527 | | |
| |||
526 | 539 | | |
527 | 540 | | |
528 | 541 | | |
529 | | - | |
| 542 | + | |
530 | 543 | | |
531 | 544 | | |
532 | 545 | | |
| |||
563 | 576 | | |
564 | 577 | | |
565 | 578 | | |
566 | | - | |
| 579 | + | |
567 | 580 | | |
568 | 581 | | |
569 | 582 | | |
| |||
594 | 607 | | |
595 | 608 | | |
596 | 609 | | |
597 | | - | |
| 610 | + | |
598 | 611 | | |
599 | 612 | | |
600 | 613 | | |
| |||
641 | 654 | | |
642 | 655 | | |
643 | 656 | | |
644 | | - | |
| 657 | + | |
645 | 658 | | |
646 | 659 | | |
647 | 660 | | |
| |||
799 | 812 | | |
800 | 813 | | |
801 | 814 | | |
802 | | - | |
| 815 | + | |
803 | 816 | | |
804 | 817 | | |
805 | 818 | | |
806 | 819 | | |
807 | | - | |
| 820 | + | |
808 | 821 | | |
809 | 822 | | |
810 | 823 | | |
811 | 824 | | |
812 | | - | |
| 825 | + | |
| 826 | + | |
813 | 827 | | |
814 | 828 | | |
815 | 829 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
Lines changed: 9 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | | - | |
| 168 | + | |
168 | 169 | | |
169 | 170 | | |
170 | | - | |
171 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| |||
328 | 330 | | |
329 | 331 | | |
330 | 332 | | |
331 | | - | |
| 333 | + | |
332 | 334 | | |
333 | 335 | | |
334 | 336 | | |
| |||
351 | 353 | | |
352 | 354 | | |
353 | 355 | | |
354 | | - | |
| 356 | + | |
355 | 357 | | |
356 | 358 | | |
357 | 359 | | |
| |||
402 | 404 | | |
403 | 405 | | |
404 | 406 | | |
405 | | - | |
| 407 | + | |
406 | 408 | | |
407 | 409 | | |
408 | 410 | | |
| |||
Lines changed: 5 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
100 | 98 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 99 | + | |
105 | 100 | | |
106 | 101 | | |
107 | 102 | | |
108 | 103 | | |
109 | 104 | | |
110 | | - | |
| 105 | + | |
111 | 106 | | |
112 | 107 | | |
113 | 108 | | |
| |||
129 | 124 | | |
130 | 125 | | |
131 | 126 | | |
132 | | - | |
| 127 | + | |
133 | 128 | | |
134 | 129 | | |
135 | 130 | | |
| |||
0 commit comments