<commit_before>/* eslint-disable */
import axios from 'axios';
import { login } from './auth';
import config from './config';
import history from '../configuration/history';
import { parseJwt } from '../../helpers';

const headers = {
    Accept: 'application/vnd.janus.v1+json',
};

const client = axios.create({
    baseURL: process.env.NODE_ENV !== 'production' ? config.gateway.uri : MAIN_CONFIG.gateway.uri,
    headers,
});

export const setAccessToken = (token) => {
    localStorage.setItem('access_token', token);
    client.defaults.headers.common.Authorization = `Bearer ${token}`;
};

export const getAccessToken = () => {
    const token = localStorage.getItem('access_token');

    if (token) {
        const expirationTime = parseJwt(token).exp * 1000;
        const dateNow = new Date();

        if (expirationTime > dateNow.getTime()) {
            return token;
        }
    }

    return token
};

export const setRefreshToken = token => localStorage.setItem('refresh_token', token);

export const getRefreshToken = () => localStorage.getItem('refresh_token');

if (getAccessToken()) {
    setAccessToken(getAccessToken());
}

client.interceptors.response.use(undefined, (error) => {<commit_msg>prettify<commit_after>/* eslint-disable */
import axios from 'axios';
import { login } from './auth';
import config from './config';
import history from '../configuration/history';
import { parseJwt } from '../../helpers';

const headers = {
    Accept: 'application/vnd.janus.v1+json',
};

const client = axios.create({
    baseURL: process.env.NODE_ENV !== 'production' ? config.gateway.uri : MAIN_CONFIG.gateway.uri,
    headers,
});

export const setAccessToken = (token) => {
    localStorage.setItem('access_token', token);
    client.defaults.headers.common.Authorization = `Bearer ${token}`;
};

export const getAccessToken = () => {
    const token = localStorage.getItem('access_token');

    if (!token) return;

    const expirationTime = parseJwt(token).exp * 1000;
    const dateNow = new Date();

    if (expirationTime > dateNow.getTime()) {
        return token;
    }
};

export const setRefreshToken = token => localStorage.setItem('refresh_token', token);

export const getRefreshToken = () => localStorage.getItem('refresh_token');

if (getAccessToken()) {
    setAccessToken(getAccessToken());
}

client.interceptors.response.use(undefined, (error) => {
{'fraction_non_alphanumeric': 0.15223755750731913, 'fraction_numerical': 0.004182350480970306, 'mean_word_length': 3.9421487603305785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5249940', 'n_tokens_mistral': 721, 'n_tokens_neox': 710, 'n_words': 163}