using DodoSSH.Client.Domain;
using DodoSSH.Client.Storage;
namespace DodoSSH.Client.Sync;
///
/// The credentials in a vault, decrypted, with unpushed local changes laid over them.
///
///
///
/// The third facade over the same generic repository, and by now that is the point: adding an item type to
/// this client is a kind, a facade and a view, with no new reconciliation logic and no new sync path.
///
///
/// A credential listed here has its password in memory. Listing decrypts every credential in the
/// vault, so the caller holds them all for as long as it holds the listing — the same bargain
/// makes for key material, and worth restating because it is the reason the
/// interface reads a listing once per reload rather than holding one open.
///
///
public sealed class CredentialRepository(
ItemStore items,
OutboxStore outbox,
VaultKeyring keyring,
IActivityLogSink? activity = null)
{
private readonly VaultItemRepository credentials =
new(CredentialKind.Instance, items, outbox, keyring, activity);
///
public Task> ListAsync(
Guid vaultId,
CancellationToken cancellationToken) =>
credentials.ListAsync(vaultId, cancellationToken);
///
public Task CreateAsync(
Guid vaultId,
CredentialSecret credential,
CancellationToken cancellationToken) =>
credentials.CreateAsync(vaultId, credential, cancellationToken);
///
public Task UpdateAsync(
Guid vaultId,
Guid entityId,
CredentialSecret credential,
CancellationToken cancellationToken) =>
credentials.UpdateAsync(vaultId, entityId, credential, cancellationToken);
///
public Task DeleteAsync(Guid vaultId, Guid entityId, CancellationToken cancellationToken) =>
credentials.DeleteAsync(vaultId, entityId, cancellationToken);
}