Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add JWT string validator #3893

Merged

Conversation

Mokshit06
Copy link
Contributor

@Mokshit06 Mokshit06 commented Dec 9, 2024

This PR retroactively implements the jwt string format in Zod v3. Resolves #2946. Link to Devin run: https://preview.devin.ai/sessions/51826709fcd3457abc4be25e587c790c

Supports the following API:

z.string().jwt() // checks for jwt format
z.string().jwt({ alg?: string }) // with optional algorithm

Implements:

  • A three-part JWT structure (header.payload.signature), with base64 encoding of all parts and header containing required 'typ' and 'alg' fields.
  • Optional algorithm validation when specified
  • Implement in both main and Deno versions
  • Add comprehensive test coverage

- Add z.string().jwt() validator for checking JWT format
- Add optional algorithm validation with z.string().jwt({ alg: string })
- Implement in both main and Deno versions
- Add comprehensive test coverage
- Use atob() for browser compatibility
Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 70eaa22
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/6757c00ee6837d000810ba46
😎 Deploy Preview https://deploy-preview-3893--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@colinhacks colinhacks merged commit b68c05f into colinhacks:main Dec 10, 2024
4 checks passed
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.

Add support for jwt
2 participants