@capgo/capacitor-native-biometric 7.5.4 → 8.0.1
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/CapgoCapacitorNativeBiometric.podspec +1 -1
- package/Package.swift +2 -2
- package/README.md +96 -18
- package/android/build.gradle +9 -9
- package/android/src/main/java/ee/forgr/biometric/AuthActivity.java +3 -1
- package/android/src/main/java/ee/forgr/biometric/NativeBiometric.java +69 -22
- package/dist/docs.json +143 -45
- package/dist/esm/definitions.d.ts +42 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -1
- package/dist/esm/web.js +24 -6
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +23 -6
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +23 -6
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/NativeBiometricPlugin/NativeBiometricPlugin.swift +83 -32
- package/package.json +12 -12
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
1
2
|
export declare enum BiometryType {
|
|
2
3
|
NONE = 0,
|
|
3
4
|
TOUCH_ID = 1,
|
|
@@ -45,6 +46,22 @@ export interface AvailableResult {
|
|
|
45
46
|
* The strength of available authentication method (STRONG, WEAK, or NONE)
|
|
46
47
|
*/
|
|
47
48
|
authenticationStrength: AuthenticationStrength;
|
|
49
|
+
/**
|
|
50
|
+
* The primary biometry type available on the device.
|
|
51
|
+
* On Android devices with multiple biometry types, this returns MULTIPLE.
|
|
52
|
+
* Use this for display purposes only - always use isAvailable for logic decisions.
|
|
53
|
+
*/
|
|
54
|
+
biometryType: BiometryType;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the device has a secure lock screen (PIN, pattern, or password).
|
|
57
|
+
* This is independent of biometric enrollment.
|
|
58
|
+
*/
|
|
59
|
+
deviceIsSecure: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Whether strong biometry (Face ID, Touch ID, or fingerprint on devices that consider it strong)
|
|
62
|
+
* is specifically available, separate from weak biometry or device credentials.
|
|
63
|
+
*/
|
|
64
|
+
strongBiometryIsAvailable: boolean;
|
|
48
65
|
/**
|
|
49
66
|
* Error code from BiometricAuthError enum. Only present when isAvailable is false.
|
|
50
67
|
* Indicates why biometric authentication is not available.
|
|
@@ -172,6 +189,10 @@ export declare enum BiometricAuthError {
|
|
|
172
189
|
*/
|
|
173
190
|
USER_FALLBACK = 17
|
|
174
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Callback type for biometry change listener
|
|
194
|
+
*/
|
|
195
|
+
export type BiometryChangeListener = (result: AvailableResult) => void;
|
|
175
196
|
export interface NativeBiometricPlugin {
|
|
176
197
|
/**
|
|
177
198
|
* Checks if biometric authentication hardware is available.
|
|
@@ -181,6 +202,27 @@ export interface NativeBiometricPlugin {
|
|
|
181
202
|
* @since 1.0.0
|
|
182
203
|
*/
|
|
183
204
|
isAvailable(options?: IsAvailableOptions): Promise<AvailableResult>;
|
|
205
|
+
/**
|
|
206
|
+
* Adds a listener that is called when the app resumes from background.
|
|
207
|
+
* This is useful to detect if biometry availability has changed while
|
|
208
|
+
* the app was in the background (e.g., user enrolled/unenrolled biometrics).
|
|
209
|
+
*
|
|
210
|
+
* @param eventName - Must be 'biometryChange'
|
|
211
|
+
* @param {BiometryChangeListener} listener - Callback function that receives the updated AvailableResult
|
|
212
|
+
* @returns {Promise<PluginListenerHandle>} Handle to remove the listener
|
|
213
|
+
* @since 7.6.0
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* const handle = await NativeBiometric.addListener('biometryChange', (result) => {
|
|
218
|
+
* console.log('Biometry availability changed:', result.isAvailable);
|
|
219
|
+
* });
|
|
220
|
+
*
|
|
221
|
+
* // To remove the listener:
|
|
222
|
+
* await handle.remove();
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
addListener(eventName: 'biometryChange', listener: BiometryChangeListener): Promise<PluginListenerHandle>;
|
|
184
226
|
/**
|
|
185
227
|
* Prompts the user to authenticate with biometrics.
|
|
186
228
|
* @param {BiometricOptions} [options]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,YAeX;AAfD,WAAY,YAAY;IACtB,eAAe;IACf,+CAAQ,CAAA;IACR,MAAM;IACN,uDAAY,CAAA;IACZ,MAAM;IACN,qDAAW,CAAA;IACX,UAAU;IACV,6DAAe,CAAA;IACf,UAAU;IACV,6EAAuB,CAAA;IACvB,UAAU;IACV,6EAAuB,CAAA;IACvB,UAAU;IACV,uDAAY,CAAA;AACd,CAAC,EAfW,YAAY,KAAZ,YAAY,QAevB;AAED,MAAM,CAAN,IAAY,sBAeX;AAfD,WAAY,sBAAsB;IAChC;;OAEG;IACH,mEAAQ,CAAA;IACR;;;OAGG;IACH,uEAAU,CAAA;IACV;;;OAGG;IACH,mEAAQ,CAAA;AACV,CAAC,EAfW,sBAAsB,KAAtB,sBAAsB,QAejC;AAuGD;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,kBAiEX;AAjED,WAAY,kBAAkB;IAC5B;;OAEG;IACH,6EAAiB,CAAA;IACjB;;;OAGG;IACH,+FAA0B,CAAA;IAC1B;;;OAGG;IACH,2EAAgB,CAAA;IAChB;;;OAGG;IACH,iGAA2B,CAAA;IAC3B;;;OAGG;IACH,+FAA0B,CAAA;IAC1B;;;OAGG;IACH,8FAA0B,CAAA;IAC1B;;;OAGG;IACH,wEAAe,CAAA;IACf;;;OAGG;IACH,kFAAoB,CAAA;IACpB;;;OAGG;IACH,kFAAoB,CAAA;IACpB;;;OAGG;IACH,oFAAqB,CAAA;IACrB;;;OAGG;IACH,8EAAkB,CAAA;IAClB;;;OAGG;IACH,0EAAgB,CAAA;IAChB;;;OAGG;IACH,8EAAkB,CAAA;AACpB,CAAC,EAjEW,kBAAkB,KAAlB,kBAAkB,QAiE7B","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport enum BiometryType {\n // Android, iOS\n NONE = 0,\n // iOS\n TOUCH_ID = 1,\n // iOS\n FACE_ID = 2,\n // Android\n FINGERPRINT = 3,\n // Android\n FACE_AUTHENTICATION = 4,\n // Android\n IRIS_AUTHENTICATION = 5,\n // Android\n MULTIPLE = 6,\n}\n\nexport enum AuthenticationStrength {\n /**\n * No authentication available, even if PIN is available but useFallback = false\n */\n NONE = 0,\n /**\n * Strong authentication: Face ID on iOS, fingerprints on devices that consider fingerprints strong (Android).\n * Note: PIN/pattern/password is NEVER considered STRONG, even when useFallback = true.\n */\n STRONG = 1,\n /**\n * Weak authentication: Face authentication on Android devices that consider face weak,\n * or PIN/pattern/password if useFallback = true (PIN is always WEAK, never STRONG).\n */\n WEAK = 2,\n}\n\nexport interface Credentials {\n username: string;\n password: string;\n}\n\nexport interface IsAvailableOptions {\n /**\n * Specifies if should fallback to passcode authentication if biometric authentication is not available.\n */\n useFallback: boolean;\n}\n\n/**\n * Result from isAvailable() method indicating biometric authentication availability.\n */\nexport interface AvailableResult {\n /**\n * Whether authentication is available (biometric or fallback if useFallback is true)\n */\n isAvailable: boolean;\n /**\n * The strength of available authentication method (STRONG, WEAK, or NONE)\n */\n authenticationStrength: AuthenticationStrength;\n /**\n * The primary biometry type available on the device.\n * On Android devices with multiple biometry types, this returns MULTIPLE.\n * Use this for display purposes only - always use isAvailable for logic decisions.\n */\n biometryType: BiometryType;\n /**\n * Whether the device has a secure lock screen (PIN, pattern, or password).\n * This is independent of biometric enrollment.\n */\n deviceIsSecure: boolean;\n /**\n * Whether strong biometry (Face ID, Touch ID, or fingerprint on devices that consider it strong)\n * is specifically available, separate from weak biometry or device credentials.\n */\n strongBiometryIsAvailable: boolean;\n /**\n * Error code from BiometricAuthError enum. Only present when isAvailable is false.\n * Indicates why biometric authentication is not available.\n * @see BiometricAuthError\n */\n errorCode?: BiometricAuthError;\n}\n\nexport interface BiometricOptions {\n reason?: string;\n title?: string;\n subtitle?: string;\n description?: string;\n negativeButtonText?: string;\n /**\n * Specifies if should fallback to passcode authentication if biometric authentication fails.\n */\n useFallback?: boolean;\n /**\n * Only for iOS.\n * Set the text for the fallback button in the authentication dialog.\n * If this property is not specified, the default text is set by the system.\n */\n fallbackTitle?: string;\n /**\n * Only for Android.\n * Set a maximum number of attempts for biometric authentication. The maximum allowed by android is 5.\n * @default 1\n */\n maxAttempts?: number;\n /**\n * Only for Android.\n * Specify which biometry types are allowed for authentication.\n * If not specified, all available types will be allowed.\n * @example [BiometryType.FINGERPRINT, BiometryType.FACE_AUTHENTICATION]\n */\n allowedBiometryTypes?: BiometryType[];\n}\n\nexport interface GetCredentialOptions {\n server: string;\n}\n\nexport interface SetCredentialOptions {\n username: string;\n password: string;\n server: string;\n}\n\nexport interface DeleteCredentialOptions {\n server: string;\n}\n\nexport interface IsCredentialsSavedOptions {\n server: string;\n}\n\nexport interface IsCredentialsSavedResult {\n isSaved: boolean;\n}\n\n/**\n * Biometric authentication error codes.\n * These error codes are used in both isAvailable() and verifyIdentity() methods.\n *\n * Keep this in sync with BiometricAuthError in README.md\n * Update whenever `convertToPluginErrorCode` functions are modified\n */\nexport enum BiometricAuthError {\n /**\n * Unknown error occurred\n */\n UNKNOWN_ERROR = 0,\n /**\n * Biometrics are unavailable (no hardware or hardware error)\n * Platform: Android, iOS\n */\n BIOMETRICS_UNAVAILABLE = 1,\n /**\n * User has been locked out due to too many failed attempts\n * Platform: Android, iOS\n */\n USER_LOCKOUT = 2,\n /**\n * No biometrics are enrolled on the device\n * Platform: Android, iOS\n */\n BIOMETRICS_NOT_ENROLLED = 3,\n /**\n * User is temporarily locked out (Android: 30 second lockout)\n * Platform: Android\n */\n USER_TEMPORARY_LOCKOUT = 4,\n /**\n * Authentication failed (user did not authenticate successfully)\n * Platform: Android, iOS\n */\n AUTHENTICATION_FAILED = 10,\n /**\n * App canceled the authentication (iOS only)\n * Platform: iOS\n */\n APP_CANCEL = 11,\n /**\n * Invalid context (iOS only)\n * Platform: iOS\n */\n INVALID_CONTEXT = 12,\n /**\n * Authentication was not interactive (iOS only)\n * Platform: iOS\n */\n NOT_INTERACTIVE = 13,\n /**\n * Passcode/PIN is not set on the device\n * Platform: Android, iOS\n */\n PASSCODE_NOT_SET = 14,\n /**\n * System canceled the authentication (e.g., due to screen lock)\n * Platform: Android, iOS\n */\n SYSTEM_CANCEL = 15,\n /**\n * User canceled the authentication\n * Platform: Android, iOS\n */\n USER_CANCEL = 16,\n /**\n * User chose to use fallback authentication method\n * Platform: Android, iOS\n */\n USER_FALLBACK = 17,\n}\n\n/**\n * Callback type for biometry change listener\n */\nexport type BiometryChangeListener = (result: AvailableResult) => void;\n\nexport interface NativeBiometricPlugin {\n /**\n * Checks if biometric authentication hardware is available.\n * @param {IsAvailableOptions} [options]\n * @returns {Promise<AvailableResult>}\n * @memberof NativeBiometricPlugin\n * @since 1.0.0\n */\n isAvailable(options?: IsAvailableOptions): Promise<AvailableResult>;\n\n /**\n * Adds a listener that is called when the app resumes from background.\n * This is useful to detect if biometry availability has changed while\n * the app was in the background (e.g., user enrolled/unenrolled biometrics).\n *\n * @param eventName - Must be 'biometryChange'\n * @param {BiometryChangeListener} listener - Callback function that receives the updated AvailableResult\n * @returns {Promise<PluginListenerHandle>} Handle to remove the listener\n * @since 7.6.0\n *\n * @example\n * ```typescript\n * const handle = await NativeBiometric.addListener('biometryChange', (result) => {\n * console.log('Biometry availability changed:', result.isAvailable);\n * });\n *\n * // To remove the listener:\n * await handle.remove();\n * ```\n */\n addListener(eventName: 'biometryChange', listener: BiometryChangeListener): Promise<PluginListenerHandle>;\n /**\n * Prompts the user to authenticate with biometrics.\n * @param {BiometricOptions} [options]\n * @returns {Promise<any>}\n * @memberof NativeBiometricPlugin\n * @since 1.0.0\n */\n verifyIdentity(options?: BiometricOptions): Promise<void>;\n /**\n * Gets the stored credentials for a given server.\n * @param {GetCredentialOptions} options\n * @returns {Promise<Credentials>}\n * @memberof NativeBiometricPlugin\n * @since 1.0.0\n */\n getCredentials(options: GetCredentialOptions): Promise<Credentials>;\n /**\n * Stores the given credentials for a given server.\n * @param {SetCredentialOptions} options\n * @returns {Promise<any>}\n * @memberof NativeBiometricPlugin\n * @since 1.0.0\n */\n setCredentials(options: SetCredentialOptions): Promise<void>;\n /**\n * Deletes the stored credentials for a given server.\n * @param {DeleteCredentialOptions} options\n * @returns {Promise<any>}\n * @memberof NativeBiometricPlugin\n * @since 1.0.0\n */\n deleteCredentials(options: DeleteCredentialOptions): Promise<void>;\n /**\n * Checks if credentials are already saved for a given server.\n * @param {IsCredentialsSavedOptions} options\n * @returns {Promise<IsCredentialsSavedResult>}\n * @memberof NativeBiometricPlugin\n * @since 7.3.0\n */\n isCredentialsSaved(options: IsCredentialsSavedOptions): Promise<IsCredentialsSavedResult>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * @returns Promise that resolves with the plugin version\n * @since 1.0.0\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PluginListenerHandle } from '@capacitor/core';
|
|
3
|
+
import type { NativeBiometricPlugin, AvailableResult, BiometricOptions, GetCredentialOptions, SetCredentialOptions, DeleteCredentialOptions, IsCredentialsSavedOptions, IsCredentialsSavedResult, Credentials, BiometryChangeListener } from './definitions';
|
|
3
4
|
export declare class NativeBiometricWeb extends WebPlugin implements NativeBiometricPlugin {
|
|
4
5
|
constructor();
|
|
5
6
|
isAvailable(): Promise<AvailableResult>;
|
|
7
|
+
addListener(_eventName: 'biometryChange', _listener: BiometryChangeListener): Promise<PluginListenerHandle>;
|
|
6
8
|
verifyIdentity(_options?: BiometricOptions): Promise<void>;
|
|
7
9
|
getCredentials(_options: GetCredentialOptions): Promise<Credentials>;
|
|
8
10
|
setCredentials(_options: SetCredentialOptions): Promise<void>;
|
package/dist/esm/web.js
CHANGED
|
@@ -1,30 +1,48 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import { BiometryType, AuthenticationStrength } from './definitions';
|
|
2
3
|
export class NativeBiometricWeb extends WebPlugin {
|
|
3
4
|
constructor() {
|
|
4
5
|
super();
|
|
5
6
|
}
|
|
6
7
|
isAvailable() {
|
|
7
|
-
|
|
8
|
+
// Web platform: biometrics not available, but return structured response
|
|
9
|
+
return Promise.resolve({
|
|
10
|
+
isAvailable: false,
|
|
11
|
+
authenticationStrength: AuthenticationStrength.NONE,
|
|
12
|
+
biometryType: BiometryType.NONE,
|
|
13
|
+
deviceIsSecure: false,
|
|
14
|
+
strongBiometryIsAvailable: false,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
|
+
async addListener(_eventName, _listener) {
|
|
19
|
+
// Web platform: no-op, but return a valid handle
|
|
20
|
+
return {
|
|
21
|
+
remove: async () => {
|
|
22
|
+
// Nothing to remove on web
|
|
23
|
+
},
|
|
24
|
+
};
|
|
8
25
|
}
|
|
9
26
|
verifyIdentity(_options) {
|
|
10
27
|
console.log('verifyIdentity', _options);
|
|
11
|
-
throw new Error('
|
|
28
|
+
throw new Error('Biometric authentication is not available on web platform.');
|
|
12
29
|
}
|
|
13
30
|
getCredentials(_options) {
|
|
14
31
|
console.log('getCredentials', _options);
|
|
15
|
-
throw new Error('
|
|
32
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
16
33
|
}
|
|
17
34
|
setCredentials(_options) {
|
|
18
35
|
console.log('setCredentials', _options);
|
|
19
|
-
throw new Error('
|
|
36
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
20
37
|
}
|
|
21
38
|
deleteCredentials(_options) {
|
|
22
39
|
console.log('deleteCredentials', _options);
|
|
23
|
-
throw new Error('
|
|
40
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
24
41
|
}
|
|
25
42
|
isCredentialsSaved(_options) {
|
|
26
43
|
console.log('isCredentialsSaved', _options);
|
|
27
|
-
|
|
44
|
+
// Return false on web - no credentials can be saved
|
|
45
|
+
return Promise.resolve({ isSaved: false });
|
|
28
46
|
}
|
|
29
47
|
async getPluginVersion() {
|
|
30
48
|
return { version: 'web' };
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAe5C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,WAAW;QACT,yEAAyE;QACzE,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,WAAW,EAAE,KAAK;YAClB,sBAAsB,EAAE,sBAAsB,CAAC,IAAI;YACnD,YAAY,EAAE,YAAY,CAAC,IAAI;YAC/B,cAAc,EAAE,KAAK;YACrB,yBAAyB,EAAE,KAAK;SACjC,CAAC,CAAC;IACL,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,WAAW,CAAC,UAA4B,EAAE,SAAiC;QAC/E,iDAAiD;QACjD,OAAO;YACL,MAAM,EAAE,KAAK,IAAI,EAAE;gBACjB,2BAA2B;YAC7B,CAAC;SACF,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,QAA2B;QACxC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IAED,cAAc,CAAC,QAA8B;QAC3C,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,cAAc,CAAC,QAA8B;QAC3C,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,iBAAiB,CAAC,QAAiC;QACjD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,kBAAkB,CAAC,QAAmC;QACpD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;QAC5C,oDAAoD;QACpD,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { PluginListenerHandle } from '@capacitor/core';\n\nimport type {\n NativeBiometricPlugin,\n AvailableResult,\n BiometricOptions,\n GetCredentialOptions,\n SetCredentialOptions,\n DeleteCredentialOptions,\n IsCredentialsSavedOptions,\n IsCredentialsSavedResult,\n Credentials,\n BiometryChangeListener,\n} from './definitions';\nimport { BiometryType, AuthenticationStrength } from './definitions';\n\nexport class NativeBiometricWeb extends WebPlugin implements NativeBiometricPlugin {\n constructor() {\n super();\n }\n\n isAvailable(): Promise<AvailableResult> {\n // Web platform: biometrics not available, but return structured response\n return Promise.resolve({\n isAvailable: false,\n authenticationStrength: AuthenticationStrength.NONE,\n biometryType: BiometryType.NONE,\n deviceIsSecure: false,\n strongBiometryIsAvailable: false,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async addListener(_eventName: 'biometryChange', _listener: BiometryChangeListener): Promise<PluginListenerHandle> {\n // Web platform: no-op, but return a valid handle\n return {\n remove: async () => {\n // Nothing to remove on web\n },\n };\n }\n\n verifyIdentity(_options?: BiometricOptions): Promise<void> {\n console.log('verifyIdentity', _options);\n throw new Error('Biometric authentication is not available on web platform.');\n }\n\n getCredentials(_options: GetCredentialOptions): Promise<Credentials> {\n console.log('getCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n\n setCredentials(_options: SetCredentialOptions): Promise<void> {\n console.log('setCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n\n deleteCredentials(_options: DeleteCredentialOptions): Promise<void> {\n console.log('deleteCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n\n isCredentialsSaved(_options: IsCredentialsSavedOptions): Promise<IsCredentialsSavedResult> {\n console.log('isCredentialsSaved', _options);\n // Return false on web - no credentials can be saved\n return Promise.resolve({ isSaved: false });\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -120,27 +120,44 @@ class NativeBiometricWeb extends core.WebPlugin {
|
|
|
120
120
|
super();
|
|
121
121
|
}
|
|
122
122
|
isAvailable() {
|
|
123
|
-
|
|
123
|
+
// Web platform: biometrics not available, but return structured response
|
|
124
|
+
return Promise.resolve({
|
|
125
|
+
isAvailable: false,
|
|
126
|
+
authenticationStrength: exports.AuthenticationStrength.NONE,
|
|
127
|
+
biometryType: exports.BiometryType.NONE,
|
|
128
|
+
deviceIsSecure: false,
|
|
129
|
+
strongBiometryIsAvailable: false,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
133
|
+
async addListener(_eventName, _listener) {
|
|
134
|
+
// Web platform: no-op, but return a valid handle
|
|
135
|
+
return {
|
|
136
|
+
remove: async () => {
|
|
137
|
+
// Nothing to remove on web
|
|
138
|
+
},
|
|
139
|
+
};
|
|
124
140
|
}
|
|
125
141
|
verifyIdentity(_options) {
|
|
126
142
|
console.log('verifyIdentity', _options);
|
|
127
|
-
throw new Error('
|
|
143
|
+
throw new Error('Biometric authentication is not available on web platform.');
|
|
128
144
|
}
|
|
129
145
|
getCredentials(_options) {
|
|
130
146
|
console.log('getCredentials', _options);
|
|
131
|
-
throw new Error('
|
|
147
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
132
148
|
}
|
|
133
149
|
setCredentials(_options) {
|
|
134
150
|
console.log('setCredentials', _options);
|
|
135
|
-
throw new Error('
|
|
151
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
136
152
|
}
|
|
137
153
|
deleteCredentials(_options) {
|
|
138
154
|
console.log('deleteCredentials', _options);
|
|
139
|
-
throw new Error('
|
|
155
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
140
156
|
}
|
|
141
157
|
isCredentialsSaved(_options) {
|
|
142
158
|
console.log('isCredentialsSaved', _options);
|
|
143
|
-
|
|
159
|
+
// Return false on web - no credentials can be saved
|
|
160
|
+
return Promise.resolve({ isSaved: false });
|
|
144
161
|
}
|
|
145
162
|
async getPluginVersion() {
|
|
146
163
|
return { version: 'web' };
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BiometryType;\n(function (BiometryType) {\n // Android, iOS\n BiometryType[BiometryType[\"NONE\"] = 0] = \"NONE\";\n // iOS\n BiometryType[BiometryType[\"TOUCH_ID\"] = 1] = \"TOUCH_ID\";\n // iOS\n BiometryType[BiometryType[\"FACE_ID\"] = 2] = \"FACE_ID\";\n // Android\n BiometryType[BiometryType[\"FINGERPRINT\"] = 3] = \"FINGERPRINT\";\n // Android\n BiometryType[BiometryType[\"FACE_AUTHENTICATION\"] = 4] = \"FACE_AUTHENTICATION\";\n // Android\n BiometryType[BiometryType[\"IRIS_AUTHENTICATION\"] = 5] = \"IRIS_AUTHENTICATION\";\n // Android\n BiometryType[BiometryType[\"MULTIPLE\"] = 6] = \"MULTIPLE\";\n})(BiometryType || (BiometryType = {}));\nexport var AuthenticationStrength;\n(function (AuthenticationStrength) {\n /**\n * No authentication available, even if PIN is available but useFallback = false\n */\n AuthenticationStrength[AuthenticationStrength[\"NONE\"] = 0] = \"NONE\";\n /**\n * Strong authentication: Face ID on iOS, fingerprints on devices that consider fingerprints strong (Android).\n * Note: PIN/pattern/password is NEVER considered STRONG, even when useFallback = true.\n */\n AuthenticationStrength[AuthenticationStrength[\"STRONG\"] = 1] = \"STRONG\";\n /**\n * Weak authentication: Face authentication on Android devices that consider face weak,\n * or PIN/pattern/password if useFallback = true (PIN is always WEAK, never STRONG).\n */\n AuthenticationStrength[AuthenticationStrength[\"WEAK\"] = 2] = \"WEAK\";\n})(AuthenticationStrength || (AuthenticationStrength = {}));\n/**\n * Biometric authentication error codes.\n * These error codes are used in both isAvailable() and verifyIdentity() methods.\n *\n * Keep this in sync with BiometricAuthError in README.md\n * Update whenever `convertToPluginErrorCode` functions are modified\n */\nexport var BiometricAuthError;\n(function (BiometricAuthError) {\n /**\n * Unknown error occurred\n */\n BiometricAuthError[BiometricAuthError[\"UNKNOWN_ERROR\"] = 0] = \"UNKNOWN_ERROR\";\n /**\n * Biometrics are unavailable (no hardware or hardware error)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"BIOMETRICS_UNAVAILABLE\"] = 1] = \"BIOMETRICS_UNAVAILABLE\";\n /**\n * User has been locked out due to too many failed attempts\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_LOCKOUT\"] = 2] = \"USER_LOCKOUT\";\n /**\n * No biometrics are enrolled on the device\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"BIOMETRICS_NOT_ENROLLED\"] = 3] = \"BIOMETRICS_NOT_ENROLLED\";\n /**\n * User is temporarily locked out (Android: 30 second lockout)\n * Platform: Android\n */\n BiometricAuthError[BiometricAuthError[\"USER_TEMPORARY_LOCKOUT\"] = 4] = \"USER_TEMPORARY_LOCKOUT\";\n /**\n * Authentication failed (user did not authenticate successfully)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"AUTHENTICATION_FAILED\"] = 10] = \"AUTHENTICATION_FAILED\";\n /**\n * App canceled the authentication (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"APP_CANCEL\"] = 11] = \"APP_CANCEL\";\n /**\n * Invalid context (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"INVALID_CONTEXT\"] = 12] = \"INVALID_CONTEXT\";\n /**\n * Authentication was not interactive (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"NOT_INTERACTIVE\"] = 13] = \"NOT_INTERACTIVE\";\n /**\n * Passcode/PIN is not set on the device\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"PASSCODE_NOT_SET\"] = 14] = \"PASSCODE_NOT_SET\";\n /**\n * System canceled the authentication (e.g., due to screen lock)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"SYSTEM_CANCEL\"] = 15] = \"SYSTEM_CANCEL\";\n /**\n * User canceled the authentication\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_CANCEL\"] = 16] = \"USER_CANCEL\";\n /**\n * User chose to use fallback authentication method\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_FALLBACK\"] = 17] = \"USER_FALLBACK\";\n})(BiometricAuthError || (BiometricAuthError = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeBiometric = registerPlugin('NativeBiometric', {\n web: () => import('./web').then((m) => new m.NativeBiometricWeb()),\n});\nexport * from './definitions';\nexport { NativeBiometric };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class NativeBiometricWeb extends WebPlugin {\n constructor() {\n super();\n }\n isAvailable() {\n throw new Error('Method not implemented.');\n }\n verifyIdentity(_options) {\n console.log('verifyIdentity', _options);\n throw new Error('Method not implemented.');\n }\n getCredentials(_options) {\n console.log('getCredentials', _options);\n throw new Error('Method not implemented.');\n }\n setCredentials(_options) {\n console.log('setCredentials', _options);\n throw new Error('Method not implemented.');\n }\n deleteCredentials(_options) {\n console.log('deleteCredentials', _options);\n throw new Error('Method not implemented.');\n }\n isCredentialsSaved(_options) {\n console.log('isCredentialsSaved', _options);\n throw new Error('Method not implemented.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BiometryType","AuthenticationStrength","BiometricAuthError","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,YAAY,EAAE;AACzB;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACnD;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;AAC3D;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;AACzD;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa;AACjE;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAAG,qBAAqB;AACjF;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAAG,qBAAqB;AACjF;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;AAC3D,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K,CAAC,yBAAyB,CAAC;AAClD;AACA,IAAI,cAAc,CAAC,QAAQ,EAAE;AAC7B,QAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC;AAC/C,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;AAClD;AACA,IAAI,cAAc,CAAC,QAAQ,EAAE;AAC7B,QAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC;AAC/C,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;AAClD;AACA,IAAI,iBAAiB,CAAC,QAAQ,EAAE;AAChC,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC;AAClD,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;AAClD;AACA,IAAI,kBAAkB,CAAC,QAAQ,EAAE;AACjC,QAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,CAAC;AACnD,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;AAClD;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC;AACA;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BiometryType;\n(function (BiometryType) {\n // Android, iOS\n BiometryType[BiometryType[\"NONE\"] = 0] = \"NONE\";\n // iOS\n BiometryType[BiometryType[\"TOUCH_ID\"] = 1] = \"TOUCH_ID\";\n // iOS\n BiometryType[BiometryType[\"FACE_ID\"] = 2] = \"FACE_ID\";\n // Android\n BiometryType[BiometryType[\"FINGERPRINT\"] = 3] = \"FINGERPRINT\";\n // Android\n BiometryType[BiometryType[\"FACE_AUTHENTICATION\"] = 4] = \"FACE_AUTHENTICATION\";\n // Android\n BiometryType[BiometryType[\"IRIS_AUTHENTICATION\"] = 5] = \"IRIS_AUTHENTICATION\";\n // Android\n BiometryType[BiometryType[\"MULTIPLE\"] = 6] = \"MULTIPLE\";\n})(BiometryType || (BiometryType = {}));\nexport var AuthenticationStrength;\n(function (AuthenticationStrength) {\n /**\n * No authentication available, even if PIN is available but useFallback = false\n */\n AuthenticationStrength[AuthenticationStrength[\"NONE\"] = 0] = \"NONE\";\n /**\n * Strong authentication: Face ID on iOS, fingerprints on devices that consider fingerprints strong (Android).\n * Note: PIN/pattern/password is NEVER considered STRONG, even when useFallback = true.\n */\n AuthenticationStrength[AuthenticationStrength[\"STRONG\"] = 1] = \"STRONG\";\n /**\n * Weak authentication: Face authentication on Android devices that consider face weak,\n * or PIN/pattern/password if useFallback = true (PIN is always WEAK, never STRONG).\n */\n AuthenticationStrength[AuthenticationStrength[\"WEAK\"] = 2] = \"WEAK\";\n})(AuthenticationStrength || (AuthenticationStrength = {}));\n/**\n * Biometric authentication error codes.\n * These error codes are used in both isAvailable() and verifyIdentity() methods.\n *\n * Keep this in sync with BiometricAuthError in README.md\n * Update whenever `convertToPluginErrorCode` functions are modified\n */\nexport var BiometricAuthError;\n(function (BiometricAuthError) {\n /**\n * Unknown error occurred\n */\n BiometricAuthError[BiometricAuthError[\"UNKNOWN_ERROR\"] = 0] = \"UNKNOWN_ERROR\";\n /**\n * Biometrics are unavailable (no hardware or hardware error)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"BIOMETRICS_UNAVAILABLE\"] = 1] = \"BIOMETRICS_UNAVAILABLE\";\n /**\n * User has been locked out due to too many failed attempts\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_LOCKOUT\"] = 2] = \"USER_LOCKOUT\";\n /**\n * No biometrics are enrolled on the device\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"BIOMETRICS_NOT_ENROLLED\"] = 3] = \"BIOMETRICS_NOT_ENROLLED\";\n /**\n * User is temporarily locked out (Android: 30 second lockout)\n * Platform: Android\n */\n BiometricAuthError[BiometricAuthError[\"USER_TEMPORARY_LOCKOUT\"] = 4] = \"USER_TEMPORARY_LOCKOUT\";\n /**\n * Authentication failed (user did not authenticate successfully)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"AUTHENTICATION_FAILED\"] = 10] = \"AUTHENTICATION_FAILED\";\n /**\n * App canceled the authentication (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"APP_CANCEL\"] = 11] = \"APP_CANCEL\";\n /**\n * Invalid context (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"INVALID_CONTEXT\"] = 12] = \"INVALID_CONTEXT\";\n /**\n * Authentication was not interactive (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"NOT_INTERACTIVE\"] = 13] = \"NOT_INTERACTIVE\";\n /**\n * Passcode/PIN is not set on the device\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"PASSCODE_NOT_SET\"] = 14] = \"PASSCODE_NOT_SET\";\n /**\n * System canceled the authentication (e.g., due to screen lock)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"SYSTEM_CANCEL\"] = 15] = \"SYSTEM_CANCEL\";\n /**\n * User canceled the authentication\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_CANCEL\"] = 16] = \"USER_CANCEL\";\n /**\n * User chose to use fallback authentication method\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_FALLBACK\"] = 17] = \"USER_FALLBACK\";\n})(BiometricAuthError || (BiometricAuthError = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeBiometric = registerPlugin('NativeBiometric', {\n web: () => import('./web').then((m) => new m.NativeBiometricWeb()),\n});\nexport * from './definitions';\nexport { NativeBiometric };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { BiometryType, AuthenticationStrength } from './definitions';\nexport class NativeBiometricWeb extends WebPlugin {\n constructor() {\n super();\n }\n isAvailable() {\n // Web platform: biometrics not available, but return structured response\n return Promise.resolve({\n isAvailable: false,\n authenticationStrength: AuthenticationStrength.NONE,\n biometryType: BiometryType.NONE,\n deviceIsSecure: false,\n strongBiometryIsAvailable: false,\n });\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async addListener(_eventName, _listener) {\n // Web platform: no-op, but return a valid handle\n return {\n remove: async () => {\n // Nothing to remove on web\n },\n };\n }\n verifyIdentity(_options) {\n console.log('verifyIdentity', _options);\n throw new Error('Biometric authentication is not available on web platform.');\n }\n getCredentials(_options) {\n console.log('getCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n setCredentials(_options) {\n console.log('setCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n deleteCredentials(_options) {\n console.log('deleteCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n isCredentialsSaved(_options) {\n console.log('isCredentialsSaved', _options);\n // Return false on web - no credentials can be saved\n return Promise.resolve({ isSaved: false });\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BiometryType","AuthenticationStrength","BiometricAuthError","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,YAAY,EAAE;AACzB;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACnD;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;AAC3D;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;AACzD;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa;AACjE;AACA,IAAI,YAAY,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAAG,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O,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClD,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -119,27 +119,44 @@ var capacitorCapacitorBiometric = (function (exports, core) {
|
|
|
119
119
|
super();
|
|
120
120
|
}
|
|
121
121
|
isAvailable() {
|
|
122
|
-
|
|
122
|
+
// Web platform: biometrics not available, but return structured response
|
|
123
|
+
return Promise.resolve({
|
|
124
|
+
isAvailable: false,
|
|
125
|
+
authenticationStrength: exports.AuthenticationStrength.NONE,
|
|
126
|
+
biometryType: exports.BiometryType.NONE,
|
|
127
|
+
deviceIsSecure: false,
|
|
128
|
+
strongBiometryIsAvailable: false,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
132
|
+
async addListener(_eventName, _listener) {
|
|
133
|
+
// Web platform: no-op, but return a valid handle
|
|
134
|
+
return {
|
|
135
|
+
remove: async () => {
|
|
136
|
+
// Nothing to remove on web
|
|
137
|
+
},
|
|
138
|
+
};
|
|
123
139
|
}
|
|
124
140
|
verifyIdentity(_options) {
|
|
125
141
|
console.log('verifyIdentity', _options);
|
|
126
|
-
throw new Error('
|
|
142
|
+
throw new Error('Biometric authentication is not available on web platform.');
|
|
127
143
|
}
|
|
128
144
|
getCredentials(_options) {
|
|
129
145
|
console.log('getCredentials', _options);
|
|
130
|
-
throw new Error('
|
|
146
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
131
147
|
}
|
|
132
148
|
setCredentials(_options) {
|
|
133
149
|
console.log('setCredentials', _options);
|
|
134
|
-
throw new Error('
|
|
150
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
135
151
|
}
|
|
136
152
|
deleteCredentials(_options) {
|
|
137
153
|
console.log('deleteCredentials', _options);
|
|
138
|
-
throw new Error('
|
|
154
|
+
throw new Error('Credential storage is not available on web platform.');
|
|
139
155
|
}
|
|
140
156
|
isCredentialsSaved(_options) {
|
|
141
157
|
console.log('isCredentialsSaved', _options);
|
|
142
|
-
|
|
158
|
+
// Return false on web - no credentials can be saved
|
|
159
|
+
return Promise.resolve({ isSaved: false });
|
|
143
160
|
}
|
|
144
161
|
async getPluginVersion() {
|
|
145
162
|
return { version: 'web' };
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BiometryType;\n(function (BiometryType) {\n // Android, iOS\n BiometryType[BiometryType[\"NONE\"] = 0] = \"NONE\";\n // iOS\n BiometryType[BiometryType[\"TOUCH_ID\"] = 1] = \"TOUCH_ID\";\n // iOS\n BiometryType[BiometryType[\"FACE_ID\"] = 2] = \"FACE_ID\";\n // Android\n BiometryType[BiometryType[\"FINGERPRINT\"] = 3] = \"FINGERPRINT\";\n // Android\n BiometryType[BiometryType[\"FACE_AUTHENTICATION\"] = 4] = \"FACE_AUTHENTICATION\";\n // Android\n BiometryType[BiometryType[\"IRIS_AUTHENTICATION\"] = 5] = \"IRIS_AUTHENTICATION\";\n // Android\n BiometryType[BiometryType[\"MULTIPLE\"] = 6] = \"MULTIPLE\";\n})(BiometryType || (BiometryType = {}));\nexport var AuthenticationStrength;\n(function (AuthenticationStrength) {\n /**\n * No authentication available, even if PIN is available but useFallback = false\n */\n AuthenticationStrength[AuthenticationStrength[\"NONE\"] = 0] = \"NONE\";\n /**\n * Strong authentication: Face ID on iOS, fingerprints on devices that consider fingerprints strong (Android).\n * Note: PIN/pattern/password is NEVER considered STRONG, even when useFallback = true.\n */\n AuthenticationStrength[AuthenticationStrength[\"STRONG\"] = 1] = \"STRONG\";\n /**\n * Weak authentication: Face authentication on Android devices that consider face weak,\n * or PIN/pattern/password if useFallback = true (PIN is always WEAK, never STRONG).\n */\n AuthenticationStrength[AuthenticationStrength[\"WEAK\"] = 2] = \"WEAK\";\n})(AuthenticationStrength || (AuthenticationStrength = {}));\n/**\n * Biometric authentication error codes.\n * These error codes are used in both isAvailable() and verifyIdentity() methods.\n *\n * Keep this in sync with BiometricAuthError in README.md\n * Update whenever `convertToPluginErrorCode` functions are modified\n */\nexport var BiometricAuthError;\n(function (BiometricAuthError) {\n /**\n * Unknown error occurred\n */\n BiometricAuthError[BiometricAuthError[\"UNKNOWN_ERROR\"] = 0] = \"UNKNOWN_ERROR\";\n /**\n * Biometrics are unavailable (no hardware or hardware error)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"BIOMETRICS_UNAVAILABLE\"] = 1] = \"BIOMETRICS_UNAVAILABLE\";\n /**\n * User has been locked out due to too many failed attempts\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_LOCKOUT\"] = 2] = \"USER_LOCKOUT\";\n /**\n * No biometrics are enrolled on the device\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"BIOMETRICS_NOT_ENROLLED\"] = 3] = \"BIOMETRICS_NOT_ENROLLED\";\n /**\n * User is temporarily locked out (Android: 30 second lockout)\n * Platform: Android\n */\n BiometricAuthError[BiometricAuthError[\"USER_TEMPORARY_LOCKOUT\"] = 4] = \"USER_TEMPORARY_LOCKOUT\";\n /**\n * Authentication failed (user did not authenticate successfully)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"AUTHENTICATION_FAILED\"] = 10] = \"AUTHENTICATION_FAILED\";\n /**\n * App canceled the authentication (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"APP_CANCEL\"] = 11] = \"APP_CANCEL\";\n /**\n * Invalid context (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"INVALID_CONTEXT\"] = 12] = \"INVALID_CONTEXT\";\n /**\n * Authentication was not interactive (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"NOT_INTERACTIVE\"] = 13] = \"NOT_INTERACTIVE\";\n /**\n * Passcode/PIN is not set on the device\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"PASSCODE_NOT_SET\"] = 14] = \"PASSCODE_NOT_SET\";\n /**\n * System canceled the authentication (e.g., due to screen lock)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"SYSTEM_CANCEL\"] = 15] = \"SYSTEM_CANCEL\";\n /**\n * User canceled the authentication\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_CANCEL\"] = 16] = \"USER_CANCEL\";\n /**\n * User chose to use fallback authentication method\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_FALLBACK\"] = 17] = \"USER_FALLBACK\";\n})(BiometricAuthError || (BiometricAuthError = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeBiometric = registerPlugin('NativeBiometric', {\n web: () => import('./web').then((m) => new m.NativeBiometricWeb()),\n});\nexport * from './definitions';\nexport { NativeBiometric };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class NativeBiometricWeb extends WebPlugin {\n constructor() {\n super();\n }\n isAvailable() {\n throw new Error('Method not implemented.');\n }\n verifyIdentity(_options) {\n console.log('verifyIdentity', _options);\n throw new Error('Method not implemented.');\n }\n getCredentials(_options) {\n console.log('getCredentials', _options);\n throw new Error('Method not implemented.');\n }\n setCredentials(_options) {\n console.log('setCredentials', _options);\n throw new Error('Method not implemented.');\n }\n deleteCredentials(_options) {\n console.log('deleteCredentials', _options);\n throw new Error('Method not implemented.');\n }\n isCredentialsSaved(_options) {\n console.log('isCredentialsSaved', _options);\n throw new Error('Method not implemented.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BiometryType","AuthenticationStrength","BiometricAuthError","registerPlugin","WebPlugin"],"mappings":";;;A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AAE,QAAQ,CAAC;IACnD,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;IAClD;IACA,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC;IACA;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var BiometryType;\n(function (BiometryType) {\n // Android, iOS\n BiometryType[BiometryType[\"NONE\"] = 0] = \"NONE\";\n // iOS\n BiometryType[BiometryType[\"TOUCH_ID\"] = 1] = \"TOUCH_ID\";\n // iOS\n BiometryType[BiometryType[\"FACE_ID\"] = 2] = \"FACE_ID\";\n // Android\n BiometryType[BiometryType[\"FINGERPRINT\"] = 3] = \"FINGERPRINT\";\n // Android\n BiometryType[BiometryType[\"FACE_AUTHENTICATION\"] = 4] = \"FACE_AUTHENTICATION\";\n // Android\n BiometryType[BiometryType[\"IRIS_AUTHENTICATION\"] = 5] = \"IRIS_AUTHENTICATION\";\n // Android\n BiometryType[BiometryType[\"MULTIPLE\"] = 6] = \"MULTIPLE\";\n})(BiometryType || (BiometryType = {}));\nexport var AuthenticationStrength;\n(function (AuthenticationStrength) {\n /**\n * No authentication available, even if PIN is available but useFallback = false\n */\n AuthenticationStrength[AuthenticationStrength[\"NONE\"] = 0] = \"NONE\";\n /**\n * Strong authentication: Face ID on iOS, fingerprints on devices that consider fingerprints strong (Android).\n * Note: PIN/pattern/password is NEVER considered STRONG, even when useFallback = true.\n */\n AuthenticationStrength[AuthenticationStrength[\"STRONG\"] = 1] = \"STRONG\";\n /**\n * Weak authentication: Face authentication on Android devices that consider face weak,\n * or PIN/pattern/password if useFallback = true (PIN is always WEAK, never STRONG).\n */\n AuthenticationStrength[AuthenticationStrength[\"WEAK\"] = 2] = \"WEAK\";\n})(AuthenticationStrength || (AuthenticationStrength = {}));\n/**\n * Biometric authentication error codes.\n * These error codes are used in both isAvailable() and verifyIdentity() methods.\n *\n * Keep this in sync with BiometricAuthError in README.md\n * Update whenever `convertToPluginErrorCode` functions are modified\n */\nexport var BiometricAuthError;\n(function (BiometricAuthError) {\n /**\n * Unknown error occurred\n */\n BiometricAuthError[BiometricAuthError[\"UNKNOWN_ERROR\"] = 0] = \"UNKNOWN_ERROR\";\n /**\n * Biometrics are unavailable (no hardware or hardware error)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"BIOMETRICS_UNAVAILABLE\"] = 1] = \"BIOMETRICS_UNAVAILABLE\";\n /**\n * User has been locked out due to too many failed attempts\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_LOCKOUT\"] = 2] = \"USER_LOCKOUT\";\n /**\n * No biometrics are enrolled on the device\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"BIOMETRICS_NOT_ENROLLED\"] = 3] = \"BIOMETRICS_NOT_ENROLLED\";\n /**\n * User is temporarily locked out (Android: 30 second lockout)\n * Platform: Android\n */\n BiometricAuthError[BiometricAuthError[\"USER_TEMPORARY_LOCKOUT\"] = 4] = \"USER_TEMPORARY_LOCKOUT\";\n /**\n * Authentication failed (user did not authenticate successfully)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"AUTHENTICATION_FAILED\"] = 10] = \"AUTHENTICATION_FAILED\";\n /**\n * App canceled the authentication (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"APP_CANCEL\"] = 11] = \"APP_CANCEL\";\n /**\n * Invalid context (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"INVALID_CONTEXT\"] = 12] = \"INVALID_CONTEXT\";\n /**\n * Authentication was not interactive (iOS only)\n * Platform: iOS\n */\n BiometricAuthError[BiometricAuthError[\"NOT_INTERACTIVE\"] = 13] = \"NOT_INTERACTIVE\";\n /**\n * Passcode/PIN is not set on the device\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"PASSCODE_NOT_SET\"] = 14] = \"PASSCODE_NOT_SET\";\n /**\n * System canceled the authentication (e.g., due to screen lock)\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"SYSTEM_CANCEL\"] = 15] = \"SYSTEM_CANCEL\";\n /**\n * User canceled the authentication\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_CANCEL\"] = 16] = \"USER_CANCEL\";\n /**\n * User chose to use fallback authentication method\n * Platform: Android, iOS\n */\n BiometricAuthError[BiometricAuthError[\"USER_FALLBACK\"] = 17] = \"USER_FALLBACK\";\n})(BiometricAuthError || (BiometricAuthError = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeBiometric = registerPlugin('NativeBiometric', {\n web: () => import('./web').then((m) => new m.NativeBiometricWeb()),\n});\nexport * from './definitions';\nexport { NativeBiometric };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { BiometryType, AuthenticationStrength } from './definitions';\nexport class NativeBiometricWeb extends WebPlugin {\n constructor() {\n super();\n }\n isAvailable() {\n // Web platform: biometrics not available, but return structured response\n return Promise.resolve({\n isAvailable: false,\n authenticationStrength: AuthenticationStrength.NONE,\n biometryType: BiometryType.NONE,\n deviceIsSecure: false,\n strongBiometryIsAvailable: false,\n });\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async addListener(_eventName, _listener) {\n // Web platform: no-op, but return a valid handle\n return {\n remove: async () => {\n // Nothing to remove on web\n },\n };\n }\n verifyIdentity(_options) {\n console.log('verifyIdentity', _options);\n throw new Error('Biometric authentication is not available on web platform.');\n }\n getCredentials(_options) {\n console.log('getCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n setCredentials(_options) {\n console.log('setCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n deleteCredentials(_options) {\n console.log('deleteCredentials', _options);\n throw new Error('Credential storage is not available on web platform.');\n }\n isCredentialsSaved(_options) {\n console.log('isCredentialsSaved', _options);\n // Return false on web - no credentials can be saved\n return Promise.resolve({ isSaved: false });\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BiometryType","AuthenticationStrength","BiometricAuthError","registerPlugin","WebPlugin"],"mappings":";;;AAAWA;IACX,CAAC,UAAU,YAAY,EAAE;IACzB;IACA,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;IACnD;IACA,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;IAC3D;IACA,IAAI,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;IACzD;IACA,IAAI,YAAY,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa;IACjE;IACA,IAAI,YAAY,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAAG,qBAAqB;IACjF;IACA,IAAI,YAAY,CAAC,YAAY,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,GAAG,qBAAqB;IACjF;IACA,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;IAC3D,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;AAC5BC;IACX,CAAC,UAAU,sBAAsB,EAAE;IACnC;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;IACvE;IACA;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ;IAC3E;IACA;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;IACvE,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IACJ,IAAI,cAAc,CAAC,QAAQ,EAAE;IAC7B,QAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC;IAC/C,QAAQ,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC;IAC/E,IAAI;IACJ,IAAI,cAAc,CAAC,QAAQ,EAAE;IAC7B,QAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC;IAC/C,QAAQ,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC;IAC/E,IAAI;IACJ,IAAI,iBAAiB,CAAC,QAAQ,EAAE;IAChC,QAAQ,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IAClD,QAAQ,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC;IAC/E,IAAI;IACJ,IAAI,kBAAkB,CAAC,QAAQ,EAAE;IACjC,QAAQ,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,CAAC;IACnD;IACA,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClD,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -2,6 +2,8 @@ import Foundation
|
|
|
2
2
|
import Capacitor
|
|
3
3
|
import LocalAuthentication
|
|
4
4
|
|
|
5
|
+
// swiftlint:disable type_body_length cyclomatic_complexity
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Please read the Capacitor iOS Plugin Development Guide
|
|
7
9
|
* here: https://capacitor.ionicframework.com/docs/plugins/ios
|
|
@@ -9,7 +11,7 @@ import LocalAuthentication
|
|
|
9
11
|
|
|
10
12
|
@objc(NativeBiometricPlugin)
|
|
11
13
|
public class NativeBiometricPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
12
|
-
private let pluginVersion: String = "
|
|
14
|
+
private let pluginVersion: String = "8.0.1"
|
|
13
15
|
public let identifier = "NativeBiometricPlugin"
|
|
14
16
|
public let jsName = "NativeBiometric"
|
|
15
17
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -21,65 +23,106 @@ public class NativeBiometricPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
21
23
|
CAPPluginMethod(name: "isCredentialsSaved", returnType: CAPPluginReturnPromise),
|
|
22
24
|
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
|
|
23
25
|
]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
override public func load() {
|
|
28
|
+
NotificationCenter.default.addObserver(
|
|
29
|
+
self,
|
|
30
|
+
selector: #selector(handleAppDidBecomeActive),
|
|
31
|
+
name: UIApplication.didBecomeActiveNotification,
|
|
32
|
+
object: nil
|
|
33
|
+
)
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
case unexpectedPasswordData
|
|
32
|
-
case duplicateItem
|
|
33
|
-
case unhandledError(status: OSStatus)
|
|
36
|
+
deinit {
|
|
37
|
+
NotificationCenter.default.removeObserver(self)
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
@objc private func handleAppDidBecomeActive() {
|
|
41
|
+
// Notify listeners when app becomes active (resumes from background)
|
|
42
|
+
let result = checkBiometryAvailability(useFallback: false)
|
|
43
|
+
notifyListeners("biometryChange", data: result)
|
|
44
|
+
}
|
|
37
45
|
|
|
38
|
-
|
|
46
|
+
private func checkBiometryAvailability(useFallback: Bool) -> JSObject {
|
|
39
47
|
let context = LAContext()
|
|
40
48
|
var error: NSError?
|
|
41
49
|
var obj = JSObject()
|
|
42
50
|
|
|
43
51
|
obj["isAvailable"] = false
|
|
44
52
|
obj["authenticationStrength"] = 0 // NONE
|
|
53
|
+
obj["biometryType"] = 0 // NONE
|
|
54
|
+
obj["deviceIsSecure"] = false
|
|
55
|
+
obj["strongBiometryIsAvailable"] = false
|
|
45
56
|
|
|
46
|
-
let useFallback = call.getBool("useFallback", false)
|
|
47
|
-
|
|
48
57
|
// Check biometric-only policy first
|
|
49
58
|
let biometricPolicy = LAPolicy.deviceOwnerAuthenticationWithBiometrics
|
|
50
59
|
let hasBiometric = context.canEvaluatePolicy(biometricPolicy, error: &error)
|
|
51
|
-
|
|
60
|
+
|
|
61
|
+
// Determine biometry type
|
|
62
|
+
let biometryType: Int
|
|
63
|
+
switch context.biometryType {
|
|
64
|
+
case .touchID:
|
|
65
|
+
biometryType = 1 // TOUCH_ID
|
|
66
|
+
case .faceID:
|
|
67
|
+
biometryType = 2 // FACE_ID
|
|
68
|
+
case .opticID:
|
|
69
|
+
biometryType = 2 // Treat opticID as FACE_ID for compatibility
|
|
70
|
+
default:
|
|
71
|
+
biometryType = 0 // NONE
|
|
72
|
+
}
|
|
73
|
+
obj["biometryType"] = biometryType
|
|
74
|
+
|
|
75
|
+
// Check if device has passcode set (device is secure)
|
|
76
|
+
let devicePolicy = LAPolicy.deviceOwnerAuthentication
|
|
77
|
+
var deviceError: NSError?
|
|
78
|
+
let deviceIsSecure = context.canEvaluatePolicy(devicePolicy, error: &deviceError)
|
|
79
|
+
obj["deviceIsSecure"] = deviceIsSecure
|
|
80
|
+
|
|
52
81
|
// Check device credentials policy if fallback is enabled
|
|
53
82
|
var hasDeviceCredentials = false
|
|
54
83
|
if useFallback {
|
|
55
|
-
|
|
56
|
-
var deviceError: NSError?
|
|
57
|
-
hasDeviceCredentials = context.canEvaluatePolicy(devicePolicy, error: &deviceError)
|
|
84
|
+
hasDeviceCredentials = deviceIsSecure
|
|
58
85
|
}
|
|
59
|
-
|
|
86
|
+
|
|
87
|
+
// Strong biometry is available if biometric authentication works
|
|
88
|
+
// On iOS, both Face ID and Touch ID are considered STRONG
|
|
89
|
+
obj["strongBiometryIsAvailable"] = hasBiometric
|
|
90
|
+
|
|
60
91
|
if hasBiometric {
|
|
61
|
-
// Biometric available - Face ID and Touch ID are both considered STRONG on iOS
|
|
62
92
|
obj["authenticationStrength"] = 1 // STRONG
|
|
63
93
|
obj["isAvailable"] = true
|
|
64
|
-
call.resolve(obj)
|
|
65
94
|
} else if hasDeviceCredentials {
|
|
66
|
-
// Only device credentials (PIN/password) available when useFallback is true
|
|
67
|
-
// PIN/password is ALWAYS considered WEAK, never STRONG
|
|
68
95
|
obj["authenticationStrength"] = 2 // WEAK
|
|
69
96
|
obj["isAvailable"] = true
|
|
70
|
-
call.resolve(obj)
|
|
71
97
|
} else {
|
|
72
|
-
|
|
73
|
-
|
|
98
|
+
if let authError = error {
|
|
99
|
+
let pluginErrorCode = convertToPluginErrorCode(authError.code)
|
|
100
|
+
obj["errorCode"] = pluginErrorCode
|
|
101
|
+
} else {
|
|
74
102
|
obj["errorCode"] = 0
|
|
75
|
-
call.resolve(obj)
|
|
76
|
-
return
|
|
77
103
|
}
|
|
78
|
-
var pluginErrorCode = convertToPluginErrorCode(authError.code)
|
|
79
|
-
obj["errorCode"] = pluginErrorCode
|
|
80
|
-
call.resolve(obj)
|
|
81
104
|
}
|
|
82
105
|
|
|
106
|
+
return obj
|
|
107
|
+
}
|
|
108
|
+
struct Credentials {
|
|
109
|
+
var username: String
|
|
110
|
+
var password: String
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
enum KeychainError: Error {
|
|
114
|
+
case noPassword
|
|
115
|
+
case unexpectedPasswordData
|
|
116
|
+
case duplicateItem
|
|
117
|
+
case unhandledError(status: OSStatus)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
typealias JSObject = [String: Any]
|
|
121
|
+
|
|
122
|
+
@objc func isAvailable(_ call: CAPPluginCall) {
|
|
123
|
+
let useFallback = call.getBool("useFallback", false)
|
|
124
|
+
let result = checkBiometryAvailability(useFallback: useFallback)
|
|
125
|
+
call.resolve(result)
|
|
83
126
|
}
|
|
84
127
|
|
|
85
128
|
@objc func verifyIdentity(_ call: CAPPluginCall) {
|
|
@@ -201,10 +244,14 @@ public class NativeBiometricPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
201
244
|
|
|
202
245
|
// Store user Credentials in Keychain
|
|
203
246
|
func storeCredentialsInKeychain(_ credentials: Credentials, _ server: String) throws {
|
|
247
|
+
guard let passwordData = credentials.password.data(using: .utf8) else {
|
|
248
|
+
throw KeychainError.unexpectedPasswordData
|
|
249
|
+
}
|
|
250
|
+
|
|
204
251
|
let query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
|
|
205
252
|
kSecAttrAccount as String: credentials.username,
|
|
206
253
|
kSecAttrServer as String: server,
|
|
207
|
-
kSecValueData as String:
|
|
254
|
+
kSecValueData as String: passwordData]
|
|
208
255
|
|
|
209
256
|
let status = SecItemAdd(query as CFDictionary, nil)
|
|
210
257
|
|
|
@@ -218,7 +265,9 @@ public class NativeBiometricPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
218
265
|
kSecAttrServer as String: server]
|
|
219
266
|
|
|
220
267
|
let account = credentials.username
|
|
221
|
-
let password = credentials.password.data(using: String.Encoding.utf8)
|
|
268
|
+
guard let password = credentials.password.data(using: String.Encoding.utf8) else {
|
|
269
|
+
throw KeychainError.unexpectedPasswordData
|
|
270
|
+
}
|
|
222
271
|
let attributes: [String: Any] = [kSecAttrAccount as String: account,
|
|
223
272
|
kSecValueData as String: password]
|
|
224
273
|
|
|
@@ -311,3 +360,5 @@ public class NativeBiometricPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
311
360
|
call.resolve(["version": self.pluginVersion])
|
|
312
361
|
}
|
|
313
362
|
}
|
|
363
|
+
|
|
364
|
+
// swiftlint:enable type_body_length cyclomatic_complexity
|