<commit_before>library Firebase;

import 'dart:js';
import 'dart:async';
import 'dart:convert';

part 'query.dart';
part 'snapshot.dart';
part 'disconnect.dart';

/**
 * A firebase represents a particular location in your Firebase and can be used
 * for reading or writing data to that Firebase location.
 */
class Firebase extends Query {
  Disconnect _onDisconnect;

  /**
   * Construct a new Firebase reference from a full Firebase URL.
   */
  Firebase(String url) : super(url);

  /**
   * Construct a new Firebase reference from a JsObject.
   */
  Firebase.fromJsObject(JsObject obj) : super.fromJsObject(obj);

  /**
   * Getter for onDisconnect.
   */
  Disconnect get onDisconnect {
    if (this._onDisconnect != null) {
      return this._onDisconnect;
    }
    this._onDisconnect = new Disconnect(this._fb.callMethod('onDisconnect'));
    return this._onDisconnect;
  }

  /**
   * Authenticates a Firebase client using a provided Authentication token.
   * Takes a single token as an argument and returns a Future that will be
   * resolved when the authentication succeeds (or fails).
   */
  Future auth(String token) {
    var c = new Completer();
    this._fb.callMethod('auth', [token, (err) {
      if (err != null) {
        c.completeError(err);
      } else {
        // FIXME: Get optional second argument 'user'.
      }
    }, (err) {
      c.completeError(err);
    }]);
    return c.future;
  }

  /**
   * Unauthenticates a Firebase client (i.e. logs out).
   */
  void unauth() {
    this._fb.callMethod('unauth');<commit_msg>pass along the auth response on a successful login<commit_after>library Firebase;

import 'dart:js';
import 'dart:async';
import 'dart:convert';

part 'query.dart';
part 'snapshot.dart';
part 'disconnect.dart';

/**
 * A successful authentication response.
 */
class AuthResponse {
  final int expires;
  final String auth;

  AuthResponse(JsObject response)
      : expires = response['expires'],
        auth = response['auth'];

  String toString() => 'expires: $expires, auth: $auth';
}

/**
 * A firebase represents a particular location in your Firebase and can be used
 * for reading or writing data to that Firebase location.
 */
class Firebase extends Query {
  Disconnect _onDisconnect;

  /**
   * Construct a new Firebase reference from a full Firebase URL.
   */
  Firebase(String url) : super(url);

  /**
   * Construct a new Firebase reference from a JsObject.
   */
  Firebase.fromJsObject(JsObject obj) : super.fromJsObject(obj);

  /**
   * Getter for onDisconnect.
   */
  Disconnect get onDisconnect {
    if (this._onDisconnect != null) {
      return this._onDisconnect;
    }
    this._onDisconnect = new Disconnect(this._fb.callMethod('onDisconnect'));
    return this._onDisconnect;
  }

  /**
   * Authenticates a Firebase client using a provided Authentication token.
   * Takes a single token as an argument and returns a Future that will be
   * resolved when the authentication succeeds (or fails).
   */
  Future<AuthResponse> auth(String token) {
    var c = new Completer();
    // On failure, the first argument will be an Error object indicating the
    // failure. On success, the first argument will be null and the second
    // will be an object containing { auth: <auth payload>, expires:
    // <expiration time in seconds since the unix epoch> }.
    this._fb.callMethod('auth', [token, (err, result) {
      if (err != null) {
        c.completeError(err);
      } else {
        // TODO why are result['expires'] and result['auth'] null?
        c.complete(new AuthResponse(result));
      }
    }, (err) {
      c.completeError(err);
    }]);
    return c.future;
  }

  /**
   * Unauthenticates a Firebase client (i.e. logs out).
   */
  void unauth() {
    this._fb.callMethod('unauth');
{'fraction_non_alphanumeric': 0.11524261603375527, 'fraction_numerical': 0.0, 'mean_word_length': 3.0394036208732693, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, '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': '575032', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1136, 'n_words': 370}