Skip to content

Commit 48ad584

Browse files
Merge master into release
2 parents a084f84 + e06d906 commit 48ad584

File tree

27 files changed

+131
-109
lines changed

27 files changed

+131
-109
lines changed

.changeset/curly-mirrors-occur.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+
Included a reference to AuthInternal in MultiFactorSessionImpl.

.changeset/eleven-moons-shave.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@firebase/firestore": minor
3+
"@firebase/webchannel-wrapper": minor
4+
---
5+
6+
Enable encodeInitMessageHeaders. This transitions the Firestore client from encoding HTTP Headers via the Query Param to the request's POST payload.
7+
8+
Requires Cloud Firestore Emulator v1.14.4 or newer.

.changeset/spotty-pillows-applaud.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+
Update custom claim type of `ParsedToken` to be `any`

common/api-review/auth.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ export function parseActionCodeURL(link: string): ActionCodeURL | null;
538538

539539
// @public
540540
export interface ParsedToken {
541-
[key: string]: string | object | undefined;
541+
[key: string]: any;
542542
'auth_time'?: string;
543543
'exp'?: string;
544544
'firebase'?: {

packages/auth/karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ function getTestFiles(argv) {
5454
}
5555

5656
function getTestBrowsers(argv) {
57-
let browsers = ["ChromeHeadless"];
57+
let browsers = ['ChromeHeadless'];
5858
if (process.env?.BROWSERS && argv.unit) {
5959
browsers = process.env?.BROWSERS?.split(',');
60-
}
60+
}
6161
return browsers;
6262
}
6363

packages/auth/src/api/account_management/mfa.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('api/account_management/startEnrollPhoneMfa', () => {
5252
afterEach(mockFetch.tearDown);
5353

5454
it('should POST to the correct endpoint', async () => {
55-
const mock = mockEndpoint(Endpoint.START_PHONE_MFA_ENROLLMENT, {
55+
const mock = mockEndpoint(Endpoint.START_MFA_ENROLLMENT, {
5656
phoneSessionInfo: {
5757
sessionInfo: 'session-info'
5858
}
@@ -72,7 +72,7 @@ describe('api/account_management/startEnrollPhoneMfa', () => {
7272

7373
it('should handle errors', async () => {
7474
const mock = mockEndpoint(
75-
Endpoint.START_PHONE_MFA_ENROLLMENT,
75+
Endpoint.START_MFA_ENROLLMENT,
7676
{
7777
error: {
7878
code: 400,
@@ -116,7 +116,7 @@ describe('api/account_management/finalizeEnrollPhoneMfa', () => {
116116
afterEach(mockFetch.tearDown);
117117

118118
it('should POST to the correct endpoint', async () => {
119-
const mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT, {
119+
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_ENROLLMENT, {
120120
idToken: 'id-token',
121121
refreshToken: 'refresh-token'
122122
});
@@ -136,7 +136,7 @@ describe('api/account_management/finalizeEnrollPhoneMfa', () => {
136136

137137
it('should handle errors', async () => {
138138
const mock = mockEndpoint(
139-
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
139+
Endpoint.FINALIZE_MFA_ENROLLMENT,
140140
{
141141
error: {
142142
code: 400,

packages/auth/src/api/account_management/mfa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function startEnrollPhoneMfa(
7171
>(
7272
auth,
7373
HttpMethod.POST,
74-
Endpoint.START_PHONE_MFA_ENROLLMENT,
74+
Endpoint.START_MFA_ENROLLMENT,
7575
_addTidIfNecessary(auth, request)
7676
);
7777
}
@@ -96,7 +96,7 @@ export function finalizeEnrollPhoneMfa(
9696
>(
9797
auth,
9898
HttpMethod.POST,
99-
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
99+
Endpoint.FINALIZE_MFA_ENROLLMENT,
100100
_addTidIfNecessary(auth, request)
101101
);
102102
}

packages/auth/src/api/authentication/mfa.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('api/authentication/startSignInPhoneMfa', () => {
4848
afterEach(mockFetch.tearDown);
4949

5050
it('should POST to the correct endpoint', async () => {
51-
const mock = mockEndpoint(Endpoint.START_PHONE_MFA_SIGN_IN, {
51+
const mock = mockEndpoint(Endpoint.START_MFA_SIGN_IN, {
5252
phoneResponseInfo: {
5353
sessionInfo: 'session-info'
5454
}
@@ -68,7 +68,7 @@ describe('api/authentication/startSignInPhoneMfa', () => {
6868

6969
it('should handle errors', async () => {
7070
const mock = mockEndpoint(
71-
Endpoint.START_PHONE_MFA_SIGN_IN,
71+
Endpoint.START_MFA_SIGN_IN,
7272
{
7373
error: {
7474
code: 400,
@@ -112,7 +112,7 @@ describe('api/authentication/finalizeSignInPhoneMfa', () => {
112112
afterEach(mockFetch.tearDown);
113113

114114
it('should POST to the correct endpoint', async () => {
115-
const mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_SIGN_IN, {
115+
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, {
116116
idToken: 'id-token',
117117
refreshToken: 'refresh-token'
118118
});
@@ -132,7 +132,7 @@ describe('api/authentication/finalizeSignInPhoneMfa', () => {
132132

133133
it('should handle errors', async () => {
134134
const mock = mockEndpoint(
135-
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
135+
Endpoint.FINALIZE_MFA_SIGN_IN,
136136
{
137137
error: {
138138
code: 400,

packages/auth/src/api/authentication/mfa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function startSignInPhoneMfa(
6868
>(
6969
auth,
7070
HttpMethod.POST,
71-
Endpoint.START_PHONE_MFA_SIGN_IN,
71+
Endpoint.START_MFA_SIGN_IN,
7272
_addTidIfNecessary(auth, request)
7373
);
7474
}
@@ -91,7 +91,7 @@ export function finalizeSignInPhoneMfa(
9191
>(
9292
auth,
9393
HttpMethod.POST,
94-
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
94+
Endpoint.FINALIZE_MFA_SIGN_IN,
9595
_addTidIfNecessary(auth, request)
9696
);
9797
}

packages/auth/src/api/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ export const enum Endpoint {
6060
SET_ACCOUNT_INFO = '/v1/accounts:update',
6161
GET_ACCOUNT_INFO = '/v1/accounts:lookup',
6262
GET_RECAPTCHA_PARAM = '/v1/recaptchaParams',
63-
START_PHONE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:start',
64-
FINALIZE_PHONE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:finalize',
65-
START_PHONE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:start',
66-
FINALIZE_PHONE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:finalize',
63+
START_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:start',
64+
FINALIZE_MFA_ENROLLMENT = '/v2/accounts/mfaEnrollment:finalize',
65+
START_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:start',
66+
FINALIZE_MFA_SIGN_IN = '/v2/accounts/mfaSignIn:finalize',
6767
WITHDRAW_MFA = '/v2/accounts/mfaEnrollment:withdraw',
6868
GET_PROJECT_CONFIG = '/v1/projects'
6969
}

packages/auth/src/core/util/version.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ describe('core/util/_getClientVersion', () => {
4242
context('worker', () => {
4343
it('should set the correct version', () => {
4444
expect(_getClientVersion(ClientPlatform.WORKER)).to.eq(
45-
`${_getBrowserName(getUA())}-Worker/JsCore/${SDK_VERSION}/FirebaseCore-web`
45+
`${_getBrowserName(
46+
getUA()
47+
)}-Worker/JsCore/${SDK_VERSION}/FirebaseCore-web`
4648
);
4749
});
4850
});

packages/auth/src/mfa/mfa_resolver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('core/mfa/mfa_resolver/MultiFactorResolver', () => {
114114
};
115115

116116
beforeEach(() => {
117-
mock = mockEndpoint(Endpoint.FINALIZE_PHONE_MFA_SIGN_IN, {
117+
mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, {
118118
idToken: finalIdToken,
119119
refreshToken: 'final-refresh-token'
120120
});

packages/auth/src/mfa/mfa_session.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
import { AuthInternal } from '../model/auth';
1718
import { MultiFactorSession } from '../model/public_types';
1819

1920
export const enum MultiFactorSessionType {
@@ -31,11 +32,19 @@ interface SerializedMultiFactorSession {
3132
export class MultiFactorSessionImpl implements MultiFactorSession {
3233
private constructor(
3334
readonly type: MultiFactorSessionType,
34-
readonly credential: string
35+
readonly credential: string,
36+
readonly auth?: AuthInternal
3537
) {}
3638

37-
static _fromIdtoken(idToken: string): MultiFactorSessionImpl {
38-
return new MultiFactorSessionImpl(MultiFactorSessionType.ENROLL, idToken);
39+
static _fromIdtoken(
40+
idToken: string,
41+
auth?: AuthInternal
42+
): MultiFactorSessionImpl {
43+
return new MultiFactorSessionImpl(
44+
MultiFactorSessionType.ENROLL,
45+
idToken,
46+
auth
47+
);
3948
}
4049

4150
static _fromMfaPendingCredential(

packages/auth/src/mfa/mfa_user.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ describe('core/mfa/mfa_user/MultiFactorUser', () => {
8484
expect(mfaSession.type).to.eq(MultiFactorSessionType.ENROLL);
8585
expect(mfaSession.credential).to.eq('access-token');
8686
});
87+
it('should contain a reference to auth', async () => {
88+
const mfaSession = (await mfaUser.getSession()) as MultiFactorSessionImpl;
89+
expect(mfaSession.type).to.eq(MultiFactorSessionType.ENROLL);
90+
expect(mfaSession.credential).to.eq('access-token');
91+
expect(mfaSession.auth).to.eq(auth);
92+
});
8793
});
8894

8995
describe('enroll', () => {

packages/auth/src/mfa/mfa_user.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ export class MultiFactorUserImpl implements MultiFactorUser {
4949
}
5050

5151
async getSession(): Promise<MultiFactorSession> {
52-
return MultiFactorSessionImpl._fromIdtoken(await this.user.getIdToken());
52+
return MultiFactorSessionImpl._fromIdtoken(
53+
await this.user.getIdToken(),
54+
this.user.auth
55+
);
5356
}
5457

5558
async enroll(

packages/auth/src/model/public_types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
/* eslint-disable @typescript-eslint/no-explicit-any */
19+
1820
import { FirebaseApp } from '@firebase/app';
1921
import {
2022
CompleteFn,
@@ -104,7 +106,7 @@ export interface ParsedToken {
104106
'identities'?: Record<string, string>;
105107
};
106108
/** Map of any additional custom claims. */
107-
[key: string]: string | object | undefined;
109+
[key: string]: any;
108110
}
109111

110112
/**

packages/auth/src/platform_browser/mfa/assertions/phone.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@ describe('platform_browser/mfa/phone', () => {
5858

5959
describe('enroll', () => {
6060
beforeEach(() => {
61-
session = MultiFactorSessionImpl._fromIdtoken('enrollment-id-token');
61+
session = MultiFactorSessionImpl._fromIdtoken(
62+
'enrollment-id-token',
63+
auth
64+
);
6265
});
6366

6467
it('should finalize the MFA enrollment', async () => {
6568
const mock = mockEndpoint(
66-
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
69+
Endpoint.FINALIZE_MFA_ENROLLMENT,
6770
serverResponse
6871
);
6972
const response = await assertion._process(auth, session);
@@ -75,12 +78,13 @@ describe('platform_browser/mfa/phone', () => {
7578
sessionInfo: 'verification-id'
7679
}
7780
});
81+
expect(session.auth).to.eql(auth);
7882
});
7983

8084
context('with display name', () => {
8185
it('should set the display name', async () => {
8286
const mock = mockEndpoint(
83-
Endpoint.FINALIZE_PHONE_MFA_ENROLLMENT,
87+
Endpoint.FINALIZE_MFA_ENROLLMENT,
8488
serverResponse
8589
);
8690
const response = await assertion._process(
@@ -97,6 +101,7 @@ describe('platform_browser/mfa/phone', () => {
97101
sessionInfo: 'verification-id'
98102
}
99103
});
104+
expect(session.auth).to.eql(auth);
100105
});
101106
});
102107
});
@@ -109,10 +114,7 @@ describe('platform_browser/mfa/phone', () => {
109114
});
110115

111116
it('should finalize the MFA sign in', async () => {
112-
const mock = mockEndpoint(
113-
Endpoint.FINALIZE_PHONE_MFA_SIGN_IN,
114-
serverResponse
115-
);
117+
const mock = mockEndpoint(Endpoint.FINALIZE_MFA_SIGN_IN, serverResponse);
116118
const response = await assertion._process(auth, session);
117119
expect(response).to.eql(serverResponse);
118120
expect(mock.calls[0].request).to.eql({
@@ -122,6 +124,7 @@ describe('platform_browser/mfa/phone', () => {
122124
sessionInfo: 'verification-id'
123125
}
124126
});
127+
expect(session.auth).to.eql(undefined);
125128
});
126129
});
127130
});

packages/auth/src/platform_browser/persistence/session_storage.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ describe('platform_browser/persistence/session_storage', () => {
6666
afterEach(() => sinon.restore());
6767

6868
it('should emit false if sessionStorage setItem throws', async () => {
69-
sinon.stub(Storage.prototype, 'setItem').throws(new Error('nope'));
70-
expect(await persistence._isAvailable()).to.be.false;
69+
sinon.stub(Storage.prototype, 'setItem').throws(new Error('nope'));
70+
expect(await persistence._isAvailable()).to.be.false;
7171
});
7272

7373
it('should emit false if sessionStorage removeItem throws', async () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe('platform_browser/strategies/phone', () => {
323323
});
324324

325325
it('works with an enrollment flow', async () => {
326-
const endpoint = mockEndpoint(Endpoint.START_PHONE_MFA_ENROLLMENT, {
326+
const endpoint = mockEndpoint(Endpoint.START_MFA_ENROLLMENT, {
327327
phoneSessionInfo: {
328328
sessionInfo: 'session-info'
329329
}
@@ -345,7 +345,7 @@ describe('platform_browser/strategies/phone', () => {
345345
});
346346

347347
it('works when completing the sign in flow', async () => {
348-
const endpoint = mockEndpoint(Endpoint.START_PHONE_MFA_SIGN_IN, {
348+
const endpoint = mockEndpoint(Endpoint.START_MFA_SIGN_IN, {
349349
phoneResponseInfo: {
350350
sessionInfo: 'session-info'
351351
}

packages/auth/src/platform_cordova/popup_redirect/events.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ describe('platform_cordova/popup_redirect/events', () => {
7373
const spy = sinon.spy(Storage.prototype, 'setItem');
7474
const event = _generateNewEvent(auth, AuthEventType.REAUTH_VIA_REDIRECT);
7575
await _savePartialEvent(auth, event);
76-
expect(spy).to.have.been.calledWith('firebase:authEvent:test-api-key:test-app',
77-
JSON.stringify(event));
76+
expect(spy).to.have.been.calledWith(
77+
'firebase:authEvent:test-api-key:test-app',
78+
JSON.stringify(event)
79+
);
7880
});
7981
});
8082

packages/firestore/src/local/index_backfiller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ import { isIndexedDbTransactionError } from './simple_db';
3535
const LOG_TAG = 'IndexBackiller';
3636

3737
/** How long we wait to try running index backfill after SDK initialization. */
38-
const INITIAL_BACKFILL_DELAY_MS = 15;
38+
const INITIAL_BACKFILL_DELAY_MS = 15 * 1000;
3939

4040
/** Minimum amount of time between backfill checks, after the first one. */
41-
const REGULAR_BACKFILL_DELAY_MS = 1;
41+
const REGULAR_BACKFILL_DELAY_MS = 60 * 1000;
4242

4343
/** The maximum number of documents to process each time backfill() is called. */
4444
const MAX_DOCUMENTS_TO_PROCESS = 50;

0 commit comments

Comments
 (0)