84 lines
4.7 KiB
C#
84 lines
4.7 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace WebDrop.Core;
|
|
|
|
public sealed class DomainEnvelope
|
|
{
|
|
[JsonPropertyName("channelId")] public required string ChannelId { get; init; }
|
|
[JsonPropertyName("domain")] public required CryptoDomain Domain { get; init; }
|
|
[JsonPropertyName("epoch")] public required int Epoch { get; init; }
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
[JsonPropertyName("payload")] public required string Payload { get; init; }
|
|
}
|
|
public sealed class ObjectEnvelope
|
|
{
|
|
[JsonPropertyName("createdRevision")] public long CreatedRevision { get; set; }
|
|
[JsonPropertyName("itemId")] public required string ItemId { get; init; }
|
|
[JsonPropertyName("channelId")] public required string ChannelId { get; init; }
|
|
[JsonPropertyName("domain")] public required CryptoDomain Domain { get; init; }
|
|
[JsonPropertyName("epoch")] public required int Epoch { get; init; }
|
|
[JsonPropertyName("keyEnvelope")] public required string KeyEnvelope { get; init; }
|
|
[JsonPropertyName("authorAccount")] public string? AuthorAccount { get; set; }
|
|
[JsonPropertyName("event")] public SignedContentEventRecord? Event { get; set; }
|
|
[JsonPropertyName("deleteEvent")] public SignedContentEventRecord? DeleteEvent { get; set; }
|
|
}
|
|
|
|
public sealed class SignedContentEventRecord
|
|
{
|
|
[JsonPropertyName("eventId")] public required string EventId { get; init; }
|
|
[JsonPropertyName("kind")] public required string Kind { get; init; }
|
|
[JsonPropertyName("frameCount")] public required int FrameCount { get; init; }
|
|
[JsonPropertyName("manifestHash")] public required string ManifestHash { get; init; }
|
|
[JsonPropertyName("signerDeviceId")] public required string SignerDeviceId { get; init; }
|
|
[JsonPropertyName("signature")] public required string Signature { get; init; }
|
|
[JsonPropertyName("targetItemId")] public string? TargetItemId { get; init; }
|
|
[JsonPropertyName("signerRootPublicKey")] public required string SignerRootPublicKey { get; init; }
|
|
[JsonPropertyName("signerDevicePublicKey")] public required string SignerDevicePublicKey { get; init; }
|
|
[JsonPropertyName("deviceCertificateSignature")] public required string DeviceCertificateSignature { get; init; }
|
|
}
|
|
|
|
public sealed record SignedContentEventProof(byte[] EventIdBytes, string EventKind, string Username, string ChannelId, CryptoDomain Domain, int Epoch,
|
|
int FrameCount, byte[] ManifestHash, string DeviceId, byte[] Signature, string? TargetItemId,
|
|
string RootPublicKey, string DevicePublicKey, byte[] DeviceCertificateSignature);
|
|
public sealed class ChannelAccess
|
|
{
|
|
[JsonPropertyName("chatFromRevision")] public long ChatFromRevision { get; set; }
|
|
[JsonPropertyName("channelId")] public required string ChannelId { get; init; }
|
|
[JsonPropertyName("filesFromRevision")] public long FilesFromRevision { get; set; }
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
[JsonPropertyName("chatRead")] public bool ChatRead { get; set; } = true;
|
|
[JsonPropertyName("chatWrite")] public bool ChatWrite { get; set; } = true;
|
|
[JsonPropertyName("filesRead")] public bool FilesRead { get; set; } = true;
|
|
[JsonPropertyName("filesUpload")] public bool FilesUpload { get; set; } = true;
|
|
}
|
|
public sealed class CryptoGrantBatch
|
|
{
|
|
[JsonPropertyName("domain")] public required CryptoDomain Domain { get; init; }
|
|
[JsonPropertyName("epoch")] public required int Epoch { get; init; }
|
|
[JsonPropertyName("recipients")] public required List<string> Recipients { get; init; }
|
|
[JsonPropertyName("rotate")] public required bool Rotate { get; init; }
|
|
}
|
|
public sealed class InvitationCryptoPlan
|
|
{
|
|
[JsonPropertyName("channelId")] public required string ChannelId { get; init; }
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
[JsonPropertyName("batches")] public required List<CryptoGrantBatch> Batches { get; init; }
|
|
}
|
|
public sealed class CryptoState
|
|
{
|
|
[JsonPropertyName("revision")] public long Revision { get; set; }
|
|
[JsonPropertyName("envelopes")] public List<DomainEnvelope> Envelopes { get; init; } = [];
|
|
[JsonPropertyName("objects")] public List<ObjectEnvelope> Objects { get; init; } = [];
|
|
[JsonPropertyName("access")] public List<ChannelAccess> Access { get; init; } = [];
|
|
}
|
|
public sealed class DomainPublishRequest
|
|
{
|
|
[JsonPropertyName("channelId")] public required string ChannelId { get; init; }
|
|
[JsonPropertyName("domain")] public required CryptoDomain Domain { get; init; }
|
|
[JsonPropertyName("epoch")] public required int Epoch { get; init; }
|
|
[JsonPropertyName("envelopes")] public required List<DomainEnvelope> Envelopes { get; init; }
|
|
}
|
|
|
|
[JsonSerializable(typeof(CryptoState))]
|
|
public sealed partial class WorkspaceCryptoJson : JsonSerializerContext;
|