A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
added JWT decoder tools (#36)
BenjaminT4ffbb329bd73
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.mdindex 399b42cf5..3f23de20e 100644--- a/THIRD-PARTY-NOTICES.md+++ b/THIRD-PARTY-NOTICES.md@@ -11,6 +11,7 @@ This project incorporates components from the projects listed below. The origina9. Monaco Editor (https://github.com/Microsoft/monaco-editor)10. Monaco Editor UWP (https://github.com/hawkerm/monaco-editor-uwp)11. Observable Vector (https://github.com/jamesqo/observable-vector)+12. Azure Active Directory IdentityModel Extensions for .NET (https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet)Newtonsoft.Json NOTICES AND INFORMATION BEGIN HERE=========================================@@ -183,6 +184,30 @@ furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.++Azure Active Directory IdentityModel Extensions for .NET+=========================================+The MIT License (MIT)++Copyright (c) Microsoft Corporation++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEdiff --git a/src/Directory.Build.props b/src/Directory.Build.propsindex 05cb25b19..55ab9db91 100644--- a/src/Directory.Build.props+++ b/src/Directory.Build.props@@ -37,5 +37,6 @@<NuGet_SystemComposition>5.0.0</NuGet_SystemComposition><NuGet_Win2D>1.26.0</NuGet_Win2D><NuGet_YamlDotNet>11.2.1</NuGet_YamlDotNet>+ <NuGet_IdentityModelTokenJwt>6.13.1</NuGet_IdentityModelTokenJwt></PropertyGroup></Project>\ No newline at end of filediff --git a/src/dev/impl/DevToys/DevToys.csproj b/src/dev/impl/DevToys/DevToys.csprojindex f49f90b9b..109bf245a 100644--- a/src/dev/impl/DevToys/DevToys.csproj+++ b/src/dev/impl/DevToys/DevToys.csproj@@ -193,6 +193,7 @@<Compile Include="Core\Threading\ThreadPriority.cs" /><Compile Include="Core\TitleBar.cs" /><Compile Include="Core\ToolProviderFactory.cs" />+ <Compile Include="Helpers\JwtHelper.cs" /><Compile Include="Models\IndentationDisplayPair.cs" /><Compile Include="Models\Indentation.cs" /><Compile Include="UI\Controls\CodeEditor.xaml.cs">@@ -206,6 +207,8 @@<Compile Include="Helpers\YamlHelper.cs" /><Compile Include="ViewModels\Tools\JsonYaml\JsonYamlToolProvider.cs" /><Compile Include="ViewModels\Tools\JsonYaml\JsonYamlToolViewModel.cs" />+ <Compile Include="ViewModels\Tools\JwtDecoderEncoder\JwtDecoderEncoderToolProvider.cs" />+ <Compile Include="ViewModels\Tools\JwtDecoderEncoder\JwtDecoderEncoderToolViewModel.cs" /><Compile Include="ViewModels\Tools\ToolProviderBase.cs" /><Compile Include="Core\UriActivationProtocolService.cs" /><Compile Include="LanguageDefinition.cs" />@@ -274,6 +277,9 @@<Compile Include="Views\Tools\JsonFormatter\JsonFormatterToolPage.xaml.cs"><DependentUpon>JsonFormatterToolPage.xaml</DependentUpon></Compile>+ <Compile Include="Views\Tools\JwtDecoderEncoder\JwtDecoderEncoderToolPage.xaml.cs">+ <DependentUpon>JwtDecoderEncoderToolPage.xaml</DependentUpon>+ </Compile><Compile Include="Views\Tools\RegEx\RegExToolPage.xaml.cs"><DependentUpon>RegExToolPage.xaml</DependentUpon></Compile>@@ -362,6 +368,10 @@<Generator>MSBuild:Compile</Generator><SubType>Designer</SubType></Page>+ <Page Include="Views\Tools\JwtDecoderEncoder\JwtDecoderEncoderToolPage.xaml">+ <Generator>MSBuild:Compile</Generator>+ <SubType>Designer</SubType>+ </Page><Page Include="Views\Tools\RegEx\RegExToolPage.xaml"><Generator>MSBuild:Compile</Generator><SubType>Designer</SubType>@@ -389,6 +399,7 @@<PackageReference Include="Microsoft.UI.Xaml" Version="$(NuGet_MicrosoftUIXaml)" /><PackageReference Include="Newtonsoft.Json" Version="$(NuGet_NewtonsoftJson)" /><PackageReference Include="System.Composition" Version="$(NuGet_SystemComposition)" />+ <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="$(NuGet_IdentityModelTokenJwt)" /><PackageReference Include="YamlDotNet" Version="$(NuGet_YamlDotNet)" /><PackageReference Include="Win2D.uwp" Version="$(Nuget_Win2D)" /></ItemGroup>diff --git a/src/dev/impl/DevToys/Helpers/JwtHelper.cs b/src/dev/impl/DevToys/Helpers/JwtHelper.csnew file mode 100644index 000000000..562035224--- /dev/null+++ b/src/dev/impl/DevToys/Helpers/JwtHelper.cs@@ -0,0 +1,34 @@+#nullable enable++using System;+using System.IdentityModel.Tokens.Jwt;++namespace DevToys.Helpers+{+ internal static class JwtHelper+ {+ /// <summary>+ /// Detects whether the given string is a JWT Token or not.+ /// </summary>+ internal static bool IsValid(string? input)+ {+ if (string.IsNullOrWhiteSpace(input))+ {+ return false;+ }++ input = input!.Trim();++ try+ {+ JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();+ JwtSecurityToken jwtSecurityToken = handler.ReadJwtToken(input);+ return jwtSecurityToken is not null;+ }+ catch (Exception) //some other exception+ {+ return false;+ }+ }+ }+}diff --git a/src/dev/impl/DevToys/LanguageManager.cs b/src/dev/impl/DevToys/LanguageManager.csindex 31733cbf6..eb274eb74 100644--- a/src/dev/impl/DevToys/LanguageManager.cs+++ b/src/dev/impl/DevToys/LanguageManager.cs@@ -29,6 +29,7 @@ namespace DevToysprivate readonly HashGeneratorStrings _hashgenerator = new HashGeneratorStrings();private readonly JsonFormatterStrings _jsonformatter = new JsonFormatterStrings();private readonly JsonYamlStrings _jsonyaml = new JsonYamlStrings();+ private readonly JwtDecoderEncoderStrings _jwtdecoderencoder = new JwtDecoderEncoderStrings();private readonly MainPageStrings _mainpage = new MainPageStrings();private readonly RegExStrings _regex = new RegExStrings();private readonly SettingsStrings _settings = new SettingsStrings();@@ -69,6 +70,11 @@ namespace DevToys/// </summary>public JsonYamlStrings JsonYaml => _jsonyaml;+ /// <summary>+ /// Gets the <see cref="JwtDecoderEncoderStrings"/>.+ /// </summary>+ public JwtDecoderEncoderStrings JwtDecoderEncoder => _jwtdecoderencoder;+/// <summary>/// Gets the <see cref="MainPageStrings"/>./// </summary>@@ -437,6 +443,71 @@ namespace DevToyspublic string YamlToJson => _resources.GetString("YamlToJson");}+ public class JwtDecoderEncoderStrings : ObservableObject+ {+ private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("JwtDecoderEncoder");++ /// <summary>+ /// Gets the resource Configuration.+ /// </summary>+ public string Configuration => _resources.GetString("Configuration");++ /// <summary>+ /// Gets the resource ConversionDescription.+ /// </summary>+ public string ConversionDescription => _resources.GetString("ConversionDescription");++ /// <summary>+ /// Gets the resource ConversionTitle.+ /// </summary>+ public string ConversionTitle => _resources.GetString("ConversionTitle");++ /// <summary>+ /// Gets the resource Decode.+ /// </summary>+ public string Decode => _resources.GetString("Decode");++ /// <summary>+ /// Gets the resource DisplayName.+ /// </summary>+ public string DisplayName => _resources.GetString("DisplayName");++ /// <summary>+ /// Gets the resource Encode.+ /// </summary>+ public string Encode => _resources.GetString("Encode");++ /// <summary>+ /// Gets the resource EncodingDescription.+ /// </summary>+ public string EncodingDescription => _resources.GetString("EncodingDescription");++ /// <summary>+ /// Gets the resource EncodingTitle.+ /// </summary>+ public string EncodingTitle => _resources.GetString("EncodingTitle");++ /// <summary>+ /// Gets the resource HeaderLabel.+ /// </summary>+ public string HeaderLabel => _resources.GetString("HeaderLabel");++ /// <summary>+ /// Gets the resource JwtTokenLabel.+ /// </summary>+ public string JwtTokenLabel => _resources.GetString("JwtTokenLabel");++ /// <summary>+ /// Gets the resource PayloadLabel.+ /// </summary>+ public string PayloadLabel => _resources.GetString("PayloadLabel");++ /// <summary>+ /// Gets the resource SecurityLabel.+ /// </summary>+ public string SecurityLabel => _resources.GetString("SecurityLabel");+ }+public class MainPageStrings : ObservableObject{private readonly ResourceLoader _resources = ResourceLoader.GetForViewIndependentUse("MainPage");diff --git a/src/dev/impl/DevToys/Properties/Default.rd.rd.xml b/src/dev/impl/DevToys/Properties/Default.rd.rd.xmlindex a4c980736..23e4aa1d6 100644--- a/src/dev/impl/DevToys/Properties/Default.rd.rd.xml+++ b/src/dev/impl/DevToys/Properties/Default.rd.rd.xml@@ -23,6 +23,7 @@--><Namespace Name="Microsoft.Toolkit.Mvvm" Dynamic="Required All" /><Namespace Name="DevToys" Dynamic="Required All" />+ <Namespace Name="System.IdentityModel.Tokens.Jwt" Dynamic="Required All"/><!-- Add your application specific runtime directives here. --></Application>diff --git a/src/dev/impl/DevToys/Strings/en/JwtDecoderEncoder.resw b/src/dev/impl/DevToys/Strings/en/JwtDecoderEncoder.reswnew file mode 100644index 000000000..43b3bc866--- /dev/null+++ b/src/dev/impl/DevToys/Strings/en/JwtDecoderEncoder.resw@@ -0,0 +1,156 @@+<?xml version="1.0" encoding="utf-8"?>+<root>+ <!--+ Microsoft ResX Schema++ Version 2.0++ The primary goals of this format is to allow a simple XML format+ that is mostly human readable. The generation and parsing of the+ various data types are done through the TypeConverter classes+ associated with the data types.++ Example:++ ... ado.net/XML headers & schema ...+ <resheader name="resmimetype">text/microsoft-resx</resheader>+ <resheader name="version">2.0</resheader>+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">+ <value>[base64 mime encoded serialized .NET Framework object]</value>+ </data>+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>+ <comment>This is a comment</comment>+ </data>++ There are any number of "resheader" rows that contain simple+ name/value pairs.++ Each data row contains a name, and value. The row also contains a+ type or mimetype. Type corresponds to a .NET class that support+ text/value conversion through the TypeConverter architecture.+ Classes that don't support this are serialized and stored with the+ mimetype set.++ The mimetype is used for serialized objects, and tells the+ ResXResourceReader how to depersist the object. This is currently not+ extensible. For a given mimetype the value must be set accordingly:++ Note - application/x-microsoft.net.object.binary.base64 is the format+ that the ResXResourceWriter will generate, however the reader can+ read any of the formats listed below.++ mimetype: application/x-microsoft.net.object.binary.base64+ value : The object must be serialized with+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter+ : and then encoded with base64 encoding.++ mimetype: application/x-microsoft.net.object.soap.base64+ value : The object must be serialized with+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter+ : and then encoded with base64 encoding.++ mimetype: application/x-microsoft.net.object.bytearray.base64+ value : The object must be serialized into a byte array+ : using a System.ComponentModel.TypeConverter+ : and then encoded with base64 encoding.+ -->+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />+ <xsd:element name="root" msdata:IsDataSet="true">+ <xsd:complexType>+ <xsd:choice maxOccurs="unbounded">+ <xsd:element name="metadata">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" />+ </xsd:sequence>+ <xsd:attribute name="name" use="required" type="xsd:string" />+ <xsd:attribute name="type" type="xsd:string" />+ <xsd:attribute name="mimetype" type="xsd:string" />+ <xsd:attribute ref="xml:space" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="assembly">+ <xsd:complexType>+ <xsd:attribute name="alias" type="xsd:string" />+ <xsd:attribute name="name" type="xsd:string" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="data">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />+ </xsd:sequence>+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />+ <xsd:attribute ref="xml:space" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="resheader">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />+ </xsd:sequence>+ <xsd:attribute name="name" type="xsd:string" use="required" />+ </xsd:complexType>+ </xsd:element>+ </xsd:choice>+ </xsd:complexType>+ </xsd:element>+ </xsd:schema>+ <resheader name="resmimetype">+ <value>text/microsoft-resx</value>+ </resheader>+ <resheader name="version">+ <value>2.0</value>+ </resheader>+ <resheader name="reader">+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>+ </resheader>+ <resheader name="writer">+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>+ </resheader>+ <data name="Configuration" xml:space="preserve">+ <value>Configuration</value>+ </data>+ <data name="ConversionDescription" xml:space="preserve">+ <value>Select which action you want to use</value>+ </data>+ <data name="ConversionTitle" xml:space="preserve">+ <value>Action</value>+ </data>+ <data name="Decode" xml:space="preserve">+ <value>Decode</value>+ </data>+ <data name="DisplayName" xml:space="preserve">+ <value>JWT Decoder</value>+ </data>+ <data name="Encode" xml:space="preserve">+ <value>Encode</value>+ </data>+ <data name="EncodingDescription" xml:space="preserve">+ <value>Select which encoding algorithm you want to use</value>+ </data>+ <data name="EncodingTitle" xml:space="preserve">+ <value>Encoding</value>+ </data>+ <data name="HeaderLabel" xml:space="preserve">+ <value>Header</value>+ </data>+ <data name="JwtTokenLabel" xml:space="preserve">+ <value>Jwt Token</value>+ </data>+ <data name="PayloadLabel" xml:space="preserve">+ <value>Payload</value>+ </data>+ <data name="SecurityLabel" xml:space="preserve">+ <value>Security</value>+ </data>+</root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/fr/JwtDecoderEncoder.resw b/src/dev/impl/DevToys/Strings/fr/JwtDecoderEncoder.reswnew file mode 100644index 000000000..a77dfe9c8--- /dev/null+++ b/src/dev/impl/DevToys/Strings/fr/JwtDecoderEncoder.resw@@ -0,0 +1,156 @@+<?xml version="1.0" encoding="utf-8"?>+<root>+ <!--+ Microsoft ResX Schema++ Version 2.0++ The primary goals of this format is to allow a simple XML format+ that is mostly human readable. The generation and parsing of the+ various data types are done through the TypeConverter classes+ associated with the data types.++ Example:++ ... ado.net/XML headers & schema ...+ <resheader name="resmimetype">text/microsoft-resx</resheader>+ <resheader name="version">2.0</resheader>+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">+ <value>[base64 mime encoded serialized .NET Framework object]</value>+ </data>+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>+ <comment>This is a comment</comment>+ </data>++ There are any number of "resheader" rows that contain simple+ name/value pairs.++ Each data row contains a name, and value. The row also contains a+ type or mimetype. Type corresponds to a .NET class that support+ text/value conversion through the TypeConverter architecture.+ Classes that don't support this are serialized and stored with the+ mimetype set.++ The mimetype is used for serialized objects, and tells the+ ResXResourceReader how to depersist the object. This is currently not+ extensible. For a given mimetype the value must be set accordingly:++ Note - application/x-microsoft.net.object.binary.base64 is the format+ that the ResXResourceWriter will generate, however the reader can+ read any of the formats listed below.++ mimetype: application/x-microsoft.net.object.binary.base64+ value : The object must be serialized with+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter+ : and then encoded with base64 encoding.++ mimetype: application/x-microsoft.net.object.soap.base64+ value : The object must be serialized with+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter+ : and then encoded with base64 encoding.++ mimetype: application/x-microsoft.net.object.bytearray.base64+ value : The object must be serialized into a byte array+ : using a System.ComponentModel.TypeConverter+ : and then encoded with base64 encoding.+ -->+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />+ <xsd:element name="root" msdata:IsDataSet="true">+ <xsd:complexType>+ <xsd:choice maxOccurs="unbounded">+ <xsd:element name="metadata">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" />+ </xsd:sequence>+ <xsd:attribute name="name" use="required" type="xsd:string" />+ <xsd:attribute name="type" type="xsd:string" />+ <xsd:attribute name="mimetype" type="xsd:string" />+ <xsd:attribute ref="xml:space" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="assembly">+ <xsd:complexType>+ <xsd:attribute name="alias" type="xsd:string" />+ <xsd:attribute name="name" type="xsd:string" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="data">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />+ </xsd:sequence>+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />+ <xsd:attribute ref="xml:space" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="resheader">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />+ </xsd:sequence>+ <xsd:attribute name="name" type="xsd:string" use="required" />+ </xsd:complexType>+ </xsd:element>+ </xsd:choice>+ </xsd:complexType>+ </xsd:element>+ </xsd:schema>+ <resheader name="resmimetype">+ <value>text/microsoft-resx</value>+ </resheader>+ <resheader name="version">+ <value>2.0</value>+ </resheader>+ <resheader name="reader">+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>+ </resheader>+ <resheader name="writer">+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>+ </resheader>+ <data name="Configuration" xml:space="preserve">+ <value>Configuration</value>+ </data>+ <data name="ConversionDescription" xml:space="preserve">+ <value>Sélectionnez l'action que vous souhaitez utiliser</value>+ </data>+ <data name="ConversionTitle" xml:space="preserve">+ <value>Action</value>+ </data>+ <data name="Decode" xml:space="preserve">+ <value>Decoder</value>+ </data>+ <data name="DisplayName" xml:space="preserve">+ <value>Décodeur JWT</value>+ </data>+ <data name="Encode" xml:space="preserve">+ <value>Encoder</value>+ </data>+ <data name="EncodingDescription" xml:space="preserve">+ <value>Sélectionnez l'algorithme d'encodage que vous souhaitez utiliser.</value>+ </data>+ <data name="EncodingTitle" xml:space="preserve">+ <value>Encodage</value>+ </data>+ <data name="HeaderLabel" xml:space="preserve">+ <value>En-tête</value>+ </data>+ <data name="JwtTokenLabel" xml:space="preserve">+ <value>Jeton JWT</value>+ </data>+ <data name="PayloadLabel" xml:space="preserve">+ <value>Charge utile</value>+ </data>+ <data name="SecurityLabel" xml:space="preserve">+ <value>Sécurité</value>+ </data>+</root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/ru/JwtDecoderEncoder.resw b/src/dev/impl/DevToys/Strings/ru/JwtDecoderEncoder.reswnew file mode 100644index 000000000..e81fb5675--- /dev/null+++ b/src/dev/impl/DevToys/Strings/ru/JwtDecoderEncoder.resw@@ -0,0 +1,156 @@+<?xml version="1.0" encoding="utf-8"?>+<root>+ <!--+ Microsoft ResX Schema++ Version 2.0++ The primary goals of this format is to allow a simple XML format+ that is mostly human readable. The generation and parsing of the+ various data types are done through the TypeConverter classes+ associated with the data types.++ Example:++ ... ado.net/XML headers & schema ...+ <resheader name="resmimetype">text/microsoft-resx</resheader>+ <resheader name="version">2.0</resheader>+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">+ <value>[base64 mime encoded serialized .NET Framework object]</value>+ </data>+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>+ <comment>This is a comment</comment>+ </data>++ There are any number of "resheader" rows that contain simple+ name/value pairs.++ Each data row contains a name, and value. The row also contains a+ type or mimetype. Type corresponds to a .NET class that support+ text/value conversion through the TypeConverter architecture.+ Classes that don't support this are serialized and stored with the+ mimetype set.++ The mimetype is used for serialized objects, and tells the+ ResXResourceReader how to depersist the object. This is currently not+ extensible. For a given mimetype the value must be set accordingly:++ Note - application/x-microsoft.net.object.binary.base64 is the format+ that the ResXResourceWriter will generate, however the reader can+ read any of the formats listed below.++ mimetype: application/x-microsoft.net.object.binary.base64+ value : The object must be serialized with+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter+ : and then encoded with base64 encoding.++ mimetype: application/x-microsoft.net.object.soap.base64+ value : The object must be serialized with+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter+ : and then encoded with base64 encoding.++ mimetype: application/x-microsoft.net.object.bytearray.base64+ value : The object must be serialized into a byte array+ : using a System.ComponentModel.TypeConverter+ : and then encoded with base64 encoding.+ -->+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />+ <xsd:element name="root" msdata:IsDataSet="true">+ <xsd:complexType>+ <xsd:choice maxOccurs="unbounded">+ <xsd:element name="metadata">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" />+ </xsd:sequence>+ <xsd:attribute name="name" use="required" type="xsd:string" />+ <xsd:attribute name="type" type="xsd:string" />+ <xsd:attribute name="mimetype" type="xsd:string" />+ <xsd:attribute ref="xml:space" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="assembly">+ <xsd:complexType>+ <xsd:attribute name="alias" type="xsd:string" />+ <xsd:attribute name="name" type="xsd:string" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="data">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />+ </xsd:sequence>+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />+ <xsd:attribute ref="xml:space" />+ </xsd:complexType>+ </xsd:element>+ <xsd:element name="resheader">+ <xsd:complexType>+ <xsd:sequence>+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />+ </xsd:sequence>+ <xsd:attribute name="name" type="xsd:string" use="required" />+ </xsd:complexType>+ </xsd:element>+ </xsd:choice>+ </xsd:complexType>+ </xsd:element>+ </xsd:schema>+ <resheader name="resmimetype">+ <value>text/microsoft-resx</value>+ </resheader>+ <resheader name="version">+ <value>2.0</value>+ </resheader>+ <resheader name="reader">+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>+ </resheader>+ <resheader name="writer">+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>+ </resheader>+ <data name="Configuration" xml:space="preserve">+ <value>Configuration</value>+ </data>+ <data name="ConversionDescription" xml:space="preserve">+ <value>Select which action you want to use</value>+ </data>+ <data name="ConversionTitle" xml:space="preserve">+ <value>Action</value>+ </data>+ <data name="Decode" xml:space="preserve">+ <value>Decode</value>+ </data>+ <data name="DisplayName" xml:space="preserve">+ <value>JWT Debugger</value>+ </data>+ <data name="Encode" xml:space="preserve">+ <value>Encode</value>+ </data>+ <data name="EncodingDescription" xml:space="preserve">+ <value>Select which encoding algorithm you want to use</value>+ </data>+ <data name="EncodingTitle" xml:space="preserve">+ <value>Encoding</value>+ </data>+ <data name="HeaderLabel" xml:space="preserve">+ <value>Header</value>+ </data>+ <data name="JwtTokenLabel" xml:space="preserve">+ <value>Jwt Token</value>+ </data>+ <data name="PayloadLabel" xml:space="preserve">+ <value>Payload</value>+ </data>+ <data name="SecurityLabel" xml:space="preserve">+ <value>Security</value>+ </data>+</root>\ No newline at end of filediff --git a/src/dev/impl/DevToys/Strings/ru/Settings.resw b/src/dev/impl/DevToys/Strings/ru/Settings.reswindex 859939f83..2bfbe29f6 100644--- a/src/dev/impl/DevToys/Strings/ru/Settings.resw+++ b/src/dev/impl/DevToys/Strings/ru/Settings.resw@@ -195,6 +195,12 @@<data name="SmartDetectionDescription" xml:space="preserve"><value>Автоматическое определение инструмента на основе содержимого буфера обмена</value></data>+ <data name="SmartDetectionHowTo" xml:space="preserve">+ <value>How to use Smart Detection</value>+ </data>+ <data name="SmartDetectionPaste" xml:space="preserve">+ <value>Automatically paste the clipboard content when selecting a recommended tool</value>+ </data><data name="SourceCode" xml:space="preserve"><value>Исходный код</value></data>diff --git a/src/dev/impl/DevToys/Themes/Custom.xaml b/src/dev/impl/DevToys/Themes/Custom.xamlindex 896d968f1..f8779dc67 100644--- a/src/dev/impl/DevToys/Themes/Custom.xaml+++ b/src/dev/impl/DevToys/Themes/Custom.xaml@@ -13,6 +13,7 @@<x:String x:Key="TextDiffToolProvider">M 6 3 L 6 29 L 13 29 L 13 27 L 8 27 L 8 5 L 13 5 L 13 3 L 6 3 z M 15 3 L 15 5 L 17 5 L 17 3 L 15 3 z M 19 3 L 19 5 L 24 5 L 24 27 L 19 27 L 19 29 L 26 29 L 26 3 L 19 3 z M 15 7 L 15 9 L 17 9 L 17 7 L 15 7 z M 15 11 L 15 13 L 17 13 L 17 11 L 15 11 z M 15 15 L 15 17 L 17 17 L 17 15 L 15 15 z M 15 19 L 15 21 L 17 21 L 17 19 L 15 19 z M 15 23 L 15 25 L 17 25 L 17 23 L 15 23 z M 15 27 L 15 29 L 17 29 L 17 27 L 15 27 z</x:String><x:String x:Key="RegExToolProvider">M1.62 10a13.63 13.63 0 0 0 .45 3.51A13.39 13.39 0 0 0 3.4 16.7a.91.91 0 0 1 .1.27.41.41 0 0 1 0 .21.38.38 0 0 1-.1.15l-.14.11-.83.5a14.89 14.89 0 0 1-1.11-2 13.62 13.62 0 0 1-.74-2 13.22 13.22 0 0 1-.42-2 16.4 16.4 0 0 1 0-4.14 13.22 13.22 0 0 1 .42-2 13.84 13.84 0 0 1 .74-2A14.94 14.94 0 0 1 2.4 2l.83.51.14.11a.4.4 0 0 1 .1.15.41.41 0 0 1 0 .21.93.93 0 0 1-.1.27A13.6 13.6 0 0 0 1.62 10zM5 13.51a1.53 1.53 0 0 1 .11-.59 1.5 1.5 0 0 1 .31-.48 1.5 1.5 0 0 1 1.65-.32 1.51 1.51 0 0 1 .8.8 1.47 1.47 0 0 1 .12.59 1.46 1.46 0 0 1-.12.59 1.56 1.56 0 0 1-.32.48 1.46 1.46 0 0 1-.48.32 1.57 1.57 0 0 1-1.18 0 1.4 1.4 0 0 1-.47-.32A1.5 1.5 0 0 1 5 13.51zm10.8-4.72l-.54.94-1.75-1-.34-.23a1.38 1.38 0 0 1-.27-.26A1.84 1.84 0 0 1 13 9v2h-1V9a2.16 2.16 0 0 1 .12-.76 1.82 1.82 0 0 1-.58.48l-1.74 1-.54-.94 1.73-1a2.25 2.25 0 0 1 .75-.29 1.77 1.77 0 0 1-.75-.28L9.2 6.2l.54-.94 1.75 1 .33.24a1.64 1.64 0 0 1 .27.27A2 2 0 0 1 12 6V4h1v2a2.93 2.93 0 0 1 0 .4 1.36 1.36 0 0 1-.1.36 2.24 2.24 0 0 1 .59-.49l1.74-1 .54.94-1.73 1-.36.18a1.29 1.29 0 0 1-.36.1 2.11 2.11 0 0 1 .36.1 2 2 0 0 1 .36.19zM18.37 10a13.65 13.65 0 0 0-.45-3.51 13.81 13.81 0 0 0-1.32-3.27.93.93 0 0 1-.1-.27.45.45 0 0 1 0-.21.36.36 0 0 1 .1-.15l.14-.11.86-.48a15.54 15.54 0 0 1 1.1 2 13.79 13.79 0 0 1 .74 2 13.18 13.18 0 0 1 .42 2 16.16 16.16 0 0 1 .14 2 16.21 16.21 0 0 1-.13 2 13.18 13.18 0 0 1-.42 2 13.57 13.57 0 0 1-.74 2 15.49 15.49 0 0 1-1.1 2l-.84-.5-.14-.11a.35.35 0 0 1-.1-.15.44.44 0 0 1 0-.21.91.91 0 0 1 .1-.27 13.62 13.62 0 0 0 1.31-3.23 13.69 13.69 0 0 0 .43-3.53z</x:String><x:String x:Key="JsonYamlToolProvider">M 5 5 L 5 7 L 25 7 L 25 18.585938 L 23.707031 17.292969 L 22.292969 18.707031 L 26 22.414062 L 29.707031 18.707031 L 28.292969 17.292969 L 27 18.585938 L 27 5 L 5 5 z M 6 9.5859375 L 2.2929688 13.292969 L 3.7070312 14.707031 L 5 13.414062 L 5 27 L 27 27 L 27 25 L 7 25 L 7 13.414062 L 8.2929688 14.707031 L 9.7070312 13.292969 L 6 9.5859375 z M 11 11 L 11 13 L 21 13 L 21 11 L 11 11 z M 11 15 L 11 17 L 21 17 L 21 15 L 11 15 z M 11 19 L 11 21 L 18 21 L 18 19 L 11 19 z</x:String>+ <x:String x:Key="JwtDecoderEncoderToolProvider">M 16.996 26.797 L 19.597 24.073 L 22.197 26.797 L 22.197 38.025 L 16.996 38.025 Z M 12.827 24.083 L 16.532 23.408 L 17.035 27.14 L 10.435 36.224 L 6.228 33.166 Z M 11.052 19.434 L 14.445 21.066 L 12.659 24.381 L 1.98 27.85 L 0.373 22.904 Z M 12.346 14.632 L 14.132 17.947 L 10.739 19.579 L 0.06 16.109 L 1.667 11.162 Z M 16.216 11.507 L 15.713 15.239 L 12.008 14.564 L 5.408 5.48 L 9.616 2.423 Z M 21.184 11.253 L 18.583 13.977 L 15.983 11.253 L 15.983 0.025 L 21.184 0.025 Z M 25.352 13.968 L 21.648 14.643 L 21.145 10.911 L 27.744 1.827 L 31.952 4.884 Z M 27.129 18.615 L 23.735 16.983 L 25.521 13.668 L 36.2 10.199 L 37.807 15.145 Z M 25.834 23.418 L 24.048 20.103 L 27.441 18.472 L 38.12 21.941 L 36.513 26.888 Z M 21.964 26.543 L 22.468 22.811 L 26.172 23.486 L 32.772 32.57 L 28.564 35.627 Z</x:String><!-- From https://github.com/morning4coffe-dev/storylines --><Style x:Key="RightAlignedToggleSwitchStyle" TargetType="ToggleSwitch">diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolViewModel.csindex 3a6f06d94..e5d40771f 100644--- a/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolViewModel.cs+++ b/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolViewModel.cs@@ -24,7 +24,7 @@ namespace DevToys.ViewModels.Tools.JsonFormatter/// </summary>private static readonly SettingDefinition<Indentation> Indentation= new(- name: $"{nameof(JsonFormatter.JsonFormatterToolViewModel)}.{nameof(Indentation)}",+ name: $"{nameof(JsonFormatterToolViewModel)}.{nameof(Indentation)}",isRoaming: true,defaultValue: Models.Indentation.TwoSpaces);@@ -47,11 +47,11 @@ namespace DevToys.ViewModels.Tools.JsonFormatter{Indentation settingsValue = SettingsProvider.GetSetting(Indentation);var indentation = Indentations.FirstOrDefault(x => x.Value == settingsValue);- return indentation ?? Models.IndentationDisplayPair.TwoSpaces;+ return indentation ?? IndentationDisplayPair.TwoSpaces;}set{- if (!IndentationMode.Equals(value))+ if (IndentationMode != value){SettingsProvider.SetSetting(Indentation, value.Value);OnPropertyChanged();diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolProvider.csnew file mode 100644index 000000000..ee477c950--- /dev/null+++ b/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolProvider.cs@@ -0,0 +1,39 @@+#nullable enable++using DevToys.Api.Core.Injection;+using DevToys.Api.Tools;+using DevToys.Helpers;+using System.Composition;++namespace DevToys.ViewModels.Tools.JwtDecoderEncoder+{+ [Export(typeof(IToolProvider))]+ [Name("Jwt Decoder / Encoder")]+ [ProtocolName("jwt")]+ [Order(0)]+ [NotScrollable]+ internal sealed class JwtDecoderEncoderToolProvider : ToolProviderBase, IToolProvider+ {+ private readonly IMefProvider _mefProvider;++ public string DisplayName => LanguageManager.Instance.JwtDecoderEncoder.DisplayName;++ public object IconSource => CreatePathIconFromPath(nameof(JwtDecoderEncoderToolProvider));++ [ImportingConstructor]+ public JwtDecoderEncoderToolProvider(IMefProvider mefProvider)+ {+ _mefProvider = mefProvider;+ }++ public bool CanBeTreatedByTool(string data)+ {+ return JwtHelper.IsValid(data);+ }++ public IToolViewModel CreateTool()+ {+ return _mefProvider.Import<JwtDecoderEncoderToolViewModel>();+ }+ }+}diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolViewModel.csnew file mode 100644index 000000000..572c3df21--- /dev/null+++ b/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolViewModel.cs@@ -0,0 +1,115 @@+#nullable enable++using DevToys.Api.Tools;+using DevToys.Core.Threading;+using DevToys.Helpers;+using DevToys.Models;+using DevToys.Views.Tools.JwtDecoderEncoder;+using Microsoft.Toolkit.Mvvm.ComponentModel;+using System;+using System.Collections.Generic;+using System.Composition;+using System.IdentityModel.Tokens.Jwt;+using System.Threading.Tasks;++namespace DevToys.ViewModels.Tools.JwtDecoderEncoder+{+ [Export(typeof(JwtDecoderEncoderToolViewModel))]+ public sealed class JwtDecoderEncoderToolViewModel : ObservableRecipient, IToolViewModel+ {+ private readonly Queue<string> _decodingQueue = new();++ private bool _decodingInProgress;+ private string? _jwtToken;+ private string? _jwtHeader;+ private string? _jwtPayload;++ public Type View { get; } = typeof(JwtDecoderEncoderToolPage);++ internal JwtDecoderEncoderStrings Strings => LanguageManager.Instance.JwtDecoderEncoder;++ /// <summary>+ /// Gets or sets the jwt token.+ /// </summary>+ internal string? JwtToken+ {+ get => _jwtToken;+ set+ {+ SetProperty(ref _jwtToken, value);+ QueueConversion();+ }+ }++ /// <summary>+ /// Gets or sets the jwt header.+ /// </summary>+ internal string? JwtHeader+ {+ get => _jwtHeader;+ set => SetProperty(ref _jwtHeader, value);+ }++ /// <summary>+ /// Gets or sets the jwt payload.+ /// </summary>+ internal string? JwtPayload+ {+ get => _jwtPayload;+ set => SetProperty(ref _jwtPayload, value);+ }++ private void QueueConversion()+ {+ _decodingQueue.Enqueue(JwtToken ?? string.Empty);+ TreatQueueAsync().Forget();+ }++ private async Task TreatQueueAsync()+ {+ if (_decodingInProgress)+ {+ return;+ }++ _decodingInProgress = true;++ await TaskScheduler.Default;++ while (_decodingQueue.TryDequeue(out string text))+ {+ JwtDecode(text, out string header, out string payload);+ ThreadHelper.RunOnUIThreadAsync(ThreadPriority.Low, () =>+ {+ JwtHeader = header;+ JwtPayload = payload;+ }).ForgetSafely();+ }++ _decodingInProgress = false;+ }++ private void JwtDecode(string input, out string header, out string payload)+ {+ if (string.IsNullOrWhiteSpace(input))+ {+ header = string.Empty;+ payload = string.Empty;+ return;+ }++ try+ {+ JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();+ JwtSecurityToken jwtSecurityToken = handler.ReadJwtToken(input);+ header = JsonHelper.Format(jwtSecurityToken.Header.SerializeToJson(), Indentation.TwoSpaces);+ payload = JsonHelper.Format(jwtSecurityToken.Payload.SerializeToJson(), Indentation.TwoSpaces);+ }+ catch (Exception ex)+ {+ header = ex.Message;+ payload = ex.Message;+ }+ }+ }+}diff --git a/src/dev/impl/DevToys/Views/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolPage.xaml b/src/dev/impl/DevToys/Views/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolPage.xamlnew file mode 100644index 000000000..bcc77f130--- /dev/null+++ b/src/dev/impl/DevToys/Views/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolPage.xaml@@ -0,0 +1,47 @@+<Page+ x:Class="DevToys.Views.Tools.JwtDecoderEncoder.JwtDecoderEncoderToolPage"+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"+ xmlns:controls="using:DevToys.UI.Controls"+ mc:Ignorable="d"+ NavigationCacheMode="Required">++ <Grid Margin="0,0,0,16" RowSpacing="12">+ <Grid.ChildrenTransitions>+ <TransitionCollection>+ <EntranceThemeTransition IsStaggeringEnabled="True" FromVerticalOffset="50"/>+ </TransitionCollection>+ </Grid.ChildrenTransitions>++ <Grid.RowDefinitions>+ <RowDefinition Height="Auto"/>+ <RowDefinition Height="*"/>+ <RowDefinition Height="*"/>+ </Grid.RowDefinitions>++ <controls:CustomTextBox+ Header="{x:Bind ViewModel.Strings.JwtTokenLabel}"+ Height="150"+ AcceptsReturn="True"+ Text="{x:Bind ViewModel.JwtToken, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>++ <controls:CodeEditor+ x:Name="HeaderCodeEditor"+ Grid.Row="1"+ Header="{x:Bind ViewModel.Strings.HeaderLabel}"+ Text="{x:Bind ViewModel.JwtHeader, Mode=OneWay}"+ CodeLanguage="json"+ IsReadOnly="True"/>++ <controls:CodeEditor+ x:Name="PayloadCodeEditor"+ Grid.Row="2"+ Header="{x:Bind ViewModel.Strings.PayloadLabel}"+ Text="{x:Bind ViewModel.JwtPayload, Mode=OneWay}"+ CodeLanguage="json"+ IsReadOnly="True"/>++ </Grid>+</Page>diff --git a/src/dev/impl/DevToys/Views/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolPage.xaml.cs b/src/dev/impl/DevToys/Views/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolPage.xaml.csnew file mode 100644index 000000000..ffc7df4c7--- /dev/null+++ b/src/dev/impl/DevToys/Views/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolPage.xaml.cs@@ -0,0 +1,55 @@+#nullable enable++using DevToys.Api.Core.Navigation;+using DevToys.Core;+using DevToys.ViewModels.Tools.JwtDecoderEncoder;+using Windows.UI.Xaml;+using Windows.UI.Xaml.Controls;+using Windows.UI.Xaml.Navigation;++namespace DevToys.Views.Tools.JwtDecoderEncoder+{+ public sealed partial class JwtDecoderEncoderToolPage : Page+ {+ public static readonly DependencyProperty ViewModelProperty+ = DependencyProperty.Register(+ nameof(ViewModel),+ typeof(JwtDecoderEncoderToolViewModel),+ typeof(JwtDecoderEncoderToolPage),+ new PropertyMetadata(null));++ /// <summary>+ /// Gets the page's view model.+ /// </summary>+ public JwtDecoderEncoderToolViewModel ViewModel+ {+ get => (JwtDecoderEncoderToolViewModel)GetValue(ViewModelProperty);+ set => SetValue(ViewModelProperty, value);+ }++ public JwtDecoderEncoderToolPage()+ {+ InitializeComponent();+ }++ protected override void OnNavigatedTo(NavigationEventArgs e)+ {+ var parameters = (NavigationParameter)e.Parameter;++ if (ViewModel is null)+ {+ // Set the view model+ Assumes.NotNull(parameters.ViewModel, nameof(parameters.ViewModel));+ ViewModel = (JwtDecoderEncoderToolViewModel)parameters.ViewModel!;+ DataContext = ViewModel;+ }++ if (!string.IsNullOrWhiteSpace(parameters.ClipBoardContent))+ {+ ViewModel.JwtToken = parameters.ClipBoardContent;+ }++ base.OnNavigatedTo(e);+ }+ }+}