Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问clear审计通过

understanding-tauri-ipcunderstanding Tauri IPC 前端

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

1,608

周安装

67

GitHub Stars

18

下载量

536
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:understanding-tauri-ipc(understanding Tauri IPC 前端)
来源仓库:https://github.com/dchuk/claude-code-tauri-skills
仓库路径:skills/understanding-tauri-ipc
安装命令:
npx skills add https://github.com/dchuk/claude-code-tauri-skills --skill understanding-tauri-ipc
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/dchuk/claude-code-tauri-skills --skill understanding-tauri-ipc

简介

用于辅助前端页面、组件、样式和交互逻辑的开发与维护,适合生成或审查 React、Vue 等框架相关代码。

  • 支持组件结构整理、布局优化和性能问题定位,适用于 Next.js、Tailwind、CSS 等场景。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 使用时需结合项目设计系统与构建方式,避免生成孤立片段;页面改动应配合预览确认效果。
  • understanding-tauri-ipc 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Tauri Inter-Process Communication (IPC)

This skill covers Tauri's IPC system, including the brownfield and isolation patterns for secure communication between frontend and backend processes.

Overview

Tauri implements Inter-Process Communication using Asynchronous Message Passing. This enables isolated processes to exchange serialized requests and responses securely.

Why Message Passing?

  • Safer than shared memory or direct function access
  • Recipients can reject or discard malicious requests
  • Tauri Core validates all requests before execution
  • Prevents unauthorized function invocation

IPC Primitives

Tauri provides two IPC primitives:

Events

  • Direction: Bidirectional (Frontend <-> Tauri Core)
  • Type: Fire-and-forget, one-way messaging
  • Best for: Lifecycle events, state changes, notifications

Rust (emit to frontend):

use tauri::{AppHandle, Emitter};

fn emit_event(app: &AppHandle) {
    app.emit("backend-event", "payload data").unwrap();
}

Frontend (listen):

import { listen } from '@tauri-apps/api/event';

const unlisten = await listen('backend-event', (event) => {
  console.log('Received:', event.payload);
});

// Call unlisten() when done

Frontend (emit to backend):

import { emit } from '@tauri-apps/api/event';

await emit('frontend-event', { data: 'value' });

Commands

  • Direction: Frontend -> Rust backend
  • Protocol: JSON-RPC-based abstraction
  • API: Similar to browser's fetch() API
  • Requirement: Arguments and return data must be JSON-serializable

Rust command definition:

#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}!", name)
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Frontend invocation:

import { invoke } from '@tauri-apps/api/core';

const greeting = await invoke('greet', { name: 'World' });
console.log(greeting); // "Hello, World!"

Async command with Result:

#[tauri::command]
async fn read_file(path: String) -> Result<String, String> {
    std::fs::read_to_string(&path)
        .map_err(|e| e.to_string())
}

IPC Patterns

Tauri provides two IPC security patterns: Brownfield (default) and Isolation.


Brownfield Pattern

What It Is

The brownfield pattern is Tauri's default IPC approach. It prioritizes compatibility with existing web frontend projects by requiring minimal modifications.

When to Use

  • Migrating existing web applications to desktop
  • Rapid prototyping and development
  • Applications with trusted frontend code
  • Simple applications with limited IPC surface

Why Use It

  • Zero configuration required
  • Minimal changes to existing web code
  • Direct access to Tauri APIs
  • Fastest development path

Configuration

Brownfield is the default. Explicit configuration is optional:

{
  "app": {
    "security": {
      "pattern": {
        "use": "brownfield"
      }
    }
  }
}

Note: There are no additional configuration options for brownfield.

Code Example

Rust backend:

#[tauri::command]
fn process_data(input: String) -> Result<String, String> {
    // Direct processing without isolation layer
    Ok(format!("Processed: {}", input))
}

Frontend:

import { invoke } from '@tauri-apps/api/core';

// Direct invocation - no isolation layer
const result = await invoke('process_data', { input: 'test' });

Security Considerations

  • Frontend code has direct access to all exposed commands
  • No additional validation layer between frontend and backend
  • Supply chain attacks in frontend dependencies could invoke commands
  • Rely on command-level validation in Rust

Isolation Pattern

What It Is

The isolation pattern intercepts and modifies all Tauri API messages from the frontend using JavaScript before they reach Tauri Core. A secure JavaScript application (the Isolation application) runs in a sandboxed iframe to validate and encrypt all IPC communications.

When to Use

  • Applications with many frontend dependencies
  • High-security requirements
  • Handling sensitive data or operations
  • Public-facing applications
  • When supply chain attacks are a concern

Why Use It

Protection against Development Threats:

  • Validates all IPC calls before execution
  • Catches malicious or unwanted frontend calls
  • Mitigates supply chain attack risks
  • Provides a checkpoint for all communications

Tauri recommends using isolation whenever feasible.

How It Works

  1. Tauri's IPC handler receives a message from frontend
  2. Message routes to the Isolation application (sandboxed iframe)
  3. Isolation hook validates and potentially modifies the message
  4. Message encrypts using AES-GCM with runtime-generated keys
  5. Encrypted message returns to IPC handler
  6. Encrypted message passes to Tauri Core for decryption and execution

