blixify-server 0.1.71 → 0.1.73
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 -1
- package/dist/apis/crypto.d.ts.map +1 -1
- package/dist/apis/crypto.js +17 -25
- package/package.json +1 -1
package/dist/apis/crypto.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export declare class CryptoMiddleware {
|
|
|
4
4
|
nextJs: boolean;
|
|
5
5
|
constructor(secretKey: string, forceDecryption: boolean, nextJs: boolean);
|
|
6
6
|
handleDecryption: (data: string) => any;
|
|
7
|
-
init(): (req: any, res: any) =>
|
|
7
|
+
init(): (req: any, res: any, next?: any) => any;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -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,
|
|
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"}
|
package/dist/apis/crypto.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -49,27 +40,28 @@ class CryptoMiddleware {
|
|
|
49
40
|
init() {
|
|
50
41
|
// eslint-disable-next-line
|
|
51
42
|
const wrapper = this;
|
|
52
|
-
const cryptoMiddleware = function (req, res) {
|
|
43
|
+
const cryptoMiddleware = function (req, res, next) {
|
|
53
44
|
var _a, _b;
|
|
54
|
-
|
|
45
|
+
try {
|
|
46
|
+
if (wrapper.forceDecryption && !req.body.sign) {
|
|
47
|
+
throw new Error("Missing signature for signing");
|
|
48
|
+
}
|
|
55
49
|
try {
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
if ((_a = req.body) === null || _a === void 0 ? void 0 : _a.sign)
|
|
61
|
-
req.body = wrapper.handleDecryption(req.body.sign);
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
throw new Error("Wrong Signature");
|
|
65
|
-
}
|
|
50
|
+
if ((_a = req.body) === null || _a === void 0 ? void 0 : _a.sign)
|
|
51
|
+
req.body = wrapper.handleDecryption(req.body.sign);
|
|
66
52
|
}
|
|
67
53
|
catch (err) {
|
|
68
|
-
|
|
69
|
-
return err;
|
|
70
|
-
return res.status(400).json({ error: (_b = err === null || err === void 0 ? void 0 : err.message) !== null && _b !== void 0 ? _b : "" });
|
|
54
|
+
throw new Error("Wrong Signature");
|
|
71
55
|
}
|
|
72
|
-
}
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
if (wrapper.nextJs)
|
|
59
|
+
return err;
|
|
60
|
+
return res.status(400).json({ error: (_b = err === null || err === void 0 ? void 0 : err.message) !== null && _b !== void 0 ? _b : "" });
|
|
61
|
+
}
|
|
62
|
+
if (next) {
|
|
63
|
+
next();
|
|
64
|
+
}
|
|
73
65
|
};
|
|
74
66
|
return cryptoMiddleware;
|
|
75
67
|
}
|