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,410 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
3
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
+
var m = o[Symbol.asyncIterator], i;
|
|
5
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
6
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
7
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.StorageLayer = exports.StoredFile = void 0;
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
|
+
const metadata_1 = require("./metadata");
|
|
13
|
+
const errors_1 = require("./errors");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const fse = require("fs-extra");
|
|
16
|
+
const logger_1 = require("../../logger");
|
|
17
|
+
const adminSdkConfig_1 = require("../adminSdkConfig");
|
|
18
|
+
const types_1 = require("./rules/types");
|
|
19
|
+
const upload_1 = require("./upload");
|
|
20
|
+
const track_1 = require("../../track");
|
|
21
|
+
const types_2 = require("../types");
|
|
22
|
+
class StoredFile {
|
|
23
|
+
get metadata() {
|
|
24
|
+
return this._metadata;
|
|
25
|
+
}
|
|
26
|
+
set metadata(value) {
|
|
27
|
+
this._metadata = value;
|
|
28
|
+
}
|
|
29
|
+
constructor(metadata) {
|
|
30
|
+
this.metadata = metadata;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.StoredFile = StoredFile;
|
|
34
|
+
const TRAILING_SLASHES_PATTERN = /\/+$/;
|
|
35
|
+
class StorageLayer {
|
|
36
|
+
constructor(_projectId, _files, _buckets, _rulesValidator, _adminCredsValidator, _persistence, _cloudFunctions) {
|
|
37
|
+
this._projectId = _projectId;
|
|
38
|
+
this._files = _files;
|
|
39
|
+
this._buckets = _buckets;
|
|
40
|
+
this._rulesValidator = _rulesValidator;
|
|
41
|
+
this._adminCredsValidator = _adminCredsValidator;
|
|
42
|
+
this._persistence = _persistence;
|
|
43
|
+
this._cloudFunctions = _cloudFunctions;
|
|
44
|
+
}
|
|
45
|
+
createBucket(id) {
|
|
46
|
+
if (!this._buckets.has(id)) {
|
|
47
|
+
this._buckets.set(id, new metadata_1.CloudStorageBucketMetadata(id));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async listBuckets() {
|
|
51
|
+
if (this._buckets.size === 0) {
|
|
52
|
+
let adminSdkConfig = await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(this._projectId);
|
|
53
|
+
if (!adminSdkConfig) {
|
|
54
|
+
adminSdkConfig = (0, adminSdkConfig_1.constructDefaultAdminSdkConfig)(this._projectId);
|
|
55
|
+
}
|
|
56
|
+
this.createBucket(adminSdkConfig.storageBucket);
|
|
57
|
+
}
|
|
58
|
+
return [...this._buckets.values()];
|
|
59
|
+
}
|
|
60
|
+
async getObject(request) {
|
|
61
|
+
var _a;
|
|
62
|
+
const metadata = this.getMetadata(request.bucketId, request.decodedObjectId);
|
|
63
|
+
const hasValidDownloadToken = ((metadata === null || metadata === void 0 ? void 0 : metadata.downloadTokens) || []).includes((_a = request.downloadToken) !== null && _a !== void 0 ? _a : "");
|
|
64
|
+
let authorized = hasValidDownloadToken;
|
|
65
|
+
if (!authorized) {
|
|
66
|
+
authorized = await this._rulesValidator.validate(["b", request.bucketId, "o", request.decodedObjectId].join("/"), request.bucketId, types_1.RulesetOperationMethod.GET, { before: metadata === null || metadata === void 0 ? void 0 : metadata.asRulesResource() }, this._projectId, request.authorization);
|
|
67
|
+
}
|
|
68
|
+
if (!authorized) {
|
|
69
|
+
throw new errors_1.ForbiddenError("Failed auth");
|
|
70
|
+
}
|
|
71
|
+
if (!metadata) {
|
|
72
|
+
throw new errors_1.NotFoundError("File not found");
|
|
73
|
+
}
|
|
74
|
+
return { metadata: metadata, data: this.getBytes(request.bucketId, request.decodedObjectId) };
|
|
75
|
+
}
|
|
76
|
+
getMetadata(bucket, object) {
|
|
77
|
+
const key = this.path(bucket, object);
|
|
78
|
+
const val = this._files.get(key);
|
|
79
|
+
if (val) {
|
|
80
|
+
return val.metadata;
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
getBytes(bucket, object, size, offset) {
|
|
85
|
+
const key = this.path(bucket, object);
|
|
86
|
+
const val = this._files.get(key);
|
|
87
|
+
if (val) {
|
|
88
|
+
const len = size ? size : Number(val.metadata.size);
|
|
89
|
+
return this._persistence.readBytes(this.path(bucket, object), len, offset);
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
async deleteObject(request) {
|
|
94
|
+
const storedMetadata = this.getMetadata(request.bucketId, request.decodedObjectId);
|
|
95
|
+
const authorized = await this._rulesValidator.validate(["b", request.bucketId, "o", request.decodedObjectId].join("/"), request.bucketId, types_1.RulesetOperationMethod.DELETE, { before: storedMetadata === null || storedMetadata === void 0 ? void 0 : storedMetadata.asRulesResource() }, this._projectId, request.authorization);
|
|
96
|
+
if (!authorized) {
|
|
97
|
+
throw new errors_1.ForbiddenError();
|
|
98
|
+
}
|
|
99
|
+
if (!storedMetadata) {
|
|
100
|
+
throw new errors_1.NotFoundError();
|
|
101
|
+
}
|
|
102
|
+
this.deleteFile(request.bucketId, request.decodedObjectId);
|
|
103
|
+
}
|
|
104
|
+
deleteFile(bucketId, objectId) {
|
|
105
|
+
const isFolder = objectId.toLowerCase().endsWith("%2f");
|
|
106
|
+
if (isFolder) {
|
|
107
|
+
objectId = objectId.slice(0, -3);
|
|
108
|
+
}
|
|
109
|
+
let filePath = this.path(bucketId, objectId);
|
|
110
|
+
if (isFolder) {
|
|
111
|
+
filePath += "%2F";
|
|
112
|
+
}
|
|
113
|
+
const file = this._files.get(filePath);
|
|
114
|
+
if (file === undefined) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this._files.delete(filePath);
|
|
119
|
+
this._persistence.deleteFile(filePath);
|
|
120
|
+
this._cloudFunctions.dispatch("delete", new metadata_1.CloudStorageObjectMetadata(file.metadata));
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async updateObjectMetadata(request) {
|
|
125
|
+
const storedMetadata = this.getMetadata(request.bucketId, request.decodedObjectId);
|
|
126
|
+
const authorized = await this._rulesValidator.validate(["b", request.bucketId, "o", request.decodedObjectId].join("/"), request.bucketId, types_1.RulesetOperationMethod.UPDATE, {
|
|
127
|
+
before: storedMetadata === null || storedMetadata === void 0 ? void 0 : storedMetadata.asRulesResource(),
|
|
128
|
+
after: storedMetadata === null || storedMetadata === void 0 ? void 0 : storedMetadata.asRulesResource(request.metadata),
|
|
129
|
+
}, this._projectId, request.authorization);
|
|
130
|
+
if (!authorized) {
|
|
131
|
+
throw new errors_1.ForbiddenError();
|
|
132
|
+
}
|
|
133
|
+
if (!storedMetadata) {
|
|
134
|
+
throw new errors_1.NotFoundError();
|
|
135
|
+
}
|
|
136
|
+
storedMetadata.update(request.metadata);
|
|
137
|
+
return storedMetadata;
|
|
138
|
+
}
|
|
139
|
+
async uploadObject(upload) {
|
|
140
|
+
if (upload.status !== upload_1.UploadStatus.FINISHED) {
|
|
141
|
+
throw new Error(`Unexpected upload status encountered: ${upload.status}.`);
|
|
142
|
+
}
|
|
143
|
+
const storedMetadata = this.getMetadata(upload.bucketId, upload.objectId);
|
|
144
|
+
const filePath = this.path(upload.bucketId, upload.objectId);
|
|
145
|
+
function getIncomingMetadata(field) {
|
|
146
|
+
if (!upload.metadata) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
const value = upload.metadata[field];
|
|
150
|
+
return value === null ? undefined : value;
|
|
151
|
+
}
|
|
152
|
+
const metadata = new metadata_1.StoredFileMetadata({
|
|
153
|
+
name: upload.objectId,
|
|
154
|
+
bucket: upload.bucketId,
|
|
155
|
+
contentType: getIncomingMetadata("contentType"),
|
|
156
|
+
contentDisposition: getIncomingMetadata("contentDisposition"),
|
|
157
|
+
contentEncoding: getIncomingMetadata("contentEncoding"),
|
|
158
|
+
contentLanguage: getIncomingMetadata("contentLanguage"),
|
|
159
|
+
cacheControl: getIncomingMetadata("cacheControl"),
|
|
160
|
+
customMetadata: getIncomingMetadata("metadata"),
|
|
161
|
+
}, this._cloudFunctions, this._persistence.readBytes(upload.path, upload.size));
|
|
162
|
+
const authorized = await this._rulesValidator.validate(["b", upload.bucketId, "o", upload.objectId].join("/"), upload.bucketId, types_1.RulesetOperationMethod.CREATE, {
|
|
163
|
+
before: storedMetadata === null || storedMetadata === void 0 ? void 0 : storedMetadata.asRulesResource(),
|
|
164
|
+
after: metadata.asRulesResource(),
|
|
165
|
+
}, this._projectId, upload.authorization);
|
|
166
|
+
if (!authorized) {
|
|
167
|
+
this._persistence.deleteFile(upload.path);
|
|
168
|
+
throw new errors_1.ForbiddenError();
|
|
169
|
+
}
|
|
170
|
+
this._persistence.deleteFile(filePath, true);
|
|
171
|
+
this._persistence.renameFile(upload.path, filePath);
|
|
172
|
+
this._files.set(filePath, new StoredFile(metadata));
|
|
173
|
+
this._cloudFunctions.dispatch("finalize", new metadata_1.CloudStorageObjectMetadata(metadata));
|
|
174
|
+
return metadata;
|
|
175
|
+
}
|
|
176
|
+
copyObject({ sourceBucket, sourceObject, destinationBucket, destinationObject, incomingMetadata, authorization, }) {
|
|
177
|
+
if (!this._adminCredsValidator.validate(authorization)) {
|
|
178
|
+
throw new errors_1.ForbiddenError();
|
|
179
|
+
}
|
|
180
|
+
const sourceMetadata = this.getMetadata(sourceBucket, sourceObject);
|
|
181
|
+
if (!sourceMetadata) {
|
|
182
|
+
throw new errors_1.NotFoundError();
|
|
183
|
+
}
|
|
184
|
+
const sourceBytes = this.getBytes(sourceBucket, sourceObject);
|
|
185
|
+
const destinationFilePath = this.path(destinationBucket, destinationObject);
|
|
186
|
+
this._persistence.deleteFile(destinationFilePath, true);
|
|
187
|
+
this._persistence.appendBytes(destinationFilePath, sourceBytes);
|
|
188
|
+
const newMetadata = Object.assign(Object.assign(Object.assign({}, sourceMetadata), { metadata: sourceMetadata.customMetadata }), incomingMetadata);
|
|
189
|
+
if (sourceMetadata.downloadTokens.length &&
|
|
190
|
+
!((incomingMetadata === null || incomingMetadata === void 0 ? void 0 : incomingMetadata.metadata) && Object.keys(incomingMetadata === null || incomingMetadata === void 0 ? void 0 : incomingMetadata.metadata).length)) {
|
|
191
|
+
if (!newMetadata.metadata)
|
|
192
|
+
newMetadata.metadata = {};
|
|
193
|
+
newMetadata.metadata.firebaseStorageDownloadTokens = sourceMetadata.downloadTokens.join(",");
|
|
194
|
+
}
|
|
195
|
+
if (newMetadata.metadata) {
|
|
196
|
+
for (const [k, v] of Object.entries(newMetadata.metadata)) {
|
|
197
|
+
if (v === null)
|
|
198
|
+
newMetadata.metadata[k] = "";
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function getMetadata(field) {
|
|
202
|
+
const value = newMetadata[field];
|
|
203
|
+
return value === null ? undefined : value;
|
|
204
|
+
}
|
|
205
|
+
const copiedFileMetadata = new metadata_1.StoredFileMetadata({
|
|
206
|
+
name: destinationObject,
|
|
207
|
+
bucket: destinationBucket,
|
|
208
|
+
contentType: getMetadata("contentType"),
|
|
209
|
+
contentDisposition: getMetadata("contentDisposition"),
|
|
210
|
+
contentEncoding: getMetadata("contentEncoding"),
|
|
211
|
+
contentLanguage: getMetadata("contentLanguage"),
|
|
212
|
+
cacheControl: getMetadata("cacheControl"),
|
|
213
|
+
customMetadata: getMetadata("metadata"),
|
|
214
|
+
}, this._cloudFunctions, sourceBytes);
|
|
215
|
+
const file = new StoredFile(copiedFileMetadata);
|
|
216
|
+
this._files.set(destinationFilePath, file);
|
|
217
|
+
this._cloudFunctions.dispatch("finalize", new metadata_1.CloudStorageObjectMetadata(file.metadata));
|
|
218
|
+
return file.metadata;
|
|
219
|
+
}
|
|
220
|
+
async listObjects(request) {
|
|
221
|
+
var _a;
|
|
222
|
+
const { bucketId, prefix, delimiter, pageToken, authorization } = request;
|
|
223
|
+
const authorized = await this._rulesValidator.validate(["b", bucketId, "o", prefix.replace(TRAILING_SLASHES_PATTERN, "")].join("/"), bucketId, types_1.RulesetOperationMethod.LIST, {}, this._projectId, authorization, delimiter);
|
|
224
|
+
if (!authorized) {
|
|
225
|
+
throw new errors_1.ForbiddenError();
|
|
226
|
+
}
|
|
227
|
+
let items = [];
|
|
228
|
+
const prefixes = new Set();
|
|
229
|
+
for (const [, file] of this._files) {
|
|
230
|
+
if (file.metadata.bucket !== bucketId) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const name = file.metadata.name;
|
|
234
|
+
if (!name.startsWith(prefix)) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
let includeMetadata = true;
|
|
238
|
+
if (delimiter) {
|
|
239
|
+
const delimiterIdx = name.indexOf(delimiter);
|
|
240
|
+
const delimiterAfterPrefixIdx = name.indexOf(delimiter, prefix.length);
|
|
241
|
+
includeMetadata = delimiterIdx === -1 || delimiterAfterPrefixIdx === -1;
|
|
242
|
+
if (delimiterAfterPrefixIdx !== -1) {
|
|
243
|
+
prefixes.add(name.slice(0, delimiterAfterPrefixIdx + delimiter.length));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (includeMetadata) {
|
|
247
|
+
items.push(file.metadata);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
items.sort((a, b) => {
|
|
251
|
+
if (a.name === b.name) {
|
|
252
|
+
return 0;
|
|
253
|
+
}
|
|
254
|
+
else if (a.name < b.name) {
|
|
255
|
+
return -1;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
return 1;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
if (pageToken) {
|
|
262
|
+
const idx = items.findIndex((v) => v.name === pageToken);
|
|
263
|
+
if (idx !== -1) {
|
|
264
|
+
items = items.slice(idx);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const maxResults = (_a = request.maxResults) !== null && _a !== void 0 ? _a : 1000;
|
|
268
|
+
let nextPageToken = undefined;
|
|
269
|
+
if (items.length > maxResults) {
|
|
270
|
+
nextPageToken = items[maxResults].name;
|
|
271
|
+
items = items.slice(0, maxResults);
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
nextPageToken,
|
|
275
|
+
prefixes: prefixes.size > 0 ? [...prefixes].sort() : undefined,
|
|
276
|
+
items: items.length > 0 ? items : undefined,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
createDownloadToken(request) {
|
|
280
|
+
if (!this._adminCredsValidator.validate(request.authorization)) {
|
|
281
|
+
throw new errors_1.ForbiddenError();
|
|
282
|
+
}
|
|
283
|
+
const metadata = this.getMetadata(request.bucketId, request.decodedObjectId);
|
|
284
|
+
if (!metadata) {
|
|
285
|
+
throw new errors_1.NotFoundError();
|
|
286
|
+
}
|
|
287
|
+
metadata.addDownloadToken();
|
|
288
|
+
return metadata;
|
|
289
|
+
}
|
|
290
|
+
deleteDownloadToken(request) {
|
|
291
|
+
if (!this._adminCredsValidator.validate(request.authorization)) {
|
|
292
|
+
throw new errors_1.ForbiddenError();
|
|
293
|
+
}
|
|
294
|
+
const metadata = this.getMetadata(request.bucketId, request.decodedObjectId);
|
|
295
|
+
if (!metadata) {
|
|
296
|
+
throw new errors_1.NotFoundError();
|
|
297
|
+
}
|
|
298
|
+
metadata.deleteDownloadToken(request.token);
|
|
299
|
+
return metadata;
|
|
300
|
+
}
|
|
301
|
+
path(bucket, object) {
|
|
302
|
+
return path.join(bucket, object);
|
|
303
|
+
}
|
|
304
|
+
get dirPath() {
|
|
305
|
+
return this._persistence.dirPath;
|
|
306
|
+
}
|
|
307
|
+
async export(storageExportPath, options) {
|
|
308
|
+
var _a, e_1, _b, _c;
|
|
309
|
+
const bucketsList = {
|
|
310
|
+
buckets: [],
|
|
311
|
+
};
|
|
312
|
+
for (const b of await this.listBuckets()) {
|
|
313
|
+
bucketsList.buckets.push({ id: b.id });
|
|
314
|
+
}
|
|
315
|
+
void (0, track_1.trackEmulator)("emulator_export", {
|
|
316
|
+
initiated_by: options.initiatedBy,
|
|
317
|
+
emulator_name: types_2.Emulators.STORAGE,
|
|
318
|
+
count: bucketsList.buckets.length,
|
|
319
|
+
});
|
|
320
|
+
const bucketsFilePath = path.join(storageExportPath, "buckets.json");
|
|
321
|
+
await fse.writeFile(bucketsFilePath, JSON.stringify(bucketsList, undefined, 2));
|
|
322
|
+
const blobsDirPath = path.join(storageExportPath, "blobs");
|
|
323
|
+
await fse.ensureDir(blobsDirPath);
|
|
324
|
+
const metadataDirPath = path.join(storageExportPath, "metadata");
|
|
325
|
+
await fse.ensureDir(metadataDirPath);
|
|
326
|
+
try {
|
|
327
|
+
for (var _d = true, _e = __asyncValues(this._files.entries()), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
|
328
|
+
_c = _f.value;
|
|
329
|
+
_d = false;
|
|
330
|
+
try {
|
|
331
|
+
const [, file] = _c;
|
|
332
|
+
const diskFileName = this._persistence.getDiskFileName(this.path(file.metadata.bucket, file.metadata.name));
|
|
333
|
+
await fse.copy(path.join(this.dirPath, diskFileName), path.join(blobsDirPath, diskFileName));
|
|
334
|
+
const metadataExportPath = path.join(metadataDirPath, encodeURIComponent(diskFileName)) + ".json";
|
|
335
|
+
await fse.writeFile(metadataExportPath, metadata_1.StoredFileMetadata.toJSON(file.metadata));
|
|
336
|
+
}
|
|
337
|
+
finally {
|
|
338
|
+
_d = true;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
343
|
+
finally {
|
|
344
|
+
try {
|
|
345
|
+
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
|
|
346
|
+
}
|
|
347
|
+
finally { if (e_1) throw e_1.error; }
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
import(storageExportPath, options) {
|
|
351
|
+
const bucketsFile = path.join(storageExportPath, "buckets.json");
|
|
352
|
+
const bucketsList = JSON.parse((0, fs_1.readFileSync)(bucketsFile, "utf-8"));
|
|
353
|
+
void (0, track_1.trackEmulator)("emulator_import", {
|
|
354
|
+
initiated_by: options.initiatedBy,
|
|
355
|
+
emulator_name: types_2.Emulators.STORAGE,
|
|
356
|
+
count: bucketsList.buckets.length,
|
|
357
|
+
});
|
|
358
|
+
for (const b of bucketsList.buckets) {
|
|
359
|
+
const bucketMetadata = new metadata_1.CloudStorageBucketMetadata(b.id);
|
|
360
|
+
this._buckets.set(b.id, bucketMetadata);
|
|
361
|
+
}
|
|
362
|
+
const metadataDir = path.join(storageExportPath, "metadata");
|
|
363
|
+
const blobsDir = path.join(storageExportPath, "blobs");
|
|
364
|
+
if (!(0, fs_1.existsSync)(metadataDir) || !(0, fs_1.existsSync)(blobsDir)) {
|
|
365
|
+
logger_1.logger.warn(`Could not find metadata directory at "${metadataDir}" and/or blobs directory at "${blobsDir}".`);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const metadataList = this.walkDirSync(metadataDir);
|
|
369
|
+
const dotJson = ".json";
|
|
370
|
+
for (const f of metadataList) {
|
|
371
|
+
if (path.extname(f) !== dotJson) {
|
|
372
|
+
logger_1.logger.debug(`Skipping unexpected storage metadata file: ${f}`);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
const metadata = metadata_1.StoredFileMetadata.fromJSON((0, fs_1.readFileSync)(f, "utf-8"), this._cloudFunctions);
|
|
376
|
+
const metadataRelPath = path.relative(metadataDir, f);
|
|
377
|
+
const blobPath = metadataRelPath.substring(0, metadataRelPath.length - dotJson.length);
|
|
378
|
+
const blobAbsPath = path.join(blobsDir, blobPath);
|
|
379
|
+
if (!(0, fs_1.existsSync)(blobAbsPath)) {
|
|
380
|
+
logger_1.logger.warn(`Could not find file "${blobPath}" in storage export.`);
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
let fileName = metadata.name;
|
|
384
|
+
const objectNameSep = getPathSep(fileName);
|
|
385
|
+
if (fileName !== path.sep) {
|
|
386
|
+
fileName = fileName.split(objectNameSep).join(path.sep);
|
|
387
|
+
}
|
|
388
|
+
const filepath = this.path(metadata.bucket, fileName);
|
|
389
|
+
this._persistence.copyFromExternalPath(blobAbsPath, filepath);
|
|
390
|
+
this._files.set(filepath, new StoredFile(metadata));
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
*walkDirSync(dir) {
|
|
394
|
+
const files = (0, fs_1.readdirSync)(dir);
|
|
395
|
+
for (const file of files) {
|
|
396
|
+
const p = path.join(dir, file);
|
|
397
|
+
if ((0, fs_1.statSync)(p).isDirectory()) {
|
|
398
|
+
yield* this.walkDirSync(p);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
yield p;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
exports.StorageLayer = StorageLayer;
|
|
407
|
+
function getPathSep(decodedPath) {
|
|
408
|
+
const firstSepIndex = decodedPath.search(/[\/|\\\\]/g);
|
|
409
|
+
return decodedPath[firstSepIndex];
|
|
410
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StorageEmulator = void 0;
|
|
4
|
+
const os_1 = require("os");
|
|
5
|
+
const utils = require("../../utils");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const server_1 = require("./server");
|
|
9
|
+
const files_1 = require("./files");
|
|
10
|
+
const emulatorLogger_1 = require("../emulatorLogger");
|
|
11
|
+
const manager_1 = require("./rules/manager");
|
|
12
|
+
const runtime_1 = require("./rules/runtime");
|
|
13
|
+
const utils_1 = require("./rules/utils");
|
|
14
|
+
const persistence_1 = require("./persistence");
|
|
15
|
+
const upload_1 = require("./upload");
|
|
16
|
+
const cloudFunctions_1 = require("./cloudFunctions");
|
|
17
|
+
class StorageEmulator {
|
|
18
|
+
constructor(args) {
|
|
19
|
+
this.args = args;
|
|
20
|
+
this._logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.STORAGE);
|
|
21
|
+
this._files = new Map();
|
|
22
|
+
this._buckets = new Map();
|
|
23
|
+
this._rulesRuntime = new runtime_1.StorageRulesRuntime();
|
|
24
|
+
this._rulesManager = this.createRulesManager(this.args.rules);
|
|
25
|
+
this._cloudFunctions = new cloudFunctions_1.StorageCloudFunctions(args.projectId);
|
|
26
|
+
this._persistence = new persistence_1.Persistence(this.getPersistenceTmpDir());
|
|
27
|
+
this._uploadService = new upload_1.UploadService(this._persistence);
|
|
28
|
+
const createStorageLayer = (rulesValidator) => {
|
|
29
|
+
return new files_1.StorageLayer(args.projectId, this._files, this._buckets, rulesValidator, (0, utils_1.getAdminCredentialValidator)(), this._persistence, this._cloudFunctions);
|
|
30
|
+
};
|
|
31
|
+
this._storageLayer = createStorageLayer((0, utils_1.getFirebaseRulesValidator)((resource) => this._rulesManager.getRuleset(resource)));
|
|
32
|
+
this._adminStorageLayer = createStorageLayer((0, utils_1.getAdminOnlyFirebaseRulesValidator)());
|
|
33
|
+
}
|
|
34
|
+
get storageLayer() {
|
|
35
|
+
return this._storageLayer;
|
|
36
|
+
}
|
|
37
|
+
get adminStorageLayer() {
|
|
38
|
+
return this._adminStorageLayer;
|
|
39
|
+
}
|
|
40
|
+
get uploadService() {
|
|
41
|
+
return this._uploadService;
|
|
42
|
+
}
|
|
43
|
+
get rulesManager() {
|
|
44
|
+
return this._rulesManager;
|
|
45
|
+
}
|
|
46
|
+
get logger() {
|
|
47
|
+
return this._logger;
|
|
48
|
+
}
|
|
49
|
+
reset() {
|
|
50
|
+
this._files.clear();
|
|
51
|
+
this._buckets.clear();
|
|
52
|
+
this._persistence.reset(this.getPersistenceTmpDir());
|
|
53
|
+
this._uploadService.reset();
|
|
54
|
+
}
|
|
55
|
+
async start() {
|
|
56
|
+
const { host, port } = this.getInfo();
|
|
57
|
+
await this._rulesRuntime.start(this.args.auto_download);
|
|
58
|
+
await this._rulesManager.start();
|
|
59
|
+
this._app = await (0, server_1.createApp)(this.args.projectId, this);
|
|
60
|
+
const server = this._app.listen(port, host);
|
|
61
|
+
this.destroyServer = utils.createDestroyer(server);
|
|
62
|
+
}
|
|
63
|
+
async connect() {
|
|
64
|
+
}
|
|
65
|
+
async stop() {
|
|
66
|
+
await this._persistence.deleteAll();
|
|
67
|
+
await this._rulesRuntime.stop();
|
|
68
|
+
await this._rulesManager.stop();
|
|
69
|
+
return this.destroyServer ? this.destroyServer() : Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
getInfo() {
|
|
72
|
+
const host = this.args.host || constants_1.Constants.getDefaultHost();
|
|
73
|
+
const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.STORAGE);
|
|
74
|
+
return {
|
|
75
|
+
name: this.getName(),
|
|
76
|
+
host,
|
|
77
|
+
port,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
getName() {
|
|
81
|
+
return types_1.Emulators.STORAGE;
|
|
82
|
+
}
|
|
83
|
+
getApp() {
|
|
84
|
+
return this._app;
|
|
85
|
+
}
|
|
86
|
+
createRulesManager(rules) {
|
|
87
|
+
return (0, manager_1.createStorageRulesManager)(rules, this._rulesRuntime);
|
|
88
|
+
}
|
|
89
|
+
async replaceRules(rules) {
|
|
90
|
+
await this._rulesManager.stop();
|
|
91
|
+
this._rulesManager = this.createRulesManager(rules);
|
|
92
|
+
return this._rulesManager.start();
|
|
93
|
+
}
|
|
94
|
+
getPersistenceTmpDir() {
|
|
95
|
+
return `${(0, os_1.tmpdir)()}/firebase/storage/blobs`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.StorageEmulator = StorageEmulator;
|