Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

JWT encoder signs payloads that aren't JSON objects, and the decoder then rejects them

未关闭
#253 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@MugdhoAI 已经在做这个了。

开始于 2026年10月22日。

评估

这个 Issue 还没有评估数据。

描述

bug good first issue hacktoberfest

In the JWT decoder's Encode tab, a payload of [1, 2, 3], "hello", 42 or null is signed without complaint. Paste the token into Decode, as the panel suggests, and you get "Payload is not a JSON object". A JWT's claims set has to be a JSON object (RFC 7519), and decodeJwt already checks that (lib/jwt-utils.ts, lines 89 to 91).

generate (app/(tools)/jwt-decoder/components/EncoderTab.tsx, lines 37 to 51) only checks that the payload is valid JSON (line 39) before it signs it (line 51).

What to do

  • After the JSON check, refuse anything that isn't a plain object (arrays, strings, numbers, booleans and null) with an error like "The payload must be a JSON object", shown where the JSON error shows today.
  • Objects sign exactly as before.

Where to look

  • app/(tools)/jwt-decoder/components/EncoderTab.tsx: generate (lines 37 to 51)
  • lib/jwt-utils.ts: the same check in decodeJwt (lines 89 to 91)
  • app/(tools)/jwt-decoder/components/DecodedCard.test.tsx: a component test for this tool

Acceptance criteria

  • [1, 2, 3], "hello", 42, true and null show the error and produce no token
  • An object payload still produces a token that Decode accepts
  • Tests for these cases
  • npm run lint, npm run test and npm run build pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #253 in the description.

主要语言
TypeScript
星标
1
派生
9
平均合并
9 小时 9 分钟
30 天内合并 PR
118

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codercops/toolbelt 的其他 Issue

查看 codercops/toolbelt 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。