<commit_before>import auth0 from 'auth0-js';
import history from './history';

export default class Auth {
  auth0 = new auth0.WebAuth({
    domain: 'gbptm.eu.auth0.com',
    clientID: 'sUts4RKy04JcyZ2IVFgMAC0rhPARCQYg',
    redirectUri: `${window.location.orign}/callback`,
    responseType: 'token id_token',
    audience: 'https://www.toiletmap.org.uk/api',
    scope: 'openid profile report:loo',
  });

  constructor() {
    this.login = this.login.bind(this);
    this.logout = this.logout.bind(this);
    this.handleAuthentication = this.handleAuthentication.bind(this);
    this.isAuthenticated = this.isAuthenticated.bind(this);
    this.getAccessToken = this.getAccessToken.bind(this);
  }

  handleAuthentication() {
    return new Promise((resolve, reject) => {
      this.auth0.parseHash((err, authResult) => {
        if (authResult && authResult.accessToken && authResult.idToken) {
          this.setSession(authResult);
          resolve();
        } else if (err) {
          reject(err);
        }
      });<commit_msg>feat: connect to cross-app auth<commit_after>import auth0 from 'auth0-js';
import history from './history';

export default class Auth {
  auth0 = new auth0.WebAuth({
    domain: 'gbptm.eu.auth0.com',
    clientID: 'sUts4RKy04JcyZ2IVFgMAC0rhPARCQYg',
    redirectUri: `${window.location.origin}/callback`,
    responseType: 'token id_token',
    audience: 'https://www.toiletmap.org.uk/api',
    scope: 'openid profile report:loo',
  });

  constructor() {
    this.login = this.login.bind(this);
    this.logout = this.logout.bind(this);
    this.handleAuthentication = this.handleAuthentication.bind(this);
    this.isAuthenticated = this.isAuthenticated.bind(this);
    this.getAccessToken = this.getAccessToken.bind(this);
  }

  handleAuthentication() {
    return new Promise((resolve, reject) => {
      this.auth0.parseHash((err, authResult) => {
        if (authResult && authResult.accessToken && authResult.idToken) {
          this.setSession(authResult);
          resolve();
        } else if (err) {
          reject(err);
        }
      });
{'fraction_non_alphanumeric': 0.14033412887828162, 'fraction_numerical': 0.010501193317422435, 'mean_word_length': 3.2775510204081635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '320604', 'n_tokens_mistral': 681, 'n_tokens_neox': 674, 'n_words': 120}