@arkitektbedriftene/fe-lib 0.2.4
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/.github/workflows/auto-publish.yaml +20 -0
- package/.github/workflows/publish.yaml +21 -0
- package/.github/workflows/tag-versions.yaml +16 -0
- package/README.md +23 -0
- package/dist/hooks.cjs.js +1 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.es.js +5 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +4 -0
- package/dist/lib/hooks/hooks.d.ts +2 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/oidc/impersonate.d.ts +30 -0
- package/dist/lib/oidc/oidc.d.ts +29 -0
- package/dist/oidc.cjs.js +27 -0
- package/dist/oidc.d.ts +1 -0
- package/dist/oidc.es.js +3431 -0
- package/dist/useLocalStorageState-b4fb2a60.js +100 -0
- package/dist/useLocalStorageState-f72b4add.cjs +1 -0
- package/index.html +13 -0
- package/package.json +64 -0
- package/src/App.css +42 -0
- package/src/App.tsx +35 -0
- package/src/assets/react.svg +1 -0
- package/src/index.css +69 -0
- package/src/lib/hooks/hooks.ts +3 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/oidc/README.md +28 -0
- package/src/lib/oidc/impersonate.tsx +102 -0
- package/src/lib/oidc/oidc.tsx +248 -0
- package/src/main.tsx +10 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +21 -0
- package/tsconfig.node.json +9 -0
- package/vite.config.ts +33 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Auto Publish NPM
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v3
|
|
13
|
+
- uses: actions/setup-node@v3
|
|
14
|
+
with:
|
|
15
|
+
node-version: 16
|
|
16
|
+
- run: npm ci
|
|
17
|
+
- run: npm run build
|
|
18
|
+
- uses: JS-DevTools/npm-publish@v1
|
|
19
|
+
with:
|
|
20
|
+
token: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Publish package to NPM
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
packages: write
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v3
|
|
13
|
+
- uses: actions/setup-node@v3
|
|
14
|
+
with:
|
|
15
|
+
node-version: '16.x'
|
|
16
|
+
registry-url: 'https://registry.npmjs.org'
|
|
17
|
+
- run: npm ci
|
|
18
|
+
- run: npm run build
|
|
19
|
+
- run: npm publish
|
|
20
|
+
env:
|
|
21
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Create Tag
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
- uses: Klemensas/action-autotag@1.2.3
|
|
14
|
+
with:
|
|
15
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
16
|
+
tag_prefix: "v"
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Slik bruker du biblioteket
|
|
2
|
+
|
|
3
|
+
### 1. Opprett "Personal Access Token (classic)" hos GitHub
|
|
4
|
+
|
|
5
|
+
User Settings > Developer settings > New personal access token (classic)
|
|
6
|
+
|
|
7
|
+
Scope: `read:packages`
|
|
8
|
+
|
|
9
|
+
Husk å notere ned token når du har opprettet den.
|
|
10
|
+
|
|
11
|
+
### 2. Logg inn gjennom NPM
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npm login --scope=@arkitektbedriftene --auth-type=legacy --registry=https://npm.pkg.github.com
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Skriv inn brukernavn og bruke token som passord. Bruk din AiN-epost når du blir etterspurt passord.
|
|
18
|
+
|
|
19
|
+
### 3. Innstallér pakken
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
npm install @arkitektbedriftene/fe-lib
|
|
23
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useLocalStorageState-f72b4add.cjs");require("react");exports.useLocalStorageState=e.useLocalStorageState;
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/hooks/hooks'
|
package/dist/hooks.es.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l="Hello From Library!";exports.helloWorld=l;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/index'
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const helloWorld = "Hello From Library!";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type UserInfo = {
|
|
3
|
+
email: string;
|
|
4
|
+
firmaccess: string;
|
|
5
|
+
firstname: string;
|
|
6
|
+
lastname: string;
|
|
7
|
+
username: string;
|
|
8
|
+
};
|
|
9
|
+
export type ImpersonationContextType = {
|
|
10
|
+
accessToken?: string;
|
|
11
|
+
userInfo?: UserInfo;
|
|
12
|
+
setImpersonation?: (accessToken?: string, userInfo?: UserInfo) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const useImpersonationContext: () => ImpersonationContextType;
|
|
15
|
+
export declare const ImpersonationContextProvider: ({ children, }: {
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}) => JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* This hook is used to pick up the impersonation access token from the URL.
|
|
20
|
+
* The access token must be provided in the query string as "impersonateAccessToken".
|
|
21
|
+
*
|
|
22
|
+
* You may optionally provide a callback that will be called after the impersonation
|
|
23
|
+
* access token has been picked up. This is useful if you want to redirect the user
|
|
24
|
+
* to a different page after the impersonation access token has been picked up.
|
|
25
|
+
*
|
|
26
|
+
* For security reasons you should immediately remove the impersonateAccessToken
|
|
27
|
+
* from the query string after picking it up.
|
|
28
|
+
*/
|
|
29
|
+
export declare const useImpersonationCallback: (onDone: () => void) => void;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { User, UserManager } from "oidc-client-ts";
|
|
2
|
+
import { Context, ReactNode } from "react";
|
|
3
|
+
export * from "oidc-client-ts";
|
|
4
|
+
export * from "./impersonate";
|
|
5
|
+
export type AuthState = {
|
|
6
|
+
user: User | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
isAuthenticated: boolean;
|
|
9
|
+
isError: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
};
|
|
12
|
+
export type AuthContextData = {
|
|
13
|
+
state: AuthState;
|
|
14
|
+
handleSigninCallback: () => Promise<User | undefined>;
|
|
15
|
+
redirectToSignin: UserManager["signinRedirect"];
|
|
16
|
+
};
|
|
17
|
+
export type AuthProviderConfig = {
|
|
18
|
+
onSigninComplete: (user: User | null) => void;
|
|
19
|
+
};
|
|
20
|
+
export declare const createAuthContext: (userManager: UserManager) => {
|
|
21
|
+
AuthContext: Context<AuthContextData | null>;
|
|
22
|
+
AuthProvider: ({ children }: {
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}) => JSX.Element;
|
|
25
|
+
useAuthContext: () => AuthContextData;
|
|
26
|
+
useAuthState: () => AuthState;
|
|
27
|
+
useSigninCallback: (onDone?: ((user?: User) => void) | undefined) => AuthState;
|
|
28
|
+
getAccessToken: () => Promise<string | null>;
|
|
29
|
+
};
|
package/dist/oidc.cjs.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),Xt=require("./useLocalStorageState-f72b4add.cjs");var ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qt(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function s(){if(this instanceof s){var n=[null];n.push.apply(n,arguments);var o=Function.bind.apply(t,n);return new o}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(s){var n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,n.get?n:{enumerable:!0,get:function(){return e[s]}})}),r}var ue={},Zt={get exports(){return ue},set exports(e){ue=e}},ae={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var ot;function er(){if(ot)return ae;ot=1;var e=M,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,n=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(d,l,h){var p,_={},b=null,w=null;h!==void 0&&(b=""+h),l.key!==void 0&&(b=""+l.key),l.ref!==void 0&&(w=l.ref);for(p in l)s.call(l,p)&&!o.hasOwnProperty(p)&&(_[p]=l[p]);if(d&&d.defaultProps)for(p in l=d.defaultProps,l)_[p]===void 0&&(_[p]=l[p]);return{$$typeof:t,type:d,key:b,ref:w,props:_,_owner:n.current}}return ae.Fragment=r,ae.jsx=a,ae.jsxs=a,ae}var ce={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var at;function tr(){return at||(at=1,process.env.NODE_ENV!=="production"&&function(){var e=M,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),d=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),w=Symbol.for("react.offscreen"),I=Symbol.iterator,v="@@iterator";function R(i){if(i===null||typeof i!="object")return null;var u=I&&i[I]||i[v];return typeof u=="function"?u:null}var k=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function c(i){{for(var u=arguments.length,f=new Array(u>1?u-1:0),S=1;S<u;S++)f[S-1]=arguments[S];g("error",i,f)}}function g(i,u,f){{var S=k.ReactDebugCurrentFrame,x=S.getStackAddendum();x!==""&&(u+="%s",f=f.concat([x]));var U=f.map(function(T){return String(T)});U.unshift("Warning: "+u),Function.prototype.apply.call(console[i],console,U)}}var m=!1,E=!1,P=!1,O=!1,A=!1,j;j=Symbol.for("react.module.reference");function B(i){return!!(typeof i=="string"||typeof i=="function"||i===s||i===o||A||i===n||i===h||i===p||O||i===w||m||E||P||typeof i=="object"&&i!==null&&(i.$$typeof===b||i.$$typeof===_||i.$$typeof===a||i.$$typeof===d||i.$$typeof===l||i.$$typeof===j||i.getModuleId!==void 0))}function D(i,u,f){var S=i.displayName;if(S)return S;var x=u.displayName||u.name||"";return x!==""?f+"("+x+")":f}function z(i){return i.displayName||"Context"}function W(i){if(i==null)return null;if(typeof i.tag=="number"&&c("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case s:return"Fragment";case r:return"Portal";case o:return"Profiler";case n:return"StrictMode";case h:return"Suspense";case p:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case d:var u=i;return z(u)+".Consumer";case a:var f=i;return z(f._context)+".Provider";case l:return D(i,i.render,"ForwardRef");case _:var S=i.displayName||null;return S!==null?S:W(i.type)||"Memo";case b:{var x=i,U=x._payload,T=x._init;try{return W(T(U))}catch{return null}}}return null}var $=Object.assign,Y=0,re,Z,de,Le,He,Be,$e;function ze(){}ze.__reactDisabledLog=!0;function Ct(){{if(Y===0){re=console.log,Z=console.info,de=console.warn,Le=console.error,He=console.group,Be=console.groupCollapsed,$e=console.groupEnd;var i={configurable:!0,enumerable:!0,value:ze,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}Y++}}function Tt(){{if(Y--,Y===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:$({},i,{value:re}),info:$({},i,{value:Z}),warn:$({},i,{value:de}),error:$({},i,{value:Le}),group:$({},i,{value:He}),groupCollapsed:$({},i,{value:Be}),groupEnd:$({},i,{value:$e})})}Y<0&&c("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var be=k.ReactCurrentDispatcher,ke;function he(i,u,f){{if(ke===void 0)try{throw Error()}catch(x){var S=x.stack.trim().match(/\n( *(at )?)/);ke=S&&S[1]||""}return`
|
|
18
|
+
`+ke+i}}var Ee=!1,ge;{var xt=typeof WeakMap=="function"?WeakMap:Map;ge=new xt}function Je(i,u){if(!i||Ee)return"";{var f=ge.get(i);if(f!==void 0)return f}var S;Ee=!0;var x=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var U;U=be.current,be.current=null,Ct();try{if(u){var T=function(){throw Error()};if(Object.defineProperty(T.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(T,[])}catch(G){S=G}Reflect.construct(i,[],T)}else{try{T.call()}catch(G){S=G}i.call(T.prototype)}}else{try{throw Error()}catch(G){S=G}i()}}catch(G){if(G&&S&&typeof G.stack=="string"){for(var C=G.stack.split(`
|
|
19
|
+
`),F=S.stack.split(`
|
|
20
|
+
`),N=C.length-1,q=F.length-1;N>=1&&q>=0&&C[N]!==F[q];)q--;for(;N>=1&&q>=0;N--,q--)if(C[N]!==F[q]){if(N!==1||q!==1)do if(N--,q--,q<0||C[N]!==F[q]){var L=`
|
|
21
|
+
`+C[N].replace(" at new "," at ");return i.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",i.displayName)),typeof i=="function"&&ge.set(i,L),L}while(N>=1&&q>=0);break}}}finally{Ee=!1,be.current=U,Tt(),Error.prepareStackTrace=x}var ie=i?i.displayName||i.name:"",nt=ie?he(ie):"";return typeof i=="function"&&ge.set(i,nt),nt}function It(i,u,f){return Je(i,!1)}function Pt(i){var u=i.prototype;return!!(u&&u.isReactComponent)}function fe(i,u,f){if(i==null)return"";if(typeof i=="function")return Je(i,Pt(i));if(typeof i=="string")return he(i);switch(i){case h:return he("Suspense");case p:return he("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case l:return It(i.render);case _:return fe(i.type,u,f);case b:{var S=i,x=S._payload,U=S._init;try{return fe(U(x),u,f)}catch{}}}return""}var _e=Object.prototype.hasOwnProperty,Ke={},Ve=k.ReactDebugCurrentFrame;function pe(i){if(i){var u=i._owner,f=fe(i.type,i._source,u?u.type:null);Ve.setExtraStackFrame(f)}else Ve.setExtraStackFrame(null)}function Ot(i,u,f,S,x){{var U=Function.call.bind(_e);for(var T in i)if(U(i,T)){var C=void 0;try{if(typeof i[T]!="function"){var F=Error((S||"React class")+": "+f+" type `"+T+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[T]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw F.name="Invariant Violation",F}C=i[T](u,T,S,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(N){C=N}C&&!(C instanceof Error)&&(pe(x),c("%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).",S||"React class",f,T,typeof C),pe(null)),C instanceof Error&&!(C.message in Ke)&&(Ke[C.message]=!0,pe(x),c("Failed %s type: %s",f,C.message),pe(null))}}}var Ut=Array.isArray;function Re(i){return Ut(i)}function At(i){{var u=typeof Symbol=="function"&&Symbol.toStringTag,f=u&&i[Symbol.toStringTag]||i.constructor.name||"Object";return f}}function jt(i){try{return Ye(i),!1}catch{return!0}}function Ye(i){return""+i}function Ge(i){if(jt(i))return c("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",At(i)),Ye(i)}var oe=k.ReactCurrentOwner,Nt={key:!0,ref:!0,__self:!0,__source:!0},Xe,Qe,Ce;Ce={};function qt(i){if(_e.call(i,"ref")){var u=Object.getOwnPropertyDescriptor(i,"ref").get;if(u&&u.isReactWarning)return!1}return i.ref!==void 0}function Mt(i){if(_e.call(i,"key")){var u=Object.getOwnPropertyDescriptor(i,"key").get;if(u&&u.isReactWarning)return!1}return i.key!==void 0}function Wt(i,u){if(typeof i.ref=="string"&&oe.current&&u&&oe.current.stateNode!==u){var f=W(oe.current.type);Ce[f]||(c('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',W(oe.current.type),i.ref),Ce[f]=!0)}}function Ft(i,u){{var f=function(){Xe||(Xe=!0,c("%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)",u))};f.isReactWarning=!0,Object.defineProperty(i,"key",{get:f,configurable:!0})}}function Dt(i,u){{var f=function(){Qe||(Qe=!0,c("%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)",u))};f.isReactWarning=!0,Object.defineProperty(i,"ref",{get:f,configurable:!0})}}var Lt=function(i,u,f,S,x,U,T){var C={$$typeof:t,type:i,key:u,ref:f,props:T,_owner:U};return C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(C,"_self",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.defineProperty(C,"_source",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C};function Ht(i,u,f,S,x){{var U,T={},C=null,F=null;f!==void 0&&(Ge(f),C=""+f),Mt(u)&&(Ge(u.key),C=""+u.key),qt(u)&&(F=u.ref,Wt(u,x));for(U in u)_e.call(u,U)&&!Nt.hasOwnProperty(U)&&(T[U]=u[U]);if(i&&i.defaultProps){var N=i.defaultProps;for(U in N)T[U]===void 0&&(T[U]=N[U])}if(C||F){var q=typeof i=="function"?i.displayName||i.name||"Unknown":i;C&&Ft(T,q),F&&Dt(T,q)}return Lt(i,C,F,x,S,oe.current,T)}}var Te=k.ReactCurrentOwner,Ze=k.ReactDebugCurrentFrame;function se(i){if(i){var u=i._owner,f=fe(i.type,i._source,u?u.type:null);Ze.setExtraStackFrame(f)}else Ze.setExtraStackFrame(null)}var xe;xe=!1;function Ie(i){return typeof i=="object"&&i!==null&&i.$$typeof===t}function et(){{if(Te.current){var i=W(Te.current.type);if(i)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+i+"`."}return""}}function Bt(i){{if(i!==void 0){var u=i.fileName.replace(/^.*[\\\/]/,""),f=i.lineNumber;return`
|
|
24
|
+
|
|
25
|
+
Check your code at `+u+":"+f+"."}return""}}var tt={};function $t(i){{var u=et();if(!u){var f=typeof i=="string"?i:i.displayName||i.name;f&&(u=`
|
|
26
|
+
|
|
27
|
+
Check the top-level render call using <`+f+">.")}return u}}function rt(i,u){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var f=$t(u);if(tt[f])return;tt[f]=!0;var S="";i&&i._owner&&i._owner!==Te.current&&(S=" It was passed a child from "+W(i._owner.type)+"."),se(i),c('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,S),se(null)}}function st(i,u){{if(typeof i!="object")return;if(Re(i))for(var f=0;f<i.length;f++){var S=i[f];Ie(S)&&rt(S,u)}else if(Ie(i))i._store&&(i._store.validated=!0);else if(i){var x=R(i);if(typeof x=="function"&&x!==i.entries)for(var U=x.call(i),T;!(T=U.next()).done;)Ie(T.value)&&rt(T.value,u)}}}function zt(i){{var u=i.type;if(u==null||typeof u=="string")return;var f;if(typeof u=="function")f=u.propTypes;else if(typeof u=="object"&&(u.$$typeof===l||u.$$typeof===_))f=u.propTypes;else return;if(f){var S=W(u);Ot(f,i.props,"prop",S,i)}else if(u.PropTypes!==void 0&&!xe){xe=!0;var x=W(u);c("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",x||"Unknown")}typeof u.getDefaultProps=="function"&&!u.getDefaultProps.isReactClassApproved&&c("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Jt(i){{for(var u=Object.keys(i.props),f=0;f<u.length;f++){var S=u[f];if(S!=="children"&&S!=="key"){se(i),c("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",S),se(null);break}}i.ref!==null&&(se(i),c("Invalid attribute `ref` supplied to `React.Fragment`."),se(null))}}function it(i,u,f,S,x,U){{var T=B(i);if(!T){var C="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).length===0)&&(C+=" 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 F=Bt(x);F?C+=F:C+=et();var N;i===null?N="null":Re(i)?N="array":i!==void 0&&i.$$typeof===t?(N="<"+(W(i.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):N=typeof i,c("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",N,C)}var q=Ht(i,u,f,x,U);if(q==null)return q;if(T){var L=u.children;if(L!==void 0)if(S)if(Re(L)){for(var ie=0;ie<L.length;ie++)st(L[ie],i);Object.freeze&&Object.freeze(L)}else c("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 st(L,i)}return i===s?Jt(q):zt(q),q}}function Kt(i,u,f){return it(i,u,f,!0)}function Vt(i,u,f){return it(i,u,f,!1)}var Yt=Vt,Gt=Kt;ce.Fragment=s,ce.jsx=Yt,ce.jsxs=Gt}()),ce}(function(e){process.env.NODE_ENV==="production"?e.exports=er():e.exports=tr()})(Zt);function rr(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ne={},sr={get exports(){return ne},set exports(e){ne=e}};const ir={},nr=Object.freeze(Object.defineProperty({__proto__:null,default:ir},Symbol.toStringTag,{value:"Module"})),or=Qt(nr);(function(e,t){(function(r,s){e.exports=s()})(ee,function(){var r=r||function(s,n){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof ee<"u"&&ee.crypto&&(o=ee.crypto),!o&&typeof rr=="function")try{o=or}catch{}var a=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},d=Object.create||function(){function c(){}return function(g){var m;return c.prototype=g,m=new c,c.prototype=null,m}}(),l={},h=l.lib={},p=h.Base=function(){return{extend:function(c){var g=d(this);return c&&g.mixIn(c),(!g.hasOwnProperty("init")||this.init===g.init)&&(g.init=function(){g.$super.init.apply(this,arguments)}),g.init.prototype=g,g.$super=this,g},create:function(){var c=this.extend();return c.init.apply(c,arguments),c},init:function(){},mixIn:function(c){for(var g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);c.hasOwnProperty("toString")&&(this.toString=c.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),_=h.WordArray=p.extend({init:function(c,g){c=this.words=c||[],g!=n?this.sigBytes=g:this.sigBytes=c.length*4},toString:function(c){return(c||w).stringify(this)},concat:function(c){var g=this.words,m=c.words,E=this.sigBytes,P=c.sigBytes;if(this.clamp(),E%4)for(var O=0;O<P;O++){var A=m[O>>>2]>>>24-O%4*8&255;g[E+O>>>2]|=A<<24-(E+O)%4*8}else for(var j=0;j<P;j+=4)g[E+j>>>2]=m[j>>>2];return this.sigBytes+=P,this},clamp:function(){var c=this.words,g=this.sigBytes;c[g>>>2]&=4294967295<<32-g%4*8,c.length=s.ceil(g/4)},clone:function(){var c=p.clone.call(this);return c.words=this.words.slice(0),c},random:function(c){for(var g=[],m=0;m<c;m+=4)g.push(a());return new _.init(g,c)}}),b=l.enc={},w=b.Hex={stringify:function(c){for(var g=c.words,m=c.sigBytes,E=[],P=0;P<m;P++){var O=g[P>>>2]>>>24-P%4*8&255;E.push((O>>>4).toString(16)),E.push((O&15).toString(16))}return E.join("")},parse:function(c){for(var g=c.length,m=[],E=0;E<g;E+=2)m[E>>>3]|=parseInt(c.substr(E,2),16)<<24-E%8*4;return new _.init(m,g/2)}},I=b.Latin1={stringify:function(c){for(var g=c.words,m=c.sigBytes,E=[],P=0;P<m;P++){var O=g[P>>>2]>>>24-P%4*8&255;E.push(String.fromCharCode(O))}return E.join("")},parse:function(c){for(var g=c.length,m=[],E=0;E<g;E++)m[E>>>2]|=(c.charCodeAt(E)&255)<<24-E%4*8;return new _.init(m,g)}},v=b.Utf8={stringify:function(c){try{return decodeURIComponent(escape(I.stringify(c)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(c){return I.parse(unescape(encodeURIComponent(c)))}},R=h.BufferedBlockAlgorithm=p.extend({reset:function(){this._data=new _.init,this._nDataBytes=0},_append:function(c){typeof c=="string"&&(c=v.parse(c)),this._data.concat(c),this._nDataBytes+=c.sigBytes},_process:function(c){var g,m=this._data,E=m.words,P=m.sigBytes,O=this.blockSize,A=O*4,j=P/A;c?j=s.ceil(j):j=s.max((j|0)-this._minBufferSize,0);var B=j*O,D=s.min(B*4,P);if(B){for(var z=0;z<B;z+=O)this._doProcessBlock(E,z);g=E.splice(0,B),m.sigBytes-=D}return new _.init(g,D)},clone:function(){var c=p.clone.call(this);return c._data=this._data.clone(),c},_minBufferSize:0});h.Hasher=R.extend({cfg:p.extend(),init:function(c){this.cfg=this.cfg.extend(c),this.reset()},reset:function(){R.reset.call(this),this._doReset()},update:function(c){return this._append(c),this._process(),this},finalize:function(c){c&&this._append(c);var g=this._doFinalize();return g},blockSize:16,_createHelper:function(c){return function(g,m){return new c.init(m).finalize(g)}},_createHmacHelper:function(c){return function(g,m){return new k.HMAC.init(c,m).finalize(g)}}});var k=l.algo={};return l}(Math);return r})})(sr);var Pe={},ar={get exports(){return Pe},set exports(e){Pe=e}};(function(e,t){(function(r,s){e.exports=s(ne)})(ee,function(r){return function(s){var n=r,o=n.lib,a=o.WordArray,d=o.Hasher,l=n.algo,h=[],p=[];(function(){function w(k){for(var c=s.sqrt(k),g=2;g<=c;g++)if(!(k%g))return!1;return!0}function I(k){return(k-(k|0))*4294967296|0}for(var v=2,R=0;R<64;)w(v)&&(R<8&&(h[R]=I(s.pow(v,1/2))),p[R]=I(s.pow(v,1/3)),R++),v++})();var _=[],b=l.SHA256=d.extend({_doReset:function(){this._hash=new a.init(h.slice(0))},_doProcessBlock:function(w,I){for(var v=this._hash.words,R=v[0],k=v[1],c=v[2],g=v[3],m=v[4],E=v[5],P=v[6],O=v[7],A=0;A<64;A++){if(A<16)_[A]=w[I+A]|0;else{var j=_[A-15],B=(j<<25|j>>>7)^(j<<14|j>>>18)^j>>>3,D=_[A-2],z=(D<<15|D>>>17)^(D<<13|D>>>19)^D>>>10;_[A]=B+_[A-7]+z+_[A-16]}var W=m&E^~m&P,$=R&k^R&c^k&c,Y=(R<<30|R>>>2)^(R<<19|R>>>13)^(R<<10|R>>>22),re=(m<<26|m>>>6)^(m<<21|m>>>11)^(m<<7|m>>>25),Z=O+re+W+p[A]+_[A],de=Y+$;O=P,P=E,E=m,m=g+Z|0,g=c,c=k,k=R,R=Z+de|0}v[0]=v[0]+R|0,v[1]=v[1]+k|0,v[2]=v[2]+c|0,v[3]=v[3]+g|0,v[4]=v[4]+m|0,v[5]=v[5]+E|0,v[6]=v[6]+P|0,v[7]=v[7]+O|0},_doFinalize:function(){var w=this._data,I=w.words,v=this._nDataBytes*8,R=w.sigBytes*8;return I[R>>>5]|=128<<24-R%32,I[(R+64>>>9<<4)+14]=s.floor(v/4294967296),I[(R+64>>>9<<4)+15]=v,w.sigBytes=I.length*4,this._process(),this._hash},clone:function(){var w=d.clone.call(this);return w._hash=this._hash.clone(),w}});n.SHA256=d._createHelper(b),n.HmacSHA256=d._createHmacHelper(b)}(Math),r.SHA256})})(ar);var we={},cr={get exports(){return we},set exports(e){we=e}};(function(e,t){(function(r,s){e.exports=s(ne)})(ee,function(r){return function(){var s=r,n=s.lib,o=n.WordArray,a=s.enc;a.Base64={stringify:function(l){var h=l.words,p=l.sigBytes,_=this._map;l.clamp();for(var b=[],w=0;w<p;w+=3)for(var I=h[w>>>2]>>>24-w%4*8&255,v=h[w+1>>>2]>>>24-(w+1)%4*8&255,R=h[w+2>>>2]>>>24-(w+2)%4*8&255,k=I<<16|v<<8|R,c=0;c<4&&w+c*.75<p;c++)b.push(_.charAt(k>>>6*(3-c)&63));var g=_.charAt(64);if(g)for(;b.length%4;)b.push(g);return b.join("")},parse:function(l){var h=l.length,p=this._map,_=this._reverseMap;if(!_){_=this._reverseMap=[];for(var b=0;b<p.length;b++)_[p.charCodeAt(b)]=b}var w=p.charAt(64);if(w){var I=l.indexOf(w);I!==-1&&(h=I)}return d(l,h,_)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function d(l,h,p){for(var _=[],b=0,w=0;w<h;w++)if(w%4){var I=p[l.charCodeAt(w-1)]<<w%4*2,v=p[l.charCodeAt(w)]>>>6-w%4*2,R=I|v;_[b>>>2]|=R<<24-b%4*8,b++}return o.create(_,b)}}(),r.enc.Base64})})(cr);var Oe={},lr={get exports(){return Oe},set exports(e){Oe=e}};(function(e,t){(function(r,s){e.exports=s(ne)})(ee,function(r){return r.enc.Utf8})})(lr);function Ue(e){this.message=e}Ue.prototype=new Error,Ue.prototype.name="InvalidCharacterError";var ct=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Ue("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,s,n=0,o=0,a="";s=t.charAt(o++);~s&&(r=n%4?64*r+s:s,n++%4)?a+=String.fromCharCode(255&r>>(-2*n&6)):0)s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);return a};function ur(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(r){return decodeURIComponent(ct(r).replace(/(.)/g,function(s,n){var o=n.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o="0"+o),"%"+o}))}(t)}catch{return ct(t)}}function me(e){this.message=e}function dr(e,t){if(typeof e!="string")throw new me("Invalid token specified");var r=(t=t||{}).header===!0?0:1;try{return JSON.parse(ur(e.split(".")[r]))}catch(s){throw new me("Invalid token specified: "+s.message)}}me.prototype=new Error,me.prototype.name="InvalidTokenError";var hr={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},J,K;exports.Log=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(exports.Log||{});(e=>{function t(){J=3,K=hr}e.reset=t;function r(n){if(!(0<=n&&n<=4))throw new Error("Invalid log level");J=n}e.setLevel=r;function s(n){K=n}e.setLogger=s})(exports.Log||(exports.Log={}));var y=class{constructor(e){this._name=e}debug(...e){J>=4&&K.debug(y._format(this._name,this._method),...e)}info(...e){J>=3&&K.info(y._format(this._name,this._method),...e)}warn(...e){J>=2&&K.warn(y._format(this._name,this._method),...e)}error(...e){J>=1&&K.error(y._format(this._name,this._method),...e)}throw(e){throw this.error(e),e}create(e){const t=Object.create(this);return t._method=e,t.debug("begin"),t}static createStatic(e,t){const r=new y(`${e}.${t}`);return r.debug("begin"),r}static _format(e,t){const r=`[${e}]`;return t?`${r} ${t}:`:r}static debug(e,...t){J>=4&&K.debug(y._format(e),...t)}static info(e,...t){J>=3&&K.info(y._format(e),...t)}static warn(e,...t){J>=2&&K.warn(y._format(e),...t)}static error(e,...t){J>=1&&K.error(y._format(e),...t)}};exports.Log.reset();var gr="10000000-1000-4000-8000-100000000000",V=class{static _randomWord(){return ne.lib.WordArray.random(1).words[0]}static generateUUIDv4(){return gr.replace(/[018]/g,t=>(+t^V._randomWord()&15>>+t/4).toString(16)).replace(/-/g,"")}static generateCodeVerifier(){return V.generateUUIDv4()+V.generateUUIDv4()+V.generateUUIDv4()}static generateCodeChallenge(e){try{const t=Pe(e);return we.stringify(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(t){throw y.error("CryptoUtils.generateCodeChallenge",t),t}}static generateBasicAuth(e,t){const r=Oe.parse([e,t].join(":"));return we.stringify(r)}},X=class{constructor(e){this._name=e,this._logger=new y(`Event('${this._name}')`),this._callbacks=[]}addHandler(e){return this._callbacks.push(e),()=>this.removeHandler(e)}removeHandler(e){const t=this._callbacks.lastIndexOf(e);t>=0&&this._callbacks.splice(t,1)}raise(...e){this._logger.debug("raise:",...e);for(const t of this._callbacks)t(...e)}},Ae=class{static decode(e){try{return dr(e)}catch(t){throw y.error("JwtUtils.decode",t),t}}},lt=class{static center({...e}){var t,r,s;return e.width==null&&(e.width=(t=[800,720,600,480].find(n=>n<=window.outerWidth/1.618))!=null?t:360),(r=e.left)!=null||(e.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-e.width)/2))),e.height!=null&&((s=e.top)!=null||(e.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-e.height)/2)))),e}static serialize(e){return Object.entries(e).filter(([,t])=>t!=null).map(([t,r])=>`${t}=${typeof r!="boolean"?r:r?"yes":"no"}`).join(",")}},H=class extends X{constructor(){super(...arguments),this._logger=new y(`Timer('${this._name}')`),this._timerHandle=null,this._expiration=0,this._callback=()=>{const e=this._expiration-H.getEpochTime();this._logger.debug("timer completes in",e),this._expiration<=H.getEpochTime()&&(this.cancel(),super.raise())}}static getEpochTime(){return Math.floor(Date.now()/1e3)}init(e){const t=this._logger.create("init");e=Math.max(Math.floor(e),1);const r=H.getEpochTime()+e;if(this.expiration===r&&this._timerHandle){t.debug("skipping since already initialized for expiration at",this.expiration);return}this.cancel(),t.debug("using duration",e),this._expiration=r;const s=Math.min(e,5);this._timerHandle=setInterval(this._callback,s*1e3)}get expiration(){return this._expiration}cancel(){this._logger.create("cancel"),this._timerHandle&&(clearInterval(this._timerHandle),this._timerHandle=null)}},je=class{static readParams(e,t="query"){if(!e)throw new TypeError("Invalid URL");const s=new URL(e,window.location.origin)[t==="fragment"?"hash":"search"];return new URLSearchParams(s.slice(1))}},Q=class extends Error{constructor(e,t){var r,s,n;if(super(e.error_description||e.error||""),this.form=t,this.name="ErrorResponse",!e.error)throw y.error("ErrorResponse","No error passed"),new Error("No error passed");this.error=e.error,this.error_description=(r=e.error_description)!=null?r:null,this.error_uri=(s=e.error_uri)!=null?s:null,this.state=e.userState,this.session_state=(n=e.session_state)!=null?n:null}},Se=class extends Error{constructor(e){super(e),this.name="ErrorTimeout"}},ht=class{constructor(e){this._logger=new y("AccessTokenEvents"),this._expiringTimer=new H("Access token expiring"),this._expiredTimer=new H("Access token expired"),this._expiringNotificationTimeInSeconds=e.expiringNotificationTimeInSeconds}load(e){const t=this._logger.create("load");if(e.access_token&&e.expires_in!==void 0){const r=e.expires_in;if(t.debug("access token present, remaining duration:",r),r>0){let n=r-this._expiringNotificationTimeInSeconds;n<=0&&(n=1),t.debug("registering expiring timer, raising in",n,"seconds"),this._expiringTimer.init(n)}else t.debug("canceling existing expiring timer because we're past expiration."),this._expiringTimer.cancel();const s=r+1;t.debug("registering expired timer, raising in",s,"seconds"),this._expiredTimer.init(s)}else this._expiringTimer.cancel(),this._expiredTimer.cancel()}unload(){this._logger.debug("unload: canceling existing access token timers"),this._expiringTimer.cancel(),this._expiredTimer.cancel()}addAccessTokenExpiring(e){return this._expiringTimer.addHandler(e)}removeAccessTokenExpiring(e){this._expiringTimer.removeHandler(e)}addAccessTokenExpired(e){return this._expiredTimer.addHandler(e)}removeAccessTokenExpired(e){this._expiredTimer.removeHandler(e)}},gt=class{constructor(e,t,r,s,n){this._callback=e,this._client_id=t,this._intervalInSeconds=s,this._stopOnError=n,this._logger=new y("CheckSessionIFrame"),this._timer=null,this._session_state=null,this._message=a=>{a.origin===this._frame_origin&&a.source===this._frame.contentWindow&&(a.data==="error"?(this._logger.error("error message from check session op iframe"),this._stopOnError&&this.stop()):a.data==="changed"?(this._logger.debug("changed message from check session op iframe"),this.stop(),this._callback()):this._logger.debug(a.data+" message from check session op iframe"))};const o=new URL(r);this._frame_origin=o.origin,this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="fixed",this._frame.style.left="-1000px",this._frame.style.top="0",this._frame.width="0",this._frame.height="0",this._frame.src=o.href}load(){return new Promise(e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),window.addEventListener("message",this._message,!1)})}start(e){if(this._session_state===e)return;this._logger.create("start"),this.stop(),this._session_state=e;const t=()=>{!this._frame.contentWindow||!this._session_state||this._frame.contentWindow.postMessage(this._client_id+" "+this._session_state,this._frame_origin)};t(),this._timer=setInterval(t,this._intervalInSeconds*1e3)}stop(){this._logger.create("stop"),this._session_state=null,this._timer&&(clearInterval(this._timer),this._timer=null)}},qe=class{constructor(){this._logger=new y("InMemoryWebStorage"),this._data={}}clear(){this._logger.create("clear"),this._data={}}getItem(e){return this._logger.create(`getItem('${e}')`),this._data[e]}setItem(e,t){this._logger.create(`setItem('${e}')`),this._data[e]=t}removeItem(e){this._logger.create(`removeItem('${e}')`),delete this._data[e]}get length(){return Object.getOwnPropertyNames(this._data).length}key(e){return Object.getOwnPropertyNames(this._data)[e]}},Me=class{constructor(e=[],t=null){this._jwtHandler=t,this._logger=new y("JsonService"),this._contentTypes=[],this._contentTypes.push(...e,"application/json"),t&&this._contentTypes.push("application/jwt")}async fetchWithTimeout(e,t={}){const{timeoutInSeconds:r,...s}=t;if(!r)return await fetch(e,s);const n=new AbortController,o=setTimeout(()=>n.abort(),r*1e3);try{return await fetch(e,{...t,signal:n.signal})}catch(a){throw a instanceof DOMException&&a.name==="AbortError"?new Se("Network timed out"):a}finally{clearTimeout(o)}}async getJson(e,{token:t,credentials:r}={}){const s=this._logger.create("getJson"),n={Accept:this._contentTypes.join(", ")};t&&(s.debug("token passed, setting Authorization header"),n.Authorization="Bearer "+t);let o;try{s.debug("url:",e),o=await this.fetchWithTimeout(e,{method:"GET",headers:n,credentials:r})}catch(l){throw s.error("Network Error"),l}s.debug("HTTP response received, status",o.status);const a=o.headers.get("Content-Type");if(a&&!this._contentTypes.find(l=>a.startsWith(l))&&s.throw(new Error(`Invalid response Content-Type: ${a??"undefined"}, from URL: ${e}`)),o.ok&&this._jwtHandler&&(a!=null&&a.startsWith("application/jwt")))return await this._jwtHandler(await o.text());let d;try{d=await o.json()}catch(l){throw s.error("Error parsing JSON response",l),o.ok?l:new Error(`${o.statusText} (${o.status})`)}if(!o.ok)throw s.error("Error from server:",d),d.error?new Q(d):new Error(`${o.statusText} (${o.status}): ${JSON.stringify(d)}`);return d}async postForm(e,{body:t,basicAuth:r,timeoutInSeconds:s,initCredentials:n}){const o=this._logger.create("postForm"),a={Accept:this._contentTypes.join(", "),"Content-Type":"application/x-www-form-urlencoded"};r!==void 0&&(a.Authorization="Basic "+r);let d;try{o.debug("url:",e),d=await this.fetchWithTimeout(e,{method:"POST",headers:a,body:t,timeoutInSeconds:s,credentials:n})}catch(_){throw o.error("Network error"),_}o.debug("HTTP response received, status",d.status);const l=d.headers.get("Content-Type");if(l&&!this._contentTypes.find(_=>l.startsWith(_)))throw new Error(`Invalid response Content-Type: ${l??"undefined"}, from URL: ${e}`);const h=await d.text();let p={};if(h)try{p=JSON.parse(h)}catch(_){throw o.error("Error parsing JSON response",_),d.ok?_:new Error(`${d.statusText} (${d.status})`)}if(!d.ok)throw o.error("Error from server:",p),p.error?new Q(p,t):new Error(`${d.statusText} (${d.status}): ${JSON.stringify(p)}`);return p}},ft=class{constructor(e){this._settings=e,this._logger=new y("MetadataService"),this._jsonService=new Me(["application/jwk-set+json"]),this._signingKeys=null,this._metadata=null,this._metadataUrl=this._settings.metadataUrl,this._settings.signingKeys&&(this._logger.debug("using signingKeys from settings"),this._signingKeys=this._settings.signingKeys),this._settings.metadata&&(this._logger.debug("using metadata from settings"),this._metadata=this._settings.metadata),this._settings.fetchRequestCredentials&&(this._logger.debug("using fetchRequestCredentials from settings"),this._fetchRequestCredentials=this._settings.fetchRequestCredentials)}resetSigningKeys(){this._signingKeys=null}async getMetadata(){const e=this._logger.create("getMetadata");if(this._metadata)return e.debug("using cached values"),this._metadata;if(!this._metadataUrl)throw e.throw(new Error("No authority or metadataUrl configured on settings")),null;e.debug("getting metadata from",this._metadataUrl);const t=await this._jsonService.getJson(this._metadataUrl,{credentials:this._fetchRequestCredentials});return e.debug("merging remote JSON with seed metadata"),this._metadata=Object.assign({},this._settings.metadataSeed,t),this._metadata}getIssuer(){return this._getMetadataProperty("issuer")}getAuthorizationEndpoint(){return this._getMetadataProperty("authorization_endpoint")}getUserInfoEndpoint(){return this._getMetadataProperty("userinfo_endpoint")}getTokenEndpoint(e=!0){return this._getMetadataProperty("token_endpoint",e)}getCheckSessionIframe(){return this._getMetadataProperty("check_session_iframe",!0)}getEndSessionEndpoint(){return this._getMetadataProperty("end_session_endpoint",!0)}getRevocationEndpoint(e=!0){return this._getMetadataProperty("revocation_endpoint",e)}getKeysEndpoint(e=!0){return this._getMetadataProperty("jwks_uri",e)}async _getMetadataProperty(e,t=!1){const r=this._logger.create(`_getMetadataProperty('${e}')`),s=await this.getMetadata();if(r.debug("resolved"),s[e]===void 0){if(t===!0){r.warn("Metadata does not contain optional property");return}r.throw(new Error("Metadata does not contain property "+e))}return s[e]}async getSigningKeys(){const e=this._logger.create("getSigningKeys");if(this._signingKeys)return e.debug("returning signingKeys from cache"),this._signingKeys;const t=await this.getKeysEndpoint(!1);e.debug("got jwks_uri",t);const r=await this._jsonService.getJson(t);if(e.debug("got key set",r),!Array.isArray(r.keys))throw e.throw(new Error("Missing keys on keyset")),null;return this._signingKeys=r.keys,this._signingKeys}},We=class{constructor({prefix:e="oidc.",store:t=localStorage}={}){this._logger=new y("WebStorageStateStore"),this._store=t,this._prefix=e}async set(e,t){this._logger.create(`set('${e}')`),e=this._prefix+e,await this._store.setItem(e,t)}async get(e){return this._logger.create(`get('${e}')`),e=this._prefix+e,await this._store.getItem(e)}async remove(e){this._logger.create(`remove('${e}')`),e=this._prefix+e;const t=await this._store.getItem(e);return await this._store.removeItem(e),t}async getAllKeys(){this._logger.create("getAllKeys");const e=await this._store.length,t=[];for(let r=0;r<e;r++){const s=await this._store.key(r);s&&s.indexOf(this._prefix)===0&&t.push(s.substr(this._prefix.length))}return t}},fr="code",_r="openid",pr="client_secret_post",vr="query",wr=60*15,mr=60*5,Fe=class{constructor({authority:e,metadataUrl:t,metadata:r,signingKeys:s,metadataSeed:n,client_id:o,client_secret:a,response_type:d=fr,scope:l=_r,redirect_uri:h,post_logout_redirect_uri:p,client_authentication:_=pr,prompt:b,display:w,max_age:I,ui_locales:v,acr_values:R,resource:k,response_mode:c=vr,filterProtocolClaims:g=!0,loadUserInfo:m=!1,staleStateAgeInSeconds:E=wr,clockSkewInSeconds:P=mr,userInfoJwtIssuer:O="OP",mergeClaims:A=!1,disablePKCE:j=!1,stateStore:B,refreshTokenCredentials:D,revokeTokenAdditionalContentTypes:z,fetchRequestCredentials:W,refreshTokenAllowedScope:$,extraQueryParams:Y={},extraTokenParams:re={}}){if(this.authority=e,t?this.metadataUrl=t:(this.metadataUrl=e,e&&(this.metadataUrl.endsWith("/")||(this.metadataUrl+="/"),this.metadataUrl+=".well-known/openid-configuration")),this.metadata=r,this.metadataSeed=n,this.signingKeys=s,this.client_id=o,this.client_secret=a,this.response_type=d,this.scope=l,this.redirect_uri=h,this.post_logout_redirect_uri=p,this.client_authentication=_,this.prompt=b,this.display=w,this.max_age=I,this.ui_locales=v,this.acr_values=R,this.resource=k,this.response_mode=c,this.filterProtocolClaims=g??!0,this.loadUserInfo=!!m,this.staleStateAgeInSeconds=E,this.clockSkewInSeconds=P,this.userInfoJwtIssuer=O,this.mergeClaims=!!A,this.disablePKCE=!!j,this.revokeTokenAdditionalContentTypes=z,W&&D&&console.warn("Both fetchRequestCredentials and refreshTokenCredentials is set. Only fetchRequestCredentials will be used."),this.fetchRequestCredentials=W||D||"same-origin",B)this.stateStore=B;else{const Z=typeof window<"u"?window.localStorage:new qe;this.stateStore=new We({store:Z})}this.refreshTokenAllowedScope=$,this.extraQueryParams=Y,this.extraTokenParams=re}},Sr=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new y("UserInfoService"),this._getClaimsFromJwt=async r=>{const s=this._logger.create("_getClaimsFromJwt");try{const n=Ae.decode(r);return s.debug("JWT decoding successful"),n}catch(n){throw s.error("Error parsing JWT response"),n}},this._jsonService=new Me(void 0,this._getClaimsFromJwt)}async getClaims(e){const t=this._logger.create("getClaims");e||this._logger.throw(new Error("No token passed"));const r=await this._metadataService.getUserInfoEndpoint();t.debug("got userinfo url",r);const s=await this._jsonService.getJson(r,{token:e,credentials:this._settings.fetchRequestCredentials});return t.debug("got claims",s),s}},_t=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new y("TokenClient"),this._jsonService=new Me(this._settings.revokeTokenAdditionalContentTypes)}async exchangeCode({grant_type:e="authorization_code",redirect_uri:t=this._settings.redirect_uri,client_id:r=this._settings.client_id,client_secret:s=this._settings.client_secret,...n}){const o=this._logger.create("exchangeCode");r||o.throw(new Error("A client_id is required")),t||o.throw(new Error("A redirect_uri is required")),n.code||o.throw(new Error("A code is required"));const a=new URLSearchParams({grant_type:e,redirect_uri:t});for(const[p,_]of Object.entries(n))_!=null&&a.set(p,_);let d;switch(this._settings.client_authentication){case"client_secret_basic":if(!s)throw o.throw(new Error("A client_secret is required")),null;d=V.generateBasicAuth(r,s);break;case"client_secret_post":a.append("client_id",r),s&&a.append("client_secret",s);break}const l=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const h=await this._jsonService.postForm(l,{body:a,basicAuth:d,initCredentials:this._settings.fetchRequestCredentials});return o.debug("got response"),h}async exchangeCredentials({grant_type:e="password",client_id:t=this._settings.client_id,client_secret:r=this._settings.client_secret,scope:s=this._settings.scope,...n}){const o=this._logger.create("exchangeCredentials");t||o.throw(new Error("A client_id is required"));const a=new URLSearchParams({grant_type:e,scope:s});for(const[p,_]of Object.entries(n))_!=null&&a.set(p,_);let d;switch(this._settings.client_authentication){case"client_secret_basic":if(!r)throw o.throw(new Error("A client_secret is required")),null;d=V.generateBasicAuth(t,r);break;case"client_secret_post":a.append("client_id",t),r&&a.append("client_secret",r);break}const l=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const h=await this._jsonService.postForm(l,{body:a,basicAuth:d,initCredentials:this._settings.fetchRequestCredentials});return o.debug("got response"),h}async exchangeRefreshToken({grant_type:e="refresh_token",client_id:t=this._settings.client_id,client_secret:r=this._settings.client_secret,timeoutInSeconds:s,...n}){const o=this._logger.create("exchangeRefreshToken");t||o.throw(new Error("A client_id is required")),n.refresh_token||o.throw(new Error("A refresh_token is required"));const a=new URLSearchParams({grant_type:e});for(const[p,_]of Object.entries(n))_!=null&&a.set(p,_);let d;switch(this._settings.client_authentication){case"client_secret_basic":if(!r)throw o.throw(new Error("A client_secret is required")),null;d=V.generateBasicAuth(t,r);break;case"client_secret_post":a.append("client_id",t),r&&a.append("client_secret",r);break}const l=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const h=await this._jsonService.postForm(l,{body:a,basicAuth:d,timeoutInSeconds:s,initCredentials:this._settings.fetchRequestCredentials});return o.debug("got response"),h}async revoke(e){var t;const r=this._logger.create("revoke");e.token||r.throw(new Error("A token is required"));const s=await this._metadataService.getRevocationEndpoint(!1);r.debug(`got revocation endpoint, revoking ${(t=e.token_type_hint)!=null?t:"default token type"}`);const n=new URLSearchParams;for(const[o,a]of Object.entries(e))a!=null&&n.set(o,a);n.set("client_id",this._settings.client_id),this._settings.client_secret&&n.set("client_secret",this._settings.client_secret),await this._jsonService.postForm(s,{body:n}),r.debug("got response")}},yr=["nbf","jti","auth_time","nonce","acr","amr","azp","at_hash"],br=["sub","iss","aud","exp","iat"],kr=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new y("ResponseValidator"),this._userInfoService=new Sr(this._settings,this._metadataService),this._tokenClient=new _t(this._settings,this._metadataService)}async validateSigninResponse(e,t){const r=this._logger.create("validateSigninResponse");this._processSigninState(e,t),r.debug("state processed"),await this._processCode(e,t),r.debug("code processed"),e.isOpenId&&this._validateIdTokenAttributes(e),r.debug("tokens validated"),await this._processClaims(e,t==null?void 0:t.skipUserInfo,e.isOpenId),r.debug("claims processed")}async validateCredentialsResponse(e,t){const r=this._logger.create("validateCredentialsResponse");e.isOpenId&&this._validateIdTokenAttributes(e),r.debug("tokens validated"),await this._processClaims(e,t,e.isOpenId),r.debug("claims processed")}async validateRefreshResponse(e,t){var r,s;const n=this._logger.create("validateRefreshResponse");e.userState=t.data,(r=e.session_state)!=null||(e.session_state=t.session_state),(s=e.scope)!=null||(e.scope=t.scope),e.isOpenId&&e.id_token&&(this._validateIdTokenAttributes(e,t.id_token),n.debug("ID Token validated")),e.id_token||(e.id_token=t.id_token,e.profile=t.profile);const o=e.isOpenId&&!!e.id_token;await this._processClaims(e,!1,o),n.debug("claims processed")}validateSignoutResponse(e,t){const r=this._logger.create("validateSignoutResponse");if(t.id!==e.state&&r.throw(new Error("State does not match")),r.debug("state validated"),e.userState=t.data,e.error)throw r.warn("Response was error",e.error),new Q(e)}_processSigninState(e,t){var r;const s=this._logger.create("_processSigninState");if(t.id!==e.state&&s.throw(new Error("State does not match")),t.client_id||s.throw(new Error("No client_id on state")),t.authority||s.throw(new Error("No authority on state")),this._settings.authority!==t.authority&&s.throw(new Error("authority mismatch on settings vs. signin state")),this._settings.client_id&&this._settings.client_id!==t.client_id&&s.throw(new Error("client_id mismatch on settings vs. signin state")),s.debug("state validated"),e.userState=t.data,(r=e.scope)!=null||(e.scope=t.scope),e.error)throw s.warn("Response was error",e.error),new Q(e);t.code_verifier&&!e.code&&s.throw(new Error("Expected code in response"))}async _processClaims(e,t=!1,r=!0){const s=this._logger.create("_processClaims");if(e.profile=this._filterProtocolClaims(e.profile),t||!this._settings.loadUserInfo||!e.access_token){s.debug("not loading user info");return}s.debug("loading user info");const n=await this._userInfoService.getClaims(e.access_token);s.debug("user info claims received from user info endpoint"),r&&n.sub!==e.profile.sub&&s.throw(new Error("subject from UserInfo response does not match subject in ID Token")),e.profile=this._mergeClaims(e.profile,this._filterProtocolClaims(n)),s.debug("user info claims received, updated profile:",e.profile)}_mergeClaims(e,t){const r={...e};for(const[s,n]of Object.entries(t))for(const o of Array.isArray(n)?n:[n]){const a=r[s];a?Array.isArray(a)?a.includes(o)||a.push(o):r[s]!==o&&(typeof o=="object"&&this._settings.mergeClaims?r[s]=this._mergeClaims(a,o):r[s]=[a,o]):r[s]=o}return r}_filterProtocolClaims(e){const t={...e};if(this._settings.filterProtocolClaims){let r;Array.isArray(this._settings.filterProtocolClaims)?r=this._settings.filterProtocolClaims:r=yr;for(const s of r)br.includes(s)||delete t[s]}return t}async _processCode(e,t){const r=this._logger.create("_processCode");if(e.code){r.debug("Validating code");const s=await this._tokenClient.exchangeCode({client_id:t.client_id,client_secret:t.client_secret,code:e.code,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier,...t.extraTokenParams});Object.assign(e,s)}else r.debug("No code to process")}_validateIdTokenAttributes(e,t){var r;const s=this._logger.create("_validateIdTokenAttributes");s.debug("decoding ID Token JWT");const n=Ae.decode((r=e.id_token)!=null?r:"");if(n.sub||s.throw(new Error("ID Token is missing a subject claim")),t){const o=Ae.decode(t);o.sub!==n.sub&&s.throw(new Error("sub in id_token does not match current sub")),o.auth_time&&o.auth_time!==n.auth_time&&s.throw(new Error("auth_time in id_token does not match original auth_time")),o.azp&&o.azp!==n.azp&&s.throw(new Error("azp in id_token does not match original azp")),!o.azp&&n.azp&&s.throw(new Error("azp not in id_token, but present in original id_token"))}e.profile=n}},te=class{constructor(e){this.id=e.id||V.generateUUIDv4(),this.data=e.data,e.created&&e.created>0?this.created=e.created:this.created=H.getEpochTime(),this.request_type=e.request_type}toStorageString(){return new y("State").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type})}static fromStorageString(e){return y.createStatic("State","fromStorageString"),new te(JSON.parse(e))}static async clearStaleState(e,t){const r=y.createStatic("State","clearStaleState"),s=H.getEpochTime()-t,n=await e.getAllKeys();r.debug("got keys",n);for(let o=0;o<n.length;o++){const a=n[o],d=await e.get(a);let l=!1;if(d)try{const h=te.fromStorageString(d);r.debug("got item from key:",a,h.created),h.created<=s&&(l=!0)}catch(h){r.error("Error parsing state for key:",a,h),l=!0}else r.debug("no item in storage for key:",a),l=!0;l&&(r.debug("removed item for key:",a),e.remove(a))}}},ye=class extends te{constructor(e){super(e),e.code_verifier===!0?this.code_verifier=V.generateCodeVerifier():e.code_verifier&&(this.code_verifier=e.code_verifier),this.code_verifier&&(this.code_challenge=V.generateCodeChallenge(this.code_verifier)),this.authority=e.authority,this.client_id=e.client_id,this.redirect_uri=e.redirect_uri,this.scope=e.scope,this.client_secret=e.client_secret,this.extraTokenParams=e.extraTokenParams,this.response_mode=e.response_mode,this.skipUserInfo=e.skipUserInfo}toStorageString(){return new y("SigninState").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,code_verifier:this.code_verifier,authority:this.authority,client_id:this.client_id,redirect_uri:this.redirect_uri,scope:this.scope,client_secret:this.client_secret,extraTokenParams:this.extraTokenParams,response_mode:this.response_mode,skipUserInfo:this.skipUserInfo})}static fromStorageString(e){y.createStatic("SigninState","fromStorageString");const t=JSON.parse(e);return new ye(t)}},Er=class{constructor({url:e,authority:t,client_id:r,redirect_uri:s,response_type:n,scope:o,state_data:a,response_mode:d,request_type:l,client_secret:h,nonce:p,resource:_,skipUserInfo:b,extraQueryParams:w,extraTokenParams:I,disablePKCE:v,...R}){if(this._logger=new y("SigninRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");if(!r)throw this._logger.error("ctor: No client_id passed"),new Error("client_id");if(!s)throw this._logger.error("ctor: No redirect_uri passed"),new Error("redirect_uri");if(!n)throw this._logger.error("ctor: No response_type passed"),new Error("response_type");if(!o)throw this._logger.error("ctor: No scope passed"),new Error("scope");if(!t)throw this._logger.error("ctor: No authority passed"),new Error("authority");this.state=new ye({data:a,request_type:l,code_verifier:!v,client_id:r,authority:t,redirect_uri:s,response_mode:d,client_secret:h,scope:o,extraTokenParams:I,skipUserInfo:b});const k=new URL(e);k.searchParams.append("client_id",r),k.searchParams.append("redirect_uri",s),k.searchParams.append("response_type",n),k.searchParams.append("scope",o),p&&k.searchParams.append("nonce",p),k.searchParams.append("state",this.state.id),this.state.code_challenge&&(k.searchParams.append("code_challenge",this.state.code_challenge),k.searchParams.append("code_challenge_method","S256")),_&&(Array.isArray(_)?_:[_]).forEach(g=>k.searchParams.append("resource",g));for(const[c,g]of Object.entries({response_mode:d,...R,...w}))g!=null&&k.searchParams.append(c,g.toString());this.url=k.href}},Rr="openid",ve=class{constructor(e){this.access_token="",this.token_type="",this.profile={},this.state=e.get("state"),this.session_state=e.get("session_state"),this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri"),this.code=e.get("code")}get expires_in(){if(this.expires_at!==void 0)return this.expires_at-H.getEpochTime()}set expires_in(e){typeof e=="string"&&(e=Number(e)),e!==void 0&&e>=0&&(this.expires_at=Math.floor(e)+H.getEpochTime())}get isOpenId(){var e;return((e=this.scope)==null?void 0:e.split(" ").includes(Rr))||!!this.id_token}},Cr=class{constructor({url:e,state_data:t,id_token_hint:r,post_logout_redirect_uri:s,extraQueryParams:n,request_type:o}){if(this._logger=new y("SignoutRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");const a=new URL(e);r&&a.searchParams.append("id_token_hint",r),s&&(a.searchParams.append("post_logout_redirect_uri",s),t&&(this.state=new te({data:t,request_type:o}),a.searchParams.append("state",this.state.id)));for(const[d,l]of Object.entries({...n}))l!=null&&a.searchParams.append(d,l.toString());this.url=a.href}},pt=class{constructor(e){this.state=e.get("state"),this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri")}},vt=class{constructor(e){this._logger=new y("OidcClient"),this.settings=new Fe(e),this.metadataService=new ft(this.settings),this._validator=new kr(this.settings,this.metadataService),this._tokenClient=new _t(this.settings,this.metadataService)}async createSigninRequest({state:e,request:t,request_uri:r,request_type:s,id_token_hint:n,login_hint:o,skipUserInfo:a,nonce:d,response_type:l=this.settings.response_type,scope:h=this.settings.scope,redirect_uri:p=this.settings.redirect_uri,prompt:_=this.settings.prompt,display:b=this.settings.display,max_age:w=this.settings.max_age,ui_locales:I=this.settings.ui_locales,acr_values:v=this.settings.acr_values,resource:R=this.settings.resource,response_mode:k=this.settings.response_mode,extraQueryParams:c=this.settings.extraQueryParams,extraTokenParams:g=this.settings.extraTokenParams}){const m=this._logger.create("createSigninRequest");if(l!=="code")throw new Error("Only the Authorization Code flow (with PKCE) is supported");const E=await this.metadataService.getAuthorizationEndpoint();m.debug("Received authorization endpoint",E);const P=new Er({url:E,authority:this.settings.authority,client_id:this.settings.client_id,redirect_uri:p,response_type:l,scope:h,state_data:e,prompt:_,display:b,max_age:w,ui_locales:I,id_token_hint:n,login_hint:o,acr_values:v,resource:R,request:t,request_uri:r,extraQueryParams:c,extraTokenParams:g,request_type:s,response_mode:k,client_secret:this.settings.client_secret,skipUserInfo:a,nonce:d,disablePKCE:this.settings.disablePKCE});await this.clearStaleState();const O=P.state;return await this.settings.stateStore.set(O.id,O.toStorageString()),P}async readSigninResponseState(e,t=!1){const r=this._logger.create("readSigninResponseState"),s=new ve(je.readParams(e,this.settings.response_mode));if(!s.state)throw r.throw(new Error("No state in response")),null;const n=await this.settings.stateStore[t?"remove":"get"](s.state);if(!n)throw r.throw(new Error("No matching state found in storage")),null;return{state:ye.fromStorageString(n),response:s}}async processSigninResponse(e){const t=this._logger.create("processSigninResponse"),{state:r,response:s}=await this.readSigninResponseState(e,!0);return t.debug("received state from storage; validating response"),await this._validator.validateSigninResponse(s,r),s}async processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:r=!1,extraTokenParams:s={}}){const n=await this._tokenClient.exchangeCredentials({username:e,password:t,...s}),o=new ve(new URLSearchParams);return Object.assign(o,n),await this._validator.validateCredentialsResponse(o,r),o}async useRefreshToken({state:e,timeoutInSeconds:t}){var r;const s=this._logger.create("useRefreshToken");let n;if(this.settings.refreshTokenAllowedScope===void 0)n=e.scope;else{const d=this.settings.refreshTokenAllowedScope.split(" ");n=(((r=e.scope)==null?void 0:r.split(" "))||[]).filter(h=>d.includes(h)).join(" ")}const o=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:n,timeoutInSeconds:t}),a=new ve(new URLSearchParams);return Object.assign(a,o),s.debug("validating response",a),await this._validator.validateRefreshResponse(a,{...e,scope:n}),a}async createSignoutRequest({state:e,id_token_hint:t,request_type:r,post_logout_redirect_uri:s=this.settings.post_logout_redirect_uri,extraQueryParams:n=this.settings.extraQueryParams}={}){const o=this._logger.create("createSignoutRequest"),a=await this.metadataService.getEndSessionEndpoint();if(!a)throw o.throw(new Error("No end session endpoint")),null;o.debug("Received end session endpoint",a);const d=new Cr({url:a,id_token_hint:t,post_logout_redirect_uri:s,state_data:e,extraQueryParams:n,request_type:r});await this.clearStaleState();const l=d.state;return l&&(o.debug("Signout request has state to persist"),await this.settings.stateStore.set(l.id,l.toStorageString())),d}async readSignoutResponseState(e,t=!1){const r=this._logger.create("readSignoutResponseState"),s=new pt(je.readParams(e,this.settings.response_mode));if(!s.state){if(r.debug("No state in response"),s.error)throw r.warn("Response was error:",s.error),new Q(s);return{state:void 0,response:s}}const n=await this.settings.stateStore[t?"remove":"get"](s.state);if(!n)throw r.throw(new Error("No matching state found in storage")),null;return{state:te.fromStorageString(n),response:s}}async processSignoutResponse(e){const t=this._logger.create("processSignoutResponse"),{state:r,response:s}=await this.readSignoutResponseState(e,!0);return r?(t.debug("Received state from storage; validating response"),this._validator.validateSignoutResponse(s,r)):t.debug("No state from storage; skipping response validation"),s}clearStaleState(){return this._logger.create("clearStaleState"),te.clearStaleState(this.settings.stateStore,this.settings.staleStateAgeInSeconds)}async revokeToken(e,t){return this._logger.create("revokeToken"),await this._tokenClient.revoke({token:e,token_type_hint:t})}},wt=class{constructor(e){this._userManager=e,this._logger=new y("SessionMonitor"),this._start=async t=>{const r=t.session_state;if(!r)return;const s=this._logger.create("_start");if(t.profile?(this._sub=t.profile.sub,this._sid=t.profile.sid,s.debug("session_state",r,", sub",this._sub)):(this._sub=void 0,this._sid=void 0,s.debug("session_state",r,", anonymous user")),this._checkSessionIFrame){this._checkSessionIFrame.start(r);return}try{const n=await this._userManager.metadataService.getCheckSessionIframe();if(n){s.debug("initializing check session iframe");const o=this._userManager.settings.client_id,a=this._userManager.settings.checkSessionIntervalInSeconds,d=this._userManager.settings.stopCheckSessionOnError,l=new gt(this._callback,o,n,a,d);await l.load(),this._checkSessionIFrame=l,l.start(r)}else s.warn("no check session iframe found in the metadata")}catch(n){s.error("Error from getCheckSessionIframe:",n instanceof Error?n.message:n)}},this._stop=()=>{const t=this._logger.create("_stop");if(this._sub=void 0,this._sid=void 0,this._checkSessionIFrame&&this._checkSessionIFrame.stop(),this._userManager.settings.monitorAnonymousSession){const r=setInterval(async()=>{clearInterval(r);try{const s=await this._userManager.querySessionStatus();if(s){const n={session_state:s.session_state,profile:s.sub&&s.sid?{sub:s.sub,sid:s.sid}:null};this._start(n)}}catch(s){t.error("error from querySessionStatus",s instanceof Error?s.message:s)}},1e3)}},this._callback=async()=>{const t=this._logger.create("_callback");try{const r=await this._userManager.querySessionStatus();let s=!0;r&&this._checkSessionIFrame?r.sub===this._sub?(s=!1,this._checkSessionIFrame.start(r.session_state),r.sid===this._sid?t.debug("same sub still logged in at OP, restarting check session iframe; session_state",r.session_state):(t.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state",r.session_state),this._userManager.events._raiseUserSessionChanged())):t.debug("different subject signed into OP",r.sub):t.debug("subject no longer signed into OP"),s?this._sub?this._userManager.events._raiseUserSignedOut():this._userManager.events._raiseUserSignedIn():t.debug("no change in session detected, no event to raise")}catch(r){this._sub&&(t.debug("Error calling queryCurrentSigninSession; raising signed out event",r),this._userManager.events._raiseUserSignedOut())}},e||this._logger.throw(new Error("No user manager passed")),this._userManager.events.addUserLoaded(this._start),this._userManager.events.addUserUnloaded(this._stop),this._init().catch(t=>{this._logger.error(t)})}async _init(){this._logger.create("_init");const e=await this._userManager.getUser();if(e)this._start(e);else if(this._userManager.settings.monitorAnonymousSession){const t=await this._userManager.querySessionStatus();if(t){const r={session_state:t.session_state,profile:t.sub&&t.sid?{sub:t.sub,sid:t.sid}:null};this._start(r)}}}},le=class{constructor(e){var t;this.id_token=e.id_token,this.session_state=(t=e.session_state)!=null?t:null,this.access_token=e.access_token,this.refresh_token=e.refresh_token,this.token_type=e.token_type,this.scope=e.scope,this.profile=e.profile,this.expires_at=e.expires_at,this.state=e.userState}get expires_in(){if(this.expires_at!==void 0)return this.expires_at-H.getEpochTime()}set expires_in(e){e!==void 0&&(this.expires_at=Math.floor(e)+H.getEpochTime())}get expired(){const e=this.expires_in;if(e!==void 0)return e<=0}get scopes(){var e,t;return(t=(e=this.scope)==null?void 0:e.split(" "))!=null?t:[]}toStorageString(){return new y("User").create("toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})}static fromStorageString(e){return y.createStatic("User","fromStorageString"),new le(JSON.parse(e))}},ut="oidc-client",mt=class{constructor(){this._abort=new X("Window navigation aborted"),this._disposeHandlers=new Set,this._window=null}async navigate(e){const t=this._logger.create("navigate");if(!this._window)throw new Error("Attempted to navigate on a disposed window");t.debug("setting URL in window"),this._window.location.replace(e.url);const{url:r,keepOpen:s}=await new Promise((n,o)=>{const a=d=>{var l;const h=d.data,p=(l=e.scriptOrigin)!=null?l:window.location.origin;if(!(d.origin!==p||(h==null?void 0:h.source)!==ut)){try{const _=je.readParams(h.url,e.response_mode).get("state");if(_||t.warn("no state found in response url"),d.source!==this._window&&_!==e.state)return}catch{this._dispose(),o(new Error("Invalid response from window"))}n(h)}};window.addEventListener("message",a,!1),this._disposeHandlers.add(()=>window.removeEventListener("message",a,!1)),this._disposeHandlers.add(this._abort.addHandler(d=>{this._dispose(),o(d)}))});return t.debug("got response from window"),this._dispose(),s||this.close(),{url:r}}_dispose(){this._logger.create("_dispose");for(const e of this._disposeHandlers)e();this._disposeHandlers.clear()}static _notifyParent(e,t,r=!1,s=window.location.origin){e.postMessage({source:ut,url:t,keepOpen:r},s)}},St={location:!1,toolbar:!1,height:640},yt="_blank",Tr=60,xr=2,bt=10,kt=class extends Fe{constructor(e){const{popup_redirect_uri:t=e.redirect_uri,popup_post_logout_redirect_uri:r=e.post_logout_redirect_uri,popupWindowFeatures:s=St,popupWindowTarget:n=yt,redirectMethod:o="assign",redirectTarget:a="self",iframeNotifyParentOrigin:d=e.iframeNotifyParentOrigin,iframeScriptOrigin:l=e.iframeScriptOrigin,silent_redirect_uri:h=e.redirect_uri,silentRequestTimeoutInSeconds:p=bt,automaticSilentRenew:_=!0,validateSubOnSilentRenew:b=!0,includeIdTokenInSilentRenew:w=!1,monitorSession:I=!1,monitorAnonymousSession:v=!1,checkSessionIntervalInSeconds:R=xr,query_status_response_type:k="code",stopCheckSessionOnError:c=!0,revokeTokenTypes:g=["access_token","refresh_token"],revokeTokensOnSignout:m=!1,includeIdTokenInSilentSignout:E=!1,accessTokenExpiringNotificationTimeInSeconds:P=Tr,userStore:O}=e;if(super(e),this.popup_redirect_uri=t,this.popup_post_logout_redirect_uri=r,this.popupWindowFeatures=s,this.popupWindowTarget=n,this.redirectMethod=o,this.redirectTarget=a,this.iframeNotifyParentOrigin=d,this.iframeScriptOrigin=l,this.silent_redirect_uri=h,this.silentRequestTimeoutInSeconds=p,this.automaticSilentRenew=_,this.validateSubOnSilentRenew=b,this.includeIdTokenInSilentRenew=w,this.monitorSession=I,this.monitorAnonymousSession=v,this.checkSessionIntervalInSeconds=R,this.stopCheckSessionOnError=c,this.query_status_response_type=k,this.revokeTokenTypes=g,this.revokeTokensOnSignout=m,this.includeIdTokenInSilentSignout=E,this.accessTokenExpiringNotificationTimeInSeconds=P,O)this.userStore=O;else{const A=typeof window<"u"?window.sessionStorage:new qe;this.userStore=new We({store:A})}}},Ne=class extends mt{constructor({silentRequestTimeoutInSeconds:e=bt}){super(),this._logger=new y("IFrameWindow"),this._timeoutInSeconds=e,this._frame=Ne.createHiddenIframe(),this._window=this._frame.contentWindow}static createHiddenIframe(){const e=window.document.createElement("iframe");return e.style.visibility="hidden",e.style.position="fixed",e.style.left="-1000px",e.style.top="0",e.width="0",e.height="0",e.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),window.document.body.appendChild(e),e}async navigate(e){this._logger.debug("navigate: Using timeout of:",this._timeoutInSeconds);const t=setTimeout(()=>this._abort.raise(new Se("IFrame timed out without a response")),this._timeoutInSeconds*1e3);return this._disposeHandlers.add(()=>clearTimeout(t)),await super.navigate(e)}close(){var e;this._frame&&(this._frame.parentNode&&(this._frame.addEventListener("load",t=>{var r;const s=t.target;(r=s.parentNode)==null||r.removeChild(s),this._abort.raise(new Error("IFrame removed from DOM"))},!0),(e=this._frame.contentWindow)==null||e.location.replace("about:blank")),this._frame=null),this._window=null}static notifyParent(e,t){return super._notifyParent(window.parent,e,!1,t)}},Ir=class{constructor(e){this._settings=e,this._logger=new y("IFrameNavigator")}async prepare({silentRequestTimeoutInSeconds:e=this._settings.silentRequestTimeoutInSeconds}){return new Ne({silentRequestTimeoutInSeconds:e})}async callback(e){this._logger.create("callback"),Ne.notifyParent(e,this._settings.iframeNotifyParentOrigin)}},Pr=500,dt=class extends mt{constructor({popupWindowTarget:e=yt,popupWindowFeatures:t={}}){super(),this._logger=new y("PopupWindow");const r=lt.center({...St,...t});this._window=window.open(void 0,e,lt.serialize(r))}async navigate(e){var t;(t=this._window)==null||t.focus();const r=setInterval(()=>{(!this._window||this._window.closed)&&this._abort.raise(new Error("Popup closed by user"))},Pr);return this._disposeHandlers.add(()=>clearInterval(r)),await super.navigate(e)}close(){this._window&&(this._window.closed||(this._window.close(),this._abort.raise(new Error("Popup closed")))),this._window=null}static notifyOpener(e,t){if(!window.opener)throw new Error("No window.opener. Can't complete notification.");return super._notifyParent(window.opener,e,t)}},Or=class{constructor(e){this._settings=e,this._logger=new y("PopupNavigator")}async prepare({popupWindowFeatures:e=this._settings.popupWindowFeatures,popupWindowTarget:t=this._settings.popupWindowTarget}){return new dt({popupWindowFeatures:e,popupWindowTarget:t})}async callback(e,t=!1){this._logger.create("callback"),dt.notifyOpener(e,t)}},Ur=class{constructor(e){this._settings=e,this._logger=new y("RedirectNavigator")}async prepare({redirectMethod:e=this._settings.redirectMethod,redirectTarget:t=this._settings.redirectTarget}){var r;this._logger.create("prepare");let s=window.self;t==="top"&&(s=(r=window.top)!=null?r:window.self);const n=s.location[e].bind(s.location);let o;return{navigate:async a=>{this._logger.create("navigate");const d=new Promise((l,h)=>{o=h});return n(a.url),await d},close:()=>{this._logger.create("close"),o==null||o(new Error("Redirect aborted")),s.stop()}}}},Ar=class extends ht{constructor(e){super({expiringNotificationTimeInSeconds:e.accessTokenExpiringNotificationTimeInSeconds}),this._logger=new y("UserManagerEvents"),this._userLoaded=new X("User loaded"),this._userUnloaded=new X("User unloaded"),this._silentRenewError=new X("Silent renew error"),this._userSignedIn=new X("User signed in"),this._userSignedOut=new X("User signed out"),this._userSessionChanged=new X("User session changed")}load(e,t=!0){super.load(e),t&&this._userLoaded.raise(e)}unload(){super.unload(),this._userUnloaded.raise()}addUserLoaded(e){return this._userLoaded.addHandler(e)}removeUserLoaded(e){return this._userLoaded.removeHandler(e)}addUserUnloaded(e){return this._userUnloaded.addHandler(e)}removeUserUnloaded(e){return this._userUnloaded.removeHandler(e)}addSilentRenewError(e){return this._silentRenewError.addHandler(e)}removeSilentRenewError(e){return this._silentRenewError.removeHandler(e)}_raiseSilentRenewError(e){this._silentRenewError.raise(e)}addUserSignedIn(e){return this._userSignedIn.addHandler(e)}removeUserSignedIn(e){this._userSignedIn.removeHandler(e)}_raiseUserSignedIn(){this._userSignedIn.raise()}addUserSignedOut(e){return this._userSignedOut.addHandler(e)}removeUserSignedOut(e){this._userSignedOut.removeHandler(e)}_raiseUserSignedOut(){this._userSignedOut.raise()}addUserSessionChanged(e){return this._userSessionChanged.addHandler(e)}removeUserSessionChanged(e){this._userSessionChanged.removeHandler(e)}_raiseUserSessionChanged(){this._userSessionChanged.raise()}},jr=class{constructor(e){this._userManager=e,this._logger=new y("SilentRenewService"),this._isStarted=!1,this._retryTimer=new H("Retry Silent Renew"),this._tokenExpiring=async()=>{const t=this._logger.create("_tokenExpiring");try{await this._userManager.signinSilent(),t.debug("silent token renewal successful")}catch(r){if(r instanceof Se){t.warn("ErrorTimeout from signinSilent:",r,"retry in 5s"),this._retryTimer.init(5);return}t.error("Error from signinSilent:",r),this._userManager.events._raiseSilentRenewError(r)}}}async start(){const e=this._logger.create("start");if(!this._isStarted){this._isStarted=!0,this._userManager.events.addAccessTokenExpiring(this._tokenExpiring),this._retryTimer.addHandler(this._tokenExpiring);try{await this._userManager.getUser()}catch(t){e.error("getUser error",t)}}}stop(){this._isStarted&&(this._retryTimer.cancel(),this._retryTimer.removeHandler(this._tokenExpiring),this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring),this._isStarted=!1)}},Nr=class{constructor(e){this.refresh_token=e.refresh_token,this.id_token=e.id_token,this.session_state=e.session_state,this.scope=e.scope,this.profile=e.profile,this.data=e.state}},qr=class{constructor(e){this._logger=new y("UserManager"),this.settings=new kt(e),this._client=new vt(e),this._redirectNavigator=new Ur(this.settings),this._popupNavigator=new Or(this.settings),this._iframeNavigator=new Ir(this.settings),this._events=new Ar(this.settings),this._silentRenewService=new jr(this),this.settings.automaticSilentRenew&&this.startSilentRenew(),this._sessionMonitor=null,this.settings.monitorSession&&(this._sessionMonitor=new wt(this))}get events(){return this._events}get metadataService(){return this._client.metadataService}async getUser(){const e=this._logger.create("getUser"),t=await this._loadUser();return t?(e.info("user loaded"),this._events.load(t,!1),t):(e.info("user not found in storage"),null)}async removeUser(){const e=this._logger.create("removeUser");await this.storeUser(null),e.info("user removed from storage"),this._events.unload()}async signinRedirect(e={}){this._logger.create("signinRedirect");const{redirectMethod:t,...r}=e,s=await this._redirectNavigator.prepare({redirectMethod:t});await this._signinStart({request_type:"si:r",...r},s)}async signinRedirectCallback(e=window.location.href){const t=this._logger.create("signinRedirectCallback"),r=await this._signinEnd(e);return r.profile&&r.profile.sub?t.info("success, signed in subject",r.profile.sub):t.info("no subject"),r}async signinResourceOwnerCredentials({username:e,password:t,skipUserInfo:r=!1}){const s=this._logger.create("signinResourceOwnerCredential"),n=await this._client.processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:r,extraTokenParams:this.settings.extraTokenParams});s.debug("got signin response");const o=await this._buildUser(n);return o.profile&&o.profile.sub?s.info("success, signed in subject",o.profile.sub):s.info("no subject"),o}async signinPopup(e={}){const t=this._logger.create("signinPopup"),{popupWindowFeatures:r,popupWindowTarget:s,...n}=e,o=this.settings.popup_redirect_uri;o||t.throw(new Error("No popup_redirect_uri configured"));const a=await this._popupNavigator.prepare({popupWindowFeatures:r,popupWindowTarget:s}),d=await this._signin({request_type:"si:p",redirect_uri:o,display:"popup",...n},a);return d&&(d.profile&&d.profile.sub?t.info("success, signed in subject",d.profile.sub):t.info("no subject")),d}async signinPopupCallback(e=window.location.href,t=!1){const r=this._logger.create("signinPopupCallback");await this._popupNavigator.callback(e,t),r.info("success")}async signinSilent(e={}){var t;const r=this._logger.create("signinSilent"),{silentRequestTimeoutInSeconds:s,...n}=e;let o=await this._loadUser();if(o!=null&&o.refresh_token){r.debug("using refresh token");const h=new Nr(o);return await this._useRefreshToken(h)}const a=this.settings.silent_redirect_uri;a||r.throw(new Error("No silent_redirect_uri configured"));let d;o&&this.settings.validateSubOnSilentRenew&&(r.debug("subject prior to silent renew:",o.profile.sub),d=o.profile.sub);const l=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:s});return o=await this._signin({request_type:"si:s",redirect_uri:a,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?o==null?void 0:o.id_token:void 0,...n},l,d),o&&((t=o.profile)!=null&&t.sub?r.info("success, signed in subject",o.profile.sub):r.info("no subject")),o}async _useRefreshToken(e){const t=await this._client.useRefreshToken({state:e,timeoutInSeconds:this.settings.silentRequestTimeoutInSeconds}),r=new le({...e,...t});return await this.storeUser(r),this._events.load(r),r}async signinSilentCallback(e=window.location.href){const t=this._logger.create("signinSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async signinCallback(e=window.location.href){const{state:t}=await this._client.readSigninResponseState(e);switch(t.request_type){case"si:r":return await this.signinRedirectCallback(e);case"si:p":return await this.signinPopupCallback(e);case"si:s":return await this.signinSilentCallback(e);default:throw new Error("invalid response_type in state")}}async signoutCallback(e=window.location.href,t=!1){const{state:r}=await this._client.readSignoutResponseState(e);if(r)switch(r.request_type){case"so:r":await this.signoutRedirectCallback(e);break;case"so:p":await this.signoutPopupCallback(e,t);break;case"so:s":await this.signoutSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async querySessionStatus(e={}){const t=this._logger.create("querySessionStatus"),{silentRequestTimeoutInSeconds:r,...s}=e,n=this.settings.silent_redirect_uri;n||t.throw(new Error("No silent_redirect_uri configured"));const o=await this._loadUser(),a=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:r}),d=await this._signinStart({request_type:"si:s",redirect_uri:n,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?o==null?void 0:o.id_token:void 0,response_type:this.settings.query_status_response_type,scope:"openid",skipUserInfo:!0,...s},a);try{const l=await this._client.processSigninResponse(d.url);return t.debug("got signin response"),l.session_state&&l.profile.sub?(t.info("success for subject",l.profile.sub),{session_state:l.session_state,sub:l.profile.sub,sid:l.profile.sid}):(t.info("success, user not authenticated"),null)}catch(l){if(this.settings.monitorAnonymousSession&&l instanceof Q)switch(l.error){case"login_required":case"consent_required":case"interaction_required":case"account_selection_required":return t.info("success for anonymous user"),{session_state:l.session_state}}throw l}}async _signin(e,t,r){const s=await this._signinStart(e,t);return await this._signinEnd(s.url,r)}async _signinStart(e,t){const r=this._logger.create("_signinStart");try{const s=await this._client.createSigninRequest(e);return r.debug("got signin request"),await t.navigate({url:s.url,state:s.state.id,response_mode:s.state.response_mode,scriptOrigin:this.settings.iframeScriptOrigin})}catch(s){throw r.debug("error after preparing navigator, closing navigator window"),t.close(),s}}async _signinEnd(e,t){const r=this._logger.create("_signinEnd"),s=await this._client.processSigninResponse(e);return r.debug("got signin response"),await this._buildUser(s,t)}async _buildUser(e,t){const r=this._logger.create("_buildUser"),s=new le(e);if(t){if(t!==s.profile.sub)throw r.debug("current user does not match user returned from signin. sub from signin:",s.profile.sub),new Q({...e,error:"login_required"});r.debug("current user matches user returned from signin")}return await this.storeUser(s),r.debug("user stored"),this._events.load(s),s}async signoutRedirect(e={}){const t=this._logger.create("signoutRedirect"),{redirectMethod:r,...s}=e,n=await this._redirectNavigator.prepare({redirectMethod:r});await this._signoutStart({request_type:"so:r",post_logout_redirect_uri:this.settings.post_logout_redirect_uri,...s},n),t.info("success")}async signoutRedirectCallback(e=window.location.href){const t=this._logger.create("signoutRedirectCallback"),r=await this._signoutEnd(e);return t.info("success"),r}async signoutPopup(e={}){const t=this._logger.create("signoutPopup"),{popupWindowFeatures:r,popupWindowTarget:s,...n}=e,o=this.settings.popup_post_logout_redirect_uri,a=await this._popupNavigator.prepare({popupWindowFeatures:r,popupWindowTarget:s});await this._signout({request_type:"so:p",post_logout_redirect_uri:o,state:o==null?void 0:{},...n},a),t.info("success")}async signoutPopupCallback(e=window.location.href,t=!1){const r=this._logger.create("signoutPopupCallback");await this._popupNavigator.callback(e,t),r.info("success")}async _signout(e,t){const r=await this._signoutStart(e,t);return await this._signoutEnd(r.url)}async _signoutStart(e={},t){var r;const s=this._logger.create("_signoutStart");try{const n=await this._loadUser();s.debug("loaded current user from storage"),this.settings.revokeTokensOnSignout&&await this._revokeInternal(n);const o=e.id_token_hint||n&&n.id_token;o&&(s.debug("setting id_token_hint in signout request"),e.id_token_hint=o),await this.removeUser(),s.debug("user removed, creating signout request");const a=await this._client.createSignoutRequest(e);return s.debug("got signout request"),await t.navigate({url:a.url,state:(r=a.state)==null?void 0:r.id})}catch(n){throw s.debug("error after preparing navigator, closing navigator window"),t.close(),n}}async _signoutEnd(e){const t=this._logger.create("_signoutEnd"),r=await this._client.processSignoutResponse(e);return t.debug("got signout response"),r}async signoutSilent(e={}){var t;const r=this._logger.create("signoutSilent"),{silentRequestTimeoutInSeconds:s,...n}=e,o=this.settings.includeIdTokenInSilentSignout?(t=await this._loadUser())==null?void 0:t.id_token:void 0,a=this.settings.popup_post_logout_redirect_uri,d=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:s});await this._signout({request_type:"so:s",post_logout_redirect_uri:a,id_token_hint:o,...n},d),r.info("success")}async signoutSilentCallback(e=window.location.href){const t=this._logger.create("signoutSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async revokeTokens(e){const t=await this._loadUser();await this._revokeInternal(t,e)}async _revokeInternal(e,t=this.settings.revokeTokenTypes){const r=this._logger.create("_revokeInternal");if(!e)return;const s=t.filter(n=>typeof e[n]=="string");if(!s.length){r.debug("no need to revoke due to no token(s)");return}for(const n of s)await this._client.revokeToken(e[n],n),r.info(`${n} revoked successfully`),n!=="access_token"&&(e[n]=null);await this.storeUser(e),r.debug("user stored"),this._events.load(e)}startSilentRenew(){this._logger.create("startSilentRenew"),this._silentRenewService.start()}stopSilentRenew(){this._silentRenewService.stop()}get _userStoreKey(){return`user:${this.settings.authority}:${this.settings.client_id}`}async _loadUser(){const e=this._logger.create("_loadUser"),t=await this.settings.userStore.get(this._userStoreKey);return t?(e.debug("user storageString loaded"),le.fromStorageString(t)):(e.debug("no user storageString"),null)}async storeUser(e){const t=this._logger.create("storeUser");if(e){t.debug("storing user");const r=e.toStorageString();await this.settings.userStore.set(this._userStoreKey,r)}else this._logger.debug("removing user"),await this.settings.userStore.remove(this._userStoreKey)}async clearStaleState(){await this._client.clearStaleState()}},Mr="2.2.2",Wr=Mr;const Et=M.createContext(null),Rt=()=>{const e=M.useContext(Et);if(!e)throw new Error("useImpersonationContext must be used within a ImpersonationContextProvider");return e},Fr=({children:e})=>{const[t,r]=Xt.useLocalStorageState("impersonationState",{defaultValue:{}}),s=M.useMemo(()=>({accessToken:t==null?void 0:t.accessToken,userInfo:t==null?void 0:t.userInfo,setImpersonation:(n,o)=>{r({accessToken:n,userInfo:o})}}),[]);return ue.jsx(Et.Provider,{value:s,children:e})},Dr=e=>{const r=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=atob(r);return JSON.parse(s)},Lr=e=>{const{setImpersonation:t}=Rt();M.useEffect(()=>{const{search:r}=window.location,s=new URLSearchParams(r).get("impersonateAccessToken");if(s&&t){const n=Dr(s);t(s,n),e()}},[])},Hr=({userManager:e,context:t,children:r})=>{const[s,n]=M.useState({user:null,isLoading:!0,isAuthenticated:!1,isError:!1,error:null}),o=M.useRef(!1);M.useEffect(()=>{o.current||(o.current=!0,(async()=>{try{const h=await e.getUser();n({user:h,isLoading:!1,isAuthenticated:h?!h.expired:!1,isError:!1,error:null})}catch(h){n({user:null,isLoading:!1,isAuthenticated:!1,isError:!0,error:h instanceof Error?h:new Error("Unknown error during auth")})}})())},[e]),M.useEffect(()=>{const h=b=>{n({user:b,isLoading:!1,isAuthenticated:!b.expired,isError:!1,error:null})};e.events.addUserLoaded(h);const p=()=>{n({...s,user:null,isAuthenticated:!1})};e.events.addUserUnloaded(p);const _=b=>{n({...s,isLoading:!1,isError:!0,error:b})};return e.events.addSilentRenewError(_),()=>{e.events.removeUserLoaded(h),e.events.removeUserUnloaded(p),e.events.removeSilentRenewError(_)}},[e]);const a=M.useCallback(async()=>{const h=await e.signinCallback();return n({user:h??null,isLoading:!1,isAuthenticated:h?!h.expired:!1,isError:!1,error:null}),h??void 0},[e]),d=M.useCallback(async h=>{try{await e.signinRedirect(h)}catch(p){console.error(p)}},[e]),l=M.useMemo(()=>({state:s,handleSigninCallback:a,redirectToSignin:d}),[s,a,d]);return ue.jsx(t.Provider,{value:l,children:r})},De=e=>{const t=M.useContext(e);if(!t)throw new Error("useAuthContext must be used within an AuthProvider");return t},Br=e=>{const{state:t}=De(e);return t},$r=(e,t)=>{const{state:r,handleSigninCallback:s}=De(e),n=M.useRef(!1);return M.useEffect(()=>{n.current||(n.current=!0,s().then(o=>new Promise(a=>setTimeout(()=>a(o),0))).then(o=>t==null?void 0:t(o)))},[s]),r},zr=e=>{const t=M.createContext(null);return{AuthContext:t,AuthProvider:({children:d})=>ue.jsx(Hr,{userManager:e,context:t,children:d}),useAuthContext:()=>De(t),useAuthState:()=>Br(t),useSigninCallback:d=>$r(t,d),getAccessToken:async()=>{const d=await e.getUser();return d?d.access_token:null}}};exports.AccessTokenEvents=ht;exports.CheckSessionIFrame=gt;exports.ErrorResponse=Q;exports.ErrorTimeout=Se;exports.ImpersonationContextProvider=Fr;exports.InMemoryWebStorage=qe;exports.Logger=y;exports.MetadataService=ft;exports.OidcClient=vt;exports.OidcClientSettingsStore=Fe;exports.SessionMonitor=wt;exports.SigninResponse=ve;exports.SigninState=ye;exports.SignoutResponse=pt;exports.State=te;exports.User=le;exports.UserManager=qr;exports.UserManagerSettingsStore=kt;exports.Version=Wr;exports.WebStorageStateStore=We;exports.createAuthContext=zr;exports.useImpersonationCallback=Lr;exports.useImpersonationContext=Rt;
|
package/dist/oidc.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/oidc/oidc'
|