How to use react-native-sha256 - 2 common examples

To help you get started, we’ve selected a few react-native-sha256 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 demokratie-live / democracy-client / src / graphql / client.js View on Github external
const decodedRefreshToken = jwtDecode(refreshToken);

    const currentTime = Date.now() / 1000;
    if (decodedToken.exp >= currentTime || decodedRefreshToken.exp >= currentTime) {
      // Token valid
      return {
        headers: {
          ...headers,
          'x-token': token,
          'x-refresh-token': refreshToken,
        },
      };
    }
  }
  // No (valid) Token present - login
  const deviceHash = await sha256(DeviceInfo.getUniqueID());
  const phoneHash = await AsyncStorage.getItem('auth_phoneHash');
  const newHeaders = {
    ...headers,
    'x-device-hash': deviceHash,
  };
  if (phoneHash) {
    newHeaders['x-phone-hash'] = phoneHash;
  }
  return { headers: newHeaders };
});
github demokratie-live / democracy-client / src / screens / SmsVerification / Code.js View on Github external
onChangeCode = async code => {
    if (code.length === 6) {
      const phoneNumber = await AsyncStorage.getItem('auth_phone');
      const phoneNumberHash = await sha256(phoneNumber);
      const res = await this.props.requestVerification({
        variables: { code, newPhoneHash: phoneNumberHash },
      });
      if (res.data.requestVerification.succeeded) {
        AsyncStorage.setItem('auth_phoneHash', phoneNumberHash);
        Keyboard.dismiss();
        this.props.navigator.push({
          screen: 'democracy.SmsVerification.Success',
          backButtonTitle: 'Zurück',
          passProps: {
            onComplete: this.props.onComplete,
          },
          navigatorStyle: { navBarHidden: true },
        });
      } else {
        this.showNotification({ message: res.data.requestVerification.reason });

react-native-sha256

Native sha256 react-native

MIT
Latest version published 10 months ago

Package Health Score

64 / 100
Full package analysis

Popular react-native-sha256 functions