Scan your whole stack
From OX Research Newsroom
Are you using @qelos/integrator-fastify?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v4.5.1
@qelos/integrator-fastify was last scanned on 28 Nov 2026 at version 4.5.1. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 4.5.1 LATEST | 28 Nov 2026 | No rules fired |
| 4.5.0 | 28 Nov 2026 | No rules fired |
| 4.4.0 | 16 Nov 2026 | No rules fired |
| 4.3.1 | 4 Oct 2026 | Not shown |
| 4.2.2 | 17 Sep 2026 | Not shown |
Findings for v4.5.1. 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 4.5.1; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Fastify integrator for Qelos. It plugs into a Fastify app
to make the Node host act as a same-origin BFF for a managed Qelos app:
requests under /api/** are proxied to Qelos, and every other request resolves
the current user up front so your route handlers can use request.qelos.user /
request.qelos.workspace / request.qelos.workspaces / request.qelos.sdk
directly.
npm install @qelos/integrator-fastify @qelos/sdk
# fastify is a peer dependency
npm install fastify
Requires Node 18+ — the plugin uses
Response.headers.getSetCookie()to pipe individual upstreamSet-Cookieheaders back to the client.
import Fastify from 'fastify';
import qelosFastify, { requireUser } from '@qelos/integrator-fastify';
const app = Fastify();
await app.register(qelosFastify, {
config: {
appUrl: process.env.QELOS_APP_URL!, // e.g. https://yourdomain.com
},
});
// User-defined routes still take precedence — register them BEFORE listening,
// they win over the wildcard `/api/*` proxy in Fastify's radix-tree router.
app.get('/me', async (request) => ({
user: request.qelos.user,
workspace: request.qelos.workspace,
}));
// Short-circuit anonymous requests with 401:
app.get(
'/private',
{ preHandler: requireUser },
async (request) => request.qelos.user,
);
await app.listen({ port: 3000 });
When the plugin is registered with disableProxy !== true, it installs a
catch-all /api/* route that transparently proxies any /api/** request the
consuming app does not handle itself to the configured Qelos managed-app
origin. This lets the Fastify app act as a same-origin BFF: @qelos/sdk calls
from the browser, server, or the Qelos web SDK can all hit /api/... on the
Fastify host and reach Qelos without CORS or cross-site cookie pain.
User-defined routes still take precedence — Fastify's radix-tree router
matches more specific routes (/api/users) before the wildcard (/api/*), so
the proxy only catches requests no other handler matched.
The proxy forwards the incoming Cookie header as-is (the Qelos session
cookie name is treated as opaque) and forwards upstream Set-Cookie headers
back to the client, rewriting the Domain= attribute on every upstream
cookie to the inbound request's own host. That way the session cookie set by
Qelos is valid on the Fastify app's domain regardless of which host Qelos
issues cookies from.
The managed Qelos app URL (config.appUrl) is the proxy target. Env vars are
only dev-time overrides for when the configured appUrl isn't reachable from
the local host:
QELOS_PROXY_TARGET env var.QELOS_IP env var (dev fallback).QELOS_API_IP env var (dev fallback).config.appUrl.If none of these are set, the proxy handler responds with 503 so
misconfiguration fails loudly.
Set disableProxy: true on the config to skip registration of the proxy
route — useful when the Fastify app implements every /api/* route itself or
terminates the proxy elsewhere (CDN, reverse proxy, etc.). When the proxy is
disabled, /api/ is not auto-added to skipPaths, so the user-resolution
preHandler runs on /api/* routes you handle yourself.
WebSocket upgrades are not proxied; route them explicitly if needed.
On every non-/api/ request, the plugin's preHandler hook identifies the
current user by calling the managed Qelos app directly:
/api/** proxy does
(QELOS_PROXY_TARGET → QELOS_IP → QELOS_API_IP → config.appUrl).fetch('${upstream}/api/me') with the incoming request's Cookie
header forwarded verbatim — the Qelos session cookie name is opaque to
the integrator, so the whole header is piped through unchanged. Any
incoming Authorization header is forwarded too.Set-Cookie header on the upstream response, rewrite the
Domain= attribute to the inbound request's Host (port stripped) and
append it to the outgoing response. This is how session rotations from
Qelos reach the browser when the managed app and the Fastify host live on
different origins.2xx, parse the JSON body and expose it as request.qelos.user. On any
other status (or a network error), leave user = null — and respond with
401 if requireAuth is set.The preHandler is independent from the /api/** proxy: the proxy handles
forwarding of API calls themselves, while the preHandler identifies the user
on every page/non-API request before your route handlers run. To avoid
double-hitting Qelos for /api/me (once for proxying, once for user
resolution), the plugin adds /api/ to skipPaths automatically when the
proxy is enabled.
The plugin does not attempt to strip the
Secureattribute from rotated cookies. In local dev over plain HTTP, browsers will dropSecurecookies — configure the managed Qelos app to issue non-Securecookies in that environment, or run the Fastify host over HTTPS.
request.qelos is augmented onto the Fastify FastifyRequest type and gives
you a typed QelosRequestContext:
| field | description |
|---|---|
user |
The IUser body returned by /api/me, or null when anonymous. |
workspace |
The active IWorkspace for the request, or null. |
workspaces |
All workspaces the user has access to. |
sdk |
A request-scoped QelosSDK instance bound to the live cookies. |
app.get(
'/products',
{ preHandler: requireUser },
async (request) => request.qelos.sdk.entities('products').getList(),
);
The sdk reads cookies from the current request on every call, so any
session rotation piped through by the plugin is picked up automatically by
subsequent SDK requests in the same handler.
request.qelos.workspace defaults to whatever the managed Qelos app reports
on user.workspace from /api/me. That field is non-null only when the user
has already activated a workspace on the Qelos side; when it is null, the
frontend is expected to prompt the user to either activate an existing
workspace or create a new one. The plugin deliberately does not auto-pick
workspaces[0] — that would silently put the user into the wrong workspace.
To override the default (e.g. force a particular workspace per request),
pass a resolveWorkspace callback:
await app.register(qelosFastify, {
config: { appUrl: process.env.QELOS_APP_URL! },
resolveWorkspace: ({ request, user, workspaces }) => {
const headerId = request.headers['x-qelos-workspace'];
return (
workspaces.find((w) => w._id === headerId) ||
user.workspace ||
null
);
},
});
await app.register(qelosFastify, {
config: {
appUrl: 'https://yourdomain.com', // required
// Service-to-service: use a static API token instead of cookies.
apiToken: process.env.QELOS_API_TOKEN,
// Reject anonymous requests with 401. Defaults to false.
requireAuth: false,
// Skip the user-resolution preHandler for these path prefixes.
skipPaths: ['/health', '/metrics'],
// Skip registration of the catch-all `/api/*` reverse proxy route.
// When true, `/api/` is also NOT auto-added to skipPaths.
disableProxy: false,
// Anything you want passed through to the per-request SDK.
sdkOptions: {},
},
});
appUrl may also be omitted from config and passed at the top level — both
of these shapes are accepted:
await app.register(qelosFastify, {
appUrl: 'https://yourdomain.com',
apiToken: process.env.QELOS_API_TOKEN,
});
For service-to-service deployments where every request shares one Qelos API
token, set apiToken and the plugin will skip the cookie flow entirely and
build an SDK that authenticates with the static token:
await app.register(qelosFastify, {
config: {
appUrl: process.env.QELOS_APP_URL!,
apiToken: process.env.QELOS_API_TOKEN,
},
});
Install the optional @qelos/testing package and enable mock mode. The /api/** proxy then answers from an in-process mock of the Qelos API (auth, workspaces, personas, entities, ...) instead of forwarding upstream, and request.qelos / the per-request SDK talk to the same mock, with no network involved.
npm i -D @qelos/testing
await app.register(qelosFastify, {
config: {
appUrl: process.env.QELOS_URL ?? '',
// true | folder with `qelos pull` / `qelos dump` artifacts + state | MockQelosOptions
mock: process.env.NODE_ENV !== 'production' ? './.qelos-mock' : false,
},
});
You can also enable it with the environment: QELOS_MOCK=1, QELOS_MOCK=true
or QELOS_MOCK=./path/to/folder (folder with qelos pull / qelos dump
artifacts and mock state). An explicit mock config wins over the env.
fastify.qelosMock is the mock controller: await fastify.qelosMock.get() resolves to the @qelos/testing instance (state, ...) for programmatic control in dev.
The mock is created lazily, once per config, and shared by the proxy and the per-request SDK.
If mock mode is requested but @qelos/testing is not installed, requests
fail with a clear error. Production bundles without it keep working because
the package is only imported dynamically when mock mode is on.
Production guard: with NODE_ENV=production mock mode is ignored (a
warning is logged) unless you pass mock: { allowInProduction: true }.
A banner is logged whenever the mock is active.
| Runtime | Supported versions |
|---|---|
| Node.js | >= 18 |
| Fastify | 4.x, 5.x (peer: `^4.0.0 |
Unit tests run against both Fastify 4 and 5 (pnpm run test:4 / pnpm run test:5).
fetch and Headers.getSetCookie).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.
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).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.