react-oauth2-code-pkce
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -38,2 +38,3 @@ "use strict"; | ||
var _f = (0, react_1.useState)(), tokenData = _f[0], setTokenData = _f[1]; | ||
var _g = (0, react_1.useState)(null), error = _g[0], setError = _g[1]; | ||
(0, validateAuthConfig_1.validateAuthConfig)(authConfig); | ||
@@ -45,3 +46,2 @@ function logOut() { | ||
setTokenData(undefined); | ||
// @ts-ignore | ||
setLoginInProgress(false); | ||
@@ -53,3 +53,2 @@ } | ||
setIdToken(response === null || response === void 0 ? void 0 : response.id_token); | ||
// @ts-ignore | ||
setLoginInProgress(false); | ||
@@ -63,3 +62,7 @@ setTokenData((0, authentication_1.decodeToken)(response.access_token)); | ||
// This should not happen. There should be a 'code' parameter in the url by now..." | ||
// Clearing all site data... | ||
var error_description = urlParams.get('error_description'); | ||
if (error_description) { | ||
console.error(error_description); | ||
setError(error_description); | ||
} | ||
logOut(); | ||
@@ -70,4 +73,10 @@ location.reload(); | ||
(0, authentication_1.getTokens)(authConfig).then(function (response) { | ||
handleTokenResponse(response); | ||
history.replaceState(null, "", location.pathname); // Clear ugly url params | ||
if (!response.ok) { | ||
console.error(response.body.error_description); | ||
setError(response.body.error_description); | ||
} | ||
else { | ||
handleTokenResponse(response.body); | ||
history.replaceState(null, "", location.pathname); // Clear ugly url params | ||
} | ||
}); | ||
@@ -77,3 +86,2 @@ } | ||
else if (!token) { // First page visit | ||
// @ts-ignore | ||
setLoginInProgress(true); | ||
@@ -91,3 +99,2 @@ (0, authentication_1.login)(authConfig); | ||
console.error(error); | ||
// @ts-ignore | ||
setLoginInProgress(true); | ||
@@ -102,4 +109,4 @@ (0, authentication_1.login)(authConfig); | ||
}, []); | ||
return (react_1.default.createElement(exports.AuthContext.Provider, { value: { tokenData: tokenData, token: token, idToken: idToken, logOut: logOut } }, children)); | ||
return (react_1.default.createElement(exports.AuthContext.Provider, { value: { tokenData: tokenData, token: token, idToken: idToken, logOut: logOut, error: error } }, children)); | ||
}; | ||
exports.AuthProvider = AuthProvider; |
@@ -92,3 +92,6 @@ "use strict"; | ||
}) | ||
.then(function (response) { return response.json(); }); | ||
.then(function (response) { return response.json().then(function (body) { return ({ ok: response.ok, body: body }); }); }) | ||
.catch(function (error) { | ||
console.log(error); | ||
}); | ||
}; | ||
@@ -95,0 +98,0 @@ exports.getTokens = getTokens; |
@@ -1,2 +0,2 @@ | ||
declare function useLocalStorage<T>(key: string, initialValue: T): (T | ((value: T | ((val: T) => T)) => void))[]; | ||
declare function useLocalStorage<T>(key: string, initialValue: T): [any, Function]; | ||
export default useLocalStorage; |
{ | ||
"name": "react-oauth2-code-pkce", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Plug-and-play react package for OAuth2 Authorization Code flow with PKCE", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23945
429