Skip to content

Commit d36e50a

Browse files
committed
Merge remote-tracking branch 'origin/master' into BloomFilterUnicodeTestSimplification
2 parents d75194f + 1ff891c commit d36e50a

File tree

17 files changed

+72
-34
lines changed

17 files changed

+72
-34
lines changed

.changeset/old-badgers-mate.md

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

.changeset/silly-eagles-unite.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@firebase/database-compat": major
3+
"@firebase/database-types": major
4+
"@firebase/database": major
5+
---
6+
7+
Updated type of action parameter for DataSnapshot#forEach

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
//

common/api-review/database.api.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class DataSnapshot {
3333
child(path: string): DataSnapshot;
3434
exists(): boolean;
3535
exportVal(): any;
36-
forEach(action: (child: DataSnapshot) => boolean | void): boolean;
36+
forEach(action: (child: IteratedDataSnapshot) => boolean | void): boolean;
3737
hasChild(path: string): boolean;
3838
hasChildren(): boolean;
3939
get key(): string | null;
@@ -85,6 +85,12 @@ export function goOnline(db: Database): void;
8585
// @public
8686
export function increment(delta: number): object;
8787

88+
// @public
89+
export interface IteratedDataSnapshot extends DataSnapshot {
90+
// (undocumented)
91+
key: string;
92+
}
93+
8894
// @public
8995
export function limitToFirst(limit: number): QueryConstraint;
9096

docs-devsite/auth.recaptchaverifier.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export declare class RecaptchaVerifier implements ApplicationVerifierInternal
2525
2626
| Constructor | Modifiers | Description |
2727
| --- | --- | --- |
28-
| [(constructor)(containerOrId, parameters, authExtern)](./auth.recaptchaverifier.md#recaptchaverifierconstructor) | | Constructs a new instance of the <code>RecaptchaVerifier</code> class |
28+
| [(constructor)(authExtern, containerOrId, parameters)](./auth.recaptchaverifier.md#recaptchaverifierconstructor) | | Constructs a new instance of the <code>RecaptchaVerifier</code> class |
2929
3030
## Properties
3131
@@ -50,16 +50,16 @@ Check the reCAPTCHA docs for a comprehensive list. All parameters are accepted e
5050
<b>Signature:</b>
5151
5252
```typescript
53-
constructor(containerOrId: HTMLElement | string, parameters: RecaptchaParameters, authExtern: Auth);
53+
constructor(authExtern: Auth, containerOrId: HTMLElement | string, parameters?: RecaptchaParameters);
5454
```
5555
5656
### Parameters
5757
5858
| Parameter | Type | Description |
5959
| --- | --- | --- |
60+
| authExtern | [Auth](./auth.auth.md#auth_interface) | The corresponding Firebase [Auth](./auth.auth.md#auth_interface) instance. |
6061
| containerOrId | HTMLElement \| string | The reCAPTCHA container parameter. |
6162
| parameters | [RecaptchaParameters](./auth.recaptchaparameters.md#recaptchaparameters_interface) | The optional reCAPTCHA parameters. |
62-
| authExtern | [Auth](./auth.auth.md#auth_interface) | The corresponding Firebase [Auth](./auth.auth.md#auth_interface) instance. |
6363
6464
## RecaptchaVerifier.type
6565

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/demo/src/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,9 @@ function onSignInWithGenericIdPCredential() {
521521
function makeApplicationVerifier(submitButtonId) {
522522
const container =
523523
recaptchaSize === 'invisible' ? submitButtonId : 'recaptcha-container';
524-
applicationVerifier = new RecaptchaVerifier(
525-
container,
526-
{ 'size': recaptchaSize },
527-
auth
528-
);
524+
applicationVerifier = new RecaptchaVerifier(auth, container, {
525+
'size': recaptchaSize
526+
});
529527
}
530528

531529
/**

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
@@ -70,6 +70,7 @@ export class RecaptchaVerifier implements ApplicationVerifierInternal {
7070
private recaptcha: Recaptcha | null = null;
7171

7272
/**
73+
* @param authExtern - The corresponding Firebase {@link Auth} instance.
7374
*
7475
* @param containerOrId - The reCAPTCHA container parameter.
7576
*
@@ -86,15 +87,13 @@ export class RecaptchaVerifier implements ApplicationVerifierInternal {
8687
* the sitekey. Firebase Auth backend provisions a reCAPTCHA for each project and will
8788
* configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
8889
* 'invisible'.
89-
*
90-
* @param authExtern - The corresponding Firebase {@link Auth} instance.
9190
*/
9291
constructor(
92+
authExtern: Auth,
9393
containerOrId: HTMLElement | string,
9494
private readonly parameters: RecaptchaParameters = {
9595
...DEFAULT_PARAMS
96-
},
97-
authExtern: Auth
96+
}
9897
) {
9998
this.auth = _castAuth(authExtern);
10099
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

packages/database-compat/src/api/Reference.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class DataSnapshot implements Compat<ModularDataSnapshot> {
164164
* @returns True if forEach was canceled by action returning true for
165165
* one of the child nodes.
166166
*/
167-
forEach(action: (snapshot: DataSnapshot) => boolean | void): boolean {
167+
forEach(action: (snapshot: IteratedDataSnapshot) => boolean | void): boolean {
168168
validateArgCount('DataSnapshot.forEach', 1, 1, arguments.length);
169169
validateCallback('DataSnapshot.forEach', 'action', action, false);
170170
return this._delegate.forEach(expDataSnapshot =>
@@ -208,6 +208,13 @@ export class DataSnapshot implements Compat<ModularDataSnapshot> {
208208
}
209209
}
210210

211+
/**
212+
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
213+
*/
214+
export interface IteratedDataSnapshot extends DataSnapshot {
215+
key: string; // key of the location of this snapshot.
216+
}
217+
211218
export interface SnapshotCallback {
212219
(dataSnapshot: DataSnapshot, previousChildName?: string | null): unknown;
213220
}

packages/database-types/index.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,18 @@
1818
import { FirebaseApp } from '@firebase/app-types';
1919
import { EmulatorMockTokenOptions } from '@firebase/util';
2020

21+
/**
22+
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
23+
*/
24+
export interface IteratedDataSnapshot extends DataSnapshot {
25+
key: string; // key of the location of this snapshot.
26+
}
27+
2128
export interface DataSnapshot {
2229
child(path: string): DataSnapshot;
2330
exists(): boolean;
2431
exportVal(): any;
25-
forEach(action: (a: DataSnapshot) => boolean | void): boolean;
32+
forEach(action: (a: IteratedDataSnapshot) => boolean | void): boolean;
2633
getPriority(): string | number | null;
2734
hasChild(path: string): boolean;
2835
hasChildren(): boolean;

packages/database/src/api.standalone.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export { OnDisconnect } from './api/OnDisconnect';
3737
export {
3838
DataSnapshot,
3939
EventType,
40+
IteratedDataSnapshot,
4041
QueryConstraint,
4142
QueryConstraintType,
4243
endAt,

packages/database/src/api/Reference_impl.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export class DataSnapshot {
376376
}
377377

378378
/**
379-
* Enumerates the top-level children in the `DataSnapshot`.
379+
* Enumerates the top-level children in the `IteratedDataSnapshot`.
380380
*
381381
* Because of the way JavaScript objects work, the ordering of data in the
382382
* JavaScript object returned by `val()` is not guaranteed to match the
@@ -393,7 +393,7 @@ export class DataSnapshot {
393393
* @returns true if enumeration was canceled due to your callback returning
394394
* true.
395395
*/
396-
forEach(action: (child: DataSnapshot) => boolean | void): boolean {
396+
forEach(action: (child: IteratedDataSnapshot) => boolean | void): boolean {
397397
if (this._node.isLeafNode()) {
398398
return false;
399399
}
@@ -463,6 +463,13 @@ export class DataSnapshot {
463463
}
464464
}
465465

466+
/**
467+
* Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
468+
*/
469+
export interface IteratedDataSnapshot extends DataSnapshot {
470+
key: string; // key of the location of this snapshot.
471+
}
472+
466473
/**
467474
*
468475
* Returns a `Reference` representing the location in the Database

packages/firebase/compat/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5819,7 +5819,7 @@ declare namespace firebase.database {
58195819
* returning true.
58205820
*/
58215821
forEach(
5822-
action: (a: firebase.database.DataSnapshot) => boolean | void
5822+
action: (a: firebase.database.IteratorDataSnapshot) => boolean | void
58235823
): boolean;
58245824
/**
58255825
* Gets the priority value of the data in this `DataSnapshot`.

0 commit comments

Comments
 (0)