fix(AWS SNS Trigger Node): add missing jsonParse import (#4463)

* fix(AwsSnsTrigger): add missing jsonParse import

* add clear typings for req.rawBody and getHeaderData()
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-10-28 11:24:11 +02:00
committed by GitHub
parent d9a41ea9d7
commit e6ec134cf3
16 changed files with 17 additions and 30 deletions

View File

@@ -6,7 +6,7 @@ import {
INodeType,
INodeTypeDescription,
IWebhookResponseData,
NodeApiError,
jsonParse,
NodeOperationError,
} from 'n8n-workflow';
@@ -177,8 +177,9 @@ export class AwsSnsTrigger implements INodeType {
const req = this.getRequestObject();
const topic = this.getNodeParameter('topic') as string;
// @ts-ignore
const body = jsonParse(req.rawBody.toString());
const body = jsonParse<{ Type: string; TopicArn: string; Token: string }>(
req.rawBody.toString(),
);
if (body.Type === 'SubscriptionConfirmation' && body.TopicArn === topic) {
const { Token } = body;

View File

@@ -587,7 +587,6 @@ export class CiscoWebexTrigger implements INodeType {
//@ts-ignore
const computedSignature = createHmac('sha1', webhookData.secret)
//@ts-ignore
.update(req.rawBody)
.digest('hex');
if (headers['x-spark-signature'] !== computedSignature) {

View File

@@ -268,7 +268,6 @@ export class FacebookTrigger implements INodeType {
// validate signature if app secret is set
if (credentials.appSecret !== '') {
const computedSignature = createHmac('sha1', credentials.appSecret as string)
//@ts-ignore
.update(req.rawBody)
.digest('hex');
if (headerData['x-hub-signature'] !== `sha1=${computedSignature}`) {

View File

@@ -189,7 +189,6 @@ export class HelpScoutTrigger implements INodeType {
}
const computedSignature = createHmac('sha1', webhookData.secret as string)
//@ts-ignore
.update(req.rawBody)
.digest('base64');
if (headerData['x-helpscout-signature'] !== computedSignature) {

View File

@@ -157,7 +157,6 @@ export class JotFormTrigger implements INodeType {
},
};
//@ts-ignore
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const req = this.getRequestObject();
const formId = this.getNodeParameter('form') as string;

View File

@@ -119,7 +119,6 @@ export class MailjetTrigger implements INodeType {
},
};
//@ts-ignore
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const req = this.getRequestObject();
return {

View File

@@ -412,7 +412,6 @@ export class ShopifyTrigger implements INodeType {
headerData['x-shopify-shop-domain'] !== undefined &&
headerData['x-shopify-api-version'] !== undefined
) {
// @ts-ignore
const computedSignature = createHmac('sha256', secret).update(req.rawBody).digest('base64');
if (headerData['x-shopify-hmac-sha256'] !== computedSignature) {

View File

@@ -781,7 +781,6 @@ export class Wait implements INodeType {
if (options.rawBody) {
response.binary = {
data: {
// @ts-ignore
data: req.rawBody.toString(BINARY_ENCODING),
mimeType,
},

View File

@@ -593,7 +593,6 @@ export class Webhook implements INodeType {
if (options.rawBody) {
response.binary = {
data: {
// @ts-ignore
data: req.rawBody.toString(BINARY_ENCODING),
mimeType,
},

View File

@@ -182,7 +182,6 @@ export class WiseTrigger implements INodeType {
const publicKey =
credentials.environment === 'test' ? testPublicKey : (livePublicKey as string);
//@ts-ignore
const sig = createVerify('RSA-SHA1').update(req.rawBody);
const verified = sig.verify(publicKey, signature, 'base64');

View File

@@ -156,21 +156,17 @@ export class WooCommerceTrigger implements INodeType {
},
};
//@ts-ignore
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const req = this.getRequestObject();
const headerData = this.getHeaderData();
const webhookData = this.getWorkflowStaticData('node');
//@ts-ignore
if (headerData['x-wc-webhook-id'] === undefined) {
return {};
}
const computedSignature = createHmac('sha256', webhookData.secret as string)
//@ts-ignore
.update(req.rawBody)
.digest('base64');
//@ts-ignore
if (headerData['x-wc-webhook-signature'] !== computedSignature) {
// Signature is not valid so ignore call
return {};