Veröffentlichte Quellen
Quellen als ZIP herunterladen
CH-J Tools
Durchsuchen Sie Verzeichnisse und Dateien einer bestimmten Anwendungsausgabe.
CH-J / Server Manager
872 Dateien
core-20261030T220507Z-61e4558d889f
Hinzugefügt: · Erstellt:
1
//! Tauri command layer: thin adapters between the CH-J API (`src/api`) and the Rust Core.2
//! Every command first resolves the calling window (security layer) and only then touches3
//! a service. Core commands accept only the main window; module commands only registered4
//! module windows with the required manifest permission; license commands only the5
//! license window.7
pub mod app;8
pub mod availability;9
pub mod diagnostics;10
pub mod license;11
pub mod module_api;12
pub mod modules;13
pub mod profiles;14
#[cfg(feature = "smoke")]15
pub mod smoke;16
pub mod ssh;17
pub mod updates;18
pub mod vault;20
use crate::core::app::{Core, CoreSlot};21
use crate::core::error::{CoreError, CoreResult};22
use crate::security::caller::{require_main, require_module, ModuleContext};23
use serde_json::{json, Value};24
use std::sync::Arc;25
use tauri::Webview;27
pub type CommandResult = Result<Value, CoreError>;29
pub fn payload(value: Option<Value>) -> Value {30
match value {31
Some(Value::Object(map)) => Value::Object(map),32
_ => json!({}),33
}34
}36
pub fn text<'a>(payload: &'a Value, key: &str) -> &'a str {37
payload.get(key).and_then(Value::as_str).unwrap_or("")38
}40
/// Core command guard (Electron `assertTrustedSender`).41
pub fn main_core(webview: &Webview, slot: &CoreSlot) -> CoreResult<Arc<Core>> {42
require_main(webview.label(), webview.url().ok())?;43
slot.get()44
}46
/// Wraps a core command result: failures are logged like `registerCoreIpc.handle`.47
pub fn logged(core: &Core, channel: &str, result: CoreResult<Value>) -> CommandResult {48
if let Err(error) = &result {49
core.log_ipc_failure(channel, error);50
}51
result52
}54
/// `{ok, value}` / `{ok:false, error}` envelope (SSH, biometrics, diagnostics).55
pub fn envelope(result: CoreResult<Value>, default_code: &str, limit: Option<usize>) -> Value {56
match result {57
Ok(value) => json!({ "ok": true, "value": value }),58
Err(error) => {59
let mut body = serde_json::to_value(&error).unwrap_or_else(|_| json!({}));60
if body["code"].as_str().map(str::is_empty).unwrap_or(true) {61
body["code"] = json!(default_code);62
}63
if let Some(limit) = limit {64
body = json!({ "code": body["code"], "message": error.message.chars().take(limit).collect::<String>() });65
}66
json!({ "ok": false, "error": body })67
}68
}69
}71
/// Module command guard: registered module window + manifest permission.72
pub fn module_call(webview: &Webview, slot: &CoreSlot, permission: Option<&str>) -> CoreResult<(Arc<Core>, Arc<ModuleContext>)> {73
let core = slot.get()?;74
let context = require_module(&core.windows, webview.label(), webview.url().ok())?;75
if let Some(permission) = permission {76
context.require(permission)?;77
}78
Ok((core, context))79
}81
/// The 0.1.0 plugin runtime exposed error codes inside the message for these channels,82
/// because Electron dropped custom error properties.83
pub fn module_error(channel: &str, error: CoreError) -> CoreError {84
let valid_code = error.code.len() >= 3 && error.code.len() <= 64 && error.code.chars().next().map(|c| c.is_ascii_uppercase()).unwrap_or(false) && error.code.chars().all(|c| c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_');85
let expose = error.code.starts_with("HASH_")86
|| (["plugin:users:", "plugin:system:", "plugin:files:", "plugin:disks:"].iter().any(|p| channel.starts_with(p)) && valid_code);87
if expose {88
let message = error.prefixed_message();89
CoreError { message, ..error }90
} else {91
error92
}93
}95
pub fn module_result(channel: &str, result: CoreResult<Value>) -> CommandResult {96
result.map_err(|e| module_error(channel, e))97
}SHA-256
3aed28ff4eab9c9ee9e3b9cfd279ba651c96662e814d1d4cc577994e1595dd30CH-J Proprietary Software License 1.14 · Die Quellen werden unter der CH-J Proprietary Software License 1.14 bereitgestellt. Ihre Verfügbarkeit ändert die Lizenzbedingungen nicht und gewährt keine zusätzlichen Rechte.
SHA-256 des Archivs
77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df