Class KeyBackupService
Server-side key backups: versions and the encrypted room keys in them.
Inherited Members
Namespace: Uniform.Matrix.Server.Encryption
Assembly: Uniform.Matrix.Server.dll
Syntax
public sealed class KeyBackupService
Remarks
The latest version that is not deleted is current; keys are uploaded only to it. A stored key is replaced only by a better one: verified over unverified, then a lower first message index, then a lower forward count.
Constructors
| Edit this page View SourceKeyBackupService(IDbContextFactory<ServerDbContext>)
Create the service.
Declaration
public KeyBackupService(IDbContextFactory<ServerDbContext> contexts)
Parameters
| Type | Name | Description |
|---|---|---|
| IDbContextFactory<ServerDbContext> | contexts |
Methods
| Edit this page View SourceCreateVersionAsync(string, JsonObject, CancellationToken)
Create a version, which becomes current; return its ID.
Declaration
public Task<string> CreateVersionAsync(string userId, JsonObject body, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| JsonObject | body | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<string> |
DeleteKeysAsync(string, string, string?, string?, CancellationToken)
Delete keys of a version: all of them, one room's, or one session's; return the new etag and count.
Declaration
public Task<JsonObject> DeleteKeysAsync(string userId, string version, string? roomId, string? sessionId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | version | |
| string | roomId | |
| string | sessionId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
DeleteVersionAsync(string, string, CancellationToken)
Delete a version and its keys.
Declaration
public Task DeleteVersionAsync(string userId, string version, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | version | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
GetKeysAsync(string, string, string?, string?, CancellationToken)
Return the keys of a version: all of them, one room's, or one session's.
Declaration
public Task<JsonObject> GetKeysAsync(string userId, string version, string? roomId, string? sessionId, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | version | |
| string | roomId | |
| string | sessionId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
|
GetVersionAsync(string, string?, CancellationToken)
Return a version, or the current one when version is null, with its key count and etag.
Declaration
public Task<JsonObject> GetVersionAsync(string userId, string? version, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | version | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
PutKeysAsync(string, string, IEnumerable<(string RoomId, string SessionId, JsonObject Data)>, CancellationToken)
Store keys in the current version by room and session, keeping the better of old and new; return the new etag and count.
Declaration
public Task<JsonObject> PutKeysAsync(string userId, string version, IEnumerable<(string RoomId, string SessionId, JsonObject Data)> keys, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | Owner. |
| string | version | Version, which must be current. |
| IEnumerable<(string RoomId, string SessionId, JsonObject Data)> | keys | Room ID, then session ID, then key data. |
| CancellationToken | cancellationToken | Cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<JsonObject> |
UpdateVersionAsync(string, string, JsonObject, CancellationToken)
Replace a version's auth data; the algorithm and version in the body must match.
Declaration
public Task UpdateVersionAsync(string userId, string version, JsonObject body, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | |
| string | version | |
| JsonObject | body | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |