Requirements
- Node.js 18.0 or later
- No runtime dependencies beyond Node.js built-ins
Installation
Install from npm as@authforgecc/sdk:
authforge.mjs and TypeScript declarations (authforge.d.ts).
Prefer a single file in-repo? Copy
authforge.mjs from GitHub. The npm package is recommended for versioning and updates.TypeScript
Use the same import as JavaScript; types resolve from the package:Quick start
Constructor parameters
ttlSeconds
Requested session token lifetime in seconds for /auth/validate. Pass null (or omit) to accept the server default of 24 hours. The server clamps to [3600, 604800] (1 hour to 7 days). The requested TTL is preserved across heartbeat refreshes so long-running apps in LOCAL mode can stretch their offline window up to 7 days.
Billing
- Each successful
login()orvalidateLicense()costs 1 credit (one/auth/validatedebit). - Heartbeats cost 1 credit per 10 successful calls (billed on every 10th heartbeat). Any
heartbeatInterval ≥ 1is economically safe. - Revocations take effect on the next heartbeat regardless of interval.
Login
Promise<boolean>. It resolves to true if authentication succeeded, false otherwise. On success, the SDK starts background heartbeats automatically.
Validate license (no heartbeat)
/auth/validate request and Ed25519 verification as login, without mutating the client’s stored session or starting the heartbeat timer. Use this for bots and repeated checks; use login when you want background heartbeats. Successful results may also include sessionExpiresAt, licenseExpiresAt (null for lifetime keys), maxHwidSlots, hwidCount, and licenseLabel when present in the signed payload; the decoded payload is always available as sessionData.
Failure callback
If authentication or a heartbeat fails, the SDK calls youronFailure callback. If no callback is set (or the callback throws), the SDK exits the process.