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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rurylox/sdk-node

v0.1.2

Published

SDK de Node.js para el backend de Ruryauth.

Downloads

324

Readme

@rurylox/sdk-node

Cliente mínimo para consumir el backend Rust de Ruryauth desde Node.js (sin dependencias externas).

Instalación

Node 18+ (fetch nativo) o trae tu propio fetch con fetchImpl.

Base URL recomendada por entorno: define RURYAUTH_BASE_URL (o RURYAUTH_URL) en tu .env o variables de entorno. El SDK la toma automáticamente. Si no existe, usa http://127.0.0.1:8080.

Local (mientras desarrollas el backend)

# pnpm
pnpm add ./sdk/node
# npm
npm install ./sdk/node
# yarn
yarn add ./sdk/node

Si se publica en un registry

pnpm add @rurylox/sdk-node

Uso rápido

# Dentro del repo
node -e "const { RuryauthClient } = require('./sdk/node'); console.log(new RuryauthClient().baseUrl);"

Si quieres usarlo desde otro proyecto, puedes referenciarlo con file: en tu package.json o copiar index.js.

Uso rápido

// Si lo instalaste con file: usa la ruta al paquete
const { RuryauthClient } = require('@rurylox/sdk-node');

const auth = new RuryauthClient({ baseUrl: 'http://127.0.0.1:8080' });

async function demo() {
  await auth.health(); // { status: "ok" }
  await auth.login('[email protected]'); // envía código y auto-registra si no existe
  // ...
}

Si prefieres no pasar la URL en código, exporta en tu entorno:

export RURYAUTH_BASE_URL=https://auth.midominio.com
# luego simplemente:
const auth = new RuryauthClient();

API

  • new RuryauthClient({ baseUrl?, timeoutMs?, fetchImpl? })
    • baseUrl: por defecto http://127.0.0.1:8080.
    • timeoutMs: por defecto 8000.
    • fetchImpl: opcional si tu entorno no tiene fetch global.
  • health()GET /health.
  • login(email)POST /login (auto-registro).
  • sendCode(email)POST /send-code (no auto-registro).
  • verifyCode(email, code)POST /verify-code{ token, email, redirect, message }.
  • me(token)GET /me con Authorization: Bearer <token>.
  • register(username, password)POST /register (flujo legacy).

Errores

Los errores de red o HTTP no 2xx lanzan RuryauthError con:

  • status: código HTTP.
  • body: JSON devuelto por el backend (o texto).
  • message: resumen amigable.

Ejemplo:

try {
  await auth.verifyCode('[email protected]', 'XXXXXX');
} catch (err) {
  if (err.status === 401) console.log('Código incorrecto');
  else console.error(err);
}