mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # Wabbajack.CLI/Verbs/SetNexusApiKey.cs
This commit is contained in:
commit
749baf1bdf
@ -1,5 +1,8 @@
|
||||
### Changelog
|
||||
|
||||
#### Version - 3.6.1.1 - TBD
|
||||
* Fixed `set-nexus-api-key` CLI command
|
||||
|
||||
#### Version - 3.6.1.0 - 5/26/2024
|
||||
* Fixed a race condition on renewing Nexus Mods OAuth2 tokens
|
||||
* Added `set-nexus-api-key` CLI command
|
||||
|
@ -94,7 +94,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2478.35" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||
<PackageReference Include="Orc.FileAssociation" Version="5.0.0-alpha0061" />
|
||||
<PackageReference Include="Orc.FileAssociation" Version="5.0.0" />
|
||||
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
|
||||
<PackageReference Include="ReactiveUI" Version="19.5.1" />
|
||||
<PackageReference Include="ReactiveUI.Fody" Version="19.5.1" />
|
||||
|
@ -1,13 +1,7 @@
|
||||
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using System.CommandLine.NamingConventionBinder;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.CLI.Builder;
|
||||
using Wabbajack.DTOs.Logins;
|
||||
using Wabbajack.Paths;
|
||||
using Wabbajack.Paths.IO;
|
||||
using Wabbajack.Services.OSIntegrated;
|
||||
|
||||
namespace Wabbajack.CLI.Verbs;
|
||||
@ -23,7 +17,7 @@ public class SetNexusApiKey
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public static VerbDefinition Definition = new VerbDefinition("set-nexus-api-key",
|
||||
public static VerbDefinition Definition = new("set-nexus-api-key",
|
||||
"Sets the Nexus API key to the specified value",
|
||||
[
|
||||
new OptionDefinition(typeof(string), "k", "key", "The Nexus API key")
|
||||
@ -38,7 +32,7 @@ public class SetNexusApiKey
|
||||
}
|
||||
else
|
||||
{
|
||||
await _tokenProvider.SetToken(new NexusOAuthState { ApiKey = key });
|
||||
await _tokenProvider.SetToken(new() { ApiKey = key });
|
||||
_logger.LogInformation("Set Nexus API Key to {key}", key);
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.5" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
|
||||
</ItemGroup>
|
||||
|
@ -148,8 +148,9 @@ public class DownloadDispatcher
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (HttpException)
|
||||
catch (HttpException ex)
|
||||
{
|
||||
_logger.LogError($"Failed verifying {a.State.PrimaryKeyString}: {ex}");
|
||||
await _verificationCache.Put(a.State, false);
|
||||
return false;
|
||||
}
|
||||
|
@ -217,8 +217,9 @@ public class NexusDownloader : ADownloader<Nexus>, IUrlDownloader
|
||||
|
||||
return fileInfo.info.FileId == state.FileID;
|
||||
}
|
||||
catch (HttpException)
|
||||
catch (HttpException ex)
|
||||
{
|
||||
_logger.LogError($"HttpException: {ex} on {archive.Name}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Shipwreck.Phash" Version="0.5.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
|
||||
<PackageReference Include="xunit" Version="2.6.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
@ -3,6 +3,6 @@ using Wabbajack.Networking.Http.Interfaces;
|
||||
|
||||
namespace Wabbajack.Networking.NexusApi;
|
||||
|
||||
public interface AuthInfo : ITokenProvider<NexusOAuthState>
|
||||
public interface IAuthInfo : ITokenProvider<NexusOAuthState>
|
||||
{
|
||||
}
|
@ -188,7 +188,6 @@ public class NexusApi
|
||||
protected virtual async ValueTask<HttpRequestMessage> GenerateMessage(HttpMethod method, string uri,
|
||||
params object?[] parameters)
|
||||
{
|
||||
using var _ = await _authLock.WaitAsync();
|
||||
var msg = new HttpRequestMessage();
|
||||
msg.Method = method;
|
||||
|
||||
@ -232,6 +231,7 @@ public class NexusApi
|
||||
|
||||
private async ValueTask<(bool IsApiKey, string code)> GetAuthInfo()
|
||||
{
|
||||
using var _ = await _authLock.WaitAsync();
|
||||
if (AuthInfo.HaveToken())
|
||||
{
|
||||
var info = await AuthInfo.Get();
|
||||
@ -272,6 +272,8 @@ public class NexusApi
|
||||
var response = await _client.PostAsync($"https://users.nexusmods.com/oauth/token", content, cancel);
|
||||
var responseString = await response.Content.ReadAsStringAsync(cancel);
|
||||
var newJwt = JsonSerializer.Deserialize<JwtTokenReply>(responseString);
|
||||
if (newJwt != null)
|
||||
newJwt.ReceivedAt = DateTime.UtcNow.ToFileTimeUtc();
|
||||
|
||||
state.OAuth = newJwt;
|
||||
await AuthInfo.SetToken(state);
|
||||
|
@ -5,7 +5,7 @@ using Wabbajack.Networking.NexusApi;
|
||||
|
||||
namespace Wabbajack.Services.OSIntegrated.TokenProviders;
|
||||
|
||||
public class NexusApiTokenProvider : EncryptedJsonTokenProvider<NexusOAuthState>, AuthInfo
|
||||
public class NexusApiTokenProvider : EncryptedJsonTokenProvider<NexusOAuthState>, IAuthInfo
|
||||
{
|
||||
public NexusApiTokenProvider(ILogger<NexusApiTokenProvider> logger, DTOSerializer dtos) : base(logger, dtos,
|
||||
"nexus-oauth-info")
|
||||
|
Loading…
Reference in New Issue
Block a user