@capgo/capacitor-native-biometric 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/CapgoCapacitorNativeBiometric.podspec +13 -0
  2. package/LICENSE +21 -0
  3. package/android/.gradle/8.0.2/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.0.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  5. package/android/.gradle/8.0.2/dependencies-accessors/gc.properties +0 -0
  6. package/android/.gradle/8.0.2/executionHistory/executionHistory.bin +0 -0
  7. package/android/.gradle/8.0.2/executionHistory/executionHistory.lock +0 -0
  8. package/android/.gradle/8.0.2/fileChanges/last-build.bin +0 -0
  9. package/android/.gradle/8.0.2/fileHashes/fileHashes.bin +0 -0
  10. package/android/.gradle/8.0.2/fileHashes/fileHashes.lock +0 -0
  11. package/android/.gradle/8.0.2/fileHashes/resourceHashesCache.bin +0 -0
  12. package/android/.gradle/8.0.2/gc.properties +0 -0
  13. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  14. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  15. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  16. package/android/.gradle/vcs-1/gc.properties +0 -0
  17. package/android/android.iml +40 -0
  18. package/android/build.gradle +59 -0
  19. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  20. package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  21. package/android/gradle.properties +20 -0
  22. package/android/gradlew +244 -0
  23. package/android/gradlew.bat +92 -0
  24. package/android/local.properties +8 -0
  25. package/android/proguard-rules.pro +21 -0
  26. package/android/settings.gradle +2 -0
  27. package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +28 -0
  28. package/android/src/main/AndroidManifest.xml +12 -0
  29. package/android/src/main/java/ee/forgr/biometric/AuthActivity.java +129 -0
  30. package/android/src/main/java/ee/forgr/biometric/NativeBiometric.java +457 -0
  31. package/android/src/main/res/layout/activity_auth_acitivy.xml +12 -0
  32. package/android/src/main/res/layout/bridge_layout_main.xml +15 -0
  33. package/android/src/main/res/navigation/nav_graph.xml +28 -0
  34. package/android/src/main/res/values/colors.xml +3 -0
  35. package/android/src/main/res/values/dimens.xml +3 -0
  36. package/android/src/main/res/values/strings.xml +12 -0
  37. package/android/src/main/res/values/styles.xml +16 -0
  38. package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +18 -0
  39. package/dist/docs.json +426 -0
  40. package/dist/esm/definitions.d.ts +91 -0
  41. package/dist/esm/definitions.js +11 -0
  42. package/dist/esm/definitions.js.map +1 -0
  43. package/dist/esm/index.d.ts +4 -0
  44. package/dist/esm/index.js +7 -0
  45. package/dist/esm/index.js.map +1 -0
  46. package/dist/esm/web.d.ts +10 -0
  47. package/dist/esm/web.js +22 -0
  48. package/dist/esm/web.js.map +1 -0
  49. package/dist/plugin.cjs.js +47 -0
  50. package/dist/plugin.cjs.js.map +1 -0
  51. package/dist/plugin.js +50 -0
  52. package/dist/plugin.js.map +1 -0
  53. package/ios/Plugin/Info.plist +24 -0
  54. package/ios/Plugin/Plugin.h +10 -0
  55. package/ios/Plugin/Plugin.m +12 -0
  56. package/ios/Plugin/Plugin.swift +264 -0
  57. package/ios/Plugin.xcodeproj/project.pbxproj +554 -0
  58. package/ios/Plugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  59. package/ios/Plugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  60. package/ios/Plugin.xcodeproj/project.xcworkspace/xcuserdata/pilito.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  61. package/ios/Plugin.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  62. package/ios/Plugin.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  63. package/ios/Plugin.xcodeproj/xcuserdata/pilito.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  64. package/ios/Plugin.xcworkspace/contents.xcworkspacedata +10 -0
  65. package/ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  66. package/ios/Plugin.xcworkspace/xcuserdata/jmartinez.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  67. package/ios/Plugin.xcworkspace/xcuserdata/josemartinez.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  68. package/ios/Plugin.xcworkspace/xcuserdata/pilito.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  69. package/ios/PluginTests/Info.plist +22 -0
  70. package/ios/PluginTests/PluginTests.swift +35 -0
  71. package/ios/Podfile +16 -0
  72. package/ios/Podfile.lock +22 -0
  73. package/ios/Pods/Local Podspecs/Capacitor.podspec.json +34 -0
  74. package/ios/Pods/Local Podspecs/CapacitorCordova.podspec.json +26 -0
  75. package/ios/Pods/Manifest.lock +22 -0
  76. package/ios/Pods/Pods.xcodeproj/project.pbxproj +1626 -0
  77. package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/Capacitor.xcscheme +60 -0
  78. package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +58 -0
  79. package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +58 -0
  80. package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +58 -0
  81. package/ios/Pods/Pods.xcodeproj/xcuserdata/jmartinez.xcuserdatad/xcschemes/xcschememanagement.plist +39 -0
  82. package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/Capacitor.xcscheme +60 -0
  83. package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +58 -0
  84. package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +58 -0
  85. package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +58 -0
  86. package/ios/Pods/Pods.xcodeproj/xcuserdata/josemartinez.xcuserdatad/xcschemes/xcschememanagement.plist +39 -0
  87. package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/Capacitor.xcscheme +58 -0
  88. package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +58 -0
  89. package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +58 -0
  90. package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +58 -0
  91. package/ios/Pods/Pods.xcodeproj/xcuserdata/martindonadieu.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
  92. package/ios/Pods/Pods.xcodeproj/xcuserdata/pilito.xcuserdatad/xcschemes/xcschememanagement.plist +29 -0
  93. package/ios/Pods/Target Support Files/Capacitor/Capacitor-Info.plist +26 -0
  94. package/ios/Pods/Target Support Files/Capacitor/Capacitor-dummy.m +5 -0
  95. package/ios/Pods/Target Support Files/Capacitor/Capacitor-prefix.pch +12 -0
  96. package/ios/Pods/Target Support Files/Capacitor/Capacitor-umbrella.h +23 -0
  97. package/ios/Pods/Target Support Files/Capacitor/Capacitor.debug.xcconfig +16 -0
  98. package/ios/Pods/Target Support Files/Capacitor/Capacitor.modulemap +8 -0
  99. package/ios/Pods/Target Support Files/Capacitor/Capacitor.release.xcconfig +16 -0
  100. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-Info.plist +26 -0
  101. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-dummy.m +5 -0
  102. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-prefix.pch +12 -0
  103. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-umbrella.h +32 -0
  104. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.debug.xcconfig +13 -0
  105. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.modulemap +6 -0
  106. package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.release.xcconfig +13 -0
  107. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-Info.plist +26 -0
  108. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-acknowledgements.markdown +53 -0
  109. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-acknowledgements.plist +91 -0
  110. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-dummy.m +5 -0
  111. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-umbrella.h +16 -0
  112. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.debug.xcconfig +14 -0
  113. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.modulemap +6 -0
  114. package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig +14 -0
  115. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-Info.plist +26 -0
  116. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-acknowledgements.markdown +53 -0
  117. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-acknowledgements.plist +91 -0
  118. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-dummy.m +5 -0
  119. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-frameworks.sh +188 -0
  120. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-umbrella.h +16 -0
  121. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.debug.xcconfig +15 -0
  122. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.modulemap +6 -0
  123. package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.release.xcconfig +15 -0
  124. package/package.json +80 -0
  125. package/readme.md +284 -0
