Skip to content

Commit 371ccd7

Browse files
Merge branch 'mrschmidt/readtime' into mrschmidt/fieldindex
2 parents ada9cb7 + 3883ff4 commit 371ccd7

File tree

66 files changed

+594
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+594
-108
lines changed

.changeset/curvy-brooms-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/auth": patch
3+
---
4+
5+
Fix bug where `user.providerData` field was being improperly initialized

common/api-review/auth.api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,11 @@ export class PhoneMultiFactorGenerator {
601601
static FACTOR_ID: string;
602602
}
603603

604+
// @public
605+
export interface PhoneMultiFactorInfo extends MultiFactorInfo {
606+
readonly phoneNumber: string;
607+
}
608+
604609
// @public
605610
export interface PhoneMultiFactorSignInInfoOptions {
606611
multiFactorHint?: MultiFactorInfo;

integration/compat-interop/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
"test:debug": "karma start --browsers Chrome --auto-watch"
99
},
1010
"dependencies": {
11-
"@firebase/app": "0.7.14",
12-
"@firebase/app-compat": "0.1.15",
11+
"@firebase/app": "0.7.15",
12+
"@firebase/app-compat": "0.1.16",
1313
"@firebase/analytics": "0.7.5",
1414
"@firebase/analytics-compat": "0.1.6",
15-
"@firebase/auth": "0.19.6",
16-
"@firebase/auth-compat": "0.2.6",
17-
"@firebase/functions": "0.7.7",
18-
"@firebase/functions-compat": "0.1.8",
15+
"@firebase/auth": "0.19.7",
16+
"@firebase/auth-compat": "0.2.7",
17+
"@firebase/functions": "0.7.8",
18+
"@firebase/functions-compat": "0.1.9",
1919
"@firebase/messaging": "0.9.7",
2020
"@firebase/messaging-compat": "0.1.7",
2121
"@firebase/performance": "0.5.5",

integration/firebase/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test"
88
},
99
"devDependencies": {
10-
"firebase": "9.6.4",
10+
"firebase": "9.6.5",
1111
"@types/chai": "4.2.22",
1212
"@types/mocha": "9.0.0",
1313
"chai": "4.3.4",

integration/firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"test:memory:debug": "yarn build:memory; karma start --auto-watch --browsers Chrome"
1616
},
1717
"dependencies": {
18-
"@firebase/app": "0.7.14",
19-
"@firebase/firestore": "3.4.3"
18+
"@firebase/app": "0.7.15",
19+
"@firebase/firestore": "3.4.4"
2020
},
2121
"devDependencies": {
2222
"@types/mocha": "9.0.0",

integration/messaging/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"test:manual": "mocha --exit"
1010
},
1111
"devDependencies": {
12-
"firebase": "9.6.4",
12+
"firebase": "9.6.5",
1313
"chai": "4.3.4",
1414
"chromedriver": "94.0.0",
1515
"express": "4.17.1",
1616
"geckodriver": "2.0.4",
1717
"mocha": "9.1.1",
18-
"node-fetch": "2.6.5",
18+
"node-fetch": "2.6.7",
1919
"selenium-assistant": "6.1.0"
2020
}
2121
}

