Skip to content

feat: add refresh-expired and refresh-timeout attributes to Turnstile #146

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

Merged
merged 1 commit into from
Jun 9, 2025

Conversation

nullcoder
Copy link
Owner

Summary

  • Add support for Cloudflare Turnstile's refresh attributes
  • Simplify token expiration handling in create page
  • Fix test to match actual placeholder text

Changes

  • Added new Turnstile props:
    • refreshExpired?: "auto" | "manual" | "never" - Controls token regeneration on expiry (defaults to "auto")
    • refreshTimeout?: "auto" | "manual" | "never" - Controls widget refresh on timeout (defaults to "auto")
    • onTimeout?: () => void - Callback for interactive timeout events
  • Updated Window interface with timeout-callback and refresh attributes
  • Simplified create page by removing onExpire handler since refreshExpired="auto" handles token expiration automatically
  • Fixed test to use correct placeholder text ("Leave empty for no protection")

Benefits

  • Automatic token refresh on expiration improves user experience
  • Less manual token management needed in parent components
  • Better alignment with Cloudflare Turnstile best practices

Test plan

  • All Turnstile component tests pass
  • Create page tests pass
  • Manual testing shows tokens refresh automatically
  • No TypeScript errors
  • Linting passes

🤖 Generated with Claude Code

- Add refreshExpired and refreshTimeout props with "auto" | "manual" | "never" options
- Add onTimeout callback for handling interactive timeouts
- Update Window interface to include timeout-callback and refresh attributes
- Remove onExpire handler from create page since refreshExpired="auto" handles it
- Fix test to use correct placeholder text for password input
- Both refresh attributes default to "auto" for automatic handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ghostpaste 45dd1d4 Visit preview Jun 08 2025, 06:45 PM

@nullcoder nullcoder merged commit 53ebf29 into main Jun 9, 2025
1 check passed
@nullcoder nullcoder deleted the feat/turnstile-refresh-attributes branch June 9, 2025 06:23
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