firebase-tools-with-isolate 13.29.1 → 14.10.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/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
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateBinaryLike = exports.encodeHex = exports.concat = exports.createPreHashedPassword = exports.generateMd5Salt = exports.md5 = exports.hashPreHashedPassword = exports.Md5AuthFlow = void 0;
|
|
4
|
-
const backend_error_1 = require("../backend-error");
|
|
5
|
-
const connection_1 = require("../connection");
|
|
6
|
-
const message_codes_1 = require("../message-codes");
|
|
7
|
-
const base_auth_flow_1 = require("./base-auth-flow");
|
|
8
|
-
class Md5AuthFlow extends base_auth_flow_1.BaseAuthFlow {
|
|
9
|
-
constructor(params) {
|
|
10
|
-
super(params);
|
|
11
|
-
this.completed = false;
|
|
12
|
-
this.auth = {
|
|
13
|
-
...params.auth,
|
|
14
|
-
validateCredentials: params.auth.validateCredentials ??
|
|
15
|
-
(async ({ preHashedPassword, hashedPassword, salt }) => {
|
|
16
|
-
const expectedHashedPassword = await hashPreHashedPassword(preHashedPassword, salt);
|
|
17
|
-
return hashedPassword === expectedHashedPassword;
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
20
|
-
this.username = params.username;
|
|
21
|
-
this.salt = generateMd5Salt();
|
|
22
|
-
}
|
|
23
|
-
async *handleClientMessage(message) {
|
|
24
|
-
const length = this.reader.int32();
|
|
25
|
-
const hashedPassword = this.reader.cstring();
|
|
26
|
-
const preHashedPassword = await this.auth.getPreHashedPassword({
|
|
27
|
-
username: this.username,
|
|
28
|
-
}, this.connectionState);
|
|
29
|
-
const isValid = await this.auth.validateCredentials({
|
|
30
|
-
username: this.username,
|
|
31
|
-
hashedPassword,
|
|
32
|
-
preHashedPassword,
|
|
33
|
-
salt: this.salt,
|
|
34
|
-
}, this.connectionState);
|
|
35
|
-
if (!isValid) {
|
|
36
|
-
yield (0, backend_error_1.createBackendErrorMessage)({
|
|
37
|
-
severity: 'FATAL',
|
|
38
|
-
code: '28P01',
|
|
39
|
-
message: `password authentication failed for user "${this.username}"`,
|
|
40
|
-
});
|
|
41
|
-
yield connection_1.closeSignal;
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.completed = true;
|
|
45
|
-
}
|
|
46
|
-
createInitialAuthMessage() {
|
|
47
|
-
return this.createAuthenticationMD5Password();
|
|
48
|
-
}
|
|
49
|
-
get isCompleted() {
|
|
50
|
-
return this.completed;
|
|
51
|
-
}
|
|
52
|
-
createAuthenticationMD5Password() {
|
|
53
|
-
this.writer.addInt32(5);
|
|
54
|
-
this.writer.add(Buffer.from(this.salt));
|
|
55
|
-
return this.writer.flush(message_codes_1.BackendMessageCode.AuthenticationResponse);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.Md5AuthFlow = Md5AuthFlow;
|
|
59
|
-
async function hashPreHashedPassword(preHashedPassword, salt) {
|
|
60
|
-
const hash = await md5(concat([
|
|
61
|
-
new TextEncoder().encode(preHashedPassword),
|
|
62
|
-
salt instanceof ArrayBuffer
|
|
63
|
-
? new Uint8Array(salt)
|
|
64
|
-
: new Uint8Array(salt.buffer, salt.byteOffset, salt.byteLength),
|
|
65
|
-
]));
|
|
66
|
-
return `md5${hash}`;
|
|
67
|
-
}
|
|
68
|
-
exports.hashPreHashedPassword = hashPreHashedPassword;
|
|
69
|
-
async function md5(value) {
|
|
70
|
-
const hash = await crypto.subtle.digest('MD5', typeof value === 'string' ? new TextEncoder().encode(value) : value);
|
|
71
|
-
return encodeHex(hash);
|
|
72
|
-
}
|
|
73
|
-
exports.md5 = md5;
|
|
74
|
-
function generateMd5Salt() {
|
|
75
|
-
const salt = new Uint8Array(4);
|
|
76
|
-
crypto.getRandomValues(salt);
|
|
77
|
-
return salt;
|
|
78
|
-
}
|
|
79
|
-
exports.generateMd5Salt = generateMd5Salt;
|
|
80
|
-
async function createPreHashedPassword(username, password) {
|
|
81
|
-
return await md5(`${password}${username}`);
|
|
82
|
-
}
|
|
83
|
-
exports.createPreHashedPassword = createPreHashedPassword;
|
|
84
|
-
function concat(buffers) {
|
|
85
|
-
let length = 0;
|
|
86
|
-
for (const buffer of buffers) {
|
|
87
|
-
length += buffer.length;
|
|
88
|
-
}
|
|
89
|
-
const output = new Uint8Array(length);
|
|
90
|
-
let index = 0;
|
|
91
|
-
for (const buffer of buffers) {
|
|
92
|
-
output.set(buffer, index);
|
|
93
|
-
index += buffer.length;
|
|
94
|
-
}
|
|
95
|
-
return output;
|
|
96
|
-
}
|
|
97
|
-
exports.concat = concat;
|
|
98
|
-
const hexTable = new TextEncoder().encode("0123456789abcdef");
|
|
99
|
-
const textEncoder = new TextEncoder();
|
|
100
|
-
const textDecoder = new TextDecoder();
|
|
101
|
-
function encodeHex(src) {
|
|
102
|
-
const u8 = validateBinaryLike(src);
|
|
103
|
-
const dst = new Uint8Array(u8.length * 2);
|
|
104
|
-
for (let i = 0; i < u8.length; i++) {
|
|
105
|
-
const v = u8[i];
|
|
106
|
-
dst[i * 2] = hexTable[v >> 4];
|
|
107
|
-
dst[i * 2 + 1] = hexTable[v & 0x0f];
|
|
108
|
-
}
|
|
109
|
-
return textDecoder.decode(dst);
|
|
110
|
-
}
|
|
111
|
-
exports.encodeHex = encodeHex;
|
|
112
|
-
function validateBinaryLike(source) {
|
|
113
|
-
if (typeof source === "string") {
|
|
114
|
-
return textEncoder.encode(source);
|
|
115
|
-
}
|
|
116
|
-
else if (source instanceof Uint8Array) {
|
|
117
|
-
return source;
|
|
118
|
-
}
|
|
119
|
-
else if (source instanceof ArrayBuffer) {
|
|
120
|
-
return new Uint8Array(source);
|
|
121
|
-
}
|
|
122
|
-
throw new TypeError(`Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer`);
|
|
123
|
-
}
|
|
124
|
-
exports.validateBinaryLike = validateBinaryLike;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PasswordAuthFlow = void 0;
|
|
4
|
-
const backend_error_1 = require("../backend-error");
|
|
5
|
-
const connection_1 = require("../connection");
|
|
6
|
-
const message_codes_1 = require("../message-codes");
|
|
7
|
-
const base_auth_flow_1 = require("./base-auth-flow");
|
|
8
|
-
class PasswordAuthFlow extends base_auth_flow_1.BaseAuthFlow {
|
|
9
|
-
constructor(params) {
|
|
10
|
-
super(params);
|
|
11
|
-
this.completed = false;
|
|
12
|
-
this.auth = {
|
|
13
|
-
...params.auth,
|
|
14
|
-
validateCredentials: params.auth.validateCredentials ??
|
|
15
|
-
(async ({ password, clearTextPassword }) => {
|
|
16
|
-
return password === clearTextPassword;
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
19
|
-
this.username = params.username;
|
|
20
|
-
}
|
|
21
|
-
async *handleClientMessage(message) {
|
|
22
|
-
const length = this.reader.int32();
|
|
23
|
-
const password = this.reader.cstring();
|
|
24
|
-
const clearTextPassword = await this.auth.getClearTextPassword({
|
|
25
|
-
username: this.username,
|
|
26
|
-
}, this.connectionState);
|
|
27
|
-
const isValid = await this.auth.validateCredentials({
|
|
28
|
-
username: this.username,
|
|
29
|
-
password,
|
|
30
|
-
clearTextPassword,
|
|
31
|
-
}, this.connectionState);
|
|
32
|
-
if (!isValid) {
|
|
33
|
-
yield (0, backend_error_1.createBackendErrorMessage)({
|
|
34
|
-
severity: 'FATAL',
|
|
35
|
-
code: '28P01',
|
|
36
|
-
message: `password authentication failed for user "${this.username}"`,
|
|
37
|
-
});
|
|
38
|
-
yield connection_1.closeSignal;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
this.completed = true;
|
|
42
|
-
}
|
|
43
|
-
createInitialAuthMessage() {
|
|
44
|
-
return this.createAuthenticationCleartextPassword();
|
|
45
|
-
}
|
|
46
|
-
get isCompleted() {
|
|
47
|
-
return this.completed;
|
|
48
|
-
}
|
|
49
|
-
createAuthenticationCleartextPassword() {
|
|
50
|
-
this.writer.addInt32(3);
|
|
51
|
-
return this.writer.flush(message_codes_1.BackendMessageCode.AuthenticationResponse);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.PasswordAuthFlow = PasswordAuthFlow;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SaslMechanism = void 0;
|
|
4
|
-
const message_codes_1 = require("../../message-codes");
|
|
5
|
-
const SaslMessageCode = {
|
|
6
|
-
AuthenticationSASL: 10,
|
|
7
|
-
AuthenticationSASLContinue: 11,
|
|
8
|
-
AuthenticationSASLFinal: 12,
|
|
9
|
-
};
|
|
10
|
-
class SaslMechanism {
|
|
11
|
-
constructor(params) {
|
|
12
|
-
this.writer = params.writer;
|
|
13
|
-
}
|
|
14
|
-
createAuthenticationSASL() {
|
|
15
|
-
const mechanisms = ['SCRAM-SHA-256'];
|
|
16
|
-
this.writer.addInt32(SaslMessageCode.AuthenticationSASL);
|
|
17
|
-
for (const mechanism of mechanisms) {
|
|
18
|
-
this.writer.addCString(mechanism);
|
|
19
|
-
}
|
|
20
|
-
this.writer.addCString('');
|
|
21
|
-
return this.writer.flush(message_codes_1.BackendMessageCode.AuthenticationResponse);
|
|
22
|
-
}
|
|
23
|
-
createAuthenticationSASLContinue(message) {
|
|
24
|
-
this.writer.addInt32(SaslMessageCode.AuthenticationSASLContinue);
|
|
25
|
-
this.writer.addString(message);
|
|
26
|
-
return this.writer.flush(message_codes_1.BackendMessageCode.AuthenticationResponse);
|
|
27
|
-
}
|
|
28
|
-
createAuthenticationSASLFinal(message) {
|
|
29
|
-
this.writer.addInt32(SaslMessageCode.AuthenticationSASLFinal);
|
|
30
|
-
this.writer.addString(message);
|
|
31
|
-
return this.writer.flush(message_codes_1.BackendMessageCode.AuthenticationResponse);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.SaslMechanism = SaslMechanism;
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeBase64 = exports.encodeBase64 = exports.ScramSha256AuthFlow = exports.verifyScramSha256Password = exports.createScramSha256Data = void 0;
|
|
4
|
-
const backend_error_1 = require("../../backend-error");
|
|
5
|
-
const connection_1 = require("../../connection");
|
|
6
|
-
const crypto_1 = require("../../crypto");
|
|
7
|
-
const sasl_mechanism_1 = require("./sasl-mechanism");
|
|
8
|
-
async function createScramSha256Data(password, iterations = 4096) {
|
|
9
|
-
const salt = new Uint8Array(16);
|
|
10
|
-
crypto.getRandomValues(salt);
|
|
11
|
-
const saltedPassword = await (0, crypto_1.pbkdf2)(password, salt, iterations, 32, 'SHA-256');
|
|
12
|
-
const clientKey = await (0, crypto_1.createHmacKey)(saltedPassword, 'Client Key', 'SHA-256');
|
|
13
|
-
const storedKey = await (0, crypto_1.createHashKey)(clientKey, 'SHA-256');
|
|
14
|
-
const serverKey = await (0, crypto_1.createHmacKey)(saltedPassword, 'Server Key', 'SHA-256');
|
|
15
|
-
return {
|
|
16
|
-
salt: encodeBase64(salt),
|
|
17
|
-
iterations,
|
|
18
|
-
storedKey: encodeBase64(storedKey),
|
|
19
|
-
serverKey: encodeBase64(serverKey),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
exports.createScramSha256Data = createScramSha256Data;
|
|
23
|
-
async function verifyScramSha256Password(params) {
|
|
24
|
-
const { authMessage, clientProof, storedKey } = params;
|
|
25
|
-
const clientProofBuffer = decodeBase64(clientProof);
|
|
26
|
-
const storedKeyBuffer = decodeBase64(storedKey);
|
|
27
|
-
const clientSignature = await (0, crypto_1.createHmacKey)(storedKeyBuffer, authMessage, 'SHA-256');
|
|
28
|
-
const clientSignatureView = new Uint8Array(clientSignature);
|
|
29
|
-
const clientKey = new Uint8Array(clientProofBuffer.length);
|
|
30
|
-
for (let i = 0; i < clientProofBuffer.length; i++) {
|
|
31
|
-
clientKey[i] = clientProofBuffer[i] ^ clientSignatureView[i];
|
|
32
|
-
}
|
|
33
|
-
const computedStoredKey = await (0, crypto_1.createHashKey)(clientKey, 'SHA-256');
|
|
34
|
-
return await (0, crypto_1.timingSafeEqual)(storedKeyBuffer, computedStoredKey);
|
|
35
|
-
}
|
|
36
|
-
exports.verifyScramSha256Password = verifyScramSha256Password;
|
|
37
|
-
const ScramSha256Step = {
|
|
38
|
-
Initial: 'Initial',
|
|
39
|
-
ServerFirstMessage: 'ServerFirstMessage',
|
|
40
|
-
ServerFinalMessage: 'ServerFinalMessage',
|
|
41
|
-
Completed: 'Completed',
|
|
42
|
-
};
|
|
43
|
-
class ScramSha256AuthFlow extends sasl_mechanism_1.SaslMechanism {
|
|
44
|
-
constructor(params) {
|
|
45
|
-
super({ writer: params.writer });
|
|
46
|
-
this.step = ScramSha256Step.Initial;
|
|
47
|
-
this.username = params.username;
|
|
48
|
-
this.auth = {
|
|
49
|
-
...params.auth,
|
|
50
|
-
validateCredentials: params.auth.validateCredentials ??
|
|
51
|
-
(async ({ authMessage, clientProof, scramSha256Data }) => {
|
|
52
|
-
return verifyScramSha256Password({
|
|
53
|
-
authMessage,
|
|
54
|
-
clientProof,
|
|
55
|
-
storedKey: scramSha256Data.storedKey,
|
|
56
|
-
});
|
|
57
|
-
}),
|
|
58
|
-
};
|
|
59
|
-
this.reader = params.reader;
|
|
60
|
-
this.connectionState = params.connectionState;
|
|
61
|
-
}
|
|
62
|
-
async getScramSha256Data(params) {
|
|
63
|
-
if (!this.scramSha256Data) {
|
|
64
|
-
this.scramSha256Data = await this.auth.getScramSha256Data(params, this.connectionState);
|
|
65
|
-
}
|
|
66
|
-
return this.scramSha256Data;
|
|
67
|
-
}
|
|
68
|
-
createInitialAuthMessage() {
|
|
69
|
-
return this.createAuthenticationSASL();
|
|
70
|
-
}
|
|
71
|
-
async *handleClientMessage(message) {
|
|
72
|
-
switch (this.step) {
|
|
73
|
-
case ScramSha256Step.Initial:
|
|
74
|
-
return yield* this.handleClientFirstMessage(message);
|
|
75
|
-
case ScramSha256Step.ServerFirstMessage:
|
|
76
|
-
return yield* this.handleClientFinalMessage(message);
|
|
77
|
-
default:
|
|
78
|
-
throw new Error('Unexpected SCRAM-SHA-256 authentication step');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async *handleClientFirstMessage(message) {
|
|
82
|
-
const length = this.reader.int32();
|
|
83
|
-
const saslMechanism = this.reader.cstring();
|
|
84
|
-
if (saslMechanism !== 'SCRAM-SHA-256') {
|
|
85
|
-
yield (0, backend_error_1.createBackendErrorMessage)({
|
|
86
|
-
severity: 'FATAL',
|
|
87
|
-
code: '28000',
|
|
88
|
-
message: 'Unsupported SASL authentication mechanism',
|
|
89
|
-
});
|
|
90
|
-
yield connection_1.closeSignal;
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const responseLength = this.reader.int32();
|
|
94
|
-
const clientFirstMessage = this.reader.string(responseLength);
|
|
95
|
-
const serverFirstMessage = await this.createServerFirstMessage(clientFirstMessage);
|
|
96
|
-
this.step = ScramSha256Step.ServerFirstMessage;
|
|
97
|
-
yield this.createAuthenticationSASLContinue(serverFirstMessage);
|
|
98
|
-
}
|
|
99
|
-
async createServerFirstMessage(clientFirstMessage) {
|
|
100
|
-
const clientFirstMessageParts = clientFirstMessage.split(',');
|
|
101
|
-
this.clientFirstMessageBare = clientFirstMessageParts.slice(2).join(',');
|
|
102
|
-
const clientNonce = clientFirstMessageParts.find((part) => part.startsWith('r='))?.substring(2) || '';
|
|
103
|
-
const serverNoncePart = new Uint8Array(18);
|
|
104
|
-
crypto.getRandomValues(serverNoncePart);
|
|
105
|
-
this.serverNonce = clientNonce + encodeBase64(serverNoncePart);
|
|
106
|
-
const { salt, iterations } = await this.getScramSha256Data({
|
|
107
|
-
username: this.username,
|
|
108
|
-
});
|
|
109
|
-
this.serverFirstMessage = `r=${this.serverNonce},s=${salt},i=${iterations}`;
|
|
110
|
-
return this.serverFirstMessage;
|
|
111
|
-
}
|
|
112
|
-
async *handleClientFinalMessage(message) {
|
|
113
|
-
try {
|
|
114
|
-
const serverFinalMessage = await this.createServerFinalMessage(message);
|
|
115
|
-
this.step = ScramSha256Step.Completed;
|
|
116
|
-
yield this.createAuthenticationSASLFinal(serverFinalMessage);
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
yield (0, backend_error_1.createBackendErrorMessage)({
|
|
120
|
-
severity: 'FATAL',
|
|
121
|
-
code: '28000',
|
|
122
|
-
message: error.message,
|
|
123
|
-
});
|
|
124
|
-
yield connection_1.closeSignal;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
get isCompleted() {
|
|
129
|
-
return this.step === ScramSha256Step.Completed;
|
|
130
|
-
}
|
|
131
|
-
async createServerFinalMessage(message) {
|
|
132
|
-
const length = this.reader.int32();
|
|
133
|
-
const stringLength = length - 4;
|
|
134
|
-
const clientFinalMessage = this.reader.string(stringLength);
|
|
135
|
-
const clientFinalMessageParts = clientFinalMessage.split(',');
|
|
136
|
-
const channelBinding = clientFinalMessageParts
|
|
137
|
-
.find((part) => part.startsWith('c='))
|
|
138
|
-
?.substring(2);
|
|
139
|
-
const fullNonce = clientFinalMessageParts.find((part) => part.startsWith('r='))?.substring(2);
|
|
140
|
-
const clientProof = clientFinalMessageParts.find((part) => part.startsWith('p='))?.substring(2);
|
|
141
|
-
if (!channelBinding || !fullNonce || !clientProof) {
|
|
142
|
-
throw new Error('Invalid client final message');
|
|
143
|
-
}
|
|
144
|
-
if (fullNonce !== this.serverNonce) {
|
|
145
|
-
throw new Error('Nonce mismatch');
|
|
146
|
-
}
|
|
147
|
-
const clientFinalMessageWithoutProof = `c=${channelBinding},r=${fullNonce}`;
|
|
148
|
-
const authMessage = `${this.clientFirstMessageBare},${this.serverFirstMessage},${clientFinalMessageWithoutProof}`;
|
|
149
|
-
const data = await this.getScramSha256Data({
|
|
150
|
-
username: this.username,
|
|
151
|
-
});
|
|
152
|
-
const isValid = await this.auth.validateCredentials({
|
|
153
|
-
authMessage,
|
|
154
|
-
clientProof,
|
|
155
|
-
username: this.username,
|
|
156
|
-
scramSha256Data: data,
|
|
157
|
-
}, this.connectionState);
|
|
158
|
-
if (!isValid) {
|
|
159
|
-
throw new Error(`password authentication failed for user "${this.username}"`);
|
|
160
|
-
}
|
|
161
|
-
const serverKeyBuffer = decodeBase64(data.serverKey);
|
|
162
|
-
const serverSignature = await (0, crypto_1.createHmacKey)(serverKeyBuffer, authMessage, 'SHA-256');
|
|
163
|
-
return `v=${encodeBase64(serverSignature)}`;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
exports.ScramSha256AuthFlow = ScramSha256AuthFlow;
|
|
167
|
-
function encodeBase64(data) {
|
|
168
|
-
const uint8 = data;
|
|
169
|
-
let result = "";
|
|
170
|
-
let i;
|
|
171
|
-
const l = uint8.length;
|
|
172
|
-
for (i = 2; i < l; i += 3) {
|
|
173
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
174
|
-
result += base64abc[(((uint8[i - 2]) & 0x03) << 4) |
|
|
175
|
-
((uint8[i - 1]) >> 4)];
|
|
176
|
-
result += base64abc[(((uint8[i - 1]) & 0x0f) << 2) |
|
|
177
|
-
((uint8[i]) >> 6)];
|
|
178
|
-
result += base64abc[(uint8[i]) & 0x3f];
|
|
179
|
-
}
|
|
180
|
-
if (i === l + 1) {
|
|
181
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
182
|
-
result += base64abc[((uint8[i - 2]) & 0x03) << 4];
|
|
183
|
-
result += "==";
|
|
184
|
-
}
|
|
185
|
-
if (i === l) {
|
|
186
|
-
result += base64abc[(uint8[i - 2]) >> 2];
|
|
187
|
-
result += base64abc[(((uint8[i - 2]) & 0x03) << 4) |
|
|
188
|
-
((uint8[i - 1]) >> 4)];
|
|
189
|
-
result += base64abc[((uint8[i - 1]) & 0x0f) << 2];
|
|
190
|
-
result += "=";
|
|
191
|
-
}
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
exports.encodeBase64 = encodeBase64;
|
|
195
|
-
function decodeBase64(b64) {
|
|
196
|
-
const binString = atob(b64);
|
|
197
|
-
const size = binString.length;
|
|
198
|
-
const bytes = new Uint8Array(size);
|
|
199
|
-
for (let i = 0; i < size; i++) {
|
|
200
|
-
bytes[i] = binString.charCodeAt(i);
|
|
201
|
-
}
|
|
202
|
-
return bytes;
|
|
203
|
-
}
|
|
204
|
-
exports.decodeBase64 = decodeBase64;
|
|
205
|
-
const base64abc = [
|
|
206
|
-
"A",
|
|
207
|
-
"B",
|
|
208
|
-
"C",
|
|
209
|
-
"D",
|
|
210
|
-
"E",
|
|
211
|
-
"F",
|
|
212
|
-
"G",
|
|
213
|
-
"H",
|
|
214
|
-
"I",
|
|
215
|
-
"J",
|
|
216
|
-
"K",
|
|
217
|
-
"L",
|
|
218
|
-
"M",
|
|
219
|
-
"N",
|
|
220
|
-
"O",
|
|
221
|
-
"P",
|
|
222
|
-
"Q",
|
|
223
|
-
"R",
|
|
224
|
-
"S",
|
|
225
|
-
"T",
|
|
226
|
-
"U",
|
|
227
|
-
"V",
|
|
228
|
-
"W",
|
|
229
|
-
"X",
|
|
230
|
-
"Y",
|
|
231
|
-
"Z",
|
|
232
|
-
"a",
|
|
233
|
-
"b",
|
|
234
|
-
"c",
|
|
235
|
-
"d",
|
|
236
|
-
"e",
|
|
237
|
-
"f",
|
|
238
|
-
"g",
|
|
239
|
-
"h",
|
|
240
|
-
"i",
|
|
241
|
-
"j",
|
|
242
|
-
"k",
|
|
243
|
-
"l",
|
|
244
|
-
"m",
|
|
245
|
-
"n",
|
|
246
|
-
"o",
|
|
247
|
-
"p",
|
|
248
|
-
"q",
|
|
249
|
-
"r",
|
|
250
|
-
"s",
|
|
251
|
-
"t",
|
|
252
|
-
"u",
|
|
253
|
-
"v",
|
|
254
|
-
"w",
|
|
255
|
-
"x",
|
|
256
|
-
"y",
|
|
257
|
-
"z",
|
|
258
|
-
"0",
|
|
259
|
-
"1",
|
|
260
|
-
"2",
|
|
261
|
-
"3",
|
|
262
|
-
"4",
|
|
263
|
-
"5",
|
|
264
|
-
"6",
|
|
265
|
-
"7",
|
|
266
|
-
"8",
|
|
267
|
-
"9",
|
|
268
|
-
"+",
|
|
269
|
-
"/",
|
|
270
|
-
];
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBackendErrorMessage = void 0;
|
|
4
|
-
const buffer_writer_1 = require("./buffer-writer");
|
|
5
|
-
const message_codes_1 = require("./message-codes");
|
|
6
|
-
function createBackendErrorMessage(error) {
|
|
7
|
-
const writer = new buffer_writer_1.BufferWriter();
|
|
8
|
-
writer.addString('S');
|
|
9
|
-
writer.addCString(error.severity);
|
|
10
|
-
writer.addString('V');
|
|
11
|
-
writer.addCString(error.severity);
|
|
12
|
-
writer.addString('C');
|
|
13
|
-
writer.addCString(error.code);
|
|
14
|
-
writer.addString('M');
|
|
15
|
-
writer.addCString(error.message);
|
|
16
|
-
if (error.detail !== undefined) {
|
|
17
|
-
writer.addString('D');
|
|
18
|
-
writer.addCString(error.detail);
|
|
19
|
-
}
|
|
20
|
-
if (error.hint !== undefined) {
|
|
21
|
-
writer.addString('H');
|
|
22
|
-
writer.addCString(error.hint);
|
|
23
|
-
}
|
|
24
|
-
if (error.position !== undefined) {
|
|
25
|
-
writer.addString('P');
|
|
26
|
-
writer.addCString(error.position);
|
|
27
|
-
}
|
|
28
|
-
if (error.internalPosition !== undefined) {
|
|
29
|
-
writer.addString('p');
|
|
30
|
-
writer.addCString(error.internalPosition);
|
|
31
|
-
}
|
|
32
|
-
if (error.internalQuery !== undefined) {
|
|
33
|
-
writer.addString('q');
|
|
34
|
-
writer.addCString(error.internalQuery);
|
|
35
|
-
}
|
|
36
|
-
if (error.where !== undefined) {
|
|
37
|
-
writer.addString('W');
|
|
38
|
-
writer.addCString(error.where);
|
|
39
|
-
}
|
|
40
|
-
if (error.schema !== undefined) {
|
|
41
|
-
writer.addString('s');
|
|
42
|
-
writer.addCString(error.schema);
|
|
43
|
-
}
|
|
44
|
-
if (error.table !== undefined) {
|
|
45
|
-
writer.addString('t');
|
|
46
|
-
writer.addCString(error.table);
|
|
47
|
-
}
|
|
48
|
-
if (error.column !== undefined) {
|
|
49
|
-
writer.addString('c');
|
|
50
|
-
writer.addCString(error.column);
|
|
51
|
-
}
|
|
52
|
-
if (error.dataType !== undefined) {
|
|
53
|
-
writer.addString('d');
|
|
54
|
-
writer.addCString(error.dataType);
|
|
55
|
-
}
|
|
56
|
-
if (error.constraint !== undefined) {
|
|
57
|
-
writer.addString('n');
|
|
58
|
-
writer.addCString(error.constraint);
|
|
59
|
-
}
|
|
60
|
-
if (error.file !== undefined) {
|
|
61
|
-
writer.addString('F');
|
|
62
|
-
writer.addCString(error.file);
|
|
63
|
-
}
|
|
64
|
-
if (error.line !== undefined) {
|
|
65
|
-
writer.addString('L');
|
|
66
|
-
writer.addCString(error.line);
|
|
67
|
-
}
|
|
68
|
-
if (error.routine !== undefined) {
|
|
69
|
-
writer.addString('R');
|
|
70
|
-
writer.addCString(error.routine);
|
|
71
|
-
}
|
|
72
|
-
writer.addCString('');
|
|
73
|
-
return writer.flush(message_codes_1.BackendMessageCode.ErrorMessage);
|
|
74
|
-
}
|
|
75
|
-
exports.createBackendErrorMessage = createBackendErrorMessage;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferReader = void 0;
|
|
4
|
-
class BufferReader {
|
|
5
|
-
constructor(offset = 0) {
|
|
6
|
-
this.offset = offset;
|
|
7
|
-
this.buffer = new Uint8Array();
|
|
8
|
-
this.decoder = new TextDecoder();
|
|
9
|
-
}
|
|
10
|
-
setBuffer(buffer, offset = 0) {
|
|
11
|
-
this.buffer = buffer;
|
|
12
|
-
this.offset = offset;
|
|
13
|
-
}
|
|
14
|
-
int16() {
|
|
15
|
-
const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
16
|
-
const result = dataView.getInt16(this.offset);
|
|
17
|
-
this.offset += 2;
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
byte() {
|
|
21
|
-
const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
22
|
-
const result = dataView.getUint8(this.offset);
|
|
23
|
-
this.offset++;
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
int32() {
|
|
27
|
-
const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
28
|
-
const result = dataView.getInt32(this.offset);
|
|
29
|
-
this.offset += 4;
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
string(length) {
|
|
33
|
-
const dataView = new DataView(this.buffer.buffer, this.offset, length);
|
|
34
|
-
this.offset += length;
|
|
35
|
-
return this.decoder.decode(dataView);
|
|
36
|
-
}
|
|
37
|
-
cstring() {
|
|
38
|
-
const start = this.offset;
|
|
39
|
-
let end = start;
|
|
40
|
-
while ((this.buffer[end++] ?? 0) !== 0) { }
|
|
41
|
-
if (this.buffer[end - 1] === undefined) {
|
|
42
|
-
throw new Error('Reached end of buffer before null character found for PG String');
|
|
43
|
-
}
|
|
44
|
-
const dataView = new DataView(this.buffer.buffer, start, end - start - 1);
|
|
45
|
-
this.offset = end;
|
|
46
|
-
return this.decoder.decode(dataView);
|
|
47
|
-
}
|
|
48
|
-
bytes(length) {
|
|
49
|
-
const result = this.buffer.slice(this.offset, this.offset + length);
|
|
50
|
-
this.offset += length;
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.BufferReader = BufferReader;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferWriter = void 0;
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
class BufferWriter {
|
|
6
|
-
constructor(size = 256) {
|
|
7
|
-
this.size = size;
|
|
8
|
-
this.offset = 5;
|
|
9
|
-
this.headerPosition = 0;
|
|
10
|
-
this.encoder = new TextEncoder();
|
|
11
|
-
this.buffer = new Uint8Array(size);
|
|
12
|
-
}
|
|
13
|
-
ensure(size) {
|
|
14
|
-
const remaining = this.buffer.length - this.offset;
|
|
15
|
-
if (remaining < size) {
|
|
16
|
-
const oldBuffer = this.buffer;
|
|
17
|
-
const newSize = oldBuffer.length + (oldBuffer.length >> 1) + size;
|
|
18
|
-
this.buffer = new Uint8Array(newSize);
|
|
19
|
-
(0, utils_1.copy)(oldBuffer, this.buffer);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
addInt32(num) {
|
|
23
|
-
this.ensure(4);
|
|
24
|
-
this.buffer[this.offset++] = (num >>> 24) & 0xff;
|
|
25
|
-
this.buffer[this.offset++] = (num >>> 16) & 0xff;
|
|
26
|
-
this.buffer[this.offset++] = (num >>> 8) & 0xff;
|
|
27
|
-
this.buffer[this.offset++] = (num >>> 0) & 0xff;
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
addInt16(num) {
|
|
31
|
-
this.ensure(2);
|
|
32
|
-
this.buffer[this.offset++] = (num >>> 8) & 0xff;
|
|
33
|
-
this.buffer[this.offset++] = (num >>> 0) & 0xff;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
addCString(string) {
|
|
37
|
-
if (!string) {
|
|
38
|
-
this.ensure(1);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
const stringBuffer = this.encoder.encode(string);
|
|
42
|
-
this.ensure(stringBuffer.byteLength + 1);
|
|
43
|
-
this.buffer.set(stringBuffer, this.offset);
|
|
44
|
-
this.offset += stringBuffer.byteLength;
|
|
45
|
-
}
|
|
46
|
-
this.buffer[this.offset++] = 0;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
addString(string = '') {
|
|
50
|
-
const stringBuffer = this.encoder.encode(string);
|
|
51
|
-
this.ensure(stringBuffer.byteLength);
|
|
52
|
-
this.buffer.set(stringBuffer, this.offset);
|
|
53
|
-
this.offset += stringBuffer.byteLength;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
add(otherBuffer) {
|
|
57
|
-
this.ensure(otherBuffer.byteLength);
|
|
58
|
-
(0, utils_1.copy)(otherBuffer, this.buffer, this.offset);
|
|
59
|
-
this.offset += otherBuffer.length;
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
join(code) {
|
|
63
|
-
if (code) {
|
|
64
|
-
this.buffer[this.headerPosition] = code;
|
|
65
|
-
const length = this.offset - (this.headerPosition + 1);
|
|
66
|
-
const dataView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
67
|
-
dataView.setInt32(this.headerPosition + 1, length);
|
|
68
|
-
}
|
|
69
|
-
return this.buffer.slice(code ? 0 : 5, this.offset);
|
|
70
|
-
}
|
|
71
|
-
flush(code) {
|
|
72
|
-
const result = this.join(code);
|
|
73
|
-
this.offset = 5;
|
|
74
|
-
this.headerPosition = 0;
|
|
75
|
-
this.buffer = new Uint8Array(this.size);
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.BufferWriter = BufferWriter;
|