uSignIn.CommonSettings 10.2.1

Prefix Reserved
dotnet add package uSignIn.CommonSettings --version 10.2.1
                    
NuGet\Install-Package uSignIn.CommonSettings -Version 10.2.1
                    
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.

                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.

                    
Directory.Packages.props

                    
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 uSignIn.CommonSettings --version 10.2.1
                    
#r "nuget: uSignIn.CommonSettings, 10.2.1"
                    
#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 uSignIn.CommonSettings@10.2.1
                    
#: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=uSignIn.CommonSettings&version=10.2.1
                    
Install as a Cake Addin
#tool nuget:?package=uSignIn.CommonSettings&version=10.2.1
                    
Install as a Cake Tool

uSignIn.CommonSettings

NuGet GitHub

uSignIn.CommonSettings is a robust C# class library designed to centralize configuration management and provide essential validation logic for the uSignIn ecosystem. It acts as a strongly-typed wrapper around appsettings.json, ensuring consistency and safety across your projects.

Features

  • Centralized Configuration: Strongly-typed access to common settings like API URLs, frontend endpoints, and platform-specific configurations (Android/iOS).
  • Request Freshness Validation: Built-in logic to validate request timestamps, helping to prevent replay attacks by enforcing a configurable time window.
  • History Tracking: Generic History DTOs and extensions to easily track and retrieve the latest values from a time-ordered sequence.
  • Platform Support: dedicated configuration sections for Android and iOS specific settings (Scheme, Host).

Installation

Install the NuGet package via the .NET CLI:

dotnet add package uSignIn.CommonSettings

Or via the NuGet Package Manager in Visual Studio.

Configuration

Add the following Settings section to your appsettings.json. Adjust the values to match your environment.

{
  "Settings": {
    "BaseUrl": "https://api.yourdomain.com",
    "FrontendUrl": "https://app.yourdomain.com",
    "RequestTimeSpanRangeInMilliseconds": "-120000:120000",
    "Android": {
      "Scheme": "usignin",
      "Host": "callback"
    },
    "iOS": {
      "Scheme": "usignin",
      "Host": "callback"
    }
  }
}

Configuration Breakdown

  • BaseUrl: The root URL for your backend API.
  • FrontendUrl: The root URL for your frontend application.
  • RequestTimeSpanRangeInMilliseconds: Defines the valid time window for requests relative to the server time.
    • Format: "LowerLimit:UpperLimit" (in milliseconds). Both limits are offsets of the request timestamp from server time: a negative limit lies in the past, a positive limit in the future. LowerLimit must be less than or equal to UpperLimit.
    • Example "-120000:120000" means a request timestamp is valid if it is between 2 minutes in the past and 2 minutes in the future.
    • Asymmetric windows are supported: "-600000:1000" tolerates 10 minutes of age but only 1 second of future clock skew.
    • Values are parsed with the invariant culture, so the same configuration behaves identically on every host regardless of locale. Do not use group separators — "-60.000" is read as -60 milliseconds, not -60000.
    • If the value is missing or malformed, a critical message is logged and the default "-180000000:120000" (50 hours of age, 2 minutes of future skew) is used.
  • Android / iOS: Platform-specific settings used for deep linking or redirects. Optional — when a section is absent a warning is logged and Scheme/Host are empty strings rather than null.

Usage

1. Registering the services

Call AddCommonSettingsServices() on your service collection during startup. It registers SettingsService as a singleton and is safe to call more than once.

using uSignIn.CommonSettings;

builder.Services.AddCommonSettingsServices();

SettingsService reads and validates configuration when it is first constructed, throwing InvalidOperationException if Settings:BaseUrl or Settings:FrontendUrl is missing or is not an absolute URL.

2. Settings Service

Inject SettingsService into your classes.

using uSignIn.CommonSettings.Settings;

public class MyService
{
    private readonly SettingsService _settings;

    public MyService(SettingsService settings)
    {
        _settings = settings;
    }

    public void DoWork()
    {
        // Access URLs
        var apiUrl = _settings.BaseUri;
        
        // Access Platform Settings
        var androidScheme = _settings.Android.Scheme;
    }

    public void ValidateRequest(DateTimeOffset requestTime)
    {
        // Check if the request is within the allowed time window
        if (!_settings.IsFresh(requestTime))
        {
            throw new InvalidOperationException("Request is expired or invalid.");
        }
    }
}

3. History Tracking

Use the History DTO and HistoryExtensions to manage historical data.

using uSignIn.CommonSettings.DTOs;

var loginHistory = new List>
{
    new History { Value = "Login_Attempt_1", TimeStamp = DateTimeOffset.UtcNow.AddMinutes(-10) },
    new History { Value = "Login_Success", TimeStamp = DateTimeOffset.UtcNow }
};

// Get the value of the most recent entry
string? latestStatus = loginHistory.LatestValue(); // Returns "Login_Success"

// Get the entire latest record
History? latestRecord = loginHistory.LatestRecord();

Contributing

We welcome contributions! If you find a bug or have an idea for improvement, please submit an issue or a pull request on our GitHub repository.

License

This project is licensed under the GNU GENERAL PUBLIC LICENSE.

Happy coding! 🚀🌐📚

Product Compatible and additional computed target framework versions.
.NET 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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on uSignIn.CommonSettings:

Package Downloads
SMSwitch

Package Description

EmailSwitch

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.2.1 103 9/29/2026
10.2.0 288 7/29/2026
10.0.1 308 11/24/2025
10.0.0 222 11/24/2025
5.0.1 239 11/9/2025
5.0.0 372 4/12/2025
4.0.3 396 2/17/2025
4.0.2 250 1/30/2025
4.0.1 174 1/30/2025
4.0.0 218 1/8/2025
3.1.0 315 8/7/2024
3.0.0 180 8/6/2024
2.1.0 413 7/21/2024
2.0.0 295 7/21/2024
1.0.0 216 7/21/2024