react-oauth2-code-pkce
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -50,3 +50,3 @@ "use strict"; | ||
setToken(response.access_token); | ||
setIdToken(response === null || response === void 0 ? void 0 : response.id_token); | ||
setIdToken((response === null || response === void 0 ? void 0 : response.id_token) || "None"); | ||
setLoginInProgress(false); | ||
@@ -60,9 +60,6 @@ setTokenData((0, authentication_1.decodeToken)(response.access_token)); | ||
// This should not happen. There should be a 'code' parameter in the url by now..." | ||
var error_description = urlParams.get('error_description'); | ||
if (error_description) { | ||
console.error(error_description); | ||
setError(error_description); | ||
} | ||
var error_description = urlParams.get('error_description') || 'Bad authorization state. Refreshing the page might solve the issue.'; | ||
console.error(error_description); | ||
setError(error_description); | ||
logOut(); | ||
location.reload(); | ||
} | ||
@@ -78,2 +75,5 @@ else { // Request token from auth server with the auth code | ||
history.replaceState(null, "", location.pathname); // Clear ugly url params | ||
// Call any postLogin function in authConfig | ||
if (authConfig === null || authConfig === void 0 ? void 0 : authConfig.postLogin) | ||
authConfig.postLogin(); | ||
} | ||
@@ -80,0 +80,0 @@ }); |
@@ -59,2 +59,5 @@ "use strict"; | ||
}); | ||
// Call any preLogin function in authConfig | ||
if (authConfig === null || authConfig === void 0 ? void 0 : authConfig.preLogin) | ||
authConfig.preLogin(); | ||
location.replace(authConfig.authorizationEndpoint + "?" + params.toString()); | ||
@@ -61,0 +64,0 @@ }); |
@@ -7,3 +7,3 @@ import { ReactChildren } from "react"; | ||
export interface IAuthProvider { | ||
authConfig: any; | ||
authConfig: TAuthConfig; | ||
children: ReactChildren; | ||
@@ -19,2 +19,4 @@ } | ||
logoutRedirect?: string; | ||
preLogin?: Function; | ||
postLogin?: Function; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateAuthConfig = void 0; | ||
function stringIsUnset(value) { | ||
var unset = ["", undefined, null]; | ||
return unset.includes(value); | ||
} | ||
function validateAuthConfig(authConfig) { | ||
if (authConfig.clientId === "" || null || undefined) | ||
throw "ClientId must be set in the 'AuthConfig' object passed to 'react-oauth2-code-pkce' AuthProvider"; | ||
if (authConfig.authorizationEndpoint === "" || null || undefined) | ||
throw "authorizationEndpoint must be set in the 'AuthConfig' object passed to 'react-oauth2-code-pkce' AuthProvider"; | ||
if (authConfig.tokenEndpoint === "" || null || undefined) | ||
throw "tokenEndpoint must be set in the 'AuthConfig' object passed to 'react-oauth2-code-pkce' AuthProvider"; | ||
if (authConfig.redirectUri === "" || null || undefined) | ||
throw "redirectUri must be set in the 'AuthConfig' object passed to 'react-oauth2-code-pkce' AuthProvider"; | ||
if (stringIsUnset(authConfig === null || authConfig === void 0 ? void 0 : authConfig.clientId)) | ||
throw "'clientId' must be set in the 'AuthConfig' object passed to 'react-oauth2-code-pkce' AuthProvider"; | ||
if (stringIsUnset(authConfig === null || authConfig === void 0 ? void 0 : authConfig.authorizationEndpoint)) | ||
throw "'authorizationEndpoint' must be set in the 'AuthConfig' object passed to 'react-oauth2-code-pkce' AuthProvider"; | ||
if (stringIsUnset(authConfig === null || authConfig === void 0 ? void 0 : authConfig.tokenEndpoint)) | ||
throw "'tokenEndpoint' must be set in the 'AuthConfig' object passed to 'react-oauth2-code-pkce' AuthProvider"; | ||
if (stringIsUnset(authConfig === null || authConfig === void 0 ? void 0 : authConfig.redirectUri)) | ||
throw "'redirectUri' must be set in the 'AuthConfig' object passed to 'react-oauth2-code-pkce' AuthProvider"; | ||
} | ||
exports.validateAuthConfig = validateAuthConfig; |
{ | ||
"name": "react-oauth2-code-pkce", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"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
24701
438