<commit_before>import Auth0 from 'auth0-js';
import * as StringUtils from '../utils/string_utils';

class Auth0WebAPI {
  constructor() {
    this.clients = {};
  }

  setupClient(lockID, clientID, domain) {
    // TODO: reuse clients
    this.clients[lockID] = new Auth0({
      clientID: clientID,
      domain: domain,
      sendSDKClientInfo: true
    });
  }

  signIn(lockID, options, cb) {
    this.clients[lockID].login(options, function (error, profile, idToken, accessToken, state, refreshToken) {
      cb(normalizeError(error), profile, idToken, accessToken, state, refreshToken);
    });
  }

  signOut(lockID, query) {
    this.clients[lockID].logout(query);
  }

  startPasswordless(lockID, options, cb) {
    this.clients[lockID].startPasswordless(options, err => cb(normalizeError(err)));
  }
}

export default new Auth0WebAPI();

function normalizeError(error) {
  return error && {
    error: error.details ? error.details.error : (error.statusCode || error.error),
    description: error.details ? error.details.error_description : (error.error_description || error.message)
  }
}
<commit_msg>Don't use error.message as a custom error<commit_after>import Auth0 from 'auth0-js';
import * as StringUtils from '../utils/string_utils';

class Auth0WebAPI {
  constructor() {
    this.clients = {};
  }

  setupClient(lockID, clientID, domain) {
    // TODO: reuse clients
    this.clients[lockID] = new Auth0({
      clientID: clientID,
      domain: domain,
      sendSDKClientInfo: true
    });
  }

  signIn(lockID, options, cb) {
    this.clients[lockID].login(options, function (error, profile, idToken, accessToken, state, refreshToken) {
      cb(normalizeError(error), profile, idToken, accessToken, state, refreshToken);
    });
  }

  signOut(lockID, query) {
    this.clients[lockID].logout(query);
  }

  startPasswordless(lockID, options, cb) {
    this.clients[lockID].startPasswordless(options, err => cb(normalizeError(err)));
  }
}

export default new Auth0WebAPI();

function normalizeError(error) {
  return error && {
    error: error.details ? error.details.error : (error.statusCode || error.error),
    description: error.details ? error.details.error_description : (error.error_description || error.error)
  }
}

{'fraction_non_alphanumeric': 0.1341030195381883, 'fraction_numerical': 0.004440497335701598, 'mean_word_length': 3.9407894736842106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6497041', 'n_tokens_mistral': 725, 'n_tokens_neox': 709, 'n_words': 150}