UNPKG

@phemium-costaisa/fingerprint-auth

Version:

Automatic plugin to work with FaceID and TouchID authentication

99 lines (98 loc) 3.79 kB
import { FingerprintAIO } from '@ionic-native/fingerprint-aio/ngx'; import { AndroidFingerprintAuth } from '@ionic-native/android-fingerprint-auth/ngx'; import { TouchID } from '@ionic-native/touch-id/ngx'; import { Keychain } from '@ionic-native/keychain/ngx'; import { Platform } from '@ionic/angular'; import { TranslateService } from '@ngx-translate/core'; import { Router } from '@angular/router'; import { StorageService } from './storage.service'; import { FingerprintAuthConfiguration } from '../interfaces'; export declare enum Biometric { Face = "face", Fingerprint = "finger", Common = "biometric" } export interface BiometricsAvailable { face: boolean; touch: boolean; } export declare type Biometrics = 'face' | 'fingerprint' | 'biometric'; export declare class FingerprintService { private platform; private faio; private androidFingerprintAuth; private touchId; private keychain; private router; private storage; private translateService; private readonly config; constructor(platform: Platform, faio: FingerprintAIO, androidFingerprintAuth: AndroidFingerprintAuth, touchId: TouchID, keychain: Keychain, router: Router, storage: StorageService, translateService: TranslateService, config: FingerprintAuthConfiguration); /** * Use this method in Login page to check if user * should be redirected to the Biometric Activator */ checkIfNeedsBiometric(user: string): Promise<boolean>; /** * Use in Login page to open Biometric prompt * @param user string */ showBiometricPrompt(user: string): Promise<{ user: string; password: string; }>; private _iosShowTouchPrompt; private _sanitizeUser; private _getStorageKey; private _getStorageToken; private getLang; isBiometricActive(user: string, biometricType: keyof BiometricsAvailable): Promise<any>; isPlatformMobile(): boolean; clearBiometricData(user: string, biometricType: keyof BiometricsAvailable): Promise<void>; disableBiometricData(user: string, biometricType: keyof BiometricsAvailable): Promise<void>; showFingerprintId(user: string, biometricType: keyof BiometricsAvailable): import("rxjs").Observable<boolean>; /** * Use in Login page to show the Biometric Activator page * @param user User * @param password Password * @param callbackUrl URL to return after success or fail */ showBiometricActivator(user: string, password: string, callbackUrl: string): void; /** * Checks and returns which biometrics methods are available * for the current device * @returns Promise<Biometric[]> */ retrieveDeviceBiometrics(): Promise<BiometricsAvailable>; private _isIOS; /** * Stores the credentials used for biometrics * @param user Client user * @param password Client password */ private _storePassword; /** * Shows the FaceID dialog to the user * @param user Client user * @returns Promise<void> */ activateFaceID(user: string, password: string): Promise<void>; /** * Shows the TouchID dialog to the user * @param user Client user * @param password Client password */ activateTouchID(user: string, password: string): Promise<void>; /** * Executes an attempt to check for the client fingerprint * Used mainly in Login * @returns Promise<void> */ launchTouchID(user: string): Promise<string | null>; /** * Executes an attempt to check for the client face * Used mainly in Login * @returns Promise<void> */ launchFaceID(user: string): Promise<string | null>; }