@riddix/hamh 2.1.0-alpha.849 → 2.1.0-alpha.850

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.
@@ -136608,7 +136608,20 @@ var PluginRegistry = class {
136608
136608
  }
136609
136609
  };
136610
136610
 
136611
+ // src/plugins/types.ts
136612
+ var SECRET_UNCHANGED = "__unchanged__";
136613
+
136611
136614
  // src/api/plugin-api.ts
136615
+ function redactSecrets(config11, schema6) {
136616
+ if (!schema6) return config11;
136617
+ const out = { ...config11 };
136618
+ for (const [key, prop] of Object.entries(schema6.properties)) {
136619
+ if (prop.secret && out[key] != null && out[key] !== "") {
136620
+ out[key] = SECRET_UNCHANGED;
136621
+ }
136622
+ }
136623
+ return out;
136624
+ }
136612
136625
  var MAX_UPLOAD_BYTES = 50 * 1024 * 1024;
136613
136626
  var BLOCKED_PREFIXES = [
136614
136627
  "/bin",
@@ -136647,7 +136660,10 @@ function pluginApi(bridgeService, storageLocation) {
136647
136660
  version: meta.version,
136648
136661
  source: meta.source,
136649
136662
  enabled: meta.enabled,
136650
- config: meta.config,
136663
+ config: redactSecrets(
136664
+ meta.config,
136665
+ bridge.getPluginConfigSchema?.(meta.name)
136666
+ ),
136651
136667
  circuitBreaker: info.circuitBreakers[meta.name],
136652
136668
  devices: info.devices.filter((d) => d.pluginName === meta.name).map((d) => ({
136653
136669
  id: d.device.id,
@@ -156746,6 +156762,9 @@ var PluginManager = class {
156746
156762
  } else if (this.runner.getState(name).failures === 0) {
156747
156763
  instance.started = true;
156748
156764
  }
156765
+ if (instance.plugin.getCurrentConfig) {
156766
+ instance.metadata.config = instance.plugin.getCurrentConfig();
156767
+ }
156749
156768
  }
156750
156769
  }
156751
156770
  /**
@@ -156846,6 +156865,17 @@ var PluginManager = class {
156846
156865
  async updateConfig(pluginName, config11) {
156847
156866
  const instance = this.instances.get(pluginName);
156848
156867
  if (!instance) return false;
156868
+ config11 = { ...config11 };
156869
+ const schema6 = instance.plugin.getConfigSchema?.();
156870
+ if (schema6) {
156871
+ for (const [key, prop] of Object.entries(schema6.properties)) {
156872
+ if (prop.secret && config11[key] === SECRET_UNCHANGED) {
156873
+ const stored = instance.metadata.config[key];
156874
+ if (stored == null) delete config11[key];
156875
+ else config11[key] = stored;
156876
+ }
156877
+ }
156878
+ }
156849
156879
  instance.metadata.config = config11;
156850
156880
  this.registry?.updateConfig(pluginName, config11);
156851
156881
  if (instance.plugin.onConfigChanged) {
@@ -173989,6 +174019,9 @@ var CameraPlugin = class {
173989
174019
  async onShutdown() {
173990
174020
  await this.teardown();
173991
174021
  }
174022
+ getCurrentConfig() {
174023
+ return { ...this.config };
174024
+ }
173992
174025
  getConfigSchema() {
173993
174026
  return {
173994
174027
  title: "Camera",
@@ -174004,7 +174037,8 @@ var CameraPlugin = class {
174004
174037
  type: "string",
174005
174038
  title: "Long-lived access token",
174006
174039
  description: "Leave empty to use the bridge's Home Assistant connection.",
174007
- required: false
174040
+ required: false,
174041
+ secret: true
174008
174042
  },
174009
174043
  cameras: {
174010
174044
  type: "string",