Skip to content

Commit 971870c

Browse files
committed
Mark appVerifier param in Phone Auth APIs as required
1 parent 233c31f commit 971870c

File tree

7 files changed

+36
-88
lines changed

7 files changed

+36
-88
lines changed

common/api-review/auth.api.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ export class AuthCredential {
104104
protected constructor(
105105
providerId: string,
106106
signInMethod: string);
107-
// Warning: (ae-forgotten-export) The symbol "AuthInternal" needs to be exported by the entry point index.d.ts
108-
// Warning: (ae-forgotten-export) The symbol "PhoneOrOauthTokenResponse" needs to be exported by the entry point index.d.ts
107+
// Warning: (ae-forgotten-export) The symbol "AuthInternal" needs to be exported by the entry point index.doc.d.ts
108+
// Warning: (ae-forgotten-export) The symbol "PhoneOrOauthTokenResponse" needs to be exported by the entry point index.doc.d.ts
109109
//
110110
// @internal (undocumented)
111111
_getIdTokenResponse(_auth: AuthInternal): Promise<PhoneOrOauthTokenResponse>;
112112
// @internal (undocumented)
113113
_getReauthenticationResolver(_auth: AuthInternal): Promise<IdTokenResponse>;
114-
// Warning: (ae-forgotten-export) The symbol "IdTokenResponse" needs to be exported by the entry point index.d.ts
114+
// Warning: (ae-forgotten-export) The symbol "IdTokenResponse" needs to be exported by the entry point index.doc.d.ts
115115
//
116116
// @internal (undocumented)
117117
_linkToIdToken(_auth: AuthInternal, _idToken: string): Promise<IdTokenResponse>;
@@ -293,6 +293,9 @@ export function connectAuthEmulator(auth: Auth, url: string, options?: {
293293
disableWarnings: boolean;
294294
}): void;
295295

296+
// @public
297+
export const cordovaPopupRedirectResolver: PopupRedirectResolver;
298+
296299
// @public
297300
export function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
298301

@@ -356,7 +359,7 @@ export interface EmulatorConfig {
356359

357360
export { ErrorFn }
358361

359-
// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.d.ts
362+
// Warning: (ae-forgotten-export) The symbol "BaseOAuthProvider" needs to be exported by the entry point index.doc.d.ts
360363
//
361364
// @public
362365
export class FacebookAuthProvider extends BaseOAuthProvider {
@@ -392,6 +395,9 @@ export function getIdTokenResult(user: User, forceRefresh?: boolean): Promise<Id
392395
// @public
393396
export function getMultiFactorResolver(auth: Auth, error: MultiFactorError): MultiFactorResolver;
394397

398+
// @public
399+
export function getReactNativePersistence(storage: ReactNativeAsyncStorage): Persistence;
400+
395401
// @public
396402
export function getRedirectResult(auth: Auth, resolver?: PopupRedirectResolver): Promise<UserCredential | null>;
397403

@@ -445,7 +451,7 @@ export function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean;
445451
export function linkWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
446452

447453
// @public
448-
export function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
454+
export function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
449455

450456
// @public
451457
export function linkWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
@@ -504,7 +510,7 @@ export type NextOrObserver<T> = NextFn<T | null> | Observer<T | null>;
504510
export class OAuthCredential extends AuthCredential {
505511
accessToken?: string;
506512
static fromJSON(json: string | object): OAuthCredential | null;
507-
// Warning: (ae-forgotten-export) The symbol "OAuthCredentialParams" needs to be exported by the entry point index.d.ts
513+
// Warning: (ae-forgotten-export) The symbol "OAuthCredentialParams" needs to be exported by the entry point index.doc.d.ts
508514
//
509515
// @internal (undocumented)
510516
static _fromParams(params: OAuthCredentialParams): OAuthCredential;
@@ -609,7 +615,7 @@ export class PhoneAuthCredential extends AuthCredential {
609615
_getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
610616
// @internal (undocumented)
611617
_linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
612-
// Warning: (ae-forgotten-export) The symbol "SignInWithPhoneNumberRequest" needs to be exported by the entry point index.d.ts
618+
// Warning: (ae-forgotten-export) The symbol "SignInWithPhoneNumberRequest" needs to be exported by the entry point index.doc.d.ts
613619
//
614620
// @internal (undocumented)
615621
_makeVerificationRequest(): SignInWithPhoneNumberRequest;
@@ -625,7 +631,7 @@ export class PhoneAuthProvider {
625631
static readonly PHONE_SIGN_IN_METHOD: 'phone';
626632
static readonly PROVIDER_ID: 'phone';
627633
readonly providerId: "phone";
628-
verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier?: ApplicationVerifier): Promise<string>;
634+
verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier: ApplicationVerifier): Promise<string>;
629635
}
630636

631637
// @public
@@ -692,7 +698,7 @@ export interface ReactNativeAsyncStorage {
692698
export function reauthenticateWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
693699

694700
// @public
695-
export function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
701+
export function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
696702

697703
// @public
698704
export function reauthenticateWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
@@ -706,13 +712,13 @@ export interface RecaptchaParameters {
706712
[key: string]: any;
707713
}
708714

709-
// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.d.ts
715+
// Warning: (ae-forgotten-export) The symbol "ApplicationVerifierInternal" needs to be exported by the entry point index.doc.d.ts
710716
//
711717
// @public
712718
export class RecaptchaVerifier implements ApplicationVerifierInternal {
713719
constructor(authExtern: Auth, containerOrId: HTMLElement | string, parameters?: RecaptchaParameters);
714720
clear(): void;
715-
// Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.d.ts
721+
// Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.doc.d.ts
716722
//
717723
// @internal (undocumented)
718724
readonly _recaptchaLoader: ReCaptchaLoader;
@@ -729,7 +735,7 @@ export function reload(user: User): Promise<void>;
729735
// @public
730736
export function revokeAccessToken(auth: Auth, token: string): Promise<void>;
731737

732-
// Warning: (ae-forgotten-export) The symbol "FederatedAuthProvider" needs to be exported by the entry point index.d.ts
738+
// Warning: (ae-forgotten-export) The symbol "FederatedAuthProvider" needs to be exported by the entry point index.doc.d.ts
733739
//
734740
// @public
735741
export class SAMLAuthProvider extends FederatedAuthProvider {
@@ -778,7 +784,7 @@ export function signInWithEmailAndPassword(auth: Auth, email: string, password:
778784
export function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;
779785

780786
// @public
781-
export function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
787+
export function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
782788

783789
// @public
784790
export function signInWithPopup(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
@@ -810,13 +816,13 @@ export class TotpSecret {
810816
readonly codeIntervalSeconds: number;
811817
readonly codeLength: number;
812818
readonly enrollmentCompletionDeadline: string;
813-
// Warning: (ae-forgotten-export) The symbol "StartTotpMfaEnrollmentResponse" needs to be exported by the entry point index.d.ts
819+
// Warning: (ae-forgotten-export) The symbol "StartTotpMfaEnrollmentResponse" needs to be exported by the entry point index.doc.d.ts
814820
//
815821
// @internal (undocumented)
816822
static _fromStartTotpMfaEnrollmentResponse(response: StartTotpMfaEnrollmentResponse, auth: AuthInternal): TotpSecret;
817823
generateQrCodeUrl(accountName?: string, issuer?: string): string;
818824
readonly hashingAlgorithm: string;
819-
// Warning: (ae-forgotten-export) The symbol "TotpVerificationInfo" needs to be exported by the entry point index.d.ts
825+
// Warning: (ae-forgotten-export) The symbol "TotpVerificationInfo" needs to be exported by the entry point index.doc.d.ts
820826
//
821827
// @internal (undocumented)
822828
_makeTotpVerificationInfo(otp: string): TotpVerificationInfo;

docs-devsite/auth.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ This method does not work in a Node.js environment or with [Auth](./auth.auth.md
930930
<b>Signature:</b>
931931

932932
```typescript
933-
export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
933+
export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
934934
```
935935

936936
#### Parameters
@@ -1304,7 +1304,7 @@ This method does not work in a Node.js environment.
13041304
<b>Signature:</b>
13051305

13061306
```typescript
1307-
export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
1307+
export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
13081308
```
13091309

13101310
#### Parameters
@@ -1457,7 +1457,7 @@ This method does not work in a Node.js environment or on any [User](./auth.user.
14571457
<b>Signature:</b>
14581458

14591459
```typescript
1460-
export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
1460+
export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
14611461
```
14621462

14631463
#### Parameters

docs-devsite/auth.phoneauthprovider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Starts a phone number authentication flow by sending a verification code to the
203203
<b>Signature:</b>
204204

205205
```typescript
206-
verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier?: ApplicationVerifier): Promise<string>;
206+
verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier: ApplicationVerifier): Promise<string>;
207207
```
208208

209209
#### Parameters

packages/auth/src/platform_browser/providers/phone.test.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -106,49 +106,6 @@ describe('platform_browser/providers/phone', () => {
106106
recaptchaVersion: RecaptchaVersion.ENTERPRISE
107107
});
108108
});
109-
110-
it('calls the server without appVerifier when recaptcha enterprise is enabled', async () => {
111-
const recaptchaConfigResponseEnforce = {
112-
recaptchaKey: 'foo/bar/to/site-key',
113-
recaptchaEnforcementState: [
114-
{
115-
provider: RecaptchaProvider.PHONE_PROVIDER,
116-
enforcementState: EnforcementState.ENFORCE
117-
}
118-
]
119-
};
120-
const recaptcha = new MockGreCAPTCHATopLevel();
121-
if (typeof window === 'undefined') {
122-
return;
123-
}
124-
window.grecaptcha = recaptcha;
125-
sinon
126-
.stub(recaptcha.enterprise, 'execute')
127-
.returns(Promise.resolve('enterprise-token'));
128-
129-
mockEndpointWithParams(
130-
Endpoint.GET_RECAPTCHA_CONFIG,
131-
{
132-
clientType: RecaptchaClientType.WEB,
133-
version: RecaptchaVersion.ENTERPRISE
134-
},
135-
recaptchaConfigResponseEnforce
136-
);
137-
138-
const route = mockEndpoint(Endpoint.SEND_VERIFICATION_CODE, {
139-
sessionInfo: 'verification-id'
140-
});
141-
142-
const provider = new PhoneAuthProvider(auth);
143-
const result = await provider.verifyPhoneNumber('+15105550000');
144-
expect(result).to.eq('verification-id');
145-
expect(route.calls[0].request).to.eql({
146-
phoneNumber: '+15105550000',
147-
captchaResponse: 'enterprise-token',
148-
clientType: RecaptchaClientType.WEB,
149-
recaptchaVersion: RecaptchaVersion.ENTERPRISE
150-
});
151-
});
152109
});
153110

154111
context('.credential', () => {

packages/auth/src/platform_browser/providers/phone.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ export class PhoneAuthProvider {
100100
* {@link RecaptchaVerifier}.
101101
*
102102
* @returns A Promise for a verification ID that can be passed to
103-
* {@link PhoneAuthProvider.credential} to identify this flow..
103+
* {@link PhoneAuthProvider.credential} to identify this flow.
104104
*/
105105
verifyPhoneNumber(
106106
phoneOptions: PhoneInfoOptions | string,
107-
applicationVerifier?: ApplicationVerifier
107+
applicationVerifier: ApplicationVerifier
108108
): Promise<string> {
109109
return _verifyPhoneNumber(
110110
this.auth,

packages/auth/src/platform_browser/strategies/phone.test.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ describe('platform_browser/strategies/phone', () => {
171171
return;
172172
}
173173
mockRecaptchaEnterpriseEnablement(EnforcementState.ENFORCE);
174-
await signInWithPhoneNumber(auth, '+15105550000');
174+
await signInWithPhoneNumber(auth, '+15105550000', v2Verifier);
175175

176176
expect(sendCodeEndpoint.calls[0].request).to.eql({
177177
phoneNumber: '+15105550000',
@@ -504,21 +504,6 @@ describe('platform_browser/strategies/phone', () => {
504504
});
505505
});
506506

507-
it('works without v2 verifier when recaptcha enterprise is enabled', async () => {
508-
if (typeof window === 'undefined') {
509-
return;
510-
}
511-
mockRecaptchaEnterpriseEnablement(EnforcementState.ENFORCE);
512-
const sessionInfo = await _verifyPhoneNumber(auth, 'number');
513-
expect(sessionInfo).to.eq('session-info');
514-
expect(sendCodeEndpoint.calls[0].request).to.eql({
515-
phoneNumber: 'number',
516-
captchaResponse: RECAPTCHA_ENTERPRISE_TOKEN,
517-
clientType: RecaptchaClientType.WEB,
518-
recaptchaVersion: RecaptchaVersion.ENTERPRISE
519-
});
520-
});
521-
522507
it('calls fallback to recaptcha v2 flow when receiving MISSING_RECAPTCHA_TOKEN error in recaptcha enterprise audit mode', async () => {
523508
if (typeof window === 'undefined') {
524509
return;

packages/auth/src/platform_browser/strategies/phone.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class ConfirmationResultImpl implements ConfirmationResult {
129129
export async function signInWithPhoneNumber(
130130
auth: Auth,
131131
phoneNumber: string,
132-
appVerifier?: ApplicationVerifier
132+
appVerifier: ApplicationVerifier
133133
): Promise<ConfirmationResult> {
134134
if (_isFirebaseServerApp(auth.app)) {
135135
return Promise.reject(
@@ -162,7 +162,7 @@ export async function signInWithPhoneNumber(
162162
export async function linkWithPhoneNumber(
163163
user: User,
164164
phoneNumber: string,
165-
appVerifier?: ApplicationVerifier
165+
appVerifier: ApplicationVerifier
166166
): Promise<ConfirmationResult> {
167167
const userInternal = getModularInstance(user) as UserInternal;
168168
await _assertLinkedStatus(false, userInternal, ProviderId.PHONE);
@@ -194,7 +194,7 @@ export async function linkWithPhoneNumber(
194194
export async function reauthenticateWithPhoneNumber(
195195
user: User,
196196
phoneNumber: string,
197-
appVerifier?: ApplicationVerifier
197+
appVerifier: ApplicationVerifier
198198
): Promise<ConfirmationResult> {
199199
const userInternal = getModularInstance(user) as UserInternal;
200200
if (_isFirebaseServerApp(userInternal.auth.app)) {
@@ -224,7 +224,7 @@ type PhoneApiCaller<TRequest, TResponse> = (
224224
export async function _verifyPhoneNumber(
225225
auth: AuthInternal,
226226
options: PhoneInfoOptions | string,
227-
verifier?: ApplicationVerifierInternal
227+
verifier: ApplicationVerifierInternal
228228
): Promise<string> {
229229
if (!auth._getRecaptchaConfig()) {
230230
const enterpriseVerifier = new RecaptchaEnterpriseVerifier(auth);
@@ -274,7 +274,7 @@ export async function _verifyPhoneNumber(
274274
request.phoneEnrollmentInfo.captchaResponse === FAKE_TOKEN
275275
) {
276276
_assert(
277-
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
277+
verifier.type === RECAPTCHA_VERIFIER_TYPE,
278278
authInstance,
279279
AuthErrorCode.ARGUMENT_ERROR
280280
);
@@ -336,7 +336,7 @@ export async function _verifyPhoneNumber(
336336
request.phoneSignInInfo.captchaResponse === FAKE_TOKEN
337337
) {
338338
_assert(
339-
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
339+
verifier.type === RECAPTCHA_VERIFIER_TYPE,
340340
authInstance,
341341
AuthErrorCode.ARGUMENT_ERROR
342342
);
@@ -387,7 +387,7 @@ export async function _verifyPhoneNumber(
387387
request.captchaResponse === FAKE_TOKEN
388388
) {
389389
_assert(
390-
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
390+
verifier.type === RECAPTCHA_VERIFIER_TYPE,
391391
authInstance,
392392
AuthErrorCode.ARGUMENT_ERROR
393393
);
@@ -421,7 +421,7 @@ export async function _verifyPhoneNumber(
421421
return response.sessionInfo;
422422
}
423423
} finally {
424-
verifier?._reset();
424+
verifier._reset();
425425
}
426426
}
427427

0 commit comments

Comments
 (0)