Topaz Node SDK

raw JSON →
0.0.10 verified Sat Apr 25 auth: no javascript

The official Node.js SDK for Topaz, a modern authorization service. Version 0.0.10 provides early-stage client bindings for managing users, roles, and permissions via the Topaz API. It ships with TypeScript definitions and supports both ESM and CommonJS. As a very early release (pre-1.0), the API is subject to rapid change. Key differentiators include native TypeScript support and a promise-based interface, but users should be cautious about stability and expect breaking changes between minor versions.

error Cannot find module 'topaz-node'
cause Package not installed or import path incorrect.
fix
Run 'npm install topaz-node@0.0.10' and verify node_modules.
error Topaz is not a constructor
cause Using default import in CJS without .default.
fix
Use: const Topaz = require('topaz-node').default;
error TypeError: client.users.get is not a function
cause Using older version before method was renamed.
fix
Upgrade to v0.0.10: npm install topaz-node@0.0.10
error Error: API key is required
cause Missing or empty TOPAZ_API_KEY environment variable.
fix
Set environment variable or pass apiKey option in constructor.
breaking The SDK is pre-1.0 (v0.0.10) – expect frequent breaking changes between minor versions.
fix Pin to exact version and review changelog before upgrading.
deprecated The `createUser` method signature changed in v0.0.9; old signature with positional arguments is deprecated.
fix Use object parameter: client.users.create({ name: '...', email: '...' })
gotcha ESM-only environments (like Deno) require explicit import of 'topaz-node' due to missing CJS compat in some build outputs.
fix Use dynamic import or bundler that handles ESM.
gotcha The SDK uses `node-fetch` under the hood, which may cause issues in browser environments.
fix Do not use in browser; intended for Node.js only.
npm install topaz-node
yarn add topaz-node
pnpm add topaz-node

Initializes the Topaz client with environment variables and fetches a user by ID.

import Topaz, { User } from 'topaz-node';
import 'dotenv/config';

const client = new Topaz({
  apiKey: process.env.TOPAZ_API_KEY ?? '',
  baseUrl: process.env.TOPAZ_BASE_URL ?? 'https://api.topaz.sh'
});

async function main() {
  const user = await client.users.get('user123');
  console.log(user.name);
}

main().catch(console.error);