KeyThai.Client 0.1.0

dotnet add package KeyThai.Client --version 0.1.0
                    
NuGet\Install-Package KeyThai.Client -Version 0.1.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="KeyThai.Client" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KeyThai.Client" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="KeyThai.Client" />
                    
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 KeyThai.Client --version 0.1.0
                    
#r "nuget: KeyThai.Client, 0.1.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 KeyThai.Client@0.1.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=KeyThai.Client&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=KeyThai.Client&version=0.1.0
                    
Install as a Cake Tool

KeyThai.Client

Official KeyThai SDK for .NET — license activation, validation, the Management API, and offline Ed25519 signature verification. Targets .NET 8. Ed25519 verification is pure-managed (BouncyCastle), so it works on every platform without native libraries.

dotnet add package KeyThai.Client

Quickstart

using KeyThai;

using var client = new KeyThaiClient("kt_live_xxxxxxxxxxxx");

var key = "KEYT-AB12-3C4D-5E6F-7G8H-9J0K";
var fingerprint = KeyThaiClient.GetDeviceFingerprint();

try
{
    // Activate this machine (consumes one seat; idempotent per fingerprint)
    var res = await client.ActivateAsync(key, fingerprint,
        new ActivateOptions { Name = "My PC", Platform = "windows" });
    Console.WriteLine($"valid={res.Valid} status={res.Status} expires={res.ExpiresAt}");

    // Later: just check status
    var v = await client.ValidateAsync(key, fingerprint);
    if (!v.Valid) Console.WriteLine($"not valid: {v.Status}");
}
catch (KeyThaiApiException ex)
{
    Console.WriteLine($"[{ex.Code}] ({ex.Status}) {ex.Message}");
}

Dependency injection

Inject an HttpClient (e.g. from IHttpClientFactory) instead of letting the client create its own:

var client = new KeyThaiClient("kt_live_...", httpClient);

Offline verification (Ed25519)

using KeyThai;

// Fetch the public JWK once and cache/embed it.
var keys = await client.ListKeysAsync();
var jwk = keys.Keys[0].PublicJwk;

// 1) Verify a live response (pass the raw JSON body, or re-serialize the object)
bool ok = KeyThaiVerifier.VerifySignature(rawResponseJson, jwk);

// 2) Verify an offline .lic file (checks signature AND expires_at)
LicFileResult lic = KeyThaiVerifier.VerifyLicFile(licFileContents, jwk);
if (!lic.Valid) throw new Exception(lic.Reason);   // e.g. "license หมดอายุ"
Console.WriteLine(lic.Payload!.ExpiresAt);

Management API

var products = await client.ListProductsAsync();
var policies = await client.ListPoliciesAsync(products[0].Id);

// Issue a license — Key (plaintext) is returned ONCE.
var created = await client.CreateLicenseAsync(new CreateLicenseRequest
{
    Product = products[0].Code!,
    PolicyId = policies[0].Id,
    HolderName = "สมชาย",
    HolderEmail = "somchai@example.com",
    Quantity = 1,
});
Console.WriteLine(created.Licenses[0].Key);

var page = await client.ListLicensesAsync(new ListLicensesQuery { Status = "active", Q = "somchai" });
await client.UpdateLicenseAsync(created.Licenses[0].Key, new UpdateLicenseRequest { Action = "suspend" });
await client.RemoveMachineAsync(created.Licenses[0].Key, fingerprint);

Error handling

Every non-2xx response throws KeyThaiApiException with Code (e.g. SEAT_LIMIT_REACHED) and Status (HTTP code). Codes: INVALID_KEY, LICENSE_SUSPENDED, LICENSE_REVOKED, LICENSE_EXPIRED, SEAT_LIMIT_REACHED, MACHINE_NOT_FOUND, RATE_LIMITED, QUOTA_EXCEEDED, UNAUTHORIZED, VALIDATION_ERROR.


คู่มือภาษาไทย

KeyThai.Client คือ SDK อย่างเป็นทางการของ KeyThai สำหรับ .NET 8 — รองรับ activate / validate license, Management API และตรวจลายเซ็น Ed25519 แบบ offline (ใช้ BouncyCastle จึงทำงานได้ทุกแพลตฟอร์ม)

ติดตั้ง

dotnet add package KeyThai.Client

เริ่มต้นใช้งาน

using KeyThai;

using var client = new KeyThaiClient("kt_live_xxxxxxxxxxxx");
var fp = KeyThaiClient.GetDeviceFingerprint();

try
{
    var res = await client.ActivateAsync("KEYT-AB12-3C4D-5E6F-7G8H-9J0K", fp,
        new ActivateOptions { Platform = "windows" });
    Console.WriteLine($"สถานะ: {res.Status}, valid: {res.Valid}");
}
catch (KeyThaiApiException ex)
{
    Console.WriteLine($"ผิดพลาด [{ex.Code}]: {ex.Message}");
}

ตรวจลายเซ็น offline + ไฟล์ .lic

var keys = await client.ListKeysAsync();
var jwk = keys.Keys[0].PublicJwk;

var lic = KeyThaiVerifier.VerifyLicFile(licFileContents, jwk);
if (!lic.Valid) throw new Exception(lic.Reason); // เช่น "license หมดอายุ"

ออก license อัตโนมัติ (Management API)

var created = await client.CreateLicenseAsync(new CreateLicenseRequest
{
    Product = "my-app",
    PolicyId = "01J...",
    HolderName = "สมชาย",
    Quantity = 1,
});
// created.Licenses[0].Key คือ plaintext key — แสดงครั้งเดียวเท่านั้น

License

MIT © KeyThai

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 137 6/6/2026