npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

authnest-server

v1.0.5

Published

Official server-side SDK for AuthNest.Provides simple Node.js utilities to integrate secure authentication, user registration, and account management via the AuthNest API..

Readme

For authnest-server npm package:

File: README.md (authnest-server)

# AuthNest Server SDK

Official Node.js/Express server library for the AuthNest authentication service. Easily handle authentication endpoints, security middleware, and route management.

## Installation

```bash
npm install authnest-server

Quick Start

const AuthNestClient = require('authnest-server');

// Initialize with environment variables
const authnest = new AuthNestClient();

// Or initialize with explicit configuration
const authnest = new AuthNestClient({
  apiKey: process.env.CLIENT_AUTHNEST_API_KEY,
  secretKey: process.env.CLIENT_AUTHNEST_SECRET_KEY,
  authnestBaseUrl: process.env.AUTHNEST_BASE_URL,
  clientBaseUrl: process.env.CLIENT_BASE_URL,
  env: process.env.NODE_ENV
});

Constructor Options

{
  apiKey: 'your_api_key',           // Required
  secretKey: 'your_secret_key',     // Required
  authnestBaseUrl: 'https://...',   // Required: AuthNest service URL
  clientBaseUrl: 'https://...',     // Required: Your server URL for callbacks
  env: 'production'                 // Optional: 'production' or 'development'
}

API Reference

getRouteHandlers()

Returns all pre-configured route handlers for easy endpoint setup.

Returns: Object with registration, login, getUserData, emailVerification, etc.

getSecurityMiddlewares()

Returns: Array of middleware functions

getModalSessionCORS()

Returns CORS setup for modal session endpoints.

Returns: Middleware function

getRegistrationLink([redirectUri, websiteId, sessionId, req])

Generates a registration redirect URL.

redirectUri: Optional callback URI (default: /api/auth/callback) websiteId: Optional website identifier sessionId: Optional session ID for frontend tracking req: Optional request object for origin detection

getLoginLink([redirectUri, websiteId, sessionId, req])

Generates a login redirect URL..

redirectUri: Optional callback URI (default: /api/auth/callback) websiteId: Optional website identifier sessionId: Optional session ID for frontend tracking req: Optional request object for origin detection

getUserDataBySession(sessionId, [filters])

Generates a user data retrieval URL using session ID.

sessionId: Required session identifier filters: Optional object with user filtering options

getUserDataBySession(sessionId, [filters])

Handles user data callback from AuthNest.

handleClientDataCallback(req, res)

Handles client data callback from AuthNest.

handleModalCallback(req, res)

Handles modal verification callback from AuthNest.

Express.js Example

const express = require('express');
const AuthNestClient = require('authnest-server');
const cookieParser = require('cookie-parser');

const app = express();
const authnest = new AuthNestClient();

app.use(cookieParser());

// Use security middlewares
app.use(AuthNestClient.getSecurityMiddlewares());

// Get all route handlers
const routeHandlers = authnest.getRouteHandlers();

// Simplified endpoints
app.get('/api/registrationLink', routeHandlers.registration);
app.get('/api/loginLink', routeHandlers.login);
app.get('/api/getUserData', routeHandlers.getUserData);
app.get('/api/emailVerificationLink', routeHandlers.emailVerification);

// Modal session endpoint
app.options('/api/authnest/authenticated-modal-session', authnest.getModalSessionCORS());
app.post('/api/authnest/authenticated-modal-session', routeHandlers.modalSession);

// Callback handlers
app.get('/api/auth/user-data-callback', routeHandlers.userDataCallback);
app.get('/api/auth/client-data-callback', routeHandlers.clientDataCallback);
app.get('/api/auth/modal-callback', routeHandlers.modalCallback);

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

Error Handling

All methods throw descriptive errors for easy debugging:

try {
  const redirectUrl = authnest.getRegistrationLink();
} catch (error) {
  console.error('Authentication error:', error.message);
}

License

MIT License - see LICENSE file for details.

Support

Create an issue on GitHub

Email: [email protected]