搜尋套件、儲存庫與 APP 分類

套件詳情v3.8.1

cloudflare_turnstile

一種免費的驗證碼替代方案,用於增強安全性並防範機器人。

AndroidiOSWebmacOSWindows
近 30 天下載
6萬
喜歡數
50
Pub 分數
160

安裝套件

flutter pub add cloudflare_turnstile

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,整合 Cloudflare Turnstile,這是一種免費的 CAPTCHA 替代方案,專為保護應用程式免受機器人攻擊,同時提供無縫的使用者體驗而設計。它以簡單且注重隱私的挑戰取代傳統的 CAPTCHA,無需複雜互動即可驗證人類使用者。此套件支援多個平台,包括 Android、iOS、Web、macOS 和 Windows,非常適合需要強大防機器人保護功能的跨平台應用。Turnstile 使用先進的風險分析,以最小化合法使用者的使用摩擦。安裝簡單,設定極少,適用於表單、登入畫面,以及任何容易遭受濫用的高流量入口點。

適用情境

  • 保護登入表單
  • 保護表單提交
  • 防止機器人驅動的註冊
  • 增強API端點安全性
  • 減少評論區的垃圾訊息

主要特色

  • 免費使用
  • 低用戶摩擦
  • 注重隱私的設計
  • 跨平台支援
  • 即時風險分析

適合對象

  • Web 和移動應用
  • 高流量網站
  • 用戶註冊系統
  • API端點
  • 面向全球受眾的應用程式

使用建議

  • 需要互聯網連接
  • 依賴於 Cloudflare 的基礎設施
  • 有限的自定選項
  • 可能需要後端驗證
  • 不適用於離線環境

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Cloudflare Turnstile Pub

head

Cloudflare turnstile is a free CAPTCHAs Alternative, Turnstile delivers frustration-free, CAPTCHA-free web experiences to website visitors - with just a simple snippet of free code. Moreover, Turnstile stops abuse and confirms visitors are real without the data privacy concerns or awful user experience of CAPTCHAs.

[!WARNING]

This package is unofficial and not endorsed by Cloudflare. Use it at your own discretion.

Installation

flutter pub add cloudflare_turnstile

For Windows platform, please follow the inappwebview windows setup instructions.

Example

Here's a quick example that shows how to add Cloudflare Turnstile widget to your flutter app

import 'package:flutter/material.dart';
import 'package:cloudflare_turnstile/cloudflare_turnstile.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    // Turnstile widget configuration
    final TurnstileOptions options = const TurnstileOptions(
      size: TurnstileSize.normal,
      theme: TurnstileTheme.light,
      language: 'ar',
      retryAutomatically: false,
      refreshTimeout: TurnstileRefreshTimeout.manual,
    );

    return Scaffold(
      body: Center(
        child: CloudflareTurnstile(
          siteKey: '3x00000000000000000000FF', //Change with your site key
          baseUrl: 'http://localhost/',
          onTokenReceived: (token) {
            print(token);
          },
        ),
      ),
    );
  }
}

For Android and iOS platforms you need to provide the baseUrl parameter with the actual URL of your Turnstile Widget Domains list. baseUrl must be the same as the list of domains when creating a Widget.

Using Turnstile invisible mode

Here's how to use Cloudflare's invisible Turnstile, which automatically solves the challenge in the background

import 'package:cloudflare_turnstile/cloudflare_turnstile.dart';


class TurnstileService {
  /// Retrieves the CloudFlare Turnstile token using invisible mode.
  static Future<String?> get token async {
    // Initialize an instance of invisible Cloudflare Turnstile with your site key
    final turnstile = CloudflareTurnstile.invisible(
      siteKey: '1x00000000000000000000BB', // Replace with your actual site key
    );

    try {
      // Get the Turnstile token
      final token = await turnstile.getToken();
      return token; // Return the token upon success
    } on TurnstileException catch (e) {
      // Handle Turnstile failure
      print('Challenge failed: ${e.message}');
    } finally {
      // Ensure the Turnstile instance is properly disposed of
      turnstile.dispose();
    }

    // Return null if the token couldn't be generated
    return null;
  }
}

[!WARNING]

It's important to call dispose() on the CloudflareTurnstile instance when you no longer need it. This ensures that resources are properly cleaned up, preventing any potential memory issues.

Contribution

Your contributions are welcome and greatly valued! If you have ideas, suggestions, or improvements, feel free to open an issue or submit a pull request. Every bit of help is appreciated, and your input can make a big difference. Just ensure your contributions fit with the project's goals and guidelines.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

所在榜單