firebase-tools 11.0.1 → 11.2.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.
Files changed (214) hide show
  1. package/lib/accountExporter.js +11 -4
  2. package/lib/accountImporter.js +93 -95
  3. package/lib/api.js +77 -218
  4. package/lib/apiv2.js +5 -4
  5. package/lib/appdistribution/client.js +7 -9
  6. package/lib/auth.js +72 -52
  7. package/lib/bin/firebase.js +42 -47
  8. package/lib/checkValidTargetFilters.js +36 -25
  9. package/lib/commands/appdistribution-distribute.js +2 -1
  10. package/lib/commands/appdistribution-testers-add.js +2 -1
  11. package/lib/commands/appdistribution-testers-remove.js +2 -1
  12. package/lib/commands/apps-android-sha-create.js +2 -1
  13. package/lib/commands/apps-android-sha-delete.js +2 -1
  14. package/lib/commands/apps-android-sha-list.js +2 -1
  15. package/lib/commands/apps-create.js +2 -1
  16. package/lib/commands/apps-list.js +2 -1
  17. package/lib/commands/apps-sdkconfig.js +2 -1
  18. package/lib/commands/auth-export.js +2 -1
  19. package/lib/commands/auth-import.js +7 -10
  20. package/lib/commands/crashlytics-symbols-upload.js +2 -1
  21. package/lib/commands/database-get.js +4 -3
  22. package/lib/commands/database-instances-create.js +2 -1
  23. package/lib/commands/database-instances-list.js +3 -3
  24. package/lib/commands/database-profile.js +4 -4
  25. package/lib/commands/database-push.js +4 -4
  26. package/lib/commands/database-remove.js +3 -3
  27. package/lib/commands/database-rules-canary.js +2 -1
  28. package/lib/commands/database-rules-get.js +2 -1
  29. package/lib/commands/database-rules-list.js +2 -1
  30. package/lib/commands/database-rules-release.js +2 -1
  31. package/lib/commands/database-rules-stage.js +2 -1
  32. package/lib/commands/database-set.js +3 -3
  33. package/lib/commands/database-settings-get.js +2 -1
  34. package/lib/commands/database-settings-set.js +2 -1
  35. package/lib/commands/database-update.js +2 -1
  36. package/lib/commands/deploy.js +26 -25
  37. package/lib/commands/emulators-exec.js +2 -1
  38. package/lib/commands/emulators-export.js +2 -1
  39. package/lib/commands/emulators-start.js +2 -1
  40. package/lib/commands/experimental-functions-shell.js +10 -8
  41. package/lib/commands/ext-configure.js +2 -1
  42. package/lib/commands/ext-dev-deprecate.js +2 -1
  43. package/lib/commands/ext-dev-emulators-exec.js +3 -2
  44. package/lib/commands/ext-dev-emulators-start.js +3 -2
  45. package/lib/commands/ext-dev-extension-delete.js +2 -1
  46. package/lib/commands/ext-dev-init.js +2 -1
  47. package/lib/commands/ext-dev-list.js +8 -8
  48. package/lib/commands/ext-dev-publish.js +2 -1
  49. package/lib/commands/ext-dev-register.js +2 -1
  50. package/lib/commands/ext-dev-undeprecate.js +2 -1
  51. package/lib/commands/ext-dev-unpublish.js +2 -1
  52. package/lib/commands/ext-dev-usage.js +2 -1
  53. package/lib/commands/ext-export.js +2 -1
  54. package/lib/commands/ext-info.js +14 -14
  55. package/lib/commands/ext-install.js +2 -1
  56. package/lib/commands/ext-list.js +2 -1
  57. package/lib/commands/ext-sources-create.js +2 -1
  58. package/lib/commands/ext-uninstall.js +2 -1
  59. package/lib/commands/ext-update.js +2 -1
  60. package/lib/commands/ext.js +4 -4
  61. package/lib/commands/firestore-delete.js +2 -1
  62. package/lib/commands/firestore-indexes-list.js +2 -1
  63. package/lib/commands/functions-config-clone.js +4 -3
  64. package/lib/commands/functions-config-export.js +2 -1
  65. package/lib/commands/functions-config-get.js +2 -1
  66. package/lib/commands/functions-config-set.js +2 -1
  67. package/lib/commands/functions-config-unset.js +2 -1
  68. package/lib/commands/functions-delete.js +3 -8
  69. package/lib/commands/functions-deletegcfartifacts.js +2 -1
  70. package/lib/commands/functions-list.js +2 -1
  71. package/lib/commands/functions-log.js +2 -1
  72. package/lib/commands/functions-secrets-access.js +2 -1
  73. package/lib/commands/functions-secrets-destroy.js +2 -1
  74. package/lib/commands/functions-secrets-get.js +2 -1
  75. package/lib/commands/functions-secrets-prune.js +2 -1
  76. package/lib/commands/functions-secrets-set.js +2 -1
  77. package/lib/commands/functions-shell.js +12 -10
  78. package/lib/commands/help.js +2 -1
  79. package/lib/commands/hosting-channel-create.js +2 -1
  80. package/lib/commands/hosting-channel-delete.js +2 -1
  81. package/lib/commands/hosting-channel-deploy.js +2 -1
  82. package/lib/commands/hosting-channel-list.js +2 -1
  83. package/lib/commands/hosting-channel-open.js +2 -1
  84. package/lib/commands/hosting-clone.js +2 -1
  85. package/lib/commands/hosting-disable.js +2 -1
  86. package/lib/commands/hosting-sites-create.js +2 -1
  87. package/lib/commands/hosting-sites-delete.js +2 -1
  88. package/lib/commands/hosting-sites-get.js +2 -1
  89. package/lib/commands/hosting-sites-list.js +2 -1
  90. package/lib/commands/index.js +23 -13
  91. package/lib/commands/init.js +47 -43
  92. package/lib/commands/login-add.js +2 -1
  93. package/lib/commands/login-ci.js +2 -1
  94. package/lib/commands/login-list.js +2 -1
  95. package/lib/commands/login-use.js +2 -1
  96. package/lib/commands/login.js +2 -1
  97. package/lib/commands/logout.js +2 -1
  98. package/lib/commands/open.js +7 -7
  99. package/lib/commands/projects-addfirebase.js +2 -1
  100. package/lib/commands/projects-create.js +2 -1
  101. package/lib/commands/projects-list.js +2 -1
  102. package/lib/commands/remoteconfig-get.js +2 -1
  103. package/lib/commands/remoteconfig-rollback.js +2 -1
  104. package/lib/commands/remoteconfig-versions-list.js +2 -1
  105. package/lib/commands/serve.js +30 -30
  106. package/lib/commands/setup-emulators-database.js +2 -1
  107. package/lib/commands/setup-emulators-firestore.js +2 -1
  108. package/lib/commands/setup-emulators-pubsub.js +2 -1
  109. package/lib/commands/setup-emulators-storage.js +2 -1
  110. package/lib/commands/setup-emulators-ui.js +2 -1
  111. package/lib/commands/target-apply.js +2 -1
  112. package/lib/commands/target-clear.js +2 -1
  113. package/lib/commands/target-remove.js +2 -1
  114. package/lib/commands/target.js +2 -1
  115. package/lib/commands/use.js +54 -53
  116. package/lib/config.js +7 -6
  117. package/lib/deploy/database/deploy.js +3 -2
  118. package/lib/deploy/database/index.js +8 -5
  119. package/lib/deploy/database/prepare.js +22 -20
  120. package/lib/deploy/database/release.js +12 -9
  121. package/lib/deploy/extensions/secrets.js +3 -3
  122. package/lib/deploy/firestore/prepare.js +2 -2
  123. package/lib/deploy/functions/build.js +33 -20
  124. package/lib/deploy/functions/ensure.js +1 -11
  125. package/lib/deploy/functions/prepare.js +3 -13
  126. package/lib/deploy/functions/prepareFunctionsUpload.js +2 -3
  127. package/lib/deploy/functions/release/fabricator.js +0 -1
  128. package/lib/deploy/functions/release/index.js +1 -5
  129. package/lib/deploy/functions/runtimes/discovery/index.js +18 -3
  130. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +188 -54
  131. package/lib/deploy/functions/runtimes/golang/index.js +2 -22
  132. package/lib/deploy/functions/runtimes/node/index.js +3 -7
  133. package/lib/deploy/functions/runtimes/node/parseTriggers.js +16 -4
  134. package/lib/deploy/functions/services/database.js +14 -0
  135. package/lib/deploy/functions/services/index.js +14 -0
  136. package/lib/deploy/index.js +3 -3
  137. package/lib/deploy/lifecycleHooks.js +27 -27
  138. package/lib/deploy/remoteconfig/prepare.js +2 -2
  139. package/lib/deploy/storage/prepare.js +1 -1
  140. package/lib/emulator/auth/apiSpec.js +14 -46
  141. package/lib/emulator/auth/index.js +1 -1
  142. package/lib/emulator/auth/operations.js +342 -93
  143. package/lib/emulator/auth/server.js +2 -2
  144. package/lib/emulator/auth/state.js +34 -32
  145. package/lib/emulator/commandUtils.js +1 -1
  146. package/lib/emulator/constants.js +1 -1
  147. package/lib/emulator/controller.js +7 -6
  148. package/lib/emulator/databaseEmulator.js +4 -4
  149. package/lib/emulator/download.js +1 -1
  150. package/lib/emulator/downloadableEmulators.js +5 -5
  151. package/lib/emulator/events/types.js +2 -3
  152. package/lib/emulator/firestoreEmulator.js +2 -2
  153. package/lib/emulator/functionsEmulator.js +31 -45
  154. package/lib/emulator/functionsEmulatorRuntime.js +12 -16
  155. package/lib/emulator/functionsEmulatorShared.js +7 -5
  156. package/lib/emulator/functionsRuntimeWorker.js +0 -6
  157. package/lib/emulator/hostingEmulator.js +1 -1
  158. package/lib/emulator/hub.js +1 -1
  159. package/lib/emulator/loggingEmulator.js +1 -1
  160. package/lib/emulator/pubsubEmulator.js +1 -1
  161. package/lib/emulator/storage/crc.js +4 -4
  162. package/lib/emulator/storage/index.js +1 -1
  163. package/lib/emulator/types.js +1 -1
  164. package/lib/errorOut.js +2 -2
  165. package/lib/extensions/askUserForConsent.js +1 -2
  166. package/lib/extensions/askUserForParam.js +15 -18
  167. package/lib/extensions/emulator/optionsHelper.js +4 -4
  168. package/lib/extensions/extensionsApi.js +1 -22
  169. package/lib/extensions/extensionsHelper.js +6 -6
  170. package/lib/extensions/listExtensions.js +9 -10
  171. package/lib/extensions/manifest.js +2 -2
  172. package/lib/extensions/resolveSource.js +11 -7
  173. package/lib/extensions/secretsUtils.js +3 -3
  174. package/lib/extensions/types.js +24 -0
  175. package/lib/extensions/updateHelper.js +1 -1
  176. package/lib/extensions/utils.js +1 -2
  177. package/lib/extensions/warnings.js +3 -3
  178. package/lib/firestore/encodeFirestoreValue.js +11 -8
  179. package/lib/fsAsync.js +3 -3
  180. package/lib/functions/events/v2.js +7 -1
  181. package/lib/functionsConfig.js +17 -14
  182. package/lib/functionsConfigClone.js +46 -46
  183. package/lib/gcp/cloudfunctions.js +2 -15
  184. package/lib/gcp/cloudfunctionsv2.js +17 -2
  185. package/lib/gcp/iam.js +1 -1
  186. package/lib/gcp/index.js +10 -10
  187. package/lib/gcp/rules.js +1 -1
  188. package/lib/gcp/runtimeconfig.js +45 -47
  189. package/lib/hosting/proxy.js +1 -1
  190. package/lib/index.js +29 -28
  191. package/lib/init/features/database.js +10 -2
  192. package/lib/init/features/functions/index.js +1 -1
  193. package/lib/init/features/functions/javascript.js +23 -20
  194. package/lib/init/features/functions/npm-dependencies.js +17 -14
  195. package/lib/init/features/functions/typescript.js +27 -24
  196. package/lib/init/features/hosting/github.js +6 -5
  197. package/lib/init/features/hosting/index.js +2 -2
  198. package/lib/loadCJSON.js +9 -6
  199. package/lib/localFunction.js +4 -4
  200. package/lib/logError.js +15 -12
  201. package/lib/parseBoltRules.js +15 -14
  202. package/lib/previews.js +1 -1
  203. package/lib/profileReport.js +504 -512
  204. package/lib/profiler.js +4 -4
  205. package/lib/prompt.js +1 -2
  206. package/lib/rc.js +1 -1
  207. package/lib/requireAuth.js +0 -1
  208. package/lib/responseToError.js +8 -5
  209. package/lib/rulesDeploy.js +2 -2
  210. package/lib/scopes.js +9 -9
  211. package/lib/serve/index.js +4 -5
  212. package/lib/utils.js +30 -6
  213. package/npm-shrinkwrap.json +537 -193
  214. package/package.json +17 -14
