From e33fa804fa844abd6853e0f6cb435931feec4247 Mon Sep 17 00:00:00 2001 From: haex Date: Tue, 17 Jun 2025 16:46:44 +0200 Subject: [PATCH] implemented device name --- .../migrations/0009_curved_selene.sql | 1 + .../migrations/meta/0009_snapshot.json | 634 ++++++++++++++++++ .../database/migrations/meta/_journal.json | 7 + src-tauri/database/schemas/vault.ts | 1 + src-tauri/database/vault.db | Bin 106496 -> 106496 bytes src-tauri/src/database/mod.rs | 57 +- src/components/haex/menu/notifications.vue | 2 +- src/components/ui/dialog/confirm.vue | 14 +- src/components/ui/dialog/index.vue | 4 +- src/components/ui/input/index.vue | 13 +- src/components/ui/test.vue | 7 + src/components/vault/button/open.vue | 4 +- src/layouts/app.vue | 6 +- src/layouts/default.vue | 2 +- src/pages/index.vue | 10 +- src/pages/vault.vue | 89 ++- src/pages/vault/[vaultId]/index.vue | 3 +- .../[vaultId]/passwords/[[groupId]]/edit.vue | 6 +- .../passwords/[[groupId]]/item/[itemId].vue | 14 +- src/pages/vault/[vaultId]/settings.vue | 19 +- src/stores/passwords/items.ts | 6 +- src/stores/vault/device.ts | 98 +++ src/stores/vault/instance.ts | 47 -- src/stores/vault/settings.ts | 150 ++++- 24 files changed, 1004 insertions(+), 190 deletions(-) create mode 100644 src-tauri/database/migrations/0009_curved_selene.sql create mode 100644 src-tauri/database/migrations/meta/0009_snapshot.json create mode 100644 src/components/ui/test.vue create mode 100644 src/stores/vault/device.ts delete mode 100644 src/stores/vault/instance.ts diff --git a/src-tauri/database/migrations/0009_curved_selene.sql b/src-tauri/database/migrations/0009_curved_selene.sql new file mode 100644 index 0000000..cc5931e --- /dev/null +++ b/src-tauri/database/migrations/0009_curved_selene.sql @@ -0,0 +1 @@ +ALTER TABLE `haex_settings` ADD `type` text; \ No newline at end of file diff --git a/src-tauri/database/migrations/meta/0009_snapshot.json b/src-tauri/database/migrations/meta/0009_snapshot.json new file mode 100644 index 0000000..18de799 --- /dev/null +++ b/src-tauri/database/migrations/meta/0009_snapshot.json @@ -0,0 +1,634 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "c3a688c3-9537-4aa8-be95-a8f55546caf1", + "prevId": "c4edecb8-6aef-49e2-8498-0c4b74653c75", + "tables": { + "haex_extensions": { + "name": "haex_extensions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "haex_extensions_permissions": { + "name": "haex_extensions_permissions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "extension_id": { + "name": "extension_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "resource": { + "name": "resource", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "operation": { + "name": "operation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "(CURRENT_TIMESTAMP)" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "haex_extensions_permissions_extension_id_resource_operation_path_unique": { + "name": "haex_extensions_permissions_extension_id_resource_operation_path_unique", + "columns": [ + "extension_id", + "resource", + "operation", + "path" + ], + "isUnique": true + } + }, + "foreignKeys": { + "haex_extensions_permissions_extension_id_haex_extensions_id_fk": { + "name": "haex_extensions_permissions_extension_id_haex_extensions_id_fk", + "tableFrom": "haex_extensions_permissions", + "tableTo": "haex_extensions", + "columnsFrom": [ + "extension_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "haex_notifications": { + "name": "haex_notifications", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "alt": { + "name": "alt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "read": { + "name": "read", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "haex_passwords_group_items": { + "name": "haex_passwords_group_items", + "columns": { + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "item_id": { + "name": "item_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "haex_passwords_group_items_group_id_haex_passwords_groups_id_fk": { + "name": "haex_passwords_group_items_group_id_haex_passwords_groups_id_fk", + "tableFrom": "haex_passwords_group_items", + "tableTo": "haex_passwords_groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "haex_passwords_group_items_item_id_haex_passwords_item_details_id_fk": { + "name": "haex_passwords_group_items_item_id_haex_passwords_item_details_id_fk", + "tableFrom": "haex_passwords_group_items", + "tableTo": "haex_passwords_item_details", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "haex_passwords_group_items_item_id_group_id_pk": { + "columns": [ + "item_id", + "group_id" + ], + "name": "haex_passwords_group_items_item_id_group_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "haex_passwords_groups": { + "name": "haex_passwords_groups", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "(CURRENT_TIMESTAMP)" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "haex_passwords_groups_parent_id_haex_passwords_groups_id_fk": { + "name": "haex_passwords_groups_parent_id_haex_passwords_groups_id_fk", + "tableFrom": "haex_passwords_groups", + "tableTo": "haex_passwords_groups", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "haex_passwords_item_details": { + "name": "haex_passwords_item_details", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tags": { + "name": "tags", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "(CURRENT_TIMESTAMP)" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "haex_passwords_item_history": { + "name": "haex_passwords_item_history", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "item_id": { + "name": "item_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "changed_property": { + "name": "changed_property", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "old_value": { + "name": "old_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "new_value": { + "name": "new_value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "(CURRENT_TIMESTAMP)" + } + }, + "indexes": {}, + "foreignKeys": { + "haex_passwords_item_history_item_id_haex_passwords_item_details_id_fk": { + "name": "haex_passwords_item_history_item_id_haex_passwords_item_details_id_fk", + "tableFrom": "haex_passwords_item_history", + "tableTo": "haex_passwords_item_details", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "haex_passwords_item_key_values": { + "name": "haex_passwords_item_key_values", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "item_id": { + "name": "item_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "haex_passwords_item_key_values_item_id_haex_passwords_item_details_id_fk": { + "name": "haex_passwords_item_key_values_item_id_haex_passwords_item_details_id_fk", + "tableFrom": "haex_passwords_item_key_values", + "tableTo": "haex_passwords_item_details", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "haex_settings": { + "name": "haex_settings", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/src-tauri/database/migrations/meta/_journal.json b/src-tauri/database/migrations/meta/_journal.json index bd5c50c..8e9cd3b 100644 --- a/src-tauri/database/migrations/meta/_journal.json +++ b/src-tauri/database/migrations/meta/_journal.json @@ -64,6 +64,13 @@ "when": 1749727958231, "tag": "0008_faulty_mercury", "breakpoints": true + }, + { + "idx": 9, + "version": "6", + "when": 1750158916787, + "tag": "0009_curved_selene", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src-tauri/database/schemas/vault.ts b/src-tauri/database/schemas/vault.ts index 9b42026..4a656e6 100644 --- a/src-tauri/database/schemas/vault.ts +++ b/src-tauri/database/schemas/vault.ts @@ -11,6 +11,7 @@ import { export const haexSettings = sqliteTable('haex_settings', { id: text().primaryKey(), key: text(), + type: text(), value: text(), }) export type InsertHaexSettings = typeof haexSettings.$inferInsert diff --git a/src-tauri/database/vault.db b/src-tauri/database/vault.db index 8bbe4fad12e05d95e31d0c6477b6652bd284a4a7..d66fa61c9449203941683e429324ac994403c1aa 100644 GIT binary patch delta 280 zcmZoTz}9epZGyBQCj$e66c7smF%uB0PSi1Go@SiPIK6h}p3R%RWp^@3aPgmK;Qzz_ zo&OX6TmBdPkNNNM-{il-e}1!~!ghW}uI4NH+pp*|>Kcf1RWopNq%iPD@bmLI@iFt1 z^C)mLaHMRPNMQ8g;A-UOU>8?cXKaj}EXY$OqN9*dQdy9ipiq)pQKIS0%_bghIQb%r a?BrG4O53e7866l|fc|dXUZ2I-XbJ%KzD$w; delta 179 zcmZoTz}9epZGyBQ2Ll6x6c7smF%uB0Ow=)Esz$f&UNxcm7ZOZ~0&FKjy#3f0O^pWOSzayz%{cI!+=2gc3pJbxIsm*+5c8Up~?crV2O diff --git a/src-tauri/src/database/mod.rs b/src-tauri/src/database/mod.rs index bed79a2..ae04c2a 100644 --- a/src-tauri/src/database/mod.rs +++ b/src-tauri/src/database/mod.rs @@ -88,7 +88,6 @@ pub fn create_encrypted_database( } else { println!("Datei '{}' existiert nicht.", target.display()); } - //core::copy_file(&resource_path, &path)?; println!( "Öffne unverschlüsselte Datenbank: {}", @@ -102,8 +101,6 @@ pub fn create_encrypted_database( ) })?; - //let conn = Connection::open(&resource_path)?; - println!("Hänge neue, verschlüsselte Datenbank an unter '{}'", &path); // ATTACH DATABASE 'Dateiname' AS Alias KEY 'Passwort'; conn.execute("ATTACH DATABASE ?1 AS encrypted KEY ?2;", [&path, &key]) @@ -124,14 +121,6 @@ pub fn create_encrypted_database( return Err(e.to_string()); // Gib den Fehler zurück } } - // sqlcipher_export('Alias') kopiert Schema und Daten von 'main' zur Alias-DB - /* conn.execute("SELECT sqlcipher_export('encrypted');", []) - .map_err(|e| { - format!( - "Fehler bei SELECT sqlcipher_export('encrypted'): {}", - e.to_string() - ) - })?; */ println!("Löse die verschlüsselte Datenbank vom Handle..."); conn.execute("DETACH DATABASE encrypted;", []) @@ -143,27 +132,6 @@ pub fn create_encrypted_database( resource_path.as_path().display() ); - /* // Neue Datenbank erstellen - let conn = Connection::open_with_flags( - &path, - OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE, - ) - .map_err(|e| format!("Fehler beim Erstellen der Datenbank: {}", e.to_string()))?; - - // Datenbank mit dem angegebenen Passwort verschlüsseln - conn.pragma_update(None, "key", &key) - .map_err(|e| format!("Fehler beim Verschlüsseln der Datenbank: {}", e.to_string()))?; - - println!("Datenbank verschlüsselt mit key {}", &key); - // Überprüfen, ob die Datenbank korrekt verschlüsselt wurde - let validation_result: Result = conn.query_row("SELECT 1", [], |row| row.get(0)); - if let Err(e) = validation_result { - return Err(format!( - "Fehler beim Testen der verschlüsselten Datenbank: {}", - e.to_string() - )); - } */ - // 2. VERSUCHEN, EINE SQLCIPHER-SPEZIFISCHE OPERATION AUSZUFÜHREN println!("Prüfe SQLCipher-Aktivität mit 'PRAGMA cipher_version;'..."); match conn.query_row("PRAGMA cipher_version;", [], |row| { @@ -172,20 +140,6 @@ pub fn create_encrypted_database( }) { Ok(version) => { println!("SQLCipher ist aktiv! Version: {}", version); - - /* // Fahre mit normalen Operationen fort - println!("Erstelle Tabelle 'benutzer'..."); - conn.execute( - "CREATE TABLE benutzer (id INTEGER PRIMARY KEY, name TEXT NOT NULL)", - [], - ) - .map_err(|e| format!("Fehler beim Verschlüsseln der Datenbank: {}", e.to_string()))?; - println!("Füge Benutzer 'Bob' hinzu..."); - conn.execute("INSERT INTO benutzer (name) VALUES ('Bob')", []) - .map_err(|e| { - format!("Fehler beim Verschlüsseln der Datenbank: {}", e.to_string()) - })?; - println!("Benutzer hinzugefügt."); */ } Err(e) => { eprintln!("FEHLER: SQLCipher scheint NICHT aktiv zu sein!"); @@ -236,10 +190,7 @@ pub fn create_encrypted_database( .map_err(|e| format!("Mutex-Fehler: {}", e.to_string()))?; *db = Some(conn); - Ok(format!( - "Verschlüsselte CRDT-Datenbank erstellt unter: {} and password", - key - )) + Ok(format!("Verschlüsselte CRDT-Datenbank erstellt",)) } #[tauri::command] @@ -249,11 +200,11 @@ pub fn open_encrypted_database( state: State<'_, DbConnection>, ) -> Result { if !std::path::Path::new(&path).exists() { - return Err("Datenbankdatei nicht gefunden".into()); + return Err("File not found ".into()); } - let conn = core::open_and_init_db(&path, &key, false) - .map_err(|e| format!("Fehler beim öffnen: {}", e)); + let conn = + core::open_and_init_db(&path, &key, false).map_err(|e| format!("Error during open: {}", e)); let mut db = state.0.lock().map_err(|e| e.to_string())?; *db = Some(conn.unwrap()); diff --git a/src/components/haex/menu/notifications.vue b/src/components/haex/menu/notifications.vue index 914434a..6331b62 100644 --- a/src/components/haex/menu/notifications.vue +++ b/src/components/haex/menu/notifications.vue @@ -6,7 +6,7 @@