Summary
Session renewal
A signed session used to end when its TTL ran out (24 hours by default), and the app had to log in again. Now the SDK keeps it going:- Default mode (no online check-ins): near the end of the session (the last fifth of its lifetime, or the last two heartbeat intervals if that is longer), the SDK sends one check-in,
POST /auth/heartbeat, that refreshes it. That is one check-in per session lifetime, at the check-in price (10 check-ins cost 1 credit). A transient failure is not reported; the SDK tries again at the next tick. - Renewal: if the session ran out first (the machine slept, or was offline through the end of the session), or a check-in is answered
session_expired, the SDK callsPOST /auth/renewwith the app secret, license key and HWID. It costs 1 credit, like a login, never takes a seat, and replaces the session and both variable maps. Refused (revoked,expired,hwid_mismatch, …), the session ends with that code. - Online check-ins: unchanged, except that a
session_expiredanswer, or a transient failure once the session has run out, leads to a renewal before the session ends.
With renewal off, the SDK behaves as 2.0.1 did (apart from the clocks below): no request after login in the default mode, and the session ends with
session_expired when its TTL runs out.
What it costs. An app that is started and closed within a session pays what it paid: one validation per start. An app that keeps running pays one check-in per session lifetime instead of stopping, and a renewal only when it could not refresh in time. Each renewal fires the license.validated webhook and shows in the auth log as a validation whose detail starts with renewal. See Session renewal and POST /auth/renew.
The server must have the route. A server without /auth/renew answers 404, which the SDK treats as transient: the session then ends when its lifetime is over, as with 2.0.1.
No process exit without a callback
In 2.0.1 and earlier, the Python, Node.js, C# and C++ SDKs exited the process (os._exit(1), process.exit(1), Environment.Exit(1), std::exit(1)) when a login was rejected or a session ended and no failure callback was set, and also when the callback threw. Now they never exit on their own:
- A rejected
login()returnsfalseand writes nothing to stderr. - A background failure that ends the session clears it (
isAuthenticated()isfalse), stops the timer and writesAuthForge: session ended (<code>)to stderr. - An exception thrown by the callback is ignored.
login() without checking the result, or counted on the process ending when the license is lost, either handle it yourself (check login()’s result, set a failure callback, or poll isAuthenticated()), or turn the old exit back on:
With the opt-in the SDK exits exactly as 2.0.1 did. In C++, an exit from the heartbeat thread uses
std::quick_exit(1) (std::_Exit(1) on macOS) instead of std::exit(1), so static destructors and atexit handlers do not run off the main thread. Go and Rust never exited and have no such option; loginFromFile and activateOffline never exit in any SDK.
Last failure
The Python, Node.js, C# and C++ SDKs keep the last failure they reported, with a callback or without, so an app can say whylogin() returned false:
reason is login_failed, heartbeat_failed or offline_login_failed; code is the error code. A successful login clears it; logout() does not. Go and Rust return the error from login instead. The quick starts on each SDK page now print it.
Session clocks
The SDK times a session from the moment it received it, on the monotonic clock and the wall clock together, and uses whichever has moved further. Setting the clock back no longer stretches a session, a clock that is wrong by a constant amount no longer matters, and time asleep still counts. The lifetime comes from the signed response (expiresIn minus the server’s timestamp) and never runs past the license’s expiry.
isAuthenticated()isfalseas soon as a session has run out, before the background timer reports it. For an offline license file, it turnsfalseonce the file’sexpiresAthas passed, also in a process that is already running.- A login, check-in or renewal response whose session has already ended is refused with
session_expired. - A
heartbeatIntervalof at least half the session TTL printsAuthForge: heartbeatInterval <n>s is at least half the session TTL <ttl>s; sessions may lapse between background checksonce, at construction.
Requests
- Every HTTP attempt carries a fresh nonce, including the retry after a lost response and the rate-limit retries, so a request the server processed before its response was lost is not refused as
replay_detected. - The SDK retries once only when no HTTP response arrived at all (refused, reset, closed before a response, timed out); any HTTP response is final, except
rate_limited, which is still retried after 2 and 5 seconds. - A check-in response that names a different HWID or license key than the session’s is refused as
signature_mismatch(definitive).
HTTP base URLs
An API base URL that starts withhttp:// is refused when the client is created, unless its host is 127.0.0.1, ::1 or localhost (a local test server). Use https:// for anything else. In Rust, where AuthForgeClient::new cannot return an error, the client is created, but every request fails with insecure_api_base_url (definitive) and nothing is sent.
Self-ban and the IP blacklist
selfBan() in the Python, Node.js, C# and C++ SDKs no longer adds the caller’s IP address to the app’s blacklist by default, since one address can be a whole office, school or carrier network. Pass blacklistIp: true (blacklist_ip=True) to keep the old behaviour. Go and Rust take the flag as an argument and are unchanged; the /auth/selfban endpoint itself leaves the IP alone unless the request sets the flag.
HWID source
Every SDK reports where its HWID came from:machine-id (the OS machine id), override (hwidOverride is set) or legacy (the machine id could not be read, so the pre-2.0 fingerprint is used). On the legacy fallback the SDK writes AuthForge: could not read the OS machine id (<reason>); using the legacy fingerprint as the HWID to stderr once, at construction.
The HWID itself does not change. Machines cloned from one image share a machine id and so one seat: see Cloned machines and containers.
Smaller changes
- C++:
SelfBan()throwsauthforge::AuthForgeErroron failure instead of calling the failure callback, asActivateOffline()does. The destructor no longer waits for a check-in or renewal in flight. A response larger than 1 MiB fails asnetwork_error. - Rust:
AuthForgeConfighas a new public field,auto_renew, so a struct literal that names every field and does not end with..Default::default()no longer compiles. Dropping the client no longer waits for a check-in or renewal in flight; the client isClone, and dropping any clone stops background checks for all of them, as before.heartbeat_request_timeout(8 seconds by default) also applies to renewals. - Python: a connection closed after the request was sent (
RemoteDisconnected,ConnectionResetErrorand otherOSErrors) is anetwork_error, retried once with a fresh nonce, instead of being reported asunknown_error.