mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-08-05 18:58:40 +02:00
refactor: make cookie and extension management free
This commit is contained in:
@@ -10,7 +10,7 @@ use tauri::AppHandle;
|
|||||||
/// Chromium cookie encryption/decryption support.
|
/// Chromium cookie encryption/decryption support.
|
||||||
/// On macOS: uses "Chromium Safe Storage" key from Keychain with PBKDF2 + AES-128-CBC.
|
/// On macOS: uses "Chromium Safe Storage" key from Keychain with PBKDF2 + AES-128-CBC.
|
||||||
/// On Linux: uses os_crypt_key file from profile directory with PBKDF2 + AES-128-CBC.
|
/// On Linux: uses os_crypt_key file from profile directory with PBKDF2 + AES-128-CBC.
|
||||||
mod chrome_decrypt {
|
pub mod chrome_decrypt {
|
||||||
use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit};
|
use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|||||||
@@ -1091,12 +1091,6 @@ lazy_static::lazy_static! {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn list_extensions() -> Result<Vec<Extension>, String> {
|
pub async fn list_extensions() -> Result<Vec<Extension>, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.list_extensions()
|
.list_extensions()
|
||||||
@@ -1115,12 +1109,6 @@ pub async fn add_extension(
|
|||||||
file_name: String,
|
file_name: String,
|
||||||
file_data: Vec<u8>,
|
file_data: Vec<u8>,
|
||||||
) -> Result<Extension, String> {
|
) -> Result<Extension, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.add_extension(name, file_name, file_data)
|
.add_extension(name, file_name, file_data)
|
||||||
@@ -1134,12 +1122,6 @@ pub async fn update_extension(
|
|||||||
file_name: Option<String>,
|
file_name: Option<String>,
|
||||||
file_data: Option<Vec<u8>>,
|
file_data: Option<Vec<u8>>,
|
||||||
) -> Result<Extension, String> {
|
) -> Result<Extension, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.update_extension(&extension_id, name, file_name, file_data)
|
.update_extension(&extension_id, name, file_name, file_data)
|
||||||
@@ -1151,12 +1133,6 @@ pub async fn delete_extension(
|
|||||||
app_handle: tauri::AppHandle,
|
app_handle: tauri::AppHandle,
|
||||||
extension_id: String,
|
extension_id: String,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.delete_extension(&app_handle, &extension_id)
|
.delete_extension(&app_handle, &extension_id)
|
||||||
@@ -1165,12 +1141,6 @@ pub async fn delete_extension(
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn list_extension_groups() -> Result<Vec<ExtensionGroup>, String> {
|
pub async fn list_extension_groups() -> Result<Vec<ExtensionGroup>, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.list_groups()
|
.list_groups()
|
||||||
@@ -1179,12 +1149,6 @@ pub async fn list_extension_groups() -> Result<Vec<ExtensionGroup>, String> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn create_extension_group(name: String) -> Result<ExtensionGroup, String> {
|
pub async fn create_extension_group(name: String) -> Result<ExtensionGroup, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.create_group(name)
|
.create_group(name)
|
||||||
@@ -1197,12 +1161,6 @@ pub async fn update_extension_group(
|
|||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
extension_ids: Option<Vec<String>>,
|
extension_ids: Option<Vec<String>>,
|
||||||
) -> Result<ExtensionGroup, String> {
|
) -> Result<ExtensionGroup, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.update_group(&group_id, name, extension_ids)
|
.update_group(&group_id, name, extension_ids)
|
||||||
@@ -1214,12 +1172,6 @@ pub async fn delete_extension_group(
|
|||||||
app_handle: tauri::AppHandle,
|
app_handle: tauri::AppHandle,
|
||||||
group_id: String,
|
group_id: String,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.delete_group(&app_handle, &group_id)
|
.delete_group(&app_handle, &group_id)
|
||||||
@@ -1231,12 +1183,6 @@ pub async fn add_extension_to_group(
|
|||||||
group_id: String,
|
group_id: String,
|
||||||
extension_id: String,
|
extension_id: String,
|
||||||
) -> Result<ExtensionGroup, String> {
|
) -> Result<ExtensionGroup, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.add_extension_to_group(&group_id, &extension_id)
|
.add_extension_to_group(&group_id, &extension_id)
|
||||||
@@ -1248,12 +1194,6 @@ pub async fn remove_extension_from_group(
|
|||||||
group_id: String,
|
group_id: String,
|
||||||
extension_id: String,
|
extension_id: String,
|
||||||
) -> Result<ExtensionGroup, String> {
|
) -> Result<ExtensionGroup, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
let mgr = EXTENSION_MANAGER.lock().unwrap();
|
||||||
mgr
|
mgr
|
||||||
.remove_extension_from_group(&group_id, &extension_id)
|
.remove_extension_from_group(&group_id, &extension_id)
|
||||||
@@ -1265,13 +1205,6 @@ pub async fn assign_extension_group_to_profile(
|
|||||||
profile_id: String,
|
profile_id: String,
|
||||||
extension_group_id: Option<String>,
|
extension_group_id: Option<String>,
|
||||||
) -> Result<crate::profile::BrowserProfile, String> {
|
) -> Result<crate::profile::BrowserProfile, String> {
|
||||||
if !crate::cloud_auth::CLOUD_AUTH
|
|
||||||
.has_active_paid_subscription()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
return Err("Extension management requires an active Pro subscription".to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate compatibility if assigning a group
|
// Validate compatibility if assigning a group
|
||||||
if let Some(ref group_id) = extension_group_id {
|
if let Some(ref group_id) = extension_group_id {
|
||||||
let profile_manager = crate::profile::ProfileManager::instance();
|
let profile_manager = crate::profile::ProfileManager::instance();
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import {
|
|||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "./ui/dropdown-menu";
|
} from "./ui/dropdown-menu";
|
||||||
import { Input } from "./ui/input";
|
import { Input } from "./ui/input";
|
||||||
import { ProBadge } from "./ui/pro-badge";
|
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
|
||||||
|
|
||||||
const CLICK_THRESHOLD = 5;
|
const CLICK_THRESHOLD = 5;
|
||||||
@@ -301,15 +300,12 @@ const HomeHeader = ({
|
|||||||
{t("header.menu.groups")}
|
{t("header.menu.groups")}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
disabled={!crossOsUnlocked}
|
|
||||||
className={cn(!crossOsUnlocked && "opacity-50")}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onExtensionManagementDialogOpen(true);
|
onExtensionManagementDialogOpen(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LuPuzzle className="mr-2 w-4 h-4" />
|
<LuPuzzle className="mr-2 w-4 h-4" />
|
||||||
{t("header.menu.extensions")}
|
{t("header.menu.extensions")}
|
||||||
{!crossOsUnlocked && <ProBadge className="ml-auto" />}
|
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user