react-oauth2-code-pkce
Advanced tools
Comparing version 1.19.0 to 1.20.0
@@ -10,4 +10,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, } = 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 }); | ||
const { autoLogin = true, clearURL = true, decodeToken = true, scope = undefined, preLogin = () => null, postLogin = () => null, onRefreshTokenExpire = undefined, storage = 'local', storageKeyPrefix = 'ROCP_', refreshWithScope = true, refreshTokenExpiryStrategy = 'renewable', } = 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 }); | ||
validateConfig(config); | ||
@@ -14,0 +14,0 @@ return config; |
@@ -111,3 +111,5 @@ "use strict"; | ||
setRefreshToken(response.refresh_token); | ||
setRefreshTokenExpire((0, timeUtils_1.epochAtSecondsFromNow)(refreshTokenExpiresIn)); | ||
if (!refreshTokenExpire || config.refreshTokenExpiryStrategy !== 'absolute') { | ||
setRefreshTokenExpire((0, timeUtils_1.epochAtSecondsFromNow)(refreshTokenExpiresIn)); | ||
} | ||
} | ||
@@ -114,0 +116,0 @@ } |
@@ -35,3 +35,3 @@ import { ReactNode } from 'react'; | ||
token: string; | ||
logIn: (state?: string, additionalParameters?: TPrimitiveRecord) => void; | ||
logIn: (state?: string, additionalParameters?: TPrimitiveRecord, method?: 'redirect' | 'popup') => void; | ||
logOut: (state?: string, logoutHint?: string, additionalParameters?: TPrimitiveRecord) => void; | ||
@@ -71,2 +71,3 @@ /** @deprecated Use `logIn` instead */ | ||
refreshTokenExpiresIn?: number; | ||
refreshTokenExpiryStrategy?: 'renewable' | 'absolute'; | ||
storage?: 'session' | 'local'; | ||
@@ -77,5 +78,5 @@ storageKeyPrefix?: string; | ||
export type TRefreshTokenExpiredEvent = { | ||
logIn: () => void; | ||
logIn: (state?: string, additionalParameters?: TPrimitiveRecord, method?: 'redirect' | 'popup') => void; | ||
/** @deprecated Use `logIn` instead. Will be removed in a future version. */ | ||
login: () => void; | ||
login: (state?: string, additionalParameters?: TPrimitiveRecord, method?: 'redirect' | 'popup') => void; | ||
}; | ||
@@ -104,2 +105,3 @@ export type TInternalConfig = { | ||
refreshTokenExpiresIn?: number; | ||
refreshTokenExpiryStrategy: 'renewable' | 'absolute'; | ||
storage: 'session' | 'local'; | ||
@@ -106,0 +108,0 @@ storageKeyPrefix: string; |
{ | ||
"name": "react-oauth2-code-pkce", | ||
"version": "1.19.0", | ||
"version": "1.20.0", | ||
"description": "Provider agnostic react package for OAuth2 Authorization Code flow with PKCE", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -167,2 +167,6 @@ # react-oauth2-code-pkce | ||
refreshTokenExpiresIn?: number // default: null | ||
// Defines the expiration strategy for the refresh token. | ||
// - 'renewable': The refresh token's expiration time is renewed each time it is used, getting a new validity period. | ||
// - 'absolute': The refresh token's expiration time is fixed from its initial issuance and does not change, regardless of how many times it is used. | ||
refreshTokenExpiryStrategy?: 'renewable' | 'absolute' // default: renewable | ||
// Whether or not to post 'scope' when refreshing the access token | ||
@@ -169,0 +173,0 @@ refreshWithScope?: boolean // default: true |
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
51889
792
224