refactor(client): migrate captcha flow to betterCaptcha adapter model#3442
refactor(client): migrate captcha flow to betterCaptcha adapter model#3442
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9820d8d660
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
I am confused why this is called betterCaptcha, not just captcha? The better prefix seeks meaningless for option design |
See #3441,Cause the library was called |
|
Users do NOT care what libraries are behind the sense, in short, as long as the options are not "favored", shorter name with no confusion shall be always preferred. And we are now in the case. |
|
Also I would suggest leaving this as drafts till the package becomes stable or at least api solid |
|
@Mister-Hope I had AI initialize the relevant changes for this PR. Currently, the PR is still in draft. I will add you to the CR after I have made the necessary revisions and completed the testing. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92a2c815fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR refactors Waline’s captcha integration to use the @better-captcha/* adapter model, introducing a unified captcha config (and request field) while deprecating the legacy recaptchaV3Key / turnstileKey flow. It addresses #1829 by making the client/admin captcha layer more extensible.
Changes:
- Add
captchaconfiguration to client typings/config and wire comment submission to sendcomment.captcha. - Replace admin login/register captcha UI with
@better-captcha/reactproviders and sendcaptchain auth requests. - Add server-side compatibility by accepting
captchainBaseLogic.useCaptchaCheck().
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds @better-captcha/react / @better-captcha/vue and removes recaptcha-v3. |
| packages/server/src/middleware/dashboard.js | Exposes captcha configuration to admin UI via window.*. |
| packages/server/src/logic/base.js | Accepts captcha token as an alternative to turnstile / recaptchaV3. |
| packages/client/template/init.html | Updates example config to reflect new captcha configuration direction. |
| packages/client/src/utils/config.ts | Adds captcha to normalized config and maps legacy keys into captcha. |
| packages/client/src/typings/waline.ts | Adds captcha prop and deprecates legacy captcha keys in typings. |
| packages/client/src/typings/index.ts | Re-exports new captcha typings. |
| packages/client/src/typings/captcha.ts | Introduces captcha provider option typings (based on @better-captcha/vue). |
| packages/client/src/composables/index.ts | Removes old recaptcha/turnstile composables exports. |
| packages/client/src/components/CommentBox.vue | Integrates @better-captcha/vue and sends captcha response with comment submit. |
| packages/client/src/components/Captcha.ts | Adds provider-to-component mapping for client captcha rendering. |
| packages/client/rollup.config.ts | Updates externals list (but currently does not account for @better-captcha/vue). |
| packages/client/package.json | Adds @better-captcha/vue (currently in devDependencies). |
| packages/admin/src/utils/getCaptchaConfig.js | Centralizes admin captcha config derivation. |
| packages/admin/src/store/user.js | Adds captcha to login action payload. |
| packages/admin/src/services/auth.js | Sends captcha field to server token endpoint. |
| packages/admin/src/pages/register/index.jsx | Renders captcha provider component and submits captcha token. |
| packages/admin/src/pages/login/index.jsx | Renders captcha provider component and submits captcha token. |
| packages/admin/src/components/Captcha.js | Adds provider-to-component mapping for admin captcha rendering. |
| packages/admin/package.json | Adds @better-captcha/react. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)
packages/client/src/components/CommentBox.vue:224
commentis typed asWalineCommentData, but later you assigncomment.captcha(line 293).WalineCommentDatafrom@waline/apicurrently only definesrecaptchaV3/turnstileand has nocaptchafield, which will break.d.tsgeneration/type-checking. Update the API typings to includecaptcha?: string(or extend the local type) so this assignment is type-safe.
const { serverURL, lang, login, wordLimit, requiredMeta, captcha } = config.value;
const comment: WalineCommentData = {
comment: content.value,
nick: userMeta.value.nick,
mail: userMeta.value.mail,
link: userMeta.value.link,
url: config.value.path,
ua: await userAgent(),
};
packages/client/package.json:88
@better-captcha/vueis imported at runtime (e.g. inCommentBox.vue/Captcha.ts) and its types are referenced from the exported typings. Keeping it indevDependenciesmeans downstream TypeScript consumers may fail to resolve the generated.d.tsimports. Move it todependencies(orpeerDependencies+dependenciesMeta), consistent with other runtime deps.
"dependencies": {
"@vueuse/core": "^14.2.1",
"@waline/api": "workspace:*",
"autosize": "^6.0.1",
"marked": "^17.0.2",
"marked-highlight": "^2.2.3",
"vue": "^3.5.28"
},
"devDependencies": {
"@babel/core": "7.29.0",
"@babel/preset-env": "7.29.0",
"@better-captcha/vue": "^0.5.6",
"@giphy/js-types": "5.1.0",
"@types/autosize": "4.0.3",
"@vitejs/plugin-vue": "6.0.4",
"vite": "7.3.1"
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ], | ||
| treeshake: 'smallest', | ||
| external: [ | ||
| '@vueuse/core', | ||
| '@waline/api', | ||
| 'autosize', | ||
| 'marked', | ||
| 'marked-highlight', | ||
| 'recaptcha-v3', | ||
| 'vue', | ||
| ], | ||
| external: ['@vueuse/core', '@waline/api', 'autosize', 'marked', 'marked-highlight', 'vue'], | ||
| }, |
There was a problem hiding this comment.
@better-captcha/vue is now a runtime import in the slim/components builds, but it isn’t listed in external. This will bundle the captcha adapter into slim.js/component.js, which is inconsistent with how other runtime deps are treated here and may increase bundle size / duplicate dependencies. Consider adding @better-captcha/vue to external (and ensure it’s a proper dependency/peerDependency).
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
|
@lizheming I've opened a new pull request, #3455, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…dency (#3455) * Initial plan * fix: add @better-captcha/vue to external and move to dependencies Co-authored-by: lizheming <424491+lizheming@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lizheming <424491+lizheming@users.noreply.github.com> Co-authored-by: Austin Lee <i@imnerd.org>
… github.com:walinejs/waline into codex/refactor-@waline/client-to-use-better-captcha
|
@Mister-Hope the pr has been ready. You can code review it in your free time now. |
|
Yes, I agree it. It will be merged after I check more captcha service later. It won't be soon |

fix #1829