exodus-framework 2.0.801 → 2.0.803

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.
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../src/middlewares/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,cAAc,EAAE,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAMtC,qBAAa,wBAAyB,SAAQ,cAAc;IAC1D,YAAY,CAAC,QAAQ,GAAE,OAAc,GAAG,cAAc;CAUvD;AAED,qBAAa,8BAA+B,SAAQ,gBAAgB;IAClE,YAAY,QAAe,eAAe,OAAO,cAAc,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,mBAgGxF;CACH"}
1
+ {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../src/middlewares/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,cAAc,EAAE,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAMtC,qBAAa,wBAAyB,SAAQ,cAAc;IAC1D,YAAY,CAAC,QAAQ,GAAE,OAAc,GAAG,cAAc;CAUvD;AAED,qBAAa,8BAA+B,SAAQ,gBAAgB;IAClE,YAAY,QAAe,eAAe,OAAO,cAAc,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,mBAiGxF;CACH"}
@@ -28,7 +28,7 @@ class AuthenticationMiddleware extends _controller.default {
28
28
  exports.AuthenticationMiddleware = AuthenticationMiddleware;
29
29
  class SocketAuthenticationMiddleware extends _controller.SocketController {
30
30
  decryptToken = async (req, res, next) => {
31
- const token = req.headers.authorization;
31
+ const token = req.headers.authorization ? req.headers.authorization.replace('Bearer ', '') : '';
32
32
  const tenantId = req.headers['X-Exodus-Tenant-ID'];
33
33
  const applicationId = req.headers['X-Exodus-Application-ID'];
34
34
  let isApplication = false;
@@ -36,14 +36,15 @@ class SocketAuthenticationMiddleware extends _controller.SocketController {
36
36
  try {
37
37
  if (!token) {
38
38
  const error = new Error('Token ausente');
39
- error.code = 401;
40
- return next(error);
39
+ res.statusCode = 401;
40
+ return res.writeContinue();
41
+ // return next(error);
41
42
  }
42
43
  const data = await _security.default.getService().verifySignature(token, _security.default.singleton().getServicePublicKey());
43
44
  if (!data) {
44
45
  const error = new Error('Token inválido');
45
- error.code = 401;
46
- return next(error);
46
+ res.statusCode = 401;
47
+ return res.writeContinue();
47
48
  }
48
49
  req.auth = {
49
50
  account: data.payload,
@@ -70,23 +71,23 @@ class SocketAuthenticationMiddleware extends _controller.SocketController {
70
71
  });
71
72
  if (!application) {
72
73
  const error = new Error('Token de aplicação inválido');
73
- error.code = 401;
74
- return next(error);
74
+ res.statusCode = 401;
75
+ return res.writeContinue();
75
76
  } else if (!application.active) {
76
77
  const error = new Error('Token de aplicação desativado');
77
- error.code = 403;
78
- return next(error);
78
+ res.statusCode = 403;
79
+ return res.writeContinue();
79
80
  } else if ((0, _dateFns.isBefore)(application.expiresAt, new Date())) {
80
81
  const error = new Error('Token de aplicação expirado');
81
- error.code = 403;
82
- return next(error);
82
+ res.statusCode = 403;
83
+ return res.writeContinue();
83
84
  } else {
84
85
  //valido
85
86
  const data = await _security.default.singleton().verifySignature(applicationId, _security.default.singleton().getServicePublicKey());
86
87
  if (!data) {
87
88
  const error = new Error('Token de aplicação sem autênticidade');
88
- error.code = 401;
89
- return next(error);
89
+ res.statusCode = 401;
90
+ return res.writeContinue();
90
91
  }
91
92
  requestor.database = data.payload.database;
92
93
  requestor.environmentId = data.payload.envUuid;
@@ -109,7 +110,8 @@ class SocketAuthenticationMiddleware extends _controller.SocketController {
109
110
  req.isApplication = isApplication;
110
111
  next();
111
112
  } catch (error) {
112
- next(error);
113
+ res.statusCode = 500;
114
+ return res.writeContinue();
113
115
  }
114
116
  };
115
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodus-framework",
3
- "version": "2.0.801",
3
+ "version": "2.0.803",
4
4
  "description": "Exodus Framework",
5
5
  "author": "jhownpaixao",
6
6
  "license": "ISC",