2
1
mirror of https://github.com/Thream/socketio-jwt.git synced 2024-07-21 09:38:31 +02:00

Workaround for node 4

This commit is contained in:
Fabian Arndt 2019-10-14 04:13:25 +02:00
parent 8f2b55a7aa
commit e66148fbb2
4 changed files with 11 additions and 0 deletions

View File

@ -7,6 +7,7 @@ function noQsMethod (options) {
options = xtend(defaults, options); options = xtend(defaults, options);
return (socket) => { return (socket) => {
'use strict'; // Node 4.x workaround
const server = this.server || socket.server; const server = this.server || socket.server;
if (!server.$emit) { if (!server.$emit) {
@ -144,7 +145,9 @@ function authorize (options, onConnection) {
const auth = xtend(defaults, options); const auth = xtend(defaults, options);
return (socket, accept) => { return (socket, accept) => {
'use strict'; // Node 4.x workaround
let token, error; let token, error;
const handshake = socket.handshake; const handshake = socket.handshake;
const req = socket.request || socket; const req = socket.request || socket;
const authorization_header = (req.headers || {}).authorization; const authorization_header = (req.headers || {}).authorization;
@ -219,6 +222,8 @@ function authorize (options, onConnection) {
} }
function getSecret (request, secret, token, callback) { function getSecret (request, secret, token, callback) {
'use strict'; // Node 4.x workaround
if (typeof secret === 'function') { if (typeof secret === 'function') {
if (!token) { if (!token) {
return callback({ code: 'invalid_token', message: 'jwt must be provided' }); return callback({ code: 'invalid_token', message: 'jwt must be provided' });

View File

@ -1,3 +1,5 @@
'use strict'; // Node 4.x workaround
const express = require('express'); const express = require('express');
const http = require('http'); const http = require('http');

View File

@ -1,3 +1,5 @@
'use strict'; // Node 4.x workaround
const express = require('express'); const express = require('express');
const http = require('http'); const http = require('http');

View File

@ -1,3 +1,5 @@
'use strict'; // Node 4.x workaround
const express = require('express'); const express = require('express');
const http = require('http'); const http = require('http');