device/lib/tls.js
function buildBuilder(mqttClient, opts) {
   var connection;

   connection = tls.connect(opts);

   function handleTLSerrors(err) {
      mqttClient.emit('error', err);
      connection.end();
   }

   connection.on('secureConnect', function() {
      if (!connection.authorized) {
         connection.emit('error', new Error('TLS not authorized'));
      } else {
         connection.removeListener('error', handleTLSerrors);
      }
   });

   connection.on('error', handleTLSerrors);
   return connection;
}
function buildBuilder(mqttClient, opts) {
   var connection;

   connection = tls.connect(opts);

   function handleTLSerrors(err) {
      mqttClient.emit('error', err);
      connection.end();
   }

   connection.on('secureConnect', function() {
      if (!connection.authorized) {
         connection.emit('error', new Error('TLS not authorized'));
      } else {
         connection.removeListener('error', handleTLSerrors);
      }
   });

   connection.on('error', handleTLSerrors);
   return connection;
}
function buildBuilder ( mqttClient , opts ) { var connection ; connection = tls . connect ( opts ) ; function handleTLSerrors ( err ) { mqttClient . emit ( 'error' , err ) ; connection . end ( ) ; } connection . on ( 'secureConnect' , function ( ) { if ( ! connection . authorized ) { connection . emit ( 'error' , new Error ( 'TLS not authorized' ) ) ; } else { connection . removeListener ( 'error' , handleTLSerrors ) ; } } ) ; connection . on ( 'error' , handleTLSerrors ) ; return connection ; }
npm deps app deps
npm deps app deps