backend-manager 5.11.6 → 5.11.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "5.11.6",
3
+ "version": "5.11.7",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "files": [
@@ -207,14 +207,61 @@ class ServeCommand extends BaseCommand {
207
207
  const certFile = certFiles.find((f) => !f.includes('-key.pem'));
208
208
 
209
209
  if (keyFile && certFile) {
210
- this.log(chalk.gray(' Using existing mkcert certificates from .temp/certs/'));
211
- return { key: keyFile, cert: certFile };
210
+ const problem = this._checkCertProblem(certFile);
211
+
212
+ if (!problem) {
213
+ this.log(chalk.gray(' Using existing mkcert certificates from .temp/certs/'));
214
+ return { key: keyFile, cert: certFile };
215
+ }
216
+
217
+ // Stale certs (expired, or issued by a DIFFERENT machine's mkcert CA — e.g.
218
+ // .temp copied over from another Mac) make browsers reject the proxy outright,
219
+ // so the only thing that responds is the internal plain-HTTP firebase port.
220
+ // Wipe and regenerate against THIS machine's trusted CA.
221
+ this.log(chalk.yellow(` Existing certificates are not usable (${problem}) — regenerating...`));
222
+ jetpack.remove(certsDir);
223
+ jetpack.dir(certsDir);
212
224
  }
213
225
 
214
226
  // Try to generate with mkcert
215
227
  return this._generateMkcertCerts(certsDir);
216
228
  }
217
229
 
230
+ // Returns a reason string when the existing cert must be regenerated, or null
231
+ // when it's usable: unexpired AND signed by this machine's trusted mkcert root CA.
232
+ _checkCertProblem(certFile) {
233
+ const { X509Certificate } = require('crypto');
234
+ const { execSync } = require('child_process');
235
+
236
+ let cert;
237
+ try {
238
+ cert = new X509Certificate(fs.readFileSync(certFile));
239
+ } catch (e) {
240
+ return 'unreadable certificate';
241
+ }
242
+
243
+ if (new Date(cert.validTo) <= new Date()) {
244
+ return `expired ${cert.validTo}`;
245
+ }
246
+
247
+ // Verify the signature chains to the CURRENT mkcert root CA. If mkcert (or its
248
+ // root) isn't available we can't verify — keep the existing certs rather than
249
+ // breaking the no-mkcert fallback path.
250
+ try {
251
+ const caRoot = execSync('mkcert -CAROOT', { encoding: 'utf8' }).trim();
252
+ const ca = new X509Certificate(fs.readFileSync(path.join(caRoot, 'rootCA.pem')));
253
+
254
+ if (!cert.verify(ca.publicKey)) {
255
+ const issuerCN = cert.issuer.split('\n').find((line) => line.startsWith('CN=')) || cert.issuer;
256
+ return `issued by a different CA (${issuerCN})`;
257
+ }
258
+ } catch (e) {
259
+ return null;
260
+ }
261
+
262
+ return null;
263
+ }
264
+
218
265
  async _generateMkcertCerts(certsDir) {
219
266
  try {
220
267
  await powertools.execute('which mkcert', { log: false });
@@ -2,5 +2,5 @@
2
2
  "env": {
3
3
  "TEST_EXTENDED_MODE": ""
4
4
  },
5
- "updatedAt": "2026-07-03T23:27:14.219Z"
5
+ "updatedAt": "2026-07-04T00:56:35.608Z"
6
6
  }
@@ -2,17 +2,11 @@ WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
2
2
  WARNING: sun.misc.Unsafe::objectFieldOffset has been called by akka.util.Unsafe (file:/Users/ian/.cache/firebase/emulators/firebase-database-emulator-v4.11.2.jar)
3
3
  WARNING: Please consider reporting this to the maintainers of class akka.util.Unsafe
4
4
  WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
5
- 16:27:21.224 [NamespaceSystem-akka.actor.default-dispatcher-4] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
6
- 16:27:21.341 [main] INFO com.firebase.server.forge.App$ - Listening at 127.0.0.1:9000
7
- 16:27:31.969 [NamespaceSystem-akka.actor.default-dispatcher-4] INFO com.firebase.core.namespace.NamespaceActor - demo-backend-manager-default-rtdb successfully activated FBKV (SurveyIdle(0)) wait: 74ms, init: 0ms
8
- 16:27:32.006 [NamespaceSystem-blocking-namespace-operation-dispatcher-6] INFO com.firebase.core.namespace.StateManager - Namespace demo-backend-manager-default-rtdb status Active to Active
9
- 16:28:15.226 [FirebaseWorkerPool-1-3] WARN com.firebase.core.persistence.backend.dummy.EmulatorMetadataPersistence - Multiple projectIds are not recommended in single project mode. Requested
10
- namespace demo-backend-manager, but the emulator is configured for demo-backend-manager-default-rtdb. To
11
- opt-out of single project mode add/set the singleProjectMode: false property in
12
- the firebase.json emulators config.
13
- 16:28:15.229 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO com.firebase.core.namespace.NamespaceActor - demo-backend-manager successfully activated FBKV (SurveyIdle(0)) wait: 1ms, init: 0ms
14
- 16:28:27.505 [Thread-0] INFO com.firebase.server.forge.App$ - Attempting graceful shutdown.
15
- 16:28:27.511 [NamespaceSystem-akka.actor.default-dispatcher-9] INFO com.firebase.core.namespace.Terminator$Terminator - 2 actors left to terminate: demo-backend-manager-default-rtdb, demo-backend-manager
16
- 16:28:27.524 [NamespaceSystem-akka.actor.default-dispatcher-9] INFO com.firebase.core.namespace.NamespaceActor - stopped namespace actor for demo-backend-manager
17
- 16:28:27.524 [NamespaceSystem-akka.actor.default-dispatcher-12] INFO com.firebase.core.namespace.NamespaceActor - stopped namespace actor for demo-backend-manager-default-rtdb
18
- 16:28:27.532 [Thread-0] INFO com.firebase.server.forge.App$ - Graceful shutdown complete.
5
+ 17:56:43.904 [NamespaceSystem-akka.actor.default-dispatcher-4] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
6
+ 17:56:44.025 [main] INFO com.firebase.server.forge.App$ - Listening at 127.0.0.1:9000
7
+ 17:56:55.055 [NamespaceSystem-akka.actor.default-dispatcher-4] INFO com.firebase.core.namespace.NamespaceActor - demo-backend-manager-default-rtdb successfully activated FBKV (SurveyIdle(0)) wait: 84ms, init: 0ms
8
+ 17:56:55.099 [NamespaceSystem-blocking-namespace-operation-dispatcher-6] INFO com.firebase.core.namespace.StateManager - Namespace demo-backend-manager-default-rtdb status Active to Active
9
+ 17:57:09.904 [Thread-0] INFO com.firebase.server.forge.App$ - Attempting graceful shutdown.
10
+ 17:57:09.909 [NamespaceSystem-akka.actor.default-dispatcher-4] INFO com.firebase.core.namespace.Terminator$Terminator - 1 actors left to terminate: demo-backend-manager-default-rtdb
11
+ 17:57:09.913 [NamespaceSystem-akka.actor.default-dispatcher-4] INFO com.firebase.core.namespace.NamespaceActor - stopped namespace actor for demo-backend-manager-default-rtdb
12
+ 17:57:09.917 [Thread-0] INFO com.firebase.server.forge.App$ - Graceful shutdown complete.