npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-xmpp-tmp

v1.0.1

Published

Idiomatic XMPP client, component & server library for node.js + browserify

Downloads

1

Readme

node-xmpp

idiomatic XMPP library for node.js

Now usable in browsers too thanks to Browserify.

build status

Sub-modules

We've split node-xmpp into a set of submodules, realistically its now one of these that you'll want to use rather than node-xmpp itself. This project remains so existing users can continue to use the project, and as a location for integration tests. New users should make use of the sub-modules.

build status node-xmpp-server

build status node-xmpp-client

build status node-xmpp-component

build status node-xmpp-core

Installation

Note: We now only support nodejs versions 0.8.0 and greater.

With package manager npm:

npm install node-xmpp

Testing

Install the dev dependencies, then...

npm test

To run the tests and the code style checks then use:

grunt test

Also see the tests run in travis. The tests in travis run both the code and code style tests.

How to use

Please see the various examples.

Objectives of node-xmpp:

  • Use node.js conventions, especially EventEmitter, ie. for write buffer control
  • Fast parsing, node-expat was written for this library
  • Client support for both XMPP clients and components
  • Optional server infrastructure with Router
  • After authentication, leave trivial protocol bits to the user, that is XML handling according to any XEP

Features

  • Client authentication with SASL DIGEST-MD5, PLAIN, ANONYMOUS, X-FACEBOOK-PLATFORM
  • _xmpp-client._tcp SRV record support
  • Simple JID parsing with Stringprep normalization
    • Optional now, you won't need ICU for just node-xmpp
    • Please be aware if you identify users by JIDs
    • npm install node-stringprep
  • Uses ltx
    • Much easier to handle than a standard DOM
    • xmlns-aware
    • Easy XML builder like Strophe.js (see down)
    • Non-buffering serialization
    • Was split out of node-xmpp for modularization and resuability
  • Component connections
  • Run your own server/talk to other servers with xmpp.Router
  • Even runs in the Browser.

Dependencies

Optional

Built with node-xmpp

Related Libraries

Design

Inheritance tree and associations:

┌────────────┐1     1┌────────────┐
│ net.Stream ├───────┤ Connection │
└────────────┘       └────────────┘
                           ↑
      ┌────────────┬───────┴───┬────────────┐
      │            │           │            │
┏━━━━━┷━━━━┓ ┏━━━━━┷━━━━━┓ ┌───┴────┐ ┌─────┴─────┐
┃  Client  ┃ ┃ Component ┃ │ Server │ │ C2SStream │
┗━━━━━━━━━━┛ ┗━━━━━━━━━━━┛ └────────┘ └───────────┘
                               ↑            ↑0..*
         ┌─────────────────────┤            │accepts
         │                     │            │1
┌────────┴───────┐ ┌───────────┴────┐ ┏━━━━━┷━━━━━┓
│ OutgoingServer │ │ IncomingServer │ ┃ C2SServer ┃
└─────────────┬──┘ └───┬────────────┘ ┗━━━━━┯━━━━━┛
         0..* │        │ 0..*               │
      creates │        │ accepts            │
             ┏┷━━━━━━━━┷┓                   │
             ┃  Router  ┃←──────────────────┘
             ┗━━━━━━━━━━┛ 1

This foundation is complemented by two basic data structures:

  • JID: a Jabber-Id, represented as a triple of user, domain, resource
  • Element: any XML Element

Building XML Elements

Strophe.js' XML Builder is very convenient for producing XMPP stanzas. ltx includes it in a much more primitive way: the c(), cnode() and t() methods can be called on any Element object, returning the new child element.

This can be confusing: in the end, you will hold the last-added child until you use up(), a getter for the parent. Connection.send() first invokes tree() to retrieve the uppermost parent, the XMPP stanza, before sending it out the wire.

Browser Support

node-xmpp now comes with a prebuilt browser bundle:

<script src="/node_modules/node-xmpp/node-xmpp-browser.js"></script>
<script type="text/javascript">
    var client = new XMPP.Client(opts);
</script>

Keepalives

Rather than send empty packets in order to keep any socket alive please try the following:

this.client.connection.socket.setTimeout(0)
this.client.connection.socket.setKeepAlive(true, 10000)

Where this.client is the result of new require('node-xmpp').Client().

Development Roadmap

For the next releases, we will focus on stability and security of node-xmpp. Pull requests are welcome to position node-xmpp as the best, most secure and most stable xmpp library for nodejs.

node-xmpp-core:

  • manifesto: support the STARTTLS method in XMPP as specified in RFC 6120, including mandatory-to-implement cipher suites and certificate validation consistent with RFC 6125
  • manifesto: prefer the latest version of TLS (TLS 1.2) #192
  • manifesto: disable support for the older and less secure SSL standard (SSLv2 and SSLv3)
  • manifesto: provide configuration options to require channel encryption for client-to-server and server-to-server connections
  • manifesto: provide configuration options to prefer or require cipher suites that enable forward secrecy
  • Events harmonization
  • Common pause/resume/... for any Client/Component/Server session
  • Smoothen reconnect
  • Properly disconnect on stream errors, not on connection errors
  • more tests to verify against RFC3920

node-xmpp-client:

  • Lookup BOSH URLs in DNS TXT records
  • Move connecting to connection, use WS/BOSH as TCP fallback
  • Ensure tls end/close/drain events
  • Possible may to use strophe plugins with node-xmpp, see dodo/Lightstream
  • more tests to verify against RFC3921
  • more demo apps to spead the usage
  • develop high-level client-api as seperate project to use json as input and output, see inspiration xmpp-ftw/xmpp-ftw
  • work on early DNSSEC implementation, see XMPP-DNA and DNSSEC

node-xmpp-server:

  • simple Websockets server (at least for testing the client)
  • Tests for S2S connections
  • maifesto: prefer authenticated encryption
  • harmonize c2s, bosh and websocket server components

Documentation

(Builing up documentation slowly)

C2S Client to Server

var client = new xmpp.Client({
    jid: '[email protected]',
    password: 'password'
})

client.on('connection', function() {
    console.log('online')
})

client.on('stanza', function(stanza) {
    console.log('Incoming stanza: ', stanza.toString())
})

Closing a connection

client.end()