firebase-tools 13.5.2 → 13.6.1
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/accountExporter.js +1 -1
- package/lib/accountImporter.js +1 -1
- package/lib/api.js +112 -58
- package/lib/apiv2.js +3 -1
- package/lib/appdistribution/client.js +4 -4
- package/lib/apphosting/config.js +31 -0
- package/lib/apphosting/githubConnections.js +261 -0
- package/lib/{init/features/apphosting → apphosting}/index.js +26 -22
- package/lib/{init/features/apphosting → apphosting}/repo.js +25 -13
- package/lib/apphosting/secrets/dialogs.js +169 -0
- package/lib/apphosting/secrets/index.js +98 -0
- package/lib/auth.js +17 -17
- package/lib/commands/apphosting-backends-create.js +4 -2
- package/lib/commands/apphosting-backends-delete.js +1 -1
- package/lib/commands/apphosting-secrets-describe.js +29 -0
- package/lib/commands/apphosting-secrets-grantaccess.js +45 -0
- package/lib/commands/apphosting-secrets-set.js +102 -0
- package/lib/commands/functions-secrets-access.js +2 -2
- package/lib/commands/functions-secrets-describe.js +14 -0
- package/lib/commands/functions-secrets-destroy.js +2 -2
- package/lib/commands/functions-secrets-get.js +3 -17
- package/lib/commands/functions-secrets-prune.js +2 -1
- package/lib/commands/functions-secrets-set.js +2 -2
- package/lib/commands/hosting-disable.js +1 -1
- package/lib/commands/index.js +5 -0
- package/lib/commands/open.js +1 -1
- package/lib/database/metadata.js +3 -3
- package/lib/defaultCredentials.js +2 -2
- package/lib/deploy/extensions/v2FunctionHelper.js +1 -1
- package/lib/deploy/functions/build.js +1 -1
- package/lib/deploy/functions/checkIam.js +3 -6
- package/lib/deploy/functions/containerCleaner.js +5 -15
- package/lib/deploy/functions/deploy.js +8 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/params.js +2 -2
- package/lib/deploy/functions/prepare.js +16 -7
- package/lib/deploy/functions/release/fabricator.js +8 -8
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
- package/lib/deploy/functions/runtimes/index.js +6 -43
- package/lib/deploy/functions/runtimes/node/index.js +3 -2
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +15 -34
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +2 -2
- package/lib/deploy/functions/runtimes/python/index.js +11 -7
- package/lib/deploy/functions/runtimes/supported.js +135 -0
- package/lib/deploy/hosting/uploader.js +1 -1
- package/lib/deploy/index.js +1 -1
- package/lib/deploy/remoteconfig/functions.js +1 -1
- package/lib/emulator/adminSdkConfig.js +1 -1
- package/lib/emulator/controller.js +8 -1
- package/lib/emulator/downloadableEmulators.js +6 -6
- package/lib/emulator/functionsEmulator.js +2 -2
- package/lib/emulator/hub.js +5 -0
- package/lib/ensureApiEnabled.js +1 -1
- package/lib/extensions/emulator/specHelper.js +4 -3
- package/lib/extensions/extensionsApi.js +5 -5
- package/lib/extensions/extensionsHelper.js +4 -4
- package/lib/extensions/provisioningHelper.js +2 -2
- package/lib/extensions/publishHelpers.js +1 -1
- package/lib/extensions/publisherApi.js +3 -3
- package/lib/extensions/resolveSource.js +1 -1
- package/lib/extensions/secretsUtils.js +1 -1
- package/lib/extensions/tos.js +1 -1
- package/lib/fetchMOTD.js +1 -1
- package/lib/fetchWebSetup.js +2 -2
- package/lib/firestore/api-sort.js +17 -0
- package/lib/firestore/api.js +9 -2
- package/lib/firestore/checkDatabaseType.js +1 -1
- package/lib/firestore/delete.js +1 -1
- package/lib/firestore/pretty-print.js +11 -2
- package/lib/functional.js +2 -2
- package/lib/functions/secrets.js +42 -24
- package/lib/functionsConfig.js +1 -1
- package/lib/gcp/apphosting.js +17 -4
- package/lib/gcp/artifactregistry.js +1 -1
- package/lib/gcp/auth.js +1 -1
- package/lib/gcp/cloudbilling.js +1 -1
- package/lib/gcp/cloudbuild.js +8 -4
- package/lib/gcp/cloudfunctions.js +6 -6
- package/lib/gcp/cloudfunctionsv2.js +4 -4
- package/lib/gcp/cloudlogging.js +1 -1
- package/lib/gcp/cloudmonitoring.js +1 -1
- package/lib/gcp/cloudscheduler.js +3 -3
- package/lib/gcp/cloudtasks.js +1 -1
- package/lib/gcp/computeEngine.js +7 -0
- package/lib/gcp/devConnect.js +45 -22
- package/lib/gcp/eventarc.js +1 -1
- package/lib/gcp/firestore.js +2 -2
- package/lib/gcp/iam.js +11 -3
- package/lib/gcp/identityPlatform.js +1 -1
- package/lib/gcp/pubsub.js +1 -1
- package/lib/gcp/resourceManager.js +2 -1
- package/lib/gcp/rules.js +1 -1
- package/lib/gcp/run.js +1 -1
- package/lib/gcp/runtimeconfig.js +1 -1
- package/lib/gcp/secretManager.js +54 -14
- package/lib/gcp/serviceusage.js +21 -5
- package/lib/gcp/storage.js +12 -8
- package/lib/hosting/api.js +2 -2
- package/lib/hosting/cloudRunProxy.js +1 -1
- package/lib/init/features/database.js +1 -1
- package/lib/init/features/extensions/index.js +1 -1
- package/lib/init/features/functions/index.js +2 -2
- package/lib/init/features/functions/python.js +4 -3
- package/lib/init/features/hosting/github.js +4 -3
- package/lib/init/features/index.js +1 -1
- package/lib/management/apps.js +4 -4
- package/lib/management/database.js +1 -1
- package/lib/management/projects.js +4 -4
- package/lib/remoteconfig/get.js +1 -1
- package/lib/remoteconfig/rollback.js +1 -1
- package/lib/remoteconfig/versionslist.js +1 -1
- package/lib/shortenUrl.js +2 -2
- package/lib/utils.js +1 -1
- package/package.json +1 -1
- package/schema/firebase-config.json +12 -2
- /package/lib/{init/features/apphosting → apphosting}/constants.js +0 -0
|
@@ -11,7 +11,7 @@ const extensionsApi_1 = require("./extensionsApi");
|
|
|
11
11
|
const PUBLISHER_API_VERSION = "v1beta";
|
|
12
12
|
const PAGE_SIZE_MAX = 100;
|
|
13
13
|
const extensionsPublisherApiClient = new apiv2_1.Client({
|
|
14
|
-
urlPrefix: api_1.extensionsPublisherOrigin,
|
|
14
|
+
urlPrefix: (0, api_1.extensionsPublisherOrigin)(),
|
|
15
15
|
apiVersion: PUBLISHER_API_VERSION,
|
|
16
16
|
});
|
|
17
17
|
async function getPublisherProfile(projectId, publisherId) {
|
|
@@ -97,7 +97,7 @@ async function createExtensionVersionFromLocalSource(args) {
|
|
|
97
97
|
},
|
|
98
98
|
});
|
|
99
99
|
const pollRes = await operationPoller.pollOperation({
|
|
100
|
-
apiOrigin: api_1.extensionsPublisherOrigin,
|
|
100
|
+
apiOrigin: (0, api_1.extensionsPublisherOrigin)(),
|
|
101
101
|
apiVersion: PUBLISHER_API_VERSION,
|
|
102
102
|
operationResourceName: uploadRes.body.name,
|
|
103
103
|
masterTimeout: 600000,
|
|
@@ -119,7 +119,7 @@ async function createExtensionVersionFromGitHubSource(args) {
|
|
|
119
119
|
},
|
|
120
120
|
});
|
|
121
121
|
const pollRes = await operationPoller.pollOperation({
|
|
122
|
-
apiOrigin: api_1.extensionsPublisherOrigin,
|
|
122
|
+
apiOrigin: (0, api_1.extensionsPublisherOrigin)(),
|
|
123
123
|
apiVersion: PUBLISHER_API_VERSION,
|
|
124
124
|
operationResourceName: uploadRes.body.name,
|
|
125
125
|
masterTimeout: 600000,
|
|
@@ -6,7 +6,7 @@ const api_1 = require("../api");
|
|
|
6
6
|
const EXTENSIONS_REGISTRY_ENDPOINT = "/extensions.json";
|
|
7
7
|
async function getExtensionRegistry(onlyFeatured = false) {
|
|
8
8
|
var _a;
|
|
9
|
-
const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseExtensionsRegistryOrigin });
|
|
9
|
+
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseExtensionsRegistryOrigin)() });
|
|
10
10
|
const res = await client.get(EXTENSIONS_REGISTRY_ENDPOINT);
|
|
11
11
|
const extensions = res.body.mods || {};
|
|
12
12
|
if (onlyFeatured) {
|
|
@@ -13,7 +13,7 @@ exports.SECRET_LABEL = "firebase-extensions-managed";
|
|
|
13
13
|
exports.SECRET_ROLE = "secretmanager.secretAccessor";
|
|
14
14
|
async function ensureSecretManagerApiEnabled(options) {
|
|
15
15
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
|
-
return await (0, ensureApiEnabled_1.ensure)(projectId, api_1.secretManagerOrigin, "extensions", options.markdown);
|
|
16
|
+
return await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.secretManagerOrigin)(), "extensions", options.markdown);
|
|
17
17
|
}
|
|
18
18
|
exports.ensureSecretManagerApiEnabled = ensureSecretManagerApiEnabled;
|
|
19
19
|
function usesSecrets(spec) {
|
package/lib/extensions/tos.js
CHANGED
|
@@ -10,7 +10,7 @@ const extensionsHelper_1 = require("./extensionsHelper");
|
|
|
10
10
|
const utils = require("../utils");
|
|
11
11
|
const VERSION = "v1";
|
|
12
12
|
const extensionsTosUrl = (tos) => `https://firebase.google.com/terms/extensions/${tos}`;
|
|
13
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.extensionsTOSOrigin, apiVersion: VERSION });
|
|
13
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.extensionsTOSOrigin)(), apiVersion: VERSION });
|
|
14
14
|
async function getAppDeveloperTOSStatus(projectId) {
|
|
15
15
|
const res = await apiClient.get(`/projects/${projectId}/appdevtos`);
|
|
16
16
|
return res.body;
|
package/lib/fetchMOTD.js
CHANGED
|
@@ -29,7 +29,7 @@ function fetchMOTD() {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
const origin = utils.addSubdomain(api_1.realtimeOrigin, "firebase-public");
|
|
32
|
+
const origin = utils.addSubdomain((0, api_1.realtimeOrigin)(), "firebase-public");
|
|
33
33
|
const c = new apiv2_1.Client({ urlPrefix: origin, auth: false });
|
|
34
34
|
c.get("/cli.json")
|
|
35
35
|
.then((res) => {
|
package/lib/fetchWebSetup.js
CHANGED
|
@@ -7,9 +7,9 @@ const api_1 = require("./api");
|
|
|
7
7
|
const projectUtils_1 = require("./projectUtils");
|
|
8
8
|
const logger_1 = require("./logger");
|
|
9
9
|
const constants_1 = require("./emulator/constants");
|
|
10
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseApiOrigin, auth: true, apiVersion: "v1beta1" });
|
|
10
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseApiOrigin)(), auth: true, apiVersion: "v1beta1" });
|
|
11
11
|
const hostingApiClient = new apiv2_1.Client({
|
|
12
|
-
urlPrefix: api_1.hostingApiOrigin,
|
|
12
|
+
urlPrefix: (0, api_1.hostingApiOrigin)(),
|
|
13
13
|
auth: true,
|
|
14
14
|
apiVersion: "v1beta1",
|
|
15
15
|
});
|
|
@@ -100,6 +100,9 @@ function compareIndexField(a, b) {
|
|
|
100
100
|
if (a.arrayConfig !== b.arrayConfig) {
|
|
101
101
|
return compareArrayConfig(a.arrayConfig, b.arrayConfig);
|
|
102
102
|
}
|
|
103
|
+
if (a.vectorConfig !== b.vectorConfig) {
|
|
104
|
+
return compareVectorConfig(a.vectorConfig, b.vectorConfig);
|
|
105
|
+
}
|
|
103
106
|
return 0;
|
|
104
107
|
}
|
|
105
108
|
function compareFieldIndex(a, b) {
|
|
@@ -123,6 +126,20 @@ function compareOrder(a, b) {
|
|
|
123
126
|
function compareArrayConfig(a, b) {
|
|
124
127
|
return ARRAY_CONFIG_SEQUENCE.indexOf(a) - ARRAY_CONFIG_SEQUENCE.indexOf(b);
|
|
125
128
|
}
|
|
129
|
+
function compareVectorConfig(a, b) {
|
|
130
|
+
if (!a) {
|
|
131
|
+
if (!b) {
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (!b) {
|
|
139
|
+
return -1;
|
|
140
|
+
}
|
|
141
|
+
return a.dimension - b.dimension;
|
|
142
|
+
}
|
|
126
143
|
function compareArrays(a, b, fn) {
|
|
127
144
|
const minFields = Math.min(a.length, b.length);
|
|
128
145
|
for (let i = 0; i < minFields; i++) {
|
package/lib/firestore/api.js
CHANGED
|
@@ -15,7 +15,7 @@ const apiv2_1 = require("../apiv2");
|
|
|
15
15
|
const pretty_print_1 = require("./pretty-print");
|
|
16
16
|
class FirestoreApi {
|
|
17
17
|
constructor() {
|
|
18
|
-
this.apiClient = new apiv2_1.Client({ urlPrefix: api_1.firestoreOrigin, apiVersion: "v1" });
|
|
18
|
+
this.apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.firestoreOrigin)(), apiVersion: "v1" });
|
|
19
19
|
this.printer = new pretty_print_1.PrettyPrint();
|
|
20
20
|
}
|
|
21
21
|
async deploy(options, indexes, fieldOverrides, databaseId = "(default)") {
|
|
@@ -204,13 +204,17 @@ class FirestoreApi {
|
|
|
204
204
|
validator.assertHas(index, "fields");
|
|
205
205
|
index.fields.forEach((field) => {
|
|
206
206
|
validator.assertHas(field, "fieldPath");
|
|
207
|
-
validator.assertHasOneOf(field, ["order", "arrayConfig"]);
|
|
207
|
+
validator.assertHasOneOf(field, ["order", "arrayConfig", "vectorConfig"]);
|
|
208
208
|
if (field.order) {
|
|
209
209
|
validator.assertEnum(field, "order", Object.keys(types.Order));
|
|
210
210
|
}
|
|
211
211
|
if (field.arrayConfig) {
|
|
212
212
|
validator.assertEnum(field, "arrayConfig", Object.keys(types.ArrayConfig));
|
|
213
213
|
}
|
|
214
|
+
if (field.vectorConfig) {
|
|
215
|
+
validator.assertType("vectorConfig.dimension", field.vectorConfig.dimension, "number");
|
|
216
|
+
validator.assertHas(field.vectorConfig, "flat");
|
|
217
|
+
}
|
|
214
218
|
});
|
|
215
219
|
}
|
|
216
220
|
validateField(field) {
|
|
@@ -373,6 +377,9 @@ class FirestoreApi {
|
|
|
373
377
|
else if (field.arrayConfig) {
|
|
374
378
|
f.arrayConfig = field.arrayConfig;
|
|
375
379
|
}
|
|
380
|
+
else if (field.vectorConfig) {
|
|
381
|
+
f.vectorConfig = field.vectorConfig;
|
|
382
|
+
}
|
|
376
383
|
else if (field.mode === types.Mode.ARRAY_CONTAINS) {
|
|
377
384
|
f.arrayConfig = types.ArrayConfig.CONTAINS;
|
|
378
385
|
}
|
|
@@ -6,7 +6,7 @@ const apiv2_1 = require("../apiv2");
|
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
7
|
async function checkDatabaseType(projectId) {
|
|
8
8
|
try {
|
|
9
|
-
const client = new apiv2_1.Client({ urlPrefix: api_1.firestoreOrigin, apiVersion: "v1" });
|
|
9
|
+
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firestoreOrigin)(), apiVersion: "v1" });
|
|
10
10
|
const resp = await client.get(`/projects/${projectId}/databases/(default)`);
|
|
11
11
|
return resp.body.type;
|
|
12
12
|
}
|
package/lib/firestore/delete.js
CHANGED
|
@@ -140,8 +140,17 @@ class PrettyPrint {
|
|
|
140
140
|
if (field.fieldPath === "__name__") {
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
let configString;
|
|
144
|
+
if (field.order) {
|
|
145
|
+
configString = field.order;
|
|
146
|
+
}
|
|
147
|
+
else if (field.arrayConfig) {
|
|
148
|
+
configString = field.arrayConfig;
|
|
149
|
+
}
|
|
150
|
+
else if (field.vectorConfig) {
|
|
151
|
+
configString = `VECTOR<${field.vectorConfig.dimension}>`;
|
|
152
|
+
}
|
|
153
|
+
result += `(${field.fieldPath},${configString}) `;
|
|
145
154
|
});
|
|
146
155
|
return result;
|
|
147
156
|
}
|
package/lib/functional.js
CHANGED
|
@@ -52,8 +52,8 @@ const zipIn = (other) => (elem, ndx) => {
|
|
|
52
52
|
return [elem, other[ndx]];
|
|
53
53
|
};
|
|
54
54
|
exports.zipIn = zipIn;
|
|
55
|
-
function assertExhaustive(val) {
|
|
56
|
-
throw new Error(`Never has a value (${val}).`);
|
|
55
|
+
function assertExhaustive(val, message) {
|
|
56
|
+
throw new Error(message || `Never has a value (${val}).`);
|
|
57
57
|
}
|
|
58
58
|
exports.assertExhaustive = assertExhaustive;
|
|
59
59
|
function partition(arr, predicate) {
|
package/lib/functions/secrets.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateEndpointSecret = exports.pruneAndDestroySecrets = exports.pruneSecrets = exports.versionInUse = exports.inUse = exports.getSecretVersions = exports.of = exports.ensureSecret = exports.ensureValidKey =
|
|
3
|
+
exports.describeSecret = exports.updateEndpointSecret = exports.pruneAndDestroySecrets = exports.pruneSecrets = exports.versionInUse = exports.inUse = exports.getSecretVersions = exports.of = exports.ensureSecret = exports.ensureValidKey = void 0;
|
|
4
4
|
const utils = require("../utils");
|
|
5
5
|
const poller = require("../operation-poller");
|
|
6
6
|
const gcfV1 = require("../gcp/cloudfunctions");
|
|
7
7
|
const gcfV2 = require("../gcp/cloudfunctionsv2");
|
|
8
|
-
const ensureApiEnabled = require("../ensureApiEnabled");
|
|
9
8
|
const api_1 = require("../api");
|
|
10
9
|
const secretManager_1 = require("../gcp/secretManager");
|
|
11
10
|
const error_1 = require("../error");
|
|
@@ -14,39 +13,28 @@ const prompt_1 = require("../prompt");
|
|
|
14
13
|
const env_1 = require("./env");
|
|
15
14
|
const logger_1 = require("../logger");
|
|
16
15
|
const functional_1 = require("../functional");
|
|
16
|
+
const secretManager_2 = require("../gcp/secretManager");
|
|
17
|
+
const secretManager_3 = require("../gcp/secretManager");
|
|
17
18
|
const projectUtils_1 = require("../projectUtils");
|
|
18
|
-
const
|
|
19
|
+
const Table = require("cli-table");
|
|
19
20
|
const gcfV1PollerOptions = {
|
|
20
|
-
apiOrigin: api_1.functionsOrigin,
|
|
21
|
+
apiOrigin: (0, api_1.functionsOrigin)(),
|
|
21
22
|
apiVersion: "v1",
|
|
22
23
|
masterTimeout: 25 * 60 * 1000,
|
|
23
24
|
maxBackoff: 10000,
|
|
24
25
|
};
|
|
25
26
|
const gcfV2PollerOptions = {
|
|
26
|
-
apiOrigin: api_1.functionsV2Origin,
|
|
27
|
+
apiOrigin: (0, api_1.functionsV2Origin)(),
|
|
27
28
|
apiVersion: "v2",
|
|
28
29
|
masterTimeout: 25 * 60 * 1000,
|
|
29
30
|
maxBackoff: 10000,
|
|
30
31
|
};
|
|
31
|
-
function isFirebaseManaged(secret) {
|
|
32
|
-
return Object.keys(secret.labels || []).includes(FIREBASE_MANAGED);
|
|
33
|
-
}
|
|
34
|
-
exports.isFirebaseManaged = isFirebaseManaged;
|
|
35
|
-
function labels() {
|
|
36
|
-
return { [FIREBASE_MANAGED]: "true" };
|
|
37
|
-
}
|
|
38
|
-
exports.labels = labels;
|
|
39
32
|
function toUpperSnakeCase(key) {
|
|
40
33
|
return key
|
|
41
34
|
.replace(/[.-]/g, "_")
|
|
42
35
|
.replace(/([a-z])([A-Z])/g, "$1_$2")
|
|
43
36
|
.toUpperCase();
|
|
44
37
|
}
|
|
45
|
-
function ensureApi(options) {
|
|
46
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
47
|
-
return ensureApiEnabled.ensure(projectId, api_1.secretManagerOrigin, "secretmanager", true);
|
|
48
|
-
}
|
|
49
|
-
exports.ensureApi = ensureApi;
|
|
50
38
|
async function ensureValidKey(key, options) {
|
|
51
39
|
const transformedKey = toUpperSnakeCase(key);
|
|
52
40
|
if (transformedKey !== key) {
|
|
@@ -76,18 +64,34 @@ exports.ensureValidKey = ensureValidKey;
|
|
|
76
64
|
async function ensureSecret(projectId, name, options) {
|
|
77
65
|
try {
|
|
78
66
|
const secret = await (0, secretManager_1.getSecret)(projectId, name);
|
|
79
|
-
if (
|
|
67
|
+
if ((0, secretManager_1.isAppHostingManaged)(secret)) {
|
|
68
|
+
(0, utils_1.logWarning)("Your secret is managed by Firebase App Hosting. Continuing will disable automatic deletion of old versions.");
|
|
69
|
+
const stopTracking = await (0, prompt_1.promptOnce)({
|
|
70
|
+
name: "doNotTrack",
|
|
71
|
+
type: "confirm",
|
|
72
|
+
default: false,
|
|
73
|
+
message: "Do you wish to continue?",
|
|
74
|
+
}, options);
|
|
75
|
+
if (stopTracking) {
|
|
76
|
+
delete secret.labels[secretManager_2.FIREBASE_MANAGED];
|
|
77
|
+
await (0, secretManager_1.patchSecret)(secret.projectId, secret.name, secret.labels);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw new Error("A secret cannot be managed by both Firebase App Hosting and Cloud Functions for Firebase");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (!(0, secretManager_2.isFunctionsManaged)(secret)) {
|
|
80
84
|
if (!options.force) {
|
|
81
|
-
(0, utils_1.logWarning)("Your secret is not managed by Firebase. " +
|
|
85
|
+
(0, utils_1.logWarning)("Your secret is not managed by Cloud Functions for Firebase. " +
|
|
82
86
|
"Firebase managed secrets are automatically pruned to reduce your monthly cost for using Secret Manager. ");
|
|
83
87
|
const confirm = await (0, prompt_1.promptOnce)({
|
|
84
88
|
name: "updateLabels",
|
|
85
89
|
type: "confirm",
|
|
86
90
|
default: true,
|
|
87
|
-
message: `Would you like to have your secret ${secret.name} managed by Firebase?`,
|
|
91
|
+
message: `Would you like to have your secret ${secret.name} managed by Cloud Functions for Firebase?`,
|
|
88
92
|
}, options);
|
|
89
93
|
if (confirm) {
|
|
90
|
-
return (0, secretManager_1.patchSecret)(projectId, secret.name, Object.assign(Object.assign({}, secret.labels), labels()));
|
|
94
|
+
return (0, secretManager_1.patchSecret)(projectId, secret.name, Object.assign(Object.assign({}, secret.labels), (0, secretManager_3.labels)()));
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
}
|
|
@@ -98,7 +102,7 @@ async function ensureSecret(projectId, name, options) {
|
|
|
98
102
|
throw err;
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
|
-
return await (0, secretManager_1.createSecret)(projectId, name, labels());
|
|
105
|
+
return await (0, secretManager_1.createSecret)(projectId, name, (0, secretManager_3.labels)());
|
|
102
106
|
}
|
|
103
107
|
exports.ensureSecret = ensureSecret;
|
|
104
108
|
function of(endpoints) {
|
|
@@ -139,7 +143,7 @@ async function pruneSecrets(projectInfo, endpoints) {
|
|
|
139
143
|
const { projectId, projectNumber } = projectInfo;
|
|
140
144
|
const pruneKey = (name, version) => `${name}@${version}`;
|
|
141
145
|
const prunedSecrets = new Set();
|
|
142
|
-
const haveSecrets = await (0, secretManager_1.listSecrets)(projectId, `labels.${FIREBASE_MANAGED}=true`);
|
|
146
|
+
const haveSecrets = await (0, secretManager_1.listSecrets)(projectId, `labels.${secretManager_2.FIREBASE_MANAGED}=true`);
|
|
143
147
|
for (const secret of haveSecrets) {
|
|
144
148
|
const versions = await (0, secretManager_1.listSecretVersions)(projectId, secret.name, `NOT state: DESTROYED`);
|
|
145
149
|
for (const version of versions) {
|
|
@@ -237,3 +241,17 @@ async function updateEndpointSecret(projectInfo, secretVersion, endpoint) {
|
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
exports.updateEndpointSecret = updateEndpointSecret;
|
|
244
|
+
async function describeSecret(key, options) {
|
|
245
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
246
|
+
const versions = await (0, secretManager_1.listSecretVersions)(projectId, key);
|
|
247
|
+
const table = new Table({
|
|
248
|
+
head: ["Version", "State"],
|
|
249
|
+
style: { head: ["yellow"] },
|
|
250
|
+
});
|
|
251
|
+
for (const version of versions) {
|
|
252
|
+
table.push([version.versionId, version.state]);
|
|
253
|
+
}
|
|
254
|
+
logger_1.logger.info(table.toString());
|
|
255
|
+
return { secrets: versions };
|
|
256
|
+
}
|
|
257
|
+
exports.describeSecret = describeSecret;
|
package/lib/functionsConfig.js
CHANGED
|
@@ -10,7 +10,7 @@ const error_1 = require("./error");
|
|
|
10
10
|
const projectUtils_1 = require("./projectUtils");
|
|
11
11
|
const runtimeconfig = require("./gcp/runtimeconfig");
|
|
12
12
|
exports.RESERVED_NAMESPACES = ["firebase"];
|
|
13
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseApiOrigin });
|
|
13
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseApiOrigin)() });
|
|
14
14
|
function keyToIds(key) {
|
|
15
15
|
const keyParts = key.split(".");
|
|
16
16
|
const variable = keyParts.slice(1).join("/");
|
package/lib/gcp/apphosting.js
CHANGED
|
@@ -11,7 +11,7 @@ const error_1 = require("../error");
|
|
|
11
11
|
const metaprogramming_1 = require("../metaprogramming");
|
|
12
12
|
exports.API_VERSION = "v1alpha";
|
|
13
13
|
exports.client = new apiv2_1.Client({
|
|
14
|
-
urlPrefix: api_1.apphostingOrigin,
|
|
14
|
+
urlPrefix: (0, api_1.apphostingOrigin)(),
|
|
15
15
|
auth: true,
|
|
16
16
|
apiVersion: exports.API_VERSION,
|
|
17
17
|
});
|
|
@@ -31,9 +31,22 @@ async function getBackend(projectId, location, backendId) {
|
|
|
31
31
|
}
|
|
32
32
|
exports.getBackend = getBackend;
|
|
33
33
|
async function listBackends(projectId, location) {
|
|
34
|
+
var _a;
|
|
34
35
|
const name = `projects/${projectId}/locations/${location}/backends`;
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
let pageToken;
|
|
37
|
+
const res = {
|
|
38
|
+
backends: [],
|
|
39
|
+
unreachable: [],
|
|
40
|
+
};
|
|
41
|
+
do {
|
|
42
|
+
const queryParams = pageToken ? { pageToken } : {};
|
|
43
|
+
const int = await exports.client.get(name, { queryParams });
|
|
44
|
+
res.backends.push(...(int.body.backends || []));
|
|
45
|
+
(_a = res.unreachable) === null || _a === void 0 ? void 0 : _a.push(...(int.body.unreachable || []));
|
|
46
|
+
pageToken = int.body.nextPageToken;
|
|
47
|
+
} while (pageToken);
|
|
48
|
+
res.unreachable = [...new Set(res.unreachable)];
|
|
49
|
+
return res;
|
|
37
50
|
}
|
|
38
51
|
exports.listBackends = listBackends;
|
|
39
52
|
async function deleteBackend(projectId, location, backendId) {
|
|
@@ -125,7 +138,7 @@ async function listLocations(projectId) {
|
|
|
125
138
|
exports.listLocations = listLocations;
|
|
126
139
|
async function ensureApiEnabled(options) {
|
|
127
140
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
128
|
-
return await (0, ensureApiEnabled_1.ensure)(projectId, api_1.apphostingOrigin, "app hosting", true);
|
|
141
|
+
return await (0, ensureApiEnabled_1.ensure)(projectId, (0, api_1.apphostingOrigin)(), "app hosting", true);
|
|
129
142
|
}
|
|
130
143
|
exports.ensureApiEnabled = ensureApiEnabled;
|
|
131
144
|
async function getNextRolloutId(projectId, location, backendId, counter) {
|
|
@@ -5,7 +5,7 @@ const apiv2_1 = require("../apiv2");
|
|
|
5
5
|
const api_1 = require("../api");
|
|
6
6
|
exports.API_VERSION = "v1beta2";
|
|
7
7
|
const client = new apiv2_1.Client({
|
|
8
|
-
urlPrefix: api_1.artifactRegistryDomain,
|
|
8
|
+
urlPrefix: (0, api_1.artifactRegistryDomain)(),
|
|
9
9
|
auth: true,
|
|
10
10
|
apiVersion: exports.API_VERSION,
|
|
11
11
|
});
|
package/lib/gcp/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateAuthDomains = exports.getAuthDomains = void 0;
|
|
4
4
|
const apiv2_1 = require("../apiv2");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.identityOrigin, auth: true });
|
|
6
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.identityOrigin)(), auth: true });
|
|
7
7
|
async function getAuthDomains(project) {
|
|
8
8
|
const res = await apiClient.get(`/admin/v2/projects/${project}/config`, { headers: { "x-goog-user-project": project } });
|
|
9
9
|
return res.body.authorizedDomains;
|
package/lib/gcp/cloudbilling.js
CHANGED
|
@@ -5,7 +5,7 @@ const api_1 = require("../api");
|
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const utils = require("../utils");
|
|
7
7
|
const API_VERSION = "v1";
|
|
8
|
-
const client = new apiv2_1.Client({ urlPrefix: api_1.cloudbillingOrigin, apiVersion: API_VERSION });
|
|
8
|
+
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudbillingOrigin)(), apiVersion: API_VERSION });
|
|
9
9
|
async function checkBillingEnabled(projectId) {
|
|
10
10
|
const res = await client.get(utils.endpoint(["projects", projectId, "billingInfo"]), { retryCodes: [500, 503] });
|
|
11
11
|
return res.body.billingEnabled;
|
package/lib/gcp/cloudbuild.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getDefaultServiceAgent = exports.getDefaultServiceAccount = exports.deleteRepository = exports.getRepository = exports.createRepository = exports.fetchLinkableRepositories = exports.deleteConnection = exports.listConnections = exports.getConnection = exports.createConnection = void 0;
|
|
4
4
|
const apiv2_1 = require("../apiv2");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
6
|
const PAGE_SIZE_MAX = 100;
|
|
7
7
|
const client = new apiv2_1.Client({
|
|
8
|
-
urlPrefix: api_1.cloudbuildOrigin,
|
|
8
|
+
urlPrefix: (0, api_1.cloudbuildOrigin)(),
|
|
9
9
|
auth: true,
|
|
10
10
|
apiVersion: "v2",
|
|
11
11
|
});
|
|
@@ -74,7 +74,11 @@ async function deleteRepository(projectId, location, connectionId, repositoryId)
|
|
|
74
74
|
return res.body;
|
|
75
75
|
}
|
|
76
76
|
exports.deleteRepository = deleteRepository;
|
|
77
|
-
function
|
|
77
|
+
function getDefaultServiceAccount(projectNumber) {
|
|
78
|
+
return `${projectNumber}@cloudbuild.gserviceaccount.com`;
|
|
79
|
+
}
|
|
80
|
+
exports.getDefaultServiceAccount = getDefaultServiceAccount;
|
|
81
|
+
function getDefaultServiceAgent(projectNumber) {
|
|
78
82
|
return `service-${projectNumber}@gcp-sa-cloudbuild.iam.gserviceaccount.com`;
|
|
79
83
|
}
|
|
80
|
-
exports.
|
|
84
|
+
exports.getDefaultServiceAgent = getDefaultServiceAgent;
|
|
@@ -7,13 +7,13 @@ const logger_1 = require("../logger");
|
|
|
7
7
|
const backend = require("../deploy/functions/backend");
|
|
8
8
|
const utils = require("../utils");
|
|
9
9
|
const proto = require("./proto");
|
|
10
|
-
const
|
|
10
|
+
const supported = require("../deploy/functions/runtimes/supported");
|
|
11
11
|
const projectConfig = require("../functions/projectConfig");
|
|
12
12
|
const apiv2_1 = require("../apiv2");
|
|
13
13
|
const api_1 = require("../api");
|
|
14
14
|
const constants_1 = require("../functions/constants");
|
|
15
15
|
exports.API_VERSION = "v1";
|
|
16
|
-
const client = new apiv2_1.Client({ urlPrefix: api_1.functionsOrigin, apiVersion: exports.API_VERSION });
|
|
16
|
+
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.functionsOrigin)(), apiVersion: exports.API_VERSION });
|
|
17
17
|
function functionsOpLogReject(funcName, type, err) {
|
|
18
18
|
var _a, _b, _c, _d;
|
|
19
19
|
if (((_b = (_a = err === null || err === void 0 ? void 0 : err.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) === 429) {
|
|
@@ -241,8 +241,8 @@ function endpointFromFunction(gcfFunction) {
|
|
|
241
241
|
uri = gcfFunction.httpsTrigger.url;
|
|
242
242
|
securityLevel = gcfFunction.httpsTrigger.securityLevel;
|
|
243
243
|
}
|
|
244
|
-
if (!
|
|
245
|
-
logger_1.logger.debug("
|
|
244
|
+
if (!supported.isRuntime(gcfFunction.runtime)) {
|
|
245
|
+
logger_1.logger.debug("GCF 1st gen function has unsupported runtime:", JSON.stringify(gcfFunction, null, 2));
|
|
246
246
|
}
|
|
247
247
|
const endpoint = Object.assign(Object.assign({ platform: "gcfv1", id,
|
|
248
248
|
project,
|
|
@@ -273,9 +273,9 @@ function functionFromEndpoint(endpoint, sourceUploadUrl) {
|
|
|
273
273
|
if (endpoint.platform !== "gcfv1") {
|
|
274
274
|
throw new error_1.FirebaseError("Trying to create a v1 CloudFunction with v2 API. This should never happen");
|
|
275
275
|
}
|
|
276
|
-
if (!
|
|
276
|
+
if (!supported.isRuntime(endpoint.runtime)) {
|
|
277
277
|
throw new error_1.FirebaseError("Failed internal assertion. Trying to deploy a new function with a deprecated runtime." +
|
|
278
|
-
" This should never happen");
|
|
278
|
+
" This should never happen", { exit: 1 });
|
|
279
279
|
}
|
|
280
280
|
const gcfFunction = {
|
|
281
281
|
name: backend.functionName(endpoint),
|
|
@@ -7,7 +7,7 @@ const api_1 = require("../api");
|
|
|
7
7
|
const logger_1 = require("../logger");
|
|
8
8
|
const v2_1 = require("../functions/events/v2");
|
|
9
9
|
const backend = require("../deploy/functions/backend");
|
|
10
|
-
const
|
|
10
|
+
const supported = require("../deploy/functions/runtimes/supported");
|
|
11
11
|
const proto = require("./proto");
|
|
12
12
|
const utils = require("../utils");
|
|
13
13
|
const projectConfig = require("../functions/projectConfig");
|
|
@@ -15,7 +15,7 @@ const constants_1 = require("../functions/constants");
|
|
|
15
15
|
exports.API_VERSION = "v2";
|
|
16
16
|
const DEFAULT_MAX_INSTANCE_COUNT = 100;
|
|
17
17
|
const client = new apiv2_1.Client({
|
|
18
|
-
urlPrefix: api_1.functionsV2Origin,
|
|
18
|
+
urlPrefix: (0, api_1.functionsV2Origin)(),
|
|
19
19
|
auth: true,
|
|
20
20
|
apiVersion: exports.API_VERSION,
|
|
21
21
|
});
|
|
@@ -175,7 +175,7 @@ function functionFromEndpoint(endpoint) {
|
|
|
175
175
|
if (endpoint.platform !== "gcfv2") {
|
|
176
176
|
throw new error_1.FirebaseError("Trying to create a v2 CloudFunction with v1 API. This should never happen");
|
|
177
177
|
}
|
|
178
|
-
if (!
|
|
178
|
+
if (!supported.isRuntime(endpoint.runtime)) {
|
|
179
179
|
throw new error_1.FirebaseError("Failed internal assertion. Trying to deploy a new function with a deprecated runtime." +
|
|
180
180
|
" This should never happen");
|
|
181
181
|
}
|
|
@@ -337,7 +337,7 @@ function endpointFromFunction(gcfFunction) {
|
|
|
337
337
|
else {
|
|
338
338
|
trigger = { httpsTrigger: {} };
|
|
339
339
|
}
|
|
340
|
-
if (!
|
|
340
|
+
if (!supported.isRuntime(gcfFunction.buildConfig.runtime)) {
|
|
341
341
|
logger_1.logger.debug("GCFv2 function has a deprecated runtime:", JSON.stringify(gcfFunction, null, 2));
|
|
342
342
|
}
|
|
343
343
|
const endpoint = Object.assign(Object.assign({ platform: "gcfv2", id,
|
package/lib/gcp/cloudlogging.js
CHANGED
|
@@ -6,7 +6,7 @@ const apiv2_1 = require("../apiv2");
|
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const API_VERSION = "v2";
|
|
8
8
|
async function listEntries(projectId, filter, pageSize, order) {
|
|
9
|
-
const client = new apiv2_1.Client({ urlPrefix: api_1.cloudloggingOrigin, apiVersion: API_VERSION });
|
|
9
|
+
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
|
|
10
10
|
try {
|
|
11
11
|
const result = await client.post("/entries:list", {
|
|
12
12
|
resourceNames: [`projects/${projectId}`],
|
|
@@ -59,7 +59,7 @@ var ValueType;
|
|
|
59
59
|
})(ValueType = exports.ValueType || (exports.ValueType = {}));
|
|
60
60
|
async function queryTimeSeries(query, projectNumber) {
|
|
61
61
|
const client = new apiv2_1.Client({
|
|
62
|
-
urlPrefix: api_1.cloudMonitoringOrigin,
|
|
62
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
63
63
|
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
64
64
|
});
|
|
65
65
|
try {
|
|
@@ -8,12 +8,12 @@ const api_1 = require("../api");
|
|
|
8
8
|
const apiv2_1 = require("../apiv2");
|
|
9
9
|
const backend = require("../deploy/functions/backend");
|
|
10
10
|
const proto = require("./proto");
|
|
11
|
-
const
|
|
11
|
+
const gce = require("../gcp/computeEngine");
|
|
12
12
|
const functional_1 = require("../functional");
|
|
13
13
|
const VERSION = "v1";
|
|
14
14
|
const DEFAULT_TIME_ZONE_V1 = "America/Los_Angeles";
|
|
15
15
|
const DEFAULT_TIME_ZONE_V2 = "UTC";
|
|
16
|
-
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.cloudschedulerOrigin, apiVersion: VERSION });
|
|
16
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudschedulerOrigin)(), apiVersion: VERSION });
|
|
17
17
|
function createJob(job) {
|
|
18
18
|
const strippedName = job.name.substring(0, job.name.lastIndexOf("/"));
|
|
19
19
|
const json = job.pubsubTarget
|
|
@@ -130,7 +130,7 @@ function jobFromEndpoint(endpoint, location, projectNumber) {
|
|
|
130
130
|
uri: endpoint.uri,
|
|
131
131
|
httpMethod: "POST",
|
|
132
132
|
oidcToken: {
|
|
133
|
-
serviceAccountEmail: (_a = endpoint.serviceAccount) !== null && _a !== void 0 ? _a :
|
|
133
|
+
serviceAccountEmail: (_a = endpoint.serviceAccount) !== null && _a !== void 0 ? _a : gce.getDefaultServiceAccount(projectNumber),
|
|
134
134
|
},
|
|
135
135
|
};
|
|
136
136
|
}
|
package/lib/gcp/cloudtasks.js
CHANGED
|
@@ -7,7 +7,7 @@ const api_1 = require("../api");
|
|
|
7
7
|
const functional_1 = require("../functional");
|
|
8
8
|
const API_VERSION = "v2";
|
|
9
9
|
const client = new apiv2_1.Client({
|
|
10
|
-
urlPrefix: api_1.cloudTasksOrigin,
|
|
10
|
+
urlPrefix: (0, api_1.cloudTasksOrigin)(),
|
|
11
11
|
auth: true,
|
|
12
12
|
apiVersion: API_VERSION,
|
|
13
13
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultServiceAccount = void 0;
|
|
4
|
+
function getDefaultServiceAccount(projectNumber) {
|
|
5
|
+
return `${projectNumber}-compute@developer.gserviceaccount.com`;
|
|
6
|
+
}
|
|
7
|
+
exports.getDefaultServiceAccount = getDefaultServiceAccount;
|