@aparajita/capacitor-biometric-auth
Advanced tools
Comparing version 1.0.7 to 2.0.0
@@ -1,7 +0,3 @@ | ||
declare module '@capacitor/core' { | ||
interface PluginRegistry { | ||
WSBiometricAuth: WSBiometricAuthPlugin; | ||
} | ||
} | ||
import { PluginResultError } from '@capacitor/core'; | ||
import type { DecoratedNativePlugin } from '@aparajita/capacitor-native-decorator'; | ||
import type { PluginListenerHandle, PluginResultError } from '@capacitor/core'; | ||
export declare enum BiometryType { | ||
@@ -35,4 +31,3 @@ /** | ||
/** | ||
* The reason for requesting authentication. Displays in the authentication dialog presented to the user. | ||
* If not supplied, a default message is displayed. | ||
* The reason for requesting authentication. Displays in the authentication dialog presented to the user. If not supplied, a default message is displayed. | ||
*/ | ||
@@ -57,3 +52,3 @@ reason?: string; | ||
cancelTitle?: string; | ||
/*** | ||
/** | ||
* If true, allows for authentication using device unlock credentials. Default is false. | ||
@@ -63,6 +58,6 @@ * | ||
* If biometry is available, enrolled, and not disabled, the system uses that first. | ||
* After the first Touch ID failure or second Face ID failure, if iosFallbackTitle | ||
* After the first Touch ID failure or second Face ID failure, if `iosFallbackTitle` | ||
* is not an empty string, a fallback button appears in the authentication dialog. | ||
* If the user taps the fallback button, the system prompts the user for the device | ||
* passcode or the user’s password. If iosFallbackTitle is an empty string, no | ||
* passcode or the user’s password. If `iosFallbackTitle` is an empty string, no | ||
* fallback button will appear. | ||
@@ -72,5 +67,5 @@ * | ||
* the system immediately prompts the user for the device passcode or user’s password. | ||
* Authentication fails with the error code passcodeNotSet if the device passcode isn’t enabled. | ||
* Authentication fails with the error code `passcodeNotSet` if the device passcode isn’t enabled. | ||
* | ||
* If a passcode is not set on the device, a passcodeNotSet error is returned. | ||
* If a passcode is not set on the device, a `passcodeNotSet` error is returned. | ||
* | ||
@@ -80,3 +75,3 @@ * The system disables passcode authentication after 6 unsuccessful attempts, with progressively | ||
* | ||
* The title of the fallback button may be customized by setting iosFallbackTitle to | ||
* The title of the fallback button may be customized by setting `iosFallbackTitle` to | ||
* a non-empty string. | ||
@@ -96,3 +91,3 @@ * | ||
* | ||
* If allowDeviceCredential is false, tapping this button dismisses the | ||
* If `allowDeviceCredential` is false, tapping this button dismisses the | ||
* authentication dialog and returns the error code userFallback. If undefined, | ||
@@ -102,3 +97,3 @@ * the localized systetm default title is used. Passing an empty string | ||
* | ||
* If allowDeviceCredential is true and this is undefined, | ||
* If `allowDeviceCredential` is true and this is undefined, | ||
* the localized system default title is used. | ||
@@ -117,3 +112,3 @@ */ | ||
* The maximum number of failed biometric verification attempts before | ||
* returning BiometryError.authenticationFailed. The default is 3. | ||
* returning `BiometryError.authenticationFailed`. The default is 3. | ||
*/ | ||
@@ -123,3 +118,3 @@ androidMaxAttempts?: number; | ||
/** | ||
* If the authenticate() method throws an exception, the error object | ||
* If the `authenticate()` method throws an exception, the error object | ||
* contains a .code property which will contain one of these strings, | ||
@@ -170,14 +165,10 @@ * indicating what the error was. | ||
/** | ||
* The signature of the callback passed to addResumeListener(). | ||
* The signature of the callback passed to `addResumeListener()`. | ||
*/ | ||
export declare type ResumeListener = (info: CheckBiometryResult) => void; | ||
export interface WSBiometricAuthPlugin { | ||
export interface BiometricAuthPlugin extends DecoratedNativePlugin { | ||
/** | ||
* Check to see what biometry type (if any) is available. | ||
* For testing on the web, a BiometryType name (case-sensitive) | ||
* may be specified as an environment variable. For example: | ||
* | ||
* WS_BIOMETRY_TYPE=touchId | ||
*/ | ||
checkBiometry(): Promise<CheckBiometryResult>; | ||
checkBiometry: () => Promise<CheckBiometryResult>; | ||
/** | ||
@@ -187,10 +178,10 @@ * web only | ||
* On the web, this method allows you to dynamically simulate | ||
* different types of biometry. You may either pass a BiometryType enum | ||
* or the string name of a BiometryType. If a string is passed and | ||
* it isn't a valid | ||
* different types of biometry. You may either pass a `BiometryType` enum | ||
* or the string name of a `BiometryType`. If a string is passed and | ||
* it isn't a valid value, nothing happens. | ||
*/ | ||
setBiometryType(type: BiometryType | string | undefined): void; | ||
setBiometryType: (type: BiometryType | string | undefined) => void; | ||
/** | ||
* Prompt the user for authentication. If authorization fails for any reason, | ||
* the promise is rejected with a BiometryError. | ||
* the promise is rejected with a `BiometryError`. | ||
* | ||
@@ -201,6 +192,6 @@ * @param {AuthenticateOptions} options | ||
*/ | ||
authenticate(options?: AuthenticateOptions): Promise<void>; | ||
authenticate: (options?: AuthenticateOptions) => Promise<void>; | ||
/** | ||
* Register a function that will be called when the app resumes. | ||
* The function will be passed the result of checkBiometry(). | ||
* The function will be passed the result of `checkBiometry()`. | ||
* | ||
@@ -210,3 +201,4 @@ * @param {ResumeListener} listener | ||
*/ | ||
addResumeListener(listener: ResumeListener): void; | ||
addResumeListener: (listener: ResumeListener) => Promise<PluginListenerHandle>; | ||
} | ||
export declare const kPluginName = "BiometricAuth"; |
@@ -29,3 +29,3 @@ export var BiometryType; | ||
/** | ||
* If the authenticate() method throws an exception, the error object | ||
* If the `authenticate()` method throws an exception, the error object | ||
* contains a .code property which will contain one of these strings, | ||
@@ -58,2 +58,3 @@ * indicating what the error was. | ||
} | ||
export const kPluginName = 'BiometricAuth'; | ||
//# sourceMappingURL=definitions.js.map |
@@ -0,2 +1,5 @@ | ||
import type { BiometricAuthPlugin } from './definitions'; | ||
declare const biometricAuth: BiometricAuthPlugin; | ||
export * from './definitions'; | ||
export * from './web'; | ||
export { biometricAuth as BiometricAuth }; | ||
export { getBiometryName } from './web'; |
@@ -0,3 +1,17 @@ | ||
import { registerPlugin } from '@capacitor/core'; | ||
import { kPluginName } from './definitions'; | ||
import { BiometricAuth } from './web'; | ||
// Because we are using @aparajita/capacitor-native-decorator, | ||
// we have one version of the TS code to rule them all, and there | ||
// is no need to lazy load. 😁 | ||
const plugin = new BiometricAuth(); | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const biometricAuth = registerPlugin(kPluginName, { | ||
web: plugin, | ||
ios: plugin, | ||
android: plugin | ||
}); | ||
export * from './definitions'; | ||
export * from './web'; | ||
export { biometricAuth as BiometricAuth }; | ||
export { getBiometryName } from './web'; | ||
//# sourceMappingURL=index.js.map |
import { WebPlugin } from '@capacitor/core'; | ||
import { CheckBiometryResult, AuthenticateOptions, BiometryType, WSBiometricAuthPlugin, ResumeListener } from './definitions'; | ||
export declare class WSBiometricAuthWeb extends WebPlugin implements WSBiometricAuthPlugin { | ||
import type { PluginListenerHandle } from '@capacitor/core'; | ||
import type { AuthenticateOptions, BiometricAuthPlugin, CheckBiometryResult, ResumeListener } from './definitions'; | ||
import { BiometryType } from './definitions'; | ||
export declare class BiometricAuth extends WebPlugin implements BiometricAuthPlugin { | ||
private biometryType; | ||
constructor(); | ||
getRegisteredPluginName(): string; | ||
setBiometryType(type: BiometryType | string | undefined): void; | ||
checkBiometry(): Promise<CheckBiometryResult>; | ||
authenticate(options?: AuthenticateOptions): Promise<void>; | ||
addResumeListener(listener: ResumeListener): void; | ||
addResumeListener(listener: ResumeListener): Promise<PluginListenerHandle> & PluginListenerHandle; | ||
} | ||
@@ -18,3 +20,1 @@ /** | ||
export declare function getBiometryName(type: BiometryType): string; | ||
declare const WSBiometricAuth: WSBiometricAuthWeb; | ||
export { WSBiometricAuth }; |
@@ -1,5 +0,11 @@ | ||
import { __decorate } from "tslib"; | ||
import { Plugins, registerWebPlugin, WebPlugin } from '@capacitor/core'; | ||
import { BiometryError, BiometryErrorType, BiometryType, } from './definitions'; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
import { native } from '@aparajita/capacitor-native-decorator'; | ||
import { App } from '@capacitor/app'; | ||
import { WebPlugin } from '@capacitor/core'; | ||
import { BiometryError, BiometryErrorType, BiometryType, kPluginName } from './definitions'; | ||
const kBiometryTypeNameMap = { | ||
@@ -11,13 +17,12 @@ [BiometryType.none]: '', | ||
[BiometryType.faceAuthentication]: 'Face Authentication', | ||
[BiometryType.irisAuthentication]: 'Iris Authentication', | ||
[BiometryType.irisAuthentication]: 'Iris Authentication' | ||
}; | ||
export class WSBiometricAuthWeb extends WebPlugin { | ||
export class BiometricAuth extends WebPlugin { | ||
constructor() { | ||
super({ | ||
name: 'WSBiometricAuth', | ||
platforms: ['web', 'ios', 'android'], | ||
}); | ||
super(...arguments); | ||
this.biometryType = BiometryType.none; | ||
this.setBiometryType(process.env.WS_BIOMETRY_TYPE); | ||
} | ||
getRegisteredPluginName() { | ||
return kPluginName; | ||
} | ||
setBiometryType(type) { | ||
@@ -28,3 +33,5 @@ if (typeof type === 'undefined') { | ||
if (typeof type === 'string') { | ||
if (type && BiometryType.hasOwnProperty(type)) { | ||
// eslint-disable-next-line no-prototype-builtins | ||
if (BiometryType.hasOwnProperty(type)) { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
this.biometryType = BiometryType[type]; | ||
@@ -37,13 +44,15 @@ } | ||
} | ||
checkBiometry() { | ||
async checkBiometry() { | ||
return Promise.resolve({ | ||
isAvailable: this.biometryType !== BiometryType.none, | ||
biometryType: this.biometryType, | ||
reason: '', | ||
reason: '' | ||
}); | ||
} | ||
authenticate(options) { | ||
async authenticate(options) { | ||
return this.checkBiometry().then(({ isAvailable, biometryType }) => { | ||
if (isAvailable) { | ||
if (confirm((options === null || options === void 0 ? void 0 : options.reason) || | ||
if ( | ||
// eslint-disable-next-line no-alert | ||
confirm((options === null || options === void 0 ? void 0 : options.reason) || | ||
`Authenticate with ${kBiometryTypeNameMap[biometryType]}?`)) { | ||
@@ -58,11 +67,13 @@ return; | ||
addResumeListener(listener) { | ||
const app = Plugins.App; | ||
if (app) { | ||
app.addListener('appStateChange', async (state) => { | ||
if (state.isActive) { | ||
const info = await this.checkBiometry(); | ||
return App.addListener('appStateChange', ({ isActive }) => { | ||
if (isActive) { | ||
this.checkBiometry() | ||
.then((info) => { | ||
listener(info); | ||
} | ||
}); | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error(error.message); | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -72,6 +83,6 @@ } | ||
native() | ||
], WSBiometricAuthWeb.prototype, "checkBiometry", null); | ||
], BiometricAuth.prototype, "checkBiometry", null); | ||
__decorate([ | ||
native() | ||
], WSBiometricAuthWeb.prototype, "authenticate", null); | ||
], BiometricAuth.prototype, "authenticate", null); | ||
/** | ||
@@ -86,5 +97,2 @@ * Return a human-readable name for a BiometryType. | ||
} | ||
const WSBiometricAuth = new WSBiometricAuthWeb(); | ||
export { WSBiometricAuth }; | ||
registerWebPlugin(WSBiometricAuth); | ||
//# sourceMappingURL=web.js.map |
119
package.json
{ | ||
"name": "@aparajita/capacitor-biometric-auth", | ||
"version": "1.0.7", | ||
"version": "2.0.0", | ||
"description": "Provides access to the native biometric auth APIs for Capacitor apps", | ||
"main": "dist/esm/index.js", | ||
"author": "Aparajita Fishman", | ||
"license": "MIT", | ||
"main": "dist/plugin.cjs.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/esm/index.d.ts", | ||
"scripts": { | ||
"clean": "rimraf ./dist", | ||
"build": "npm run clean && tsc && rollup -c rollup.config.js && make-ios-plugin", | ||
"watch": "nodemon -w ./src -w tsconfig.json -w rollup.config.js --exec 'npm run build --silent' -e ts", | ||
"lint": "npm run prettier && npm run swiftlint", | ||
"lint.fix": "npm run prettier.fix && npm run swiftlint.fix", | ||
"prettier": "prettier --check --plugin=./node_modules/prettier-plugin-java \"**/*.{css,html,ts,js,java}\"", | ||
"prettier.fix": "prettier --write --check --plugin=./node_modules/prettier-plugin-java \"**/*.{css,html,ts,js,java}\"", | ||
"swiftlint": "cd ios; node-swiftlint; cd ..", | ||
"swiftlint.fix": "cd ios; node-swiftlint autocorrect; cd ..", | ||
"docgen": "docgen --api WSBiometricAuthPlugin --output-readme README.md", | ||
"release": "standard-version", | ||
"push": "git push --follow-tags origin main && npm publish" | ||
"unpkg": "dist/plugin.js", | ||
"engines": { | ||
"node": ">=16.15.1" | ||
}, | ||
"author": "Aparajita Fishman", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@aparajita/capacitor-docgen": "^0.0.10-3", | ||
"@ionic/prettier-config": "^1.0.1", | ||
"@ionic/swiftlint-config": "^1.1.2", | ||
"@rollup/plugin-commonjs": "^18.0.0", | ||
"@rollup/plugin-node-resolve": "^11.2.1", | ||
"@types/node": "^14.14.37", | ||
"nodemon": "^2.0.7", | ||
"prettier": "^2.2.1", | ||
"prettier-plugin-java": "^1.0.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.44.0", | ||
"swiftlint": "^1.0.1", | ||
"typescript": "~4.2.3" | ||
}, | ||
"files": [ | ||
"dist/esm/*.d.ts", | ||
"dist/esm/*.js", | ||
"ios/Plugin", | ||
"ios/Podfile", | ||
"ios/Podfile.lock", | ||
"android/src/main/", | ||
"android/build.gradle", | ||
"dist/", | ||
"ios/Plugin/", | ||
"*.podspec", | ||
"android/build.gradle", | ||
"android/gradle.properties", | ||
"android/settings.gradle", | ||
"android/src/main" | ||
"LICENSE" | ||
], | ||
@@ -69,3 +40,2 @@ "keywords": [ | ||
}, | ||
"prettier": "@ionic/prettier-config", | ||
"swiftlint": "@ionic/swiftlint-config", | ||
@@ -79,9 +49,62 @@ "repository": { | ||
}, | ||
"devDependencies": { | ||
"@aparajita/capacitor-docgen": "github:aparajita/capacitor-docgen", | ||
"@aparajita/capacitor-docgen-format": "github:aparajita/capacitor-docgen-format", | ||
"@aparajita/eslint-config-base": "^1.1.2", | ||
"@aparajita/prettier-config": "^1.0.0", | ||
"@aparajita/swiftly": "^1.0.0", | ||
"@capacitor/core": "^3.6.0", | ||
"@ionic/swiftlint-config": "^1.1.2", | ||
"@types/node": "^18.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.30.2", | ||
"@typescript-eslint/parser": "^5.30.2", | ||
"chalk": "^5.0.1", | ||
"commit-and-tag-version": "^10.0.1", | ||
"eslint": "^8.18.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-config-standard": "^17.0.0", | ||
"eslint-import-resolver-typescript": "^3.1.4", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-n": "^15.2.3", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"nodemon": "^2.0.18", | ||
"prettier": "^2.7.1", | ||
"prettier-plugin-java": "^1.6.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.75.7", | ||
"typescript": "~4.7.4" | ||
}, | ||
"dependencies": { | ||
"@aparajita/capacitor-native-decorator": "^1.1.1", | ||
"@capacitor/android": "^2.4.7", | ||
"@capacitor/core": "^2.4.7", | ||
"@capacitor/ios": "^2.4.7", | ||
"tslib": "^2.1.0" | ||
"@aparajita/capacitor-native-decorator": "link:../capacitor-native-decorator", | ||
"@capacitor/android": "^3.6.0", | ||
"@capacitor/app": "^1.1.1", | ||
"@capacitor/ios": "^3.6.0" | ||
}, | ||
"peerDependencies": { | ||
"@capacitor/core": "^3.6.0" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf ./dist", | ||
"verify": "pnpm verify:ios && pnpm verify:android && pnpm verify:web", | ||
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..", | ||
"verify:android": "cd android && ./gradlew clean build test && cd ..", | ||
"verify:web": "pnpm build", | ||
"build": "pnpm clean && tsc && rollup -c rollup.config.js && pnpm docgen && pnpm make", | ||
"make": "make-ios-plugin", | ||
"watch": "nodemon -w ./src -w tsconfig.json -w rollup.config.js --exec 'pnpm build --silent' -e ts", | ||
"lint": "eslint . && pnpm typecheck", | ||
"lint.fix": "eslint --fix . && pnpm typecheck", | ||
"typecheck": "tsc --noEmit", | ||
"lint.swift": "pnpm swiftlint", | ||
"prettier": "prettier --check \"**/*.{css,html,ts,js,java}\"", | ||
"prettier.fix": "pnpm prettier --write", | ||
"swiftlint": "swiftly ios", | ||
"swiftlint.fix": "swiftly --fix ios", | ||
"check": "pnpm lint && pnpm prettier && pnpm swiftlint", | ||
"check.fix": "pnpm lint.fix && pnpm prettier.fix && pnpm swiftlint.fix", | ||
"docgen": "docgen --api BiometricAuthPlugin --output-readme README.md && docgen-format", | ||
"release": "commit-and-tag-version", | ||
"push": "git push --follow-tags origin main" | ||
} | ||
} | ||
} |
138
README.md
@@ -0,6 +1,8 @@ | ||
<div class="markdown-body"> | ||
# capacitor-biometric-auth | ||
This plugin for [Capacitor 2](https://capacitorjs.com) provides access to native biometry on iOS and Android. In addition, biometry is simulated on the web so you can test your logic without making any changes to your code. | ||
This plugin for [Capacitor 3](https://capacitorjs.com) provides access to native biometry on iOS and Android. It supports every type of biometry and every configuration option on both platforms. In addition, biometry is simulated on the web so you can test your logic without making any changes to your code. | ||
👉 **NOTE:** This plugin has only been tested with Capacitor 2. | ||
👉 **NOTE:** This plugin only works with Capacitor 3. If you are upgrading from the Capacitor 2 version, note that the plugin name has changed to `BiometricAuth`. | ||
@@ -10,5 +12,3 @@ ## Installation | ||
```sh | ||
pnpm install @aparajita/capacitor-biometric-auth # 'pnpm add' also works | ||
npm install @aparajita/capacitor-biometric-auth | ||
yarn add @aparajita/capacitor-biometric-auth | ||
pnpm add @aparajita/capacitor-biometric-auth | ||
``` | ||
@@ -20,3 +20,3 @@ | ||
The API is documented [here](src/definitions.ts) and [below](#api). For a complete example of how to use this plugin in practice, see the [demo app](https://github.com/aparajita/capacitor-biometric-auth-demo). | ||
The API is extensively documented in the [TypeScript definitions file](src/definitions.ts). There is also (somewhat incomplete auto-generated) documentation [below](#api). For a complete example of how to use this plugin in practice, see the [demo app](https://github.com/aparajita/capacitor-biometric-auth-demo). | ||
@@ -27,14 +27,14 @@ ### Checking availability | ||
Because the availability of biometry can change while your app is in the background, it’s important to recheck availability when your app resumes. By calling [`addResumeListener`](#addresumelistener) you can register a callback that is passed a [`CheckBiometryResult`](#checkbiometryresult) when your app resumes. | ||
Because the availability of biometry can change while your app is in the background, it’s important to check availability when your app resumes. By calling [`addResumeListener`](#addresumelistener) you can register a callback that is passed a [`CheckBiometryResult`](#checkbiometryresult) when your app resumes. | ||
### Authenticating | ||
Once you have determined that biometry is available, to initiate biometric authentication call [authenticate](#authenticate). `authenticate` takes an [AuthenticateOptions](#authenticateoptions) object which you will want to use in order to control the behavior and appearance of the biometric prompt. | ||
Once you have determined that biometry is available, to initiate biometric authentication call [`authenticate`](#authenticate). `authenticate` takes an [`AuthenticateOptions`](#authenticateoptions) object which you will want to use in order to control the behavior and appearance of the biometric prompt. | ||
If authentication succeeds, the Promise resolves. If authentication fails, the Promise is rejected with a `BiometryError`, which has two properties: | ||
| Property | Type | Description | | ||
| :---------- | :------ | :------------- | | ||
| message | string | A description of the error suitable for debugging | | ||
| code | BiometryErrorType | What caused the error | | ||
| Property | Type | Description | | ||
| :---------- |:--------------------------------------------------------------------------------------------------------| :------------- | | ||
| message | string | A description of the error suitable for debugging | | ||
| code | [BiometryErrorType](https://github.com/aparajita/capacitor-biometric-auth/blob/main/src/definitions.ts) | What caused the error | | ||
@@ -45,7 +45,4 @@ ## Biometry support | ||
On the web, you can fake any of the supported biometry types by one of two methods: | ||
On the web, you can fake any of the supported biometry types by calling [`setBiometryType()`](#setbiometrytype). | ||
- Set the environment variable `WS_BIOMETRY_TYPE` to one of the `BiometryType` enums. This value is case-sensitive; for example to simulate Touch ID on the web, set `WS_BIOMETRY_TYPE` to `touchId`. | ||
- Call `setBiometryType()`. | ||
### iOS | ||
@@ -60,15 +57,13 @@ | ||
## API | ||
<docgen-index> | ||
**Methods**<br> | ||
[checkBiometry()](#checkbiometry)<br> | ||
[setBiometryType(...)](#setbiometrytype)<br> | ||
[authenticate(...)](#authenticate)<br> | ||
[checkBiometry()](#checkbiometry) | ||
[setBiometryType(...)](#setbiometrytype) | ||
[authenticate(...)](#authenticate) | ||
[addResumeListener(...)](#addresumelistener) | ||
[Interfaces](#interfaces) | ||
[Type Aliases](#type-aliases) | ||
[Enums](#enums) | ||
[Interfaces](#interfaces)<br> | ||
[Enums](#enums)<br> | ||
</docgen-index> | ||
@@ -84,3 +79,3 @@ <docgen-api> | ||
Check to see what biometry type (if any) is available. For testing on the web, a <a href="#biometrytype">BiometryType</a> name (case-sensitive) may be specified as an environment variable. For example:<br><br>WS_BIOMETRY_TYPE=touchId | ||
Check to see what biometry type (if any) is available. | ||
@@ -98,7 +93,7 @@ **Returns:** Promise<<a href="#checkbiometryresult">CheckBiometryResult</a>> | ||
web only<br><br>On the web, this method allows you to dynamically simulate different types of biometry. You may either pass a <a href="#biometrytype">BiometryType</a> enum or the string name of a <a href="#biometrytype">BiometryType</a>. If a string is passed and it isn't a valid | ||
web only<br><br>On the web, this method allows you to dynamically simulate different types of biometry. You may either pass a <a href="#biometrytype">`BiometryType`</a> enum or the string name of a <a href="#biometrytype">`BiometryType`</a>. If a string is passed and it isn't a valid value, nothing happens. | ||
| Param | Type | | ||
| :---- | :------------------------------------------------- | | ||
| type | string \| <a href="#biometrytype">BiometryType</a> | | ||
| Param | Type | | ||
| :---------- | :--------------------------------------------------------------- | | ||
|type|string \| <a href="#biometrytype">BiometryType</a>| | ||
@@ -111,10 +106,10 @@ -------------------- | ||
```typescript | ||
authenticate(options?: AuthenticateOptions | undefined) => Promise<void> | ||
authenticate(options?: AuthenticateOptions) => Promise<void> | ||
``` | ||
Prompt the user for authentication. If authorization fails for any reason, the promise is rejected with a BiometryError. | ||
Prompt the user for authentication. If authorization fails for any reason, the promise is rejected with a `BiometryError`. | ||
| Param | Type | | ||
| :------ | :----------------------------------------------------- | | ||
| options | <a href="#authenticateoptions">AuthenticateOptions</a> | | ||
| Param | Type | | ||
| :------------- | :------------------------------------------------------------------- | | ||
|options|<a href="#authenticateoptions">AuthenticateOptions</a>| | ||
@@ -127,11 +122,13 @@ -------------------- | ||
```typescript | ||
addResumeListener(listener: ResumeListener) => void | ||
addResumeListener(listener: ResumeListener) => Promise<PluginListenerHandle> | ||
``` | ||
Register a function that will be called when the app resumes. The function will be passed the result of checkBiometry(). | ||
Register a function that will be called when the app resumes. The function will be passed the result of `checkBiometry()`. | ||
| Param | Type | | ||
| :------- | :------------------------------------------------------------------------ | | ||
| listener | (info: <a href="#checkbiometryresult">CheckBiometryResult</a>) => void | | ||
| Param | Type | | ||
| :-------------- | :--------------------------------------------------------- | | ||
|listener|<a href="#resumelistener">ResumeListener</a>| | ||
**Returns:** Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> | ||
-------------------- | ||
@@ -145,23 +142,39 @@ | ||
| Prop | Type | Description | | ||
| :----------- | :--------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ | | ||
| isAvailable | boolean | True if the device has biometric authentication capability and the current user has enrolled in biometry. | | ||
| biometryType | <a href="#biometrytype">BiometryType</a> | The type of biometry available on the device. | | ||
| reason | string | If biometry is not available and the system gives a reason why, it will be returned here. Otherwise it's an empty string. | | ||
| Prop | Type | Description | | ||
| :------------------ | :----------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------- | | ||
|isAvailable|boolean| True if the device has biometric authentication capability and the current user has enrolled in biometry. | | ||
|biometryType|<a href="#biometrytype">BiometryType</a>| The type of biometry available on the device. | | ||
|reason|string| If biometry is not available and the system gives a reason why, it will be returned here. Otherwise it's an empty string. | | ||
<br> | ||
#### AuthenticateOptions | ||
| Prop | Type | Description | | ||
| :-------------------- | :------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| reason | string | The reason for requesting authentication. Displays in the authentication dialog presented to the user. If not supplied, a default message is displayed. | | ||
| cancelTitle | string | iOS: The system presents a cancel button during biometric authentication to let the user abort the authentication attempt. The button appears every time the system asks the user to present a finger registered with Touch ID. For Face ID, the button only appears if authentication fails and the user is prompted to try again. Either way, the user can stop trying to authenticate by tapping the button.<br><br>Android: The text for the negative button. This would typically be used as a "Cancel" button, but may be also used to show an alternative method for authentication, such as a screen that asks for a backup password.<br><br>Default: "Cancel" | | ||
| allowDeviceCredential | boolean | * If true, allows for authentication using device unlock credentials. Default is false.<br><br>iOS: If biometry is available, enrolled, and not disabled, the system uses that first. After the first Touch ID failure or second Face ID failure, if iosFallbackTitle is not an empty string, a fallback button appears in the authentication dialog. If the user taps the fallback button, the system prompts the user for the device passcode or the user’s password. If iosFallbackTitle is an empty string, no fallback button will appear.<br><br>If biometry is not available, enrolled and enabled, and a passcode is set, the system immediately prompts the user for the device passcode or user’s password. Authentication fails with the error code passcodeNotSet if the device passcode isn’t enabled.<br><br>If a passcode is not set on the device, a passcodeNotSet error is returned.<br><br>The system disables passcode authentication after 6 unsuccessful attempts, with progressively increasing delays between attempts.<br><br>The title of the fallback button may be customized by setting iosFallbackTitle to a non-empty string.<br><br>Android: The user will first be prompted to authenticate with biometrics, but also given the option to authenticate with their device PIN, pattern, or password by tapping a button in the authentication dialog. The title of the button is supplied by the system. | | ||
| iosFallbackTitle | string | The system presents a fallback button when biometric authentication fails — for example, because the system doesn’t recognize the presented finger, or after several failed attempts to recognize the user’s face.<br><br>If allowDeviceCredential is false, tapping this button dismisses the authentication dialog and returns the error code userFallback. If undefined, the localized systetm default title is used. Passing an empty string hides the fallback button completely.<br><br>If allowDeviceCredential is true and this is undefined, the localized system default title is used. | | ||
| androidTitle | string | Title for the Android dialog. If not supplied, the system default is used. | | ||
| androidSubtitle | string | Subtitle for the Android dialog. If not supplied, the system default is used. | | ||
| androidMaxAttempts | number | The maximum number of failed biometric verification attempts before returning BiometryError.authenticationFailed. The default is 3. | | ||
| Prop | Type | Description | | ||
| :--------------------------- | :-------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
|reason|string| The reason for requesting authentication. Displays in the authentication dialog presented to the user. If not supplied, a default message is displayed. | | ||
|cancelTitle|string| iOS: The system presents a cancel button during biometric authentication to let the user abort the authentication attempt. The button appears every time the system asks the user to present a finger registered with Touch ID. For Face ID, the button only appears if authentication fails and the user is prompted to try again. Either way, the user can stop trying to authenticate by tapping the button.<br><br>Android: The text for the negative button. This would typically be used as a "Cancel" button, but may be also used to show an alternative method for authentication, such as a screen that asks for a backup password.<br><br>Default: "Cancel" | | ||
|allowDeviceCredential|boolean| If true, allows for authentication using device unlock credentials. Default is false.<br><br>iOS: If biometry is available, enrolled, and not disabled, the system uses that first. After the first Touch ID failure or second Face ID failure, if `iosFallbackTitle` is not an empty string, a fallback button appears in the authentication dialog. If the user taps the fallback button, the system prompts the user for the device passcode or the user’s password. If `iosFallbackTitle` is an empty string, no fallback button will appear.<br><br>If biometry is not available, enrolled and enabled, and a passcode is set, the system immediately prompts the user for the device passcode or user’s password. Authentication fails with the error code `passcodeNotSet` if the device passcode isn’t enabled.<br><br>If a passcode is not set on the device, a `passcodeNotSet` error is returned.<br><br>The system disables passcode authentication after 6 unsuccessful attempts, with progressively increasing delays between attempts.<br><br>The title of the fallback button may be customized by setting `iosFallbackTitle` to a non-empty string.<br><br>Android: The user will first be prompted to authenticate with biometrics, but also given the option to authenticate with their device PIN, pattern, or password by tapping a button in the authentication dialog. The title of the button is supplied by the system. | | ||
|iosFallbackTitle|string| The system presents a fallback button when biometric authentication fails — for example, because the system doesn’t recognize the presented finger, or after several failed attempts to recognize the user’s face.<br><br>If `allowDeviceCredential` is false, tapping this button dismisses the authentication dialog and returns the error code userFallback. If undefined, the localized systetm default title is used. Passing an empty string hides the fallback button completely.<br><br>If `allowDeviceCredential` is true and this is undefined, the localized system default title is used. | | ||
|androidTitle|string| Title for the Android dialog. If not supplied, the system default is used. | | ||
|androidSubtitle|string| Subtitle for the Android dialog. If not supplied, the system default is used. | | ||
|androidMaxAttempts|number| The maximum number of failed biometric verification attempts before returning `BiometryError.authenticationFailed`. The default is 3. | | ||
#### PluginListenerHandle | ||
| Method | Signature | | ||
| :---------- | :---------------------------- | | ||
| **remove** | () => Promise<void> | | ||
### Type Aliases | ||
#### ResumeListener | ||
The signature of the callback passed to `addResumeListener()`. | ||
<code>(info: <a href="#checkbiometryresult">CheckBiometryResult</a>): void</code> | ||
### Enums | ||
@@ -172,11 +185,12 @@ | ||
| Members | Description | | ||
| :------------------------ | :---------------------------------------------- | | ||
| none | No biometry is available | | ||
| touchId | iOS Touch ID is available | | ||
| faceId | iOS Face ID is available | | ||
| fingerprintAuthentication | Android fingerprint authentication is available | | ||
| faceAuthentication | Android face authentication is available | | ||
| irisAuthentication | Android iris authentication is available | | ||
| Members | Description | | ||
| :------------------------------- | :----------------------------------------------- | | ||
|none| No biometry is available | | ||
|touchId| iOS Touch ID is available | | ||
|faceId| iOS Face ID is available | | ||
|fingerprintAuthentication| Android fingerprint authentication is available | | ||
|faceAuthentication| Android face authentication is available | | ||
|irisAuthentication| Android iris authentication is available | | ||
</docgen-api> | ||
</div> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
119906
33
707
186
0
26
1
1
+ Added@capacitor/app@^1.1.1
+ Added@capacitor/android@3.9.0(transitive)
+ Added@capacitor/app@1.1.1(transitive)
+ Added@capacitor/core@3.9.0(transitive)
+ Added@capacitor/ios@3.9.0(transitive)
- Removed@capacitor/core@^2.4.7
- Removedtslib@^2.1.0
- Removed@aparajita/capacitor-native-decorator@1.1.1(transitive)
- Removed@capacitor/android@2.5.0(transitive)
- Removed@capacitor/core@2.5.0(transitive)
- Removed@capacitor/ios@2.5.0(transitive)
- Removedtslib@1.14.1(transitive)
Updated@aparajita/capacitor-native-decorator@link:../capacitor-native-decorator
Updated@capacitor/android@^3.6.0
Updated@capacitor/ios@^3.6.0