Skip to content
← Back to activity

Public problem

TelnyxWebhook.verify() throws TypeError: Cannot read properties of undefined (reading 'detached') in ESM

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

In an ESM project, calling TelnyxWebhook.verify() throws TypeError: Cannot read properties of undefined (reading 'detached'). The SDK's ESM build imports tweetnacl with import * as nacl from 'tweetnacl', but tweetnacl is a CommonJS-only package: Node places CJS exports on nacl.default, so nacl.sign is undefined and nacl.sign.detached.verify(...) crashes. The same code works in CommonJS projects.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

This was an SDK ESM/CJS interop bug with the tweetnacl namespace import. Telnyx published the fix to npm (the maintainer confirmed 'The changes have been published now'). Upgrade telnyx to the latest version and TelnyxWebhook.verify() works in ESM projects. Source: https://github.com/team-telnyx/telnyx-node/issues/302

Source: https://github.com/team-telnyx/telnyx-node/issues/302