KeyThai.Client
0.1.0
dotnet add package KeyThai.Client --version 0.1.0
NuGet\Install-Package KeyThai.Client -Version 0.1.0
<PackageReference Include="KeyThai.Client" Version="0.1.0" />
<PackageVersion Include="KeyThai.Client" Version="0.1.0" />
<PackageReference Include="KeyThai.Client" />
paket add KeyThai.Client --version 0.1.0
#r "nuget: KeyThai.Client, 0.1.0"
#:package KeyThai.Client@0.1.0
#addin nuget:?package=KeyThai.Client&version=0.1.0
#tool nuget:?package=KeyThai.Client&version=0.1.0
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 | 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
- BouncyCastle.Cryptography (>= 2.4.0)
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 |