@vulkano/core 1.15.0 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/libs/Jwt.js +35 -8
  2. package/package.json +1 -1
package/libs/Jwt.js CHANGED
@@ -74,13 +74,18 @@ module.exports = {
74
74
  ? req.cookies[cookieName]
75
75
  : null;
76
76
 
77
+ // Get Token via Cookie RAW
78
+ const cookieTokenRaw = req.headers.cookie && this.getCookieRAW(req, cookieName)
79
+ ? this.getCookieRAW(req, cookieName)
80
+ : null;
81
+
77
82
  // Get Token via Query Parameter
78
83
  const queryToken = req.query && req.query[queryParameter]
79
84
  ? req.query[queryParameter]
80
85
  : null;
81
86
 
82
87
  // Current Token
83
- const token = headerToken || cookieToken || queryToken || null;
88
+ const token = headerToken || cookieToken || cookieTokenRaw || queryToken || null;
84
89
 
85
90
  // Decode Token
86
91
  const hasData = this.decode(token);
@@ -207,20 +212,42 @@ module.exports = {
207
212
  } = socket.handshake.auth || {};
208
213
 
209
214
  if (token === null || typeof token === 'undefined' || !token) {
210
- return false;
215
+ return this.getToken(socket.handshake);
211
216
  }
212
217
 
218
+ // Decode Token
213
219
  const data = this.decode(token);
214
220
 
221
+ // Return only if token is valid
222
+ return data ? data : null;
223
+
224
+ },
225
+
226
+ /**
227
+ * Read cookie RAW
228
+ *
229
+ * @param {Socket} socket
230
+ * @returns String
231
+ */
232
+ getCookieRAW(req, cookieName) {
233
+
215
234
  const {
216
- _id
217
- } = data || {};
235
+ cookie
236
+ } = req.headers || {};
218
237
 
219
- if (!_id) {
220
- return false;
221
- }
238
+ const name = `${cookieName}=`;
239
+ const cDecoded = decodeURIComponent(cookie || '');
240
+ const cArr = cDecoded.split(';');
222
241
 
223
- return data;
242
+ let res;
243
+
244
+ cArr.forEach((val) => {
245
+ if (String(val).trim().indexOf(name) === 0) {
246
+ res = String(val).trim().substring(name.length);
247
+ }
248
+ });
249
+
250
+ return res;
224
251
 
225
252
  }
226
253
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulkano/core",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "A MVC framework using Express 4",
5
5
  "license": "MIT",
6
6
  "author": "Vulkano Team",