File tree 1 file changed +24
-3
lines changed 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -141,9 +141,30 @@ export class BiometricAuth implements BiometricApi {
141
141
} ) ;
142
142
}
143
143
144
- didBiometricDatabaseChange ( ) : Promise < boolean > {
145
- return Promise . resolve ( false ) ;
146
- }
144
+ // Following: https://stackoverflow.com/questions/61193681/check-if-the-user-changed-biometric-fingerprint-in-android as a guide
145
+ didBiometricDatabaseChange ( ) : Promise < boolean > {
146
+ return new Promise ( ( resolve , reject ) => {
147
+ const options = { } ;
148
+ const cipher = this . getCipher ( ) ;
149
+ var secretKey = this . getSecretKey ( KEY_NAME ) ;
150
+ if ( secretKey === null ) {
151
+ BiometricAuth . generateSecretKey ( options , reject ) ;
152
+ secretKey = this . getSecretKey ( KEY_NAME ) ;
153
+ }
154
+ try {
155
+ cipher . init ( javax . crypto . Cipher . ENCRYPT_MODE , secretKey ) ;
156
+ } catch ( ex ) {
157
+ console . log ( `Error in biometrics-auth.verifyBiometric: ${ ex } ` ) ;
158
+ try {
159
+ BiometricAuth . generateSecretKey ( options , reject ) ;
160
+ resolve ( true ) ;
161
+ } catch ( e ) {
162
+ console . log ( `Error when generating new key: ${ ex } ` ) ;
163
+ }
164
+ }
165
+ resolve ( false ) ;
166
+ } ) ;
167
+ }
147
168
148
169
// Following: https://developer.android.com/training/sign-in/biometric-auth#java as a guide
149
170
verifyBiometric ( options : VerifyBiometricOptions ) : Promise < BiometricResult > {
You can’t perform that action at this time.
0 commit comments