From d340c81fd5c44502c4146ea172f8411d65682db2 Mon Sep 17 00:00:00 2001 From: Root-Core Date: Tue, 18 Apr 2017 23:31:38 +0200 Subject: [PATCH] Added option to store encoded jwt, default "encoded_token" --- lib/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index bfcb715..54b33b7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -61,6 +61,9 @@ function noQsMethod(options) { return onError({message: 'invalid token datatype'}, 'invalid_token'); } + // Store encoded JWT + socket[options.encodedPropertyName] = token; + var onJwtVerificationReady = function(err, decoded) { if (err) { @@ -105,7 +108,7 @@ function noQsMethod(options) { } function authorize(options, onConnection) { - options = xtend({ decodedPropertyName: 'decoded_token' }, options); + options = xtend({ decodedPropertyName: 'decoded_token', encodedPropertyName: 'encoded_token' }, options); if (!options.handshake) { return noQsMethod(options); @@ -167,6 +170,9 @@ function authorize(options, onConnection) { return auth.fail(error, data, accept); } + // Store encoded JWT + socket[options.encodedPropertyName] = token; + var onJwtVerificationReady = function(err, decoded) { if (err) {