@konplit-services/common 1.0.117 → 1.0.119

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.
@@ -113,4 +113,5 @@ export declare const PERMISSIONS: {
113
113
  CAN_CREATE_VALUE_BANKACCOUNT: string;
114
114
  CAN_VIEW_VALUE_BANKACCOUNT: string;
115
115
  CAN_VIEW_LOGS: string;
116
+ CAN_MANAGE_KYC: string;
116
117
  };
@@ -117,4 +117,5 @@ exports.PERMISSIONS = {
117
117
  CAN_CREATE_VALUE_BANKACCOUNT: "CAN_CREATE_VALUE_BANKACCOUNT",
118
118
  CAN_VIEW_VALUE_BANKACCOUNT: "CAN_VIEW_VALUE_BANKACCOUNT",
119
119
  CAN_VIEW_LOGS: "CAN_VIEW_LOGS",
120
+ CAN_MANAGE_KYC: "CAN_MANAGE_KYC",
120
121
  };
@@ -4,3 +4,4 @@ export * from "./error-handler";
4
4
  export * from "./permission";
5
5
  export * from "./require-auth";
6
6
  export * from "./validate-request";
7
+ export * from "./validate-fields";
@@ -20,3 +20,4 @@ __exportStar(require("./error-handler"), exports);
20
20
  __exportStar(require("./permission"), exports);
21
21
  __exportStar(require("./require-auth"), exports);
22
22
  __exportStar(require("./validate-request"), exports);
23
+ __exportStar(require("./validate-fields"), exports);
@@ -0,0 +1,2 @@
1
+ import { NextFunction, Request, Response } from "express";
2
+ export declare const validAllowedFields: (allowFields: string[]) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.validAllowedFields = void 0;
13
+ const error_codes_1 = require("../helper/errorCodes/error-codes");
14
+ const errors_1 = require("../errors");
15
+ const validAllowedFields = (allowFields) => {
16
+ return (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
17
+ try {
18
+ const submittedFields = Object.keys(req.body);
19
+ const extraFields = submittedFields.filter((field) => !allowFields.includes(field));
20
+ if (extraFields.length > 0) {
21
+ throw new errors_1.BadRequestError(`Extra fields submitted: ${extraFields.join(", ")}`, error_codes_1.error_codes.INVALID_INPUT);
22
+ }
23
+ return next();
24
+ }
25
+ catch (error) {
26
+ console.log();
27
+ throw error;
28
+ }
29
+ });
30
+ };
31
+ exports.validAllowedFields = validAllowedFields;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.117",
3
+ "version": "1.0.119",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",