Registry / auth-security / sp-plugin-auth

sp-plugin-auth

JSON →
library0.1.10jsnpmunverified

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.

npm install sp-plugin-auth
INSTALL
IMPORT
SIG · SP-PLUGIN-AUTH
S
sp-plugin-auth
auth-securityjavascriptv0.1.10
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.

default
import authPlugin from 'sp-plugin-auth'
The package exports a single default function that returns middleware.
AuthConfig
import type { AuthConfig } from 'sp-plugin-auth'
import { AuthConfig } from 'sp-plugin-auth'
AuthConfig is a TypeScript type, not a value. Use 'import type'.
createAuthMiddleware
import { createAuthMiddleware } from 'sp-plugin-auth'
For explicit middleware creation, use this named export. Not typically needed.

Shows basic setup of the auth plugin with GitHub OAuth, session middleware, and a protected route.

import authPlugin from 'sp-plugin-auth'; import express from 'express'; import session from 'express-session'; const app = express(); app.use(session({ secret: process.env.SESSION_SECRET ?? 'change-me', resave: false, saveUninitialized: true })); app.use(authPlugin({ provider: 'github', clientId: process.env.GITHUB_CLIENT_ID ?? '', clientSecret: process.env.GITHUB_CLIENT_SECRET ?? '' })); app.get('/profile', (req, res) => { res.json({ user: req.user }); }); app.listen(3000);
Debug
Known issues
breakingv0.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'`.
fix
Use default import syntax and call the function with config.
affects: <0.1.0
deprecatedThe `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.
fix
Remove `session` from config and add express-session middleware before the auth plugin.
affects: >=0.1.0 <0.2.0
gotchaSession middleware (express-session) must be applied before sp-plugin-auth. Otherwise, the plugin cannot initialize the session store.
fix
Ensure `app.use(session(...))` is called before `app.use(authPlugin(...))`.
affects: >=0.1.0
gotchaWhen 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'`.
fix
Reference Streamplace type definitions by importing 'sp-core' or adding `/// <reference types="sp-core" />`.
affects: >=0.1.0
gotchaThe plugin uses async callback handlers. Errors thrown in callbacks are not caught by Express unless you wrap them or use an error-handling middleware.
fix
Wrap route handlers in `try/catch` or use a package like `express-async-errors`.
affects: >=0.1.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'sp-core' imported from .../sp-plugin-auth/build/index.js
The package requires sp-core as a peer dependency, but it is not installed.
fix
Run `npm install sp-core` as a dependency in your project.
TypeError: authPlugin is not a function
Using the old import style (e.g., `const authPlugin = require('sp-plugin-auth')`) which yields an object, not a callable function.
fix
Update to `import authPlugin from 'sp-plugin-auth'` and call it as a function.
Property 'user' does not exist on type 'Request'.
TypeScript cannot find the augmented Express Request type because Streamplace type definitions are missing.
fix
Ensure 'sp-core' is installed and a tsconfig includes its types, or add a local type declaration.
Upgrade
Version history
0.1.10latest on npm
Audit
Dependencies
sp-corerequiredCore Streamplace types and utilities are required for plugin functionality.
express-sessionrequiredSession management is a peer dependency for auth middleware.
Agent activity
14 hits · last 30 days
node
10
OpenAI (training)
1
Resources
sp-plugin-auth — npm install sp-plugin-auth · libregistry