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

lxp-auth-lib

v1.0.2

Published

Biblioteca de autenticação para plataforma da LXP.

Readme

Biblioteca de Autenticação e Autorização

Esta biblioteca fornece funcionalidades de autenticação e autorização para Serviços da plataforma da LXP. Ela permite criar e verificar tokens JWT para proteger seus serviços.

Instalação

Para instalar a biblioteca, você pode usar o npm:

npm install lxp-auth-lib

Configuração

Esta biblioteca requer as seguintes variáveis de ambiente:

RSA_PRIVATE_KEY=sua-chave-privada-rsa
RSA_PUBLIC_KEY=sua-chave-publica-rsa
LXP_JWT_EXPIRATION=24h

Elas servem para configurar e manter o token JWE gerado.

Uso Básico

Criando um Token

Para gerar um token JWE para um usuário:

import { createToken } from 'lxp-auth-lib';

// Exemplo básico - apenas com ID do usuário
const [objDecrypted, newToken] = await createToken('usuario123');

// Exemplo com informações adicionais
const [objDecrypted, newToken] = await createToken('usuario123', {
  name: 'Nome do Usuário',
  email: '[email protected]',
  roles: [1, 2], // IDs dos papéis/permissões
  isAdult: true,
  avatar: 'https://exemplo.com/avatar.jpg'
});

Verificando um Token

Para verificar um token JWT em uma requisição:

import { verifyToken } from 'lxp-auth-lib';
import { IRequest } from 'lxp-auth-lib/interfaces/request';

// Verificar um token sem restrição de papéis
const request = {
  headers: {
    authorization: 'Bearer seu-token-jwt'
  }
};
const [objDecrypted, newToken] = await verifyToken(request);

// Verificar um token com restrição de papéis
const permittedRoles = [1, 2]; // Apenas usuários com papel 1 ou 2
const [objDecrypted, newToken] = await verifyToken(request, permittedRoles);

Funcionalidades

  • Criação de tokens JWE com chaves RSA para maior segurança
  • Verificação de tokens com suporte a validação de papéis
  • Suporte para informações adicionais do usuário no payload do token

Contribuição

Para detalhes de como contribuir, acessar o CONTRIBUTING

Licença

Este projeto é licenciado sob a Licença MIT. Veja o arquivo LICENSE para detalhes.