
* chore: fixing typescript return types * refactor(keychain-touch-id): more specific return types * docs(keychain-touch-id): correct verify func desc
97 lines
3.1 KiB
TypeScript
97 lines
3.1 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
|
|
|
export type BiometryType = 'face' | 'touch';
|
|
|
|
/**
|
|
* @name Keychain Touch Id
|
|
* @description
|
|
* A cordova plugin adding the iOS TouchID / Android fingerprint to your
|
|
* app and allowing you to store a password securely in the device keychain.
|
|
*
|
|
* @usage
|
|
* ```typescript
|
|
* import { KeychainTouchId } from '@ionic-native/keychain-touch-id/ngx';
|
|
*
|
|
*
|
|
* constructor(private keychainTouchId: KeychainTouchId) { }
|
|
*
|
|
* ...
|
|
*
|
|
*
|
|
* this.keychainTouchId.isAvailable()
|
|
* .then((res: any) => console.log(res))
|
|
* .catch((error: any) => console.error(error));
|
|
*
|
|
* ```
|
|
*/
|
|
@Plugin({
|
|
pluginName: 'KeychainTouchId',
|
|
plugin: 'cordova-plugin-keychain-touch-id',
|
|
pluginRef: 'plugins.touchid',
|
|
repo: 'https://github.com/sjhoeksma/cordova-plugin-keychain-touch-id',
|
|
platforms: ['Android', 'iOS'],
|
|
})
|
|
@Injectable()
|
|
export class KeychainTouchId extends IonicNativePlugin {
|
|
/**
|
|
* Check if Touch ID / Fingerprint is supported by the device
|
|
* @return {Promise<any>} Returns a promise that resolves when there is hardware support
|
|
*/
|
|
@Cordova()
|
|
isAvailable(): Promise<BiometryType> {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Encrypts and Saves a password under the key in the device keychain, which can be retrieved after
|
|
* successful authentication using fingerprint
|
|
* @param key {string} the key you want to store
|
|
* @param password {string} the password you want to encrypt and store
|
|
* @return {Promise<void>} Returns a promise that resolves when there is a result
|
|
*/
|
|
@Cordova()
|
|
save(key: string, password: string, userAuthenticationRequired: boolean): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Opens the fingerprint dialog, for the given key, showing an additional message. Promise will resolve
|
|
* with the password stored in keychain or will reject with an error code, where "-1" indicated not available.
|
|
* @param key {string} the key you want to retrieve from keychain
|
|
* @param message {string} a message to the user
|
|
* @return {Promise<string>} Returns a promise that resolves when the key value is successfully retrieved or an error
|
|
*/
|
|
@Cordova()
|
|
verify(key: string, message: string): Promise<string> {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Checks if there is a password stored within the keychain for the given key.
|
|
* @param key {string} the key you want to check from keychain
|
|
* @return {Promise<void>} Returns a promise that resolves with success if the key is available or failure if key is not.
|
|
*/
|
|
@Cordova()
|
|
has(key: string): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Deletes the password stored under given key from the keychain.
|
|
* @param key {string} the key you want to delete from keychain
|
|
* @return {Promise<void>} Returns a promise that resolves with success if the key is deleted or failure if key is not
|
|
*/
|
|
@Cordova()
|
|
delete(key: string): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Sets the language of the fingerprint dialog
|
|
* @param locale {string} locale subtag from [this list](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry).
|
|
*/
|
|
@Cordova()
|
|
setLocale(locale: string): void {}
|
|
}
|