package/readme.md ADDED
@@ -0,0 +1,284 @@
1
+ # Capacitor Native Biometric
2
+
3
+ Use biometrics confirm device owner presence or authenticate users. A couple of methods are provided to handle user credentials. These are securely stored using Keychain (iOS) and Keystore (Android).
4
+
5
+ ## Installation (Only supports Capacitor 3 and 4)
6
+
7
+ - `npm i capacitor-native-biometric`
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { NativeBiometric } from "capacitor-native-biometric";
13
+
14
+ async performBiometricVerificatin(){
15
+ const result = await NativeBiometric.isAvailable();
16
+
17
+ if(!result.isAvailable) return;
18
+
19
+ const isFaceID = result.biometryType == BiometryType.FACE_ID;
20
+
21
+ const verified = await NativeBiometric.verifyIdentity({
22
+ reason: "For easy log in",
23
+ title: "Log in",
24
+ subtitle: "Maybe add subtitle here?",
25
+ description: "Maybe a description too?",
26
+ })
27
+ .then(() => true)
28
+ .catch(() => false);
29
+
30
+ if(!verified) return;
31
+
32
+ const credentials = await NativeBiometric.getCredentials({
33
+ server: "www.example.com",
34
+ });
35
+ }
36
+
37
+ // Save user's credentials
38
+ NativeBiometric.setCredentials({
39
+ username: "username",
40
+ password: "password",
41
+ server: "www.example.com",
42
+ }).then();
43
+
44
+ // Delete user's credentials
45
+ NativeBiometric.deleteCredentials({
46
+ server: "www.example.com",
47
+ }).then();
48
+ ```
49
+ <docgen-index>
50
+
51
+ * [`isAvailable(...)`](#isavailable)
52
+ * [`verifyIdentity(...)`](#verifyidentity)
53
+ * [`getCredentials(...)`](#getcredentials)
54
+ * [`setCredentials(...)`](#setcredentials)
55
+ * [`deleteCredentials(...)`](#deletecredentials)
56
+ * [Interfaces](#interfaces)
57
+ * [Enums](#enums)
58
+
59
+ </docgen-index>
60
+
61
+ <docgen-api>
62
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
63
+
64
+ ### isAvailable(...)
65
+
66
+ ```typescript
67
+ isAvailable(options?: IsAvailableOptions) => any
68
+ ```
69
+
70
+ Checks if biometric authentication hardware is available.
71
+
72
+ | Param | Type |
73
+ | ------------- | ----------------------------------------------------------------- |
74
+ | **`options`** | <code><a href="#isavailableoptions">IsAvailableOptions</a></code> |
75
+
76
+ **Returns:** <code>any</code>
77
+
78
+ **Since:** 1.0.0
79
+
80
+ --------------------
81
+
82
+
83
+ ### verifyIdentity(...)
84
+
85
+ ```typescript
86
+ verifyIdentity(options?: BiometricOptions) => any
87
+ ```
88
+
89
+ Prompts the user to authenticate with biometrics.
90
+
91
+ | Param | Type |
92
+ | ------------- | ------------------------------------------------------------- |
93
+ | **`options`** | <code><a href="#biometricoptions">BiometricOptions</a></code> |
94
+
95
+ **Returns:** <code>any</code>
96
+
97
+ **Since:** 1.0.0
98
+
99
+ --------------------
100
+
101
+
102
+ ### getCredentials(...)
103
+
104
+ ```typescript
105
+ getCredentials(options: GetCredentialOptions) => any
106
+ ```
107
+
108
+ Gets the stored credentials for a given server.
109
+
110
+ | Param | Type |
111
+ | ------------- | --------------------------------------------------------------------- |
112
+ | **`options`** | <code><a href="#getcredentialoptions">GetCredentialOptions</a></code> |
113
+
114
+ **Returns:** <code>any</code>
115
+
116
+ **Since:** 1.0.0
117
+
118
+ --------------------
119
+
120
+
121
+ ### setCredentials(...)
122
+
123
+ ```typescript
124
+ setCredentials(options: SetCredentialOptions) => any
125
+ ```
126
+
127
+ Stores the given credentials for a given server.
128
+
129
+ | Param | Type |
130
+ | ------------- | --------------------------------------------------------------------- |
131
+ | **`options`** | <code><a href="#setcredentialoptions">SetCredentialOptions</a></code> |
132
+
133
+ **Returns:** <code>any</code>
134
+
135
+ **Since:** 1.0.0
136
+
137
+ --------------------
138
+
139
+
140
+ ### deleteCredentials(...)
141
+
142
+ ```typescript
143
+ deleteCredentials(options: DeleteCredentialOptions) => any
144
+ ```
145
+
146
+ Deletes the stored credentials for a given server.
147
+
148
+ | Param | Type |
149
+ | ------------- | --------------------------------------------------------------------------- |
150
+ | **`options`** | <code><a href="#deletecredentialoptions">DeleteCredentialOptions</a></code> |
151
+
152
+ **Returns:** <code>any</code>
153
+
154
+ **Since:** 1.0.0
155
+
156
+ --------------------
157
+
158
+
159
+ ### Interfaces
160
+
161
+
162
+ #### IsAvailableOptions
163
+
164
+ | Prop | Type | Description |
165
+ | ----------------- | -------------------- | ----------------------------------------------------------------------------------------------------- |
166
+ | **`useFallback`** | <code>boolean</code> | Specifies if should fallback to passcode authentication if biometric authentication is not available. |
167
+
168
+
169
+ #### AvailableResult
170
+
171
+ | Prop | Type |
172
+ | ------------------ | ----------------------------------------------------- |
173
+ | **`isAvailable`** | <code>boolean</code> |
174
+ | **`biometryType`** | <code><a href="#biometrytype">BiometryType</a></code> |
175
+ | **`errorCode`** | <code>number</code> |
176
+
177
+
178
+ #### BiometricOptions
179
+
180
+ | Prop | Type | Description | Default |
181
+ | ------------------------ | -------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------- |
182
+ | **`reason`** | <code>string</code> | | |
183
+ | **`title`** | <code>string</code> | | |
184
+ | **`subtitle`** | <code>string</code> | | |
185
+ | **`description`** | <code>string</code> | | |
186
+ | **`negativeButtonText`** | <code>string</code> | | |
187
+ | **`useFallback`** | <code>boolean</code> | | |
188
+ | **`maxAttempts`** | <code>number</code> | Only for Android. Set a maximum number of attempts for biometric authentication. The maximum allowed by android is 5. | <code>1</code> |
189
+
190
+
191
+ #### GetCredentialOptions
192
+
193
+ | Prop | Type |
194
+ | ------------ | ------------------- |
195
+ | **`server`** | <code>string</code> |
196
+
197
+
198
+ #### Credentials
199
+
200
+ | Prop | Type |
201
+ | -------------- | ------------------- |
202
+ | **`username`** | <code>string</code> |
203
+ | **`password`** | <code>string</code> |
204
+
205
+
206
+ #### SetCredentialOptions
207
+
208
+ | Prop | Type |
209
+ | -------------- | ------------------- |
210
+ | **`username`** | <code>string</code> |
211
+ | **`password`** | <code>string</code> |
212
+ | **`server`** | <code>string</code> |
213
+
214
+
215
+ #### DeleteCredentialOptions
216
+
217
+ | Prop | Type |
218
+ | ------------ | ------------------- |
219
+ | **`server`** | <code>string</code> |
220
+
221
+
222
+ ### Enums
223
+
224
+
225
+ #### BiometryType
226
+
227
+ | Members |
228
+ | ------------------------- |
229
+ | **`NONE`** |
230
+ | **`TOUCH_ID`** |
231
+ | **`FACE_ID`** |
232
+ | **`FINGERPRINT`** |
233
+ | **`FACE_AUTHENTICATION`** |
234
+ | **`IRIS_AUTHENTICATION`** |
235
+ | **`MULTIPLE`** |
236
+
237
+ </docgen-api>
238
+ ## Face ID (iOS)
239
+
240
+ To use FaceID Make sure to provide a value for NSFaceIDUsageDescription, otherwise your app may crash on iOS devices with FaceID.
241
+
242
+ This value is just the reason for using FaceID. You can add something like the following example to App/info.plist:
243
+
244
+ ```xml
245
+ <key>NSFaceIDUsageDescription</key>
246
+ <string>For an easier and faster log in.</string>
247
+ ```
248
+
249
+ ## Biometric (Android)
250
+
251
+ To use android's BiometricPrompt api you must add the following permission to your AndroidManifest.xml:
252
+
253
+ ```xml
254
+ <uses-permission android:name="android.permission.USE_BIOMETRIC">
255
+ ```
256
+
257
+ And register the plugin by adding it to you MainActivity's onCreate (Not needed for Capacitor 3):
258
+
259
+ ```java
260
+ import ee.forgr.biometric.NativeBiometric;
261
+
262
+ public class MainActivity extends BridgeActivity {
263
+ @Override
264
+ public void onCreate(Bundle savedInstanceState) {
265
+ super.onCreate(savedInstanceState);
266
+
267
+ // Initializes the Bridge
268
+ this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
269
+ // Additional plugins you've installed go here
270
+ // Ex: add(TotallyAwesomePlugin.class);
271
+ add(NativeBiometric.class);
272
+ }});
273
+ }
274
+ }
275
+ ```
276
+
277
+ ## Contributors
278
+
279
+ [Jonthia](https://github.com/jonthia)
280
+ [One Click Web Studio](https://github.com/oneclickwebstudio)
281
+
282
+ ## Notes
283
+
284
+ Hasn't been tested on Android API level 22 or lower.