Skip to content

Commit e09043c

Browse files
committed
Fixing up for merge
1 parent 777c206 commit e09043c

File tree

11 files changed

+121
-63
lines changed

11 files changed

+121
-63
lines changed

common/api-review/util.api.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
55
```ts
66

7-
// Warning: (ae-missing-release-tag) "__PRIVATE_getDefaultEmulatorHost" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
8-
//
9-
// @public (undocumented)
10-
export const __PRIVATE_getDefaultEmulatorHost: (name: string) => string | undefined;
11-
127
// Warning: (ae-missing-release-tag) "areCookiesEnabled" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
138
//
149
// @public
@@ -203,17 +198,19 @@ export type FirebaseSignInProvider = 'custom' | 'email' | 'password' | 'phone' |
203198
// Warning: (ae-missing-release-tag) "getDefaultAppConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
204199
//
205200
// @public (undocumented)
206-
export const getDefaultAppConfig: () => Object | undefined;
201+
export const getDefaultAppConfig: () => Record<string, string> | undefined;
207202

208203
// Warning: (ae-missing-release-tag) "getDefaultEmulatorHost" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
209204
//
210205
// @public (undocumented)
211206
export const getDefaultEmulatorHost: (name: string) => string | undefined;
212207

208+
// Warning: (ae-forgotten-export) The symbol "ExperimentalKey" needs to be exported by the entry point index.d.ts
209+
// Warning: (ae-forgotten-export) The symbol "FirebaseDefaults" needs to be exported by the entry point index.d.ts
213210
// Warning: (ae-missing-release-tag) "getExperimentalSetting" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
214211
//
215212
// @public (undocumented)
216-
export const getExperimentalSetting: (name: string) => any;
213+
export const getExperimentalSetting: <T extends ExperimentalKey>(name: T) => FirebaseDefaults[`_${T}`];
217214

218215
// Warning: (ae-missing-release-tag) "getGlobal" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
219216
//

config/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ module.exports = {
129129
{
130130
// Check dependencies from both local package.json
131131
// and from root package.json.
132-
'packageDir': [path.join(__dirname, '../'), './'],
132+
'packageDir': [context.getFilename(), path.join(__dirname, '../'), './'],
133133
'devDependencies': [
134134
'**/*.test.ts',
135135
'**/test/**/*.ts',

packages/app/src/api.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function initializeApp(
115115
*
116116
* @public
117117
*/
118-
export function initializeApp(): FirebaseApp;
118+
export function initializeApp(): FirebaseApp;
119119
export function initializeApp(
120120
_options?: FirebaseOptions,
121121
rawConfig = {}
@@ -142,7 +142,9 @@ export function initializeApp(
142142

143143
options ||= getDefaultAppConfig();
144144

145-
if (!options) throw 'Need to provide options, when not being deployed to hosting via source.';
145+
if (!options) {
146+
throw ERROR_FACTORY.create(AppError.NO_OPTIONS);
147+
}
146148

147149
const existingApp = _apps.get(name) as FirebaseAppImpl;
148150
if (existingApp) {
@@ -200,7 +202,9 @@ export function initializeApp(
200202
*/
201203
export function getApp(name: string = DEFAULT_ENTRY_NAME): FirebaseApp {
202204
const app = _apps.get(name);
203-
if (!app && name === DEFAULT_ENTRY_NAME) return initializeApp();
205+
if (!app && name === DEFAULT_ENTRY_NAME) {
206+
return initializeApp();
207+
}
204208
if (!app) {
205209
throw ERROR_FACTORY.create(AppError.NO_APP, { appName: name });
206210
}

packages/app/src/errors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const enum AppError {
2222
BAD_APP_NAME = 'bad-app-name',
2323
DUPLICATE_APP = 'duplicate-app',
2424
APP_DELETED = 'app-deleted',
25+
NO_OPTIONS = 'no-options',
2526
INVALID_APP_ARGUMENT = 'invalid-app-argument',
2627
INVALID_LOG_ARGUMENT = 'invalid-log-argument',
2728
IDB_OPEN = 'idb-open',
@@ -38,6 +39,7 @@ const ERRORS: ErrorMap<AppError> = {
3839
[AppError.DUPLICATE_APP]:
3940
"Firebase App named '{$appName}' already exists with different options or config",
4041
[AppError.APP_DELETED]: "Firebase App named '{$appName}' already deleted",
42+
[AppError.NO_OPTIONS]: "Need to provide options, when not being deployed to hosting via source.",
4143
[AppError.INVALID_APP_ARGUMENT]:
4244
'firebase.{$appName}() takes either no argument or a ' +
4345
'Firebase App instance.',

packages/auth/src/platform_browser/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ import { browserPopupRedirectResolver } from './popup_redirect';
2727
import { Auth, User } from '../model/public_types';
2828
import { getDefaultEmulatorHost, getExperimentalSetting } from '@firebase/util';
2929

30-
const ID_TOKEN_MAX_AGE = 5 * 60;
30+
const DEFAULT_ID_TOKEN_MAX_AGE = 5 * 60;
31+
const authIdTokenMaxAge = getExperimentalSetting('authIdTokenMaxAge') || DEFAULT_ID_TOKEN_MAX_AGE;
3132

3233
let lastPostedIdToken: string|undefined|null = null;
3334

3435
const mintCookieFactory = (url:string) => async (user: User|null) => {
3536
const idTokenResult = user && await user.getIdTokenResult();
3637
const idTokenAge = idTokenResult && (new Date().getTime() - Date.parse(idTokenResult.issuedAtTime)) / 1_000;
37-
if (idTokenAge && idTokenAge > ID_TOKEN_MAX_AGE) return;
38+
if (idTokenAge && idTokenAge > authIdTokenMaxAge) return;
3839
// Specifically trip null => undefined when logged out, to delete any existing cookie
3940
const idToken = idTokenResult?.token;
4041
if (lastPostedIdToken === idToken) return;

packages/database/src/api/Database.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import { Provider } from '@firebase/component';
2727
import {
2828
getModularInstance,
2929
createMockUserToken,
30-
EmulatorMockTokenOptions
30+
EmulatorMockTokenOptions,
31+
getDefaultEmulatorHost
3132
} from '@firebase/util';
3233

3334
import { AppCheckTokenProvider } from '../core/AppCheckTokenProvider';
@@ -53,7 +54,10 @@ import { WebSocketConnection } from '../realtime/WebSocketConnection';
5354

5455
import { ReferenceImpl } from './Reference_impl';
5556

56-
export { EmulatorMockTokenOptions, getDefaultEmulatorHost } from '@firebase/util';
57+
export {
58+
EmulatorMockTokenOptions,
59+
getDefaultEmulatorHost
60+
} from '@firebase/util';
5761
/**
5862
* This variable is also defined in the firebase Node.js Admin SDK. Before
5963
* modifying this definition, consult the definition in:
@@ -321,7 +325,7 @@ export function getDatabase(
321325
}) as Database;
322326
const databaseEmulatorHost = getDefaultEmulatorHost('database');
323327
if (databaseEmulatorHost) {
324-
const [ host, port ] = databaseEmulatorHost.split(':');
328+
const [host, port] = databaseEmulatorHost.split(':');
325329
connectDatabaseEmulator(db, host, parseInt(port, 10));
326330
}
327331
return db;

packages/firestore/src/api/database.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
// eslint-disable-next-line import/no-extraneous-dependencies
1918
import {
2019
_getProvider,
2120
_removeServiceInstance,
@@ -43,7 +42,10 @@ import {
4342
setOnlineComponentProvider
4443
} from '../core/firestore_client';
4544
import { makeDatabaseInfo } from '../lite-api/components';
46-
import { Firestore as LiteFirestore } from '../lite-api/database';
45+
import {
46+
Firestore as LiteFirestore,
47+
connectFirestoreEmulator
48+
} from '../lite-api/database';
4749
import { Query } from '../lite-api/reference';
4850
import {
4951
indexedDbClearPersistence,
@@ -66,7 +68,6 @@ export {
6668
connectFirestoreEmulator,
6769
EmulatorMockTokenOptions
6870
} from '../lite-api/database';
69-
import { connectFirestoreEmulator } from '../lite-api/database';
7071

7172
declare module '@firebase/component' {
7273
interface NameServiceMapping {
@@ -153,9 +154,9 @@ export function initializeFirestore(
153154
throw new FirestoreError(
154155
Code.FAILED_PRECONDITION,
155156
'initializeFirestore() has already been called with ' +
156-
'different options. To avoid this error, call initializeFirestore() with the ' +
157-
'same options as when it was originally called, or call getFirestore() to return the' +
158-
' already initialized instance.'
157+
'different options. To avoid this error, call initializeFirestore() with the ' +
158+
'same options as when it was originally called, or call getFirestore() to return the' +
159+
' already initialized instance.'
159160
);
160161
}
161162
}
@@ -188,7 +189,7 @@ export function getFirestore(app: FirebaseApp = getApp()): Firestore {
188189
if (!db._initialized) {
189190
const firestoreEmulatorHost = getDefaultEmulatorHost('firestore');
190191
if (firestoreEmulatorHost) {
191-
const [ host, port ] = firestoreEmulatorHost.split(':');
192+
const [host, port] = firestoreEmulatorHost.split(':');
192193
connectFirestoreEmulator(db, host, parseInt(port, 10));
193194
}
194195
}
@@ -344,8 +345,8 @@ function setPersistenceProviders(
344345
}
345346
logWarn(
346347
'Error enabling offline persistence. Falling back to ' +
347-
'persistence disabled: ' +
348-
error
348+
'persistence disabled: ' +
349+
error
349350
);
350351
persistenceResult.reject(error);
351352
}
@@ -418,7 +419,7 @@ export function clearIndexedDbPersistence(firestore: Firestore): Promise<void> {
418419
throw new FirestoreError(
419420
Code.FAILED_PRECONDITION,
420421
'Persistence can only be cleared before a Firestore instance is ' +
421-
'initialized or after it is terminated.'
422+
'initialized or after it is terminated.'
422423
);
423424
}
424425

@@ -570,8 +571,8 @@ function verifyNotInitialized(firestore: Firestore): void {
570571
throw new FirestoreError(
571572
Code.FAILED_PRECONDITION,
572573
'Firestore has already been started and persistence can no longer be ' +
573-
'enabled. You can only enable persistence before calling any other ' +
574-
'methods on a Firestore object.'
574+
'enabled. You can only enable persistence before calling any other ' +
575+
'methods on a Firestore object.'
575576
);
576577
}
577578
}

packages/firestore/src/lite-api/database.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import {
2222
FirebaseApp,
2323
getApp
2424
} from '@firebase/app';
25-
import { createMockUserToken, EmulatorMockTokenOptions, getDefaultEmulatorHost } from '@firebase/util';
25+
import {
26+
createMockUserToken,
27+
EmulatorMockTokenOptions,
28+
getDefaultEmulatorHost
29+
} from '@firebase/util';
2630

2731
import {
2832
CredentialsProvider,
@@ -44,6 +48,8 @@ import {
4448
FirestoreSettings
4549
} from './settings';
4650

51+
export { EmulatorMockTokenOptions } from '@firebase/util';
52+
4753
declare module '@firebase/component' {
4854
interface NameServiceMapping {
4955
'firestore/lite': Firestore;
@@ -215,14 +221,13 @@ export function getFirestore(app: FirebaseApp = getApp()): Firestore {
215221
if (!db._initialized) {
216222
const firestoreEmulatorHost = getDefaultEmulatorHost('firestore');
217223
if (firestoreEmulatorHost) {
218-
const [ host, port ] = firestoreEmulatorHost.split(':');
224+
const [host, port] = firestoreEmulatorHost.split(':');
219225
connectFirestoreEmulator(db, host, parseInt(port, 10));
220226
}
221227
}
222228
return db;
223229
}
224230

225-
export { EmulatorMockTokenOptions } from '@firebase/util';
226231
/**
227232
* Modify this instance to communicate with the Cloud Firestore emulator.
228233
*

packages/functions/src/api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export function getFunctions(
5353
});
5454
const functionsEmulatorHost = getDefaultEmulatorHost('functions');
5555
if (functionsEmulatorHost) {
56-
const [ host, port ] = functionsEmulatorHost.split(':');
56+
const [host, port] = functionsEmulatorHost.split(':');
57+
// eslint-disable-next-line no-restricted-globals
5758
connectFunctionsEmulator(functionsInstance, host, parseInt(port, 10));
5859
}
5960
return functionsInstance;

packages/storage/src/api.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
// eslint-disable-next-line import/no-extraneous-dependencies
1817
import { _getProvider, FirebaseApp, getApp } from '@firebase/app';
1918

2019
import {
@@ -51,7 +50,11 @@ import {
5150
getBytesInternal
5251
} from './reference';
5352
import { STORAGE_TYPE } from './constants';
54-
import { EmulatorMockTokenOptions, getModularInstance, getDefaultEmulatorHost } from '@firebase/util';
53+
import {
54+
EmulatorMockTokenOptions,
55+
getModularInstance,
56+
getDefaultEmulatorHost
57+
} from '@firebase/util';
5558
import { StringFormat } from './implementation/string';
5659

5760
export { EmulatorMockTokenOptions } from '@firebase/util';
@@ -333,7 +336,8 @@ export function getStorage(
333336
});
334337
const storageEmulatorHost = getDefaultEmulatorHost('storage');
335338
if (storageEmulatorHost) {
336-
const [ host, port ] = storageEmulatorHost.split(':');
339+
const [host, port] = storageEmulatorHost.split(':');
340+
// eslint-disable-next-line no-restricted-globals
337341
connectStorageEmulator(storageInstance, host, parseInt(port, 10));
338342
}
339343
return storageInstance;

0 commit comments

Comments
 (0)