{ "version": 3, "sources": ["../javascripts/selectors/auth.ts"], "sourcesContent": ["import { createSelector } from '@reduxjs/toolkit';\nimport { jwtDecode } from 'jwt-decode';\nimport type { Token } from '../@types/Token';\nimport type { RootState } from '../reducers';\n\nexport const isAuthenticated = createSelector(\n (state: RootState) => state.auth.token,\n (token) => {\n if (token && process.env.SSR && process.env.NODE_ENV === 'testing') return true;\n\n if (token) {\n const data = jwtDecode(token);\n const expires = new Date(data.exp * 1000);\n\n if (expires > new Date()) {\n return true;\n }\n }\n\n return false;\n },\n);\n\nexport const getTokenId = createSelector(\n (state: RootState) => state.auth.token,\n (token) => {\n if (!token) return null;\n return jwtDecode(token).sub;\n },\n);\n\nexport const getToken = (state: RootState) => state.auth.token;\n\nexport const getResponseStatus = (state: RootState) => state.auth.requestStatus;\n"], "mappings": "8FAKO,IAAMA,EAAkBC,EAC5BC,GAAqBA,EAAM,KAAK,MAChCC,GAAU,CAGT,GAAIA,EAAO,CACT,IAAMC,EAAOC,EAAiBF,CAAK,EAGnC,GAFgB,IAAI,KAAKC,EAAK,IAAM,GAAI,EAE1B,IAAI,KAChB,MAAO,EAEX,CAEA,MAAO,EACT,CACF,EAEaE,EAAaL,EACvBC,GAAqBA,EAAM,KAAK,MAChCC,GACMA,EACEE,EAAiBF,CAAK,EAAE,IADZ,IAGvB,EAEaI,EAAYL,GAAqBA,EAAM,KAAK,MAE5CM,EAAqBN,GAAqBA,EAAM,KAAK", "names": ["isAuthenticated", "createSelector", "state", "token", "data", "jwtDecode", "getTokenId", "getToken", "getResponseStatus"] }