@riddix/hamh 2.1.0-alpha.798 → 2.1.0-alpha.799

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.
@@ -124292,6 +124292,9 @@ var init_clusters = __esm({
124292
124292
  function classifyController(vendorId3) {
124293
124293
  return controllerByVendorId[vendorId3];
124294
124294
  }
124295
+ function alexaPairingPortProblem(vendorId3, port) {
124296
+ return classifyController(vendorId3) === "alexa" && port !== 5540;
124297
+ }
124295
124298
  function computeControllerWarnings(controllers, exposed) {
124296
124299
  const seen = /* @__PURE__ */ new Set();
124297
124300
  const warnings = [];
@@ -148999,6 +149002,9 @@ var Bridge = class {
148999
149002
  sessionAddedHandler;
149000
149003
  // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
149001
149004
  sessionDeletedHandler;
149005
+ // Warns when Alexa pairs on a non-5540 port, the fabric rolls back later (#401).
149006
+ // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
149007
+ fabricAddedHandler;
149002
149008
  get id() {
149003
149009
  return this.dataProvider.id;
149004
149010
  }
@@ -149168,6 +149174,7 @@ var Bridge = class {
149168
149174
  });
149169
149175
  }
149170
149176
  this.wireSessionDiagnostics();
149177
+ this.wireFabricWarnings();
149171
149178
  this.startSessionRotation();
149172
149179
  logMemoryUsage(this.log, "bridge running");
149173
149180
  diagnosticEventBus.emit("bridge_started", `Bridge started`, {
@@ -149193,6 +149200,7 @@ ${e?.toString()}`);
149193
149200
  }
149194
149201
  async runStop(code, reason) {
149195
149202
  this.unwireSessionDiagnostics();
149203
+ this.unwireFabricWarnings();
149196
149204
  this.stopAutoForceSync();
149197
149205
  await this.closeActiveSessions();
149198
149206
  await this.endpointManager.stopPlugins();
@@ -149530,6 +149538,35 @@ ${e?.toString()}`);
149530
149538
  this.stopSessionRotation();
149531
149539
  this.sessionStartedAt.clear();
149532
149540
  }
149541
+ // Warn at the fabric-added event when Alexa pairs on a non-5540 port. Alexa
149542
+ // completes AddNOC but never CASEs, so the fabric rolls back on failsafe
149543
+ // expiry ~20s later and the committed-fabric warning path never sees it (#401).
149544
+ wireFabricWarnings() {
149545
+ this.unwireFabricWarnings();
149546
+ try {
149547
+ const fabrics = this.server.env.get(FabricManager);
149548
+ this.fabricAddedHandler = (fabric) => {
149549
+ const port = this.dataProvider.port;
149550
+ if (alexaPairingPortProblem(fabric.rootVendorId, port)) {
149551
+ this.log.warn(
149552
+ `Fabric added by Amazon Alexa (vendor ${fabric.rootVendorId}) on port ${port}. Alexa only completes pairing on port 5540, this attempt will roll back about 20s after AddNOC. Recreate the bridge on port 5540 (#401)`
149553
+ );
149554
+ }
149555
+ };
149556
+ fabrics.events.added.on(this.fabricAddedHandler);
149557
+ } catch {
149558
+ }
149559
+ }
149560
+ unwireFabricWarnings() {
149561
+ try {
149562
+ const fabrics = this.server.env.get(FabricManager);
149563
+ if (this.fabricAddedHandler) {
149564
+ fabrics.events.added.off(this.fabricAddedHandler);
149565
+ }
149566
+ } catch {
149567
+ }
149568
+ this.fabricAddedHandler = void 0;
149569
+ }
149533
149570
  stopAutoForceSync() {
149534
149571
  if (this.autoForceSyncTimer) {
149535
149572
  clearInterval(this.autoForceSyncTimer);
@@ -165311,6 +165348,9 @@ var ServerModeBridge = class {
165311
165348
  sessionAddedHandler;
165312
165349
  // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
165313
165350
  sessionDeletedHandler;
165351
+ // Warns when Alexa pairs on a non-5540 port, the fabric rolls back later (#401).
165352
+ // biome-ignore lint/suspicious/noExplicitAny: matter.js internal types
165353
+ fabricAddedHandler;
165314
165354
  get id() {
165315
165355
  return this.dataProvider.id;
165316
165356
  }
@@ -165436,6 +165476,7 @@ var ServerModeBridge = class {
165436
165476
  });
165437
165477
  }
165438
165478
  this.wireSessionDiagnostics();
165479
+ this.wireFabricWarnings();
165439
165480
  this.startSessionRotation();
165440
165481
  this.scheduleWarmStart();
165441
165482
  logMemoryUsage(this.log, "server mode bridge running");
@@ -165454,6 +165495,7 @@ ${e?.toString()}`);
165454
165495
  async stop(code = BridgeStatus.Stopped, reason = "Manually stopped") {
165455
165496
  this.stopSessionRotation();
165456
165497
  this.unwireSessionDiagnostics();
165498
+ this.unwireFabricWarnings();
165457
165499
  this.cancelWarmStart();
165458
165500
  this.stopAutoForceSync();
165459
165501
  await this.closeActiveSessions();
@@ -165792,6 +165834,35 @@ ${e?.toString()}`);
165792
165834
  this.staleSessionTimers.clear();
165793
165835
  this.sessionStartedAt.clear();
165794
165836
  }
165837
+ // Warn at the fabric-added event when Alexa pairs on a non-5540 port. Alexa
165838
+ // completes AddNOC but never CASEs, so the fabric rolls back on failsafe
165839
+ // expiry ~20s later and the committed-fabric warning path never sees it (#401).
165840
+ wireFabricWarnings() {
165841
+ this.unwireFabricWarnings();
165842
+ try {
165843
+ const fabrics = this.server.env.get(FabricManager);
165844
+ this.fabricAddedHandler = (fabric) => {
165845
+ const port = this.dataProvider.port;
165846
+ if (alexaPairingPortProblem(fabric.rootVendorId, port)) {
165847
+ this.log.warn(
165848
+ `Fabric added by Amazon Alexa (vendor ${fabric.rootVendorId}) on port ${port}. Alexa only completes pairing on port 5540, this attempt will roll back about 20s after AddNOC. Recreate the bridge on port 5540 (#401)`
165849
+ );
165850
+ }
165851
+ };
165852
+ fabrics.events.added.on(this.fabricAddedHandler);
165853
+ } catch {
165854
+ }
165855
+ }
165856
+ unwireFabricWarnings() {
165857
+ try {
165858
+ const fabrics = this.server.env.get(FabricManager);
165859
+ if (this.fabricAddedHandler) {
165860
+ fabrics.events.added.off(this.fabricAddedHandler);
165861
+ }
165862
+ } catch {
165863
+ }
165864
+ this.fabricAddedHandler = void 0;
165865
+ }
165795
165866
  // Start the periodic age-based session rotation (#287).
165796
165867
  startSessionRotation() {
165797
165868
  this.stopSessionRotation();