@atomiqlabs/lp-lib 16.0.9 → 16.0.10
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/info/InfoHandler.js +11 -9
- package/package.json +1 -1
- package/src/info/InfoHandler.ts +13 -10
package/dist/info/InfoHandler.js
CHANGED
|
@@ -18,20 +18,19 @@ class InfoHandler {
|
|
|
18
18
|
* @param restServer
|
|
19
19
|
*/
|
|
20
20
|
startRestServer(restServer) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
!HEX_REGEX.test(req.body.nonce)) {
|
|
21
|
+
const infoHandler = async (req, res) => {
|
|
22
|
+
const reqParams = { ...req.body, ...req.query };
|
|
23
|
+
if (reqParams.nonce == null ||
|
|
24
|
+
typeof (reqParams.nonce) !== "string" ||
|
|
25
|
+
reqParams.nonce.length > 64 ||
|
|
26
|
+
!HEX_REGEX.test(reqParams.nonce)) {
|
|
28
27
|
res.status(400).json({
|
|
29
28
|
msg: "Invalid request body (nonce)"
|
|
30
29
|
});
|
|
31
30
|
return;
|
|
32
31
|
}
|
|
33
32
|
const env = {
|
|
34
|
-
nonce:
|
|
33
|
+
nonce: reqParams.nonce,
|
|
35
34
|
services: {}
|
|
36
35
|
};
|
|
37
36
|
for (let swapHandler of this.swapHandlers) {
|
|
@@ -52,7 +51,10 @@ class InfoHandler {
|
|
|
52
51
|
chains
|
|
53
52
|
};
|
|
54
53
|
res.status(200).json(response);
|
|
55
|
-
}
|
|
54
|
+
};
|
|
55
|
+
restServer.use(this.path + "/info", express.json());
|
|
56
|
+
restServer.post(this.path + "/info", infoHandler);
|
|
57
|
+
restServer.get(this.path + "/info", infoHandler);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
exports.InfoHandler = InfoHandler;
|
package/package.json
CHANGED
package/src/info/InfoHandler.ts
CHANGED
|
@@ -44,15 +44,14 @@ export class InfoHandler {
|
|
|
44
44
|
*/
|
|
45
45
|
startRestServer(restServer: Express) {
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
req.body == null ||
|
|
47
|
+
const infoHandler = async (req, res) => {
|
|
48
|
+
const reqParams = {...req.body, ...req.query};
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
if (
|
|
51
|
+
reqParams.nonce == null ||
|
|
52
|
+
typeof(reqParams.nonce) !== "string" ||
|
|
53
|
+
reqParams.nonce.length>64 ||
|
|
54
|
+
!HEX_REGEX.test(reqParams.nonce)
|
|
56
55
|
) {
|
|
57
56
|
res.status(400).json({
|
|
58
57
|
msg: "Invalid request body (nonce)"
|
|
@@ -61,7 +60,7 @@ export class InfoHandler {
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
const env: InfoHandlerResponseEnvelope = {
|
|
64
|
-
nonce:
|
|
63
|
+
nonce: reqParams.nonce,
|
|
65
64
|
services: {}
|
|
66
65
|
};
|
|
67
66
|
|
|
@@ -92,7 +91,11 @@ export class InfoHandler {
|
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
res.status(200).json(response);
|
|
95
|
-
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
restServer.use(this.path+"/info", express.json());
|
|
97
|
+
restServer.post(this.path+"/info", infoHandler);
|
|
98
|
+
restServer.get(this.path+"/info", infoHandler);
|
|
96
99
|
|
|
97
100
|
}
|
|
98
101
|
|