How to use node-xmpp-core - 10 common examples

To help you get started, we’ve selected a few node-xmpp-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xmppjs / radiowave / lib / router / ConnectionRouter.js View on Github external
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);
};
github xmppjs / radiowave / lib / core / XComponent.js View on Github external
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;
    }
};
github xmppjs / radiowave / xep / Xep0045-muc / index.js View on Github external
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);
github xmppjs / radiowave / lib / components / Xep0045-muc / modules / Presence.js View on Github external
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;
};
github xmppjs / radiowave / xep / Xep0045-muc / index.js View on Github external
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)) ||
github sessionbird / xmpp-smtp-gw / lib / mailer.js View on Github external
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 {
github xmppjs / radiowave / lib / api / routes / Room.js View on Github external
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);
github xmppjs / radiowave / lib / components / Xep0045-muc / modules / Invitation.js View on Github external
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
github xmppjs / radiowave / lib / api / routes / Room.js View on Github external
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;
        }
github xmppjs / radiowave / lib / api / routes / Channel.js View on Github external
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);

node-xmpp-core

core files for the node-xmpp project

ISC
Latest version published 8 years ago

Package Health Score

61 / 100
Full package analysis

Popular node-xmpp-core functions