oblador / react-native-keychain

:key: Keychain Access for React Native
MIT License
3.17k stars 519 forks source link

App asking Re-enter password for my app #324

Open Piraban opened 4 years ago

Piraban commented 4 years ago

My Keychain.ts file look like

  `
  import { Storage } from 'redux-persist';
 import * as RNKeychain from 'react-native-keychain';
 import { Option, Compare } from 'nasi';

 export class Keychain implements Storage {
    private options: RNKeychain.Options;
    private prefix = 'EEAAXXXXX.com.abcsgroup';

     constructor(options?: RNKeychain.Options, prefix?: string) {
         this.options = options ?? {};
         if (Option.isSome(prefix)) {
              this.prefix = prefix;
          }
      }

     public getItem = async (key: string) => {
             const service = `${this.prefix}${key}`;

              const response = await RNKeychain.getInternetCredentials(
              service,
              this.options,
              );

          if (!response || !Compare.strEq(response.username, service)) {
              throw new Error('Keychain retrieval failed.');
          }
               return response.password;
        };

     public setItem = async (key: string, value: string) => {
        const service = `${this.prefix}${key}`;

       try {
          await this.getItem(key);
         await this.removeItem(key);
       } catch {}

     const response = await RNKeychain.setInternetCredentials(
       service,
       service,
      value,
      this.options,
     );

    if (!response) {
       throw new Error('Keychain set failed.');
    }
   };
   public removeItem = async (key: string) => {
     const service = `${this.prefix}${key}`;
     return RNKeychain.resetInternetCredentials(service, this.options);
  };
}
  `

I added project.entitlements and info.plist added

  ```
NSFaceIDUsageDescription
  <string>Enabling Face ID allows you quick and secure access to your account.</string>


But app is prompting to enter password for App on top of my main screen...

may I know what is the reason it is prompting to enter keychain password?
cladjules commented 4 years ago

What did you pass as accessControl in your options?