packages/analytics-compat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@firebase/app-compat": "0.x"
2424
},
2525
"devDependencies": {
26-
"@firebase/app-compat": "0.1.15",
26+
"@firebase/app-compat": "0.1.16",
2727
"rollup": "2.57.0",
2828
"@rollup/plugin-json": "4.1.0",
2929
"rollup-plugin-typescript2": "0.30.0",

packages/analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
"license": "Apache-2.0",
4949
"devDependencies": {
50-
"@firebase/app": "0.7.14",
50+
"@firebase/app": "0.7.15",
5151
"rollup": "2.57.0",
5252
"@rollup/plugin-commonjs": "21.0.0",
5353
"@rollup/plugin-json": "4.1.0",

packages/app-check-compat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"license": "Apache-2.0",
4444
"devDependencies": {
45-
"@firebase/app-compat": "0.1.15",
45+
"@firebase/app-compat": "0.1.16",
4646
"rollup": "2.57.0",
4747
"@rollup/plugin-commonjs": "21.0.0",
4848
"@rollup/plugin-json": "4.1.0",

packages/app-check/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"license": "Apache-2.0",
4646
"devDependencies": {
47-
"@firebase/app": "0.7.14",
47+
"@firebase/app": "0.7.15",
4848
"rollup": "2.57.0",
4949
"@rollup/plugin-commonjs": "21.0.0",
5050
"@rollup/plugin-json": "4.1.0",

packages/app-compat/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @firebase/app-compat
22

3+
## 0.1.16
4+
5+
### Patch Changes
6+
7+
- Updated dependencies []:
8+
- @firebase/app@0.7.15
9+
310
## 0.1.15
411

512
### Patch Changes

packages/app-compat/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/app-compat",
3-
"version": "0.1.15",
3+
"version": "0.1.16",
44
"description": "The primary entrypoint to the Firebase JS SDK",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/index.cjs.js",
@@ -39,7 +39,7 @@
3939
},
4040
"license": "Apache-2.0",
4141
"dependencies": {
42-
"@firebase/app": "0.7.14",
42+
"@firebase/app": "0.7.15",
4343
"@firebase/util": "1.4.3",
4444
"@firebase/logger": "0.3.2",
4545
"@firebase/component": "0.5.10",

packages/app/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @firebase/app
22

3+
## 0.7.15
4+
5+
### Patch Changes
6+
7+
- Update SDK_VERSION.
8+
39
## 0.7.14
410

511
### Patch Changes

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/app",
3-
"version": "0.7.14",
3+
"version": "0.7.15",
44
"description": "The primary entrypoint to the Firebase JS SDK",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/index.cjs.js",

packages/auth-compat/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @firebase/auth-compat
22

3+
## 0.2.7
4+
5+
### Patch Changes
6+
7+
- [`4983f4d5a`](https://github.com/firebase/firebase-js-sdk/commit/4983f4d5a0dc385c5b3e042ace44c8204d3cce81) [#5923](https://github.com/firebase/firebase-js-sdk/pull/5923) - Fix errors in compatibility layer when cookies are fully disabled in Chrome
8+
9+
* [`d612d6f6e`](https://github.com/firebase/firebase-js-sdk/commit/d612d6f6e4d3113d45427b7df68459c0a3e31a1f) [#5928](https://github.com/firebase/firebase-js-sdk/pull/5928) - Upgrade `node-fetch` dependency due to a security issue.
10+
11+
* Updated dependencies [[`4983f4d5a`](https://github.com/firebase/firebase-js-sdk/commit/4983f4d5a0dc385c5b3e042ace44c8204d3cce81), [`d612d6f6e`](https://github.com/firebase/firebase-js-sdk/commit/d612d6f6e4d3113d45427b7df68459c0a3e31a1f), [`e04b7452b`](https://github.com/firebase/firebase-js-sdk/commit/e04b7452bae10e6525cfb9c551f76a1aa98f9078), [`2820674b8`](https://github.com/firebase/firebase-js-sdk/commit/2820674b848e918ab164e7d0ec9d5b838bbfa6e0)]:
12+
- @firebase/auth@0.19.7
13+
314
## 0.2.6
415

516
### Patch Changes

packages/auth-compat/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firebase/auth-compat",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"description": "FirebaseAuth compatibility package that uses API style compatible with Firebase@8 and prior versions",
55
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
66
"main": "dist/index.node.cjs.js",
@@ -43,17 +43,17 @@
4343
"@firebase/app-compat": "0.x"
4444
},
4545
"dependencies": {
46-
"@firebase/auth": "0.19.6",
46+
"@firebase/auth": "0.19.7",
4747
"@firebase/auth-types": "0.11.0",
4848
"@firebase/component": "0.5.10",
4949
"@firebase/util": "1.4.3",
50-
"node-fetch": "2.6.5",
50+
"node-fetch": "2.6.7",
5151
"selenium-webdriver": "^4.0.0-beta.2",
5252
"tslib": "^2.1.0"
5353
},
5454
"license": "Apache-2.0",
5555
"devDependencies": {
56-
"@firebase/app-compat": "0.1.15",
56+
"@firebase/app-compat": "0.1.16",
5757
"@rollup/plugin-json": "4.1.0",
5858
"rollup": "2.57.0",
5959
"rollup-plugin-replace": "2.2.0",

packages/auth-compat/src/auth.test.ts

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ import * as sinon from 'sinon';
2323
import sinonChai from 'sinon-chai';
2424
import { Auth } from './auth';
2525
import { CompatPopupRedirectResolver } from './popup_redirect';
26+
import * as platform from './platform';
2627

2728
use(sinonChai);
2829

30+
function delay(ms: number): Promise<void> {
31+
return new Promise(resolve => setTimeout(resolve, ms));
32+
}
33+
2934
// For the most part, the auth methods just call straight through. Some parts
3035
// of the auth compat layer are more complicated: these tests cover those
3136
describe('auth compat', () => {
@@ -45,7 +50,7 @@ describe('auth compat', () => {
4550
});
4651

4752
afterEach(() => {
48-
sinon.restore;
53+
sinon.restore();
4954
});
5055

5156
it('saves the persistence into session storage if available', async () => {
@@ -75,6 +80,40 @@ describe('auth compat', () => {
7580
}
7681
});
7782

83+
it('does not save persistence if property throws DOMException', async () => {
84+
if (typeof self !== 'undefined') {
85+
sinon.stub(platform, '_getSelfWindow').returns({
86+
get sessionStorage(): Storage {
87+
throw new DOMException('Nope!');
88+
}
89+
} as unknown as Window);
90+
const setItemSpy = sinon.spy(sessionStorage, 'setItem');
91+
sinon.stub(underlyingAuth, '_getPersistence').returns('TEST');
92+
sinon
93+
.stub(underlyingAuth, '_initializationPromise')
94+
.value(Promise.resolve());
95+
sinon.stub(
96+
exp._getInstance<exp.PopupRedirectResolverInternal>(
97+
CompatPopupRedirectResolver
98+
),
99+
'_openRedirect'
100+
);
101+
providerStub.isInitialized.returns(true);
102+
providerStub.getImmediate.returns(underlyingAuth);
103+
const authCompat = new Auth(
104+
app,
105+
providerStub as unknown as Provider<'auth'>
106+
);
107+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
108+
await authCompat.signInWithRedirect(new exp.GoogleAuthProvider());
109+
await delay(50);
110+
expect(setItemSpy).not.to.have.been.calledWith(
111+
'firebase:persistence:api-key:undefined',
112+
'TEST'
113+
);
114+
}
115+
});
116+
78117
it('pulls the persistence and sets as the main persitsence if set', () => {
79118
if (typeof self !== 'undefined') {
80119
sessionStorage.setItem(
@@ -98,5 +137,35 @@ describe('auth compat', () => {
98137
});
99138
}
100139
});
140+
141+
it('does not die if sessionStorage errors', async () => {
142+
if (typeof self !== 'undefined') {
143+
sinon.stub(platform, '_getSelfWindow').returns({
144+
get sessionStorage(): Storage {
145+
throw new DOMException('Nope!');
146+
}
147+
} as unknown as Window);
148+
sessionStorage.setItem(
149+
'firebase:persistence:api-key:undefined',
150+
'none'
151+
);
152+
providerStub.isInitialized.returns(false);
153+
providerStub.initialize.returns(underlyingAuth);
154+
new Auth(app, providerStub as unknown as Provider<'auth'>);
155+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
156+
await delay(50);
157+
expect(providerStub.initialize).to.have.been.calledWith({
158+
options: {
159+
popupRedirectResolver: CompatPopupRedirectResolver,
160+
persistence: [
161+
exp.indexedDBLocalPersistence,
162+
exp.browserLocalPersistence,
163+
exp.browserSessionPersistence,
164+
exp.inMemoryPersistence
165+
]
166+
}
167+
});
168+
}
169+
});
101170
});
102171
});

packages/auth-compat/src/persistence.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import * as exp from '@firebase/auth/internal';
1919
import { isIndexedDBAvailable, isNode, isReactNative } from '@firebase/util';
20-
import { _isWebStorageSupported, _isWorker } from './platform';
20+
import { _getSelfWindow, _isWebStorageSupported, _isWorker } from './platform';
2121

2222
export const Persistence = {
2323
LOCAL: 'local',
@@ -84,29 +84,28 @@ export async function _savePersistenceForRedirect(
8484
auth: exp.AuthInternal
8585
): Promise<void> {
8686
await auth._initializationPromise;
87-
88-
const win = getSelfWindow();
87+
const session = getSessionStorageIfAvailable();
8988
const key = exp._persistenceKeyName(
9089
PERSISTENCE_KEY,
9190
auth.config.apiKey,
9291
auth.name
9392
);
94-
if (win?.sessionStorage) {
95-
win.sessionStorage.setItem(key, auth._getPersistence());
93+
if (session) {
94+
session.setItem(key, auth._getPersistence());
9695
}
9796
}
9897

9998
export function _getPersistencesFromRedirect(
10099
apiKey: string,
101100
appName: string
102101
): exp.Persistence[] {
103-
const win = getSelfWindow();
104-
if (!win?.sessionStorage) {
102+
const session = getSessionStorageIfAvailable();
103+
if (!session) {
105104
return [];
106105
}
107106

108107
const key = exp._persistenceKeyName(PERSISTENCE_KEY, apiKey, appName);
109-
const persistence = win.sessionStorage.getItem(key);
108+
const persistence = session.getItem(key);
110109

111110
switch (persistence) {
112111
case Persistence.NONE:
@@ -120,6 +119,11 @@ export function _getPersistencesFromRedirect(
120119
}
121120
}
122121

123-
function getSelfWindow(): Window | null {
124-
return typeof window !== 'undefined' ? window : null;
122+
/** Returns session storage, or null if the property access errors */
123+
function getSessionStorageIfAvailable(): Storage | null {
124+
try {
125+
return _getSelfWindow()?.sessionStorage || null;
126+
} catch (e) {
127+
return null;
128+
}
125129
}

packages/auth-compat/src/platform.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,7 @@ export async function _isCordova(): Promise<boolean> {
171171
});
172172
});
173173
}
174+
175+
export function _getSelfWindow(): Window | null {
176+
return typeof window !== 'undefined' ? window : null;
177+
}

packages/auth/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @firebase/auth
22

3+
## 0.19.7
4+
5+
### Patch Changes
6+
7+
- [`4983f4d5a`](https://github.com/firebase/firebase-js-sdk/commit/4983f4d5a0dc385c5b3e042ace44c8204d3cce81) [#5923](https://github.com/firebase/firebase-js-sdk/pull/5923) - Fix errors in compatibility layer when cookies are fully disabled in Chrome
8+
9+
* [`d612d6f6e`](https://github.com/firebase/firebase-js-sdk/commit/d612d6f6e4d3113d45427b7df68459c0a3e31a1f) [#5928](https://github.com/firebase/firebase-js-sdk/pull/5928) - Upgrade `node-fetch` dependency due to a security issue.
10+
11+
- [`e04b7452b`](https://github.com/firebase/firebase-js-sdk/commit/e04b7452bae10e6525cfb9c551f76a1aa98f9078) [#5924](https://github.com/firebase/firebase-js-sdk/pull/5924) (fixes [#5922](https://github.com/firebase/firebase-js-sdk/issues/5922)) - Add missing PhoneMultiFactorInfo public interface
12+
13+
* [`2820674b8`](https://github.com/firebase/firebase-js-sdk/commit/2820674b848e918ab164e7d0ec9d5b838bbfa6e0) [#5927](https://github.com/firebase/firebase-js-sdk/pull/5927) - Prevent React Native from logging a warning about deprecation of `AsyncStorage` if the developer has provided the non-deprecated version.
14+
315
## 0.19.6
416

517
### Patch Changes

0 commit comments

Comments
 (0)