@camstack/server 1.2.594 → 1.2.596
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/addon-root-inventory.js +50 -11
- package/dist/agent/addon-scan.js +44 -6
- package/dist/agent/agent-addon-runtime.js +8 -3
- package/dist/agent/agent-addon-updates.js +52 -12
- package/dist/agent/agent-cap-dispatch-service.js +5 -3
- package/dist/agent/agent-config.js +42 -7
- package/dist/agent/agent-deploy-swap.js +41 -5
- package/dist/agent/agent-group-runner.js +47 -8
- package/dist/agent/agent-http-auth.js +22 -10
- package/dist/agent/agent-http.js +113 -64
- package/dist/agent/agent-hub-addon-update.js +16 -10
- package/dist/agent/agent-hub-registration.js +7 -4
- package/dist/agent/agent-infra-capabilities.js +9 -5
- package/dist/agent/agent-json-file.js +42 -5
- package/dist/agent/agent-mesh-gate.js +8 -5
- package/dist/agent/agent-node-certificates.js +28 -25
- package/dist/agent/agent-pairing-local.js +47 -10
- package/dist/agent/agent-pairing-routes.js +20 -16
- package/dist/agent/agent-pairing-store.js +58 -18
- package/dist/agent/agent-reconnect.js +4 -1
- package/dist/agent/agent-service.js +71 -35
- package/dist/agent/agent-sniffing-listener.js +48 -11
- package/dist/agent/agent-undeploy.js +41 -5
- package/dist/agent/agent-update-routes.js +19 -14
- package/dist/agent/agent-update-service.js +80 -38
- package/dist/agent/apply-model-distribution.js +4 -1
- package/dist/agent/apply-stage-dev-uploads.js +9 -6
- package/dist/agent/derive-hub-url.js +8 -3
- package/dist/agent/fetch-bundle-from-hub.js +9 -6
- package/dist/agent/hubs-found.js +43 -6
- package/dist/agent/infra-boot-guard.js +4 -1
- package/dist/agent/infra-boot-plan.js +6 -2
- package/dist/agent/main.js +183 -148
- package/dist/agent/register-agent-cap-dispatch.js +6 -3
- package/dist/agent/serial-queue.js +7 -2
- package/dist/agent-status-page.js +4 -1
- package/dist/api/addon-upload.js +61 -22
- package/dist/api/agent-addon-delivery.js +11 -6
- package/dist/api/auth-whoami.js +4 -1
- package/dist/api/backup-download-pump.js +9 -5
- package/dist/api/backup-download.js +10 -7
- package/dist/api/core/addon-settings.router.js +19 -16
- package/dist/api/core/agent-pairing.router.js +79 -76
- package/dist/api/core/agents.router.js +24 -21
- package/dist/api/core/auth-admin-tokens.procedures.js +52 -48
- package/dist/api/core/auth-device-cert.procedures.js +67 -62
- package/dist/api/core/auth-limits.js +25 -16
- package/dist/api/core/auth-reauth.procedures.js +37 -32
- package/dist/api/core/auth-revoke-credentials.procedures.js +26 -22
- package/dist/api/core/auth-sessions.procedures.js +56 -52
- package/dist/api/core/auth.router.js +304 -300
- package/dist/api/core/cap-providers.js +121 -74
- package/dist/api/core/capabilities.router.js +37 -34
- package/dist/api/core/capability-preference-writes.js +17 -10
- package/dist/api/core/certificates.router.js +109 -106
- package/dist/api/core/cluster-nodes.router.js +18 -15
- package/dist/api/core/collection-preference.js +6 -2
- package/dist/api/core/event-bus-proxy.router.js +37 -34
- package/dist/api/core/failure-contributions.js +8 -4
- package/dist/api/core/hwaccel.router.js +20 -17
- package/dist/api/core/integration-secrets.js +12 -8
- package/dist/api/core/lifecycle-job-runner.js +49 -13
- package/dist/api/core/live-events.router.js +32 -29
- package/dist/api/core/load-contributions.js +8 -4
- package/dist/api/core/logging-settings.js +43 -30
- package/dist/api/core/logs.router.js +43 -40
- package/dist/api/core/notifications.router.js +18 -15
- package/dist/api/core/public-event-filter.js +8 -4
- package/dist/api/core/repl.router.js +21 -18
- package/dist/api/core/request-census-settings.js +16 -11
- package/dist/api/core/server-management.provider.js +4 -1
- package/dist/api/core/server-name.js +17 -9
- package/dist/api/core/site-location.js +24 -16
- package/dist/api/core/stream-probe.router.js +24 -21
- package/dist/api/core/system-events.router.js +26 -23
- package/dist/api/cors/cors-policy.js +29 -20
- package/dist/api/cors/register-cors-policy.js +14 -9
- package/dist/api/deploy-stage-registry.js +10 -6
- package/dist/api/dev-uploads-bundle.js +50 -12
- package/dist/api/health/adaptive-probe.routes.js +13 -9
- package/dist/api/health/health.routes.js +13 -8
- package/dist/api/hub-cluster-url.js +9 -3
- package/dist/api/model-distributor.js +50 -12
- package/dist/api/oauth2/consent-page.js +13 -10
- package/dist/api/oauth2/oauth2-routes.js +25 -17
- package/dist/api/oauth2/private-host.js +4 -1
- package/dist/api/server-upload-propagate.js +51 -15
- package/dist/api/server-upload.js +50 -13
- package/dist/api/sse-no-compression.js +4 -1
- package/dist/api/static/frame-policy.js +9 -4
- package/dist/api/static/precompressed-asset.js +57 -15
- package/dist/api/static/spa-mount.js +47 -8
- package/dist/api/static/spa-static.js +12 -5
- package/dist/api/tarball-manifest.js +44 -7
- package/dist/api/trpc/cap-mount-helpers.js +12 -7
- package/dist/api/trpc/cap-route-error-formatter.js +13 -10
- package/dist/api/trpc/cap-router-runtime.js +51 -40
- package/dist/api/trpc/client-ip.js +20 -9
- package/dist/api/trpc/core-cap-bridge.js +42 -32
- package/dist/api/trpc/device-collection-dispatch.js +27 -23
- package/dist/api/trpc/device-config-secret-redaction.js +40 -24
- package/dist/api/trpc/generated-cap-mounts.js +225 -219
- package/dist/api/trpc/generated-cap-routers.js +5167 -4852
- package/dist/api/trpc/http-request-census-hook.js +11 -8
- package/dist/api/trpc/http-request-census.js +41 -34
- package/dist/api/trpc/http-request-census.singleton.js +8 -4
- package/dist/api/trpc/localized-schema-paths.js +4 -1
- package/dist/api/trpc/principal-visibility.js +22 -14
- package/dist/api/trpc/remote-addon-update-grant.js +4 -1
- package/dist/api/trpc/scope-access.js +15 -10
- package/dist/api/trpc/server-provided-caps.js +7 -3
- package/dist/api/trpc/share-view-access.js +14 -6
- package/dist/api/trpc/trpc-error-device-tags.js +6 -3
- package/dist/api/trpc/trpc-error-principal.js +6 -2
- package/dist/api/trpc/trpc.context.js +25 -20
- package/dist/api/trpc/trpc.middleware.js +46 -38
- package/dist/api/trpc/trpc.router.js +99 -58
- package/dist/api/trpc/user-error.js +8 -5
- package/dist/api/trpc/ws-request-census.js +24 -17
- package/dist/api/trpc/ws-slow-consumer-guard.js +16 -11
- package/dist/api/upload-auth.js +9 -5
- package/dist/auth/addon-route-jwt-gate.js +7 -4
- package/dist/auth/addon-route-share-gate.js +12 -7
- package/dist/auth/app-confirm-page.js +22 -17
- package/dist/auth/app-confirm-routes.js +31 -26
- package/dist/auth/app-confirmations.js +44 -7
- package/dist/auth/app-page-shell.js +30 -17
- package/dist/auth/app-page-strings.js +17 -11
- package/dist/auth/app-passkey-page.js +21 -16
- package/dist/auth/app-passkey-routes.js +41 -37
- package/dist/auth/app-refused-route.js +18 -13
- package/dist/auth/auth-network-policy.js +15 -11
- package/dist/auth/auth-provider-gate.js +9 -4
- package/dist/auth/auth-rate-limit.js +7 -3
- package/dist/auth/client-address.js +9 -6
- package/dist/auth/device-enroll-proofs.js +43 -6
- package/dist/auth/external-link-intents.js +7 -3
- package/dist/auth/hub-sessions.js +12 -6
- package/dist/auth/native-link-completions.js +11 -7
- package/dist/auth/native-return.js +13 -9
- package/dist/auth/passkey-provider.js +32 -26
- package/dist/auth/second-factors.js +10 -6
- package/dist/auth/session-connections.js +12 -6
- package/dist/auth/session-cookie.js +23 -12
- package/dist/auth/session-lifetimes.js +12 -8
- package/dist/auth/session-mint.js +11 -4
- package/dist/auth/sso-finish-app.js +16 -13
- package/dist/auth/sso-finish-deps.js +27 -21
- package/dist/auth/sso-finish.js +38 -28
- package/dist/auth/sso-routes.js +25 -22
- package/dist/auth/used-bridge-ids.js +5 -1
- package/dist/boot/boot-config.js +55 -16
- package/dist/boot/init-sequence.js +4 -1
- package/dist/boot/integration-id-backfill.js +8 -3
- package/dist/boot/platform-keychain-key.js +42 -5
- package/dist/boot/post-boot.service.js +18 -14
- package/dist/boot/reconcile-lifecycle-jobs.js +6 -3
- package/dist/boot/retired-public-url-env.js +8 -4
- package/dist/bootstrap-packages.js +4 -1
- package/dist/closure-node-modules.js +38 -2
- package/dist/core/addon/addon-call-gateway.js +5 -1
- package/dist/core/addon/addon-package.service.js +123 -83
- package/dist/core/addon/addon-process-view.js +6 -2
- package/dist/core/addon/addon-realign-plan.js +4 -1
- package/dist/core/addon/addon-registry.service.js +187 -146
- package/dist/core/addon/addon-row-manifest.js +4 -1
- package/dist/core/addon/addon-search.service.js +7 -3
- package/dist/core/addon/addon-settings-provider.js +3 -1
- package/dist/core/addon/addon-uninstall.js +11 -4
- package/dist/core/addon/addon.tokens.js +5 -2
- package/dist/core/addon/device-meta-mirror.js +13 -8
- package/dist/core/addon/forked-custom-actions.js +11 -6
- package/dist/core/addon/integration-visibility.js +6 -3
- package/dist/core/addon/materialize-route-path.js +4 -1
- package/dist/core/addon/package-dir-utils.js +45 -8
- package/dist/core/addon/prune-misplaced-addons.js +43 -5
- package/dist/core/addon/runner-convergence.js +4 -1
- package/dist/core/addon/runner-serialization.js +4 -1
- package/dist/core/addon/runner-spawn-fanout.js +8 -3
- package/dist/core/addon/settings-door-wiring.js +8 -5
- package/dist/core/addon/single-flight-refresh.js +4 -1
- package/dist/core/addon-bridge/addon-bridge.service.js +44 -7
- package/dist/core/addon-pages/addon-pages.service.js +40 -3
- package/dist/core/addon-widgets/addon-widgets.service.js +42 -4
- package/dist/core/agent/agent-addon-backfill.js +17 -9
- package/dist/core/agent/agent-delivery-ledger.js +7 -3
- package/dist/core/agent/agent-liveness-event.js +6 -2
- package/dist/core/agent/agent-pairing-http.js +45 -41
- package/dist/core/agent/agent-registry.service.js +89 -50
- package/dist/core/agent/cluster-node-history-mirror.js +7 -3
- package/dist/core/agent/cluster-node-history-store.js +35 -31
- package/dist/core/agent/hub-agent-pairing.js +5 -1
- package/dist/core/agent/node-certificates-client.js +6 -3
- package/dist/core/agent/node-directory.js +4 -1
- package/dist/core/app-links/well-known-app-links.js +6 -2
- package/dist/core/auth/auth.service.js +8 -3
- package/dist/core/auth/handoff-code.service.js +49 -11
- package/dist/core/auth/record-kinds.js +19 -16
- package/dist/core/auth/share-token.service.js +79 -42
- package/dist/core/capability/capability.service.js +5 -1
- package/dist/core/config/config.schema.js +6 -1
- package/dist/core/config/config.service.js +6 -2
- package/dist/core/events/event-bus.service.js +7 -3
- package/dist/core/feature/feature.service.js +6 -2
- package/dist/core/lifecycle/lifecycle-runner.singleton.js +10 -5
- package/dist/core/lifecycle/lifecycle-state-machine.js +5 -1
- package/dist/core/logging/log-ring-buffer.js +5 -1
- package/dist/core/logging/logging.service.js +9 -5
- package/dist/core/logging/scoped-logger.js +5 -1
- package/dist/core/moleculer/agent-readiness-pull.js +4 -1
- package/dist/core/moleculer/agent-registration-request.js +7 -3
- package/dist/core/moleculer/cap-call-fn.js +7 -4
- package/dist/core/moleculer/cap-route-authority.js +8 -3
- package/dist/core/moleculer/hub-mesh-guard.js +9 -5
- package/dist/core/moleculer/moleculer.service.js +86 -79
- package/dist/core/network/network-quality.service.js +6 -2
- package/dist/core/notification/notification-wrapper.service.js +7 -3
- package/dist/core/notification/toast-wrapper.service.js +7 -3
- package/dist/core/provider/provider.tokens.js +4 -1
- package/dist/core/repl/repl-engine.service.js +8 -4
- package/dist/core/runner-health/runner-boot-check.js +15 -7
- package/dist/core/runner-health/update-preflight.js +14 -9
- package/dist/core/server-update/server-update.service.js +49 -12
- package/dist/core/server-update/system-apply-closure-patches.js +42 -6
- package/dist/core/server-update/system-ensure-prebuilds.js +6 -3
- package/dist/core/server-update/system-exec-npm.js +5 -2
- package/dist/core/storage/fs-storage-backend.js +5 -1
- package/dist/core/storage/storage-location-manager.js +5 -1
- package/dist/core/storage/storage.service.js +6 -2
- package/dist/core/streaming/ffmpeg-stream-info.js +8 -3
- package/dist/core/streaming/stream-probe.service.js +16 -12
- package/dist/core/streaming/ttl-cache.js +5 -1
- package/dist/core/topology/topology-emitter.service.js +23 -19
- package/dist/core/update-availability-emitter.js +7 -3
- package/dist/core/update-availability-store.js +45 -8
- package/dist/core/updates/agent-installed-packages.js +9 -5
- package/dist/core/updates/restart-marker.js +8 -3
- package/dist/core/updates/update-check-scheduler.js +18 -13
- package/dist/core/updates/wrapper-update-checker.js +7 -3
- package/dist/first-boot-addon-plan.js +6 -2
- package/dist/framework-nodepath.js +38 -2
- package/dist/i18n/request-lang.js +11 -7
- package/dist/launcher.js +65 -30
- package/dist/lifecycle-journal-path.js +38 -2
- package/dist/main.js +324 -286
- package/dist/manual-boot.js +156 -117
- package/dist/node-role.js +4 -1
- package/dist/package-inventory.js +48 -7
- package/dist/pending-restore.js +43 -7
- package/dist/single-copy-cleanup-runner.js +45 -9
- package/dist/single-copy-cleanup.js +15 -7
- package/dist/sqlite-restore.js +48 -9
- package/dist/starter.js +39 -4
- package/dist/ui-serving/lazy-ui-serving.js +39 -3
- package/package.json +7 -7
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.HandoffCodeService = exports.HANDOFF_CODE_MAX_PENDING = exports.HANDOFF_CODE_TTL_MS = exports.HANDOFF_CODE_PREFIX = void 0;
|
|
37
|
+
exports.pkceChallenge = pkceChallenge;
|
|
38
|
+
const types_1 = require("@camstack/types");
|
|
2
39
|
/**
|
|
3
40
|
* HandoffCodeService — one-time login handoff codes for the native-app
|
|
4
41
|
* auth handoff (viewer "Sign in with CamStack").
|
|
@@ -22,26 +59,26 @@ import { userError } from '@camstack/types';
|
|
|
22
59
|
* (the browser just re-runs the handoff), and a bounded store +
|
|
23
60
|
* prune-on-mint keeps the map from growing.
|
|
24
61
|
*/
|
|
25
|
-
|
|
62
|
+
const crypto = __importStar(require("node:crypto"));
|
|
26
63
|
/** Wire prefix — `chc_` = CamStack Handoff Code (cf. `cst_`/`csv_`). */
|
|
27
|
-
|
|
28
|
-
|
|
64
|
+
exports.HANDOFF_CODE_PREFIX = 'chc_';
|
|
65
|
+
exports.HANDOFF_CODE_TTL_MS = 60_000;
|
|
29
66
|
/** Hard bound on concurrently-pending codes (mint is auth-gated, so this
|
|
30
67
|
* only guards against a runaway authenticated client). */
|
|
31
|
-
|
|
68
|
+
exports.HANDOFF_CODE_MAX_PENDING = 1_000;
|
|
32
69
|
/** RFC 7636 S256: `base64url(sha256(verifier))`. */
|
|
33
|
-
|
|
70
|
+
function pkceChallenge(verifier) {
|
|
34
71
|
return crypto.createHash('sha256').update(verifier).digest('base64url');
|
|
35
72
|
}
|
|
36
73
|
function hashCode(code) {
|
|
37
74
|
return crypto.createHash('sha256').update(code).digest('hex');
|
|
38
75
|
}
|
|
39
|
-
|
|
76
|
+
class HandoffCodeService {
|
|
40
77
|
now;
|
|
41
78
|
ttlMs;
|
|
42
79
|
/** Keyed by SHA-256(raw code). */
|
|
43
80
|
pending = new Map();
|
|
44
|
-
constructor(now = Date.now, ttlMs = HANDOFF_CODE_TTL_MS) {
|
|
81
|
+
constructor(now = Date.now, ttlMs = exports.HANDOFF_CODE_TTL_MS) {
|
|
45
82
|
this.now = now;
|
|
46
83
|
this.ttlMs = ttlMs;
|
|
47
84
|
}
|
|
@@ -50,10 +87,10 @@ export class HandoffCodeService {
|
|
|
50
87
|
* legitimate flow never has anywhere near this many in flight). */
|
|
51
88
|
create(userId, options = {}) {
|
|
52
89
|
this.prune();
|
|
53
|
-
if (this.pending.size >= HANDOFF_CODE_MAX_PENDING) {
|
|
54
|
-
throw userError('server.handoff-busy', undefined, 'Too many pending handoff codes — try again shortly');
|
|
90
|
+
if (this.pending.size >= exports.HANDOFF_CODE_MAX_PENDING) {
|
|
91
|
+
throw (0, types_1.userError)('server.handoff-busy', undefined, 'Too many pending handoff codes — try again shortly');
|
|
55
92
|
}
|
|
56
|
-
const code = `${HANDOFF_CODE_PREFIX}${crypto.randomBytes(32).toString('hex')}`;
|
|
93
|
+
const code = `${exports.HANDOFF_CODE_PREFIX}${crypto.randomBytes(32).toString('hex')}`;
|
|
57
94
|
const expiresAt = this.now() + this.ttlMs;
|
|
58
95
|
this.pending.set(hashCode(code), {
|
|
59
96
|
userId,
|
|
@@ -107,3 +144,4 @@ export class HandoffCodeService {
|
|
|
107
144
|
}
|
|
108
145
|
}
|
|
109
146
|
}
|
|
147
|
+
exports.HandoffCodeService = HandoffCodeService;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coreAuthRecordKinds = exports.SHARE_VIEW_TOKENS_LEGACY = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Record kinds owned by `core-auth` (hub-resident, phase 6 / §2.8).
|
|
3
6
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ShareTokenScopeSchema = z.object({
|
|
7
|
-
kind: z.enum(SHARE_VIEW_KINDS),
|
|
8
|
-
deviceIds: z.array(z.number().int().nonnegative()).min(1).max(64),
|
|
9
|
-
talk: z.boolean().optional(),
|
|
7
|
+
const types_1 = require("@camstack/types");
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const ShareTokenScopeSchema = zod_1.z.object({
|
|
10
|
+
kind: zod_1.z.enum(types_1.SHARE_VIEW_KINDS),
|
|
11
|
+
deviceIds: zod_1.z.array(zod_1.z.number().int().nonnegative()).min(1).max(64),
|
|
12
|
+
talk: zod_1.z.boolean().optional(),
|
|
10
13
|
});
|
|
11
|
-
|
|
12
|
-
const ShareViewTokenBodySchema = z.object({
|
|
13
|
-
userId: z.string(),
|
|
14
|
-
tokenHash: z.string(),
|
|
15
|
-
tokenPrefix: z.string(),
|
|
14
|
+
exports.SHARE_VIEW_TOKENS_LEGACY = 'share_view_tokens';
|
|
15
|
+
const ShareViewTokenBodySchema = zod_1.z.object({
|
|
16
|
+
userId: zod_1.z.string(),
|
|
17
|
+
tokenHash: zod_1.z.string(),
|
|
18
|
+
tokenPrefix: zod_1.z.string(),
|
|
16
19
|
scope: ShareTokenScopeSchema,
|
|
17
|
-
createdAt: z.number(),
|
|
18
|
-
expiresAt: z.number().nullable(),
|
|
19
|
-
lastUsedAt: z.number().nullish(),
|
|
20
|
+
createdAt: zod_1.z.number(),
|
|
21
|
+
expiresAt: zod_1.z.number().nullable(),
|
|
22
|
+
lastUsedAt: zod_1.z.number().nullish(),
|
|
20
23
|
});
|
|
21
|
-
|
|
24
|
+
exports.coreAuthRecordKinds = (0, types_1.defineRecordKinds)({
|
|
22
25
|
'share-view-tokens': {
|
|
23
26
|
schema: ShareViewTokenBodySchema,
|
|
24
27
|
class: 'config',
|
|
@@ -30,6 +33,6 @@ export const coreAuthRecordKinds = defineRecordKinds({
|
|
|
30
33
|
{ name: 'user', fields: ['userId'] },
|
|
31
34
|
],
|
|
32
35
|
retention: { none: 'revoke only; expiry enforced at validate' },
|
|
33
|
-
adoptsFrom: SHARE_VIEW_TOKENS_LEGACY,
|
|
36
|
+
adoptsFrom: exports.SHARE_VIEW_TOKENS_LEGACY,
|
|
34
37
|
},
|
|
35
38
|
});
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ShareTokenService = exports.ShareTokenRecordSchema = exports.ShareTokenScopeSchema = exports.SHARE_TOKEN_MAX_DEVICES = exports.SHARE_TOKEN_TTL_DEFAULT_SEC = exports.SHARE_TOKEN_TTL_MAX_SEC = exports.SHARE_TOKEN_TTL_MIN_SEC = exports.SHARE_TOKEN_PREFIX = void 0;
|
|
1
37
|
/**
|
|
2
38
|
* ShareTokenService — scoped, TTL'd VIEW tokens for standalone share links
|
|
3
39
|
* (grid rework R6: the embed page opened by a third party authenticates with
|
|
@@ -22,10 +58,10 @@
|
|
|
22
58
|
* live in, reached directly instead of over the settings-store cap since
|
|
23
59
|
* this service is hub-resident). Collection: `share_view_tokens`.
|
|
24
60
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
61
|
+
const crypto = __importStar(require("node:crypto"));
|
|
62
|
+
const zod_1 = require("zod");
|
|
63
|
+
const types_1 = require("@camstack/types");
|
|
64
|
+
const record_kinds_js_1 = require("./record-kinds.js");
|
|
29
65
|
/**
|
|
30
66
|
* @durable class=config owner=core-auth
|
|
31
67
|
* write="a user mints a share link; and a best-effort lastUsedAt touch on every successful validation"
|
|
@@ -56,12 +92,12 @@ const SHARE_TOKENS_INDEXES = [
|
|
|
56
92
|
{ name: 'idx_share_view_tokens_user', columns: ['userId'] },
|
|
57
93
|
];
|
|
58
94
|
/** Wire prefix — `csv_` = CamStack Share View (cf. `cst_` scoped tokens). */
|
|
59
|
-
|
|
95
|
+
exports.SHARE_TOKEN_PREFIX = 'csv_';
|
|
60
96
|
// ── TTL / scope bounds (enforced at mint, re-checked by the router schema) ──
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
97
|
+
exports.SHARE_TOKEN_TTL_MIN_SEC = 60;
|
|
98
|
+
exports.SHARE_TOKEN_TTL_MAX_SEC = 30 * 24 * 60 * 60; // 30 days
|
|
99
|
+
exports.SHARE_TOKEN_TTL_DEFAULT_SEC = 7 * 24 * 60 * 60; // 7 days
|
|
100
|
+
exports.SHARE_TOKEN_MAX_DEVICES = 64;
|
|
65
101
|
/**
|
|
66
102
|
* What a share token is allowed to see. Keyed on `kind` so future share
|
|
67
103
|
* surfaces (single-camera view, recording clip, …) extend the set without
|
|
@@ -80,9 +116,9 @@ export const SHARE_TOKEN_MAX_DEVICES = 64;
|
|
|
80
116
|
* Neither kind is a superset of the other — an events link cannot open a
|
|
81
117
|
* WebRTC session, and a grid link cannot read a track.
|
|
82
118
|
*/
|
|
83
|
-
|
|
84
|
-
kind: z.enum(SHARE_VIEW_KINDS),
|
|
85
|
-
deviceIds: z.array(z.number().int().nonnegative()).min(1).max(SHARE_TOKEN_MAX_DEVICES),
|
|
119
|
+
exports.ShareTokenScopeSchema = zod_1.z.object({
|
|
120
|
+
kind: zod_1.z.enum(types_1.SHARE_VIEW_KINDS),
|
|
121
|
+
deviceIds: zod_1.z.array(zod_1.z.number().int().nonnegative()).min(1).max(exports.SHARE_TOKEN_MAX_DEVICES),
|
|
86
122
|
/**
|
|
87
123
|
* TALK-BACK, opt-in at mint time. Absent means OFF, and that is the whole
|
|
88
124
|
* point: a share link is handed to third parties, so the difference between
|
|
@@ -98,24 +134,24 @@ export const ShareTokenScopeSchema = z.object({
|
|
|
98
134
|
* It widens WHAT may be called, never WHICH cameras — `deviceIds` still
|
|
99
135
|
* gates every talk call.
|
|
100
136
|
*/
|
|
101
|
-
talk: z.boolean().optional(),
|
|
137
|
+
talk: zod_1.z.boolean().optional(),
|
|
102
138
|
});
|
|
103
139
|
/** Persisted record — never leaves the server with `tokenHash` attached. */
|
|
104
|
-
|
|
105
|
-
id: z.string(),
|
|
140
|
+
exports.ShareTokenRecordSchema = zod_1.z.object({
|
|
141
|
+
id: zod_1.z.string(),
|
|
106
142
|
/** The user that minted the share link (owner — may revoke it). */
|
|
107
|
-
userId: z.string(),
|
|
108
|
-
tokenHash: z.string(),
|
|
143
|
+
userId: zod_1.z.string(),
|
|
144
|
+
tokenHash: zod_1.z.string(),
|
|
109
145
|
/** First 12 chars of the raw token — display/audit label only. */
|
|
110
|
-
tokenPrefix: z.string(),
|
|
111
|
-
scope: ShareTokenScopeSchema,
|
|
112
|
-
createdAt: z.number(),
|
|
146
|
+
tokenPrefix: zod_1.z.string(),
|
|
147
|
+
scope: exports.ShareTokenScopeSchema,
|
|
148
|
+
createdAt: zod_1.z.number(),
|
|
113
149
|
/** Epoch ms — or `null` for a never-expiring token (explicit choice at mint). */
|
|
114
|
-
expiresAt: z.number().nullable(),
|
|
115
|
-
lastUsedAt: z.number().optional(),
|
|
150
|
+
expiresAt: zod_1.z.number().nullable(),
|
|
151
|
+
lastUsedAt: zod_1.z.number().optional(),
|
|
116
152
|
});
|
|
117
153
|
function parseShareToken(data) {
|
|
118
|
-
const parsed = ShareTokenRecordSchema.safeParse(data);
|
|
154
|
+
const parsed = exports.ShareTokenRecordSchema.safeParse(data);
|
|
119
155
|
return parsed.success ? parsed.data : null;
|
|
120
156
|
}
|
|
121
157
|
function recordToBody(record) {
|
|
@@ -123,7 +159,7 @@ function recordToBody(record) {
|
|
|
123
159
|
return body;
|
|
124
160
|
}
|
|
125
161
|
function rowToRecord(id, body) {
|
|
126
|
-
return ShareTokenRecordSchema.safeParse({ id, ...body }).data ?? null;
|
|
162
|
+
return exports.ShareTokenRecordSchema.safeParse({ id, ...body }).data ?? null;
|
|
127
163
|
}
|
|
128
164
|
async function readAllShareTokenRows(kind, where) {
|
|
129
165
|
const out = [];
|
|
@@ -141,7 +177,7 @@ async function readAllShareTokenRows(kind, where) {
|
|
|
141
177
|
}
|
|
142
178
|
throw new Error('share-view-tokens: row count exceeds pagination bound');
|
|
143
179
|
}
|
|
144
|
-
|
|
180
|
+
class ShareTokenService {
|
|
145
181
|
getStore;
|
|
146
182
|
logger;
|
|
147
183
|
/**
|
|
@@ -180,7 +216,7 @@ export class ShareTokenService {
|
|
|
180
216
|
async persistRecord(record) {
|
|
181
217
|
const kind = this.kind();
|
|
182
218
|
if (kind !== null) {
|
|
183
|
-
const parsed = coreAuthRecordKinds['share-view-tokens'].schema.safeParse(recordToBody(record));
|
|
219
|
+
const parsed = record_kinds_js_1.coreAuthRecordKinds['share-view-tokens'].schema.safeParse(recordToBody(record));
|
|
184
220
|
if (!parsed.success)
|
|
185
221
|
throw new Error(parsed.error.message);
|
|
186
222
|
await kind.put({
|
|
@@ -244,16 +280,16 @@ export class ShareTokenService {
|
|
|
244
280
|
* Returns the RAW token exactly once; only its hash is persisted.
|
|
245
281
|
*/
|
|
246
282
|
async create(input) {
|
|
247
|
-
const scope = ShareTokenScopeSchema.parse(input.scope);
|
|
248
|
-
const ttlSec = input.ttlSec ?? SHARE_TOKEN_TTL_DEFAULT_SEC;
|
|
283
|
+
const scope = exports.ShareTokenScopeSchema.parse(input.scope);
|
|
284
|
+
const ttlSec = input.ttlSec ?? exports.SHARE_TOKEN_TTL_DEFAULT_SEC;
|
|
249
285
|
if (ttlSec !== 'never' &&
|
|
250
286
|
(!Number.isInteger(ttlSec) ||
|
|
251
|
-
ttlSec < SHARE_TOKEN_TTL_MIN_SEC ||
|
|
252
|
-
ttlSec > SHARE_TOKEN_TTL_MAX_SEC)) {
|
|
287
|
+
ttlSec < exports.SHARE_TOKEN_TTL_MIN_SEC ||
|
|
288
|
+
ttlSec > exports.SHARE_TOKEN_TTL_MAX_SEC)) {
|
|
253
289
|
throw new Error(`Share token TTL out of bounds — got ${ttlSec}s, allowed ` +
|
|
254
|
-
`[${SHARE_TOKEN_TTL_MIN_SEC}s, ${SHARE_TOKEN_TTL_MAX_SEC}s] or 'never'`);
|
|
290
|
+
`[${exports.SHARE_TOKEN_TTL_MIN_SEC}s, ${exports.SHARE_TOKEN_TTL_MAX_SEC}s] or 'never'`);
|
|
255
291
|
}
|
|
256
|
-
const rawToken = `${SHARE_TOKEN_PREFIX}${crypto.randomBytes(32).toString('hex')}`;
|
|
292
|
+
const rawToken = `${exports.SHARE_TOKEN_PREFIX}${crypto.randomBytes(32).toString('hex')}`;
|
|
257
293
|
const now = Date.now();
|
|
258
294
|
const record = {
|
|
259
295
|
id: crypto.randomUUID(),
|
|
@@ -266,7 +302,7 @@ export class ShareTokenService {
|
|
|
266
302
|
};
|
|
267
303
|
const kind = this.kind();
|
|
268
304
|
if (kind !== null) {
|
|
269
|
-
const parsed = coreAuthRecordKinds['share-view-tokens'].schema.safeParse(recordToBody(record));
|
|
305
|
+
const parsed = record_kinds_js_1.coreAuthRecordKinds['share-view-tokens'].schema.safeParse(recordToBody(record));
|
|
270
306
|
if (!parsed.success)
|
|
271
307
|
throw new Error(parsed.error.message);
|
|
272
308
|
await kind.put({
|
|
@@ -298,7 +334,7 @@ export class ShareTokenService {
|
|
|
298
334
|
* Never throws on bad input — the auth boundary treats `null` as 401.
|
|
299
335
|
*/
|
|
300
336
|
async validate(rawToken) {
|
|
301
|
-
if (!rawToken.startsWith(SHARE_TOKEN_PREFIX))
|
|
337
|
+
if (!rawToken.startsWith(exports.SHARE_TOKEN_PREFIX))
|
|
302
338
|
return null;
|
|
303
339
|
const tokenHash = crypto.createHash('sha256').update(rawToken).digest('hex');
|
|
304
340
|
const kind = this.kind();
|
|
@@ -335,24 +371,24 @@ export class ShareTokenService {
|
|
|
335
371
|
*/
|
|
336
372
|
async extend(input) {
|
|
337
373
|
if (!Number.isInteger(input.ttlSec) ||
|
|
338
|
-
input.ttlSec < SHARE_TOKEN_TTL_MIN_SEC ||
|
|
339
|
-
input.ttlSec > SHARE_TOKEN_TTL_MAX_SEC) {
|
|
374
|
+
input.ttlSec < exports.SHARE_TOKEN_TTL_MIN_SEC ||
|
|
375
|
+
input.ttlSec > exports.SHARE_TOKEN_TTL_MAX_SEC) {
|
|
340
376
|
throw new Error(`Share token TTL out of bounds — got ${input.ttlSec}s, allowed ` +
|
|
341
|
-
`[${SHARE_TOKEN_TTL_MIN_SEC}s, ${SHARE_TOKEN_TTL_MAX_SEC}s]`);
|
|
377
|
+
`[${exports.SHARE_TOKEN_TTL_MIN_SEC}s, ${exports.SHARE_TOKEN_TTL_MAX_SEC}s]`);
|
|
342
378
|
}
|
|
343
379
|
const record = await this.findById(input.id);
|
|
344
380
|
if (record === null) {
|
|
345
|
-
throw userError('auth.share-token-not-found', { id: input.id }, `Share token not found: ${input.id}`);
|
|
381
|
+
throw (0, types_1.userError)('auth.share-token-not-found', { id: input.id }, `Share token not found: ${input.id}`);
|
|
346
382
|
}
|
|
347
383
|
if (!input.callerIsAdmin && record.userId !== input.callerUserId) {
|
|
348
|
-
throw userError('auth.share-owner-only-extend', undefined, 'Only the token owner or an admin can extend a share token');
|
|
384
|
+
throw (0, types_1.userError)('auth.share-owner-only-extend', undefined, 'Only the token owner or an admin can extend a share token');
|
|
349
385
|
}
|
|
350
386
|
if (record.expiresAt === null) {
|
|
351
|
-
throw userError('auth.share-never-expiring-extend', undefined, 'A never-expiring share token cannot be extended');
|
|
387
|
+
throw (0, types_1.userError)('auth.share-never-expiring-extend', undefined, 'A never-expiring share token cannot be extended');
|
|
352
388
|
}
|
|
353
389
|
const now = Date.now();
|
|
354
390
|
if (now > record.expiresAt) {
|
|
355
|
-
throw userError('server.share-token-expired', { id: String(input.id) }, `Share token expired: ${input.id}`);
|
|
391
|
+
throw (0, types_1.userError)('server.share-token-expired', { id: String(input.id) }, `Share token expired: ${input.id}`);
|
|
356
392
|
}
|
|
357
393
|
const updated = {
|
|
358
394
|
...record,
|
|
@@ -378,7 +414,7 @@ export class ShareTokenService {
|
|
|
378
414
|
if (record === null)
|
|
379
415
|
return false;
|
|
380
416
|
if (!input.callerIsAdmin && record.userId !== input.callerUserId) {
|
|
381
|
-
throw userError('auth.share-owner-only-revoke', undefined, 'Only the token owner or an admin can revoke a share token');
|
|
417
|
+
throw (0, types_1.userError)('auth.share-owner-only-revoke', undefined, 'Only the token owner or an admin can revoke a share token');
|
|
382
418
|
}
|
|
383
419
|
await this.deleteById(input.id);
|
|
384
420
|
this.logger?.info('Share token revoked', {
|
|
@@ -420,3 +456,4 @@ export class ShareTokenService {
|
|
|
420
456
|
await this.persistRecord({ ...record, lastUsedAt: Date.now() });
|
|
421
457
|
}
|
|
422
458
|
}
|
|
459
|
+
exports.ShareTokenService = ShareTokenService;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* CapabilityService — NestJS-injectable wrapper around the CapabilityRegistry.
|
|
3
4
|
*
|
|
4
5
|
* Server services inject this instead of accessing the registry directly.
|
|
5
6
|
* The registry reference is set once during boot by AddonRegistryService.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CapabilityService = void 0;
|
|
10
|
+
class CapabilityService {
|
|
8
11
|
registry = null;
|
|
9
12
|
/** Called once during boot by AddonRegistryService to wire the registry */
|
|
10
13
|
setRegistry(registry) {
|
|
@@ -52,3 +55,4 @@ export class CapabilityService {
|
|
|
52
55
|
return this.registry?.resolveCollectionForDevice(capability, deviceId) ?? [];
|
|
53
56
|
}
|
|
54
57
|
}
|
|
58
|
+
exports.CapabilityService = CapabilityService;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIME_DEFAULTS = exports.bootstrapSchema = void 0;
|
|
1
4
|
// Re-export from @camstack/system
|
|
2
|
-
|
|
5
|
+
var system_1 = require("@camstack/system");
|
|
6
|
+
Object.defineProperty(exports, "bootstrapSchema", { enumerable: true, get: function () { return system_1.bootstrapSchema; } });
|
|
7
|
+
Object.defineProperty(exports, "RUNTIME_DEFAULTS", { enumerable: true, get: function () { return system_1.RUNTIME_DEFAULTS; } });
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigService = void 0;
|
|
4
|
+
const system_1 = require("@camstack/system");
|
|
5
|
+
class ConfigService extends system_1.ConfigManager {
|
|
3
6
|
}
|
|
7
|
+
exports.ConfigService = ConfigService;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventBusService = void 0;
|
|
4
|
+
const system_1 = require("@camstack/system");
|
|
2
5
|
/**
|
|
3
6
|
* Hub-side event bus. Pre-broker boot the service buffers nothing —
|
|
4
7
|
* subscribers / emits are no-ops until `attachBroker` lands the
|
|
@@ -16,7 +19,7 @@ import { getBrokerEventBus } from '@camstack/system';
|
|
|
16
19
|
* `systemEvents.subscribe`, which is enough for the operator to see
|
|
17
20
|
* continuity across page reloads.
|
|
18
21
|
*/
|
|
19
|
-
|
|
22
|
+
class EventBusService {
|
|
20
23
|
broker = null;
|
|
21
24
|
inner = null;
|
|
22
25
|
// Used only as a loose ring buffer for the very first events emitted
|
|
@@ -38,7 +41,7 @@ export class EventBusService {
|
|
|
38
41
|
// addon runners + remote agents leave `retainRecent` false: their events
|
|
39
42
|
// are one-shot (fire-and-forget), fanned out to local subscribers but never
|
|
40
43
|
// accumulated, so their heap can't grow an unbounded recent[] backlog.
|
|
41
|
-
const inner = getBrokerEventBus(broker, { retainRecent: true });
|
|
44
|
+
const inner = (0, system_1.getBrokerEventBus)(broker, { retainRecent: true });
|
|
42
45
|
this.inner = inner;
|
|
43
46
|
// Replay deferred subscriptions onto the real bus.
|
|
44
47
|
for (const sub of this.deferredSubs) {
|
|
@@ -82,3 +85,4 @@ export class EventBusService {
|
|
|
82
85
|
return this.inner?.getRecent(filter, limit) ?? [];
|
|
83
86
|
}
|
|
84
87
|
}
|
|
88
|
+
exports.EventBusService = EventBusService;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FeatureService = void 0;
|
|
4
|
+
const system_1 = require("@camstack/system");
|
|
5
|
+
class FeatureService extends system_1.FeatureManager {
|
|
3
6
|
}
|
|
7
|
+
exports.FeatureService = FeatureService;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Process-wide singleton holder for the lifecycle job runner.
|
|
3
4
|
*
|
|
@@ -7,15 +8,19 @@
|
|
|
7
8
|
* at boot (from the `AddonPackageService` + event bus, wired in `manual-boot`)
|
|
8
9
|
* and exposes it to every consumer.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.initLifecycleRunner = initLifecycleRunner;
|
|
13
|
+
exports.getLifecycleRunner = getLifecycleRunner;
|
|
14
|
+
exports.__resetLifecycleRunnerForTests = __resetLifecycleRunnerForTests;
|
|
15
|
+
const lifecycle_job_runner_js_1 = require("../../api/core/lifecycle-job-runner.js");
|
|
11
16
|
let instance = null;
|
|
12
17
|
/**
|
|
13
18
|
* Build the runner once. Idempotent: a second call returns the already-built
|
|
14
19
|
* instance and ignores the new deps (it does NOT rebuild).
|
|
15
20
|
*/
|
|
16
|
-
|
|
21
|
+
function initLifecycleRunner(deps) {
|
|
17
22
|
if (instance === null) {
|
|
18
|
-
instance = createLifecycleJobRunner(deps);
|
|
23
|
+
instance = (0, lifecycle_job_runner_js_1.createLifecycleJobRunner)(deps);
|
|
19
24
|
}
|
|
20
25
|
return instance;
|
|
21
26
|
}
|
|
@@ -23,13 +28,13 @@ export function initLifecycleRunner(deps) {
|
|
|
23
28
|
* Return the process-wide runner. Throws if `initLifecycleRunner` has not been
|
|
24
29
|
* called yet (boot wiring is expected to init it before any consumer runs).
|
|
25
30
|
*/
|
|
26
|
-
|
|
31
|
+
function getLifecycleRunner() {
|
|
27
32
|
if (instance === null) {
|
|
28
33
|
throw new Error('lifecycle runner not initialized — call initLifecycleRunner(deps) at boot before use');
|
|
29
34
|
}
|
|
30
35
|
return instance;
|
|
31
36
|
}
|
|
32
37
|
/** Test-only: reset the singleton between specs. */
|
|
33
|
-
|
|
38
|
+
function __resetLifecycleRunnerForTests() {
|
|
34
39
|
instance = null;
|
|
35
40
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LifecycleStateMachine = void 0;
|
|
1
4
|
// Re-export from @camstack/system — LifecycleStateMachine is already a plain class
|
|
2
|
-
|
|
5
|
+
var system_1 = require("@camstack/system");
|
|
6
|
+
Object.defineProperty(exports, "LifecycleStateMachine", { enumerable: true, get: function () { return system_1.LifecycleStateMachine; } });
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogRingBuffer = void 0;
|
|
1
4
|
// Re-export from @camstack/system
|
|
2
|
-
|
|
5
|
+
var system_1 = require("@camstack/system");
|
|
6
|
+
Object.defineProperty(exports, "LogRingBuffer", { enumerable: true, get: function () { return system_1.LogRingBuffer; } });
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggingService = void 0;
|
|
4
|
+
const system_1 = require("@camstack/system");
|
|
5
|
+
const types_1 = require("@camstack/types");
|
|
3
6
|
/** Baseline tags every hub-local logger gets, so console output never
|
|
4
7
|
* falls back to `?` for the agent slot. Hub-local addons already
|
|
5
8
|
* re-tag with their addonId; this ensures non-addon scopes (core
|
|
@@ -10,7 +13,7 @@ import { EventCategory } from '@camstack/types';
|
|
|
10
13
|
* forked workers via `$hub.log` carry their own `tags.pid` which
|
|
11
14
|
* wins over this baseline (right-biased merge in `writeFromWorker`). */
|
|
12
15
|
const HUB_BASELINE_TAGS = { agentId: 'hub', nodeId: 'hub', pid: process.pid };
|
|
13
|
-
|
|
16
|
+
class LoggingService extends system_1.LogManager {
|
|
14
17
|
/**
|
|
15
18
|
* Device-name cache consulted by the formatter when a log line
|
|
16
19
|
* carries `tags.deviceId` but no explicit `deviceName`. Populated
|
|
@@ -74,7 +77,7 @@ export class LoggingService extends LogManager {
|
|
|
74
77
|
*/
|
|
75
78
|
attachDeviceNameStream(eventBus) {
|
|
76
79
|
const selfLogger = this.createLogger('logging').withTags({ addonId: 'logging' });
|
|
77
|
-
eventBus.subscribe({ category: EventCategory.DeviceRegistered }, (event) => {
|
|
80
|
+
eventBus.subscribe({ category: types_1.EventCategory.DeviceRegistered }, (event) => {
|
|
78
81
|
const data = event.data;
|
|
79
82
|
if (data && typeof data.deviceId === 'number') {
|
|
80
83
|
this.upsertDeviceName(data.deviceId, data.name);
|
|
@@ -87,7 +90,7 @@ export class LoggingService extends LogManager {
|
|
|
87
90
|
});
|
|
88
91
|
}
|
|
89
92
|
});
|
|
90
|
-
eventBus.subscribe({ category: EventCategory.DeviceUnregistered }, (event) => {
|
|
93
|
+
eventBus.subscribe({ category: types_1.EventCategory.DeviceUnregistered }, (event) => {
|
|
91
94
|
const data = event.data;
|
|
92
95
|
if (data && typeof data.deviceId === 'number')
|
|
93
96
|
this.removeDeviceName(data.deviceId);
|
|
@@ -134,3 +137,4 @@ export class LoggingService extends LogManager {
|
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
}
|
|
140
|
+
exports.LoggingService = LoggingService;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScopedLogger = void 0;
|
|
1
4
|
// Re-export from @camstack/system
|
|
2
|
-
|
|
5
|
+
var system_1 = require("@camstack/system");
|
|
6
|
+
Object.defineProperty(exports, "ScopedLogger", { enumerable: true, get: function () { return system_1.ScopedLogger; } });
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterAgentAuthoritativeRecords = filterAgentAuthoritativeRecords;
|
|
1
4
|
const VALID_STATES = new Set(['starting', 'ready', 'down']);
|
|
2
5
|
const VALID_SCOPE_TYPES = new Set(['global', 'node', 'device']);
|
|
3
6
|
/** Structural validation for a record received from a remote node. */
|
|
@@ -24,7 +27,7 @@ function isWellFormedRecord(value) {
|
|
|
24
27
|
* Keep only the records `agentNodeId` is authoritative for, dropping
|
|
25
28
|
* malformed entries. See module doc for why this filter must exist.
|
|
26
29
|
*/
|
|
27
|
-
|
|
30
|
+
function filterAgentAuthoritativeRecords(records, agentNodeId) {
|
|
28
31
|
if (!Array.isArray(records))
|
|
29
32
|
return [];
|
|
30
33
|
return records.filter((record) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* The hub asks a (re)connected agent for its capability set.
|
|
3
4
|
*
|
|
@@ -17,7 +18,10 @@
|
|
|
17
18
|
* be asked: that is said, with whether the hub holds its registration, so an
|
|
18
19
|
* online-but-capless node is never silent.
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.AGENT_REQUEST_REGISTRATION_ACTION = void 0;
|
|
23
|
+
exports.requestAgentRegistration = requestAgentRegistration;
|
|
24
|
+
exports.AGENT_REQUEST_REGISTRATION_ACTION = '$agent.requestRegistration';
|
|
21
25
|
function errorType(err) {
|
|
22
26
|
if (typeof err !== 'object' || err === null)
|
|
23
27
|
return null;
|
|
@@ -28,9 +32,9 @@ function errorText(err) {
|
|
|
28
32
|
return err instanceof Error ? err.message : String(err);
|
|
29
33
|
}
|
|
30
34
|
/** Ask `nodeId` to re-send its complete capability manifest. Never throws. */
|
|
31
|
-
|
|
35
|
+
async function requestAgentRegistration(deps, nodeId) {
|
|
32
36
|
try {
|
|
33
|
-
await deps.call(AGENT_REQUEST_REGISTRATION_ACTION, {}, { nodeID: nodeId });
|
|
37
|
+
await deps.call(exports.AGENT_REQUEST_REGISTRATION_ACTION, {}, { nodeID: nodeId });
|
|
34
38
|
return 'requested';
|
|
35
39
|
}
|
|
36
40
|
catch (err) {
|