import { UserManagerSettings , WebStorageStateStore } from 'oidc-client' ; import { storageFactory } from './storageFactory' ; export interface AuthSettings extends Omit < UserManagerSettings , 'scope' > { /**
     * Make client id required.
     */ client_id : string ; baseUrl ? : string ; redirectPath ? : string ; /**
     * Used to bind React Router callback route and to build a default value for `silent_redirect_uri` with baseUrl.
     * Should be relative from baseUrl and start with a "/".
     * Default: "/auth/callback-silent"
     */ redirectPathSilent ? : string ; /**
     * Prefix for storing user access tokens in session storage.
     */ userStorePrefix ? : string ; /**
     * Allow to pass the scope as an array.
     */ scope ? : string [ ] ; /**
     * Which URL to send the user to after switching users.
     */ switchUserRedirectUrl ? : string ; } export const mergeAuthSettings = ( settings ) => { const baseUrl = settings . baseUrl ?? window . location . origin ; const redirectPath = settings . redirectPath ?? '/auth/callback' ; const redirectPathSilent = settings . redirectPathSilent ?? '/auth/callback-silent' ; const onIdsDomain = /(is|dev)land.is$/ . test ( window . location . origin ) ; return { baseUrl , redirectPath , redirectPathSilent , authority : 'https://innskra.island.is' , silent_redirect_uri : `${ baseUrl }${ redirectPathSilent }` , redirect_uri : `${ baseUrl }${ redirectPath }` , post_logout_redirect_uri : baseUrl , response_type : 'code' , revokeAccessTokenOnSignout : true , loadUserInfo : true , monitorSession : onIdsDomain , userStore : new WebStorageStateStore ( { store : storageFactory ( ( ) => sessionStorage ) , prefix : settings . userStorePrefix , } ) , ... settings , } ; } ;