A websocket plugin for Authorify authorization and authentication system for REST server

Usage no npm install needed!

<script type="module">
  import authorifyWebsocket from '';


Authorify Websocket

A plugin for Authorify that enable websockets. A provided router allow to use both http and websockets like a REST server. When the plugin is loaded it is available under the main namespace of the host application: app.plugin['your short plugin name'].


This plugin must be installed both in server and client, respectively in conjunction with Authorify and Authorify-Client.


Install authorify-websocket as usual:

$ npm install --save authorify-websocket



var restify = require('restify');
var authorify = require('authorify')({
  //... options
// create the http server
var server = restify.createServer();
// add plugin to the server
authorify.load('authorify-websocket', 'ws', {
  transports: ['ws', 'http'],
  requestTimeout: 200
// get the loaded plugin
var ws =;
// create the websocket server
var router = ws.router;
// add routes
router.get('/handshake', ok);
router.get('/auth', ok);
router.get('/logout', ok);'/test', ok);
// start the server

Client (Node)

// create the client
var client = require('authorify-client')({
  //... options
// add plugin to the client
client.load('authorify-websocket', 'ws', {
  transports: ['ws', 'http'],
  requestTimeout: 200

Client (browser)

To create a single file to use in browser environment use a simple script that uses browserify:

$ ./

and add the obtained authorify-websocket.js file to your html file.

NOTE: this file must be added AFTER authorify.js (the client) and BEFORE your script (index.js in this example):

// index.js
var client = authorify;   // authorify is a global exposed by authorify-client
// configure the client
  //... options
// load plugin
client.load('authorify-websocket', 'ws', {
  transports: ['ws', 'http'],
  requestTimeout: 200
// request a resource
var message = { field1: 'value1', field2: 'value2' };'/test')
   .end(function(err, res) {
      // the reply here or err only if request is over timeout
// index.html
    <script src="authorify.js"></script>    // this is the browser version of Authorify-Client
    <script src="authorify-websocket.js"></script>
    <script src="index.js"></script>

Run Tests

Au usual we use mocha as test framework and you can run all tests simply typing:

$ npm test

A full test for both server and client side is available into authorify package.

For more information about the client please read authorify-client documentation and the local documentation into doc` folder.


To create your own documentation you must install JSDuck and type in your terminal:

$ cd /path-of-package
$ ./

See full documentation into doc folder.


The version number is laid out as: major.minor.patch and tries to follow semver as closely as possible but this is how we use our version numbering:


A major and possible breaking change has been made in the authorify core. These changes could be not backwards compatible with older versions.


New features are added or a big change has happened with one of the third party libraries.


A bug has been fixed, without any major internal and breaking changes.


To contribute to the project follow the GitHub guidelines.


This program is released under a GNU Affero General Public License version 3 or above, which in summary means:

  • You can use this program for no cost.
  • You can use this program for both personal and commercial reasons.
  • You do not have to share your own program's code which uses this program.
  • You have to share modifications (e.g bug-fixes) you've made to this program.

For more convoluted language, see the LICENSE file.