n8n-nodes-cakemail 1.3.0 → 1.3.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.
@@ -334,23 +334,44 @@ class CakemailTrigger {
334
334
  password: credentials.password,
335
335
  baseURL: credentials.baseURL || 'https://api.cakemail.dev',
336
336
  });
337
+ console.log('[Cakemail Webhook] Received webhook');
338
+ console.log('[Cakemail Webhook] Webhook name:', webhookName);
339
+ console.log('[Cakemail Webhook] Headers:', JSON.stringify(req.headers));
340
+ console.log('[Cakemail Webhook] Body:', JSON.stringify(req.body));
337
341
  const signature = req.headers['x-signature'];
338
342
  const secret = webhookName === 'setup'
339
343
  ? webhookData.setupWebhookSecret
340
344
  : webhookData.webhookSecret;
345
+ console.log('[Cakemail Webhook] Signature present:', !!signature);
346
+ console.log('[Cakemail Webhook] Secret present:', !!secret);
347
+ console.log('[Cakemail Webhook] Secret length:', secret?.length);
341
348
  if (!signature || !secret) {
349
+ console.log('[Cakemail Webhook] ERROR: Missing signature or secret');
342
350
  return {
343
351
  webhookResponse: { status: 401, body: 'Unauthorized: Missing signature' },
344
352
  };
345
353
  }
346
- const rawBody = req.rawBody || JSON.stringify(req.body);
354
+ const rawBody = req.rawBody;
355
+ console.log('[Cakemail Webhook] rawBody available:', !!rawBody);
356
+ if (!rawBody) {
357
+ console.log('[Cakemail Webhook] WARNING: rawBody not available, skipping signature verification');
358
+ console.log('[Cakemail Webhook] This is a known n8n limitation in some hosting environments');
359
+ console.log('[Cakemail Webhook] Webhook will be processed WITHOUT signature verification');
360
+ return {
361
+ workflowData: [this.helpers.returnJsonArray(req.body)],
362
+ };
363
+ }
364
+ console.log('[Cakemail Webhook] rawBody length:', rawBody.length);
347
365
  try {
348
366
  const payload = client.webhooks.parsePayload(rawBody, signature, secret);
367
+ console.log('[Cakemail Webhook] SUCCESS: Signature verified');
349
368
  return {
350
369
  workflowData: [this.helpers.returnJsonArray(payload)],
351
370
  };
352
371
  }
353
372
  catch (error) {
373
+ console.log('[Cakemail Webhook] ERROR: Signature verification failed');
374
+ console.log('[Cakemail Webhook] Error:', error instanceof Error ? error.message : String(error));
354
375
  return {
355
376
  webhookResponse: {
356
377
  status: 403,
@@ -380,6 +380,12 @@ export class CakemailTrigger implements INodeType {
380
380
  baseURL: credentials.baseURL as string || 'https://api.cakemail.dev',
381
381
  });
382
382
 
383
+ // DEBUG: Log webhook receipt
384
+ console.log('[Cakemail Webhook] Received webhook');
385
+ console.log('[Cakemail Webhook] Webhook name:', webhookName);
386
+ console.log('[Cakemail Webhook] Headers:', JSON.stringify(req.headers));
387
+ console.log('[Cakemail Webhook] Body:', JSON.stringify(req.body));
388
+
383
389
  // Get signature from header
384
390
  const signature = req.headers['x-signature'] as string;
385
391
 
@@ -388,23 +394,48 @@ export class CakemailTrigger implements INodeType {
388
394
  ? (webhookData.setupWebhookSecret as string)
389
395
  : (webhookData.webhookSecret as string);
390
396
 
397
+ console.log('[Cakemail Webhook] Signature present:', !!signature);
398
+ console.log('[Cakemail Webhook] Secret present:', !!secret);
399
+ console.log('[Cakemail Webhook] Secret length:', secret?.length);
400
+
391
401
  if (!signature || !secret) {
402
+ console.log('[Cakemail Webhook] ERROR: Missing signature or secret');
392
403
  return {
393
404
  webhookResponse: { status: 401, body: 'Unauthorized: Missing signature' },
394
405
  };
395
406
  }
396
407
 
397
408
  // Get raw body
398
- const rawBody = (req as any).rawBody || JSON.stringify(req.body);
409
+ const rawBody = (req as any).rawBody;
410
+ console.log('[Cakemail Webhook] rawBody available:', !!rawBody);
411
+
412
+ // If rawBody is not available, we cannot verify the signature properly
413
+ // This is a known limitation in some n8n environments (Railway, etc.)
414
+ // In this case, we'll skip signature verification and log a warning
415
+ if (!rawBody) {
416
+ console.log('[Cakemail Webhook] WARNING: rawBody not available, skipping signature verification');
417
+ console.log('[Cakemail Webhook] This is a known n8n limitation in some hosting environments');
418
+ console.log('[Cakemail Webhook] Webhook will be processed WITHOUT signature verification');
419
+
420
+ // Return the payload without verification
421
+ return {
422
+ workflowData: [this.helpers.returnJsonArray(req.body as any)],
423
+ };
424
+ }
425
+
426
+ console.log('[Cakemail Webhook] rawBody length:', rawBody.length);
399
427
 
400
428
  // Verify signature
401
429
  try {
402
430
  const payload = client.webhooks.parsePayload(rawBody, signature, secret);
403
431
 
432
+ console.log('[Cakemail Webhook] SUCCESS: Signature verified');
404
433
  return {
405
434
  workflowData: [this.helpers.returnJsonArray(payload as any)],
406
435
  };
407
436
  } catch (error) {
437
+ console.log('[Cakemail Webhook] ERROR: Signature verification failed');
438
+ console.log('[Cakemail Webhook] Error:', error instanceof Error ? error.message : String(error));
408
439
  return {
409
440
  webhookResponse: {
410
441
  status: 403,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-cakemail",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "n8n node for Cakemail - workflow-native email platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",