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

scalper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scalper

An authentication ticket store designed to allow using an express app to do auth for a socket.io app

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

scalper

A ticket store designed to allow an application to use an express app to do auth for a socket.io app. compatible with Express 4

Installation

npm install scalper

Options

  • authenticate - Function that checks if current request is authenticated. It is passed the request object, and should return the value that will be stored in the ticket. (default checks req.user._id and req.user.id)
  • genTicket - Function that returns the ticket. (default uses the node-uuid v4 method)
  • route - String that represents the GET route that will serve tickets. (default is '/socket-ticket')
  • store - an instance of a ticket store. (default is a memory-store instance)

Store Option

Note: The default memory store should not be used in production. A store should expose a get and a set method. set should take three arguments. A key, a value, and a callback. The store implementation should ensure the uniqueness of tickets get should take two arguments. A key and a callback. Important get should delete the ticket as soon as its retrieved, so that tickets can not be used twice.

Look at redis-ticket for an example implementation with mongodb.

Motivation

There are many advantages for token based authentication when using websockets. Heroku docs have a nice article outlining some of the details of securing websockets. authO.com has a blog post that also goes over the details of token based auth with socket.io

FAQs

Package last updated on 02 Jul 2020

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