tauri-plugin-outis-captcha-api 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Tauri Plugin: Outis Captcha
2
+
3
+ A drop-in Tauri plugin for local, offline captcha solving.
4
+ Powered by `outis-captcha-core` with a custom-trained ONNX model.
5
+
6
+ ## Features
7
+
8
+ - **Zero Runtime Config**: No model paths, no downloads, no network requests at runtime.
9
+ - **Offline Ready**: The model is downloaded at *build time* and embedded directly into the application binary.
10
+ - **Fast**: ~50ms inference time on CPU.
11
+
12
+ ## Installation
13
+
14
+ 1. **Add dependency**:
15
+
16
+ Full feature set (recommended):
17
+ ```toml
18
+ [dependencies]
19
+ tauri-plugin-outis-captcha = { git = "https://github.com/milangress/outis", branch = "main" }
20
+ ```
21
+
22
+ 2. **Register the plugin** in `src-tauri/src/lib.rs`:
23
+
24
+ ```rust
25
+ #[cfg_attr(mobile, tauri::mobile_entry_point)]
26
+ pub fn run() {
27
+ tauri::Builder::default()
28
+ .plugin(tauri_plugin_outis_captcha::init())
29
+ .run(tauri::generate_context!())
30
+ .expect("error running app");
31
+ }
32
+ ```
33
+
34
+ 3. **Allow permissions** in `src-tauri/capabilities/default.json` (or similar):
35
+
36
+ ```json
37
+ {
38
+ "permissions": [
39
+ "outis-captcha:default"
40
+ ]
41
+ }
42
+ ```
43
+
44
+ ## Usage (Frontend)
45
+
46
+ ```typescript
47
+ import { invoke } from '@tauri-apps/api/core';
48
+
49
+ // 1. Initialize (Optional)
50
+ // Pre-loads the model into memory. If you skip this, it auto-loads on first use.
51
+ // Doing this at app startup makes the first user interaction feel instant.
52
+ await invoke('plugin:outis-captcha|init_model');
53
+
54
+ // 2. Break a Captcha
55
+ try {
56
+ const result = await invoke<string>('plugin:outis-captcha|read_captcha', {
57
+ // You can pass:
58
+ // - A URL (http://...) -> Plugin will download it
59
+ // - A Data URI (data:image/png;base64,...)
60
+ // - A local file path (/Users/...)
61
+ imagePath: 'https://example.com/captcha.png'
62
+ });
63
+
64
+ console.log('Captcha Result:', result);
65
+ } catch (error) {
66
+ console.error('Failed to break captcha:', error);
67
+ }
68
+ ```
69
+
70
+ ## How it Works (Model Downloading)
71
+
72
+ You might wonder where the model comes from if you don't provide it.
73
+
74
+ 1. **Build Time**: When you run `cargo build`, the `outis-captcha-core` build script checks for the model file (`assets/outis-model.rten`).
75
+ 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/outis`) to Rust's `OUT_DIR`.
76
+ 3. **Embedding**: The model bytes (~19MB) are then compiled **into the binary** itself.
77
+ 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.
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var core = require('@tauri-apps/api/core');
4
+
5
+ /**
6
+ * Reads a captcha from a local file path or a remote URL.
7
+ *
8
+ * @param imagePath Local path or HTTP/HTTPS URL of the captcha image.
9
+ * @returns The decoded captcha text.
10
+ */
11
+ async function readCaptcha(imagePath) {
12
+ return await core.invoke('plugin:outis|read_captcha', {
13
+ imagePath,
14
+ });
15
+ }
16
+ /**
17
+ * Ensures the model is downloaded and loaded into memory.
18
+ * This can be called pre-emptively to avoid lag on the first captcha break.
19
+ */
20
+ async function initModel() {
21
+ return await core.invoke('plugin:outis|init_model');
22
+ }
23
+ /**
24
+ * Deletes the model from disk and from memory.
25
+ */
26
+ async function deleteModel() {
27
+ return await core.invoke('plugin:outis|delete_model');
28
+ }
29
+
30
+ exports.deleteModel = deleteModel;
31
+ exports.initModel = initModel;
32
+ exports.readCaptcha = readCaptcha;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Reads a captcha from a local file path or a remote URL.
3
+ *
4
+ * @param imagePath Local path or HTTP/HTTPS URL of the captcha image.
5
+ * @returns The decoded captcha text.
6
+ */
7
+ export declare function readCaptcha(imagePath: string): Promise<string>;
8
+ /**
9
+ * Ensures the model is downloaded and loaded into memory.
10
+ * This can be called pre-emptively to avoid lag on the first captcha break.
11
+ */
12
+ export declare function initModel(): Promise<void>;
13
+ /**
14
+ * Deletes the model from disk and from memory.
15
+ */
16
+ export declare function deleteModel(): Promise<void>;
@@ -0,0 +1,28 @@
1
+ import { invoke } from '@tauri-apps/api/core';
2
+
3
+ /**
4
+ * Reads a captcha from a local file path or a remote URL.
5
+ *
6
+ * @param imagePath Local path or HTTP/HTTPS URL of the captcha image.
7
+ * @returns The decoded captcha text.
8
+ */
9
+ async function readCaptcha(imagePath) {
10
+ return await invoke('plugin:outis|read_captcha', {
11
+ imagePath,
12
+ });
13
+ }
14
+ /**
15
+ * Ensures the model is downloaded and loaded into memory.
16
+ * This can be called pre-emptively to avoid lag on the first captcha break.
17
+ */
18
+ async function initModel() {
19
+ return await invoke('plugin:outis|init_model');
20
+ }
21
+ /**
22
+ * Deletes the model from disk and from memory.
23
+ */
24
+ async function deleteModel() {
25
+ return await invoke('plugin:outis|delete_model');
26
+ }
27
+
28
+ export { deleteModel, initModel, readCaptcha };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "tauri-plugin-outis-captcha-api",
3
+ "version": "1.0.1",
4
+ "author": "Milan Gress",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/milangress/outis-captcha.git",
9
+ "directory": "plugins/tauri-plugin-outis-captcha"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "description": "Tauri plugin for reading captchas.",
15
+ "type": "module",
16
+ "types": "./dist-js/index.d.ts",
17
+ "main": "./dist-js/index.cjs",
18
+ "module": "./dist-js/index.js",
19
+ "exports": {
20
+ "types": "./dist-js/index.d.ts",
21
+ "import": "./dist-js/index.js",
22
+ "require": "./dist-js/index.cjs"
23
+ },
24
+ "files": [
25
+ "dist-js",
26
+ "README.md"
27
+ ],
28
+ "dependencies": {
29
+ "@tauri-apps/api": "^2.10.1"
30
+ },
31
+ "devDependencies": {
32
+ "@rollup/plugin-typescript": "^12.3.0",
33
+ "rollup": "^4.57.1",
34
+ "typescript": "^5.9.3",
35
+ "tslib": "^2.8.1"
36
+ },
37
+ "scripts": {
38
+ "build": "rollup -c",
39
+ "pretest": "pnpm build"
40
+ }
41
+ }