Skip to content

Commit 044732a

Browse files
committed
Formatting
1 parent 994acee commit 044732a

33 files changed

+418
-346
lines changed

packages-exp/auth-compat-exp/src/auth.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class Auth
134134
_assert(
135135
_isPopupRedirectSupported(),
136136
this.auth,
137-
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED,
137+
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED
138138
);
139139
const credential = await impl.getRedirectResult(
140140
this.auth,
@@ -272,7 +272,7 @@ export class Auth
272272
_assert(
273273
_isPopupRedirectSupported(),
274274
this.auth,
275-
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED,
275+
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED
276276
);
277277
return convertCredential(
278278
this.auth,
@@ -287,7 +287,8 @@ export class Auth
287287
_assert(
288288
_isPopupRedirectSupported(),
289289
this.auth,
290-
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED);
290+
impl.AuthErrorCode.OPERATION_NOT_SUPPORTED
291+
);
291292
this.savePersistenceForRedirect();
292293
return impl.signInWithRedirect(
293294
this.auth,

packages-exp/auth-compat-exp/src/persistence.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ export function _validatePersistenceArgument(
3737
_assert(
3838
Object.values(Persistence).includes(persistence),
3939
auth,
40-
AuthErrorCode.INVALID_PERSISTENCE,
40+
AuthErrorCode.INVALID_PERSISTENCE
4141
);
4242
// Validate if the specified type is supported in the current environment.
4343
if (isReactNative()) {
4444
// This is only supported in a browser.
4545
_assert(
4646
persistence !== Persistence.SESSION,
4747
auth,
48-
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
48+
AuthErrorCode.UNSUPPORTED_PERSISTENCE
4949
);
5050
return;
5151
}
@@ -54,7 +54,7 @@ export function _validatePersistenceArgument(
5454
_assert(
5555
persistence === Persistence.NONE,
5656
auth,
57-
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
57+
AuthErrorCode.UNSUPPORTED_PERSISTENCE
5858
);
5959
return;
6060
}
@@ -65,14 +65,14 @@ export function _validatePersistenceArgument(
6565
persistence === Persistence.NONE ||
6666
(persistence === Persistence.LOCAL && isIndexedDBAvailable()),
6767
auth,
68-
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
68+
AuthErrorCode.UNSUPPORTED_PERSISTENCE
6969
);
7070
return;
7171
}
7272
// This is restricted by what the browser supports.
7373
_assert(
7474
persistence === Persistence.NONE || _isWebStorageSupported(),
7575
auth,
76-
AuthErrorCode.UNSUPPORTED_PERSISTENCE,
76+
AuthErrorCode.UNSUPPORTED_PERSISTENCE
7777
);
7878
}

packages-exp/auth-exp/src/api/index.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818
import { FirebaseError, querystring } from '@firebase/util';
1919

20-
import {
21-
AuthErrorCode,
22-
NamedErrorParams,
23-
} from '../core/errors';
20+
import { AuthErrorCode, NamedErrorParams } from '../core/errors';
2421
import { _createError, _fail } from '../core/util/assert';
2522
import { Delay } from '../core/util/delay';
2623
import { _emulatorUrl } from '../core/util/emulator';
@@ -208,9 +205,7 @@ class NetworkTimeout<T> {
208205
private timer: any | null = null;
209206
readonly promise = new Promise<T>((_, reject) => {
210207
this.timer = setTimeout(() => {
211-
return reject(
212-
_createError(this.auth, AuthErrorCode.TIMEOUT)
213-
);
208+
return reject(_createError(this.auth, AuthErrorCode.TIMEOUT));
214209
}, DEFAULT_API_TIMEOUT_MS.get());
215210
});
216211

@@ -232,7 +227,7 @@ function makeTaggedError(
232227
response: PotentialResponse
233228
): FirebaseError {
234229
const errorParams: NamedErrorParams = {
235-
appName: auth.name,
230+
appName: auth.name
236231
};
237232

238233
if (response.email) {

packages-exp/auth-exp/src/core/auth/auth_event_manager.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ export class AuthEventManager implements EventManager {
9292
const code =
9393
(event.error.code?.split('auth/')[1] as AuthErrorCode) ||
9494
AuthErrorCode.INTERNAL_ERROR;
95-
consumer.onError(
96-
_createError(this.auth, code)
97-
);
95+
consumer.onError(_createError(this.auth, code));
9896
} else {
9997
consumer.onAuthEvent(event);
10098
}

packages-exp/auth-exp/src/core/auth/auth_impl.ts

+23-9
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ import {
3131
import { Auth, ConfigInternal } from '../../model/auth';
3232
import { PopupRedirectResolver } from '../../model/popup_redirect';
3333
import { User } from '../../model/user';
34-
import { AuthErrorCode, AuthErrorMap, AuthErrorParams, ErrorMapRetriever, FALLBACK_AUTH_ERROR_FACTORY } from '../errors';
34+
import {
35+
AuthErrorCode,
36+
AuthErrorMap,
37+
AuthErrorParams,
38+
ErrorMapRetriever,
39+
FALLBACK_AUTH_ERROR_FACTORY
40+
} from '../errors';
3541
import { Persistence } from '../persistence';
3642
import {
3743
KeyName,
@@ -69,7 +75,10 @@ export class AuthImpl implements Auth, _FirebaseService {
6975
_deleted = false;
7076
_initializationPromise: Promise<void> | null = null;
7177
_popupRedirectResolver: PopupRedirectResolver | null = null;
72-
_errorFactory: ErrorFactory<AuthErrorCode, AuthErrorParams> = FALLBACK_AUTH_ERROR_FACTORY;
78+
_errorFactory: ErrorFactory<
79+
AuthErrorCode,
80+
AuthErrorParams
81+
> = FALLBACK_AUTH_ERROR_FACTORY;
7382
readonly name: string;
7483

7584
// Tracks the last notified UID for state change listeners to prevent
@@ -203,7 +212,11 @@ export class AuthImpl implements Auth, _FirebaseService {
203212
useEmulator(url: string): void {
204213
_assert(this._canInitEmulator, this, AuthErrorCode.EMULATOR_CONFIG_FAILED);
205214

206-
_assert(/^https?:\/\//.test(url), this, AuthErrorCode.INVALID_EMULATOR_SCHEME);
215+
_assert(
216+
/^https?:\/\//.test(url),
217+
this,
218+
AuthErrorCode.INVALID_EMULATOR_SCHEME
219+
);
207220

208221
this.config.emulator = { url };
209222
this.settings.appVerificationDisabledForTesting = true;
@@ -220,7 +233,7 @@ export class AuthImpl implements Auth, _FirebaseService {
220233
_assert(
221234
!user || user.auth.name === this.name,
222235
this,
223-
AuthErrorCode.ARGUMENT_ERROR,
236+
AuthErrorCode.ARGUMENT_ERROR
224237
);
225238

226239
return this._updateCurrentUser(user && user._clone());
@@ -234,7 +247,7 @@ export class AuthImpl implements Auth, _FirebaseService {
234247
_assert(
235248
this.tenantId === user.tenantId,
236249
this,
237-
AuthErrorCode.TENANT_ID_MISMATCH,
250+
AuthErrorCode.TENANT_ID_MISMATCH
238251
);
239252
}
240253
return this.queue(async () => {
@@ -263,10 +276,11 @@ export class AuthImpl implements Auth, _FirebaseService {
263276
}
264277

265278
_updateErrorMap(errorMap: AuthErrorMap): void {
266-
this._errorFactory = new ErrorFactory<
267-
AuthErrorCode,
268-
AuthErrorParams
269-
>('auth', 'Firebase', (errorMap as ErrorMapRetriever)());
279+
this._errorFactory = new ErrorFactory<AuthErrorCode, AuthErrorParams>(
280+
'auth',
281+
'Firebase',
282+
(errorMap as ErrorMapRetriever)()
283+
);
270284
}
271285

272286
onAuthStateChanged(

packages-exp/auth-exp/src/core/errors.test.ts

+26-9
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,34 @@ import { ErrorFactory } from '@firebase/util';
1717
*/
1818

1919
import { expect } from 'chai';
20-
import { AuthErrorCode, verboseErrorMap, prodErrorMap, ErrorMapRetriever, AuthErrorMap, AuthErrorParams } from './errors';
20+
import {
21+
AuthErrorCode,
22+
verboseErrorMap,
23+
prodErrorMap,
24+
ErrorMapRetriever,
25+
AuthErrorMap,
26+
AuthErrorParams
27+
} from './errors';
2128
import { _createError } from './util/assert';
2229

23-
function getErrorFactory(errorMap: AuthErrorMap): ErrorFactory<AuthErrorCode, AuthErrorParams> {
30+
function getErrorFactory(
31+
errorMap: AuthErrorMap
32+
): ErrorFactory<AuthErrorCode, AuthErrorParams> {
2433
const map = (errorMap as ErrorMapRetriever)();
25-
const factory = new ErrorFactory<AuthErrorCode, AuthErrorParams>('auth', 'Firebase', map);
34+
const factory = new ErrorFactory<AuthErrorCode, AuthErrorParams>(
35+
'auth',
36+
'Firebase',
37+
map
38+
);
2639
return factory;
2740
}
2841

2942
describe('verboseErrorMap', () => {
3043
it('should create an Auth namespaced FirebaseError with full message', () => {
31-
const error = getErrorFactory(verboseErrorMap).create(AuthErrorCode.INTERNAL_ERROR, {});
44+
const error = getErrorFactory(verboseErrorMap).create(
45+
AuthErrorCode.INTERNAL_ERROR,
46+
{}
47+
);
3248
expect(error.code).to.eq('auth/internal-error');
3349
expect(error.message).to.eq(
3450
'Firebase: An internal AuthError has occurred. (auth/internal-error).'
@@ -39,11 +55,12 @@ describe('verboseErrorMap', () => {
3955

4056
describe('prodErrorMap', () => {
4157
it('should create an Auth namespaced FirebaseError with full message', () => {
42-
const error = getErrorFactory(prodErrorMap).create(AuthErrorCode.INTERNAL_ERROR, {});
43-
expect(error.code).to.eq('auth/internal-error');
44-
expect(error.message).to.eq(
45-
'Firebase: Error (auth/internal-error).'
58+
const error = getErrorFactory(prodErrorMap).create(
59+
AuthErrorCode.INTERNAL_ERROR,
60+
{}
4661
);
62+
expect(error.code).to.eq('auth/internal-error');
63+
expect(error.message).to.eq('Firebase: Error (auth/internal-error).');
4764
expect(error.name).to.eq('FirebaseError');
4865
});
49-
});
66+
});

0 commit comments

Comments
 (0)