src/servers.js
function encryptSecrects(server, cryptoSecret, oldSever) {
  const updatedServer = { ...server };

  /* eslint no-param-reassign:0 */
  if (server.password) {
    const isPassDiff = (oldSever && server.password !== oldSever.password);

    if (!oldSever || isPassDiff) {
      updatedServer.password = crypto.encrypt(server.password, cryptoSecret);
    }
  }

  if (server.ssh && server.ssh.password) {
    const isPassDiff = (oldSever && server.ssh.password !== oldSever.ssh.password);

    if (!oldSever || isPassDiff) {
      updatedServer.ssh.password = crypto.encrypt(server.ssh.password, cryptoSecret);
    }
  }

  updatedServer.encrypted = true;
  return updatedServer;
}
function encryptSecrects(server, cryptoSecret, oldSever) {
  const updatedServer = { ...server };

  /* eslint no-param-reassign:0 */
  if (server.password) {
    const isPassDiff = (oldSever && server.password !== oldSever.password);

    if (!oldSever || isPassDiff) {
      updatedServer.password = crypto.encrypt(server.password, cryptoSecret);
    }
  }

  if (server.ssh && server.ssh.password) {
    const isPassDiff = (oldSever && server.ssh.password !== oldSever.ssh.password);

    if (!oldSever || isPassDiff) {
      updatedServer.ssh.password = crypto.encrypt(server.ssh.password, cryptoSecret);
    }
  }

  updatedServer.encrypted = true;
  return updatedServer;
}
function encryptSecrects ( server , cryptoSecret , oldSever ) { const updatedServer = { ... server } ; /* eslint no-param-reassign:0 */ if ( server . password ) { const isPassDiff = ( oldSever && server . password !== oldSever . password ) ; if ( ! oldSever || isPassDiff ) { updatedServer . password = crypto . encrypt ( server . password , cryptoSecret ) ; } } if ( server . ssh && server . ssh . password ) { const isPassDiff = ( oldSever && server . ssh . password !== oldSever . ssh . password ) ; if ( ! oldSever || isPassDiff ) { updatedServer . ssh . password = crypto . encrypt ( server . ssh . password , cryptoSecret ) ; } } updatedServer . encrypted = true ; return updatedServer ; }
ensure all secret fields are encrypted
ensure all secret fields are encrypted