From 3f980a5c71b0edffca209be4bddaa22b1f0afec6 Mon Sep 17 00:00:00 2001 From: Fabian Arndt Date: Tue, 8 Oct 2019 18:56:18 +0200 Subject: [PATCH] Fixed regressions of b0cd246 and 3128fdf 3128fdf: - Secret can be a string or function - Compatibility with older node versions b0cd246: - Fixed dependencies --- lib/index.js | 6 +++--- package.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index 947dc61..cfa8f58 100644 --- a/lib/index.js +++ b/lib/index.js @@ -111,9 +111,9 @@ function noQsMethod(options) { function authorize(options, onConnection) { options = xtend({ decodedPropertyName: 'decoded_token', encodedPropertyName: 'encoded_token' }, options); - - if (typeof options.secret !== 'string') { - throw new Error(`Provided secret "${options.secret}" is invalid, must be of type string.`) + + if (typeof options.secret !== 'string' && typeof options.secret !== 'function') { + throw new Error('Provided secret "' + options.secret + '" is invalid, must be of type string or function.') } if (!options.handshake) { diff --git a/package.json b/package.json index 5770270..a2072df 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ }, "license": "MIT", "dependencies": { + "jsonwebtoken": "^8.3.0", + "xtend": "~2.1.2" }, "devDependencies": { "@types/socket.io": "~1.4.29", @@ -31,11 +33,9 @@ "mocha": "~3.2.0", "request": "~2.81.0", "serve-static": "^1.12.1", - "jsonwebtoken": "^8.3.0", - "xtend": "~2.1.2", "server-destroy": "~1.0.1", "should": "~11.2.1", "socket.io": "^1.7.3", "socket.io-client": "^1.7.3" } -} \ No newline at end of file +}