@axa-fr/react-oidc 5.11.1 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -504,44 +504,56 @@ More information about OIDC
504
504
 
505
505
  To work with NextJS you need to inject your own history surcharge like the sample below.
506
506
 
507
+ component/layout.js
507
508
  ```javascript
508
- const MyApp: React.FC<AppProps> = ({ Component, pageProps: { session, ...pageProps }, router }) => {
509
- const [loading, setLoading] = useState(router.asPath.includes('access_token'));
509
+ import { OidcProvider } from '@axa-fr/react-oidc';
510
+ import { useRouter } from 'next/router'
511
+
512
+ const configuration = {
513
+ client_id: 'interactive.public.short',
514
+ redirect_uri: 'http://localhost:3001/#authentication/callback',
515
+ silent_redirect_uri: 'http://localhost:3001/#authentication/silent-callback', // Optional activate silent-signin that use cookies between OIDC server and client javascript to restore the session
516
+ scope: 'openid profile email api offline_access',
517
+ authority: 'https://demo.identityserver.io',
518
+ authority_configuration: {
519
+ authorization_endpoint: 'https://demo.duendesoftware.com/connect/authorize',
520
+ token_endpoint: 'https://demo.duendesoftware.com/connect/token',
521
+ userinfo_endpoint: 'https://demo.duendesoftware.com/connect/userinfo',
522
+ end_session_endpoint: 'https://demo.duendesoftware.com/connect/endsession',
523
+ revocation_endpoint: 'https://demo.duendesoftware.com/connect/revocation',
524
+ },
525
+ };
510
526
 
511
- const store = useStore(pageProps.initialReduxState);
512
- let searchRedirectPage: PageUrl;
527
+ const onEvent=(configurationName, eventName, data )=>{
528
+ console.log(`oidc:${configurationName}:${eventName}`, data);
529
+ }
513
530
 
514
- const withCustomHistory: () => CustomHistory = () => {
531
+ export default function Layout({ children }) {
532
+ const router = useRouter()
533
+ const withCustomHistory= () => {
515
534
  return {
516
- replaceState: (url?: string | null, stateHistory?: WindowHistoryState): void => {
517
- router.replace({
518
- pathname: url,
519
- });
520
- }
521
- };
535
+ replaceState: (url) => {
536
+ router.replace({
537
+ pathname: url,
538
+ });
539
+ window.dispatchEvent(new Event('popstate'));
540
+ }
541
+ };
522
542
  };
523
- // Code omitted...
524
-
525
- return !loading ? (
543
+
544
+ return (
526
545
  <>
527
- <Head>
528
- <meta
529
- name="viewport"
530
- content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=no;user-scalable=0;"
531
- />
532
- </Head>
533
- <OidcProvider configuration={OIDC_CONFIGURATION} withCustomHistory={withCustomHistory}>
534
- <Provider store={store}>
535
- <RouterScrollProvider>{layout}</RouterScrollProvider>
536
- </Provider>
546
+ <OidcProvider configuration={configuration} onEvent={onEvent} withCustomHistory={withCustomHistory} >
547
+ <main>{children}</main>
537
548
  </OidcProvider>
538
549
  </>
539
- ) : null;
540
- };
541
-
550
+ )
551
+ }
542
552
 
543
553
  ```
544
554
 
555
+ For more information checkout the nextjs react oidc demo: https://github.com/AxaGuilDEv/react-oidc/tree/master/packages/nextjs-demo
556
+
545
557
  # Hash route
546
558
 
547
559
  React oidc work also with hash router.
