npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-security

v0.0.15

Published

Redux security

Downloads

28

Readme

redux-security

Redux security subsystem with user, group and access management

NPM version Discord

alt tag

INSTALL

Stable

npm i -S redux-security

Development

npm i -S lokhmakov/redux-security

FEATURES

  • Service architecture (redux-manager powered)
  • Journaling (redux-journal powered)
  • Persist state (PouchDB powered)
  • Dynamic service configuration (state.config):
    • docsMax = 2 - maximum docs in state.docs
    • docsMaxOverRemove: true - remove old images over docsMax
  • User management
  • Session management
  • Auth
    • signup
    • login
    • logout
    • email confirmation
  • API
    • local
    • express
    • pouch
    • socket (SocketIO)

EXAMPLES

USERS: NODE-API

require('redux-journal').enable()

const tags = 'redux-security.examples.users.node-api'

import { write, error }   from 'redux-journal'
import { manager }        from 'redux-manager'
import { usersLocal }     from 'redux-security'

const api = usersLocal()

manager.enableLogger(require('redux-node-logger')())
manager.getStore()

api.create({ username: 'user1', password: 'password1' }).then(({ userID }) => {
  write(`USER _id = ${userID} CREATED`, `${tags}.api.create`)
  return api.update({ _id: userID, username: 'user2' }).then((result) => {
    write(`SUCCESS result = ${result}`, `${tags}.api.update`)
    return api.remove({ _id: userID })
  })
}).then((result) => {
  write(`SUCCESS result = ${result}`, `${tags}.api.remove`)
}).catch((e) => {
  error(e)
})

AUTH: NODE-API

require('redux-journal').enable()

const tags = 'redux-security.examples.auth.node-api'

import { write, error }     from 'redux-journal'
import { manager }          from 'redux-manager'

const serviceAuth     = 'auth'
const serviceSessions = 'sessions'
const serviceUsers    = 'users'

import { sessionsLocal }    from 'redux-security'

const apiSessions = sessionsLocal({ serviceName: serviceSessions })

import { usersLocal }       from 'redux-security'

const apiUsers = usersLocal({ serviceName: serviceUsers })

import { authLocal }        from 'redux-security'

const apiAuth = authLocal({ serviceName: serviceAuth, serviceSessions, serviceUsers })

manager.enableLogger(require('redux-node-logger')())
manager.getStore()

const username = 'root'
const password = 'toor'

apiUsers.create({ username, password }).then(() => {
  return apiAuth.login({ username, password})
}).then((result) => {
  write(`({ username = '${username}', password = '${password}'}) SUCCESS`, `${tags}.login`)
}).catch((e) => {
  error(e)
})

AUTH: NODE-REDUX

require('redux-journal').enable()

const tags = 'redux-security.examples.auth.node-redux'

import { write, error }     from 'redux-journal'
import { manager }          from 'redux-manager'

const serviceAuth     = 'auth'
const serviceSessions = 'sessions'
const serviceUsers    = 'users'

import { sessionsLocal }    from 'redux-security'

const apiSessions = sessionsLocal({ serviceName: serviceSessions })

import { usersLocal }       from 'redux-security'

const apiUsers = usersLocal({ serviceName: serviceUsers })

import { authLocal }        from 'redux-security'
import { authActions }      from 'redux-security'

const apiAuth = authLocal({ serviceName: serviceAuth, serviceSessions, serviceUsers })

manager.enableLogger(require('redux-node-logger')())
manager.getStore()

const username = 'root'
const password = 'toor'

apiUsers.create({ username, password }).then(() => {
  manager.dispatch(authActions.login({ username, password }), serviceAuth)
}).catch((e) => {
  error(e)
})

AUTH: NODE-SOCKET

server.js

require('redux-journal').enable()

const tags = 'redux-security.examples.auth.node-socket.server'

import { write, error }     from 'redux-journal'
import { manager }          from 'redux-manager'

const serviceAuth     = 'auth'
const serviceSessions = 'sessions'
const serviceUsers    = 'users'

import { sessionsLocal }    from 'redux-security'

sessionsLocal({ serviceName: serviceSessions })

import { usersLocal }       from 'redux-security'

const apiUsers = usersLocal({ serviceName: serviceUsers })

import { authLocal }        from 'redux-security'
import { authActions }      from 'redux-security'

authLocal({ serviceName: serviceAuth, serviceSessions, serviceUsers })

manager.enableLogger(require('redux-node-logger')())
manager.getStore()

const username = 'root'
const password = 'toor'

