{"id":27409,"library":"sp-plugin-auth","title":"Streamplace Auth Plugin","description":"An authentication plugin for Streamplace, an open-source live streaming platform. This package provides authentication middleware and utilities for Streamplace plugins. Version 0.1.10 is prerelease with no stable release cadence yet. It is designed specifically for the Streamplace ecosystem and not intended for general use. Differentiators include simple integration with Streamplace's plugin system and built-in session management.","status":"active","version":"0.1.10","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install sp-plugin-auth","lang":"bash","label":"npm"},{"cmd":"yarn add sp-plugin-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add sp-plugin-auth","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core Streamplace types and utilities are required for plugin functionality.","package":"sp-core","optional":false},{"reason":"Session management is a peer dependency for auth middleware.","package":"express-session","optional":false}],"imports":[{"note":"The package exports a single default function that returns middleware.","symbol":"default","correct":"import authPlugin from 'sp-plugin-auth'"},{"note":"AuthConfig is a TypeScript type, not a value. Use 'import type'.","wrong":"import { AuthConfig } from 'sp-plugin-auth'","symbol":"AuthConfig","correct":"import type { AuthConfig } from 'sp-plugin-auth'"},{"note":"For explicit middleware creation, use this named export. Not typically needed.","symbol":"createAuthMiddleware","correct":"import { createAuthMiddleware } from 'sp-plugin-auth'"}],"quickstart":{"code":"import authPlugin from 'sp-plugin-auth';\nimport express from 'express';\nimport session from 'express-session';\n\nconst app = express();\n\napp.use(session({ secret: process.env.SESSION_SECRET ?? 'change-me', resave: false, saveUninitialized: true }));\napp.use(authPlugin({ provider: 'github', clientId: process.env.GITHUB_CLIENT_ID ?? '', clientSecret: process.env.GITHUB_CLIENT_SECRET ?? '' }));\n\napp.get('/profile', (req, res) => {\n  res.json({ user: req.user });\n});\n\napp.listen(3000);","lang":"typescript","description":"Shows basic setup of the auth plugin with GitHub OAuth, session middleware, and a protected route."},"warnings":[{"fix":"Use default import syntax and call the function with config.","message":"v0.1.0 changed the default export from an object to a function. Update import: `import authPlugin from 'sp-plugin-auth'` instead of `const authPlugin = require('sp-plugin-auth')` or `import * as authPlugin from 'sp-plugin-auth'`.","severity":"breaking","affected_versions":"<0.1.0"},{"fix":"Remove `session` from config and add express-session middleware before the auth plugin.","message":"The `session` option in AuthConfig has been deprecated in favor of using express-session directly as middleware. Setting session in config will be removed in the next major version.","severity":"deprecated","affected_versions":">=0.1.0 <0.2.0"},{"fix":"Ensure `app.use(session(...))` is called before `app.use(authPlugin(...))`.","message":"Session middleware (express-session) must be applied before sp-plugin-auth. Otherwise, the plugin cannot initialize the session store.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Reference Streamplace type definitions by importing 'sp-core' or adding `/// <reference types=\"sp-core\" />`.","message":"When using TypeScript, the `req.user` type is augmented globally. You must include a tsconfig with Streamplace types, or you may get `Property 'user' does not exist on type 'Request'`.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Wrap route handlers in `try/catch` or use a package like `express-async-errors`.","message":"The plugin uses async callback handlers. Errors thrown in callbacks are not caught by Express unless you wrap them or use an error-handling middleware.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install sp-core` as a dependency in your project.","cause":"The package requires sp-core as a peer dependency, but it is not installed.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sp-core' imported from .../sp-plugin-auth/build/index.js"},{"fix":"Update to `import authPlugin from 'sp-plugin-auth'` and call it as a function.","cause":"Using the old import style (e.g., `const authPlugin = require('sp-plugin-auth')`) which yields an object, not a callable function.","error":"TypeError: authPlugin is not a function"},{"fix":"Ensure 'sp-core' is installed and a tsconfig includes its types, or add a local type declaration.","cause":"TypeScript cannot find the augmented Express Request type because Streamplace type definitions are missing.","error":"Property 'user' does not exist on type 'Request'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}