node-xmpp-serviceadmin

Service Administration (XEP-0133) library for node-xmpp

npm install node-xmpp-serviceadmin
2 downloads in the last day
3 downloads in the last week
16 downloads in the last month

node-xmpp-serviceadmin

Jabber Service Administration XEP-0133 library for node-xmpp.

Build Status Dependency Status NPM version

Installation

With package manager npm:

npm install node-xmpp-serviceadmin

Usage

First of all make sure your server is configured correctly (see "Configuring your server"). Then you can require and use the module like that:

var xmpp          = require("node-xmpp");
var ServiceAdmin  = require("node-xmpp-serviceadmin");

// define the host
var service = "example.org";

// define the JID that has the admin privileges
var root = "root@mycomponent.example.org";

// create the xmpp connection
var comp = new xmpp.Component({
  jid       : "mycomponent",
  password  : "secret",
  host      : "127.0.0.1",
  port      : "8888"
});

var sa = new ServiceAdmin(root, comp, service);

// wait until the component is online
comp.on("online", function(){

  // creating a new user
  sa.addUser(
    "jid@example.org",
    "secret",
    { name: "Der Weihnachtsmann" },
    function(err){ /*...*/ }
  );

  // changing a user password
  sa.changeUserPassword(
    "jid@example.org",
    "newSecret",
    function(err){ /*...*/ }
  );

  // delete a user
  sa.deleteUser(
    "jid@example.org",
    function(err){ /*...*/ }
  );

  // delete multiple users at once
  sa.deleteUser(
    ["jid@example.org","jid2@example.org"],
    function(err){ /*...*/ }
  );

});

Configuring your server

Make sure that:

  1. The server supports XEP-0133
  2. The JID of your component has admin privileges
  3. XEP-0133 is enabled

Prosody

admins = { "root@example.org", "admin@component.example.org" }

modules_enabled = {
  --
  "admin_adhoc";
  --
};

ejabberd

v2.13 and older

{acl, admin, {user, "root", "example.org"}}.
{acl, admin, {user, "admin", "component.example.org"}}.

v13.10 and newer

acl:
  admin:
    user:
      - "root":  "example.org"
      - "admin": "component.example.org"

Running tests

npm install
npm test

License

node-xmpp-serviceadmin is licensed under the MIT-Licence (see LICENSE.txt)

npm loves you