@autofleet/zehut 1.4.1 → 1.4.5

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.
package/lib/index.d.ts CHANGED
@@ -9,7 +9,7 @@ declare const _default: {
9
9
  eagerLoadUserPermissions?: boolean;
10
10
  eagerLoadUserPermissionsLegacy?: boolean;
11
11
  }) => (req: any, res: any, next: any) => Promise<void>;
12
- eagerLoadPermissionsMiddleware: (req: any, res: any, next: any) => Promise<void>;
12
+ eagerLoadPermissionsMiddleware: (req: any, res: any, next: any) => Promise<any>;
13
13
  getCurrentPayload: () => any;
14
14
  getDecodedBearer: (req: any) => any;
15
15
  };
package/lib/tracer.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getCurrentTrace = exports.enable = exports.newTrace = void 0;
7
7
  const async_hooks_1 = __importDefault(require("async_hooks"));
8
- const uuid_1 = __importDefault(require("uuid"));
8
+ const uuid_1 = require("uuid");
9
9
  const prevStates = {};
10
10
  const tracer = {
11
11
  currentTrace: null,
@@ -40,7 +40,7 @@ const hook = async_hooks_1.default.createHook({
40
40
  });
41
41
  class Trace {
42
42
  constructor(type) {
43
- this.id = uuid_1.default.v1();
43
+ this.id = uuid_1.v1();
44
44
  this.type = type;
45
45
  this.context = new Map();
46
46
  }
@@ -7,6 +7,6 @@ export declare const middlewareWithDecode: (options?: {
7
7
  eagerLoadUserPermissions?: boolean;
8
8
  eagerLoadUserPermissionsLegacy?: boolean;
9
9
  }) => (req: any, res: any, next: any) => Promise<void>;
10
- export declare const eagerLoadPermissionsMiddleware: (req: any, res: any, next: any) => Promise<void>;
10
+ export declare const eagerLoadPermissionsMiddleware: (req: any, res: any, next: any) => Promise<any>;
11
11
  export declare const getDecodedBearer: (req: any) => any;
12
12
  export default ApiUser;
package/lib/user/index.js CHANGED
@@ -20,9 +20,8 @@ exports.middleware = (options = {}) => (req, res, next) => __awaiter(void 0, voi
20
20
  const userId = req.headers['x-af-user-id'];
21
21
  const trace = tracer_1.newTrace('userPayload');
22
22
  if (!userId) {
23
- next();
24
23
  trace.context.set('userObject', {});
25
- return;
24
+ return next();
26
25
  }
27
26
  const userObject = new ApiUser_1.default(userId);
28
27
  if (options.eagerLoadUserPermissions) {
@@ -35,7 +34,7 @@ exports.middleware = (options = {}) => (req, res, next) => __awaiter(void 0, voi
35
34
  trace.context.set('userObject', userObject);
36
35
  // Added in order to support outbreak.
37
36
  req.headers['x-af-user-permissions'] = userObject;
38
- next();
37
+ return next();
39
38
  });
40
39
  exports.middlewareWithDecode = (options = {}) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
41
40
  var _a;
@@ -60,11 +59,11 @@ exports.middlewareWithDecode = (options = {}) => (req, res, next) => __awaiter(v
60
59
  const entities = req.user.permissions;
61
60
  }
62
61
  trace.context.set('userObject', {});
63
- next();
62
+ return next();
64
63
  });
65
64
  exports.eagerLoadPermissionsMiddleware = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
66
65
  yield req.user.getUserPermissions();
67
- next();
66
+ return next();
68
67
  });
69
68
  exports.getDecodedBearer = (req) => {
70
69
  if (req.headers.authorization) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/zehut",
3
- "version": "1.4.1",
3
+ "version": "1.4.5",
4
4
  "description": "manage user's identity",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -28,7 +28,8 @@
28
28
  "dependencies": {
29
29
  "@autofleet/network": "^1.1.4",
30
30
  "axios": "^0.19.2",
31
- "jsonwebtoken": "^8.5.1"
31
+ "jsonwebtoken": "^8.5.1",
32
+ "uuid": "^8.3.2"
32
33
  },
33
34
  "devDependencies": {
34
35
  "typescript": "^3.9.5"