Class EncryptedFileStore
- Namespace
- JD.AI.Core.Providers.Credentials
- Assembly
- JD.AI.Core.dll
Cross-platform credential store using DPAPI (Windows) or AES-GCM with locally rotated key material (Linux/macOS). Credentials are stored in ~/.jdai/credentials/ by default.
public sealed class EncryptedFileStore : ICredentialStore
- Inheritance
-
EncryptedFileStore
- Implements
- Inherited Members
Constructors
EncryptedFileStore(string?, HttpClient?, EncryptedFileStoreOptions?)
public EncryptedFileStore(string? basePath = null, HttpClient? httpClient = null, EncryptedFileStoreOptions? options = null)
Parameters
basePathstringhttpClientHttpClientoptionsEncryptedFileStoreOptions
Properties
IsAvailable
Whether this store is available on the current platform.
public bool IsAvailable { get; }
Property Value
StoreName
Human-readable name of the backing store.
public string StoreName { get; }
Property Value
Methods
GetAsync(string, CancellationToken)
Gets a stored credential value.
public Task<string?> GetAsync(string key, CancellationToken ct = default)
Parameters
keystringctCancellationToken
Returns
ListKeysAsync(string, CancellationToken)
Lists all keys matching a prefix.
public Task<IReadOnlyList<string>> ListKeysAsync(string prefix, CancellationToken ct = default)
Parameters
prefixstringctCancellationToken
Returns
RemoveAsync(string, CancellationToken)
Removes a stored credential.
public Task RemoveAsync(string key, CancellationToken ct = default)
Parameters
keystringctCancellationToken
Returns
RotateKeyAsync(CancellationToken)
Rotates the local non-Windows AES-GCM key and marks the previous key as retired. Existing secrets remain readable with historical keys.
public Task RotateKeyAsync(CancellationToken ct = default)
Parameters
Returns
RotateKeysAsync(CancellationToken)
Re-encrypts all stored credentials in place. On Windows this is a no-op (DPAPI handles key rotation at the OS level). On Linux/macOS this reads each credential and re-writes it, picking up any changes in the derived key material. Returns the number of credentials rotated.
public Task<int> RotateKeysAsync(CancellationToken ct = default)
Parameters
Returns
SetAsync(string, string, CancellationToken)
Stores a credential value.
public Task SetAsync(string key, string value, CancellationToken ct = default)
Parameters
keystringvaluestringctCancellationToken