@autofleet/zehut 1.4.5 → 1.4.6-beta1
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 +1 -1
- package/lib/tracer.js +2 -2
- package/lib/user/index.d.ts +1 -1
- package/lib/user/index.js +5 -4
- package/package.json +2 -1
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<
|
|
12
|
+
eagerLoadPermissionsMiddleware: (req: any, res: any, next: any) => Promise<void>;
|
|
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 = require("uuid");
|
|
8
|
+
const uuid_1 = __importDefault(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.v1();
|
|
43
|
+
this.id = uuid_1.default.v1();
|
|
44
44
|
this.type = type;
|
|
45
45
|
this.context = new Map();
|
|
46
46
|
}
|
package/lib/user/index.d.ts
CHANGED
|
@@ -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<
|
|
10
|
+
export declare const eagerLoadPermissionsMiddleware: (req: any, res: any, next: any) => Promise<void>;
|
|
11
11
|
export declare const getDecodedBearer: (req: any) => any;
|
|
12
12
|
export default ApiUser;
|
package/lib/user/index.js
CHANGED
|
@@ -21,7 +21,8 @@ exports.middleware = (options = {}) => (req, res, next) => __awaiter(void 0, voi
|
|
|
21
21
|
const trace = tracer_1.newTrace('userPayload');
|
|
22
22
|
if (!userId) {
|
|
23
23
|
trace.context.set('userObject', {});
|
|
24
|
-
|
|
24
|
+
next();
|
|
25
|
+
return;
|
|
25
26
|
}
|
|
26
27
|
const userObject = new ApiUser_1.default(userId);
|
|
27
28
|
if (options.eagerLoadUserPermissions) {
|
|
@@ -34,7 +35,7 @@ exports.middleware = (options = {}) => (req, res, next) => __awaiter(void 0, voi
|
|
|
34
35
|
trace.context.set('userObject', userObject);
|
|
35
36
|
// Added in order to support outbreak.
|
|
36
37
|
req.headers['x-af-user-permissions'] = userObject;
|
|
37
|
-
|
|
38
|
+
next();
|
|
38
39
|
});
|
|
39
40
|
exports.middlewareWithDecode = (options = {}) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
41
|
var _a;
|
|
@@ -59,11 +60,11 @@ exports.middlewareWithDecode = (options = {}) => (req, res, next) => __awaiter(v
|
|
|
59
60
|
const entities = req.user.permissions;
|
|
60
61
|
}
|
|
61
62
|
trace.context.set('userObject', {});
|
|
62
|
-
|
|
63
|
+
next();
|
|
63
64
|
});
|
|
64
65
|
exports.eagerLoadPermissionsMiddleware = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
66
|
yield req.user.getUserPermissions();
|
|
66
|
-
|
|
67
|
+
next();
|
|
67
68
|
});
|
|
68
69
|
exports.getDecodedBearer = (req) => {
|
|
69
70
|
if (req.headers.authorization) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/zehut",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6-beta1",
|
|
4
4
|
"description": "manage user's identity",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rm -rf lib && tsc",
|
|
9
|
+
"pepublish": "npm run build",
|
|
9
10
|
"coverage": "jest --coverage --forceExit --runInBand",
|
|
10
11
|
"test": "jest --forceExit --runInBand",
|
|
11
12
|
"test-auto": "jest --watch --runInBand",
|