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

lib-keycloak-se

v0.4.9

Published

Librería reutilizable de integración con Keycloak para proyectos de Salud Electrónica.

Readme

@salud-electronica/keycloak-se

Librería de integración con Keycloak para el ecosistema de Salud Electrónica.

Instalación

npm install @salud-electronica/keycloak-se

Configuración

import { KeycloakSE, KeycloakSEConfig } from '@salud-electronica/keycloak-se';

const config: KeycloakSEConfig = {
  authServerUrl: 'https://ssokeycloack.saludelectronica.com.co',
  realm: 'salud-electronica-dev',
  adminUsername: 'sre-admin',
  adminClientId: 'admin-cli',
  adminPassword: 'contraseña',
  clientConfig: {
    clientId: 'tu-aplicacion',
    appRole: 'rol-aplicacion',
    publicClient: false
  }
};

const keycloak = new KeycloakSE(config);

Funcionalidades Principales

1. Autenticación

// Login
const response = await keycloak.login(username, password, otpCode);

// Logout
const result = await keycloak.logout(tokenSession);

// Verificar sesión
const isValid = await keycloak.checkSessionStatus(tokenSession);

2. Gestión de Usuarios

// Crear/Asignar usuario
const result = await keycloak.createOrAssignUserWithAppRole({
  username,
  email,
  password,
  firstName,
  lastName
});

// Editar usuario
const result = await keycloak.editUser(userId, {
  firstName,
  lastName,
  email,
  enabled
});

// Eliminar usuario
const result = await keycloak.deleteUser(userId);

// Buscar por email
const result = await keycloak.getUserIdByEmail(email);

3. Gestión de Roles

// Asignar rol
const result = await keycloak.assignRoleToUser(userId, roleName);

// Obtener roles
const result = await keycloak.getUserRoles(userId);

// Eliminar rol
const result = await keycloak.removeRoleFromUser(userId, roleName);

4. Autenticación de Dos Factores

// Verificar estado 2FA
const status = await keycloak.getOtpStatus(tokenSession);

// Activar/Desactivar 2FA
const result = await keycloak.toggleTwoFactor({ tokenSession, enable });

Manejo de Errores

La librería maneja los errores de forma consistente. Todas las operaciones retornan objetos con la siguiente estructura:

interface Response {
  message: string;
  error?: boolean;
  // Campos adicionales específicos de cada operación
}

Consideraciones de Seguridad

  1. Validación de Entrada:

    • Validar todos los datos de entrada
    • Sanitizar emails y nombres de usuario
    • Implementar límites de longitud
  2. Logging:

    • Registrar intentos de login fallidos
    • Mantener registro de cambios de contraseña
    • Monitorear actividad sospechosa

Requisitos

  • Node.js >= 14
  • TypeScript >= 4.5
  • Acceso a un servidor Keycloak configurado

Documentación Adicional

Para más detalles sobre la configuración de Keycloak y mejores prácticas, consulta el Manual de Implementación.

Licencia

Este proyecto es propiedad de Salud Electrónica y su uso está restringido a los términos de la licencia.