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

@policiarcc/rccsystem-atlas-oidc-vanilla

v0.1.3

Published

Cliente OIDC do RCCSystem Atlas para JavaScript sem framework.

Downloads

576

Readme

@policiarcc/rccsystem-atlas-oidc-vanilla

Cliente de Login com o RCCSystem para JavaScript puro. createAtlasVanillaAuth() fornece um store pequeno com login, completeCallback, logout, subscribe e getSnapshot, sem depender de React ou Vue.

O que este pacote é

Ele atende uma SPA pública. Portanto, pode conter clientId, mas nunca clientSecret ou API Key. A transação PKCE fica em sessionStorage; tokens e identidade ficam apenas em memória. Para painel administrativo ou autorização por grupo/cargo atual, adicione um backend/BFF.

Cadastro e instalação

Cadastre no Atlas uma SPA pública com callback exato:

http://localhost:8080/auth/callback
https://portal.parceiro.com/auth/callback
npm install @policiarcc/rccsystem-atlas-oidc @policiarcc/rccsystem-atlas-oidc-vanilla

Use Vite, Parcel ou outro bundler ESM. Não tente esconder segredo com minificação/ofuscação: qualquer JavaScript entregue ao browser é público.

Cliente e store

import { createAtlasClient } from "@policiarcc/rccsystem-atlas-oidc/client";
import { createAtlasVanillaAuth } from "@policiarcc/rccsystem-atlas-oidc-vanilla";

const atlas = createAtlasClient({
  issuer: "https://atlas.policercc.com.br",
  clientId: "oidc_public_...",
  redirectUri: `${window.location.origin}/auth/callback`,
  scopes: ["openid", "profile_basic", "profile_rcc"],
});

export const auth = createAtlasVanillaAuth(atlas);

Login e callback

import { auth } from "./auth.js";

document
  .querySelector("#login")
  .addEventListener("click", () => void auth.login());
auth.subscribe((snapshot) => {
  if (snapshot.status === "error")
    showError("Não foi possível concluir o login.");
});
import { auth } from "./auth.js";

const snapshot = await auth.completeCallback();
if (snapshot.status === "authenticated") {
  renderDashboard(snapshot.session);
} else if (snapshot.status === "error") {
  renderLoginError();
} else {
  renderLogin();
}

Mantenha o callback na mesma SPA ou em um roteador client-side. Redirecionar para uma página HTML nova recria o JavaScript e descarta a sessão em memória, como esperado.

Estado e logout

const current = auth.getSnapshot();
if (current.status === "authenticated") {
  document.querySelector("#username").textContent =
    current.session.identity.username ?? "militar";
}

document.querySelector("#logout").addEventListener("click", () => {
  auth.logout();
  renderLogin();
});

Esta é uma proteção de interface, não de backend. Não use o estado da SPA para liberar dados sigilosos ou ações de maior impacto. Para isso, implemente um BFF com createAtlasServer e sessão opaca.

Problemas comuns

  • unauthorized_client: callback, host, porta ou tipo public_spa estão incorretos no Atlas.
  • Callback sem transação: usuário abriu outra aba ou o sessionStorage foi apagado; reinicie login.
  • Não logue URL de callback, authorization code, tokens ou headers.

Guia completo: SDK para JavaScript puro.