Sign In

@authon/node

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@authon/node

Authon Node.js SDK — verify tokens, manage users, validate webhooks

Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
21
Maintainers
1
Weekly downloads
 
Created
Source

@authon/node

Node.js server SDK for Authon — verify tokens, manage users, and validate webhooks.

Install

npm install @authon/node
# or
pnpm add @authon/node

Quick Start

Token Verification

import { AuthonBackend } from '@authon/node';

const authon = new AuthonBackend('sk_live_...');

const user = await authon.verifyToken(accessToken);
console.log(user.id, user.email);

Express Middleware

import express from 'express';
import { expressMiddleware } from '@authon/node';

const app = express();

app.use('/api', expressMiddleware({
  secretKey: process.env.AUTHON_SECRET_KEY!,
}));

app.get('/api/profile', (req, res) => {
  // req.auth is the verified AuthonUser
  res.json({ user: req.auth });
});

Fastify Plugin

import Fastify from 'fastify';
import { fastifyPlugin } from '@authon/node';

const app = Fastify();

app.addHook('onRequest', fastifyPlugin({
  secretKey: process.env.AUTHON_SECRET_KEY!,
}));

app.get('/api/profile', (request, reply) => {
  reply.send({ user: request.auth });
});

User Management

const authon = new AuthonBackend('sk_live_...');

// List users
const { data, total } = await authon.users.list({ page: 1, limit: 20 });

// Get a user
const user = await authon.users.get('user_abc123');

// Create a user
const newUser = await authon.users.create({
  email: 'new@example.com',
  password: 'securePassword',
  displayName: 'New User',
});

// Update a user
await authon.users.update('user_abc123', {
  displayName: 'Updated Name',
  publicMetadata: { role: 'admin' },
});

// Ban / unban
await authon.users.ban('user_abc123', 'Violation of ToS');
await authon.users.unban('user_abc123');

// Delete a user
await authon.users.delete('user_abc123');

Webhook Verification

import { AuthonBackend } from '@authon/node';

const authon = new AuthonBackend('sk_live_...');

app.post('/webhooks/authon', express.raw({ type: 'application/json' }), (req, res) => {
  const signature = req.headers['x-authon-signature'] as string;
  try {
    const event = authon.webhooks.verify(req.body, signature, process.env.WEBHOOK_SECRET!);
    console.log('Event:', event);
    res.sendStatus(200);
  } catch (err) {
    res.sendStatus(400);
  }
});

API Reference

AuthonBackend

MethodReturnsDescription
verifyToken(token)Promise<AuthonUser>Verify an access token
users.list(options?)Promise<ListResult<AuthonUser>>List users with pagination
users.get(id)Promise<AuthonUser>Get a user by ID
users.create(data)Promise<AuthonUser>Create a user
users.update(id, data)Promise<AuthonUser>Update a user
users.delete(id)Promise<void>Delete a user
users.ban(id, reason?)Promise<AuthonUser>Ban a user
users.unban(id)Promise<AuthonUser>Unban a user
webhooks.verify(payload, signature, secret)Record<string, unknown>Verify webhook HMAC-SHA256 signature

Middleware

ExportDescription
expressMiddleware(options)Express/Connect middleware, sets req.auth
fastifyPlugin(options)Fastify onRequest hook, sets request.auth

Documentation

authon.dev/docs

License

MIT

Keywords

authon

FAQs

Package last updated on 02 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts