react-oauth2-code-pkce
Advanced tools
Comparing version 1.21.1 to 1.22.0
@@ -11,4 +11,4 @@ "use strict"; | ||
// Set default values for internal config object | ||
const { autoLogin = true, clearURL = true, decodeToken = true, scope = undefined, preLogin = () => null, postLogin = () => null, onRefreshTokenExpire = undefined, storage = 'local', storageKeyPrefix = 'ROCP_', refreshWithScope = true, refreshTokenExpiryStrategy = 'renewable', tokenRequestCredentials = 'same-origin', } = passedConfig; | ||
const config = Object.assign(Object.assign({}, passedConfig), { autoLogin: autoLogin, clearURL: clearURL, decodeToken: decodeToken, scope: scope, preLogin: preLogin, postLogin: postLogin, onRefreshTokenExpire: onRefreshTokenExpire, storage: storage, storageKeyPrefix: storageKeyPrefix, refreshWithScope: refreshWithScope, refreshTokenExpiryStrategy: refreshTokenExpiryStrategy, tokenRequestCredentials: tokenRequestCredentials }); | ||
const { autoLogin = true, clearURL = true, decodeToken = true, scope = undefined, preLogin = () => null, postLogin = () => null, loginMethod = 'redirect', onRefreshTokenExpire = undefined, storage = 'local', storageKeyPrefix = 'ROCP_', refreshWithScope = true, refreshTokenExpiryStrategy = 'renewable', tokenRequestCredentials = 'same-origin', } = passedConfig; | ||
const config = Object.assign(Object.assign({}, passedConfig), { autoLogin: autoLogin, clearURL: clearURL, decodeToken: decodeToken, scope: scope, preLogin: preLogin, postLogin: postLogin, loginMethod: loginMethod, onRefreshTokenExpire: onRefreshTokenExpire, storage: storage, storageKeyPrefix: storageKeyPrefix, refreshWithScope: refreshWithScope, refreshTokenExpiryStrategy: refreshTokenExpiryStrategy, tokenRequestCredentials: tokenRequestCredentials }); | ||
validateConfig(config); | ||
@@ -15,0 +15,0 @@ return config; |
@@ -122,6 +122,6 @@ "use strict"; | ||
if (initial) | ||
return logIn(); | ||
return logIn(undefined, undefined, config.loginMethod); | ||
// TODO: Breaking change - remove automatic login during ongoing session | ||
if (!config.onRefreshTokenExpire) | ||
return logIn(); | ||
return logIn(undefined, undefined, config.loginMethod); | ||
config.onRefreshTokenExpire({ | ||
@@ -163,3 +163,3 @@ login: logIn, | ||
if (initial) | ||
logIn(); | ||
logIn(undefined, undefined, config.loginMethod); | ||
} | ||
@@ -171,3 +171,3 @@ // Unknown error. Set error, and log in if first page load | ||
if (initial) | ||
logIn(); | ||
logIn(undefined, undefined, config.loginMethod); | ||
} | ||
@@ -243,3 +243,3 @@ }) | ||
if (!token && config.autoLogin) | ||
return logIn(); | ||
return logIn(undefined, undefined, config.loginMethod); | ||
refreshAccessToken(true); // Check if token should be updated | ||
@@ -246,0 +246,0 @@ }, []); |
@@ -59,2 +59,3 @@ import type { ReactNode } from 'react'; | ||
postLogin?: () => void; | ||
loginMethod: 'redirect' | 'popup'; | ||
onRefreshTokenExpire?: (event: TRefreshTokenExpiredEvent) => void; | ||
@@ -93,2 +94,3 @@ decodeToken?: boolean; | ||
postLogin?: () => void; | ||
loginMethod: 'redirect' | 'popup'; | ||
onRefreshTokenExpire?: (event: TRefreshTokenExpiredEvent) => void; | ||
@@ -95,0 +97,0 @@ decodeToken: boolean; |
{ | ||
"name": "react-oauth2-code-pkce", | ||
"version": "1.21.1", | ||
"version": "1.22.0", | ||
"description": "Provider agnostic react package for OAuth2 Authorization Code flow with PKCE", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -84,2 +84,3 @@ # react-oauth2-code-pkce | ||
// If you want to use 'state', you might want to set 'clearURL' configuration parameter to 'false'. | ||
// Note that most browsers block popups by default. The library will print a warning and fallback to redirect if the popup is blocked | ||
logIn: (state?: string, additionalParameters?: { [key: string]: string | boolean | number }, method: 'redirect' | 'popup' = 'redirect') => void | ||
@@ -138,2 +139,5 @@ // Function to trigger logout from authentication provider. You may provide optional 'state', and 'logout_hint' values. | ||
postLogin?: () => void // default: () => null | ||
// Which method to use for login. Can be either 'redirect' or 'popup' | ||
// Note that most browsers block popups by default. The library will print a warning and fallback to redirect if the popup is blocked | ||
loginMethod: 'redirect' | 'popup' // default: 'redirect' | ||
// Optional callback function for the 'refreshTokenExpired' event. | ||
@@ -140,0 +144,0 @@ // You likely want to display a message saying the user need to log in again. A page refresh is enough. |
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
53904
811
233