Skip to content

Commit d3229fa

Browse files
committed
Fix a couple emulator related issues
1 parent 4cc1a83 commit d3229fa

File tree

8 files changed

+109
-4
lines changed

8 files changed

+109
-4
lines changed

packages/auth/demo/.gitignore

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
firebase-debug.log*
8+
firebase-debug.*.log*
9+
10+
# Firebase cache
11+
.firebase/
12+
13+
# Firebase config
14+
15+
# Uncomment this if you'd like others to create their own Firebase project.
16+
# For a team working on the same Firebase project(s), it is recommended to leave
17+
# it commented so all members can deploy to the same project(s) in .firebaserc.
18+
# .firebaserc
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
32+
# nyc test coverage
33+
.nyc_output
34+
35+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
36+
.grunt
37+
38+
# Bower dependency directory (https://bower.io/)
39+
bower_components
40+
41+
# node-waf configuration
42+
.lock-wscript
43+
44+
# Compiled binary addons (http://nodejs.org/api/addons.html)
45+
build/Release
46+
47+
# Dependency directories
48+
node_modules/
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Optional REPL history
57+
.node_repl_history
58+
59+
# Output of 'npm pack'
60+
*.tgz
61+
62+
# Yarn Integrity file
63+
.yarn-integrity
64+
65+
# dotenv environment variables file
66+
.env

packages/auth/demo/firebase.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,22 @@
1010
"function": "checkIfAuthenticated"
1111
}
1212
]
13+
},
14+
"emulators": {
15+
"auth": {
16+
"port": 9099
17+
},
18+
"functions": {
19+
"port": 5001
20+
},
21+
"database": {
22+
"port": 9000
23+
},
24+
"hosting": {
25+
"port": 5000
26+
},
27+
"ui": {
28+
"enabled": true
29+
}
1330
}
1431
}

packages/auth/demo/public/sample-config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ var config = {
2121
storageBucket: "your-app.appspot.com",
2222
messagingSenderId: "MESSAGING_SENDER_ID"
2323
};
24+
25+
// Uncomment the following line to use with emulator
26+
// var emulatorUrl = 'http://localhost:9099';

packages/auth/demo/public/script.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,12 +1623,18 @@ function initApp(){
16231623
log('Initializing app...');
16241624
app = firebase.initializeApp(config);
16251625
auth = app.auth();
1626+
if (emulatorUrl) {
1627+
auth.useEmulator(emulatorUrl);
1628+
}
16261629

16271630
tempApp = firebase.initializeApp({
16281631
'apiKey': config['apiKey'],
16291632
'authDomain': config['authDomain']
16301633
}, auth['app']['name'] + '-temp');
16311634
tempAuth = tempApp.auth();
1635+
if (emulatorUrl) {
1636+
tempAuth.useEmulator(emulatorUrl);
1637+
}
16321638

16331639
// Listen to reCAPTCHA config togglers.
16341640
initRecaptchaToggle(function(size) {

packages/auth/demo/public/service-worker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ self.addEventListener('install', function(event) {
9191
});
9292

9393
// As this is a test app, let's only return cached data when offline.
94-
self.addEventListener('fetch', function(event) {
94+
self.addEventListener('fetch', function (event) {
9595
var fetchEvent = event;
9696
var requestProcessor = function(idToken) {
9797
var req = event.request;
@@ -154,7 +154,10 @@ self.addEventListener('fetch', function(event) {
154154
event.respondWith(getIdToken().then(requestProcessor, requestProcessor));
155155
});
156156

157-
self.addEventListener('activate', function(event) {
157+
self.addEventListener('activate', function (event) {
158+
if (emulatorUrl) {
159+
firebase.auth().useEmulator(emulatorUrl);
160+
}
158161
// Update this list with all caches that need to remain cached.
159162
var cacheWhitelist = ['cache-v1'];
160163
event.waitUntil(caches.keys().then(function(cacheNames) {

packages/auth/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@firebase/auth-types": "0.10.1"
2626
},
2727
"devDependencies": {
28+
"firebase-tools": "8.11.2",
2829
"google-closure-compiler": "20200112.0.0",
2930
"google-closure-library": "20200224.0.0",
3031
"gulp": "4.0.2",

packages/auth/src/auth.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ fireauth.Auth.prototype.useEmulator = function(url) {
304304
// Persist the config.
305305
this.emulatorConfig_ = { url };
306306
// Disable app verification.
307-
this.settings.setAppVerificationDisabledForTesting(true);
307+
this.settings_().setAppVerificationDisabledForTesting(true);
308308
// Update RPC handler endpoints.
309309
this.rpcHandler_.updateEmulatorConfig(this.emulatorConfig_);
310310
// Notify external event listeners.
@@ -1793,6 +1793,15 @@ fireauth.Auth.prototype.app_ = function() {
17931793
};
17941794

17951795

1796+
/**
1797+
* @return {!fireauth.AuthSettings} The settings for this Auth object.
1798+
* @private
1799+
*/
1800+
fireauth.Auth.prototype.settings_ = function () {
1801+
return this['settings'];
1802+
};
1803+
1804+
17961805
/**
17971806
* @return {!fireauth.RpcHandler} The RPC handler.
17981807
*/

packages/auth/test/iframeclient/ifchandler_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ function testIfcHandler() {
520520
asyncTestCase.waitForSignals(6);
521521
// The expected iframe URL.
522522
var expectedUrl = fireauth.iframeclient.IfcHandler.getAuthIframeUrl(
523-
authDomain, apiKey, appName, version, ignoreArgument);
523+
authDomain, apiKey, appName, version);
524524
var authEvent = new fireauth.AuthEvent(
525525
'unknown', '1234', 'http://www.example.com/#oauthResponse', 'SESSION_ID');
526526
var resp = {

0 commit comments

Comments
 (0)