Importing `decode` function from jsonwebtoken causes error
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript, vite
- 领域
- web-dev
调研方向
在报告的 Svelte 4.0.5/Vite 4.4.2 配置和 Chrome 中复现该导入。先从 node_modules/safe-buffer/index.js 开始,沿着 jws/lib/sign-stream.js、jsonwebtoken/decode.js 和 jsonwebtoken/index.js 跟踪调用栈;当导入 decode 不再抛出报告中的浏览器错误时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Description
Provide a clear and concise description of the issue, including what you expected to happen.
Importing decode function from jsonwebtoken causes error. I am unable to import the 'decode' function as normal.
I suspect that this is an issue with vite and svelte. Seems the package safe-buffer, that jsonwebtoken is dependant on, is doing something vite doesn't like saying Module externalized for browser compatibility meaning it is likely using a Node.js module that is not polyfilled in and the vite doesn't accept. That is just my guess. (See vite info on issue here. )
If you make node-jsonwebtoken work with strict mode with all it's dependencies, this may fix this probelm.
Reproduction
In my code I used the following:
import { decode, sign } from 'jsonwebtoken';
I get the following errors:
app.js:28 TypeError: Cannot read properties of undefined (reading 'from')
at node_modules/safe-buffer/index.js (jsonwebtoken.js?v=1203475a:28:17)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
at node_modules/jws/lib/sign-stream.js (jsonwebtoken.js?v=1203475a:591:19)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
at node_modules/jws/index.js (jsonwebtoken.js?v=1203475a:771:22)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
at node_modules/jsonwebtoken/decode.js (jsonwebtoken.js?v=1203475a:804:15)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
at node_modules/jsonwebtoken/index.js (jsonwebtoken.js?v=1203475a:4397:15)
at __require (chunk-34KZWS7D.js?v=08cf2519:5:50)
Looking into the chrome debugger and stopping the code before the error it seems that it has to do with the package safe-buffer that jsonwebtoken is dependant on.
Environment
Using svelte (v4.0.5) with vite (v4.4.2) on macOS and test with Chrome browser (v120).
- 主要语言
- JavaScript
- 星标
- 18.2k
- 派生
- 1.3k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
auth0/node-jsonwebtoken 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
auth0/node-jsonwebtoken#1042 · 1 条评论 ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errors可能已有人在做 @cobyfrombrooklyn-bot 于 229 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
auth0/node-jsonwebtoken#1000 · 2 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 45/100
auth0/node-jsonwebtoken#1048 ·
-
verify() resolves a string secret by attempting createPublicKey() first, costing 4x-52x on the HS* path可能已有人在做 @Hashim1999164 于 23 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 65/100
auth0/node-jsonwebtoken#1046 ·
-
难度 5/5 一周以上 新手友好度 10/100
auth0/node-jsonwebtoken#1034 ·
查看 auth0/node-jsonwebtoken 的全部 Issue
相似的 Issue
-
channels:add check:passed
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 9 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 88/100
githubnext/gh-aw-workshop#4496 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
swc-project/swc#12516 ·
维护者通常 1 天内回复
-
Opening Files on a demo drive logs you out可能已有人在做 @RChang06 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 2 天内回复
-
feature-request
难度 2/5 1-3 小时 新手友好度 72/100
omegaup/omegaup#10323 · 1 条评论 ·
维护者通常 5 天内回复