Nod management API for TypeScript
A typed client for each realm's management API (<issuer>/api/v1). The types are generated from the API's OpenAPI description, so they match what the server serves.
import { Management, NodError } from "@nod/management";
const m = new Management({ issuer: "https://auth.example.com/acme", clientId: "ops", clientSecret: process.env.SECRET! });
const alice = await m.users.create({ username: "alice", email: "alice@example.com" });
await m.organizations.addMember("initech", alice.id!);
for await (const u of m.users.all()) console.log(u.username); // follows the cursor for you
for await (const e of m.logs.all({ type: "signin.failure" })) alert(e); // the security log, oldest first
try {
await m.users.create({ username: "x" });
} catch (e) {
if (e instanceof NodError) console.log(e.status, e.error, e.description);
}
- Credentials: a machine client of the realm granted management scopes:
nod client register acme ops --machine, thennod client grant acme ops <issuer>/api --scope users:read --scope users:write …. The client gets and renews its own access token. - Covers the realm, users, clients, roles, organizations (members, roles, connections, invitations), fine-grained authorization, and the security log.
m.request(method, path, …)reaches anything else. - **Works anywhere
fetchdoes:** Node 18+, Deno, Bun, workers. Passfetchto use your own.
Developing: npm ci, npm run generate after the API's description changes, npm test (builds Nod and runs the client against a real server on a throwaway PostgreSQL). Not published yet: publishing under a package name is a person's decision.