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

@nexartis/sentinel-sdk

v1.7.0

Published

Passwordless magic-link authentication SDK for SvelteKit — client for the hosted Nexartis Sentinel auth backend.

Readme

@nexartis/sentinel-sdk

npm version License: Apache 2.0 Node

Passwordless, magic-link authentication for SvelteKit. A batteries-included client SDK for the hosted Nexartis Sentinel auth backend — five lines in hooks.server.ts, three lines in your auth route, and you're done.

Sentinel is a passwordless authentication service: users sign in with a one-time magic link delivered to their email, the SDK handles JWT issuance, secure cookie storage, automatic token refresh, and route protection. No passwords. No sessions to reap. No boilerplate.


Table of contents


What you get

  • Framework-agnostic coreSentinelClient, local JWT decode, expiry checks, structured errors, retry classification.
  • SvelteKit handle hook — JWT validation, automatic refresh on stale access tokens, route protection, event.locals.user hydration.
  • Drop-in API handlerscreateAuthHandlers() mounts login / register / poll / claim / refresh / logout on a single catch-all +server.ts.
  • Page handlershandleMagicLink, handleVerifyEmail, handleVerified for the browser-side magic-link flow.
  • Authenticated fetchauthFetch / authFetchJson for long-running client operations with transparent token refresh.
  • Launch primitivesonBeforeLogin gating, resolveRedirect for role-aware post-login destinations, configurable logoutRedirect.
  • Cookie management — HTTP-only, Secure, SameSite=Lax cookies with rotation on refresh.
  • TypeScript-first — ships .d.ts and sourcemaps.

Install

pnpm add @nexartis/sentinel-sdk
# or
npm install @nexartis/sentinel-sdk
# or
yarn add @nexartis/sentinel-sdk

Requirements

  • Node.js ≥ 20
  • SvelteKit ≥ 2.0 (optional peer — only needed for the /sveltekit* subpath exports)
  • A running Sentinel backend (self-hosted, or the free hosted tier — see below).

Configure

The SDK does not bake in any backend URL. Every request is directed at the URL you configure. Two values drive everything:

