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 🙏

© 2026 – Pkg Stats / Ryan Hefner

dunv-auth

v0.0.8

Published

Helpers for authorization in react

Readme

dunv-auth

A helper library for logging in and out of a react-application. It is using a pretty standard jwt token-scheme. The token is saved to local storage. I built this package to be able to interface easily with uauth (https://github.com/dunv/uauth)

Setup

required

  • the authReducer needs to be added to the store i.e. (auth: authReducer)
  • setStore (access to redux-store) when initializing the app
  • dispatch the action loginBySavedtoken after setting the store

optional

  • setAuthComponent when a custom component for the login-screen is desired
  • if using the default authComponent for logging in: include import 'dunv-auth/lib/component.auth.less';

Usage

  • login and logout actions can be dispatched on a redux-store anywhere in the app
  • the full jwt and anything an auth-endpoint returns will be saved to the redux-store (property auth)
  • a HOC for requiring authorization with any other component can be used (withAuth)
  • creating requests with Authorization header (using Bearer jwt-token) already set (by means of Axios base requests)

Example

store.js

import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import ReduxThunk from 'redux-thunk';
import { authReducer } from 'dunv-auth';
const store = createStore(
    combineReducers({
        auth: authReducer,
    }),
    compose(applyMiddleware(ReduxThunk))
);
export default store;

index.js

import { loginBySavedToken, setStore as setStoreInDunvAuth } from 'dunv-auth';
import 'dunv-auth/lib/component.auth.less';
(async () => {
    // Init
    setStoreInDunvAuth(store);

    // If there is a saved token: log in with it
    await store.dispatch(loginBySavedToken());

    // Render
    ReactDOM.render(routes, root);
})();

requests.js

import { apiRequest, apiRequestWithoutAuth } from 'dunv-auth';
// an authenticated request to the backend with a apiUrl specified in redux-state (store.getState().config.apiUrl)
await apiRequest().post(urlPart, data);

// an authenticated request to the backend with a apiUrl specified in redux-state (store.getState().config.apiUrl) and timeout
apiRequest(timeout).post(urlPart, data);

// an authenticated request to the backend with a custom apiUrl
apiRequest(timeout, customBaseUrl).get(urlPart);

// an unauthenticated request to the backend
apiRequestWithoutAuth(timeout, customBaseUrl).get(urlPart)

Development

  • clone into dunvAuth folder
  • run npm link in dunvAuth folder
  • depend on this package in another project
  • run npm link dunv-auth in that project
  • run npm link <pathToNodeModulesReactOfProject> in dunvAuth folder (otherwise we will get the "two react versions" error https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react)
  • Hint: I could not get connect to work in this library, so I worked around it, using the store directly.
  • publish npm publish
  • build npm run build
  • watch npm run watch