@xopcai/xopc 0.0.254 → 0.0.256
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-Ci5Rxmi_.js → activity-store-DYb6xFC3.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D82jpmFL.js → agent-avatar-dicebear-BZJZvmYw.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Bq7GNF1L.js +1 -0
- package/dist/gateway/static/root/assets/{agents-p3kWyz1T.js → agents-1vtaw07m.js} +1 -1
- package/dist/gateway/static/root/assets/{api-CXIzQJ2Z.js → api-NADZ8X8B.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-mhxcQpkQ.js → app-management-settings-panel-DG64SQsx.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BIMwACUF.js → appearance-settings-BRWQdIIy.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-D3ziBisx.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C63Xp_sU.js → archive-plugin-D3FQ9VzV.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-D12KYOav.js → attachment-load-Cid3dBaW.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DXj0o5CY.js → automations-page-BUTNaZtj.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-D4NJSE8l.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Bcv8hun6.js → binary-plugins-BSYMCuaB.js} +1 -1
- package/dist/gateway/static/root/assets/block-editor-qDlC3t7b.js +159 -0
- package/dist/gateway/static/root/assets/{browser-automation-inputs-CAclu735.js → browser-automation-inputs-rA2QROKe.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BITfKX8L.js → browser-automations-page-Du1KVE01.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-WZ0Jt5Hp.js +8 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D1AYoRx4.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-CZnlYu2L.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-Cmbx0E8O.js → channels-status-swr-B2aMPOSM.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CNBgHN9U.js → chat-terminal-dock-CY-I_bCe.js} +2 -2
- package/dist/gateway/static/root/assets/{chunk-KS7C4IRE-BaASWQor.js → chunk-KS7C4IRE-Cq1tE_3b.js} +2 -2
- package/dist/gateway/static/root/assets/code-editor-CXIH8jQw.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-CkH3gaqs.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DCTN4QAG.js → cron-expression-z4WOWyBU.js} +1 -1
- package/dist/gateway/static/root/assets/date-picker-vKUcJeQZ.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-l6IXzk0C.js → dependency-picker-BpZ9A2gi.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-cGn_20DO.js → desktop-pet-ClrAMqgn.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DIfccDKS.js → desktop-pet-settings-DKNKGiEG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CTS5RP_D.js → extension-debug-page-C39hFkJm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Dg9YssYH.js → extension-page-DkqVsWB7.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CWZYL8Fi.js → extension-settings-page-Be4lFw8f.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Chsr5wGH.js → gateway-config-swr-DEKSw3d-.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-HIHGY-0Y.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-C9ynH6VV.js → gateway-startup-retry-Dlyt2VhF.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-WUhSfvob.js → heartbeat-settings-DiYjWa1F.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-BLZNEVmk.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-D_TsVe7h.js → image-generation-api-CJIPVk_d.js} +1 -1
- package/dist/gateway/static/root/assets/index-50Kr6L6C.css +2 -0
- package/dist/gateway/static/root/assets/index-BWdn9NaX.js +76 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DGBf6YfD.js → keyboard-shortcuts-settings-ge76J038.js} +1 -1
- package/dist/gateway/static/root/assets/languages-BFe8nIOO.js +2 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-E47xrPDI.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DGWP_xsQ.js → local-apps-page-gkw7VRL4.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-B2v8mNJw.js → locale-store-DJPCr2mb.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-HHtDMSUW.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-DUAZ-dtt.js → management-settings-DOfCSojd.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-editor-BhBJANcx.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DBWu9d_n.js → markdown-view-k_PJsY2C.js} +2 -2
- package/dist/gateway/static/root/assets/{media-plugins-CsUjcIBy.js → media-plugins-D8wMcUtB.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BeIiRpmk.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-Dxu8twiQ.js → mobile-pairing-wizard-B4Ewewwr.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-DPd5L2A9.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-CE_De-iQ.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-YeJKwV-7.js → page-tabs-DoxnT3X4.js} +1 -1
- package/dist/gateway/static/root/assets/popover-select-CKBYnT3c.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BfJ3jMDG.js → preview-open-alternatives-D4oL1yua.js} +1 -1
- package/dist/gateway/static/root/assets/product-open-page-CeStuxSl.js +1 -0
- package/dist/gateway/static/root/assets/project-detail-page-DXhBJzJy.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CcqhmZoX.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-B9OZUdwC.js → registry-api-Dalzf2w0.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-ulmJT_Ac.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-uJ8Br3ZL.js → runtime-tools-settings-panel-CrOpchy5.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-CXwn6up5.js → schema-form-Dk52v4cQ.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-RM0kAsNa.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BfLbu67w.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-YVNYsR0U.js → settings-form-section-dvGi1APN.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-cHqrIdVR.js → settings-page-CEYjEm2D.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BZ4i0CYX.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DnjSDQru.js → share-preview-page-DP4Qgsv6.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-B5yHTrGO.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BicZK04u.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DkrGEdiY.js → skills-page-Dlr1Ue1w.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-CqZbiZuK.js → skills-page.utils-I1wcnceD.js} +1 -1
- package/dist/gateway/static/root/assets/source-workspace-editor-DunRD1gY.js +1 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Dmw0RfxZ.js → system-settings-panel-DIaFAHT0.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-4_5g-V8B.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-CubltMKm.js → theme-store-DYDrhfnD.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CiieC6HP.js → tunnel-api-DAXx1rHF.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-XQ3SuyB9.js → use-autosave-BwEFbveP.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CQnXw4ba.js +2 -0
- package/dist/gateway/static/root/assets/{vendor-codemirror-Qdcjid65.js → vendor-codemirror-DFxP3B9T.js} +16 -16
- package/dist/gateway/static/root/assets/{voice-api-key-field-D4QzVgdt.js → voice-api-key-field-C-WbC2fM.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-B1ZbyVmF.js → voice-config-api-Ds0z9O11.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-D5Tf8GRZ.js → work-discovery-overlay-DiGw5KKj.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BW9p8Maz.js → workflow-run-setup-panel-BIU2wg99.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-D3Z7JVHH.js +6 -0
- package/dist/gateway/static/root/index.html +12 -12
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/user-message-display.js +0 -18
- package/dist/src/agent/context/execution-context.js +34 -21
- package/dist/src/agent/context/execution-context.types.d.ts +2 -0
- package/dist/src/agent/inbound/attachment-pipeline.d.ts +1 -0
- package/dist/src/agent/inbound/attachment-pipeline.js +6 -1
- package/dist/src/agent/prompt/sections/memory-skills.js +2 -1
- package/dist/src/agent/prompt/sections/tooling.js +2 -0
- package/dist/src/agent/tools/create-share-tool.js +39 -1
- package/dist/src/agent/tools/delegate-tool.js +1 -0
- package/dist/src/agent/tools/factory.js +14 -1
- package/dist/src/agent/tools/index.d.ts +1 -1
- package/dist/src/agent/tools/index.js +2 -2
- package/dist/src/agent/tools/user-context-tool.d.ts +3 -0
- package/dist/src/agent/tools/user-context-tool.js +147 -4
- package/dist/src/agent/workflow/catalog.js +6 -2
- package/dist/src/chat-commands/builtins/workflow.js +1 -1
- package/dist/src/cli/commands/tunnel.js +3 -3
- package/dist/src/connectors/connected-source-understanding.js +4 -4
- package/dist/src/gateway/agent-builtin-tools.d.ts +7 -1
- package/dist/src/gateway/agent-builtin-tools.js +7 -0
- package/dist/src/gateway/device-routes.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +2 -2
- package/dist/src/gateway/hono/routes/sessions.js +1 -1
- package/dist/src/gateway/hono/routes/shares.js +404 -7
- package/dist/src/gateway/hono/routes/site-shares.js +19 -13
- package/dist/src/gateway/hono/routes/tunnel.js +1 -1
- package/dist/src/gateway/hono/routes/user-model.js +35 -102
- package/dist/src/gateway/hono/routes/workflows.js +7 -4
- package/dist/src/gateway/service/sessions-api.js +1 -1
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/remote-access/exposure-manager.js +1 -1
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +1 -1
- package/dist/src/share/hosted-note-publication.d.ts +22 -0
- package/dist/src/share/hosted-note-publication.js +96 -0
- package/dist/src/share/hosted-session-share.d.ts +86 -7
- package/dist/src/share/hosted-session-share.js +72 -15
- package/dist/src/share/hosted-static-site-publication.d.ts +16 -0
- package/dist/src/share/hosted-static-site-publication.js +108 -0
- package/dist/src/share/hosted-static-site-publish.d.ts +23 -0
- package/dist/src/share/hosted-static-site-publish.js +53 -0
- package/dist/src/share/note-share-service.d.ts +1 -0
- package/dist/src/share/note-share-service.js +4 -4
- package/dist/src/share/share-url.d.ts +1 -1
- package/dist/src/share/share-url.js +14 -9
- package/dist/src/tui/backends/embedded-backend.js +2 -2
- package/dist/src/tui/tui-agent-events.js +1 -1
- package/dist/src/tui/tui-workflow-slash.d.ts +3 -6
- package/dist/src/tui/tui-workflow-slash.js +3 -6
- package/dist/src/tunnel/index.js +1 -1
- package/dist/src/tunnel/tunnel-service.js +1 -1
- package/dist/src/user-model/bootstrap.d.ts +17 -0
- package/dist/src/user-model/bootstrap.js +118 -0
- package/dist/src/user-model/index.d.ts +3 -0
- package/dist/src/user-model/index.js +4 -1
- package/dist/src/user-model/profile.d.ts +5 -0
- package/dist/src/user-model/profile.js +98 -0
- package/dist/src/user-model/usage-policy.d.ts +2 -0
- package/dist/src/user-model/usage-policy.js +6 -0
- package/dist/src/voice/realtime/agentEngine.js +17 -0
- package/dist/src/voice/realtime/memory-context.js +1 -1
- package/dist/src/voice/realtime/playback-echo.d.ts +2 -0
- package/dist/src/voice/realtime/playback-echo.js +15 -0
- package/dist/src/work-discovery/analyzer.js +8 -6
- package/dist/src/work-discovery/service.d.ts +1 -1
- package/dist/src/work-discovery/service.js +4 -4
- package/dist/src/work-discovery/types.d.ts +1 -1
- package/dist/src/workflows/domain/run.d.ts +8 -1
- package/dist/src/workflows/domain/validation.d.ts +3 -4
- package/dist/src/workflows/domain/validation.js +119 -8
- package/dist/src/workflows/service/workflow-run-service.js +8 -1
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-vul32IsP.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-CJFJKNwS.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-B2wxcpgq.js +0 -6
- package/dist/gateway/static/root/assets/block-editor-C61LqK_-.js +0 -185
- package/dist/gateway/static/root/assets/browser-settings-page-BMjY8cyv.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-wB3Vgmp3.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-U5ffzu4r.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BGaF--m5.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-BuEyUxZn.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-vHI_Que8.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CYjlMzPx.js +0 -1
- package/dist/gateway/static/root/assets/index-BBlJYVxR.js +0 -74
- package/dist/gateway/static/root/assets/index-_I0dD2LN.css +0 -2
- package/dist/gateway/static/root/assets/languages-5WaOu0Lf.js +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-CLlIl83V.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DuhCigiB.js +0 -2
- package/dist/gateway/static/root/assets/markdown-editor-BjMTIM-m.js +0 -1
- package/dist/gateway/static/root/assets/messages-ChSTFZR5.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-DMdbaTZp.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-xe_vX0nM.js +0 -8
- package/dist/gateway/static/root/assets/popover-select-C-Hj-nXR.js +0 -1
- package/dist/gateway/static/root/assets/product-open-page-B7NRGPox.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-hG7ELibZ.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-C5G2ET4w.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DTO-faxH.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CwzsUCgP.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Djc3EdoO.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-MUAMcZLD.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-C7A0aywX.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-D1xSGJAQ.js +0 -1
- package/dist/gateway/static/root/assets/source-workspace-editor-CVWzt0oT.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BvZSCLUH.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-BKJC7tyW.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-DuqRodIc.js +0 -5
|
@@ -192,7 +192,7 @@ const AUTHENTICATED_LAZY_ROUTE_BUNDLES = [
|
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
id: "notes",
|
|
195
|
-
match: (path) => startsWithAny(path, ["/api/notes"]),
|
|
195
|
+
match: (path) => startsWithAny(path, ["/api/notes"]) && !/^\/api\/notes\/[^/]+\/hosted-publications(?:\/.*)?$/.test(path),
|
|
196
196
|
load: async () => {
|
|
197
197
|
const { registerNotesRoutes } = await import("./notes.js");
|
|
198
198
|
return { register: registerNotesRoutes };
|
|
@@ -224,7 +224,7 @@ const AUTHENTICATED_LAZY_ROUTE_BUNDLES = [
|
|
|
224
224
|
},
|
|
225
225
|
{
|
|
226
226
|
id: "shares",
|
|
227
|
-
match: (path) => startsWithAny(path, ["/api/shares"]) || /^\/api\/sessions\/[^/]+\/(?:share-preview|shares|hosted-shares)(?:\/.*)?$/.test(path),
|
|
227
|
+
match: (path) => startsWithAny(path, ["/api/shares", "/api/hosted-publications"]) || /^\/api\/notes\/[^/]+\/hosted-publications(?:\/.*)?$/.test(path) || /^\/api\/sessions\/[^/]+\/(?:share-preview|shares|hosted-shares)(?:\/.*)?$/.test(path),
|
|
228
228
|
load: async () => {
|
|
229
229
|
const { registerShareRoutes } = await import("./shares.js");
|
|
230
230
|
return { register: registerShareRoutes };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildSessionKey, init_session_key } from "../../../routing/session-key.js";
|
|
2
2
|
import { resolveProjectAgentId } from "../../../projects/project-agent.js";
|
|
3
3
|
import "../../../projects/index.js";
|
|
4
|
+
import { messagesToClientHistory } from "../../../session/client-history.js";
|
|
4
5
|
import { evictEmbeddedSessionRunner } from "../../../agent/embedded/session-runner.js";
|
|
5
6
|
import { SessionEnvironmentService } from "../../../execution-environments/session-environment-service.js";
|
|
6
|
-
import { messagesToClientHistory } from "../../../session/client-history.js";
|
|
7
7
|
import { deleteMediaUrisNoLongerReferenced } from "../../../media/session-references.js";
|
|
8
8
|
import { getGatewayPrincipal } from "../../security/gateway-principal.js";
|
|
9
9
|
import { createGatewayRouteLogger, logRouteError } from "../lib/route-logger.js";
|
|
@@ -8,6 +8,10 @@ import { logShareAudit } from "../../../share/share-audit.js";
|
|
|
8
8
|
import { getShareStore, shareResponseContentType } from "../../../share/share-store.js";
|
|
9
9
|
import { getSiteShareStore } from "../../../share/site-share-store.js";
|
|
10
10
|
import { resolveShareUrl, resolveSiteShareUrl } from "../../../share/share-url.js";
|
|
11
|
+
import { SessionShareService, SessionShareSnapshotConflictError } from "../../../share/session-share-service.js";
|
|
12
|
+
import { HostedPublicationPublisher, HostedSessionShareBuilder, HostedShareAuthorizationError, HostedShareBindingStore, HostedShareRemoteError } from "../../../share/hosted-session-share.js";
|
|
13
|
+
import { HostedStaticSitePublicationBuilder } from "../../../share/hosted-static-site-publication.js";
|
|
14
|
+
import { publishHostedStaticSite } from "../../../share/hosted-static-site-publish.js";
|
|
11
15
|
import { resolveReverseProxyPublicUrl } from "../../public-url.js";
|
|
12
16
|
import { audienceDefaults, cleanupStagedSite, decideShareKind, forgetStagedSite, makeDescription, makeTitle, probeShareTarget, rememberStagedSite, stageSingleHtmlAsSite } from "../../../share/share-auto.js";
|
|
13
17
|
import { deleteThumbnail, placeholderSvg, readThumbnail, scheduleThumbnail, thumbnailContentType, thumbnailExists } from "../../../share/share-thumbnail.js";
|
|
@@ -17,9 +21,8 @@ import { getClientIpFromHeaders } from "../../security/loopback.js";
|
|
|
17
21
|
import { SHARED_HTML_CSP } from "../../security/csp.js";
|
|
18
22
|
import { renderFolderLandingPage, renderShareExpiredPage, renderShareLandingPage, renderSnapshotShareLandingPage } from "../../../share/share-landing.js";
|
|
19
23
|
import { resolveScopedMediaReference } from "../../media-access.js";
|
|
20
|
-
import { SessionShareService, SessionShareSnapshotConflictError } from "../../../share/session-share-service.js";
|
|
21
|
-
import { HostedSessionShareBuilder, HostedSessionSharePublisher, HostedShareAuthorizationError, HostedShareBindingStore } from "../../../share/hosted-session-share.js";
|
|
22
24
|
import { NoteShareService } from "../../../share/note-share-service.js";
|
|
25
|
+
import { HostedNotePublicationBuilder, HostedNoteVersionConflictError } from "../../../share/hosted-note-publication.js";
|
|
23
26
|
import { consumeSharePublicLimit } from "../../../share/share-rate-limit.js";
|
|
24
27
|
import { createZipStream, planDirectoryFiles } from "../../../share/share-zip.js";
|
|
25
28
|
import { basename, dirname } from "node:path";
|
|
@@ -529,7 +532,9 @@ function registerShareRoutes(authenticated, deps) {
|
|
|
529
532
|
const noteShares = new NoteShareService(store, service.notesServiceInstance);
|
|
530
533
|
const sessionShares = createSessionShareService(service, store);
|
|
531
534
|
const hostedBuilder = new HostedSessionShareBuilder(createSessionShareSource(service));
|
|
532
|
-
const
|
|
535
|
+
const hostedNoteBuilder = new HostedNotePublicationBuilder(service.notesServiceInstance);
|
|
536
|
+
const hostedSiteBuilder = new HostedStaticSitePublicationBuilder();
|
|
537
|
+
const hostedPublisher = new HostedPublicationPublisher();
|
|
533
538
|
const hostedBindings = new HostedShareBindingStore();
|
|
534
539
|
getSiteShareStore(resolveSiteShareConfig(service)).setCleanupHook((rec) => {
|
|
535
540
|
const dir = forgetStagedSite(rec.id);
|
|
@@ -696,7 +701,7 @@ function registerShareRoutes(authenticated, deps) {
|
|
|
696
701
|
error: { message: "Session not found" }
|
|
697
702
|
}, 404);
|
|
698
703
|
try {
|
|
699
|
-
await hostedBindings.reconcile(await hostedPublisher.
|
|
704
|
+
await hostedBindings.reconcile(await hostedPublisher.listPublications());
|
|
700
705
|
return c.json({
|
|
701
706
|
ok: true,
|
|
702
707
|
payload: { shares: (await hostedBindings.list(metadata.sessionId)).map(hostedBindingResponse) }
|
|
@@ -720,6 +725,17 @@ function registerShareRoutes(authenticated, deps) {
|
|
|
720
725
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
721
726
|
const binding = {
|
|
722
727
|
...result,
|
|
728
|
+
kind: "session_document",
|
|
729
|
+
source: {
|
|
730
|
+
kind: "session",
|
|
731
|
+
id: snapshot.sessionId,
|
|
732
|
+
version: String(snapshot.cutoffSeq)
|
|
733
|
+
},
|
|
734
|
+
revisionSources: { [String(result.snapshotRevision)]: {
|
|
735
|
+
kind: "session",
|
|
736
|
+
id: snapshot.sessionId,
|
|
737
|
+
version: String(snapshot.cutoffSeq)
|
|
738
|
+
} },
|
|
723
739
|
sessionId: snapshot.sessionId,
|
|
724
740
|
cutoffSeq: snapshot.cutoffSeq,
|
|
725
741
|
title: snapshot.manifest.title,
|
|
@@ -763,6 +779,20 @@ function registerShareRoutes(authenticated, deps) {
|
|
|
763
779
|
const binding = {
|
|
764
780
|
...previous,
|
|
765
781
|
...result,
|
|
782
|
+
kind: "session_document",
|
|
783
|
+
source: {
|
|
784
|
+
kind: "session",
|
|
785
|
+
id: snapshot.sessionId,
|
|
786
|
+
version: String(snapshot.cutoffSeq)
|
|
787
|
+
},
|
|
788
|
+
revisionSources: {
|
|
789
|
+
...previous.revisionSources,
|
|
790
|
+
[String(result.snapshotRevision)]: {
|
|
791
|
+
kind: "session",
|
|
792
|
+
id: snapshot.sessionId,
|
|
793
|
+
version: String(snapshot.cutoffSeq)
|
|
794
|
+
}
|
|
795
|
+
},
|
|
766
796
|
cutoffSeq: snapshot.cutoffSeq,
|
|
767
797
|
title: snapshot.manifest.title,
|
|
768
798
|
messageCount: snapshot.manifest.messages.length,
|
|
@@ -806,6 +836,299 @@ function registerShareRoutes(authenticated, deps) {
|
|
|
806
836
|
return hostedShareErrorResponse(c, err);
|
|
807
837
|
}
|
|
808
838
|
});
|
|
839
|
+
authenticated.get("/api/hosted-publications/capabilities", async (c) => {
|
|
840
|
+
try {
|
|
841
|
+
return c.json({
|
|
842
|
+
ok: true,
|
|
843
|
+
payload: await hostedPublisher.capabilities()
|
|
844
|
+
});
|
|
845
|
+
} catch (err) {
|
|
846
|
+
return hostedShareErrorResponse(c, err);
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
authenticated.get("/api/notes/:id/hosted-publications", async (c) => {
|
|
850
|
+
try {
|
|
851
|
+
return c.json({
|
|
852
|
+
ok: true,
|
|
853
|
+
payload: { publications: (await hostedBindings.listBySource("note", c.req.param("id"))).map(hostedPublicationBindingResponse) }
|
|
854
|
+
});
|
|
855
|
+
} catch (err) {
|
|
856
|
+
return hostedShareErrorResponse(c, err);
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
authenticated.post("/api/notes/:id/hosted-publications", async (c) => {
|
|
860
|
+
const body = await c.req.json().catch(() => ({}));
|
|
861
|
+
try {
|
|
862
|
+
const snapshot = await hostedNoteBuilder.build(c.req.param("id"), {
|
|
863
|
+
expectedNoteVersion: typeof body.expectedNoteVersion === "number" ? body.expectedNoteVersion : void 0,
|
|
864
|
+
attachmentIds: Array.isArray(body.attachmentIds) ? body.attachmentIds.filter((id) => typeof id === "string") : void 0,
|
|
865
|
+
description: typeof body.description === "string" ? body.description : void 0
|
|
866
|
+
});
|
|
867
|
+
const result = await hostedPublisher.createPublication(snapshot, {
|
|
868
|
+
ttlMs: typeof body.ttlMs === "number" ? body.ttlMs : 864e5,
|
|
869
|
+
maxViews: body.maxViews === null ? null : typeof body.maxViews === "number" ? body.maxViews : null
|
|
870
|
+
});
|
|
871
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
872
|
+
const binding = {
|
|
873
|
+
...result,
|
|
874
|
+
kind: "note_document",
|
|
875
|
+
source: {
|
|
876
|
+
kind: "note",
|
|
877
|
+
id: snapshot.sourceNoteId,
|
|
878
|
+
version: String(snapshot.sourceVersion)
|
|
879
|
+
},
|
|
880
|
+
revisionSources: { [String(result.snapshotRevision)]: {
|
|
881
|
+
kind: "note",
|
|
882
|
+
id: snapshot.sourceNoteId,
|
|
883
|
+
version: String(snapshot.sourceVersion)
|
|
884
|
+
} },
|
|
885
|
+
title: snapshot.title,
|
|
886
|
+
description: typeof body.description === "string" ? body.description.trim() || null : null,
|
|
887
|
+
attachmentCount: snapshot.attachmentCount,
|
|
888
|
+
attachmentIds: snapshot.assets.map((asset) => asset.id),
|
|
889
|
+
createdAt: now,
|
|
890
|
+
updatedAt: now,
|
|
891
|
+
revoked: false
|
|
892
|
+
};
|
|
893
|
+
await hostedBindings.upsert(binding);
|
|
894
|
+
return c.json({
|
|
895
|
+
ok: true,
|
|
896
|
+
payload: hostedPublicationBindingResponse(binding)
|
|
897
|
+
}, 201);
|
|
898
|
+
} catch (err) {
|
|
899
|
+
return hostedShareErrorResponse(c, err);
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
authenticated.post("/api/notes/:id/hosted-publications/:publicationId/refresh", async (c) => {
|
|
903
|
+
const body = await c.req.json().catch(() => ({}));
|
|
904
|
+
const previous = (await hostedBindings.listBySource("note", c.req.param("id"))).find((binding) => binding.id === c.req.param("publicationId") && !binding.revoked);
|
|
905
|
+
if (!previous) return c.json({
|
|
906
|
+
ok: false,
|
|
907
|
+
error: { message: "Hosted publication not found" }
|
|
908
|
+
}, 404);
|
|
909
|
+
try {
|
|
910
|
+
const snapshot = await hostedNoteBuilder.build(c.req.param("id"), {
|
|
911
|
+
expectedNoteVersion: typeof body.expectedNoteVersion === "number" ? body.expectedNoteVersion : void 0,
|
|
912
|
+
attachmentIds: Array.isArray(body.attachmentIds) ? body.attachmentIds.filter((id) => typeof id === "string") : previous.attachmentIds,
|
|
913
|
+
description: previous.description ?? void 0
|
|
914
|
+
});
|
|
915
|
+
const result = await hostedPublisher.refreshPublication(previous.id, previous.snapshotRevision, previous.shareUrl, snapshot);
|
|
916
|
+
const binding = {
|
|
917
|
+
...previous,
|
|
918
|
+
...result,
|
|
919
|
+
kind: "note_document",
|
|
920
|
+
source: {
|
|
921
|
+
kind: "note",
|
|
922
|
+
id: snapshot.sourceNoteId,
|
|
923
|
+
version: String(snapshot.sourceVersion)
|
|
924
|
+
},
|
|
925
|
+
revisionSources: {
|
|
926
|
+
...previous.revisionSources,
|
|
927
|
+
[String(result.snapshotRevision)]: {
|
|
928
|
+
kind: "note",
|
|
929
|
+
id: snapshot.sourceNoteId,
|
|
930
|
+
version: String(snapshot.sourceVersion)
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
title: snapshot.title,
|
|
934
|
+
attachmentCount: snapshot.attachmentCount,
|
|
935
|
+
attachmentIds: snapshot.assets.map((asset) => asset.id),
|
|
936
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
937
|
+
};
|
|
938
|
+
await hostedBindings.upsert(binding);
|
|
939
|
+
return c.json({
|
|
940
|
+
ok: true,
|
|
941
|
+
payload: hostedPublicationBindingResponse(binding)
|
|
942
|
+
});
|
|
943
|
+
} catch (err) {
|
|
944
|
+
return hostedShareErrorResponse(c, err);
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
authenticated.post("/api/hosted-publications/static-sites", async (c) => {
|
|
948
|
+
const body = await c.req.json().catch(() => ({}));
|
|
949
|
+
if (typeof body.path !== "string") return c.json({
|
|
950
|
+
ok: false,
|
|
951
|
+
error: { message: "Static site path is required" }
|
|
952
|
+
}, 400);
|
|
953
|
+
try {
|
|
954
|
+
const workspaceRoot = await resolveWorkspaceRootForShare(service, typeof body.sessionKey === "string" ? body.sessionKey : void 0, typeof body.agentId === "string" ? body.agentId : void 0);
|
|
955
|
+
if (!workspaceRoot) return c.json({
|
|
956
|
+
ok: false,
|
|
957
|
+
error: { message: "Workspace not configured" }
|
|
958
|
+
}, 400);
|
|
959
|
+
const { binding, snapshot } = await publishHostedStaticSite({
|
|
960
|
+
workspaceRoot,
|
|
961
|
+
path: body.path,
|
|
962
|
+
title: typeof body.title === "string" ? body.title : void 0,
|
|
963
|
+
description: typeof body.description === "string" ? body.description : void 0,
|
|
964
|
+
spaFallback: typeof body.spaFallback === "boolean" ? body.spaFallback : void 0,
|
|
965
|
+
ttlMs: typeof body.ttlMs === "number" ? body.ttlMs : 864e5,
|
|
966
|
+
maxViews: body.maxViews === null ? null : typeof body.maxViews === "number" ? body.maxViews : null,
|
|
967
|
+
sessionKey: typeof body.sessionKey === "string" ? body.sessionKey : void 0,
|
|
968
|
+
agentId: typeof body.agentId === "string" ? body.agentId : void 0
|
|
969
|
+
}, {
|
|
970
|
+
builder: hostedSiteBuilder,
|
|
971
|
+
publisher: hostedPublisher,
|
|
972
|
+
bindings: hostedBindings
|
|
973
|
+
});
|
|
974
|
+
return c.json({
|
|
975
|
+
ok: true,
|
|
976
|
+
payload: {
|
|
977
|
+
...hostedPublicationBindingResponse(binding),
|
|
978
|
+
fileCount: snapshot.fileCount,
|
|
979
|
+
totalBytes: snapshot.totalBytes
|
|
980
|
+
}
|
|
981
|
+
}, 201);
|
|
982
|
+
} catch (err) {
|
|
983
|
+
return hostedShareErrorResponse(c, err);
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
authenticated.post("/api/hosted-publications/static-sites/:publicationId/refresh", async (c) => {
|
|
987
|
+
const previous = (await hostedBindings.listAll()).find((binding) => binding.id === c.req.param("publicationId") && binding.kind === "static_site" && !binding.revoked);
|
|
988
|
+
if (!previous || previous.source.kind !== "static_site") return c.json({
|
|
989
|
+
ok: false,
|
|
990
|
+
error: { message: "Hosted publication not found" }
|
|
991
|
+
}, 404);
|
|
992
|
+
try {
|
|
993
|
+
const workspaceRoot = previous.workspaceContext?.workspaceRoot ?? await resolveWorkspaceRootForShare(service, previous.workspaceContext?.sessionKey, previous.workspaceContext?.agentId);
|
|
994
|
+
if (!workspaceRoot) return c.json({
|
|
995
|
+
ok: false,
|
|
996
|
+
error: { message: "Workspace not configured" }
|
|
997
|
+
}, 400);
|
|
998
|
+
const snapshot = await hostedSiteBuilder.build(workspaceRoot, {
|
|
999
|
+
path: previous.source.id,
|
|
1000
|
+
title: previous.title,
|
|
1001
|
+
description: previous.description ?? void 0,
|
|
1002
|
+
spaFallback: true
|
|
1003
|
+
});
|
|
1004
|
+
const result = await hostedPublisher.refreshPublication(previous.id, previous.snapshotRevision, previous.shareUrl, snapshot);
|
|
1005
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1006
|
+
const binding = {
|
|
1007
|
+
...previous,
|
|
1008
|
+
...result,
|
|
1009
|
+
source: {
|
|
1010
|
+
kind: "static_site",
|
|
1011
|
+
id: previous.source.id,
|
|
1012
|
+
version: now
|
|
1013
|
+
},
|
|
1014
|
+
revisionSources: {
|
|
1015
|
+
...previous.revisionSources,
|
|
1016
|
+
[String(result.snapshotRevision)]: {
|
|
1017
|
+
kind: "static_site",
|
|
1018
|
+
id: previous.source.id,
|
|
1019
|
+
version: now
|
|
1020
|
+
}
|
|
1021
|
+
},
|
|
1022
|
+
attachmentCount: snapshot.fileCount,
|
|
1023
|
+
attachmentIds: snapshot.assets.map((asset) => asset.id),
|
|
1024
|
+
updatedAt: now
|
|
1025
|
+
};
|
|
1026
|
+
await hostedBindings.upsert(binding);
|
|
1027
|
+
return c.json({
|
|
1028
|
+
ok: true,
|
|
1029
|
+
payload: {
|
|
1030
|
+
...hostedPublicationBindingResponse(binding),
|
|
1031
|
+
fileCount: snapshot.fileCount,
|
|
1032
|
+
totalBytes: snapshot.totalBytes
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
} catch (err) {
|
|
1036
|
+
return hostedShareErrorResponse(c, err);
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
authenticated.get("/api/hosted-publications/:publicationId/revisions", async (c) => {
|
|
1040
|
+
try {
|
|
1041
|
+
return c.json({
|
|
1042
|
+
ok: true,
|
|
1043
|
+
payload: { revisions: await hostedPublisher.listRevisions(c.req.param("publicationId")) }
|
|
1044
|
+
});
|
|
1045
|
+
} catch (err) {
|
|
1046
|
+
return hostedShareErrorResponse(c, err);
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
authenticated.post("/api/hosted-publications/:publicationId/rollback", async (c) => {
|
|
1050
|
+
const body = await c.req.json().catch(() => ({}));
|
|
1051
|
+
if (typeof body.expectedRevision !== "number" || typeof body.targetRevision !== "number") return c.json({
|
|
1052
|
+
ok: false,
|
|
1053
|
+
error: { message: "Expected and target revisions are required" }
|
|
1054
|
+
}, 400);
|
|
1055
|
+
try {
|
|
1056
|
+
const id = c.req.param("publicationId");
|
|
1057
|
+
const binding = (await hostedBindings.listAll()).find((item) => item.id === id);
|
|
1058
|
+
const targetSource = binding?.revisionSources[String(body.targetRevision)];
|
|
1059
|
+
if (binding && !targetSource) return c.json({
|
|
1060
|
+
ok: false,
|
|
1061
|
+
error: { message: "Publication revision source not found" }
|
|
1062
|
+
}, 409);
|
|
1063
|
+
const item = await hostedPublisher.rollbackPublication(id, body.expectedRevision, body.targetRevision);
|
|
1064
|
+
if (binding) await hostedBindings.upsert({
|
|
1065
|
+
...binding,
|
|
1066
|
+
source: targetSource,
|
|
1067
|
+
snapshotRevision: item.revision,
|
|
1068
|
+
title: item.title,
|
|
1069
|
+
description: item.description,
|
|
1070
|
+
expiresAt: item.expiresAt,
|
|
1071
|
+
maxViews: item.maxViews,
|
|
1072
|
+
viewCount: item.viewCount,
|
|
1073
|
+
updatedAt: item.updatedAt
|
|
1074
|
+
});
|
|
1075
|
+
return c.json({
|
|
1076
|
+
ok: true,
|
|
1077
|
+
payload: {
|
|
1078
|
+
publicationId: id,
|
|
1079
|
+
revision: body.targetRevision
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
} catch (err) {
|
|
1083
|
+
return hostedShareErrorResponse(c, err);
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
authenticated.get("/api/hosted-publications", async (c) => {
|
|
1087
|
+
try {
|
|
1088
|
+
const [remote, localBindings] = await Promise.all([hostedPublisher.listPublications(), hostedBindings.listAll()]);
|
|
1089
|
+
const bindingById = new Map(localBindings.map((binding) => [binding.id, binding]));
|
|
1090
|
+
return c.json({
|
|
1091
|
+
ok: true,
|
|
1092
|
+
payload: { publications: remote.map((item) => {
|
|
1093
|
+
const binding = bindingById.get(item.id);
|
|
1094
|
+
return {
|
|
1095
|
+
id: item.id,
|
|
1096
|
+
kind: item.kind,
|
|
1097
|
+
delivery: item.deliveryMode,
|
|
1098
|
+
title: item.title,
|
|
1099
|
+
description: item.description,
|
|
1100
|
+
status: item.status,
|
|
1101
|
+
revision: item.revision,
|
|
1102
|
+
expiresAt: item.expiresAt,
|
|
1103
|
+
maxViews: item.maxViews,
|
|
1104
|
+
viewCount: item.viewCount,
|
|
1105
|
+
createdAt: item.createdAt,
|
|
1106
|
+
updatedAt: item.updatedAt,
|
|
1107
|
+
owner: item.owner ?? null,
|
|
1108
|
+
workspaceId: item.workspaceId ?? null,
|
|
1109
|
+
createdByPrincipalId: item.createdByPrincipalId ?? null,
|
|
1110
|
+
shareUrl: binding?.shareUrl ?? null,
|
|
1111
|
+
managedFromThisDevice: Boolean(binding)
|
|
1112
|
+
};
|
|
1113
|
+
}) }
|
|
1114
|
+
});
|
|
1115
|
+
} catch (err) {
|
|
1116
|
+
return hostedShareErrorResponse(c, err);
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
authenticated.delete("/api/hosted-publications/:publicationId", async (c) => {
|
|
1120
|
+
try {
|
|
1121
|
+
const id = c.req.param("publicationId");
|
|
1122
|
+
await hostedPublisher.revokePublication(id);
|
|
1123
|
+
await hostedBindings.markRevoked(id);
|
|
1124
|
+
return c.json({
|
|
1125
|
+
ok: true,
|
|
1126
|
+
payload: { revoked: id }
|
|
1127
|
+
});
|
|
1128
|
+
} catch (err) {
|
|
1129
|
+
return hostedShareErrorResponse(c, err);
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
809
1132
|
authenticated.post("/api/shares", async (c) => {
|
|
810
1133
|
const gatewayToken = extractToken({ authorization: c.req.header("authorization") ?? void 0 });
|
|
811
1134
|
if (!gatewayToken) return c.json({
|
|
@@ -993,6 +1316,61 @@ function registerShareRoutes(authenticated, deps) {
|
|
|
993
1316
|
const siteStore = getSiteShareStore(resolveSiteShareConfig(service));
|
|
994
1317
|
let sitePath = path;
|
|
995
1318
|
let stagedDir = null;
|
|
1319
|
+
const titleOut = makeTitle(probe.kind === "directory" ? path.split("/").pop() || path : path, title);
|
|
1320
|
+
if (resolveSiteShareUrl({
|
|
1321
|
+
...urlCtx,
|
|
1322
|
+
token: "reachability-check",
|
|
1323
|
+
subdomainLabel: "reachability-check",
|
|
1324
|
+
publicHostSuffix: siteStore.getConfig().publicHostSuffix
|
|
1325
|
+
}).reachability !== "public") {
|
|
1326
|
+
const { binding } = await publishHostedStaticSite({
|
|
1327
|
+
workspaceRoot,
|
|
1328
|
+
path: sitePath,
|
|
1329
|
+
title: titleOut,
|
|
1330
|
+
description,
|
|
1331
|
+
spaFallback: true,
|
|
1332
|
+
ttlMs,
|
|
1333
|
+
maxViews: maxViews ?? null,
|
|
1334
|
+
sessionKey,
|
|
1335
|
+
agentId
|
|
1336
|
+
}, {
|
|
1337
|
+
builder: hostedSiteBuilder,
|
|
1338
|
+
publisher: hostedPublisher,
|
|
1339
|
+
bindings: hostedBindings
|
|
1340
|
+
});
|
|
1341
|
+
return c.json({
|
|
1342
|
+
ok: true,
|
|
1343
|
+
payload: {
|
|
1344
|
+
share: {
|
|
1345
|
+
id: binding.id,
|
|
1346
|
+
kind: "site",
|
|
1347
|
+
delivery: "hosted",
|
|
1348
|
+
title: binding.title,
|
|
1349
|
+
description: makeDescription({
|
|
1350
|
+
audience,
|
|
1351
|
+
expiresAt: binding.expiresAt,
|
|
1352
|
+
override: description
|
|
1353
|
+
}),
|
|
1354
|
+
shareUrl: binding.shareUrl,
|
|
1355
|
+
lanUrl: null,
|
|
1356
|
+
reachability: "public",
|
|
1357
|
+
reachabilityHint: null,
|
|
1358
|
+
expiresAt: binding.expiresAt,
|
|
1359
|
+
maxViews: binding.maxViews
|
|
1360
|
+
},
|
|
1361
|
+
thumbnail: {
|
|
1362
|
+
url: "",
|
|
1363
|
+
status: "unavailable",
|
|
1364
|
+
width: SHARE_CONFIG_DEFAULTS.thumbnail.viewportWidth,
|
|
1365
|
+
height: SHARE_CONFIG_DEFAULTS.thumbnail.viewportHeight
|
|
1366
|
+
},
|
|
1367
|
+
routing: {
|
|
1368
|
+
reason: decision.reason,
|
|
1369
|
+
hint: decision.hint
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}, 201);
|
|
1373
|
+
}
|
|
996
1374
|
if (probe.kind === "file") {
|
|
997
1375
|
const staged = await stageSingleHtmlAsSite(workspaceRoot, probe.absolutePath);
|
|
998
1376
|
sitePath = staged.relativePath;
|
|
@@ -1028,7 +1406,6 @@ function registerShareRoutes(authenticated, deps) {
|
|
|
1028
1406
|
}, thumbnailRenderContext(service));
|
|
1029
1407
|
siteStore.setThumbnailStatus(siteRec.id, "pending");
|
|
1030
1408
|
}
|
|
1031
|
-
const titleOut = makeTitle(probe.kind === "directory" ? path.split("/").pop() || path : path, title);
|
|
1032
1409
|
return c.json({
|
|
1033
1410
|
ok: true,
|
|
1034
1411
|
payload: {
|
|
@@ -1267,14 +1644,34 @@ function hostedBindingResponse(binding) {
|
|
|
1267
1644
|
cutoffSeq: binding.cutoffSeq
|
|
1268
1645
|
};
|
|
1269
1646
|
}
|
|
1647
|
+
function hostedPublicationBindingResponse(binding) {
|
|
1648
|
+
return {
|
|
1649
|
+
id: binding.id,
|
|
1650
|
+
kind: binding.kind,
|
|
1651
|
+
delivery: "hosted_snapshot",
|
|
1652
|
+
shareUrl: binding.shareUrl,
|
|
1653
|
+
expiresAt: binding.expiresAt,
|
|
1654
|
+
maxViews: binding.maxViews,
|
|
1655
|
+
viewCount: binding.viewCount,
|
|
1656
|
+
revision: binding.snapshotRevision,
|
|
1657
|
+
title: binding.title,
|
|
1658
|
+
description: binding.description,
|
|
1659
|
+
attachmentCount: binding.attachmentCount,
|
|
1660
|
+
createdAt: binding.createdAt,
|
|
1661
|
+
updatedAt: binding.updatedAt,
|
|
1662
|
+
revoked: binding.revoked,
|
|
1663
|
+
expired: Date.now() >= new Date(binding.expiresAt).getTime(),
|
|
1664
|
+
source: binding.source
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1270
1667
|
function hostedShareErrorResponse(c, err) {
|
|
1271
1668
|
const message = err instanceof Error ? err.message : String(err);
|
|
1272
|
-
const status = err instanceof HostedShareAuthorizationError ? 401 : err instanceof SessionShareSnapshotConflictError ? 409 : message === "Session not found" || message === "Hosted share not found" ? 404 : 400;
|
|
1669
|
+
const status = err instanceof HostedShareAuthorizationError ? 401 : err instanceof HostedShareRemoteError && err.status === 403 ? 403 : err instanceof SessionShareSnapshotConflictError || err instanceof HostedNoteVersionConflictError ? 409 : message === "Session not found" || message === "Hosted share not found" || message === "Hosted publication not found" || message === "Note not found" ? 404 : 400;
|
|
1273
1670
|
return c.json({
|
|
1274
1671
|
ok: false,
|
|
1275
1672
|
error: {
|
|
1276
1673
|
message,
|
|
1277
|
-
code: err instanceof HostedShareAuthorizationError ? "hosted_share_auth_required" : status === 409 ? "session_snapshot_conflict" : void 0
|
|
1674
|
+
code: err instanceof HostedShareAuthorizationError ? "hosted_share_auth_required" : err instanceof HostedShareRemoteError && err.status === 403 ? err.code ?? "hosted_share_forbidden" : status === 409 ? "session_snapshot_conflict" : void 0
|
|
1278
1675
|
}
|
|
1279
1676
|
}, status);
|
|
1280
1677
|
}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import { resolveGatewayEffectiveHost } from "../../../config/gateway-bind.js";
|
|
2
2
|
import { resolveSiteShareConfig } from "../../../share/site-share-config.js";
|
|
3
3
|
import { getSiteShareStore } from "../../../share/site-share-store.js";
|
|
4
|
+
import { resolveSiteShareUrl } from "../../../share/share-url.js";
|
|
5
|
+
import { resolveReverseProxyPublicUrl } from "../../public-url.js";
|
|
4
6
|
import { extractToken } from "../../auth.js";
|
|
5
7
|
import { createHash } from "node:crypto";
|
|
6
8
|
//#region src/gateway/hono/routes/site-shares.ts
|
|
7
9
|
function hashGatewayToken(token) {
|
|
8
10
|
return createHash("sha256").update(token, "utf8").digest("hex").slice(0, 12);
|
|
9
11
|
}
|
|
10
|
-
function buildShareUrls(record, publicHostSuffix,
|
|
12
|
+
function buildShareUrls(record, publicHostSuffix, service) {
|
|
13
|
+
const label = record.subdomain ?? record.token;
|
|
14
|
+
const gatewayHost = resolveGatewayEffectiveHost(service.currentConfig);
|
|
15
|
+
const gatewayPort = service.currentConfig.gateway.port ?? 18790;
|
|
16
|
+
const subpathUrl = `http://${gatewayHost}:${gatewayPort}/site/${record.token}/`;
|
|
11
17
|
return {
|
|
12
|
-
publicUrl:
|
|
13
|
-
|
|
18
|
+
publicUrl: resolveSiteShareUrl({
|
|
19
|
+
gatewayHost,
|
|
20
|
+
gatewayPort,
|
|
21
|
+
reverseProxyPublicUrl: resolveReverseProxyPublicUrl(service.currentConfig),
|
|
22
|
+
token: record.token,
|
|
23
|
+
subdomainLabel: label,
|
|
24
|
+
publicHostSuffix
|
|
25
|
+
}).shareUrl,
|
|
26
|
+
subpathUrl
|
|
14
27
|
};
|
|
15
28
|
}
|
|
16
29
|
function registerSiteShareRoutes(authenticated, deps) {
|
|
@@ -85,9 +98,7 @@ function registerSiteShareRoutes(authenticated, deps) {
|
|
|
85
98
|
workspaceRoot,
|
|
86
99
|
gatewayTokenHash: hashGatewayToken(gatewayToken)
|
|
87
100
|
});
|
|
88
|
-
const
|
|
89
|
-
const gw = service.currentConfig.gateway;
|
|
90
|
-
const urls = buildShareUrls(record, cfg.publicHostSuffix, resolveGatewayEffectiveHost(service.currentConfig), gw.port ?? 18790);
|
|
101
|
+
const urls = buildShareUrls(record, store.getConfig().publicHostSuffix, service);
|
|
91
102
|
return c.json({
|
|
92
103
|
ok: true,
|
|
93
104
|
payload: {
|
|
@@ -114,11 +125,8 @@ function registerSiteShareRoutes(authenticated, deps) {
|
|
|
114
125
|
authenticated.get("/api/site-shares", (c) => {
|
|
115
126
|
store.updateConfig(resolveSiteShareConfig(service));
|
|
116
127
|
const cfg = store.getConfig();
|
|
117
|
-
const gw = service.currentConfig.gateway;
|
|
118
|
-
const gatewayHost = resolveGatewayEffectiveHost(service.currentConfig);
|
|
119
|
-
const gatewayPort = gw.port ?? 18790;
|
|
120
128
|
const items = store.getAllShares().map((r) => {
|
|
121
|
-
const urls = buildShareUrls(r, cfg.publicHostSuffix,
|
|
129
|
+
const urls = buildShareUrls(r, cfg.publicHostSuffix, service);
|
|
122
130
|
const expired = Date.now() >= new Date(r.expiresAt).getTime();
|
|
123
131
|
return {
|
|
124
132
|
id: r.id,
|
|
@@ -150,9 +158,7 @@ function registerSiteShareRoutes(authenticated, deps) {
|
|
|
150
158
|
ok: false,
|
|
151
159
|
error: { message: "Not found" }
|
|
152
160
|
}, 404);
|
|
153
|
-
const
|
|
154
|
-
const gw = service.currentConfig.gateway;
|
|
155
|
-
const urls = buildShareUrls(record, cfg.publicHostSuffix, resolveGatewayEffectiveHost(service.currentConfig), gw.port ?? 18790);
|
|
161
|
+
const urls = buildShareUrls(record, store.getConfig().publicHostSuffix, service);
|
|
156
162
|
return c.json({
|
|
157
163
|
ok: true,
|
|
158
164
|
payload: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { init_public_url, validatePublicUrl } from "../../../config/public-url.js";
|
|
2
|
-
import { extractToken } from "../../auth.js";
|
|
3
2
|
import { TUNNEL_REGISTRATION_SECRET_REQUIRED_CODE, TunnelRegistrationSecretError, getTunnelRegistrationSecretMeta, readTunnelRegistrationSecretFromConfigOnly, resolveTunnelBrokerUrl } from "../../../tunnel/env.js";
|
|
4
3
|
import { logTunnelAudit } from "../../../tunnel/tunnel-audit.js";
|
|
5
4
|
import { getTunnelService, hashGatewayToken } from "../../../tunnel/tunnel-service.js";
|
|
5
|
+
import { extractToken } from "../../auth.js";
|
|
6
6
|
import { TUNNEL_CONSENT_REQUIRED_CODE, TunnelConsentError, assertTunnelMayStart, getTunnelConsentState } from "../../../tunnel/consent.js";
|
|
7
7
|
import { configureTunnelFromGatewayConfig } from "../../../tunnel/gateway-lifecycle.js";
|
|
8
8
|
import { applyTunnelConsentToConfig, mergeTunnelConfigPatch, setTunnelEnabledInConfig } from "../../../tunnel/tunnel-config.js";
|