firebase-tools-with-isolate 12.9.1-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/LICENSE +21 -0
- package/README.md +48 -0
- package/lib/accountExporter.js +207 -0
- package/lib/accountImporter.js +305 -0
- package/lib/api.js +84 -0
- package/lib/apiv2.js +353 -0
- package/lib/appdistribution/client.js +193 -0
- package/lib/appdistribution/distribution.js +51 -0
- package/lib/appdistribution/options-parser-util.js +51 -0
- package/lib/archiveDirectory.js +120 -0
- package/lib/auth.js +535 -0
- package/lib/bin/firebase.js +132 -0
- package/lib/checkMinRequiredVersion.js +14 -0
- package/lib/checkValidTargetFilters.js +46 -0
- package/lib/command.js +250 -0
- package/lib/commands/appdistribution-distribute.js +121 -0
- package/lib/commands/appdistribution-group-create.js +19 -0
- package/lib/commands/appdistribution-group-delete.js +24 -0
- package/lib/commands/appdistribution-testers-add.js +24 -0
- package/lib/commands/appdistribution-testers-remove.js +40 -0
- package/lib/commands/apps-android-sha-create.js +29 -0
- package/lib/commands/apps-android-sha-delete.js +16 -0
- package/lib/commands/apps-android-sha-list.js +42 -0
- package/lib/commands/apps-create.js +166 -0
- package/lib/commands/apps-list.js +53 -0
- package/lib/commands/apps-sdkconfig.js +103 -0
- package/lib/commands/auth-export.js +44 -0
- package/lib/commands/auth-import.js +114 -0
- package/lib/commands/crashlytics-mappingfile-generateid.js +26 -0
- package/lib/commands/crashlytics-mappingfile-upload.js +46 -0
- package/lib/commands/crashlytics-symbols-upload.js +78 -0
- package/lib/commands/database-get.js +122 -0
- package/lib/commands/database-import.js +85 -0
- package/lib/commands/database-instances-create.js +29 -0
- package/lib/commands/database-instances-list.js +53 -0
- package/lib/commands/database-profile.js +46 -0
- package/lib/commands/database-push.js +63 -0
- package/lib/commands/database-remove.js +42 -0
- package/lib/commands/database-rules-canary.js +24 -0
- package/lib/commands/database-rules-get.js +22 -0
- package/lib/commands/database-rules-list.js +36 -0
- package/lib/commands/database-rules-release.js +24 -0
- package/lib/commands/database-rules-stage.js +26 -0
- package/lib/commands/database-set.js +68 -0
- package/lib/commands/database-settings-get.js +44 -0
- package/lib/commands/database-settings-set.js +46 -0
- package/lib/commands/database-update.js +69 -0
- package/lib/commands/deploy.js +101 -0
- package/lib/commands/emulators-exec.js +19 -0
- package/lib/commands/emulators-export.js +14 -0
- package/lib/commands/emulators-start.js +115 -0
- package/lib/commands/experimental-functions-shell.js +13 -0
- package/lib/commands/experiments-describe.js +31 -0
- package/lib/commands/experiments-disable.js +28 -0
- package/lib/commands/experiments-enable.js +28 -0
- package/lib/commands/experiments-list.js +29 -0
- package/lib/commands/ext-configure.js +110 -0
- package/lib/commands/ext-dev-deprecate.js +68 -0
- package/lib/commands/ext-dev-init.js +148 -0
- package/lib/commands/ext-dev-list.js +47 -0
- package/lib/commands/ext-dev-publish.js +32 -0
- package/lib/commands/ext-dev-register.js +50 -0
- package/lib/commands/ext-dev-undeprecate.js +57 -0
- package/lib/commands/ext-dev-upload.js +88 -0
- package/lib/commands/ext-dev-usage.js +141 -0
- package/lib/commands/ext-export.js +68 -0
- package/lib/commands/ext-info.js +118 -0
- package/lib/commands/ext-install.js +167 -0
- package/lib/commands/ext-list.js +18 -0
- package/lib/commands/ext-uninstall.js +29 -0
- package/lib/commands/ext-update.js +105 -0
- package/lib/commands/ext.js +41 -0
- package/lib/commands/firestore-databases-create.js +55 -0
- package/lib/commands/firestore-databases-delete.js +39 -0
- package/lib/commands/firestore-databases-get.js +25 -0
- package/lib/commands/firestore-databases-list.js +24 -0
- package/lib/commands/firestore-databases-update.js +59 -0
- package/lib/commands/firestore-delete.js +88 -0
- package/lib/commands/firestore-indexes-list.js +38 -0
- package/lib/commands/firestore-locations.js +24 -0
- package/lib/commands/frameworks-backends-create.js +14 -0
- package/lib/commands/frameworks-backends-delete.js +98 -0
- package/lib/commands/frameworks-backends-get.js +80 -0
- package/lib/commands/frameworks-backends-list.js +68 -0
- package/lib/commands/functions-config-clone.js +53 -0
- package/lib/commands/functions-config-export.js +118 -0
- package/lib/commands/functions-config-get.js +35 -0
- package/lib/commands/functions-config-set.js +43 -0
- package/lib/commands/functions-config-unset.js +42 -0
- package/lib/commands/functions-delete.js +95 -0
- package/lib/commands/functions-deletegcfartifacts.js +44 -0
- package/lib/commands/functions-list.js +47 -0
- package/lib/commands/functions-log.js +34 -0
- package/lib/commands/functions-secrets-access.js +22 -0
- package/lib/commands/functions-secrets-destroy.js +64 -0
- package/lib/commands/functions-secrets-get.js +28 -0
- package/lib/commands/functions-secrets-prune.js +57 -0
- package/lib/commands/functions-secrets-set.js +108 -0
- package/lib/commands/functions-shell.js +15 -0
- package/lib/commands/help.js +27 -0
- package/lib/commands/hosting-channel-create.js +78 -0
- package/lib/commands/hosting-channel-delete.js +47 -0
- package/lib/commands/hosting-channel-deploy.js +146 -0
- package/lib/commands/hosting-channel-list.js +40 -0
- package/lib/commands/hosting-channel-open.js +48 -0
- package/lib/commands/hosting-clone.js +103 -0
- package/lib/commands/hosting-disable.js +31 -0
- package/lib/commands/hosting-sites-create.js +34 -0
- package/lib/commands/hosting-sites-delete.js +39 -0
- package/lib/commands/hosting-sites-get.js +27 -0
- package/lib/commands/hosting-sites-list.js +28 -0
- package/lib/commands/index.js +191 -0
- package/lib/commands/init.js +195 -0
- package/lib/commands/internaltesting-frameworks-compose.js +22 -0
- package/lib/commands/internaltesting-functions-discover.js +25 -0
- package/lib/commands/login-add.js +32 -0
- package/lib/commands/login-ci.js +25 -0
- package/lib/commands/login-list.js +28 -0
- package/lib/commands/login-use.js +24 -0
- package/lib/commands/login.js +57 -0
- package/lib/commands/logout.js +76 -0
- package/lib/commands/open.js +100 -0
- package/lib/commands/projects-addfirebase.js +19 -0
- package/lib/commands/projects-create.js +37 -0
- package/lib/commands/projects-list.js +61 -0
- package/lib/commands/remoteconfig-get.js +68 -0
- package/lib/commands/remoteconfig-rollback.js +48 -0
- package/lib/commands/remoteconfig-versions-list.js +34 -0
- package/lib/commands/serve.js +60 -0
- package/lib/commands/setup-emulators-database.js +12 -0
- package/lib/commands/setup-emulators-firestore.js +12 -0
- package/lib/commands/setup-emulators-pubsub.js +12 -0
- package/lib/commands/setup-emulators-storage.js +12 -0
- package/lib/commands/setup-emulators-ui.js +12 -0
- package/lib/commands/target-apply.js +24 -0
- package/lib/commands/target-clear.js +20 -0
- package/lib/commands/target-remove.js +20 -0
- package/lib/commands/target.js +34 -0
- package/lib/commands/use.js +162 -0
- package/lib/config.js +227 -0
- package/lib/configstore.js +6 -0
- package/lib/crashlytics/buildToolsJarHelper.js +51 -0
- package/lib/database/api.js +19 -0
- package/lib/database/import.js +218 -0
- package/lib/database/listRemote.js +37 -0
- package/lib/database/metadata.js +67 -0
- package/lib/database/remove.js +88 -0
- package/lib/database/removeRemote.js +51 -0
- package/lib/database/rulesConfig.js +79 -0
- package/lib/database/settings.js +62 -0
- package/lib/defaultCredentials.js +80 -0
- package/lib/deploy/database/deploy.js +5 -0
- package/lib/deploy/database/index.js +9 -0
- package/lib/deploy/database/prepare.js +54 -0
- package/lib/deploy/database/release.js +30 -0
- package/lib/deploy/extensions/args.js +2 -0
- package/lib/deploy/extensions/deploy.js +49 -0
- package/lib/deploy/extensions/deploymentSummary.js +56 -0
- package/lib/deploy/extensions/errors.js +31 -0
- package/lib/deploy/extensions/index.js +9 -0
- package/lib/deploy/extensions/planner.js +157 -0
- package/lib/deploy/extensions/prepare.js +110 -0
- package/lib/deploy/extensions/release.js +57 -0
- package/lib/deploy/extensions/secrets.js +150 -0
- package/lib/deploy/extensions/tasks.js +156 -0
- package/lib/deploy/extensions/v2FunctionHelper.js +53 -0
- package/lib/deploy/extensions/validate.js +17 -0
- package/lib/deploy/firestore/deploy.js +44 -0
- package/lib/deploy/firestore/index.js +9 -0
- package/lib/deploy/firestore/prepare.js +59 -0
- package/lib/deploy/firestore/release.js +22 -0
- package/lib/deploy/functions/args.js +2 -0
- package/lib/deploy/functions/backend.js +316 -0
- package/lib/deploy/functions/build.js +311 -0
- package/lib/deploy/functions/cache/applyHash.js +22 -0
- package/lib/deploy/functions/cache/hash.js +30 -0
- package/lib/deploy/functions/cel.js +365 -0
- package/lib/deploy/functions/checkIam.js +183 -0
- package/lib/deploy/functions/containerCleaner.js +305 -0
- package/lib/deploy/functions/deploy.js +108 -0
- package/lib/deploy/functions/ensure.js +105 -0
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +1 -0
- package/lib/deploy/functions/functionsDeployHelper.js +134 -0
- package/lib/deploy/functions/index.js +9 -0
- package/lib/deploy/functions/params.js +517 -0
- package/lib/deploy/functions/prepare.js +304 -0
- package/lib/deploy/functions/prepareFunctionsUpload.js +113 -0
- package/lib/deploy/functions/pricing.js +171 -0
- package/lib/deploy/functions/prompts.js +157 -0
- package/lib/deploy/functions/release/executor.js +51 -0
- package/lib/deploy/functions/release/fabricator.js +584 -0
- package/lib/deploy/functions/release/index.js +93 -0
- package/lib/deploy/functions/release/planner.js +205 -0
- package/lib/deploy/functions/release/reporter.js +196 -0
- package/lib/deploy/functions/release/sourceTokenScraper.js +67 -0
- package/lib/deploy/functions/release/timer.js +14 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +85 -0
- package/lib/deploy/functions/runtimes/discovery/mockDiscoveryServer.js +14 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +95 -0
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +296 -0
- package/lib/deploy/functions/runtimes/index.js +59 -0
- package/lib/deploy/functions/runtimes/node/extractTriggers.js +23 -0
- package/lib/deploy/functions/runtimes/node/index.js +173 -0
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +57 -0
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +332 -0
- package/lib/deploy/functions/runtimes/node/triggerParser.js +72 -0
- package/lib/deploy/functions/runtimes/node/validate.js +34 -0
- package/lib/deploy/functions/runtimes/node/versioning.js +95 -0
- package/lib/deploy/functions/runtimes/python/index.js +154 -0
- package/lib/deploy/functions/services/auth.js +95 -0
- package/lib/deploy/functions/services/database.js +14 -0
- package/lib/deploy/functions/services/firebaseAlerts.js +14 -0
- package/lib/deploy/functions/services/firestore.js +17 -0
- package/lib/deploy/functions/services/index.js +117 -0
- package/lib/deploy/functions/services/remoteConfig.js +14 -0
- package/lib/deploy/functions/services/storage.js +44 -0
- package/lib/deploy/functions/services/testLab.js +14 -0
- package/lib/deploy/functions/triggerRegionHelper.js +16 -0
- package/lib/deploy/functions/validate.js +198 -0
- package/lib/deploy/hosting/args.js +2 -0
- package/lib/deploy/hosting/context.js +2 -0
- package/lib/deploy/hosting/convertConfig.js +181 -0
- package/lib/deploy/hosting/deploy.js +85 -0
- package/lib/deploy/hosting/hashcache.js +48 -0
- package/lib/deploy/hosting/index.js +9 -0
- package/lib/deploy/hosting/prepare.js +162 -0
- package/lib/deploy/hosting/release.js +40 -0
- package/lib/deploy/hosting/uploader.js +207 -0
- package/lib/deploy/index.js +127 -0
- package/lib/deploy/lifecycleHooks.js +151 -0
- package/lib/deploy/remoteconfig/deploy.js +4 -0
- package/lib/deploy/remoteconfig/functions.js +69 -0
- package/lib/deploy/remoteconfig/index.js +9 -0
- package/lib/deploy/remoteconfig/prepare.js +23 -0
- package/lib/deploy/remoteconfig/release.js +14 -0
- package/lib/deploy/storage/deploy.js +12 -0
- package/lib/deploy/storage/index.js +9 -0
- package/lib/deploy/storage/prepare.js +52 -0
- package/lib/deploy/storage/release.js +27 -0
- package/lib/deploymentTool.js +22 -0
- package/lib/detectProjectRoot.js +28 -0
- package/lib/downloadUtils.js +37 -0
- package/lib/dynamicImport.js +22 -0
- package/lib/emulator/ExpressBasedEmulator.js +92 -0
- package/lib/emulator/adminSdkConfig.js +65 -0
- package/lib/emulator/auth/apiSpec.js +8138 -0
- package/lib/emulator/auth/cloudFunctions.js +70 -0
- package/lib/emulator/auth/errors.js +77 -0
- package/lib/emulator/auth/handlers.js +281 -0
- package/lib/emulator/auth/index.js +146 -0
- package/lib/emulator/auth/operations.js +2145 -0
- package/lib/emulator/auth/schema.js +2 -0
- package/lib/emulator/auth/server.js +474 -0
- package/lib/emulator/auth/state.js +668 -0
- package/lib/emulator/auth/types.js +2 -0
- package/lib/emulator/auth/utils.js +84 -0
- package/lib/emulator/auth/widget_ui.js +620 -0
- package/lib/emulator/commandUtils.js +380 -0
- package/lib/emulator/constants.js +111 -0
- package/lib/emulator/controller.js +654 -0
- package/lib/emulator/databaseEmulator.js +172 -0
- package/lib/emulator/dns.js +49 -0
- package/lib/emulator/download.js +88 -0
- package/lib/emulator/downloadableEmulators.js +384 -0
- package/lib/emulator/emulatorLogger.js +237 -0
- package/lib/emulator/env.js +37 -0
- package/lib/emulator/eventarcEmulator.js +143 -0
- package/lib/emulator/eventarcEmulatorUtils.js +62 -0
- package/lib/emulator/events/types.js +28 -0
- package/lib/emulator/extensions/postinstall.js +41 -0
- package/lib/emulator/extensions/validation.js +72 -0
- package/lib/emulator/extensionsEmulator.js +254 -0
- package/lib/emulator/firestoreEmulator.js +96 -0
- package/lib/emulator/functionsEmulator.js +1038 -0
- package/lib/emulator/functionsEmulatorRuntime.js +730 -0
- package/lib/emulator/functionsEmulatorShared.js +322 -0
- package/lib/emulator/functionsEmulatorShell.js +88 -0
- package/lib/emulator/functionsEmulatorUtils.js +91 -0
- package/lib/emulator/functionsRuntimeWorker.js +314 -0
- package/lib/emulator/hostingEmulator.js +40 -0
- package/lib/emulator/hub.js +162 -0
- package/lib/emulator/hubClient.js +53 -0
- package/lib/emulator/hubExport.js +208 -0
- package/lib/emulator/loggingEmulator.js +118 -0
- package/lib/emulator/portUtils.js +323 -0
- package/lib/emulator/pubsubEmulator.js +186 -0
- package/lib/emulator/registry.js +122 -0
- package/lib/emulator/shared/request.js +19 -0
- package/lib/emulator/storage/apis/firebase.js +500 -0
- package/lib/emulator/storage/apis/gcloud.js +405 -0
- package/lib/emulator/storage/apis/shared.js +44 -0
- package/lib/emulator/storage/cloudFunctions.js +88 -0
- package/lib/emulator/storage/crc.js +33 -0
- package/lib/emulator/storage/errors.js +9 -0
- package/lib/emulator/storage/files.js +410 -0
- package/lib/emulator/storage/index.js +98 -0
- package/lib/emulator/storage/metadata.js +349 -0
- package/lib/emulator/storage/multipart.js +63 -0
- package/lib/emulator/storage/persistence.js +92 -0
- package/lib/emulator/storage/rules/config.js +53 -0
- package/lib/emulator/storage/rules/expressionValue.js +2 -0
- package/lib/emulator/storage/rules/manager.js +88 -0
- package/lib/emulator/storage/rules/runtime.js +363 -0
- package/lib/emulator/storage/rules/types.js +19 -0
- package/lib/emulator/storage/rules/utils.js +60 -0
- package/lib/emulator/storage/server.js +113 -0
- package/lib/emulator/storage/upload.js +143 -0
- package/lib/emulator/types.js +200 -0
- package/lib/emulator/ui.js +52 -0
- package/lib/emulator/workQueue.js +114 -0
- package/lib/ensureApiEnabled.js +110 -0
- package/lib/ensureCloudResourceLocation.js +12 -0
- package/lib/error.js +29 -0
- package/lib/errorOut.js +23 -0
- package/lib/experiments.js +153 -0
- package/lib/extensions/askUserForEventsConfig.js +97 -0
- package/lib/extensions/askUserForParam.js +338 -0
- package/lib/extensions/billingMigrationHelper.js +61 -0
- package/lib/extensions/change-log.js +95 -0
- package/lib/extensions/checkProjectBilling.js +82 -0
- package/lib/extensions/diagnose.js +56 -0
- package/lib/extensions/displayExtensionInfo.js +175 -0
- package/lib/extensions/emulator/optionsHelper.js +73 -0
- package/lib/extensions/emulator/specHelper.js +102 -0
- package/lib/extensions/emulator/triggerHelper.js +105 -0
- package/lib/extensions/etags.js +28 -0
- package/lib/extensions/export.js +64 -0
- package/lib/extensions/extensionsApi.js +361 -0
- package/lib/extensions/extensionsHelper.js +862 -0
- package/lib/extensions/listExtensions.js +53 -0
- package/lib/extensions/localHelper.js +67 -0
- package/lib/extensions/manifest.js +205 -0
- package/lib/extensions/metricsTypeDef.js +2 -0
- package/lib/extensions/metricsUtils.js +98 -0
- package/lib/extensions/paramHelper.js +140 -0
- package/lib/extensions/provisioningHelper.js +109 -0
- package/lib/extensions/publishHelpers.js +8 -0
- package/lib/extensions/publisherApi.js +214 -0
- package/lib/extensions/refs.js +67 -0
- package/lib/extensions/resolveSource.js +24 -0
- package/lib/extensions/secretsUtils.js +60 -0
- package/lib/extensions/tos.js +90 -0
- package/lib/extensions/types.js +25 -0
- package/lib/extensions/updateHelper.js +127 -0
- package/lib/extensions/utils.js +63 -0
- package/lib/extensions/versionHelper.js +14 -0
- package/lib/extensions/warnings.js +44 -0
- package/lib/fetchMOTD.js +46 -0
- package/lib/fetchWebSetup.js +75 -0
- package/lib/filterTargets.js +34 -0
- package/lib/firebaseConfig.js +2 -0
- package/lib/firebaseConfigValidate.js +29 -0
- package/lib/firestore/api-sort.js +118 -0
- package/lib/firestore/api-spec.js +2 -0
- package/lib/firestore/api-types.js +60 -0
- package/lib/firestore/api.js +566 -0
- package/lib/firestore/checkDatabaseType.js +18 -0
- package/lib/firestore/delete.js +347 -0
- package/lib/firestore/encodeFirestoreValue.js +59 -0
- package/lib/firestore/fsConfig.js +74 -0
- package/lib/firestore/options.js +2 -0
- package/lib/firestore/util.js +39 -0
- package/lib/firestore/validator.js +38 -0
- package/lib/frameworks/angular/index.js +193 -0
- package/lib/frameworks/angular/interfaces.js +2 -0
- package/lib/frameworks/angular/utils.js +431 -0
- package/lib/frameworks/astro/index.js +73 -0
- package/lib/frameworks/astro/utils.js +40 -0
- package/lib/frameworks/compose/discover/filesystem.js +52 -0
- package/lib/frameworks/compose/discover/frameworkMatcher.js +76 -0
- package/lib/frameworks/compose/discover/frameworkSpec.js +39 -0
- package/lib/frameworks/compose/discover/index.js +32 -0
- package/lib/frameworks/compose/discover/runtime/node.js +149 -0
- package/lib/frameworks/compose/discover/types.js +2 -0
- package/lib/frameworks/compose/driver/docker.js +187 -0
- package/lib/frameworks/compose/driver/hooks.js +22 -0
- package/lib/frameworks/compose/driver/index.js +16 -0
- package/lib/frameworks/compose/driver/local.js +51 -0
- package/lib/frameworks/compose/index.js +31 -0
- package/lib/frameworks/compose/interfaces.js +21 -0
- package/lib/frameworks/constants.js +40 -0
- package/lib/frameworks/docs/index.js +2 -0
- package/lib/frameworks/express/index.js +102 -0
- package/lib/frameworks/flutter/constants.js +72 -0
- package/lib/frameworks/flutter/index.js +58 -0
- package/lib/frameworks/flutter/utils.js +11 -0
- package/lib/frameworks/frameworks.js +31 -0
- package/lib/frameworks/index.js +421 -0
- package/lib/frameworks/interfaces.js +2 -0
- package/lib/frameworks/lit/index.js +23 -0
- package/lib/frameworks/next/constants.js +12 -0
- package/lib/frameworks/next/index.js +403 -0
- package/lib/frameworks/next/interfaces.js +2 -0
- package/lib/frameworks/next/utils.js +197 -0
- package/lib/frameworks/nuxt/index.js +92 -0
- package/lib/frameworks/nuxt/interfaces.js +2 -0
- package/lib/frameworks/nuxt/utils.js +23 -0
- package/lib/frameworks/nuxt2/index.js +79 -0
- package/lib/frameworks/preact/index.js +23 -0
- package/lib/frameworks/react/index.js +23 -0
- package/lib/frameworks/svelte/index.js +23 -0
- package/lib/frameworks/sveltekit/index.js +54 -0
- package/lib/frameworks/sveltekit/interfaces.js +2 -0
- package/lib/frameworks/utils.js +260 -0
- package/lib/frameworks/vite/index.js +99 -0
- package/lib/fsAsync.js +43 -0
- package/lib/fsutils.js +35 -0
- package/lib/functional.js +87 -0
- package/lib/functions/constants.js +14 -0
- package/lib/functions/ensureTargeted.js +21 -0
- package/lib/functions/env.js +246 -0
- package/lib/functions/events/index.js +7 -0
- package/lib/functions/events/v1.js +6 -0
- package/lib/functions/events/v2.js +25 -0
- package/lib/functions/functionslog.js +35 -0
- package/lib/functions/projectConfig.js +68 -0
- package/lib/functions/python.js +23 -0
- package/lib/functions/runtimeConfigExport.js +141 -0
- package/lib/functions/secrets.js +239 -0
- package/lib/functionsConfig.js +157 -0
- package/lib/functionsConfigClone.js +68 -0
- package/lib/functionsShellCommandAction.js +112 -0
- package/lib/gcp/artifactregistry.js +16 -0
- package/lib/gcp/auth.js +16 -0
- package/lib/gcp/cloudbilling.js +25 -0
- package/lib/gcp/cloudbuild.js +50 -0
- package/lib/gcp/cloudfunctions.js +351 -0
- package/lib/gcp/cloudfunctionsv2.js +389 -0
- package/lib/gcp/cloudlogging.js +25 -0
- package/lib/gcp/cloudmonitoring.js +77 -0
- package/lib/gcp/cloudscheduler.js +155 -0
- package/lib/gcp/cloudtasks.js +162 -0
- package/lib/gcp/docker.js +80 -0
- package/lib/gcp/eventarc.js +42 -0
- package/lib/gcp/firestore.js +47 -0
- package/lib/gcp/frameworks.js +40 -0
- package/lib/gcp/iam.js +76 -0
- package/lib/gcp/identityPlatform.js +44 -0
- package/lib/gcp/index.js +11 -0
- package/lib/gcp/location.js +44 -0
- package/lib/gcp/proto.js +130 -0
- package/lib/gcp/pubsub.js +34 -0
- package/lib/gcp/resourceManager.js +74 -0
- package/lib/gcp/rules.js +156 -0
- package/lib/gcp/run.js +157 -0
- package/lib/gcp/runtimeconfig.js +127 -0
- package/lib/gcp/secretManager.js +207 -0
- package/lib/gcp/serviceusage.js +24 -0
- package/lib/gcp/storage.js +111 -0
- package/lib/getDefaultDatabaseInstance.js +10 -0
- package/lib/getDefaultHostingSite.js +32 -0
- package/lib/getProjectNumber.js +15 -0
- package/lib/handlePreviewToggles.js +38 -0
- package/lib/hosting/api.js +289 -0
- package/lib/hosting/cloudRunProxy.js +52 -0
- package/lib/hosting/config.js +189 -0
- package/lib/hosting/expireUtils.js +33 -0
- package/lib/hosting/functionsProxy.js +42 -0
- package/lib/hosting/implicitInit.js +58 -0
- package/lib/hosting/initMiddleware.js +63 -0
- package/lib/hosting/interactive.js +75 -0
- package/lib/hosting/options.js +3 -0
- package/lib/hosting/proxy.js +143 -0
- package/lib/hosting/runTags.js +114 -0
- package/lib/index.js +71 -0
- package/lib/init/features/account.js +62 -0
- package/lib/init/features/database.js +133 -0
- package/lib/init/features/emulators.js +102 -0
- package/lib/init/features/extensions/index.js +16 -0
- package/lib/init/features/firestore/index.js +36 -0
- package/lib/init/features/firestore/indexes.js +71 -0
- package/lib/init/features/firestore/rules.js +80 -0
- package/lib/init/features/frameworks/constants.js +7 -0
- package/lib/init/features/frameworks/index.js +116 -0
- package/lib/init/features/frameworks/repo.js +125 -0
- package/lib/init/features/functions/index.js +165 -0
- package/lib/init/features/functions/javascript.js +46 -0
- package/lib/init/features/functions/npm-dependencies.js +37 -0
- package/lib/init/features/functions/python.js +48 -0
- package/lib/init/features/functions/typescript.js +61 -0
- package/lib/init/features/hosting/github.js +397 -0
- package/lib/init/features/hosting/index.js +183 -0
- package/lib/init/features/index.js +27 -0
- package/lib/init/features/project.js +101 -0
- package/lib/init/features/remoteconfig.js +32 -0
- package/lib/init/features/storage.js +27 -0
- package/lib/init/index.js +45 -0
- package/lib/listFiles.js +15 -0
- package/lib/loadCJSON.js +17 -0
- package/lib/localFunction.js +222 -0
- package/lib/logError.js +29 -0
- package/lib/logger.js +31 -0
- package/lib/management/apps.js +280 -0
- package/lib/management/database.js +184 -0
- package/lib/management/projects.js +312 -0
- package/lib/metaprogramming.js +2 -0
- package/lib/monospace/index.js +82 -0
- package/lib/monospace/interfaces.js +2 -0
- package/lib/operation-poller.js +59 -0
- package/lib/options.js +2 -0
- package/lib/parseBoltRules.js +29 -0
- package/lib/profileReport.js +577 -0
- package/lib/profiler.js +99 -0
- package/lib/projectPath.js +16 -0
- package/lib/projectUtils.js +59 -0
- package/lib/prompt.js +50 -0
- package/lib/rc.js +165 -0
- package/lib/remoteconfig/get.js +49 -0
- package/lib/remoteconfig/interfaces.js +17 -0
- package/lib/remoteconfig/rollback.js +22 -0
- package/lib/remoteconfig/versionslist.js +33 -0
- package/lib/requireAuth.js +81 -0
- package/lib/requireConfig.js +13 -0
- package/lib/requireDatabaseInstance.js +26 -0
- package/lib/requireHostingSite.js +12 -0
- package/lib/requireInteractive.js +12 -0
- package/lib/requirePermissions.js +30 -0
- package/lib/responseToError.js +58 -0
- package/lib/rtdb.js +35 -0
- package/lib/rulesDeploy.js +180 -0
- package/lib/scopes.js +10 -0
- package/lib/serve/functions.js +64 -0
- package/lib/serve/hosting.js +115 -0
- package/lib/serve/index.js +53 -0
- package/lib/shortenUrl.js +29 -0
- package/lib/throttler/errors/retries-exhausted-error.js +11 -0
- package/lib/throttler/errors/task-error.js +9 -0
- package/lib/throttler/errors/timeout-error.js +9 -0
- package/lib/throttler/queue.js +23 -0
- package/lib/throttler/stack.js +28 -0
- package/lib/throttler/throttler.js +230 -0
- package/lib/track.js +196 -0
- package/lib/unzip.js +126 -0
- package/lib/utils.js +488 -0
- package/package.json +239 -0
- package/schema/extension-yaml.json +432 -0
- package/schema/firebase-config.json +2619 -0
- package/standalone/check.js +6 -0
- package/standalone/config.template.js +19 -0
- package/standalone/firepit.js +1074 -0
- package/standalone/package-lock.json +7019 -0
- package/standalone/package.json +36 -0
- package/standalone/runtime.js +122 -0
- package/standalone/welcome.js +178 -0
- package/templates/_gitignore +66 -0
- package/templates/banner.txt +6 -0
- package/templates/emulators/default_storage.rules +8 -0
- package/templates/extensions/CL-template.md +2 -0
- package/templates/extensions/POSTINSTALL.md +29 -0
- package/templates/extensions/PREINSTALL.md +22 -0
- package/templates/extensions/extension.yaml +61 -0
- package/templates/extensions/integration-test.env +2 -0
- package/templates/extensions/integration-test.json +14 -0
- package/templates/extensions/javascript/WELCOME.md +18 -0
- package/templates/extensions/javascript/_gitignore +1 -0
- package/templates/extensions/javascript/index.js +25 -0
- package/templates/extensions/javascript/integration-test.js +13 -0
- package/templates/extensions/javascript/package.lint.json +25 -0
- package/templates/extensions/javascript/package.nolint.json +19 -0
- package/templates/extensions/typescript/WELCOME.md +22 -0
- package/templates/extensions/typescript/_gitignore +8 -0
- package/templates/extensions/typescript/_mocharc +10 -0
- package/templates/extensions/typescript/index.ts +26 -0
- package/templates/extensions/typescript/integration-test.ts +13 -0
- package/templates/extensions/typescript/package.lint.json +31 -0
- package/templates/extensions/typescript/package.nolint.json +24 -0
- package/templates/extensions/typescript/tsconfig.dev.json +5 -0
- package/templates/extensions/typescript/tsconfig.json +15 -0
- package/templates/firebase.json +9 -0
- package/templates/hosting/init.js +36 -0
- package/templates/init/firestore/firestore.indexes.json +26 -0
- package/templates/init/firestore/firestore.rules +16 -0
- package/templates/init/functions/javascript/_eslintrc +28 -0
- package/templates/init/functions/javascript/_gitignore +1 -0
- package/templates/init/functions/javascript/index.js +19 -0
- package/templates/init/functions/javascript/package.lint.json +26 -0
- package/templates/init/functions/javascript/package.nolint.json +23 -0
- package/templates/init/functions/python/_gitignore +0 -0
- package/templates/init/functions/python/main.py +13 -0
- package/templates/init/functions/python/requirements.txt +1 -0
- package/templates/init/functions/typescript/_eslintrc +32 -0
- package/templates/init/functions/typescript/_gitignore +9 -0
- package/templates/init/functions/typescript/index.ts +19 -0
- package/templates/init/functions/typescript/package.lint.json +31 -0
- package/templates/init/functions/typescript/package.nolint.json +25 -0
- package/templates/init/functions/typescript/tsconfig.dev.json +5 -0
- package/templates/init/functions/typescript/tsconfig.json +15 -0
- package/templates/init/hosting/404.html +33 -0
- package/templates/init/hosting/index.html +89 -0
- package/templates/init/storage/storage.rules +12 -0
- package/templates/loginFailure.html +34 -0
- package/templates/loginSuccess.html +32 -0
- package/templates/loginSuccessGithub.html +32 -0
- package/templates/setup/web.js +5 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveExpression = exports.ExprParseError = exports.isCelExpression = void 0;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
const functional_1 = require("../../functional");
|
|
6
|
+
const paramRegexp = /params\.(\S+)/;
|
|
7
|
+
const CMP = /((?:!=)|(?:==)|(?:>=)|(?:<=)|>|<)/.source;
|
|
8
|
+
const identityRegexp = /{{ params\.(\S+) }}/;
|
|
9
|
+
const dualComparisonRegexp = new RegExp(/{{ params\.(\S+) CMP params\.(\S+) }}/.source.replace("CMP", CMP));
|
|
10
|
+
const comparisonRegexp = new RegExp(/{{ params\.(\S+) CMP (.+) }}/.source.replace("CMP", CMP));
|
|
11
|
+
const dualTernaryRegexp = new RegExp(/{{ params\.(\S+) CMP params\.(\S+) \? (.+) : (.+) }/.source.replace("CMP", CMP));
|
|
12
|
+
const ternaryRegexp = new RegExp(/{{ params\.(\S+) CMP (.+) \? (.+) : (.+) }/.source.replace("CMP", CMP));
|
|
13
|
+
const literalTernaryRegexp = /{{ params\.(\S+) \? (.+) : (.+) }/;
|
|
14
|
+
function listEquals(a, b) {
|
|
15
|
+
return a.every((item) => b.includes(item)) && b.every((item) => a.includes(item));
|
|
16
|
+
}
|
|
17
|
+
function isCelExpression(value) {
|
|
18
|
+
return typeof value === "string" && value.includes("{{") && value.includes("}}");
|
|
19
|
+
}
|
|
20
|
+
exports.isCelExpression = isCelExpression;
|
|
21
|
+
function isIdentityExpression(value) {
|
|
22
|
+
return identityRegexp.test(value);
|
|
23
|
+
}
|
|
24
|
+
function isComparisonExpression(value) {
|
|
25
|
+
return comparisonRegexp.test(value);
|
|
26
|
+
}
|
|
27
|
+
function isDualComparisonExpression(value) {
|
|
28
|
+
return dualComparisonRegexp.test(value);
|
|
29
|
+
}
|
|
30
|
+
function isTernaryExpression(value) {
|
|
31
|
+
return ternaryRegexp.test(value);
|
|
32
|
+
}
|
|
33
|
+
function isLiteralTernaryExpression(value) {
|
|
34
|
+
return literalTernaryRegexp.test(value);
|
|
35
|
+
}
|
|
36
|
+
function isDualTernaryExpression(value) {
|
|
37
|
+
return dualTernaryRegexp.test(value);
|
|
38
|
+
}
|
|
39
|
+
class ExprParseError extends error_1.FirebaseError {
|
|
40
|
+
}
|
|
41
|
+
exports.ExprParseError = ExprParseError;
|
|
42
|
+
function resolveExpression(wantType, expr, params) {
|
|
43
|
+
expr = preprocessLists(wantType, expr, params);
|
|
44
|
+
if (isIdentityExpression(expr)) {
|
|
45
|
+
return resolveIdentity(wantType, expr, params);
|
|
46
|
+
}
|
|
47
|
+
else if (isDualTernaryExpression(expr)) {
|
|
48
|
+
return resolveDualTernary(wantType, expr, params);
|
|
49
|
+
}
|
|
50
|
+
else if (isLiteralTernaryExpression(expr)) {
|
|
51
|
+
return resolveLiteralTernary(wantType, expr, params);
|
|
52
|
+
}
|
|
53
|
+
else if (isTernaryExpression(expr)) {
|
|
54
|
+
return resolveTernary(wantType, expr, params);
|
|
55
|
+
}
|
|
56
|
+
else if (isDualComparisonExpression(expr)) {
|
|
57
|
+
return resolveDualComparison(expr, params);
|
|
58
|
+
}
|
|
59
|
+
else if (isComparisonExpression(expr)) {
|
|
60
|
+
return resolveComparison(expr, params);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new ExprParseError("CEL expression '" + expr + "' is of an unsupported form");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.resolveExpression = resolveExpression;
|
|
67
|
+
function preprocessLists(wantType, expr, params) {
|
|
68
|
+
let rv = expr;
|
|
69
|
+
const listMatcher = /\[[^\[\]]*\]/g;
|
|
70
|
+
let match;
|
|
71
|
+
while ((match = listMatcher.exec(expr)) != null) {
|
|
72
|
+
const list = match[0];
|
|
73
|
+
const resolved = resolveList("string", list, params);
|
|
74
|
+
rv = rv.replace(list, JSON.stringify(resolved));
|
|
75
|
+
}
|
|
76
|
+
return rv;
|
|
77
|
+
}
|
|
78
|
+
function resolveList(wantType, list, params) {
|
|
79
|
+
if (!list.startsWith("[") || !list.endsWith("]")) {
|
|
80
|
+
throw new ExprParseError("Invalid list: must start with '[' and end with ']'");
|
|
81
|
+
}
|
|
82
|
+
else if (list === "[]") {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
const rv = [];
|
|
86
|
+
const entries = list.slice(1, -1).split(",");
|
|
87
|
+
for (const entry of entries) {
|
|
88
|
+
const trimmed = entry.trim();
|
|
89
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
|
|
90
|
+
rv.push(trimmed.slice(1, -1));
|
|
91
|
+
}
|
|
92
|
+
else if (trimmed.startsWith("{{") && trimmed.endsWith("}}")) {
|
|
93
|
+
rv.push(resolveExpression("string", trimmed, params));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const paramMatch = paramRegexp.exec(trimmed);
|
|
97
|
+
if (!paramMatch) {
|
|
98
|
+
throw new ExprParseError(`Malformed list component ${trimmed}`);
|
|
99
|
+
}
|
|
100
|
+
else if (!(paramMatch[1] in params)) {
|
|
101
|
+
throw new ExprParseError(`List expansion referenced nonexistent param ${paramMatch[1]}`);
|
|
102
|
+
}
|
|
103
|
+
rv.push(resolveParamListOrLiteral("string", trimmed, params));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return rv;
|
|
107
|
+
}
|
|
108
|
+
function assertType(wantType, paramName, paramValue) {
|
|
109
|
+
if ((wantType === "string" && !paramValue.legalString) ||
|
|
110
|
+
(wantType === "number" && !paramValue.legalNumber) ||
|
|
111
|
+
(wantType === "boolean" && !paramValue.legalBoolean) ||
|
|
112
|
+
(wantType === "string[]" && !paramValue.legalList)) {
|
|
113
|
+
throw new ExprParseError(`Illegal type coercion of param ${paramName} to type ${wantType}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function readParamValue(wantType, paramName, paramValue) {
|
|
117
|
+
assertType(wantType, paramName, paramValue);
|
|
118
|
+
if (wantType === "string") {
|
|
119
|
+
return paramValue.asString();
|
|
120
|
+
}
|
|
121
|
+
else if (wantType === "number") {
|
|
122
|
+
return paramValue.asNumber();
|
|
123
|
+
}
|
|
124
|
+
else if (wantType === "boolean") {
|
|
125
|
+
return paramValue.asBoolean();
|
|
126
|
+
}
|
|
127
|
+
else if (wantType === "string[]") {
|
|
128
|
+
return paramValue.asList();
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
(0, functional_1.assertExhaustive)(wantType);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function resolveIdentity(wantType, expr, params) {
|
|
135
|
+
const match = identityRegexp.exec(expr);
|
|
136
|
+
if (!match) {
|
|
137
|
+
throw new ExprParseError("Malformed CEL identity expression '" + expr + "'");
|
|
138
|
+
}
|
|
139
|
+
const name = match[1];
|
|
140
|
+
const value = params[name];
|
|
141
|
+
if (!value) {
|
|
142
|
+
throw new ExprParseError("CEL identity expression '" + expr + "' was not resolvable to a param");
|
|
143
|
+
}
|
|
144
|
+
return readParamValue(wantType, name, value);
|
|
145
|
+
}
|
|
146
|
+
function resolveComparison(expr, params) {
|
|
147
|
+
const match = comparisonRegexp.exec(expr);
|
|
148
|
+
if (!match) {
|
|
149
|
+
throw new ExprParseError("Malformed CEL comparison expression '" + expr + "'");
|
|
150
|
+
}
|
|
151
|
+
const cmp = match[2];
|
|
152
|
+
const test = function (a, b) {
|
|
153
|
+
switch (cmp) {
|
|
154
|
+
case "!=":
|
|
155
|
+
return Array.isArray(a) ? !listEquals(a, b) : a !== b;
|
|
156
|
+
case "==":
|
|
157
|
+
return Array.isArray(a) ? listEquals(a, b) : a === b;
|
|
158
|
+
case ">=":
|
|
159
|
+
return a >= b;
|
|
160
|
+
case "<=":
|
|
161
|
+
return a <= b;
|
|
162
|
+
case ">":
|
|
163
|
+
return a > b;
|
|
164
|
+
case "<":
|
|
165
|
+
return a < b;
|
|
166
|
+
default:
|
|
167
|
+
throw new ExprParseError("Illegal comparison operator '" + cmp + "'");
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const lhsName = match[1];
|
|
171
|
+
const lhsVal = params[lhsName];
|
|
172
|
+
if (!lhsVal) {
|
|
173
|
+
throw new ExprParseError("CEL comparison expression '" + expr + "' references missing param " + lhsName);
|
|
174
|
+
}
|
|
175
|
+
let rhs;
|
|
176
|
+
if (lhsVal.legalString) {
|
|
177
|
+
rhs = resolveLiteral("string", match[3]);
|
|
178
|
+
return test(lhsVal.asString(), rhs);
|
|
179
|
+
}
|
|
180
|
+
else if (lhsVal.legalNumber) {
|
|
181
|
+
rhs = resolveLiteral("number", match[3]);
|
|
182
|
+
return test(lhsVal.asNumber(), rhs);
|
|
183
|
+
}
|
|
184
|
+
else if (lhsVal.legalBoolean) {
|
|
185
|
+
rhs = resolveLiteral("boolean", match[3]);
|
|
186
|
+
return test(lhsVal.asBoolean(), rhs);
|
|
187
|
+
}
|
|
188
|
+
else if (lhsVal.legalList) {
|
|
189
|
+
if (!["==", "!="].includes(cmp)) {
|
|
190
|
+
throw new ExprParseError(`Unsupported comparison operation ${cmp} on list operands in expression ${expr}`);
|
|
191
|
+
}
|
|
192
|
+
rhs = resolveLiteral("string[]", match[3]);
|
|
193
|
+
return test(lhsVal.asList(), rhs);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
throw new ExprParseError(`Could not infer type of param ${lhsName} used in comparison operation`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function resolveDualComparison(expr, params) {
|
|
200
|
+
const match = dualComparisonRegexp.exec(expr);
|
|
201
|
+
if (!match) {
|
|
202
|
+
throw new ExprParseError("Malformed CEL comparison expression '" + expr + "'");
|
|
203
|
+
}
|
|
204
|
+
const cmp = match[2];
|
|
205
|
+
const test = function (a, b) {
|
|
206
|
+
switch (cmp) {
|
|
207
|
+
case "!=":
|
|
208
|
+
return Array.isArray(a) ? !listEquals(a, b) : a !== b;
|
|
209
|
+
case "==":
|
|
210
|
+
return Array.isArray(a) ? listEquals(a, b) : a === b;
|
|
211
|
+
case ">=":
|
|
212
|
+
return a >= b;
|
|
213
|
+
case "<=":
|
|
214
|
+
return a <= b;
|
|
215
|
+
case ">":
|
|
216
|
+
return a > b;
|
|
217
|
+
case "<":
|
|
218
|
+
return a < b;
|
|
219
|
+
default:
|
|
220
|
+
throw new ExprParseError("Illegal comparison operator '" + cmp + "'");
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const lhsName = match[1];
|
|
224
|
+
const lhsVal = params[lhsName];
|
|
225
|
+
if (!lhsVal) {
|
|
226
|
+
throw new ExprParseError("CEL comparison expression '" + expr + "' references missing param " + lhsName);
|
|
227
|
+
}
|
|
228
|
+
const rhsName = match[3];
|
|
229
|
+
const rhsVal = params[rhsName];
|
|
230
|
+
if (!rhsVal) {
|
|
231
|
+
throw new ExprParseError("CEL comparison expression '" + expr + "' references missing param " + lhsName);
|
|
232
|
+
}
|
|
233
|
+
if (lhsVal.legalString) {
|
|
234
|
+
if (!rhsVal.legalString) {
|
|
235
|
+
throw new ExprParseError(`CEL comparison expression ${expr} has type mismatch between the operands`);
|
|
236
|
+
}
|
|
237
|
+
return test(lhsVal.asString(), rhsVal.asString());
|
|
238
|
+
}
|
|
239
|
+
else if (lhsVal.legalNumber) {
|
|
240
|
+
if (!rhsVal.legalNumber) {
|
|
241
|
+
throw new ExprParseError(`CEL comparison expression ${expr} has type mismatch between the operands`);
|
|
242
|
+
}
|
|
243
|
+
return test(lhsVal.asNumber(), rhsVal.asNumber());
|
|
244
|
+
}
|
|
245
|
+
else if (lhsVal.legalBoolean) {
|
|
246
|
+
if (!rhsVal.legalBoolean) {
|
|
247
|
+
throw new ExprParseError(`CEL comparison expression ${expr} has type mismatch between the operands`);
|
|
248
|
+
}
|
|
249
|
+
return test(lhsVal.asBoolean(), rhsVal.asBoolean());
|
|
250
|
+
}
|
|
251
|
+
else if (lhsVal.legalList) {
|
|
252
|
+
if (!rhsVal.legalList) {
|
|
253
|
+
throw new ExprParseError(`CEL comparison expression ${expr} has type mismatch between the operands`);
|
|
254
|
+
}
|
|
255
|
+
if (!["==", "!="].includes(cmp)) {
|
|
256
|
+
throw new ExprParseError(`Unsupported comparison operation ${cmp} on list operands in expression ${expr}`);
|
|
257
|
+
}
|
|
258
|
+
return test(lhsVal.asList(), rhsVal.asList());
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
throw new ExprParseError(`could not infer type of param ${lhsName} used in comparison operation`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function resolveTernary(wantType, expr, params) {
|
|
265
|
+
const match = ternaryRegexp.exec(expr);
|
|
266
|
+
if (!match) {
|
|
267
|
+
throw new ExprParseError("malformed CEL ternary expression '" + expr + "'");
|
|
268
|
+
}
|
|
269
|
+
const comparisonExpr = `{{ params.${match[1]} ${match[2]} ${match[3]} }}`;
|
|
270
|
+
const isTrue = resolveComparison(comparisonExpr, params);
|
|
271
|
+
if (isTrue) {
|
|
272
|
+
return resolveParamListOrLiteral(wantType, match[4], params);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
return resolveParamListOrLiteral(wantType, match[5], params);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function resolveDualTernary(wantType, expr, params) {
|
|
279
|
+
const match = dualTernaryRegexp.exec(expr);
|
|
280
|
+
if (!match) {
|
|
281
|
+
throw new ExprParseError("Malformed CEL ternary expression '" + expr + "'");
|
|
282
|
+
}
|
|
283
|
+
const comparisonExpr = `{{ params.${match[1]} ${match[2]} params.${match[3]} }}`;
|
|
284
|
+
const isTrue = resolveDualComparison(comparisonExpr, params);
|
|
285
|
+
if (isTrue) {
|
|
286
|
+
return resolveParamListOrLiteral(wantType, match[4], params);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
return resolveParamListOrLiteral(wantType, match[5], params);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function resolveLiteralTernary(wantType, expr, params) {
|
|
293
|
+
const match = literalTernaryRegexp.exec(expr);
|
|
294
|
+
if (!match) {
|
|
295
|
+
throw new ExprParseError("Malformed CEL ternary expression '" + expr + "'");
|
|
296
|
+
}
|
|
297
|
+
const paramName = match[1];
|
|
298
|
+
const paramValue = params[match[1]];
|
|
299
|
+
if (!paramValue) {
|
|
300
|
+
throw new ExprParseError("CEL ternary expression '" + expr + "' references missing param " + paramName);
|
|
301
|
+
}
|
|
302
|
+
if (!paramValue.legalBoolean) {
|
|
303
|
+
throw new ExprParseError("CEL ternary expression '" + expr + "' is conditional on non-boolean param " + paramName);
|
|
304
|
+
}
|
|
305
|
+
if (paramValue.asBoolean()) {
|
|
306
|
+
return resolveParamListOrLiteral(wantType, match[2], params);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
return resolveParamListOrLiteral(wantType, match[3], params);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function resolveParamListOrLiteral(wantType, field, params) {
|
|
313
|
+
const match = paramRegexp.exec(field);
|
|
314
|
+
if (!match) {
|
|
315
|
+
return resolveLiteral(wantType, field);
|
|
316
|
+
}
|
|
317
|
+
const paramValue = params[match[1]];
|
|
318
|
+
if (!paramValue) {
|
|
319
|
+
throw new ExprParseError("CEL expression resolved to the value of a missing param " + match[1]);
|
|
320
|
+
}
|
|
321
|
+
return readParamValue(wantType, match[1], paramValue);
|
|
322
|
+
}
|
|
323
|
+
function resolveLiteral(wantType, value) {
|
|
324
|
+
if (paramRegexp.exec(value)) {
|
|
325
|
+
throw new ExprParseError("CEL tried to evaluate param." + value + " in a context which only permits literal values");
|
|
326
|
+
}
|
|
327
|
+
if (wantType === "string[]") {
|
|
328
|
+
const parsed = JSON.parse(value);
|
|
329
|
+
if (!Array.isArray(parsed)) {
|
|
330
|
+
throw new ExprParseError(`CEL tried to read non-list ${JSON.stringify(parsed)} as a list`);
|
|
331
|
+
}
|
|
332
|
+
for (const shouldBeString of parsed) {
|
|
333
|
+
if (typeof shouldBeString !== "string") {
|
|
334
|
+
throw new ExprParseError(`Evaluated CEL list ${JSON.stringify(parsed)} contained non-string values`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return parsed;
|
|
338
|
+
}
|
|
339
|
+
else if (wantType === "number") {
|
|
340
|
+
if (isNaN(+value)) {
|
|
341
|
+
throw new ExprParseError("CEL literal " + value + " does not seem to be a number");
|
|
342
|
+
}
|
|
343
|
+
return +value;
|
|
344
|
+
}
|
|
345
|
+
else if (wantType === "string") {
|
|
346
|
+
if (!value.startsWith('"') || !value.endsWith('"')) {
|
|
347
|
+
throw new ExprParseError("CEL literal " + value + ' does not seem to be a "-delimited string');
|
|
348
|
+
}
|
|
349
|
+
return value.slice(1, -1);
|
|
350
|
+
}
|
|
351
|
+
else if (wantType === "boolean") {
|
|
352
|
+
if (value === "true") {
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
else if (value === "false") {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
throw new ExprParseError("CEL literal " + value + "does not seem to be a true/false boolean");
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
throw new ExprParseError("CEL literal '" + value + "' somehow was resolved with a non-string/number/boolean type");
|
|
364
|
+
}
|
|
365
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureServiceAgentRoles = exports.mergeBindings = exports.obtainDefaultComputeServiceAgentBindings = exports.obtainPubSubServiceAgentBindings = exports.getDefaultComputeServiceAgent = exports.checkHttpIam = exports.checkServiceAccountIam = exports.EVENTARC_EVENT_RECEIVER_ROLE = exports.RUN_INVOKER_ROLE = exports.SERVICE_ACCOUNT_TOKEN_CREATOR_ROLE = void 0;
|
|
4
|
+
const colorette_1 = require("colorette");
|
|
5
|
+
const logger_1 = require("../../logger");
|
|
6
|
+
const functionsDeployHelper_1 = require("./functionsDeployHelper");
|
|
7
|
+
const error_1 = require("../../error");
|
|
8
|
+
const functional_1 = require("../../functional");
|
|
9
|
+
const iam = require("../../gcp/iam");
|
|
10
|
+
const backend = require("./backend");
|
|
11
|
+
const track_1 = require("../../track");
|
|
12
|
+
const utils = require("../../utils");
|
|
13
|
+
const resourceManager_1 = require("../../gcp/resourceManager");
|
|
14
|
+
const services_1 = require("./services");
|
|
15
|
+
const PERMISSION = "cloudfunctions.functions.setIamPolicy";
|
|
16
|
+
exports.SERVICE_ACCOUNT_TOKEN_CREATOR_ROLE = "roles/iam.serviceAccountTokenCreator";
|
|
17
|
+
exports.RUN_INVOKER_ROLE = "roles/run.invoker";
|
|
18
|
+
exports.EVENTARC_EVENT_RECEIVER_ROLE = "roles/eventarc.eventReceiver";
|
|
19
|
+
async function checkServiceAccountIam(projectId) {
|
|
20
|
+
const saEmail = `${projectId}@appspot.gserviceaccount.com`;
|
|
21
|
+
let passed = false;
|
|
22
|
+
try {
|
|
23
|
+
const iamResult = await iam.testResourceIamPermissions("https://iam.googleapis.com", "v1", `projects/${projectId}/serviceAccounts/${saEmail}`, ["iam.serviceAccounts.actAs"]);
|
|
24
|
+
passed = iamResult.passed;
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
logger_1.logger.debug("[functions] service account IAM check errored, deploy may fail:", err);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (!passed) {
|
|
31
|
+
throw new error_1.FirebaseError(`Missing permissions required for functions deploy. You must have permission ${(0, colorette_1.bold)("iam.serviceAccounts.ActAs")} on service account ${(0, colorette_1.bold)(saEmail)}.\n\n` +
|
|
32
|
+
`To address this error, ask a project Owner to assign your account the "Service Account User" role from this URL:\n\n` +
|
|
33
|
+
`https://console.cloud.google.com/iam-admin/iam?project=${projectId}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.checkServiceAccountIam = checkServiceAccountIam;
|
|
37
|
+
async function checkHttpIam(context, options, payload) {
|
|
38
|
+
if (!payload.functions) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const filters = context.filters || (0, functionsDeployHelper_1.getEndpointFilters)(options);
|
|
42
|
+
const wantBackends = Object.values(payload.functions).map(({ wantBackend }) => wantBackend);
|
|
43
|
+
const httpEndpoints = [...(0, functional_1.flattenArray)(wantBackends.map((b) => backend.allEndpoints(b)))]
|
|
44
|
+
.filter(backend.isHttpsTriggered)
|
|
45
|
+
.filter((f) => (0, functionsDeployHelper_1.endpointMatchesAnyFilter)(f, filters));
|
|
46
|
+
const existing = await backend.existingBackend(context);
|
|
47
|
+
const newHttpsEndpoints = httpEndpoints.filter(backend.missingEndpoint(existing));
|
|
48
|
+
if (newHttpsEndpoints.length === 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
logger_1.logger.debug("[functions] found", newHttpsEndpoints.length, "new HTTP functions, testing setIamPolicy permission...");
|
|
52
|
+
let passed = true;
|
|
53
|
+
try {
|
|
54
|
+
const iamResult = await iam.testIamPermissions(context.projectId, [PERMISSION]);
|
|
55
|
+
passed = iamResult.passed;
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
logger_1.logger.debug("[functions] failed http create setIamPolicy permission check. deploy may fail:", e);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!passed) {
|
|
62
|
+
void (0, track_1.trackGA4)("error", {
|
|
63
|
+
error_type: "Error (User)",
|
|
64
|
+
details: "deploy:functions:http_create_missing_iam",
|
|
65
|
+
});
|
|
66
|
+
throw new error_1.FirebaseError(`Missing required permission on project ${(0, colorette_1.bold)(context.projectId)} to deploy new HTTPS functions. The permission ${(0, colorette_1.bold)(PERMISSION)} is required to deploy the following functions:\n\n- ` +
|
|
67
|
+
newHttpsEndpoints.map((func) => func.id).join("\n- ") +
|
|
68
|
+
`\n\nTo address this error, please ask a project Owner to assign your account the "Cloud Functions Admin" role at the following URL:\n\nhttps://console.cloud.google.com/iam-admin/iam?project=${context.projectId}`);
|
|
69
|
+
}
|
|
70
|
+
logger_1.logger.debug("[functions] found setIamPolicy permission, proceeding with deploy");
|
|
71
|
+
}
|
|
72
|
+
exports.checkHttpIam = checkHttpIam;
|
|
73
|
+
function getPubsubServiceAgent(projectNumber) {
|
|
74
|
+
return `service-${projectNumber}@gcp-sa-pubsub.iam.gserviceaccount.com`;
|
|
75
|
+
}
|
|
76
|
+
function getDefaultComputeServiceAgent(projectNumber) {
|
|
77
|
+
return `${projectNumber}-compute@developer.gserviceaccount.com`;
|
|
78
|
+
}
|
|
79
|
+
exports.getDefaultComputeServiceAgent = getDefaultComputeServiceAgent;
|
|
80
|
+
function reduceEventsToServices(services, endpoint) {
|
|
81
|
+
const service = (0, services_1.serviceForEndpoint)(endpoint);
|
|
82
|
+
if (service.requiredProjectBindings && !services.find((s) => s.name === service.name)) {
|
|
83
|
+
services.push(service);
|
|
84
|
+
}
|
|
85
|
+
return services;
|
|
86
|
+
}
|
|
87
|
+
function obtainPubSubServiceAgentBindings(projectNumber) {
|
|
88
|
+
const serviceAccountTokenCreatorBinding = {
|
|
89
|
+
role: exports.SERVICE_ACCOUNT_TOKEN_CREATOR_ROLE,
|
|
90
|
+
members: [`serviceAccount:${getPubsubServiceAgent(projectNumber)}`],
|
|
91
|
+
};
|
|
92
|
+
return [serviceAccountTokenCreatorBinding];
|
|
93
|
+
}
|
|
94
|
+
exports.obtainPubSubServiceAgentBindings = obtainPubSubServiceAgentBindings;
|
|
95
|
+
function obtainDefaultComputeServiceAgentBindings(projectNumber) {
|
|
96
|
+
const defaultComputeServiceAgent = `serviceAccount:${getDefaultComputeServiceAgent(projectNumber)}`;
|
|
97
|
+
const runInvokerBinding = {
|
|
98
|
+
role: exports.RUN_INVOKER_ROLE,
|
|
99
|
+
members: [defaultComputeServiceAgent],
|
|
100
|
+
};
|
|
101
|
+
const eventarcEventReceiverBinding = {
|
|
102
|
+
role: exports.EVENTARC_EVENT_RECEIVER_ROLE,
|
|
103
|
+
members: [defaultComputeServiceAgent],
|
|
104
|
+
};
|
|
105
|
+
return [runInvokerBinding, eventarcEventReceiverBinding];
|
|
106
|
+
}
|
|
107
|
+
exports.obtainDefaultComputeServiceAgentBindings = obtainDefaultComputeServiceAgentBindings;
|
|
108
|
+
function mergeBindings(policy, requiredBindings) {
|
|
109
|
+
let updated = false;
|
|
110
|
+
for (const requiredBinding of requiredBindings) {
|
|
111
|
+
const match = policy.bindings.find((b) => b.role === requiredBinding.role);
|
|
112
|
+
if (!match) {
|
|
113
|
+
updated = true;
|
|
114
|
+
policy.bindings.push(requiredBinding);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
for (const requiredMember of requiredBinding.members) {
|
|
118
|
+
if (!match.members.find((m) => m === requiredMember)) {
|
|
119
|
+
updated = true;
|
|
120
|
+
match.members.push(requiredMember);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return updated;
|
|
125
|
+
}
|
|
126
|
+
exports.mergeBindings = mergeBindings;
|
|
127
|
+
function printManualIamConfig(requiredBindings, projectId) {
|
|
128
|
+
utils.logLabeledBullet("functions", "Failed to verify the project has the correct IAM bindings for a successful deployment.", "warn");
|
|
129
|
+
utils.logLabeledBullet("functions", "You can either re-run `firebase deploy` as a project owner or manually run the following set of `gcloud` commands:", "warn");
|
|
130
|
+
for (const binding of requiredBindings) {
|
|
131
|
+
for (const member of binding.members) {
|
|
132
|
+
utils.logLabeledBullet("functions", `\`gcloud projects add-iam-policy-binding ${projectId} ` +
|
|
133
|
+
`--member=${member} ` +
|
|
134
|
+
`--role=${binding.role}\``, "warn");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function ensureServiceAgentRoles(projectId, projectNumber, want, have) {
|
|
139
|
+
const wantServices = backend.allEndpoints(want).reduce(reduceEventsToServices, []);
|
|
140
|
+
const haveServices = backend.allEndpoints(have).reduce(reduceEventsToServices, []);
|
|
141
|
+
const newServices = wantServices.filter((wantS) => !haveServices.find((haveS) => wantS.name === haveS.name));
|
|
142
|
+
if (newServices.length === 0) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const requiredBindingsPromises = [];
|
|
146
|
+
for (const service of newServices) {
|
|
147
|
+
requiredBindingsPromises.push(service.requiredProjectBindings(projectNumber));
|
|
148
|
+
}
|
|
149
|
+
const nestedRequiredBindings = await Promise.all(requiredBindingsPromises);
|
|
150
|
+
const requiredBindings = [...(0, functional_1.flattenArray)(nestedRequiredBindings)];
|
|
151
|
+
if (haveServices.length === 0) {
|
|
152
|
+
requiredBindings.push(...obtainPubSubServiceAgentBindings(projectNumber));
|
|
153
|
+
requiredBindings.push(...obtainDefaultComputeServiceAgentBindings(projectNumber));
|
|
154
|
+
}
|
|
155
|
+
if (requiredBindings.length === 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
let policy;
|
|
159
|
+
try {
|
|
160
|
+
policy = await (0, resourceManager_1.getIamPolicy)(projectNumber);
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
printManualIamConfig(requiredBindings, projectId);
|
|
164
|
+
utils.logLabeledBullet("functions", "Could not verify the necessary IAM configuration for the following newly-integrated services: " +
|
|
165
|
+
`${newServices.map((service) => service.api).join(", ")}` +
|
|
166
|
+
". Deployment may fail.", "warn");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const hasUpdatedBindings = mergeBindings(policy, requiredBindings);
|
|
170
|
+
if (!hasUpdatedBindings) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
await (0, resourceManager_1.setIamPolicy)(projectNumber, policy, "bindings");
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
printManualIamConfig(requiredBindings, projectId);
|
|
178
|
+
throw new error_1.FirebaseError("We failed to modify the IAM policy for the project. The functions " +
|
|
179
|
+
"deployment requires specific roles to be granted to service agents," +
|
|
180
|
+
" otherwise the deployment will fail.", { original: err });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.ensureServiceAgentRoles = ensureServiceAgentRoles;
|