{"version":3,"sources":["webpack:///./src/authenticatestep.ts","webpack:///./src/app.ts","webpack:///./src/app.html","webpack:///./src/callback.ts","webpack:///./src/callback.html","webpack:///./src/components/admin/admin.ts","webpack:///./src/components/admin/admin.html","webpack:///./src/auth-service.ts"],"names":["auth","run","routingContext","next","isLoggedIn","this","isAuthenticated","getAllInstructions","some","route","config","cancel","fragment","AuthenticateStep","authService","router","attached","refresh","configureRouter","options","pushState","addAuthorizeStep","map","redirect","nav","name","href","moduleId","title","roles","App","module","exports","handleAuthentication","Callback","adminService","singalrwrapper","pingmessage","ispinging","isUpdatingUnitCounts","forceRecalculation","ping","error","onPong","message","success","updateAllOrganizationUnitCounts","onAllOrganizationUnitCountsUpdated","onAllOrganizationUnitCountsUpdateFailed","on","detached","off","Admin","authNotifier","auth0","domain","clientID","clientId","redirectUri","base","audience","responseType","scope","setAccessTokenRefresh","setInterval","expiresAt","JSON","parse","window","localStorage","getItem","Date","getTime","console","log","checkSession","err","result","setSession","login","savedurl","currentInstruction","endsWith","setItem","stringify","url","authorize","parseHash","authResult","accessToken","idToken","navigateTarget","navigate","emit","authenticated","idTokenExpiresAt","expiresIn","toDate","accessTokenExpiresAt","exp","logout","removeItem","returnTo","getAccessToken","claimNamespace","concat","isSystemAdmin","AuthService"],"mappings":"ipBAMA,aACE,WAAmBA,GAAA,KAAAA,OAgBrB,OAdE,YAAAC,IAAA,SAAIC,EAAgBC,GAClB,IAAMC,EAAaC,KAAKL,KAAKM,gBAG7B,GAAIJ,EAAeK,qBAAqBC,KAAK,SAAAC,GAAS,OAAsB,IAAtBA,EAAMC,OAAOV,QACjE,IAAKI,EACH,OAAOD,EAAKQ,OAAO,IAAI,IAJR,eAMZ,GAAIP,GAAcF,EAAeK,qBAAqBC,KAAK,SAAAC,GAAS,MANxD,UAMwDA,EAAMG,WAC/E,OAAOT,EAAKQ,OAAO,IAAI,IAAS,SAGlC,OAAOR,KAfEU,EAAgB,GAD5B,I,uBAE0B,OADdA,GAAb,G,ueCIA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C,OAAOC,aAAagC,WAnGQ,2BAoG5BjC,OAAOC,aAAagC,WAnGgB,oCAqGpChG,KAAKgD,aAAawC,KAAK,aAAc,CAAEC,eAAe,IACtDzF,KAAKiD,MAAM8C,OAAO,CAChB5C,SAAU,IAAIF,MAAMG,SACpB6C,SAAU,IAAIhD,MAAMgD,YAIxB,YAAAC,eAAA,WAEE,OADoBnC,OAAOC,aAAaC,QA/GrB,iBAmHrB,sBAAI,uBAAQ,C,IAAZ,WACE,GAAIjE,KAAKC,gBAET,OADgB,IAAU8D,OAAOC,aAAaC,QAxH/B,aAyHGkC,gD,gCAGpB,sBAAI,4BAAa,C,IAAjB,WACE,QAAInG,KAAKC,iBACO,IAAU8D,OAAOC,aAAaC,QA9H/B,aA+HGkC,qD,gCAGpB,sBAAI,oBAAK,C,IAAT,WACE,MAAO,GAAGC,OAAOpG,KAAKqG,cAAgB,CAAC,YAAc,K,gCAzH5CC,EAAW,GADvB,I,uBAc6B,OAbjBA,GAAb","file":"app~d28f829f.a57201e594cf7d49f8c9.chunk.js","sourcesContent":["import { Redirect } from \"aurelia-router\";\r\nimport { autoinject } from \"aurelia-framework\";\r\n\r\nimport { AuthService } from \"auth-service\";\r\n\r\n@autoinject\r\nexport class AuthenticateStep {\r\n constructor(public auth: AuthService) { }\r\n\r\n run(routingContext, next) {\r\n const isLoggedIn = this.auth.isAuthenticated;\r\n const loginRoute = \"login\";\r\n\r\n if (routingContext.getAllInstructions().some(route => route.config.auth === true)) {\r\n if (!isLoggedIn) {\r\n return next.cancel(new Redirect(loginRoute));\r\n }\r\n } else if (isLoggedIn && routingContext.getAllInstructions().some(route => route.fragment === loginRoute)) {\r\n return next.cancel(new Redirect(\"home\"));\r\n }\r\n\r\n return next();\r\n }\r\n}","import { Router, RouterConfiguration } from \"aurelia-router\";\r\nimport { PLATFORM } from 'aurelia-pal';\r\nimport { AuthenticateStep } from \"authenticatestep\";\r\nimport { RolesAuthoriseStep } from \"rolesauthorisestep\";\r\nimport { AuthService } from \"auth-service\";\r\nimport { inject } from \"aurelia-framework\";\r\n\r\n@inject(\r\n AuthService\r\n)\r\nexport class App {\r\n constructor(\r\n public authService: AuthService) {\r\n }\r\n\r\n attached() {\r\n if (this.authService.isAuthenticated) {\r\n this.authService.refresh();\r\n }\r\n }\r\n\r\n router: Router = null;\r\n configureRouter(config: RouterConfiguration, router: Router) {\r\n this.router = router;\r\n config.options.pushState = true;\r\n config.addAuthorizeStep(AuthenticateStep);\r\n config.addAuthorizeStep(RolesAuthoriseStep);\r\n config.map([\r\n // unauthenticated\r\n { route: [\"\"], redirect: \"welcome\", nav: false },\r\n { route: [\"login\", \"Welcome\"], name: \"welcome\", href: \"welcome\", moduleId: PLATFORM.moduleName(\"components/welcome/welcome\"), nav: true, title: \"Welcome\" },\r\n { route: [\"support\", \"Support\"], name: \"support\", href: \"support\", moduleId: PLATFORM.moduleName(\"components/support/support\"), nav: true, title: \"Support\" },\r\n // auth0\r\n { route: 'callback', name: 'callback', moduleId: PLATFORM.moduleName(\"callback\"), nav: false },\r\n\r\n // authenticated\r\n { route: \"dashboard\", name: \"dashboard\", href: \"dashboard\", moduleId: PLATFORM.moduleName(\"components/dashboard/dashboard\"), nav: true, auth: true, title: \"Dashboard\" },\r\n { route: \"plans-and-reports\", name: \"plans-and-reports\", href: \"plans-and-reports\", moduleId: PLATFORM.moduleName(\"components/plans-and-reports/plans-and-reports\"), nav: true, auth: true, title: \"Plans and Reports\" },\r\n { route: \"manage-organizations\", name: \"manage-organizations\", href: \"manage-organizations\", moduleId: PLATFORM.moduleName(\"components/manage-organizations/manage-organizations\"), nav: true, auth: true, roles: [\"sysadmin\"], title: \"Manage Organisations\" },\r\n { route: \"manage-organization-users\", name: \"manage-organization-users\", href: \"manage-organization-users\", moduleId: PLATFORM.moduleName(\"components/manage-organization-users/manage-organization-users\"), nav: true, auth: true, roles: [\"sysadmin\"], title: \"User Administration\" },\r\n\r\n { route: \"plan-create\", name: \"plan-create\", href: \"plan-create\", moduleId: PLATFORM.moduleName(\"components/plan-create/plan-create\"), nav: false, auth: true, roles: [\"sysadmin\"], title: \"New Plan\" },\r\n\r\n { route: \"unit-kpi/:planid\", name: \"unit-kpi\", href: \"unit-kpi\", moduleId: PLATFORM.moduleName(\"components/unit-kpi/unit-kpi\"), nav: false, auth: true, title: \"View Unit KPI\" },\r\n { route: \"state-kpi/:planid\", name: \"state-kpi\", href: \"state-kpi\", moduleId: PLATFORM.moduleName(\"components/state-kpi/state-kpi\"), nav: false, auth: true, title: \"View State KPI\" },\r\n { route: \"zone-kpi/:planid\", name: \"zone-kpi\", href: \"zone-kpi\", moduleId: PLATFORM.moduleName(\"components/zone-kpi/zone-kpi\"), nav: false, auth: true, title: \"View Zone KPI\" },\r\n { route: \"central-kpi/:planid\", name: \"central-kpi\", href: \"central-kpi\", moduleId: PLATFORM.moduleName(\"components/central-kpi/central-kpi\"), nav: false, auth: true, title: \"View Central KPI\" },\r\n { route: \"unit-plan-view/:planid\", name: \"unit-plan-view\", href: \"unit-plan-view\", moduleId: PLATFORM.moduleName(\"components/unit-plan-view/unit-plan-view\"), nav: false, auth: true, title: \"View Unit Plan\" },\r\n { route: \"unit-plan-edit/:planid\", name: \"unit-plan-edit\", href: \"unit-plan-edit\", moduleId: PLATFORM.moduleName(\"components/unit-plan-edit/unit-plan-edit\"), nav: false, auth: true, title: \"Edit Unit Plan\" },\r\n { route: \"unit-report-view/:reportid\", name: \"unit-report-view\", href: \"unit-report-view\", moduleId: PLATFORM.moduleName(\"components/unit-report-view/unit-report-view\"), nav: false, auth: true, title: \"View Unit Report\" },\r\n { route: \"unit-report-edit/:reportid\", name: \"unit-report-edit\", href: \"unit-report-edit\", moduleId: PLATFORM.moduleName(\"components/unit-report-edit/unit-report-edit\"), nav: false, auth: true, title: \"Edit Unit Report\" },\r\n { route: \"unit-plan-copy/:planid\", name: \"unit-plan-copy\", href: \"unit-plan-copy\", moduleId: PLATFORM.moduleName(\"components/unit-plan-copy/unit-plan-copy\"), nav: false, auth: true, title: \"Copy Unit Plan\" },\r\n {\r\n route: \"unit-report-lastperiod-edit/:reportid\",\r\n name: \"unit-report-lastperiod-edit\",\r\n href: \"unit-report-lastperiod-edit\",\r\n moduleId: PLATFORM.moduleName(\"components/unit-report-lastperiod-edit/unit-report-lastperiod-edit\"),\r\n nav: false, auth: true, roles: [\"sysadmin\"], title: \"Edit Unit Report Last Period\"\r\n },\r\n\r\n { route: \"state-plan-view/:planid\", name: \"state-plan-view\", href: \"state-plan-view\", moduleId: PLATFORM.moduleName(\"components/state-plan-view/state-plan-view\"), nav: false, auth: true, title: \"View State Plan\" },\r\n { route: \"state-plan-edit/:planid\", name: \"state-plan-edit\", href: \"state-plan-edit\", moduleId: PLATFORM.moduleName(\"components/state-plan-edit/state-plan-edit\"), nav: false, auth: true, title: \"Edit State Plan\" },\r\n { route: \"state-report-view/:reportid\", name: \"state-report-view\", href: \"state-report-view\", moduleId: PLATFORM.moduleName(\"components/state-report-view/state-report-view\"), nav: false, auth: true, title: \"View State Report\" },\r\n { route: \"state-report-edit/:reportid\", name: \"state-report-edit\", href: \"state-report-edit\", moduleId: PLATFORM.moduleName(\"components/state-report-edit/state-report-edit\"), nav: false, auth: true, title: \"Edit State Report\" },\r\n { route: \"state-plan-copy/:planid\", name: \"state-plan-copy\", href: \"state-plan-copy\", moduleId: PLATFORM.moduleName(\"components/state-plan-copy/state-plan-copy\"), nav: false, auth: true, title: \"Copy State Plan\" },\r\n {\r\n route: \"state-report-lastperiod-edit/:reportid\",\r\n name: \"state-report-lastperiod-edit\",\r\n href: \"state-report-lastperiod-edit\",\r\n moduleId: PLATFORM.moduleName(\"components/state-report-lastperiod-edit/state-report-lastperiod-edit\"),\r\n nav: false, auth: true, roles: [\"sysadmin\"], title: \"Edit State Report Last Period\"\r\n },\r\n\r\n { route: \"zone-plan-view/:planid\", name: \"zone-plan-view\", href: \"zone-plan-view\", moduleId: PLATFORM.moduleName(\"components/zone-plan-view/zone-plan-view\"), nav: false, auth: true, title: \"View Zone Plan\" },\r\n { route: \"zone-plan-edit/:planid\", name: \"zone-plan-edit\", href: \"zone-plan-edit\", moduleId: PLATFORM.moduleName(\"components/zone-plan-edit/zone-plan-edit\"), nav: false, auth: true, title: \"Edit Zone Plan\" },\r\n { route: \"zone-report-view/:reportid\", name: \"zone-report-view\", href: \"zone-report-view\", moduleId: PLATFORM.moduleName(\"components/zone-report-view/zone-report-view\"), nav: false, auth: true, title: \"View Zone Report\" },\r\n { route: \"zone-report-edit/:reportid\", name: \"zone-report-edit\", href: \"zone-report-edit\", moduleId: PLATFORM.moduleName(\"components/zone-report-edit/zone-report-edit\"), nav: false, auth: true, title: \"Edit Zone Report\" },\r\n { route: \"zone-plan-copy/:planid\", name: \"zone-plan-copy\", href: \"zone-plan-copy\", moduleId: PLATFORM.moduleName(\"components/zone-plan-copy/zone-plan-copy\"), nav: false, auth: true, title: \"Copy Zone Plan\" },\r\n {\r\n route: \"zone-report-lastperiod-edit/:reportid\",\r\n name: \"zone-report-lastperiod-edit\",\r\n href: \"zone-report-lastperiod-edit\",\r\n moduleId: PLATFORM.moduleName(\"components/zone-report-lastperiod-edit/zone-report-lastperiod-edit\"),\r\n nav: false, auth: true, roles: [\"sysadmin\"], title: \"Edit Zone Report Last Period\"\r\n },\r\n\r\n { route: \"central-plan-view/:planid\", name: \"central-plan-view\", href: \"central-plan-view\", moduleId: PLATFORM.moduleName(\"components/central-plan-view/central-plan-view\"), nav: false, auth: true, title: \"View Central Plan\" },\r\n { route: \"central-plan-edit/:planid\", name: \"central-plan-edit\", href: \"central-plan-edit\", moduleId: PLATFORM.moduleName(\"components/central-plan-edit/central-plan-edit\"), nav: false, auth: true, title: \"Edit Central Plan\" },\r\n { route: \"central-report-view/:reportid\", name: \"central-report-view\", href: \"central-report-view\", moduleId: PLATFORM.moduleName(\"components/central-report-view/central-report-view\"), nav: false, auth: true, title: \"View Central Report\" },\r\n { route: \"central-report-edit/:reportid\", name: \"central-report-edit\", href: \"central-report-edit\", moduleId: PLATFORM.moduleName(\"components/central-report-edit/central-report-edit\"), nav: false, auth: true, title: \"Edit Central Report\" },\r\n { route: \"central-plan-copy/:planid\", name: \"central-plan-copy\", href: \"central-plan-copy\", moduleId: PLATFORM.moduleName(\"components/central-plan-copy/central-plan-copy\"), nav: false, auth: true, title: \"Copy Central Plan\" },\r\n {\r\n route: \"central-report-lastperiod-edit/:reportid\",\r\n name: \"central-report-lastperiod-edit\",\r\n href: \"central-report-lastperiod-edit\",\r\n moduleId: PLATFORM.moduleName(\"components/central-report-lastperiod-edit/central-report-lastperiod-edit\"),\r\n nav: false, auth: true, roles: [\"sysadmin\"], title: \"Edit Central Report Last Period\"\r\n },\r\n\r\n { route: \"organization-create\", name: \"organization-create\", href: \"organization-create\", moduleId: PLATFORM.moduleName(\"components/organization-create/organization-create\"), nav: false, auth: true, roles: [\"sysadmin\"], title: \"New Organisation\" },\r\n { route: \"organization-edit/:organizationId\", name: \"organization-edit\", href: \"organization-edit\", moduleId: PLATFORM.moduleName(\"components/organization-edit/organization-edit\"), nav: false, auth: true, title: \"Edit Organisation\" },\r\n\r\n { route: \"organization-user-create\", name: \"organization-user-create\", href: \"organization-user-create\", moduleId: PLATFORM.moduleName(\"components/organization-user-create/organization-user-create\"), nav: false, auth: true, roles: [\"sysadmin\"], title: \"New Organisation User\" },\r\n\r\n { route: \"admin\", name: \"admin\", href: \"admin\", moduleId: PLATFORM.moduleName(\"components/admin/admin\"), nav: true, auth: true, roles: [\"sysadmin\"], title: \"Admin Tools\" },\r\n\r\n { route: \"analytic-reports\", name: \"analytic-reports\", href: \"analytic-reports\", moduleId: PLATFORM.moduleName(\"components/analytic-reports/analytic-reports\"), nav: true, auth: true, title: \"Analytic Reports\" },\r\n { route: \"kpi-reports\", name: \"kpi-reports\", href: \"kpi-reports\", moduleId: PLATFORM.moduleName(\"components/kpi-reports/kpi-reports\"), nav: false, auth: true, title: \"Kpi Reports\" },\r\n { route: \"analytic-report-create\", name: \"analytic-report-create\", href: \"analytic-report-create\", moduleId: PLATFORM.moduleName(\"components/analytic-report-create/analytic-report-create\"), nav: false, auth: true, title: \"Create New Analytic Report\" },\r\n { route: \"support-auth\", name: \"support-auth\", href: \"support-auth\", moduleId: PLATFORM.moduleName(\"components/support/support\"), nav: true, auth: true, title: \"Support\" },\r\n ])\r\n }\r\n}\r\n","module.exports = \"\";","import { autoinject } from 'aurelia-framework';\r\nimport { AuthService } from 'auth-service';\r\n\r\n@autoinject\r\nexport class Callback {\r\n constructor(private auth: AuthService) {\r\n auth.handleAuthentication();\r\n }\r\n}","module.exports = \"\";","import { autoinject } from \"aurelia-framework\";\r\nimport { AdminService } from \"services/AdminService\";\r\nimport { SignalrWrapper } from \"signalrwrapper\";\r\nimport toastr from \"toastr\";\r\n\r\n@autoinject\r\nexport class Admin {\r\n pingmessage = \"\";\r\n ispinging = false;\r\n isUpdatingUnitCounts = false;\r\n forceRecalculation = false;\r\n constructor(public adminService: AdminService, public singalrwrapper: SignalrWrapper) {}\r\n\r\n attached() {\r\n this.singalrwrapper.on(\"Pong\", this.onPong);\r\n this.singalrwrapper.on(\"AllOrganizationUnitCountsUpdated\", this.onAllOrganizationUnitCountsUpdated);\r\n this.singalrwrapper.on(\"AllOrganizationUnitCountsUpdateFailed\", this.onAllOrganizationUnitCountsUpdateFailed);\r\n }\r\n\r\n detached() {\r\n this.singalrwrapper.off(\"Pong\", this.onPong);\r\n this.singalrwrapper.off(\"AllOrganizationUnitCountsUpdated\", this.onAllOrganizationUnitCountsUpdated);\r\n this.singalrwrapper.off(\"AllOrganizationUnitCountsUpdateFailed\", this.onAllOrganizationUnitCountsUpdateFailed);\r\n }\r\n\r\n ping = async () => {\r\n try {\r\n await this.adminService.ping(this.pingmessage);\r\n this.ispinging = true;\r\n } catch(error) {\r\n toastr.error(error);\r\n }\r\n }\r\n\r\n onPong = (message: string) => {\r\n toastr.success(message);\r\n this.ispinging = false;\r\n }\r\n\r\n updateAllOrganizationUnitCounts = async () => {\r\n try {\r\n await this.adminService.updateAllOrganizationUnitCounts(this.forceRecalculation);\r\n this.isUpdatingUnitCounts = true;\r\n } catch(error) {\r\n toastr.error(error);\r\n }\r\n }\r\n\r\n onAllOrganizationUnitCountsUpdated = () => {\r\n toastr.success(\"Successfully updated all organization unit counts\");\r\n this.isUpdatingUnitCounts = false;\r\n }\r\n\r\n onAllOrganizationUnitCountsUpdateFailed = (message: string) => {\r\n toastr.error(message);\r\n this.isUpdatingUnitCounts = false;\r\n }\r\n}","module.exports = \"\";","import { WebAuth, Auth0DecodedHash, Auth0Error } from \"auth0-js\";\r\nimport { autoinject } from \"aurelia-framework\";\r\nimport { Router } from \"aurelia-router\";\r\nimport { EventEmitter } from \"events\";\r\nimport jwtDecode from \"jwt-decode\";\r\nimport moment from \"moment\";\r\nimport env from \"./environment\";\r\n\r\nconst fiveMinuteInterval = 5 * 60 * 1000;\r\nconst fifteenMinuteInterval = 15 * 60 * 1000;\r\nconst idTokenKey = \"id_token\";\r\nconst idTokenExpiresAtKey = \"id_token_expires_at\";\r\nconst idTokenExpiresAtDateTimeKey = \"id_token_expires_at_datetime\";\r\nconst accessTokenKey = \"access_token\";\r\nconst accessTokenExpiresAtKey = \"access_token_expires_at\";\r\nconst accessTokenExpiresAtDateTimeKey = \"access_token_expires_at_datetime\";\r\nconst locationKey = \"location\";\r\nconst claimNamespace = \"https://reportingmodule.com/claims\";\r\n\r\n@autoinject\r\nexport class AuthService {\r\n\r\n authNotifier = new EventEmitter();\r\n\r\n auth0 = new WebAuth({\r\n domain: env.auth0.domain,\r\n clientID: env.auth0.clientId,\r\n redirectUri: `${env.auth0.base}/callback`,\r\n audience: env.auth0.audience,\r\n responseType: \"token id_token\",\r\n scope: \"openid email\",\r\n });\r\n\r\n constructor(private router: Router) { \r\n }\r\n\r\n setAccessTokenRefresh() {\r\n let timeoutId = setInterval(() => {\r\n if (this.isAuthenticated) {\r\n let expiresAt = JSON.parse(window.localStorage.getItem(accessTokenExpiresAtKey));\r\n if (expiresAt) {\r\n let currentTime = new Date().getTime();\r\n if ((expiresAt - currentTime) < fifteenMinuteInterval) {\r\n this.refresh();\r\n }\r\n }\r\n }\r\n }, fiveMinuteInterval);\r\n }\r\n\r\n refresh() {\r\n console.log('refresh token');\r\n this.auth0.checkSession({}, (err: Auth0Error, result: Auth0DecodedHash) => {\r\n if (err) {\r\n console.log(err);\r\n } else {\r\n this.setSession(result);\r\n }\r\n });\r\n }\r\n\r\n login(): void {\r\n const savedurl = this.router.currentInstruction.fragment.endsWith(\"/Welcome\") ? \"/dashboard\" : this.router.currentInstruction.fragment;\r\n window.localStorage.setItem(locationKey, JSON.stringify({ url: savedurl }));\r\n this.auth0.authorize();\r\n }\r\n\r\n handleAuthentication(): void {\r\n this.auth0.parseHash((err, authResult) => {\r\n if (authResult && authResult.accessToken && authResult.idToken) {\r\n this.setSession(authResult);\r\n \r\n const savedLocation = JSON.parse(window.localStorage.getItem(locationKey));\r\n const navigateTarget = savedLocation.url || 'dashboard';\r\n \r\n this.router.navigate(navigateTarget);\r\n \r\n this.authNotifier.emit('authChange', { authenticated: true });\r\n } else if (err) {\r\n console.log(err);\r\n }\r\n });\r\n }\r\n\r\n setSession(authResult: Auth0DecodedHash): void {\r\n const idTokenExpiresAt = authResult.expiresIn * 1000 + new Date().getTime();\r\n \r\n window.localStorage.setItem(idTokenKey, authResult.idToken);\r\n window.localStorage.setItem(idTokenExpiresAtKey, JSON.stringify(idTokenExpiresAt));\r\n window.localStorage.setItem(idTokenExpiresAtDateTimeKey, JSON.stringify(moment(idTokenExpiresAt).toDate()));\r\n \r\n let decodedAccessToken: any = jwtDecode(authResult.accessToken);\r\n let accessTokenExpiresAt = decodedAccessToken.exp * 1000;\r\n window.localStorage.setItem(accessTokenKey, authResult.accessToken);\r\n window.localStorage.setItem(accessTokenExpiresAtKey, JSON.stringify(accessTokenExpiresAt));\r\n window.localStorage.setItem(accessTokenExpiresAtDateTimeKey, JSON.stringify(moment(accessTokenExpiresAt).toDate()));\r\n }\r\n\r\n get isAuthenticated(): boolean {\r\n const accessToken = window.localStorage.getItem(accessTokenKey);\r\n const expiresAt = window.localStorage.getItem(idTokenExpiresAtKey);\r\n if (!expiresAt || !accessToken)\r\n return false;\r\n \r\n const authenticated = new Date().getTime() < JSON.parse(expiresAt);\r\n return authenticated;\r\n }\r\n\r\n logout(): void {\r\n window.localStorage.removeItem(accessTokenKey);\r\n window.localStorage.removeItem(idTokenKey);\r\n window.localStorage.removeItem(idTokenExpiresAtKey);\r\n window.localStorage.removeItem(idTokenExpiresAtDateTimeKey);\r\n window.localStorage.removeItem(accessTokenExpiresAtKey);\r\n window.localStorage.removeItem(accessTokenExpiresAtDateTimeKey);\r\n \r\n this.authNotifier.emit('authChange', { authenticated: false });\r\n this.auth0.logout({\r\n clientID: env.auth0.clientId,\r\n returnTo: env.auth0.returnTo\r\n });\r\n }\r\n\r\n getAccessToken(): string {\r\n const accessToken = window.localStorage.getItem(accessTokenKey);\r\n return accessToken;\r\n }\r\n\r\n get username(): string {\r\n if(!this.isAuthenticated) return;\r\n const idToken = jwtDecode(window.localStorage.getItem(idTokenKey));\r\n return idToken[`${claimNamespace}/username`]\r\n }\r\n\r\n get isSystemAdmin(): boolean {\r\n if(!this.isAuthenticated) return false;\r\n const idToken = jwtDecode(window.localStorage.getItem(idTokenKey));\r\n return idToken[`${claimNamespace}/IsSystemAdmin`]\r\n }\r\n\r\n get roles(): string[] {\r\n return [].concat(this.isSystemAdmin ? [\"sysadmin\"] : []);\r\n }\r\n}"],"sourceRoot":""}