Skip to content

Commit

Permalink
Add WebView2 requirement message
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeFZ committed Oct 26, 2022
1 parent ee85aa7 commit 2f058b0
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions DragaliaClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using DragaliaClient.Models;
using Microsoft.Web.WebView2.Core;
using NintendoAuth.Popup;
using Org.BouncyCastle.Crypto.Parameters;

Expand All @@ -13,6 +14,12 @@ internal class Program
[STAThread]
static void Main(string[] args)
{
if (CoreWebView2Environment.GetAvailableBrowserVersionString() == null)
{
Console.WriteLine("Error: You need to install the WebView2 Runtime. Download Link: https://go.microsoft.com/fwlink/p/?LinkId=2124703");
Console.ReadKey(); Environment.Exit(-1);
}

Console.WriteLine("Creating device account...");
var (nintendoSessionId, deviceUserId, deviceAccount) = GetDeviceAccount();
Console.WriteLine("Created device account!");
Expand Down Expand Up @@ -44,12 +51,13 @@ static void Main(string[] args)
SaveResponse(coneshellClient, "endeavour.txt", Constants.DmodeGetData);

Console.WriteLine("Finished! Press any key to exit.");
Console.ReadKey();
}
else
{
Console.WriteLine("Failed to login.");
}

Console.ReadKey();
}

private static void SaveResponse(ConeshellClient client, string filename, string url)
Expand Down Expand Up @@ -98,7 +106,7 @@ private static (string sessionId, string deviceUserId, DeviceAccount deviceAccou
if (loginResponseData?.User == null)
{
Console.WriteLine("Failed to create new device account.");
Console.ReadLine(); Environment.Exit(-1);
Console.ReadKey(); Environment.Exit(-1);
}

return (loginResponseData.SessionId, loginResponseData.User!.Id, loginResponseData.CreatedDeviceAccount);
Expand Down Expand Up @@ -141,7 +149,7 @@ private static (string transferredIdToken, string transferredUserId) AssociateWi
if (loginResponseData?.User == null)
{
Console.WriteLine("Failed to associate device with Nintendo account.");
Console.ReadLine(); Environment.Exit(-1);
Console.ReadKey(); Environment.Exit(-1);
}

return (loginResponseData.IdToken, loginResponseData.User.Id);
Expand All @@ -168,7 +176,7 @@ private static string DoNintendoLogin()
if (oauthToken == "")
{
Console.WriteLine("Failed to acquire OAuth token.");
Console.ReadLine(); Environment.Exit(-1);
Console.ReadKey(); Environment.Exit(-1);
}

var sessionTokenCode = oauthToken.Split("&").First(entry => entry.StartsWith("session_token_code"))[19..];
Expand All @@ -193,7 +201,7 @@ private static string DoNintendoLogin()
if (sessionTokenInfo == null)
{
Console.WriteLine("Failed to acquire session token.");
Console.ReadLine(); Environment.Exit(-1);
Console.ReadKey(); Environment.Exit(-1);
}

var sessionToken = sessionTokenInfo.session_token;
Expand All @@ -210,13 +218,15 @@ private static string DoNintendoLogin()
if (sdkTokenInfo == null)
{
Console.WriteLine("Failed to acquire sdk token.");
Console.ReadLine(); Environment.Exit(-1);
Console.ReadKey(); Environment.Exit(-1);
}

var userId = sdkTokenInfo.User.Id;
var idToken = sdkTokenInfo.IdToken;

//Console.WriteLine($"BaaS User Id: {sdkTokenInfo.User.Id} | ID Token: {sdkTokenInfo.IdToken}");
#if DEBUG
Console.WriteLine($"BaaS User Id: {sdkTokenInfo.User.Id} | ID Token: {sdkTokenInfo.IdToken}");
#endif

return idToken;
}
Expand Down

0 comments on commit 2f058b0

Please sign in to comment.