@konplit-services/common 1.12.0 → 1.14.0

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.
@@ -270,6 +270,7 @@ declare class AppConfigs {
270
270
  getBVNEnvironment(): string;
271
271
  getSettlementInterval(): string;
272
272
  getCardExpiryInterval(): string;
273
+ getRequeryTransactionInterval(): string;
273
274
  getNodeMAilDetails(): {
274
275
  host: string;
275
276
  port: number;
@@ -203,6 +203,12 @@ class AppConfigs {
203
203
  }
204
204
  return this.env.CARD_EXPIRY_INTERVAL;
205
205
  }
206
+ getRequeryTransactionInterval() {
207
+ if (!this.env.REQUERY_TRANSACTION) {
208
+ throw new Error("REQUERY_TRANSACTION is required");
209
+ }
210
+ return this.env.REQUERY_TRANSACTION;
211
+ }
206
212
  getNodeMAilDetails() {
207
213
  if (!this.env.MAIL_HOST) {
208
214
  throw new Error("MAIL_HOST is required");
@@ -7,4 +7,5 @@ declare global {
7
7
  }
8
8
  }
9
9
  }
10
+ export declare const expiredTime: (expires: number) => number;
10
11
  export declare const TwoFactorSessionValidation: (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -9,13 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TwoFactorSessionValidation = void 0;
12
+ exports.TwoFactorSessionValidation = exports.expiredTime = void 0;
13
13
  const Jwt_1 = require("../services/Jwt");
14
14
  const notAuthorized_1 = require("../errors/notAuthorized");
15
15
  const error_codes_1 = require("../helper/errorCodes/error-codes");
16
16
  const app_configs_1 = require("../app.configs");
17
17
  const helper_1 = require("../helper");
18
18
  const redis_1 = require("../redis");
19
+ const expiredTime = (expires) => {
20
+ const expiryTime = expires - Math.floor(Date.now() / 1000);
21
+ return expiryTime;
22
+ };
23
+ exports.expiredTime = expiredTime;
19
24
  const TwoFactorSessionValidation = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
20
25
  if (!req.headers["k-2fa-session"]) {
21
26
  throw new notAuthorized_1.NotAuthorizedError("k-2fa-session token not provided", error_codes_1.error_codes.INVALID_AUTHORIZATION);
@@ -29,7 +34,7 @@ const TwoFactorSessionValidation = (req, res, next) => __awaiter(void 0, void 0,
29
34
  if (isValidToken) {
30
35
  throw new notAuthorized_1.NotAuthorizedError(helper_1.lang.not_authorized, error_codes_1.error_codes.INVALID_AUTHORIZATION);
31
36
  }
32
- yield redis_1.redisWrapper.isTokenRevoked((0, redis_1.setsetRevokedToken)(payload.userId, token));
37
+ yield redis_1.redisWrapper.revokeToken((0, redis_1.setsetRevokedToken)(payload.userId, token), (0, exports.expiredTime)(payload.exp));
33
38
  req.twoFaData = payload;
34
39
  }
35
40
  return next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",