AstraGuard.SDK
2.2.3
See the version list below for details.
dotnet add package AstraGuard.SDK --version 2.2.3
NuGet\Install-Package AstraGuard.SDK -Version 2.2.3
<PackageReference Include="AstraGuard.SDK" Version="2.2.3" />
<PackageVersion Include="AstraGuard.SDK" Version="2.2.3" />
<PackageReference Include="AstraGuard.SDK" />
paket add AstraGuard.SDK --version 2.2.3
#r "nuget: AstraGuard.SDK, 2.2.3"
#:package AstraGuard.SDK@2.2.3
#addin nuget:?package=AstraGuard.SDK&version=2.2.3
#tool nuget:?package=AstraGuard.SDK&version=2.2.3
AstraGuard.SDK — .NET License Management
The official .NET SDK for integrating AstraGuard license management into your applications.
Quick Start
Installation
dotnet add package AstraGuard.SDK
Basic Usage
using AstraGuard.SDK;
var guard = new AstraGuardClient(
apiUrl: "https://api.astraguard.io",
productId: "YOUR-PRODUCT-ID"
);
// Verify license or exit automatically
await guard.VerifyOrExit(userLicenseKey);
// Your application code runs here - license is valid!
RunYourApplication();
Features
| Feature | Description |
|---|---|
| License Validation | Validate license keys with hardware binding |
| HWID Binding | Lock licenses to specific devices automatically |
| Cloud Configuration | Remote feature toggles and runtime settings |
| Security Protections | Comprehensive tamper and analysis protection |
| Heartbeat Monitoring | Continuous license validation during runtime |
| Event System | React to license and security events |
Usage Examples
1. Simple Protection
var guard = new AstraGuardClient("https://api.astraguard.io", "PRODUCT-ID");
await guard.VerifyOrExit(licenseKey);
Console.WriteLine("Licensed application running!");
2. Advanced Integration
var guard = new AstraGuardClient("https://api.astraguard.io", "PRODUCT-ID");
// Enable protections
guard.EnableProtections();
// Event handlers
guard.OnLicenseInvalid += (s, e) => HandleInvalidLicense();
guard.OnCloudConfigUpdated += (s, config) => UpdateFeatures(config);
// Verify license
var result = await guard.VerifyLicense(licenseKey);
if (!result.Valid)
{
Console.WriteLine($"Invalid: {result.Error}");
return;
}
// Start continuous validation
guard.StartHeartbeat(TimeSpan.FromMinutes(5));
RunApp();
guard.StopHeartbeat();
guard.Dispose();
3. Cloud Configuration
⚠️ Security Notice: Cloud Variables are stored as plain strings in process memory after retrieval. They are suitable for configuration values (MOTD, URLs, feature labels) but not for security-critical gates. A memory scanner can read and modify these values at runtime. Do not use
GetCloudVariable()as the sole check for unlocking paid features or sensitive access.
// Check maintenance mode
if (guard.IsMaintenanceMode())
{
Console.WriteLine("App is in maintenance");
return;
}
// Get remote variables (use for config, not security gates)
string? motd = guard.GetCloudVariable("motd");
bool premium = guard.GetCloudVariable("premium_mode") == "true"; // ← Not tamper-proof alone
// Access all variables
foreach (var kvp in guard.CloudConfig)
{
Console.WriteLine($"{kvp.Key} = {kvp.Value}");
}
4. Custom HWID
// Use auto-generated HWID
await guard.VerifyLicense(licenseKey);
// Or provide custom HWID
await guard.VerifyLicense(licenseKey, "MY-CUSTOM-DEVICE-ID");
// Get the auto-generated HWID
string hwid = AstraGuardClient.GetMachineId();
API Reference
AstraGuardClient
Constructor
AstraGuardClient(string apiUrl, string productId)
Methods
| Method | Description |
|---|---|
VerifyLicense(key, hwid?) |
Validate a license key |
VerifyOrExit(key, hwid?, message?) |
Validate or terminate application |
StartHeartbeat(interval?, onInvalid?) |
Start continuous validation |
StopHeartbeat() |
Stop continuous validation |
EnableProtections() |
Enable all security protections |
GetCloudVariable(key) |
Get a remote configuration value |
IsMaintenanceMode() |
Check if kill switch is active |
GetMachineId() |
Get the device hardware ID |
Properties
| Property | Type | Description |
|---|---|---|
CloudConfig |
Dictionary<string, string> |
All cloud variables |
CurrentLicense |
LicenseDetails? |
Current license info |
Events
| Event | Description |
|---|---|
OnLicenseInvalid |
Fired when license becomes invalid |
OnCloudConfigUpdated |
Fired when cloud config changes |
Error Handling
var result = await guard.VerifyLicense(licenseKey);
if (!result.Valid)
{
switch (result.Error)
{
case "Key not found":
Console.WriteLine("Invalid license key");
break;
case "Key is revoked":
Console.WriteLine("License has been revoked");
break;
case "HWID mismatch":
Console.WriteLine("License bound to another device");
break;
default:
Console.WriteLine($"Error: {result.Error}");
break;
}
}
Requirements
- .NET 8.0 or later
- Newtonsoft.Json >= 13.0.3
Support
- Discord: Join Server
- Docs: docs.astraguard.io
License
MIT License
Made with ❤️ by AstraGuard
| Product | Versions 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 was computed. 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 was computed. 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. |
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
- System.Management (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.