@@ -381,12 +381,12 @@ function wrapValidateBody(pluginContext) {
381
381
  if (op.validateBody && !op._authEmulatorValidateBodyWrapped) {
382
382
  const validateBody = op.validateBody.bind(op);
383
383
  op.validateBody = (body) => {
384
- return validateAndFixRestMappingRequestBody(validateBody, body, pluginContext.api);
384
+ return validateAndFixRestMappingRequestBody(validateBody, body);
385
385
  };
386
386
  op._authEmulatorValidateBodyWrapped = true;
387
387
  }
388
388
  }
389
- function validateAndFixRestMappingRequestBody(validate, body, api) {
389
+ function validateAndFixRestMappingRequestBody(validate, body) {
390
390
  var _a;
391
391
  body = convertKeysToCamelCase(body);
392
392
  let result;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeRefreshToken = exports.encodeRefreshToken = exports.BlockingFunctionEvents = exports.UsageMode = exports.TenantProjectState = exports.AgentProjectState = exports.ProjectState = exports.SIGNIN_METHOD_EMAIL_LINK = exports.PROVIDER_GAME_CENTER = exports.PROVIDER_CUSTOM = exports.PROVIDER_ANONYMOUS = exports.PROVIDER_PHONE = exports.PROVIDER_PASSWORD = void 0;
3
+ exports.decodeRefreshToken = exports.encodeRefreshToken = exports.BlockingFunctionEvents = exports.TenantProjectState = exports.AgentProjectState = exports.ProjectState = exports.SIGNIN_METHOD_EMAIL_LINK = exports.PROVIDER_GAME_CENTER = exports.PROVIDER_CUSTOM = exports.PROVIDER_ANONYMOUS = exports.PROVIDER_PHONE = exports.PROVIDER_PASSWORD = void 0;
4
4
  const utils_1 = require("./utils");
5
5
  const cloudFunctions_1 = require("./cloudFunctions");
6
6
  const errors_1 = require("./errors");
@@ -22,16 +22,17 @@ class ProjectState {
22
22
  this.oobs = new Map();
23
23
  this.verificationCodes = new Map();
24
24
  this.temporaryProofs = new Map();
25
+ this.pendingLocalIds = new Set();
25
26
  }
26
27
  get projectNumber() {
27
28
  return "12345";
28
29
  }
29
- createUser(props) {
30
+ generateLocalId() {
30
31
  for (let i = 0; i < 10; i++) {
31
32
  const localId = (0, utils_1.randomId)(28);
32
- const user = this.createUserWithLocalId(localId, props);
33
- if (user) {
34
- return user;
33
+ if (!this.users.has(localId) && !this.pendingLocalIds.has(localId)) {
34
+ this.pendingLocalIds.add(localId);
35
+ return localId;
35
36
  }
36
37
  }
37
38
  throw new Error("Cannot generate a random unique localId after 10 tries.");
@@ -40,12 +41,10 @@ class ProjectState {
40
41
  if (this.users.has(localId)) {
41
42
  return undefined;
42
43
  }
43
- const timestamp = new Date();
44
44
  this.users.set(localId, {
45
45
  localId,
46
- createdAt: props.createdAt || timestamp.getTime().toString(),
47
- lastLoginAt: timestamp.getTime().toString(),
48
46
  });
47
+ this.pendingLocalIds.delete(localId);
49
48
  const user = this.updateUserByLocalId(localId, props, {
50
49
  upsertProviders: props.providerUserInfo,
51
50
  });
@@ -412,7 +411,6 @@ class AgentProjectState extends ProjectState {
412
411
  this._authCloudFunction = new cloudFunctions_1.AuthCloudFunction(this.projectId);
413
412
  this._config = {
414
413
  signIn: { allowDuplicateEmails: false },
415
- usageMode: UsageMode.DEFAULT,
416
414
  blockingFunctions: {},
417
415
  };
418
416
  }
@@ -425,12 +423,6 @@ class AgentProjectState extends ProjectState {
425
423
  set oneAccountPerEmail(oneAccountPerEmail) {
426
424
  this._config.signIn.allowDuplicateEmails = !oneAccountPerEmail;
427
425
  }
428
- get usageMode() {
429
- return this._config.usageMode;
430
- }
431
- set usageMode(usageMode) {
432
- this._config.usageMode = usageMode;
433
- }
434
426
  get allowPasswordSignup() {
435
427
  return true;
436
428
  }
@@ -455,18 +447,31 @@ class AgentProjectState extends ProjectState {
455
447
  set blockingFunctionsConfig(blockingFunctions) {
456
448
  this._config.blockingFunctions = blockingFunctions;
457
449
  }
458
- updateConfig(update, updateMask) {
459
- var _a, _b, _c, _d;
460
- if (update.usageMode) {
461
- (0, errors_1.assert)(update.usageMode !== UsageMode.USAGE_MODE_UNSPECIFIED, "INVALID_USAGE_MODE: ((Invalid usage mode provided.))");
462
- if (update.usageMode === UsageMode.PASSTHROUGH) {
463
- (0, errors_1.assert)(this.getUserCount() === 0, "USERS_STILL_EXIST: ((Users are present, unable to set passthrough mode.))");
464
- }
450
+ shouldForwardCredentialToBlockingFunction(type) {
451
+ var _a, _b, _c, _d, _e, _f;
452
+ switch (type) {
453
+ case "accessToken":
454
+ return (_b = (_a = this._config.blockingFunctions.forwardInboundCredentials) === null || _a === void 0 ? void 0 : _a.accessToken) !== null && _b !== void 0 ? _b : false;
455
+ case "idToken":
456
+ return (_d = (_c = this._config.blockingFunctions.forwardInboundCredentials) === null || _c === void 0 ? void 0 : _c.idToken) !== null && _d !== void 0 ? _d : false;
457
+ case "refreshToken":
458
+ return (_f = (_e = this._config.blockingFunctions.forwardInboundCredentials) === null || _e === void 0 ? void 0 : _e.refreshToken) !== null && _f !== void 0 ? _f : false;
465
459
  }
460
+ }
461
+ getBlockingFunctionUri(event) {
462
+ const triggers = this.blockingFunctionsConfig.triggers;
463
+ if (triggers) {
464
+ return Object.prototype.hasOwnProperty.call(triggers, event)
465
+ ? triggers[event].functionUri
466
+ : undefined;
467
+ }
468
+ return undefined;
469
+ }
470
+ updateConfig(update, updateMask) {
471
+ var _a, _b, _c;
466
472
  if (!updateMask) {
467
473
  this.oneAccountPerEmail = (_b = !((_a = update.signIn) === null || _a === void 0 ? void 0 : _a.allowDuplicateEmails)) !== null && _b !== void 0 ? _b : true;
468
474
  this.blockingFunctionsConfig = (_c = update.blockingFunctions) !== null && _c !== void 0 ? _c : {};
469
- this.usageMode = (_d = update.usageMode) !== null && _d !== void 0 ? _d : UsageMode.DEFAULT;
470
475
  return this.config;
471
476
  }
472
477
  return applyMask(updateMask, this.config, update);
@@ -542,9 +547,6 @@ class TenantProjectState extends ProjectState {
542
547
  get authCloudFunction() {
543
548
  return this.parentProject.authCloudFunction;
544
549
  }
545
- get usageMode() {
546
- return this.parentProject.usageMode;
547
- }
548
550
  get tenantConfig() {
549
551
  return this._tenantConfig;
550
552
  }
@@ -563,6 +565,12 @@ class TenantProjectState extends ProjectState {
563
565
  get enableEmailLinkSignin() {
564
566
  return this._tenantConfig.enableEmailLinkSignin;
565
567
  }
568
+ shouldForwardCredentialToBlockingFunction(type) {
569
+ return this.parentProject.shouldForwardCredentialToBlockingFunction(type);
570
+ }
571
+ getBlockingFunctionUri(event) {
572
+ return this.parentProject.getBlockingFunctionUri(event);
573
+ }
566
574
  delete() {
567
575
  this.parentProject.deleteTenant(this.tenantId);
568
576
  }
@@ -592,12 +600,6 @@ class TenantProjectState extends ProjectState {
592
600
  }
593
601
  }
594
602
  exports.TenantProjectState = TenantProjectState;
595
- var UsageMode;
596
- (function (UsageMode) {
597
- UsageMode["USAGE_MODE_UNSPECIFIED"] = "USAGE_MODE_UNSPECIFIED";
598
- UsageMode["DEFAULT"] = "DEFAULT";
599
- UsageMode["PASSTHROUGH"] = "PASSTHROUGH";
600
- })(UsageMode = exports.UsageMode || (exports.UsageMode = {}));
601
603
  var BlockingFunctionEvents;
602
604
  (function (BlockingFunctionEvents) {
603
605
  BlockingFunctionEvents["BEFORE_CREATE"] = "beforeCreate";
@@ -76,7 +76,7 @@ function warnEmulatorNotSupported(options, emulator) {
76
76
  type: "confirm",
77
77
  default: false,
78
78
  message: "Do you want to continue?",
79
- }).then((confirm) => {
79
+ }).then(() => {
80
80
  if (!opts.confirm) {
81
81
  return utils.reject("Command aborted.", { exit: 1 });
82
82
  }
@@ -67,7 +67,7 @@ class Constants {
67
67
  return service;
68
68
  }
69
69
  }
70
- static getDefaultHost(emulator) {
70
+ static getDefaultHost() {
71
71
  return DEFAULT_HOST;
72
72
  }
73
73
  static getDefaultPort(emulator) {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.exportEmulatorData = exports.startAll = exports.shouldStart = exports.filterEmulatorTargets = exports.cleanShutdown = exports.onExit = exports.exportOnExit = exports.startEmulator = void 0;
4
- const _ = require("lodash");
5
4
  const clc = require("cli-color");
6
5
  const fs = require("fs");
7
6
  const path = require("path");
@@ -47,7 +46,7 @@ async function getAndCheckAddress(emulator, options) {
47
46
  if (emulator === types_1.Emulators.EXTENSIONS) {
48
47
  emulator = types_1.Emulators.FUNCTIONS;
49
48
  }
50
- let host = ((_b = (_a = options.config.src.emulators) === null || _a === void 0 ? void 0 : _a[emulator]) === null || _b === void 0 ? void 0 : _b.host) || constants_1.Constants.getDefaultHost(emulator);
49
+ let host = ((_b = (_a = options.config.src.emulators) === null || _a === void 0 ? void 0 : _a[emulator]) === null || _b === void 0 ? void 0 : _b.host) || constants_1.Constants.getDefaultHost();
51
50
  if (host === "localhost" && utils.isRunningInWSL()) {
52
51
  host = "127.0.0.1";
53
52
  }
@@ -135,7 +134,7 @@ function filterEmulatorTargets(options) {
135
134
  const only = onlyOptions.split(",").map((o) => {
136
135
  return o.split(":")[0];
137
136
  });
138
- targets = _.intersection(targets, only);
137
+ targets = targets.filter((t) => only.includes(t));
139
138
  }
140
139
  return targets;
141
140
  }
@@ -234,7 +233,7 @@ async function startAll(options, showUI = true) {
234
233
  const requested = onlyOptions.split(",").map((o) => {
235
234
  return o.split(":")[0];
236
235
  });
237
- const ignored = _.difference(requested, targets);
236
+ const ignored = requested.filter((k) => !targets.includes(k));
238
237
  for (const name of ignored) {
239
238
  if ((0, types_1.isEmulator)(name)) {
240
239
  emulatorLogger_1.EmulatorLogger.forEmulator(name).logLabeled("WARN", name, `Not starting the ${clc.bold(name)} emulator, make sure you have run ${clc.bold("firebase init")}.`);
@@ -246,7 +245,7 @@ async function startAll(options, showUI = true) {
246
245
  }
247
246
  if (previews_1.previews.frameworkawareness) {
248
247
  const config = options.config.get("hosting");
249
- if (Array.isArray(config) ? config.some((it) => it.source) : config.source) {
248
+ if (Array.isArray(config) ? config.some((it) => it.source) : config === null || config === void 0 ? void 0 : config.source) {
250
249
  await (0, frameworks_1.prepareFrameworks)(targets, options, options);
251
250
  }
252
251
  }
@@ -473,7 +472,9 @@ async function startAll(options, showUI = true) {
473
472
  await startEmulator(hostingEmulator);
474
473
  }
475
474
  if (showUI && !shouldStart(options, types_1.Emulators.UI)) {
476
- hubLogger.logLabeled("WARN", "emulators", "The Emulator UI requires a project ID to start. Configure your default project with 'firebase use' or pass the --project flag.");
475
+ hubLogger.logLabeled("WARN", "emulators", "The Emulator UI is not starting, either because none of the emulated " +
476
+ "products have an interaction layer in Emulator UI or it cannot " +
477
+ "determine the Project ID. Pass the --project flag to specify a project.");
477
478
  }
478
479
  if (showUI && (shouldStart(options, types_1.Emulators.UI) || START_LOGGING_EMULATOR)) {
479
480
  const loggingAddr = await getAndCheckAddress(types_1.Emulators.LOGGING, options);
@@ -12,7 +12,7 @@ const constants_1 = require("./constants");
12
12
  const registry_1 = require("./registry");
13
13
  const emulatorLogger_1 = require("./emulatorLogger");
14
14
  const error_1 = require("../error");
15
- const parseBoltRules = require("../parseBoltRules");
15
+ const parseBoltRules_1 = require("../parseBoltRules");
16
16
  const apiv2_1 = require("../apiv2");
17
17
  class DatabaseEmulator {
18
18
  constructor(args) {
@@ -34,7 +34,7 @@ class DatabaseEmulator {
34
34
  continue;
35
35
  }
36
36
  this.rulesWatcher = chokidar.watch(c.rules, { persistent: true, ignoreInitial: true });
37
- this.rulesWatcher.on("change", async (event, stats) => {
37
+ this.rulesWatcher.on("change", async () => {
38
38
  await new Promise((res) => setTimeout(res, 5));
39
39
  this.logger.logLabeled("BULLET", "database", `Change detected, updating rules for ${c.instance}...`);
40
40
  try {
@@ -72,7 +72,7 @@ class DatabaseEmulator {
72
72
  return downloadableEmulators.stop(types_1.Emulators.DATABASE);
73
73
  }
74
74
  getInfo() {
75
- const host = this.args.host || constants_1.Constants.getDefaultHost(types_1.Emulators.DATABASE);
75
+ const host = this.args.host || constants_1.Constants.getDefaultHost();
76
76
  const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.DATABASE);
77
77
  return {
78
78
  name: this.getName(),
@@ -125,7 +125,7 @@ class DatabaseEmulator {
125
125
  var _a;
126
126
  const rulesExt = path.extname(rulesPath);
127
127
  const content = rulesExt === ".bolt"
128
- ? parseBoltRules(rulesPath).toString()
128
+ ? (0, parseBoltRules_1.parseBoltRules)(rulesPath).toString()
129
129
  : fs.readFileSync(rulesPath, "utf8");
130
130
  const info = this.getInfo();
131
131
  try {
@@ -34,7 +34,7 @@ async function downloadEmulator(name) {
34
34
  exports.downloadEmulator = downloadEmulator;
35
35
  async function downloadExtensionVersion(extensionVersionRef, sourceDownloadUri, targetDir) {
36
36
  const emulatorLogger = emulatorLogger_1.EmulatorLogger.forExtension({ ref: extensionVersionRef });
37
- emulatorLogger.logLabeled("BULLET", "extensions", `Starting download for ${extensionVersionRef} source code...`);
37
+ emulatorLogger.logLabeled("BULLET", "extensions", `Starting download for ${extensionVersionRef} source code to ${targetDir}..`);
38
38
  try {
39
39
  fs.mkdirSync(targetDir);
40
40
  }
@@ -29,13 +29,13 @@ exports.DownloadDetails = {
29
29
  },
30
30
  },
31
31
  firestore: {
32
- downloadPath: path.join(CACHE_DIR, "cloud-firestore-emulator-v1.14.3.jar"),
33
- version: "1.14.3",
32
+ downloadPath: path.join(CACHE_DIR, "cloud-firestore-emulator-v1.14.4.jar"),
33
+ version: "1.14.4",
34
34
  opts: {
35
35
  cacheDir: CACHE_DIR,
36
- remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.14.3.jar",
37
- expectedSize: 60442855,
38
- expectedChecksum: "63517534875818689639ee5dee57dd52",
36
+ remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.14.4.jar",
37
+ expectedSize: 61017177,
38
+ expectedChecksum: "953d10e73798484aa0b84c45005faadb",
39
39
  namePrefix: "cloud-firestore-emulator",
40
40
  },
41
41
  },
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventUtils = void 0;
4
- const _ = require("lodash");
5
4
  class EventUtils {
6
5
  static isEvent(proto) {
7
- return _.has(proto, "context") && _.has(proto, "data");
6
+ return proto.context && proto.data;
8
7
  }
9
8
  static isLegacyEvent(proto) {
10
- return _.has(proto, "data") && _.has(proto, "resource");
9
+ return proto.data && proto.resource;
11
10
  }
12
11
  static isBinaryCloudEvent(req) {
13
12
  return !!(req.header("ce-type") &&
@@ -23,7 +23,7 @@ class FirestoreEmulator {
23
23
  if (this.args.rules && this.args.projectId) {
24
24
  const rulesPath = this.args.rules;
25
25
  this.rulesWatcher = chokidar.watch(rulesPath, { persistent: true, ignoreInitial: true });
26
- this.rulesWatcher.on("change", async (event, stats) => {
26
+ this.rulesWatcher.on("change", async () => {
27
27
  await new Promise((res) => setTimeout(res, 5));
28
28
  utils.logLabeledBullet("firestore", "Change detected, updating rules...");
29
29
  const newContent = fs.readFileSync(rulesPath, "utf8").toString();
@@ -53,7 +53,7 @@ class FirestoreEmulator {
53
53
  return downloadableEmulators.stop(types_1.Emulators.FIRESTORE);
54
54
  }
55
55
  getInfo() {
56
- const host = this.args.host || constants_1.Constants.getDefaultHost(types_1.Emulators.FIRESTORE);
56
+ const host = this.args.host || constants_1.Constants.getDefaultHost();
57
57
  const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.FIRESTORE);
58
58
  return {
59
59
  name: this.getName(),
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FunctionsEmulator = void 0;
4
- const _ = require("lodash");
5
4
  const fs = require("fs");
6
5
  const path = require("path");
7
6
  const express = require("express");
@@ -34,6 +33,7 @@ const backend = require("../deploy/functions/backend");
34
33
  const functionsEnv = require("../functions/env");
35
34
  const v1_1 = require("../functions/events/v1");
36
35
  const apiv2_1 = require("../apiv2");
36
+ const build_1 = require("../deploy/functions/build");
37
37
  const EVENT_INVOKE = "functions:invoke";
38
38
  const DATABASE_PATH_PATTERN = new RegExp("^projects/[^/]+/instances/([^/]+)/refs(/.*)$");
39
39
  class FunctionsEmulator {
@@ -43,6 +43,7 @@ class FunctionsEmulator {
43
43
  this.triggerGeneration = 0;
44
44
  this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FUNCTIONS);
45
45
  this.multicastTriggers = {};
46
+ this.blockingFunctionsConfig = {};
46
47
  emulatorLogger_1.EmulatorLogger.verbosity = this.args.quiet ? emulatorLogger_1.Verbosity.QUIET : emulatorLogger_1.Verbosity.DEBUG;
47
48
  if (this.args.debugPort) {
48
49
  this.args.disabledRuntimeFeatures = this.args.disabledRuntimeFeatures || {};
@@ -54,16 +55,6 @@ class FunctionsEmulator {
54
55
  : types_1.FunctionsExecutionMode.AUTO;
55
56
  this.workerPool = new functionsRuntimeWorker_1.RuntimeWorkerPool(mode);
56
57
  this.workQueue = new workQueue_1.WorkQueue(mode);
57
- this.blockingFunctionsConfig = {
58
- triggers: {
59
- beforeCreate: {
60
- functionUri: "",
61
- },
62
- beforeSignIn: {
63
- functionUri: "",
64
- },
65
- },
66
- };
67
58
  }
68
59
  static getHttpFunctionUrl(host, port, projectId, name, region) {
69
60
  return `http://${host}:${port}/${projectId}/${region}/${name}`;
@@ -105,7 +96,6 @@ class FunctionsEmulator {
105
96
  const listBackendsRoute = `/backends`;
106
97
  const backgroundHandler = (req, res) => {
107
98
  var _a;
108
- const region = req.params.region;
109
99
  const triggerId = req.params.trigger_name;
110
100
  const projectId = req.params.project_id;
111
101
  const reqBody = req.rawBody;
@@ -232,7 +222,7 @@ class FunctionsEmulator {
232
222
  ],
233
223
  persistent: true,
234
224
  });
235
- const debouncedLoadTriggers = _.debounce(() => this.loadTriggers(backend), 1000);
225
+ const debouncedLoadTriggers = (0, utils_1.debounce)(() => this.loadTriggers(backend), 1000);
236
226
  watcher.on("change", (filePath) => {
237
227
  this.logger.log("DEBUG", `File ${filePath} changed, reloading triggers`);
238
228
  return debouncedLoadTriggers();
@@ -260,6 +250,7 @@ class FunctionsEmulator {
260
250
  if (!emulatableBackend.nodeBinary) {
261
251
  throw new error_1.FirebaseError(`No node binary for ${emulatableBackend.functionsDir}. This should never happen.`);
262
252
  }
253
+ this.blockingFunctionsConfig = {};
263
254
  let triggerDefinitions;
264
255
  if (emulatableBackend.predefinedTriggers) {
265
256
  triggerDefinitions = (0, functionsEmulatorShared_1.emulatedFunctionsByRegion)(emulatableBackend.predefinedTriggers, emulatableBackend.secretEnv);
@@ -280,7 +271,9 @@ class FunctionsEmulator {
280
271
  logger_1.logger.debug(`Building ${runtimeDelegate.name} source`);
281
272
  await runtimeDelegate.build();
282
273
  logger_1.logger.debug(`Analyzing ${runtimeDelegate.name} backend spec`);
283
- const discoveredBackend = await runtimeDelegate.discoverSpec(runtimeConfig, Object.assign(Object.assign(Object.assign(Object.assign({}, this.getSystemEnvs()), this.getEmulatorEnvs()), { FIREBASE_CONFIG: this.getFirebaseConfig() }), emulatableBackend.env));
274
+ const environment = Object.assign(Object.assign(Object.assign(Object.assign({}, this.getSystemEnvs()), this.getEmulatorEnvs()), { FIREBASE_CONFIG: this.getFirebaseConfig() }), emulatableBackend.env);
275
+ const discoveredBuild = await runtimeDelegate.discoverBuild(runtimeConfig, environment);
276
+ const discoveredBackend = (0, build_1.resolveBackend)(discoveredBuild, environment);
284
277
  const endpoints = backend.allEndpoints(discoveredBackend);
285
278
  (0, functionsEmulatorShared_1.prepareEndpoints)(endpoints);
286
279
  for (const e of endpoints) {
@@ -348,7 +341,7 @@ class FunctionsEmulator {
348
341
  added = this.addBlockingTrigger(url, definition.blockingTrigger);
349
342
  }
350
343
  else {
351
- this.logger.log("WARN", `Unsupported function type on ${definition.name}. Expected either httpsTrigger or eventTrigger.`);
344
+ this.logger.log("WARN", `Unsupported function type on ${definition.name}. Expected either an httpsTrigger, eventTrigger, or blockingTrigger.`);
352
345
  }
353
346
  const ignored = !added;
354
347
  this.addTriggerRecord(definition, { backend: emulatableBackend, ignored, url });
@@ -371,9 +364,8 @@ class FunctionsEmulator {
371
364
  }
372
365
  }
373
366
  async performPostLoadOperations() {
374
- var _a, _b, _c, _d;
375
- if (((_b = (_a = this.blockingFunctionsConfig.triggers) === null || _a === void 0 ? void 0 : _a.beforeCreate) === null || _b === void 0 ? void 0 : _b.functionUri) === "" &&
376
- ((_d = (_c = this.blockingFunctionsConfig.triggers) === null || _c === void 0 ? void 0 : _c.beforeSignIn) === null || _d === void 0 ? void 0 : _d.functionUri) === "") {
367
+ if (!this.blockingFunctionsConfig.triggers &&
368
+ !this.blockingFunctionsConfig.forwardInboundCredentials) {
377
369
  return;
378
370
  }
379
371
  const authEmu = registry_1.EmulatorRegistry.get(types_1.Emulators.AUTH);
@@ -500,33 +492,31 @@ class FunctionsEmulator {
500
492
  addBlockingTrigger(url, blockingTrigger) {
501
493
  logger_1.logger.debug(`addBlockingTrigger`, JSON.stringify({ blockingTrigger }));
502
494
  const eventType = blockingTrigger.eventType;
503
- if (v1_1.AUTH_BLOCKING_EVENTS.includes(eventType)) {
504
- if (blockingTrigger.eventType === v1_1.BEFORE_CREATE_EVENT) {
505
- this.blockingFunctionsConfig.triggers = Object.assign(Object.assign({}, this.blockingFunctionsConfig.triggers), { beforeCreate: {
506
- functionUri: url,
507
- } });
508
- }
509
- else {
510
- this.blockingFunctionsConfig.triggers = Object.assign(Object.assign({}, this.blockingFunctionsConfig.triggers), { beforeSignIn: {
511
- functionUri: url,
512
- } });
513
- }
514
- this.blockingFunctionsConfig.forwardInboundCredentials = {
515
- accessToken: blockingTrigger.options.accessToken,
516
- idToken: blockingTrigger.options.idToken,
517
- refreshToken: blockingTrigger.options.refreshToken,
518
- };
519
- }
520
- else {
495
+ if (!v1_1.AUTH_BLOCKING_EVENTS.includes(eventType)) {
521
496
  return false;
522
497
  }
498
+ if (blockingTrigger.eventType === v1_1.BEFORE_CREATE_EVENT) {
499
+ this.blockingFunctionsConfig.triggers = Object.assign(Object.assign({}, this.blockingFunctionsConfig.triggers), { beforeCreate: {
500
+ functionUri: url,
501
+ } });
502
+ }
503
+ else {
504
+ this.blockingFunctionsConfig.triggers = Object.assign(Object.assign({}, this.blockingFunctionsConfig.triggers), { beforeSignIn: {
505
+ functionUri: url,
506
+ } });
507
+ }
508
+ this.blockingFunctionsConfig.forwardInboundCredentials = {
509
+ accessToken: !!blockingTrigger.options.accessToken,
510
+ idToken: !!blockingTrigger.options.idToken,
511
+ refreshToken: !!blockingTrigger.options.refreshToken,
512
+ };
523
513
  return true;
524
514
  }
525
515
  getProjectId() {
526
516
  return this.args.projectId;
527
517
  }
528
518
  getInfo() {
529
- const host = this.args.host || constants_1.Constants.getDefaultHost(types_1.Emulators.FUNCTIONS);
519
+ const host = this.args.host || constants_1.Constants.getDefaultHost();
530
520
  const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.FUNCTIONS);
531
521
  return {
532
522
  name: this.getName(),
@@ -788,9 +778,10 @@ class FunctionsEmulator {
788
778
  }
789
779
  const runtimeEnv = this.getRuntimeEnvs(backend, trigger);
790
780
  const secretEnvs = await this.resolveSecretEnvs(backend, trigger);
781
+ const socketPath = (0, functionsEmulatorShared_1.getTemporarySocketPath)();
791
782
  const childProcess = spawn(opts.nodeBinary, args, {
792
783
  cwd: backend.functionsDir,
793
- env: Object.assign(Object.assign(Object.assign({ node: opts.nodeBinary }, process.env), runtimeEnv), secretEnvs),
784
+ env: Object.assign(Object.assign(Object.assign(Object.assign({ node: opts.nodeBinary }, process.env), runtimeEnv), secretEnvs), { PORT: socketPath }),
794
785
  stdio: ["pipe", "pipe", "pipe", "ipc"],
795
786
  });
796
787
  if (!childProcess.stderr) {
@@ -822,6 +813,7 @@ class FunctionsEmulator {
822
813
  }),
823
814
  events: emitter,
824
815
  cwd: backend.functionsDir,
816
+ socketPath,
825
817
  shutdown: () => {
826
818
  childProcess.kill();
827
819
  },
@@ -960,12 +952,6 @@ class FunctionsEmulator {
960
952
  await worker.waitForSocketReady();
961
953
  void (0, track_1.track)(EVENT_INVOKE, "https");
962
954
  this.logger.log("DEBUG", `[functions] Runtime ready! Sending request!`);
963
- if (!worker.lastArgs) {
964
- throw new error_1.FirebaseError("Cannot execute on a worker with no arguments");
965
- }
966
- if (!worker.lastArgs.frb.socketPath) {
967
- throw new error_1.FirebaseError(`Cannot execute on a worker without a socketPath: ${JSON.stringify(worker.lastArgs)}`);
968
- }
969
955
  const url = new url_1.URL(`${req.protocol}://${req.hostname}${req.url}`);
970
956
  const path = `${url.pathname}${url.search}`.replace(new RegExp(`\/${this.args.projectId}\/[^\/]*\/${triggerName}\/?`), "/");
971
957
  this.logger.log("DEBUG", `[functions] Got req.url=${req.url}, mapping to path=${path}`);
@@ -973,7 +959,7 @@ class FunctionsEmulator {
973
959
  method,
974
960
  path,
975
961
  headers: req.headers,
976
- socketPath: worker.lastArgs.frb.socketPath,
962
+ socketPath: worker.runtime.socketPath,
977
963
  }, (runtimeRes) => {
978
964
  function forwardStatusAndHeaders() {
979
965
  res.status(runtimeRes.statusCode || 200);
@@ -105,7 +105,7 @@ class Proxied {
105
105
  }
106
106
  }
107
107
  async function resolveDeveloperNodeModule(frb, name) {
108
- const pkg = requirePackageJson(frb);
108
+ const pkg = requirePackageJson();
109
109
  if (!pkg) {
110
110
  new types_1.EmulatorLog("SYSTEM", "missing-package-json", "").log();
111
111
  throw new Error("Could not find package.json");
@@ -159,7 +159,7 @@ async function verifyDeveloperNodeModules(frb) {
159
159
  }
160
160
  return true;
161
161
  }
162
- function requirePackageJson(frb) {
162
+ function requirePackageJson() {
163
163
  if (developerPkgJSON) {
164
164
  return developerPkgJSON;
165
165
  }
@@ -176,7 +176,7 @@ function requirePackageJson(frb) {
176
176
  return;
177
177
  }
178
178
  }
179
- function initializeNetworkFiltering(frb) {
179
+ function initializeNetworkFiltering() {
180
180
  const networkingModules = [
181
181
  { name: "http", module: require("http"), path: ["request"] },
182
182
  { name: "http", module: require("http"), path: ["get"] },
@@ -323,7 +323,7 @@ function wrapCallableHandler(handler) {
323
323
  function getDefaultConfig() {
324
324
  return JSON.parse(process.env.FIREBASE_CONFIG || "{}");
325
325
  }
326
- function initializeRuntimeConfig(frb) {
326
+ function initializeRuntimeConfig() {
327
327
  if (!process.env.CLOUD_RUNTIME_CONFIG) {
328
328
  const configPath = `${process.cwd()}/.runtimeconfig.json`;
329
329
  try {
@@ -470,7 +470,7 @@ async function initializeFunctionsConfigHelper(frb) {
470
470
  .finalize();
471
471
  const functionsModuleProxy = new Proxied(localFunctionsModule);
472
472
  const proxiedFunctionsModule = functionsModuleProxy
473
- .when("config", (target) => () => {
473
+ .when("config", () => () => {
474
474
  return proxiedConfig;
475
475
  })
476
476
  .finalize();
@@ -485,14 +485,9 @@ async function initializeFunctionsConfigHelper(frb) {
485
485
  function rawBodySaver(req, res, buf) {
486
486
  req.rawBody = buf;
487
487
  }
488
- async function processHTTPS(trigger, frb) {
488
+ async function processHTTPS(trigger) {
489
489
  const ephemeralServer = express();
490
490
  const functionRouter = express.Router();
491
- const socketPath = frb.socketPath;
492
- if (!socketPath) {
493
- new types_1.EmulatorLog("FATAL", "runtime-error", "Called processHTTPS with no socketPath").log();
494
- return;
495
- }
496
491
  await new Promise((resolveEphemeralServer, rejectEphemeralServer) => {
497
492
  const handler = async (req, res) => {
498
493
  try {
@@ -534,8 +529,9 @@ async function processHTTPS(trigger, frb) {
534
529
  }));
535
530
  functionRouter.all("*", handler);
536
531
  ephemeralServer.use([`/`, `/*`], functionRouter);
537
- logDebug(`Attempting to listen to socketPath: ${socketPath}`);
538
- const instance = ephemeralServer.listen(socketPath, () => {
532
+ logDebug(`Attempting to listen to port: ${process.env.PORT}`);
533
+ const instance = ephemeralServer.listen(process.env.PORT, () => {
534
+ logDebug(`Listening to port: ${process.env.PORT}`);
539
535
  new types_1.EmulatorLog("SYSTEM", "runtime-status", "ready", { state: "ready" }).log();
540
536
  });
541
537
  instance.on("error", rejectEphemeralServer);
@@ -640,7 +636,7 @@ async function invokeTrigger(trigger, frb) {
640
636
  await processBackground(trigger, frb, FUNCTION_SIGNATURE);
641
637
  break;
642
638
  case "http":
643
- await processHTTPS(trigger, frb);
639
+ await processHTTPS(trigger);
644
640
  break;
645
641
  }
646
642
  if (timeoutId) {
@@ -669,8 +665,8 @@ async function initializeRuntime(frb) {
669
665
  new types_1.EmulatorLog("INFO", "runtime-status", `Your functions could not be parsed due to an issue with your node_modules (see above)`).log();
670
666
  return;
671
667
  }
672
- initializeRuntimeConfig(frb);
673
- initializeNetworkFiltering(frb);
668
+ initializeRuntimeConfig();
669
+ initializeNetworkFiltering();
674
670
  await initializeFunctionsConfigHelper(frb);
675
671
  await initializeFirebaseFunctionsStubs(frb);
676
672
  await initializeFirebaseAdminStubs(frb);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toBackendInfo = exports.getSecretLocalPath = exports.getSignatureType = exports.formatHost = exports.findModuleRoot = exports.waitForBody = exports.getServiceFromEventType = exports.getFunctionService = exports.getTemporarySocketPath = exports.getEmulatedTriggersFromDefinitions = exports.emulatedFunctionsByRegion = exports.emulatedFunctionsFromEndpoints = exports.prepareEndpoints = exports.EmulatedTrigger = exports.HttpConstants = void 0;
4
- const _ = require("lodash");
5
4
  const os = require("os");
6
5
  const path = require("path");
7
6
  const fs = require("fs");
7
+ const crypto_1 = require("crypto");
8
+ const _ = require("lodash");
8
9
  const backend = require("../deploy/functions/backend");
9
10
  const constants_1 = require("./constants");
10
11
  const proto_1 = require("../gcp/proto");
@@ -142,12 +143,13 @@ function getEmulatedTriggersFromDefinitions(definitions, module) {
142
143
  }, {});
143
144
  }
144
145
  exports.getEmulatedTriggersFromDefinitions = getEmulatedTriggersFromDefinitions;
145
- function getTemporarySocketPath(pid, cwd) {
146
+ function getTemporarySocketPath() {
147
+ const rand = (0, crypto_1.randomBytes)(8).toString("hex");
146
148
  if (process.platform === "win32") {
147
- return path.join("\\\\?\\pipe", cwd, pid.toString());
149
+ return path.join("\\\\?\\pipe", `fire_emu_${rand}`);
148
150
  }
149
151
  else {
150
- return path.join(os.tmpdir(), `fire_emu_${pid.toString()}.sock`);
152
+ return path.join(os.tmpdir(), `fire_emu_${rand}.sock`);
151
153
  }
152
154
  }
153
155
  exports.getTemporarySocketPath = getTemporarySocketPath;
@@ -239,7 +241,7 @@ function formatHost(info) {
239
241
  }
240
242
  exports.formatHost = formatHost;
241
243
  function getSignatureType(def) {
242
- if (def.httpsTrigger) {
244
+ if (def.httpsTrigger || def.blockingTrigger) {
243
245
  return "http";
244
246
  }
245
247
  return def.platform === "gcfv2" ? "cloudevent" : "event";