epicshaggy / capacitor-native-biometric

181 stars 94 forks source link

Save multiple Credentials on Android #26

Open Steffen86de opened 3 years ago

Steffen86de commented 3 years ago

Hi @epicshaggy

First of all thanks a lot for this great plugin.

I am wondering if there is any chance to save more than one credential pair on Android. The current behaviour is that any new saved credentials will overwrite existing ones. As per the code username and password are stored on Android's keystore using the fix key "username" and "password". Can this be changed to use a composite key e.g. KEY_ALIAS+".username" and KEY_ALIAS+".password"?

See NativeBiometric.java, Line 137-139: SharedPreferences.Editor editor = getContext().getSharedPreferences(NATIVE_BIOMETRIC_SHARED_PREFERENCES, Context.MODE_PRIVATE).edit(); editor.putString("username", encryptString(username, KEY_ALIAS)); editor.putString("password", encryptString(password, KEY_ALIAS));

On iOS it works perfectly fine and more than one credential pair can be saved.

Thanks and best regards, Steffen

epicshaggy commented 2 years ago

Thank you! That's a great idea, but I'm currently not able to implemented. However feel free to submit a PR if you can do it!