import { Runtime } from '@wireapp/commons' ; import { EventEmitter } from 'events' ; import type { Cookie } from './Cookie' ; enum TOPIC { COOKIE_REFRESH = 'CookieStore.TOPIC.COOKIE_REFRESH' } export class CookieStore { private static cookie ? : Cookie ; public static emitter = new EventEmitter ( ) ; public static readonly TOPIC = TOPIC ; static getCookie ( ) { return CookieStore . cookie ; } private static emit ( ) { if ( Runtime . isNode ( ) ) { CookieStore . emitter . emit ( CookieStore . TOPIC . COOKIE_REFRESH , CookieStore . cookie ) ; } } static setCookie ( cookie ? ) { CookieStore . cookie = cookie ; CookieStore . emit ( ) ; } static deleteCookie ( ) { CookieStore . cookie = undefined ; CookieStore . emit ( ) ; } }