Skip to content

Commit f5a3a99

Browse files
madster456N2D4
andauthored
[Docs][Content][UI] - JWT docs and JWT component (#905)
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> Adds JWT docs and JWT viewer component to docs <img width="1182" height="668" alt="image" src="https://github.com/user-attachments/assets/f4196dd9-e159-420e-9d78-a3928983f126" /> <!-- RECURSEML_SUMMARY:START --> ## High-level PR Summary This PR adds comprehensive JWT (JSON Web Token) documentation and an interactive JWT viewer component to the Stack Auth documentation. The main additions are a new documentation page explaining JWT concepts, structure, and usage within Stack Auth, along with a React component that allows users to decode and inspect JWT tokens. The JWT viewer can automatically load the current user's session token if they are signed in, or accept manually pasted tokens. The documentation provides examples of both client-side and server-side JWT usage, security considerations, troubleshooting guidance, and best practices. The PR also includes necessary updates to metadata files and component exports to integrate the new content into the documentation platform. ⏱️ Estimated Review Time: 15-30 minutes <details> <summary>💡 Review Order Suggestion</summary> | Order | File Path | |-------|-----------| | 1 | `docs/templates/concepts/jwt.mdx` | | 2 | `docs/src/components/mdx/jwt-viewer.tsx` | | 3 | `docs/docs-platform.yml` | | 4 | `docs/src/components/mdx/index.ts` | | 5 | `docs/src/mdx-components.tsx` | | 6 | `docs/templates/meta.json` | | 7 | `docs/templates-python/meta.json` | </details> <!-- RECURSEML_SUMMARY:END --> <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Adds a new JWT concepts page and an interactive `JWTViewer` component, integrating it into MDX and navigation, with `jose` added for decoding. > > - **Docs**: > - Add `concepts/jwt.mdx` with JWT structure, claims, examples, verification, security, and best practices. > - Include JWT page in navigation: `docs-platform.yml`, `templates/meta.json`, and Python `templates-python/meta.json`. > - **UI Component**: > - Add `JWTViewer` in `docs/src/components/mdx/jwt-viewer.tsx` to decode JWTs (header, payload, signature), show time-based indicators, and load current user token via `useUser()`. > - Export and register in MDX: `docs/src/components/mdx/index.ts`, `docs/src/mdx-components.tsx`. > - **Dependencies**: > - Add `jose` to `docs/package.json` (lockfile updated). > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup> for f25e369. You can [customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> ---- <!-- ELLIPSIS_HIDDEN --> <!-- RECURSEML_ANALYSIS:START --> ## Review by RecurseML _🔍 Review performed on [ad34cfe..a135bbd](ad34cfe...a135bbdd77d0bc385dc660516029897887502dec)_ ✨ No bugs found, your code is sparkling clean <details> <summary>✅ Files analyzed, no issues (3)</summary> • `docs/src/components/mdx/jwt-viewer.tsx` • `docs/src/mdx-components.tsx` • `docs/src/components/mdx/index.ts` </details> <details> <summary>⏭️ Files skipped (trigger manually) (4)</summary> | &nbsp; Locations &nbsp; | &nbsp; Trigger Analysis &nbsp; | |-----------|:------------------:| `docs/docs-platform.yml` | [![Analyze](https://img.shields.io/badge/Analyze-238636?style=plastic)](https://squash-322339097191.europe-west3.run.app/interactive/4da4b078574a59406b7d9b8bcb847990999591df6cc54c74e830e62cf092a96c/?repo_owner=stack-auth&repo_name=stack-auth&pr_number=905) `docs/templates-python/meta.json` | [![Analyze](https://img.shields.io/badge/Analyze-238636?style=plastic)](https://squash-322339097191.europe-west3.run.app/interactive/36697f876fcf97a260cb8c86fda245d0d9ee5c722d28419599524fd4b61accc5/?repo_owner=stack-auth&repo_name=stack-auth&pr_number=905) `docs/templates/concepts/jwt.mdx` | [![Analyze](https://img.shields.io/badge/Analyze-238636?style=plastic)](https://squash-322339097191.europe-west3.run.app/interactive/d6cbe744221c23fdd0d6abe405c84027eefc3c6a3a1647e0a88b5d0a5d5fdc8e/?repo_owner=stack-auth&repo_name=stack-auth&pr_number=905) `docs/templates/meta.json` | [![Analyze](https://img.shields.io/badge/Analyze-238636?style=plastic)](https://squash-322339097191.europe-west3.run.app/interactive/49fb1d30374f5d38349d3b118155d87ace27b836040357dfcfefa1807a1ed6dd/?repo_owner=stack-auth&repo_name=stack-auth&pr_number=905) </details> [![Need help? Join our Discord](https://img.shields.io/badge/Need%20help%3F%20Join%20our%20Discord-5865F2?style=plastic&logo=discord&logoColor=white)](https://discord.gg/n3SsVDAW6U) <!-- RECURSEML_ANALYSIS:END --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Interactive JWT Viewer in the docs: paste or auto-load a token to inspect header, payload, signature with live decoding, validity/time indicators, per-field copy controls, and "load my token". * **Documentation** * New "JWT" concept page covering structure, claims, examples, client/server/manual usage, security, troubleshooting, and best practices. * JWT page added to site navigation and enabled across Next, React, JS, and Python docs. * **Chores** * Added runtime dependency to support JWT decoding in the docs. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds a new JWT concepts page and an interactive `JWTViewer` component, integrating it into MDX and navigation, with `jose` added for decoding. > > - **Docs**: > - Add `concepts/jwt.mdx` with JWT structure, claims, examples, verification, security, and best practices. > - Include JWT page in navigation: `docs-platform.yml`, `templates/meta.json`, and Python `templates-python/meta.json`. > - **UI Component**: > - Add `JWTViewer` in `docs/src/components/mdx/jwt-viewer.tsx` to decode JWTs (header, payload, signature), show time-based indicators, and load current user token via `useUser()`. > - Export and register in MDX: `docs/src/components/mdx/index.ts`, `docs/src/mdx-components.tsx`. > - **Dependencies**: > - Add `jose` to `docs/package.json` (lockfile updated). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 837fffb. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
1 parent 8da7186 commit f5a3a99

9 files changed

Lines changed: 739 additions & 1 deletion

File tree

docs/docs-platform.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ pages:
110110

111111
- path: concepts/backend-integration.mdx
112112
platforms: ["next", "react", "js", "python"]
113+
114+
- path: concepts/jwt.mdx
115+
platforms: ["next", "react", "js", "python"]
113116

114117
- path: concepts/emails.mdx
115118
platforms: ["next", "react", "js"] # No Python (server-side email functionality)

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"fumadocs-openapi": "^8.1.12",
4141
"fumadocs-typescript": "^4.0.5",
4242
"fumadocs-ui": "15.3.3",
43+
"jose": "^6.1.0",
4344
"js-yaml": "^4.1.0",
4445
"lucide-react": "^0.511.0",
4546
"mermaid": "^11.6.0",

docs/src/components/mdx/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export { Card } from './card';
22
export { CardGroup } from './card-group';
33
export { DynamicCodeblock } from './dynamic-code-block';
44
export { Info } from './info';
5+
export { JWTViewer } from './jwt-viewer';
56
export { StackContainer } from './stack-container';
67

78

0 commit comments

Comments
 (0)