プロジェクト ファイルを追加します。

This commit is contained in:
mii
2020-11-04 00:25:16 +09:00
parent 187ded66e9
commit e059652cd3
17 changed files with 1096 additions and 0 deletions

25
VRCExternalTools.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29926.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VRCExternalTools", "VRCExternalTools\VRCExternalTools.csproj", "{12F51A26-2AE2-4798-9087-516F7BC3B788}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{12F51A26-2AE2-4798-9087-516F7BC3B788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12F51A26-2AE2-4798-9087-516F7BC3B788}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12F51A26-2AE2-4798-9087-516F7BC3B788}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12F51A26-2AE2-4798-9087-516F7BC3B788}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8C051168-3506-465E-A54B-B3E613B01B97}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -0,0 +1,9 @@
<Application x:Class="VRCExternalTools.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VRCExternalTools"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace VRCExternalTools
{
/// <summary>
/// App.xaml の相互作用ロジック
/// </summary>
public partial class App : Application
{
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VRCExternalTools
{
class Friend
{
public String id { get; set; }
public Friend(String userId)
{
id = userId;
}
}
}

View File

@ -0,0 +1,57 @@
<Window x:Class="VRCExternalTools.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VRCExternalTools"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<TabControl>
<TabItem Header="Settings">
<Grid Background="#FFE5E5E5">
<Label Content="Name" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,6,0,0" Height="26" Width="42"/>
<TextBox x:Name="userName" HorizontalAlignment="Left" Height="23" Margin="57,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="186" AutomationProperties.HelpText="Email or Name"/>
<Label Content="Pass" HorizontalAlignment="Left" Margin="10,32,0,0" VerticalAlignment="Top"/>
<PasswordBox x:Name="password" HorizontalAlignment="Left" Margin="57,38,0,0" VerticalAlignment="Top" Width="186"/>
<Label Content="OnetimePass" HorizontalAlignment="Left" Margin="10,57,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="oneTimePassword" HorizontalAlignment="Left" Height="23" Margin="93,61,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="150"/>
<Button x:Name="loginButton" Content="Login" HorizontalAlignment="Left" Margin="10,88,0,0" VerticalAlignment="Top" Width="75" Click="loginButton_Click"/>
<Label Content="Name" HorizontalAlignment="Left" Margin="10,113,0,0" VerticalAlignment="Top"/>
<Label x:Name="Name" Content="" HorizontalAlignment="Left" Margin="52,113,0,0" VerticalAlignment="Top" Width="724"/>
</Grid>
</TabItem>
<TabItem Header="Avatars" Height="22" VerticalAlignment="Bottom">
<Grid Background="#FFE5E5E5">
<ListView x:Name="avatars" Margin="10">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding name}" FontSize="15"/>
<TextBlock Text="{Binding description}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</TabItem>
<TabItem Header="Friends" Height="22" VerticalAlignment="Bottom">
<Grid Background="#FFE5E5E5">
<Button x:Name="reloadFriends" Content="Reload" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75" Click="reloadFriends_Click"/>
<ListView x:Name="friends" Margin="10,35,10,10">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding displayName}" FontSize="15"/>
<TextBlock Text="{Binding username}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Window>

View File

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VRCExternalTools.VRCAPI;
namespace VRCExternalTools
{
/// <summary>
/// MainWindow.xaml の相互作用ロジック
/// </summary>
public partial class MainWindow : Window
{
ObservableCollection<VRCAPIBase.LimitedUserObject> friendsCollection = new ObservableCollection<VRCAPIBase.LimitedUserObject>();
ObservableCollection<VRCAPIBase.AvatarObject> avatarsCollection = new ObservableCollection<VRCAPIBase.AvatarObject>();
private VRCAPI.VRCAPI api;
public MainWindow()
{
InitializeComponent();
friends.ItemsSource = friendsCollection;
avatars.ItemsSource = avatarsCollection;
BindingOperations.EnableCollectionSynchronization(this.friendsCollection, new object());
BindingOperations.EnableCollectionSynchronization(this.avatarsCollection, new object());
}
private void loginButton_Click(object sender, RoutedEventArgs e)
{
var authenticator = new VRCAuthenticator(userName.Text, password.Password);
api = authenticator.loginAsync().Result;
if (api != null && !authenticator.isTwoAuthentication())
{
loginButton.IsEnabled = false;
} else if (api != null && authenticator.isTwoAuthentication())
{
var result = authenticator.verifyTwoFactor(int.Parse(oneTimePassword.Text));
if (result)
{
loginButton.IsEnabled = false;
var userConfig = api.getUserConfig();
Name.Content = userConfig.username;
var avatars = api.searchAvatars(user: "me", releaseStatus: "all");
foreach (var avatar in avatars)
{
avatarsCollection.Add(avatar);
}
}
else
{
MessageBox.Show("2FA Failed.");
}
}
else if (api == null)
{
MessageBox.Show("Invalid Username or Password");
}
}
private void reloadFriends_Click(object sender, RoutedEventArgs e)
{
if (api != null)
{
var friends = api.getFriends(500,true,0);
friendsCollection.Clear();
foreach (var friend in friends)
{
friendsCollection.Add(friend);
}
}
}
}
}

