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.
Files changed (396) hide show
  1. package/README.md +53 -4
  2. package/lib/api.js +10 -2
  3. package/lib/appdistribution/client.js +2 -2
  4. package/lib/apphosting/backend.js +157 -55
  5. package/lib/apphosting/config.js +121 -101
  6. package/lib/apphosting/githubConnections.js +65 -100
  7. package/lib/apphosting/repo.js +22 -36
  8. package/lib/apphosting/rollout.js +5 -11
  9. package/lib/apphosting/secrets/dialogs.js +13 -11
  10. package/lib/apphosting/secrets/index.js +47 -5
  11. package/lib/apphosting/utils.js +1 -3
  12. package/lib/apphosting/yaml.js +35 -49
  13. package/lib/auth.js +23 -6
  14. package/lib/bin/cli.js +99 -0
  15. package/lib/bin/firebase.js +7 -123
  16. package/lib/bin/mcp.js +49 -0
  17. package/lib/checkValidTargetFilters.js +1 -0
  18. package/lib/command.js +3 -2
  19. package/lib/commands/appdistribution-distribute.js +1 -1
  20. package/lib/commands/appdistribution-groups-create.js +1 -1
  21. package/lib/commands/appdistribution-groups-delete.js +1 -1
  22. package/lib/commands/appdistribution-groups-list.js +2 -2
  23. package/lib/commands/appdistribution-testers-add.js +1 -1
  24. package/lib/commands/appdistribution-testers-list.js +3 -3
  25. package/lib/commands/appdistribution-testers-remove.js +1 -1
  26. package/lib/commands/apphosting-backends-create.js +3 -3
  27. package/lib/commands/apphosting-backends-delete.js +23 -27
  28. package/lib/commands/apphosting-backends-get.js +12 -12
  29. package/lib/commands/apphosting-backends-list.js +5 -5
  30. package/lib/commands/apphosting-builds-create.js +8 -2
  31. package/lib/commands/apphosting-builds-get.js +8 -1
  32. package/lib/commands/apphosting-rollouts-create.js +3 -3
  33. package/lib/commands/apphosting-rollouts-list.js +8 -2
  34. package/lib/commands/apphosting-secrets-access.js +1 -1
  35. package/lib/commands/apphosting-secrets-describe.js +2 -2
  36. package/lib/commands/apphosting-secrets-grantaccess.js +20 -10
  37. package/lib/commands/apphosting-secrets-set.js +27 -1
  38. package/lib/commands/apps-android-sha-create.js +1 -1
  39. package/lib/commands/apps-android-sha-delete.js +1 -1
  40. package/lib/commands/apps-android-sha-list.js +2 -2
  41. package/lib/commands/apps-create.js +4 -108
  42. package/lib/commands/apps-init.js +94 -0
  43. package/lib/commands/apps-list.js +1 -1
  44. package/lib/commands/apps-sdkconfig.js +5 -10
  45. package/lib/commands/auth-export.js +1 -1
  46. package/lib/commands/auth-import.js +1 -1
  47. package/lib/commands/database-import.js +4 -6
  48. package/lib/commands/database-instances-create.js +1 -1
  49. package/lib/commands/database-instances-list.js +1 -1
  50. package/lib/commands/database-profile.js +1 -2
  51. package/lib/commands/database-remove.js +4 -6
  52. package/lib/commands/database-set.js +6 -6
  53. package/lib/commands/database-settings-set.js +1 -1
  54. package/lib/commands/database-update.js +6 -6
  55. package/lib/commands/dataconnect-sdk-generate.js +5 -2
  56. package/lib/commands/dataconnect-services-list.js +2 -2
  57. package/lib/commands/dataconnect-sql-diff.js +2 -2
  58. package/lib/commands/dataconnect-sql-grant.js +3 -3
  59. package/lib/commands/dataconnect-sql-migrate.js +2 -2
  60. package/lib/commands/dataconnect-sql-setup.js +39 -0
  61. package/lib/commands/dataconnect-sql-shell.js +5 -7
  62. package/lib/commands/deploy.js +4 -3
  63. package/lib/commands/emulators-exec.js +1 -1
  64. package/lib/commands/emulators-start.js +4 -3
  65. package/lib/commands/experiments-list.js +1 -1
  66. package/lib/commands/ext-dev-deprecate.js +1 -0
  67. package/lib/commands/ext-dev-init.js +3 -12
  68. package/lib/commands/ext-dev-list.js +1 -1
  69. package/lib/commands/ext-dev-register.js +3 -5
  70. package/lib/commands/ext-dev-undeprecate.js +1 -2
  71. package/lib/commands/ext-dev-usage.js +4 -6
  72. package/lib/commands/ext-export.js +1 -2
  73. package/lib/commands/ext-install.js +3 -3
  74. package/lib/commands/ext-sdk-install.js +1 -0
  75. package/lib/commands/ext-update.js +1 -0
  76. package/lib/commands/firestore-backups-delete.js +3 -4
  77. package/lib/commands/firestore-backups-get.js +1 -1
  78. package/lib/commands/firestore-backups-list.js +2 -2
  79. package/lib/commands/firestore-backups-schedules-create.js +4 -4
  80. package/lib/commands/firestore-backups-schedules-delete.js +3 -4
  81. package/lib/commands/firestore-backups-schedules-list.js +2 -2
  82. package/lib/commands/firestore-backups-schedules-update.js +1 -1
  83. package/lib/commands/firestore-databases-create.js +6 -6
  84. package/lib/commands/firestore-databases-delete.js +3 -7
  85. package/lib/commands/firestore-databases-get.js +1 -1
  86. package/lib/commands/firestore-databases-list.js +1 -1
  87. package/lib/commands/firestore-databases-restore.js +5 -5
  88. package/lib/commands/firestore-databases-update.js +4 -4
  89. package/lib/commands/firestore-delete.js +13 -14
  90. package/lib/commands/firestore-indexes-list.js +4 -4
  91. package/lib/commands/firestore-locations.js +1 -1
  92. package/lib/commands/functions-artifacts-setpolicy.js +132 -0
  93. package/lib/commands/functions-config-export.js +6 -10
  94. package/lib/commands/functions-delete.js +5 -7
  95. package/lib/commands/functions-deletegcfartifacts.js +5 -5
  96. package/lib/commands/functions-list.js +24 -33
  97. package/lib/commands/functions-secrets-access.js +1 -1
  98. package/lib/commands/functions-secrets-describe.js +1 -1
  99. package/lib/commands/functions-secrets-destroy.js +10 -12
  100. package/lib/commands/functions-secrets-get.js +1 -1
  101. package/lib/commands/functions-secrets-prune.js +14 -15
  102. package/lib/commands/functions-secrets-set.js +14 -18
  103. package/lib/commands/hosting-channel-create.js +1 -2
  104. package/lib/commands/hosting-channel-delete.js +4 -4
  105. package/lib/commands/hosting-channel-list.js +1 -1
  106. package/lib/commands/hosting-channel-open.js +2 -3
  107. package/lib/commands/hosting-disable.js +5 -5
  108. package/lib/commands/hosting-sites-delete.js +4 -4
  109. package/lib/commands/hosting-sites-get.js +1 -1
  110. package/lib/commands/hosting-sites-list.js +1 -1
  111. package/lib/commands/index.js +7 -4
  112. package/lib/commands/init.js +54 -60
  113. package/lib/commands/internaltesting-frameworks-compose.js +1 -1
  114. package/lib/commands/login-use.js +2 -11
  115. package/lib/commands/login.js +10 -8
  116. package/lib/commands/logout.js +2 -3
  117. package/lib/commands/mcp.js +11 -0
  118. package/lib/commands/open.js +4 -2
  119. package/lib/commands/projects-create.js +1 -2
  120. package/lib/commands/projects-list.js +1 -1
  121. package/lib/commands/remoteconfig-get.js +1 -1
  122. package/lib/commands/remoteconfig-rollback.js +5 -5
  123. package/lib/commands/remoteconfig-versions-list.js +2 -2
  124. package/lib/commands/setup-emulators-database.js +1 -1
  125. package/lib/commands/setup-emulators-dataconnect.js +1 -1
  126. package/lib/commands/setup-emulators-firestore.js +1 -1
  127. package/lib/commands/setup-emulators-pubsub.js +1 -1
  128. package/lib/commands/setup-emulators-storage.js +1 -1
  129. package/lib/commands/setup-emulators-ui.js +1 -1
  130. package/lib/commands/use.js +115 -111
  131. package/lib/config.js +49 -33
  132. package/lib/crashlytics/buildToolsJarHelper.js +1 -1
  133. package/lib/crashlytics/listTopIssues.js +45 -0
  134. package/lib/dataconnect/build.js +61 -4
  135. package/lib/dataconnect/client.js +26 -17
  136. package/lib/dataconnect/cloudAICompanionClient.js +72 -0
  137. package/lib/dataconnect/dataplaneClient.js +19 -2
  138. package/lib/dataconnect/ensureApis.js +6 -3
  139. package/lib/dataconnect/fileUtils.js +39 -6
  140. package/lib/dataconnect/freeTrial.js +21 -9
  141. package/lib/dataconnect/graphqlError.js +56 -2
  142. package/lib/dataconnect/provisionCloudSql.js +23 -12
  143. package/lib/dataconnect/schemaMigration.js +46 -26
  144. package/lib/dataconnect/types.js +5 -1
  145. package/lib/defaultCredentials.js +12 -1
  146. package/lib/deploy/apphosting/args.js +2 -0
  147. package/lib/deploy/apphosting/deploy.js +77 -0
  148. package/lib/deploy/apphosting/index.js +9 -0
  149. package/lib/deploy/apphosting/prepare.js +138 -0
  150. package/lib/deploy/apphosting/release.js +56 -0
  151. package/lib/deploy/apphosting/util.js +65 -0
  152. package/lib/deploy/dataconnect/deploy.js +14 -7
  153. package/lib/deploy/dataconnect/prepare.js +3 -5
  154. package/lib/deploy/extensions/v2FunctionHelper.js +2 -1
  155. package/lib/deploy/firestore/deploy.js +50 -4
  156. package/lib/deploy/functions/build.js +1 -0
  157. package/lib/deploy/functions/checkIam.js +41 -6
  158. package/lib/deploy/functions/containerCleaner.js +17 -2
  159. package/lib/deploy/functions/ensure.js +2 -1
  160. package/lib/deploy/functions/params.js +10 -17
  161. package/lib/deploy/functions/prepare.js +51 -18
  162. package/lib/deploy/functions/prepareFunctionsUpload.js +9 -5
  163. package/lib/deploy/functions/prompts.js +24 -17
  164. package/lib/deploy/functions/release/fabricator.js +4 -4
  165. package/lib/deploy/functions/release/index.js +27 -9
  166. package/lib/deploy/functions/release/planner.js +1 -0
  167. package/lib/deploy/functions/runtimes/discovery/index.js +13 -5
  168. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -4
  169. package/lib/deploy/functions/runtimes/python/index.js +4 -1
  170. package/lib/deploy/functions/runtimes/supported/types.js +17 -11
  171. package/lib/deploy/functions/services/firestore.js +23 -4
  172. package/lib/deploy/index.js +29 -10
  173. package/lib/deploy/lifecycleHooks.js +6 -12
  174. package/lib/emulator/ExpressBasedEmulator.js +1 -1
  175. package/lib/emulator/apphosting/config.js +15 -14
  176. package/lib/emulator/apphosting/index.js +2 -0
  177. package/lib/emulator/apphosting/serve.js +147 -10
  178. package/lib/emulator/auth/cloudFunctions.js +13 -1
  179. package/lib/emulator/auth/operations.js +2 -1
  180. package/lib/emulator/auth/widget_ui.js +2 -1
  181. package/lib/emulator/commandUtils.js +14 -20
  182. package/lib/emulator/constants.js +2 -0
  183. package/lib/emulator/controller.js +24 -9
  184. package/lib/emulator/dataconnect/pgliteServer.js +136 -45
  185. package/lib/emulator/dataconnectEmulator.js +34 -6
  186. package/lib/emulator/dataconnectToolkitController.js +5 -0
  187. package/lib/emulator/downloadableEmulatorInfo.json +81 -0
  188. package/lib/emulator/downloadableEmulators.js +28 -80
  189. package/lib/emulator/env.js +47 -1
  190. package/lib/emulator/extensionsEmulator.js +5 -3
  191. package/lib/emulator/functionsEmulator.js +6 -26
  192. package/lib/emulator/hub.js +5 -4
  193. package/lib/emulator/hubClient.js +5 -0
  194. package/lib/emulator/initEmulators.js +29 -15
  195. package/lib/emulator/ui.js +4 -8
  196. package/lib/ensureApiEnabled.js +32 -1
  197. package/lib/experiments.js +11 -12
  198. package/lib/extensions/askUserForEventsConfig.js +6 -15
  199. package/lib/extensions/askUserForParam.js +23 -52
  200. package/lib/extensions/change-log.js +1 -25
  201. package/lib/extensions/checkProjectBilling.js +3 -9
  202. package/lib/extensions/diagnose.js +3 -6
  203. package/lib/extensions/emulator/triggerHelper.js +4 -0
  204. package/lib/extensions/extensionsHelper.js +25 -31
  205. package/lib/extensions/listExtensions.js +1 -1
  206. package/lib/extensions/manifest.js +3 -7
  207. package/lib/extensions/paramHelper.js +11 -2
  208. package/lib/extensions/provisioningHelper.js +1 -1
  209. package/lib/extensions/tos.js +4 -2
  210. package/lib/extensions/utils.js +1 -10
  211. package/lib/firebaseConfigValidate.js +7 -5
  212. package/lib/firestore/delete.js +5 -4
  213. package/lib/firestore/pretty-print.js +1 -1
  214. package/lib/frameworks/angular/index.js +11 -6
  215. package/lib/frameworks/angular/utils.js +76 -47
  216. package/lib/frameworks/constants.js +1 -1
  217. package/lib/frameworks/index.js +6 -4
  218. package/lib/frameworks/next/index.js +7 -4
  219. package/lib/frameworks/utils.js +11 -3
  220. package/lib/frameworks/vite/index.js +2 -3
  221. package/lib/fsAsync.js +9 -2
  222. package/lib/fsutils.js +16 -1
  223. package/lib/functions/artifacts.js +196 -0
  224. package/lib/functions/secrets.js +15 -16
  225. package/lib/gcp/apphosting.js +13 -1
  226. package/lib/gcp/artifactregistry.js +27 -2
  227. package/lib/gcp/auth.js +113 -1
  228. package/lib/gcp/cloudbilling.js +12 -1
  229. package/lib/gcp/cloudfunctions.js +32 -4
  230. package/lib/gcp/cloudfunctionsv2.js +15 -9
  231. package/lib/gcp/cloudscheduler.js +2 -2
  232. package/lib/gcp/cloudsql/cloudsqladmin.js +32 -11
  233. package/lib/gcp/cloudsql/connect.js +21 -14
  234. package/lib/gcp/cloudsql/interactive.js +1 -1
  235. package/lib/gcp/cloudsql/permissions.js +46 -99
  236. package/lib/gcp/cloudsql/permissionsSetup.js +224 -0
  237. package/lib/gcp/computeEngine.js +19 -2
  238. package/lib/gcp/devConnect.js +6 -1
  239. package/lib/gcp/firestore.js +55 -16
  240. package/lib/gcp/iam.js +1 -5
  241. package/lib/gcp/proto.js +4 -3
  242. package/lib/gcp/run.js +18 -1
  243. package/lib/gcp/serviceusage.js +2 -1
  244. package/lib/gcp/storage.js +47 -1
  245. package/lib/gemini/fdcExperience.js +56 -0
  246. package/lib/gemini/types.js +2 -0
  247. package/lib/hosting/api.js +4 -0
  248. package/lib/hosting/implicitInit.js +7 -3
  249. package/lib/hosting/interactive.js +2 -3
  250. package/lib/index.js +1 -2
  251. package/lib/init/features/account.js +2 -4
  252. package/lib/init/features/apphosting.js +75 -6
  253. package/lib/init/features/database.js +63 -62
  254. package/lib/init/features/dataconnect/index.js +131 -85
  255. package/lib/init/features/dataconnect/sdk.js +73 -18
  256. package/lib/init/features/emulators.js +29 -46
  257. package/lib/init/features/firestore/index.js +79 -43
  258. package/lib/init/features/firestore/indexes.js +30 -45
  259. package/lib/init/features/firestore/rules.js +36 -62
  260. package/lib/init/features/functions/index.js +11 -16
  261. package/lib/init/features/functions/javascript.js +17 -30
  262. package/lib/init/features/functions/npm-dependencies.js +4 -8
  263. package/lib/init/features/functions/python.js +1 -3
  264. package/lib/init/features/functions/typescript.js +25 -43
  265. package/lib/init/features/genkit/index.js +111 -106
  266. package/lib/init/features/hosting/github.js +22 -52
  267. package/lib/init/features/hosting/index.js +37 -57
  268. package/lib/init/features/index.js +10 -5
  269. package/lib/init/features/project.js +18 -21
  270. package/lib/init/features/remoteconfig.js +5 -10
  271. package/lib/init/features/storage.js +30 -10
  272. package/lib/init/index.js +79 -24
  273. package/lib/logger.js +76 -3
  274. package/lib/management/apps.js +292 -7
  275. package/lib/management/projects.js +100 -52
  276. package/lib/mcp/errors.js +20 -0
  277. package/lib/mcp/index.js +227 -0
  278. package/lib/mcp/tool.js +12 -0
  279. package/lib/mcp/tools/apphosting/fetch_logs.js +68 -0
  280. package/lib/mcp/tools/apphosting/index.js +6 -0
  281. package/lib/mcp/tools/apphosting/list_backends.js +51 -0
  282. package/lib/mcp/tools/auth/disable_user.js +30 -0
  283. package/lib/mcp/tools/auth/get_user.js +38 -0
  284. package/lib/mcp/tools/auth/index.js +15 -0
  285. package/lib/mcp/tools/auth/list_users.js +36 -0
  286. package/lib/mcp/tools/auth/set_claims.js +43 -0
  287. package/lib/mcp/tools/auth/set_sms_region_policy.js +36 -0
  288. package/lib/mcp/tools/core/consult_assistant.js +28 -0
  289. package/lib/mcp/tools/core/create_android_sha.js +43 -0
  290. package/lib/mcp/tools/core/create_app.js +90 -0
  291. package/lib/mcp/tools/core/create_project.js +68 -0
  292. package/lib/mcp/tools/core/get_admin_sdk_config.js +26 -0
  293. package/lib/mcp/tools/core/get_environment.js +51 -0
  294. package/lib/mcp/tools/core/get_project.js +22 -0
  295. package/lib/mcp/tools/core/get_sdk_config.js +40 -0
  296. package/lib/mcp/tools/core/index.js +29 -0
  297. package/lib/mcp/tools/core/init.js +153 -0
  298. package/lib/mcp/tools/core/list_apps.js +34 -0
  299. package/lib/mcp/tools/core/list_projects.js +45 -0
  300. package/lib/mcp/tools/core/update_environment.js +55 -0
  301. package/lib/mcp/tools/crashlytics/index.js +5 -0
  302. package/lib/mcp/tools/crashlytics/list_top_issues.js +39 -0
  303. package/lib/mcp/tools/dataconnect/converter.js +60 -0
  304. package/lib/mcp/tools/dataconnect/emulator.js +16 -0
  305. package/lib/mcp/tools/dataconnect/execute_graphql.js +48 -0
  306. package/lib/mcp/tools/dataconnect/execute_graphql_read.js +48 -0
  307. package/lib/mcp/tools/dataconnect/execute_mutation.js +62 -0
  308. package/lib/mcp/tools/dataconnect/execute_query.js +62 -0
  309. package/lib/mcp/tools/dataconnect/generate_operation.js +34 -0
  310. package/lib/mcp/tools/dataconnect/generate_schema.js +26 -0
  311. package/lib/mcp/tools/dataconnect/get_connector.js +31 -0
  312. package/lib/mcp/tools/dataconnect/get_schema.js +31 -0
  313. package/lib/mcp/tools/dataconnect/index.js +23 -0
  314. package/lib/mcp/tools/dataconnect/list_services.js +23 -0
  315. package/lib/mcp/tools/firestore/converter.js +102 -0
  316. package/lib/mcp/tools/firestore/delete_document.js +50 -0
  317. package/lib/mcp/tools/firestore/get_documents.js +58 -0
  318. package/lib/mcp/tools/firestore/index.js +17 -0
  319. package/lib/mcp/tools/firestore/list_collections.js +36 -0
  320. package/lib/mcp/tools/firestore/query_collection.js +132 -0
  321. package/lib/mcp/tools/index.js +62 -0
  322. package/lib/mcp/tools/messaging/index.js +5 -0
  323. package/lib/mcp/tools/messaging/send_message.js +42 -0
  324. package/lib/mcp/tools/remoteconfig/get_template.js +27 -0
  325. package/lib/mcp/tools/remoteconfig/index.js +7 -0
  326. package/lib/mcp/tools/remoteconfig/publish_template.js +34 -0
  327. package/lib/mcp/tools/remoteconfig/rollback_template.js +29 -0
  328. package/lib/mcp/tools/rules/get_rules.js +29 -0
  329. package/lib/mcp/tools/rules/validate_rules.js +97 -0
  330. package/lib/mcp/tools/storage/get_download_url.js +40 -0
  331. package/lib/mcp/tools/storage/get_rules.js +26 -0
  332. package/lib/mcp/tools/storage/index.js +11 -0
  333. package/lib/mcp/types.js +13 -0
  334. package/lib/mcp/util.js +214 -0
  335. package/lib/mcp/util.test.js +468 -0
  336. package/lib/messaging/interfaces.js +2 -0
  337. package/lib/messaging/sendMessage.js +48 -0
  338. package/lib/operation-poller.js +3 -1
  339. package/lib/profileReport.js +1 -1
  340. package/lib/prompt.js +86 -54
  341. package/lib/remoteconfig/publish.js +39 -0
  342. package/lib/requireAuth.js +2 -2
  343. package/lib/requireTosAcceptance.js +4 -0
  344. package/lib/rulesDeploy.js +10 -15
  345. package/lib/track.js +7 -37
  346. package/lib/utils.js +28 -41
  347. package/lib/vsCodeUtils.js +7 -3
  348. package/package.json +31 -15
  349. package/schema/connector-yaml.json +12 -0
  350. package/schema/dataconnect-yaml.json +5 -0
  351. package/schema/extension-yaml.json +17 -4
  352. package/schema/firebase-config.json +1117 -2121
  353. package/standalone/package-lock.json +1255 -992
  354. package/standalone/package.json +1 -1
  355. package/templates/dataconnect-prompts/operation-generation-cursor-windsurf-rule.txt +273 -0
  356. package/templates/dataconnect-prompts/schema-generation-cursor-windsurf-rule.txt +653 -0
  357. package/templates/genkit/firebase.0.9.0.template +1 -1
  358. package/templates/genkit/firebase.1.0.0.template +71 -0
  359. package/templates/init/dataconnect/connector.yaml +4 -1
  360. package/templates/init/dataconnect/dataconnect.yaml +1 -1
  361. package/templates/init/dataconnect/mutations.gql +9 -26
  362. package/templates/init/dataconnect/queries.gql +9 -14
  363. package/templates/init/dataconnect/schema.gql +28 -21
  364. package/templates/init/firestore/firestore.rules +2 -0
  365. package/templates/init/functions/javascript/index.js +14 -1
  366. package/templates/init/functions/javascript/package.lint.json +1 -1
  367. package/templates/init/functions/javascript/package.nolint.json +1 -1
  368. package/templates/init/functions/python/_gitignore +6 -1
  369. package/templates/init/functions/python/main.py +8 -0
  370. package/templates/init/functions/typescript/index.ts +14 -1
  371. package/templates/init/functions/typescript/package.lint.json +2 -2
  372. package/templates/init/functions/typescript/package.nolint.json +3 -3
  373. package/lib/commands/apphosting-config-export.js +0 -28
  374. package/lib/commands/experimental-functions-shell.js +0 -13
  375. package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +0 -11
  376. package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +0 -58
  377. package/lib/emulator/dataconnect/pg-gateway/auth/index.js +0 -22
  378. package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +0 -124
  379. package/lib/emulator/dataconnect/pg-gateway/auth/password.js +0 -54
  380. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +0 -34
  381. package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +0 -270
  382. package/lib/emulator/dataconnect/pg-gateway/backend-error.js +0 -75
  383. package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +0 -54
  384. package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +0 -79
  385. package/lib/emulator/dataconnect/pg-gateway/connection.js +0 -315
  386. package/lib/emulator/dataconnect/pg-gateway/connection.types.js +0 -8
  387. package/lib/emulator/dataconnect/pg-gateway/crypto.js +0 -40
  388. package/lib/emulator/dataconnect/pg-gateway/duplex.js +0 -53
  389. package/lib/emulator/dataconnect/pg-gateway/index.js +0 -27
  390. package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +0 -82
  391. package/lib/emulator/dataconnect/pg-gateway/message-codes.js +0 -52
  392. package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +0 -16
  393. package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +0 -35
  394. package/lib/emulator/dataconnect/pg-gateway/utils.js +0 -40
  395. package/templates/setup/web.js +0 -5
  396. /package/lib/{emulator/dataconnect/pg-gateway/auth/trust.js → dataconnect/cloudAICompanionTypes.js} +0 -0
