plac-micro-common 1.2.48 → 1.2.50

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,2 +1,4 @@
1
+ export * from "./internal_service.guard";
1
2
  export * from "./jwt_auth.guard";
3
+ export * from "./org_context.guard";
2
4
  export * from "./permission.guard";
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./internal_service.guard"), exports);
17
18
  __exportStar(require("./jwt_auth.guard"), exports);
19
+ __exportStar(require("./org_context.guard"), exports);
18
20
  __exportStar(require("./permission.guard"), exports);
@@ -0,0 +1,4 @@
1
+ import { CanActivate, ExecutionContext } from "@nestjs/common";
2
+ export declare class InternalServiceGuard implements CanActivate {
3
+ canActivate(context: ExecutionContext): boolean;
4
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.InternalServiceGuard = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ let InternalServiceGuard = class InternalServiceGuard {
12
+ canActivate(context) {
13
+ const request = context.switchToHttp().getRequest();
14
+ const internalSecret = request.headers["x-internal-secret"];
15
+ if (!internalSecret) {
16
+ throw new common_1.ForbiddenException("Missing internal service secret");
17
+ }
18
+ if (internalSecret !== process.env.INTERNAL_SERVICE_SECRET) {
19
+ throw new common_1.ForbiddenException("Invalid internal service secret");
20
+ }
21
+ return true;
22
+ }
23
+ };
24
+ exports.InternalServiceGuard = InternalServiceGuard;
25
+ exports.InternalServiceGuard = InternalServiceGuard = __decorate([
26
+ (0, common_1.Injectable)()
27
+ ], InternalServiceGuard);
@@ -0,0 +1,4 @@
1
+ import { CanActivate, ExecutionContext } from "@nestjs/common";
2
+ export declare class OrgStaffContextGuard implements CanActivate {
3
+ canActivate(context: ExecutionContext): boolean;
4
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.OrgStaffContextGuard = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ let OrgStaffContextGuard = class OrgStaffContextGuard {
12
+ canActivate(context) {
13
+ const req = context.switchToHttp().getRequest();
14
+ const user = req.current_user;
15
+ if (!user) {
16
+ throw new common_1.ForbiddenException("User context missing");
17
+ }
18
+ if (!user.org_id || !user.org_staff_id) {
19
+ throw new common_1.ForbiddenException("Organization and staff context is required to access or operate this module.");
20
+ }
21
+ return true;
22
+ }
23
+ };
24
+ exports.OrgStaffContextGuard = OrgStaffContextGuard;
25
+ exports.OrgStaffContextGuard = OrgStaffContextGuard = __decorate([
26
+ (0, common_1.Injectable)()
27
+ ], OrgStaffContextGuard);
@@ -24,5 +24,5 @@ __decorate([
24
24
  __metadata("design:type", Number)
25
25
  ], TermEntity.prototype, "term_year", void 0);
26
26
  exports.TermEntity = TermEntity = __decorate([
27
- (0, typeorm_1.Entity)({ schema: "core", name: "riders" })
27
+ (0, typeorm_1.Entity)({ schema: "core", name: "terms" })
28
28
  ], TermEntity);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plac-micro-common",
3
- "version": "1.2.48",
3
+ "version": "1.2.50",
4
4
  "types": "dist/index.d.ts",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {