157 lines
7.2 KiB
C#
157 lines
7.2 KiB
C#
using System.Text.Json.Serialization;
|
|
using WebDrop.Core;
|
|
|
|
namespace WebDrop.Api;
|
|
|
|
public sealed class ErrorBody
|
|
{
|
|
[JsonPropertyName("error")] public required string Error { get; init; }
|
|
}
|
|
|
|
public sealed class GoneLogBody
|
|
{
|
|
[JsonPropertyName("error")] public string Error { get; init; } = "gone";
|
|
[JsonPropertyName("oldest_seq")] public required long OldestSeq { get; init; }
|
|
}
|
|
|
|
public sealed class ServerInfoBody
|
|
{
|
|
[JsonPropertyName("protocol")] public int Protocol { get; init; } = 1;
|
|
[JsonPropertyName("contract_version")] public string ContractVersion { get; init; } = ApiContract.Version;
|
|
[JsonPropertyName("captcha")] public required CaptchaBody Captcha { get; init; }
|
|
[JsonPropertyName("transports")] public required TransportsBody Transports { get; init; }
|
|
[JsonPropertyName("limits")] public required LimitsBody Limits { get; init; }
|
|
}
|
|
|
|
/// <summary>告诉前端要不要出示验证码、widget 该连哪里(Cap 的 data-cap-api-endpoint)。</summary>
|
|
public sealed class CaptchaBody
|
|
{
|
|
[JsonPropertyName("provider")] public required string Provider { get; init; }
|
|
[JsonPropertyName("enabled")] public required bool Enabled { get; init; }
|
|
[JsonPropertyName("api_endpoint")] public string? ApiEndpoint { get; init; }
|
|
}
|
|
|
|
public sealed class TransportsBody
|
|
{
|
|
[JsonPropertyName("websocket")] public bool WebSocket { get; init; } = true;
|
|
[JsonPropertyName("sse")] public bool Sse { get; init; } = true;
|
|
[JsonPropertyName("http3")] public required bool Http3 { get; init; }
|
|
}
|
|
|
|
public sealed class LimitsBody
|
|
{
|
|
[JsonPropertyName("max_payload_bytes")] public required int MaxPayloadBytes { get; init; }
|
|
[JsonPropertyName("max_frames_per_item")] public required int MaxFramesPerItem { get; init; }
|
|
[JsonPropertyName("max_channel_bytes")] public required long MaxChannelBytes { get; init; }
|
|
[JsonPropertyName("max_seats")] public required int MaxSeats { get; init; }
|
|
[JsonPropertyName("max_ttl_seconds")] public required int MaxTtlSeconds { get; init; }
|
|
}
|
|
|
|
public sealed class AccountRegisterRequest
|
|
{
|
|
[JsonPropertyName("public_key")] public required string PublicKey { get; init; }
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
[JsonPropertyName("salt")] public required string Salt { get; init; }
|
|
[JsonPropertyName("verifier")] public required string Verifier { get; init; }
|
|
[JsonPropertyName("vault")] public required string Vault { get; init; }
|
|
}
|
|
public sealed class AccountSaltRequest { [JsonPropertyName("username")] public required string Username { get; init; } }
|
|
public sealed class AccountSessionRequest
|
|
{
|
|
[JsonPropertyName("device_id")] public string? DeviceId { get; init; }
|
|
[JsonPropertyName("device_name")] public string? DeviceName { get; init; }
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
[JsonPropertyName("verifier")] public required string Verifier { get; init; }
|
|
}
|
|
public sealed class AccountVaultRequest
|
|
{
|
|
[JsonPropertyName("revision")] public required long Revision { get; init; }
|
|
[JsonPropertyName("vault")] public required string Vault { get; init; }
|
|
}
|
|
public sealed class AccountSaltBody
|
|
{
|
|
[JsonPropertyName("salt")] public required string Salt { get; init; }
|
|
}
|
|
public sealed class AccountSessionBody
|
|
{
|
|
[JsonPropertyName("token")] public required string Token { get; init; }
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
}
|
|
public sealed class AccountVaultBody
|
|
{
|
|
[JsonPropertyName("revision")] public required long Revision { get; init; }
|
|
[JsonPropertyName("vault")] public required string Vault { get; init; }
|
|
}
|
|
|
|
public sealed class PublicKeyBody { [JsonPropertyName("public_key")] public required string PublicKey { get; init; } }
|
|
public sealed class InvitationRequest
|
|
{
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
[JsonPropertyName("payload")] public required string Payload { get; init; }
|
|
}
|
|
public sealed class InvitationBody
|
|
{
|
|
[JsonPropertyName("channel_id")] public required string ChannelId { get; init; }
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
[JsonPropertyName("payload")] public required string Payload { get; init; }
|
|
[JsonPropertyName("created_at")] public required long CreatedAt { get; init; }
|
|
}
|
|
public sealed class JoinRequest { [JsonPropertyName("password")] public string? Password { get; init; } }
|
|
public sealed class KeyPackageRequest { [JsonPropertyName("payload")] public required string Payload { get; init; } }
|
|
public sealed class AccountDeviceNameRequest { [JsonPropertyName("name")] public required string Name { get; init; } }
|
|
public sealed class AccountDeviceBody
|
|
{
|
|
[JsonPropertyName("id")] public required string Id { get; init; }
|
|
[JsonPropertyName("name")] public required string Name { get; init; }
|
|
[JsonPropertyName("created_at")] public required long CreatedAt { get; init; }
|
|
[JsonPropertyName("last_seen")] public required long LastSeen { get; init; }
|
|
[JsonPropertyName("current")] public required bool Current { get; init; }
|
|
}
|
|
public sealed class AccountChannelBody
|
|
{
|
|
[JsonPropertyName("channel_id")] public required string ChannelId { get; init; }
|
|
[JsonPropertyName("role")] public required string Role { get; init; }
|
|
[JsonPropertyName("payload")] public required string Payload { get; init; }
|
|
[JsonPropertyName("created_at")] public required long CreatedAt { get; init; }
|
|
}
|
|
public sealed class MemberBody
|
|
{
|
|
[JsonPropertyName("username")] public required string Username { get; init; }
|
|
[JsonPropertyName("role")] public required string Role { get; init; }
|
|
[JsonPropertyName("joined_at")] public required long JoinedAt { get; init; }
|
|
}
|
|
|
|
[JsonSerializable(typeof(ErrorBody))]
|
|
[JsonSerializable(typeof(GoneLogBody))]
|
|
[JsonSerializable(typeof(ServerInfoBody))]
|
|
[JsonSerializable(typeof(ChannelInfo))]
|
|
[JsonSerializable(typeof(ShareInfo))]
|
|
[JsonSerializable(typeof(CreateShareRequest))]
|
|
[JsonSerializable(typeof(ShareSettingsPatch))]
|
|
[JsonSerializable(typeof(FinishShareRequest))]
|
|
[JsonSerializable(typeof(CreateChannelRequest))]
|
|
[JsonSerializable(typeof(ChannelSettingsPatch))]
|
|
[JsonSerializable(typeof(SeatJoined))]
|
|
[JsonSerializable(typeof(List<SeatInfo>))]
|
|
[JsonSerializable(typeof(AppendResult))]
|
|
[JsonSerializable(typeof(SiteverifyRequest))]
|
|
[JsonSerializable(typeof(SiteverifyResponse))]
|
|
[JsonSerializable(typeof(AccountRegisterRequest))]
|
|
[JsonSerializable(typeof(AccountSaltRequest))]
|
|
[JsonSerializable(typeof(AccountSessionRequest))]
|
|
[JsonSerializable(typeof(AccountVaultRequest))]
|
|
[JsonSerializable(typeof(AccountSaltBody))]
|
|
[JsonSerializable(typeof(AccountSessionBody))]
|
|
[JsonSerializable(typeof(AccountVaultBody))]
|
|
[JsonSerializable(typeof(PublicKeyBody))]
|
|
[JsonSerializable(typeof(InvitationRequest))]
|
|
[JsonSerializable(typeof(List<InvitationBody>))]
|
|
[JsonSerializable(typeof(JoinRequest))]
|
|
[JsonSerializable(typeof(List<MemberBody>))]
|
|
[JsonSerializable(typeof(KeyPackageRequest))]
|
|
[JsonSerializable(typeof(List<AccountChannelBody>))]
|
|
[JsonSerializable(typeof(AccountDeviceNameRequest))]
|
|
[JsonSerializable(typeof(List<AccountDeviceBody>))]
|
|
[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public sealed partial class ApiJson : JsonSerializerContext;
|