From e051007ecdb3097bc9942fd9db369101a9568a0d Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 23 Dec 2023 08:54:55 +0100 Subject: Basic test --- ModAS.Server/AppServiceRegistration.cs | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 ModAS.Server/AppServiceRegistration.cs (limited to 'ModAS.Server/AppServiceRegistration.cs') diff --git a/ModAS.Server/AppServiceRegistration.cs b/ModAS.Server/AppServiceRegistration.cs new file mode 100644 index 0000000..fbf323a --- /dev/null +++ b/ModAS.Server/AppServiceRegistration.cs @@ -0,0 +1,60 @@ +using System.Collections.Frozen; +using System.Collections.ObjectModel; +using System.Security.Cryptography; +using System.Text.Json.Serialization; + +namespace ModAS.Server; + +public class AppServiceRegistration { + private const string ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~+/"; + private const string ExtendedValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~+/"; + + [JsonPropertyName("as_token")] + public string AsToken { get; set; } = RandomNumberGenerator.GetString(ExtendedValidChars, RandomNumberGenerator.GetInt32(512, 1024)); + + [JsonPropertyName("hs_token")] + public string HsToken { get; set; } = RandomNumberGenerator.GetString(ExtendedValidChars, RandomNumberGenerator.GetInt32(512, 1024)); + + [JsonPropertyName("id")] + public string Id { get; set; } = "ModAS-"+RandomNumberGenerator.GetString(ValidChars, 5); + + [JsonPropertyName("namespaces")] + public NamespacesObject Namespaces { get; set; } = new() { + Users = [new() { Exclusive = false, Regex = "@.*" }], + Aliases = [new() { Exclusive = false, Regex = "#.*" }], + Rooms = [new() { Exclusive = false, Regex = "!.*" }] + }; + + [JsonPropertyName("protocols")] + public Collection Protocols { get; set; } = new(new[] { + "ModAS" + }); + + [JsonPropertyName("rate_limited")] + public bool RateLimited { get; set; } = false; + + [JsonPropertyName("sender_localpart")] + public string SenderLocalpart { get; set; } = "ModAS"; + + [JsonPropertyName("url")] + public string Url { get; set; } = "http://localhost:5071"; + + public class NamespacesObject { + [JsonPropertyName("users")] + public List Users { get; set; } = new(); + + [JsonPropertyName("aliases")] + public List Aliases { get; set; } = new(); + + [JsonPropertyName("rooms")] + public List Rooms { get; set; } = new(); + } + + public class NamespaceObject { + [JsonPropertyName("exclusive")] + public bool Exclusive { get; set; } = false; + + [JsonPropertyName("regex")] + public string Regex { get; set; } = "*"; + } +} \ No newline at end of file -- cgit 1.5.1