> ## Documentation Index
> Fetch the complete documentation index at: https://docs.authforge.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# What's New in SDK 3.0.0

> SDK 3.0.0: session renewal, no process exit without a failure callback, the last failure and HWID source accessors, fresh nonces on retries, and what an app has to do.

This page lists what changes in the official SDKs (Python, Node.js, Go, Rust, C#, C++) in 3.0.0, and what an app has to do about each change. For most apps the answer is nothing. Apps that count on the SDK to exit the process when there is no failure callback must act: see [No process exit without a callback](#no-process-exit-without-a-callback).

## Summary

| Change | SDKs | What your app must do |
| - | - | - |
| [Session renewal](#session-renewal), on by default | All six | Nothing. Turn it off to keep the 2.0.1 behaviour. |
| [No process exit without a callback](#no-process-exit-without-a-callback) | Python, Node.js, C#, C++ | Handle a `false` from `login()`, or set `exitOnFailure` to keep the old exit. |
| [Last failure accessor](#last-failure) | Python, Node.js, C#, C++ | Nothing; use it to say why a login failed. |
| [Session clocks](#session-clocks) | All six | Nothing. |
| [Requests: a fresh nonce per attempt](#requests) | All six | Nothing. |
| [`http://` base URLs refused](#http-base-urls) | All six | Use `https://`, or a loopback host for a local test server. |
| [Self-ban leaves the IP alone by default](#self-ban-and-the-ip-blacklist) | Python, Node.js, C#, C++ | Pass `blacklistIp: true` if you want the IP blacklisted. |
| [HWID source accessor](#hwid-source) | All six | Nothing. |
| Go module path is now `github.com/AuthForgeCC/authforge-go/v3` | Go | Change the import to `/v3` and run `go get github.com/AuthForgeCC/authforge-go/v3@v3.0.0`. |
| [Smaller changes](#smaller-changes) | C++, Rust, Python | Nothing, unless you relied on the old behaviour. In Rust, a config struct literal without `..Default::default()` needs the new field. |

## 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 calls `POST /auth/renew` with 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_expired` answer, or a transient failure once the session has run out, leads to a renewal before the session ends.

The option, on by default:

| Python | Node.js | Go | Rust | C# | C++ |
| - | - | - | - | - | - |
| `auto_renew=True` (keyword only) | `autoRenew: true` | `DisableAutoRenew: false` | `auto_renew: true` | `AutoRenew = true` | `SetAutoRenew(true)` before `Login` |

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](https://docs.authforge.cc/concepts.md#session-renewal) and [POST /auth/renew](https://docs.authforge.cc/api/security.md#session-renewal-endpoint).

**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()` returns `false` and writes nothing to stderr.
* A background failure that ends the session clears it (`isAuthenticated()` is `false`), stops the timer and writes `AuthForge: session ended (<code>)` to stderr.
* An exception thrown by the callback is ignored.

**What to do.** If your app called `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:

| Python | Node.js | C# | C++ |
| - | - | - | - |
| `exit_on_failure=True` (keyword only) | `exitOnFailure: true` | `ExitOnFailure = true` | `SetExitOnFailure(true)` |

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 why `login()` returned `false`:

| Python | Node.js | C# | C++ |
| - | - | - | - |
| `get_last_failure()`: dict with `reason`, `code`, `error`, or `None` | `getLastFailure()`: `{ reason, code, error }` or `null` | `LastFailure`: `AuthForgeFailure?` with `Reason`, `Code`, `Exception` | `GetLastFailure()`: `std::optional<AuthForgeFailure>` with `reason`, `code`, `message` |

`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()` is `false` as soon as a session has run out, before the background timer reports it. For an offline license file, it turns `false` once the file's `expiresAt` has 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 `heartbeatInterval` of at least half the session TTL prints `AuthForge: heartbeatInterval <n>s is at least half the session TTL <ttl>s; sessions may lapse between background checks` once, 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 with `http://` 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.

| Python | Node.js | Go | Rust | C# | C++ |
| - | - | - | - | - | - |
| `get_hwid_source()` | `getHwidSource()` | `HwidSource()` | `hwid_source()` | `HwidSource` | `GetHwidSource()` |

The HWID itself does not change. Machines cloned from one image share a machine id and so one seat: see [Cloned machines and containers](https://docs.authforge.cc/features/hwid-locking.md#cloned-machines-and-containers).

## Smaller changes

* **C++**: `SelfBan()` throws `authforge::AuthForgeError` on failure instead of calling the failure callback, as `ActivateOffline()` does. The destructor no longer waits for a check-in or renewal in flight. A response larger than 1 MiB fails as `network_error`.
* **Rust**: `AuthForgeConfig` has 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 is `Clone`, 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`, `ConnectionResetError` and other `OSError`s) is a `network_error`, retried once with a fresh nonce, instead of being reported as `unknown_error`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.