{ "version": 3, "sources": ["libs/core/src/lib/util.ts", "libs/core/src/lib/session.service.ts"], "sourcesContent": ["/**\n * If a component is being used in an iframe with a different domain\n * localstorage access will fail on Chrome\n * https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityer\\\n * ror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-thi\\\n * s-document\n *\n * this solution is cited here:\n * https://michalzalecki.com/why-using-localStorage-directly-is-a-bad-idea/\n */\nexport function isLocalStorageAvailable(): boolean {\n try {\n const key = '__some_random_key_just_to_test_localstorage__';\n window.localStorage.setItem(key, key);\n window.localStorage.removeItem(key);\n return true;\n } catch (e) {\n return false;\n }\n}\n", "import { Injectable } from '@angular/core';\nimport { BehaviorSubject, Observable } from 'rxjs';\nimport { isLocalStorageAvailable } from './util';\n\ndeclare const iamSession: string;\nconst LOCAL_SESSION_KEY = 'local_session';\nconst USE_LOCAL_STORAGE = isLocalStorageAvailable();\n\n@Injectable({ providedIn: 'root' })\nexport class SessionService {\n private sessionIdSubject$$: BehaviorSubject;\n\n constructor() {\n if (typeof iamSession !== 'undefined' && !!iamSession) {\n this.sessionIdSubject$$ = new BehaviorSubject(iamSession);\n } else if (USE_LOCAL_STORAGE) {\n const localSession = this.getLocalStoredSession();\n this.sessionIdSubject$$ = new BehaviorSubject(localSession);\n } else {\n this.sessionIdSubject$$ = new BehaviorSubject(null);\n }\n\n this.sessionIdSubject$$.subscribe((sessionId) => {\n if (USE_LOCAL_STORAGE) {\n this.setLocalStoredSession(sessionId);\n }\n });\n }\n\n getSessionId(): Observable {\n return this.sessionIdSubject$$.asObservable();\n }\n\n setSessionId(sessionId: string): void {\n this.sessionIdSubject$$.next(sessionId);\n }\n\n clearSessionId(): void {\n this.sessionIdSubject$$.next('');\n }\n\n private getLocalStoredSession(): string | null {\n return localStorage.getItem(LOCAL_SESSION_KEY);\n }\n\n private setLocalStoredSession(session: string | null): void {\n localStorage.setItem(LOCAL_SESSION_KEY, session ?? '');\n }\n}\n"], "mappings": "gDAUM,SAAUA,GAAuB,CACrC,GAAI,CACF,IAAMC,EAAM,gDACZC,cAAOC,aAAaC,QAAQH,EAAKA,CAAG,EACpCC,OAAOC,aAAaE,WAAWJ,CAAG,EAC3B,EACT,MAAY,CACV,MAAO,EACT,CACF,CCdA,IAAMK,EAAoB,gBACpBC,EAAoBC,EAAuB,EAGpCC,GAAc,IAAA,CAArB,IAAOA,EAAP,MAAOA,CAAc,CAGzBC,aAAA,CACE,GAAI,OAAOC,WAAe,KAAiBA,WACzC,KAAKC,mBAAqB,IAAIC,EAA+BF,UAAU,UAC9DJ,EAAmB,CAC5B,IAAMO,EAAe,KAAKC,sBAAqB,EAC/C,KAAKH,mBAAqB,IAAIC,EAAgBC,CAAY,CAC5D,MACE,KAAKF,mBAAqB,IAAIC,EAA+B,IAAI,EAGnE,KAAKD,mBAAmBI,UAAWC,GAAa,CAC1CV,GACF,KAAKW,sBAAsBD,CAAS,CAExC,CAAC,CACH,CAEAE,cAAY,CACV,OAAO,KAAKP,mBAAmBQ,aAAY,CAC7C,CAEAC,aAAaJ,EAAiB,CAC5B,KAAKL,mBAAmBU,KAAKL,CAAS,CACxC,CAEAM,gBAAc,CACZ,KAAKX,mBAAmBU,KAAK,EAAE,CACjC,CAEQP,uBAAqB,CAC3B,OAAOS,aAAaC,QAAQnB,CAAiB,CAC/C,CAEQY,sBAAsBQ,EAAsB,CAClDF,aAAaG,QAAQrB,EAAmBoB,GAAW,EAAE,CACvD,yCAtCWjB,EAAc,wBAAdA,EAAcmB,QAAdnB,EAAcoB,UAAAC,WADD,MAAM,CAAA,EAC1B,IAAOrB,EAAPsB,SAAOtB,CAAc,GAAA", "names": ["isLocalStorageAvailable", "key", "window", "localStorage", "setItem", "removeItem", "LOCAL_SESSION_KEY", "USE_LOCAL_STORAGE", "isLocalStorageAvailable", "SessionService", "constructor", "iamSession", "sessionIdSubject$$", "BehaviorSubject", "localSession", "getLocalStoredSession", "subscribe", "sessionId", "setLocalStoredSession", "getSessionId", "asObservable", "setSessionId", "next", "clearSessionId", "localStorage", "getItem", "session", "setItem", "factory", "\u0275fac", "providedIn", "_SessionService"] }