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.
- package/dist/apis/crypto.d.ts +1 -2
- package/dist/apis/crypto.d.ts.map +1 -1
- package/dist/apis/crypto.js +17 -23
- package/package.json +1 -1
package/dist/apis/crypto.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export declare class CryptoMiddleware {
|
|
2
2
|
secretKey: string;
|
|
3
3
|
forceDecryption: boolean;
|
|
4
|
-
|
|
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":"
|
|
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"}
|
package/dist/apis/crypto.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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 (
|
|
59
|
-
|
|
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
|
}
|