@camstack/server 1.2.909 → 1.2.911
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/CHANGELOG.md +14 -0
- package/dist/agent/main.js +21 -8
- package/dist/api/core/cap-providers.js +81 -78
- package/dist/api/trpc/device-config-secret-redaction.js +42 -2
- package/dist/api/trpc/generated-cap-routers.js +20 -0
- package/dist/api/trpc/trpc.middleware.js +10 -2
- package/dist/core/addon/addon-registry.service.js +25 -1
- package/dist/core/addon/instance-lifecycle.js +106 -33
- package/package.json +29 -12
- package/system/dist/addon-runner.js +229 -21
- package/system/dist/addon-runner.mjs +230 -22
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +6 -5
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +6 -5
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +3 -3
- package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
- package/system/dist/builtins/loki-logging/index.js +15 -9
- package/system/dist/builtins/loki-logging/index.mjs +15 -9
- package/system/dist/builtins/loki-logging/loki-logging.addon.d.ts +6 -0
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-C6IjgNU4.js → capture-engine-CRXUcNzg.js} +1 -1
- package/system/dist/{capture-engine-CE9QyWYX.mjs → capture-engine-erwNulcY.mjs} +1 -1
- package/system/dist/{composition-sources-YIJB6QG7.js → composition-sources-CmJRQLAB.js} +1 -1
- package/system/dist/{composition-sources-CsPiXLpf.mjs → composition-sources-DrQFzsQU.mjs} +1 -1
- package/system/dist/{constants-D6sXdBUu.js → constants-BuRweEmb.js} +1 -1
- package/system/dist/{constants-D1n14R3Y.mjs → constants-D9ZICjoN.mjs} +1 -1
- package/system/dist/{device-ca-BTbsR2J2.js → device-ca-DGwzbKB7.js} +1 -1
- package/system/dist/{device-ca-DahOgcXb.mjs → device-ca-XXMVM6Lu.mjs} +1 -1
- package/system/dist/{dist-_gUzcZPn.js → dist-CZx3IYRz.js} +523 -42
- package/system/dist/{dist-DxW5ebV-.mjs → dist-DUYpvNfO.mjs} +522 -41
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-DpzA5fuQ.mjs → hub-identity-Dc-SOwBk.mjs} +1 -1
- package/system/dist/{hub-identity-CDhT1yT0.js → hub-identity-vVRXZi0z.js} +1 -1
- package/system/dist/{hub-mdns-ciao-C6nswov4.mjs → hub-mdns-ciao-DpRGDUEE.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-BWDuSepO.js → hub-mdns-ciao-uCdDDwE4.js} +2 -2
- package/system/dist/index.d.ts +1 -0
- package/system/dist/index.js +218 -26
- package/system/dist/index.mjs +219 -28
- package/system/dist/kernel/moleculer/accessory-spawn-retry.d.ts +67 -0
- package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +2 -0
- package/system/dist/kernel/moleculer/hub-connect-switches.d.ts +23 -0
- package/system/dist/{legacy-integration-rows-door-vKSv01GH.js → legacy-integration-rows-door-CtObsXaU.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-lCNawQ-w.mjs → legacy-integration-rows-door-DvbF3IY8.mjs} +1 -1
- package/system/dist/{rename-composition-block-ONfuFbfd.mjs → rename-composition-block-CowZDV1m.mjs} +1 -1
- package/system/dist/{rename-composition-block-ozGMTnI_.js → rename-composition-block-rKmnICiK.js} +1 -1
- package/system/dist/{restore-archive-CUVoxsCu.js → restore-archive-BvvAR6Ww.js} +1 -1
- package/system/dist/{restore-archive-DWTsdq1K.mjs → restore-archive-DH-lFUT0.mjs} +1 -1
- package/system/dist/{wal-maintenance-B6pvtESa.mjs → wal-maintenance-B0uiPZUs.mjs} +0 -0
- package/system/dist/{wal-maintenance-Cgpar8TL.js → wal-maintenance-CB9zUxb-.js} +0 -0
- package/system/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.2.911] - 2026-11-19
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- A device-provider accessory child that failed to spawn at boot is now retried a bounded number of times, then reported as failed in the log, instead of staying unroutable until the addon restarts.
|
|
15
|
+
- Integration list, get and getByAddonId are pure registry reads that never call an addon, ending the hub and addon call cycle behind hub stalls
|
|
16
|
+
|
|
17
|
+
## [1.2.910] - 2026-11-19
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- An automation run that crashes outside its steps now records the reason on its trace, and a hold's pending row is folded into the run it became.
|
|
22
|
+
- Camera logins inside stream URLs (stream catalog, camera stream views, runtime-state slice) are now masked for admin sessions too
|
|
23
|
+
|
|
10
24
|
## [1.2.909] - 2026-11-19
|
|
11
25
|
|
|
12
26
|
### Changed
|
package/dist/agent/main.js
CHANGED
|
@@ -1211,16 +1211,29 @@ async function startAgent(configPath) {
|
|
|
1211
1211
|
// Hub connected — its view of this agent was reset, so the full manifest goes again.
|
|
1212
1212
|
// (A stale `certificate-rejected` clears on the registration's ack.)
|
|
1213
1213
|
registration.onHubConnected();
|
|
1214
|
-
|
|
1215
|
-
|
|
1214
|
+
// Every (re)connect reads the switches again for each addon that serves instance kinds: an
|
|
1215
|
+
// owner whose registry read failed earlier is retried by the next connect (event-driven, D3),
|
|
1216
|
+
// and a hub restart after a good read changes nothing the addon already knows.
|
|
1217
|
+
const first = !hubReachableFired;
|
|
1216
1218
|
hubReachableFired = true;
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1219
|
+
void (async () => {
|
|
1220
|
+
await (0, system_1.rehydrateSwitchesOnHubConnect)([...loadedAddons.values()].flatMap((entry) => entry.addon ? [{ addonId: entry.id, addon: entry.addon }] : []), {
|
|
1221
|
+
fatalOnUnread: false,
|
|
1222
|
+
onUnread: (addonId, err) => {
|
|
1223
|
+
console.error(`[Agent] ${addonId} instance switches not read:`, err);
|
|
1224
|
+
},
|
|
1225
|
+
exit: () => undefined,
|
|
1222
1226
|
});
|
|
1223
|
-
|
|
1227
|
+
if (!first)
|
|
1228
|
+
return;
|
|
1229
|
+
for (const [, entry] of loadedAddons) {
|
|
1230
|
+
if (!entry.addon || typeof entry.addon.onHubReachable !== 'function')
|
|
1231
|
+
continue;
|
|
1232
|
+
Promise.resolve(entry.addon.onHubReachable()).catch((err) => {
|
|
1233
|
+
console.error(`[Agent] ${entry.id} onHubReachable() threw:`, err);
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
})();
|
|
1224
1237
|
});
|
|
1225
1238
|
console.log(`[Agent] Node "${config.nodeId}" (name="${config.name}") ready — ${loadedAddons.size} addon(s) loaded`);
|
|
1226
1239
|
}
|
|
@@ -790,12 +790,12 @@ exports.INTEGRATION_CAP_MARKERS = new Set(['device-provider', 'device-adoption']
|
|
|
790
790
|
* `integration-instances` declares its role (`devices`) and is listed for its devices. Decided from the manifest, so a not-yet-registered provider does
|
|
791
791
|
* not flash a row in. A row it already has stays in the registry and reachable by id.
|
|
792
792
|
*/
|
|
793
|
-
|
|
793
|
+
function hidesFromIntegrations(ar, addonId) {
|
|
794
794
|
const addon = ar.listAddons().find((a) => a.manifest.id === addonId);
|
|
795
795
|
if (addon === undefined)
|
|
796
796
|
return false;
|
|
797
797
|
const declared = addon.declaration?.integrationRole ?? addon.manifest.integrationRole;
|
|
798
|
-
const described = declared === undefined ?
|
|
798
|
+
const described = declared === undefined ? describedInstancesOf(ar, addonId) : null;
|
|
799
799
|
return !(0, integration_role_js_1.bringsDevices)((0, integration_role_js_1.resolveIntegrationRole)({
|
|
800
800
|
integrationRole: declared,
|
|
801
801
|
describedRole: (0, integration_role_js_1.describedRoleOf)(described),
|
|
@@ -803,18 +803,13 @@ async function hidesFromIntegrations(ar, addonId) {
|
|
|
803
803
|
}));
|
|
804
804
|
}
|
|
805
805
|
/**
|
|
806
|
-
*
|
|
807
|
-
*
|
|
806
|
+
* What the addon's provider described when it registered (the hub keeps it, `cachedDescription`), or
|
|
807
|
+
* null when it is not registered yet. NEVER a call to the addon: a registry read that awaits an addon
|
|
808
|
+
* makes every integration read depend on every addon (D1066), so it falls back to the manifest.
|
|
808
809
|
*/
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
try {
|
|
813
|
-
return await provider.describe();
|
|
814
|
-
}
|
|
815
|
-
catch {
|
|
816
|
-
return null;
|
|
817
|
-
}
|
|
810
|
+
function describedInstancesOf(ar, addonId) {
|
|
811
|
+
const provider = getInstancesProvider(ar, addonId);
|
|
812
|
+
return provider === null ? null : (0, instance_lifecycle_1.cachedDescription)(provider);
|
|
818
813
|
}
|
|
819
814
|
/** The wizard's discovery word for what a provider describes (`none` and `account` find nothing before an instance exists). */
|
|
820
815
|
function wizardDiscoveryMode(described) {
|
|
@@ -823,45 +818,6 @@ function wizardDiscoveryMode(described) {
|
|
|
823
818
|
function getInstancesProvider(ar, addonId) {
|
|
824
819
|
return (0, integration_instances_provider_js_1.findInstancesProvider)(ar.getCapabilityRegistry(), addonId);
|
|
825
820
|
}
|
|
826
|
-
/**
|
|
827
|
-
* An integration's `enabled` is a projection of its instance body (epic #440, step 3): the one
|
|
828
|
-
* switch is `setInstanceEnabled`, stored in the addon's record. One `listInstances` call per
|
|
829
|
-
* addon answers every row of it. A row the addon cannot speak for (its provider is not up, it
|
|
830
|
-
* keeps no instance for the row, it fails to answer) keeps the registry's stored flag but is
|
|
831
|
-
* marked `switchUnknown`: that flag is stale, not the state, and a reader must not draw it as on or
|
|
832
|
-
* off (D315). A failure is logged: a listing never fails because one addon did not answer.
|
|
833
|
-
*
|
|
834
|
-
* A FIXED builtin is the exception: its switch is the registry flag, the hub's own, written by
|
|
835
|
-
* `setFixedBuiltinEnabled` (`instance-lifecycle.ts`) from `setInstanceEnabled` or from
|
|
836
|
-
* `integrations.update({ enabled })`, and the name-only record it is seeded with carries no flag,
|
|
837
|
-
* which a body reads as "on". Its row is never projected and the flag is the answer, whether or
|
|
838
|
-
* not its addon is up.
|
|
839
|
-
*/
|
|
840
|
-
async function projectSwitches(ar, logger, integrations) {
|
|
841
|
-
const byAddon = new Map();
|
|
842
|
-
for (const addonId of new Set(integrations.filter((i) => !(0, instance_lifecycle_1.isFixedBuiltin)(i)).map((i) => i.addonId))) {
|
|
843
|
-
const provider = getInstancesProvider(ar, addonId);
|
|
844
|
-
if (provider === null)
|
|
845
|
-
continue;
|
|
846
|
-
try {
|
|
847
|
-
const instances = await provider.listInstances();
|
|
848
|
-
byAddon.set(addonId, new Map(instances.map((i) => [i.id, i.enabled !== false])));
|
|
849
|
-
}
|
|
850
|
-
catch (err) {
|
|
851
|
-
logger.warn('integration switch not projected: the addon did not answer', {
|
|
852
|
-
tags: { addonId },
|
|
853
|
-
meta: { error: (0, types_1.errMsg)(err) },
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
return integrations.map((i) => {
|
|
858
|
-
// A fixed builtin's switch is the registry flag: the hub owns it, the addon does not answer for it.
|
|
859
|
-
if ((0, instance_lifecycle_1.isFixedBuiltin)(i))
|
|
860
|
-
return i;
|
|
861
|
-
const enabled = byAddon.get(i.addonId)?.get(i.id);
|
|
862
|
-
return enabled === undefined ? { ...i, switchUnknown: true } : { ...i, enabled };
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
821
|
function buildIntegrationsProvider(ar, loggingService) {
|
|
866
822
|
const logger = loggingService.createLogger('integrations');
|
|
867
823
|
const withProcessState = (i) => ({
|
|
@@ -873,24 +829,81 @@ function buildIntegrationsProvider(ar, loggingService) {
|
|
|
873
829
|
const integrations = await requireIntegrationRegistry(ar).listIntegrations();
|
|
874
830
|
const hidden = new Map();
|
|
875
831
|
for (const addonId of new Set(integrations.map((i) => i.addonId))) {
|
|
876
|
-
hidden.set(addonId,
|
|
832
|
+
hidden.set(addonId, hidesFromIntegrations(ar, addonId));
|
|
877
833
|
}
|
|
878
|
-
|
|
879
|
-
|
|
834
|
+
return integrations
|
|
835
|
+
.filter((i) => hidden.get(i.addonId) !== true && i.info[types_1.SERVICE_INSTANCE_INFO_KEY] !== true)
|
|
836
|
+
.map(withProcessState);
|
|
880
837
|
},
|
|
881
838
|
get: async (input) => {
|
|
882
839
|
const integration = await requireIntegrationRegistry(ar).getIntegration(input.id);
|
|
883
840
|
if (!integration)
|
|
884
841
|
throw new Error(`Integration "${input.id}" not found`);
|
|
885
|
-
|
|
886
|
-
return withProcessState(projected ?? integration);
|
|
842
|
+
return withProcessState(integration);
|
|
887
843
|
},
|
|
888
844
|
getByAddonId: async (input) => {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
const
|
|
893
|
-
return
|
|
845
|
+
// The row of a devices-role addon only: a services instance row (`info.serviceInstance`)
|
|
846
|
+
// belongs to an instance, never to the addon, and would answer for it.
|
|
847
|
+
const bare = (0, types_1.bareAddonId)(input.addonId);
|
|
848
|
+
const rows = await requireIntegrationRegistry(ar).listIntegrations();
|
|
849
|
+
return (rows.find((i) => i.addonId === bare && i.info?.[types_1.SERVICE_INSTANCE_INFO_KEY] !== true) ?? null);
|
|
850
|
+
},
|
|
851
|
+
listByAddon: async (input) => {
|
|
852
|
+
const rows = await requireIntegrationRegistry(ar).listIntegrations();
|
|
853
|
+
const bare = (0, types_1.bareAddonId)(input.addonId);
|
|
854
|
+
return rows.filter((i) => i.addonId === bare);
|
|
855
|
+
},
|
|
856
|
+
adoptInstanceRows: async (input) => {
|
|
857
|
+
const reg = requireIntegrationRegistry(ar);
|
|
858
|
+
const addonId = (0, types_1.bareAddonId)(input.addonId);
|
|
859
|
+
// An addon states rows of its OWN instances only: the transport stamps who is calling.
|
|
860
|
+
const stamp = Reflect.get(input, 'callerAddonId');
|
|
861
|
+
if (typeof stamp === 'string' && stamp.length > 0 && (0, types_1.bareAddonId)(stamp) !== addonId) {
|
|
862
|
+
throw new server_1.TRPCError({
|
|
863
|
+
code: 'FORBIDDEN',
|
|
864
|
+
message: `addon "${(0, types_1.bareAddonId)(stamp)}" cannot adopt instance rows of addon "${addonId}"`,
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
let created = 0;
|
|
868
|
+
let updated = 0;
|
|
869
|
+
const conflicts = [];
|
|
870
|
+
for (const row of input.rows) {
|
|
871
|
+
const existing = await reg.getIntegration(row.id);
|
|
872
|
+
if (existing === null) {
|
|
873
|
+
// An absent row with a record is a services instance under its addon-minted id. The
|
|
874
|
+
// registry writes an explicit id with `ifRev: 0`, so it can never overwrite a row a
|
|
875
|
+
// concurrent writer (or the `int_NNNN` counter) placed first.
|
|
876
|
+
try {
|
|
877
|
+
await reg.createIntegration({
|
|
878
|
+
id: row.id,
|
|
879
|
+
addonId,
|
|
880
|
+
name: row.name,
|
|
881
|
+
enabled: row.enabled,
|
|
882
|
+
info: { [types_1.SERVICE_INSTANCE_INFO_KEY]: true },
|
|
883
|
+
});
|
|
884
|
+
created += 1;
|
|
885
|
+
}
|
|
886
|
+
catch (err) {
|
|
887
|
+
const raced = await reg.getIntegration(row.id);
|
|
888
|
+
if (raced === null)
|
|
889
|
+
throw err;
|
|
890
|
+
if (raced.addonId !== addonId)
|
|
891
|
+
conflicts.push({ id: row.id, ownerAddonId: raced.addonId });
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
else if (existing.addonId !== addonId) {
|
|
895
|
+
logger.warn('adopt skipped: the row belongs to another addon', {
|
|
896
|
+
tags: { integrationId: row.id, addonId },
|
|
897
|
+
meta: { owner: existing.addonId },
|
|
898
|
+
});
|
|
899
|
+
conflicts.push({ id: row.id, ownerAddonId: existing.addonId });
|
|
900
|
+
}
|
|
901
|
+
else if (row.stated && existing.enabled !== row.enabled) {
|
|
902
|
+
await reg.updateIntegration(row.id, { enabled: row.enabled });
|
|
903
|
+
updated += 1;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
return { created, updated, conflicts };
|
|
894
907
|
},
|
|
895
908
|
update: async (input) => {
|
|
896
909
|
const reg = requireIntegrationRegistry(ar);
|
|
@@ -902,19 +915,10 @@ function buildIntegrationsProvider(ar, loggingService) {
|
|
|
902
915
|
});
|
|
903
916
|
throw new Error(`Integration "${input.id}" not found`);
|
|
904
917
|
}
|
|
905
|
-
if (input.enabled !== undefined
|
|
906
|
-
// The
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
else if (input.enabled !== undefined) {
|
|
910
|
-
logger.warn('refused: integrations.update does not switch', {
|
|
911
|
-
tags: { integrationId: input.id, addonId: previous.addonId },
|
|
912
|
-
meta: { phase: 'update', reason: 'switch-through-set-instance-enabled' },
|
|
913
|
-
});
|
|
914
|
-
throw new server_1.TRPCError({
|
|
915
|
-
code: 'BAD_REQUEST',
|
|
916
|
-
message: `Integration "${input.id}" is switched through integration-instances.setInstanceEnabled, not integrations.update`,
|
|
917
|
-
});
|
|
918
|
+
if (input.enabled !== undefined) {
|
|
919
|
+
// The one door of the switch (D1066): the registry row, then the addon is told. Works while the addon is down.
|
|
920
|
+
const raw = getInstancesProvider(ar, previous.addonId);
|
|
921
|
+
await (0, instance_lifecycle_1.switchRegisteredInstance)(ar.instanceLifecycleDeps(), previous, input.enabled, raw === null ? null : (0, instance_lifecycle_1.rawInstancesProvider)(raw));
|
|
918
922
|
}
|
|
919
923
|
const { id, enabled: _switched, ...updates } = input;
|
|
920
924
|
const changedFields = Object.keys(updates).filter((k) => updates[k] !== undefined);
|
|
@@ -996,7 +1000,7 @@ function buildIntegrationsProvider(ar, loggingService) {
|
|
|
996
1000
|
}));
|
|
997
1001
|
const providerAddons = [];
|
|
998
1002
|
for (const addon of markerAddons) {
|
|
999
|
-
if (!
|
|
1003
|
+
if (!hidesFromIntegrations(ar, addon.manifest.id))
|
|
1000
1004
|
providerAddons.push(addon);
|
|
1001
1005
|
}
|
|
1002
1006
|
const integrations = await reg.listIntegrations();
|
|
@@ -1005,8 +1009,7 @@ function buildIntegrationsProvider(ar, loggingService) {
|
|
|
1005
1009
|
const d = addon.declaration;
|
|
1006
1010
|
const icon = d?.icon ?? m.icon;
|
|
1007
1011
|
const color = d?.color ?? m.color ?? '#78716c';
|
|
1008
|
-
const
|
|
1009
|
-
const described = await describedInstancesOf(instances);
|
|
1012
|
+
const described = describedInstancesOf(ar, m.id);
|
|
1010
1013
|
const instanceMode = described !== null
|
|
1011
1014
|
? described.instanceMode === 'single'
|
|
1012
1015
|
? 'unique'
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
* pattern as `scope-access.ts` and `share-view-access.ts`).
|
|
41
41
|
*/
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.NON_ADMIN_CONFIG_REDACTED_METHODS = exports.NON_ADMIN_SECRET_FREE_BY_CONTRACT = exports.REDACTED_SECRET = void 0;
|
|
43
|
+
exports.ALL_PRINCIPALS_REDACTED_METHODS = exports.NON_ADMIN_CONFIG_REDACTED_METHODS = exports.NON_ADMIN_SECRET_FREE_BY_CONTRACT = exports.REDACTED_SECRET = void 0;
|
|
44
44
|
exports.isSecretConfigKey = isSecretConfigKey;
|
|
45
45
|
exports.redactDeviceInfoSecrets = redactDeviceInfoSecrets;
|
|
46
46
|
exports.redactDeviceInfoRecordSecrets = redactDeviceInfoRecordSecrets;
|
|
@@ -388,7 +388,10 @@ const DEVICE_EXPORT_CAP = 'device-export';
|
|
|
388
388
|
function redactStatusAggregateSetup(data) {
|
|
389
389
|
if (!isRecord(data) || !(DEVICE_EXPORT_CAP in data))
|
|
390
390
|
return data;
|
|
391
|
-
return {
|
|
391
|
+
return {
|
|
392
|
+
...data,
|
|
393
|
+
[DEVICE_EXPORT_CAP]: redactExportSetup(data[DEVICE_EXPORT_CAP]),
|
|
394
|
+
};
|
|
392
395
|
}
|
|
393
396
|
/** Project a batch status aggregate (`Record<deviceId, Record<capName, status>>`). */
|
|
394
397
|
function redactStatusAggregateBatchSetup(data) {
|
|
@@ -538,3 +541,40 @@ exports.NON_ADMIN_CONFIG_REDACTED_METHODS = new Map([
|
|
|
538
541
|
['deviceState.getCapSlice', maskUrlCredentialsDeep],
|
|
539
542
|
['deviceState.getAllSnapshots', maskUrlCredentialsDeep],
|
|
540
543
|
]);
|
|
544
|
+
const STREAM_CATALOG_CAP = 'stream-catalog';
|
|
545
|
+
/** Mask URL credentials in the `stream-catalog` slice of a `capName -> slice` record. */
|
|
546
|
+
function maskCatalogSliceOfSnapshot(snapshot) {
|
|
547
|
+
if (!isRecord(snapshot) || !(STREAM_CATALOG_CAP in snapshot))
|
|
548
|
+
return snapshot;
|
|
549
|
+
return {
|
|
550
|
+
...snapshot,
|
|
551
|
+
[STREAM_CATALOG_CAP]: maskUrlCredentialsDeep(snapshot[STREAM_CATALOG_CAP]),
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Reads that carry a CAMERA's own login inside a stream URL (`rtsp://user:pass@…`,
|
|
556
|
+
* Reolink FLV `…&user=…&password=…`) and are masked for EVERY principal, an admin
|
|
557
|
+
* included — an admin session is a browser, a script, a leaked token; it has no use for
|
|
558
|
+
* the camera's password, and the settings form already shows it only as `{ $secret }`.
|
|
559
|
+
*
|
|
560
|
+
* Applied at the transport boundary only. The stream broker reads `stream-catalog` through
|
|
561
|
+
* its in-process link (`NEVER_BRIDGED_CAPS`) and the credential reaches the process that
|
|
562
|
+
* opens the connection without crossing this middleware. Distinct from
|
|
563
|
+
* {@link NON_ADMIN_CONFIG_REDACTED_METHODS}, which an admin skips.
|
|
564
|
+
*/
|
|
565
|
+
exports.ALL_PRINCIPALS_REDACTED_METHODS = new Map([
|
|
566
|
+
['streamCatalog.getCatalog', (d) => maskUrlCredentialsDeep(d)],
|
|
567
|
+
['cameraStreams.getCameraStreams', (d) => redactStreamUrlSecrets(d)],
|
|
568
|
+
['streamBroker.listAllCameraStreams', (d) => redactStreamUrlSecrets(d)],
|
|
569
|
+
['deviceState.getSnapshot', (d) => maskCatalogSliceOfSnapshot(d)],
|
|
570
|
+
[
|
|
571
|
+
'deviceState.getCapSlice',
|
|
572
|
+
(d, input) => isRecord(input) && input['capName'] === STREAM_CATALOG_CAP ? maskUrlCredentialsDeep(d) : d,
|
|
573
|
+
],
|
|
574
|
+
[
|
|
575
|
+
'deviceState.getAllSnapshots',
|
|
576
|
+
(d) => isRecord(d)
|
|
577
|
+
? Object.fromEntries(Object.entries(d).map(([id, snap]) => [id, maskCatalogSliceOfSnapshot(snap)]))
|
|
578
|
+
: d,
|
|
579
|
+
],
|
|
580
|
+
]);
|
|
@@ -6043,6 +6043,26 @@ function createCapRouter_integrations(getProvider, createRemoteProxy) {
|
|
|
6043
6043
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
6044
6044
|
return p.getByAddonId(methodInput);
|
|
6045
6045
|
}),
|
|
6046
|
+
listByAddon: trpc_middleware_js_1.protectedProcedure
|
|
6047
|
+
.input(types_74.integrationsCapability.methods.listByAddon.input.loose())
|
|
6048
|
+
.output(types_74.integrationsCapability.methods.listByAddon.output)
|
|
6049
|
+
.query(async ({ input, ctx }) => {
|
|
6050
|
+
const parsedInput = ctx.req !== undefined ? (0, types_3.withoutCallerStamp)(input) : input;
|
|
6051
|
+
const { nodeId, ...methodInput } = parsedInput;
|
|
6052
|
+
const p = resolveProvider('integrations', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
6053
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
6054
|
+
return p.listByAddon(methodInput);
|
|
6055
|
+
}),
|
|
6056
|
+
adoptInstanceRows: trpc_middleware_js_1.adminProcedure
|
|
6057
|
+
.input(types_74.integrationsCapability.methods.adoptInstanceRows.input.loose())
|
|
6058
|
+
.output(types_74.integrationsCapability.methods.adoptInstanceRows.output)
|
|
6059
|
+
.mutation(async ({ input, ctx }) => {
|
|
6060
|
+
const parsedInput = ctx.req !== undefined ? (0, types_3.withoutCallerStamp)(input) : input;
|
|
6061
|
+
const { nodeId, ...methodInput } = parsedInput;
|
|
6062
|
+
const p = resolveProvider('integrations', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
6063
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
6064
|
+
return p.adoptInstanceRows(methodInput);
|
|
6065
|
+
}),
|
|
6046
6066
|
update: trpc_middleware_js_1.adminProcedure
|
|
6047
6067
|
.input(types_74.integrationsCapability.methods.update.input.loose())
|
|
6048
6068
|
.output(types_74.integrationsCapability.methods.update.output)
|
|
@@ -81,7 +81,10 @@ const localizeSchemaOutput = t.middleware(async ({ ctx, path, next }) => {
|
|
|
81
81
|
const lang = ctx.lang ?? types_1.DEFAULT_CATALOG_LANG;
|
|
82
82
|
if (!out.ok || lang === types_1.DEFAULT_CATALOG_LANG || !localized_schema_paths_js_1.LOCALIZED_SCHEMA_PATHS.has(path))
|
|
83
83
|
return out;
|
|
84
|
-
return {
|
|
84
|
+
return {
|
|
85
|
+
...out,
|
|
86
|
+
data: (0, types_1.localizeConfigTree)(out.data, (0, system_1.getCatalogRegistry)().lookupFor(lang)),
|
|
87
|
+
};
|
|
85
88
|
});
|
|
86
89
|
/** Every authenticated procedure starts from here, so the localizing middleware is the outermost. */
|
|
87
90
|
const localized = t.procedure.use(localizeSchemaOutput);
|
|
@@ -139,7 +142,12 @@ exports.protectedProcedure = localized.use(async ({ ctx, next, path, getRawInput
|
|
|
139
142
|
// Spread+reassign of `user` narrows downstream ctx from `User | null` to
|
|
140
143
|
// `User` so `adminProcedure` can read fields without re-checking.
|
|
141
144
|
if (verdict.mode === 'all') {
|
|
142
|
-
|
|
145
|
+
// A camera's own login in a stream URL is withheld from an admin too.
|
|
146
|
+
const redactForAll = device_config_secret_redaction_js_1.ALL_PRINCIPALS_REDACTED_METHODS.get(path);
|
|
147
|
+
const out = await next({ ctx: { ...ctx, user } });
|
|
148
|
+
if (!out.ok || !redactForAll)
|
|
149
|
+
return out;
|
|
150
|
+
return { ...out, data: redactForAll(out.data, await getRawInput()) };
|
|
143
151
|
}
|
|
144
152
|
if (verdict.mode === 'share') {
|
|
145
153
|
const grant = verdict.grant;
|
|
@@ -1485,6 +1485,23 @@ class AddonRegistryService {
|
|
|
1485
1485
|
setCredentialTokenService(service) {
|
|
1486
1486
|
this.credentialTokenService = service;
|
|
1487
1487
|
}
|
|
1488
|
+
/** Every in-process addon with instance kinds reads its switches from the now-wired registry. */
|
|
1489
|
+
async rehydrateInProcessSwitches() {
|
|
1490
|
+
for (const [addonId, entry] of this.addonEntries) {
|
|
1491
|
+
const addon = entry.addon;
|
|
1492
|
+
if (addon?.rehydrateSwitches === undefined)
|
|
1493
|
+
continue;
|
|
1494
|
+
try {
|
|
1495
|
+
await addon.rehydrateSwitches();
|
|
1496
|
+
}
|
|
1497
|
+
catch (err) {
|
|
1498
|
+
this.logger.error('in-process addon instance switches not read: its instances stay off', {
|
|
1499
|
+
tags: { addonId },
|
|
1500
|
+
meta: { error: (0, types_2.errMsg)(err) },
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1488
1505
|
async wireHubMainOrphanRecords() {
|
|
1489
1506
|
const recordsCap = this.capabilityRegistry.getSingleton('records');
|
|
1490
1507
|
if (recordsCap === null || recordsCap === undefined) {
|
|
@@ -1499,6 +1516,9 @@ class AddonRegistryService {
|
|
|
1499
1516
|
this.integrationRegistry = new system_1.IntegrationRegistry(system_1.IntegrationRegistry.recordStoresOf(integrationRecords));
|
|
1500
1517
|
await this.integrationRegistry.initialize();
|
|
1501
1518
|
this.logger.info('IntegrationRegistry initialized (records)', { meta: { phase: 'v2' } });
|
|
1519
|
+
// The registry wires asynchronously, so an in-process addon that booted first read nothing and
|
|
1520
|
+
// holds its instances off (D1066): every one reads its switches now, in this process, directly.
|
|
1521
|
+
await this.rehydrateInProcessSwitches();
|
|
1502
1522
|
const clusterRecords = this.recordsForOwner('cluster-agent', this.secretsForOwner('cluster-agent'));
|
|
1503
1523
|
await clusterRecords.declare(system_1.clusterAgentRecordKinds);
|
|
1504
1524
|
this.clusterAgentRecords = clusterRecords;
|
|
@@ -3117,7 +3137,11 @@ class AddonRegistryService {
|
|
|
3117
3137
|
// An `integration-instances` holder is registered with its delete guarded by the link index (D1013).
|
|
3118
3138
|
this.capabilityRegistry.registerProvider(capabilityName, addonId, (0, instance_links_service_js_1.registeredProviderFor)(capabilityName, provider, this.capabilityRegistry, {
|
|
3119
3139
|
addonId,
|
|
3120
|
-
wrap:
|
|
3140
|
+
wrap: (wrapAddonId, held) => {
|
|
3141
|
+
const wrapped = this.instanceLifecycleWrap(wrapAddonId, held);
|
|
3142
|
+
(0, instance_lifecycle_js_1.rememberDescription)(wrapped, addonId, logger);
|
|
3143
|
+
return wrapped;
|
|
3144
|
+
},
|
|
3121
3145
|
}));
|
|
3122
3146
|
logger.info('Registered provider via context.registerProvider()', {
|
|
3123
3147
|
meta: { capabilityName },
|