Giter VIP home page Giter VIP logo

firebase-dart's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

firebase-dart's Issues

Wrong return types for addScope/setCustomParameters in AuthProviders

When I use the addScope method of GithubAuthProvider I get the following error:

Return value for method: addScope is JSObjectImpl which is inconsistent with all typed JS interop definitions for method addScope.
EXCEPTION: type 'JSObjectImpl' is not a subtype of type 'void' of 'function result' where
  JSObjectImpl is from dart:js

STACKTRACE: 
package:firebase/src/auth.dart 368:43                         GithubAuthProvider.addScope

see https://github.com/firebase/firebase-dart/blob/master/lib/src/interop/auth_interop.dart#L76

  • dart version: 1.22.1 on "windows_x64"
  • firebase-dart version: 3.0.1
  • included firebase-js version: 3.7.8

I guess that the method addScope returns another GithubAuthProvider instead of void on the JavaScript side (to allow fluent calls). The same might be true for setCustomParameters.

I tried fixing it with my own custom implementation of GithubAuthProviderJsImpl but wasn't able to completely succeed. Is there something else needed than replacing the void return types with GithubAuthProviderJsImpl?

DDC compatibility

Please it's possible to add a @JS() annotation to each external declaration in order to provide compatibility with dartdevc ?

Running Tests Receives "out-of-band" error

I'm trying to write tests for some auth functionality, but I'm having a tough time with the test runner. I keep getting

Caught Bad state: An out-of-band error was signaled outside of wrapAsync after the schedule finished running.
The schedule had no errors.

Sometimes I get this error, other times the tests pass just fine. Does this happen to anyone else?

Republish to pub

Looks like there have been some tweaks since we last pushed to pub. Can I help you do that?

You can add me as a publisher via the pub command line tool if that helps.

Add Flutter support

Flutter is a new project to help developers build high-performance, high-fidelity, mobile apps for iOS and Android from a single codebase. Flutter developers need the firebase-dart package to add Firebase support to their app.

Here is an example of a Firebase app using Flutter: https://github.com/flutter/firechat-flutter

Mojo is the IPC system that Flutter apps use to call native iOS and Android SDKs. By refactoring firebase-dart into a JavaScript and Mojo backend with a common interface, we can allow the firebase-dart package to work for Flutter developers. We will need dart-lang/sdk#24581 to be fixed before we can do this.

.name() fails with Class 'String' has no instance method 'call' after update

Updated to latest, and now my Firebase calls throw:

Exception: Uncaught Error: Class 'String' has no instance method 'call'.

NoSuchMethodError: method not found: 'call'
Receiver: "thelab"
Arguments: []
Stack Trace:
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#1      MainViewModel.loadCommunities.<anonymous closure> (package:woven/src/client/view_model/main.dart:104:40)
#2      dirtyCheckZoneSpec.wrapUnaryCallback.<anonymous closure> (package:observe/src/dirty_check.dart:120:15)
#3      _rootRunUnary (dart:async/zone.dart:840)
#4      _CustomZone.runUnary (dart:async/zone.dart:748)
#5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:656)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
#7      _DelayedData.perform (dart:async/stream_impl.dart:595)
#8      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:711)
#9      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:671)
#10     _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#11     _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#12     _handleMutation (dart:html:39006)

It doesn't seem to like e.snapshot.name() any more.

endAt() throws exception: second argument was an invalid key: "null"

var f = new db.Firebase('https://....');
var lastItemsQuery = f.endAt().limit(5);

gives error:

Exception: Error: Query.endAt failed: second argument was an invalid key: "null".  Firebase keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]").

The line in query.dart where it occurs is:

Query endAt({var priority, var name}) {
    return new Query.fromJsObject(this._fb.callMethod('endAt',
                                                      [priority, name]));
  }

AuthResponse does not contain full AuthData from Firebase.

The authResponse object only exposes the expires and auth items from the authData that gets returned from a successful auth or the getAuth() method. The auth item is insufficient as it only contains the uid and provider

Each authentication method for Firebase returns much more data, and that data should all be accessible in the authResponse.

For example, the authWithPassword() authData contains something like this:

{
    uid: <some-uid>,
    provider: "password",
    token: <firebase-authentication-token>,
    auth: {
        uid: <some-uid>,
        provider: "password"
    },
    expires: <timestamp>,
    password: {
        email: "[email protected]",
        isTemporaryPassword: false
    }
}

The Google, Facebook, Twitter, Github, and anonymous authentication methods all return their own distinct authData elements.
https://www.firebase.com/docs/web/guide/login/google.html
https://www.firebase.com/docs/web/guide/login/facebook.html
https://www.firebase.com/docs/web/guide/login/twitter.html
https://www.firebase.com/docs/web/guide/login/github.html
https://www.firebase.com/docs/web/guide/login/anonymous.html

is there a reason we couldn't or shouldn't expose the raw JsObject? Because each authentication method returns different elements for authData, I don't believe adding all possible items as properties on the AuthResponse object is the right solution.

