Doesn't work with esbuild/Vite.js
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript, typescript, vite
- Domain
- build-system
Research direction
Start by reproducing the jwt.sign failure with Vite, then inspect node_modules/jws/lib/data-stream.js and sign-stream.js from the stack trace, including their use of util.inherits. Confirm the relevant behavior against the jsonwebtoken 8.5.1 dependency chain; done means signing works in the reported Vite setup and the regression is covered by an appropriate test.
Written by the indexing model from the issue text.
Description
Please do not report security vulnerabilities here. The Responsible Disclosure Program details the procedure for disclosing security issues.
Thank you in advance for helping us to improve this library! Please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community or Auth0 Support. Finally, to avoid duplicates, please search existing Issues before submitting one here.
By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct.
Description
Provide a clear and concise description of the issue, including what you expected to happen.
I'm trying to convert a project from using Webpack to Vite.js (which uses esbuild internally for development builds), and I'm getting the following error/stack trace:
inherits_browser.js:5 Uncaught TypeError: Object prototype may only be an Object or null: undefined
at Function.create (<anonymous>)
at Object.inherits (inherits_browser.js:5)
at node_modules/jws/lib/data-stream.js (data-stream.js:39)
at __require2 (chunk-IHTDASF6.js?v=d5f5f338:17)
at node_modules/jws/lib/sign-stream.js (sign-stream.js:3)
at __require2 (chunk-IHTDASF6.js?v=d5f5f338:17)
at node_modules/jws/index.js (index.js:2)
at __require2 (chunk-IHTDASF6.js?v=d5f5f338:17)
at node_modules/jsonwebtoken/decode.js (decode.js:1)
at __require2 (chunk-IHTDASF6.js?v=d5f5f338:17)
I expected the library to work just as well on Vite.js as it did when using Webpack to compile.
I'm raising this issue here because I think I found a way to fix the problem by removing this package's dependency on util.inherits, the use of which is now discouraged.
Reproduction
Detail the steps taken to reproduce this error, what was expected, and whether this issue can be reproduced consistently or if it is intermittent.
Where applicable, please include:
- Code sample to reproduce the issue
- Log files (redact/remove sensitive information)
- Application settings (redact/remove sensitive information)
- Screenshots
Relevant code samples:
tldr; I'm calling the jwt.sign function.
/* I've omitted/changed much of the code here for security and relevance */
import jwt from 'jsonwebtoken';
export type userType = 'a' | 'b';
export type JwtPayload = {
type: userType;
ACLS: { [key: string]: CoreACLs[] };
aud: [string];
exp: number;
expBuffer: number;
iat: number;
jti: string;
user_id?: string;
username?: string;
};
export type Auth = JwtPayload & {
jwt: string;
loading?: boolean;
error?: string;
};
export const mockAuth = (props: Partial<Auth> = {}): Auth => {
const now = Math.floor(Date.now() / 1000);
const auth: Omit<Auth, 'jwt'> = {
ACLS: {
/* ... */
},
aud: ['us'],
exp: now + 14400,
expBuffer: now + 28800,
iat: now - 3600,
jti: uuid(),
type: 'a',
user_id: uuid(),
username: '[email protected]',
...props,
};
return {
jwt: jwt.sign(auth, 'fakePrivateKey'),
...auth,
};
};
Environment
Please provide the following:
- Version of this library used: 3.2.2
- Version of the platform or framework used, if applicable:
- Other relevant versions (language, server software, OS, browser):
- macOS Big Sur version 11.4
- Google Chrome v92.0.4515.131
- Node.js v16.6.1
- npm v7.20.3
- Other modules/plugins/libraries that might be involved:
vitev2.4.4jsonwebtokenv8.5.1
- Dominant language
- JavaScript
- Stars
- 721
- Forks
- 141
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from auth0/node-jws
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Remove unnecessary safe-buffer dependency (use Node.js built-in Buffer API)May be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
OWASP/CheatSheetSeries#3018 ·
Maintainers usually reply within 1 day
-
Radix number block generates NaN after switching a negative or decimal number to binary, octal or hexPossibly taken @matthewalberto claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
mit-cml/appinventor-sources#4246 · 1 comment ·
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 83/100
GoogleChrome/modern-web-guidance-src#3675 · 2 comments ·
Maintainers usually reply within 1 day