
MonoCloud Auth Node SDK β secure authentication and session management for Node.js backends.
MonoCloud is a modern, developer-friendly Identity & Access Management platform.
This package provides a high-level authentication client for Node.js applications, built on top of MonoCloudβs OpenID Connect (OIDC) implementation. It abstracts the complexity of OAuth/OIDC while remaining framework-agnostic.
The SDK handles:
This package builds on
@monocloud/auth-coreand adds Node.jsβspecific session and cookie handling.
npm install @monocloud/auth-node-core
Initialize the client with your tenant and application configuration.
import { MonoCloudCoreClient } from '@monocloud/auth-node-core';
const nodeClient = new MonoCloudCoreClient({
tenantDomain: 'https://<your-tenant-domain>',
clientId: '<your-client-id>',
clientSecret: '<your-client-secret>',
appUrl: '<application-server-url>',
cookieSecret: '<cookie-secret>', // Used to encrypt the session cookie
});
β οΈ Security Note: Never commit secrets to source control. Always load them from environment variables.
The SDK is framework-agnostic. It operates on generic request/response adapters so it can be used with Express, Fastify, Hapi, or custom servers.
Redirects the user to MonoCloud to start authentication.
import type { MonoCloudRequest, MonoCloudResponse } from '@monocloud/auth-node-core';
const request: MonoCloudRequest = /* framework adapter */;
const response: MonoCloudResponse = /* framework adapter */;
// Default route: /api/auth/signin
await nodeClient.signIn(request, response);
Handles the redirect from MonoCloud, validates state, exchanges the authorization code for tokens, and sets the encrypted session cookie.
import type { MonoCloudRequest, MonoCloudResponse } from '@monocloud/auth-node-core';
const request: MonoCloudRequest = /* framework adapter */;
const response: MonoCloudResponse = /* framework adapter */;
// Default route: /api/auth/callback
await nodeClient.callback(request, response);
Retrieve the current authenticated session from the request.
const session = await nodeClient.getSession(request, response);
console.log(session);
Clears the local session and redirects the user to MonoCloud to terminate the SSO session.
import type { MonoCloudRequest, MonoCloudResponse } from '@monocloud/auth-node-core';
const request: MonoCloudRequest = /* framework adapter */;
const response: MonoCloudResponse = /* framework adapter */;
// Default route: /api/auth/signout
await nodeClient.signOut(request, response);
auth-node-core?Use @monocloud/auth-node-core if you are building a Node.js backend and want a secure authentication solution without tying yourself to a specific framework.
This package is a good fit if you:
auth-node-core builds on top of @monocloud/auth-core and adds Node-specific features such as encrypted session cookies and refresh token rotation.
Higher-level packages reuse the same underlying OIDC implementation but provide framework-specific ergonomics.
Do not report security issues publicly. Please follow the contact instructions at: https://www.monocloud.com/contact
Licensed under the MIT License. See the included LICENSE file.