@camstack/system 1.2.376 → 1.2.377

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 (92) hide show
  1. package/dist/addon-runner.js +9 -4
  2. package/dist/addon-runner.mjs +10 -5
  3. package/dist/addon-utils.js +1 -1
  4. package/dist/addon-utils.mjs +1 -1
  5. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  11. package/dist/builtins/autotrack/index.js +1 -1
  12. package/dist/builtins/autotrack/index.mjs +1 -1
  13. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  14. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  15. package/dist/builtins/calendars/calendars.addon.js +1 -1
  16. package/dist/builtins/calendars/calendars.addon.mjs +1 -1
  17. package/dist/builtins/camera-grid/index.js +1 -1
  18. package/dist/builtins/camera-grid/index.mjs +1 -1
  19. package/dist/builtins/composer/composer.addon.js +2 -2
  20. package/dist/builtins/composer/composer.addon.mjs +2 -2
  21. package/dist/builtins/console-logging/index.js +1 -1
  22. package/dist/builtins/console-logging/index.mjs +1 -1
  23. package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  24. package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  25. package/dist/builtins/device-manager/device-config-secrets.d.ts +21 -0
  26. package/dist/builtins/device-manager/device-manager.addon.js +85 -6
  27. package/dist/builtins/device-manager/device-manager.addon.mjs +85 -6
  28. package/dist/builtins/hub-forwarder/index.js +1 -1
  29. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  30. package/dist/builtins/keychain/index.d.ts +1 -0
  31. package/dist/builtins/keychain/index.js +1416 -0
  32. package/dist/builtins/keychain/index.mjs +1409 -0
  33. package/dist/builtins/keychain/key-sources.d.ts +37 -0
  34. package/dist/builtins/keychain/keychain-crypto.d.ts +28 -0
  35. package/dist/builtins/keychain/keychain-service.d.ts +103 -0
  36. package/dist/builtins/keychain/keychain-store.d.ts +82 -0
  37. package/dist/builtins/keychain/keychain-usage.d.ts +6 -0
  38. package/dist/builtins/keychain/keychain.addon.d.ts +11 -0
  39. package/dist/builtins/keychain/platform-key-source.d.ts +24 -0
  40. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  41. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  42. package/dist/builtins/local-auth/local-auth.addon.js +19 -2
  43. package/dist/builtins/local-auth/local-auth.addon.mjs +19 -2
  44. package/dist/builtins/local-network/local-network.addon.js +1 -1
  45. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  46. package/dist/builtins/loki-logging/index.js +1 -1
  47. package/dist/builtins/loki-logging/index.mjs +1 -1
  48. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  49. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  50. package/dist/builtins/platform-probe/index.js +1 -1
  51. package/dist/builtins/platform-probe/index.mjs +1 -1
  52. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  53. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  54. package/dist/builtins/snapshot/index.js +1 -1
  55. package/dist/builtins/snapshot/index.mjs +1 -1
  56. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  57. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  58. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  59. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  60. package/dist/builtins/storage-orchestrator/location-store.d.ts +6 -0
  61. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +15 -0
  62. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +74 -14
  63. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +74 -14
  64. package/dist/builtins/system-config/system-config.addon.js +1 -1
  65. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  66. package/dist/builtins/winston-logging/index.js +1 -1
  67. package/dist/builtins/winston-logging/index.mjs +1 -1
  68. package/dist/{child-cap-dispatch-8qMgog1O.mjs → child-cap-dispatch-CgmOo0yl.mjs} +170 -27
  69. package/dist/{child-cap-dispatch-BWtaSmWf.js → child-cap-dispatch-DlDSoqm1.js} +198 -25
  70. package/dist/{composition-sources-DW7CgMsg.js → composition-sources-BNyXPSs_.js} +1 -1
  71. package/dist/{composition-sources-zxQPPtP_.mjs → composition-sources-D39bl0nP.mjs} +1 -1
  72. package/dist/{dist-D732NygW.mjs → dist-BWNoS-1S.mjs} +2195 -105
  73. package/dist/{dist-BcUWQGr9.js → dist-D_a9mUiM.js} +2260 -104
  74. package/dist/{event-loop-stall-monitor-8W4yWNVW.mjs → event-loop-stall-monitor-ClPhfx7Y.mjs} +1 -1
  75. package/dist/{event-loop-stall-monitor-QX4RjNe7.js → event-loop-stall-monitor-DuOn8H1n.js} +1 -1
  76. package/dist/{hub-cap-forward-BdT320dq.mjs → hub-cap-forward-CH6_VWVO.mjs} +13 -4
  77. package/dist/{hub-cap-forward-DmHNjbB0.js → hub-cap-forward-COCmYaup.js} +13 -4
  78. package/dist/index.d.ts +2 -0
  79. package/dist/index.js +20 -6
  80. package/dist/index.mjs +13 -7
  81. package/dist/kernel/config-schema.d.ts +4 -0
  82. package/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +6 -0
  83. package/dist/kernel/transport/cap-route-resolver.d.ts +19 -0
  84. package/dist/kernel/transport/hub-cap-forward.d.ts +22 -1
  85. package/dist/kernel/transport/index.d.ts +2 -2
  86. package/dist/kernel/transport/local-child-registry.d.ts +4 -3
  87. package/dist/logging/log-redactor.d.ts +9 -0
  88. package/dist/platform-key-source-BWlq0jjn.mjs +23 -0
  89. package/dist/platform-key-source-Di7HrlGR.js +40 -0
  90. package/dist/{retired-settings-keys-MaESpO18.js → retired-settings-keys-CDyOGAje.js} +1 -1
  91. package/dist/{retired-settings-keys-CxPOg7BF.mjs → retired-settings-keys-iGcmzwLV.mjs} +1 -1
  92. package/package.json +17 -1
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BcUWQGr9.js");
7
- const require_hub_cap_forward = require("../../hub-cap-forward-DmHNjbB0.js");
6
+ const require_dist = require("../../dist-D_a9mUiM.js");
7
+ const require_hub_cap_forward = require("../../hub-cap-forward-COCmYaup.js");
8
8
  let zod = require("zod");
