summary refs log tree commit diff
path: root/ModAS.Server/AppServiceRegistration.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-12-23 08:54:55 +0100
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-12-23 08:54:55 +0100
commite051007ecdb3097bc9942fd9db369101a9568a0d (patch)
tree8227a254a69ad7227cc230127ef4052dff9a08d1 /ModAS.Server/AppServiceRegistration.cs
downloadModAS-e051007ecdb3097bc9942fd9db369101a9568a0d.tar.xz
Basic test
Diffstat (limited to 'ModAS.Server/AppServiceRegistration.cs')
-rw-r--r--ModAS.Server/AppServiceRegistration.cs60
1 files changed, 60 insertions, 0 deletions
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<string> 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<NamespaceObject> Users { get; set; } = new();
+
+        [JsonPropertyName("aliases")]
+        public List<NamespaceObject> Aliases { get; set; } = new();
+
+        [JsonPropertyName("rooms")]
+        public List<NamespaceObject> 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