Registry / security / queueit-knownuser

queueit-knownuser

JSON →
library3.7.12jsnpmunverified

SDK for integrating Queue-it's queue management into JavaScript server-side applications, enabling request validation and redirect logic to protect backend services during traffic spikes. Current stable version is 3.7.12, released on npm and maintained by Queue-it. Key differentiators: supports Express, provides AJAX redirect handling, uses integration configuration for trigger matching. Requires Node.js v8.12+. Ships TypeScript types.

npm install queueit-knownuser
INSTALL
IMPORT
SIG · QUEUEIT-KNOWNUSER
Q
queueit-knownuser
securityjavascriptv3.7.12
harness data pending
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.

KnownUser
import { KnownUser } from 'queueit-knownuser'
const KnownUser = require('queueit-knownuser')
ESM import is preferred; CommonJS require works but may miss type definitions. The SDK exports a class, not a default.
initializeExpressContextProvider
import { initializeExpressContextProvider } from 'queueit-knownuser'
const init = require('queueit-knownuser').initializeExpressContextProvider
Function used to create context provider for Express. Not a default export.
QueueITConnector (default import)
import QueueITConnector from 'queueit-knownuser'
const QueueITConnector = require('queueit-knownuser')
The default export is an object containing KnownUser and other utilities. CommonJS require works but is not the recommended pattern for ES modules.

Demonstrates basic validation flow: reading integration config, extracting token, validating request, and handling redirects (including AJAX).

import express from 'express'; import { KnownUser, initializeExpressContextProvider } from 'queueit-knownuser'; import fs from 'fs'; const app = express(); const customerId = process.env.CUSTOMER_ID ?? ''; const secretKey = process.env.SECRET_KEY ?? ''; app.get('/', (req, res) => { const configRaw = fs.readFileSync('integrationconfiguration.json', 'utf8'); const contextProvider = initializeExpressContextProvider(req, res); const queueitToken = req.query[KnownUser.QueueITTokenKey]; const requestUrl = `${req.protocol}://${req.hostname}${req.originalUrl}`; const requestUrlWithoutToken = requestUrl.split('?')[0]; const validationResult = KnownUser.validateRequestByIntegrationConfig( requestUrlWithoutToken, queueitToken, configRaw, customerId, secretKey, contextProvider ); if (validationResult.doRedirect()) { if (validationResult.isAjaxResult) { res.set(validationResult.getAjaxQueueRedirectHeaderKey(), validationResult.getAjaxRedirectUrl()); } else { res.redirect(validationResult.redirectUrl); } } else { res.send('Welcome to the protected site'); } }); app.listen(3000);
Debug
Known issues
deprecatedThe `validateRequestByIntegrationConfig` method returns an object with `doRedirect()`, `isAjaxResult`, `getAjaxQueueRedirectHeaderKey()`, and `redirectUrl` — these are stable but the method signature might change in future major versions.
fix
Check the changelog for migrations if upgrading to v4.
affects: >=3.0.0 <4.0.0
gotchaThe `requestUrlWithoutToken` must match the browser's URL exactly; load balancers or proxies may alter the host/port. Not accounting for this will cause trigger mismatches.
fix
Use `req.hostname` (not `req.headers.host`) and reconstruct the URL carefully.
affects: >=3.0.0
gotchaThe `integrationsConfigString` must be reread on every request if the configuration changes frequently; otherwise, use caching with TTL to avoid disk I/O on every call.
fix
Implement a caching layer (e.g., in-memory cache) to store parsed config and invalidate periodically.
affects: >=3.0.0
breakingIn v3, `initializeExpressContextProvider` signature changed from `(req, res, next)` to `(req, res)`. Passing `next` as third argument causes runtime error.
fix
Call `initializeExpressContextProvider(req, res)` without `next`.
affects: >=3.0.0 <3.0.0
deprecatedThe `QueueITConnector` default import is an object; accessing `QueueITConnector.KnownUser` is correct but deprecated in favor of named imports since v3.7.
fix
Use `import { KnownUser } from 'queueit-knownuser'` instead.
affects: >=3.7.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'getHttpRequest')
Missing or malformed context provider; `initializeExpressContextProvider` not called or called incorrectly.
fix
Ensure you call `const contextProvider = initializeExpressContextProvider(req, res);` before passing it to validation.
Error: Invalid integration configuration
The `integrationconfiguration.json` file is missing, malformed, or contains invalid JSON.
fix
Verify the file exists at the expected path and is valid JSON. Use `JSON.parse(fs.readFileSync('integrationconfiguration.json', 'utf8'))` to test.
Request url is null
The `requestUrlWithoutToken` passed to `validateRequestByIntegrationConfig` is undefined or null.
fix
Ensure `requestUrlWithoutToken` is constructed correctly; use `req.protocol + '://' + req.hostname + req.originalUrl` and strip query parameters.
CORS error: Request header field x-queueit-redirect is not allowed by Access-Control-Allow-Headers
AJAX redirect headers need to be exposed via CORS; `Access-Control-Expose-Headers` must include the redirect header name.
fix
Set `Access-Control-Expose-Headers` to the value returned by `validationResult.getAjaxQueueRedirectHeaderKey()` before sending the response.
Upgrade
Version history
3.7.12latest on npm
Audit
Dependencies
expressoptionalRequired for context provider initialization in Express applications
Agent activity
16 hits · last 30 days
node
10
OpenAI (training)
1
Resources
queueit-knownuser — npm install queueit-knownuser · libregistry