@pinelab/vendure-plugin-sendcloud 1.2.3 → 1.2.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.2.4 (2024-06-13)
2
+
3
+ - Check if incoming request is a Buffer or already parsed by other middleware
4
+
1
5
  # 1.2.3 (2024-06-13)
2
6
 
3
7
  - Log request body, instead of util.inspect
@@ -25,12 +25,19 @@ let SendcloudController = class SendcloudController {
25
25
  }
26
26
  async webhook(req, signature, channelToken) {
27
27
  let body;
28
- try {
29
- body = JSON.parse(req.body.toString());
28
+ if (!Buffer.isBuffer(req.body)) {
29
+ core_1.Logger.warn(`Incoming webhook body is not a Buffer. This means the body was already parsed by some other middleware. This might cause problems when validating the incoming webhook signature.`, constants_1.loggerCtx);
30
+ body = req.body;
30
31
  }
31
- catch (e) {
32
- core_1.Logger.error(`Error parsing incoming webhook body: ${e?.message ?? e}`, constants_1.loggerCtx, req.body.toString());
33
- return;
32
+ else {
33
+ // Else we try and parse the body
34
+ try {
35
+ body = JSON.parse(req.body.toString());
36
+ }
37
+ catch (e) {
38
+ core_1.Logger.error(`Error parsing incoming webhook body: ${e?.message ?? e}`, constants_1.loggerCtx, req.body.toString());
39
+ return;
40
+ }
34
41
  }
35
42
  const rawBody = req.rawBody;
36
43
  const ctx = await this.sendcloudService.createContext(channelToken);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinelab/vendure-plugin-sendcloud",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Vendure plugin for syncing orders with SendCloud",
5
5
  "author": "Martijn van de Brug <martijn@pinelab.studio>",
6
6
  "homepage": "https://pinelab-plugins.com/",
@@ -23,5 +23,5 @@
23
23
  "start": "yarn ts-node test/dev-server.ts",
24
24
  "lint": "echo 'No linting configured'"
25
25
  },
26
- "gitHead": "1a364f2738b44895e9f3eec133a66f4ac0df7678"
26
+ "gitHead": "55ad85256aabbf322470155a78c517111e8c754c"
27
27
  }