@axa-fr/react-oidc 7.22.4 → 7.22.5
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/dist/OidcProvider.d.ts +2 -2
- package/dist/OidcSecure.d.ts +1 -1
- package/dist/core/routes/OidcRoutes.d.ts +2 -2
- package/dist/index.js +369 -354
- package/dist/index.umd.cjs +15 -10
- package/package.json +14 -14
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(E,
|
|
1
|
+
(function(E,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("@axa-fr/oidc-client")):typeof define=="function"&&define.amd?define(["exports","react","@axa-fr/oidc-client"],g):(E=typeof globalThis<"u"?globalThis:E||self,g(E["react-oidc"]={},E.React,E.oidcClient))})(this,function(E,g,a){"use strict";var re={exports:{}},X={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var me;function
|
|
9
|
+
*/var me;function qe(){if(me)return X;me=1;var s=g,i=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function _(d,v,b){var k,m={},j=null,C=null;b!==void 0&&(j=""+b),v.key!==void 0&&(j=""+v.key),v.ref!==void 0&&(C=v.ref);for(k in v)o.call(v,k)&&!u.hasOwnProperty(k)&&(m[k]=v[k]);if(d&&d.defaultProps)for(k in v=d.defaultProps,v)m[k]===void 0&&(m[k]=v[k]);return{$$typeof:i,type:d,key:j,ref:C,props:m,_owner:l.current}}return X.Fragment=n,X.jsx=_,X.jsxs=_,X}var H={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,14 +14,19 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),T=h.length-1,
|
|
21
|
-
`+h[T].replace(" at new "," at ");return e.displayName&&
|
|
17
|
+
*/var Ee;function $e(){return Ee||(Ee=1,process.env.NODE_ENV!=="production"&&function(){var s=g,i=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),d=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),I=Symbol.iterator,K="@@iterator";function Y(e){if(e===null||typeof e!="object")return null;var t=I&&e[I]||e[K];return typeof t=="function"?t:null}var U=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function R(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),f=1;f<t;f++)r[f-1]=arguments[f];ae("error",e,r)}}function ae(e,t,r){{var f=U.ReactDebugCurrentFrame,y=f.getStackAddendum();y!==""&&(t+="%s",r=r.concat([y]));var O=r.map(function(p){return String(p)});O.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,O)}}var V=!1,ie=!1,ce=!1,le=!1,ue=!1,D;D=Symbol.for("react.module.reference");function de(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===u||ue||e===l||e===b||e===k||le||e===C||V||ie||ce||typeof e=="object"&&e!==null&&(e.$$typeof===j||e.$$typeof===m||e.$$typeof===_||e.$$typeof===d||e.$$typeof===v||e.$$typeof===D||e.getModuleId!==void 0))}function fe(e,t,r){var f=e.displayName;if(f)return f;var y=t.displayName||t.name||"";return y!==""?r+"("+y+")":r}function W(e){return e.displayName||"Context"}function x(e){if(e==null)return null;if(typeof e.tag=="number"&&R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case n:return"Portal";case u:return"Profiler";case l:return"StrictMode";case b:return"Suspense";case k:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case d:var t=e;return W(t)+".Consumer";case _:var r=e;return W(r._context)+".Provider";case v:return fe(e,e.render,"ForwardRef");case m:var f=e.displayName||null;return f!==null?f:x(e.type)||"Memo";case j:{var y=e,O=y._payload,p=y._init;try{return x(p(O))}catch{return null}}}return null}var M=Object.assign,L=0,J,w,N,Fe,Ie,De,Le;function Ne(){}Ne.__reactDisabledLog=!0;function wt(){{if(L===0){J=console.log,w=console.info,N=console.warn,Fe=console.error,Ie=console.group,De=console.groupCollapsed,Le=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}L++}}function St(){{if(L--,L===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},e,{value:J}),info:M({},e,{value:w}),warn:M({},e,{value:N}),error:M({},e,{value:Fe}),group:M({},e,{value:Ie}),groupCollapsed:M({},e,{value:De}),groupEnd:M({},e,{value:Le})})}L<0&&R("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ve=U.ReactCurrentDispatcher,he;function $(e,t,r){{if(he===void 0)try{throw Error()}catch(y){var f=y.stack.trim().match(/\n( *(at )?)/);he=f&&f[1]||""}return`
|
|
18
|
+
`+he+e}}var pe=!1,ee;{var Rt=typeof WeakMap=="function"?WeakMap:Map;ee=new Rt}function Ue(e,t){if(!e||pe)return"";{var r=ee.get(e);if(r!==void 0)return r}var f;pe=!0;var y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var O;O=ve.current,ve.current=null,wt();try{if(t){var p=function(){throw Error()};if(Object.defineProperty(p.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(p,[])}catch(A){f=A}Reflect.construct(e,[],p)}else{try{p.call()}catch(A){f=A}e.call(p.prototype)}}else{try{throw Error()}catch(A){f=A}e()}}catch(A){if(A&&f&&typeof A.stack=="string"){for(var h=A.stack.split(`
|
|
19
|
+
`),P=f.stack.split(`
|
|
20
|
+
`),T=h.length-1,S=P.length-1;T>=1&&S>=0&&h[T]!==P[S];)S--;for(;T>=1&&S>=0;T--,S--)if(h[T]!==P[S]){if(T!==1||S!==1)do if(T--,S--,S<0||h[T]!==P[S]){var F=`
|
|
21
|
+
`+h[T].replace(" at new "," at ");return e.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",e.displayName)),typeof e=="function"&&ee.set(e,F),F}while(T>=1&&S>=0);break}}}finally{pe=!1,ve.current=O,St(),Error.prepareStackTrace=y}var G=e?e.displayName||e.name:"",B=G?$(G):"";return typeof e=="function"&&ee.set(e,B),B}function jt(e,t,r){return Ue(e,!1)}function Pt(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function te(e,t,r){if(e==null)return"";if(typeof e=="function")return Ue(e,Pt(e));if(typeof e=="string")return $(e);switch(e){case b:return $("Suspense");case k:return $("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return jt(e.render);case m:return te(e.type,t,r);case j:{var f=e,y=f._payload,O=f._init;try{return te(O(y),t,r)}catch{}}}return""}var Z=Object.prototype.hasOwnProperty,We={},Me=U.ReactDebugCurrentFrame;function ne(e){if(e){var t=e._owner,r=te(e.type,e._source,t?t.type:null);Me.setExtraStackFrame(r)}else Me.setExtraStackFrame(null)}function Ct(e,t,r,f,y){{var O=Function.call.bind(Z);for(var p in e)if(O(e,p)){var h=void 0;try{if(typeof e[p]!="function"){var P=Error((f||"React class")+": "+r+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[p]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw P.name="Invariant Violation",P}h=e[p](t,p,f,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(T){h=T}h&&!(h instanceof Error)&&(ne(y),R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",f||"React class",r,p,typeof h),ne(null)),h instanceof Error&&!(h.message in We)&&(We[h.message]=!0,ne(y),R("Failed %s type: %s",r,h.message),ne(null))}}}var xt=Array.isArray;function ge(e){return xt(e)}function At(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function Ft(e){try{return Ye(e),!1}catch{return!0}}function Ye(e){return""+e}function Ve(e){if(Ft(e))return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",At(e)),Ye(e)}var q=U.ReactCurrentOwner,It={key:!0,ref:!0,__self:!0,__source:!0},Be,Ke,_e;_e={};function Dt(e){if(Z.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Lt(e){if(Z.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function Nt(e,t){if(typeof e.ref=="string"&&q.current&&t&&q.current.stateNode!==t){var r=x(q.current.type);_e[r]||(R('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',x(q.current.type),e.ref),_e[r]=!0)}}function Ut(e,t){{var r=function(){Be||(Be=!0,R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function Wt(e,t){{var r=function(){Ke||(Ke=!0,R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var Mt=function(e,t,r,f,y,O,p){var h={$$typeof:i,type:e,key:t,ref:r,props:p,_owner:O};return h._store={},Object.defineProperty(h._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(h,"_self",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.defineProperty(h,"_source",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.freeze&&(Object.freeze(h.props),Object.freeze(h)),h};function Yt(e,t,r,f,y){{var O,p={},h=null,P=null;r!==void 0&&(Ve(r),h=""+r),Lt(t)&&(Ve(t.key),h=""+t.key),Dt(t)&&(P=t.ref,Nt(t,y));for(O in t)Z.call(t,O)&&!It.hasOwnProperty(O)&&(p[O]=t[O]);if(e&&e.defaultProps){var T=e.defaultProps;for(O in T)p[O]===void 0&&(p[O]=T[O])}if(h||P){var S=typeof e=="function"?e.displayName||e.name||"Unknown":e;h&&Ut(p,S),P&&Wt(p,S)}return Mt(e,h,P,y,f,q.current,p)}}var ye=U.ReactCurrentOwner,Je=U.ReactDebugCurrentFrame;function z(e){if(e){var t=e._owner,r=te(e.type,e._source,t?t.type:null);Je.setExtraStackFrame(r)}else Je.setExtraStackFrame(null)}var be;be=!1;function ke(e){return typeof e=="object"&&e!==null&&e.$$typeof===i}function ze(){{if(ye.current){var e=x(ye.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function Vt(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),r=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+t+":"+r+"."}return""}}var Ge={};function
|
|
25
|
+
Check your code at `+t+":"+r+"."}return""}}var Ge={};function Bt(e){{var t=ze();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+r+">.")}return t}}function Je(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=Yt(t);if(Ge[r])return;Ge[r]=!0;var d="";e&&e._owner&&e._owner!==ge.current&&(d=" It was passed a child from "+x(e._owner.type)+"."),G(e),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,d),G(null)}}function Ke(e,t){{if(typeof e!="object")return;if(pe(e))for(var r=0;r<e.length;r++){var d=e[r];be(d)&&Je(d,t)}else if(be(e))e._store&&(e._store.validated=!0);else if(e){var y=Y(e);if(typeof y=="function"&&y!==e.entries)for(var O=y.call(e),p;!(p=O.next()).done;)be(p.value)&&Je(p.value,t)}}}function Vt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===v||t.$$typeof===k))r=t.propTypes;else return;if(r){var d=x(t);Pt(r,e.props,"prop",d,e)}else if(t.PropTypes!==void 0&&!ye){ye=!0;var y=x(t);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Bt(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var d=t[r];if(d!=="children"&&d!=="key"){G(e),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",d),G(null);break}}e.ref!==null&&(G(e),S("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}function He(e,t,r,d,y,O){{var p=ue(e);if(!p){var h="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(h+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var j=Wt(y);j?h+=j:h+=ze();var T;e===null?T="null":pe(e)?T="array":e!==void 0&&e.$$typeof===c?(T="<"+(x(e.type)||"Unknown")+" />",h=" Did you accidentally export a JSX literal instead of a component?"):T=typeof e,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",T,h)}var R=Mt(e,t,r,y,O);if(R==null)return R;if(p){var A=t.children;if(A!==void 0)if(d)if(pe(A)){for(var J=0;J<A.length;J++)Ke(A[J],e);Object.freeze&&Object.freeze(A)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ke(A,e)}return e===o?Bt(R):Vt(R),R}}function zt(e,t,r){return He(e,t,r,!0)}function Gt(e,t,r){return He(e,t,r,!1)}var Jt=Gt,Kt=zt;H.Fragment=o,H.jsx=Jt,H.jsxs=Kt}()),H}process.env.NODE_ENV==="production"?ne.exports=Qe():ne.exports=Ze();var i=ne.exports;const ke="default",qe=(s,c,n=!1)=>async(...o)=>await c().fetchWithTokens(s,n)(...o),$e=(s=null,c=ke,n=!1)=>o=>l=>{const{fetch:u}=Ee(s||l.fetch,c,n);return i.jsx(o,{...l,fetch:u})},Ee=(s=null,c=ke,n=!1)=>{const o=s||window.fetch,l=a.OidcClient.get;return{fetch:_.useCallback((g,f)=>qe(o,()=>l(c),n)(g,f),[o,c])}},Te=()=>i.jsx("div",{className:"oidc-authenticating",children:i.jsxs("div",{className:"oidc-authenticating__container",children:[i.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),i.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),et=()=>i.jsx("div",{className:"oidc-authenticating",children:i.jsxs("div",{className:"oidc-authenticating__container",children:[i.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),i.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),tt=()=>Math.random().toString(36).substr(2,6),nt=(s,c)=>(n,o)=>{if(typeof s.CustomEvent=="function")return new s.CustomEvent(n,o);const l=o||{bubbles:!1,cancelable:!1,detail:void 0},u=c.createEvent("CustomEvent");return u.initCustomEvent(n,l.bubbles,l.cancelable,l.detail),u.prototype=s.Event.prototype,u},rt=(s,c,n)=>({replaceState:(o,l)=>{const u=n(),g=l||s.history.state;s.history.replaceState({key:u,state:g},null,o),s.dispatchEvent(c("popstate"))}}),st=()=>rt(window,nt(window,document),tt),we=()=>i.jsx("div",{className:"oidc-callback",children:i.jsxs("div",{className:"oidc-callback__container",children:[i.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),i.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),ot=({callBackError:s,callBackSuccess:c,configurationName:n,withCustomHistory:o})=>{const[l,u]=_.useState(!1);_.useEffect(()=>{let v=!0;return(async()=>{const m=a.OidcClient.get;try{const{callbackPath:k}=await m(n).loginCallbackAsync();(o?o():st()).replaceState(k||"/")}catch(k){v&&(console.warn(k),u(!0))}})(),()=>{v=!1}},[]);const g=s||Te,f=c||we;return l?i.jsx(g,{configurationName:n}):i.jsx(f,{configurationName:n})},at=()=>i.jsx("span",{className:"oidc-loading",children:"Loading"}),ct=()=>i.jsx("div",{className:"oidc-serviceworker",children:i.jsxs("div",{className:"oidc-serviceworker__container",children:[i.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),i.jsx("p",{className:"oidc-serviceworker__content",children:"Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."})]})}),it=()=>i.jsx("div",{className:"oidc-session-lost",children:i.jsxs("div",{className:"oidc-session-lost__container",children:[i.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),i.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),lt=({configurationName:s})=>(_.useEffect(()=>{(async()=>{const n=a.OidcClient.get;n(s).silentLoginCallbackAsync()})()},[]),i.jsx(i.Fragment,{})),ut=({configurationName:s})=>{const c=a.getParseQueryStringFromLocation(window.location.href),n=a.OidcClient.get,o=n(s);let l=null;for(const[u,g]of Object.entries(c))u==="state"||u==="scope"||(l===null&&(l={}),l[u]=g);return _.useEffect(()=>{o.tokens||o.loginAsync(null,l,!0,c.scope)},[]),i.jsx(i.Fragment,{})},ft=({callbackErrorComponent:s,callbackSuccessComponent:c,redirect_uri:n,silent_redirect_uri:o,silent_login_uri:l,children:u,configurationName:g,withCustomHistory:f=null,location:v})=>{const b=window?a.getPath(window.location.href):"",[m,k]=_.useState(b);_.useEffect(()=>{const C=()=>k(a.getPath(window.location.href));return C(),window.addEventListener("popstate",C,!1),()=>window.removeEventListener("popstate",C,!1)},[]);const P=a.getPath(n);if(o&&m===a.getPath(o))return i.jsx(lt,{configurationName:g});if(l&&m===a.getPath(l))return i.jsx(ut,{configurationName:g});switch(m){case P:return i.jsx(ot,{callBackError:s,callBackSuccess:c,configurationName:g,withCustomHistory:f});default:return i.jsx(i.Fragment,{children:u})}},dt=_.memo(ft),Re={name:"",data:null},vt=({loadingComponent:s,children:c,configurationName:n})=>{const[o,l]=_.useState(!0),u=a.OidcClient.get,g=u(n);_.useEffect(()=>{let v=!0;return g&&g.tryKeepExistingSessionAsync().then(()=>{v&&l(!1)}),()=>{v=!1}},[n]);const f=s;return i.jsx(i.Fragment,{children:o?i.jsx(f,{configurationName:n}):i.jsx(i.Fragment,{children:c})})},X=({isLoading:s,loadingComponent:c,children:n,configurationName:o})=>{const l=c;return s?i.jsx(l,{configurationName:o,children:n}):i.jsx(i.Fragment,{children:n})},ht=({children:s,configuration:c,configurationName:n="default",callbackSuccessComponent:o=we,authenticatingComponent:l=et,loadingComponent:u=at,serviceWorkerNotSupportedComponent:g=ct,authenticatingErrorComponent:f=Te,sessionLostComponent:v=it,onSessionLost:b=null,onLogoutFromAnotherTab:m=null,onLogoutFromSameTab:k=null,withCustomHistory:P=null,onEvent:C=null,getFetch:F=null,location:B=null})=>{const Y=(D="default")=>a.OidcClient.getOrCreate(F??a.getFetchDefault,B??new a.OidcLocation)(c,D),[U,S]=_.useState(!0),[oe,V]=_.useState(Re),[ae,ce]=_.useState("default");_.useEffect(()=>{const z=Y(n).subscribeEvents((w,N)=>{C&&C(n,w,N)});return()=>{Y(n).removeEventSubscription(z)}},[n,C]),_.useEffect(()=>{const z=Y(n).subscribeEvents((w,N)=>{if(w===a.OidcClient.eventNames.refreshTokensAsync_error||w===a.OidcClient.eventNames.syncTokensAsync_error){if(b!=null){b();return}V({name:w,data:N})}else if(w===a.OidcClient.eventNames.logout_from_another_tab){if(m!=null){m();return}V({name:w,data:N})}else w===a.OidcClient.eventNames.logout_from_same_tab?k!=null&&k():w===a.OidcClient.eventNames.loginAsync_begin||w===a.OidcClient.eventNames.loginCallbackAsync_end||w===a.OidcClient.eventNames.loginAsync_error||w===a.OidcClient.eventNames.loginCallbackAsync_error?V({name:w,data:N}):w===a.OidcClient.eventNames.service_worker_not_supported_by_browser&&c.service_worker_only===!0&&V({name:w,data:N})});return ce(n),S(!1),()=>{Y(n).removeEventSubscription(z),V(Re)}},[c,n]);const ie=v,le=l,I=u,ue=g,fe=f,M=U||ae!==n,x=Y(n);switch(oe.name){case a.OidcClient.eventNames.service_worker_not_supported_by_browser:return i.jsx(X,{loadingComponent:I,isLoading:M,configurationName:n,children:i.jsx(ue,{configurationName:n})});case a.OidcClient.eventNames.loginAsync_begin:return i.jsx(X,{loadingComponent:I,isLoading:M,configurationName:n,children:i.jsx(le,{configurationName:n})});case a.OidcClient.eventNames.loginAsync_error:case a.OidcClient.eventNames.loginCallbackAsync_error:return i.jsx(X,{loadingComponent:I,isLoading:M,configurationName:n,children:i.jsx(fe,{configurationName:n})});case a.OidcClient.eventNames.refreshTokensAsync_error:case a.OidcClient.eventNames.syncTokensAsync_error:case a.OidcClient.eventNames.logout_from_another_tab:return i.jsx(X,{loadingComponent:I,isLoading:M,configurationName:n,children:i.jsx(ie,{configurationName:n})});default:return i.jsx(X,{loadingComponent:I,isLoading:M,configurationName:n,children:i.jsx(dt,{redirect_uri:x.configuration.redirect_uri,silent_redirect_uri:x.configuration.silent_redirect_uri,silent_login_uri:x.configuration.silent_login_uri,callbackSuccessComponent:o,callbackErrorComponent:f,authenticatingComponent:l,configurationName:n,withCustomHistory:P,location:B??new a.OidcLocation,children:i.jsx(vt,{loadingComponent:I,configurationName:n,children:s})})})}},Se=({children:s,callbackPath:c=null,extras:n=null,configurationName:o="default"})=>{const l=a.OidcClient.get,u=l(o);return _.useEffect(()=>{u.tokens||u.loginAsync(c,n)},[o,c,n]),u.tokens?i.jsx(i.Fragment,{children:s}):null},pt=(s,c=null,n=null,o="default")=>l=>i.jsx(Se,{callbackPath:c,extras:n,configurationName:o,children:i.jsx(s,{...l})}),re="default",se=(s,c)=>{let n=!1;return s(c)&&(n=s(c).tokens!=null),n},_t=(s=re)=>{const c=a.OidcClient.get,[n,o]=_.useState(se(c,s));return _.useEffect(()=>{let f=!0;const v=c(s);o(se(c,s));const b=v.subscribeEvents((m,k)=>{(m===a.OidcClient.eventNames.logout_from_another_tab||m===a.OidcClient.eventNames.logout_from_same_tab||m===a.OidcClient.eventNames.token_aquired)&&f&&o(se(c,s))});return()=>{f=!1,v.removeEventSubscription(b)}},[s]),{login:(f=void 0,v=null,b=!1)=>c(s).loginAsync(f,v,!1,void 0,b),logout:(f=void 0,v=null)=>c(s).logoutAsync(f,v),renewTokens:async(f=null)=>{const v=await c(s).renewTokensAsync(f);return{accessToken:v.accessToken,accessTokenPayload:v.accessTokenPayload,idToken:v.idToken,idTokenPayload:v.idTokenPayload}},isAuthenticated:n}},Pe={accessToken:null,accessTokenPayload:null},gt=s=>{const c=a.OidcClient.get,n=c(s);if(n.tokens){const o=n.tokens;return{accessToken:o.accessToken,accessTokenPayload:o.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:n.configuration.demonstrating_proof_of_possession?(l,u)=>n.generateDemonstrationOfProofOfPossessionAsync(o.accessToken,l,u):null}}return Pe};function yt(s,c){return s.configuration.demonstrating_proof_of_possession?(n,o,l={})=>s.generateDemonstrationOfProofOfPossessionAsync(c.accessToken,n,o,l):null}const bt=(s=re)=>{const c=a.OidcClient.get,[n,o]=_.useState(gt(s));return _.useEffect(()=>{let l=!0;const u=c(s);if(u.tokens){const f=u.tokens;o({accessToken:f.accessToken,accessTokenPayload:f.accessTokenPayload})}const g=u.subscribeEvents((f,v)=>{if((f===a.OidcClient.eventNames.token_renewed||f===a.OidcClient.eventNames.token_aquired||f===a.OidcClient.eventNames.logout_from_another_tab||f===a.OidcClient.eventNames.logout_from_same_tab||f===a.OidcClient.eventNames.refreshTokensAsync_error||f===a.OidcClient.eventNames.syncTokensAsync_error)&&l){const b=u.tokens;o(b!=null?{accessToken:b.accessToken,accessTokenPayload:b.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:yt(u,b)}:Pe)}});return()=>{l=!1,u.removeEventSubscription(g)}},[s]),n},je={idToken:null,idTokenPayload:null},mt=s=>{const c=a.OidcClient.get,n=c(s);if(n.tokens){const o=n.tokens;return{idToken:o.idToken,idTokenPayload:o.idTokenPayload}}return je},Ot=(s=re)=>{const c=a.OidcClient.get,[n,o]=_.useState(mt(s));return _.useEffect(()=>{let l=!0;const u=c(s);if(u.tokens){const f=u.tokens;o({idToken:f.idToken,idTokenPayload:f.idTokenPayload})}const g=u.subscribeEvents((f,v)=>{if((f===a.OidcClient.eventNames.token_renewed||f===a.OidcClient.eventNames.token_aquired||f===a.OidcClient.eventNames.logout_from_another_tab||f===a.OidcClient.eventNames.logout_from_same_tab||f===a.OidcClient.eventNames.refreshTokensAsync_error||f===a.OidcClient.eventNames.syncTokensAsync_error)&&l){const b=u.tokens;o(b!=null?{idToken:b.idToken,idTokenPayload:b.idTokenPayload}:je)}});return()=>{l=!1,u.removeEventSubscription(g)}},[s]),n};var Ce=(s=>(s.Unauthenticated="Unauthenticated",s.Loading="Loading user",s.Loaded="User loaded",s.LoadingError="Error loading user",s))(Ce||{});const kt=(s="default",c=!1)=>{const o=a.OidcClient.get(s).userInfo(),[l,u]=_.useState({user:o,status:o?"User loaded":"Unauthenticated"}),[g,f]=_.useState(o?1:0),[v,b]=_.useState(o?1:0);_.useEffect(()=>{const k=a.OidcClient.get(s);let P=!0;if(k&&k.tokens){const F=g===v;if(F&&k.userInfo())return;u({...l,status:"Loading user"}),k.userInfoAsync(!F,c).then(B=>{P&&u({user:B,status:"User loaded"})}).catch(()=>u({...l,status:"Error loading user"})),b(g)}else u({user:null,status:"Unauthenticated"});const C=k.subscribeEvents(F=>{(F===a.OidcClient.eventNames.logout_from_another_tab||F===a.OidcClient.eventNames.logout_from_same_tab)&&P&&u({user:null,status:"Unauthenticated"})});return()=>{P=!1,k.removeEventSubscription(C)}},[g]);const m=()=>{f(g+1)};return{oidcUser:l.user,oidcUserLoadingState:l.status,reloadOidcUser:m}};Object.defineProperty(E,"OidcClient",{enumerable:!0,get:()=>a.OidcClient}),Object.defineProperty(E,"OidcLocation",{enumerable:!0,get:()=>a.OidcLocation}),Object.defineProperty(E,"TokenAutomaticRenewMode",{enumerable:!0,get:()=>a.TokenAutomaticRenewMode}),Object.defineProperty(E,"TokenRenewMode",{enumerable:!0,get:()=>a.TokenRenewMode}),E.OidcProvider=ht,E.OidcSecure=Se,E.OidcUserStatus=Ce,E.useOidc=_t,E.useOidcAccessToken=bt,E.useOidcFetch=Ee,E.useOidcIdToken=Ot,E.useOidcUser=kt,E.withOidcFetch=$e,E.withOidcSecure=pt,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
27
|
+
Check the top-level render call using <`+r+">.")}return t}}function Xe(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=Bt(t);if(Ge[r])return;Ge[r]=!0;var f="";e&&e._owner&&e._owner!==ye.current&&(f=" It was passed a child from "+x(e._owner.type)+"."),z(e),R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,f),z(null)}}function He(e,t){{if(typeof e!="object")return;if(ge(e))for(var r=0;r<e.length;r++){var f=e[r];ke(f)&&Xe(f,t)}else if(ke(e))e._store&&(e._store.validated=!0);else if(e){var y=Y(e);if(typeof y=="function"&&y!==e.entries)for(var O=y.call(e),p;!(p=O.next()).done;)ke(p.value)&&Xe(p.value,t)}}}function Kt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===v||t.$$typeof===m))r=t.propTypes;else return;if(r){var f=x(t);Ct(r,e.props,"prop",f,e)}else if(t.PropTypes!==void 0&&!be){be=!0;var y=x(t);R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Jt(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var f=t[r];if(f!=="children"&&f!=="key"){z(e),R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),z(null);break}}e.ref!==null&&(z(e),R("Invalid attribute `ref` supplied to `React.Fragment`."),z(null))}}var Qe={};function Ze(e,t,r,f,y,O){{var p=de(e);if(!p){var h="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(h+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var P=Vt(y);P?h+=P:h+=ze();var T;e===null?T="null":ge(e)?T="array":e!==void 0&&e.$$typeof===i?(T="<"+(x(e.type)||"Unknown")+" />",h=" Did you accidentally export a JSX literal instead of a component?"):T=typeof e,R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",T,h)}var S=Yt(e,t,r,y,O);if(S==null)return S;if(p){var F=t.children;if(F!==void 0)if(f)if(ge(F)){for(var G=0;G<F.length;G++)He(F[G],e);Object.freeze&&Object.freeze(F)}else R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else He(F,e)}if(Z.call(t,"key")){var B=x(e),A=Object.keys(t).filter(function(Zt){return Zt!=="key"}),Oe=A.length>0?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}";if(!Qe[B+Oe]){var Qt=A.length>0?"{"+A.join(": ..., ")+": ...}":"{}";R(`A props object containing a "key" prop is being spread into JSX:
|
|
28
|
+
let props = %s;
|
|
29
|
+
<%s {...props} />
|
|
30
|
+
React keys must be passed directly to JSX without using spread:
|
|
31
|
+
let props = %s;
|
|
32
|
+
<%s key={someKey} {...props} />`,Oe,B,Qt,B),Qe[B+Oe]=!0}}return e===o?Jt(S):Kt(S),S}}function zt(e,t,r){return Ze(e,t,r,!0)}function Gt(e,t,r){return Ze(e,t,r,!1)}var Xt=Gt,Ht=zt;H.Fragment=o,H.jsx=Xt,H.jsxs=Ht}()),H}process.env.NODE_ENV==="production"?re.exports=qe():re.exports=$e();var c=re.exports;const Te="default",et=(s,i,n=!1)=>async(...o)=>await i().fetchWithTokens(s,n)(...o),tt=(s=null,i=Te,n=!1)=>o=>l=>{const{fetch:u}=we(s||l.fetch,i,n);return c.jsx(o,{...l,fetch:u})},we=(s=null,i=Te,n=!1)=>{const o=s||window.fetch,l=a.OidcClient.get;return{fetch:g.useCallback((_,d)=>et(o,()=>l(i),n)(_,d),[o,i])}},Se=()=>c.jsx("div",{className:"oidc-authenticating",children:c.jsxs("div",{className:"oidc-authenticating__container",children:[c.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),c.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),nt=()=>c.jsx("div",{className:"oidc-authenticating",children:c.jsxs("div",{className:"oidc-authenticating__container",children:[c.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),c.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),rt=()=>Math.random().toString(36).substr(2,6),st=(s,i)=>(n,o)=>{if(typeof s.CustomEvent=="function")return new s.CustomEvent(n,o);const l=o||{bubbles:!1,cancelable:!1,detail:void 0},u=i.createEvent("CustomEvent");return u.initCustomEvent(n,l.bubbles,l.cancelable,l.detail),u.prototype=s.Event.prototype,u},ot=(s,i,n)=>({replaceState:(o,l)=>{const u=n(),_=l||s.history.state;s.history.replaceState({key:u,state:_},null,o),s.dispatchEvent(i("popstate"))}}),at=()=>ot(window,st(window,document),rt),Re=()=>c.jsx("div",{className:"oidc-callback",children:c.jsxs("div",{className:"oidc-callback__container",children:[c.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),c.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),it=({callBackError:s,callBackSuccess:i,configurationName:n,withCustomHistory:o})=>{const[l,u]=g.useState(!1);g.useEffect(()=>{let v=!0;return(async()=>{const k=a.OidcClient.get;try{const{callbackPath:m}=await k(n).loginCallbackAsync();(o?o():at()).replaceState(m||"/")}catch(m){v&&(console.warn(m),u(!0))}})(),()=>{v=!1}},[]);const _=s||Se,d=i||Re;return l?c.jsx(_,{configurationName:n}):c.jsx(d,{configurationName:n})},ct=()=>c.jsx("span",{className:"oidc-loading",children:"Loading"}),lt=()=>c.jsx("div",{className:"oidc-serviceworker",children:c.jsxs("div",{className:"oidc-serviceworker__container",children:[c.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),c.jsx("p",{className:"oidc-serviceworker__content",children:"Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."})]})}),ut=()=>c.jsx("div",{className:"oidc-session-lost",children:c.jsxs("div",{className:"oidc-session-lost__container",children:[c.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),c.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),dt=({configurationName:s})=>(g.useEffect(()=>{(async()=>{const n=a.OidcClient.get;n(s).silentLoginCallbackAsync()})()},[]),c.jsx(c.Fragment,{})),ft=({configurationName:s})=>{const i=a.getParseQueryStringFromLocation(window.location.href),n=a.OidcClient.get,o=n(s);let l=null;for(const[u,_]of Object.entries(i))u==="state"||u==="scope"||(l===null&&(l={}),l[u]=_);return g.useEffect(()=>{o.tokens||o.loginAsync(null,l,!0,i.scope)},[]),c.jsx(c.Fragment,{})},vt=({callbackErrorComponent:s,callbackSuccessComponent:i,redirect_uri:n,silent_redirect_uri:o,silent_login_uri:l,children:u,configurationName:_,withCustomHistory:d=null,location:v})=>{const b=window?a.getPath(window.location.href):"",[k,m]=g.useState(b);g.useEffect(()=>{const C=()=>m(a.getPath(window.location.href));return C(),window.addEventListener("popstate",C,!1),()=>window.removeEventListener("popstate",C,!1)},[]);const j=a.getPath(n);if(o&&k===a.getPath(o))return c.jsx(dt,{configurationName:_});if(l&&k===a.getPath(l))return c.jsx(ft,{configurationName:_});switch(k){case j:return c.jsx(it,{callBackError:s,callBackSuccess:i,configurationName:_,withCustomHistory:d});default:return c.jsx(c.Fragment,{children:u})}},ht=g.memo(vt),je={name:"",data:null},pt=({loadingComponent:s,children:i,configurationName:n})=>{const[o,l]=g.useState(!0),u=a.OidcClient.get,_=u(n);g.useEffect(()=>{let v=!0;return _&&_.tryKeepExistingSessionAsync().then(()=>{v&&l(!1)}),()=>{v=!1}},[n]);const d=s;return c.jsx(c.Fragment,{children:o?c.jsx(d,{configurationName:n}):c.jsx(c.Fragment,{children:i})})},Q=({isLoading:s,loadingComponent:i,children:n,configurationName:o})=>{const l=i;return s?c.jsx(l,{configurationName:o,children:n}):c.jsx(c.Fragment,{children:n})},gt=({children:s,configuration:i,configurationName:n="default",callbackSuccessComponent:o=Re,authenticatingComponent:l=nt,loadingComponent:u=ct,serviceWorkerNotSupportedComponent:_=lt,authenticatingErrorComponent:d=Se,sessionLostComponent:v=ut,onSessionLost:b=null,onLogoutFromAnotherTab:k=null,onLogoutFromSameTab:m=null,withCustomHistory:j=null,onEvent:C=null,getFetch:I=null,location:K=null})=>{const Y=(L="default")=>a.OidcClient.getOrCreate(I??a.getFetchDefault,K??new a.OidcLocation)(i,L),[U,R]=g.useState(!0),[ae,V]=g.useState(je),[ie,ce]=g.useState("default");g.useEffect(()=>{const J=Y(n).subscribeEvents((w,N)=>{C&&C(n,w,N)});return()=>{Y(n).removeEventSubscription(J)}},[n,C]),g.useEffect(()=>{const J=Y(n).subscribeEvents((w,N)=>{if(w===a.OidcClient.eventNames.refreshTokensAsync_error||w===a.OidcClient.eventNames.syncTokensAsync_error){if(b!=null){b();return}V({name:w,data:N})}else if(w===a.OidcClient.eventNames.logout_from_another_tab){if(k!=null){k();return}V({name:w,data:N})}else w===a.OidcClient.eventNames.logout_from_same_tab?m!=null&&m():w===a.OidcClient.eventNames.loginAsync_begin||w===a.OidcClient.eventNames.loginCallbackAsync_end||w===a.OidcClient.eventNames.loginAsync_error||w===a.OidcClient.eventNames.loginCallbackAsync_error?V({name:w,data:N}):w===a.OidcClient.eventNames.service_worker_not_supported_by_browser&&i.service_worker_only===!0&&V({name:w,data:N})});return ce(n),R(!1),()=>{Y(n).removeEventSubscription(J),V(je)}},[i,n]);const le=v,ue=l,D=u,de=_,fe=d,W=U||ie!==n,x=Y(n);switch(ae.name){case a.OidcClient.eventNames.service_worker_not_supported_by_browser:return c.jsx(Q,{loadingComponent:D,isLoading:W,configurationName:n,children:c.jsx(de,{configurationName:n})});case a.OidcClient.eventNames.loginAsync_begin:return c.jsx(Q,{loadingComponent:D,isLoading:W,configurationName:n,children:c.jsx(ue,{configurationName:n})});case a.OidcClient.eventNames.loginAsync_error:case a.OidcClient.eventNames.loginCallbackAsync_error:return c.jsx(Q,{loadingComponent:D,isLoading:W,configurationName:n,children:c.jsx(fe,{configurationName:n})});case a.OidcClient.eventNames.refreshTokensAsync_error:case a.OidcClient.eventNames.syncTokensAsync_error:case a.OidcClient.eventNames.logout_from_another_tab:return c.jsx(Q,{loadingComponent:D,isLoading:W,configurationName:n,children:c.jsx(le,{configurationName:n})});default:return c.jsx(Q,{loadingComponent:D,isLoading:W,configurationName:n,children:c.jsx(ht,{redirect_uri:x.configuration.redirect_uri,silent_redirect_uri:x.configuration.silent_redirect_uri,silent_login_uri:x.configuration.silent_login_uri,callbackSuccessComponent:o,callbackErrorComponent:d,authenticatingComponent:l,configurationName:n,withCustomHistory:j,location:K??new a.OidcLocation,children:c.jsx(pt,{loadingComponent:D,configurationName:n,children:s})})})}},Pe=({children:s,callbackPath:i=null,extras:n=null,configurationName:o="default"})=>{const l=a.OidcClient.get,u=l(o);return g.useEffect(()=>{u.tokens||u.loginAsync(i,n)},[o,i,n]),u.tokens?c.jsx(c.Fragment,{children:s}):null},_t=(s,i=null,n=null,o="default")=>l=>c.jsx(Pe,{callbackPath:i,extras:n,configurationName:o,children:c.jsx(s,{...l})}),se="default",oe=(s,i)=>{let n=!1;return s(i)&&(n=s(i).tokens!=null),n},yt=(s=se)=>{const i=a.OidcClient.get,[n,o]=g.useState(oe(i,s));return g.useEffect(()=>{let d=!0;const v=i(s);o(oe(i,s));const b=v.subscribeEvents((k,m)=>{(k===a.OidcClient.eventNames.logout_from_another_tab||k===a.OidcClient.eventNames.logout_from_same_tab||k===a.OidcClient.eventNames.token_aquired)&&d&&o(oe(i,s))});return()=>{d=!1,v.removeEventSubscription(b)}},[s]),{login:(d=void 0,v=null,b=!1)=>i(s).loginAsync(d,v,!1,void 0,b),logout:(d=void 0,v=null)=>i(s).logoutAsync(d,v),renewTokens:async(d=null)=>{const v=await i(s).renewTokensAsync(d);return{accessToken:v.accessToken,accessTokenPayload:v.accessTokenPayload,idToken:v.idToken,idTokenPayload:v.idTokenPayload}},isAuthenticated:n}},Ce={accessToken:null,accessTokenPayload:null},bt=s=>{const i=a.OidcClient.get,n=i(s);if(n.tokens){const o=n.tokens;return{accessToken:o.accessToken,accessTokenPayload:o.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:n.configuration.demonstrating_proof_of_possession?(l,u)=>n.generateDemonstrationOfProofOfPossessionAsync(o.accessToken,l,u):null}}return Ce};function kt(s,i){return s.configuration.demonstrating_proof_of_possession?(n,o,l={})=>s.generateDemonstrationOfProofOfPossessionAsync(i.accessToken,n,o,l):null}const Ot=(s=se)=>{const i=a.OidcClient.get,[n,o]=g.useState(bt(s));return g.useEffect(()=>{let l=!0;const u=i(s);if(u.tokens){const d=u.tokens;o({accessToken:d.accessToken,accessTokenPayload:d.accessTokenPayload})}const _=u.subscribeEvents((d,v)=>{if((d===a.OidcClient.eventNames.token_renewed||d===a.OidcClient.eventNames.token_aquired||d===a.OidcClient.eventNames.logout_from_another_tab||d===a.OidcClient.eventNames.logout_from_same_tab||d===a.OidcClient.eventNames.refreshTokensAsync_error||d===a.OidcClient.eventNames.syncTokensAsync_error)&&l){const b=u.tokens;o(b!=null?{accessToken:b.accessToken,accessTokenPayload:b.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:kt(u,b)}:Ce)}});return()=>{l=!1,u.removeEventSubscription(_)}},[s]),n},xe={idToken:null,idTokenPayload:null},mt=s=>{const i=a.OidcClient.get,n=i(s);if(n.tokens){const o=n.tokens;return{idToken:o.idToken,idTokenPayload:o.idTokenPayload}}return xe},Et=(s=se)=>{const i=a.OidcClient.get,[n,o]=g.useState(mt(s));return g.useEffect(()=>{let l=!0;const u=i(s);if(u.tokens){const d=u.tokens;o({idToken:d.idToken,idTokenPayload:d.idTokenPayload})}const _=u.subscribeEvents((d,v)=>{if((d===a.OidcClient.eventNames.token_renewed||d===a.OidcClient.eventNames.token_aquired||d===a.OidcClient.eventNames.logout_from_another_tab||d===a.OidcClient.eventNames.logout_from_same_tab||d===a.OidcClient.eventNames.refreshTokensAsync_error||d===a.OidcClient.eventNames.syncTokensAsync_error)&&l){const b=u.tokens;o(b!=null?{idToken:b.idToken,idTokenPayload:b.idTokenPayload}:xe)}});return()=>{l=!1,u.removeEventSubscription(_)}},[s]),n};var Ae=(s=>(s.Unauthenticated="Unauthenticated",s.Loading="Loading user",s.Loaded="User loaded",s.LoadingError="Error loading user",s))(Ae||{});const Tt=(s="default",i=!1)=>{const o=a.OidcClient.get(s).userInfo(),[l,u]=g.useState({user:o,status:o?"User loaded":"Unauthenticated"}),[_,d]=g.useState(o?1:0),[v,b]=g.useState(o?1:0);g.useEffect(()=>{const m=a.OidcClient.get(s);let j=!0;if(m&&m.tokens){const I=_===v;if(I&&m.userInfo())return;u({...l,status:"Loading user"}),m.userInfoAsync(!I,i).then(K=>{j&&u({user:K,status:"User loaded"})}).catch(()=>u({...l,status:"Error loading user"})),b(_)}else u({user:null,status:"Unauthenticated"});const C=m.subscribeEvents(I=>{(I===a.OidcClient.eventNames.logout_from_another_tab||I===a.OidcClient.eventNames.logout_from_same_tab)&&j&&u({user:null,status:"Unauthenticated"})});return()=>{j=!1,m.removeEventSubscription(C)}},[_]);const k=()=>{d(_+1)};return{oidcUser:l.user,oidcUserLoadingState:l.status,reloadOidcUser:k}};Object.defineProperty(E,"OidcClient",{enumerable:!0,get:()=>a.OidcClient}),Object.defineProperty(E,"OidcLocation",{enumerable:!0,get:()=>a.OidcLocation}),Object.defineProperty(E,"TokenAutomaticRenewMode",{enumerable:!0,get:()=>a.TokenAutomaticRenewMode}),Object.defineProperty(E,"TokenRenewMode",{enumerable:!0,get:()=>a.TokenRenewMode}),E.OidcProvider=gt,E.OidcSecure=Pe,E.OidcUserStatus=Ae,E.useOidc=yt,E.useOidcAccessToken=Ot,E.useOidcFetch=we,E.useOidcIdToken=Et,E.useOidcUser=Tt,E.withOidcFetch=tt,E.withOidcSecure=_t,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/react-oidc",
|
|
3
|
-
"version": "7.22.
|
|
3
|
+
"version": "7.22.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -40,31 +40,31 @@
|
|
|
40
40
|
"lint": "eslint src"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@axa-fr/oidc-client-service-worker": "7.22.
|
|
44
|
-
"@axa-fr/oidc-client": "7.22.
|
|
43
|
+
"@axa-fr/oidc-client-service-worker": "7.22.5",
|
|
44
|
+
"@axa-fr/oidc-client": "7.22.5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^17.0.0 || ^18.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@testing-library/jest-dom": "6.4.
|
|
51
|
-
"@testing-library/react": "15.0.
|
|
50
|
+
"@testing-library/jest-dom": "6.4.5",
|
|
51
|
+
"@testing-library/react": "15.0.7",
|
|
52
52
|
"@testing-library/user-event": "14.5.2",
|
|
53
|
-
"@types/react": "
|
|
53
|
+
"@types/react": "18.3.2",
|
|
54
54
|
"@vitejs/plugin-react": "4.2.1",
|
|
55
|
-
"@vitest/coverage-v8": "1.
|
|
55
|
+
"@vitest/coverage-v8": "1.6.0",
|
|
56
56
|
"cpy": "11.0.1",
|
|
57
57
|
"cpy-cli": "^5.0.0",
|
|
58
58
|
"cross-env": "^7.0.3",
|
|
59
59
|
"jsdom": "24.0.0",
|
|
60
|
-
"msw": "2.
|
|
61
|
-
"react": "^18.
|
|
62
|
-
"react-dom": "^18.
|
|
63
|
-
"rimraf": "5.0.
|
|
60
|
+
"msw": "2.3.0",
|
|
61
|
+
"react": "^18.3.1",
|
|
62
|
+
"react-dom": "^18.3.1",
|
|
63
|
+
"rimraf": "5.0.7",
|
|
64
64
|
"typescript": "5.4.5",
|
|
65
|
-
"vite": "5.2.
|
|
66
|
-
"vite-plugin-dts": "3.
|
|
67
|
-
"vitest": "1.
|
|
65
|
+
"vite": "5.2.11",
|
|
66
|
+
"vite-plugin-dts": "3.9.1",
|
|
67
|
+
"vitest": "1.6.0"
|
|
68
68
|
},
|
|
69
69
|
"license": "MIT",
|
|
70
70
|
"publishConfig": {
|