<commit_before>/* eslint-disable react/jsx-filename-extension */
/* eslint-disable no-console */
import App from 'component/app';
import SnackBar from 'component/snackBar';
import SplashScreen from 'component/splash';
import moment from 'moment';
import * as ACTIONS from 'constants/action_types';
import * as MODALS from 'constants/modal_types';
import { ipcRenderer, remote, shell } from 'electron';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import {
  doConditionalAuthNavigate,
  doDaemonReady,
  doAutoUpdate,
  doOpenModal,
} from 'redux/actions/app';
import { doToast, doBlackListedOutpointsSubscribe, isURIValid } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation';
import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings';
import { doUserEmailVerify, doAuthenticate, Lbryio, rewards } from 'lbryinc';
import 'scss/all.scss';
import store from 'store';
import pjson from 'package.json';
import app from './app';
import analytics from './analytics';
import doLogWarningConsoleMessage from './logWarningConsoleMessage';

const { autoUpdater } = remote.require('electron-updater');
const APPPAGEURL = 'lbry://?';

autoUpdater.logger = remote.require('electron-log');

// We need to override Lbryio for getting/setting the authToken
// We interect with ipcRenderer to get the auth key from a users keyring
let authToken;
Lbryio.setOverride('setAuthToken', status => {
  Lbryio.call(
    'user',
    'new',
    {
      auth_token: '',
      language: 'en',
      app_id: status.installation_id,
    },
    'post'
  ).then(response => {
    if (!response.auth_token) {
      throw new Error(__('auth_token is missing from response'));
    }

    const newAuthToken = response.auth_token;
    authToken = <PASSWORD>AuthToken;
    ipcRenderer.send('set-auth-token', authToken);
  });
});

Lbryio.setOverride(<commit_msg>use promise for setAuthToken so we only continue after the auth token has been set<commit_after>/* eslint-disable react/jsx-filename-extension */
/* eslint-disable no-console */
import App from 'component/app';
import SnackBar from 'component/snackBar';
import SplashScreen from 'component/splash';
import moment from 'moment';
import * as ACTIONS from 'constants/action_types';
import * as MODALS from 'constants/modal_types';
import { ipcRenderer, remote, shell } from 'electron';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import {
  doConditionalAuthNavigate,
  doDaemonReady,
  doAutoUpdate,
  doOpenModal,
} from 'redux/actions/app';
import { doToast, doBlackListedOutpointsSubscribe, isURIValid } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation';
import { doDownloadLanguages, doUpdateIsNightAsync } from 'redux/actions/settings';
import { doUserEmailVerify, doAuthenticate, Lbryio, rewards } from 'lbryinc';
import 'scss/all.scss';
import store from 'store';
import pjson from 'package.json';
import app from './app';
import analytics from './analytics';
import doLogWarningConsoleMessage from './logWarningConsoleMessage';

const { autoUpdater } = remote.require('electron-updater');
const APPPAGEURL = 'lbry://?';

autoUpdater.logger = remote.require('electron-log');

// We need to override Lbryio for getting/setting the authToken
// We interect with ipcRenderer to get the auth key from a users keyring
// We keep a local variable for authToken beacuse `ipcRenderer.send` does not
// contain a response, so there is no way to know when it's been set
let authToken;
Lbryio.setOverride(
  'setAuthToken',
  status =>
    new Promise(resolve => {
      Lbryio.call(
        'user',
        'new',
        {
          auth_token: '',
          language: 'en',
          app_id: status.installation_id,
        },
        'post'
      ).then(response => {
        if (!response.auth_token) {
          throw new Error(__('auth_token is missing from response'));
        }

        const newAuthToken = response.auth_token;
        authToken = <PASSWORD>AuthToken;
        ipcRenderer.send('set-auth-token', authToken);
        resolve();
      });
    })
);

Lbryio.setOverride(
{'fraction_non_alphanumeric': 0.11775923718712754, 'fraction_numerical': 0.0, 'mean_word_length': 4.148466257668711, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6500822', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1270, 'n_words': 364}