firebase-tools-with-isolate 13.29.1 → 14.10.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -4
- package/lib/api.js +10 -2
- package/lib/appdistribution/client.js +2 -2
- package/lib/apphosting/backend.js +157 -55
- package/lib/apphosting/config.js +121 -101
- package/lib/apphosting/githubConnections.js +65 -100
- package/lib/apphosting/repo.js +22 -36
- package/lib/apphosting/rollout.js +5 -11
- package/lib/apphosting/secrets/dialogs.js +13 -11
- package/lib/apphosting/secrets/index.js +47 -5
- package/lib/apphosting/utils.js +1 -3
- package/lib/apphosting/yaml.js +35 -49
- package/lib/auth.js +23 -6
- package/lib/bin/cli.js +99 -0
- package/lib/bin/firebase.js +7 -123
- package/lib/bin/mcp.js +49 -0
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +3 -2
- package/lib/commands/appdistribution-distribute.js +1 -1
- package/lib/commands/appdistribution-groups-create.js +1 -1
- package/lib/commands/appdistribution-groups-delete.js +1 -1
- package/lib/commands/appdistribution-groups-list.js +2 -2
- package/lib/commands/appdistribution-testers-add.js +1 -1
- package/lib/commands/appdistribution-testers-list.js +3 -3
- package/lib/commands/appdistribution-testers-remove.js +1 -1
- package/lib/commands/apphosting-backends-create.js +3 -3
- package/lib/commands/apphosting-backends-delete.js +23 -27
- package/lib/commands/apphosting-backends-get.js +12 -12
- package/lib/commands/apphosting-backends-list.js +5 -5
- package/lib/commands/apphosting-builds-create.js +8 -2
- package/lib/commands/apphosting-builds-get.js +8 -1
- package/lib/commands/apphosting-rollouts-create.js +3 -3
- package/lib/commands/apphosting-rollouts-list.js +8 -2
- package/lib/commands/apphosting-secrets-access.js +1 -1
- package/lib/commands/apphosting-secrets-describe.js +2 -2
- package/lib/commands/apphosting-secrets-grantaccess.js +20 -10
- package/lib/commands/apphosting-secrets-set.js +27 -1
- package/lib/commands/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-android-sha-list.js +2 -2
- package/lib/commands/apps-create.js +4 -108
- package/lib/commands/apps-init.js +94 -0
- package/lib/commands/apps-list.js +1 -1
- package/lib/commands/apps-sdkconfig.js +5 -10
- package/lib/commands/auth-export.js +1 -1
- package/lib/commands/auth-import.js +1 -1
- package/lib/commands/database-import.js +4 -6
- package/lib/commands/database-instances-create.js +1 -1
- package/lib/commands/database-instances-list.js +1 -1
- package/lib/commands/database-profile.js +1 -2
- package/lib/commands/database-remove.js +4 -6
- package/lib/commands/database-set.js +6 -6
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/database-update.js +6 -6
- package/lib/commands/dataconnect-sdk-generate.js +5 -2
- package/lib/commands/dataconnect-services-list.js +2 -2
- package/lib/commands/dataconnect-sql-diff.js +2 -2
- package/lib/commands/dataconnect-sql-grant.js +3 -3
- package/lib/commands/dataconnect-sql-migrate.js +2 -2
- package/lib/commands/dataconnect-sql-setup.js +39 -0
- package/lib/commands/dataconnect-sql-shell.js +5 -7
- package/lib/commands/deploy.js +4 -3
- package/lib/commands/emulators-exec.js +1 -1
- package/lib/commands/emulators-start.js +4 -3
- package/lib/commands/experiments-list.js +1 -1
- package/lib/commands/ext-dev-deprecate.js +1 -0
- package/lib/commands/ext-dev-init.js +3 -12
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-register.js +3 -5
- package/lib/commands/ext-dev-undeprecate.js +1 -2
- package/lib/commands/ext-dev-usage.js +4 -6
- package/lib/commands/ext-export.js +1 -2
- package/lib/commands/ext-install.js +3 -3
- package/lib/commands/ext-sdk-install.js +1 -0
- package/lib/commands/ext-update.js +1 -0
- package/lib/commands/firestore-backups-delete.js +3 -4
- package/lib/commands/firestore-backups-get.js +1 -1
- package/lib/commands/firestore-backups-list.js +2 -2
- package/lib/commands/firestore-backups-schedules-create.js +4 -4
- package/lib/commands/firestore-backups-schedules-delete.js +3 -4
- package/lib/commands/firestore-backups-schedules-list.js +2 -2
- package/lib/commands/firestore-backups-schedules-update.js +1 -1
- package/lib/commands/firestore-databases-create.js +6 -6
- package/lib/commands/firestore-databases-delete.js +3 -7
- package/lib/commands/firestore-databases-get.js +1 -1
- package/lib/commands/firestore-databases-list.js +1 -1
- package/lib/commands/firestore-databases-restore.js +5 -5
- package/lib/commands/firestore-databases-update.js +4 -4
- package/lib/commands/firestore-delete.js +13 -14
- package/lib/commands/firestore-indexes-list.js +4 -4
- package/lib/commands/firestore-locations.js +1 -1
- package/lib/commands/functions-artifacts-setpolicy.js +132 -0
- package/lib/commands/functions-config-export.js +6 -10
- package/lib/commands/functions-delete.js +5 -7
- package/lib/commands/functions-deletegcfartifacts.js +5 -5
- package/lib/commands/functions-list.js +24 -33
- package/lib/commands/functions-secrets-access.js +1 -1
- package/lib/commands/functions-secrets-describe.js +1 -1
- package/lib/commands/functions-secrets-destroy.js +10 -12
- package/lib/commands/functions-secrets-get.js +1 -1
- package/lib/commands/functions-secrets-prune.js +14 -15
- package/lib/commands/functions-secrets-set.js +14 -18
- package/lib/commands/hosting-channel-create.js +1 -2
- package/lib/commands/hosting-channel-delete.js +4 -4
- package/lib/commands/hosting-channel-list.js +1 -1
- package/lib/commands/hosting-channel-open.js +2 -3
- package/lib/commands/hosting-disable.js +5 -5
- package/lib/commands/hosting-sites-delete.js +4 -4
- package/lib/commands/hosting-sites-get.js +1 -1
- package/lib/commands/hosting-sites-list.js +1 -1
- package/lib/commands/index.js +7 -4
- package/lib/commands/init.js +54 -60
- package/lib/commands/internaltesting-frameworks-compose.js +1 -1
- package/lib/commands/login-use.js +2 -11
- package/lib/commands/login.js +10 -8
- package/lib/commands/logout.js +2 -3
- package/lib/commands/mcp.js +11 -0
- package/lib/commands/open.js +4 -2
- package/lib/commands/projects-create.js +1 -2
- package/lib/commands/projects-list.js +1 -1
- package/lib/commands/remoteconfig-get.js +1 -1
- package/lib/commands/remoteconfig-rollback.js +5 -5
- package/lib/commands/remoteconfig-versions-list.js +2 -2
- package/lib/commands/setup-emulators-database.js +1 -1
- package/lib/commands/setup-emulators-dataconnect.js +1 -1
- package/lib/commands/setup-emulators-firestore.js +1 -1
- package/lib/commands/setup-emulators-pubsub.js +1 -1
- package/lib/commands/setup-emulators-storage.js +1 -1
- package/lib/commands/setup-emulators-ui.js +1 -1
- package/lib/commands/use.js +115 -111
- package/lib/config.js +49 -33
- package/lib/crashlytics/buildToolsJarHelper.js +1 -1
- package/lib/crashlytics/listTopIssues.js +45 -0
- package/lib/dataconnect/build.js +61 -4
- package/lib/dataconnect/client.js +26 -17
- package/lib/dataconnect/cloudAICompanionClient.js +72 -0
- package/lib/dataconnect/dataplaneClient.js +19 -2
- package/lib/dataconnect/ensureApis.js +6 -3
- package/lib/dataconnect/fileUtils.js +39 -6
- package/lib/dataconnect/freeTrial.js +21 -9
- package/lib/dataconnect/graphqlError.js +56 -2
- package/lib/dataconnect/provisionCloudSql.js +23 -12
- package/lib/dataconnect/schemaMigration.js +46 -26
- package/lib/dataconnect/types.js +5 -1
- package/lib/defaultCredentials.js +12 -1
- package/lib/deploy/apphosting/args.js +2 -0
- package/lib/deploy/apphosting/deploy.js +77 -0
- package/lib/deploy/apphosting/index.js +9 -0
- package/lib/deploy/apphosting/prepare.js +138 -0
- package/lib/deploy/apphosting/release.js +56 -0
- package/lib/deploy/apphosting/util.js +65 -0
- package/lib/deploy/dataconnect/deploy.js +14 -7
- package/lib/deploy/dataconnect/prepare.js +3 -5
- package/lib/deploy/extensions/v2FunctionHelper.js +2 -1
- package/lib/deploy/firestore/deploy.js +50 -4
- package/lib/deploy/functions/build.js +1 -0
- package/lib/deploy/functions/checkIam.js +41 -6
- package/lib/deploy/functions/containerCleaner.js +17 -2
- package/lib/deploy/functions/ensure.js +2 -1
- package/lib/deploy/functions/params.js +10 -17
- package/lib/deploy/functions/prepare.js +51 -18
- package/lib/deploy/functions/prepareFunctionsUpload.js +9 -5
- package/lib/deploy/functions/prompts.js +24 -17
- package/lib/deploy/functions/release/fabricator.js +4 -4
- package/lib/deploy/functions/release/index.js +27 -9
- package/lib/deploy/functions/release/planner.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +13 -5
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -4
- package/lib/deploy/functions/runtimes/python/index.js +4 -1
- package/lib/deploy/functions/runtimes/supported/types.js +17 -11
- package/lib/deploy/functions/services/firestore.js +23 -4
- package/lib/deploy/index.js +29 -10
- package/lib/deploy/lifecycleHooks.js +6 -12
- package/lib/emulator/ExpressBasedEmulator.js +1 -1
- package/lib/emulator/apphosting/config.js +15 -14
- package/lib/emulator/apphosting/index.js +2 -0
- package/lib/emulator/apphosting/serve.js +147 -10
- package/lib/emulator/auth/cloudFunctions.js +13 -1
- package/lib/emulator/auth/operations.js +2 -1
- package/lib/emulator/auth/widget_ui.js +2 -1
- package/lib/emulator/commandUtils.js +14 -20
- package/lib/emulator/constants.js +2 -0
- package/lib/emulator/controller.js +24 -9
- package/lib/emulator/dataconnect/pgliteServer.js +136 -45
- package/lib/emulator/dataconnectEmulator.js +34 -6
- package/lib/emulator/dataconnectToolkitController.js +5 -0
- package/lib/emulator/downloadableEmulatorInfo.json +81 -0
- package/lib/emulator/downloadableEmulators.js +28 -80
- package/lib/emulator/env.js +47 -1
- package/lib/emulator/extensionsEmulator.js +5 -3
- package/lib/emulator/functionsEmulator.js +6 -26
- package/lib/emulator/hub.js +5 -4
- package/lib/emulator/hubClient.js +5 -0
- package/lib/emulator/initEmulators.js +29 -15
- package/lib/emulator/ui.js +4 -8
- package/lib/ensureApiEnabled.js +32 -1
- package/lib/experiments.js +11 -12
- package/lib/extensions/askUserForEventsConfig.js +6 -15
- package/lib/extensions/askUserForParam.js +23 -52
- package/lib/extensions/change-log.js +1 -25
- package/lib/extensions/checkProjectBilling.js +3 -9
- package/lib/extensions/diagnose.js +3 -6
- package/lib/extensions/emulator/triggerHelper.js +4 -0
- package/lib/extensions/extensionsHelper.js +25 -31
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/manifest.js +3 -7
- package/lib/extensions/paramHelper.js +11 -2
- package/lib/extensions/provisioningHelper.js +1 -1
- package/lib/extensions/tos.js +4 -2
- package/lib/extensions/utils.js +1 -10
- package/lib/firebaseConfigValidate.js +7 -5
- package/lib/firestore/delete.js +5 -4
- package/lib/firestore/pretty-print.js +1 -1
- package/lib/frameworks/angular/index.js +11 -6
- package/lib/frameworks/angular/utils.js +76 -47
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/index.js +6 -4
- package/lib/frameworks/next/index.js +7 -4
- package/lib/frameworks/utils.js +11 -3
- package/lib/frameworks/vite/index.js +2 -3
- package/lib/fsAsync.js +9 -2
- package/lib/fsutils.js +16 -1
- package/lib/functions/artifacts.js +196 -0
- package/lib/functions/secrets.js +15 -16
- package/lib/gcp/apphosting.js +13 -1
- package/lib/gcp/artifactregistry.js +27 -2
- package/lib/gcp/auth.js +113 -1
- package/lib/gcp/cloudbilling.js +12 -1
- package/lib/gcp/cloudfunctions.js +32 -4
- package/lib/gcp/cloudfunctionsv2.js +15 -9
- package/lib/gcp/cloudscheduler.js +2 -2
- package/lib/gcp/cloudsql/cloudsqladmin.js +32 -11
- package/lib/gcp/cloudsql/connect.js +21 -14
- package/lib/gcp/cloudsql/interactive.js +1 -1
- package/lib/gcp/cloudsql/permissions.js +46 -99
- package/lib/gcp/cloudsql/permissionsSetup.js +224 -0
- package/lib/gcp/computeEngine.js +19 -2
- package/lib/gcp/devConnect.js +6 -1
- package/lib/gcp/firestore.js +55 -16
- package/lib/gcp/iam.js +1 -5
- package/lib/gcp/proto.js +4 -3
- package/lib/gcp/run.js +18 -1
- package/lib/gcp/serviceusage.js +2 -1
- package/lib/gcp/storage.js +47 -1
- package/lib/gemini/fdcExperience.js +56 -0
- package/lib/gemini/types.js +2 -0
- package/lib/hosting/api.js +4 -0
- package/lib/hosting/implicitInit.js +7 -3
- package/lib/hosting/interactive.js +2 -3
- package/lib/index.js +1 -2
- package/lib/init/features/account.js +2 -4
- package/lib/init/features/apphosting.js +75 -6
- package/lib/init/features/database.js +63 -62
- package/lib/init/features/dataconnect/index.js +131 -85
- package/lib/init/features/dataconnect/sdk.js +73 -18
- package/lib/init/features/emulators.js +29 -46
- package/lib/init/features/firestore/index.js +79 -43
- package/lib/init/features/firestore/indexes.js +30 -45
- package/lib/init/features/firestore/rules.js +36 -62
- package/lib/init/features/functions/index.js +11 -16
- package/lib/init/features/functions/javascript.js +17 -30
- package/lib/init/features/functions/npm-dependencies.js +4 -8
- package/lib/init/features/functions/python.js +1 -3
- package/lib/init/features/functions/typescript.js +25 -43
- package/lib/init/features/genkit/index.js +111 -106
- package/lib/init/features/hosting/github.js +22 -52
- package/lib/init/features/hosting/index.js +37 -57
- package/lib/init/features/index.js +10 -5
- package/lib/init/features/project.js +18 -21
- package/lib/init/features/remoteconfig.js +5 -10
- package/lib/init/features/storage.js +30 -10
- package/lib/init/index.js +79 -24
- package/lib/logger.js +76 -3
- package/lib/management/apps.js +292 -7
- package/lib/management/projects.js +100 -52
- package/lib/mcp/errors.js +20 -0
- package/lib/mcp/index.js +227 -0
- package/lib/mcp/tool.js +12 -0
- package/lib/mcp/tools/apphosting/fetch_logs.js +68 -0
- package/lib/mcp/tools/apphosting/index.js +6 -0
- package/lib/mcp/tools/apphosting/list_backends.js +51 -0
- package/lib/mcp/tools/auth/disable_user.js +30 -0
- package/lib/mcp/tools/auth/get_user.js +38 -0
- package/lib/mcp/tools/auth/index.js +15 -0
- package/lib/mcp/tools/auth/list_users.js +36 -0
- package/lib/mcp/tools/auth/set_claims.js +43 -0
- package/lib/mcp/tools/auth/set_sms_region_policy.js +36 -0
- package/lib/mcp/tools/core/consult_assistant.js +28 -0
- package/lib/mcp/tools/core/create_android_sha.js +43 -0
- package/lib/mcp/tools/core/create_app.js +90 -0
- package/lib/mcp/tools/core/create_project.js +68 -0
- package/lib/mcp/tools/core/get_admin_sdk_config.js +26 -0
- package/lib/mcp/tools/core/get_environment.js +51 -0
- package/lib/mcp/tools/core/get_project.js +22 -0
- package/lib/mcp/tools/core/get_sdk_config.js +40 -0
- package/lib/mcp/tools/core/index.js +29 -0
- package/lib/mcp/tools/core/init.js +153 -0
- package/lib/mcp/tools/core/list_apps.js +34 -0
- package/lib/mcp/tools/core/list_projects.js +45 -0
- package/lib/mcp/tools/core/update_environment.js +55 -0
- package/lib/mcp/tools/crashlytics/index.js +5 -0
- package/lib/mcp/tools/crashlytics/list_top_issues.js +39 -0
- package/lib/mcp/tools/dataconnect/converter.js +60 -0
- package/lib/mcp/tools/dataconnect/emulator.js +16 -0
- package/lib/mcp/tools/dataconnect/execute_graphql.js +48 -0
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +48 -0
- package/lib/mcp/tools/dataconnect/execute_mutation.js +62 -0
- package/lib/mcp/tools/dataconnect/execute_query.js +62 -0
- package/lib/mcp/tools/dataconnect/generate_operation.js +34 -0
- package/lib/mcp/tools/dataconnect/generate_schema.js +26 -0
- package/lib/mcp/tools/dataconnect/get_connector.js +31 -0
- package/lib/mcp/tools/dataconnect/get_schema.js +31 -0
- package/lib/mcp/tools/dataconnect/index.js +23 -0
- package/lib/mcp/tools/dataconnect/list_services.js +23 -0
- package/lib/mcp/tools/firestore/converter.js +102 -0
- package/lib/mcp/tools/firestore/delete_document.js +50 -0
- package/lib/mcp/tools/firestore/get_documents.js +58 -0
- package/lib/mcp/tools/firestore/index.js +17 -0
- package/lib/mcp/tools/firestore/list_collections.js +36 -0
- package/lib/mcp/tools/firestore/query_collection.js +132 -0
- package/lib/mcp/tools/index.js +62 -0
- package/lib/mcp/tools/messaging/index.js +5 -0
- package/lib/mcp/tools/messaging/send_message.js +42 -0
- package/lib/mcp/tools/remoteconfig/get_template.js +27 -0
- package/lib/mcp/tools/remoteconfig/index.js +7 -0
- package/lib/mcp/tools/remoteconfig/publish_template.js +34 -0
- package/lib/mcp/tools/remoteconfig/rollback_template.js +29 -0
- package/lib/mcp/tools/rules/get_rules.js +29 -0
- package/lib/mcp/tools/rules/validate_rules.js +97 -0
- package/lib/mcp/tools/storage/get_download_url.js +40 -0
- package/lib/mcp/tools/storage/get_rules.js +26 -0
- package/lib/mcp/tools/storage/index.js +11 -0
- package/lib/mcp/types.js +13 -0
- package/lib/mcp/util.js +214 -0
- package/lib/mcp/util.test.js +468 -0
- package/lib/messaging/interfaces.js +2 -0
- package/lib/messaging/sendMessage.js +48 -0
- package/lib/operation-poller.js +3 -1
- package/lib/profileReport.js +1 -1
- package/lib/prompt.js +86 -54
- package/lib/remoteconfig/publish.js +39 -0
- package/lib/requireAuth.js +2 -2
- package/lib/requireTosAcceptance.js +4 -0
- package/lib/rulesDeploy.js +10 -15
- package/lib/track.js +7 -37
- package/lib/utils.js +28 -41
- package/lib/vsCodeUtils.js +7 -3
- package/package.json +31 -15
- package/schema/connector-yaml.json +12 -0
- package/schema/dataconnect-yaml.json +5 -0
- package/schema/extension-yaml.json +17 -4
- package/schema/firebase-config.json +1117 -2121
- package/standalone/package-lock.json +1255 -992
- package/standalone/package.json +1 -1
- package/templates/dataconnect-prompts/operation-generation-cursor-windsurf-rule.txt +273 -0
- package/templates/dataconnect-prompts/schema-generation-cursor-windsurf-rule.txt +653 -0
- package/templates/genkit/firebase.0.9.0.template +1 -1
- package/templates/genkit/firebase.1.0.0.template +71 -0
- package/templates/init/dataconnect/connector.yaml +4 -1
- package/templates/init/dataconnect/dataconnect.yaml +1 -1
- package/templates/init/dataconnect/mutations.gql +9 -26
- package/templates/init/dataconnect/queries.gql +9 -14
- package/templates/init/dataconnect/schema.gql +28 -21
- package/templates/init/firestore/firestore.rules +2 -0
- package/templates/init/functions/javascript/index.js +14 -1
- package/templates/init/functions/javascript/package.lint.json +1 -1
- package/templates/init/functions/javascript/package.nolint.json +1 -1
- package/templates/init/functions/python/_gitignore +6 -1
- package/templates/init/functions/python/main.py +8 -0
- package/templates/init/functions/typescript/index.ts +14 -1
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +3 -3
- package/lib/commands/apphosting-config-export.js +0 -28
- package/lib/commands/experimental-functions-shell.js +0 -13
- package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +0 -11
- package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +0 -58
- package/lib/emulator/dataconnect/pg-gateway/auth/index.js +0 -22
- package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +0 -124
- package/lib/emulator/dataconnect/pg-gateway/auth/password.js +0 -54
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +0 -34
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +0 -270
- package/lib/emulator/dataconnect/pg-gateway/backend-error.js +0 -75
- package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +0 -54
- package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +0 -79
- package/lib/emulator/dataconnect/pg-gateway/connection.js +0 -315
- package/lib/emulator/dataconnect/pg-gateway/connection.types.js +0 -8
- package/lib/emulator/dataconnect/pg-gateway/crypto.js +0 -40
- package/lib/emulator/dataconnect/pg-gateway/duplex.js +0 -53
- package/lib/emulator/dataconnect/pg-gateway/index.js +0 -27
- package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +0 -82
- package/lib/emulator/dataconnect/pg-gateway/message-codes.js +0 -52
- package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +0 -16
- package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +0 -35
- package/lib/emulator/dataconnect/pg-gateway/utils.js +0 -40
- package/templates/setup/web.js +0 -5
- /package/lib/{emulator/dataconnect/pg-gateway/auth/trust.js → dataconnect/cloudAICompanionTypes.js} +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Import the Genkit core libraries and plugins.
|
|
2
|
+
import {genkit, z} from "genkit";
|
|
3
|
+
$GENKIT_CONFIG_IMPORTS
|
|
4
|
+
$GENKIT_MODEL_IMPORT
|
|
5
|
+
|
|
6
|
+
// Cloud Functions for Firebase supports Genkit natively. The onCallGenkit function creates a callable
|
|
7
|
+
// function from a Genkit action. It automatically implements streaming if your flow does.
|
|
8
|
+
// The https library also has other utility methods such as hasClaim, which verifies that
|
|
9
|
+
// a caller's token has a specific claim (optionally matching a specific value)
|
|
10
|
+
import { onCallGenkit, hasClaim } from "firebase-functions/https";
|
|
11
|
+
|
|
12
|
+
// Genkit models generally depend on an API key. APIs should be stored in Cloud Secret Manager so that
|
|
13
|
+
// access to these sensitive values can be controlled. defineSecret does this for you automatically.
|
|
14
|
+
// If you are using Google generative AI you can get an API key at https://aistudio.google.com/app/apikey
|
|
15
|
+
import { defineSecret } from "firebase-functions/params";
|
|
16
|
+
const apiKey = defineSecret("GOOGLE_GENAI_API_KEY");
|
|
17
|
+
|
|
18
|
+
// The Firebase telemetry plugin exports a combination of metrics, traces, and logs to Google Cloud
|
|
19
|
+
// Observability. See https://firebase.google.com/docs/genkit/observability/telemetry-collection.
|
|
20
|
+
$TELEMETRY_COMMENTimport {enableFirebaseTelemetry} from "@genkit-ai/firebase";
|
|
21
|
+
$TELEMETRY_COMMENTenableFirebaseTelemetry();
|
|
22
|
+
|
|
23
|
+
const ai = genkit({
|
|
24
|
+
plugins: [
|
|
25
|
+
$GENKIT_CONFIG_PLUGINS
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Define a simple flow that prompts an LLM to generate menu suggestions.
|
|
30
|
+
const menuSuggestionFlow = ai.defineFlow({
|
|
31
|
+
name: "menuSuggestionFlow",
|
|
32
|
+
inputSchema: z.string().describe("A restaurant theme").default("seafood"),
|
|
33
|
+
outputSchema: z.string(),
|
|
34
|
+
streamSchema: z.string(),
|
|
35
|
+
}, async (subject, { sendChunk }) => {
|
|
36
|
+
// Construct a request and send it to the model API.
|
|
37
|
+
const prompt =
|
|
38
|
+
`Suggest an item for the menu of a ${subject} themed restaurant`;
|
|
39
|
+
const { response, stream } = ai.generateStream({
|
|
40
|
+
model: $GENKIT_MODEL,
|
|
41
|
+
prompt: prompt,
|
|
42
|
+
config: {
|
|
43
|
+
temperature: 1,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
for await (const chunk of stream) {
|
|
48
|
+
sendChunk(chunk.text);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Handle the response from the model API. In this sample, we just
|
|
52
|
+
// convert it to a string, but more complicated flows might coerce the
|
|
53
|
+
// response into structured output or chain the response into another
|
|
54
|
+
// LLM call, etc.
|
|
55
|
+
return (await response).text;
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export const menuSuggestion = onCallGenkit({
|
|
60
|
+
// Uncomment to enable AppCheck. This can reduce costs by ensuring only your Verified
|
|
61
|
+
// app users can use your API. Read more at https://firebase.google.com/docs/app-check/cloud-functions
|
|
62
|
+
// enforceAppCheck: true,
|
|
63
|
+
|
|
64
|
+
// authPolicy can be any callback that accepts an AuthData (a uid and tokens dictionary) and the
|
|
65
|
+
// request data. The isSignedIn() and hasClaim() helpers can be used to simplify. The following
|
|
66
|
+
// will require the user to have the email_verified claim, for example.
|
|
67
|
+
// authPolicy: hasClaim("email_verified"),
|
|
68
|
+
|
|
69
|
+
// Grant access to the API key to this function:
|
|
70
|
+
secrets: [apiKey],
|
|
71
|
+
}, menuSuggestionFlow);
|
|
@@ -8,7 +8,10 @@ connectorId: __connectorId__
|
|
|
8
8
|
# packageJsonDir: < Optional. Path to your Javascript app's package.json>
|
|
9
9
|
# swiftSdk:
|
|
10
10
|
# outputDir: <Path where you want the generated SDK to be written to, relative to this file>
|
|
11
|
-
# package:
|
|
11
|
+
# package: DefaultConnector
|
|
12
12
|
# kotlinSdk:
|
|
13
13
|
# outputDir: <Path where you want the generated SDK to be written to, relative to this file>
|
|
14
14
|
# package: connectors.default
|
|
15
|
+
# dartSdk:
|
|
16
|
+
# outputDir: <Path where you want the generated SDK to be written to, relative to this file>
|
|
17
|
+
# package: default_connector
|
|
@@ -1,36 +1,20 @@
|
|
|
1
1
|
# # Example mutations for a simple movie app
|
|
2
2
|
|
|
3
3
|
# # Create a movie based on user input
|
|
4
|
-
# mutation CreateMovie(
|
|
5
|
-
#
|
|
6
|
-
# $genre:
|
|
7
|
-
# $imageUrl: String!
|
|
8
|
-
# ) @auth(level: USER_EMAIL_VERIFIED) {
|
|
9
|
-
# movie_insert(
|
|
10
|
-
# data: {
|
|
11
|
-
# title: $title
|
|
12
|
-
# genre: $genre
|
|
13
|
-
# imageUrl: $imageUrl
|
|
14
|
-
# }
|
|
15
|
-
# )
|
|
4
|
+
# mutation CreateMovie($title: String!, $genre: String!, $imageUrl: String!)
|
|
5
|
+
# @auth(level: USER_EMAIL_VERIFIED) {
|
|
6
|
+
# movie_insert(data: { title: $title, genre: $genre, imageUrl: $imageUrl })
|
|
16
7
|
# }
|
|
17
8
|
|
|
18
9
|
# # Upsert (update or insert) a user's username based on their auth.uid
|
|
19
10
|
# mutation UpsertUser($username: String!) @auth(level: USER) {
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
# id_expr: "auth.uid"
|
|
23
|
-
# username: $username
|
|
24
|
-
# }
|
|
25
|
-
# )
|
|
11
|
+
# # The "auth.uid" server value ensures that users can only register their own user.
|
|
12
|
+
# user_upsert(data: { id_expr: "auth.uid", username: $username })
|
|
26
13
|
# }
|
|
27
14
|
|
|
28
15
|
# # Add a review for a movie
|
|
29
|
-
# mutation AddReview(
|
|
30
|
-
#
|
|
31
|
-
# $rating: Int!
|
|
32
|
-
# $reviewText: String!
|
|
33
|
-
# ) @auth(level: USER) {
|
|
16
|
+
# mutation AddReview($movieId: UUID!, $rating: Int!, $reviewText: String!)
|
|
17
|
+
# @auth(level: USER) {
|
|
34
18
|
# review_upsert(
|
|
35
19
|
# data: {
|
|
36
20
|
# userId_expr: "auth.uid"
|
|
@@ -43,8 +27,7 @@
|
|
|
43
27
|
# }
|
|
44
28
|
|
|
45
29
|
# # Logged in user can delete their review for a movie
|
|
46
|
-
# mutation DeleteReview(
|
|
47
|
-
#
|
|
48
|
-
# ) @auth(level: USER) {
|
|
30
|
+
# mutation DeleteReview($movieId: UUID!) @auth(level: USER) {
|
|
31
|
+
# # The "auth.uid" server value ensures that users can only delete their own reviews.
|
|
49
32
|
# review_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
|
|
50
33
|
# }
|
|
@@ -13,19 +13,21 @@
|
|
|
13
13
|
|
|
14
14
|
# # List all users, only admins should be able to list all users, so we use NO_ACCESS
|
|
15
15
|
# query ListUsers @auth(level: NO_ACCESS) {
|
|
16
|
-
# users {
|
|
16
|
+
# users {
|
|
17
|
+
# id
|
|
18
|
+
# username
|
|
19
|
+
# }
|
|
17
20
|
# }
|
|
18
21
|
|
|
19
|
-
# # Logged in
|
|
20
|
-
# # Since the query
|
|
22
|
+
# # Logged in users can list all their reviews and movie titles associated with the review
|
|
23
|
+
# # Since the query uses the uid of the current authenticated user, we set auth level to USER
|
|
21
24
|
# query ListUserReviews @auth(level: USER) {
|
|
22
|
-
# user(key: {id_expr: "auth.uid"}) {
|
|
25
|
+
# user(key: { id_expr: "auth.uid" }) {
|
|
23
26
|
# id
|
|
24
27
|
# username
|
|
25
28
|
# # <field>_on_<foreign_key_field> makes it easy to grab info from another table
|
|
26
29
|
# # Here, we use it to grab all the reviews written by the user.
|
|
27
30
|
# reviews: reviews_on_user {
|
|
28
|
-
# id
|
|
29
31
|
# rating
|
|
30
32
|
# reviewDate
|
|
31
33
|
# reviewText
|
|
@@ -50,7 +52,6 @@
|
|
|
50
52
|
# description
|
|
51
53
|
# }
|
|
52
54
|
# reviews: reviews_on_movie {
|
|
53
|
-
# id
|
|
54
55
|
# reviewText
|
|
55
56
|
# reviewDate
|
|
56
57
|
# rating
|
|
@@ -63,16 +64,10 @@
|
|
|
63
64
|
# }
|
|
64
65
|
|
|
65
66
|
# # Search for movies, actors, and reviews
|
|
66
|
-
# query SearchMovie(
|
|
67
|
-
# $titleInput: String
|
|
68
|
-
# $genre: String
|
|
69
|
-
# ) @auth(level: PUBLIC) {
|
|
67
|
+
# query SearchMovie($titleInput: String, $genre: String) @auth(level: PUBLIC) {
|
|
70
68
|
# movies(
|
|
71
69
|
# where: {
|
|
72
|
-
# _and: [
|
|
73
|
-
# { genre: { eq: $genre } }
|
|
74
|
-
# { title: { contains: $titleInput } }
|
|
75
|
-
# ]
|
|
70
|
+
# _and: [{ genre: { eq: $genre } }, { title: { contains: $titleInput } }]
|
|
76
71
|
# }
|
|
77
72
|
# ) {
|
|
78
73
|
# id
|
|
@@ -1,44 +1,51 @@
|
|
|
1
1
|
# # Example schema for simple movie review app
|
|
2
2
|
|
|
3
|
-
# #
|
|
4
|
-
# # Suppose a user can leave reviews for movies
|
|
5
|
-
# # user -> reviews is a one to many relationship,
|
|
6
|
-
# # movie -> reviews is a one to many relationship
|
|
7
|
-
# # movie <-> user is a many to many relationship
|
|
3
|
+
# # User table is keyed by Firebase Auth UID.
|
|
8
4
|
# type User @table {
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
# #
|
|
13
|
-
# #
|
|
5
|
+
# # `@default(expr: "auth.uid")` sets it to Firebase Auth UID during insert and upsert.
|
|
6
|
+
# id: String! @default(expr: "auth.uid")
|
|
7
|
+
# username: String! @col(dataType: "varchar(50)")
|
|
8
|
+
# # The `user: User!` field in the Review table generates the following one-to-many query field.
|
|
9
|
+
# # reviews_on_user: [Review!]!
|
|
10
|
+
# # The `Review` join table the following many-to-many query field.
|
|
11
|
+
# # movies_via_Review: [Movie!]!
|
|
14
12
|
# }
|
|
15
13
|
|
|
16
|
-
# #
|
|
14
|
+
# # Movie is keyed by a randomly generated UUID.
|
|
17
15
|
# type Movie @table {
|
|
18
|
-
# #
|
|
19
|
-
# #
|
|
20
|
-
# id: UUID! @default(expr: "uuidV4()")
|
|
16
|
+
# # If you do not pass a 'key' to `@table`, Data Connect automatically adds the following 'id' column.
|
|
17
|
+
# # Feel free to uncomment and customize it.
|
|
18
|
+
# # id: UUID! @default(expr: "uuidV4()")
|
|
21
19
|
# title: String!
|
|
22
20
|
# imageUrl: String!
|
|
23
21
|
# genre: String
|
|
24
22
|
# }
|
|
25
23
|
|
|
26
|
-
# # Movie
|
|
27
|
-
# # Movie
|
|
24
|
+
# # MovieMetadata is a metadata attached to a Movie.
|
|
25
|
+
# # Movie <-> MovieMetadata is a one-to-one relationship
|
|
28
26
|
# type MovieMetadata @table {
|
|
29
|
-
# # @unique
|
|
30
|
-
# movie: Movie! @unique
|
|
31
|
-
# #
|
|
27
|
+
# # @unique ensures each Movie can only one MovieMetadata.
|
|
28
|
+
# movie: Movie! @unique
|
|
29
|
+
# # The movie field adds the following foreign key field. Feel free to uncomment and customize it.
|
|
30
|
+
# # movieId: UUID!
|
|
32
31
|
# rating: Float
|
|
33
32
|
# releaseYear: Int
|
|
34
33
|
# description: String
|
|
35
34
|
# }
|
|
36
35
|
|
|
37
|
-
# # Reviews
|
|
36
|
+
# # Reviews is a join table between User and Movie.
|
|
37
|
+
# # It has a composite primary keys `userUid` and `movieId`.
|
|
38
|
+
# # A user can leave reviews for many movies. A movie can have reviews from many users.
|
|
39
|
+
# # User <-> Review is a one-to-many relationship
|
|
40
|
+
# # Movie <-> Review is a one-to-many relationship
|
|
41
|
+
# # Movie <-> User is a many-to-many relationship
|
|
38
42
|
# type Review @table(name: "Reviews", key: ["movie", "user"]) {
|
|
39
|
-
# id: UUID! @default(expr: "uuidV4()")
|
|
40
43
|
# user: User!
|
|
44
|
+
# # The user field adds the following foreign key field. Feel free to uncomment and customize it.
|
|
45
|
+
# # userUid: String!
|
|
41
46
|
# movie: Movie!
|
|
47
|
+
# # The movie field adds the following foreign key field. Feel free to uncomment and customize it.
|
|
48
|
+
# # movieId: UUID!
|
|
42
49
|
# rating: Int
|
|
43
50
|
# reviewText: String
|
|
44
51
|
# reviewDate: Date! @default(expr: "request.time")
|
|
@@ -7,9 +7,22 @@
|
|
|
7
7
|
* See a full list of supported triggers at https://firebase.google.com/docs/functions
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
const {
|
|
10
|
+
const {setGlobalOptions} = require("firebase-functions");
|
|
11
|
+
const {onRequest} = require("firebase-functions/https");
|
|
11
12
|
const logger = require("firebase-functions/logger");
|
|
12
13
|
|
|
14
|
+
// For cost control, you can set the maximum number of containers that can be
|
|
15
|
+
// running at the same time. This helps mitigate the impact of unexpected
|
|
16
|
+
// traffic spikes by instead downgrading performance. This limit is a
|
|
17
|
+
// per-function limit. You can override the limit for each function using the
|
|
18
|
+
// `maxInstances` option in the function's options, e.g.
|
|
19
|
+
// `onRequest({ maxInstances: 5 }, (req, res) => { ... })`.
|
|
20
|
+
// NOTE: setGlobalOptions does not apply to functions using the v1 API. V1
|
|
21
|
+
// functions should each use functions.runWith({ maxInstances: 10 }) instead.
|
|
22
|
+
// In the v1 API, each function can only serve one request per container, so
|
|
23
|
+
// this will be the maximum concurrent request count.
|
|
24
|
+
setGlobalOptions({ maxInstances: 10 });
|
|
25
|
+
|
|
13
26
|
// Create and deploy your first functions
|
|
14
27
|
// https://firebase.google.com/docs/functions/get-started
|
|
15
28
|
|
|
@@ -3,8 +3,16 @@
|
|
|
3
3
|
# Deploy with `firebase deploy`
|
|
4
4
|
|
|
5
5
|
from firebase_functions import https_fn
|
|
6
|
+
from firebase_functions.options import set_global_options
|
|
6
7
|
from firebase_admin import initialize_app
|
|
7
8
|
|
|
9
|
+
# For cost control, you can set the maximum number of containers that can be
|
|
10
|
+
# running at the same time. This helps mitigate the impact of unexpected
|
|
11
|
+
# traffic spikes by instead downgrading performance. This limit is a per-function
|
|
12
|
+
# limit. You can override the limit for each function using the max_instances
|
|
13
|
+
# parameter in the decorator, e.g. @https_fn.on_request(max_instances=5).
|
|
14
|
+
set_global_options(max_instances=10)
|
|
15
|
+
|
|
8
16
|
# initialize_app()
|
|
9
17
|
#
|
|
10
18
|
#
|
|
@@ -7,12 +7,25 @@
|
|
|
7
7
|
* See a full list of supported triggers at https://firebase.google.com/docs/functions
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {setGlobalOptions} from "firebase-functions";
|
|
11
|
+
import {onRequest} from "firebase-functions/https";
|
|
11
12
|
import * as logger from "firebase-functions/logger";
|
|
12
13
|
|
|
13
14
|
// Start writing functions
|
|
14
15
|
// https://firebase.google.com/docs/functions/typescript
|
|
15
16
|
|
|
17
|
+
// For cost control, you can set the maximum number of containers that can be
|
|
18
|
+
// running at the same time. This helps mitigate the impact of unexpected
|
|
19
|
+
// traffic spikes by instead downgrading performance. This limit is a
|
|
20
|
+
// per-function limit. You can override the limit for each function using the
|
|
21
|
+
// `maxInstances` option in the function's options, e.g.
|
|
22
|
+
// `onRequest({ maxInstances: 5 }, (req, res) => { ... })`.
|
|
23
|
+
// NOTE: setGlobalOptions does not apply to functions using the v1 API. V1
|
|
24
|
+
// functions should each use functions.runWith({ maxInstances: 10 }) instead.
|
|
25
|
+
// In the v1 API, each function can only serve one request per container, so
|
|
26
|
+
// this will be the maximum concurrent request count.
|
|
27
|
+
setGlobalOptions({ maxInstances: 10 });
|
|
28
|
+
|
|
16
29
|
// export const helloWorld = onRequest((request, response) => {
|
|
17
30
|
// logger.info("Hello logs!", {structuredData: true});
|
|
18
31
|
// response.send("Hello from Firebase!");
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"logs": "firebase functions:log"
|
|
12
12
|
},
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": "
|
|
14
|
+
"node": "{{RUNTIME}}"
|
|
15
15
|
},
|
|
16
16
|
"main": "lib/index.js",
|
|
17
17
|
"dependencies": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"eslint-config-google": "^0.14.0",
|
|
26
26
|
"eslint-plugin-import": "^2.25.4",
|
|
27
27
|
"firebase-functions-test": "^3.1.0",
|
|
28
|
-
"typescript": "^
|
|
28
|
+
"typescript": "^5.7.3"
|
|
29
29
|
},
|
|
30
30
|
"private": true
|
|
31
31
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"logs": "firebase functions:log"
|
|
11
11
|
},
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": "
|
|
13
|
+
"node": "{{RUNTIME}}"
|
|
14
14
|
},
|
|
15
15
|
"main": "lib/index.js",
|
|
16
16
|
"dependencies": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"firebase-functions": "^6.0.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"typescript": "^
|
|
21
|
+
"typescript": "^5.7.3",
|
|
22
22
|
"firebase-functions-test": "^3.1.0"
|
|
23
23
|
},
|
|
24
24
|
"private": true
|
|
25
|
-
}
|
|
25
|
+
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = void 0;
|
|
4
|
-
const command_1 = require("../command");
|
|
5
|
-
const projectUtils_1 = require("../projectUtils");
|
|
6
|
-
const requireAuth_1 = require("../requireAuth");
|
|
7
|
-
const secretManager = require("../gcp/secretManager");
|
|
8
|
-
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
-
const config_1 = require("../apphosting/config");
|
|
10
|
-
const error_1 = require("../error");
|
|
11
|
-
const detectProjectRoot_1 = require("../detectProjectRoot");
|
|
12
|
-
exports.command = new command_1.Command("apphosting:config:export")
|
|
13
|
-
.description("Export App Hosting configurations such as secrets into an apphosting.local.yaml file")
|
|
14
|
-
.option("-s, --secrets <apphosting.yaml or apphosting.<environment>.yaml file to export secrets from>", "This command combines the base apphosting.yaml with the specified environment-specific file (e.g., apphosting.staging.yaml). If keys conflict, the environment-specific file takes precedence.")
|
|
15
|
-
.before(requireAuth_1.requireAuth)
|
|
16
|
-
.before(secretManager.ensureApi)
|
|
17
|
-
.before(requirePermissions_1.requirePermissions, ["secretmanager.versions.access"])
|
|
18
|
-
.action(async (options) => {
|
|
19
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
20
|
-
const environmentConfigFile = options.secrets;
|
|
21
|
-
const cwd = process.cwd();
|
|
22
|
-
const backendRoot = (0, config_1.discoverBackendRoot)(cwd);
|
|
23
|
-
if (!backendRoot) {
|
|
24
|
-
throw new error_1.FirebaseError("Missing apphosting.yaml: This command requires an apphosting.yaml configuration file. Please run 'firebase init apphosting' and try again.");
|
|
25
|
-
}
|
|
26
|
-
const projectRoot = (0, detectProjectRoot_1.detectProjectRoot)({}) ?? backendRoot;
|
|
27
|
-
await (0, config_1.exportConfig)(cwd, projectRoot, backendRoot, projectId, environmentConfigFile);
|
|
28
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = void 0;
|
|
4
|
-
const functionsShellCommandAction_1 = require("../functionsShellCommandAction");
|
|
5
|
-
const command_1 = require("../command");
|
|
6
|
-
const requireConfig_1 = require("../requireConfig");
|
|
7
|
-
const requirePermissions_1 = require("../requirePermissions");
|
|
8
|
-
exports.command = new command_1.Command("experimental:functions:shell")
|
|
9
|
-
.description("launch full Node shell with emulated functions. (Alias for `firebase functions:shell.)")
|
|
10
|
-
.option("-p, --port <port>", "the port on which to emulate functions (default: 5000)", 5000)
|
|
11
|
-
.before(requireConfig_1.requireConfig)
|
|
12
|
-
.before(requirePermissions_1.requirePermissions)
|
|
13
|
-
.action(functionsShellCommandAction_1.actionFunction);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseAuthFlow = void 0;
|
|
4
|
-
class BaseAuthFlow {
|
|
5
|
-
constructor(params) {
|
|
6
|
-
this.reader = params.reader;
|
|
7
|
-
this.writer = params.writer;
|
|
8
|
-
this.connectionState = params.connectionState;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.BaseAuthFlow = BaseAuthFlow;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CertAuthFlow = void 0;
|
|
4
|
-
const backend_error_1 = require("../backend-error");
|
|
5
|
-
const base_auth_flow_1 = require("./base-auth-flow");
|
|
6
|
-
const connection_1 = require("../connection");
|
|
7
|
-
class CertAuthFlow extends base_auth_flow_1.BaseAuthFlow {
|
|
8
|
-
constructor(params) {
|
|
9
|
-
super(params);
|
|
10
|
-
this.completed = false;
|
|
11
|
-
this.auth = {
|
|
12
|
-
...params.auth,
|
|
13
|
-
validateCredentials: params.auth.validateCredentials ??
|
|
14
|
-
(async ({ username, certificate }) => {
|
|
15
|
-
return certificate.subject.CN === username;
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
this.username = params.username;
|
|
19
|
-
}
|
|
20
|
-
async *handleClientMessage(message) {
|
|
21
|
-
if (false) {
|
|
22
|
-
yield (0, backend_error_1.createBackendErrorMessage)({
|
|
23
|
-
severity: 'FATAL',
|
|
24
|
-
code: '08000',
|
|
25
|
-
message: `ssl connection required when auth mode is 'certificate'`,
|
|
26
|
-
});
|
|
27
|
-
yield connection_1.closeSignal;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (false) {
|
|
31
|
-
yield (0, backend_error_1.createBackendErrorMessage)({
|
|
32
|
-
severity: 'FATAL',
|
|
33
|
-
code: '08000',
|
|
34
|
-
message: 'client certificate is invalid',
|
|
35
|
-
});
|
|
36
|
-
yield connection_1.closeSignal;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const isValid = false;
|
|
40
|
-
if (!isValid) {
|
|
41
|
-
yield (0, backend_error_1.createBackendErrorMessage)({
|
|
42
|
-
severity: 'FATAL',
|
|
43
|
-
code: '08000',
|
|
44
|
-
message: 'client certificate is invalid',
|
|
45
|
-
});
|
|
46
|
-
yield connection_1.closeSignal;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
this.completed = true;
|
|
50
|
-
}
|
|
51
|
-
createInitialAuthMessage() {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
get isCompleted() {
|
|
55
|
-
return this.completed;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.CertAuthFlow = CertAuthFlow;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAuthFlow = void 0;
|
|
4
|
-
const cert_1 = require("./cert");
|
|
5
|
-
const md5_1 = require("./md5");
|
|
6
|
-
const password_1 = require("./password");
|
|
7
|
-
const scram_sha_256_1 = require("./sasl/scram-sha-256");
|
|
8
|
-
function createAuthFlow(options) {
|
|
9
|
-
switch (options.auth.method) {
|
|
10
|
-
case 'password':
|
|
11
|
-
return new password_1.PasswordAuthFlow({ ...options, auth: options.auth });
|
|
12
|
-
case 'md5':
|
|
13
|
-
return new md5_1.Md5AuthFlow({ ...options, auth: options.auth });
|
|
14
|
-
case 'scram-sha-256':
|
|
15
|
-
return new scram_sha_256_1.ScramSha256AuthFlow({ ...options, auth: options.auth });
|
|
16
|
-
case 'cert':
|
|
17
|
-
return new cert_1.CertAuthFlow({ ...options, auth: options.auth });
|
|
18
|
-
default:
|
|
19
|
-
throw new Error(`Unsupported auth method: ${options.auth.method}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.createAuthFlow = createAuthFlow;
|