@aparajita/capacitor-biometric-auth 7.2.0 → 8.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.
package/README.md CHANGED
@@ -2,13 +2,18 @@
2
2
 
3
3
  # capacitor-biometric-auth  [![npm version](https://badge.fury.io/js/@aparajita%2Fcapacitor-biometric-auth.svg)](https://badge.fury.io/js/@aparajita%2Fcapacitor-biometric-auth)
4
4
 
5
- This plugin for [Capacitor 5](https://capacitorjs.com) provides access to native biometry and device credentials on iOS and Android. It supports every type of biometry and every configuration option on both platforms. In addition, biometry and device credentials are simulated on the web so you can test your logic without making any changes to your code.
5
+ This plugin for [Capacitor 6](https://capacitorjs.com) provides access to native biometry and device credentials on iOS and Android. It supports every type of biometry and every configuration option on both platforms. In addition, biometry and device credentials are simulated on the web so you can test your logic without making any changes to your code.
6
6
 
7
7
  🛑 **BREAKING CHANGES:**
8
8
 
9
9
  - If you are upgrading from a version prior to 6.0.0, please note that [`authenticate()`](#authenticate) now throws an instance of `BiometryError`, and `BiometryError.code` is now typed as [`BiometryErrorType`](#biometryerrortype).
10
+
10
11
  - If you are upgrading from a version prior to 7.0.0, please note that [`authenticate()`](#authenticate) will _immediately_ present a prompt for device credentials if `deviceIsSecure` is true, `allowDeviceCredentials` is true, and no biometry of the requested strength is available.
11
12
 
13
+ - If you are upgrading from a version prior to 8.0.0, please note that this plugin now requires Capacitor 6+.
14
+
15
+ - If you are upgrading from a version prior to 8.0.0, please note that [`addResumeListener`](#addresumelistener) now always returns a Promise and must be awaited.
16
+
12
17
  ## Installation
13
18
 
14
19
  ```sh
@@ -11,7 +11,7 @@ buildscript {
11
11
  mavenCentral()
12
12
  }
13
13
  dependencies {
14
- classpath 'com.android.tools.build:gradle:8.0.2'
14
+ classpath 'com.android.tools.build:gradle:8.2.1'
15
15
  }
16
16
  }
17
17
 
@@ -19,10 +19,10 @@ apply plugin: 'com.android.library'
19
19
 
20
20
  android {
21
21
  namespace "com.aparajita.capacitor.biometricauth"
22
- compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
22
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
23
23
  defaultConfig {
24
24
  minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
26
26
  versionCode 1
27
27
  versionName "1.0"
28
28
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -270,7 +270,7 @@ public class BiometricAuthNative extends Plugin {
270
270
  );
271
271
  intent.putExtra(BIOMETRIC_STRENGTH, getAuthenticatorFromCall(call));
272
272
 
273
- if (call.hasOption(CONFIRMATION_REQUIRED)) {
273
+ if (call.getBoolean(CONFIRMATION_REQUIRED, true) != null) {
274
274
  intent.putExtra(
275
275
  CONFIRMATION_REQUIRED,
276
276
  call.getBoolean(CONFIRMATION_REQUIRED, true)
@@ -8,5 +8,5 @@ export declare abstract class BiometricAuthBase extends WebPlugin implements Bio
8
8
  abstract setDeviceIsSecure(isSecure: boolean): Promise<void>;
9
9
  authenticate(options?: AuthenticateOptions): Promise<void>;
10
10
  protected abstract internalAuthenticate(options?: AuthenticateOptions): Promise<void>;
11
- addResumeListener(listener: ResumeListener): Promise<PluginListenerHandle> & PluginListenerHandle;
11
+ addResumeListener(listener: ResumeListener): Promise<PluginListenerHandle>;
12
12
  }
package/dist/esm/base.js CHANGED
@@ -10,16 +10,14 @@ export class BiometricAuthBase extends WebPlugin {
10
10
  // error will be an instance of CapacitorException on native platforms,
11
11
  // an instance of BiometryError on the web.
12
12
  if (error instanceof CapacitorException) {
13
- throw new BiometryError(error.message,
14
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we are converting from ExceptionCode to BiometryErrorType
15
- error.code);
13
+ throw new BiometryError(error.message, error.code);
16
14
  }
17
15
  else {
18
16
  throw error;
19
17
  }
20
18
  }
21
19
  }
22
- addResumeListener(listener) {
20
+ async addResumeListener(listener) {
23
21
  return App.addListener('appStateChange', ({ isActive }) => {
24
22
  if (isActive) {
25
23
  this.checkBiometry()
@@ -1,5 +1,6 @@
1
1
  import { BiometricAuthBase } from './base';
2
2
  import { BiometryErrorType, BiometryType } from './definitions';
3
+ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/require-await */
3
4
  // eslint-disable-next-line import/prefer-default-export
4
5
  export class BiometricAuthNative extends BiometricAuthBase {
5
6
  constructor(capProxy) {
@@ -12,12 +13,11 @@ export class BiometricAuthNative extends BiometricAuthBase {
12
13
  capProxy is a proxy of an instance of this class, so it is safe
13
14
  to cast it to this class.
14
15
  */
15
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
16
16
  const proxy = capProxy;
17
17
  /* eslint-disable @typescript-eslint/unbound-method */
18
18
  this.checkBiometry = proxy.checkBiometry;
19
19
  this.internalAuthenticate = proxy.internalAuthenticate;
20
- /* eslint-enable */
20
+ /* eslint-enable @typescript-eslint/unbound-method */
21
21
  }
22
22
  // @native
23
23
  async checkBiometry() {
@@ -36,28 +36,17 @@ export class BiometricAuthNative extends BiometricAuthBase {
36
36
  }
37
37
  // @native
38
38
  // On native platforms, this will present the native authentication UI.
39
- async internalAuthenticate(
40
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
- options) { }
39
+ async internalAuthenticate(options) { }
42
40
  // Web only, used for simulating biometric authentication.
43
- // eslint-disable-next-line @typescript-eslint/require-await
44
- async setBiometryType(
45
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
- type) {
47
- throw this.unimplemented('setBiometryType() is web only');
41
+ async setBiometryType(type) {
42
+ console.warn('setBiometryType() is web only');
48
43
  }
49
44
  // Web only, used for simulating biometry enrollment.
50
- // eslint-disable-next-line @typescript-eslint/require-await
51
- async setBiometryIsEnrolled(
52
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
- enrolled) {
54
- throw this.unimplemented('setBiometryEnrolled() is web only');
45
+ async setBiometryIsEnrolled(enrolled) {
46
+ console.warn('setBiometryEnrolled() is web only');
55
47
  }
56
48
  // Web only, used for simulating device security.
57
- // eslint-disable-next-line @typescript-eslint/require-await
58
- async setDeviceIsSecure(
59
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
60
- isSecure) {
61
- throw this.unimplemented('setDeviceIsSecure() is web only');
49
+ async setDeviceIsSecure(isSecure) {
50
+ console.warn('setDeviceIsSecure() is web only');
62
51
  }
63
52
  }
package/dist/esm/web.js CHANGED
@@ -102,9 +102,7 @@ export class BiometricAuthWeb extends BiometricAuthBase {
102
102
  for (let i = 0; i < types.length; i++) {
103
103
  // eslint-disable-next-line no-prototype-builtins
104
104
  if (BiometryType.hasOwnProperty(types[i])) {
105
- const biometryType =
106
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
107
- BiometryType[types[i]];
105
+ const biometryType = BiometryType[types[i]];
108
106
  if (this.biometryType === BiometryType.none) {
109
107
  this.biometryTypes = [];
110
108
  }
@@ -131,6 +129,5 @@ export class BiometricAuthWeb extends BiometricAuthBase {
131
129
  }
132
130
  }
133
131
  function isBiometryTypes(value) {
134
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
135
132
  return Object.values(BiometryType).includes(value[0]);
136
133
  }
@@ -107,16 +107,14 @@ class BiometricAuthBase extends core.WebPlugin {
107
107
  // error will be an instance of CapacitorException on native platforms,
108
108
  // an instance of BiometryError on the web.
109
109
  if (error instanceof core.CapacitorException) {
110
- throw new BiometryError(error.message,
111
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we are converting from ExceptionCode to BiometryErrorType
112
- error.code);
110
+ throw new BiometryError(error.message, error.code);
113
111
  }
114
112
  else {
115
113
  throw error;
116
114
  }
117
115
  }
118
116
  }
119
- addResumeListener(listener) {
117
+ async addResumeListener(listener) {
120
118
  return app.App.addListener('appStateChange', ({ isActive }) => {
121
119
  if (isActive) {
122
120
  this.checkBiometry()
@@ -230,9 +228,7 @@ class BiometricAuthWeb extends BiometricAuthBase {
230
228
  for (let i = 0; i < types.length; i++) {
231
229
  // eslint-disable-next-line no-prototype-builtins
232
230
  if (exports.BiometryType.hasOwnProperty(types[i])) {
233
- const biometryType =
234
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
235
- exports.BiometryType[types[i]];
231
+ const biometryType = exports.BiometryType[types[i]];
236
232
  if (this.biometryType === exports.BiometryType.none) {
237
233
  this.biometryTypes = [];
238
234
  }
@@ -259,7 +255,6 @@ class BiometricAuthWeb extends BiometricAuthBase {
259
255
  }
260
256
  }
261
257
  function isBiometryTypes(value) {
262
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
263
258
  return Object.values(exports.BiometryType).includes(value[0]);
264
259
  }
265
260
 
@@ -268,6 +263,7 @@ var web = /*#__PURE__*/Object.freeze({
268
263
  BiometricAuthWeb: BiometricAuthWeb
269
264
  });
270
265
 
266
+ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/require-await */
271
267
  // eslint-disable-next-line import/prefer-default-export
272
268
  class BiometricAuthNative extends BiometricAuthBase {
273
269
  constructor(capProxy) {
@@ -280,12 +276,11 @@ class BiometricAuthNative extends BiometricAuthBase {
280
276
  capProxy is a proxy of an instance of this class, so it is safe
281
277
  to cast it to this class.
282
278
  */
283
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
284
279
  const proxy = capProxy;
285
280
  /* eslint-disable @typescript-eslint/unbound-method */
286
281
  this.checkBiometry = proxy.checkBiometry;
287
282
  this.internalAuthenticate = proxy.internalAuthenticate;
288
- /* eslint-enable */
283
+ /* eslint-enable @typescript-eslint/unbound-method */
289
284
  }
290
285
  // @native
291
286
  async checkBiometry() {
@@ -304,29 +299,18 @@ class BiometricAuthNative extends BiometricAuthBase {
304
299
  }
305
300
  // @native
306
301
  // On native platforms, this will present the native authentication UI.
307
- async internalAuthenticate(
308
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
309
- options) { }
302
+ async internalAuthenticate(options) { }
310
303
  // Web only, used for simulating biometric authentication.
311
- // eslint-disable-next-line @typescript-eslint/require-await
312
- async setBiometryType(
313
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
314
- type) {
315
- throw this.unimplemented('setBiometryType() is web only');
304
+ async setBiometryType(type) {
305
+ console.warn('setBiometryType() is web only');
316
306
  }
317
307
  // Web only, used for simulating biometry enrollment.
318
- // eslint-disable-next-line @typescript-eslint/require-await
319
- async setBiometryIsEnrolled(
320
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
321
- enrolled) {
322
- throw this.unimplemented('setBiometryEnrolled() is web only');
308
+ async setBiometryIsEnrolled(enrolled) {
309
+ console.warn('setBiometryEnrolled() is web only');
323
310
  }
324
311
  // Web only, used for simulating device security.
325
- // eslint-disable-next-line @typescript-eslint/require-await
326
- async setDeviceIsSecure(
327
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
328
- isSecure) {
329
- throw this.unimplemented('setDeviceIsSecure() is web only');
312
+ async setDeviceIsSecure(isSecure) {
313
+ console.warn('setDeviceIsSecure() is web only');
330
314
  }
331
315
  }
332
316
 
package/dist/plugin.js CHANGED
@@ -105,16 +105,14 @@ var capacitorBiometricAuth = (function (exports, core, app) {
105
105
  // error will be an instance of CapacitorException on native platforms,
106
106
  // an instance of BiometryError on the web.
107
107
  if (error instanceof core.CapacitorException) {
108
- throw new BiometryError(error.message,
109
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we are converting from ExceptionCode to BiometryErrorType
110
- error.code);
108
+ throw new BiometryError(error.message, error.code);
111
109
  }
112
110
  else {
113
111
  throw error;
114
112
  }
115
113
  }
116
114
  }
117
- addResumeListener(listener) {
115
+ async addResumeListener(listener) {
118
116
  return app.App.addListener('appStateChange', ({ isActive }) => {
119
117
  if (isActive) {
120
118
  this.checkBiometry()
@@ -228,9 +226,7 @@ var capacitorBiometricAuth = (function (exports, core, app) {
228
226
  for (let i = 0; i < types.length; i++) {
229
227
  // eslint-disable-next-line no-prototype-builtins
230
228
  if (exports.BiometryType.hasOwnProperty(types[i])) {
231
- const biometryType =
232
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
233
- exports.BiometryType[types[i]];
229
+ const biometryType = exports.BiometryType[types[i]];
234
230
  if (this.biometryType === exports.BiometryType.none) {
235
231
  this.biometryTypes = [];
236
232
  }
@@ -257,7 +253,6 @@ var capacitorBiometricAuth = (function (exports, core, app) {
257
253
  }
258
254
  }
259
255
  function isBiometryTypes(value) {
260
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
261
256
  return Object.values(exports.BiometryType).includes(value[0]);
262
257
  }
263
258
 
@@ -266,6 +261,7 @@ var capacitorBiometricAuth = (function (exports, core, app) {
266
261
  BiometricAuthWeb: BiometricAuthWeb
267
262
  });
268
263
 
264
+ /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/require-await */
269
265
  // eslint-disable-next-line import/prefer-default-export
270
266
  class BiometricAuthNative extends BiometricAuthBase {
271
267
  constructor(capProxy) {
@@ -278,12 +274,11 @@ var capacitorBiometricAuth = (function (exports, core, app) {
278
274
  capProxy is a proxy of an instance of this class, so it is safe
279
275
  to cast it to this class.
280
276
  */
281
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
282
277
  const proxy = capProxy;
283
278
  /* eslint-disable @typescript-eslint/unbound-method */
284
279
  this.checkBiometry = proxy.checkBiometry;
285
280
  this.internalAuthenticate = proxy.internalAuthenticate;
286
- /* eslint-enable */
281
+ /* eslint-enable @typescript-eslint/unbound-method */
287
282
  }
288
283
  // @native
289
284
  async checkBiometry() {
@@ -302,29 +297,18 @@ var capacitorBiometricAuth = (function (exports, core, app) {
302
297
  }
303
298
  // @native
304
299
  // On native platforms, this will present the native authentication UI.
305
- async internalAuthenticate(
306
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
307
- options) { }
300
+ async internalAuthenticate(options) { }
308
301
  // Web only, used for simulating biometric authentication.
309
- // eslint-disable-next-line @typescript-eslint/require-await
310
- async setBiometryType(
311
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
312
- type) {
313
- throw this.unimplemented('setBiometryType() is web only');
302
+ async setBiometryType(type) {
303
+ console.warn('setBiometryType() is web only');
314
304
  }
315
305
  // Web only, used for simulating biometry enrollment.
316
- // eslint-disable-next-line @typescript-eslint/require-await
317
- async setBiometryIsEnrolled(
318
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
319
- enrolled) {
320
- throw this.unimplemented('setBiometryEnrolled() is web only');
306
+ async setBiometryIsEnrolled(enrolled) {
307
+ console.warn('setBiometryEnrolled() is web only');
321
308
  }
322
309
  // Web only, used for simulating device security.
323
- // eslint-disable-next-line @typescript-eslint/require-await
324
- async setDeviceIsSecure(
325
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
326
- isSecure) {
327
- throw this.unimplemented('setDeviceIsSecure() is web only');
310
+ async setDeviceIsSecure(isSecure) {
311
+ console.warn('setDeviceIsSecure() is web only');
328
312
  }
329
313
  }
330
314
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aparajita/capacitor-biometric-auth",
3
- "version": "7.2.0",
3
+ "version": "8.0.0",
4
4
  "description": "Provides access to the native biometric auth & device security APIs for Capacitor apps",
5
5
  "author": "Aparajita Fishman",
6
6
  "license": "MIT",
@@ -57,15 +57,15 @@
57
57
  "@aparajita/eslint-config-base": "^1.1.6",
58
58
  "@aparajita/prettier-config": "^2.0.0",
59
59
  "@aparajita/swiftly": "^1.0.4",
60
- "@capacitor/cli": "^5.7.4",
61
- "@commitlint/cli": "^19.2.1",
62
- "@commitlint/config-conventional": "^19.1.0",
60
+ "@capacitor/cli": "^6.0.0",
61
+ "@commitlint/cli": "^19.2.2",
62
+ "@commitlint/config-conventional": "^19.2.2",
63
63
  "@ionic/swiftlint-config": "^1.1.2",
64
64
  "@rollup/plugin-json": "^6.1.0",
65
- "@types/node": "^20.12.4",
66
- "@typescript-eslint/eslint-plugin": "^7.5.0",
67
- "@typescript-eslint/parser": "^7.5.0",
68
- "commit-and-tag-version": "^12.2.0",
65
+ "@types/node": "^20.12.7",
66
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
67
+ "@typescript-eslint/parser": "^7.7.0",
68
+ "commit-and-tag-version": "^12.4.0",
69
69
  "eslint": "^8.57.0",
70
70
  "eslint-config-prettier": "^9.1.0",
71
71
  "eslint-config-standard": "^17.1.0",
@@ -77,16 +77,16 @@
77
77
  "prettier": "^3.2.5",
78
78
  "prettier-plugin-java": "^2.6.0",
79
79
  "rimraf": "^5.0.5",
80
- "rollup": "^4.14.0",
80
+ "rollup": "^4.16.1",
81
81
  "simple-git-hooks": "^2.11.1",
82
82
  "swiftlint": "^1.0.2",
83
- "typescript": "~5.4.3"
83
+ "typescript": "~5.4.5"
84
84
  },
85
85
  "dependencies": {
86
- "@capacitor/android": "^5.7.4",
87
- "@capacitor/app": "^5.0.7",
88
- "@capacitor/core": "^5.7.4",
89
- "@capacitor/ios": "^5.7.4"
86
+ "@capacitor/android": "^6.0.0",
87
+ "@capacitor/app": "^6.0.0",
88
+ "@capacitor/core": "^6.0.0",
89
+ "@capacitor/ios": "^6.0.0"
90
90
  },
91
91
  "scripts": {
92
92
  "clean": "rimraf dist",