Skip to content

Commit 9a908a5

Browse files
committed
2 parents 987aacf + d7a7112 commit 9a908a5

64 files changed

Lines changed: 3793 additions & 998 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Sources/EasyExtensions.AspNetCore.Authorization/Abstractions/ITokenProvider.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ namespace EasyExtensions.AspNetCore.Authorization.Abstractions
1212
/// </summary>
1313
public interface ITokenProvider
1414
{
15+
/// <summary>
16+
/// Gets the duration for which a generated token remains valid before expiration.
17+
/// </summary>
18+
TimeSpan TokenLifetime { get; }
19+
1520
/// <summary>
1621
/// Creates a token with claims.
1722
/// </summary>

Sources/EasyExtensions.AspNetCore.Authorization/Services/JwtTokenProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ internal class JwtTokenProvider(IConfiguration _configuration) : ITokenProvider
1818
private readonly JwtSettings _jwtSettings = _configuration.GetJwtSettings();
1919
private readonly SymmetricSecurityKey _securityKey = new(Encoding.UTF8.GetBytes(_configuration.GetJwtSettings().Key));
2020

21+
public TimeSpan TokenLifetime => TimeSpan.FromMinutes(_jwtSettings.LifetimeMinutes);
22+
2123
public bool ValidateToken(string token)
2224
{
2325
var tokenHandler = new JwtSecurityTokenHandler();

Sources/EasyExtensions.Clients/IpApiCoClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static async Task<IpApiCoResponse> LookupAsync(string ip)
8585
{
8686
DefaultRequestHeaders =
8787
{
88-
{ "User-Agent", "EasyExtensions.Clients/1.0" }
88+
{ "User-Agent", "EasyExtensions.Clients/3.0" }
8989
}
9090
};
9191
var response = await http.GetFromJsonAsync<IpApiCoResponse>(url)

Sources/EasyExtensions.Crypto/AesGcmStreamCipher.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public class AesGcmStreamCipher : IStreamCipher, IDisposable
6464
private readonly bool _strictLengthCheck;
6565
private readonly RandomNumberGenerator _rng;
6666
private readonly long? _memoryLimitBytes;
67+
private readonly long _pipePauseWriterThresholdBytes;
68+
private readonly long _pipeResumeWriterThresholdBytes;
6769
private static readonly ArrayPool<byte> BufferPool = ArrayPool<byte>.Shared;
6870
private readonly int ConcurrencyLevel = Math.Min(4, Environment.ProcessorCount);
6971

@@ -120,6 +122,18 @@ public AesGcmStreamCipher(ReadOnlyMemory<byte> masterKey, int keyId = 1, int? th
120122
_strictLengthCheck = strictLengthCheck;
121123
_rng = rng ?? RandomNumberGenerator.Create();
122124
_memoryLimitBytes = memoryLimitBytes;
125+
126+
const long defaultPipePause = 1L * 1024L * 1024L;
127+
long pipePause = defaultPipePause;
128+
if (memoryLimitBytes.HasValue)
129+
{
130+
// Keep outer Pipe buffering small and independent from internal windowing.
131+
// Optionally respect the provided memory cap, without letting it grow unbounded.
132+
pipePause = Math.Min(defaultPipePause, Math.Max(256L * 1024L, memoryLimitBytes.Value / 64));
133+
}
134+
_pipePauseWriterThresholdBytes = pipePause;
135+
_pipeResumeWriterThresholdBytes = Math.Max(1, pipePause / 2);
136+
123137
if (threads.HasValue)
124138
{
125139
if (threads.Value < 1 || threads.Value > _maxThreads)
@@ -289,9 +303,8 @@ public Task<Stream> EncryptAsync(Stream input, int chunkSize = DefaultChunkSize,
289303
throw new ArgumentOutOfRangeException(nameof(chunkSize), $"Chunk size must be between {MinChunkSize} and {MaxChunkSize} bytes.");
290304
}
291305

292-
int effectiveWindowCap = ComputeEffectiveWindowCap(chunkSize);
293-
long pauseThreshold = (long)Math.Clamp(chunkSize, MinChunkSize, MaxChunkSize) * Math.Clamp(effectiveWindowCap, 4, int.MaxValue);
294-
long resumeThreshold = pauseThreshold / 2;
306+
long pauseThreshold = _pipePauseWriterThresholdBytes;
307+
long resumeThreshold = _pipeResumeWriterThresholdBytes;
295308
var pipe = new Pipe(new PipeOptions(
296309
pool: MemoryPool<byte>.Shared,
297310
readerScheduler: null,
@@ -340,10 +353,8 @@ public Task<Stream> DecryptAsync(Stream input, bool leaveOpen = false, Cancellat
340353
throw new ArgumentException("Input stream must be readable.", nameof(input));
341354
}
342355

343-
long perChunkGuess = DefaultChunkSize;
344-
int effectiveWindowCap = ComputeEffectiveWindowCap((int)perChunkGuess);
345-
long pauseThreshold = perChunkGuess * Math.Clamp(effectiveWindowCap, 4, int.MaxValue);
346-
long resumeThreshold = pauseThreshold / 2;
356+
long pauseThreshold = _pipePauseWriterThresholdBytes;
357+
long resumeThreshold = _pipeResumeWriterThresholdBytes;
347358
var pipe = new Pipe(new PipeOptions(
348359
pool: MemoryPool<byte>.Shared,
349360
readerScheduler: null,

Sources/EasyExtensions.EntityFrameworkCore/Database/ExtendedRefreshToken.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,11 @@ public class ExtendedRefreshToken : RefreshToken
6161
/// </summary>
6262
[Column("device")]
6363
public string? Device { get; set; }
64+
65+
/// <summary>
66+
/// Gets or sets the unique identifier for the session associated with this entity.
67+
/// </summary>
68+
[Column("session_id")]
69+
public string? SessionId { get; set; }
6470
}
6571
}

Sources/EasyExtensions.EntityFrameworkCore/Extensions/DbContextExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ public static void ApplyMigrations<TContext>(this TContext context, ILogger? log
2727
{
2828
foreach (var migration in migrations)
2929
{
30+
#pragma warning disable CA1873 // Avoid potentially expensive logging
3031
logger?.LogInformation("Applying migration {Migration}.", migration);
32+
#pragma warning restore CA1873 // Avoid potentially expensive logging
3133
}
3234
context.Database.Migrate();
3335
logger?.LogInformation("Migrations applied.");

Sources/EasyExtensions.Mediator/Contracts/IBaseRequest.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Sources/EasyExtensions.Mediator/Contracts/IMediator.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2025–2026 Vadim Belov <https://belov.us>
3-
41
namespace EasyExtensions.Mediator.Contracts
52
{
63
/// <summary>
7-
/// Defines a marker interface for notification messages used in a messaging or event-driven system.
4+
/// Marker interface to represent a notification
85
/// </summary>
9-
/// <remarks>Implement this interface to represent a notification that can be published or handled by
10-
/// notification handlers. This interface does not define any members and serves to identify types as notifications
11-
/// within the system.</remarks>
126
public interface INotification { }
13-
}
7+
}

Sources/EasyExtensions.Mediator/Contracts/INotificationHandler.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)