about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-06-20 21:09:39 +0200
committerRory& <root@rory.gay>2025-06-20 21:09:39 +0200
commitb7d1fb09414d1fa4127391bd95c02f9d9ca89c9f (patch)
tree5b7e5d0b0e4715ab606d227a53c5ccfcd42d61cd
parentBasic federation, move some response classes to the right namespace (diff)
downloadLibMatrix-b7d1fb09414d1fa4127391bd95c02f9d9ca89c9f.tar.xz
X-Matrix fixes
-rw-r--r--LibMatrix.Federation/AuthenticatedFederationClient.cs6
-rw-r--r--LibMatrix.Federation/XMatrixAuthorizationScheme.cs23
2 files changed, 26 insertions, 3 deletions
diff --git a/LibMatrix.Federation/AuthenticatedFederationClient.cs b/LibMatrix.Federation/AuthenticatedFederationClient.cs

index b66d2cb..6f8d44b 100644 --- a/LibMatrix.Federation/AuthenticatedFederationClient.cs +++ b/LibMatrix.Federation/AuthenticatedFederationClient.cs
@@ -3,6 +3,7 @@ namespace LibMatrix.Federation; public class AuthenticatedFederationClient : FederationClient { + public class AuthenticatedFederationConfiguration { } @@ -11,4 +12,9 @@ public class AuthenticatedFederationClient : FederationClient { } + // public async Task<UserDeviceListResponse> GetUserDevicesAsync(string userId) { + // var response = await GetAsync<UserDeviceListResponse>($"/_matrix/federation/v1/user/devices/{userId}", accessToken); + // return response; + // } + } \ No newline at end of file diff --git a/LibMatrix.Federation/XMatrixAuthorizationScheme.cs b/LibMatrix.Federation/XMatrixAuthorizationScheme.cs
index 5025434..fc402b7 100644 --- a/LibMatrix.Federation/XMatrixAuthorizationScheme.cs +++ b/LibMatrix.Federation/XMatrixAuthorizationScheme.cs
@@ -1,5 +1,6 @@ using System.Net; using System.Net.Http.Headers; +using System.Text.Json.Nodes; using System.Text.Json.Serialization; using ArcaneLibs.Extensions; using Microsoft.Extensions.Primitives; @@ -28,7 +29,7 @@ public class XMatrixAuthorizationScheme { Error = $"Expected authentication scheme of {Scheme}, got {header.Scheme}", ErrorCode = MatrixException.ErrorCodes.M_UNAUTHORIZED }; - + if (string.IsNullOrWhiteSpace(header.Parameter)) throw new LibMatrixException() { Error = $"Expected authentication header to have a value.", @@ -36,8 +37,7 @@ public class XMatrixAuthorizationScheme { }; var headerValues = new StringValues(header.Parameter); - foreach (var value in headerValues) - { + foreach (var value in headerValues) { Console.WriteLine(headerValues.ToJson()); } @@ -51,4 +51,21 @@ public class XMatrixAuthorizationScheme { public string ToHeaderValue() => $"{Scheme} origin=\"{Origin}\", destination=\"{Destination}\", key=\"{Key}\", sig=\"{Signature}\""; } + + public class XMatrixRequestSignature { + [JsonPropertyName("method")] + public required string Method { get; set; } + + [JsonPropertyName("uri")] + public required string Uri { get; set; } + + [JsonPropertyName("origin")] + public required string OriginServerName { get; set; } + + [JsonPropertyName("destination")] + public required string DestinationServerName { get; set; } + + [JsonPropertyName("content"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public JsonObject? Content { get; set; } + } } \ No newline at end of file