Skip to content

Conversation

@rsegecin
Copy link

This PR adds reCAPTCHA Enterprise support for web.

  • Introduces a web implementation in recaptcha_enterprise_web.dart.
  • The initialization implemented here is primarily a placeholder, since the actual initialization of the reCAPTCHA client on web is handled by the imported enterprise.js script.
  • This step ensures that the web reCAPTCHA key is set, allowing it to be used later in the execute method through JavaScript interop with the initialized client.
  • Exposes the execute method on web, keeping the API consistent with Android and iOS implementations.

Notes

  • Tested with valid site keys to confirm tokens are generated successfully via the execute method.
  • The mobile implementations remain unchanged, preserving backward compatibility.

@mcorner
Copy link
Collaborator

mcorner commented Aug 18, 2025

@rsegecin Fantastic! Would love to get this merged. First thing is that it will need to run the tests for Web in CI also: https://github.com/GoogleCloudPlatform/recaptcha-enterprise-flutter/blob/main/.github/workflows/ci.yml

@rsegecin
Copy link
Author

rsegecin commented Aug 18, 2025

Thanks for the feedback @mcorner! I’m not very familiar with setting up Web tests in CI yet, so it may take me a bit to figure this out. Could you please mark this PR as a draft in the meantime? And if someone more experienced with these tests wants to jump in, that’d be great too.

@mcorner
Copy link
Collaborator

mcorner commented Aug 22, 2025

@rsegecin Unfortunately flutter test isn't supported for web:
flutter/flutter#117955

But looks like flutter drive is:
https://docs.flutter.dev/testing/integration-tests#test-in-a-web-browser

So first step would be to see if you can get flutter drive to work with this in an integration test, then the CI part. I think you just need to add chromedriver to the workflow, but we will see.

@chandrabezzo
Copy link

chandrabezzo commented Aug 28, 2025

In my app case, mostly we can execute this code on Flutter web. Althought existing SDK doesn't support web. But, today we get reported issue from user that can't execute code below, user always get catch case. I'm confused, platform web support still in PR request but several browser can access it.

try {
   RecaptchaEnterprise.execute(RecaptchaAction.custom(action ?? ''))
} catch(e) {
   debugPrint(e.toString());
}

I hope this PR can be merged as soon as possible, with this changes makes our web app more trusted can integrated with recaptcha for web.

@rsegecin
Copy link
Author

In my app case, mostly we can execute this code on Flutter web. Althought existing SDK doesn't support web. But, today we get reported issue from user that can't execute code below, user always get catch case. I'm confused, platform web support still in PR request but several browser can access it.

try {
   RecaptchaEnterprise.execute(RecaptchaAction.custom(action ?? ''))
} catch(e) {
   debugPrint(e.toString());
}

I hope this PR can be merged as soon as possible, with this changes makes our web app more trusted can integrated with recaptcha for web.

I think your inquiry is better suited for stack overflow. This PR is only missing the automated test but you still can import this solution and use in your project by importing the PR's repo itself:

  recaptcha_enterprise_flutter:
    git:
      url: https://github.com/rsegecin/recaptcha-enterprise-flutter
      version: ^18.7.1

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.

3 participants