Remove redundant validateClaims from @moq/token#1196
Conversation
The ClaimsSchema already enforces the put/get requirement via z.refine, making validateClaims a duplicate check. The lowercase claimsSchema alias was only for backward compatibility that's no longer needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughRemoved the exported 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fix incorrect CLI syntax in README and docs (--key was shown as top-level flag, generate used non-existent --key instead of --out). Rewrite JS doc with actual API. Fix claims field names (pub/sub -> put/get). Add hard-coded cross-language test fixtures so Rust tests verify JS-generated tokens and JS tests verify Rust-generated tokens. Bump @moq/token to 0.2.0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
js/token/src/interop.test.ts (1)
10-20: Consider extracting duplicated test fixtures to module scope.The
RUST_HS256_KEYandRUST_HS256_TOKENconstants are duplicated between the twodescribeblocks. Extracting them to module-level constants would reduce duplication.♻️ Suggested refactor
import { describe, expect, test } from "bun:test"; import { generate } from "./generate.ts"; import { load, loadPublic, sign, verify } from "./key.ts"; +// Shared fixtures for Rust-generated keys/tokens +const RUST_HS256_KEY = JSON.stringify({ + alg: "HS256", + key_ops: ["verify", "sign"], + kty: "oct", + k: "jvS2B_SKkvhtObaiKg9n2vq_Iqdus-nVCVVYBWf0BQA", + kid: "d55b1f13e6bda281", +}); + +const RUST_HS256_TOKEN = + "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6ImQ1NWIxZjEzZTZiZGEyODEifQ.eyJyb290IjoiZGVtbyIsInB1dCI6WyJhbGljZSJdLCJnZXQiOlsiYm9iIl19.eyOkZtTtj_MDkLF4Eu11cygb7B_6DyP-6e0TtwVE4UE"; + // Tests that the JS `@moq/token` package can load keys generated by the Rust // moq-token crate and verify tokens signed by Rust, and vice versa. describe("Rust-generated fixtures", () => { - // cargo run -p moq-token-cli -- generate --out /tmp/rust-hs256.jwk - const RUST_HS256_KEY = JSON.stringify({ - alg: "HS256", - ... - }); - const RUST_HS256_TOKEN = "..."; // ... use module-level constants }); describe("wrong key rejects token", () => { - const RUST_HS256_KEY = JSON.stringify({...}); - const RUST_HS256_TOKEN = "..."; // ... use module-level constants });Also applies to: 100-110
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@js/token/src/interop.test.ts` around lines 10 - 20, The duplicated test fixtures RUST_HS256_KEY and RUST_HS256_TOKEN should be pulled out of the describe blocks into module-level constants so both test suites reuse the same values; locate the two definitions of RUST_HS256_KEY and RUST_HS256_TOKEN in interop.test.ts, move a single copy to the top of the file (outside any describe/it), and remove the duplicated local definitions in each describe so tests reference the shared constants.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@doc/js/`@moq/token.md:
- Around line 98-102: The Markdown table in doc/js/@moq/token.md has unescaped
pipe characters in the type column (rows like `put` and `get`) causing extra
columns; fix by ensuring the type cell content is treated as a single cell—wrap
the type values in code spans or escape internal pipes (e.g., use `\|` or
|) so the `put`, `get`, `cluster`, `exp`, and `iat` rows have exactly the
same number of columns as the header and the table alignment remains consistent.
In `@doc/rs/crate/moq-token.md`:
- Around line 161-165: The Markdown table's type cells (rows for `put`, `get`,
etc.) contain unescaped pipe characters (e.g., "string | string[]?") which break
the table; update those cells by wrapping the entire type text in inline code
ticks or escaping the pipes (e.g., `string | string[]?` or string \| string\[]?)
for the `put`, `get`, and any other affected rows so the table renders with the
correct number of columns.
---
Nitpick comments:
In `@js/token/src/interop.test.ts`:
- Around line 10-20: The duplicated test fixtures RUST_HS256_KEY and
RUST_HS256_TOKEN should be pulled out of the describe blocks into module-level
constants so both test suites reuse the same values; locate the two definitions
of RUST_HS256_KEY and RUST_HS256_TOKEN in interop.test.ts, move a single copy to
the top of the file (outside any describe/it), and remove the duplicated local
definitions in each describe so tests reference the shared constants.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fa19e068-cc41-43a4-81ec-205472f209de
📒 Files selected for processing (6)
doc/js/@moq/token.mddoc/rs/crate/moq-token.mdjs/token/package.jsonjs/token/src/interop.test.tsrs/moq-token-cli/README.mdrs/moq-token/src/key.rs
✅ Files skipped from review due to trivial changes (2)
- js/token/package.json
- rs/moq-token-cli/README.md
Escape pipe characters in type column to prevent extra column parsing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
validateClaims()— thez.refineinClaimsSchemaalready enforces the sameput || getcheck, making it a duplicateclaimsSchemalowercase re-export (backward compat alias no longer needed)Test plan
bun test)🤖 Generated with Claude Code