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

websocket-extensions

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websocket-extensions

Generic extension manager for WebSocket connections

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.3M
decreased by-43.34%
Maintainers
1
Weekly downloads
 
Created

What is websocket-extensions?

The websocket-extensions npm package is a framework for managing extensions to the WebSocket protocol. It allows for the negotiation and processing of protocol extensions between a client and server. This package is typically used in conjunction with WebSocket servers and clients to enhance the capabilities of the WebSocket connection with additional features such as compression.

What are websocket-extensions's main functionalities?

Extension negotiation

This feature allows the server to negotiate which extensions will be used in the WebSocket connection. The 'generateOffer' method is used to create an offer that can be sent in the 'Sec-WebSocket-Extensions' header.

const Extensions = require('websocket-extensions'),
      exts = new Extensions();

exts.add('permessage-deflate');

let offer = exts.generateOffer();
console.log(offer); // logs string to send in the 'Sec-WebSocket-Extensions' header

Extension parsing

This feature parses the 'Sec-WebSocket-Extensions' header from the client or server to determine which extensions have been agreed upon. The 'parseHeader' method processes the header string.

const Extensions = require('websocket-extensions'),
      exts = new Extensions();

exts.add('permessage-deflate');

let response = 'permessage-deflate; server_max_window_bits=10';
exts.parseHeader(response);

Extension processing

This feature processes incoming and outgoing messages using the agreed-upon extensions. The 'incoming' and 'outgoing' methods are used to define how messages should be transformed.

const Extensions = require('websocket-extensions'),
      exts = new Extensions();

exts.add('permessage-deflate', {
  incoming: function(message, callback) {
    // Decompress message.data if needed
    callback(null, message);
  },
  outgoing: function(message, callback) {
    // Compress message.data if needed
    callback(null, message);
  }
});

Other packages similar to websocket-extensions

Keywords

FAQs

Package last updated on 10 Sep 2017

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