Skip to content

Commit faafa5f

Browse files
committed
Formatting, license
1 parent 0ff1e54 commit faafa5f

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed
Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1-
import {Auth} from '@firebase/auth-exp';
2-
import {getApps} from '@firebase/app-exp';
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+
18+
import { Auth } from '@firebase/auth-exp';
19+
import { getApps } from '@firebase/app-exp';
320

421
interface VerificationSession {
522
code: string;
@@ -11,19 +28,21 @@ interface VerificationCodesResponse {
1128
verificationCodes: VerificationSession[];
1229
}
1330

14-
export async function getPhoneVerificationCodes(auth: Auth): Promise<Record<string, VerificationSession>> {
31+
export async function getPhoneVerificationCodes(
32+
auth: Auth
33+
): Promise<Record<string, VerificationSession>> {
1534
assertEmulator(auth);
1635
const url = getEmulatorUrl(auth, 'verificationCodes');
1736
const response: VerificationCodesResponse = await (await fetch(url)).json();
18-
37+
1938
return response.verificationCodes.reduce((accum, session) => {
2039
accum[session.sessionInfo] = session;
2140
return accum;
2241
}, {} as Record<string, VerificationSession>);
2342
}
2443

2544
function getEmulatorUrl(auth: Auth, endpoint: string): string {
26-
const {host, port, protocol} = auth.emulatorConfig!;
45+
const { host, port, protocol } = auth.emulatorConfig!;
2746
const projectId = getProjectId(auth);
2847
return `${protocol}://${host}:${port}/emulator/v1/projects/${projectId}/${endpoint}`;
2948
}
@@ -34,6 +53,6 @@ function getProjectId(auth: Auth): string {
3453

3554
function assertEmulator(auth: Auth): void {
3655
if (!auth.emulatorConfig) {
37-
throw new Error('Can\'t fetch OOB codes against prod API');
56+
throw new Error("Can't fetch OOB codes against prod API");
3857
}
39-
}
58+
}

packages-exp/auth-exp/test/integration/flows/phone.test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ describe.only('Integration test: phone auth', () => {
8383
});
8484

8585
/** If in the emulator, search for the code in the API */
86-
async function code(crOrId: ConfirmationResult|string, fallback: string): Promise<string> {
86+
async function code(
87+
crOrId: ConfirmationResult | string,
88+
fallback: string
89+
): Promise<string> {
8790
if (auth.emulatorConfig) {
8891
const codes = await getPhoneVerificationCodes(auth);
8992
const vid = typeof crOrId === 'string' ? crOrId : crOrId.verificationId;
@@ -171,15 +174,20 @@ describe.only('Integration test: phone auth', () => {
171174

172175
await updatePhoneNumber(
173176
user,
174-
PhoneAuthProvider.credential(verificationId, await code(verificationId, PHONE_B.code))
177+
PhoneAuthProvider.credential(
178+
verificationId,
179+
await code(verificationId, PHONE_B.code)
180+
)
175181
);
176182
expect(user.phoneNumber).to.eq(PHONE_B.phoneNumber);
177183

178184
await auth.signOut();
179185
resetVerifier();
180186

181187
cr = await signInWithPhoneNumber(auth, PHONE_B.phoneNumber, verifier);
182-
const { user: secondSignIn } = await cr.confirm(await code(cr, PHONE_B.code));
188+
const { user: secondSignIn } = await cr.confirm(
189+
await code(cr, PHONE_B.code)
190+
);
183191
expect(secondSignIn.uid).to.eq(user.uid);
184192
});
185193

@@ -225,7 +233,9 @@ describe.only('Integration test: phone auth', () => {
225233
// reauthenticateWithPhoneNumber does not trigger a state change
226234
resetVerifier();
227235
cr = await signInWithPhoneNumber(auth, PHONE_B.phoneNumber, verifier);
228-
const { user: otherUser } = await cr.confirm(await code(cr, PHONE_B.code));
236+
const { user: otherUser } = await cr.confirm(
237+
await code(cr, PHONE_B.code)
238+
);
229239
await otherUser.delete();
230240
});
231241
});

0 commit comments

Comments
 (0)