Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const validatePassphrase = passphrase => {
if (passphrase.trim().length === 0) {
return [{ code: 'empty_value', message: 'Invalid Passphrase' }];
}
const numberOfWords = Math.ceil(passphrase.trim().split(' ').length / 3) * 3;
const validPassLength = Math.max(Math.min(numberOfWords, 24), 12);
return Lisk.passphrase.validation.getPassphraseValidationErrors(
passphrase,
undefined,
validPassLength
);
};
export const getDerivedPathFromPassphrase = (passphrase, config) => {
const seed = Lisk.passphrase.Mnemonic.mnemonicToSeed(passphrase);
return bip32.fromSeed(seed, config.network).derivePath(config.derivationPath);
};
export const getDerivedPathFromPassphrase = passphrase => {
const seed = Lisk.passphrase.Mnemonic.mnemonicToSeed(passphrase);
return bip32.fromSeed(seed, config.network).derivePath(config.derivationPath);
};
import Lisk from '@liskhq/lisk-client';
import * as Keychain from 'react-native-keychain';
import FingerprintScanner from 'react-native-fingerprint-scanner';
import { Platform } from 'react-native';
import { extractAddress } from './api/lisk/account';
const fullWordsList = Lisk.passphrase.Mnemonic.wordlists.EN;
/**
* Checks validity of passphrase using to mnemonic
*
* detects validity of each word individually
* the result consist of [multiple] object[s]
* which have a member with a 'code' key whose value
* is one of the below
* INVALID_AMOUNT_OF_WORDS
* INVALID_AMOUNT_OF_WHITESPACES
* INVALID_AMOUNT_OF_UPPERCASE_CHARACTER
* INVALID_MNEMONIC
*
* and a message which indicates the issue
* in a more human readable fashion
*