Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Merging main branch into modular-sdk #1443

Merged
merged 119 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
f3b3caa
chore(core): Automate Daily Integration Tests (#1130)
lahirumaramba Jan 12, 2021
8ae44ce
Updating Google Cloud naming (#1122)
egilmorez Jan 14, 2021
1862342
update typo in interface name (#1138)
suchcodemuchwow Jan 22, 2021
6ce98e2
Improve token verification logic with Auth Emulator. (#1148)
yuchenshi Feb 4, 2021
01d8177
feat: Exporting all types of Messages so they can be used by consumer…
BorntraegerMarc Feb 4, 2021
fc2f557
feat(auth): Implement getUserByProviderId (#769)
rsgowman Feb 8, 2021
a00ce05
Allow enabling of anonymous provider via tenant configuration (#802)
rsgowman Feb 8, 2021
bea66a9
feat(auth): Add ability to link a federated ID with the `updateUser()…
rsgowman Feb 9, 2021
5c60cc4
(chore): Export UserProvider type and add it to toc.yaml (#1165)
lahirumaramba Feb 10, 2021
9585775
[chore] Release 9.5.0 (#1167)
lahirumaramba Feb 10, 2021
93362d5
chore: Updated doc generator for typedoc 0.19.0 (#1166)
hiranya911 Feb 11, 2021
6bcffa2
Update HOME.md (#1181)
egilmorez Feb 26, 2021
994fd43
feat(rtdb): Support emulator mode for rules management operations (#1…
hiranya911 Mar 10, 2021
bf4bacb
fix: Decoupled proactive token refresh from FirebaseApp (#1194)
hiranya911 Mar 18, 2021
738eba7
fix(rtdb): Fixing the RTDB token listener callback (#1203)
hiranya911 Mar 19, 2021
97d3823
Add emulator-based integration tests. (#1155)
yuchenshi Mar 23, 2021
19660d9
Disable one flaky tests in emulator. (#1205)
yuchenshi Mar 25, 2021
2a5b7f6
[chore] Release 9.6.0 (#1209)
hiranya911 Mar 29, 2021
60b4e29
(chore): Add JWT Decoder and Signature Verifier (#1204)
lahirumaramba Mar 30, 2021
1254850
chore: Add Mailgun send email action (#1210)
lahirumaramba Mar 31, 2021
e9e8a03
chore: Fix bug in send-email action code (#1214)
lahirumaramba Apr 1, 2021
1cc82ae
Change dispatch event name in nightly workflow (#1216)
lahirumaramba Apr 1, 2021
d961c3f
chore: Clean up nightly workflow trigger tests (#1212)
lahirumaramba Apr 1, 2021
da0f44f
Add support for FIREBASE_STORAGE_EMULATOR_HOST env var (#1175)
abeisgoat Apr 8, 2021
011c530
Revert "Disable one flaky tests in emulator. (#1205)" (#1227)
yuchenshi Apr 14, 2021
58f60d6
fix(rtdb): Fixing a token refresh livelock in Cloud Functions (#1234)
hiranya911 Apr 23, 2021
be4ebc6
[chore] Release 9.7.0 (#1240)
lahirumaramba Apr 27, 2021
c6e9ef7
fix: adds missing EMAIL_NOT_FOUND error code (#1246)
bojeil-google May 3, 2021
d8b769a
build(deps-dev): bump lodash from 4.17.19 to 4.17.21 (#1255)
dependabot[bot] May 6, 2021
43bfbd9
chore: Upgraded RTDB and other @firebase dependencies (#1250)
hiranya911 May 6, 2021
e65dbcf
build(deps): bump y18n from 3.2.1 to 3.2.2 (#1208)
dependabot[bot] May 6, 2021
3ae6a69
Fix storage emulator env formatting (#1257)
abeisgoat May 10, 2021
8267b56
build(deps): bump hosted-git-info from 2.8.8 to 2.8.9 (#1260)
dependabot[bot] May 10, 2021
b88f891
feat: Add abuse reduction support (#1264)
lahirumaramba May 10, 2021
ab034f5
Fix @types/node conflict with grpc and port type (#1258)
nikhilag May 10, 2021
e5dc9f8
[chore] Release 9.8.0 (#1266)
lahirumaramba May 10, 2021
e759958
build(deps): bump handlebars from 4.7.6 to 4.7.7 (#1253)
dependabot[bot] May 10, 2021
e7155ea
build(deps): bump jose from 2.0.4 to 2.0.5 (#1265)
dependabot[bot] May 10, 2021
fd23ad0
fix: Revert regression introduced in #1257 (#1277)
hiranya911 May 18, 2021
3b48235
fix(auth): make MFA uid optional for updateUser operations (#1278)
bojeil-google May 18, 2021
3a2d2fa
chore: Enabled dependabot (#1279)
hiranya911 May 20, 2021
6bf2aee
chore: Remove gulp-replace dependency (#1285)
hiranya911 May 20, 2021
11f2fb1
build(deps-dev): bump gulp-header from 1.8.12 to 2.0.9 (#1283)
dependabot[bot] May 20, 2021
df3b398
build(deps-dev): bump run-sequence from 1.2.2 to 2.2.1 (#1282)
dependabot[bot] May 20, 2021
89387c1
build(deps-dev): bump sinon from 9.0.2 to 9.2.4 (#1289)
dependabot[bot] May 24, 2021
a549a6c
build(deps-dev): bump nyc from 14.1.1 to 15.1.0 (#1290)
dependabot[bot] May 24, 2021
d6dcf9e
build(deps-dev): bump chalk from 1.1.3 to 4.1.1 (#1288)
dependabot[bot] May 24, 2021
9d87537
build(deps-dev): bump @microsoft/api-extractor from 7.11.2 to 7.15.2 …
dependabot[bot] May 24, 2021
7afaf6c
chore: Teporarily disabling sendToDeviceGroup integration test (#1292)
hiranya911 May 24, 2021
1d2ff69
feat(auth): Added code flow support for OIDC flow. (#1220)
xil222 May 25, 2021
03c66d8
Update supported Node version to 10.13.0v (#1300)
lahirumaramba May 26, 2021
f914f92
Fixed integration test failure of skipped tests (#1299)
xil222 May 26, 2021
c529496
[chore] Release 9.9.0 (#1302)
lahirumaramba May 26, 2021
2ffc177
Update OIDC reference docs (#1305)
lahirumaramba May 27, 2021
f4a9a16
Add OAuthResponseType to ToC (#1303)
lahirumaramba May 27, 2021
29271ad
fix(auth): Better type hierarchies for Auth API (#1294)
hiranya911 May 27, 2021
5d5cea2
build(deps-dev): bump nock from 13.0.5 to 13.0.11 (#1311)
dependabot[bot] Jun 1, 2021
09e82c0
build(deps): bump ws from 7.3.1 to 7.4.6 (#1309)
dependabot[bot] Jun 1, 2021
312cdbb
build(deps-dev): bump del from 2.2.2 to 6.0.0 (#1310)
dependabot[bot] Jun 1, 2021
278bfc9
build(deps-dev): bump @types/jsonwebtoken from 8.5.0 to 8.5.1 (#1315)
dependabot[bot] Jun 1, 2021
2256f03
build(deps-dev): bump nock from 13.0.11 to 13.1.0 (#1313)
dependabot[bot] Jun 1, 2021
2e6e5d3
build(deps-dev): bump @types/sinon-chai from 3.2.4 to 3.2.5 (#1316)
dependabot[bot] Jun 1, 2021
8548bb3
build(deps-dev): bump bcrypt from 5.0.0 to 5.0.1 (#1324)
dependabot[bot] Jun 9, 2021
eb04602
build(deps): bump @google-cloud/firestore from 4.5.0 to 4.12.2 (#1325)
dependabot[bot] Jun 9, 2021
3c78a73
build(deps-dev): bump @types/mocha from 2.2.48 to 8.2.2 (#1323)
dependabot[bot] Jun 9, 2021
2a4de46
build(deps-dev): bump @firebase/app from 0.6.21 to 0.6.26 (#1329)
dependabot[bot] Jun 14, 2021
24d3b91
build(deps): bump @firebase/database from 0.10.0 to 0.10.4 (#1328)
dependabot[bot] Jun 14, 2021
f09bd64
build(deps-dev): bump request-promise from 4.2.5 to 4.2.6 (#1331)
dependabot[bot] Jun 14, 2021
9539a50
build(deps-dev): bump gulp-filter from 6.0.0 to 7.0.0 (#1334)
dependabot[bot] Jun 22, 2021
9b0d7ef
build(deps-dev): bump @types/minimist from 1.2.0 to 1.2.1 (#1336)
dependabot[bot] Jun 22, 2021
9872b9b
fix(docs): replace all global.html -> admin.html (#1341)
NothingEverHappens Jun 22, 2021
0f9a7de
feat(fis): Adding the admin.installations() API for deleting Firebase…
hiranya911 Jun 23, 2021
6f73c8c
fix: Updated TOC for new Auth type aliases (#1342)
hiranya911 Jun 23, 2021
2ca2bca
[chore] Release 9.10.0 (#1345)
hiranya911 Jun 24, 2021
2feece3
build(deps-dev): bump @types/request-promise from 4.1.46 to 4.1.47 (#…
dependabot[bot] Jun 24, 2021
dd942b0
build(deps): bump @firebase/database from 0.10.4 to 0.10.5 (#1350)
dependabot[bot] Jul 2, 2021
bf959e3
build(deps-dev): bump @types/nock from 9.3.1 to 11.1.0 (#1351)
dependabot[bot] Jul 2, 2021
e9cd6bf
build(deps-dev): bump @types/sinon from 9.0.4 to 10.0.2 (#1326)
dependabot[bot] Jul 2, 2021
068ea80
build(deps): bump @firebase/database from 0.10.5 to 0.10.6 (#1356)
dependabot[bot] Jul 5, 2021
b8e837b
build(deps): bump jwks-rsa from 2.0.2 to 2.0.3 (#1361)
dependabot[bot] Jul 9, 2021
c87f640
build(deps-dev): bump yargs from 16.1.0 to 17.0.1 (#1357)
dependabot[bot] Jul 9, 2021
0b45481
build(deps-dev): bump @types/chai from 4.2.11 to 4.2.21 (#1365)
dependabot[bot] Jul 9, 2021
bfaec79
Update index.ts (#1367)
dhritzkiv Jul 12, 2021
760cd6a
build(deps): bump @google-cloud/firestore from 4.12.2 to 4.13.1 (#1369)
dependabot[bot] Jul 12, 2021
4e816f4
feat(fac): Add custom TTL options for App Check (#1363)
lahirumaramba Jul 14, 2021
c2b126b
Reduce App Check custom token exp to 5 mins (#1372)
lahirumaramba Jul 14, 2021
ba07e12
Add AppCheckTokenOptions type to ToC (#1375)
lahirumaramba Jul 15, 2021
21869ee
Fix typo and formatting in docs (#1378)
lahirumaramba Jul 15, 2021
20dc462
[chore] Release 9.11.0 (#1376)
lahirumaramba Jul 15, 2021
db13ec1
build(deps-dev): bump nock from 13.1.0 to 13.1.1 (#1370)
dependabot[bot] Jul 15, 2021
25429b3
build(deps-dev): bump @types/bcrypt from 2.0.0 to 5.0.0 (#1384)
dependabot[bot] Jul 19, 2021
b403c15
build(deps): bump @firebase/database from 0.10.6 to 0.10.7 (#1385)
dependabot[bot] Jul 19, 2021
8bfbadf
build(deps-dev): bump @types/lodash from 4.14.157 to 4.14.171 (#1386)
dependabot[bot] Jul 20, 2021
6841d4c
build(deps-dev): bump @types/request from 2.48.5 to 2.48.6 (#1387)
dependabot[bot] Jul 20, 2021
9ad3be7
build(deps-dev): bump @types/minimist from 1.2.1 to 1.2.2 (#1388)
dependabot[bot] Jul 20, 2021
2e5e473
build(deps): bump jwks-rsa from 2.0.3 to 2.0.4 (#1393)
dependabot[bot] Jul 27, 2021
63d12e0
build(deps-dev): bump @microsoft/api-extractor from 7.15.2 to 7.18.4 …
dependabot[bot] Aug 3, 2021
8474194
build(deps): bump tar from 6.1.0 to 6.1.3 (#1399)
dependabot[bot] Aug 3, 2021
a9d8b41
build(deps-dev): bump ts-node from 9.0.0 to 10.2.0 (#1402)
dependabot[bot] Aug 9, 2021
e22f0ef
chore: Add emulator tests to nightlies (#1409)
lahirumaramba Aug 16, 2021
9f7529f
fix: Throw error on user disabled and check revoked set true (#1401)
xil222 Aug 16, 2021
7d92a34
build(deps-dev): bump yargs from 17.0.1 to 17.1.1 (#1412)
dependabot[bot] Aug 17, 2021
973e68b
build(deps): bump path-parse from 1.0.6 to 1.0.7 (#1413)
dependabot[bot] Aug 17, 2021
e7ab2f0
fix: Update comments in index files (#1414)
xil222 Aug 19, 2021
ceaad33
[chore] Release 9.11.1 (#1415)
lahirumaramba Aug 19, 2021
3f432df
fix typo (#1420)
arthurgubaidullin Aug 27, 2021
bb1fb6f
build(deps-dev): bump @microsoft/api-extractor from 7.18.4 to 7.18.7 …
dependabot[bot] Aug 27, 2021
82391d5
feat(rc): Add Remote Config Parameter Value Type Support (#1424)
lahirumaramba Sep 14, 2021
b4b220c
build(deps-dev): bump @types/lodash from 4.14.171 to 4.14.173 (#1435)
dependabot[bot] Sep 20, 2021
8610b94
build(deps): bump tar from 6.1.3 to 6.1.11 (#1430)
dependabot[bot] Sep 20, 2021
d96e61b
Pin @types/jsonwebtoken to 8.5.1 (#1438)
lahirumaramba Sep 23, 2021
894b04a
fix(rtdb): Changed admin.database to use database-compat package (#1437)
hiranya911 Sep 27, 2021
a0b71a2
fix(fac): Verify Token: Change the jwks cache duration from 1 day to …
lahirumaramba Sep 28, 2021
137905c
[chore] Release 9.12.0 (#1442)
lahirumaramba Sep 28, 2021
e4b6a5f
chore: Merged with main branch
hiranya911 Sep 30, 2021
aa534ad
fix: Merged missing commits from #1401
hiranya911 Sep 30, 2021
c87ce53
fix: Updated integration tests
hiranya911 Sep 30, 2021
5d67bcc
fix: Temporary with for RTDB type incompatibility issue
hiranya911 Sep 30, 2021
8406d4e
fix: Cleaned up faulty API doc annotations
hiranya911 Sep 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
subject: 'Nightly build ${{github.run_id}} of ${{github.repository}} failed!'
html: >
<b>Nightly workflow ${{github.run_id}} failed on: ${{github.repository}}</b>
<br /><br />Navigate to the
<br /><br />Navigate to the
<a href="https://github.com/firebase/firebase-admin-node/actions/runs/${{github.run_id}}">failed workflow</a>.
continue-on-error: true

Expand All @@ -97,6 +97,6 @@ jobs:
subject: 'Nightly build ${{github.run_id}} of ${{github.repository}} cancelled!'
html: >
<b>Nightly workflow ${{github.run_id}} cancelled on: ${{github.repository}}</b>
<br /><br />Navigate to the
<br /><br />Navigate to the
<a href="https://github.com/firebase/firebase-admin-node/actions/runs/${{github.run_id}}">cancelled workflow</a>.
continue-on-error: true
2 changes: 2 additions & 0 deletions etc/firebase-admin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ export namespace remoteConfig {
export type ListVersionsOptions = ListVersionsOptions;
// Warning: (ae-forgotten-export) The symbol "ListVersionsResult" needs to be exported by the entry point default-namespace.d.ts
export type ListVersionsResult = ListVersionsResult;
// Warning: (ae-forgotten-export) The symbol "ParameterValueType" needs to be exported by the entry point default-namespace.d.ts
export type ParameterValueType = ParameterValueType;
// Warning: (ae-forgotten-export) The symbol "RemoteConfig" needs to be exported by the entry point default-namespace.d.ts
export type RemoteConfig = RemoteConfig;
// Warning: (ae-forgotten-export) The symbol "RemoteConfigCondition" needs to be exported by the entry point default-namespace.d.ts
Expand Down
1 change: 0 additions & 1 deletion etc/firebase-admin.installations.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function getInstallations(app?: App): Installations;

// @public
export class Installations {
constructor(app: App);
get app(): App;
deleteInstallation(fid: string): Promise<void>;
}
Expand Down
4 changes: 4 additions & 0 deletions etc/firebase-admin.remote-config.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export interface ListVersionsResult {
versions: Version[];
}

// @public
export type ParameterValueType = 'STRING' | 'BOOLEAN' | 'NUMBER' | 'JSON';

// @public
export class RemoteConfig {
// (undocumented)
Expand Down Expand Up @@ -67,6 +70,7 @@ export interface RemoteConfigParameter {
};
defaultValue?: RemoteConfigParameterValue;
description?: string;
valueType?: ParameterValueType;
}

// @public
Expand Down
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ var paths = {
// emitted.
var buildProject = ts.createProject('tsconfig.json', { rootDir: 'src', declarationMap: true });

var buildTest = ts.createProject('tsconfig.json');
// Include dom libraries during test compilation since we use some web SDK
// libraries in our tests.
var buildTest = ts.createProject('tsconfig.json', { lib: ['es2018', 'dom'] });

var banner = `/*! firebase-admin v${pkg.version} */\n`;

Expand Down
3,391 changes: 1,637 additions & 1,754 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
}
},
"dependencies": {
"@firebase/database": "^0.10.0",
"@firebase/database-compat": "^0.1.1",
"@firebase/database-types": "^0.7.2",
"@types/node": ">=12.12.47",
"dicer": "^0.3.0",
Expand All @@ -173,15 +173,15 @@
},
"devDependencies": {
"@firebase/api-documenter": "^0.1.2",
"@firebase/app": "^0.6.21",
"@firebase/auth": "^0.16.5",
"@firebase/app-compat": "^0.1.2",
"@firebase/auth-compat": "^0.1.3",
"@firebase/auth-types": "^0.10.3",
"@microsoft/api-extractor": "^7.11.2",
"@types/bcrypt": "^5.0.0",
"@types/chai": "^4.0.0",
"@types/chai-as-promised": "^7.1.0",
"@types/firebase-token-generator": "^2.0.28",
"@types/jsonwebtoken": "^8.5.0",
"@types/jsonwebtoken": "8.5.1",
"@types/lodash": "^4.14.104",
"@types/minimist": "^1.2.0",
"@types/mocha": "^8.2.2",
Expand Down
4 changes: 2 additions & 2 deletions src/app-check/token-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class AppCheckTokenGenerator {
*
* @param appId The Application ID to use for the generated token.
*
* @return A Promise fulfilled with a custom token signed with a service account key
* @returns A Promise fulfilled with a custom token signed with a service account key
* that can be exchanged to an App Check token.
*/
public createCustomToken(appId: string, options?: AppCheckTokenOptions): Promise<string> {
Expand Down Expand Up @@ -141,7 +141,7 @@ export class AppCheckTokenGenerator {
* details from a CryptoSignerError.
*
* @param err The Error to convert into a FirebaseAppCheckError error
* @return A Firebase App Check error that can be returned to the user.
* @returns A Firebase App Check error that can be returned to the user.
*/
export function appCheckErrorFromCryptoSignerError(err: Error): Error {
if (!(err instanceof CryptoSignerError)) {
Expand Down
2 changes: 1 addition & 1 deletion src/app-check/token-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class AppCheckTokenVerifier {
* Verifies the format and signature of a Firebase App Check token.
*
* @param token The Firebase Auth JWT token to verify.
* @return A promise fulfilled with the decoded claims of the Firebase App Check token.
* @returns A promise fulfilled with the decoded claims of the Firebase App Check token.
*/
public verifyToken(token: string): Promise<DecodedAppCheckToken> {
if (!validator.isString(token)) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/firebase-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class FirebaseNamespace {
};

// eslint-disable-next-line @typescript-eslint/no-var-requires
return Object.assign(fn, require('@firebase/database'));
return Object.assign(fn, require('@firebase/database-compat/standalone'));
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/auth/auth-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,6 @@ export class OIDCConfig implements OIDCAuthProviderConfig {
'"OIDCAuthProviderConfig.responseType.idToken" must be a boolean.',
);
}

const code = options.responseType.code;
if (typeof code !== 'undefined') {
if (!validator.isBoolean(code)) {
Expand All @@ -1378,7 +1377,6 @@ export class OIDCConfig implements OIDCAuthProviderConfig {
'"OIDCAuthProviderConfig.responseType.code" must be a boolean.',
);
}

// If code flow is enabled, client secret must be provided.
if (code && typeof options.clientSecret === 'undefined') {
throw new FirebaseAuthError(
Expand Down
60 changes: 42 additions & 18 deletions src/auth/base-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { deepCopy } from '../utils/deep-copy';
import * as validator from '../utils/validator';

import { AbstractAuthRequestHandler, useEmulator } from './auth-api-request';
import { FirebaseTokenGenerator, EmulatedSigner } from './token-generator';
import { FirebaseTokenGenerator, EmulatedSigner, handleCryptoSignerError } from './token-generator';
import {
FirebaseTokenVerifier, createSessionCookieVerifier, createIdTokenVerifier,
DecodedIdToken,
Expand All @@ -37,7 +37,6 @@ import {
import { UserImportOptions, UserImportRecord, UserImportResult } from './user-import-builder';
import { ActionCodeSettings } from './action-code-settings-builder';
import { cryptoSignerFromApp } from '../utils/crypto-signer';
import { FirebaseApp } from '../app/firebase-app';

/** Represents the result of the {@link BaseAuth.getUsers} API. */
export interface GetUsersResult {
Expand Down Expand Up @@ -109,6 +108,19 @@ export interface SessionCookieOptions {
expiresIn: number;
}

/**
* @internal
*/
export function createFirebaseTokenGenerator(app: App,
tenantId?: string): FirebaseTokenGenerator {
try {
const signer = useEmulator() ? new EmulatedSigner() : cryptoSignerFromApp(app);
return new FirebaseTokenGenerator(signer, tenantId);
} catch (err) {
throw handleCryptoSignerError(err);
}
}

/**
* Common parent interface for both `Auth` and `TenantAwareAuth` APIs.
*/
Expand All @@ -134,13 +146,12 @@ export abstract class BaseAuth {
*/
constructor(
app: App,
/** @internal */protected readonly authRequestHandler: AbstractAuthRequestHandler,
/** @internal */ protected readonly authRequestHandler: AbstractAuthRequestHandler,
tokenGenerator?: FirebaseTokenGenerator) {
if (tokenGenerator) {
this.tokenGenerator = tokenGenerator;
} else {
const cryptoSigner = useEmulator() ? new EmulatedSigner() : cryptoSignerFromApp(app as FirebaseApp);
this.tokenGenerator = new FirebaseTokenGenerator(cryptoSigner);
this.tokenGenerator = createFirebaseTokenGenerator(app);
}

this.sessionCookieVerifier = createSessionCookieVerifier(app);
Expand Down Expand Up @@ -171,8 +182,12 @@ export abstract class BaseAuth {
* Verifies a Firebase ID token (JWT). If the token is valid, the promise is
* fulfilled with the token's decoded claims; otherwise, the promise is
* rejected.
* An optional flag can be passed to additionally check whether the ID token
* was revoked.
*
* If `checkRevoked` is set to true, first verifies whether the corresponding
* user is disabled. If yes, an `auth/user-disabled` error is thrown. If no,
* verifies if the session corresponding to the ID token was revoked. If the
* corresponding user's session was invalidated, an `auth/id-token-revoked`
* error is thrown. If not specified the check is not applied.
*
* See {@link https://firebase.google.com/docs/auth/admin/verify-id-tokens | Verify ID Tokens}
* for code samples and detailed documentation.
Expand All @@ -193,7 +208,7 @@ export abstract class BaseAuth {
.then((decodedIdToken: DecodedIdToken) => {
// Whether to check if the token was revoked.
if (checkRevoked || isEmulator) {
return this.verifyDecodedJWTNotRevoked(
return this.verifyDecodedJWTNotRevokedOrDisabled(
decodedIdToken,
AuthClientErrorCode.ID_TOKEN_REVOKED);
}
Expand Down Expand Up @@ -669,11 +684,14 @@ export abstract class BaseAuth {

/**
* Verifies a Firebase session cookie. Returns a Promise with the cookie claims.
* Rejects the promise if the cookie could not be verified. If `checkRevoked` is
* set to true, verifies if the session corresponding to the session cookie was
* revoked. If the corresponding user's session was revoked, an
* `auth/session-cookie-revoked` error is thrown. If not specified the check is
* not performed.
* Rejects the promise if the cookie could not be verified.
*
* If `checkRevoked` is set to true, first verifies whether the corresponding
* user is disabled: If yes, an `auth/user-disabled` error is thrown. If no,
* verifies if the session corresponding to the session cookie was revoked.
* If the corresponding user's session was invalidated, an
* `auth/session-cookie-revoked` error is thrown. If not specified the check
* is not performed.
*
* See {@link https://firebase.google.com/docs/auth/admin/manage-cookies#verify_session_cookie_and_check_permissions |
* Verify Session Cookies}
Expand All @@ -696,7 +714,7 @@ export abstract class BaseAuth {
.then((decodedIdToken: DecodedIdToken) => {
// Whether to check if the token was revoked.
if (checkRevoked || isEmulator) {
return this.verifyDecodedJWTNotRevoked(
return this.verifyDecodedJWTNotRevokedOrDisabled(
decodedIdToken,
AuthClientErrorCode.SESSION_COOKIE_REVOKED);
}
Expand Down Expand Up @@ -1038,19 +1056,25 @@ export abstract class BaseAuth {
}

/**
* Verifies the decoded Firebase issued JWT is not revoked. Returns a promise that resolves
* with the decoded claims on success. Rejects the promise with revocation error if revoked.
* Verifies the decoded Firebase issued JWT is not revoked or disabled. Returns a promise that
* resolves with the decoded claims on success. Rejects the promise with revocation error if revoked
* or user disabled.
*
* @param decodedIdToken The JWT's decoded claims.
* @param revocationErrorInfo The revocation error info to throw on revocation
* detection.
* @returns A Promise that will be fulfilled after a successful verification.
* @returns A promise that will be fulfilled after a successful verification.
*/
private verifyDecodedJWTNotRevoked(
private verifyDecodedJWTNotRevokedOrDisabled(
decodedIdToken: DecodedIdToken, revocationErrorInfo: ErrorInfo): Promise<DecodedIdToken> {
// Get tokens valid after time for the corresponding user.
return this.getUser(decodedIdToken.sub)
.then((user: UserRecord) => {
if (user.disabled) {
throw new FirebaseAuthError(
AuthClientErrorCode.USER_DISABLED,
'The user record is disabled.');
}
// If no tokens valid after time available, token is not revoked.
if (user.tokensValidAfterTime) {
// Get the ID token authentication time and convert to milliseconds UTC.
Expand Down
12 changes: 4 additions & 8 deletions src/auth/tenant-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ import { App } from '../app';
import * as utils from '../utils/index';
import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error';

import { BaseAuth, SessionCookieOptions } from './base-auth';
import { BaseAuth, createFirebaseTokenGenerator, SessionCookieOptions } from './base-auth';
import { Tenant, TenantServerResponse, CreateTenantRequest, UpdateTenantRequest } from './tenant';
import { FirebaseTokenGenerator, EmulatedSigner } from './token-generator';
import {
AuthRequestHandler, TenantAwareAuthRequestHandler, useEmulator,
AuthRequestHandler, TenantAwareAuthRequestHandler,
} from './auth-api-request';
import { DecodedIdToken } from './token-verifier';
import { FirebaseApp } from '../app/firebase-app';
import { cryptoSignerFromApp } from '../utils/crypto-signer';

/**
* Interface representing the object returned from a
Expand Down Expand Up @@ -83,9 +80,8 @@ export class TenantAwareAuth extends BaseAuth {
* @internal
*/
constructor(app: App, tenantId: string) {
const cryptoSigner = useEmulator() ? new EmulatedSigner() : cryptoSignerFromApp(app as FirebaseApp);
const tokenGenerator = new FirebaseTokenGenerator(cryptoSigner, tenantId);
super(app, new TenantAwareAuthRequestHandler(app, tenantId), tokenGenerator);
super(app, new TenantAwareAuthRequestHandler(
app, tenantId), createFirebaseTokenGenerator(app, tenantId));
utils.addReadonlyGetter(this, 'tenantId', tenantId);
}

Expand Down
6 changes: 4 additions & 2 deletions src/auth/token-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export class EmulatedSigner implements CryptoSigner {

/**
* Class for generating different types of Firebase Auth tokens (JWTs).
*
* @internal
*/
export class FirebaseTokenGenerator {

Expand Down Expand Up @@ -202,8 +204,8 @@ export class FirebaseTokenGenerator {
* Creates a new FirebaseAuthError by extracting the error code, message and other relevant
* details from a CryptoSignerError.
*
* @param {Error} err The Error to convert into a FirebaseAuthError error
* @return {FirebaseAuthError} A Firebase Auth error that can be returned to the user.
* @param err The Error to convert into a FirebaseAuthError error
* @returns A Firebase Auth error that can be returned to the user.
*/
export function handleCryptoSignerError(err: Error): Error {
if (!(err instanceof CryptoSignerError)) {
Expand Down
1 change: 0 additions & 1 deletion src/auth/token-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ export class FirebaseTokenVerifier {
fullDecodedToken: DecodedToken,
projectId: string | null,
isEmulator: boolean): void {

const header = fullDecodedToken && fullDecodedToken.header;
const payload = fullDecodedToken && fullDecodedToken.payload;

Expand Down
7 changes: 4 additions & 3 deletions src/database/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import { URL } from 'url';
import * as path from 'path';

import { Database as DatabaseImpl } from '@firebase/database';
import { FirebaseDatabase } from '@firebase/database-types';
import { FirebaseDatabaseError, AppErrorCodes, FirebaseAppError } from '../utils/error';
import { Database as DatabaseImpl } from '@firebase/database-compat/standalone';

import { App } from '../app';
import { FirebaseApp } from '../app/firebase-app';
import { FirebaseDatabaseError, AppErrorCodes, FirebaseAppError } from '../utils/error';
import * as validator from '../utils/validator';
import { AuthorizedHttpClient, HttpRequestConfig, HttpError } from '../utils/api-request';
import { getSdkVersion } from '../utils/index';
Expand Down Expand Up @@ -124,7 +124,8 @@ export class DatabaseService {

let db: Database = this.databases[dbUrl];
if (typeof db === 'undefined') {
const rtdb = require('@firebase/database'); // eslint-disable-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
const rtdb = require('@firebase/database-compat/standalone');
db = rtdb.initStandalone(this.appInternal, dbUrl, getSdkVersion()).instance;

const rulesClient = new DatabaseRulesClient(this.app, dbUrl);
Expand Down
6 changes: 4 additions & 2 deletions src/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import * as rtdb from '@firebase/database-types';
import {
enableLogging as enableLoggingFunc,
ServerValue as serverValueConst,
} from '@firebase/database';
} from '@firebase/database-compat/standalone';

import { App, getApp } from '../app';
import { FirebaseApp } from '../app/firebase-app';
Expand All @@ -40,11 +40,13 @@ export {
ThenableReference,
} from '@firebase/database-types';

// TODO: Remove the following any-cast once the typins in @firebase/database-types are fixed.

/**
* {@link https://firebase.google.com/docs/reference/js/firebase.database#enablelogging | enableLogging}
* function from the `@firebase/database` package.
*/
export const enableLogging: typeof rtdb.enableLogging = enableLoggingFunc;
export const enableLogging: typeof rtdb.enableLogging = enableLoggingFunc as any;

/**
* {@link https://firebase.google.com/docs/reference/js/firebase.database.ServerValue | ServerValue}
Expand Down
2 changes: 1 addition & 1 deletion src/installations/installations-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { Installations as TInstallations } from './installations';
* return. If not provided, the default `Installations` service is
* returned.
*
* @return The default `Installations` service if
* @returns The default `Installations` service if
* no app is provided or the `Installations` service associated with the
* provided app.
*/
Expand Down
Loading