Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@mielk/auth

Latest version: v3.0.0

Overview

Last scanned
30 Nov 2026
Published
30 Nov 2026
npm package Publisher: mielk
2 Versions
737 Downloads

Scan summary

@mielk/auth was last scanned on 30 Nov 2026 at version 3.0.0. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 2 versions, all published within 7 days (24–30 Nov 2026).
  • Findings: No rules fired in version 3.0.0.
  • Downloads: 737 downloads.

Versions

2 versions published
Versions and the rules that fired in each
VersionPublishedStatus
3.0.0 LATEST 30 Nov 2026 No rules fired
2.0.1 24 Nov 2026 No rules fired

No rules fired in 3.0.0

Findings

Findings for v3.0.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 3.0.0; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@mielk/auth

Authentication for mielk applications: a server part for Express, a client for web and mobile, a React layer and a PostgreSQL adapter, in one package with several entry points.

Versions 1.x were published as mielk-auth (the last one on npm is 1.1.5). Version 2.0.0 and later are published as @mielk/auth (repository mielk-auth); mielk-auth gets no new versions and is marked deprecated on npm ("renamed to @mielk/auth"). The migration is described in CHANGELOG.md.

Version 2 is a rebuild of the library (TASK-191) and is not compatible with 1.x: see "Connecting in an Nx application" and its migration table. The main entry point @mielk/auth has the server part: createAuth(config) returns the Express router of the endpoints, authMiddleware and requireVerifiedEmail; it also exports the configuration and port types (AuthRepository, AuthMailer, OnUserDeleted, Clock), the error classes and the message keys (Msg). @mielk/auth/schemas has the Zod schemas of the requests and the TypeScript types of the requests and responses, @mielk/auth/client the session client, @mielk/auth/react the provider and hooks, and @mielk/auth/locales/<l> the translations of the message keys; @mielk/auth/pg has the PostgreSQL adapter and the reference migration.

Installation

Requires Node.js 24 or newer (engines.node is >=24). zod is a required peer dependency; install the other peer dependencies only for the entry points you use. The server part needs express, jose, bcryptjs and @mielk/http (^4, see Versions of @mielk/http; with Redis, which keeps the limits and locks):

npm install @mielk/auth zod express jose bcryptjs @mielk/http

The command above installs the latest published version of @mielk/auth from the registry (2.0.0 is published). For a change not published yet that you check in an application (npm:WYD-5), build a tarball in this repository and install that file instead of the registry name; the import lines stay the same (@mielk/auth, @mielk/auth/client, ...), because the package in the tarball has the name @mielk/auth:

# in the @mielk/auth repository, on the branch to verify
npm ci
npm run build
npm pack                      # creates mielk-auth-<version>.tgz
# in the application
npm install ../mielk-auth/mielk-auth-<version>.tgz zod express jose bcryptjs @mielk/http

The package is ESM only. Changes between versions are listed in CHANGELOG.md.

Entry points

Entry point Purpose Environment Peer dependencies (besides required zod ^4; all optional)
@mielk/auth Server side: authentication services and Express wiring Node.js express ^5, jose ^6, bcryptjs ^3, @mielk/http ^4
@mielk/auth/schemas Zod schemas of the requests, types of the requests and responses Node.js, web, mobile zod ^4 (required)
@mielk/auth/client Client for the authentication API (framework independent) web, mobile none
@mielk/auth/react React layer: provider and hooks on top of the client web, mobile react ^19
@mielk/auth/pg PostgreSQL adapter of the repository Node.js @mielk/db ^3, pg ^8
@mielk/auth/pg/migrations/<file> Reference SQL migration 0001_mielk_auth.sql (copied by the application to its own migrations) Node.js none
@mielk/auth/locales/<l> JSON translations (pl, en-GB) all none

Connecting in an Nx application

What the application provides: a PostgreSQL database (the library stores accounts and tokens there), Redis (counters and locks of the limits, through @mielk/http), a mailer (the library only asks for a message to be sent) and secrets in its own configuration (the library reads no environment variables). The steps below connect the API, a web application and a mobile application; each step names what to install.

1. Database

