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

@thream/socketio-jwt

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thream/socketio-jwt - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

8

build/__test__/authorize.test.js

@@ -33,3 +33,3 @@ "use strict";

const socket = socket_io_client_1.io('http://localhost:9000', {
extraHeaders: { Authorization: 'testing' }
auth: { token: 'testing' }
});

@@ -45,3 +45,3 @@ socket.on('connect_error', (err) => {

const socket = socket_io_client_1.io('http://localhost:9000', {
extraHeaders: { Authorization: 'Bearer testing' }
auth: { token: 'Bearer testing' }
});

@@ -57,3 +57,3 @@ socket.on('connect_error', (err) => {

const socket = socket_io_client_1.io('http://localhost:9000', {
extraHeaders: { Authorization: `Bearer ${token}` }
auth: { token: `Bearer ${token}` }
});

@@ -84,3 +84,3 @@ socket.on('connect', () => {

const socket = socket_io_client_1.io('http://localhost:9000', {
extraHeaders: { Authorization: `Bearer ${token}` }
auth: { token: `Bearer ${token}` }
});

@@ -87,0 +87,0 @@ socket.on('connect', () => {

@@ -13,5 +13,5 @@ "use strict";

let encodedToken = null;
const authorizationHeader = socket.request.headers.authorization;
if (authorizationHeader != null) {
const tokenSplitted = authorizationHeader.split(' ');
const { token } = socket.handshake.auth;
if (token != null) {
const tokenSplitted = token.split(' ');
if (tokenSplitted.length !== 2 || tokenSplitted[0] !== 'Bearer') {

@@ -29,3 +29,2 @@ return next(new UnauthorizedError_1.UnauthorizedError('credentials_bad_format', {

}
// Store encoded JWT
socket.encodedToken = encodedToken;

@@ -49,3 +48,2 @@ let keySecret = null;

}
// Store decoded JWT
socket.decodedToken = decodedToken;

@@ -52,0 +50,0 @@ return next();

# Changelog
## [2.0.0](https://github.com/Thream/socketio-jwt/compare/v1.1.1...v2.0.0) (2021-02-22)
### Features
- usage of auth option to send credentials ([a14d4e9](https://github.com/Thream/socketio-jwt/commit/a14d4e937b764fdf4fb6b173c55b6f49688766dd))
See: <https://socket.io/docs/v3/middlewares/#Sending-credentials>
### BREAKING CHANGES
- `extraHeaders` with `Authorization` doesn't work anymore
### Migration
You need to change the way to connect client side.
Before :
```ts
import { io } from 'socket.io-client'
const socket = io('http://localhost:9000', {
extraHeaders: { Authorization: `Bearer ${yourJWT}` }
})
```
After :
```ts
import { io } from 'socket.io-client'
const socket = io('http://localhost:9000', {
auth: { token: `Bearer ${yourJWT}` }
})
```
## [1.1.1](https://github.com/Thream/socketio-jwt/compare/v1.1.0...v1.1.1) (2021-01-28)

@@ -4,0 +40,0 @@

{
"name": "@thream/socketio-jwt",
"version": "1.1.1",
"version": "2.0.0",
"description": "Authenticate socket.io incoming connections with JWTs.",

@@ -28,11 +28,7 @@ "license": "MIT",

"homepage": "https://github.com/Thream/socketio-jwt#readme",
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "npm run lint"
}
},
"release-it": {
"git": {
"commitMessage": "chore(release): v${version}"
"commit": false,
"push": false,
"tag": false
},

@@ -48,2 +44,4 @@ "github": {

"npm run lint",
"npm run markdownlint",
"npm run build",
"npm run test"

@@ -77,2 +75,3 @@ ]

"build": "rimraf ./build && tsc",
"markdownlint": "markdownlint '**/*.md' --ignore node_modules",
"lint": "ts-standard | snazzy",

@@ -83,3 +82,6 @@ "format": "ts-standard --fix | snazzy",

"test:watchAll": "jest --watchAll",
"test:clearCache": "jest --clearCache"
"test:clearCache": "jest --clearCache",
"_postinstall": "husky install",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable"
},

@@ -99,18 +101,20 @@ "peerDependencies": {

"@types/jsonwebtoken": "8.5.0",
"@types/node": "14.14.22",
"@types/node": "14.14.31",
"@types/server-destroy": "1.0.1",
"axios": "0.21.1",
"express": "4.17.1",
"husky": "4.3.8",
"husky": "5.1.0",
"jest": "26.6.3",
"release-it": "14.2.2",
"markdownlint-cli": "0.26.0",
"pinst": "2.1.4",
"release-it": "14.4.1",
"rimraf": "3.0.2",
"server-destroy": "1.0.1",
"snazzy": "9.0.0",
"socket.io": "3.1.0",
"socket.io-client": "3.1.0",
"ts-jest": "26.4.4",
"socket.io": "3.1.1",
"socket.io-client": "3.1.1",
"ts-jest": "26.5.1",
"ts-standard": "10.0.0",
"typescript": "4.1.3"
"typescript": "4.1.5"
}
}

@@ -90,2 +90,7 @@ <h1 align="center">Thream/socketio-jwt</h1>

### `authorize` options
- `secret` is a string containing the secret for HMAC algorithms, or a function that should fetch the secret or public key as shown in the example with `jwks-rsa`.
- `algorithms` (default: `HS256`)
### Client side

@@ -96,5 +101,5 @@

// Require Bearer Tokens to be passed in as an Authorization Header
// Require Bearer Token
const socket = io('http://localhost:9000', {
extraHeaders: { Authorization: `Bearer ${yourJWT}` }
auth: { token: `Bearer ${yourJWT}` }
})

@@ -101,0 +106,0 @@

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