@autofleet/zehut 1.7.3-beta → 1.7.3-beta2

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
@@ -1,9 +1,9 @@
1
- import User, { middleware, eagerLoadPermissionsMiddleware, middlewareWithDecode, getDecodedBearer } from './user';
1
+ import User, { middleware, eagerLoadPermissionsMiddleware, middlewareWithDecode, getDecodedBearer, appMiddleware } from './user';
2
2
  import { checkFleetPermission, checkBusinessModelPermission, checkDemandSourcePermission, isUserExist, getUser } from './check-permission';
3
3
  import { UnauthorizedAccessError } from './errors';
4
4
  import { getRefreshTokenSecret, getTokenSecret } from './secret-getter';
5
5
  declare const getCurrentPayload: () => any;
6
- export { User, middleware, middlewareWithDecode, eagerLoadPermissionsMiddleware, getCurrentPayload, getDecodedBearer, checkFleetPermission, checkBusinessModelPermission, checkDemandSourcePermission, isUserExist, getUser, getRefreshTokenSecret, getTokenSecret, UnauthorizedAccessError, };
6
+ export { User, middleware, middlewareWithDecode, eagerLoadPermissionsMiddleware, getCurrentPayload, getDecodedBearer, checkFleetPermission, checkBusinessModelPermission, checkDemandSourcePermission, isUserExist, getUser, getRefreshTokenSecret, getTokenSecret, UnauthorizedAccessError, appMiddleware, };
7
7
  declare const _default: {
8
8
  User: typeof User;
9
9
  middleware: (options?: {
@@ -29,5 +29,10 @@ declare const _default: {
29
29
  isUserExist: () => boolean;
30
30
  getUser: () => any;
31
31
  UnauthorizedAccessError: typeof UnauthorizedAccessError;
32
+ appMiddleware: (options: {
33
+ appId: string;
34
+ clientSecret: string;
35
+ appSecret: string;
36
+ }) => (req: any, res: any, next: any) => Promise<void>;
32
37
  };
33
38
  export default _default;
package/lib/index.js CHANGED
@@ -19,13 +19,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.UnauthorizedAccessError = exports.getTokenSecret = exports.getRefreshTokenSecret = exports.getUser = exports.isUserExist = exports.checkDemandSourcePermission = exports.checkBusinessModelPermission = exports.checkFleetPermission = exports.getDecodedBearer = exports.getCurrentPayload = exports.eagerLoadPermissionsMiddleware = exports.middlewareWithDecode = exports.middleware = exports.User = void 0;
22
+ exports.appMiddleware = exports.UnauthorizedAccessError = exports.getTokenSecret = exports.getRefreshTokenSecret = exports.getUser = exports.isUserExist = exports.checkDemandSourcePermission = exports.checkBusinessModelPermission = exports.checkFleetPermission = exports.getDecodedBearer = exports.getCurrentPayload = exports.eagerLoadPermissionsMiddleware = exports.middlewareWithDecode = exports.middleware = exports.User = void 0;
23
23
  const user_1 = __importStar(require("./user"));
24
24
  exports.User = user_1.default;
25
25
  Object.defineProperty(exports, "middleware", { enumerable: true, get: function () { return user_1.middleware; } });
26
26
  Object.defineProperty(exports, "eagerLoadPermissionsMiddleware", { enumerable: true, get: function () { return user_1.eagerLoadPermissionsMiddleware; } });
27
27
  Object.defineProperty(exports, "middlewareWithDecode", { enumerable: true, get: function () { return user_1.middlewareWithDecode; } });
28
28
  Object.defineProperty(exports, "getDecodedBearer", { enumerable: true, get: function () { return user_1.getDecodedBearer; } });
29
+ Object.defineProperty(exports, "appMiddleware", { enumerable: true, get: function () { return user_1.appMiddleware; } });
29
30
  const tracer_1 = require("./tracer");
30
31
  const check_permission_1 = require("./check-permission");
31
32
  Object.defineProperty(exports, "checkFleetPermission", { enumerable: true, get: function () { return check_permission_1.checkFleetPermission; } });
@@ -54,4 +55,5 @@ exports.default = {
54
55
  isUserExist: check_permission_1.isUserExist,
55
56
  getUser: check_permission_1.getUser,
56
57
  UnauthorizedAccessError: errors_1.UnauthorizedAccessError,
58
+ appMiddleware: user_1.appMiddleware,
57
59
  };
@@ -96,14 +96,17 @@ class ApiUser {
96
96
  }
97
97
  getUserAppPermissions(appId) {
98
98
  return __awaiter(this, void 0, void 0, function* () {
99
+ console.log('getUserAppPermissions1', appId, this.id);
99
100
  if (!this.id || appId) {
100
101
  return;
101
102
  }
102
103
  const currentAppPermission = this.appPermission[appId];
104
+ console.log('getUserAppPermissions2', currentAppPermission);
103
105
  if (currentAppPermission) {
104
106
  return currentAppPermission;
105
107
  }
106
108
  const cachedResult = userCache.get(`${this.id}:${appId}`);
109
+ console.log('getUserAppPermissions3', cachedResult);
107
110
  if (cachedResult) {
108
111
  this.appPermission[appId] = cachedResult;
109
112
  return cachedResult;
@@ -111,6 +114,7 @@ class ApiUser {
111
114
  const { data } = yield services_1.AutofleetApiNetwork.post(`/api/v1/apps/${appId}/get-user-payload`, {
112
115
  userId: this.id,
113
116
  });
117
+ console.log('getUserAppPermissions4', data);
114
118
  userCache.set(this.id, data);
115
119
  this.appPermission[appId] = data;
116
120
  return this.appPermission[appId];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/zehut",
3
- "version": "1.7.3-beta",
3
+ "version": "1.7.3-beta2",
4
4
  "description": "manage user's identity",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",