oblador / react-native-keychain

:key: Keychain Access for React Native
MIT License
3.12k stars 515 forks source link

Attempt to invoke interface method 'java.lang.String com.oblador.keychain.cipherStorage.CipherStorage.getCipherStorageName()' on a null object reference #602

Open MAKARD opened 1 year ago

MAKARD commented 1 year ago

Version 8.1.1

Stacktrace: Error: Attempt to invoke interface method 'java.lang.String com.oblador.keychain.cipherStorage.CipherStorage.getCipherStorageName()' on a null object reference at Object.getGenericPasswordForOptions (index.android.bundle:58:1103) at O (index.android.bundle:748:3104) at Function.<anonymous> (index.android.bundle:747:1739) at Generator.next (<anonymous>) at n (index.android.bundle:8:70) at v (index.android.bundle:8:281) at u (index.android.bundle:100:157) at index.android.bundle:100:869 at index.android.bundle:106:1663 at k (index.android.bundle:106:498)

Affected devices and versions

image

Number of occurrences May 20-Jun 20 - 23.1k

Code sample:

import {
  getGenericPassword,
  ACCESS_CONTROL,
  ACCESSIBLE,
  SECURITY_RULES,
} from 'react-native-keychain';

const SERVICE_CREDENTIALS = 'com.myapp-keychain';

export class CredentialsManager {
  public static get = async () => {
    const options = {
      accessControl: ACCESS_CONTROL.BIOMETRY_ANY_OR_DEVICE_PASSCODE,
      accessible: ACCESSIBLE.ALWAYS,
    };

    const credentials = await getGenericPassword({
      ...options,
      service: SERVICE_CREDENTIALS,
      authenticationPrompt: {
        title: 'Confirm login to continue',
      },
      rules: SECURITY_RULES.NONE,
    });

    if (!credentials || !credentials.username || !credentials.password) {
      return false;
    }

    return {
      username: credentials.username,
      password: credentials.password,
    };
  };
}
AlixH commented 9 months ago

up