Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pusher-js-client-auth

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pusher-js-client-auth

Allow authentication to take place entirely in the client, avoiding the need for a server component. This is a security risk but may have some valid use cases or be useful when getting started.

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

pusher-js Client Authentication Plugin

Pusher is built with security in mind. Because of this you need to authenticate subscriptions to private- and presence- channels against a server. However, sometimes you don't want to do this. This plugin provides a way of authenticating on the client (in the browser).

However, you SHOULD NOT expose your application secret in production. If you have a real production use case for this then please drop me an email.

Prerequisites

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

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/2.2/pusher.min.js"></script>
<script src="dist/pusher-js-client-auth.js"></script>

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(APP_KEY, {
    authTransport: 'client',
    clientAuth: {
      key: APP_KEY,
      secret: APP_SECRET,
      user_id: USER_ID,
      user_info: {}
    }
});

clientAuth.key (String)

Required field. This is duplicating the APP_KEY. However, there is no nice way of fetching the value through the existing API so duplication seems to be the best option for now.

clientAuth.secret (String)

Required field. This is your application secret. Remember: do not deploy this to production.

user_id (String)

The user_id used when authenticating Presence channels. This user id will be used to uniquely identify the user.

user_info (Object)

The user_info used when authenticating Presence channels. The information supplied here will be available to anybody subscribed to the presence channel.

var pusher = new Pusher(APP_KEY, {
    authTransport: 'client',
    clientAuth: {
      key: APP_KEY
      secret: APP_SECRET,
      user_id: 'leggetter',
      user_info: {
        twitter: 'leggetter'
        github: 'leggetter'
        bio: 'Developer Evangelist'
      }
    }
});

Library Development

Setup

Install Gulp globally.

$ npm install --global gulp

Install module dev dependencies.

$ npm install

Testing

gulp test

Keywords

FAQs

Package last updated on 08 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc