Decode.Context.Abstractions 3.0.0

dotnet add package Decode.Context.Abstractions --version 3.0.0
                    
NuGet\Install-Package Decode.Context.Abstractions -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Decode.Context.Abstractions" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Decode.Context.Abstractions" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Decode.Context.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Decode.Context.Abstractions --version 3.0.0
                    
#r "nuget: Decode.Context.Abstractions, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Decode.Context.Abstractions@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Decode.Context.Abstractions&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Decode.Context.Abstractions&version=3.0.0
                    
Install as a Cake Tool

Decode.Context.Abstractions

Core contracts and interfaces for user and request context in the Decode ecosystem.

🚀 Features

  • IUserContext: Framework-agnostic interface for accessing current user identity (UserId), authentication state (IsAuthenticated), client IP address (IpAddress), User-Agent, Access Token, and custom claims across Domain and Application layers.
  • No implicit proxy trust: how IpAddress is resolved is left to the implementation. The ASP.NET Core one reads the connection's remote address and ignores X-Forwarded-For unless the application opts in — see the Decode.AspNetCore readme.
  • Zero Web Dependencies: No package references at all, and no reference to ASP.NET Core or any web assembly — the contract is consumable from a Domain layer without dragging a hosting stack behind it.

📦 Installation

Add the package to your Domain or Application project:

dotnet add package Decode.Context.Abstractions

📖 Usage

Inject IUserContext into your Domain Handlers, Services, or Repositories:

using Decode.Context.Abstractions;

public class CreateOrderCommandHandler(IUserContext userContext, IOrderRepository repository)
{
    public async Task HandleAsync(CreateOrderCommand command, CancellationToken ct)
    {
        // 1. Safely retrieve authenticated User ID (returns Guid.Empty if unauthenticated)
        Guid userId = userContext.UserId;
        bool isAuthenticated = userContext.IsAuthenticated;

        // 2. Retrieve client IP address and User-Agent for audit logging
        string clientIp = userContext.IpAddress;
        string userAgent = userContext.UserAgent;

        // 3. Query custom claims
        string? tenantId = userContext.GetClaim("tenant_id");

        Order order = new(command.Amount, userId, clientIp);
        await repository.AddAsync(order, ct);
    }
}

📄 License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Decode.Context.Abstractions:

Package Downloads
Decode.AspNetCore

ASP.NET Core extensions for the Decode ecosystem, including global exception handling and base controllers.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 105 9/14/2026
2.1.0 103 9/13/2026
2.0.2 97 9/13/2026
2.0.1 99 9/13/2026
2.0.0 141 7/28/2026
1.0.0 119 7/22/2026