apiUsers.create({ username, password })

import Express              from 'express'
import { Server }           from 'http'
import SocketIO             from 'socket.io'

const PORT = 3000
const app = new Express()
const server = Server(app)
const io = SocketIO(server)

server.listen(PORT, (e) => {
  if (e) return error(e)
  write(`==> 🌎  0.0.0.0:${ PORT }`)
})

import { authConfigAPISocketServer } from 'redux-security'

authConfigAPISocketServer({ io })

client.js

require('redux-journal').enable()

const tags = 'redux-security.examples.auth.node-socket'

import { write, error }     from 'redux-journal'
import { manager }          from 'redux-manager'

const serviceAuth     = 'auth'
const serverServiceName = 'auth'

import { authSocket }        from 'redux-security'
import { authActions }      from 'redux-security'

const socket = require('socket.io-client')('http://localhost:3000')
authSocket({ serviceName: serviceAuth, serverServiceName, socket })

manager.enableLogger(require('redux-node-logger')())
manager.getStore()

const username = 'root'
const password = 'toor'

manager.dispatch(authActions.login({ username, password }), serviceAuth)

REACT

server.js

require('redux-journal').enable()

import { error, write }     from 'redux-journal'

import webpack              from 'webpack'
import webpackDevMiddleware from 'webpack-dev-middleware'
import webpackHotMiddleware from 'webpack-hot-middleware'
import webpackConfig        from '../webpack.config'

const PORT = 3000
const app = require('express')()
const server = require('http').Server(app)
const io = require('socket.io')(server)

const compiler = webpack(webpackConfig)
app.use(webpackDevMiddleware(compiler, { noInfo: false, publicPath: webpackConfig.output.publicPath }))
app.use(webpackHotMiddleware(compiler))

app.use((req, res) => { res.sendFile(__dirname + '/static/index.html') })

server.listen(PORT, (e) => {
  if (e) return error(e)
  write(`==> 🌎  0.0.0.0:${ PORT }`)
})

const tags = 'redux-security.examples.auth.react.server'

import { manager }          from 'redux-manager'

const serviceAuth     = 'auth'
const serviceSessions = 'sessions'
const serviceUsers    = 'users'

import { sessionsLocal }    from 'redux-security'

sessionsLocal({ serviceName: serviceSessions })

import { usersLocal }       from 'redux-security'

const apiUsers = usersLocal({ serviceName: serviceUsers })

import { authLocal }        from 'redux-security'
import { authActions }      from 'redux-security'

authLocal({ serviceName: serviceAuth, serviceSessions, serviceUsers })

manager.enableLogger(require('redux-node-logger')())
manager.getStore()

const username = 'root'
const password = 'toor'

apiUsers.create({ username, password })

import { authConfigAPISocketServer } from 'redux-security'

authConfigAPISocketServer({ io })

client.js

require('redux-journal').enable()

import injectTapEventPlugin from 'react-tap-event-plugin'

injectTapEventPlugin()

import { manager }          from 'redux-manager'
import { authSocket }       from 'redux-security'

const serviceAuth = 'auth'

const socket = require('socket.io-client')('http://localhost:3000')
authSocket({ serviceName: serviceAuth, socket })

manager.enableLogger(require('redux-logger')())
const store = manager.getStore()

import React                from 'react'
import ReactDOM             from 'react-dom'
import { Provider }         from 'react-redux'
import { connect }          from 'react-redux'

import MuiThemeProvider     from 'material-ui/styles/MuiThemeProvider'
import getMuiTheme          from 'material-ui/styles/getMuiTheme'
import AppBar               from 'material-ui/AppBar'

import { AuthAvatar }       from 'redux-security'
import { AuthFormTabs }     from 'redux-security'

const AuthAvatar1         = connect(state => ({ auth: state[serviceAuth] }))(AuthAvatar)
const AuthFormTabs1       = connect(state => ({ auth: state[serviceAuth] }))(AuthFormTabs)

const muiTheme = getMuiTheme({ palette: { accent1Color: require('material-ui/styles/colors').deepOrange500 }})

const render = () => ReactDOM.render(
  <Provider store={ store }>
    <MuiThemeProvider muiTheme={ muiTheme }>
      <div>
        <AppBar
          title='redux-security'
          iconElementLeft={ <div/> }
          iconElementRight={ <AuthAvatar1/> }
        />
        <AuthFormTabs1/>
      </div>
    </MuiThemeProvider>
  </Provider>,
  document.getElementById('app')
)

render()