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

fix: update server-side validation response types #55

Merged
merged 3 commits into from
Feb 19, 2024

Conversation

jinsley8
Copy link
Contributor

Description

Cloudflare returns extra properties not yet accounted for in TurnstileServerValidationResponse and the error-codes is always returned whether the validation is successful or not.

messages and metadata seem like they have been added to the response more recently but not yet documented in the official server-side validation docs.

metadata is returned when validation is successful.

I am not quite sure of the purpose of messages so the comment isn't as detailed but it is only returned if validation fails.

Changes Made

  • Updated type for error-codes property so it is always required but can be an empty array.
  • Added types for messages and metadata.

Examples

Screenshot 2024-02-16 at 11 52 00 PM Screenshot 2024-02-16 at 11 52 10 PM

Copy link

vercel bot commented Feb 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-turnstile ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 18, 2024 4:58pm

@jinsley8 jinsley8 changed the title Fix/update server validation types fix: update server-side validation response types Feb 17, 2024
Copy link
Owner

@marsidev marsidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please set 'error-codes': TurnstileServerValidationErrorCode[]? That's a valid typing even for empty arrays.

@jinsley8
Copy link
Contributor Author

@marsidev I've updated the 'error-codes' type

@marsidev marsidev merged commit 4d3ebfc into marsidev:main Feb 19, 2024
7 checks passed
@marsidev
Copy link
Owner

Thanks @jinsley8!

@jinsley8 jinsley8 deleted the fix/update-server-validation-types branch February 19, 2024 23:21
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.

2 participants