firebase / firebase-js-sdk Goto Github PK
View Code? Open in Web Editor NEWFirebase Javascript SDK
Home Page: https://firebase.google.com/docs/web/setup
License: Other
Firebase Javascript SDK
Home Page: https://firebase.google.com/docs/web/setup
License: Other
Currently, the only way to get an image is to call getDownloadUrl
. The download URL is unguessable but not affected by security rules, which means that once someone has the download URL, they could theoretically use a bot to create a huge number of downloads and run up a big Cloud Storage bill or hit the project quota.
The Android SDK provides getFile
, which downloads the file directly to the device. Each download involves a security rules check (source).
Provide a function like getFile
that checks security rules every time.
Alternatively, perhaps a function that returns a signed URL (for example, getSignedUrl(expireTime)
) could accomplish a similar goal.
Followed these instructions, so I assume it is officially supported and this can be a forum to ask: https://firebase.google.com/docs/auth/web/cordova
When using signInWithRedirect in a Cordova environment and regardless of the auth provider (happen in Facebook, Google, Twitter), I receive this error below 90% of the time. Yes, it works perfectly fine around 10% of the time:
auth/network-request-failed
A network error (such as timeout, interrupted connection or unreachable host) has occurred.
My thought is Auth is giving up and failing because the the cordova-browsertab-plugin is taking a few too many milliseconds to respond. The would explain why I am receiving sporadic timeouts/network errors. If not this, any reason why I receive this error?
signInWithEmailAndPassword works perfectly fine, all the time. But, I think it's because there is no use of the Cordova browser tab plugin.
I'd like to define types of things in my firebase repo. DataSnapshot.val()
returns any
.
call .val
on a DataSnapshot
interface DataSnapshot<S> {
child(path: string): firebase.database.DataSnapshot<any>;
exists(): boolean;
exportVal(): S;
forEach(action: (a: firebase.database.DataSnapshot<S>) => boolean): boolean;
getPriority(): string | number | null;
hasChild(path: string): boolean;
hasChildren(): boolean;
key: string | null;
numChildren(): number;
ref: firebase.database.Reference;
toJSON(): Object | null;
val(): S;
}
What happened? How can we make the problem occur?
This could be a description, log/console output, etc.
Error: auth/network-request-failed
signInButton.onclick = () => {
const provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider);
};
firebase.js
is a really large file and while you can load the individual pieces of the SDK (firebase-app, firebase-database, firebase-auth, etc) you have to do so before calling firebase.initializeApp()
. This, for most use cases, means that developers load the entire firebase SDK before their app code which results in a lot of time blocking the main thread.
firebase.initializeApp()
firebase.database()
firebase.auth.Auth
is returning this error on both iOS and Android Cordova platforms.
A reproducible example with steps is at this repository.
The error occurs when the app loads. The code triggering the error is nearly the same as in the docs at the bottom, "to handle the case where the app activity is destroyed before the sign-in operation completes, call getRedirectResult when your app loads.":
firebase.auth().getRedirectResult().then(result => {
var user = result.user
console.log(user)
}).catch(error => {
this.message = error.message
})
Since the example received this error without providing an API key, I have a full example on the master branch where you can provide an API key and install the plugins, but the error still occurs.
Cannot reliably sign in using Firebase email and password on cordova
app (Android and iOS). When signing in auth/network-request-failed
is thrown.
I can reproduce this 100% of the time on my Nexus 5x phone (also tested on Firefox and Chrome desktop, but never encounter this problem). cordova-plugin-whitelist
is configured and has been worked in the past. I experimented a lot, the steps to reproduce is like this:
From Android phone:
auth/network-request-failed
will be thrownauth/network-request-failed
will be thrown againIt should has nothing to do with the keyboard or input focus / refocus but I don't have any clue either.
Related issue: angular/angularfire#581
Downgrading to Firebase SDK 3.3 does solve this issue as mentioned in the above thread.
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
console.log(error.code); // `auth/network-request-failed`
});
Hello,
I was redirected here by the people at Angularfire 2 regarding an issue I opened a few days ago. I'm not sure I should copy-paste the issue content, but here it is. Please feel free to remove everything below if you feel like it's unnecessary to write it all again).
All the best, and thank you for the amazing work.
Angular: 4.0.0
Firebase: 4.1.2
AngularFire: 4.0.0-rc.1
Other (e.g. Ionic/Cordova, Node, browser, operating system):
public logout1(): Observable<any> {
return Observable.fromPromise(
this.afAUth.auth.signOut()
).map(() => this.cleardData());
}
public logout2(): Observable<any> {
return Observable.create(obs => {
this.afAUth.auth.signOut()
.then(() => {
console.log('logged out');
obs.next();
})
.catch(err => {
throw Error(JSON.stringify(err));
});
}).map(() => this.cleardData());
}
public logout3(): Promise<any> {
return new Promise((reject, resolve) => {
this.afAUth.auth.signOut()
.then(() => {
console.log('logged out');
this.cleardData();
resolve();
})
.catch(err => {
reject(err);
});
});
}
this.auth.logout1().subscribe(
() => console.log('Logged out'),
err => console.error('Could not log out')
);
this.auth.logout2().subscribe(
() => console.log('Logged out'),
err => console.error('Could not log out')
);
this.auth.logout3()
.then(() => console.log('Logged out'))
.catch(err => console.error('Could not log out'));
All above calls should output something.
Only that to logout3
does.
It would be nice to be able to initiate a client-only database (no url, no remote link). Use cases:
My specific use case is that the model data (what is shared) needs to be heavily transformed on the client side (monte carlo simulations in web worker) so that an internal view DB is needed in addition to the shared model DB.
Given that firebase database lib is already over 100kb it feels akward need another lib (pouch db, lokijs, gun, ...) for internal app use to implement similar functionalities in a different API.
This is partly related to #34 (testing) since it would also facilitate creating and unit-testing independent module and components by removing all of the console registering and development server requirements.
I found out I can use firebase.initializeApp({databaseURL: 'x.y.z'}, 'local').database().goOffline()
but it feels like a bit of hack. Is it the correct way to do it or is this likely to fail in the future?
URL:
https://us-central1-ossbot-f0cad.cloudfunctions.net/githubWebhook
Content type:
application/json
Secret:
N/A
Select individual events:
Something I had to develop myself when working with Firebase is a small cache API so that users going back to previous views would not have to wait for data.
I implemented a in memory cache with a persistent on()
connection in the background completely decoupled from my views. After the initial data download from a database path, this memory cache is only updated with value
events so even for large datasets it works great. My users always see the updated data when returning to previous views instantly.
In any case, the Firebase SDK needs to provide a way to cache the data somehow. Maybe this would go hand in hand with the offline functionality, or not.
If a web app is started while the device is offline (for example if it's cached via service workers, or a Cordova app) the SDK doesn't properly initialize.
When the app regains connectivity. all the subsequent long polling requests (https://the-nss-server.firebaseio.com/.lp?...
) return with a status of 400 Bad request
, and the attempted web socket connection is immediatley closed.
Once the app is in that state, not even refreshing the page fixes it. After a while, though, it seems to sort itself out and reconnects.
git clone https://github.com/firebase/quickstart-js.git
cd quickstart-js/database
firebase use --add
and select the new projectfirebase serve
n/a
While the Firebase JS SDK has support for offline scenarios when the web app goes from online to offline it lacks offline first support.
Offline first is a crucial part of PWAs and should be supported by the Firebase JS SDK directly.
There is a way to use it with Google Cloud, but it is a bit complicated and firebase storage directly for web is much easier and convenient to use.
The firebase.d.ts file contains the following type definitions:
onAuthStateChanged (nextOrObserver : Object , error ? : (a : firebase.auth.Error ) => any , completed ? : ( ) => any ) : ( ) => any ;
but this means you can't just pass a function like
.onAuthStateChanged((user) => {
...
});
and let |user| by in inferred type, because typescript thinks this method takes an Object. If we look at closure externs they're more specific:
@param {!Object|function(?firebase.User)}
which would let you pass a callback without explicitly naming the type.
in typescript write:
firebase.auth().onAuthStateChanged((user) => {
console.log(user);
});
In general the "Observer" concept is mentioned in the API type definitions and docs, but I don't see anything documented about what an Observer object would be. Everything just passes a function here, is that some Firebase internal type?
Ideally the type definitions here would be specific enough that typescript could infer the argument types of all of the callbacks used in all the various firebase apis. :)
import firebase from "firebase";
const config = {
//...
};
firebase.initializeApp(config);
const googleAuthProvider = new firebaseAuth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(googleAuthProvider);
// or
firebase.auth().signInWithRedirect(googleAuthProvider);
Following up on #45 and on @jshcrowthe's comment:
Use case: just importing the database layer to develop and unit test individual modules that need a common async data store. They will likely eventually be used in the browser but development, unit testing, and packaging is just so much easier and faster in node.
//app.js
import * as firebase from './node_modules/firebase/app'
import './node_modules/firebase/database'
firebase.initializeApp({databaseURL: 'x.y.z'}, 'local').database().goOffline()
>rollup -o app.bld.js -f cjs app.js
'initializeApp' is not exported by 'node_modules\firebase\app.js'
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
'initializeApp' is not exported by 'node_modules\firebase\app.js'
Tried importing from ./node_modules/firebase/firebase-app but being build for the browser I get a navigator error in node
I also tried many a few combinations directly in the firebase/app/ folder with browserify to get an intermediate build that would be easier to consume but the build system looks like it was hacked to suit babel.
I understand I am trying to use the database component in a way that is not the intended typical use but I thought that if there were less frictions in just using the firebase toolset it would be much easier to get there progressively.
I've noticed that nothing ever gets next'ed into tokenRefreshObserver_
, meaning that the function or observer passed to firebase.messaging.Messaging#onTokenRefresh()
never gets triggered.
See: src/messaging/controllers/window-controller.ts#L72-L75
Is there some process missing that would receive token updates and trigger onTokenRefresh()
?
n/a
See linked file.
Hello,
In app.d.ts and firebase.d.ts the function credential return a Promise, but when i compile the application i have this error in console: " the function .then() missing".
In the firebase-js-sdk the function "credential" return firebase.auth.AuthCredential ?
static credential (verificationId : string , verificationCode : string ) : firebase.Promise < any > ;
==>
static credential (verificationId : string , verificationCode : string ) : firebase.auth.AuthCredential ;
Is a goog solution?
Thank you!
Add a source map to the doc generation process so that reference docs can link directly into source files for each function/constant/etc.
According to the documentation, the nextOrObserver
parameter for the firebase.storage.UploadTask#on
method should accept an observer with only some of the methods: next
, complete
, and error
.
That means this should be allowed:
uploadTask.on(TaskEvent.STATE_CHANGED, {
next: (snapshot) => { console.log(snapshot); },
error: (err) => { console.error(err); }
});
This, though, raises the following error: TypeError: Cannot read property 'bind' of undefined
since observer.complete
is undefined
. Relevant code here.
Currently, the only workaround besides providing an actual method is this:
uploadTask.on(TaskEvent.STATE_CHANGED, {
next: (snapshot) => { console.log(snapshot); },
error: (err) => { console.error(err); },
complete: null
});
See JS Bin link below.
What happened? How can we make the problem occur?
This could be a description, log/console output, etc.
On signInWithPopup via Google provider in Chrome 58.0.3029.110 (64-bit), signin popup displays no content (white page at about:blank) and then closes with a message in the console.
Sigin error N {code: "auth/network-request-failed", message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred."}
__stack_frame_overlay_proxy_console__ @ proxyConsole.js:43
(anonymous) @ App.js:96
e.lb @ auth.js:49
Ad @ auth.js:52
wd @ auth.js:52
A.Re @ auth.js:51
Xc @ auth.js:43
auth.js:157 Uncaught Error: Network Error
at auth.js:157
This persists for my Chrome profile both with locally hosted instance and deployed copy of the app. It works normally in Safari and Firefox, so far. It also works (at least initially) in incognito mode for fresh launches, but it has occurred in incognito mode.
I have tried removing local storage, clearing cache, disabling cache via devtools, all with no luck. Something appears to be stored somewhere and is preventing google auth from loading correctly, or even launching the URL for auth.
ReactJS (15.5.4) application, with firebase initialized in componentDidMount(). Signin button onClick:
signIn() {
const provider = new firebase.auth.GoogleAuthProvider();
this.firebase.auth().signInWithPopup(provider)
.then((result) => console.log('Signin result', result))
.catch((error) => console.error('Sigin error', error));
}
The catch triggers providing the error seen above.
I've verified that the initialization params are same as provided in the firebase console (though I felt they were ok due to it working in other browsers etc).
Hello,
In order to minimize load time, I am trying to build an web-app where I do not include all js files at startup time. Rather, I gradually download the different firebase-js files on a need to have basis.
I only need to interact with the firbase-database after the user has been authenticated. so initially I only includefirebase-app.js
and firebase-auth.js
.
After the user had been successfully logged in, I download firebase-database.js
and start interacting with the real-time database.
My problem is that I am getting an error:
firebase.database() takes either no argument or a Firebase App instance.
I believe the above error is caused as I call firebase.initializeApp(config);
before firebase-database.js
is available. Note, that the exception is only thrown when I try to use firebase.database!
I guess it should not be too hard to allow for gradual firebase initialization. For instance, only initializing with the databaseURL after some time (i.e. after firebase-database.js is available).
PS: Obviously, my web-app works without problem if I do include/download all necessary js files at startup (firebase-app.js
, firebase-auth.js
and firebase-database.js
)
The problem can be observed by using a Chrome broswer version 58+ in any iOS 10.3.+, the first time the issue was observed were in April 10. Basically i'm getting a console.error that is hapenning only in this specific environment. The error message is as follows:
Blocked a frame with origin "https://superpouco.com.br" from accessing a frame with origin "https://superpouco.firebaseapp.com". Protocols, domains, and ports must match.
Where "superpouco" is the domain i'm currently using, the issue also appears in another app under another domain that is using the same app with firebase.
I couldn't find anything related to this issue online so I wonder if it might be how I set the application or if it is due to the fact that it's hapenning in a very very specific scenario.
Basically accessing the app using Chrome version in the iOS described version.
It seems that currently, it is not possible to contribute to the Auth module.
Unless I missed something in my findings, as can be seen at auth.build.js.
The whole of Auth module is already checked in in a post build file.
Thus creating PRs to improve this module is impossible at the moment.
The Auth module is one of the greatest features of Firebase and It a shame that the community can't contribute to improve this important piece of Firebase.
My request is simply to allow a way to contribute to the original pre-built file.
Would very appreciate your feedback on this matter,
Thanks!
Cross Posting from #26
I writing some unit for React with the Jest unit test framework but I got the following error while
TypeError: _firebase2.default.storage is not a functionHere the stacktrace :
` FAIL src/components/organisms/PriceSettingsBlock/PriceSettingsBlock.test.js
โ Test suite failed to runTypeError: _firebase2.default.storage is not a function
at Object. (src/core/firebase/firebase.js:8:120)
at Object. (src/core/firebase/firebase-list.js:1:815)
at Object. (src/core/chat/eventList.js:30:77)
at Object. (src/core/chat/sagas.js:4:44)
at Object. (src/core/chat/index.js:2:62)
at Object. (src/core/init/sagas.js:3:39)
at Object. (src/core/init/index.js:1:387)
at Object. (src/components/organisms/PriceSettingsBlock/PriceSettingsBlock.js:6:39)
at Object. (src/components/organisms/PriceSettingsBlock/PriceSettingsBlock.test.js:4:53)
at handle (node_modules/worker-farm/lib/child/index.js:41:8)
at process. (node_modules/worker-farm/lib/child/index.js:47:3)
at emitTwo (events.js:106:13)
at process.emit (events.js:194:7)
at process.nextTick (internal/child_process.js:766:12)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)`
Test file is here :
PriceSettingsBlock.js.txt
PriceSettingsBlock.test.js.txtMy configuration is here:
`import firebase from 'firebase';
import { firebaseConfig } from './config';export const firebaseApp = firebase.initializeApp(firebaseConfig);
export const firebaseAuth = firebaseApp.auth();
export const firebaseDb = firebaseApp.database();
// firebase.storage() seems to be null
export const firebaseStorage = firebase.storage();`And my configuration ( config.js):
export const firebaseConfig = {
apiKey: 'my api key',
authDomain: 'my-project-id.firebaseapp.com',
databaseURL: 'https://my-project-id.firebaseio.com',
projectId: 'my-project-id',
storageBucket: 'my-project-id.appspot.com',
messagingSenderId: 'my-sender-id'
};Any idea ?
@jshcrowthe I have create a new project with create-react-app:
https://github.com/ataliadvanstep/firebase-jest
Just clone the project and run npm test
Using the name of any Object.prototype
member as an app name causes issues when trying to initialize or retrieve an app.
// Here we get an error saying there already is a "valueOf" app
try {
firebase.initializeApp(options, 'valueOf');
} catch (err) {
console.error(err.code + ' - ' + err.message);
}
// This simply returns the Object.prototype.toString method
const app = firebase.app('toString');
console.log(app);
JSBin reproducing these issues: http://jsbin.com/cohijesema/edit?js,console
Not sure if this should be merged into #6 or treated separately, but I have a few related feature requests:
Better integration with urish/firebase-server. It technically mostly works, but having to use 127.0.1
as the address (or edit /etc/hosts
) seems like an unnecessary hack.
Greater involvement from the Firebase team in firebase-server development (to at least get it feature compatible with the production Firebase environment) or a first-party replacement.
Support for locally testing Firebase Storage. At the very least, an equivalent to FirebaseOptions .databaseURL
for Storage that would allow me to pass in http://my-gcloud-dev_appserver/_ah/gcs
would be very useful.
I implemented Google Sign-In using Firebase Auth by following the instructions here. https://firebase.google.com/docs/auth/web/google-signin. I used .signInWithPopup(provider)
. Everything seems to work, except after entering my gmail and password, I am redirected to https://mysite.com/__auth/handler, rather than back to the page I was on on my site. Is this the expected behavior?
Follow the implementation described at https://firebase.google.com/docs/auth/web/google-signin under To sign in by redirecting to the sign-in page, call signInWithRedirect
_googleSignIn() {
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(provider).then(function(result) {
console.log('Sign in finished');
console.log(result);
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
console.log(error);
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
}
Using a query with orderByChild()
and startAt(null, 'some-key')
, I expect the results to be returned starting with the record with key 'some-key'
, however returned results start at the very first item to match any given filter.
Start with this data:
{
"products" : {
"-KlsqFgVWwUrA-j0VsZS" : {
"name" : "Product 4",
"price" : 666
},
"-Klst-cLSckuwAuNAJF8" : {
"name" : "Product 1",
"price" : 100
},
"-Klst7IINdt8YeMmauRz" : {
"name" : "Product 2",
"price" : 50
},
"-Klst9KfM2QWp8kXrOlR" : {
"name" : "Product 6",
"price" : 30
},
"-KlstB51ap1L2tcK8cL6" : {
"name" : "Product 5",
"price" : 99
},
"-KlstDR5cCayGH0XKtZ0" : {
"name" : "Product 3",
"price" : 500
}
}
}
I retrieve the first three matching records from this list using this code:
firebase.database().ref('products')
.orderByChild('price')
.limitToFirst(3)
.on('child_added', function (snapshot) {
var key = snapshot.key;
var data = snapshot.val();
console.log(key + ': ' + JSON.stringify(data))
})
Using the key of the 3rd record, I try to retrieve records number 3-5:
firebase.database().ref('products')
.orderByChild('price')
.startAt(null, '-KlstB51ap1L2tcK8cL6') // this is the key of the 3rd matching record.
.limitToFirst(3)
.on('child_added', function (snapshot) {
var key = snapshot.key;
var data = snapshot.val();
console.log(key + ': ' + JSON.stringify(data))
})
Unfortunately this returns the first 3 items again.
However, if I remove the line .orderByChild('price')
, then I am able to use .startAt()
to retrieve items starting at the given record, which is very weird, because the default ordering is .orderByKey()
, which is not supposed to support startAt's 2nd parameter according to the documentation, and also according to the source code
When creating two Firebase database queries, it'd be nice if we could compare said refs for equivalence, like so:
let x = firebase.database().ref('/items').orderByValue();
let y = firebase.database().ref('/items').orderByValue();
x.equiv(y) // => true
The use-case is for something like a React component that takes a Firebase ref as a prop. When we're passed a Firebase reference that's functionally different from the previous ref, we want to unsubscribe from the old ref and start listening to the new one. But if the new ref is essentially the same as (but necessarily ===
to) the old one, we want to avoid the overhead of unsubscribing and resubscribing.
It appears that the client is bundled via webpack and uses the CommonsChunkPlugin
. My code is also bundled via webpack uses the same plugin. As a result my code defines webpackJsonp
on the window and then later when I load Firebase from the CDN it tries to use my webpackJsonp
function which won't work because they are different bundles.
<!-- My Wepback bundles -->
<script src="/assets/bundle/common.js"></script>
<script src="/assets/bundle/app.js"></script>
<!-- Firebase -->
<!-- (throws an error) -->
<script src="https://www.gstatic.com/firebasejs/4.1.1/firebase.js"></script>
Firebase should change the name of the jsonp function used to something like webpackJsonpFirebase
to avoid conflicts.
https://webpack.js.org/configuration/output/#output-jsonpfunction
This needs to be changed if multiple webpack runtimes (from different compilation) are used on the same webpage.
firebase-js-sdk/gulp/tasks/build.js
Line 139 in 4a96189
ionic start MyApp blank
cd MyApp
npm install firebase --save
Error:
Cannot read property 'find' of undefined
Complete Log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'firebase',
1 verbose cli '--save' ]
2 info using [email protected]
3 info using [email protected]
4 silly install loadCurrentTree
5 silly install readLocalPackageData
6 http fetch GET 200 https://registry.npmjs.org/firebase 18ms (from cache)
7 silly pacote tag manifest for firebase@latest fetched in 41ms
8 silly install loadIdealTree
9 silly install cloneCurrentTreeToIdealTree
10 silly install loadShrinkwrap
11 silly install loadAllDepsIntoIdealTree
12 silly resolveWithNewModule [email protected] checking installable status
13 http fetch GET 200 https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz 15ms (from cache)
14 silly pacote remote manifest for base64url@https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz fetched in 32ms
15 http fetch GET 200 https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz 3ms (from cache)
16 silly pacote remote manifest for buffer-equal-constant-time@https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz fetched in 10ms
17 http fetch GET 200 https://registry.npmjs.org/dom-storage/-/dom-storage-2.0.2.tgz 5ms (from cache)
18 silly pacote remote manifest for dom-storage@https://registry.npmjs.org/dom-storage/-/dom-storage-2.0.2.tgz fetched in 10ms
19 http fetch GET 200 https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.9.tgz 5ms (from cache)
20 silly pacote remote manifest for ecdsa-sig-formatter@https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.9.tgz fetched in 13ms
21 http fetch GET 200 https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.9.3.tgz 2ms (from cache)
22 silly pacote remote manifest for faye-websocket@https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.9.3.tgz fetched in 14ms
23 http fetch GET 200 https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz 2ms (from cache)
24 silly pacote remote manifest for hoek@https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz fetched in 9ms
25 http fetch GET 200 https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz 3ms (from cache)
26 silly pacote remote manifest for isemail@https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz fetched in 17ms
27 http fetch GET 200 https://registry.npmjs.org/joi/-/joi-6.10.1.tgz 3ms (from cache)
28 silly pacote remote manifest for joi@https://registry.npmjs.org/joi/-/joi-6.10.1.tgz fetched in 20ms
29 http fetch GET 200 https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-7.4.1.tgz 4ms (from cache)
30 silly pacote remote manifest for jsonwebtoken@https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-7.4.1.tgz fetched in 34ms
31 http fetch GET 200 https://registry.npmjs.org/jwa/-/jwa-1.1.5.tgz 2ms (from cache)
32 silly pacote remote manifest for jwa@https://registry.npmjs.org/jwa/-/jwa-1.1.5.tgz fetched in 5ms
33 http fetch GET 200 https://registry.npmjs.org/jws/-/jws-3.1.4.tgz 4ms (from cache)
34 silly pacote remote manifest for jws@https://registry.npmjs.org/jws/-/jws-3.1.4.tgz fetched in 9ms
35 http fetch GET 200 https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz 2ms (from cache)
36 silly pacote remote manifest for lodash.once@https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz fetched in 5ms
37 http fetch GET 200 https://registry.npmjs.org/moment/-/moment-2.18.1.tgz 3ms (from cache)
38 silly pacote remote manifest for moment@https://registry.npmjs.org/moment/-/moment-2.18.1.tgz fetched in 40ms
39 http fetch GET 200 https://registry.npmjs.org/ms/-/ms-2.0.0.tgz 3ms (from cache)
40 silly pacote remote manifest for ms@https://registry.npmjs.org/ms/-/ms-2.0.0.tgz fetched in 6ms
41 http fetch GET 200 https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-6.0.2.tgz 2ms (from cache)
42 silly pacote remote manifest for promise-polyfill@https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-6.0.2.tgz fetched in 6ms
43 verbose stack TypeError: Cannot read property 'find' of undefined
43 verbose stack at opts.integrity.digests.find.hash (C:\Program Files\nodejs\node_modules\npm\node_modules\ssri\index.js:262:33)
43 verbose stack at Array.find (native)
43 verbose stack at Transform.on (C:\Program Files\nodejs\node_modules\npm\node_modules\ssri\index.js:261:15)
43 verbose stack at emitNone (events.js:110:20)
43 verbose stack at Transform.emit (events.js:207:7)
43 verbose stack at endReadableNT (_stream_readable.js:1045:12)
43 verbose stack at _combinedTickCallback (internal/process/next_tick.js:102:11)
43 verbose stack at process._tickCallback (internal/process/next_tick.js:161:9)
44 verbose cwd C:\Users\andre\dev\remindr
45 verbose Windows_NT 10.0.15063
46 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "firebase" "--save"
47 verbose node v8.0.0
48 verbose npm v5.0.0
49 error Cannot read property 'find' of undefined
50 verbose exit [ 1, true ]
What happened? How can we make the problem occur?
This could be a description, log/console output, etc.
// TODO(you): code here to reproduce the problem
When using firebase.auth.signInWithPopup(provider) a new tab is created with the auth instead of creating a popup as it did in Chrome 58 and earlier.
https://stackoverflow.com/questions/44417724/facebook-authentication-opening-tab-instead-of-popup-in-chrome-59 seems to say that the parameter 'location=no' needs to be passed in window.open(), but this is not accessible using the SDK.
Create an auth button with signInWithPopup() and click on it. A new tab will pop up instead of a new popup window.
This link describes the problem perfectly.
It seems that remote config is only available in the ios, and, c++ and unity sdk.
Could it be possible to implement it in the js sdk as well.
I think having the A/B Testing feature using some analytics for segmentation would be very nice.
I see few project that tried to create some workaround like: cordova-plugin-firebase-remoteconfig and react-native-firestack but I think the right place is in the sdk itself.
Some people where requesting this feature last year already ( https://stackoverflow.com/questions/38321012/firebase-remote-config-feature-for-web-app-after-firebase-expansion ).
What is the problem with adding this feature to the js sdk ?
In certain scenarios, it could be useful to authenticate a firebase.app.App
with a token obtained via firebase.User#getToken()
from another App, when both Apps are initialized against the same Firebase project.
My use case for this is as follows: when a certain event happens, I want to close the connection to the database to stop receiving any new updates from whatever listeners I have attached, but I still need to listen to a particular location in the database that will alert me when I need to connect again.
At the moment there's no way to authenticate a second App with the same token/credentials already present in the current App. The only way to achieve this right now would be to either ask the user to reauthenticate when initializing the second App, or to initialize and authenticate both Apps at the same time when the user logs in.
Related firebase-talk discussion: https://groups.google.com/forum/#!msg/firebase-talk/X5ry98EfK-w/8TnY2i8rCgAJ
n/a
A possible solution would be to introduce a new firebase.auth.Auth#signInWithIdToken()
method which would allow to do the following:
const options = {/* ... */};
const app1 = firebase.initializeApp(options, 'app1');
const app2 = firebase.initializeApp(options, 'app2');
// Let's assume "app1" is already authenticated
app1.auth().currentUser.getIdToken().then(token => app2.auth().signInWithIdToken(token));
Alternatively, a new IdTokenAuthProvider
could be introduced, allowing to authenticate with the already existing firebase.auth.Auth#signInWithCredential()
:
const options = {/* ... */};
const app1 = firebase.initializeApp(options, 'app1');
const app2 = firebase.initializeApp(options, 'app2');
// Let's assume "app1" is already authenticated
app1.auth().currentUser.getIdToken().then(token => {
const cred = firebase.auth.IdTokenAuthProvider.credential(token);
app2.auth().signInWithCredential(cred);
});
Introducing a new AuthProvider
for this might be confusing for the end-user though, so my preferred solution would be signInWithIdToken
.
Sending a message with notification
payload never triggers the setBackgroundMessageHandler
callback.
The guide (but not the reference) hint at this behaviour: "If you set notification fields [...] those values take precedence over any values specified in the service worker."
This makes it impossible to intercept the message if notification
fields are set.
Use case: we are sending additional fields in data
but are not able to access and use them. We also can't modify the notification
fields before displaying them to the user.
Send a message with notification
data. The callback of setBackgroundMessageHandler
is never called.
We use firebase js sdk inside of an iframe element.
That work for almost case but not work for desktop safari(ver 10.0.2).
In specific,
<!doctype html>
<html>
<head>
</head>
<body>
<script>
const iframe = document.body.appendChild(document.createElement('iframe'));
iframe.onload = () => {
const doc = iframe.contentDocument;
doc.open();
doc.writeln('<!doctype html>');
doc.writeln('<head>');
doc.writeln(`<script src="https://www.gstatic.com/firebasejs/4.0.0/firebase.js"></s` + `cript>`);
doc.writeln(`<script>firebase.initializeApp({apiKey: "API_KEY",authDomain: "AUTH_DOMAIN",databaseURL: "DATABASE_URL",storageBucket: "BUCKET"});</s` + `cript>`);
doc.writeln(`<script>firebase.database().ref('DATABASE_URL').on('value', () => {})</s` + `cript>`);
doc.writeln('</head>');
doc.writeln('<body>');
doc.writeln('<a href="https://www.google.com" target="_top">go to google</a>')
doc.writeln('</body>');
doc.close();
}
iframe.src = 'javascript:false';
</script>
</body>
</html>
In above example, link to google is worked expected, but if more than 3 or more tab opened, link to google is not accessible or iframe is disappeared.
http://jsbin.com/rinilu/edit?js,console
// TODO(you): code here to reproduce the problem
We currently don't have a very good local development workflow for the SDK.
I'd like to add some of the following:
gulp dev
experience (integrated with the above point?)
What happened? How can we make the problem occur?
This could be a description, log/console output, etc.
// TODO(you): code here to reproduce the problem
I would like to create a custom token using createCustomToken()
, and then I need to make
a REST call using the API like :
http://firebase....com/.json?auth=<ACCESS_TOKEN>
OR
http://firebase....com/.json?access_token=<ACCESS_TOKEN>
(I've tried both)
I am always getting 401, even when there are no rules on the firebase node I'm trying to reach (unprotected).
use the SDK to create a custom token
take this token and attempt to make a REST call to some firebase node
const accessToken = await firebaseAdmin.auth().createCustomToken("SomeIssuer", { scopes: "SomeScope" });
const axiousReq = await axios.get('http://firebase....com/.json?access_token=' + accessToken);
signInWithCustomToken
https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=MYAPIKEY
With the following payload:
{
"token" : "my_custom_jwt_returned_from_server",
"returnSecureToken" : true
}
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
function (user, context, callback) {
var admin = require("firebase-admin");
var serviceAccount = {
projectId: "my-fb-project",
privateKey: "-----BEGIN PRIVATE KEY-----\nMYKEY\n-----END PRIVATE KEY-----\n",
clientEmail: "[email protected]"
};
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://my-fb-account.firebaseio.com"
});
var uid = "some-uid";
admin.auth().createCustomToken(uid)
.then(function(customToken) {
user.user_metadata = user.user_metadata || {};
user.user_metadata.fbtoken = customToken;
return callback(null, user, context);
})
.catch(function(error) {
console.log("Error creating custom token:", error);
return callback(error, user, context);
});
}
Is there a way to verify the token manually to see if it is indeed correct? When I put the token this function returns into jwt.io everything looks fine, but obviously something is failing. How can I attempt to validate it the same way the service: https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=MYAPIKEY
We provide an error class (FirebaseError
) that we should be using cross SDK to be more consistent with our Error reporting.
n/a
All error implementatinos
I need to display information to the contrary.
firebase.database()
.ref('users')
.on('value')
.then(snapshot => {
// Object.keys(snapshot).reverse().forEach( ... )
// snapshot.reverse().forEach( ... )
snapshot.forEach(childSnapshot => {
const key = childSnapshot.key;
const childData = childSnapshot.val();
console.log(key, childData.name);
// xxx, a1
// xxx, a2
// xxx, a3
// Expectation:
// xxx, a3
// xxx, a2
// xxx, a1
});
});
Firebase messaging doesn't work with latest npm package. It throws:
TypeError: fetch is not a function
at WindowController.manifestCheck_ (window-controller.js?:149)
at WindowController.getToken (window-controller.js?:125)
Exact line in code is here
Install latest firebase package from npm. Follow tutorial given here.
firebase.initializeApp(opts);
const messaging = firebase.messaging();
messaging.requestPermission()
.then(function() {
console.log('Notification permission granted.');
return messaging.getToken()
.then((currentToken) => {
if (currentToken) {
console.log("Token is: " + currentToken)
} else {
// you don't have permission to show notifications
// detect whether they are blocked or not, then show your custom UI
}
})
.catch((err) => {
console.log("Error to get token is: " + err);
// retrieving token failed, analyze the error
});
})
.catch(function(err) {
console.log('Unable to get permission to notify.', err);
});
'/__/firebase/init.js'
These steps do not play well with polymerfire or angularfire. The user still needs to declare the config properties either directly or by setting up their own secrets.
var _isFirebaseHosted = fetch('/__/firebase/init.js').then(response => {
if (response.status == 200) {
return true;
}
return false;
});
if (_isFirebaseHosted) {
firebase.initializeApp('/__/firebase/init.js');
}
Hello,
I'm attempting to write a large amount of data to Firebase in a single write (I inspected the WS messages through Charles to make sure, meaning it is being sent in big chunks). There are some WebSocket errors in the console, data isn't written, and the error callback is not called.
I believe it is related to this bug: https://bugs.webkit.org/show_bug.cgi?id=170463
Errors:
Failed to send WebSocket frame.
Failed to send WebSocket frame.
INTERNAL ASSERT FAILED: sendRequest call when we're not connected not allowed.
When I run the sdk in a chrome app, I get csp errors when using the database. I see you have an example for chrome extensions (https://github.com/firebase/quickstart-js/tree/master/auth/chromextension), but since you can't set the content_security_policy in an chrome app's manifest.json, that example won't work for apps.
Here's an example of the error on stackoverflow: https://stackoverflow.com/questions/29399594/error-using-firebase-from-chrome-app
Refused to load the script 'https://{my firebase id}.firebaseio.com/.lp?start=t&ser=81980096&cb=15&v=5' because it violates the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
I want to solve the above issue but I also want to know why it's only using the https long_polling method for the database and not the websockets wss, which I normally see in my traditional web app. I don't see any reason you can't use wss in a chrome app and it might solve the above issue. It appears the sdk is not even trying to use websockets and just defaults to long polling.
It also seem you're using window.open somewhere which is also causing issues since it's not available in chrome apps.
In short, how can I use the sdk in a chrome app?
// using custom token
firebase.initializeApp(config);
firebase.auth().signInWithCustomToken(token);
// later on
firebase.database()
.ref(databaseRefPath())
.set(getRepresentation())
.catch(e=>this.log.w(`persist error: ${e}`));
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.