tgstation-server 6.12.3
The /tg/station 13 server suite
Loading...
Searching...
No Matches
JwtSerializer.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.IdentityModel.JsonWebTokens;
4
5using StrawberryShake.Serialization;
6
7#pragma warning disable CA1812 // not detecting usage via annotation in schema.extensions.graphql
8
10{
14 sealed class JwtSerializer : ScalarSerializer<string, JsonWebToken>
15 {
20 : base("Jwt")
21 {
22 }
23
25 public override JsonWebToken Parse(string serializedValue)
26 => new(serializedValue ?? throw new ArgumentNullException(nameof(serializedValue)));
27
29 protected override string Format(JsonWebToken runtimeValue)
30 {
31 ArgumentNullException.ThrowIfNull(runtimeValue);
32 return runtimeValue.EncodedToken;
33 }
34 }
35}
ScalarSerializer<TSerialized, TRuntime> for JsonWebTokens.
override JsonWebToken Parse(string serializedValue)
override string Format(JsonWebToken runtimeValue)
JwtSerializer()
Initializes a new instance of the JwtSerializer class.