From 17e78fb27febfc2cb32d79785842aa63ec8e5a5a Mon Sep 17 00:00:00 2001 From: Ivan Kuznetsov Date: Sat, 7 Dec 2024 17:09:55 +0000 Subject: [PATCH 1/3] feat: add support for Cloudflare Turnstile response param in signUp (#155) --- packages/nhost_auth_dart/lib/src/auth_client.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/nhost_auth_dart/lib/src/auth_client.dart b/packages/nhost_auth_dart/lib/src/auth_client.dart index a621324e..f5ae1e63 100644 --- a/packages/nhost_auth_dart/lib/src/auth_client.dart +++ b/packages/nhost_auth_dart/lib/src/auth_client.dart @@ -171,6 +171,9 @@ class NhostAuthClient implements HasuraAuthClient { /// returned [AuthResponse] will not contain a session. The user must first /// activate their account by clicking an activation link sent to their email. /// + /// If [turnstileResponse] is provided, it will be included in the request headers + /// as `x-cf-turnstile-response` to support Cloudflare Turnstile protection. + /// /// Throws an [NhostException] if registration fails. @override Future signUp({ @@ -182,9 +185,12 @@ class NhostAuthClient implements HasuraAuthClient { List? roles, String? displayName, String? redirectTo, + String? turnstileResponse, }) async { log.finer('Attempting user registration'); + final headers = + turnstileResponse != null ? {'x-cf-turnstile-response': turnstileResponse} : null; final includeRoleOptions = defaultRole != null || (roles != null && roles.isNotEmpty); final options = { @@ -205,6 +211,7 @@ class NhostAuthClient implements HasuraAuthClient { if (options.isNotEmpty) 'options': options, }, responseDeserializer: AuthResponse.fromJson, + headers: headers, ); log.finer('Registration successful'); @@ -220,7 +227,6 @@ class NhostAuthClient implements HasuraAuthClient { rethrow; } } - /// Authenticates a user using an [email] and [password]. /// /// If the user has multi-factor authentication enabled, the returned From f32da13676110810fc861bf93b5add32a4384bb6 Mon Sep 17 00:00:00 2001 From: Ivan Kuznetsov Date: Wed, 11 Dec 2024 10:43:24 +0000 Subject: [PATCH 2/3] Bring newline back in auth_client.dart --- packages/nhost_auth_dart/lib/src/auth_client.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nhost_auth_dart/lib/src/auth_client.dart b/packages/nhost_auth_dart/lib/src/auth_client.dart index f5ae1e63..e8dcb216 100644 --- a/packages/nhost_auth_dart/lib/src/auth_client.dart +++ b/packages/nhost_auth_dart/lib/src/auth_client.dart @@ -227,6 +227,7 @@ class NhostAuthClient implements HasuraAuthClient { rethrow; } } + /// Authenticates a user using an [email] and [password]. /// /// If the user has multi-factor authentication enabled, the returned From 0dcbc327d8117b64938f01ea6cce9641e1eb710e Mon Sep 17 00:00:00 2001 From: Ivan Kuznetsov Date: Fri, 13 Dec 2024 12:14:28 +0000 Subject: [PATCH 3/3] Add the MAX_PANA_MISSING_POINTS env value --- .github/workflows/test.nhost_auth_dart.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.nhost_auth_dart.yaml b/.github/workflows/test.nhost_auth_dart.yaml index afacf73b..8ad5a5fc 100644 --- a/.github/workflows/test.nhost_auth_dart.yaml +++ b/.github/workflows/test.nhost_auth_dart.yaml @@ -22,7 +22,8 @@ on: # Run the quality job at 4am every day # - cron: '0 4 * * *' -env: {} +env: + MAX_PANA_MISSING_POINTS: 40 jobs: # Ensure that the package meets a suitably high pub.dev score score-package-quality: