Skip to content

feat(jwt): allow custom typ in JwtHeader and createJwt - #168

Open
mehmetkr-31 wants to merge 1 commit into
agentcommercekit:mainfrom
mehmetkr-31:feat/jwt-allow-custom-typ
Open

feat(jwt): allow custom typ in JwtHeader and createJwt#168
mehmetkr-31 wants to merge 1 commit into
agentcommercekit:mainfrom
mehmetkr-31:feat/jwt-allow-custom-typ

Conversation

@mehmetkr-31

@mehmetkr-31 mehmetkr-31 commented Aug 16, 2026

Copy link
Copy Markdown

Summary

This PR updates JwtHeader and createJwt in @agentcommercekit/jwt to allow custom typ header values (e.g. "kya+JWT"), resolving the TODO in demos/skyfire-kya/src/kya-token.ts.

Changes

  • Updated JwtHeader interface from typ: "JWT" to typ?: string.
  • Updated dual validation schemas (valibot.ts and zod.ts) to validate optional string typ.
  • Removed // @ts-expect-error - TODO: fix this in demos/skyfire-kya/src/kya-token.ts.
  • Completed doc comment for ES256K-R in jwt-algorithm.ts.
  • Added unit tests in create-jwt.test.ts.
  • Added changeset for @agentcommercekit/jwt (patch).

Testing

  • pnpm --filter @agentcommercekit/jwt test (25 passed)
  • pnpm demo:skyfire-kya (runs cleanly end-to-end)
  • pnpm run check (all 29 tasks passed)

AI Disclosure

This PR was developed with the assistance of Antigravity AI coding assistant.

Summary by CodeRabbit

  • New Features
    • Added support for optional custom JWT typ headers, enabling specialized JWT profiles.
    • JWT creation now supports custom typ and alg header values.
  • Bug Fixes
    • Updated JWT validation to accept valid custom typ values while preserving algorithm checks.
  • Documentation
    • Clarified that the unsupported ES256K-R recovery-signature algorithm is not available.

Allow callers to specify custom JWT 'typ' headers (such as 'kya+JWT' for
Skyfire KYA tokens) in JwtHeader, createJwt, and schema validators.
Resolves the TODO in the skyfire-kya demo.

AI disclosure: Implemented with the assistance of Antigravity AI coding assistant.
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0db3d271-9c35-4a71-9187-842418fbb66f

📥 Commits

Reviewing files that changed from the base of the PR and between 0b8fdaa and ca326df.

📒 Files selected for processing (7)
  • .changeset/allow-custom-jwt-typ.md
  • demos/skyfire-kya/src/kya-token.ts
  • packages/jwt/src/create-jwt.test.ts
  • packages/jwt/src/create-jwt.ts
  • packages/jwt/src/jwt-algorithm.ts
  • packages/jwt/src/schemas/valibot.ts
  • packages/jwt/src/schemas/zod.ts
💤 Files with no reviewable changes (1)
  • demos/skyfire-kya/src/kya-token.ts

Included review availability: Your plan includes up to 2 reviews per rolling hour; 1 remains after this review.


Walkthrough

The JWT package now accepts optional custom typ header values. JWT creation forwards custom typ and alg values, with schema, test, demo, documentation, and changeset updates.

Changes

Custom JWT headers

Layer / File(s) Summary
Header contract and schema validation
packages/jwt/src/create-jwt.ts, packages/jwt/src/schemas/*
JwtHeader.typ and the Valibot and Zod schemas now accept an optional string instead of requiring "JWT".
JWT creation and supporting updates
packages/jwt/src/create-jwt.ts, packages/jwt/src/create-jwt.test.ts, demos/skyfire-kya/src/kya-token.ts, packages/jwt/src/jwt-algorithm.ts, .changeset/allow-custom-jwt-typ.md
createJwt forwards custom typ and alg headers to baseCreateJWT. Tests cover typ: "kya+JWT" and alg: "ES256". Supporting documentation and changeset text were updated.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ca326

This localized change allows custom JWT type headers and removes the demo workaround; reported tests and checks pass, and no actionable merge-blocking risk remains.

Suggested reviewers: venables

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: allowing custom JWT typ values in JwtHeader and createJwt.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant