Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using in Vite/Vue3 App Throws 'Uncaught TypeError: util.inherits is not a function' #15

Open
mwoodward-atd opened this issue Jun 13, 2023 · 5 comments

Comments

@mwoodward-atd
Copy link

When attempting to instantiate a Client object in a Vite/Vue3 app, the error Uncaught TypeError: util.inherits is not a function is thrown.

Environment

  • Node 18.16

Steps to Reproduce

  1. Create a new Vite/Vue3 app, install dependencies, and launch app
npm create vite@latest duo-vite-test -- --template vue
cd duo-vite-test
npm install
npm install @duosecurity/duo_universal
npm run dev
  1. Instantiate Client in App.vue <script setup> block
import { Client } from '@duosecurity/duo_universal'

const client = new Client({
  clientId: 'theclientid',
  clientSecret: 'theclientsecret',
  apiHost: 'theapihost',
  redirectUrl: 'http://localhost:5173',
})
  1. When the app reloads, the following error is thrown:
Uncaught TypeError: util.inherits is not a function
    at node_modules/jws/lib/data-stream.js (data-stream.js:39:6)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
    at node_modules/jws/lib/sign-stream.js (sign-stream.js:3:18)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
    at node_modules/jws/index.js (index.js:2:18)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
    at node_modules/jsonwebtoken/decode.js (decode.js:1:11)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
    at node_modules/jsonwebtoken/verify.js (verify.js:4:16)
    at __require (chunk-OL3AADLO.js?v=606a3168:9:50)
triggerError @ vue-router.mjs:3451
(anonymous) @ vue-router.mjs:3173
Promise.catch (async)
pushWithRedirect @ vue-router.mjs:3167
push @ vue-router.mjs:3099
install @ vue-router.mjs:3530
use @ runtime-core.esm-bundler.js:4381
start @ client-entry.js?t=1686682252177:120
await in start (async)
(anonymous) @ client-entry.js?t=1686682252177:165
Promise.then (async)
(anonymous) @ client-entry.js?t=1686682252177:163
Promise.then (async)
(anonymous) @ client-entry.js?t=1686682252177:139
@AaronAtDuo
Copy link
Contributor

AaronAtDuo commented Jun 22, 2023

@mwoodward-atd
Copy link
Author

Thanks @AaronAtDuo ! I'll take a look at that. Appreciate the reference.

@AaronAtDuo
Copy link
Contributor

I'm looking through those myself. I'm not a Node and/or JS dev so bear with me :)

@AaronAtDuo
Copy link
Contributor

It doesn't look like there's a great solution for this, but maybe the best one is to introduce some sort of polyfill to work around this?

@mwoodward-atd
Copy link
Author

Thanks @AaronAtDuo -- that's what we've found so far as well, so we'll dig into that angle a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants