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

pusher-js-auth

v4.0.1

Published

Pusher plugin for batching auth requests in one HTTP call

Downloads

44,360

Readme

Pusher plugin for authentication

Pusher plugin for batching auth requests in one HTTP call.
When subscribing to multiple private- and presence channels at once, your browser has to make an HTTP request for each channel. This plugin enables you to process multiple channel authentications within one request.

Prerequisites

This is a plugin for the official Pusher JavaScript library and compatible with the latest 7.0.x release. Make sure you have a working implementation up and running.

Notice: This version is not compatible with Pusher 6.0 and older. Please use version 3.0 of this plugin with older Pusher versions.

Documentation and configuration options are explained at the Pusher-js Github page

Usage

Load the plugin after including the Pusher library

<script src="//js.pusher.com/4.2/pusher.min.js"></script>
<script src="lib/pusher-auth.js"></script>

This plugin is also available on npm and bower:

npm install pusher-js-auth
bower install pusher-js-auth

Configuration

This plugin comes with a few extra configuration parameters. The whole list is available at the Pusher-js Github page

var pusher = new Pusher(API_KEY, {
    authorizer: PusherBatchAuthorizer,
    authDelay: 200
});

authorizer (Function)

Pass the function exposed by this plugin here. It is exposed as a module export when using AMD or CommonJS, and as the PusherBatchAuthorizer global otherwise.

authDelay (Number)

Optional, defaults to 0. Delay in milliseconds before executing an authentication request. The value can be as low as 0 when subscribing to multiple channels within the same event loop. Please note that the first authentication request is postponed anyway until the connection to Pusher succeeds.

Server side authentication

Your authentication endpoint should be able to handle batched requests.

Incoming post data

socket_id   	  00000.0000000
channel_name[0]	  private-a
channel_name[1]	  private-b

Expected output

{
    "private-a": {
        "status": 200, // HTTP status codes, optional on success
        "data": {
            "auth": "xxxxxx:xxxxxxxxxxxxx"
        }
    },
    "private-b": {
        "status": 200,
        "data": {
            "auth": "xxxxxx:xxxxxxxxxxxxx"
        }
    },
    "private-c": {
        "status": 403
    }
}

Use one of the server libraries to do most of the hard work.

Example implementation

Copy app_key.example.js and app_key.example.php to app_key.example.xx and fill in your own Pusher data. Create a small PHP server and run index.html with your browser's debug console active.