Key Security Features:

  • New encryption keys generated on each application launch
  • Sandboxed iframe prevents isolation code manipulation
  • All IPC calls validated, including event-based APIs

Configuration

tauri.conf.json:

{
  "app": {
    "security": {
      "pattern": {
        "use": "isolation",
        "options": {
          "dir": "../dist-isolation"
        }
      }
    }
  }
}

Code Example

Directory structure:

project/
  src/           # Main frontend
  src-tauri/     # Rust backend
  dist-isolation/
    index.html
    index.js

dist-isolation/index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Isolation Secure Script</title>
  </head>
  <body>
    <script src="index.js"></script>
  </body>
</html>

dist-isolation/index.js:

window.__TAURI_ISOLATION_HOOK__ = (payload) => {
  // Log all IPC calls for debugging
  console.log('IPC call intercepted:', payload);

  // Return payload unchanged (passthrough)
  return payload;
};

Validation example (index.js):

window.__TAURI_ISOLATION_HOOK__ = (payload) => {
  // Validate command calls
  if (payload.cmd === 'invoke') {
    const { __tauriModule, message } = payload;

    // Block unauthorized file system access
    if (message.cmd === 'readFile') {
      const path = message.path;
      if (!path.startsWith('/allowed/directory/')) {
        console.error('Blocked unauthorized file access:', path);
        return null; // Block the request
      }
    }

    // Validate specific commands
    if (message.cmd === 'deleteItem') {
      if (!confirm('Are you sure you want to delete this item?')) {
        return null; // User cancelled
      }
    }
  }

  return payload;
};

Comprehensive validation example:

const ALLOWED_COMMANDS = ['greet', 'read_config', 'save_settings'];
const BLOCKED_PATHS = ['/etc/', '/usr/', '/System/'];

window.__TAURI_ISOLATION_HOOK__ = (payload) => {
  // Validate invoke commands
  if (payload.cmd === 'invoke') {
    const commandName = payload.message?.cmd;

    // Whitelist approach
    if (!ALLOWED_COMMANDS.includes(commandName)) {
      console.warn('Blocked unknown command:', commandName);
      return null;
    }

    // Validate path arguments
    const args = payload.message?.args || {};
    if (args.path) {
      for (const blocked of BLOCKED_PATHS) {
        if (args.path.startsWith(blocked)) {
          console.error('Blocked access to protected path:', args.path);
          return null;
        }
      }
    }
  }

  // Validate event emissions
  if (payload.cmd === 'emit') {
    const eventName = payload.event;
    // Add event validation as needed
  }

  return payload;
};

Performance Considerations

  • AES-GCM encryption overhead is minimal for most applications
  • Comparable to TLS encryption used in HTTPS
  • Key generation requires system entropy (handled seamlessly on modern systems)
  • Performance-sensitive applications may notice slight impact

Limitations

  • ES Modules do not load in sandboxed iframes on Windows
  • Scripts must be inlined during build time
  • External files must be embedded rather than referenced
  • Avoid bundlers for the isolation application

Best Practices

  1. Keep it simple: Minimize isolation application dependencies
  2. No bundlers: Skip ES Modules and complex build processes
  3. Validate inputs: Verify IPC calls match expected parameters
  4. Whitelist commands: Only allow known, safe commands
  5. Log suspicious activity: Monitor for potential attacks
  6. Apply to events: Validate events that trigger Rust code

Pattern Comparison

AspectBrownfieldIsolation
DefaultYesNo
ConfigurationNone requiredRequires isolation app
SecurityBasicEnhanced
ValidationCommand-level onlyAll IPC calls
EncryptionNoneAES-GCM
PerformanceFastestSlight overhead
ComplexitySimpleModerate
Best forTrusted code, prototypesProduction, sensitive apps

Security Best Practices

For Both Patterns

  1. Validate all inputs in Rust commands #[tauri::command] fn process_file(path: String) -> Result<String, String> {// Always validate paths if path.contains("..") || path.starts_with("/etc") {return Err("Invalid path".into());} // Process file... Ok("Done".into())}
  2. Use typed arguments #[derive(serde::Deserialize)] struct CreateUserArgs {name: String, email: String,} #[tauri::command] fn create_user(args: CreateUserArgs) -> Result<(), String> {// Type-safe argument handling Ok(())}
  3. Limit exposed commands: Only expose necessary functionality
  4. Use capability-based permissions: Configure permissions in capabilities/

For Isolation Pattern

  1. Keep isolation code minimal: Reduce attack surface
  2. Avoid external dependencies: No npm packages in isolation app
  3. Use strict validation: Whitelist over blacklist
  4. Test thoroughly: Ensure validation catches edge cases

Choosing a Pattern

Use Brownfield when:

  • Building internal tools
  • Prototyping rapidly
  • Frontend code is fully trusted
  • Minimal security requirements

Use Isolation when:

  • Building public applications
  • Handling sensitive user data
  • Using many third-party frontend packages
  • Security is a priority
  • Compliance requirements exist

When in doubt, prefer isolation for production applications.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

32.57%
按下载量换算175

Gemini CLI

23.28%
按下载量换算125

Antigravity

18.5%
按下载量换算99

windsurf

11.96%
按下载量换算64

OpenCode

7.19%
按下载量换算39

Codex

3.72%
按下载量换算20

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills