Skip to content

Commit ed69ba9

Browse files
committed
Mark appVerifier param in Phone Auth APIs as required
1 parent 6e7e388 commit ed69ba9

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
@@ -912,7 +912,7 @@ This method does not work in a Node.js environment.
912912
<b>Signature:</b>
913913

914914
```typescript
915-
export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
915+
export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
916916
```
917917

918918
### Parameters
@@ -1278,7 +1278,7 @@ This method does not work in a Node.js environment.
12781278
<b>Signature:</b>
12791279

12801280
```typescript
1281-
export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
1281+
export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
12821282
```
12831283

12841284
### Parameters
@@ -1429,7 +1429,7 @@ This method does not work in a Node.js environment.
14291429
<b>Signature:</b>
14301430

14311431
```typescript
1432-
export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier?: ApplicationVerifier): Promise<ConfirmationResult>;
1432+
export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
14331433
```
14341434

14351435
### 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
@@ -124,7 +124,7 @@ class ConfirmationResultImpl implements ConfirmationResult {
124124
export async function signInWithPhoneNumber(
125125
auth: Auth,
126126
phoneNumber: string,
127-
appVerifier?: ApplicationVerifier
127+
appVerifier: ApplicationVerifier
128128
): Promise<ConfirmationResult> {
129129
const authInternal = _castAuth(auth);
130130
const verificationId = await _verifyPhoneNumber(
@@ -152,7 +152,7 @@ export async function signInWithPhoneNumber(
152152
export async function linkWithPhoneNumber(
153153
user: User,
154154
phoneNumber: string,
155-
appVerifier?: ApplicationVerifier
155+
appVerifier: ApplicationVerifier
156156
): Promise<ConfirmationResult> {
157157
const userInternal = getModularInstance(user) as UserInternal;
158158
await _assertLinkedStatus(false, userInternal, ProviderId.PHONE);
@@ -183,7 +183,7 @@ export async function linkWithPhoneNumber(
183183
export async function reauthenticateWithPhoneNumber(
184184
user: User,
185185
phoneNumber: string,
186-
appVerifier?: ApplicationVerifier
186+
appVerifier: ApplicationVerifier
187187
): Promise<ConfirmationResult> {
188188
const userInternal = getModularInstance(user) as UserInternal;
189189
const verificationId = await _verifyPhoneNumber(
@@ -208,7 +208,7 @@ type PhoneApiCaller<TRequest, TResponse> = (
208208
export async function _verifyPhoneNumber(
209209
auth: AuthInternal,
210210
options: PhoneInfoOptions | string,
211-
verifier?: ApplicationVerifierInternal
211+
verifier: ApplicationVerifierInternal
212212
): Promise<string> {
213213
if (!auth._getRecaptchaConfig()) {
214214
const enterpriseVerifier = new RecaptchaEnterpriseVerifier(auth);
@@ -258,7 +258,7 @@ export async function _verifyPhoneNumber(
258258
request.phoneEnrollmentInfo.captchaResponse === FAKE_TOKEN
259259
) {
260260
_assert(
261-
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
261+
verifier.type === RECAPTCHA_VERIFIER_TYPE,
262262
authInstance,
263263
AuthErrorCode.ARGUMENT_ERROR
264264
);
@@ -320,7 +320,7 @@ export async function _verifyPhoneNumber(
320320
request.phoneSignInInfo.captchaResponse === FAKE_TOKEN
321321
) {
322322
_assert(
323-
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
323+
verifier.type === RECAPTCHA_VERIFIER_TYPE,
324324
authInstance,
325325
AuthErrorCode.ARGUMENT_ERROR
326326
);
@@ -371,7 +371,7 @@ export async function _verifyPhoneNumber(
371371
request.captchaResponse === FAKE_TOKEN
372372
) {
373373
_assert(
374-
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
374+
verifier.type === RECAPTCHA_VERIFIER_TYPE,
375375
authInstance,
376376
AuthErrorCode.ARGUMENT_ERROR
377377
);
@@ -405,7 +405,7 @@ export async function _verifyPhoneNumber(
405405
return response.sessionInfo;
406406
}
407407
} finally {
408-
verifier?._reset();
408+
verifier._reset();
409409
}
410410
}
411411

0 commit comments

Comments
 (0)