New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eazy-auth

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eazy-auth - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

example/components/About.js

11

lib/auth/hocs/withAuthLogin.js

@@ -39,3 +39,4 @@ 'use strict';

var config = _extends({
credentials: ['email', 'password']
credentials: ['email', 'password'],
clearErrorOnChange: true
}, c);

@@ -65,3 +66,9 @@ var defaultCredentials = config.credentials.reduce(function (r, c) {

return function (e) {
var value = e.target.value;
var value = e;
if (e && e.target instanceof Element) {
value = e.target.value;
}
if (_this.props.error && config.clearErrorOnChange) {
_this.props.clearLoginError();
}
_this.setState(function (prevState) {

@@ -68,0 +75,0 @@ return {

49

lib/auth/saga.js

@@ -20,3 +20,3 @@ 'use strict';

var defaultMakeErrorFromException = function defaultMakeErrorFromException(ex) {
return !ex ? null : ex.message ? ex.message : ex;
return ex;
};

@@ -45,2 +45,4 @@

refreshTokenCall = _ref.refreshTokenCall,
_ref$reduxMountPoint = _ref.reduxMountPoint,
reduxMountPoint = _ref$reduxMountPoint === undefined ? 'auth' : _ref$reduxMountPoint,
_ref$localStorageName = _ref.localStorageNamespace,

@@ -208,5 +210,4 @@ localStorageNamespace = _ref$localStorageName === undefined ? 'auth' : _ref$localStorageName,

// redux saga helpers for getting tokens from redux store
// TODO: Maybe in future we can provide custom store key
var selectAuth = function selectAuth(state) {
return state.auth;
return state[reduxMountPoint];
};

@@ -497,3 +498,3 @@ function getAccessToken() {

function watchLogin() {
var _ref6, payload, credentials, _ref7, access_token, refresh_token, user;
var _ref6, payload, credentials, loginResponse, access_token, refresh_token, user;

@@ -520,19 +521,23 @@ return _regenerator2.default.wrap(function watchLogin$(_context14) {

case 10:
_ref7 = _context14.sent;
access_token = _ref7.access_token;
refresh_token = _ref7.refresh_token;
_context14.next = 15;
return (0, _effects.call)(meCall, access_token);
loginResponse = _context14.sent;
access_token = loginResponse.access_token, refresh_token = loginResponse.refresh_token;
// Using access token to get user info
// ... passing additional param loginResponse over access_token
// to get for example the user info from login response rather than
// the me api endpoint
case 15:
_context14.next = 14;
return (0, _effects.call)(meCall, access_token, loginResponse);
case 14:
user = _context14.sent;
_context14.next = 18;
_context14.next = 17;
return lsStoreAccessToken(access_token);
case 18:
_context14.next = 20;
case 17:
_context14.next = 19;
return lsStoreRefreshToken(refresh_token);
case 20:
_context14.next = 22;
case 19:
_context14.next = 21;
return (0, _effects.put)({

@@ -547,10 +552,10 @@ type: _actions.LOGIN_SUCCESS,

case 22:
_context14.next = 28;
case 21:
_context14.next = 27;
break;
case 24:
_context14.prev = 24;
case 23:
_context14.prev = 23;
_context14.t0 = _context14['catch'](7);
_context14.next = 28;
_context14.next = 27;
return (0, _effects.put)({

@@ -561,3 +566,3 @@ type: _actions.LOGIN_FAILURE,

case 28:
case 27:
case 'end':

@@ -567,3 +572,3 @@ return _context14.stop();

}
}, _marked14, this, [[7, 24]]);
}, _marked14, this, [[7, 23]]);
}

@@ -570,0 +575,0 @@

{
"name": "eazy-auth",
"version": "0.1.3",
"version": "0.1.4",
"description": "Easy auth for react + redux + saga + routerV4",

@@ -8,2 +8,3 @@ "main": "lib/index.js",

"scripts": {
"example": "webpack-dev-server",
"clean": "rimraf lib",

@@ -16,2 +17,3 @@ "build": "babel src --out-dir lib",

"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",

@@ -23,7 +25,18 @@ "babel-plugin-transform-object-rest-spread": "^6.26.0",

"babel-preset-react": "^6.24.1",
"rimraf": "^2.6.2"
"lodash": "^4.17.5",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"redux": "^3.7.2",
"redux-saga": "^0.16.0",
"rimraf": "^2.6.2",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.11.1"
},
"dependencies": {
"hoist-non-react-statics": "^2.3.1"
"css-loader": "^0.28.9",
"hoist-non-react-statics": "^2.3.1",
"style-loader": "^0.20.1"
}
}

@@ -16,2 +16,3 @@ import { PureComponent, createElement } from 'react'

credentials: ['email', 'password'],
clearErrorOnChange: true,
...c,

@@ -35,3 +36,9 @@ }

makeOnCredentialChange = field => e => {
const value = e.target.value
let value = e
if (e && e.target instanceof Element) {
value = e.target.value
}
if (this.props.error && config.clearErrorOnChange) {
this.props.clearLoginError()
}
this.setState(prevState => ({

@@ -38,0 +45,0 @@ credentials: { ...prevState.credentials, [field]: value }

@@ -15,4 +15,3 @@ import { take, call, put, select } from 'redux-saga/effects'

const defaultMakeErrorFromException = ex =>
!ex ? null : ex.message ? ex.message : ex
const defaultMakeErrorFromException = ex => ex

@@ -24,2 +23,3 @@ const makeAuth = ({

refreshTokenCall,
reduxMountPoint = 'auth',
localStorageNamespace = 'auth',

@@ -64,4 +64,3 @@ makeErrorFromException = defaultMakeErrorFromException,

// redux saga helpers for getting tokens from redux store
// TODO: Maybe in future we can provide custom store key
const selectAuth = state => state.auth
const selectAuth = state => state[reduxMountPoint]
function *getAccessToken() {

@@ -162,5 +161,9 @@ return yield select(state => selectAuth(state).accessToken)

try {
const { access_token, refresh_token } = yield call(loginCall, credentials)
const loginResponse = yield call(loginCall, credentials)
const { access_token, refresh_token } = loginResponse
// Using access token to get user info
const user = yield call(meCall, access_token)
// ... passing additional param loginResponse over access_token
// to get for example the user info from login response rather than
// the me api endpoint
const user = yield call(meCall, access_token, loginResponse)
// Store tokens

@@ -167,0 +170,0 @@ yield lsStoreAccessToken(access_token)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc