sjhoeksma / cordova-plugin-keychain-touch-id

Touch ID plugin with saving password in keychain for IOS and android
87 stars 160 forks source link

Command `save`: unable to make `userAuthenticationRequired` work #49

Open Muzietto opened 5 years ago

Muzietto commented 5 years ago

I am trying to use save on IOS.

My call is:

window.plugins.touchid.save(
  "MyAppID",
  "PasswordGivenInAPasswordPrompt",
   true,
   successCallback,
   errorCallback
)

function successCallback() {console.log('success')}
function errorCallback(err) {console.log('error', err)}

I get systematically the error Error in Success callback: TouchID xyz - Type Error: callback.success.call is not a function

If I remove the true in the third position, everything is fine.

It appears that the documentation about save is wrong: the third boolean param userAuthenticationRequired seems to be no longer in place and the two places in the docs where it is mentioned and taken as example should be amended.

MatthewPringle commented 5 years ago

I have just noticed the same, yet the code in the repo seems fine

save: function(key,password, userAuthenticationRequired, successCallback, errorCallback) { exec(successCallback, errorCallback, "TouchID", "save", [key,password, userAuthenticationRequired]); },

VDGone commented 5 years ago

If you use the last release version (3.2.1), just remove the "true" value after "PasswordGivenInAPasswordPrompt".

window.plugins.touchid.save( "MyAppID", "PasswordGivenInAPasswordPrompt", successCallback, errorCallback )

edubskiy commented 5 years ago

I think if you do this and enrolls your finger/face successfully you will always get errorCallback(message), where message equals "success".

ukenpachi commented 4 years ago

the npm library has changed so what is userAuthenticationRequired for?

 /**
     * 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<any>} Returns a promise that resolves when there is a result
     */
    save(key: string, password: string, userAuthenticationRequired: boolean): Promise<any>;

the comment does not say what it is for