strange-auth
raw JSON → 1.0.0 verified Sat Apr 25 auth: no javascript
A Redux-based authentication toolkit by strangeluv, version 1.0.0. It provides factory functions for creating auth reducers and actions, managing login/logout status, credentials, artifacts, and errors. Targets Redux 3.x and redux-thunk 2.x. No recent updates; likely maintenance-only.
Common errors
error Cannot find module 'redux-thunk' ↓
cause Missing redux-thunk peer dependency
fix
Run: npm install redux-thunk@2.x
error Uncaught TypeError: makeActions is not a function ↓
cause Using import instead of require in a CJS-only environment
fix
Use const { makeActions } = require('strange-auth') instead of import.
error Error: Invalid credentials (or custom error) ↓
cause Login function implementation error
fix
Ensure the callback is called with (null, { credentials, artifacts }) on success, or (error) on failure.
Warnings
breaking Requires Redux 3.x and redux-thunk 2.x as peer dependencies; incompatible with Redux 4+ or newer thunk versions. ↓
fix Downgrade to Redux 3.x and redux-thunk 2.x, or find an alternative library.
deprecated No updates since 2016; likely unmaintained. Not compatible with modern Redux patterns (e.g., Redux Toolkit). ↓
fix Consider migrating to Redux Toolkit or a modern auth library.
gotcha makeActions expects a callback-style or promise-returning login/logout function; using async/await incorrectly may break. ↓
fix Ensure returned value is a promise or call the callback with (error, result).
gotcha Status constants are accessed via statuses.WAITING; string literal 'WAITING' may cause silent failures if misspelled. ↓
fix Always import statuses object and use its properties.
Install
npm install strange-auth yarn add strange-auth pnpm add strange-auth Imports
- makeReducer wrong
const StrangeAuth = require('strange-auth'); const reducer = StrangeAuth.makeReducer; // okay but default import not usedcorrectconst { makeReducer } = require('strange-auth') - makeActions wrong
const StrangeAuth = require('strange-auth'); const actions = StrangeAuth.makeActions; // okaycorrectconst { makeActions } = require('strange-auth') - types wrong
import { types } from 'strange-auth' // ESM not supportedcorrectconst { types } = require('strange-auth') - statuses wrong
const statuses = require('strange-auth').statuses; // okaycorrectconst { statuses } = require('strange-auth') - default import wrong
import StrangeAuth from 'strange-auth' // ESM not supportedcorrectconst StrangeAuth = require('strange-auth')
Quickstart
const { createStore, combineReducers } = require('redux');
const { makeReducer, makeActions, types, statuses } = require('strange-auth');
const { connect } = require('react-redux');
const authReducer = makeReducer();
const rootReducer = combineReducers({ auth: authReducer });
const store = createStore(rootReducer);
const authActions = makeActions({
login: (username, password, cb) => {
setTimeout(() => {
if (username === 'user' && password === 'pass') {
cb(null, { credentials: { token: 'abc' }, artifacts: {} });
} else {
cb(new Error('Invalid credentials'));
}
}, 100);
}
});
console.log(types); // { LOGIN_ATTEMPT: ..., LOGIN_SUCCESS: ..., LOGIN_FAILURE: ..., LOGOUT_ATTEMPT: ..., LOGOUT_SUCCESS: ..., LOGOUT_FAILURE: ... }
console.log(statuses.WAITING); // 'WAITING'