Files
LehrerApp/LehrerApp.Sync/Models/SnapshotModels.cs
2026-03-29 23:47:31 +02:00

62 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace LehrerApp.Sync.Models;
/// <summary>
/// Anfrage zum Upload eines initialen Snapshots.
/// Enthält sowohl den verschlüsselten DB-Snapshot
/// als auch den mit dem Code verschlüsselten Sync-Schlüssel.
/// </summary>
public class SnapshotUploadRequest
{
/// <summary>
/// AES-256-GCM verschlüsselter Dump der lokalen LiteDB.
/// Verschlüsselt mit dem Sync-Schlüssel des Nutzers.
/// Der Server versteht den Inhalt nicht.
/// </summary>
public string EncryptedPayload { get; init; } = "";
/// <summary>
/// Der Sync-Schlüssel, verschlüsselt mit dem aus dem
/// Einmal-Code abgeleiteten Key (PBKDF2).
/// Ermöglicht dem Empfänger den Schlüssel ohne Vorabübertragung
/// zu rekonstruieren nur der Code wird benötigt.
/// </summary>
public string EncryptedSyncKey { get; init; } = "";
public DeviceType DeviceType { get; init; }
}
/// <summary>
/// Antwort nach erfolgreichem Snapshot-Upload.
/// </summary>
public class SnapshotUploadResponse
{
/// <summary>
/// Menschenlesbarer Einmal-Code.
/// Format: WORT-ZZ-WORT, z.B. "TIGER-42-BLAU"
/// Dient gleichzeitig zum Abrufen UND zum Entschlüsseln des Sync-Schlüssels.
/// </summary>
public string Code { get; init; } = "";
public DateTime ExpiresAt { get; init; }
}
/// <summary>
/// Antwort beim Abrufen eines Snapshots per Code.
/// Nach dem ersten Abruf wird der Snapshot vom Server gelöscht.
/// </summary>
public class SnapshotDownloadResponse
{
/// <summary>Der verschlüsselte DB-Snapshot.</summary>
public string EncryptedPayload { get; init; } = "";
/// <summary>
/// Der mit dem Code verschlüsselte Sync-Schlüssel.
/// Empfänger: Code → PBKDF2 → Code-Key → EncryptedSyncKey entschlüsseln
/// → Sync-Key → EncryptedPayload entschlüsseln.
/// </summary>
public string EncryptedSyncKey { get; init; } = "";
public DateTime CreatedAt { get; init; }
public DeviceType SourceDeviceType { get; init; }
}