@agentvault/agentvault 0.9.7 → 0.9.8

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/dist/index.js CHANGED
@@ -46621,10 +46621,27 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
46621
46621
  this._scanEngine = new ScanEngine();
46622
46622
  await this._fetchScanRules();
46623
46623
  }
46624
- if (!this._telemetryReporter && this._persisted?.deviceJwt && this._persisted?.hubAddress) {
46624
+ if (this._persisted && this._persisted.hubAddress && !this._persisted.hubId && this._persisted.deviceJwt) {
46625
+ try {
46626
+ const listRes = await fetch(
46627
+ `${this.config.apiUrl}/api/v1/hub/identities`,
46628
+ { headers: { Authorization: `Bearer ${this._persisted.deviceJwt}` } }
46629
+ );
46630
+ if (listRes.ok) {
46631
+ const identities = await listRes.json();
46632
+ const match = identities.find((h2) => h2.hub_address === this._persisted.hubAddress);
46633
+ if (match) {
46634
+ this._persisted.hubId = match.hub_id;
46635
+ this._persistState();
46636
+ }
46637
+ }
46638
+ } catch {
46639
+ }
46640
+ }
46641
+ if (!this._telemetryReporter && this._persisted?.deviceJwt && this._persisted?.hubId) {
46625
46642
  this._telemetryReporter = new TelemetryReporter({
46626
46643
  apiBase: this.config.apiUrl,
46627
- hubId: this._persisted.hubAddress,
46644
+ hubId: this._persisted.hubId,
46628
46645
  authHeader: `Bearer ${this._persisted.deviceJwt}`
46629
46646
  });
46630
46647
  this._telemetryReporter.startAutoFlush(3e4);
@@ -46730,6 +46747,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
46730
46747
  if (data.event === "hub_identity_assigned") {
46731
46748
  if (this._persisted) {
46732
46749
  this._persisted.hubAddress = data.data.hub_address;
46750
+ this._persisted.hubId = data.data.hub_id;
46733
46751
  this._persistState();
46734
46752
  }
46735
46753
  this.emit("hub_identity_assigned", data.data);
@@ -46737,6 +46755,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
46737
46755
  if (data.event === "hub_identity_removed") {
46738
46756
  if (this._persisted) {
46739
46757
  delete this._persisted.hubAddress;
46758
+ delete this._persisted.hubId;
46740
46759
  this._persistState();
46741
46760
  }
46742
46761
  this.emit("hub_identity_removed", data.data);