| Name | Purpose | |------|---------| | apiUrl | Base URL of the Sentinel auth backend (e.g. https://auth.example.com). | | baseUrl | Public base URL of your own app (e.g. https://app.example.com) — used when constructing magic-link callback URLs. |

Expose them via SvelteKit environment ($env/static/private for apiUrl, $env/static/public for the browser-visible base URL) and pass them into createSentinelHandle as top-level apiUrl / baseUrl options. createAuthHandlers reads the same values from event.platform.env.SENTINEL_API_URL / VITE_BASE_URL at request time and takes no URL options directly.

# .env
SENTINEL_API_URL="https://auth.example.com"
PUBLIC_BASE_URL="https://app.example.com"

Quickstart

1. Protect routes with the SvelteKit hook

// src/hooks.server.ts
import { createSentinelHandle } from '@nexartis/sentinel-sdk/sveltekit';
import { SENTINEL_API_URL } from '$env/static/private';
import { PUBLIC_BASE_URL } from '$env/static/public';

export const handle = createSentinelHandle({
  apiUrl: SENTINEL_API_URL,
  baseUrl: PUBLIC_BASE_URL,
  protectedRoutes: ['/dashboard', '/admin'],
  loginRedirect: '/auth'
});

After this hook runs, event.locals.user is populated on every request with { isAuthenticated, id, email, roles }.

2. Mount the auth API

// src/routes/api/auth/[...path]/+server.ts
import { createAuthHandlers } from '@nexartis/sentinel-sdk/sveltekit/handlers';

export const { GET, POST } = createAuthHandlers({
  // Optional: gate logins BEFORE the magic link is dispatched.
  onBeforeLogin: async (_event, { email }) => {
    if (await isBlocked(email)) {
      return { error: 'not_allowed', status: 403, redirect: '/waitlist' };
    }
  },

  // Optional: role-aware post-login destination.
  resolveRedirect: async (_event, { user, requestedRedirect, defaultRedirect }) =>
    user.roles.includes('admin') ? '/admin' : (requestedRedirect || defaultRedirect),

  // Optional: where to land after logout.
  logoutRedirect: '/'
});

3. Handle the magic link

// src/routes/auth/magic/+page.server.ts
import { handleMagicLink } from '@nexartis/sentinel-sdk/sveltekit/pages';
export const load = handleMagicLink;

// src/routes/auth/verify/+page.server.ts
import { handleVerifyEmail } from '@nexartis/sentinel-sdk/sveltekit/pages';
export const load = handleVerifyEmail;

// src/routes/auth/verified/+page.server.ts
import { handleVerified } from '@nexartis/sentinel-sdk/sveltekit/pages';
export const load = handleVerified;

4. Call your own APIs with automatic refresh

// Any client component
import { authFetchJson } from '@nexartis/sentinel-sdk/sveltekit/client';

const profile = await authFetchJson<UserProfile>('/api/me');

authFetch / authFetchJson transparently refresh the access token if it has expired mid-request, so long-running client operations don't fall over on a stale JWT.


Subpath exports

The package ships one framework-agnostic core and one SvelteKit adapter, split into focused subpaths so you only pay for what you import.

| Export | Purpose | |--------|---------| | @nexartis/sentinel-sdk/core | Framework-agnostic client: SentinelClient, decodeTokenLocally, validateToken, isTokenExpired, SentinelError, SentinelCode, createLogger, plus every response type. | | @nexartis/sentinel-sdk/sveltekit | createSentinelHandle and cookie utilities (setSessionCookies, getSessionCookies, clearAuthCookies, COOKIE_NAMES). | | @nexartis/sentinel-sdk/sveltekit/handlers | createAuthHandlers() — the catch-all API route. | | @nexartis/sentinel-sdk/sveltekit/pages | handleMagicLink, handleVerifyEmail, handleVerified for browser-side flows. | | @nexartis/sentinel-sdk/sveltekit/client | authFetch, authFetchJson for authenticated client-side requests. |

Framework-agnostic core in action

import { SentinelClient, decodeTokenLocally, isTokenExpired } from '@nexartis/sentinel-sdk/core';

const client = new SentinelClient({
  apiUrl: 'https://auth.example.com',
  baseUrl: 'https://app.example.com',
  timeoutMs: 8000,
  maxRetries: 1
});

const decoded = decodeTokenLocally(accessToken);
if (isTokenExpired(accessToken)) {
  // ... refresh via client.refresh(refreshToken)
}

Hosted Sentinel (optional)

Nexartis operates a hosted Sentinel backend so you don't have to.

  • 🆓 Free tier for reasonable use — hobby projects, small teams, side projects, indie apps.
  • 🏢 Enterprise support available for higher volumes, SLAs, custom domains, dedicated infrastructure, and compliance workloads.

Either way, this SDK is fully self-service and works against any Sentinel-compatible backend, including your own.

👉 Learn more and get in touch: https://cubicube.com


Framework support

| Framework | Status | |-----------|--------| | SvelteKit ≥ 2.0 (Svelte 5) | ✅ First-class | | Framework-agnostic core | ✅ Use anywhere — Node, Bun, Cloudflare Workers, browsers | | Next.js / Remix / Nuxt / SolidStart | Roadmap — core is designed to make new adapters straightforward |

Contributions of new adapters are welcome under the same Apache-2.0 license.


Versioning

This SDK follows Semantic Versioning and a strict never-break-minor policy: minor and patch releases are always safe to auto-update; breaking changes are reserved for majors and preceded by at least one deprecation cycle. See VERSIONING.md and CHANGELOG.md.


License

Licensed under the Apache License 2.0. Copyright © Nexartis LLC.

You may use, modify, and redistribute this SDK freely in commercial and non-commercial projects. The Sentinel hosted backend is a separate service governed by its own terms — see https://cubicube.com.