Skip to content

Commit 1cf833a

Browse files
committed
Formatting
1 parent 334aa33 commit 1cf833a

File tree

10 files changed

+106
-57
lines changed

10 files changed

+106
-57
lines changed

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

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ export class Auth implements compat.FirebaseAuth, Wrapper<externs.Auth> {
8282
}
8383
get settings(): compat.AuthSettings {
8484
return this.auth.settings;
85-
};
85+
}
8686
get tenantId(): string | null {
8787
return this.auth.tenantId;
88-
};
88+
}
8989
useDeviceLanguage(): void {
9090
this.auth.useDeviceLanguage();
9191
}
@@ -146,34 +146,30 @@ export class Auth implements compat.FirebaseAuth, Wrapper<externs.Auth> {
146146
errorFn?: (error: compat.Error) => unknown,
147147
completed?: Unsubscribe
148148
): Unsubscribe {
149-
const {next, error, complete} = wrapObservers(nextOrObserver, errorFn, completed);
150-
return this.auth.onAuthStateChanged(
151-
next!,
152-
error,
153-
complete
149+
const { next, error, complete } = wrapObservers(
150+
nextOrObserver,
151+
errorFn,
152+
completed
154153
);
154+
return this.auth.onAuthStateChanged(next!, error, complete);
155155
}
156156
onIdTokenChanged(
157157
nextOrObserver: Observer<unknown> | ((a: compat.User | null) => unknown),
158158
errorFn?: (error: compat.Error) => unknown,
159159
completed?: Unsubscribe
160160
): Unsubscribe {
161-
const {next, error, complete} = wrapObservers(nextOrObserver, errorFn, completed);
162-
return this.auth.onIdTokenChanged(
163-
next!,
164-
error,
165-
complete
161+
const { next, error, complete } = wrapObservers(
162+
nextOrObserver,
163+
errorFn,
164+
completed
166165
);
166+
return this.auth.onIdTokenChanged(next!, error, complete);
167167
}
168168
sendSignInLinkToEmail(
169169
email: string,
170170
actionCodeSettings: compat.ActionCodeSettings
171171
): Promise<void> {
172-
return impl.sendSignInLinkToEmail(
173-
this.auth,
174-
email,
175-
actionCodeSettings
176-
);
172+
return impl.sendSignInLinkToEmail(this.auth, email, actionCodeSettings);
177173
}
178174
sendPasswordResetEmail(
179175
email: string,
@@ -207,9 +203,7 @@ export class Auth implements compat.FirebaseAuth, Wrapper<externs.Auth> {
207203
}
208204
}
209205

210-
return this.auth.setPersistence(
211-
convertPersistence(this.auth, persistence)
212-
);
206+
return this.auth.setPersistence(convertPersistence(this.auth, persistence));
213207
}
214208

215209
signInAndRetrieveDataWithCredential(
@@ -218,20 +212,14 @@ export class Auth implements compat.FirebaseAuth, Wrapper<externs.Auth> {
218212
return this.signInWithCredential(credential);
219213
}
220214
signInAnonymously(): Promise<compat.UserCredential> {
221-
return convertCredential(
222-
this.auth,
223-
impl.signInAnonymously(this.auth)
224-
);
215+
return convertCredential(this.auth, impl.signInAnonymously(this.auth));
225216
}
226217
signInWithCredential(
227218
credential: compat.AuthCredential
228219
): Promise<compat.UserCredential> {
229220
return convertCredential(
230221
this.auth,
231-
impl.signInWithCredential(
232-
this.auth,
233-
credential as externs.AuthCredential
234-
)
222+
impl.signInWithCredential(this.auth, credential as externs.AuthCredential)
235223
);
236224
}
237225
signInWithCustomToken(token: string): Promise<compat.UserCredential> {
@@ -311,19 +299,24 @@ export class Auth implements compat.FirebaseAuth, Wrapper<externs.Auth> {
311299
}
312300
}
313301

314-
function wrapObservers(nextOrObserver: Observer<unknown> | ((a: compat.User|null) => unknown),
315-
error?: (error: compat.Error) => unknown,
316-
complete?: Unsubscribe): Partial<Observer<externs.User|null>> {
302+
function wrapObservers(
303+
nextOrObserver: Observer<unknown> | ((a: compat.User | null) => unknown),
304+
error?: (error: compat.Error) => unknown,
305+
complete?: Unsubscribe
306+
): Partial<Observer<externs.User | null>> {
317307
let next = nextOrObserver;
318308
if (typeof nextOrObserver !== 'function') {
319-
({next, error, complete} = nextOrObserver);
309+
({ next, error, complete } = nextOrObserver);
320310
}
321311

322312
// We know 'next' is now a function
323-
const oldNext = next as ((a: compat.User|null) => unknown);
313+
const oldNext = next as (a: compat.User | null) => unknown;
324314

325-
const newNext = (user: externs.User|null) => oldNext(user && User.getOrCreate(user as externs.User));
315+
const newNext = (user: externs.User | null) =>
316+
oldNext(user && User.getOrCreate(user as externs.User));
326317
return {
327-
next: newNext, error: error as ErrorFn, complete
318+
next: newNext,
319+
error: error as ErrorFn,
320+
complete
328321
};
329322
}
Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,62 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
import * as impl from '@firebase/auth-exp/internal';
219
import * as compat from '@firebase/auth-types';
320
import * as externs from '@firebase/auth-types-exp';
421
import firebase from '@firebase/app-compat';
522
import { unwrap, Wrapper } from './wrap';
623

7-
export class PhoneAuthProvider implements compat.PhoneAuthProvider, Wrapper<externs.PhoneAuthProvider> {
24+
export class PhoneAuthProvider
25+
implements compat.PhoneAuthProvider, Wrapper<externs.PhoneAuthProvider> {
826
providerId = 'phone';
927
private readonly phoneProvider: impl.PhoneAuthProvider;
1028

1129
static PHONE_SIGN_IN_METHOD = impl.PhoneAuthProvider.PHONE_SIGN_IN_METHOD;
1230
static PROVIDER_ID = impl.PhoneAuthProvider.PROVIDER_ID;
1331

14-
static credential ( verificationId : string , verificationCode : string ) : compat.AuthCredential {
32+
static credential(
33+
verificationId: string,
34+
verificationCode: string
35+
): compat.AuthCredential {
1536
return impl.PhoneAuthProvider.credential(verificationId, verificationCode);
1637
}
1738

1839
constructor() {
1940
this.phoneProvider = new impl.PhoneAuthProvider(unwrap(firebase.auth!()));
2041
}
2142

22-
verifyPhoneNumber(phoneInfoOptions: string | compat.PhoneSingleFactorInfoOptions | compat.PhoneMultiFactorEnrollInfoOptions | compat.PhoneMultiFactorSignInInfoOptions, applicationVerifier: compat.ApplicationVerifier): Promise<string> {
43+
verifyPhoneNumber(
44+
phoneInfoOptions:
45+
| string
46+
| compat.PhoneSingleFactorInfoOptions
47+
| compat.PhoneMultiFactorEnrollInfoOptions
48+
| compat.PhoneMultiFactorSignInInfoOptions,
49+
applicationVerifier: compat.ApplicationVerifier
50+
): Promise<string> {
2351
// The implementation matches but the types are subtly incompatible
2452
// eslint-disable-next-line @typescript-eslint/no-explicit-any
25-
return this.phoneProvider.verifyPhoneNumber(phoneInfoOptions as any, unwrap(applicationVerifier));
53+
return this.phoneProvider.verifyPhoneNumber(
54+
phoneInfoOptions as any,
55+
unwrap(applicationVerifier)
56+
);
2657
}
2758

2859
unwrap(): externs.PhoneAuthProvider {
2960
return this.phoneProvider;
3061
}
31-
}
62+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export class RecaptchaVerifier
4040
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4141
parameters as any,
4242

43-
unwrap(app.auth!()));
43+
unwrap(app.auth!())
44+
);
4445
this.type = this.verifier.type;
4546
}
4647
clear(): void {

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ export class User implements compat.User, Wrapper<externs.User> {
7777
): Promise<compat.ConfirmationResult> {
7878
return convertConfirmationResult(
7979
this.auth,
80-
impl.linkWithPhoneNumber(this.user, phoneNumber, unwrap(applicationVerifier))
80+
impl.linkWithPhoneNumber(
81+
this.user,
82+
phoneNumber,
83+
unwrap(applicationVerifier)
84+
)
8185
);
8286
}
8387
async linkWithPopup(
@@ -121,7 +125,11 @@ export class User implements compat.User, Wrapper<externs.User> {
121125
): Promise<compat.ConfirmationResult> {
122126
return convertConfirmationResult(
123127
this.auth,
124-
impl.reauthenticateWithPhoneNumber(this.user, phoneNumber, unwrap(applicationVerifier))
128+
impl.reauthenticateWithPhoneNumber(
129+
this.user,
130+
phoneNumber,
131+
unwrap(applicationVerifier)
132+
)
125133
);
126134
}
127135
reauthenticateWithPopup(
@@ -174,7 +182,11 @@ export class User implements compat.User, Wrapper<externs.User> {
174182
newEmail: string,
175183
actionCodeSettings?: compat.ActionCodeSettings | null
176184
): Promise<void> {
177-
return impl.verifyBeforeUpdateEmail(this.user, newEmail, actionCodeSettings);
185+
return impl.verifyBeforeUpdateEmail(
186+
this.user,
187+
newEmail,
188+
actionCodeSettings
189+
);
178190
}
179191
unwrap(): externs.User {
180192
return this.user;
@@ -216,6 +228,6 @@ export class User implements compat.User, Wrapper<externs.User> {
216228
return this.user.uid;
217229
}
218230
private get auth(): externs.Auth {
219-
return (this.user as impl.UserImpl).auth as unknown as externs.Auth;
231+
return ((this.user as impl.UserImpl).auth as unknown) as externs.Auth;
220232
}
221233
}
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
export interface Wrapper<T> {
219
unwrap(): T;
320
}
421

522
export function unwrap<T>(object: unknown): T {
623
return (object as Wrapper<T>).unwrap();
7-
}
24+
}

packages-exp/auth-exp/src/api/account_management/mfa.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { Endpoint, HttpMethod, _performApiRequest } from '..';
1919
import { SignInWithPhoneNumberRequest } from '../authentication/sms';
2020
import { FinalizeMfaResponse } from '../authentication/mfa';
21-
import {Auth} from '../../model/auth';
21+
import { Auth } from '../../model/auth';
2222

2323
/**
2424
* MFA Info as returned by the API

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class AuthImpl implements Auth, _FirebaseService {
7777

7878
constructor(
7979
public readonly app: FirebaseApp,
80-
public readonly config: ConfigInternal,
80+
public readonly config: ConfigInternal
8181
) {
8282
this.name = app.name;
8383
}
@@ -276,7 +276,7 @@ export class AuthImpl implements Auth, _FirebaseService {
276276
[_getInstance(resolver._redirectPersistence)],
277277
_REDIRECT_USER_KEY_NAME
278278
);
279-
this.redirectUser = (await this.redirectPersistenceManager.getCurrentUser());
279+
this.redirectUser = await this.redirectPersistenceManager.getCurrentUser();
280280
}
281281

282282
return this.redirectPersistenceManager;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class AuthInternal {
6060
}
6161

6262
const unsubscribe = this.auth.onIdTokenChanged(user => {
63-
listener((user as User|null)?.stsTokenManager.accessToken || null);
63+
listener((user as User | null)?.stsTokenManager.accessToken || null);
6464
});
6565
this.internalListeners.set(listener, unsubscribe);
6666
this.updateProactiveRefresh();

packages-exp/auth-exp/src/core/credentials/email.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ export class EmailAuthCredential
104104
}
105105
}
106106

107-
async _linkToIdToken(
108-
auth: Auth,
109-
idToken: string
110-
): Promise<IdTokenResponse> {
107+
async _linkToIdToken(auth: Auth, idToken: string): Promise<IdTokenResponse> {
111108
switch (this.signInMethod) {
112109
case externs.SignInMethod.EMAIL_PASSWORD:
113110
return updateEmailPassword(auth, {

packages-exp/auth-exp/src/platform_browser/iframe/iframe.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ function getIframeUrl(auth: Auth): string {
5656
return `${url}?${querystring(params).slice(1)}`;
5757
}
5858

59-
export async function _openIframe(
60-
auth: Auth
61-
): Promise<gapi.iframes.Iframe> {
59+
export async function _openIframe(auth: Auth): Promise<gapi.iframes.Iframe> {
6260
const context = await gapiLoader._loadGapi(auth);
6361
const gapi = _window().gapi;
6462
assert(gapi, AuthErrorCode.INTERNAL_ERROR, { appName: auth.name });

0 commit comments

Comments
 (0)