<commit_before>import * as firebase from 'firebase/app';
import * as utils from '../utils';
import 'firebase/auth';
import { Injectable, NgZone } from '@angular/core';
import { Auth } from '../interfaces';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { observeOn } from 'rxjs/operator/observeOn';
import { FirebaseApp } from '../app/index';

@Injectable()
export class AngularFireAuth {

  /**
   * Firebase Auth instance
   */
  auth: firebase.auth.Auth;
  
  /**
   * Observable of authentication state
   */
  authState: Observable<firebase.User>;

  constructor(public app: FirebaseApp) {
    this.authState = FirebaseAuthStateObservable(app);
    this.auth = app.auth();
  }

}

/**
 * Create an Observable of Firebase authentication state. Each event is called
 * within the current zone.
 * @param app - Firebase App instance
 */
export function FirebaseAuthStateObservable(app: FirebaseApp): Observable<firebase.User> {
  const authState = Observable.create((observer: Observer<firebase.User>) => {
    firebase.auth().onAuthStateChanged(<commit_msg>fix(auth): Use the injected app<commit_after>import * as firebase from 'firebase/app';
import * as utils from '../utils';
import 'firebase/auth';
import { Injectable, NgZone } from '@angular/core';
import { Auth } from '../interfaces';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { observeOn } from 'rxjs/operator/observeOn';
import { FirebaseApp } from '../app/index';

@Injectable()
export class AngularFireAuth {

  /**
   * Firebase Auth instance
   */
  auth: firebase.auth.Auth;

  /**
   * Observable of authentication state
   */
  authState: Observable<firebase.User>;

  constructor(public app: FirebaseApp) {
    this.authState = FirebaseAuthStateObservable(app);
    this.auth = app.auth();
  }

}

/**
 * Create an Observable of Firebase authentication state. Each event is called
 * within the current zone.
 * @param app - Firebase App instance
 */
export function FirebaseAuthStateObservable(app: FirebaseApp): Observable<firebase.User> {
  const authState = Observable.create((observer: Observer<firebase.User>) => {
    app.auth().onAuthStateChanged(
{'fraction_non_alphanumeric': 0.12887292321508756, 'fraction_numerical': 0.0, 'mean_word_length': 4.24235294117647, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6564986', 'n_tokens_mistral': 659, 'n_tokens_neox': 647, 'n_words': 181}