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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@monocloud/auth-web-js

v0.1.3

Published

MonoCloud Web Authentication SDK

Readme

Introduction

MonoCloud Web Authentication SDK – secure authentication for single-page applications and other browser-based JavaScript environments.

MonoCloud is a modern, developer-friendly Identity & Access Management platform.

This SDK provides a browser-side authentication client for single-page apps (SPAs) and any JavaScript environment running in the browser. It implements OAuth 2.0 / OpenID Connect with PKCE, handles redirect and popup flows, manages sessions and tokens, and serves as the foundation for higher-level framework SDKs (React, Vue, Angular, Svelte, Astro, etc.).

📘 Documentation

Supported Platforms

  • Modern Browsers (Chrome, Edge, Firefox, Safari)

🚀 Getting Started

Requirements

  • A MonoCloud Tenant
  • A Client configured as a Single Page Application (SPA)
  • The application's URL registered in Callback URLs, Sign-out URLs and Cross Origin URLs

📦 Installation

npm install @monocloud/auth-web-js

Initialization

Create a shared MonoCloudWebJSClient instance and reuse it throughout your application.

import { MonoCloudWebJSClient } from '@monocloud/auth-web-js';

export const client = new MonoCloudWebJSClient({
  tenantDomain: 'https://<your-tenant-domain>',
  clientId: '<your-client-id>',
});

Process the Callback

Call processCallback() once at application startup. It inspects the current URL and the persisted callback state to automatically complete a pending sign-in or sign-out flow — no per-route dispatch required. When the current URL is not an in-progress callback, it is a no-op.

await client.processCallback();

Sign In and Sign Out

Start an authentication flow by redirecting the user to MonoCloud, or end the session and return the user to your sign-out callback.

await client.signIn();

await client.signOut();

Silent Sign In (SSO Restore)

Attempt to restore an authenticated session at app bootstrap without disrupting the user. Uses a hidden iframe with prompt=none; resolves to the new session on success, or rejects with a MonoCloudOPError (typically login_required) when the authorization server cannot satisfy the request without interaction.

import { MonoCloudOPError } from '@monocloud/auth-web-js';

try {
  const session = await client.signInSilent();
  console.log('Restored session for:', session.user);
} catch (error) {
  if (error instanceof MonoCloudOPError && error.error === 'login_required') {
    console.log('Not signed in');
  } else {
    throw error;
  }
}

Get the Current Session

Retrieve the active session, including the authenticated user's profile and tokens. Returns null when no user is signed in.

const session = await client.getSession();

if (session) {
  console.log(session.user);
}

When should I use auth-web-js?

Use @monocloud/auth-web-js if you are building a browser-based JavaScript application and want a secure, OIDC-compliant authentication client without tying yourself to a specific UI framework.

This package is a good fit if you:

  • Are building a single-page application (SPA) in plain JavaScript / TypeScript
  • Are writing a custom framework integration on top of MonoCloud
  • Need full control over PKCE, redirects, popups, silent refresh, and token storage
  • Want cross-tab refresh coordination and pluggable storage out of the box

Higher-level packages build on top of auth-web-js and provide framework-specific ergonomics while reusing the same underlying browser implementation.

🤝 Contributing & Support

Issues & Feedback

  • Use GitHub Issues for bug reports and feature requests.
  • For tenant or account-specific help, contact MonoCloud Support through your dashboard.

Security

Do not report security issues publicly. Please follow the contact instructions at: https://www.monocloud.com/contact

📄 License

Licensed under the MIT License. See the included LICENSE file.