Skip to content

Commit

Permalink
Merge branch 'master' into Fixing-interdependency-in-mfa-totp-Integra…
Browse files Browse the repository at this point in the history
…tion-tests-ax
  • Loading branch information
AngelAngelXie authored Jun 12, 2023
2 parents 51ab498 + e522056 commit c114277
Show file tree
Hide file tree
Showing 46 changed files with 116 additions and 74 deletions.
5 changes: 0 additions & 5 deletions .changeset/giant-bees-clean.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/shaggy-donkeys-know.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report_v2.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 🐞 Bug Report
description: File a bug report
title: 'Title for the bug'
labels: 'new, type: question'
labels: 'question, new'
body:
- type: markdown
id: before-you-start
Expand Down
4 changes: 2 additions & 2 deletions integration/compat-interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"test:debug": "karma start --browsers Chrome --auto-watch"
},
"dependencies": {
"@firebase/app": "0.9.11",
"@firebase/app-compat": "0.2.11",
"@firebase/app": "0.9.12",
"@firebase/app-compat": "0.2.12",
"@firebase/analytics": "0.10.0",
"@firebase/analytics-compat": "0.2.6",
"@firebase/auth": "0.23.2",
Expand Down
2 changes: 1 addition & 1 deletion integration/firebase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test"
},
"devDependencies": {
"firebase": "9.22.1",
"firebase": "9.22.2",
"@types/chai": "4.3.4",
"@types/mocha": "9.1.1",
"chai": "4.3.7",
Expand Down
4 changes: 2 additions & 2 deletions integration/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"test:memory:debug": "yarn build:memory; karma start --auto-watch --browsers Chrome"
},
"dependencies": {
"@firebase/app": "0.9.11",
"@firebase/firestore": "3.12.1"
"@firebase/app": "0.9.12",
"@firebase/firestore": "3.12.2"
},
"devDependencies": {
"@types/mocha": "9.1.1",
Expand Down
2 changes: 1 addition & 1 deletion integration/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test:manual": "mocha --exit"
},
"devDependencies": {
"firebase": "9.22.1",
"firebase": "9.22.2",
"chai": "4.3.7",
"chromedriver": "98.0.1",
"express": "4.18.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@firebase/app-compat": "0.x"
},
"devDependencies": {
"@firebase/app-compat": "0.2.11",
"@firebase/app-compat": "0.2.12",
"rollup": "2.79.1",
"@rollup/plugin-json": "4.1.0",
"rollup-plugin-typescript2": "0.31.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app": "0.9.11",
"@firebase/app": "0.9.12",
"rollup": "2.79.1",
"@rollup/plugin-commonjs": "21.1.0",
"@rollup/plugin-json": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-check-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app-compat": "0.2.11",
"@firebase/app-compat": "0.2.12",
"rollup": "2.79.1",
"@rollup/plugin-commonjs": "21.1.0",
"@rollup/plugin-json": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app": "0.9.11",
"@firebase/app": "0.9.12",
"rollup": "2.79.1",
"@rollup/plugin-commonjs": "21.1.0",
"@rollup/plugin-json": "4.1.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/app-compat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @firebase/app-compat

## 0.2.12

### Patch Changes

- Updated dependencies []:
- @firebase/app@0.9.12

## 0.2.11

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/app-compat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebase/app-compat",
"version": "0.2.11",
"version": "0.2.12",
"description": "The primary entrypoint to the Firebase JS SDK",
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@firebase/app": "0.9.11",
"@firebase/app": "0.9.12",
"@firebase/util": "1.9.3",
"@firebase/logger": "0.4.0",
"@firebase/component": "0.6.4",
Expand Down
6 changes: 6 additions & 0 deletions packages/app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @firebase/app

## 0.9.12

### Patch Changes

- Update SDK_VERSION.

## 0.9.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebase/app",
"version": "0.9.11",
"version": "0.9.12",
"description": "The primary entrypoint to the Firebase JS SDK",
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app-compat": "0.2.11",
"@firebase/app-compat": "0.2.12",
"@rollup/plugin-json": "4.1.0",
"rollup": "2.79.1",
"rollup-plugin-replace": "2.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@firebase/app": "0.9.11",
"@firebase/app": "0.9.12",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-strip": "2.1.0",
"chromedriver": "98.0.1",
Expand Down
18 changes: 12 additions & 6 deletions packages/auth/src/mfa/assertions/totp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import { MultiFactorAssertionImpl } from '../mfa_assertion';

use(chaiAsPromised);

const fakeUid: string = 'uid';

describe('core/mfa/assertions/totp/TotpMultiFactorGenerator', () => {
let auth: TestAuth;
let session: MultiFactorSessionImpl;
Expand Down Expand Up @@ -82,7 +84,7 @@ describe('core/mfa/assertions/totp/TotpMultiFactorGenerator', () => {
});
afterEach(mockFetch.tearDown);

it('should throw error if auth instance is not found in mfaSession', async () => {
it('should throw error if user instance is not found in mfaSession', async () => {
try {
session = MultiFactorSessionImpl._fromIdtoken(
'enrollment-id-token',
Expand All @@ -100,9 +102,10 @@ describe('core/mfa/assertions/totp/TotpMultiFactorGenerator', () => {
);

auth = await testAuth();
const user = await testUser(auth, fakeUid);
session = MultiFactorSessionImpl._fromIdtoken(
'enrollment-id-token',
auth
user
);
const secret = await TotpMultiFactorGenerator.generateSecret(session);
expect(mock.calls[0].request).to.eql({
Expand Down Expand Up @@ -159,10 +162,11 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
afterEach(mockFetch.tearDown);

describe('enroll', () => {
const user = testUser(auth, fakeUid);
beforeEach(() => {
session = MultiFactorSessionImpl._fromIdtoken(
'enrollment-id-token',
auth
user
);
});

Expand All @@ -180,7 +184,8 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
sessionInfo: 'verification-id'
}
});
expect(session.auth).to.eql(auth);
expect(session.user).to.not.be.undefined;
expect(session.user).to.eql(user);
});

context('with display name', () => {
Expand All @@ -203,7 +208,8 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
sessionInfo: 'verification-id'
}
});
expect(session.auth).to.eql(auth);
expect(session.user).to.not.be.undefined;
expect(session.user).to.eql(user);
});
});
});
Expand Down Expand Up @@ -299,7 +305,7 @@ describe('core/mfa/assertions/totp/TotpSecret', async () => {
describe('generateQrCodeUrl', () => {
beforeEach(async () => {
await auth.updateCurrentUser(
testUser(_castAuth(auth), 'uid', fakeEmail, true)
testUser(_castAuth(auth), fakeUid, fakeEmail, true)
);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/auth/src/mfa/assertions/totp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ export class TotpMultiFactorGenerator {
): Promise<TotpSecret> {
const mfaSession = session as MultiFactorSessionImpl;
_assert(
typeof mfaSession.auth !== 'undefined',
typeof mfaSession.user?.auth !== 'undefined',
AuthErrorCode.INTERNAL_ERROR
);
const response = await startEnrollTotpMfa(mfaSession.auth, {
const response = await startEnrollTotpMfa(mfaSession.user.auth, {
idToken: mfaSession.credential,
totpEnrollmentInfo: {}
});
return TotpSecret._fromStartTotpMfaEnrollmentResponse(
response,
mfaSession.auth
mfaSession.user.auth
);
}

Expand Down
9 changes: 5 additions & 4 deletions packages/auth/src/mfa/mfa_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AuthInternal } from '../model/auth';

import { UserInternal } from '../model/user';
import { MultiFactorSession } from '../model/public_types';

export const enum MultiFactorSessionType {
Expand All @@ -33,17 +34,17 @@ export class MultiFactorSessionImpl implements MultiFactorSession {
private constructor(
readonly type: MultiFactorSessionType,
readonly credential: string,
readonly auth?: AuthInternal
readonly user?: UserInternal
) {}

static _fromIdtoken(
idToken: string,
auth?: AuthInternal
user?: UserInternal
): MultiFactorSessionImpl {
return new MultiFactorSessionImpl(
MultiFactorSessionType.ENROLL,
idToken,
auth
user
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/mfa/mfa_user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('core/mfa/mfa_user/MultiFactorUser', () => {
const mfaSession = (await mfaUser.getSession()) as MultiFactorSessionImpl;
expect(mfaSession.type).to.eq(MultiFactorSessionType.ENROLL);
expect(mfaSession.credential).to.eq('access-token');
expect(mfaSession.auth).to.eq(auth);
expect(mfaSession.user?.auth).to.eq(auth);
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/mfa/mfa_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class MultiFactorUserImpl implements MultiFactorUser {
async getSession(): Promise<MultiFactorSession> {
return MultiFactorSessionImpl._fromIdtoken(
await this.user.getIdToken(),
this.user.auth
this.user
);
}

Expand Down
17 changes: 12 additions & 5 deletions packages/auth/src/platform_browser/mfa/assertions/phone.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import { expect, use } from 'chai';
import chaiAsPromised from 'chai-as-promised';

import { mockEndpoint } from '../../../../test/helpers/api/helper';
import { testAuth, TestAuth } from '../../../../test/helpers/mock_auth';
import {
testAuth,
TestAuth,
testUser
} from '../../../../test/helpers/mock_auth';
import * as mockFetch from '../../../../test/helpers/mock_fetch';
import { Endpoint } from '../../../api';
import { FinalizeMfaResponse } from '../../../api/authentication/mfa';
Expand Down Expand Up @@ -57,10 +61,11 @@ describe('platform_browser/mfa/phone', () => {
afterEach(mockFetch.tearDown);

describe('enroll', () => {
const user = testUser(auth, 'uid');
beforeEach(() => {
session = MultiFactorSessionImpl._fromIdtoken(
'enrollment-id-token',
auth
user
);
});

Expand All @@ -78,7 +83,8 @@ describe('platform_browser/mfa/phone', () => {
sessionInfo: 'verification-id'
}
});
expect(session.auth).to.eql(auth);
expect(session.user).to.not.be.undefined;
expect(session.user).to.eql(user);
});

context('with display name', () => {
Expand All @@ -101,7 +107,8 @@ describe('platform_browser/mfa/phone', () => {
sessionInfo: 'verification-id'
}
});
expect(session.auth).to.eql(auth);
expect(session.user).to.not.be.undefined;
expect(session.user).to.eql(user);
});
});
});
Expand All @@ -124,7 +131,7 @@ describe('platform_browser/mfa/phone', () => {
sessionInfo: 'verification-id'
}
});
expect(session.auth).to.eql(undefined);
expect(session.user).to.be.undefined;
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/database-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"tslib": "^2.1.0"
},
"devDependencies": {
"@firebase/app-compat": "0.2.11",
"@firebase/app-compat": "0.2.12",
"typescript": "4.7.4"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"tslib": "^2.1.0"
},
"devDependencies": {
"@firebase/app": "0.9.11",
"@firebase/app": "0.9.12",
"rollup": "2.79.1",
"rollup-plugin-typescript2": "0.31.2",
"typescript": "4.7.4"
Expand Down
12 changes: 12 additions & 0 deletions packages/firebase/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# firebase

## 9.22.2

### Patch Changes

- [`4a86f4eb0`](https://github.com/firebase/firebase-js-sdk/commit/4a86f4eb0c606443ac01d99a9169e4074d5d21dc) [#7294](https://github.com/firebase/firebase-js-sdk/pull/7294) (fixes [#7279](https://github.com/firebase/firebase-js-sdk/issues/7279)) - Fixed the types path for `compat/app`.

- Updated dependencies [[`fe7da7ec3`](https://github.com/firebase/firebase-js-sdk/commit/fe7da7ec3c83c200d7a0c7b90bb6bd27654309ee)]:
- @firebase/app@0.9.12
- @firebase/firestore@3.12.2
- @firebase/app-compat@0.2.12
- @firebase/firestore-compat@0.3.11

## 9.22.1

### Patch Changes
Expand Down
Loading

0 comments on commit c114277

Please sign in to comment.