@@ -1,315 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.closeSignal = void 0;
4
- const index_1 = require("./auth/index");
5
- const backend_error_1 = require("./backend-error");
6
- const buffer_reader_1 = require("./buffer-reader");
7
- const buffer_writer_1 = require("./buffer-writer");
8
- const connection_types_1 = require("./connection.types");
9
- const utils_1 = require("./utils");
10
- const message_buffer_1 = require("./message-buffer");
11
- const message_codes_1 = require("./message-codes");
12
- const logger_1 = require("../../../logger");
13
- exports.closeSignal = Symbol('close');
14
- class PostgresConnection {
15
- constructor(duplex, options = {}) {
16
- this.duplex = duplex;
17
- this.step = connection_types_1.ServerStep.AwaitingInitialMessage;
18
- this.hasStarted = false;
19
- this.isAuthenticated = false;
20
- this.detached = false;
21
- this.writer = new buffer_writer_1.BufferWriter();
22
- this.reader = new buffer_reader_1.BufferReader();
23
- this.messageBuffer = new message_buffer_1.MessageBuffer();
24
- this.options = {
25
- auth: { method: 'trust' },
26
- ...options,
27
- };
28
- if (this.options.tls && !this.options.upgradeTls) {
29
- throw new Error('TLS options are only available when upgradeTls() is implemented. Did you mean to use fromNodeSocket()?');
30
- }
31
- this.processData();
32
- }
33
- get state() {
34
- return {
35
- hasStarted: this.hasStarted,
36
- isAuthenticated: this.isAuthenticated,
37
- clientInfo: this.clientInfo,
38
- tlsInfo: this.tlsInfo,
39
- step: this.step,
40
- };
41
- }
42
- async detach() {
43
- this.detached = true;
44
- return this.duplex;
45
- }
46
- async processData() {
47
- const writer = this.duplex.writable.getWriter();
48
- for await (const data of this.duplex.readable) {
49
- this.messageBuffer.mergeBuffer(data);
50
- for await (const clientMessage of this.messageBuffer.processMessages(this.hasStarted)) {
51
- logger_1.logger.debug('Frontend message', (0, message_codes_1.getFrontendMessageName)(clientMessage[0]));
52
- for await (const responseMessage of this.handleClientMessage(clientMessage)) {
53
- if (responseMessage === exports.closeSignal) {
54
- await writer.close();
55
- return;
56
- }
57
- for await (const msg of (0, message_buffer_1.getMessages)(responseMessage)) {
58
- if (msg[0] !== message_codes_1.BackendMessageCode.NoticeMessage) {
59
- logger_1.logger.debug('Backend message', (0, message_codes_1.getBackendMessageName)(msg[0]));
60
- if (msg[0] === message_codes_1.BackendMessageCode.ErrorMessage) {
61
- logger_1.logger.debug(new TextDecoder().decode(msg));
62
- }
63
- }
64
- }
65
- await writer.write(responseMessage);
66
- }
67
- }
68
- if (this.detached) {
69
- return;
70
- }
71
- }
72
- }
73
- async *handleClientMessage(message) {
74
- this.reader.setBuffer(message);
75
- const messageResponse = await this.options.onMessage?.(message, this.state);
76
- let skipProcessing = messageResponse !== undefined;
77
- if (messageResponse) {
78
- const iterableResponse = new utils_1.AsyncIterableWithMetadata(messageResponse instanceof Uint8Array ? [messageResponse] : messageResponse);
79
- yield* iterableResponse;
80
- if (iterableResponse.returnValue instanceof Uint8Array) {
81
- yield iterableResponse.returnValue;
82
- }
83
- skipProcessing =
84
- iterableResponse.iterations > 0 || iterableResponse.returnValue !== undefined;
85
- }
86
- if (this.detached) {
87
- return;
88
- }
89
- if (skipProcessing) {
90
- if (this.isStartupMessage(message)) {
91
- this.hasStarted = true;
92
- }
93
- return;
94
- }
95
- switch (this.step) {
96
- case connection_types_1.ServerStep.AwaitingInitialMessage:
97
- if (this.isSslRequest(message)) {
98
- yield* this.handleSslRequest();
99
- }
100
- else if (this.isStartupMessage(message)) {
101
- if (this.options.tls && !this.tlsInfo) {
102
- yield (0, backend_error_1.createBackendErrorMessage)({
103
- severity: 'FATAL',
104
- code: '08P01',
105
- message: 'SSL connection is required',
106
- });
107
- yield exports.closeSignal;
108
- return;
109
- }
110
- yield* this.handleStartupMessage(message);
111
- }
112
- else {
113
- throw new Error('Unexpected initial message');
114
- }
115
- break;
116
- case connection_types_1.ServerStep.PerformingAuthentication: {
117
- const authenticationComplete = yield* this.handleAuthenticationMessage(message);
118
- if (authenticationComplete) {
119
- yield* this.completeAuthentication();
120
- }
121
- break;
122
- }
123
- case connection_types_1.ServerStep.ReadyForQuery:
124
- yield* this.handleRegularMessage(message);
125
- break;
126
- default:
127
- throw new Error(`Unexpected step: ${this.step}`);
128
- }
129
- }
130
- async *handleSslRequest() {
131
- if (!this.options.tls || !this.options.upgradeTls) {
132
- this.writer.addString('N');
133
- yield this.writer.flush();
134
- return;
135
- }
136
- this.writer.addString('S');
137
- yield this.writer.flush();
138
- const requestCert = this.options.auth.method === 'cert';
139
- const { duplex, tlsInfo } = await this.options.upgradeTls(this.duplex, this.options.tls, this.tlsInfo, requestCert);
140
- this.duplex = duplex;
141
- this.tlsInfo = tlsInfo;
142
- await this.options.onTlsUpgrade?.(this.state);
143
- }
144
- async *handleStartupMessage(message) {
145
- const { majorVersion, minorVersion, parameters } = this.readStartupMessage();
146
- if (!parameters.user) {
147
- yield (0, backend_error_1.createBackendErrorMessage)({
148
- severity: 'FATAL',
149
- code: '08000',
150
- message: 'user is required',
151
- });
152
- yield exports.closeSignal;
153
- return;
154
- }
155
- if (majorVersion !== 3 || minorVersion !== 0) {
156
- yield (0, backend_error_1.createBackendErrorMessage)({
157
- severity: 'FATAL',
158
- code: '08000',
159
- message: `Unsupported protocol version ${majorVersion.toString()}.${minorVersion.toString()}`,
160
- });
161
- yield exports.closeSignal;
162
- return;
163
- }
164
- this.clientInfo = {
165
- majorVersion,
166
- minorVersion,
167
- parameters: {
168
- user: parameters.user,
169
- ...parameters,
170
- },
171
- };
172
- this.hasStarted = true;
173
- await this.options.onStartup?.(this.state);
174
- if (this.detached) {
175
- return;
176
- }
177
- if (this.options.auth.method === 'trust') {
178
- yield* this.completeAuthentication();
179
- return;
180
- }
181
- this.authFlow = (0, index_1.createAuthFlow)({
182
- reader: this.reader,
183
- writer: this.writer,
184
- username: this.clientInfo.parameters.user,
185
- auth: this.options.auth,
186
- connectionState: this.state,
187
- });
188
- this.step = connection_types_1.ServerStep.PerformingAuthentication;
189
- const initialAuthMessage = this.authFlow.createInitialAuthMessage();
190
- if (initialAuthMessage) {
191
- yield initialAuthMessage;
192
- }
193
- if (this.options.auth.method === 'cert') {
194
- yield* this.authFlow.handleClientMessage(message);
195
- if (this.authFlow.isCompleted) {
196
- yield* this.completeAuthentication();
197
- }
198
- }
199
- }
200
- async *handleAuthenticationMessage(message) {
201
- const code = this.reader.byte();
202
- if (code !== message_codes_1.FrontendMessageCode.Password) {
203
- throw new Error(`Unexpected authentication message code: ${code}`);
204
- }
205
- if (!this.authFlow) {
206
- throw new Error('AuthFlow not initialized');
207
- }
208
- yield* this.authFlow.handleClientMessage(message);
209
- return this.authFlow.isCompleted;
210
- }
211
- async *handleRegularMessage(message) {
212
- const code = this.reader.byte();
213
- switch (code) {
214
- case message_codes_1.FrontendMessageCode.Terminate:
215
- yield exports.closeSignal;
216
- return;
217
- default:
218
- yield (0, backend_error_1.createBackendErrorMessage)({
219
- severity: 'ERROR',
220
- code: '123',
221
- message: 'Message code not yet implemented',
222
- });
223
- yield this.createReadyForQuery();
224
- }
225
- }
226
- isSslRequest(message) {
227
- if (message.byteLength !== 8)
228
- return false;
229
- const dataView = new DataView(message.buffer, message.byteOffset, message.byteLength);
230
- const mostSignificantPart = dataView.getInt16(4);
231
- const leastSignificantPart = dataView.getInt16(6);
232
- return mostSignificantPart === 1234 && leastSignificantPart === 5679;
233
- }
234
- isStartupMessage(message) {
235
- if (message.byteLength < 8)
236
- return false;
237
- const dataView = new DataView(message.buffer, message.byteOffset, message.byteLength);
238
- const length = dataView.getInt32(0);
239
- const majorVersion = dataView.getInt16(4);
240
- const minorVersion = dataView.getInt16(6);
241
- return message.byteLength === length && majorVersion === 3 && minorVersion === 0;
242
- }
243
- async *completeAuthentication() {
244
- this.isAuthenticated = true;
245
- yield this.createAuthenticationOk();
246
- await this.options.onAuthenticated?.(this.state);
247
- if (this.options.serverVersion) {
248
- let serverVersion;
249
- if (typeof this.options.serverVersion === 'function') {
250
- serverVersion = await this.options.serverVersion(this.state);
251
- }
252
- else {
253
- serverVersion = this.options.serverVersion;
254
- }
255
- yield this.createParameterStatus('server_version', serverVersion);
256
- }
257
- this.step = connection_types_1.ServerStep.ReadyForQuery;
258
- yield this.createReadyForQuery();
259
- }
260
- readStartupMessage() {
261
- const length = this.reader.int32();
262
- const majorVersion = this.reader.int16();
263
- const minorVersion = this.reader.int16();
264
- const parameters = {};
265
- for (let key; (key = this.reader.cstring()) !== '';) {
266
- parameters[key] = this.reader.cstring();
267
- }
268
- return {
269
- majorVersion,
270
- minorVersion,
271
- parameters,
272
- };
273
- }
274
- readQuery() {
275
- const query = this.reader.cstring();
276
- return {
277
- query,
278
- };
279
- }
280
- createAuthenticationOk() {
281
- this.writer.addInt32(0);
282
- return this.writer.flush(message_codes_1.BackendMessageCode.AuthenticationResponse);
283
- }
284
- createParameterStatus(name, value) {
285
- this.writer.addCString(name);
286
- this.writer.addCString(value);
287
- return this.writer.flush(message_codes_1.BackendMessageCode.ParameterStatus);
288
- }
289
- createReadyForQuery(transactionStatus = 'idle') {
290
- switch (transactionStatus) {
291
- case 'idle':
292
- this.writer.addString('I');
293
- break;
294
- case 'transaction':
295
- this.writer.addString('T');
296
- break;
297
- case 'error':
298
- this.writer.addString('E');
299
- break;
300
- default:
301
- throw new Error(`Unknown transaction status '${transactionStatus}'`);
302
- }
303
- return this.writer.flush(message_codes_1.BackendMessageCode.ReadyForQuery);
304
- }
305
- createAuthenticationFailedError() {
306
- return (0, backend_error_1.createBackendErrorMessage)({
307
- severity: 'FATAL',
308
- code: '28P01',
309
- message: this.clientInfo?.parameters.user
310
- ? `password authentication failed for user "${this.clientInfo.parameters.user}"`
311
- : 'password authentication failed',
312
- });
313
- }
314
- }
315
- exports.default = PostgresConnection;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServerStep = void 0;
4
- exports.ServerStep = {
5
- AwaitingInitialMessage: 'AwaitingInitialMessage',
6
- PerformingAuthentication: 'PerformingAuthentication',
7
- ReadyForQuery: 'ReadyForQuery',
8
- };
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.timingSafeEqual = exports.createHashKey = exports.createHmacKey = exports.pbkdf2 = void 0;
4
- async function pbkdf2(password, salt, iterations, length, hashAlgorithm) {
5
- const encoder = new TextEncoder();
6
- const keyMaterial = await crypto.subtle.importKey('raw', encoder.encode(password), 'PBKDF2', false, ['deriveBits']);
7
- const derivedBits = await crypto.subtle.deriveBits({
8
- name: 'PBKDF2',
9
- salt,
10
- iterations: iterations,
11
- hash: hashAlgorithm,
12
- }, keyMaterial, length * 8);
13
- return derivedBits;
14
- }
15
- exports.pbkdf2 = pbkdf2;
16
- async function createHmacKey(key, message, algorithm) {
17
- const encoder = new TextEncoder();
18
- const keyMaterial = await crypto.subtle.importKey('raw', key, {
19
- name: 'HMAC',
20
- hash: { name: algorithm },
21
- }, false, ['sign']);
22
- const hmacKey = await crypto.subtle.sign('HMAC', keyMaterial, encoder.encode(message));
23
- return hmacKey;
24
- }
25
- exports.createHmacKey = createHmacKey;
26
- async function createHashKey(key, algorithm) {
27
- const hashKey = await crypto.subtle.digest({
28
- name: algorithm,
29
- }, key);
30
- return hashKey;
31
- }
32
- exports.createHashKey = createHashKey;
33
- async function timingSafeEqual(bufferA, bufferB) {
34
- const algorithm = { name: 'HMAC', hash: 'SHA-256' };
35
- const key = (await crypto.subtle.generateKey(algorithm, false, ['sign', 'verify']));
36
- const hmac = await crypto.subtle.sign(algorithm, key, bufferA);
37
- const equal = await crypto.subtle.verify(algorithm, key, hmac, bufferB);
38
- return equal;
39
- }
40
- exports.timingSafeEqual = timingSafeEqual;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createVirtualServer = exports.createDuplexPair = exports.BufferedStream = void 0;
4
- const web_1 = require("node:stream/web");
5
- class BufferedStream {
6
- constructor() {
7
- const buffer = [];
8
- this.readable = new web_1.ReadableStream({
9
- async pull(controller) {
10
- while (buffer.length === 0) {
11
- await new Promise((resolve) => setTimeout(resolve));
12
- }
13
- const chunk = buffer.shift();
14
- controller.enqueue(chunk);
15
- },
16
- });
17
- this.writable = new WritableStream({
18
- async write(chunk) {
19
- buffer.push(chunk);
20
- await new Promise((resolve) => setTimeout(resolve));
21
- },
22
- });
23
- }
24
- }
25
- exports.BufferedStream = BufferedStream;
26
- function createDuplexPair() {
27
- const aToB = new BufferedStream();
28
- const bToA = new BufferedStream();
29
- const duplexA = {
30
- readable: bToA.readable,
31
- writable: aToB.writable,
32
- };
33
- const duplexB = {
34
- readable: aToB.readable,
35
- writable: bToA.writable,
36
- };
37
- return [duplexA, duplexB];
38
- }
39
- exports.createDuplexPair = createDuplexPair;
40
- function createVirtualServer() {
41
- const listener = new BufferedStream();
42
- const connWriter = listener.writable.getWriter();
43
- function listen() {
44
- return listener.readable;
45
- }
46
- async function connect() {
47
- const [clientConn, serverConn] = createDuplexPair();
48
- await connWriter.write(serverConn);
49
- return clientConn;
50
- }
51
- return { listen, connect };
52
- }
53
- exports.createVirtualServer = createVirtualServer;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.PostgresConnection = void 0;
18
- require("./polyfills/readable-stream-async-iterator");
19
- var connection_1 = require("./connection");
20
- Object.defineProperty(exports, "PostgresConnection", { enumerable: true, get: function () { return connection_1.default; } });
21
- __exportStar(require("./connection"), exports);
22
- __exportStar(require("./auth/sasl/scram-sha-256"), exports);
23
- __exportStar(require("./auth/md5"), exports);
24
- __exportStar(require("./backend-error"), exports);
25
- __exportStar(require("./duplex"), exports);
26
- __exportStar(require("./message-codes"), exports);
27
- __exportStar(require("./message-buffer"), exports);
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMessages = exports.MessageBuffer = void 0;
4
- const utils_1 = require("./utils");
5
- class MessageBuffer {
6
- constructor() {
7
- this.buffer = new Uint8Array();
8
- this.bufferLength = 0;
9
- this.bufferOffset = 0;
10
- }
11
- mergeBuffer(newData) {
12
- if (this.bufferLength > 0) {
13
- const newLength = this.bufferLength + newData.byteLength;
14
- const newFullLength = newLength + this.bufferOffset;
15
- if (newFullLength > this.buffer.byteLength) {
16
- let newBuffer;
17
- if (newLength <= this.buffer.byteLength && this.bufferOffset >= this.bufferLength) {
18
- newBuffer = this.buffer;
19
- }
20
- else {
21
- let newBufferLength = this.buffer.byteLength * 2;
22
- while (newLength >= newBufferLength) {
23
- newBufferLength *= 2;
24
- }
25
- newBuffer = new Uint8Array(newBufferLength);
26
- }
27
- const bufferView = this.buffer.subarray(this.bufferOffset, this.bufferOffset + this.bufferLength);
28
- (0, utils_1.copy)(bufferView, newBuffer, 0);
29
- this.buffer = newBuffer;
30
- this.bufferOffset = 0;
31
- }
32
- (0, utils_1.copy)(newData, this.buffer, this.bufferOffset + this.bufferLength);
33
- this.bufferLength = newLength;
34
- }
35
- else {
36
- this.buffer = newData;
37
- this.bufferOffset = 0;
38
- this.bufferLength = newData.byteLength;
39
- }
40
- }
41
- async *processMessages(hasStarted) {
42
- const bufferFullLength = this.bufferOffset + this.bufferLength;
43
- let offset = this.bufferOffset;
44
- const codeLength = !hasStarted ? 0 : 1;
45
- const headerLength = 4 + codeLength;
46
- while (offset + headerLength <= bufferFullLength) {
47
- const dataView = new DataView(this.buffer.buffer);
48
- const length = dataView.getUint32(offset + codeLength);
49
- const fullMessageLength = codeLength + length;
50
- if (offset + fullMessageLength <= bufferFullLength) {
51
- yield this.buffer.subarray(offset, offset + fullMessageLength);
52
- offset += fullMessageLength;
53
- }
54
- else {
55
- break;
56
- }
57
- }
58
- if (offset === bufferFullLength) {
59
- this.buffer = new Uint8Array();
60
- this.bufferLength = 0;
61
- this.bufferOffset = 0;
62
- }
63
- else {
64
- this.bufferLength = bufferFullLength - offset;
65
- this.bufferOffset = offset;
66
- }
67
- }
68
- }
69
- exports.MessageBuffer = MessageBuffer;
70
- function* getMessages(data) {
71
- const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
72
- let offset = 0;
73
- if (dataView.byteLength === 0) {
74
- return;
75
- }
76
- while (offset < dataView.byteLength) {
77
- const length = dataView.getUint32(offset + 1);
78
- yield data.subarray(offset, offset + length + 1);
79
- offset += length + 1;
80
- }
81
- }
82
- exports.getMessages = getMessages;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBackendMessageName = exports.getFrontendMessageName = exports.BackendMessageCode = exports.FrontendMessageCode = void 0;
4
- exports.FrontendMessageCode = {
5
- Query: 0x51,
6
- Parse: 0x50,
7
- Bind: 0x42,
8
- Execute: 0x45,
9
- FunctionCall: 0x46,
10
- Flush: 0x48,
11
- Close: 0x43,
12
- Describe: 0x44,
13
- CopyFromChunk: 0x64,
14
- CopyDone: 0x63,
15
- CopyData: 0x64,
16
- CopyFail: 0x66,
17
- Password: 0x70,
18
- Sync: 0x53,
19
- Terminate: 0x58,
20
- };
21
- exports.BackendMessageCode = {
22
- DataRow: 0x44,
23
- ParseComplete: 0x31,
24
- BindComplete: 0x32,
25
- CloseComplete: 0x33,
26
- CommandComplete: 0x43,
27
- ReadyForQuery: 0x5a,
28
- NoData: 0x6e,
29
- NotificationResponse: 0x41,
30
- AuthenticationResponse: 0x52,
31
- ParameterStatus: 0x53,
32
- BackendKeyData: 0x4b,
33
- ErrorMessage: 0x45,
34
- NoticeMessage: 0x4e,
35
- RowDescriptionMessage: 0x54,
36
- ParameterDescriptionMessage: 0x74,
37
- PortalSuspended: 0x73,
38
- ReplicationStart: 0x57,
39
- EmptyQuery: 0x49,
40
- CopyIn: 0x47,
41
- CopyOut: 0x48,
42
- CopyDone: 0x63,
43
- CopyData: 0x64,
44
- };
45
- function getFrontendMessageName(code) {
46
- return Object.entries(exports.FrontendMessageCode).find(([_, value]) => value === code)?.[0];
47
- }
48
- exports.getFrontendMessageName = getFrontendMessageName;
49
- function getBackendMessageName(code) {
50
- return Object.entries(exports.BackendMessageCode).find(([_, value]) => value === code)?.[0];
51
- }
52
- exports.getBackendMessageName = getBackendMessageName;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromNodeSocket = void 0;
4
- const node_stream_1 = require("node:stream");
5
- const connection_1 = require("../../connection");
6
- async function fromNodeSocket(socket, options) {
7
- const rs = node_stream_1.Readable.toWeb(socket);
8
- const ws = node_stream_1.Writable.toWeb(socket);
9
- const opts = options
10
- ? {
11
- ...options,
12
- }
13
- : undefined;
14
- return new connection_1.default({ readable: rs, writable: ws }, opts);
15
- }
16
- exports.fromNodeSocket = fromNodeSocket;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var _a;
3
- (_a = ReadableStream.prototype).values ?? (_a.values = function ({ preventCancel = false } = {}) {
4
- const reader = this.getReader();
5
- return {
6
- async next() {
7
- try {
8
- const result = await reader.read();
9
- if (result.done) {
10
- reader.releaseLock();
11
- }
12
- return result;
13
- }
14
- catch (e) {
15
- reader.releaseLock();
16
- throw e;
17
- }
18
- },
19
- async return(value) {
20
- if (!preventCancel) {
21
- const cancelPromise = reader.cancel(value);
22
- reader.releaseLock();
23
- await cancelPromise;
24
- }
25
- else {
26
- reader.releaseLock();
27
- }
28
- return { done: true, value };
29
- },
30
- [Symbol.asyncIterator]() {
31
- return this;
32
- },
33
- };
34
- });
35
- ReadableStream.prototype ?? (ReadableStream.prototype = ReadableStream.prototype.values);
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.copy = exports.AsyncIterableWithMetadata = void 0;
4
- class AsyncIterableWithMetadata {
5
- constructor(iterable) {
6
- this.iterable = iterable;
7
- this.returnValue = undefined;
8
- this.iterations = 0;
9
- }
10
- [Symbol.asyncIterator]() {
11
- const asyncIterator = Symbol.asyncIterator in this.iterable
12
- ? this.iterable[Symbol.asyncIterator]()
13
- : this.iterable[Symbol.iterator]();
14
- this.returnValue = undefined;
15
- this.iterations = 0;
16
- return {
17
- next: async () => {
18
- const result = await asyncIterator.next();
19
- if (result.done) {
20
- this.returnValue = result.value;
21
- }
22
- else {
23
- this.iterations++;
24
- }
25
- return result;
26
- },
27
- };
28
- }
29
- }
30
- exports.AsyncIterableWithMetadata = AsyncIterableWithMetadata;
31
- function copy(src, dst, offset = 0) {
32
- offset = Math.max(0, Math.min(offset, dst.byteLength));
33
- const dstBytesAvailable = dst.byteLength - offset;
34
- if (src.byteLength > dstBytesAvailable) {
35
- src = src.subarray(0, dstBytesAvailable);
36
- }
37
- dst.set(src, offset);
38
- return src.byteLength;
39
- }
40
- exports.copy = copy;
@@ -1,5 +0,0 @@
1
- // Copy and paste this into your JavaScript code to initialize the Firebase SDK.
2
- // You will also need to load the Firebase SDK.
3
- // See https://firebase.google.com/docs/web/setup for more details.
4
-
5
- firebase.initializeApp({/*--CONFIG--*/});