@axa-fr/react-oidc
Advanced tools
Comparing version 5.8.1 to 5.9.0
@@ -67,5 +67,5 @@ "use strict"; | ||
var react_1 = __importStar(require("react")); | ||
var withRouter_1 = require("../routes/withRouter"); | ||
var AuthenticateError_component_1 = __importDefault(require("./AuthenticateError.component")); | ||
var oidc_1 = __importDefault(require("../../vanilla/oidc")); | ||
var withRouter_1 = require("../routes/withRouter"); | ||
var CallBackSuccess = function () { return (react_1.default.createElement("div", { className: "oidc-callback" }, | ||
@@ -77,3 +77,3 @@ react_1.default.createElement("div", { className: "oidc-callback__container" }, | ||
var CallbackManager = function (_a) { | ||
var callBackError = _a.callBackError, callBackSuccess = _a.callBackSuccess, configurationName = _a.configurationName; | ||
var callBackError = _a.callBackError, callBackSuccess = _a.callBackSuccess, configurationName = _a.configurationName, withCustomHistory = _a.withCustomHistory; | ||
var _b = (0, react_1.useState)(false), error = _b[0], setError = _b[1]; | ||
@@ -92,3 +92,3 @@ (0, react_1.useEffect)(function () { | ||
callbackPath = (_a.sent()).callbackPath; | ||
history_1 = (0, withRouter_1.getCustomHistory)(); | ||
history_1 = (withCustomHistory) ? withCustomHistory() : (0, withRouter_1.getCustomHistory)(); | ||
history_1.replaceState(callbackPath || "/"); | ||
@@ -95,0 +95,0 @@ return [3 /*break*/, 3]; |
import React, { ComponentType } from 'react'; | ||
import { CustomHistory } from "./withRouter"; | ||
declare type OidcRoutesProps = { | ||
@@ -9,2 +10,3 @@ callbackSuccessComponent?: ComponentType; | ||
silent_redirect_uri?: string; | ||
withCustomHistory?: () => CustomHistory; | ||
}; | ||
@@ -11,0 +13,0 @@ declare const _default: React.NamedExoticComponent<React.PropsWithChildren<OidcRoutesProps>>; |
@@ -42,6 +42,6 @@ "use strict"; | ||
var OidcRoutes = function (_a) { | ||
var callbackErrorComponent = _a.callbackErrorComponent, callbackSuccessComponent = _a.callbackSuccessComponent, authenticatingComponent = _a.authenticatingComponent, redirect_uri = _a.redirect_uri, silent_redirect_uri = _a.silent_redirect_uri, children = _a.children, configurationName = _a.configurationName; | ||
var callbackErrorComponent = _a.callbackErrorComponent, callbackSuccessComponent = _a.callbackSuccessComponent, authenticatingComponent = _a.authenticatingComponent, redirect_uri = _a.redirect_uri, silent_redirect_uri = _a.silent_redirect_uri, children = _a.children, configurationName = _a.configurationName, _b = _a.withCustomHistory, withCustomHistory = _b === void 0 ? null : _b; | ||
// This exist because in next.js window outside useEffect is null | ||
var pathname = window ? window.location.pathname : ''; | ||
var _b = (0, react_1.useState)(pathname), path = _b[0], setPath = _b[1]; | ||
var _c = (0, react_1.useState)(pathname), path = _c[0], setPath = _c[1]; | ||
(0, react_1.useEffect)(function () { | ||
@@ -63,3 +63,3 @@ var setNewPath = function () { | ||
case callbackPath: | ||
return react_1.default.createElement(Callback_component_1.default, { callBackError: callbackErrorComponent, callBackSuccess: callbackSuccessComponent, configurationName: configurationName }); | ||
return react_1.default.createElement(Callback_component_1.default, { callBackError: callbackErrorComponent, callBackSuccess: callbackSuccessComponent, configurationName: configurationName, withCustomHistory: withCustomHistory }); | ||
case callbackPath + "/service-worker-install": | ||
@@ -66,0 +66,0 @@ return react_1.default.createElement(ServiceWorkerInstall_component_1.default, { callBackError: callbackErrorComponent, authenticating: authenticatingComponent, configurationName: configurationName }); |
@@ -15,6 +15,7 @@ export declare type WindowInternal = Window & { | ||
} | ||
export declare const getCustomHistory: () => { | ||
replaceState: (url?: string | null, stateHistory?: WindowHistoryState) => void; | ||
export declare type CustomHistory = { | ||
replaceState(url?: string | null, stateHistory?: WindowHistoryState): void; | ||
}; | ||
export declare const getCustomHistory: () => CustomHistory; | ||
export {}; | ||
//# sourceMappingURL=withRouter.d.ts.map |
import { ComponentType, FC, PropsWithChildren } from 'react'; | ||
import { OidcConfiguration } from './vanilla/oidc'; | ||
import { CustomHistory } from "./core/routes/withRouter"; | ||
export declare type oidcContext = { | ||
@@ -18,2 +19,3 @@ getOidc: Function; | ||
onSessionLost?: Function; | ||
withCustomHistory?: () => CustomHistory; | ||
}; | ||
@@ -20,0 +22,0 @@ export declare type OidcSessionProps = { |
@@ -67,3 +67,3 @@ "use strict"; | ||
var OidcProvider = function (_a) { | ||
var children = _a.children, configuration = _a.configuration, _b = _a.configurationName, configurationName = _b === void 0 ? "default" : _b, _c = _a.callbackSuccessComponent, callbackSuccessComponent = _c === void 0 ? index_1.CallBackSuccess : _c, _d = _a.callbackErrorComponent, callbackErrorComponent = _d === void 0 ? index_1.AuthenticateError : _d, _e = _a.authenticatingComponent, authenticatingComponent = _e === void 0 ? index_1.Authenticating : _e, _f = _a.loadingComponent, loadingComponent = _f === void 0 ? index_1.Loading : _f, _g = _a.serviceWorkerNotSupportedComponent, serviceWorkerNotSupportedComponent = _g === void 0 ? ServiceWorkerNotSupported_component_1.default : _g, _h = _a.authenticatingErrorComponent, authenticatingErrorComponent = _h === void 0 ? AuthenticateError_component_1.default : _h, _j = _a.sessionLostComponent, sessionLostComponent = _j === void 0 ? index_1.SessionLost : _j, _k = _a.onSessionLost, onSessionLost = _k === void 0 ? null : _k; | ||
var children = _a.children, configuration = _a.configuration, _b = _a.configurationName, configurationName = _b === void 0 ? "default" : _b, _c = _a.callbackSuccessComponent, callbackSuccessComponent = _c === void 0 ? index_1.CallBackSuccess : _c, _d = _a.callbackErrorComponent, callbackErrorComponent = _d === void 0 ? index_1.AuthenticateError : _d, _e = _a.authenticatingComponent, authenticatingComponent = _e === void 0 ? index_1.Authenticating : _e, _f = _a.loadingComponent, loadingComponent = _f === void 0 ? index_1.Loading : _f, _g = _a.serviceWorkerNotSupportedComponent, serviceWorkerNotSupportedComponent = _g === void 0 ? ServiceWorkerNotSupported_component_1.default : _g, _h = _a.authenticatingErrorComponent, authenticatingErrorComponent = _h === void 0 ? AuthenticateError_component_1.default : _h, _j = _a.sessionLostComponent, sessionLostComponent = _j === void 0 ? index_1.SessionLost : _j, _k = _a.onSessionLost, onSessionLost = _k === void 0 ? null : _k, _l = _a.withCustomHistory, withCustomHistory = _l === void 0 ? null : _l; | ||
var getOidc = function (configurationName) { | ||
@@ -73,5 +73,5 @@ if (configurationName === void 0) { configurationName = "default"; } | ||
}; | ||
var _l = (0, react_1.useState)(true), loading = _l[0], setLoading = _l[1]; | ||
var _m = (0, react_1.useState)(defaultEventState), event = _m[0], setEvent = _m[1]; | ||
var _o = (0, react_1.useState)("default"), currentConfigurationName = _o[0], setConfigurationName = _o[1]; | ||
var _m = (0, react_1.useState)(true), loading = _m[0], setLoading = _m[1]; | ||
var _o = (0, react_1.useState)(defaultEventState), event = _o[0], setEvent = _o[1]; | ||
var _p = (0, react_1.useState)("default"), currentConfigurationName = _p[0], setConfigurationName = _p[1]; | ||
(0, react_1.useEffect)(function () { | ||
@@ -129,3 +129,3 @@ var oidc = getOidc(configurationName); | ||
return (react_1.default.createElement(Switch, { loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, | ||
react_1.default.createElement(OidcRoutes_1.default, { redirect_uri: configuration.redirect_uri, silent_redirect_uri: configuration.silent_redirect_uri, callbackSuccessComponent: callbackSuccessComponent, callbackErrorComponent: callbackErrorComponent, authenticatingComponent: authenticatingComponent, configurationName: configurationName }, | ||
react_1.default.createElement(OidcRoutes_1.default, { redirect_uri: configuration.redirect_uri, silent_redirect_uri: configuration.silent_redirect_uri, callbackSuccessComponent: callbackSuccessComponent, callbackErrorComponent: callbackErrorComponent, authenticatingComponent: authenticatingComponent, configurationName: configurationName, withCustomHistory: withCustomHistory }, | ||
react_1.default.createElement(OidcSession, { loadingComponent: LoadingComponent, configurationName: configurationName }, children)))); | ||
@@ -132,0 +132,0 @@ } |
@@ -83,7 +83,10 @@ "use strict"; | ||
if (!workerPort) { | ||
// In NextJS with SSR (Server Side Rendering) during rending in Node JS, the window object is undefined, | ||
// the global object is used instead as it is the closest approximation of a browsers window object. | ||
var bindContext = (typeof window === 'undefined') ? global : window; | ||
return { | ||
setTimeout: setTimeout.bind(window), | ||
clearTimeout: clearTimeout.bind(window), | ||
setInterval: setInterval.bind(window), | ||
clearInterval: clearInterval.bind(window) | ||
setTimeout: setTimeout.bind(bindContext), | ||
clearTimeout: clearTimeout.bind(bindContext), | ||
setInterval: setInterval.bind(bindContext), | ||
clearInterval: clearInterval.bind(bindContext) | ||
}; | ||
@@ -90,0 +93,0 @@ } |
{ | ||
"name": "@axa-fr/react-oidc", | ||
"version": "5.8.1", | ||
"version": "5.9.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -158,3 +158,4 @@ <H1> @axa-fr/react-oidc</H1> | ||
service_worker_only: PropTypes.boolean, // default false | ||
extras: StringMap|undefined // ex: {'prompt': 'consent', 'access_type': 'offline'} list of key/value that are send to the oidc server (more info: https://github.com/openid/AppAuth-JS) | ||
extras: StringMap|undefined, // ex: {'prompt': 'consent', 'access_type': 'offline'} list of key/value that are send to the oidc server (more info: https://github.com/openid/AppAuth-JS) | ||
withCustomHistory: PropTypes.function, // Override history modification, return instance with replaceState(url, stateHistory) implemented (like History.replaceState()) | ||
}).isRequired | ||
@@ -161,0 +162,0 @@ }; |
@@ -93,7 +93,11 @@ const timer = (function () { | ||
if (!workerPort) { | ||
// In NextJS with SSR (Server Side Rendering) during rending in Node JS, the window object is undefined, | ||
// the global object is used instead as it is the closest approximation of a browsers window object. | ||
const bindContext = (typeof window === 'undefined')? global: window; | ||
return { | ||
setTimeout: setTimeout.bind(window), | ||
clearTimeout: clearTimeout.bind(window), | ||
setInterval: setInterval.bind(window), | ||
clearInterval: clearInterval.bind(window) | ||
setTimeout: setTimeout.bind(bindContext), | ||
clearTimeout: clearTimeout.bind(bindContext), | ||
setInterval: setInterval.bind(bindContext), | ||
clearInterval: clearInterval.bind(bindContext) | ||
}; | ||
@@ -100,0 +104,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
353194
5496
535