Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "node-xmpp-core in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-xmpp-core' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

ConnectionRouter.prototype.handle = function (stanza) {

    // verify we have a to adress
    if (!stanza.attrs.to) {
        stanza.attrs.to = new JID(stanza.attrs.from).getDomain();
    }

    this.logger.debug('emit stanza: ' + stanza.toString());
    this.emit('stanza', stanza);
};
XComponent.prototype.verifyDomain = function (stanza)  {

    var jid = new JID(stanza.attrs.to);
    var xmppdomain = this.getDomain();

    this.logger.debug('check for domain: ' + xmppdomain);

    // check that the domain fits
    if (jid.getDomain().toString().localeCompare(xmppdomain) !== 0) {
        this.logger.debug('stanza does not match domain');
        return false;
    } else {
        return true;
    }
};
Muc.prototype.handle = function (stanza) {
    logger.debug('muc route');

    var to = new JID(stanza.attrs.to);
    var handled = false;

    if (stanza.is('presence')) {
        // handle presence request for specific room
        if (to.getDomain().toString().localeCompare(this.getDomain) !== 0) {
            handled = this.handleOccupantPresence(stanza);
        }

        // TODO handle normal presence request
        // 1. check if user is already offline
        // 2. make user offline in all active rooms
    }
    else if (stanza.is('message')) {
        // handle messages
        var msg = stanza.is('message');
        var x = stanza.getChild('x', NS.MUC_USER);
Presence.prototype.handle = function (stanza) {
  var handled = false;
  var to = new JID(stanza.attrs.to);

  if (stanza.is('presence')) {
    // handle presence request for specific room
    if (to.getDomain().toString().localeCompare(this.getDomain) !== 0) {
      handled = this.handleOccupantPresence(stanza);
    }

    // TODO handle normal presence request
    // 1. check if user is already offline
    // 2. make user offline in all active rooms
  }

  return handled;
};
Muc.prototype.match = function (stanza) {
    var jid = new JID(stanza.attrs.to);
    var domain = this.getDomain();

    // check that the domain fits
    if (jid.getDomain().toString().localeCompare(domain) !== 0) {
        return false;
    }

    if (
        // message
        (stanza.is('message') && stanza.attrs.type === 'groupchat') ||
        // mediated invitation
        (stanza.is('message') && (stanza.getChild('x', NS.MUC_USER) && stanza.getChild('x', NS.MUC_USER).getChild('invite'))) ||
        // presence
        (stanza.is('presence')) ||
        // discovery
        (stanza.is('iq') && stanza.getChild('query', NS.DISCO_ITEMS)) ||
Mailer.prototype.sendSmtp = function (data) {

  // clone data
  var mail = _.cloneDeep(data);
  mail.from = this.options.sender;

  // try to extract the target email
  // get the local part and unescape the content
  mail.to = new JID(data.to).getLocal(true)

  // remove X-Mailer header by default
  mail.xMailer = false;
  if (this.options.xMailer) {
    mail.xMailer = this.options.xMailer
  }

  if (this.smtptransport) {
    this.smtptransport.sendMail(mail, function (error, response) {
      if (error) {
        debug('message error: ' + error);
      } else {
        debug('message sent: ' + response.message);
      }
    });
  } else {
roomapi.delete('/rooms/:owner/:room/members/:user', function(req, res) {
        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;
        var membername = req.params.user;

        logger.debug('Delete member from room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        // owner of the room
        var ownerjid = new JID(username + '@' + domain);

        // check if this user is member of the room
        var memberjid = new JID(membername);

        // verify that owner and requestor are the same
        if (!ownerjid.equals(jid)) {
            res.send(400);
            return;
        }

        // owner cannot remove owner
        logger.debug('OWNER: ' + ownerjid.toString());
        logger.debug('MEMBER: ' + memberjid.toString());

        if (ownerjid.equals(memberjid)) {
            res.send(400);
Invitation.prototype.inviteEventHandler = function (inviteRequest) {

    var roomjid = new JID(inviteRequest.room.name + '@' + this.options.domain);
    var invitee = inviteRequest.invitee.jid;
    var inviter = inviteRequest.inviter.jid;
    var reason = inviteRequest.reason ||  "";

    this.logger.debug('send invite for ' + roomjid.toString() + ' to ' + invitee + ' with reason: ' + reason);

    // Sends Invitation to Invitee on Behalf of Invitor
    var invitation = new XmppMessage({
        from: roomjid.toString(),
        to: invitee
    });
    var xEl = invitation.c('x', {
        'xmlns': NS.MUC_USER
    });
    var inviteEl = xEl.c('invite', {
        'from': inviter
roomapi.delete('/rooms/:owner/:room/members/:user', function(req, res) {
        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;
        var membername = req.params.user;

        logger.debug('Delete member from room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        // owner of the room
        var ownerjid = new JID(username + '@' + domain);

        // check if this user is member of the room
        var memberjid = new JID(membername);

        // verify that owner and requestor are the same
        if (!ownerjid.equals(jid)) {
            res.send(400);
            return;
        }

        // owner cannot remove owner
        logger.debug('OWNER: ' + ownerjid.toString());
        logger.debug('MEMBER: ' + memberjid.toString());

        if (ownerjid.equals(memberjid)) {
            res.send(400);
            return;
        }
channelapi.get('/channels/:owner/:channel', function(req, res) {
        // extract parameter
        var username = req.params.owner;
        var channelname = req.params.channel;

        logger.debug('Get channel: ' +  username + '/' + channelname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);
        var ownerjid = new JID(username + '@' + domain);

        var usr = null;
        var c = null;
        storage.findUser(jid.toString()).then(function (user) {
            usr = user;
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            return storage.getChannel(owner, channelname);
        }).then(function(channel) {
            c = channel;
            return channel.isSubscriber(usr);
        }).then(function() {
            logger.debug('is subscriber');
            res.json(c);
        }).catch(function(err) {
            logger.error(err);

Is your System Free of Underlying Vulnerabilities?
Find Out Now