Merge branch 'Master' into 'Pipedrive-OAuth2-support'

This commit is contained in:
ricardo
2020-07-23 16:51:05 -04:00
parent c1b4c570fd
commit b187a8fd7d
271 changed files with 17019 additions and 2796 deletions

View File

@@ -246,7 +246,13 @@ export class HubspotTrigger implements INodeType {
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const credentials = this.getCredentials('hubspotDeveloperApi');
const credentials = this.getCredentials('hubspotDeveloperApi') as IDataObject;
if (credentials === undefined) {
throw new Error('No credentials found!');
}
const req = this.getRequestObject();
const bodyData = req.body;
const headerData = this.getHeaderData();
@@ -254,12 +260,18 @@ export class HubspotTrigger implements INodeType {
if (headerData['x-hubspot-signature'] === undefined) {
return {};
}
const hash = `${credentials!.clientSecret}${JSON.stringify(bodyData)}`;
const signature = createHash('sha256').update(hash).digest('hex');
//@ts-ignore
if (signature !== headerData['x-hubspot-signature']) {
return {};
// check signare if client secret is defined
if (credentials.clientSecret !== '') {
const hash = `${credentials!.clientSecret}${JSON.stringify(bodyData)}`;
const signature = createHash('sha256').update(hash).digest('hex');
//@ts-ignore
if (signature !== headerData['x-hubspot-signature']) {
return {};
}
}
for (let i = 0; i < bodyData.length; i++) {
const subscriptionType = bodyData[i].subscriptionType as string;
if (subscriptionType.includes('contact')) {