WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@baseballyama
Copy link
Contributor

This is IsAllowedSecFetchSiteHandler version of #4558

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.53%. Comparing base (489afe6) to head (74e8364).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4559   +/-   ##
=======================================
  Coverage   91.53%   91.53%           
=======================================
  Files         172      172           
  Lines       11228    11228           
  Branches     3260     3263    +3     
=======================================
  Hits        10278    10278           
  Misses        949      949           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings December 8, 2025 09:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for async IsAllowedSecFetchSiteHandler functions in the CSRF middleware, allowing users to perform asynchronous operations (like database lookups or API calls) when validating the Sec-Fetch-Site header.

  • Updated the IsAllowedSecFetchSiteHandler type to support both synchronous and asynchronous handlers
  • Modified the isAllowedSecFetchSite function to properly handle async handlers with await
  • Added comprehensive test coverage for async handler scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/middleware/csrf/index.ts Updated type definition and implementation to support async IsAllowedSecFetchSiteHandler with proper await handling
src/middleware/csrf/index.test.ts Added comprehensive tests covering async handler functionality including allowed values, path-based bypass, and blocked requests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yusukebe yusukebe changed the title feat(middleware): Support async IsAllowedSecFetchSiteHandler feat(csrf): Support async IsAllowedSecFetchSiteHandler Dec 9, 2025
Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

yusukebe commented Dec 9, 2025

@baseballyama

I've fixed the conflict myself. Looks good. Thanks!

@yusukebe yusukebe merged commit d2e7440 into honojs:main Dec 9, 2025
20 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.

2 participants