@kne/fastify-webhook 0.1.3-alpha.0 → 0.1.3-alpha.2

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.
@@ -63,6 +63,9 @@ module.exports = fp(async (fastify, options) => {
63
63
  fastify.post(
64
64
  `${options.prefix}/invoke/:type`,
65
65
  {
66
+ config: {
67
+ rawBody: true
68
+ },
66
69
  schema: {
67
70
  summary: '调用webhook post请求',
68
71
  params: {
@@ -76,13 +79,14 @@ module.exports = fp(async (fastify, options) => {
76
79
  },
77
80
  async request => {
78
81
  const { type } = request.params;
82
+
79
83
  return services.invoke(
80
84
  Object.assign(
81
85
  {},
82
86
  { type },
83
87
  {
84
88
  body: request.body,
85
- rawBody: request[options.rawBodyField || 'rowBody'],
89
+ rawBody: request[options.rawBodyField || 'rawBody'],
86
90
  headers: request.headers,
87
91
  query: request.query
88
92
  }
@@ -112,8 +116,6 @@ module.exports = fp(async (fastify, options) => {
112
116
  {},
113
117
  { type },
114
118
  {
115
- body: request.body,
116
- rawBody: request[options.rawBodyField || 'rowBody'],
117
119
  headers: request.headers,
118
120
  query: request.query
119
121
  }
@@ -104,11 +104,14 @@ module.exports = fp(async (fastify, options) => {
104
104
  .createHash('md5')
105
105
  .update(`${webhook.name}|${webhook.expire ? webhook.expire.getTime() : 0}`)
106
106
  .digest('hex');
107
- if (webhook.shouldEncryptVerify && generateSignature(md5, rawBody) === signature) {
107
+
108
+ const shouldEncryptVerify = webhook.inputLocation === 'body' && webhook.shouldEncryptVerify;
109
+
110
+ if (shouldEncryptVerify && generateSignature(md5, rawBody) === signature) {
108
111
  currentWebhook = webhook;
109
112
  break;
110
113
  }
111
- if (!webhook.shouldEncryptVerify) {
114
+ if (!shouldEncryptVerify) {
112
115
  if (md5 === signature) {
113
116
  currentWebhook = webhook;
114
117
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-webhook",
3
- "version": "0.1.3-alpha.0",
3
+ "version": "0.1.3-alpha.2",
4
4
  "description": "实现一个webhook功能.",
5
5
  "main": "index.js",
6
6
  "scripts": {