@@ -1 +1 @@
1
- {"version":3,"file":"OidcRoutes.d.ts","sourceRoot":"","sources":["../../../src/oidc/core/routes/OidcRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAA8C,MAAM,OAAO,CAAC;AAMzF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAY7C,aAAK,eAAe,GAAG;IACrB,wBAAwB,CAAC,EAAE,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE,aAAa,CAAC;IACvC,uBAAuB,CAAC,EAAE,aAAa,CAAC;IACxC,iBAAiB,EAAC,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAC;CACzC,CAAC;;AA6CF,wBAAsC"}
1
+ {"version":3,"file":"OidcRoutes.d.ts","sourceRoot":"","sources":["../../../src/oidc/core/routes/OidcRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAA8C,MAAM,OAAO,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAM7C,aAAK,eAAe,GAAG;IACrB,wBAAwB,CAAC,EAAE,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE,aAAa,CAAC;IACvC,uBAAuB,CAAC,EAAE,aAAa,CAAC;IACxC,iBAAiB,EAAC,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAC;CACzC,CAAC;;AA4CF,wBAAsC"}
@@ -27,16 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  var react_1 = __importStar(require("react"));
30
- var prop_types_1 = __importDefault(require("prop-types"));
31
30
  var route_utils_1 = require("./route-utils");
32
31
  var Callback_component_1 = __importDefault(require("../default-component/Callback.component"));
33
32
  var SilentCallback_component_1 = __importDefault(require("../default-component/SilentCallback.component"));
34
33
  var ServiceWorkerInstall_component_1 = __importDefault(require("../default-component/ServiceWorkerInstall.component"));
35
- var propTypes = {
36
- callbackComponent: prop_types_1.default.elementType,
37
- redirect_uri: prop_types_1.default.string.isRequired,
38
- children: prop_types_1.default.node,
39
- };
40
34
  var defaultProps = {};
41
35
  var OidcRoutes = function (_a) {
42
36
  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;
@@ -65,7 +59,6 @@ var OidcRoutes = function (_a) {
65
59
  }
66
60
  };
67
61
  // @ts-ignore
68
- OidcRoutes.propTypes = propTypes;
69
62
  OidcRoutes.defaultProps = defaultProps;
70
63
  exports.default = react_1.default.memo(OidcRoutes);
71
64
  //# sourceMappingURL=OidcRoutes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OidcRoutes.js","sourceRoot":"","sources":["../../../src/oidc/core/routes/OidcRoutes.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyF;AACzF,0DAAmC;AACnC,6CAAwC;AACxC,+FAAwE;AACxE,2GAAoF;AACpF,uHAAuF;AAGvF,IAAM,SAAS,GAAG;IAChB,iBAAiB,EAAE,oBAAS,CAAC,WAAW;IACxC,YAAY,EAAE,oBAAS,CAAC,MAAM,CAAC,UAAU;IACzC,QAAQ,EAAE,oBAAS,CAAC,IAAI;CACzB,CAAC;AAEF,IAAM,YAAY,GAA6B,EAE9C,CAAC;AAYF,IAAM,UAAU,GAA2C,UAAC,EAQ3D;QAPC,sBAAsB,4BAAA,EACtB,wBAAwB,8BAAA,EACoC,uBAAuB,6BAAA,EACvB,YAAY,kBAAA,EACZ,mBAAmB,yBAAA,EAC/E,QAAQ,cAAA,EAAE,iBAAiB,uBAAA,EAC3B,yBAAsB,EAAtB,iBAAiB,mBAAC,IAAI,KAAA;IAEtB,iEAAiE;IACjE,IAAI,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,IAAA,qBAAO,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnE,IAAA,KAAkB,IAAA,gBAAQ,EAAC,QAAQ,CAAC,EAAnC,IAAI,QAAA,EAAE,OAAO,QAAsB,CAAC;IAE3C,IAAA,iBAAS,EAAC;QACR,IAAM,UAAU,GAAG,cAAM,OAAA,OAAO,CAAC,IAAA,qBAAO,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAApD,CAA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,EAAE,iBAAiB,GAAI,CAAA;SACzE;KACF;IAED,QAAQ,IAAI,EAAE;QACZ,KAAK,YAAY;YACf,OAAO,8BAAC,4BAAiB,IAAC,aAAa,EAAE,sBAAsB,EAAE,eAAe,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,GAAI,CAAC;QAC7L,KAAK,YAAY,GAAE,yBAAyB;YAC1C,OAAO,8BAAC,wCAAoB,IAAC,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,iBAAiB,GAAI,CAAC;QACxJ;YACE,OAAO,8DAAG,QAAQ,CAAI,CAAC;KAC1B;AACH,CAAC,CAAC;AAEF,aAAa;AACb,UAAU,CAAC,YAAY,GAAG,YAAY,CAAC;AAEvC,kBAAe,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/react-oidc",
3
- "version": "5.11.1",
3
+ "version": "5.12.0",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "jsnext:main": "dist/index.js",
package/src/App.tsx CHANGED
@@ -9,8 +9,6 @@ import { MultiAuthContainer } from "./MultiAuth";
9
9
 
10
10
  const OidcSecureHoc = withOidcSecure(Profile);
11
11
 
12
-
13
-
14
12
  const onEvent=(configurationName, eventName, data )=>{
15
13
  console.log(`oidc:${configurationName}:${eventName}`, data);
16
14
  }
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import OidcRoutes from './OidcRoutes';
3
- import { FC } from 'react';
4
3
  import {render} from "@testing-library/react";
5
4
 
6
5
  describe('Authenticating test suite', () => {
@@ -1,17 +1,10 @@
1
1
  import React, { ComponentType, FC, PropsWithChildren, useEffect, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { getPath } from './route-utils';
4
3
  import CallbackComponent from '../default-component/Callback.component';
5
4
  import SilentCallbackComponent from "../default-component/SilentCallback.component";
6
5
  import ServiceWorkerInstall from "../default-component/ServiceWorkerInstall.component";
7
6
  import { CustomHistory } from "./withRouter";
8
7
 
9
- const propTypes = {
10
- callbackComponent: PropTypes.elementType,
11
- redirect_uri: PropTypes.string.isRequired,
12
- children: PropTypes.node,
13
- };
14
-
15
8
  const defaultProps: Partial<OidcRoutesProps> = {
16
9
 
17
10
  };
@@ -66,7 +59,6 @@ const OidcRoutes: FC<PropsWithChildren<OidcRoutesProps>> = ({
66
59
  };
67
60
 
68
61
  // @ts-ignore
69
- OidcRoutes.propTypes = propTypes;
70
62
  OidcRoutes.defaultProps = defaultProps;
71
63
 
72
64
  export default React.memo(OidcRoutes);
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {ComponentType, PropsWithChildren} from "react";
2
+ import {ComponentType} from "react";
3
3
  import {style} from "./style";
4
4
 
5
5
  const AuthenticatingError: ComponentType<any> = ({configurationName}) => (
@@ -1,7 +1,7 @@
1
- import React, {ComponentType, PropsWithChildren} from 'react';
1
+ import React, {ComponentType} from 'react';
2
2
  import {style} from "./style";
3
3
 
4
- export const CallBackSuccess: ComponentType<any> = ({configurationName}) => (<><div className="oidc-callback" style={style}>
4
+ export const CallBackSuccess: ComponentType<any> = ({configurationName}) => (<><div className="oidc-callback" style={style}>
5
5
  <div className="oidc-callback__container">
6
6
  <h1 className="oidc-callback__title">Authentication complete for {configurationName}</h1>
7
7
  <p className="oidc-callback__content">You will be redirected to your application.</p>
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {ComponentType, PropsWithChildren} from "react";
2
+ import {ComponentType } from "react";
3
3
  import {style} from "./style";
4
4
 
5
5
  const Loading : ComponentType<any> = ({children, configurationName}) => (
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {ComponentType, PropsWithChildren} from "react";
2
+ import {ComponentType} from "react";
3
3
  import {style} from "./style";
4
4
 
5
5
  const ServiceWorkerNotSupported : ComponentType<any> = ({configurationName}) => (
@@ -1,4 +1,4 @@
1
- import React, {ComponentType, PropsWithChildren} from 'react';
1
+ import React, {ComponentType} from 'react';
2
2
  import {style} from "./style"
3
3
  import {useOidc} from "../oidc";
4
4