Node-jsonwebtoken: Updating to 6.x.x throws errors in joi when building with webpack.

Created on 28 Apr 2016  路  5Comments  路  Source: auth0/node-jsonwebtoken

Running NODE_ENV=production node node_modules/webpack/bin/webpack.js -p --config=webpack.prod.config.js through webpack throws these errors in joi.

ERROR in ./~/joi/lib/string.js
Module not found: Error: Cannot resolve module 'net' in /node_modules/joi/lib
 @ ./~/joi/lib/string.js 5:12-26

ERROR in ./~/isemail/lib/index.js
Module not found: Error: Cannot resolve module 'dns' in /node_modules/isemail/lib
 @ ./~/isemail/lib/index.js 5:12-26

ERROR in main.entry.js from UglifyJs
Unexpected token: name (Alternatives) [./~/joi/lib/any.js:8,0]

ERROR in main.entry.js from UglifyJs
Unexpected token: name (Alternatives) [./~/joi/lib/any.js:8,0]

Adding:

  node: {
    net: 'empty',
    tls: 'empty',
    dns: 'empty'
  }

to the webpack config kills off the first two errors, but not the second two and fails to build our client js.

Most helpful comment

If you need just to _decode tokens_ in the client-side please use: https://github.com/auth0/jwt-decode

If you need to validate tokens in the client-side you can try: https://github.com/kjur/jsrsasign

This library is not meant to be used in the browser, it was designed to be used in node.js.

All 5 comments

why would you bundle this library with webpack/uglify/etc?

This library is not supposed to be used on browsers

We make auth token requests client side through an api, so we need to parse the token purely on the client..

If you need just to _decode tokens_ in the client-side please use: https://github.com/auth0/jwt-decode

If you need to validate tokens in the client-side you can try: https://github.com/kjur/jsrsasign

This library is not meant to be used in the browser, it was designed to be used in node.js.

@jfromaniello I'm using it server side but I also need it browser side to implement a mock for development purpose.. But I know browser side cryptography is a bad idea..

PS: Related to https://github.com/hapijs/joi/issues/706 and https://github.com/hapijs/joi/issues/528

Is there a fundamental reason that this package isn't intended to be used on the client side, or simply that the current implementation details make it incompatible?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ehartford picture ehartford  路  3Comments

cope picture cope  路  4Comments

salali picture salali  路  5Comments

samholmes picture samholmes  路  5Comments

Sir-hennihau picture Sir-hennihau  路  4Comments