# Tauri Plugin: Captcha Breaker
A drop-in Tauri plugin for local, offline captcha solving.
Powered by `captcha-engine` with a custom-trained ONNX model.
## Features
- **Zero Runtime Config**: No model paths, no downloads, no network requests at runtime.
- **Offline Ready**: The model is downloaded at *build time* and embedded directly into the application binary.
- **Fast**: ~50ms inference time on CPU.
## Installation
1. **Add dependency**:
Full feature set (recommended):
```toml
[dependencies]
tauri-plugin-captcha-breaker = { git = "https://github.com/milangress/voucher-captcha-system", branch = "main" }
```
2. **Register the plugin** in `src-tauri/src/lib.rs`:
```rust
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_captcha_breaker::init())
.run(tauri::generate_context!())
.expect("error running app");
}
```
3. **Allow permissions** in `src-tauri/capabilities/default.json` (or similar):
```json
{
"permissions": [
"captcha-breaker:default"
]
}
```
## Usage (Frontend)
```typescript
import { invoke } from '@tauri-apps/api/core';
// 1. Initialize (Optional)
// Pre-loads the model into memory. If you skip this, it auto-loads on first use.
// Doing this at app startup makes the first user interaction feel instant.
// 2. Break a Captcha
try {
const result = await invoke<string>('plugin:captcha-breaker|break_captcha', {
// You can pass:
// - A URL (http://...) -> Plugin will download it
// - A Data URI (data:image/png;base64,...)
// - A local file path (/Users/...)
imagePath: 'https://example.com/captcha.png'
});
console.log('Captcha Result:', result);
} catch (error) {
console.error('Failed to break captcha:', error);
}
```
## How it Works (Model Downloading)
You might wonder where the model comes from if you don't provide it.
1. **Build Time**: When you run `cargo build`, the `captcha-engine` build script checks for the model file (`assets/captcha_schwarz_finetuned.onnx`).
2. **Auto-Download**: If the file is missing (e.g., in a CI environment or fresh clone), it automatically downloads the latest version from HuggingFace (`Milang/captcha-solver`) to Rust's `OUT_DIR`.
3. **Embedding**: The model bytes (~19MB) are then compiled **into the binary** itself.
4. **Runtime**: When your app runs, the plugin loads the model directly from memory. This guarantees the model is always available and version-matched to the code.