firebase-tools 11.0.1 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/accountImporter.js +92 -93
- package/lib/api.js +77 -218
- package/lib/apiv2.js +5 -4
- package/lib/auth.js +69 -47
- package/lib/bin/firebase.js +42 -47
- package/lib/checkValidTargetFilters.js +13 -12
- package/lib/commands/appdistribution-distribute.js +2 -1
- package/lib/commands/appdistribution-testers-add.js +2 -1
- package/lib/commands/appdistribution-testers-remove.js +2 -1
- package/lib/commands/apps-android-sha-create.js +2 -1
- package/lib/commands/apps-android-sha-delete.js +2 -1
- package/lib/commands/apps-android-sha-list.js +2 -1
- package/lib/commands/apps-create.js +2 -1
- package/lib/commands/apps-list.js +2 -1
- package/lib/commands/apps-sdkconfig.js +2 -1
- package/lib/commands/auth-export.js +2 -1
- package/lib/commands/auth-import.js +7 -10
- package/lib/commands/crashlytics-symbols-upload.js +2 -1
- package/lib/commands/database-get.js +4 -3
- package/lib/commands/database-instances-create.js +2 -1
- package/lib/commands/database-instances-list.js +3 -3
- package/lib/commands/database-profile.js +2 -1
- package/lib/commands/database-push.js +2 -1
- package/lib/commands/database-remove.js +2 -1
- package/lib/commands/database-rules-canary.js +2 -1
- package/lib/commands/database-rules-get.js +2 -1
- package/lib/commands/database-rules-list.js +2 -1
- package/lib/commands/database-rules-release.js +2 -1
- package/lib/commands/database-rules-stage.js +2 -1
- package/lib/commands/database-set.js +2 -1
- package/lib/commands/database-settings-get.js +2 -1
- package/lib/commands/database-settings-set.js +2 -1
- package/lib/commands/database-update.js +2 -1
- package/lib/commands/deploy.js +23 -21
- package/lib/commands/emulators-exec.js +2 -1
- package/lib/commands/emulators-export.js +2 -1
- package/lib/commands/emulators-start.js +2 -1
- package/lib/commands/experimental-functions-shell.js +10 -8
- package/lib/commands/ext-configure.js +2 -1
- package/lib/commands/ext-dev-deprecate.js +2 -1
- package/lib/commands/ext-dev-emulators-exec.js +2 -1
- package/lib/commands/ext-dev-emulators-start.js +2 -1
- package/lib/commands/ext-dev-extension-delete.js +2 -1
- package/lib/commands/ext-dev-init.js +2 -1
- package/lib/commands/ext-dev-list.js +2 -1
- package/lib/commands/ext-dev-publish.js +2 -1
- package/lib/commands/ext-dev-register.js +2 -1
- package/lib/commands/ext-dev-undeprecate.js +2 -1
- package/lib/commands/ext-dev-unpublish.js +2 -1
- package/lib/commands/ext-dev-usage.js +2 -1
- package/lib/commands/ext-export.js +2 -1
- package/lib/commands/ext-info.js +2 -1
- package/lib/commands/ext-install.js +2 -1
- package/lib/commands/ext-list.js +2 -1
- package/lib/commands/ext-sources-create.js +2 -1
- package/lib/commands/ext-uninstall.js +2 -1
- package/lib/commands/ext-update.js +2 -1
- package/lib/commands/ext.js +2 -1
- package/lib/commands/firestore-delete.js +2 -1
- package/lib/commands/firestore-indexes-list.js +2 -1
- package/lib/commands/functions-config-clone.js +4 -3
- package/lib/commands/functions-config-export.js +2 -1
- package/lib/commands/functions-config-get.js +2 -1
- package/lib/commands/functions-config-set.js +2 -1
- package/lib/commands/functions-config-unset.js +2 -1
- package/lib/commands/functions-delete.js +2 -1
- package/lib/commands/functions-deletegcfartifacts.js +2 -1
- package/lib/commands/functions-list.js +2 -1
- package/lib/commands/functions-log.js +2 -1
- package/lib/commands/functions-secrets-access.js +2 -1
- package/lib/commands/functions-secrets-destroy.js +2 -1
- package/lib/commands/functions-secrets-get.js +2 -1
- package/lib/commands/functions-secrets-prune.js +2 -1
- package/lib/commands/functions-secrets-set.js +2 -1
- package/lib/commands/functions-shell.js +12 -10
- package/lib/commands/help.js +2 -1
- package/lib/commands/hosting-channel-create.js +2 -1
- package/lib/commands/hosting-channel-delete.js +2 -1
- package/lib/commands/hosting-channel-deploy.js +2 -1
- package/lib/commands/hosting-channel-list.js +2 -1
- package/lib/commands/hosting-channel-open.js +2 -1
- package/lib/commands/hosting-clone.js +2 -1
- package/lib/commands/hosting-disable.js +2 -1
- package/lib/commands/hosting-sites-create.js +2 -1
- package/lib/commands/hosting-sites-delete.js +2 -1
- package/lib/commands/hosting-sites-get.js +2 -1
- package/lib/commands/hosting-sites-list.js +2 -1
- package/lib/commands/index.js +23 -13
- package/lib/commands/init.js +47 -43
- package/lib/commands/login-add.js +2 -1
- package/lib/commands/login-ci.js +2 -1
- package/lib/commands/login-list.js +2 -1
- package/lib/commands/login-use.js +2 -1
- package/lib/commands/login.js +2 -1
- package/lib/commands/logout.js +2 -1
- package/lib/commands/open.js +2 -1
- package/lib/commands/projects-addfirebase.js +2 -1
- package/lib/commands/projects-create.js +2 -1
- package/lib/commands/projects-list.js +2 -1
- package/lib/commands/remoteconfig-get.js +2 -1
- package/lib/commands/remoteconfig-rollback.js +2 -1
- package/lib/commands/remoteconfig-versions-list.js +2 -1
- package/lib/commands/serve.js +29 -27
- package/lib/commands/setup-emulators-database.js +2 -1
- package/lib/commands/setup-emulators-firestore.js +2 -1
- package/lib/commands/setup-emulators-pubsub.js +2 -1
- package/lib/commands/setup-emulators-storage.js +2 -1
- package/lib/commands/setup-emulators-ui.js +2 -1
- package/lib/commands/target-apply.js +2 -1
- package/lib/commands/target-clear.js +2 -1
- package/lib/commands/target-remove.js +2 -1
- package/lib/commands/target.js +2 -1
- package/lib/commands/use.js +54 -52
- package/lib/config.js +3 -3
- package/lib/deploy/database/deploy.js +3 -2
- package/lib/deploy/database/index.js +8 -5
- package/lib/deploy/database/prepare.js +22 -19
- package/lib/deploy/database/release.js +12 -9
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/build.js +32 -20
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +187 -54
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +14 -2
- package/lib/deploy/functions/services/database.js +14 -0
- package/lib/deploy/functions/services/index.js +14 -0
- package/lib/deploy/index.js +3 -3
- package/lib/deploy/lifecycleHooks.js +23 -20
- package/lib/deploy/remoteconfig/prepare.js +2 -2
- package/lib/emulator/auth/apiSpec.js +14 -46
- package/lib/emulator/auth/operations.js +6 -29
- package/lib/emulator/auth/state.js +2 -25
- package/lib/emulator/controller.js +1 -1
- package/lib/emulator/databaseEmulator.js +2 -2
- package/lib/errorOut.js +2 -2
- package/lib/functions/events/v2.js +7 -1
- package/lib/functionsConfigClone.js +43 -41
- package/lib/gcp/cloudfunctionsv2.js +17 -2
- package/lib/gcp/iam.js +1 -1
- package/lib/gcp/index.js +10 -10
- package/lib/gcp/runtimeconfig.js +45 -47
- package/lib/index.js +29 -28
- package/lib/init/features/database.js +10 -2
- package/lib/init/features/functions/index.js +1 -1
- package/lib/init/features/functions/javascript.js +23 -20
- package/lib/init/features/functions/npm-dependencies.js +17 -14
- package/lib/init/features/functions/typescript.js +27 -24
- package/lib/init/features/hosting/github.js +5 -4
- package/lib/loadCJSON.js +9 -6
- package/lib/logError.js +15 -12
- package/lib/parseBoltRules.js +15 -14
- package/lib/profileReport.js +503 -511
- package/lib/profiler.js +4 -4
- package/lib/requireAuth.js +0 -1
- package/lib/responseToError.js +8 -5
- package/lib/scopes.js +9 -9
- package/npm-shrinkwrap.json +537 -193
- package/package.json +8 -6
|
@@ -105,7 +105,6 @@ const MFA_INELIGIBLE_PROVIDER = new Set([
|
|
|
105
105
|
function signUp(state, reqBody, ctx) {
|
|
106
106
|
var _a;
|
|
107
107
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
108
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
109
108
|
let provider;
|
|
110
109
|
const updates = {
|
|
111
110
|
lastLoginAt: Date.now().toString(),
|
|
@@ -227,7 +226,6 @@ function lookup(state, reqBody, ctx) {
|
|
|
227
226
|
function batchCreate(state, reqBody) {
|
|
228
227
|
var _a, _b;
|
|
229
228
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
230
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
231
229
|
(0, errors_1.assert)((_a = reqBody.users) === null || _a === void 0 ? void 0 : _a.length, "MISSING_USER_ACCOUNT");
|
|
232
230
|
if (reqBody.sanityCheck) {
|
|
233
231
|
if (state.oneAccountPerEmail) {
|
|
@@ -423,7 +421,6 @@ function batchGet(state, reqBody, ctx) {
|
|
|
423
421
|
function createAuthUri(state, reqBody) {
|
|
424
422
|
var _a;
|
|
425
423
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
426
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
427
424
|
const sessionId = reqBody.sessionId || (0, utils_1.randomId)(27);
|
|
428
425
|
if (reqBody.providerId) {
|
|
429
426
|
throw new errors_1.NotImplementedError("Sign-in with IDP is not yet supported.");
|
|
@@ -483,7 +480,6 @@ function createAuthUri(state, reqBody) {
|
|
|
483
480
|
const SESSION_COOKIE_MIN_VALID_DURATION = 5 * 60;
|
|
484
481
|
exports.SESSION_COOKIE_MAX_VALID_DURATION = 14 * 24 * 60 * 60;
|
|
485
482
|
function createSessionCookie(state, reqBody, ctx) {
|
|
486
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
487
483
|
(0, errors_1.assert)(reqBody.idToken, "MISSING_ID_TOKEN");
|
|
488
484
|
const validDuration = Number(reqBody.validDuration) || exports.SESSION_COOKIE_MAX_VALID_DURATION;
|
|
489
485
|
(0, errors_1.assert)(validDuration >= SESSION_COOKIE_MIN_VALID_DURATION &&
|
|
@@ -573,7 +569,6 @@ function queryAccounts(state, reqBody) {
|
|
|
573
569
|
function resetPassword(state, reqBody) {
|
|
574
570
|
var _a;
|
|
575
571
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
576
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
577
572
|
(0, errors_1.assert)(state.allowPasswordSignup, "PASSWORD_LOGIN_DISABLED");
|
|
578
573
|
(0, errors_1.assert)(reqBody.oobCode, "MISSING_OOB_CODE");
|
|
579
574
|
const oob = state.validateOobCode(reqBody.oobCode);
|
|
@@ -604,7 +599,6 @@ exports.resetPassword = resetPassword;
|
|
|
604
599
|
function sendOobCode(state, reqBody, ctx) {
|
|
605
600
|
var _a;
|
|
606
601
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
607
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
608
602
|
(0, errors_1.assert)(reqBody.requestType && reqBody.requestType !== "OOB_REQ_TYPE_UNSPECIFIED", "MISSING_REQ_TYPE");
|
|
609
603
|
if (reqBody.returnOobLink) {
|
|
610
604
|
(0, errors_1.assert)((_a = ctx.security) === null || _a === void 0 ? void 0 : _a.Oauth2, "INSUFFICIENT_PERMISSION");
|
|
@@ -673,7 +667,6 @@ function sendVerificationCode(state, reqBody) {
|
|
|
673
667
|
var _a;
|
|
674
668
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
675
669
|
(0, errors_1.assert)(state instanceof state_1.AgentProjectState, "UNSUPPORTED_TENANT_OPERATION");
|
|
676
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
677
670
|
(0, errors_1.assert)(reqBody.phoneNumber && (0, utils_1.isValidPhoneNumber)(reqBody.phoneNumber), "INVALID_PHONE_NUMBER : Invalid format.");
|
|
678
671
|
const user = state.getUserByPhoneNumber(reqBody.phoneNumber);
|
|
679
672
|
(0, errors_1.assert)(!((_a = user === null || user === void 0 ? void 0 : user.mfaInfo) === null || _a === void 0 ? void 0 : _a.length), "UNSUPPORTED_FIRST_FACTOR : A phone number cannot be set as a first factor on an SMS based MFA user.");
|
|
@@ -686,7 +679,6 @@ function sendVerificationCode(state, reqBody) {
|
|
|
686
679
|
function setAccountInfo(state, reqBody, ctx) {
|
|
687
680
|
var _a;
|
|
688
681
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
689
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
690
682
|
const url = (0, utils_1.authEmulatorUrl)(ctx.req);
|
|
691
683
|
return setAccountInfoImpl(state, reqBody, {
|
|
692
684
|
privileged: !!((_a = ctx.security) === null || _a === void 0 ? void 0 : _a.Oauth2),
|
|
@@ -943,7 +935,7 @@ function signInWithCustomToken(state, reqBody) {
|
|
|
943
935
|
extraClaims = payload.claims;
|
|
944
936
|
}
|
|
945
937
|
let user = state.getUserByLocalId(localId);
|
|
946
|
-
const isNewUser =
|
|
938
|
+
const isNewUser = !user;
|
|
947
939
|
const updates = {
|
|
948
940
|
customAuth: true,
|
|
949
941
|
lastLoginAt: Date.now().toString(),
|
|
@@ -965,7 +957,6 @@ function signInWithEmailLink(state, reqBody) {
|
|
|
965
957
|
var _a;
|
|
966
958
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
967
959
|
(0, errors_1.assert)(state.enableEmailLinkSignin, "OPERATION_NOT_ALLOWED");
|
|
968
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
969
960
|
const userFromIdToken = reqBody.idToken ? parseIdToken(state, reqBody.idToken).user : undefined;
|
|
970
961
|
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
971
962
|
const email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
@@ -1015,7 +1006,6 @@ function signInWithEmailLink(state, reqBody) {
|
|
|
1015
1006
|
function signInWithIdp(state, reqBody) {
|
|
1016
1007
|
var _a, _b, _c;
|
|
1017
1008
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1018
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1019
1009
|
if (reqBody.returnRefreshToken) {
|
|
1020
1010
|
throw new errors_1.NotImplementedError("returnRefreshToken is not implemented yet.");
|
|
1021
1011
|
}
|
|
@@ -1126,7 +1116,6 @@ function signInWithPassword(state, reqBody) {
|
|
|
1126
1116
|
var _a;
|
|
1127
1117
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1128
1118
|
(0, errors_1.assert)(state.allowPasswordSignup, "PASSWORD_LOGIN_DISABLED");
|
|
1129
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1130
1119
|
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
1131
1120
|
(0, errors_1.assert)(reqBody.password, "MISSING_PASSWORD");
|
|
1132
1121
|
if (reqBody.captchaResponse || reqBody.captchaChallenge) {
|
|
@@ -1160,7 +1149,6 @@ function signInWithPhoneNumber(state, reqBody) {
|
|
|
1160
1149
|
var _a;
|
|
1161
1150
|
(0, errors_1.assert)(!state.disableAuth, "PROJECT_DISABLED");
|
|
1162
1151
|
(0, errors_1.assert)(state instanceof state_1.AgentProjectState, "UNSUPPORTED_TENANT_OPERATION");
|
|
1163
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1164
1152
|
let phoneNumber;
|
|
1165
1153
|
if (reqBody.temporaryProof) {
|
|
1166
1154
|
(0, errors_1.assert)(reqBody.phoneNumber, "MISSING_PHONE_NUMBER");
|
|
@@ -1205,7 +1193,6 @@ function signInWithPhoneNumber(state, reqBody) {
|
|
|
1205
1193
|
phoneNumber, localId: user.localId }, tokens);
|
|
1206
1194
|
}
|
|
1207
1195
|
function grantToken(state, reqBody) {
|
|
1208
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1209
1196
|
(0, errors_1.assert)(reqBody.grantType, "MISSING_GRANT_TYPE");
|
|
1210
1197
|
(0, errors_1.assert)(reqBody.grantType === "refresh_token", "INVALID_GRANT_TYPE");
|
|
1211
1198
|
(0, errors_1.assert)(reqBody.refreshToken, "MISSING_REFRESH_TOKEN");
|
|
@@ -1234,7 +1221,6 @@ function getEmulatorProjectConfig(state) {
|
|
|
1234
1221
|
signIn: {
|
|
1235
1222
|
allowDuplicateEmails: !state.oneAccountPerEmail,
|
|
1236
1223
|
},
|
|
1237
|
-
usageMode: state.usageMode,
|
|
1238
1224
|
};
|
|
1239
1225
|
}
|
|
1240
1226
|
function updateEmulatorProjectConfig(state, reqBody, ctx) {
|
|
@@ -1243,9 +1229,6 @@ function updateEmulatorProjectConfig(state, reqBody, ctx) {
|
|
|
1243
1229
|
if (((_a = reqBody.signIn) === null || _a === void 0 ? void 0 : _a.allowDuplicateEmails) != null) {
|
|
1244
1230
|
updateMask.push("signIn.allowDuplicateEmails");
|
|
1245
1231
|
}
|
|
1246
|
-
if (reqBody.usageMode) {
|
|
1247
|
-
updateMask.push("usageMode");
|
|
1248
|
-
}
|
|
1249
1232
|
ctx.params.query.updateMask = updateMask.join();
|
|
1250
1233
|
updateConfig(state, reqBody, ctx);
|
|
1251
1234
|
return getEmulatorProjectConfig(state);
|
|
@@ -1414,7 +1397,6 @@ function hashPassword(password, salt) {
|
|
|
1414
1397
|
}
|
|
1415
1398
|
function issueTokens(state, user, signInProvider, { extraClaims, secondFactor, signInAttributes, } = {}) {
|
|
1416
1399
|
user = state.updateUserByLocalId(user.localId, { lastRefreshAt: new Date().toISOString() });
|
|
1417
|
-
const usageMode = state.usageMode === state_1.UsageMode.PASSTHROUGH ? "passthrough" : undefined;
|
|
1418
1400
|
const tenantId = state instanceof state_1.TenantProjectState ? state.tenantId : undefined;
|
|
1419
1401
|
const expiresInSeconds = 60 * 60;
|
|
1420
1402
|
const idToken = generateJwt(user, {
|
|
@@ -1423,16 +1405,13 @@ function issueTokens(state, user, signInProvider, { extraClaims, secondFactor, s
|
|
|
1423
1405
|
expiresInSeconds,
|
|
1424
1406
|
extraClaims,
|
|
1425
1407
|
secondFactor,
|
|
1426
|
-
usageMode,
|
|
1427
1408
|
tenantId,
|
|
1428
1409
|
signInAttributes,
|
|
1429
1410
|
});
|
|
1430
|
-
const refreshToken = state.
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
})
|
|
1435
|
-
: undefined;
|
|
1411
|
+
const refreshToken = state.createRefreshTokenFor(user, signInProvider, {
|
|
1412
|
+
extraClaims,
|
|
1413
|
+
secondFactor,
|
|
1414
|
+
});
|
|
1436
1415
|
return {
|
|
1437
1416
|
idToken,
|
|
1438
1417
|
refreshToken,
|
|
@@ -1440,7 +1419,6 @@ function issueTokens(state, user, signInProvider, { extraClaims, secondFactor, s
|
|
|
1440
1419
|
};
|
|
1441
1420
|
}
|
|
1442
1421
|
function parseIdToken(state, idToken) {
|
|
1443
|
-
(0, errors_1.assert)(state.usageMode !== state_1.UsageMode.PASSTHROUGH, "UNSUPPORTED_PASSTHROUGH_OPERATION");
|
|
1444
1422
|
const decoded = (0, jsonwebtoken_1.decode)(idToken, { complete: true });
|
|
1445
1423
|
(0, errors_1.assert)(decoded, "INVALID_ID_TOKEN");
|
|
1446
1424
|
if (decoded.header.alg !== "none") {
|
|
@@ -1457,7 +1435,7 @@ function parseIdToken(state, idToken) {
|
|
|
1457
1435
|
const signInProvider = decoded.payload.firebase.sign_in_provider;
|
|
1458
1436
|
return { user, signInProvider, payload: decoded.payload };
|
|
1459
1437
|
}
|
|
1460
|
-
function generateJwt(user, { projectId, signInProvider, expiresInSeconds, extraClaims = {}, secondFactor,
|
|
1438
|
+
function generateJwt(user, { projectId, signInProvider, expiresInSeconds, extraClaims = {}, secondFactor, tenantId, signInAttributes, }) {
|
|
1461
1439
|
const identities = {};
|
|
1462
1440
|
if (user.email) {
|
|
1463
1441
|
identities["email"] = [user.email];
|
|
@@ -1479,7 +1457,6 @@ function generateJwt(user, { projectId, signInProvider, expiresInSeconds, extraC
|
|
|
1479
1457
|
sign_in_provider: signInProvider,
|
|
1480
1458
|
second_factor_identifier: secondFactor === null || secondFactor === void 0 ? void 0 : secondFactor.identifier,
|
|
1481
1459
|
sign_in_second_factor: secondFactor === null || secondFactor === void 0 ? void 0 : secondFactor.provider,
|
|
1482
|
-
usage_mode: usageMode,
|
|
1483
1460
|
tenant: tenantId,
|
|
1484
1461
|
sign_in_attributes: signInAttributes,
|
|
1485
1462
|
} });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeRefreshToken = exports.encodeRefreshToken = exports.BlockingFunctionEvents = exports.
|
|
3
|
+
exports.decodeRefreshToken = exports.encodeRefreshToken = exports.BlockingFunctionEvents = exports.TenantProjectState = exports.AgentProjectState = exports.ProjectState = exports.SIGNIN_METHOD_EMAIL_LINK = exports.PROVIDER_GAME_CENTER = exports.PROVIDER_CUSTOM = exports.PROVIDER_ANONYMOUS = exports.PROVIDER_PHONE = exports.PROVIDER_PASSWORD = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const cloudFunctions_1 = require("./cloudFunctions");
|
|
6
6
|
const errors_1 = require("./errors");
|
|
@@ -412,7 +412,6 @@ class AgentProjectState extends ProjectState {
|
|
|
412
412
|
this._authCloudFunction = new cloudFunctions_1.AuthCloudFunction(this.projectId);
|
|
413
413
|
this._config = {
|
|
414
414
|
signIn: { allowDuplicateEmails: false },
|
|
415
|
-
usageMode: UsageMode.DEFAULT,
|
|
416
415
|
blockingFunctions: {},
|
|
417
416
|
};
|
|
418
417
|
}
|
|
@@ -425,12 +424,6 @@ class AgentProjectState extends ProjectState {
|
|
|
425
424
|
set oneAccountPerEmail(oneAccountPerEmail) {
|
|
426
425
|
this._config.signIn.allowDuplicateEmails = !oneAccountPerEmail;
|
|
427
426
|
}
|
|
428
|
-
get usageMode() {
|
|
429
|
-
return this._config.usageMode;
|
|
430
|
-
}
|
|
431
|
-
set usageMode(usageMode) {
|
|
432
|
-
this._config.usageMode = usageMode;
|
|
433
|
-
}
|
|
434
427
|
get allowPasswordSignup() {
|
|
435
428
|
return true;
|
|
436
429
|
}
|
|
@@ -456,17 +449,10 @@ class AgentProjectState extends ProjectState {
|
|
|
456
449
|
this._config.blockingFunctions = blockingFunctions;
|
|
457
450
|
}
|
|
458
451
|
updateConfig(update, updateMask) {
|
|
459
|
-
var _a, _b, _c
|
|
460
|
-
if (update.usageMode) {
|
|
461
|
-
(0, errors_1.assert)(update.usageMode !== UsageMode.USAGE_MODE_UNSPECIFIED, "INVALID_USAGE_MODE: ((Invalid usage mode provided.))");
|
|
462
|
-
if (update.usageMode === UsageMode.PASSTHROUGH) {
|
|
463
|
-
(0, errors_1.assert)(this.getUserCount() === 0, "USERS_STILL_EXIST: ((Users are present, unable to set passthrough mode.))");
|
|
464
|
-
}
|
|
465
|
-
}
|
|
452
|
+
var _a, _b, _c;
|
|
466
453
|
if (!updateMask) {
|
|
467
454
|
this.oneAccountPerEmail = (_b = !((_a = update.signIn) === null || _a === void 0 ? void 0 : _a.allowDuplicateEmails)) !== null && _b !== void 0 ? _b : true;
|
|
468
455
|
this.blockingFunctionsConfig = (_c = update.blockingFunctions) !== null && _c !== void 0 ? _c : {};
|
|
469
|
-
this.usageMode = (_d = update.usageMode) !== null && _d !== void 0 ? _d : UsageMode.DEFAULT;
|
|
470
456
|
return this.config;
|
|
471
457
|
}
|
|
472
458
|
return applyMask(updateMask, this.config, update);
|
|
@@ -542,9 +528,6 @@ class TenantProjectState extends ProjectState {
|
|
|
542
528
|
get authCloudFunction() {
|
|
543
529
|
return this.parentProject.authCloudFunction;
|
|
544
530
|
}
|
|
545
|
-
get usageMode() {
|
|
546
|
-
return this.parentProject.usageMode;
|
|
547
|
-
}
|
|
548
531
|
get tenantConfig() {
|
|
549
532
|
return this._tenantConfig;
|
|
550
533
|
}
|
|
@@ -592,12 +575,6 @@ class TenantProjectState extends ProjectState {
|
|
|
592
575
|
}
|
|
593
576
|
}
|
|
594
577
|
exports.TenantProjectState = TenantProjectState;
|
|
595
|
-
var UsageMode;
|
|
596
|
-
(function (UsageMode) {
|
|
597
|
-
UsageMode["USAGE_MODE_UNSPECIFIED"] = "USAGE_MODE_UNSPECIFIED";
|
|
598
|
-
UsageMode["DEFAULT"] = "DEFAULT";
|
|
599
|
-
UsageMode["PASSTHROUGH"] = "PASSTHROUGH";
|
|
600
|
-
})(UsageMode = exports.UsageMode || (exports.UsageMode = {}));
|
|
601
578
|
var BlockingFunctionEvents;
|
|
602
579
|
(function (BlockingFunctionEvents) {
|
|
603
580
|
BlockingFunctionEvents["BEFORE_CREATE"] = "beforeCreate";
|
|
@@ -246,7 +246,7 @@ async function startAll(options, showUI = true) {
|
|
|
246
246
|
}
|
|
247
247
|
if (previews_1.previews.frameworkawareness) {
|
|
248
248
|
const config = options.config.get("hosting");
|
|
249
|
-
if (Array.isArray(config) ? config.some((it) => it.source) : config.source) {
|
|
249
|
+
if (Array.isArray(config) ? config.some((it) => it.source) : config === null || config === void 0 ? void 0 : config.source) {
|
|
250
250
|
await (0, frameworks_1.prepareFrameworks)(targets, options, options);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
@@ -12,7 +12,7 @@ const constants_1 = require("./constants");
|
|
|
12
12
|
const registry_1 = require("./registry");
|
|
13
13
|
const emulatorLogger_1 = require("./emulatorLogger");
|
|
14
14
|
const error_1 = require("../error");
|
|
15
|
-
const
|
|
15
|
+
const parseBoltRules_1 = require("../parseBoltRules");
|
|
16
16
|
const apiv2_1 = require("../apiv2");
|
|
17
17
|
class DatabaseEmulator {
|
|
18
18
|
constructor(args) {
|
|
@@ -125,7 +125,7 @@ class DatabaseEmulator {
|
|
|
125
125
|
var _a;
|
|
126
126
|
const rulesExt = path.extname(rulesPath);
|
|
127
127
|
const content = rulesExt === ".bolt"
|
|
128
|
-
? parseBoltRules(rulesPath).toString()
|
|
128
|
+
? (0, parseBoltRules_1.parseBoltRules)(rulesPath).toString()
|
|
129
129
|
: fs.readFileSync(rulesPath, "utf8");
|
|
130
130
|
const info = this.getInfo();
|
|
131
131
|
try {
|
package/lib/errorOut.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.errorOut = void 0;
|
|
4
|
-
const
|
|
4
|
+
const logError_1 = require("./logError");
|
|
5
5
|
const error_1 = require("./error");
|
|
6
6
|
function errorOut(error) {
|
|
7
7
|
let fbError;
|
|
@@ -14,7 +14,7 @@ function errorOut(error) {
|
|
|
14
14
|
exit: 2,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
logError(fbError);
|
|
17
|
+
(0, logError_1.logError)(fbError);
|
|
18
18
|
process.exitCode = fbError.exit || 2;
|
|
19
19
|
setTimeout(() => {
|
|
20
20
|
process.exit();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FIREBASE_ALERTS_PUBLISH_EVENT = exports.STORAGE_EVENTS = exports.PUBSUB_PUBLISH_EVENT = void 0;
|
|
3
|
+
exports.DATABASE_EVENTS = exports.FIREBASE_ALERTS_PUBLISH_EVENT = exports.STORAGE_EVENTS = exports.PUBSUB_PUBLISH_EVENT = void 0;
|
|
4
4
|
exports.PUBSUB_PUBLISH_EVENT = "google.cloud.pubsub.topic.v1.messagePublished";
|
|
5
5
|
exports.STORAGE_EVENTS = [
|
|
6
6
|
"google.cloud.storage.object.v1.finalized",
|
|
@@ -9,3 +9,9 @@ exports.STORAGE_EVENTS = [
|
|
|
9
9
|
"google.cloud.storage.object.v1.metadataUpdated",
|
|
10
10
|
];
|
|
11
11
|
exports.FIREBASE_ALERTS_PUBLISH_EVENT = "google.firebase.firebasealerts.alerts.v1.published";
|
|
12
|
+
exports.DATABASE_EVENTS = [
|
|
13
|
+
"google.firebase.database.ref.v1.written",
|
|
14
|
+
"google.firebase.database.ref.v1.created",
|
|
15
|
+
"google.firebase.database.ref.v1.updated",
|
|
16
|
+
"google.firebase.database.ref.v1.deleted",
|
|
17
|
+
];
|
|
@@ -1,68 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functionsConfigClone = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const clc = require("cli-color");
|
|
6
|
+
const error_1 = require("./error");
|
|
7
|
+
const functionsConfig = require("./functionsConfig");
|
|
8
|
+
const runtimeconfig = require("./gcp/runtimeconfig");
|
|
9
|
+
function matchPrefix(short, long) {
|
|
8
10
|
if (short.length > long.length) {
|
|
9
11
|
return false;
|
|
10
12
|
}
|
|
11
|
-
return _.reduce(short,
|
|
13
|
+
return _.reduce(short, (accum, x, i) => {
|
|
12
14
|
return accum && x === long[i];
|
|
13
15
|
}, true);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
_.forEach(except,
|
|
16
|
+
}
|
|
17
|
+
function applyExcept(json, except) {
|
|
18
|
+
_.forEach(except, (key) => {
|
|
17
19
|
_.unset(json, key);
|
|
18
20
|
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return runtimeconfig.variables.get(varName).then(
|
|
22
|
-
|
|
21
|
+
}
|
|
22
|
+
function cloneVariable(varName, toProject) {
|
|
23
|
+
return runtimeconfig.variables.get(varName).then((variable) => {
|
|
24
|
+
const id = functionsConfig.varNameToIds(variable.name);
|
|
23
25
|
return runtimeconfig.variables.set(toProject, id.config, id.variable, variable.text);
|
|
24
26
|
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return runtimeconfig.variables.list(configName).then(
|
|
28
|
-
return Promise.all(_.map(variables,
|
|
29
|
-
return
|
|
27
|
+
}
|
|
28
|
+
function cloneConfig(configName, toProject) {
|
|
29
|
+
return runtimeconfig.variables.list(configName).then((variables) => {
|
|
30
|
+
return Promise.all(_.map(variables, (variable) => {
|
|
31
|
+
return cloneVariable(variable.name, toProject);
|
|
30
32
|
}));
|
|
31
33
|
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
}
|
|
35
|
+
async function cloneConfigOrVariable(key, fromProject, toProject) {
|
|
36
|
+
const parts = key.split(".");
|
|
35
37
|
if (_.includes(functionsConfig.RESERVED_NAMESPACES, parts[0])) {
|
|
36
|
-
throw new FirebaseError("Cannot clone reserved namespace " + clc.bold(parts[0]));
|
|
38
|
+
throw new error_1.FirebaseError("Cannot clone reserved namespace " + clc.bold(parts[0]));
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
const configName = _.join(["projects", fromProject, "configs", parts[0]], "/");
|
|
39
41
|
if (parts.length === 1) {
|
|
40
|
-
return
|
|
42
|
+
return cloneConfig(configName, toProject);
|
|
41
43
|
}
|
|
42
|
-
return runtimeconfig.variables.list(configName).then(
|
|
43
|
-
|
|
44
|
-
_.forEach(variables,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
promises.push(
|
|
44
|
+
return runtimeconfig.variables.list(configName).then((variables) => {
|
|
45
|
+
const promises = [];
|
|
46
|
+
_.forEach(variables, (variable) => {
|
|
47
|
+
const varId = functionsConfig.varNameToIds(variable.name).variable;
|
|
48
|
+
const variablePrefixFilter = parts.slice(1);
|
|
49
|
+
if (matchPrefix(variablePrefixFilter, varId.split("/"))) {
|
|
50
|
+
promises.push(cloneVariable(variable.name, toProject));
|
|
49
51
|
}
|
|
50
52
|
});
|
|
51
53
|
return Promise.all(promises);
|
|
52
54
|
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
except = except || [];
|
|
55
|
+
}
|
|
56
|
+
async function functionsConfigClone(fromProject, toProject, only, except = []) {
|
|
56
57
|
if (only) {
|
|
57
|
-
return Promise.all(_.map(only,
|
|
58
|
-
return
|
|
58
|
+
return Promise.all(_.map(only, (key) => {
|
|
59
|
+
return cloneConfigOrVariable(key, fromProject, toProject);
|
|
59
60
|
}));
|
|
60
61
|
}
|
|
61
|
-
return functionsConfig.materializeAll(fromProject).then(
|
|
62
|
+
return functionsConfig.materializeAll(fromProject).then((toClone) => {
|
|
62
63
|
_.unset(toClone, "firebase");
|
|
63
|
-
|
|
64
|
-
return Promise.all(_.map(toClone,
|
|
64
|
+
applyExcept(toClone, except);
|
|
65
|
+
return Promise.all(_.map(toClone, (val, configId) => {
|
|
65
66
|
return functionsConfig.setVariablesRecursive(toProject, configId, "", val);
|
|
66
67
|
}));
|
|
67
68
|
});
|
|
68
|
-
}
|
|
69
|
+
}
|
|
70
|
+
exports.functionsConfigClone = functionsConfigClone;
|
|
@@ -209,6 +209,13 @@ function functionFromEndpoint(endpoint, source) {
|
|
|
209
209
|
for (const [attribute, value] of Object.entries(endpoint.eventTrigger.eventFilters)) {
|
|
210
210
|
gcfFunction.eventTrigger.eventFilters.push({ attribute, value });
|
|
211
211
|
}
|
|
212
|
+
for (const [attribute, value] of Object.entries(endpoint.eventTrigger.eventFilterPathPatterns || {})) {
|
|
213
|
+
gcfFunction.eventTrigger.eventFilters.push({
|
|
214
|
+
attribute,
|
|
215
|
+
value,
|
|
216
|
+
operator: "match-path-pattern",
|
|
217
|
+
});
|
|
218
|
+
}
|
|
212
219
|
}
|
|
213
220
|
proto.renameIfPresent(gcfFunction.eventTrigger, endpoint.eventTrigger, "triggerRegion", "region");
|
|
214
221
|
proto.copyIfPresent(gcfFunction.eventTrigger, endpoint.eventTrigger, "channel");
|
|
@@ -277,8 +284,16 @@ function endpointFromFunction(gcfFunction) {
|
|
|
277
284
|
trigger.eventTrigger.eventFilters.topic = gcfFunction.eventTrigger.pubsubTopic;
|
|
278
285
|
}
|
|
279
286
|
else {
|
|
280
|
-
for (const
|
|
281
|
-
|
|
287
|
+
for (const eventFilter of gcfFunction.eventTrigger.eventFilters || []) {
|
|
288
|
+
if (eventFilter.operator === "match-path-pattern") {
|
|
289
|
+
if (!trigger.eventTrigger.eventFilterPathPatterns) {
|
|
290
|
+
trigger.eventTrigger.eventFilterPathPatterns = {};
|
|
291
|
+
}
|
|
292
|
+
trigger.eventTrigger.eventFilterPathPatterns[eventFilter.attribute] = eventFilter.value;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
trigger.eventTrigger.eventFilters[eventFilter.attribute] = eventFilter.value;
|
|
296
|
+
}
|
|
282
297
|
}
|
|
283
298
|
}
|
|
284
299
|
proto.copyIfPresent(trigger.eventTrigger, gcfFunction.eventTrigger, "channel");
|
package/lib/gcp/iam.js
CHANGED
package/lib/gcp/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rules = exports.storage = exports.pubsub = exports.iam = exports.cloudlogging = exports.cloudscheduler = exports.cloudfunctions = exports.cloudbilling = void 0;
|
|
4
|
+
exports.cloudbilling = require("./cloudbilling");
|
|
5
|
+
exports.cloudfunctions = require("./cloudfunctions");
|
|
6
|
+
exports.cloudscheduler = require("./cloudscheduler");
|
|
7
|
+
exports.cloudlogging = require("./cloudlogging");
|
|
8
|
+
exports.iam = require("./iam");
|
|
9
|
+
exports.pubsub = require("./pubsub");
|
|
10
|
+
exports.storage = require("./storage");
|
|
11
|
+
exports.rules = require("./rules");
|