@camstack/server 1.2.594 → 1.2.595
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 +222 -218
- package/dist/api/trpc/generated-cap-routers.js +4856 -4676
- 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 +1 -1
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMeshTrpcContext = createMeshTrpcContext;
|
|
4
|
+
exports.createTrpcContext = createTrpcContext;
|
|
5
|
+
exports.createWsTrpcContext = createWsTrpcContext;
|
|
6
|
+
const system_1 = require("@camstack/system");
|
|
7
|
+
const types_1 = require("@camstack/types");
|
|
8
|
+
const auth_network_policy_js_1 = require("../../auth/auth-network-policy.js");
|
|
9
|
+
const share_token_service_js_1 = require("../../core/auth/share-token.service.js");
|
|
10
|
+
const request_lang_js_1 = require("../../i18n/request-lang.js");
|
|
11
|
+
const trpc_error_principal_js_1 = require("./trpc-error-principal.js");
|
|
7
12
|
/**
|
|
8
13
|
* Live-scope refresh memo (see the JWT branch of `resolveUser`).
|
|
9
14
|
*
|
|
@@ -31,7 +36,7 @@ async function refreshScopesFromStore(userId, addonRegistry) {
|
|
|
31
36
|
? (await userMgmt.listUsers()).find((u) => u.id === userId)
|
|
32
37
|
: null;
|
|
33
38
|
if (fresh)
|
|
34
|
-
scopes = normalizeTokenScopes(fresh.scopes ?? []);
|
|
39
|
+
scopes = (0, types_1.normalizeTokenScopes)(fresh.scopes ?? []);
|
|
35
40
|
}
|
|
36
41
|
catch {
|
|
37
42
|
scopes = null;
|
|
@@ -87,7 +92,7 @@ function extractTokenFromRequest(req) {
|
|
|
87
92
|
function requestFacts(req) {
|
|
88
93
|
if (req === undefined)
|
|
89
94
|
return {};
|
|
90
|
-
const ip = DEFAULT_AUTH_NETWORK_POLICY.clientAddress(req).ip;
|
|
95
|
+
const ip = auth_network_policy_js_1.DEFAULT_AUTH_NETWORK_POLICY.clientAddress(req).ip;
|
|
91
96
|
const url = req.url;
|
|
92
97
|
const path = typeof url === 'string' ? url.split('?')[0] : undefined;
|
|
93
98
|
return { ...(path !== undefined ? { path } : {}), ...(ip !== null ? { ip } : {}) };
|
|
@@ -98,7 +103,7 @@ function requestFacts(req) {
|
|
|
98
103
|
* an admin, not revoked, not expired) is local-auth's (`AdminTokenManager`).
|
|
99
104
|
*/
|
|
100
105
|
async function resolveAdminToken(token, addonRegistry, facts) {
|
|
101
|
-
const internal = getUserManagementInternal(addonRegistry.getCapabilityRegistry().getSingleton('user-management'));
|
|
106
|
+
const internal = (0, system_1.getUserManagementInternal)(addonRegistry.getCapabilityRegistry().getSingleton('user-management'));
|
|
102
107
|
if (internal === null)
|
|
103
108
|
return null;
|
|
104
109
|
const record = await internal.adminTokens.validate(token).catch(() => null);
|
|
@@ -128,13 +133,13 @@ async function resolveAdminToken(token, addonRegistry, facts) {
|
|
|
128
133
|
async function resolveUser(token, authService, addonRegistry, shareTokens = null, logger = null, facts = {}) {
|
|
129
134
|
if (!token)
|
|
130
135
|
return null;
|
|
131
|
-
if (token.startsWith(ADMIN_TOKEN_PREFIX))
|
|
136
|
+
if (token.startsWith(system_1.ADMIN_TOKEN_PREFIX))
|
|
132
137
|
return resolveAdminToken(token, addonRegistry, facts);
|
|
133
138
|
// Share-token path (`csv_*`): resolve through the ShareTokenService.
|
|
134
139
|
// The synthetic principal is maximally restricted — non-admin, no
|
|
135
140
|
// scopes; the `shareView` grant routes it into the fail-closed
|
|
136
141
|
// allowlist in `protectedProcedure` instead of the scope matcher.
|
|
137
|
-
if (token.startsWith(SHARE_TOKEN_PREFIX)) {
|
|
142
|
+
if (token.startsWith(share_token_service_js_1.SHARE_TOKEN_PREFIX)) {
|
|
138
143
|
if (!shareTokens)
|
|
139
144
|
return null;
|
|
140
145
|
try {
|
|
@@ -186,7 +191,7 @@ async function resolveUser(token, authService, addonRegistry, shareTokens = null
|
|
|
186
191
|
isScoped: true,
|
|
187
192
|
// Migrate any v2 `device:targets` grant to a v3 selector at the
|
|
188
193
|
// boundary so the enforcement matcher only ever sees v3.
|
|
189
|
-
scopes: normalizeTokenScopes(record.scopes),
|
|
194
|
+
scopes: (0, types_1.normalizeTokenScopes)(record.scopes),
|
|
190
195
|
};
|
|
191
196
|
}
|
|
192
197
|
catch {
|
|
@@ -207,7 +212,7 @@ async function resolveUser(token, authService, addonRegistry, shareTokens = null
|
|
|
207
212
|
}
|
|
208
213
|
// What the token IS decides both WHETHER it authenticates at all and
|
|
209
214
|
// WHERE its scopes come from.
|
|
210
|
-
const principal = classifyBearerPrincipal(payload);
|
|
215
|
+
const principal = (0, types_1.classifyBearerPrincipal)(payload);
|
|
211
216
|
// ── The allowlist ────────────────────────────────────────────────
|
|
212
217
|
// Every token this hub mints verifies under the same `auth.jwtSecret`, so
|
|
213
218
|
// `verifyToken` succeeding means "we minted this", never "this is an API
|
|
@@ -239,7 +244,7 @@ async function resolveUser(token, authService, addonRegistry, shareTokens = null
|
|
|
239
244
|
// What the token says it IS. An `oauth-access` token is an account link,
|
|
240
245
|
// and until this was carried onto the principal a refusal of one was
|
|
241
246
|
// indistinguishable in the logs from a refusal of a browser session.
|
|
242
|
-
const credential = readCredentialIdentity(payload);
|
|
247
|
+
const credential = (0, trpc_error_principal_js_1.readCredentialIdentity)(payload);
|
|
243
248
|
return {
|
|
244
249
|
id: payload.userId ?? 'unknown',
|
|
245
250
|
username: payload.username ?? 'unknown',
|
|
@@ -275,7 +280,7 @@ async function resolveUser(token, authService, addonRegistry, shareTokens = null
|
|
|
275
280
|
// Assistant grant with `[]` and the hub refused the component's first
|
|
276
281
|
// call with `Have: (none)` (2026-08-19). The user store knows nothing
|
|
277
282
|
// about a link and must not get a vote on one.
|
|
278
|
-
...(payload.scopes !== undefined ? { scopes: normalizeTokenScopes(payload.scopes) } : {}),
|
|
283
|
+
...(payload.scopes !== undefined ? { scopes: (0, types_1.normalizeTokenScopes)(payload.scopes) } : {}),
|
|
279
284
|
...(!payload.isAdmin && principal.kind === 'session'
|
|
280
285
|
? await (async () => {
|
|
281
286
|
const fresh = await refreshScopesFromStore(payload.userId ?? 'unknown', addonRegistry);
|
|
@@ -326,7 +331,7 @@ function makeDeviceScopeLookup(addonRegistry) {
|
|
|
326
331
|
* next step once the mesh census has measured what each node calls (D802).
|
|
327
332
|
* There is no HTTP request behind the call.
|
|
328
333
|
*/
|
|
329
|
-
|
|
334
|
+
function createMeshTrpcContext(principal = 'mesh') {
|
|
330
335
|
const user = {
|
|
331
336
|
id: principal,
|
|
332
337
|
username: principal,
|
|
@@ -337,12 +342,12 @@ export function createMeshTrpcContext(principal = 'mesh') {
|
|
|
337
342
|
return { user };
|
|
338
343
|
}
|
|
339
344
|
/** Context factory for HTTP tRPC requests (Fastify adapter). */
|
|
340
|
-
|
|
345
|
+
async function createTrpcContext(req, authService, addonRegistry, shareTokens = null, logger = null) {
|
|
341
346
|
const token = extractTokenFromRequest(req);
|
|
342
347
|
return {
|
|
343
348
|
user: await resolveUser(token, authService, addonRegistry, shareTokens, logger, requestFacts(req)),
|
|
344
349
|
req,
|
|
345
|
-
lang: resolveRequestLang(requestLangInputFrom(req.headers, readQuery(req))),
|
|
350
|
+
lang: (0, request_lang_js_1.resolveRequestLang)((0, request_lang_js_1.requestLangInputFrom)(req.headers, readQuery(req))),
|
|
346
351
|
deviceScopeLookup: makeDeviceScopeLookup(addonRegistry),
|
|
347
352
|
deviceFleet: () => addonRegistry.getPersistedDeviceList(),
|
|
348
353
|
};
|
|
@@ -352,7 +357,7 @@ export async function createTrpcContext(req, authService, addonRegistry, shareTo
|
|
|
352
357
|
* Token is sent via tRPC connectionParams (a JSON message sent right after
|
|
353
358
|
* the WS handshake), which is more reliable than query params through proxies.
|
|
354
359
|
*/
|
|
355
|
-
|
|
360
|
+
async function createWsTrpcContext(opts, authService, addonRegistry, shareTokens = null, logger = null) {
|
|
356
361
|
// 1. connectionParams.token (sent by BackendClient's createWSClient)
|
|
357
362
|
const paramToken = opts.info.connectionParams?.['token'];
|
|
358
363
|
const token = (typeof paramToken === 'string' ? paramToken : null) ?? extractTokenFromRequest(opts.req);
|
|
@@ -361,7 +366,7 @@ export async function createWsTrpcContext(opts, authService, addonRegistry, shar
|
|
|
361
366
|
return {
|
|
362
367
|
user,
|
|
363
368
|
req: opts.req,
|
|
364
|
-
lang: resolveRequestLang(requestLangInputFrom(opts.req.headers, readQuery(opts.req), opts.info.connectionParams?.['lang'])),
|
|
369
|
+
lang: (0, request_lang_js_1.resolveRequestLang)((0, request_lang_js_1.requestLangInputFrom)(opts.req.headers, readQuery(opts.req), opts.info.connectionParams?.['lang'])),
|
|
365
370
|
...(user === null && token !== null && token !== '' ? { credentialRejected: true } : {}),
|
|
366
371
|
...(user !== null && sessionId !== undefined
|
|
367
372
|
? {
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.adminProcedure = exports.protectedProcedure = exports.createCallerFactory = exports.publicProcedure = exports.trpcRouter = void 0;
|
|
7
|
+
exports.iterableSubscription = iterableSubscription;
|
|
8
|
+
exports.iterableInterval = iterableInterval;
|
|
9
|
+
const system_1 = require("@camstack/system");
|
|
10
|
+
const types_1 = require("@camstack/types");
|
|
11
|
+
const server_1 = require("@trpc/server");
|
|
12
|
+
const superjson_1 = __importDefault(require("superjson"));
|
|
13
|
+
const cap_route_error_formatter_js_1 = require("./cap-route-error-formatter.js");
|
|
14
|
+
const device_config_secret_redaction_js_1 = require("./device-config-secret-redaction.js");
|
|
15
|
+
const principal_visibility_js_1 = require("./principal-visibility.js");
|
|
16
|
+
const localized_schema_paths_js_1 = require("./localized-schema-paths.js");
|
|
17
|
+
const scope_access_js_1 = require("./scope-access.js");
|
|
18
|
+
const share_view_access_js_1 = require("./share-view-access.js");
|
|
19
|
+
const user_error_js_1 = require("./user-error.js");
|
|
20
|
+
const t = server_1.initTRPC.context().create({
|
|
21
|
+
transformer: superjson_1.default,
|
|
22
|
+
errorFormatter: cap_route_error_formatter_js_1.formatTrpcError,
|
|
15
23
|
});
|
|
16
24
|
// ---------------------------------------------------------------------------
|
|
17
25
|
// Async-generator subscription helpers (tRPC v11 — replaces deprecated observable)
|
|
@@ -22,7 +30,7 @@ const t = initTRPC.context().create({
|
|
|
22
30
|
*
|
|
23
31
|
* @param subscribe — called once; receives a `push` callback and must return an unsubscribe fn.
|
|
24
32
|
*/
|
|
25
|
-
|
|
33
|
+
async function* iterableSubscription(subscribe) {
|
|
26
34
|
const queue = [];
|
|
27
35
|
let resolve = null;
|
|
28
36
|
const unsub = subscribe((value) => {
|
|
@@ -47,7 +55,7 @@ export async function* iterableSubscription(subscribe) {
|
|
|
47
55
|
* Create an interval-based async generator that yields a value on each tick.
|
|
48
56
|
* Useful for polling subscriptions.
|
|
49
57
|
*/
|
|
50
|
-
|
|
58
|
+
async function* iterableInterval(intervalMs, getValue) {
|
|
51
59
|
try {
|
|
52
60
|
while (true) {
|
|
53
61
|
yield getValue();
|
|
@@ -66,22 +74,22 @@ export async function* iterableInterval(intervalMs, getValue) {
|
|
|
66
74
|
*/
|
|
67
75
|
const localizeSchemaOutput = t.middleware(async ({ ctx, path, next }) => {
|
|
68
76
|
const out = await next();
|
|
69
|
-
const lang = ctx.lang ?? DEFAULT_CATALOG_LANG;
|
|
70
|
-
if (!out.ok || lang === DEFAULT_CATALOG_LANG || !LOCALIZED_SCHEMA_PATHS.has(path))
|
|
77
|
+
const lang = ctx.lang ?? types_1.DEFAULT_CATALOG_LANG;
|
|
78
|
+
if (!out.ok || lang === types_1.DEFAULT_CATALOG_LANG || !localized_schema_paths_js_1.LOCALIZED_SCHEMA_PATHS.has(path))
|
|
71
79
|
return out;
|
|
72
|
-
return { ...out, data: localizeConfigTree(out.data, getCatalogRegistry().lookupFor(lang)) };
|
|
80
|
+
return { ...out, data: (0, types_1.localizeConfigTree)(out.data, (0, system_1.getCatalogRegistry)().lookupFor(lang)) };
|
|
73
81
|
});
|
|
74
82
|
/** Every authenticated procedure starts from here, so the localizing middleware is the outermost. */
|
|
75
83
|
const localized = t.procedure.use(localizeSchemaOutput);
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
exports.trpcRouter = t.router;
|
|
85
|
+
exports.publicProcedure = t.procedure;
|
|
78
86
|
/**
|
|
79
87
|
* Server-side caller factory — turns the hub appRouter into a directly
|
|
80
88
|
* invokable record under a supplied `TrpcContext`. The core-cap bridge
|
|
81
89
|
* (`core-cap-bridge.ts`) uses it to expose core routers over the
|
|
82
90
|
* Moleculer mesh without an HTTP round-trip.
|
|
83
91
|
*/
|
|
84
|
-
|
|
92
|
+
exports.createCallerFactory = t.createCallerFactory;
|
|
85
93
|
/**
|
|
86
94
|
* Caps-only authenticated procedure (v2).
|
|
87
95
|
*
|
|
@@ -102,15 +110,15 @@ export const createCallerFactory = t.createCallerFactory;
|
|
|
102
110
|
* Single source of authority for caps: `isAdmin`. The legacy role enum
|
|
103
111
|
* collapsed onto this boolean in v2.
|
|
104
112
|
*/
|
|
105
|
-
|
|
113
|
+
exports.protectedProcedure = localized.use(async ({ ctx, next, path, getRawInput }) => {
|
|
106
114
|
if (!ctx.user) {
|
|
107
|
-
throw new TRPCError({ code: 'UNAUTHORIZED' });
|
|
115
|
+
throw new server_1.TRPCError({ code: 'UNAUTHORIZED' });
|
|
108
116
|
}
|
|
109
117
|
// A WebSocket resolves its principal once, at connect. Its login session is
|
|
110
118
|
// re-checked on every call, so a logout or revocation ends a socket that is
|
|
111
119
|
// already open — not only the next one.
|
|
112
120
|
if (ctx.sessionLive !== undefined && !ctx.sessionLive()) {
|
|
113
|
-
throw trpcUserError('UNAUTHORIZED', 'auth.session-ended', undefined, 'Session ended — sign in again');
|
|
121
|
+
throw (0, user_error_js_1.trpcUserError)('UNAUTHORIZED', 'auth.session-ended', undefined, 'Session ended — sign in again');
|
|
114
122
|
}
|
|
115
123
|
// Share-view principals (`csv_*` tokens) NEVER reach the admin bypass,
|
|
116
124
|
// the hand-written-route pass-through, or the scope matcher below —
|
|
@@ -118,9 +126,9 @@ export const protectedProcedure = localized.use(async ({ ctx, next, path, getRaw
|
|
|
118
126
|
// (`share-view-access.ts`): enumerated methods only, in-scope devices only.
|
|
119
127
|
if (ctx.user.shareView) {
|
|
120
128
|
const rawInput = await getRawInput();
|
|
121
|
-
const result = checkShareViewAccess(ctx.user.shareView.scope, path, rawInput);
|
|
129
|
+
const result = (0, share_view_access_js_1.checkShareViewAccess)(ctx.user.shareView.scope, path, rawInput);
|
|
122
130
|
if (!result.ok) {
|
|
123
|
-
throw new TRPCError({ code: 'FORBIDDEN', message: result.reason });
|
|
131
|
+
throw new server_1.TRPCError({ code: 'FORBIDDEN', message: result.reason });
|
|
124
132
|
}
|
|
125
133
|
// `deviceManager.listAll` is allowlisted for the embed's tile names,
|
|
126
134
|
// but its raw rows describe EVERY device (config incl. credentials).
|
|
@@ -128,7 +136,7 @@ export const protectedProcedure = localized.use(async ({ ctx, next, path, getRaw
|
|
|
128
136
|
if (path === 'deviceManager.listAll') {
|
|
129
137
|
const out = await next({ ctx: { ...ctx, user: ctx.user } });
|
|
130
138
|
if (out.ok) {
|
|
131
|
-
return { ...out, data: projectListAllForShareScope(out.data, ctx.user.shareView.scope) };
|
|
139
|
+
return { ...out, data: (0, share_view_access_js_1.projectListAllForShareScope)(out.data, ctx.user.shareView.scope) };
|
|
132
140
|
}
|
|
133
141
|
return out;
|
|
134
142
|
}
|
|
@@ -139,10 +147,10 @@ export const protectedProcedure = localized.use(async ({ ctx, next, path, getRaw
|
|
|
139
147
|
// those calls through — this is where the answer is cut. Without it the
|
|
140
148
|
// allowlist would be a doorman who checks the ticket and then hands over
|
|
141
149
|
// the whole building.
|
|
142
|
-
if (SHARE_SCOPE_PROJECTED_METHODS.has(path)) {
|
|
150
|
+
if (share_view_access_js_1.SHARE_SCOPE_PROJECTED_METHODS.has(path)) {
|
|
143
151
|
const out = await next({ ctx: { ...ctx, user: ctx.user } });
|
|
144
152
|
if (out.ok) {
|
|
145
|
-
return { ...out, data: projectShareScopeRows(out.data, ctx.user.shareView.scope) };
|
|
153
|
+
return { ...out, data: (0, share_view_access_js_1.projectShareScopeRows)(out.data, ctx.user.shareView.scope) };
|
|
146
154
|
}
|
|
147
155
|
return out;
|
|
148
156
|
}
|
|
@@ -160,16 +168,16 @@ export const protectedProcedure = localized.use(async ({ ctx, next, path, getRaw
|
|
|
160
168
|
// already passed; defer further gating to any explicit
|
|
161
169
|
// `adminProcedure` chained on top of this one. A cap route is
|
|
162
170
|
// scope-matched first.
|
|
163
|
-
if (path in METHOD_ACCESS_MAP) {
|
|
171
|
+
if (path in system_1.METHOD_ACCESS_MAP) {
|
|
164
172
|
// Device-scope caps may be gated by a `device:N` scope. Resolve the
|
|
165
173
|
// raw input once so the matcher can read `input.deviceId` without
|
|
166
174
|
// re-doing the Zod parse (tRPC caches the parsed input downstream).
|
|
167
175
|
// The `getDeviceAncestors` hook lets the matcher walk parent → child
|
|
168
176
|
// accessory inheritance (grant on Reolink also covers its siren / PIR).
|
|
169
177
|
const rawInput = await getRawInput();
|
|
170
|
-
const result = checkScopeAccess(ctx.user.scopes ?? [], path, rawInput, ctx.deviceScopeLookup);
|
|
178
|
+
const result = (0, scope_access_js_1.checkScopeAccess)(ctx.user.scopes ?? [], path, rawInput, ctx.deviceScopeLookup);
|
|
171
179
|
if (!result.ok) {
|
|
172
|
-
throw new TRPCError({ code: 'FORBIDDEN', message: result.reason });
|
|
180
|
+
throw new server_1.TRPCError({ code: 'FORBIDDEN', message: result.reason });
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
// A non-admin who is allowed to READ a device is not thereby allowed to
|
|
@@ -179,7 +187,7 @@ export const protectedProcedure = localized.use(async ({ ctx, next, path, getRaw
|
|
|
179
187
|
// every camera in the deployment. The value is withheld HERE, at the
|
|
180
188
|
// transport boundary, so in-process callers (`ctx.api`, the pipeline
|
|
181
189
|
// orchestrator, the drivers that must actually connect) are unaffected.
|
|
182
|
-
const redactConfigSecrets = NON_ADMIN_CONFIG_REDACTED_METHODS.get(path);
|
|
190
|
+
const redactConfigSecrets = device_config_secret_redaction_js_1.NON_ADMIN_CONFIG_REDACTED_METHODS.get(path);
|
|
183
191
|
const out = await next({ ctx: { ...ctx, user: ctx.user } });
|
|
184
192
|
if (!out.ok)
|
|
185
193
|
return out;
|
|
@@ -187,8 +195,8 @@ export const protectedProcedure = localized.use(async ({ ctx, next, path, getRaw
|
|
|
187
195
|
// matcher lets a `device`-selector grant reach `deviceManager.listAll`
|
|
188
196
|
// precisely because the answer is cut here; without this the grant would
|
|
189
197
|
// hand back the whole fleet — names, locations, online state.
|
|
190
|
-
if (DEVICE_ENUMERATION_METHODS.has(path)) {
|
|
191
|
-
const projected = projectListAllForPrincipal(out.data, ctx.user.isAdmin, ctx.user.scopes ?? [], ctx.deviceFleet?.() ?? []);
|
|
198
|
+
if (scope_access_js_1.DEVICE_ENUMERATION_METHODS.has(path)) {
|
|
199
|
+
const projected = (0, principal_visibility_js_1.projectListAllForPrincipal)(out.data, ctx.user.isAdmin, ctx.user.scopes ?? [], ctx.deviceFleet?.() ?? []);
|
|
192
200
|
return {
|
|
193
201
|
...out,
|
|
194
202
|
data: redactConfigSecrets ? redactConfigSecrets(projected) : projected,
|
|
@@ -209,9 +217,9 @@ export const protectedProcedure = localized.use(async ({ ctx, next, path, getRaw
|
|
|
209
217
|
* `protectedProcedure`. Useful on hand-written routes whose admin-only
|
|
210
218
|
* nature should be obvious to a code reader.
|
|
211
219
|
*/
|
|
212
|
-
|
|
220
|
+
exports.adminProcedure = exports.protectedProcedure.use(({ ctx, next }) => {
|
|
213
221
|
if (!ctx.user.isAdmin) {
|
|
214
|
-
throw trpcUserError('FORBIDDEN', 'auth.admin-required', undefined, 'Admin required');
|
|
222
|
+
throw (0, user_error_js_1.trpcUserError)('FORBIDDEN', 'auth.admin-required', undefined, 'Admin required');
|
|
215
223
|
}
|
|
216
224
|
return next({ ctx });
|
|
217
225
|
});
|
|
@@ -1,25 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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.enrichInputWithUserAgent = enrichInputWithUserAgent;
|
|
37
|
+
exports.enrichInputWithRelayClass = enrichInputWithRelayClass;
|
|
38
|
+
exports.stripTalkbackFromRequest = stripTalkbackFromRequest;
|
|
39
|
+
exports.enrichHintsWithClientClass = enrichHintsWithClientClass;
|
|
40
|
+
exports.wrapWebrtcSessionProviderWithRelay = wrapWebrtcSessionProviderWithRelay;
|
|
41
|
+
exports.buildAppRouter = buildAppRouter;
|
|
42
|
+
const path = __importStar(require("node:path"));
|
|
43
|
+
const addon_settings_router_js_1 = require("../core/addon-settings.router.js");
|
|
44
|
+
const session_connections_js_1 = require("../../auth/session-connections.js");
|
|
45
|
+
const agent_pairing_router_js_1 = require("../core/agent-pairing.router.js");
|
|
46
|
+
const certificates_router_js_1 = require("../core/certificates.router.js");
|
|
47
|
+
const node_certificates_client_js_1 = require("../../core/agent/node-certificates-client.js");
|
|
48
|
+
const auth_router_js_1 = require("../core/auth.router.js");
|
|
49
|
+
const cap_providers_js_1 = require("../core/cap-providers.js");
|
|
50
|
+
const capabilities_router_js_1 = require("../core/capabilities.router.js");
|
|
51
|
+
const cluster_nodes_router_js_1 = require("../core/cluster-nodes.router.js");
|
|
52
|
+
const event_bus_proxy_router_js_1 = require("../core/event-bus-proxy.router.js");
|
|
53
|
+
const hwaccel_router_js_1 = require("../core/hwaccel.router.js");
|
|
54
|
+
const live_events_router_js_1 = require("../core/live-events.router.js");
|
|
55
|
+
const logs_router_js_1 = require("../core/logs.router.js");
|
|
56
|
+
const notifications_router_js_1 = require("../core/notifications.router.js");
|
|
57
|
+
const repl_router_js_1 = require("../core/repl.router.js");
|
|
58
|
+
const server_management_provider_js_1 = require("../core/server-management.provider.js");
|
|
59
|
+
const stream_probe_router_js_1 = require("../core/stream-probe.router.js");
|
|
60
|
+
const system_events_router_js_1 = require("../core/system-events.router.js");
|
|
61
|
+
const cap_router_runtime_js_1 = require("./cap-router-runtime.js");
|
|
62
|
+
const client_ip_js_1 = require("./client-ip.js");
|
|
63
|
+
const trpc_middleware_1 = require("./trpc.middleware");
|
|
23
64
|
/**
|
|
24
65
|
* Merge the server-read User-Agent into a signaling call's
|
|
25
66
|
* `consumerAttribution`, building a NEW input object (immutable — never
|
|
@@ -28,7 +69,7 @@ import { trpcRouter } from './trpc.middleware';
|
|
|
28
69
|
* unchanged. Any client-supplied `userAgent` is OVERWRITTEN — the hub
|
|
29
70
|
* trusts only the request context, never the client.
|
|
30
71
|
*/
|
|
31
|
-
|
|
72
|
+
function enrichInputWithUserAgent(input, userAgent) {
|
|
32
73
|
if (userAgent === null)
|
|
33
74
|
return input;
|
|
34
75
|
const base = input.consumerAttribution ?? { kind: 'webrtc-browser' };
|
|
@@ -87,10 +128,10 @@ const FORCE_RELAY_REMOTE = process.env.CAMSTACK_FORCE_RELAY_REMOTE === '1' ||
|
|
|
87
128
|
*
|
|
88
129
|
* Immutable — builds a NEW input object, never mutates the caller's.
|
|
89
130
|
*/
|
|
90
|
-
|
|
131
|
+
function enrichInputWithRelayClass(input, clientClass) {
|
|
91
132
|
if (clientClass === null)
|
|
92
133
|
return input;
|
|
93
|
-
const relayOnly = FORCE_RELAY_REMOTE ? deriveRelayOnly(clientClass) : false;
|
|
134
|
+
const relayOnly = FORCE_RELAY_REMOTE ? (0, client_ip_js_1.deriveRelayOnly)(clientClass) : false;
|
|
94
135
|
return { ...input, relayOnly };
|
|
95
136
|
}
|
|
96
137
|
/**
|
|
@@ -106,7 +147,7 @@ export function enrichInputWithRelayClass(input, clientClass) {
|
|
|
106
147
|
*
|
|
107
148
|
* Immutable — builds a NEW input object, never mutates the caller's.
|
|
108
149
|
*/
|
|
109
|
-
|
|
150
|
+
function stripTalkbackFromRequest(input, clientClass) {
|
|
110
151
|
if (clientClass === null || input.talkback === undefined)
|
|
111
152
|
return input;
|
|
112
153
|
const { talkback: _dropped, ...rest } = input;
|
|
@@ -120,7 +161,7 @@ export function stripTalkbackFromRequest(input, clientClass) {
|
|
|
120
161
|
* stays as the documented seam so a future probe can still thread class
|
|
121
162
|
* without a cap change; today it is a no-op.
|
|
122
163
|
*/
|
|
123
|
-
|
|
164
|
+
function enrichHintsWithClientClass(input, _clientClass) {
|
|
124
165
|
return input;
|
|
125
166
|
}
|
|
126
167
|
/**
|
|
@@ -156,16 +197,16 @@ export function enrichHintsWithClientClass(input, _clientClass) {
|
|
|
156
197
|
* All OTHER methods delegate straight through — auth, the remote-proxy
|
|
157
198
|
* factory and every signaling behaviour are untouched.
|
|
158
199
|
*/
|
|
159
|
-
|
|
160
|
-
const userAgent = extractUserAgent(ctx.req);
|
|
161
|
-
const clientClass = classifyClientRequest(ctx.req);
|
|
200
|
+
function wrapWebrtcSessionProviderWithRelay(provider, ctx) {
|
|
201
|
+
const userAgent = (0, client_ip_js_1.extractUserAgent)(ctx.req);
|
|
202
|
+
const clientClass = (0, client_ip_js_1.classifyClientRequest)(ctx.req);
|
|
162
203
|
// The login session this request runs under: media opened here dies with it
|
|
163
204
|
// (`session-connections.ts`). A principal with no `sid` has nothing to tie to.
|
|
164
205
|
const authSessionId = ctx.user?.sessionId;
|
|
165
206
|
const hold = (deviceId, mediaSessionId) => {
|
|
166
207
|
if (authSessionId === undefined)
|
|
167
208
|
return;
|
|
168
|
-
getSessionConnections().trackMedia(authSessionId, {
|
|
209
|
+
(0, session_connections_js_1.getSessionConnections)().trackMedia(authSessionId, {
|
|
169
210
|
deviceId,
|
|
170
211
|
mediaSessionId,
|
|
171
212
|
close: () => provider.closeSession({ deviceId, sessionId: mediaSessionId }),
|
|
@@ -185,7 +226,7 @@ export function wrapWebrtcSessionProviderWithRelay(provider, ctx) {
|
|
|
185
226
|
},
|
|
186
227
|
closeSession: (input) => {
|
|
187
228
|
if (authSessionId !== undefined) {
|
|
188
|
-
getSessionConnections().forgetMedia(authSessionId, input.sessionId);
|
|
229
|
+
(0, session_connections_js_1.getSessionConnections)().forgetMedia(authSessionId, input.sessionId);
|
|
189
230
|
}
|
|
190
231
|
return provider.closeSession(input);
|
|
191
232
|
},
|
|
@@ -206,14 +247,14 @@ export function wrapWebrtcSessionProviderWithRelay(provider, ctx) {
|
|
|
206
247
|
function buildServerProviders(services) {
|
|
207
248
|
const wrap = (fn) => (ctx) => fn(ctx);
|
|
208
249
|
return {
|
|
209
|
-
'network-quality': wrap(() => buildNetworkQualityProvider(services.networkQualityService)),
|
|
210
|
-
system: wrap(() => buildSystemProvider(services.featureService, services.capabilityRegistry, services.loggingService.createLogger('site-location'))),
|
|
211
|
-
toast: wrap((ctx) => buildToastProvider(services.toastService, ctx)),
|
|
212
|
-
integrations: wrap(() => buildIntegrationsProvider(services.addonRegistry, services.eventBus, services.loggingService, services.capabilityRegistry)),
|
|
213
|
-
nodes: wrap(() => buildNodesProvider(services.agentRegistry, services.moleculer, services.addonRegistry, createNodeRootPackageLookup(services.moleculer, services.serverUpdateService), services.loggingService.createLogger('nodes'))),
|
|
250
|
+
'network-quality': wrap(() => (0, cap_providers_js_1.buildNetworkQualityProvider)(services.networkQualityService)),
|
|
251
|
+
system: wrap(() => (0, cap_providers_js_1.buildSystemProvider)(services.featureService, services.capabilityRegistry, services.loggingService.createLogger('site-location'))),
|
|
252
|
+
toast: wrap((ctx) => (0, cap_providers_js_1.buildToastProvider)(services.toastService, ctx)),
|
|
253
|
+
integrations: wrap(() => (0, cap_providers_js_1.buildIntegrationsProvider)(services.addonRegistry, services.eventBus, services.loggingService, services.capabilityRegistry)),
|
|
254
|
+
nodes: wrap(() => (0, cap_providers_js_1.buildNodesProvider)(services.agentRegistry, services.moleculer, services.addonRegistry, (0, cap_providers_js_1.createNodeRootPackageLookup)(services.moleculer, services.serverUpdateService), services.loggingService.createLogger('nodes'))),
|
|
214
255
|
// server-management — runtime-updatable root package (phase 1: hub only).
|
|
215
|
-
'server-management': wrap(() => buildServerManagementProvider(services.serverUpdateService)),
|
|
216
|
-
addons: wrap((ctx) => buildAddonsProvider(services.addonRegistry, services.addonPackageService, services.loggingService, services.moleculer, services.configService, ctx, services.agentRegistry)),
|
|
256
|
+
'server-management': wrap(() => (0, server_management_provider_js_1.buildServerManagementProvider)(services.serverUpdateService)),
|
|
257
|
+
addons: wrap((ctx) => (0, cap_providers_js_1.buildAddonsProvider)(services.addonRegistry, services.addonPackageService, services.loggingService, services.moleculer, services.configService, ctx, services.agentRegistry)),
|
|
217
258
|
// webrtc-session — the resolved broker singleton, wrapped per request to
|
|
218
259
|
// inject the server-read User-Agent into signaling attribution (the broker
|
|
219
260
|
// is a forked addon that can't see the HTTP request). Cross-node (agent-
|
|
@@ -255,7 +296,7 @@ function buildCapabilityRouters(services) {
|
|
|
255
296
|
// (`import type`) — its value is never called; the codegen
|
|
256
297
|
// `generated-cap-mounts.ts` / `generated-cap-routers.ts` remain the TYPE
|
|
257
298
|
// source of record.
|
|
258
|
-
const dynamicCaps = buildRuntimeCapRouters({
|
|
299
|
+
const dynamicCaps = (0, cap_router_runtime_js_1.buildRuntimeCapRouters)({
|
|
259
300
|
capabilityRegistry: services.capabilityRegistry,
|
|
260
301
|
moleculer: services.moleculer,
|
|
261
302
|
serverProviders: buildServerProviders(services),
|
|
@@ -270,44 +311,44 @@ function buildCapabilityRouters(services) {
|
|
|
270
311
|
// by `buildServerProviders`. ──────
|
|
271
312
|
...dynamicCaps,
|
|
272
313
|
// ── Non-cap (core) routers — hand-written, single-impl ──────────
|
|
273
|
-
notifications: createNotificationsRouter(services.notificationService),
|
|
314
|
+
notifications: (0, notifications_router_js_1.createNotificationsRouter)(services.notificationService),
|
|
274
315
|
// Raw DB proxy for forked workers to read/write addon store.
|
|
275
316
|
// Workers use ctx.api.addonSettingsRaw.getGlobal.query({...}).
|
|
276
317
|
// NOT the three-level settings gateway — that's the
|
|
277
318
|
// `addonSettings` cap router (mounted dynamically above).
|
|
278
|
-
addonSettingsRaw: createAddonSettingsRouter(services.configService),
|
|
279
|
-
eventBusProxy: createEventBusProxyRouter(services.eventBus),
|
|
280
|
-
repl: createReplRouter(services.replEngine),
|
|
281
|
-
systemEvents: createSystemEventsRouter(services.eventBus),
|
|
282
|
-
capabilities: createCapabilitiesRouter(services.capabilityRegistry, services.configService),
|
|
283
|
-
logs: createLogsRouter(services.loggingService),
|
|
284
|
-
live: createLiveEventsRouter(services.eventBus, services.addonRegistry),
|
|
319
|
+
addonSettingsRaw: (0, addon_settings_router_js_1.createAddonSettingsRouter)(services.configService),
|
|
320
|
+
eventBusProxy: (0, event_bus_proxy_router_js_1.createEventBusProxyRouter)(services.eventBus),
|
|
321
|
+
repl: (0, repl_router_js_1.createReplRouter)(services.replEngine),
|
|
322
|
+
systemEvents: (0, system_events_router_js_1.createSystemEventsRouter)(services.eventBus),
|
|
323
|
+
capabilities: (0, capabilities_router_js_1.createCapabilitiesRouter)(services.capabilityRegistry, services.configService),
|
|
324
|
+
logs: (0, logs_router_js_1.createLogsRouter)(services.loggingService),
|
|
325
|
+
live: (0, live_events_router_js_1.createLiveEventsRouter)(services.eventBus, services.addonRegistry),
|
|
285
326
|
// stream-probe — fixed core API (ffprobe wrapper), not a cap.
|
|
286
|
-
streamProbe: createStreamProbeRouter(services.streamProbe),
|
|
327
|
+
streamProbe: (0, stream_probe_router_js_1.createStreamProbeRouter)(services.streamProbe),
|
|
287
328
|
// hwaccel — fixed core API, repointed onto the `platform-probe` cap
|
|
288
329
|
// (the sole cross-node-pinnable hwaccel surface). UI pipeline /
|
|
289
330
|
// NodeDetail pages query per-node to show which hardware backend each
|
|
290
331
|
// agent will use.
|
|
291
|
-
hwaccel: createHwAccelRouter(services.capabilityRegistry, services.moleculer),
|
|
332
|
+
hwaccel: (0, hwaccel_router_js_1.createHwAccelRouter)(services.capabilityRegistry, services.moleculer),
|
|
292
333
|
// clusterNodes — fixed core API. Write-side purge for the durable
|
|
293
334
|
// offline-node history (Track A "Forget node"); read side is push-only.
|
|
294
|
-
clusterNodes: createClusterNodesRouter(services.agentRegistry),
|
|
335
|
+
clusterNodes: (0, cluster_nodes_router_js_1.createClusterNodesRouter)(services.agentRegistry),
|
|
295
336
|
// certificates - Identity -> Certificates inventory (HTTPS per node, mesh CA). D855.
|
|
296
|
-
certificates: createCertificatesRouter({
|
|
337
|
+
certificates: (0, certificates_router_js_1.createCertificatesRouter)({
|
|
297
338
|
registry: services.capabilityRegistry,
|
|
298
339
|
agentRegistry: services.agentRegistry,
|
|
299
|
-
nodeClient: (nodeId) => createNodeCertificatesClient(services.moleculer, nodeId),
|
|
340
|
+
nodeClient: (nodeId) => (0, node_certificates_client_js_1.createNodeCertificatesClient)(services.moleculer, nodeId),
|
|
300
341
|
nodeAddonIds: (nodeId) => services.moleculer.getNodeAddonIds(nodeId),
|
|
301
342
|
hubDataDir: path.resolve(services.configService.get('server.dataPath') ?? 'camstack-data'),
|
|
302
343
|
log: services.loggingService.createLogger('certificates'),
|
|
303
344
|
}),
|
|
304
345
|
// agentPairing - hub-initiated pairing of agents, unpairing (D857).
|
|
305
|
-
agentPairing: createAgentPairingRouter({
|
|
346
|
+
agentPairing: (0, agent_pairing_router_js_1.createAgentPairingRouter)({
|
|
306
347
|
registry: services.capabilityRegistry,
|
|
307
|
-
nodeClient: (nodeId) => createNodeCertificatesClient(services.moleculer, nodeId),
|
|
348
|
+
nodeClient: (nodeId) => (0, node_certificates_client_js_1.createNodeCertificatesClient)(services.moleculer, nodeId),
|
|
308
349
|
log: services.loggingService.createLogger('agent-pairing'),
|
|
309
350
|
}),
|
|
310
|
-
auth: createAuthRouter(services.authService, services.capabilityRegistry, services.moleculer, services.shareTokenService, services.handoffCodeService, services.externalLinkIntents, services.nativeLink ?? null, {
|
|
351
|
+
auth: (0, auth_router_js_1.createAuthRouter)(services.authService, services.capabilityRegistry, services.moleculer, services.shareTokenService, services.handoffCodeService, services.externalLinkIntents, services.nativeLink ?? null, {
|
|
311
352
|
...(services.authNetworkPolicy !== undefined
|
|
312
353
|
? { network: services.authNetworkPolicy }
|
|
313
354
|
: {}),
|
|
@@ -322,8 +363,8 @@ function buildCapabilityRouters(services) {
|
|
|
322
363
|
// - restreamer / streaming-engine / webrtc
|
|
323
364
|
};
|
|
324
365
|
}
|
|
325
|
-
|
|
326
|
-
return trpcRouter({
|
|
366
|
+
function buildAppRouter(services) {
|
|
367
|
+
return (0, trpc_middleware_1.trpcRouter)({
|
|
327
368
|
...buildCapabilityRouters(services),
|
|
328
369
|
});
|
|
329
370
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trpcUserError = trpcUserError;
|
|
4
|
+
const server_1 = require("@trpc/server");
|
|
5
|
+
const types_1 = require("@camstack/types");
|
|
3
6
|
/**
|
|
4
7
|
* A `TRPCError` that carries a stable i18n code (D863). `message` stays the
|
|
5
8
|
* English text; the error formatter swaps it for the `server` catalog text in
|
|
6
9
|
* the request language and keeps `{ code, params }` in `data.i18n`.
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
return new TRPCError({
|
|
11
|
+
function trpcUserError(trpcCode, i18nCode, params, englishFallback) {
|
|
12
|
+
return new server_1.TRPCError({
|
|
10
13
|
code: trpcCode,
|
|
11
14
|
message: englishFallback,
|
|
12
|
-
cause: userError(i18nCode, params, englishFallback),
|
|
15
|
+
cause: (0, types_1.userError)(i18nCode, params, englishFallback),
|
|
13
16
|
});
|
|
14
17
|
}
|