IPluginCredentialStore14.1
Interface in Unbroken.LaunchBox.Plugins.Services.Storage
public interface IPluginCredentialStoreProvides protected, package-scoped connection storage through constructor injection.
Remarks
Components in one managed package share records and notifications. Owner/connection handles are compared ordinally ignoring case; opaque value names are ordinal. These are not service account or game identities. Plugins coordinate their own refresh and client caches. Unreadable data fails without overwriting credentials. Unsubscribe event handlers when disposing a component. No cross-package storage access is provided.Methods
GetConnectionsAsyncGets saved descriptors for an owner.GetSnapshotAsyncReads one descriptor and all its values in the same transaction.GetValueAsyncGets one opaque value.RemoveConnectionAsyncRemoves a descriptor and its opaque values.SaveConnectionAsyncSaves a descriptor and applies partial changes atomically with other host credential-store writes.TryUpdateConnectionAsyncUpdates an existing connection only if its snapshot is still current in this store.
GetConnectionsAsync
Task<IReadOnlyCollection<PluginStoredConnection>> GetConnectionsAsync(
string ownerId,
CancellationToken cancellationToken
)Gets saved descriptors for an owner.
ownerId- The package-local owner ID.
cancellationToken- Cancels the read.
Returns
Saved descriptors, or an empty collection when none exist.GetSnapshotAsync
Task<PluginCredentialSnapshot?> GetSnapshotAsync(
string ownerId,
string connectionId,
CancellationToken cancellationToken
)Reads one descriptor and all its values in the same transaction.
ownerId- The package-local owner.
connectionId- The owner-local connection handle.
cancellationToken- Cancels the read.
Returns
A snapshot containing secrets, or null if the connection no longer exists.Remarks
Read a snapshot before remote token-refresh work, then persist the refreshed values with IPluginCredentialStore.TryUpdateConnectionAsync.GetValueAsync
Task<string?> GetValueAsync(
string ownerId,
string connectionId,
string name,
CancellationToken cancellationToken
)Gets one opaque value.
ownerId- The package-local owner ID.
connectionId- The owner-local connection handle.
name- The case-sensitive value name.
cancellationToken- Cancels the read.
Returns
The value, or null when absent.RemoveConnectionAsync
Task RemoveConnectionAsync(
string ownerId,
string connectionId,
CancellationToken cancellationToken
)Removes a descriptor and its opaque values.
ownerId- The package-local owner ID.
connectionId- The owner-local connection handle.
cancellationToken- Cancels the operation.
Returns
Completion of protected persistence.SaveConnectionAsync
Task SaveConnectionAsync(
PluginStoredConnection connection,
IReadOnlyDictionary<string, string?> values,
CancellationToken cancellationToken
)Saves a descriptor and applies partial changes atomically with other host credential-store writes.
connection- The descriptor to save.
values- A non-null value adds or replaces its named value, a
nullvalue removes it, and an omitted name preserves its existing value.
cancellationToken- Cancels the operation; completed writes are not rolled back.
Returns
Completion of protected persistence.TryUpdateConnectionAsync
Task<bool> TryUpdateConnectionAsync(
PluginCredentialSnapshot snapshot,
PluginStoredConnection connection,
IReadOnlyDictionary<string, string?> values,
CancellationToken cancellationToken
)Updates an existing connection only if its snapshot is still current in this store.
snapshot- The snapshot read before remote work.
connection- The updated descriptor with the same owner and connection handle.
values- Partial value changes, using the same null/removal rules as ordinary saves.
cancellationToken- Cancels persistence; completed writes are not rolled back.
Returns
True when accepted, including unchanged values; false when removed or superseded. False makes no changes and publishes no notification.Remarks
The comparison and write are atomic across participating processes; providers still coordinate service-side token rotation. Discard rejected refresh results and do not continue using their credentials. Do not fall back to an unconditional save after a remote refresh.Events
CredentialsChangedSignals a successful record change in this process; reload state instead of relying on exactly-once delivery.
CredentialsChanged
event EventHandler<PluginCredentialsChangedEventArgs>? CredentialsChangedSignals a successful record change in this process; reload state instead of relying on exactly-once delivery.