Doesn't work with esbuild/Vite.js
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- javascript, typescript, vite
- 领域
- build-system
调研方向
首先使用 Vite 重现 jwt.sign 失败,然后根据堆栈跟踪检查 node_modules/jws/lib/data-stream.js 和 sign-stream.js,包括它们对 util.inherits 的使用。根据 jsonwebtoken 8.5.1 的依赖链确认相关行为;当签名在报告中的 Vite 设置中正常工作,并且回归问题由适当的测试覆盖时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- JavaScript
- 星标
- 721
- 派生
- 141
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
auth0/node-jws 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 45/100
-
难度 5/5 一周以上 新手友好度 25/100
-
Remove unnecessary safe-buffer dependency (use Node.js built-in Buffer API)可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 50/100
-
难度 4/5 3-5 天 新手友好度 25/100
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 63/100
anothaDev/luci-theme-vantage#143 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
kingcharleslzy-ai/dsh-purge#282 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
-
a-corriger bug
难度 2/5 1-3 小时 新手友好度 86/100
christian-raj/S-Aloha#340 ·
-
area:image documentation good first issue
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复