Skip to content

Commit 350f3b0

Browse files
committed
Reorder recaptchaVerifier params so auth is the first param
1 parent 23581c5 commit 350f3b0

File tree

9 files changed

+26
-23
lines changed

9 files changed

+26
-23
lines changed

.changeset/old-badgers-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'firebase': major
3+
---
4+
5+
In @firebase/auth, reorder RecaptchaVerifier parameters so auth is the first parameter

common/api-review/auth.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ export interface RecaptchaParameters {
681681
//
682682
// @public
683683
export class RecaptchaVerifier implements ApplicationVerifierInternal {
684-
constructor(containerOrId: HTMLElement | string, parameters: RecaptchaParameters, authExtern: Auth);
684+
constructor(authExtern: Auth, containerOrId: HTMLElement | string, parameters?: RecaptchaParameters);
685685
clear(): void;
686686
// Warning: (ae-forgotten-export) The symbol "ReCaptchaLoader" needs to be exported by the entry point index.d.ts
687687
//

docs-devsite/auth.recaptchaverifier.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export declare class RecaptchaVerifier implements ApplicationVerifierInternal
2323
2424
| Constructor | Modifiers | Description |
2525
| --- | --- | --- |
26-
| [(constructor)(containerOrId, parameters, authExtern)](./auth.recaptchaverifier.md#recaptchaverifierconstructor) | | Constructs a new instance of the <code>RecaptchaVerifier</code> class |
26+
| [(constructor)(authExtern, containerOrId, parameters)](./auth.recaptchaverifier.md#recaptchaverifierconstructor) | | Constructs a new instance of the <code>RecaptchaVerifier</code> class |
2727
2828
## Properties
2929
@@ -48,16 +48,16 @@ Check the reCAPTCHA docs for a comprehensive list. All parameters are accepted e
4848
<b>Signature:</b>
4949
5050
```typescript
51-
constructor(containerOrId: HTMLElement | string, parameters: RecaptchaParameters, authExtern: Auth);
51+
constructor(authExtern: Auth, containerOrId: HTMLElement | string, parameters?: RecaptchaParameters);
5252
```
5353
5454
### Parameters
5555
5656
| Parameter | Type | Description |
5757
| --- | --- | --- |
58+
| authExtern | [Auth](./auth.auth.md#auth_interface) | The corresponding Firebase [Auth](./auth.auth.md#auth_interface) instance. |
5859
| containerOrId | HTMLElement \| string | The reCAPTCHA container parameter. |
5960
| parameters | [RecaptchaParameters](./auth.recaptchaparameters.md#recaptchaparameters_interface) | The optional reCAPTCHA parameters. |
60-
| authExtern | [Auth](./auth.auth.md#auth_interface) | The corresponding Firebase [Auth](./auth.auth.md#auth_interface) instance. |
6161
6262
## RecaptchaVerifier.type
6363

packages/auth-compat/src/recaptcha_verifier.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ export class RecaptchaVerifier
3737
appName: app.name
3838
});
3939
this._delegate = new exp.RecaptchaVerifier(
40-
container,
41-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
42-
parameters as any,
43-
4440
// TODO: remove ts-ignore when moving types from auth-types to auth-compat
4541
// @ts-ignore
46-
app.auth!()
42+
app.auth!(),
43+
container,
44+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
45+
parameters as any
4746
);
4847
this.type = this._delegate.type;
4948
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ describe('platform_browser/providers/phone', () => {
4545
});
4646

4747
const verifier = new RecaptchaVerifier(
48+
auth,
4849
document.createElement('div'),
49-
{},
50-
auth
50+
{}
5151
);
5252
sinon
5353
.stub(verifier, 'verify')

packages/auth/src/platform_browser/recaptcha/recaptcha_verifier.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('platform_browser/recaptcha/recaptcha_verifier', () => {
5050
auth.languageCode = 'fr';
5151
container = document.createElement('div');
5252
parameters = {};
53-
verifier = new RecaptchaVerifier(container, parameters, auth);
53+
verifier = new RecaptchaVerifier(auth, container, parameters);
5454
// The verifier will have set the parameters.callback field to be the wrapped callback
5555

5656
mockEndpoint(Endpoint.GET_RECAPTCHA_PARAM, {
@@ -134,7 +134,7 @@ describe('platform_browser/recaptcha/recaptcha_verifier', () => {
134134
}
135135
};
136136

137-
verifier = new RecaptchaVerifier(container, parameters, auth);
137+
verifier = new RecaptchaVerifier(auth, container, parameters);
138138
const expected = await verifier.verify();
139139
expect(token).to.eq(expected);
140140
});
@@ -149,7 +149,7 @@ describe('platform_browser/recaptcha/recaptcha_verifier', () => {
149149
callback: 'callbackOnWindowObject'
150150
};
151151

152-
verifier = new RecaptchaVerifier(container, parameters, auth);
152+
verifier = new RecaptchaVerifier(auth, container, parameters);
153153
const expected = await verifier.verify();
154154
expect(token).to.eq(expected);
155155

packages/auth/src/platform_browser/recaptcha/recaptcha_verifier.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class RecaptchaVerifier implements ApplicationVerifierInternal {
6767
private recaptcha: Recaptcha | null = null;
6868

6969
/**
70+
* @param authExtern - The corresponding Firebase {@link Auth} instance.
7071
*
7172
* @param containerOrId - The reCAPTCHA container parameter.
7273
*
@@ -83,15 +84,13 @@ export class RecaptchaVerifier implements ApplicationVerifierInternal {
8384
* the sitekey. Firebase Auth backend provisions a reCAPTCHA for each project and will
8485
* configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
8586
* 'invisible'.
86-
*
87-
* @param authExtern - The corresponding Firebase {@link Auth} instance.
8887
*/
8988
constructor(
89+
authExtern: Auth,
9090
containerOrId: HTMLElement | string,
9191
private readonly parameters: RecaptchaParameters = {
9292
...DEFAULT_PARAMS
93-
},
94-
authExtern: Auth
93+
}
9594
) {
9695
this.auth = _castAuth(authExtern);
9796
this.isInvisible = this.parameters.size === 'invisible';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('platform_browser/strategies/phone', () => {
6060
sessionInfo: 'session-info'
6161
});
6262

63-
verifier = new RecaptchaVerifier(document.createElement('div'), {}, auth);
63+
verifier = new RecaptchaVerifier(auth, document.createElement('div'), {});
6464
sinon.stub(verifier, 'verify').returns(Promise.resolve('recaptcha-token'));
6565
});
6666

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ describe('Integration test: phone auth', () => {
7373
fakeRecaptchaContainer = document.createElement('div');
7474
document.body.appendChild(fakeRecaptchaContainer);
7575
verifier = new RecaptchaVerifier(
76+
auth,
7677
fakeRecaptchaContainer,
77-
undefined as any,
78-
auth
78+
undefined as any
7979
);
8080
});
8181

@@ -87,9 +87,9 @@ describe('Integration test: phone auth', () => {
8787
function resetVerifier(): void {
8888
verifier.clear();
8989
verifier = new RecaptchaVerifier(
90+
auth,
9091
fakeRecaptchaContainer,
91-
undefined as any,
92-
auth
92+
undefined as any
9393
);
9494
}
9595

0 commit comments

Comments
 (0)