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 encryptPassphraseWithPassword', () => {
const input = {
passphrase: 'random-passphrase',
password: 'password',
};
cryptography.encryptPassphrase(input);
return expect(
cryptographyModule.encryptPassphraseWithPassword,
).to.be.calledWithExactly(input.passphrase, input.password);
});
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 };
};