Skip to content

Commit

Permalink
Android Auth Required, Fallback Added, Error Codes Consolidated
Browse files Browse the repository at this point in the history
WIP: Add Android .gitignore
WIP: Android .gitignore is now working
WIP: Android Error Codes, Updates to project level Git Ignore.
WIP: Add iOS .gitignore
WIP: iOS .gitignore is now working
WIP: Android Device Credentials Fallback
WIP: Always Invalidate on biometric enrollment
WIP: Consolidate Error Codes Between iOS and Android
WIP: Fix Swift Issues
WIP: Update comments before submission.
  • Loading branch information
brian-weasner committed Dec 2, 2022
1 parent a5b8da1 commit ca69b73
Show file tree
Hide file tree
Showing 535 changed files with 434 additions and 895,511 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea/
dist/
dist/
/node_modules
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contributing

## Submitting a Pull Request (PR)

Before you submit your Pull Request (PR) consider the following guidelines:

1. Search GitHub for an open or closed PR that relates to your submission. You don't want to duplicate existing efforts.

2. Be sure that an issue describes the problem you're fixing, or documents the design for the feature you'd like to add. Discussing the design upfront helps to ensure that we're ready to accept your work.

3. Fork the repo.

4. In your forked repository, make your changes in a new git branch:
- `git checkout -b branch-name-foo`

5. Npm install dependencies
- `npm ci` (clean install)

6. Symlink repo as `capacitor-native-biometric` package to your capacitor application for easy development via [`npm link`](https://docs.npmjs.com/cli/v8/commands/npm-link)
1. In `capacitor-native-biometric` repo root, where package.json is, run `npm link`

2. In the root of your capacitor application that uses `capacitor-native-biometric`, where package.json is, run `npm link capacitor-native-biometric`

7. Make and commit changes
- `git commit --all`

8. Push your branch to GitHub:
- `git push origin branch-name-foo`

9. In GitHub, send a pull request to `capacitor-native-biometric`
48 changes: 29 additions & 19 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ NativeBiometric.deleteCredentials({
| Method | Default | Type | Description |
| ----------------------------------------------------- | ------- | -------------------------- | --------------------------------------------------------------------------------------------- |
| `isAvailable(options?: IsAvailableOptions)` | | `Promise<AvailableResult>` | Gets available biometrics |
| `verifyIdentity(options?: BiometricOptions)` | | `Promise<any>` | Shows biometric prompt |
| `setCredentials(options: SetCredentialOptions)` | | `Promise<any>` | Securely stores user's credentials in Keychain (iOS) or encypts them using Keystore (Android) |
| `verifyIdentity(options?: BiometricOptions)` | | `Promise<void>` | Shows biometric prompt |
| `setCredentials(options: SetCredentialOptions)` | | `Promise<void>` | Securely stores user's credentials in Keychain (iOS) or encypts them using Keystore (Android) |
| `getCredentials(options: GetCredentialOptions)` | | `Promise<Credentials>` | Retrieves user's credentials if any |
| `deleteCredentials(options: DeleteCredentialOptions)` | | `Promise<any>` | Removes user's credentials if any |
| `deleteCredentials(options: DeleteCredentialOptions)` | | `Promise<void>` | Removes user's credentials if any |

## Interfaces

Expand All @@ -71,7 +71,7 @@ NativeBiometric.deleteCredentials({
| -------------- | ------- | -------------- | -------------------------------------------------------- |
| `isAvailable` | | `boolean` | Specifies if the devices has biometric enrollment |
| `biometryType` | | `BiometryType` | Specifies the available biometric hardware on the device |
| `errorCode?` | | `number` | Error code returned by the native API |
| `errorCode?` | | `number` | Biometric Auth Error Code |

### BiometryType - enum

Expand All @@ -95,21 +95,27 @@ NativeBiometric.deleteCredentials({
| `description?` | | `string` | Description for the Android prompt |
| `negativeButtonText?` | "Cancel" | `string` | Text for the negative button displayed on Android |
| `maxAttempts?` | 1 | `number` | Limit the number of attempts a user can perform biometric authentication. (Android - Max 5) |
| `useFallback?` | `false` | `boolean` | Specifies if the device should fallback to using passcode authentication.(Android - Max 5) |

### VerifyIdentityErrors

| code | Description |
| ---- | ------------------------------- |
| "0" | Biometrics error or unavailable |
| "10" | authenticationFailed |
| "11" | appCancel |
| "12" | invalidContext |
| "13" | notInteractive |
| "14" | passcodeNotSet |
| "15" | systemCancel |
| "16" | userCancel |
| "17" | userFallback |
| `useFallback?` | `false` | `boolean` | Specifies if the device should fallback to using passcode authentication. |

### Biometric Auth Errors

This is a plugin specific list of error codes that can be thrown on verifyIdentity failure, or set as a part of isAvailable. It consolidates Android and iOS specific Authentication Error codes into one combined error list.

| Code | Description | Platform |
| ---- | --------------------------- | ---------------------------- |
| 0 | Unknown Error | Android, iOS |
| 1 | Biometrics Unavailable | Android, iOS |
| 2 | User Lockout | Android, iOS |
| 3 | Biometrics Not Enrolled | Android, iOS |
| 4 | User Temporary Lockout | Android (Lockout for 30sec) |
| 10 | Authentication Failed | Android, iOS |
| 11 | App Cancel | iOS |
| 12 | Invalid Context | iOS |
| 13 | Not Interactive | iOS |
| 14 | Passcode Not Set | Android, iOS |
| 15 | System Cancel | Android, iOS |
| 16 | User Cancel | Android, iOS |
| 17 | User Fallback | Android, iOS |

### SetCredentialOptions

Expand Down Expand Up @@ -182,6 +188,10 @@ public class MainActivity extends BridgeActivity {
[Jonthia](https://github.com/jonthia)
[One Click Web Studio](https://github.com/oneclickwebstudio)

### Want to Contribute?

Learn about contributing [HERE](./CONTRIBUTING.md)

## Notes

Hasn't been tested on Android API level 22 or lower.
35 changes: 35 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Using Android gitignore template: https://github.com/github/gitignore/blob/main/Android.gitignore

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Log/OS Files
*.log

# Android Studio generated files and folders
captures/
.externalNativeBuild/
.cxx/
*.apk
output.json

# IntelliJ
*.iml
.idea/
misc.xml
deploymentTargetDropDown.xml
render.experimental.xml

# Keystore files
*.jks
*.keystore

# Google Services (e.g. APIs or Firebase)
google-services.json

# Android Profiling
*.hprof
Binary file not shown.
Binary file not shown.
Binary file removed android/.gradle/5.6.4/fileChanges/last-build.bin
Binary file not shown.
Binary file removed android/.gradle/5.6.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed android/.gradle/5.6.4/fileHashes/fileHashes.lock
Binary file not shown.
Empty file.
Binary file not shown.
2 changes: 0 additions & 2 deletions android/.gradle/buildOutputCleanup/cache.properties

This file was deleted.

Binary file removed android/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Empty file.
Binary file removed android/.idea/caches/build_file_checksums.ser
Binary file not shown.
116 changes: 0 additions & 116 deletions android/.idea/codeStyles/Project.xml

This file was deleted.

6 changes: 0 additions & 6 deletions android/.idea/compiler.xml

This file was deleted.

20 changes: 0 additions & 20 deletions android/.idea/gradle.xml

This file was deleted.

30 changes: 0 additions & 30 deletions android/.idea/jarRepositories.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ca69b73

Please sign in to comment.