9
9
  let node_crypto = require("node:crypto");
10
10
  let _camstack_types_node = require("@camstack/types/node");
@@ -3474,9 +3474,10 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
3474
3474
  upsertLocation: async (input) => {
3475
3475
  const stored = service.getLocationById(input.id);
3476
3476
  const config = restoreRedactedSecrets(input.config, stored?.config, this.secretKeysFor(input.providerId, stored?.config ?? {}));
3477
- const next = config === input.config ? input : {
3477
+ const keychained = await this.keepSecretsInKeychain(input.id, input.providerId, config, stored?.config ?? {});
3478
+ const next = keychained === input.config ? input : {
3478
3479
  ...input,
3479
- config
3480
+ config: keychained
3480
3481
  };
3481
3482
  await this.carryDataOnRepoint(stored, next);
3482
3483
  const saved = service.upsertLocation(next);
@@ -3495,7 +3496,9 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
3495
3496
  error: `Location "${id}" not found`
3496
3497
  };
3497
3498
  try {
3498
- return (await service.getProviderFor(loc)).testLocation({ config: loc.config });
3499
+ const p = await service.getProviderFor(loc);
3500
+ const live = await this.withResolvedSecrets(loc);
3501
+ return p.testLocation({ config: live.config });
3499
3502
  } catch (err) {
3500
3503
  return {
3501
3504
  ok: false,
@@ -3531,7 +3534,7 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
3531
3534
  };
3532
3535
  },
3533
3536
  resolve: async ({ location, relativePath }) => {
3534
- const loc = service.resolveRef(location);
3537
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3535
3538
  this.refuseRemoteResolve(loc);
3536
3539
  return (await service.getProviderFor(loc)).resolve({
3537
3540
  location: loc,
@@ -3539,7 +3542,7 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
3539
3542
  });
3540
3543
  },
3541
3544
  write: async ({ location, relativePath, data }) => {
3542
- const loc = service.resolveRef(location);
3545
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3543
3546
  return (await service.getProviderFor(loc)).write({
3544
3547
  location: loc,
3545
3548
  relativePath,
@@ -3547,21 +3550,21 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
3547
3550
  });
3548
3551
  },
3549
3552
  read: async ({ location, relativePath }) => {
3550
- const loc = service.resolveRef(location);
3553
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3551
3554
  return (await service.getProviderFor(loc)).read({
3552
3555
  location: loc,
3553
3556
  relativePath
3554
3557
  });
3555
3558
  },
3556
3559
  exists: async ({ location, relativePath }) => {
3557
- const loc = service.resolveRef(location);
3560
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3558
3561
  return (await service.getProviderFor(loc)).exists({
3559
3562
  location: loc,
3560
3563
  relativePath
3561
3564
  });
3562
3565
  },
3563
3566
  list: async ({ location, prefix }) => {
3564
- const loc = service.resolveRef(location);
3567
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3565
3568
  const p = await service.getProviderFor(loc);
3566
3569
  return prefix !== void 0 ? p.list({
3567
3570
  location: loc,
@@ -3569,18 +3572,18 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
3569
3572
  }) : p.list({ location: loc });
3570
3573
  },
3571
3574
  delete: async ({ location, relativePath }) => {
3572
- const loc = service.resolveRef(location);
3575
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3573
3576
  return (await service.getProviderFor(loc)).delete({
3574
3577
  location: loc,
3575
3578
  relativePath
3576
3579
  });
3577
3580
  },
3578
3581
  getAvailableSpace: async ({ location }) => {
3579
- const loc = service.resolveRef(location);
3582
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3580
3583
  return (await service.getProviderFor(loc)).getAvailableSpace({ location: loc });
3581
3584
  },
3582
3585
  beginUpload: async ({ location, relativePath, sizeBytes }) => {
3583
- const loc = service.resolveRef(location);
3586
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3584
3587
  const p = await service.getProviderFor(loc);
3585
3588
  const result = sizeBytes !== void 0 ? await p.beginUpload({
3586
3589
  location: loc,
@@ -3613,7 +3616,7 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
3613
3616
  }
3614
3617
  },
3615
3618
  beginDownload: async ({ location, relativePath }) => {
3616
- const loc = service.resolveRef(location);
3619
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3617
3620
  const result = await (await service.getProviderFor(loc)).beginDownload({
3618
3621
  location: loc,
3619
3622
  relativePath
@@ -4075,6 +4078,63 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
4075
4078
  }
4076
4079
  }
4077
4080
  /** A location with its provider's declared secrets replaced by the sentinel. */
4081
+ /**
4082
+ * The location as a PROVIDER must see it: every keychain marker in its
4083
+ * config resolved (D787). The same object when it holds none — a filesystem
4084
+ * location costs nothing. An unresolvable secret is left out and logged by
4085
+ * ref; the provider then fails its own connection, by name.
4086
+ */
4087
+ async withResolvedSecrets(location) {
4088
+ const secrets = this.ctx.secrets;
4089
+ if (secrets === void 0) return location;
4090
+ const { value, unresolved } = await require_dist.resolveSecretMarkers(location.config, secrets);
4091
+ if (unresolved.length > 0) this.ctx.logger.error("storage location secret unavailable", { meta: {
4092
+ locationId: location.id,
4093
+ secrets: unresolved.map((u) => ({
4094
+ ref: u.ref,
4095
+ reason: u.reason
4096
+ }))
4097
+ } });
4098
+ return value === location.config ? location : {
4099
+ ...location,
4100
+ config: value
4101
+ };
4102
+ }
4103
+ /**
4104
+ * Strip the provider's DECLARED secrets (its form schema, by type) out of a
4105
+ * location config into the keychain, under `row/storage_locations/<id>`.
4106
+ * A provider that has not registered declares nothing: only keys that
4107
+ * already hold a marker are handled then — a new plaintext is never guessed
4108
+ * at, it stays as sent until the provider is back and the location is saved.
4109
+ */
4110
+ async keepSecretsInKeychain(locationId, providerId, config, stored) {
4111
+ const secrets = this.ctx.secrets;
4112
+ if (secrets === void 0) return config;
4113
+ const declared = this.declaredSecretKeys(providerId) ?? /* @__PURE__ */ new Set();
4114
+ const markerKeys = Object.entries(stored).filter(([, v]) => require_dist.isSecretMarker(v)).map(([k]) => k);
4115
+ const tree = require_dist.secretTreeFromPaths([...new Set([...declared, ...markerKeys])]);
4116
+ if (tree.size === 0) return config;
4117
+ const result = await require_dist.transformSecretWrite({
4118
+ tree,
4119
+ secrets,
4120
+ patch: { ...config },
4121
+ stored: { ...stored },
4122
+ scope: {
4123
+ kind: "row",
4124
+ collection: STORAGE_LOCATIONS,
4125
+ rowId: locationId
4126
+ }
4127
+ });
4128
+ const merged = { ...result.patch };
4129
+ for (const key of tree.keys()) if (!(key in merged) && key in stored) merged[key] = stored[key];
4130
+ result.afterWrite().then(({ orphaned }) => {
4131
+ if (orphaned.length > 0) this.ctx.logger.warn("storage location: dropped keychain refs could not be deleted", { meta: {
4132
+ locationId,
4133
+ refs: [...orphaned]
4134
+ } });
4135
+ });
4136
+ return merged;
4137
+ }
4078
4138
  redacted(location) {
4079
4139
  return redactLocation(location, this.secretKeysFor(location.providerId, location.config));
4080
4140
  }
@@ -1,5 +1,5 @@
1
- import { An as settingsStoreCapability, B as StorageCleanupJobSchema, Cn as resolveLocationMode, D as LegacyStorageLocationDefaultSchema, Dr as parseJsonObject, Gn as withLocationMode, H as StorageLocationTypeSchema, Ht as isLocationEnabled, It as gbToBytes, Nn as storageCapability, P as REDACTED_SECRET, Pn as storageMigrationCapability, Pr as EventCategory, U as StorageMigrationJobSchema, V as StorageLocationModeSchema, cr as BaseAddon, en as mayReadLocation, in as modeMayWrite, it as collectSecretConfigKeys, kt as evictionPolicyOfLocation, qt as legacyModeOf, tn as mayWriteToLocation } from "../../dist-D732NygW.mjs";
2
- import { t as HUB_CAP_FWD_ACTION } from "../../hub-cap-forward-BdT320dq.mjs";
1
+ import { Ar as isSecretMarker, B as StorageLocationModeSchema, Bt as isLocationEnabled, D as LegacyStorageLocationDefaultSchema, Dt as evictionPolicyOfLocation, Fn as storageMigrationCapability, Gr as EventCategory, H as StorageMigrationJobSchema, Kn as withLocationMode, Nr as parseJsonObject, Pn as storageCapability, Pt as gbToBytes, Rr as resolveSecretMarkers, V as StorageLocationTypeSchema, Vr as secretTreeFromPaths, Wr as transformSecretWrite, an as modeMayWrite, br as collectSecretConfigKeys, jn as settingsStoreCapability, lr as BaseAddon, nn as mayWriteToLocation, pr as REDACTED_SECRET, qt as legacyModeOf, tn as mayReadLocation, wn as resolveLocationMode, z as StorageCleanupJobSchema } from "../../dist-BWNoS-1S.mjs";
2
+ import { t as HUB_CAP_FWD_ACTION } from "../../hub-cap-forward-CH6_VWVO.mjs";
3
3
  import { z } from "zod";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { containsOrEquals, physicalRootOf } from "@camstack/types/node";
@@ -3469,9 +3469,10 @@ var StorageOrchestratorAddon = class extends BaseAddon {
3469
3469
  upsertLocation: async (input) => {
3470
3470
  const stored = service.getLocationById(input.id);
3471
3471
  const config = restoreRedactedSecrets(input.config, stored?.config, this.secretKeysFor(input.providerId, stored?.config ?? {}));
3472
- const next = config === input.config ? input : {
3472
+ const keychained = await this.keepSecretsInKeychain(input.id, input.providerId, config, stored?.config ?? {});
3473
+ const next = keychained === input.config ? input : {
3473
3474
  ...input,
3474
- config
3475
+ config: keychained
3475
3476
  };
3476
3477
  await this.carryDataOnRepoint(stored, next);
3477
3478
  const saved = service.upsertLocation(next);
@@ -3490,7 +3491,9 @@ var StorageOrchestratorAddon = class extends BaseAddon {
3490
3491
  error: `Location "${id}" not found`
3491
3492
  };
3492
3493
  try {
3493
- return (await service.getProviderFor(loc)).testLocation({ config: loc.config });
3494
+ const p = await service.getProviderFor(loc);
3495
+ const live = await this.withResolvedSecrets(loc);
3496
+ return p.testLocation({ config: live.config });
3494
3497
  } catch (err) {
3495
3498
  return {
3496
3499
  ok: false,
@@ -3526,7 +3529,7 @@ var StorageOrchestratorAddon = class extends BaseAddon {
3526
3529
  };
3527
3530
  },
3528
3531
  resolve: async ({ location, relativePath }) => {
3529
- const loc = service.resolveRef(location);
3532
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3530
3533
  this.refuseRemoteResolve(loc);
3531
3534
  return (await service.getProviderFor(loc)).resolve({
3532
3535
  location: loc,
@@ -3534,7 +3537,7 @@ var StorageOrchestratorAddon = class extends BaseAddon {
3534
3537
  });
3535
3538
  },
3536
3539
  write: async ({ location, relativePath, data }) => {
3537
- const loc = service.resolveRef(location);
3540
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3538
3541
  return (await service.getProviderFor(loc)).write({
3539
3542
  location: loc,
3540
3543
  relativePath,
@@ -3542,21 +3545,21 @@ var StorageOrchestratorAddon = class extends BaseAddon {
3542
3545
  });
3543
3546
  },
3544
3547
  read: async ({ location, relativePath }) => {
3545
- const loc = service.resolveRef(location);
3548
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3546
3549
  return (await service.getProviderFor(loc)).read({
3547
3550
  location: loc,
3548
3551
  relativePath
3549
3552
  });
3550
3553
  },
3551
3554
  exists: async ({ location, relativePath }) => {
3552
- const loc = service.resolveRef(location);
3555
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3553
3556
  return (await service.getProviderFor(loc)).exists({
3554
3557
  location: loc,
3555
3558
  relativePath
3556
3559
  });
3557
3560
  },
3558
3561
  list: async ({ location, prefix }) => {
3559
- const loc = service.resolveRef(location);
3562
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3560
3563
  const p = await service.getProviderFor(loc);
3561
3564
  return prefix !== void 0 ? p.list({
3562
3565
  location: loc,
@@ -3564,18 +3567,18 @@ var StorageOrchestratorAddon = class extends BaseAddon {
3564
3567
  }) : p.list({ location: loc });
3565
3568
  },
3566
3569
  delete: async ({ location, relativePath }) => {
3567
- const loc = service.resolveRef(location);
3570
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3568
3571
  return (await service.getProviderFor(loc)).delete({
3569
3572
  location: loc,
3570
3573
  relativePath
3571
3574
  });
3572
3575
  },
3573
3576
  getAvailableSpace: async ({ location }) => {
3574
- const loc = service.resolveRef(location);
3577
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3575
3578
  return (await service.getProviderFor(loc)).getAvailableSpace({ location: loc });
3576
3579
  },
3577
3580
  beginUpload: async ({ location, relativePath, sizeBytes }) => {
3578
- const loc = service.resolveRef(location);
3581
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3579
3582
  const p = await service.getProviderFor(loc);
3580
3583
  const result = sizeBytes !== void 0 ? await p.beginUpload({
3581
3584
  location: loc,
@@ -3608,7 +3611,7 @@ var StorageOrchestratorAddon = class extends BaseAddon {
3608
3611
  }
3609
3612
  },
3610
3613
  beginDownload: async ({ location, relativePath }) => {
3611
- const loc = service.resolveRef(location);
3614
+ const loc = await this.withResolvedSecrets(service.resolveRef(location));
3612
3615
  const result = await (await service.getProviderFor(loc)).beginDownload({
3613
3616
  location: loc,
3614
3617
  relativePath
@@ -4070,6 +4073,63 @@ var StorageOrchestratorAddon = class extends BaseAddon {
4070
4073
  }
4071
4074
  }
4072
4075
  /** A location with its provider's declared secrets replaced by the sentinel. */
4076
+ /**
4077
+ * The location as a PROVIDER must see it: every keychain marker in its
4078
+ * config resolved (D787). The same object when it holds none — a filesystem
4079
+ * location costs nothing. An unresolvable secret is left out and logged by
4080
+ * ref; the provider then fails its own connection, by name.
4081
+ */
4082
+ async withResolvedSecrets(location) {
4083
+ const secrets = this.ctx.secrets;
4084
+ if (secrets === void 0) return location;
4085
+ const { value, unresolved } = await resolveSecretMarkers(location.config, secrets);
4086
+ if (unresolved.length > 0) this.ctx.logger.error("storage location secret unavailable", { meta: {
4087
+ locationId: location.id,
4088
+ secrets: unresolved.map((u) => ({
4089
+ ref: u.ref,
4090
+ reason: u.reason
4091
+ }))
4092
+ } });
4093
+ return value === location.config ? location : {
4094
+ ...location,
4095
+ config: value
4096
+ };
4097
+ }
4098
+ /**
4099
+ * Strip the provider's DECLARED secrets (its form schema, by type) out of a
4100
+ * location config into the keychain, under `row/storage_locations/<id>`.
4101
+ * A provider that has not registered declares nothing: only keys that
4102
+ * already hold a marker are handled then — a new plaintext is never guessed
4103
+ * at, it stays as sent until the provider is back and the location is saved.
4104
+ */
4105
+ async keepSecretsInKeychain(locationId, providerId, config, stored) {
4106
+ const secrets = this.ctx.secrets;
4107
+ if (secrets === void 0) return config;
4108
+ const declared = this.declaredSecretKeys(providerId) ?? /* @__PURE__ */ new Set();
4109
+ const markerKeys = Object.entries(stored).filter(([, v]) => isSecretMarker(v)).map(([k]) => k);
4110
+ const tree = secretTreeFromPaths([...new Set([...declared, ...markerKeys])]);
4111
+ if (tree.size === 0) return config;
4112
+ const result = await transformSecretWrite({
4113
+ tree,
4114
+ secrets,
4115
+ patch: { ...config },
4116
+ stored: { ...stored },
4117
+ scope: {
4118
+ kind: "row",
4119
+ collection: STORAGE_LOCATIONS,
4120
+ rowId: locationId
4121
+ }
4122
+ });
4123
+ const merged = { ...result.patch };
4124
+ for (const key of tree.keys()) if (!(key in merged) && key in stored) merged[key] = stored[key];
4125
+ result.afterWrite().then(({ orphaned }) => {
4126
+ if (orphaned.length > 0) this.ctx.logger.warn("storage location: dropped keychain refs could not be deleted", { meta: {
4127
+ locationId,
4128
+ refs: [...orphaned]
4129
+ } });
4130
+ });
4131
+ return merged;
4132
+ }
4073
4133
  redacted(location) {
4074
4134
  return redactLocation(location, this.secretKeysFor(location.providerId, location.config));
4075
4135
  }
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BcUWQGr9.js");
6
+ const require_dist = require("../../dist-D_a9mUiM.js");
7
7
  //#region src/builtins/system-config/system-config.addon.ts
8
8
  /**
9
9
  * Built-in `system-config` addon — Phase 4 of the settings redesign.
@@ -1,4 +1,4 @@
1
- import { Cr as hydrateSchema, cr as BaseAddon, sr as errMsg } from "../../dist-D732NygW.mjs";
1
+ import { Dr as hydrateSchema, cr as errMsg, lr as BaseAddon } from "../../dist-BWNoS-1S.mjs";
2
2
  //#region src/builtins/system-config/system-config.addon.ts
3
3
  /**
4
4
  * Built-in `system-config` addon — Phase 4 of the settings redesign.
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BcUWQGr9.js");
6
+ const require_dist = require("../../dist-D_a9mUiM.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  let node_path = require("node:path");
9
9
  node_path = require_chunk.__toESM(node_path);
@@ -1,4 +1,4 @@
1
- import { Zt as logDestinationCapability, cr as BaseAddon } from "../../dist-D732NygW.mjs";
1
+ import { Zt as logDestinationCapability, lr as BaseAddon } from "../../dist-BWNoS-1S.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  import * as path$1 from "node:path";
4
4
  import path from "node:path";