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

@datsi/auth-arai-usuarios-cli

v1.0.2

Published

Reusable SAML 2.0 / OIDC authentication library for Express.js — designed for Arai-Usuarios (SIU) but compatible with any standards-compliant IdP

Readme

@datsi/auth-arai-usuarios-cli

npm version License: MIT Node.js

Librería reutilizable de autenticación SAML 2.0 / OIDC para Express.js. Diseñada para integrarse con Arai-Usuarios (SIU), compatible con cualquier IdP estándar.


Características

  • Soporte dual SAML 2.0 y OIDC — un solo cambio de configuración
  • Configuración 100% JSON (sin tocar código)
  • Profile mappers pre-armados para Arai-Usuarios
  • Hooks onAuth / onLogout para lógica personalizada
  • Middleware requireAuth para proteger rutas
  • TypeScript completo — tipos exportados listos para usar
  • Node.js ≥ 18

Instalación

npm install @datsi/auth-arai-usuarios-cli

Quick Start — SAML

import express from "express";
import { createAuth, araiProfileMapper } from "@datsi/auth-arai-usuarios-cli";

const app = express();
app.set("trust proxy", 1);

const auth = createAuth({
  profileMapper: araiProfileMapper,
  // Lee auth-arai-usuarios-cli.config.json de la raíz del proyecto
});

auth.middleware.forEach((mw) => app.use(mw));
app.use(auth.router);

// Ruta protegida
app.get("/api/datos", auth.requireAuth, (req, res) => {
  res.json({ user: req.user });
});

app.listen(4000);

auth-arai-usuarios-cli.config.json:

{
  "saml": {
    "callbackUrl": "https://dominio.com/api/auth/saml/callback",
    "entryPoint": "https://arai-usuarios.universidad.edu.ar/idp/saml2/idp/SSOService.php",
    "issuer": "https://dominio.com",
    "logoutUrl": "https://arai-usuarios.universidad.edu.ar/idp/saml2/idp/SingleLogoutService.php",
    "certPath": "./certs/idp.crt"
  },
  "session": {
    "secret": "mi-secret-seguro",
    "cookie": { "domain": "dominio.com" }
  },
  "app": { "redirectUrl": "https://dominio.com" }
}

Quick Start — OIDC

import express from "express";
import { createAuth, araiOidcProfileMapper } from "@datsi/auth-arai-usuarios-cli";

const app = express();
app.set("trust proxy", 1);

const auth = createAuth({
  oidcProfileMapper: araiOidcProfileMapper,
  // Lee auth-arai-usuarios-cli.config.json de la raíz del proyecto
});

auth.middleware.forEach((mw) => app.use(mw));
app.use(auth.router);

app.get("/api/datos", auth.requireAuth, (req, res) => {
  res.json({ user: req.user });
});

app.listen(4000);

auth-arai-usuarios-cli.config.json:

{
  "protocol": "oidc",
  "oidc": {
    "clientId": "mi-client-id",
    "clientSecret": "mi-client-secret",
    "issuerUrl": "https://arai-usuarios.universidad.edu.ar/idp",
    "authorizationURL": "https://arai-usuarios.universidad.edu.ar/idp/module.php/oidc/authorize.php",
    "tokenURL": "https://arai-usuarios.universidad.edu.ar/idp/module.php/oidc/access_token.php",
    "userInfoURL": "https://arai-usuarios.universidad.edu.ar/idp/module.php/oidc/userinfo.php",
    "callbackUrl": "https://dominio.com/api/auth/oidc/callback"
  },
  "session": {
    "secret": "mi-secret-seguro",
    "cookie": { "domain": "dominio.com" }
  },
  "app": { "redirectUrl": "https://dominio.com" }
}

El código del consumidor es idéntico para SAML y OIDC. Solo cambia la config y el profile mapper.


Rutas generadas automáticamente

| Método | SAML | OIDC | Descripción | |---|---|---|---| | GET | /api/login | /api/login | Inicia el flujo de login (redirige al IdP) | | POST/GET | /api/auth/saml/callback | /api/auth/oidc/callback | Callback del IdP | | GET | /api/user | /api/user | Usuario autenticado o 401 | | GET | /api/auth/idp/logout | /api/auth/idp/logout | Cierra sesión (SLO / end_session) |

Con "launcher": true en la config, se agregan además:

| Método | Ruta | Descripción | |---|---|---| | GET | /api/launcher-config | { enabled: true/false } | | GET | /api/apps | Apps del usuario desde appLauncherData |


Profile Mappers disponibles

| Mapper | Protocolo | Descripción | |---|---|---| | defaultProfileMapper | SAML | Pass-through de todos los atributos | | araiProfileMapper | SAML | Normaliza atributos de Arai-Usuarios | | defaultOidcProfileMapper | OIDC | Pass-through de todos los claims | | araiOidcProfileMapper | OIDC | Normaliza claims OIDC de Arai-Usuarios |


API

const auth = createAuth(options?)

| Opción | Tipo | Descripción | |---|---|---| | config | AuthConfig | Config inline (alternativa al JSON) | | configPath | string | Ruta al archivo de config | | profileMapper | ProfileMapper | Mapper SAML custom | | oidcProfileMapper | OidcProfileMapper | Mapper OIDC custom | | onAuth | PostAuthHook | Hook post-autenticación | | onLogout | PreLogoutHook | Hook pre-logout |

createAuth() retorna:

| Propiedad | Descripción | |---|---| | router | Router Express con todas las rutas de auth | | middleware | Array de middlewares (session + passport) | | requireAuth | Middleware para proteger rutas | | passport | Instancia de Passport (uso avanzado) |

createSamlAuth() es un alias retrocompatible de createAuth().


Licencia

MIT