Importing `decode` function from jsonwebtoken causes error
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, vite
- Lĩnh vực
- web-dev
Hướng nghiên cứu
Tái hiện việc import trong thiết lập Svelte 4.0.5/Vite 4.4.2 và Chrome đã được báo cáo. Bắt đầu với node_modules/safe-buffer/index.js và lần theo stack qua jws/lib/sign-stream.js, jsonwebtoken/decode.js và jsonwebtoken/index.js; hoàn tất khi việc import decode không còn gây ra lỗi trình duyệt đã báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- JavaScript
- Star
- 18.2k
- Fork
- 1.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của auth0/node-jsonwebtoken
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
auth0/node-jsonwebtoken#1042 · 1 bình luận ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errorsCó thể đã có người làm @cobyfrombrooklyn-bot đã nhận 225 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
auth0/node-jsonwebtoken#1000 · 2 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
auth0/node-jsonwebtoken#1048 ·
-
verify() resolves a string secret by attempting createPublicKey() first, costing 4x-52x on the HS* pathCó thể đã có người làm @Hashim1999164 đã nhận 19 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 65/100
auth0/node-jsonwebtoken#1046 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
auth0/node-jsonwebtoken#1034 ·
Tất cả issue của auth0/node-jsonwebtoken
Issue tương tự
-
Bug pulumi/pulumi
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
andromarces/agent-loops#571 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Code Cleanup Dev Environment
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ProjectSidewalk/SidewalkWebpage#5699 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
automated issue report
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
lirantal/discoprint#38 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
zenstackhq/zenstack#2873 ·
Maintainer thường phản hồi trong vòng 1 ngày