[PR #9136] feat(captcha): add support for Yandex SmartCaptcha #25361

Open
opened 2026-04-15 22:51:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/9136
Author: @utikpuhlik
Created: 4/12/2026
Status: 🔄 Open

Base: mainHead: feat/yandex-smart-captcha


📝 Commits (3)

  • 525b680 feat(captcha): add support for Yandex SmartCaptcha
  • 9d930bd chore: change changeset bump to patch for main branch
  • d0cfd1d docs(captcha): update code snippet and wording for provider-agnostic language

📊 Changes

8 files changed (+147 additions, -4 deletions)

View changed files

.changeset/fifty-books-remain.md (+5 -0)
📝 docs/content/docs/plugins/captcha.mdx (+5 -3)
📝 packages/better-auth/src/plugins/captcha/captcha.test.ts (+75 -0)
📝 packages/better-auth/src/plugins/captcha/constants.ts (+3 -0)
📝 packages/better-auth/src/plugins/captcha/index.ts (+4 -0)
📝 packages/better-auth/src/plugins/captcha/types.ts (+6 -1)
📝 packages/better-auth/src/plugins/captcha/verify-handlers/index.ts (+1 -0)
packages/better-auth/src/plugins/captcha/verify-handlers/yandex-smart-captcha.ts (+48 -0)

📄 Description

Summary

Adds Yandex SmartCaptcha as a new captcha provider, following the same pattern as existing providers (Turnstile, reCAPTCHA, hCaptcha, CaptchaFox).

  • New verification handler with Yandex's validate API (POST https://smartcaptcha.yandexcloud.net/validate)
  • Provider registered in constants, types, and plugin router
  • Tests covering success, service failure, and validation failure
  • Documentation updated with provider listing and client-side setup link

Usage

import { betterAuth } from "better-auth";
import { captcha } from "better-auth/plugins";

export const auth = betterAuth({
    plugins: [
        captcha({
            provider: "yandex-smart-captcha",
            secretKey: process.env.YANDEX_CAPTCHA_SECRET_KEY!,
        }),
    ],
});

Test plan

  • All 20 captcha tests pass (17 existing + 3 new for Yandex)
  • pnpm typecheck passes
  • Lefthook (format, spell, biome) passes
  • Tested locally in a Next.js app with Yandex SmartCaptcha widget

Summary by cubic

Adds Yandex SmartCaptcha to the captcha plugin in better-auth, enabling server-side validation via Yandex’s validate API. Docs updated with provider-agnostic wording and a client setup link; tests included.

  • New Features
    • captcha: Added yandex-smart-captcha verify handler (POST to https://smartcaptcha.yandexcloud.net/validate with secret, token, optional IP), integrated into constants/types/router.
    • Forwards x-forwarded-for to Yandex; returns 403 on failed validation and 500 on service errors.

Written for commit d0cfd1d2fc. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/9136 **Author:** [@utikpuhlik](https://github.com/utikpuhlik) **Created:** 4/12/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/yandex-smart-captcha` --- ### 📝 Commits (3) - [`525b680`](https://github.com/better-auth/better-auth/commit/525b680fc42655beefced6e728cbcc2c149f3993) feat(captcha): add support for Yandex SmartCaptcha - [`9d930bd`](https://github.com/better-auth/better-auth/commit/9d930bdc64b9157b47b047427b37e6b8bfe069e3) chore: change changeset bump to patch for main branch - [`d0cfd1d`](https://github.com/better-auth/better-auth/commit/d0cfd1d2fc329ac2f7eefe9c13576736e5860e56) docs(captcha): update code snippet and wording for provider-agnostic language ### 📊 Changes **8 files changed** (+147 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/fifty-books-remain.md` (+5 -0) 📝 `docs/content/docs/plugins/captcha.mdx` (+5 -3) 📝 `packages/better-auth/src/plugins/captcha/captcha.test.ts` (+75 -0) 📝 `packages/better-auth/src/plugins/captcha/constants.ts` (+3 -0) 📝 `packages/better-auth/src/plugins/captcha/index.ts` (+4 -0) 📝 `packages/better-auth/src/plugins/captcha/types.ts` (+6 -1) 📝 `packages/better-auth/src/plugins/captcha/verify-handlers/index.ts` (+1 -0) ➕ `packages/better-auth/src/plugins/captcha/verify-handlers/yandex-smart-captcha.ts` (+48 -0) </details> ### 📄 Description ## Summary Adds [Yandex SmartCaptcha](https://yandex.cloud/en/services/smartcaptcha) as a new captcha provider, following the same pattern as existing providers (Turnstile, reCAPTCHA, hCaptcha, CaptchaFox). - New verification handler with Yandex's validate API (`POST https://smartcaptcha.yandexcloud.net/validate`) - Provider registered in constants, types, and plugin router - Tests covering success, service failure, and validation failure - Documentation updated with provider listing and client-side setup link ### Usage ```ts import { betterAuth } from "better-auth"; import { captcha } from "better-auth/plugins"; export const auth = betterAuth({ plugins: [ captcha({ provider: "yandex-smart-captcha", secretKey: process.env.YANDEX_CAPTCHA_SECRET_KEY!, }), ], }); ``` ## Test plan - [x] All 20 captcha tests pass (17 existing + 3 new for Yandex) - [x] `pnpm typecheck` passes - [x] Lefthook (format, spell, biome) passes - [x] Tested locally in a Next.js app with Yandex SmartCaptcha widget <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds Yandex SmartCaptcha to the `captcha` plugin in `better-auth`, enabling server-side validation via Yandex’s validate API. Docs updated with provider-agnostic wording and a client setup link; tests included. - New Features - `captcha`: Added `yandex-smart-captcha` verify handler (POST to https://smartcaptcha.yandexcloud.net/validate with secret, token, optional IP), integrated into constants/types/router. - Forwards `x-forwarded-for` to Yandex; returns 403 on failed validation and 500 on service errors. <sup>Written for commit d0cfd1d2fc329ac2f7eefe9c13576736e5860e56. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:51:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#25361