CH-J ToolsSSH-এর মাধ্যমে সার্ভার ব্যবস্থাপনা
মেনু
প্রকাশিত সোর্স

CH-J Tools

নির্দিষ্ট একটি অ্যাপ্লিকেশন রিলিজের ডিরেক্টরি ও ফাইল ব্রাউজ করুন।

সোর্স ZIP ডাউনলোড করুন
CH-J / Server Manager 1704 টি ফাইল
0.1.2-beta যোগ করা হয়েছে: · বিল্ড হয়েছে:
vault.rs যোগ করা হয়েছে: তারিখ নথিভুক্ত নেই ৫.১ KB · 133 লাইন
কোড ফাইল ডাউনলোড করুন
1//! Vault and OS-protected unlocking commands.
3use super::{envelope, logged, main_core, payload, text, CommandResult};
4use crate::core::app::CoreSlot;
5use crate::core::error::{CoreError, CoreResult};
6use serde_json::{json, Value};
7use tauri::{Manager, State, Webview};
9fn status_value(status: crate::core::vault::VaultStatus) -> Value {
10 serde_json::to_value(status).unwrap_or_else(|_| json!({}))
13#[tauri::command]
14pub async fn core_vault_status(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
15 Ok(status_value(main_core(&webview, &slot)?.vault.status()))
18#[tauri::command]
19pub async fn core_vault_create(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
20 let core = main_core(&webview, &slot)?;
21 let payload = super::payload(payload);
22 let result = core.vault.create(text(&payload, "password")).await.map(status_value);
23 if result.is_ok() {
24 core.services.lock.activity();
25 }
26 core.services.availability.changed();
27 logged(&core, "vault:create", result)
30#[tauri::command]
31pub async fn core_vault_unlock(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
32 let core = main_core(&webview, &slot)?;
33 let payload = super::payload(payload);
34 core.services.biometrics.cancel();
35 let result = core.vault.unlock(text(&payload, "password")).await.map(status_value);
36 if result.is_ok() {
37 core.services.biometrics.disarm_auto_unlock();
38 core.services.lock.activity();
39 }
40 core.services.availability.changed();
41 logged(&core, "vault:unlock", result)
44#[tauri::command]
45pub async fn core_vault_lock(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
46 let core = main_core(&webview, &slot)?;
47 let status = core.services.lock.lock(&core, "manual").await;
48 core.services.availability.changed();
49 Ok(status_value(status))
52#[tauri::command]
53pub async fn core_vault_reset(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
54 let core = main_core(&webview, &slot)?;
55 let payload = super::payload(payload);
56 let result = async {
57 let confirmation = text(&payload, "confirmation");
58 if confirmation != "SMAZAT" {
59 return Err(CoreError::new("VAULT_RESET_CONFIRMATION_REQUIRED", "Vault reset confirmation is invalid."));
60 }
61 if core.vault.is_unlocked() {
62 core.services.biometrics.require_sensitive_action().await?;
63 }
64 core.services.biometrics.disable(true).await?;
65 core.services.modules.close_all(&core);
66 core.services.sessions.disconnect_all("vault-reset").await;
67 let status = core.vault.reset(confirmation)?;
68 core.logger.warn("Encrypted user vault was reset by the user.", json!({}));
69 Ok(status_value(status))
70 }
71 .await;
72 logged(&core, "vault:reset", result)
75async fn biometric<F>(webview: Webview, slot: State<'_, CoreSlot>, work: impl FnOnce(std::sync::Arc<crate::core::app::Core>) -> F) -> CommandResult
76where
77 F: std::future::Future<Output = CoreResult<Value>>,
79 let core = main_core(&webview, &slot)?;
80 Ok(envelope(work(core).await, "SSH_OPERATION_FAILED", None))
83#[tauri::command]
84pub async fn core_biometrics_status(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
85 biometric(webview, slot, |core| async move { Ok(core.services.biometrics.status().await) }).await
88#[tauri::command]
89pub async fn core_biometrics_enable(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
90 biometric(webview, slot, |core| async move { core.services.biometrics.enable().await }).await
93#[tauri::command]
94pub async fn core_biometrics_disable(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
95 biometric(webview, slot, |core| async move { core.services.biometrics.disable(false).await }).await
98#[tauri::command]
99pub async fn core_biometrics_unlock(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
100 biometric(webview, slot, |core| async move {
101 let status = core.services.biometrics.unlock().await?;
102 core.services.lock.activity();
103 Ok(status)
104 })
105 .await
108#[tauri::command]
109pub async fn core_biometrics_auto_unlock(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
110 let window = webview.window();
111 let ready = window.is_visible().unwrap_or(false) && !window.is_minimized().unwrap_or(true);
112 let _ = window.app_handle();
113 biometric(webview, slot, move |core| async move {
114 if !ready {
115 return Ok(json!({ "attempted": false, "reason": "WINDOW_NOT_READY" }));
116 }
117 let result = core.services.biometrics.auto_unlock().await;
118 if result["status"]["unlocked"] == true {
119 core.services.lock.activity();
120 }
121 Ok(result)
122 })
123 .await
126#[tauri::command]
127pub async fn core_biometrics_authenticate(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
128 biometric(webview, slot, |core| async move { core.services.biometrics.authenticate_sensitive_action().await }).await
131pub fn _unused(value: Option<Value>) -> Value {
132 payload(value)
SHA-2565be63baad1ff0f34b902f3c5699309907a5a8c4dac3af44ceebbec4605f8309a

CH-J Proprietary Software License 1.14 · সোর্স CH-J Proprietary Software License 1.14-এর অধীনে দেওয়া হয়। এর প্রাপ্যতা লাইসেন্সের শর্ত বদলায় না এবং অতিরিক্ত কোনো অধিকারও দেয় না।

আর্কাইভ SHA-256ac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f
ফাইল