TypeScript SDK
The JavaScript package, with types built in.
Install
npm install https://wardenauth.dev/packages/npm/warden-auth-1.1.0.tgzSame package as JavaScript. Types are included, no @types package needed.
User,AppInfo,SubscriptionandChatMessagetypes are exported.
The URL includes the version, and released versions never change, so a pinned install keeps working. See the changelog for older versions.
Quickstart
Replace the placeholders with your app's values from its Overview in the dashboard, where the Add Warden to your project card shows this snippet with your credentials already filled in. The application ID and public key are safe to ship; never put your seller key in client code.
import { Warden, WardenError, type User } from "warden-auth"
const app = new Warden({
appId: "YOUR_APP_ID",
publicKey: "YOUR_PUBLIC_KEY",
version: "1.0",
apiUrl: "https://wardenauth.dev/api/v1",
})
await app.init()
const user: User = await app.license(key)
console.log(`Welcome ${user.username}!`)Example project
A complete program with the usual loader menu (login, register, upgrade, key-only login) that prints the user's details. It bundles the SDK, so it runs without installing anything. Fill in the Application credentials block and put your code where it says Your application code goes here.
- Edit
- main.ts
- Run
- npm install && npm start
- Needs
- Node 20+
API
Every method maps to one call of the client API. Each response is checked against your public key, timestamp and nonce before the SDK uses it.
| Method | What it does |
|---|---|
| await app.init(…) | Start a session. Call this first. |
| await app.login(…) | Log in with a username and password. |
| await app.register(…) | Create an account by redeeming a license key. |
| await app.license(…) | Log in with just a license key. |
| await app.upgrade(…) | Redeem another key on an existing account. |
| await app.check(…) | Whether the session is still logged in. |
| await app.checkBlacklist(…) | Whether this machine's IP or HWID is blacklisted. |
| await app.var(…) | Read a global variable. |
| await app.getVar(…) | Read one of the user's variables. |
| await app.setVar(…) | Write one of the user's variables. |
| await app.file(…) | Download a file into memory. |
| await app.webhook(…) | Call one of your webhooks through the server. |
| await app.log(…) | Send a log line to your dashboard. |
| await app.ban(…) | Ban the current user (e.g. after detecting a debugger). |
| await app.fetchOnline(…) | Usernames with a logged-in session. |
| await app.fetchStats(…) | User, online and key counts. |
| await app.chatGet(…) | The last 50 messages in a channel. |
| await app.chatSend(…) | Post to a channel. |
| await app.logout(…) | End the session. |
Errors
Failures throw WardenError; e.response holds the server's reply when it rejected the request.
Rejected responses, including a bad signature, a stale timestamp or a replayed nonce, fail the same way, so a spoofed server can't log anyone in. See verifying responses, and protecting your app for what a signature check can and can't stop.