View File

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
// アセンブリに関連付けられている情報を変更するには、
// これらの属性値を変更してください。
[assembly: AssemblyTitle("VRCExternalTools")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VRCExternalTools")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
// その型の ComVisible 属性を true に設定してください。
[assembly: ComVisible(false)]
//ローカライズ可能なアプリケーションのビルドを開始するには、
//.csproj ファイルの <UICulture>CultureYouAreCodingWith</UICulture> を
//<PropertyGroup> 内部で設定します。たとえば、
//ソース ファイルで英語を使用している場合、<UICulture> を en-US に設定します。次に、
//下の NeutralResourceLanguage 属性のコメントを解除します。下の行の "en-US" を
//プロジェクト ファイルの UICulture 設定と一致するよう更新します。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //テーマ固有のリソース ディクショナリが置かれている場所
//(リソースがページ、
// またはアプリケーション リソース ディクショナリに見つからない場合に使用されます)
ResourceDictionaryLocation.SourceAssembly //汎用リソース ディクショナリが置かれている場所
//(リソースがページ、
//アプリケーション、またはいずれのテーマ固有のリソース ディクショナリにも見つからない場合に使用されます)
)]
// アセンブリのバージョン情報は次の 4 つの値で構成されています:
//
// メジャー バージョン
// マイナー バージョン
// ビルド番号
// リビジョン
//
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// このコードはツールによって生成されました。
// ランタイム バージョン:4.0.30319.42000
//
// このファイルへの変更は、正しくない動作の原因になったり、
// コードが再生成されるときに失われたりします。
// </auto-generated>
//------------------------------------------------------------------------------
namespace VRCExternalTools.Properties
{
/// <summary>
/// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
/// </summary>
// このクラスは StronglyTypedResourceBuilder クラスによって ResGen
// または Visual Studio のようなツールを使用して自動生成されました。
// メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
// ResGen を実行し直すか、または VS プロジェクトをリビルドします。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// このクラスで使用されるキャッシュされた ResourceManager インスタンスを返します。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VRCExternalTools.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// すべてについて、現在のスレッドの CurrentUICulture プロパティをオーバーライドします
/// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace VRCExternalTools.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Newtonsoft.Json;
using JsonSerializer = System.Text.Json.JsonSerializer;
namespace VRCExternalTools.VRCAPI
{
class VRCAPI
{
public String apiKey;
public String authToken;
private HttpClientHandler handler = new HttpClientHandler();
public VRCAPI(String key, String token)
{
apiKey = key;
authToken = token;
handler.CookieContainer = new CookieContainer();
handler.CookieContainer.Add(new Cookie("auth", authToken, "/", "api.vrchat.cloud"));
}
public VRCAPIBase.UserDataReturn getUserConfig()
{
Uri uri = new Uri(VRCAPIBase.api_base + "/auth/user");
using (var client = new HttpClient(handler, false))
{
var request = new HttpRequestMessage(HttpMethod.Get, uri);
var result = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
return JsonSerializer.Deserialize<VRCAPIBase.UserDataReturn>(result);
}
}
public List<VRCAPIBase.AvatarObject> searchAvatars(String user = null, bool featured = false, String userId = null, int n = -1, int offset = -1, string order = null, string releaseStatus = null, string sort = null, string maxUnityVersion = null, string minUnityVersion = null, string maxAssetVersion = null, string minAssetVersion = null, string platform = null)
{
string urlParams = "?";
if (user != null) { urlParams += "user=" + user + "&"; }
urlParams += "featured=" + featured + "&";
if (userId != null) { urlParams += "userId=" + userId + "&"; }
if (n != -1) { urlParams += "n=" + n + "&"; }
if (offset != -1) { urlParams += "offset=" + offset + "&"; }
if (order != null) { urlParams += "order=" + order + "&"; }
if (releaseStatus != null) { urlParams += "releaseStatus=" + releaseStatus + "&"; }
if (sort != null) { urlParams += "sort=" + sort + "&"; }
if (maxUnityVersion != null) { urlParams += "maxUnityVersion=" + maxUnityVersion + "&"; }
if (minUnityVersion != null) { urlParams += "minUnityVersion=" + minUnityVersion + "&"; }
if (maxAssetVersion != null) { urlParams += "maxAssetVersion=" + maxAssetVersion + "&"; }
if (minAssetVersion != null) { urlParams += "minAssetVersion=" + minAssetVersion + "&"; }
if (platform != null) { urlParams += "platform=" + platform + "&"; }
urlParams += "apiKey=" + apiKey;
Uri uri = new Uri(VRCAPIBase.api_base + "/avatars" + urlParams);
using (var client = new HttpClient(handler, false))
{
var request = new HttpRequestMessage(HttpMethod.Get, uri);
var result = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
return JsonConvert.DeserializeObject<List<VRCAPIBase.AvatarObject>>(result);
}
}
public List<VRCAPIBase.LimitedUserObject> getFriends(int n, bool offline, int offset)
{
using (var client = new HttpClient(handler, false))
{
Uri uri = new Uri(VRCAPIBase.api_base + "/auth/user/friends?apiKey=" + apiKey + "&offline=" + offline + "&offset=" + Convert.ToString(offset));
//request.Content = new StringContent(JsonSerializer.Serialize(new VRCAPIBase.FriendsRequest() { apiKey = apiKey, n = n, offline = offline, offset = offset }), Encoding.UTF8, "application/json");
var request = new HttpRequestMessage(HttpMethod.Get, uri);
var result = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
MessageBox.Show(result);
return JsonConvert.DeserializeObject<List<VRCAPIBase.LimitedUserObject>>(result);
}
}
}
}

View File

@ -0,0 +1,243 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.Security.RightsManagement;
namespace VRCExternalTools.VRCAPI
{
class VRCAPIBase
{
public static readonly String api_base = "https://api.vrchat.cloud/api/1";
public class AvatarObject
{
public String id { get; set; }
public String name { get; set; }
public String description { get; set; }
public String authorId { get; set; }
public String authorName { get; set; }
}
public class PastDisplayNameObject
{
public String displayName { get; set; }
public String updated_at { get; set; }
}
public class CurrentUserObject
{
public String username { get; set; }
public String displayName { get; set; }
public PastDisplayNameObject[] pastDisplayNames { get; set; }
public String id { get; set; }
public String bio { get; set; }
public String[] bioLinks { get; set; }
public String email { get; set; }
public bool emailVerified { get; set; }
public bool hasEmail { get; set; }
public bool hasPendingEmail { get; set; }
public String obfuscatedEmail { get; set; }
public String obfuscatedPendingEmail { get; set; }
public String steamId { get; set; }
public String[] steamDetails { get; set; }
public String oculusId { get; set; }
public int acceptedTOSVersion { get; set; }
public bool hasBirthday { get; set; }
public String[] friends { get; set; }
public String[] onlineFriends { get; set; }
public String[] activeFriends { get; set; }
public String[] offlineFriends { get; set; }
public String[] friendGroupNames { get; set; }
public String state { get; set; }
public String status { get; set; }
}
public class WorldUnityPackageObject
{
public String id { get; set; }
public String platform { get; set; }
public String assetUrl { get; set; }
public String unityVersion { get; set; }
public int unitySortNumber { get; set; }
public int assetVersion { get; set; }
public String created_at { get; set; }
public String assetUrlObject { get; set; }
public String pluginUrl { get; set; }
public String pluginUrlObject { get; set; }
}
public class LimitedWorldObject
{
public String name { get; set; }
public String id { get; set; }
public String authorName { get; set; }
public int authorId { get; set; }
public String[] tags { get; set; }
public String created_at { get; set; }
public String updated_at { get; set; }
public String releaseStatus { get; set; }
public int visits { get; set; }
public int occupants { get; set; }
public int capacity { get; set; }
public int favorites { get; set; }
public int popularity { get; set; }
public String imageUrl { get; set; }
public String thumbnailImageUrl { get; set; }
public String organization { get; set; }
public int heat { get; set; }
public String publicationDate { get; set; }
public String labsPublicationDate { get; set; }
public WorldUnityPackageObject[] unityPackages { get; set; }
}
public class LimitedUserObject
{
public String username { get; set; }
public String displayName { get; set; }
public String id { get; set; }
public String bio { get; set; }
public String statys { get; set; }
public String currentAvatarImageUrl { get; set; }
public String currentAvatarThumbnailImageUrl { get; set; }
public String last_platform { get; set; }
public String[] tags { get; set; }
public String developerType { get; set; }
public bool isFriend { get; set; }
//public LimitedWorldObject location { get; set; }
}
public class FriendsRequest
{
public int offset { get; set; }
public int n { get; set; }
public bool offline { get; set; }
public String apiKey { get; set; }
}
public class TwoFactorRequest
{
public String apiKey { get; set; }
public String code { get; set; }
}
public class TwoFactorAuthReturn
{
public bool verified { get; set; }
}
public class DisplayNameObject
{
public String displayName { get; set; }
public String updated_at { get; set; }
}
public class UserDataReturn
{
public String id { get; set; }
public String username { get; set; }
public String displayName { get; set; }
public String userIcon { get; set; }
public String bio { get; set; }
public String[] bioLinks { get; set; }
public DisplayNameObject[] pastDisplayNames { get; set; }
public bool hasEmail { get; set; }
public bool hasPendingEmail { get; set; }
public String email { get; set; }
public String obfuscatedEmail { get; set; }
public String obfuscatedPendingEmail { get; set; }
public bool emailVerified { get; set; }
public bool hasBirthday { get; set; }
public bool unsubscribe { get; set; }
public String[] friends { get; set; }
public String[] friendGroupNames { get; set; }
public String currentAvatarImageUrl { get; set; }
public String currentAvatarThumbnailImageUrl { get; set; }
public String fallbackAvatar { get; set; }
public String currentAvatar { get; set; }
public String currentAvatarAssetUrl { get; set; }
public String accountDeletionDate { get; set; }
public int acceptedTOSVersion { get; set; }
public String steamId { get; set; }
public String oculusId { get; set; }
public bool hasLoggedInFromClient { get; set; }
public String homeLocation { get; set; }
public bool twoFactorAuthEnabled { get; set; }
public String status { get; set; }
public String statusDescription { get; set; }
public String state { get; set; }
public String[] tags { get; set; }
public String developerType { get; set; }
public String last_login { get; set; }
public String last_platform { get; set; }
public bool allowAvatarCopying { get; set; }
public bool isFriend { get; set; }
public String friendKey { get; set; }
public String[] onlineFriends { get; set; }
public String[] activeFriends { get; set; }
public String[] offlineFriends { get; set; }
}
public class ConfigDataReturn
{
public String messageOfTheDay { get; set; }
public String timeOutWorldId { get; set; }
public String gearDemoRoomId { get; set; }
public String releaseServerVersionStandalone { get; set; }
public String downloadLinkWindows { get; set; }
public String releaseAppVersionStandalone { get; set; }
public String devAppVersionStandalone { get; set; }
public String devServerVersionStandalone { get; set; }
public String devDownloadLinkWindows { get; set; }
public int currentTOSVersiona { get; set; }
public String releaseSdkUrl { get; set; }
public String releaseSdkVersion { get; set; }
public String devSdkUrl { get; set; }
public String devSdkVersion { get; set; }
public String[] whiteListedAssetUrls { get; set; }
public String clientApiKey { get; set; }
public String viveWindowsUrl { get; set; }
public String sdkUnityVersion { get; set; }
public String hubWorldId { get; set; }
public String homeWorldId { get; set; }
public String tutorialWorldId { get; set; }
public bool disableEventStream { get; set; }
public bool disableAvatarGating { get; set; }
public bool disableFeedbackGating { get; set; }
public bool disableRegistration { get; set; }
public String plugin { get; set; }
public String sdkNotAllowedToPublishMessage { get; set; }
public String sdkDeveloperFaqUrl { get; set; }
public String sdkDiscordUrl { get; set; }
public String notAllowedToSelectAvatarInPrivateWorldMessage { get; set; }
public int userVerificationTimeout { get; set; }
public int userUpdatePeriod { get; set; }
public int userVerificationDelay { get; set; }
public int userVerificationRetry { get; set; }
public int worldUpdatePeriod { get; set; }
public int moderationQueryPeriod { get; set; }
public String defaultAvatar { get; set; }
// public String dynamicWorldRows { get; set; } // Array of DynamicWorldRows WIP
public String address { get; set; }
public String contactEmail { get; set; }
public String supportEmail { get; set; }
public String jobsEmail { get; set; }
public String copyrightEmail { get; set; }
public String moderationEmail { get; set; }
public bool disableEmail { get; set; }
public String appName { get; set; }
public String serverName { get; set; }
public String deploymentGroup { get; set; }
public String buildVersionTag { get; set; }
public String apiKey { get; set; }
}
}
}

View File

@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.Text.Json;
using System.Windows;
namespace VRCExternalTools.VRCAPI
{
class VRCAuthenticator
{
private String userName;
private String password;
private String apiKey;
private String authToken;
private bool twoFactor = false;
public VRCAuthenticator(String name, String pass)
{
userName = name;
password = pass;
}
public async Task<String> getApiKey()
{
Uri uri = new Uri(VRCAPIBase.api_base + "/config");
using (var client = new HttpClient())
{
VRCAPIBase.ConfigDataReturn config = JsonSerializer.Deserialize<VRCAPIBase.ConfigDataReturn>(await client.GetAsync(uri).Result.Content.ReadAsStringAsync());
return config.apiKey;
}
}
public string getAuthToken(String name, String pass)
{
var cookieContainer = new CookieContainer();
CookieContainer cookies = new CookieContainer();
HttpClientHandler handler = new HttpClientHandler();
handler.CookieContainer = cookies;
using (var client = new HttpClient(handler))
{
var uri = new Uri(VRCAPIBase.api_base + "/auth/user");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", name, pass))));
client.DefaultRequestHeaders.Add("apiKey", apiKey);
var response = client.GetAsync(uri).Result.Content.ReadAsStringAsync().Result;
if (response.Contains("requiresTwoFactorAuth") && response.Contains("otp"))
{
twoFactor = true;
}
IEnumerable<Cookie> responseCookies = cookies.GetCookies(uri).Cast<Cookie>();
foreach (Cookie cookie in responseCookies)
{
if (cookie.Name == "auth")
{
return cookie.Value;
}
}
}
return String.Empty;
}
public async Task<VRCAPI> loginAsync()
{
apiKey = await getApiKey();
authToken = getAuthToken(userName, password);
if (authToken == String.Empty)
{
return null;
}
return new VRCAPI(apiKey, authToken);
}
public bool verifyTwoFactor(int pass)
{
Uri uri = new Uri(VRCAPIBase.api_base + "/auth/twofactorauth/totp/verify");
HttpClientHandler handler = new HttpClientHandler();
handler.CookieContainer = new CookieContainer();
handler.CookieContainer.Add(new Cookie("auth", authToken, "/", "api.vrchat.cloud"));
using (var client = new HttpClient(handler))
{
var request = new HttpRequestMessage(HttpMethod.Post, uri);
request.Content = new StringContent(JsonSerializer.Serialize(new VRCAPIBase.TwoFactorRequest() { apiKey = apiKey, code = Convert.ToString(pass)}), Encoding.UTF8, "application/json");
var result = client.SendAsync(request).Result.Content.ReadAsStringAsync().Result;
return JsonSerializer.Deserialize < VRCAPIBase.TwoFactorAuthReturn > (result).verified;
}
}
public bool isTwoAuthentication()
{
return twoFactor;
}
}
}

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{12F51A26-2AE2-4798-9087-516F7BC3B788}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>VRCExternalTools</RootNamespace>
<AssemblyName>VRCExternalTools</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.4.7.1\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.4.7.2\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Friend.cs" />
<Compile Include="VRCAPI\VRCAPIBase.cs" />
<Compile Include="VRCAPI\VRCAuthenticator.cs" />
<Compile Include="VRCAPI\VRCAPI.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="4.7.1" targetFramework="net472" />
<package id="System.Text.Json" version="4.7.2" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>