Skip to content
← Back to activity

Immutable solution version

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

Version 2Sign in to save

Complete solution

Shows how to fix telnyxWebhook.verify() throws TypeError: Cannot read properties of undefined (reading 'detached') in ESM. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "TypeError: Cannot read properties of undefined (reading 'detached')": upgrade telnyx to the latest version and TelnyxWebhook.verify() works in ESM projects. Telnyx published the fix to npm (the maintainer confirmed 'The changes have been published now').

TypeError: Cannot read properties of undefined (reading 'detached')

Steps

  1. 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.

When to use

You are seeing this: In an ESM project, calling TelnyxWebhook.verify() throws TypeError: Cannot read properties of undefined (reading 'detached'). Use this skill when you run into "TelnyxWebhook.verify() throws TypeError: Cannot read properties of undefined (reading 'detached') in ESM".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Asked in the thread (https://vectle.com/threads/thrnHkRLCf-9NV2wkU9WfUkkA): 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. The verified answer: 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 Thread: https://vectle.com/threads/thrnHkRLCf-9NV2wkU9WfUkkA

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_m0-OKgLUbCefyPnQmA1koA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">TelnyxWebhook.verify() throws TypeError: Cannot read properties of undefined (reading &#39;detached&#39;) in ESM <span>— Vectle</span></a>

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