novuhq / novu

Open-Source Notification Platform. Embeddable Notification Center, E-mail, Push and Slack Integrations.
https://novu.co
Other
35.43k stars 3.92k forks source link

πŸ› Bug Report: Node <=18 - `Unknown BridgeError: crypto is not defined` #6982

Open rifont opened 1 week ago

rifont commented 1 week ago

πŸ“œ Description

When using Node 18 that doesn't contain the global crypto WebCrypto API, Framework 2.4.0 fails to be invoked with strictAuthentication: true during the HMAC validation.

[Error]: Unknown BridgeError: crypto is not defined
    at bt.handleError (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:6281)
    at bt.handleAction (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:4889)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:3618 {
  data: {
    stack: 'ReferenceError: crypto is not defined\n' +
      '    at Or (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:1:11777)\n' +
      '    at bt.validateHmac (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:6587)\n' +
      '    at bt.handleAction (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:4619)\n' +
      '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
      '    at async /app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:3618'
  },
  statusCode: 500,
  code: 'BridgeError'
}

πŸ‘Ÿ Reproduction steps

  1. Install @novu/framework@2.4.0, serve a workflow with a Node 18 or less runtime.
  2. Attempt to sync the Workflow with strictAuthentication: true

πŸ‘ Expected behavior

Sync should be successfull

πŸ‘Ž Actual Behavior with Screenshots

Sync fails with error:

[Error]: Unknown BridgeError: crypto is not defined
    at bt.handleError (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:6281)
    at bt.handleAction (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:4889)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:3618 {
  data: {
    stack: 'ReferenceError: crypto is not defined\n' +
      '    at Or (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:1:11777)\n' +
      '    at bt.validateHmac (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:6587)\n' +
      '    at bt.handleAction (/app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:4619)\n' +
      '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
      '    at async /app/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:3618'
  },
  statusCode: 500,
  code: 'BridgeError'
}

Novu version

Novu SaaS

npm version

No response

node version

18

πŸ“ƒ Provide any additional context for the Bug.

A polyfill for global crypto should be added in Node environments with version 18 or less.

πŸ‘€ Have you spent some time to check if this bug has been raised before?

🏒 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

linear[bot] commented 1 week ago

NV-4742 πŸ› Bug Report: `Unknown BridgeError: crypto is not defined`