You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,9 @@ int main() {
62
62
|`onFailure`|`std::function<void(const std::string&, const std::exception*)>`| no |`nullptr`| Failure callback; if null, `std::exit(1)`|
63
63
|`requestTimeout`|`int`| no |`15`| HTTP timeout (seconds) |
64
64
|`ttlSeconds`|`int`| no |`0` (server default: 86400) | Requested session token lifetime. `0` means "server default". Server clamps to `[3600, 604800]`; preserved across heartbeat refreshes. |
65
+
|`hwidOverride`|`std::string`| no |`""`| Optional custom HWID/subject string. When non-empty (for example `tg:123456789`), the SDK sends it instead of generating a machine fingerprint. |
66
+
67
+
For Telegram/Discord bot flows, prefer immutable IDs (`tg:<user_id>`, `discord:<user_id>`) instead of usernames.
|`requestTimeout`| int |`15`| HTTP request timeout in seconds |
80
80
|`ttlSeconds`| int |`0` (server default: 86400) | Requested session token lifetime. `0` means "server default". Server clamps to `[3600, 604800]`; preserved across heartbeat refreshes. |
81
+
|`hwidOverride`| string |`""`| Optional custom hardware/subject identifier. When non-empty, the SDK uses this value instead of generated device fingerprint data. |
82
+
83
+
### Identity-based binding example (Telegram/Discord)
84
+
85
+
```cpp
86
+
authforge::AuthForgeClient client(
87
+
"YOUR_APP_ID",
88
+
"YOUR_APP_SECRET",
89
+
"YOUR_PUBLIC_KEY",
90
+
"SERVER",
91
+
900,
92
+
authforge::AuthForgeClient::kDefaultApiBaseUrl,
93
+
onFailure,
94
+
15,
95
+
0,
96
+
"tg:" + std::to_string(telegramUserId) // or "discord:" + std::to_string(discordUserId)
97
+
);
98
+
```
81
99
82
100
## Billing
83
101
@@ -91,6 +109,7 @@ Any heartbeat interval is safe economically: a desktop app running 6h/day at a 1
91
109
| Method | Returns | Description |
92
110
|---|---|---|
93
111
|`Login(const std::string&)`|`bool`| Validates key and stores signed session (`sessionToken`, `expiresIn`, `appVariables`, `licenseVariables`) |
112
+
|`SelfBan(...)`|`bool`| Requests `/auth/selfban` to blacklist HWID/IP and optionally revoke (session-authenticated only) |
94
113
|`Logout()`|`void`| Stops heartbeat and clears all session/auth state |
95
114
|`IsAuthenticated()`|`bool`| True when an active authenticated session exists |
96
115
|`GetSessionDataJson()`|`std::optional<std::string>`| Full decoded payload JSON |
@@ -108,7 +127,7 @@ Any heartbeat interval is safe economically: a desktop app running 6h/day at a 1
108
127
If authentication fails, the SDK calls your `onFailure` callback if one is provided. If no callback is set, **the SDK calls `std::exit(1)` to terminate the process.** This is intentional — it prevents your app from running without a valid license.
- Uses post-session mode when a session token is available (`sessionToken` arg or current SDK session).
170
+
- Falls back to pre-session mode with `licenseKey` + nonce + app secret.
171
+
- In pre-session mode, revoke is always disabled client-side to avoid unsafe key revocations.
172
+
134
173
## How It Works
135
174
136
-
1.**Login** — Collects a hardware fingerprint (MAC, CPU, disk serial), generates a random nonce, and sends everything to the AuthForge API. The server validates the license key, binds the HWID, deducts a credit, and returns a signed payload. The SDK verifies the Ed25519 signature and nonce to prevent replay attacks.
175
+
1.**Login** — Uses `hwidOverride` when non-empty; otherwise collects a hardware fingerprint (MAC, CPU, disk serial). It then generates a random nonce and sends everything to the AuthForge API. The server validates the license key, binds the HWID, deducts a credit, and returns a signed payload. The SDK verifies the Ed25519 signature and nonce to prevent replay attacks.
137
176
138
177
2.**Heartbeat** — A detached background thread checks in at the configured interval. In SERVER mode, it sends a fresh nonce and verifies the response. In LOCAL mode, it re-verifies the stored signature and checks expiry without network calls.
0 commit comments