blixify-server 0.1.73 → 0.1.75

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,8 +1,7 @@
1
1
  export declare class CryptoMiddleware {
2
2
  secretKey: string;
3
3
  forceDecryption: boolean;
4
- nextJs: boolean;
5
- constructor(secretKey: string, forceDecryption: boolean, nextJs: boolean);
4
+ constructor(secretKey: string, forceDecryption: boolean);
6
5
  handleDecryption: (data: string) => any;
7
6
  init(): (req: any, res: any, next?: any) => any;
8
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/apis/crypto.ts"],"names":[],"mappings":"AAEA,qBAAa,gBAAgB;IAC3B,SAAS,SAAM;IACf,eAAe,UAAS;IACxB,MAAM,UAAS;gBAEH,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO;IAMxE,gBAAgB,SAAU,MAAM,SAiB9B;IAEF,IAAI,UAGsC,GAAG,OAAO,GAAG,SAAS,GAAG;CAuBpE"}
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/apis/crypto.ts"],"names":[],"mappings":"AACA,qBAAa,gBAAgB;IAC3B,SAAS,SAAM;IACf,eAAe,UAAS;gBAEZ,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO;IAKvD,gBAAgB,SAAU,MAAM,SAoB9B;IAEF,IAAI,UAGsC,GAAG,OAAO,GAAG,SAAS,GAAG;CAqBpE"}
@@ -1,32 +1,28 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.CryptoMiddleware = void 0;
7
4
  const CryptoJS = require("crypto-js");
8
- const moment_timezone_1 = __importDefault(require("moment-timezone"));
9
5
  class CryptoMiddleware {
10
- constructor(secretKey, forceDecryption, nextJs) {
6
+ constructor(secretKey, forceDecryption) {
11
7
  this.secretKey = "";
12
8
  this.forceDecryption = false;
13
- this.nextJs = false;
14
9
  this.handleDecryption = (data) => {
15
- // Decrypt the data
10
+ //INFO : Decrypt the data
16
11
  const bytes = CryptoJS.AES.decrypt(data, this.secretKey);
17
12
  const decrypted = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
18
13
  if (decrypted) {
19
14
  if (decrypted.baseSignDate) {
20
- const tolerance = moment_timezone_1.default.duration(1, "minute");
21
- const startWindow = (0, moment_timezone_1.default)(decrypted.baseSignDate).utc();
22
- const endWindow = startWindow.clone().add(tolerance);
23
- const currentUTCDate = (0, moment_timezone_1.default)().utc();
24
- if (currentUTCDate.isBetween(startWindow, endWindow)) {
25
- delete decrypted["baseSignDate"];
26
- return decrypted;
27
- }
28
- else
29
- throw "Error";
15
+ //TODO : Add date timing
16
+ delete decrypted["baseSignDate"];
17
+ return decrypted;
18
+ // const tolerance = moment.duration(1, "minute");
19
+ // const startWindow = moment(decrypted.baseSignDate).utc();
20
+ // const endWindow = startWindow.clone().add(tolerance);
21
+ // const currentUTCDate = moment().utc();
22
+ // if (currentUTCDate.isBetween(startWindow, endWindow)) {
23
+ // delete decrypted["baseSignDate"];
24
+ // return decrypted;
25
+ // } else throw "Error";
30
26
  }
31
27
  else
32
28
  throw "Error";
@@ -35,7 +31,6 @@ class CryptoMiddleware {
35
31
  };
36
32
  this.secretKey = secretKey;
37
33
  this.forceDecryption = forceDecryption;
38
- this.nextJs = nextJs;
39
34
  }
40
35
  init() {
41
36
  // eslint-disable-next-line
@@ -53,15 +48,14 @@ class CryptoMiddleware {
53
48
  catch (err) {
54
49
  throw new Error("Wrong Signature");
55
50
  }
51
+ if (next)
52
+ next();
56
53
  }
57
54
  catch (err) {
58
- if (wrapper.nextJs)
59
- return err;
55
+ if (next)
56
+ next(err);
60
57
  return res.status(400).json({ error: (_b = err === null || err === void 0 ? void 0 : err.message) !== null && _b !== void 0 ? _b : "" });
61
58
  }
62
- if (next) {
63
- next();
64
- }
65
59
  };
66
60
  return cryptoMiddleware;
67
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blixify-server",
3
- "version": "0.1.73",
3
+ "version": "0.1.75",
4
4
  "license": "MIT",
5
5
  "main": "dist/apis/index.js",
6
6
  "private": false,