@digigov/auth
Advanced tools
Comparing version 0.0.1-auth-flow.1 to 0.0.1-auth-flow.4
@@ -33,2 +33,3 @@ "use strict"; | ||
token: null, | ||
authenticated: false, | ||
processing: false, | ||
@@ -41,2 +42,3 @@ error: null | ||
token: action.token, | ||
authenticated: false, | ||
processing: false, | ||
@@ -61,3 +63,4 @@ error: null, | ||
processing: true, | ||
error: null | ||
error: null, | ||
authenticated: false | ||
})); | ||
@@ -71,5 +74,7 @@ | ||
case 'error': | ||
console.error('Error occured on auth procedure', action.error); | ||
return update((0, _extends2["default"])({}, state, { | ||
code: null, | ||
processing: false, | ||
authenticated: false, | ||
error: action.error, | ||
@@ -76,0 +81,0 @@ user: null, |
@@ -21,2 +21,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
token: null, | ||
authenticated: false, | ||
processing: false, | ||
@@ -29,2 +30,3 @@ error: null | ||
token: action.token, | ||
authenticated: false, | ||
processing: false, | ||
@@ -49,3 +51,4 @@ error: null, | ||
processing: true, | ||
error: null | ||
error: null, | ||
authenticated: false | ||
})); | ||
@@ -59,5 +62,7 @@ | ||
case 'error': | ||
console.error('Error occured on auth procedure', action.error); | ||
return update(_extends({}, state, { | ||
code: null, | ||
processing: false, | ||
authenticated: false, | ||
error: action.error, | ||
@@ -64,0 +69,0 @@ user: null, |
@@ -70,2 +70,4 @@ import { useEffect, useMemo } from 'react'; | ||
externalWindow.addEventListener('beforeunload', function () { | ||
window.localStorage.removeItem('popup-login'); | ||
if (readSession().authenticated) { | ||
@@ -72,0 +74,0 @@ window.location.href = new URL(nextURL, document.baseURI).href; |
@@ -72,3 +72,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
authenticate(_token.token); | ||
_context.next = 15; | ||
_context.next = 16; | ||
break; | ||
@@ -79,2 +79,3 @@ | ||
_context.t0 = _context["catch"](2); | ||
console.error('Error occured in code handling', _context.t0); | ||
dispatch({ | ||
@@ -85,3 +86,3 @@ type: 'error', | ||
case 15: | ||
case 16: | ||
case "end": | ||
@@ -102,3 +103,3 @@ return _context.stop(); | ||
_handleToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(state, dispatch) { | ||
var _token2, data, _user; | ||
var token, data, _user; | ||
@@ -109,11 +110,6 @@ return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
case 0: | ||
if (!state.token) { | ||
_context2.next = 23; | ||
break; | ||
} | ||
token = state.token || ''; | ||
_token2 = state.token || ''; | ||
if (!state.config.userDataURL) { | ||
_context2.next = 21; | ||
_context2.next = 22; | ||
break; | ||
@@ -125,11 +121,11 @@ } | ||
}); | ||
_context2.prev = 4; | ||
_context2.next = 7; | ||
_context2.prev = 3; | ||
_context2.next = 6; | ||
return fetch(state.config.userDataURL, { | ||
headers: { | ||
Authorization: "Token ".concat(_token2) | ||
Authorization: "Token ".concat(token) | ||
} | ||
}); | ||
case 7: | ||
case 6: | ||
data = _context2.sent; | ||
@@ -142,4 +138,6 @@ | ||
console.error('Error in fetch userDataURL response', data); | ||
dispatch({ | ||
type: 'error' | ||
type: 'error', | ||
error: data | ||
}); | ||
@@ -155,6 +153,6 @@ _context2.next = 16; | ||
_user = _context2.sent; | ||
login(_token2, _user); | ||
login(token, _user); | ||
case 16: | ||
_context2.next = 21; | ||
_context2.next = 22; | ||
break; | ||
@@ -164,3 +162,4 @@ | ||
_context2.prev = 18; | ||
_context2.t0 = _context2["catch"](4); | ||
_context2.t0 = _context2["catch"](3); | ||
console.error('Error in fetch userDataURL', _context2.t0); | ||
dispatch({ | ||
@@ -171,12 +170,3 @@ type: 'error', | ||
case 21: | ||
_context2.next = 24; | ||
break; | ||
case 23: | ||
if (state.user) { | ||
logout(); | ||
} | ||
case 24: | ||
case 22: | ||
case "end": | ||
@@ -186,3 +176,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, null, [[4, 18]]); | ||
}, _callee2, null, [[3, 18]]); | ||
})); | ||
@@ -193,3 +183,3 @@ return _handleToken.apply(this, arguments); | ||
useEffect(function () { | ||
if (!state.processing) { | ||
if (!state.processing && state.token && !state.user) { | ||
dispatch({ | ||
@@ -200,2 +190,4 @@ type: 'process', | ||
handleToken(state, dispatch); | ||
} else if (!state.token && state.user) { | ||
logout(); | ||
} | ||
@@ -202,0 +194,0 @@ }, [state.token]); |
@@ -15,3 +15,3 @@ var isBrowser = typeof window !== 'undefined'; | ||
token: newAuthState.token, | ||
authenticated: newAuthState.authenticated, | ||
authenticated: !!(newAuthState.user && newAuthState.token), | ||
user: newAuthState.user, | ||
@@ -18,0 +18,0 @@ id: newAuthState.id |
@@ -16,7 +16,2 @@ import React, { useEffect } from 'react'; | ||
var isPopup = window.localStorage.getItem('popup-login') === '1'; | ||
if (isPopup) { | ||
window.localStorage.removeItem('popup-login'); | ||
} | ||
useEffect(function () { | ||
@@ -23,0 +18,0 @@ if (!code) { |
@@ -21,2 +21,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
token: null, | ||
authenticated: false, | ||
processing: false, | ||
@@ -29,2 +30,3 @@ error: null | ||
token: action.token, | ||
authenticated: false, | ||
processing: false, | ||
@@ -49,3 +51,4 @@ error: null, | ||
processing: true, | ||
error: null | ||
error: null, | ||
authenticated: false | ||
})); | ||
@@ -59,5 +62,7 @@ | ||
case 'error': | ||
console.error('Error occured on auth procedure', action.error); | ||
return update(_extends({}, state, { | ||
code: null, | ||
processing: false, | ||
authenticated: false, | ||
error: action.error, | ||
@@ -64,0 +69,0 @@ user: null, |
@@ -70,2 +70,4 @@ import { useEffect, useMemo } from 'react'; | ||
externalWindow.addEventListener('beforeunload', function () { | ||
window.localStorage.removeItem('popup-login'); | ||
if (readSession().authenticated) { | ||
@@ -72,0 +74,0 @@ window.location.href = new URL(nextURL, document.baseURI).href; |
@@ -1,2 +0,2 @@ | ||
/** @license Digigov v0.0.1-auth-flow.1+48578ec | ||
/** @license Digigov v0.0.1-auth-flow.4+9170502 | ||
* | ||
@@ -77,3 +77,3 @@ * This source code is licensed under the MIT license found in the | ||
authenticate(_token.token); | ||
_context.next = 15; | ||
_context.next = 16; | ||
break; | ||
@@ -84,2 +84,3 @@ | ||
_context.t0 = _context["catch"](2); | ||
console.error('Error occured in code handling', _context.t0); | ||
dispatch({ | ||
@@ -90,3 +91,3 @@ type: 'error', | ||
case 15: | ||
case 16: | ||
case "end": | ||
@@ -107,3 +108,3 @@ return _context.stop(); | ||
_handleToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(state, dispatch) { | ||
var _token2, data, _user; | ||
var token, data, _user; | ||
@@ -114,11 +115,6 @@ return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
case 0: | ||
if (!state.token) { | ||
_context2.next = 23; | ||
break; | ||
} | ||
token = state.token || ''; | ||
_token2 = state.token || ''; | ||
if (!state.config.userDataURL) { | ||
_context2.next = 21; | ||
_context2.next = 22; | ||
break; | ||
@@ -130,11 +126,11 @@ } | ||
}); | ||
_context2.prev = 4; | ||
_context2.next = 7; | ||
_context2.prev = 3; | ||
_context2.next = 6; | ||
return fetch(state.config.userDataURL, { | ||
headers: { | ||
Authorization: "Token ".concat(_token2) | ||
Authorization: "Token ".concat(token) | ||
} | ||
}); | ||
case 7: | ||
case 6: | ||
data = _context2.sent; | ||
@@ -147,4 +143,6 @@ | ||
console.error('Error in fetch userDataURL response', data); | ||
dispatch({ | ||
type: 'error' | ||
type: 'error', | ||
error: data | ||
}); | ||
@@ -160,6 +158,6 @@ _context2.next = 16; | ||
_user = _context2.sent; | ||
login(_token2, _user); | ||
login(token, _user); | ||
case 16: | ||
_context2.next = 21; | ||
_context2.next = 22; | ||
break; | ||
@@ -169,3 +167,4 @@ | ||
_context2.prev = 18; | ||
_context2.t0 = _context2["catch"](4); | ||
_context2.t0 = _context2["catch"](3); | ||
console.error('Error in fetch userDataURL', _context2.t0); | ||
dispatch({ | ||
@@ -176,12 +175,3 @@ type: 'error', | ||
case 21: | ||
_context2.next = 24; | ||
break; | ||
case 23: | ||
if (state.user) { | ||
logout(); | ||
} | ||
case 24: | ||
case 22: | ||
case "end": | ||
@@ -191,3 +181,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, null, [[4, 18]]); | ||
}, _callee2, null, [[3, 18]]); | ||
})); | ||
@@ -198,3 +188,3 @@ return _handleToken.apply(this, arguments); | ||
useEffect(function () { | ||
if (!state.processing) { | ||
if (!state.processing && state.token && !state.user) { | ||
dispatch({ | ||
@@ -205,2 +195,4 @@ type: 'process', | ||
handleToken(state, dispatch); | ||
} else if (!state.token && state.user) { | ||
logout(); | ||
} | ||
@@ -207,0 +199,0 @@ }, [state.token]); |
@@ -15,3 +15,3 @@ var isBrowser = typeof window !== 'undefined'; | ||
token: newAuthState.token, | ||
authenticated: newAuthState.authenticated, | ||
authenticated: !!(newAuthState.user && newAuthState.token), | ||
user: newAuthState.user, | ||
@@ -18,0 +18,0 @@ id: newAuthState.id |
@@ -16,7 +16,2 @@ import React, { useEffect } from 'react'; | ||
var isPopup = window.localStorage.getItem('popup-login') === '1'; | ||
if (isPopup) { | ||
window.localStorage.removeItem('popup-login'); | ||
} | ||
useEffect(function () { | ||
@@ -23,0 +18,0 @@ if (!code) { |
@@ -94,2 +94,4 @@ "use strict"; | ||
externalWindow.addEventListener('beforeunload', function () { | ||
window.localStorage.removeItem('popup-login'); | ||
if ((0, _localSession.readSession)().authenticated) { | ||
@@ -96,0 +98,0 @@ window.location.href = new URL(nextURL, document.baseURI).href; |
54
index.js
@@ -1,2 +0,2 @@ | ||
/** @license Digigov v0.0.1-auth-flow.1+48578ec | ||
/** @license Digigov v0.0.1-auth-flow.4+9170502 | ||
* | ||
@@ -131,3 +131,3 @@ * This source code is licensed under the MIT license found in the | ||
authenticate(_token.token); | ||
_context.next = 15; | ||
_context.next = 16; | ||
break; | ||
@@ -138,2 +138,3 @@ | ||
_context.t0 = _context["catch"](2); | ||
console.error('Error occured in code handling', _context.t0); | ||
dispatch({ | ||
@@ -144,3 +145,3 @@ type: 'error', | ||
case 15: | ||
case 16: | ||
case "end": | ||
@@ -161,3 +162,3 @@ return _context.stop(); | ||
_handleToken = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(state, dispatch) { | ||
var _token2, data, _user; | ||
var token, data, _user; | ||
@@ -168,11 +169,6 @@ return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
case 0: | ||
if (!state.token) { | ||
_context2.next = 23; | ||
break; | ||
} | ||
token = state.token || ''; | ||
_token2 = state.token || ''; | ||
if (!state.config.userDataURL) { | ||
_context2.next = 21; | ||
_context2.next = 22; | ||
break; | ||
@@ -184,11 +180,11 @@ } | ||
}); | ||
_context2.prev = 4; | ||
_context2.next = 7; | ||
_context2.prev = 3; | ||
_context2.next = 6; | ||
return fetch(state.config.userDataURL, { | ||
headers: { | ||
Authorization: "Token ".concat(_token2) | ||
Authorization: "Token ".concat(token) | ||
} | ||
}); | ||
case 7: | ||
case 6: | ||
data = _context2.sent; | ||
@@ -201,4 +197,6 @@ | ||
console.error('Error in fetch userDataURL response', data); | ||
dispatch({ | ||
type: 'error' | ||
type: 'error', | ||
error: data | ||
}); | ||
@@ -214,6 +212,6 @@ _context2.next = 16; | ||
_user = _context2.sent; | ||
login(_token2, _user); | ||
login(token, _user); | ||
case 16: | ||
_context2.next = 21; | ||
_context2.next = 22; | ||
break; | ||
@@ -223,3 +221,4 @@ | ||
_context2.prev = 18; | ||
_context2.t0 = _context2["catch"](4); | ||
_context2.t0 = _context2["catch"](3); | ||
console.error('Error in fetch userDataURL', _context2.t0); | ||
dispatch({ | ||
@@ -230,12 +229,3 @@ type: 'error', | ||
case 21: | ||
_context2.next = 24; | ||
break; | ||
case 23: | ||
if (state.user) { | ||
logout(); | ||
} | ||
case 24: | ||
case 22: | ||
case "end": | ||
@@ -245,3 +235,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, null, [[4, 18]]); | ||
}, _callee2, null, [[3, 18]]); | ||
})); | ||
@@ -252,3 +242,3 @@ return _handleToken.apply(this, arguments); | ||
(0, _react.useEffect)(function () { | ||
if (!state.processing) { | ||
if (!state.processing && state.token && !state.user) { | ||
dispatch({ | ||
@@ -259,2 +249,4 @@ type: 'process', | ||
handleToken(state, dispatch); | ||
} else if (!state.token && state.user) { | ||
logout(); | ||
} | ||
@@ -261,0 +253,0 @@ }, [state.token]); |
@@ -23,3 +23,3 @@ "use strict"; | ||
token: newAuthState.token, | ||
authenticated: newAuthState.authenticated, | ||
authenticated: !!(newAuthState.user && newAuthState.token), | ||
user: newAuthState.user, | ||
@@ -26,0 +26,0 @@ id: newAuthState.id |
{ | ||
"name": "@digigov/auth", | ||
"version": "0.0.1-auth-flow.1+48578ec", | ||
"version": "0.0.1-auth-flow.4+9170502", | ||
"description": "@digigov authentication client", | ||
@@ -20,5 +20,5 @@ "author": "GRNET Developers <devs@lists.grnet.gr>", | ||
}, | ||
"gitHead": "48578ecbac73a63dfcb24fc2da64225628973944", | ||
"gitHead": "9170502e0a3022a67be558e61b0e325306fe2ae1", | ||
"private": false, | ||
"typings": "./index.d.ts" | ||
} |
@@ -33,7 +33,2 @@ "use strict"; | ||
var isPopup = window.localStorage.getItem('popup-login') === '1'; | ||
if (isPopup) { | ||
window.localStorage.removeItem('popup-login'); | ||
} | ||
(0, _react.useEffect)(function () { | ||
@@ -40,0 +35,0 @@ if (!code) { |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
83575
2495