lib/tcp.js
/*
 * authenticates and authorize access to remote node with password
 * @param connection {Socket}: the socket connecting to the remote node
 * @param secret {String}: the encryption seceret key
 * @param passwd {String}: the remote node password
 * @return {Promise}
 */
authenticates and authorize access to remote node with password
@param connection {Socket}: the socket connecting to the remote node
@param secret {String}: the encryption seceret key
@param passwd {String}: the remote node password
@return {Promise}
authenticates and authorize access to remote node with password @param connection { Socket } : the socket connecting to the remote node @param secret { String } : the encryption seceret key @param passwd { String } : the remote node password @return { Promise }
function authOver(connection, secret, passwd) {
    var hostId = connection.path + ":" + connection.port;
    return new Promise(function(resolve, reject) {
        try {
            connection.emit('AUTH', cs.secure({data: passwd}, secret));
            connection.on('AUTH:STATUS', function(data) {
                if(data.status) {
                    resolve({connection: connection, secret: secret});
                }
                else {
                    reject(new Error(hostId + " " + data.error));
                }
            });
        }
        catch(error) { reject(new Error(hostId + " " + error.message)); }
    });
}
function authOver ( connection , secret , passwd ) { var hostId = connection . path + ":" + connection . port ; return new Promise ( function ( resolve , reject ) { try { connection . emit ( 'AUTH' , cs . secure ( { data : passwd } , secret ) ) ; connection . on ( 'AUTH:STATUS' , function ( data ) { if ( data . status ) { resolve ( { connection : connection , secret : secret } ) ; } else { reject ( new Error ( hostId + " " + data . error ) ) ; } } ) ; } catch ( error ) { reject ( new Error ( hostId + " " + error . message ) ) ; } } ) ; }
authenticates and authorize access to remote node with password
 @param connection {Socket}: the socket connecting to the remote node
 @param secret {String}: the encryption seceret key
 @param passwd {String}: the remote node password
 @return {Promise}
authenticates and authorize access to remote node with password @param connection { Socket } : the socket connecting to the remote node @param secret { String } : the encryption seceret key @param passwd { String } : the remote node password @return { Promise }