1 import { encodeBase64URL } from '../../helpers/encoding';
2 import { getItem, removeItem, setItem } from '../../helpers/storage';
4 const getKey = (UID: string) => {
5 return encodeBase64URL(`r-${UID}`);
8 export const setLastRefreshDate = (UID: string, now: Date) => {
9 setItem(getKey(UID), `${+now}`);
12 export const getLastRefreshDate = (UID: string) => {
13 const oldString = getItem(getKey(UID));
14 const parsed = Number.parseInt(oldString || '', 10);
15 const date = new Date(parsed);
16 return Number.isNaN(+date) ? undefined : date;
19 export const removeLastRefreshDate = (UID: string) => {
20 removeItem(getKey(UID));