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

@neog-cloud/neog-api-client

v0.1.4

Published

Pacote reutilizável para autenticação e consumo da API neog

Downloads

416

Readme

Neog Auth Client

Pacote TypeScript reutilizável para autenticação e consumo da API da plataforma neog.

Instalação

npm install @neog-cloud/neog-api-client

Configuração

import { createNeogAuth } from "@neog-cloud/neog-api-client";

const { AuthProvider, useAuth, createNeogClient } = createNeogAuth({
  baseUrl: "https://api_neog",
  authBaseUrl: "https://iam_neog",
  authRealm: "__REALM__",
  authEndpoint: "/realms/{realm}/protocol/openid-connect/token",
  authRequestFormat: "form",
  authGrantType: "password",
  authScope: "openid profile email",
  clientId: "app-id",
  clientSecret: "secret"
});

Variáveis de ambiente (exemplo local)

No app de exemplo (Vite), os valores sensíveis são lidos de um arquivo local de ambiente. Crie um arquivo .env.local na pasta do app e preencha as variáveis abaixo (o arquivo fica ignorado por padrão pelo .gitignore via *.local).

VITE_NEOG_BASE_URL=
VITE_NEOG_AUTH_BASE_URL=
VITE_NEOG_AUTH_REALM=
VITE_NEOG_AUTH_ENDPOINT=/realms/{realm}/protocol/openid-connect/token
VITE_NEOG_AUTH_REQUEST_FORMAT=form
VITE_NEOG_AUTH_GRANT_TYPE=password
VITE_NEOG_AUTH_SCOPE=openid profile email
VITE_NEOG_CLIENT_ID=
VITE_NEOG_CLIENT_SECRET=

No exemplo, o createNeogAuth usa essas variáveis, evitando valores fixos no repositório.

AuthProvider e useAuth

function App() {
  return (
    <AuthProvider>
      <Routes />
    </AuthProvider>
  );
}

function LoginButton() {
  const { login, logout, isAuthenticated, loading } = useAuth();
  return (
    <div>
      <button disabled={loading} onClick={() => login("user", "pass")}>Login</button>
      <button onClick={logout}>Logout</button>
      <span>{isAuthenticated ? "ok" : "off"}</span>
    </div>
  );
}

NeogClient.post

const client = createNeogClient();

const response = await client.get<{ id: string }>("/status");

Guia de migração (resumido)

  1. Instale o pacote:

npm install @neog-cloud/neog-api-client

2. Crie a instância:
```ts
import { createNeogAuth } from "@neog-cloud/neog-api-client";

const { AuthProvider, useAuth, createNeogClient } = createNeogAuth({
  baseUrl: "https://api_neog",
  authBaseUrl: "https://iam_neog",
  authRealm: "__REALM__",
  authEndpoint: "/realms/{realm}/protocol/openid-connect/token",
  authRequestFormat: "form",
  authGrantType: "password",
  authScope: "openid profile email",
  clientId: "app-id",
  clientSecret: "secret",
});
  1. Substitua o AuthProvider local:
    function App() {
      return (
        <AuthProvider>
          <Routes />
        </AuthProvider>
      );
    }
  2. Substitua os imports de useAuth locais pelos do pacote (mesmos campos).
  3. Substitua as chamadas HTTP por createNeogClient().post(...).

Persistência e refresh

  • Tokens são persistidos em localStorage na chave configurável (default: neog_auth).
  • Em caso de 401, o cliente tenta refresh com tokenRefreshEndpoint.
  • Se a API não fornecer refresh token, um 401 exige novo login.

Segurança

O uso de clientSecret no frontend expõe o segredo no bundle. Esta configuração deve ser usada apenas em ambientes controlados e/ou temporariamente, até a adoção de um fluxo mais seguro (ex: BFF ou PKCE).

Desenvolvimento

npm run build
npm test