{"id":49773,"library":"ws-user","title":"ws-user","description":"ws-user v1.0.0-rc.3 provides user authentication and authorization tailored for WebSocket applications. It offers registration, login, logout, and password/email management with WebSocket-native patterns. Unlike generic auth libraries, it integrates directly with WebSocket lifecycle events. As a release candidate, the API is stable but may see minor changes before v1.0.0. Development appears active on GitHub, with releases on npm.","status":"active","version":"1.0.0-rc.3","language":"javascript","source_language":"en","source_url":"https://github.com/manuel-lohmus/ws-user","tags":["javascript","conextra","ws","user","authentication","authorization","application","login","logout"],"install":[{"cmd":"npm install ws-user","lang":"bash","label":"npm"},{"cmd":"yarn add ws-user","lang":"bash","label":"yarn"},{"cmd":"pnpm add ws-user","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; CommonJS require is not supported.","wrong":"const createUserApp = require('ws-user')","symbol":"createUserApp","correct":"import { createUserApp } from 'ws-user'"},{"note":"User is a named export, not default.","wrong":"import User from 'ws-user'","symbol":"User","correct":"import { User } from 'ws-user'"},{"note":"Utility for middleware; can also be imported as part of createUserApp.","wrong":"","symbol":"authenticate","correct":"import { authenticate } from 'ws-user'"}],"quickstart":{"code":"import { createUserApp } from 'ws-user';\nimport WebSocket from 'ws';\n\nconst app = createUserApp({\n  jwtSecret: process.env.JWT_SECRET ?? 'changeme',\n  database: 'sqlite://users.db'\n});\n\nconst wss = new WebSocket.Server({ port: 8080 });\n\nwss.on('connection', (ws, req) => {\n  ws.on('message', async (message) => {\n    const data = JSON.parse(message.toString());\n    if (data.type === 'register') {\n      const result = await app.register(ws, data.email, data.password);\n      ws.send(JSON.stringify({ type: 'registered', ...result }));\n    } else if (data.type === 'login') {\n      const result = await app.login(ws, data.email, data.password);\n      ws.send(JSON.stringify({ type: 'loggedIn', ...result }));\n    } else if (data.type === 'logout') {\n      await app.logout(ws);\n      ws.send(JSON.stringify({ type: 'loggedOut' }));\n    }\n  });\n});\n\nconsole.log('WebSocket server with auth on ws://localhost:8080');","lang":"typescript","description":"Sets up a WebSocket server with user registration, login, and logout using ws-user. Demonstrates createUserApp and basic message handling."},"warnings":[{"fix":"Pin to exact version and test before upgrading.","message":"v1.0.0-rc.3 is a release candidate; API may change before stable release.","severity":"breaking","affected_versions":"<=1.0.0-rc.3"},{"fix":"Set database: process.env.DATABASE_URL || 'sqlite://prod.db'","message":"The 'database' option defaults to an in-memory store; for production, provide persistent database connection string.","severity":"gotcha","affected_versions":">=1.0.0-rc.1"},{"fix":"Use authenticate for now, but plan migration.","message":"The 'authenticate' middleware will be renamed to 'withAuth' in v2.","severity":"deprecated","affected_versions":">=1.0.0-rc.1"},{"fix":"Install 'ws' or 'uws' separately.","message":"WebSocket library must be explicitly passed; ws-user does not bundle it.","severity":"gotcha","affected_versions":">=1.0.0-rc.1"},{"fix":"Migrate to async/await pattern.","message":"Register / login API changed from callback-based to promise-based in v0.9.0.","severity":"breaking","affected_versions":"<1.0.0-rc.1"}],"env_vars":null,"search_vec":"'activ':58 'api':46 'appear':57 'applic':16,71 'auth':32 'authent':10,69 'author':12,70 'candid':44 'chang':53 'conextra':66 'develop':56 'direct':36 'event':40 'generic':31 'github':60 'integr':35 'javascript':65 'librari':33 'lifecycl':39 'login':20,72 'logout':21,73 'manag':24 'may':50 'minor':52 'nativ':28 'npm':64 'offer':18 'password/email':23 'pattern':29 'provid':8 'registr':19 'releas':43,62 'see':51 'stabl':48 'tailor':13 'unlik':30 'user':3,6,9,68 'v1.0.0':55 'v1.0.0-rc.3':7 'websocket':15,27,38 'websocket-n':26 'ws':2,5,67 'ws-user':1,4","created_at":"2026-06-07T17:03:31.915443+00:00","updated_at":"2026-06-07T17:03:31.915443+00:00","problems":[{"fix":"Install ws: npm install ws and import WebSocket from 'ws'","cause":"WebSocket library missing or not imported","error":"Error: ws is not defined"},{"fix":"Ensure createUserApp returns an object with register, login, etc. Check import","cause":"createUserApp not called or misconfigured","error":"TypeError: app.register is not a function"},{"fix":"Set a strong JWT_SECRET environment variable","cause":"Missing or weak jwtSecret in configuration","error":"Error: Invalid JWT secret"},{"fix":"npm install ws-user@rc","cause":"Package not installed or wrong import path","error":"Module not found: Can't resolve 'ws-user'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/manuel-lohmus/ws-user#readme","github":"https://github.com/manuel-lohmus/ws-user","docs":null,"changelog":null,"pypi":null,"npm":"ws-user","openapi_spec":null,"status_page":null,"smithery":null,"categories":["security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}