Lightweight and asynchronous Swift package for server-side verification of various CAPTCHA tokens.
Add CaptchaKit to your project's dependencies in Package.swift:
.package(url: "https://github.com/mikuwithbeer/CaptchaKit.git", from: "2.0.0")-
Create a reusable client instance:
import CaptchaKit let client = CaptchaKit.Client( CaptchaKit.Config( strategy: .turnstile, secret: "your-secret-key" ) )
-
Verify token with existing client:
let isValid = await client.isValid("user-token") if !isValid { // Unauthorized! }
Alternatively, you can verify with metadata:
if let verification = try? await client.verifyDetails("user-token", ip: "100.200.255.1") { print("Verified for \(verification.host) at \(verification.date)") }
This project is licensed under the BSD-2-Clause Plus Patent License4.