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 🙏

© 2025 – Pkg Stats / Ryan Hefner

slate-irc-sasl

v1.0.2

Published

Node.js IRC client library plugin for EXTERNAL SASL AUTHENTIFICATION

Downloads

8

Readme

slate-irc-sasl

SASL Authentication Plugin for slate-irc general purpose IRC client:

( slate-irc core: https://github.com/slate/slate-irc )

  • plugin system

  • simple api

  • arbitrary input stream

  • DEBUG support for easy debugging

Installation

// install core 
$ npm install slate-irc
// install sasl plugin
$ npm install slate-irc-sasl

Example


var irc = require('slate-irc');
var sasl = require('slate-irc-sasl');
var tls = require('tls');
var fs = require('fs');

// setup options here. 
var self = {
  host: "chat.freenode.net",
  port: "6697",
  nick: '',
  user: '',
  pass: '',
  key: '', 
  cert: ''
};

var stream = tls.connect({
  host: self.host,
  port: self.port,
  key: fs.readFileSync(require("path").resolve(__dirname, self.key)),
  cert: fs.readFileSync(require("path").resolve(__dirname, self.cert))
}, function() {
        
  var client = irc(stream);
  client.use(sasl());

  client.write("CAP LS");
  client.nick(self.nick);
  client.user(self.user, self.user);
  client.cap_req("sasl");
  client.authenticate("PLAIN");
  client.authenticate64(self.user, self.pass);
  client.cap_end();
  client.setMaxListeners(0);

  client.join('#express');
  client.names('#express', function(err, names){
  console.log(names);
  })     
})


Core API

Events

  • data (msg) parsed IRC message
  • message (event) on PRIVMSG
  • notice (event) on NOTICE
  • invite (event) on INVITE
  • names (event) on RPL_NAMREPLY
  • topic (event) on TOPIC
  • away (event) on RPL_AWAY
  • quit (event) on QUIT
  • join (event) on JOIN
  • part (event) on PART
  • kick (event) on KICK
  • mode (event) on MODE
  • motd (event) on RPL_ENDOFMOTD
  • nick (event) on NICK
  • welcome (nick) on RPL_WELCOME
  • whois (event) on RPL_ENDOFWHOIS
  • errors (event) on ERR*_
  • pong (event) on PONG

Client

Given a stream from net or tls or another network source, construct an IRC client.

var client = irc(stream);

.pass(pass)

Used at the beginning of connection to specify a 'connection password' for servers requiring a auth.

.nick(nick)

Specify an string irc nick for the user.

.user(username, realname)

Used at the beginning of connection to specify the username and realname of a new user.

.invite(name, channel)

Send an invite to name, for a channel.

.send(target, msg)

Send a msg to the target user or channel.

.action(target, msg)

Send an ACTION msg to the target user or channel. Example output: * erming slaps tj around a bit with a large trout

.notice(target, msg)

Send a NOTICE msg to the target user or channel.

.ctcp(target, msg)

Send a CTCP notice to the target user.

.join(channel, key)

Send a JOIN command for the user to join channel with optional key.

.part(channel, msg)

Send a PART command for the user to part channel with optional msg.

.names(channel, callback)

List names of users in channel, calling callback with (error, names).

.away(message)

Set the user's away message to message.

.topic(channel, topic)

Get channel topic or set the topic to topic.

.kick(channels, nicks, msg)

Kick nick(s) from channel(s) with optional msg.

.oper(name, password)

Used to obtain operator privileges. The combination of name and password are required to gain Operator privileges. Upon success, a 'mode' event will be emitted.

.mode(target, flags, params)

Used to set a user's mode or channel's mode for a user.

  • .mode('cmilhench', '-o');
    • // cmilhench 'deopping' himself.
  • .mode('#channel', '+o', 'name');
    • // give 'chanop' privileges to name on channel #channel.

.quit(msg)

Disconnect from the server with optional msg.

.whois(target, mask, callback)

Used to query information about particular user.

Writing Plugins

Plugins are simply functions that accept the IRC client as an argument. With this you can define methods, listen on events and interact with the client. For example here's a logger plugin that outputs to stdout:

function logger() {
  return function(irc){
    irc.stream.pipe(process.stdout);
  }
}

Then .use() it like so:

var client = irc(stream);
client.use(logger());

Returning a function like logger() instead of logger is optional, however it's useful to use a closure when passing options, and to keep the interface consistent with plugins that do accept options, for example:

function logger(stream) {
  return function(irc){
    irc.stream.pipe(stream);
  }
}

client.use(logger(process.stdout));

Here's a slightly more complex example of a PONG plugin responding to PING messages:

function pong(){
  return function(irc){
    irc.on('data', function(msg){
      if ('PING' != msg.command) return;
      irc.write('PONG :' + msg.trailing);
    });
  }
}

License

MIT