Registry / security / elysia-basic-auth

elysia-basic-auth

JSON →
library1.0.7jsnpmunverified

Basic authentication plugin for Elysia v1.0.7. Provides HTTP Basic Auth middleware for the Elysia web framework (peer dependency elysia >= 0.7.1). Supports user-defined credentials, realm configuration, custom error messages, route exclusion via glob patterns, and optional error suppression. Last updated in 2024; no frequent releases. Differentiates by being purpose-built for Elysia with TypeScript types and Bun compatibility.

security
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Package is ESM-only; CommonJS require will fail. Use ES import syntax.

import { basicAuth } from 'elysia-basic-auth'

BasicAuthConfig is a TypeScript type/interface; use type import to avoid runtime bundling.

import type { BasicAuthConfig } from 'elysia-basic-auth'

BasicAuthUser is a TypeScript interface; use type import.

import type { BasicAuthUser } from 'elysia-basic-auth'

Sets up an Elysia server with basic auth middleware protecting all routes except /public/**

import { Elysia } from 'elysia'; import { basicAuth } from 'elysia-basic-auth'; new Elysia() .use( basicAuth({ users: [{ username: 'admin', password: process.env.ADMIN_PASSWORD ?? 'admin' }], realm: 'Protected Area', errorMessage: 'Access denied', exclude: ['/public/**'], noErrorThrown: false, }) ) .get('/protected', () => 'You are authenticated!') .listen(3000); console.log('Server running on http://localhost:3000');
Debug
Known footguns
breakingElysia >= 0.7.1 required; older versions not supported
gotchaPlugin does not export default; named export only
gotchaIf noErrorThrown is true, auth failures return undefined and do not halt request; may cause downstream errors
deprecatedPackage has not been updated since 2024; may lack Elysia compatibility updates
gotchaExclude patterns use glob matching; incorrect patterns may expose unintended routes
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
16 hits · last 30 days
gptbot
3
bytedance
3
ahrefsbot
2
amazonbot
2
Resources