Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should call stringifyEncryptedPassphrase', () => {
const input = {
passphrase: 'random-passphrase',
password: 'password',
};
cryptography.encryptPassphrase(input);
return expect(
cryptographyModule.stringifyEncryptedPassphrase,
).to.be.calledWithExactly(passphraseObject);
});
});
config.forging.secret.forEach(secret => {
console.info('.......');
config.forging.delegates.push({
encryptedPassphrase: stringifyEncryptedPassphrase(
encryptPassphraseWithPassword(secret, password)
),
publicKey: getPrivateAndPublicKeyFromPassphrase(secret).publicKey,
});
});
config.forging.secret.forEach(secret => {
console.info('.......');
config.forging.delegates.push({
encryptedPassphrase: stringifyEncryptedPassphrase(
encryptPassphraseWithPassword(secret, password)
),
publicKey: getPrivateAndPublicKeyFromPassphrase(secret).publicKey,
});
});
export const encryptPassphrase = ({
passphrase,
password,
}: EncryptPassphraseInputs) => {
const encryptedPassphraseObject = cryptography.encryptPassphraseWithPassword(
passphrase,
password,
);
const encryptedPassphrase = cryptography.stringifyEncryptedPassphrase(
encryptedPassphraseObject,
);
return { encryptedPassphrase };
};
const processInputs = (outputPublicKey: boolean) => ({
passphrase,
password,
}: InputFromSourceOutput) => {
if (!passphrase) {
throw new ValidationError('No passphrase was provided');
}
if (!password) {
throw new ValidationError('No password was provided');
}
const encryptedPassphraseObject = encryptPassphraseWithPassword(
passphrase,
password,
);
const encryptedPassphrase = stringifyEncryptedPassphrase(
encryptedPassphraseObject,
);
return outputPublicKey
? {
encryptedPassphrase,
publicKey: getKeys(passphrase).publicKey,
}
: { encryptedPassphrase };
};