How to use the react-native-keychain.getGenericPassword function in react-native-keychain

To help you get started, we’ve selected a few react-native-keychain examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oblador / react-native-keychain / test_index.js View on Github external
(result: void);
});

// $FlowExpectedError - First two arguments are required
setGenericPassword();
setGenericPassword('username', 'password').then(result => {
  (result: boolean);
});
setGenericPassword('username', 'password', 'service');
setGenericPassword('username', 'password', simpleOptions);

getGenericPassword().then(result => {
  (result: boolean | SharedWebCredentials);
});
getGenericPassword('service');
getGenericPassword(simpleOptions);

resetGenericPassword().then(result => {
  (result: boolean);
});
resetGenericPassword('service');
resetGenericPassword(simpleOptions);

requestSharedWebCredentials().then(result => {
  if (result) {
    (result.server: string);
    (result.username: string);
    (result.password: string);
  }
});

setSharedWebCredentials('server', 'username', 'password').then(result => {
github MainframeHQ / onyx / packages / onyx-mobile / App.js View on Github external
async fetchStoredCreds () {
    try {
      const storedValues = await AsyncStorage.multiGet([
        SERVER_URL_KEY,
        CLIENT_CERT_PATH_KEY,
        CA_CERT_PATH_KEY,
      ])
      let caCertPath // Android only
      if (storedValues.length) {
        const serverUrl = storedValues[0][1]
        const clientCertPath = storedValues[1][1]
        if (Platform.OS === 'android') {
          caCertPath = storedValues[2][1]
        }
        if (serverUrl && clientCertPath){
          const credentials = await Keychain.getGenericPassword()
          this.onSelectNode(
            serverUrl,
            clientCertPath,
            credentials.password,
            caCertPath
          )
          return
        }
      }
    } catch (error) {
      console.warn(error)
    }
    this.setDisconnected()
  }
github mozilla / notes / native / app / vendor / fxa-utils.js View on Github external
function fxaGetCredential() {
    // Retrieve the credentials
    return Keychain.getGenericPassword().then((credentials) => {
      if (credentials && credentials.password) {
        // TODO: might need to refactor this to exit out if empty
        const creds = JSON.parse(credentials.password);
        return creds;
      } else {
        return {};
      }
    }).catch((error) => {
      // TODO: What on earth do we do here?
      console.log('Keychain cannot be accessed!', error);
      return {};
    });
}
github jolocom / smartwallet-app / src / lib / storage / migration / 1567674609659-reencrypt-seed.ts View on Github external
async function getPassword(): Promise {
  // At the time of writing this file, the encryption password is stored in
  // react-native-keychain and accessesed through src/lib/keychain.ts, but code
  // is reproduced here in case things change in the future

  if (typeof navigator !== 'undefined' && navigator.product == 'ReactNative') {
    // We load react-native-keychain here conditionally because it is not
    // transpiled and cannot be loaded into ts-node (if running migrations locally
    // on dev machine)
    const Keychain = require('react-native-keychain')

    const keyChainData = await Keychain.getGenericPassword()
    if (keyChainData && keyChainData.password) {
      return keyChainData.password
    } else {
      throw new Error(
        "Can't load password from react-native-keychain"
      )
    }
  } else {
    const password = process.env.SMARTWALLET_PASSWORD
    if (!password) {
      throw new Error(
        "Node envrionment detected. " +
        "Please set a password in the environment variable SMARTWALLET_PASSWORD"
      )
    }
    return password
github coreyphillips / moonshine / src / utils / helpers.js View on Github external
return new Promise(async (resolve) => {
		try {
			const result = await Keychain.getGenericPassword(key);
			resolve({ error: false, data: result });
		} catch (e) {
			resolve({ error: true, data: e });
			console.log(e);
		}
	});
};
github StoDevX / AAO-React-Native / views / settings / index.ios.js View on Github external
async retrieveCredientials() {
    let credentials = await Keychain.getGenericPassword()

    console.log('username', credentials.username)
    console.log('password', credentials.password)
    console.log('Credentials successfully created')
  }
github UCSD / campus-mobile / app / util / auth.js View on Github external
retrieveUserCreds() {
		return Keychain
			.getGenericPassword()
			.then(credentials => (credentials))
			.catch(error => (error))
	},
github zzorba / ArkhamCards / lib / auth.ts View on Github external
export function getRefreshToken() {
  return Keychain.getGenericPassword()
    .then(creds => {
      if (creds) {
        const data = JSON.parse(creds.password);
        return data.refreshToken;
      }
      return null;
    });
}
github mobius-network / wallet / src / components / Auth / PinSetup / PinPad / PinCodeEnter.js View on Github external
async componentWillMount() {
    if (!this.props.storedPin) {
      this.keyChainResult = await Keychain.getGenericPassword();
    }
  }