The library ships one reference migration, @mielk/auth/pg/migrations/0001_mielk_auth.sql, with the tables users, refresh_tokens and auth_tokens (only SHA-256 hashes of tokens are stored). The library does not run it:

  1. Copy the file from node_modules/@mielk/auth/dist/pg/migrations/0001_mielk_auth.sql to the migrations of the application as <schema>/NNNN_mielk_auth.sql, with the next number of its sequence.

  2. Replace app in SET LOCAL search_path = app, pg_catalog; with the schema of the application. The connection of the application must find the three tables on its search_path.

  3. Run it as the owner role of the schema, in one transaction (the file is one transaction, so a failed run leaves nothing behind).

  4. An application that already has the table users adapts the file instead of creating the table. Settle the identifier first, before the token tables are created:

    • user_id must be bigint and the primary key of users; the foreign keys refresh_tokens.user_id and auth_tokens.user_id reference it. The adapter selects it and passes it back as a string, but never inserts it: the database must generate it on INSERT (an identity column or a sequence default). A table whose key has another type, another name or no generated value is migrated (or mapped to a new user_id) by the application first.
    • Existing accounts keep their rows: map each account to a user_id, its e-mail to email and its bcrypt hash to password_hash (NULL for an account without a password).
    • Add the missing columns (email, password_hash, email_verified_at, created_at, updated_at) and the unique index users_email_lower_key on lower(email). An existing unique index on lower(email) may keep its own name: createUser looks the e-mail up in the same statement as the insert and inserts only when no account has it, so a registered address is recognised whatever the name of the index (POST /register answers 202 either way, audit N19 a, r1:U1).
  5. Rollback of a deployed migration is a new migration of the application that drops auth_tokens and refresh_tokens in this order. It drops users only when this migration created it; an application that adapted an existing users table keeps it (it removes only the columns and the index it added, when nothing else uses them). The library never changes the tables itself.

  6. The adapter uses the pool of @mielk/db/pg, the same pool as the rest of the application (one per process). Its transactions are short: bcrypt and Redis run before them, and the lock of a user is waited for at most lockTimeoutMs (createPgAuthRepository({ lockTimeoutMs }), 1-60000, default 3000); then the request is answered 503 (AccountBusyError, api/auth/account:busy) instead of holding a connection while requests of one account queue up. Set limits for the role of the application as well, so a transaction stuck in application code cannot hold the pool either (pg:TRX-1, pg:TRX-4), for example:

    ALTER ROLE app_finance SET idle_in_transaction_session_timeout = '15s';
    ALTER ROLE app_finance SET statement_timeout = '30s';
2. API (Node.js)
npm install @mielk/auth zod express jose bcryptjs @mielk/http @mielk/db pg   # or the tarball of a version not on the registry yet, see Installation
import { initDb } from '@mielk/db/pg';
import { createExpressApp, errorHandler, notFoundHandler } from '@mielk/http';
import { createAuth, mobileOriginErrorGuard, type AuthMailer } from '@mielk/auth';
import { createPgAuthRepository } from '@mielk/auth/pg';

// Provided by the application (not part of the library): config, dbConfig, redisConfig, pinoLogger, accountsRouter,
// sendMail, renderTemplate.

initDb(dbConfig); // 1. @mielk/db/pg: the pool the repository uses

const mailer: AuthMailer = {
    async send({ kind, to, url, locale }) {
        // kind: 'email_verification' | 'password_reset' | 'account_exists'; the mailer must handle all three (a
        // mailer written for an earlier 2.0.0 draft must add 'account_exists'). url carries the one-time token in its
        // fragment (#token=...). 'account_exists': somebody registered the address of an existing account; url is a
        // password reset link of that account, and the text says the account exists and may be ignored if it was not them.
        // The page of the 'email_verification' link asks for the password of the account (audit S4).
        // The text and its translation into `locale` belong to the application. A failure of the mailer is logged by the
        // library without the address and the link.
        await sendMail(to, renderTemplate(kind, locale, url));
    },
};

// 2. The inner application: request logger, security headers, shared Redis client, global limit, JSON parser.
const app = await createExpressApp({
    appPrefix: 'finance', // the same prefix as limits.appPrefix below
    redis: redisConfig,
    globalRateLimit: { limit: 300, windowSec: 60 }, // example limit per IP address; choose it in the configuration of the application
    // trustProxy: left out on purpose: the limiters key on req.ip, and with a direct connection to the application a client
    // could spoof it through X-Forwarded-For. Behind a reverse proxy set it to the exact number of trusted proxy hops
    // (e.g. trustProxy: 1 for one proxy in front of the application), only when that proxy overwrites X-Forwarded-For
    // itself and the application is reachable only through it.
});

// 3. The library: it needs the Redis client of createExpressApp, so it comes after it.
const auth = createAuth({
    jwt: { secret: config.jwtSecret }, // at least 32 random bytes, from the configuration, of this application only
    links: { web: config.webUrl, mobile: config.mobileLinkBase }, // the links in e-mails lead only here
    secureCookies: config.isProduction, // default true; false only in development (HTTP)
    limits: { appPrefix: 'finance' }, // prefix of the Redis keys, required
    repository: createPgAuthRepository(),
    mailer,
    onUserDeleted: async (_userId, _repository) => {
        // Optional. Delete the application data of the account; runs in the transaction that deletes it.
    },
    logger: pinoLogger, // optional: failures that do not fail a request
});

// 4. Routers, then the error guard of the mobile endpoints and the final handlers (so the errors of the library are
// answered). createExpressApp parses JSON before any router: the error guard keeps the 403 of a browser request to
// /mobile/* whose body that parser refused.
app.use('/v1/auth', auth.router);
app.use('/v1/accounts', auth.authMiddleware, accountsRouter); // in a handler: req.user.userId
app.use('/v1/invitations', auth.authMiddleware, auth.requireVerifiedEmail, invitationsRouter); // verified e-mail only
app.use('/v1/auth/mobile', mobileOriginErrorGuard);
app.use(notFoundHandler);
app.use(errorHandler);
app.listen(config.port);

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @mielk/auth

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Plug and Pray: Your AI Agents Are Taking Orders From Strangers
Research

Plug and Pray: Your AI Agents Are Taking Orders From Strangers

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

CVE

Java4Shell (CVE-2026-114938): Easy to Crash, Hard to Exploit — Less Than 0.12% of JVMs Estimated at Risk of RCE

Frame 2085668439 (1)
Group 1261154229