I'm happy to work on a patch if you give me some direction, but I'm not sure about the history or reasons why it was initially done the way it currently is.

Wrapping firebase's new auth's

Anyone working on adding wrappings for the new firebase auth calls into the library?

authWithCustomToken(), authWithOAuthPopup(), etc...

'NoSuchMethodError' with newer versions of JS SDK

I just realized that after I updated the Firebase library to 2.0.0+, I am getting errors after all of my operations.

The calls are actually being made and showing up in the Forge, but the callbacks are failing.

I apologize if I missed a prior discussion on this, I looked in depth for one.

NoSuchMethodError: incorrect number of arguments passed to method named 'call'
Receiver: Closure: (dynamic, dynamic) => dynamic
Tried calling: call(null)
Found: call(err, res)
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:45) (https://cdn.firebase.com/js/client/2.1.1/firebase.js:25)
Breaking on exception: Closure call with mismatched arguments: function 'call'

This is very easy to test. Grab the test project from this repo and change the version of the Firebase library from the CDN in test.html to verson 2.1.1.

I can start working on this but I wanted to start discussion. (Not discounting the possibility I'm just doing something wrong). It worries me about backwards compatibility but I didn't see anything in the Firebase changelog that would explain it. Haven't looked deep enough.

@sethladd the ONLY thing I found on remotely similar to this issue was actually exactly the same error you were getting over a year ago on issue #3. This one isn't specific to authentication or anything, however. Thought it was worth mentioning.

cancel of one StreamSubscription stops also another one

Dart: 1.24.2
OS: MacOS 10.12.5
firebase-dart: 4.0.0
firebase: 4.1.3

I have sample code like this:

import "package:firebase/firebase.dart" as fb;
void main() {
	fb.initializeApp(
		apiKey: "AIzaSyApMsSCCzy81YB1OgBUUZLbTxT6EBPgCDY",
		authDomain: "playground-a8df2.firebaseapp.com",
		databaseURL: "https://playground-a8df2.firebaseio.com",
//		projectId: "playground-a8df2",
		storageBucket: "",
//		messagingSenderId: "948022233563"
	);

	StreamSubscription ss1 = fb.database().ref("cities/2/name").onValue.listen((fb.QueryEvent qe) {
		print("ss1:"+qe.snapshot.val());
	});
	StreamSubscription ss2 = fb.database().ref("cities/2/name").onValue.listen((fb.QueryEvent qe) {
		print("ss2:"+qe.snapshot.val());
		ss1.cancel();
	});
	print(ss1.hashCode.toString());
	print(ss2.hashCode.toString());
}

I see in output that I have two different instances of StreamSubscription. When I change the value in cities/2/name remotely I got NO events. If I comment out the ss1.cancel() I got two notifications, each from every StreamSubscription.
Here is WS communication without cancel:

{"t":"c","d":{"t":"h","d":{"ts":1500993689518,"v":"5","h":"s-usc1c-nss-235.firebaseio.com","s":"DvetIYyJHfTKmyjyDoTnXoe0iWVz7ZQ9"}}}	
{"t":"d","d":{"r":1,"a":"s","b":{"c":{"sdk.js.4-1-3":1}}}}
{"t":"d","d":{"r":2,"a":"q","b":{"p":"/cities/2/name","h":""}}}	
{"t":"d","d":{"r":1,"b":{"s":"ok","d":""}}}	
{"t":"d","d":{"b":{"p":"cities/2/name","d":"Praha 2"},"a":"d"}}
{"t":"d","d":{"r":2,"b":{"s":"ok","d":{}}}}
{"t":"d","d":{"b":{"p":"cities/2/name","d":"Praha"},"a":"d"}}

and here is WITH the cancel:

{"t":"c","d":{"t":"h","d":{"ts":1500993854706,"v":"5","h":"s-usc1c-nss-235.firebaseio.com","s":"hDVjVGakcbyuVPMmbjYs8b5Yy3AxalYU"}}}
{"t":"d","d":{"r":1,"a":"s","b":{"c":{"sdk.js.4-1-3":1}}}}	
{"t":"d","d":{"r":2,"a":"q","b":{"p":"/cities/2/name","h":""}}}	
{"t":"d","d":{"r":1,"b":{"s":"ok","d":""}}}	
{"t":"d","d":{"b":{"p":"cities/2/name","d":"Praha 2"},"a":"d"}}	
{"t":"d","d":{"r":3,"a":"n","b":{"p":"/cities/2/name"}}}	
{"t":"d","d":{"r":2,"b":{"s":"ok","d":{}}}}	
{"t":"d","d":{"r":3,"b":{"s":"ok","d":""}}}	

So the client code really cancels subscription to the cities/2/name node, but this doesn't look correct to me. Two independent portions of the UI could subscribe to the same node and then since one cancel that, the second one will not receive any new updates.

AuthCredential implementations missing

The abstract class AuthCredential seems to have implementations in JavaScript but there are no corresponding subclasses in Dart. I would need something like the following to be able to access the GitHub accessToken in Dart:

@JS()
abstract class GithubAuthCredential extends AuthCredential{
  external String get accessToken;
}

I'm using the following code to get the access token:

    var provider = new fb.GithubAuthProvider();
    provider.addScope('repo');

    try {
      fb.UserCredential result = await _auth.signInWithPopup(provider);

      // User signed in successfully.
      _user = result.user;

      // This is the only place where we can access the Github token.
      _githubToken = (result.credential as GithubAuthCredential).accessToken;

      _fireSignedInChangedEvent();
    } catch (e) {
      print('Error authenticating with GitHub via Firebase: $e');
    }
  }

Cannot set messagingSenderId at initializeApp

I wanted to use Firebase Realtime Database in an App Engine webapp, so I went and initialized my firebase account. The Firebase console told me to use the following parameters:

authDomain: "...",
databaseURL: "...",
storageBucket: "...",
messagingSenderId: "..."

However, the current initializeApp function does not allow setting the parameter messagingSenderId.

Unable to successfully authentication

When I set my URL and token, and try to call auth(token), I get this error:

Breaking on exception: Closure call with mismatched arguments: function 'call'

Closure call with mismatched arguments: function 'call'

NoSuchMethodError: incorrect number of arguments passed to method named 'call'
Receiver: Closure: (dynamic) => dynamic
Tried calling: call(null, Instance of 'JsObject')
Found: call(err)

Right after printing 'HELLO!!!!'

Using Dart 1.1 and Firebase 0.1.0

Does it work for you?

Tests fail with user credentials

Hi,

I've wrapped getAuth() and want to create a test for it. Unfortunately, when I use my Firebase URL and email address for the tests, they run but crash at some point. I don't know where exactly the crash occurs as it doesn't seem to be in a part that isn't accessible to me. I can see on my dashboard that the user is actually created.

Here's the message I get:

FIREBASE WARNING: set at /2015-02-01T17:36:37_923Z failed: permission_denied (https://cdn.firebase.com/js/client/1.1.2/firebase.js:42)
Breaking on exception: Closure call with mismatched arguments: function 'call'

I've not changed or added any test yet, only added my credentials. Any idea what may cause this?

Possible to run tests using dart:io?

The README describes how to run tests for the firebase-dart package itself.

Is it possible to write a test using dart:io instead of the browser? (analogous to the java or node.js firebase server APIs)

Firebase 2.2.2

Hi @sethladd

Thanks for your help merging in some of the additional auth methods! I've got another patch ready that updates this library to be able to use the current firebase 2.2.2 api. I'll wait on the pull request until the oauth methods hit master so I can hopefully submit it correctly the first time.

After this I think I'm done with my planned updates for a bit. I'm loving firebase & dart together. Thanks for putting up with all the spam.

~ aaron

Upgrade to 2.4.0

I get errors when trying to run the 2.4.0 version with Dart:

FIREBASE WARNING: Exception was thrown by user callback. NoSuchMethodError: method not found: 'call'
Receiver: Closure 'yp'
Arguments: [null, null]

I have no idea what it exactly is, but I guess there were breaking changes in 2.4.0.

Throw catchable error when firebase.js wasn't loaded

initializeApp() should throw something like JsNotLoadedError when the wrapped JS functions and objects aren't available.

For example, when using the web app offline, firebase.js won't be loaded, and initializeApp() will die horribly with a null pointer exception, thus taking the whole app down.

Flutter support

Hello,

is it possible to use this library in a Flutter project?

Update startAt() and endAt()

It seems startAt() and endAt() no longer need named parameters, and in fact the idea of priorities should be divorced from those methods as the newer Firebase Query API lets you start and end based on orderBy_ methods like orderByPriority and orderByChild.

Relevant code:
https://github.com/firebase/firebase-dart/blob/master/lib/src/firebase.dart#L611-L641

See the newer stuff documented here:
https://www.firebase.com/docs/web/api/query/startat.html
https://www.firebase.com/docs/web/api/query/endat.html

Events triggered out-of-order

The Firebase JavaScript API specification states that Firebase "ensures that value events are always triggered last and are guaranteed to contain updates from any other events which occurred before that snapshot was taken".

This behavior cannot be guaranteed as firebase-dart uses multiple Dart StreamControllers to fire events (this is likely likely related to this issue.)

For example, in the following code we would expect to see: "added 1, added 2, added 3, value" printed to the console (as is the case in the Firebase JavaScript code.) However, firebase-dart outputs (e.g.) "added 1, value, added 2, added 3":

int numAdded = 0;
firebase.Firebase fb = new firebase.Firebase(TEST_URL);
fb.authWithPassword(new JsObject.jsify(
  {'email': '[email protected]', 'password': 'mypassword'}
))
.then((_) {
  fb..onChildAdded.listen((firebase.Event event) {
    print("added ${++numAdded}");
  })
  ..onValue.listen((firebase.Event event) {
    print("value");
  });
});

This becomes an issue in the common scenario where applications request an initial snashot then expects to receive notification of changes (chid_added, child_changed, child_moved, child_removed.) In this scenario, clients will often discard any child_added events received prior to the first value event.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.