@undefineds.co/xpod 0.4.13 → 0.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/config/cloud.json +0 -3
  2. package/config/components-ignore.json +11 -7
  3. package/config/local.json +0 -3
  4. package/config/xpod.base.json +0 -24
  5. package/dist/api/ai-config/AiConfigStore.d.ts +2 -2
  6. package/dist/api/ai-config/AiConfigStore.js +4 -1
  7. package/dist/api/ai-gateway/auth/CallerPodAccess.d.ts +2 -5
  8. package/dist/api/ai-gateway/auth/CallerPodAccess.js +3 -42
  9. package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.d.ts +2 -1
  10. package/dist/api/ai-gateway/auth/GatewayApiKeyAuthenticator.js +1 -1
  11. package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.d.ts +3 -8
  12. package/dist/api/ai-gateway/auth/PodGatewayAccessKeyRepository.js +9 -32
  13. package/dist/api/ai-gateway/connect/index.d.ts +3 -3
  14. package/dist/api/ai-gateway/connect/index.js +9 -38
  15. package/dist/api/ai-gateway/errors.js +2 -1
  16. package/dist/api/ai-gateway/models/PodModelSelectionRepository.d.ts +3 -3
  17. package/dist/api/ai-gateway/models/PodModelSelectionRepository.js +7 -11
  18. package/dist/api/ai-gateway/pod/HostedPodRoute.d.ts +27 -0
  19. package/dist/api/ai-gateway/pod/HostedPodRoute.js +47 -0
  20. package/dist/api/ai-gateway/pod/OwnerPodAccess.d.ts +79 -0
  21. package/dist/api/ai-gateway/pod/OwnerPodAccess.js +192 -0
  22. package/dist/api/ai-gateway/pod/PodInterfaceKeyStore.d.ts +52 -0
  23. package/dist/api/ai-gateway/pod/PodInterfaceKeyStore.js +61 -0
  24. package/dist/api/ai-gateway/providers/ProviderRegistry.js +1 -1
  25. package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.d.ts +3 -3
  26. package/dist/api/ai-gateway/quota/ProviderQuotaAdapter.js +7 -32
  27. package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.d.ts +1 -1
  28. package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.js +1 -1
  29. package/dist/api/auth/ClientCredentialsAuthenticator.js +5 -28
  30. package/dist/api/auth/TokenEndpointRoute.d.ts +18 -0
  31. package/dist/api/auth/TokenEndpointRoute.js +36 -0
  32. package/dist/api/chatkit/pod-store.d.ts +4 -4
  33. package/dist/api/chatkit/pod-store.js +24 -95
  34. package/dist/api/container/common.js +36 -23
  35. package/dist/api/container/index.js +1 -0
  36. package/dist/api/container/local.js +88 -37
  37. package/dist/api/container/routes.js +41 -7
  38. package/dist/api/container/types.d.ts +4 -2
  39. package/dist/api/handlers/AdminHandler.d.ts +17 -1
  40. package/dist/api/handlers/AdminHandler.js +40 -3
  41. package/dist/api/handlers/AiGatewayManagementHandler.d.ts +6 -0
  42. package/dist/api/handlers/AiGatewayManagementHandler.js +17 -4
  43. package/dist/api/handlers/EdgeNodeSignalHandler.js +10 -2
  44. package/dist/api/handlers/NetworkSettingsHandler.d.ts +44 -5
  45. package/dist/api/handlers/NetworkSettingsHandler.js +46 -11
  46. package/dist/api/handlers/PodSettingsHandler.d.ts +3 -3
  47. package/dist/api/handlers/PodSettingsHandler.js +3 -3
  48. package/dist/api/handlers/ProvisionHandler.d.ts +35 -1
  49. package/dist/api/handlers/ProvisionHandler.js +53 -2
  50. package/dist/api/handlers/ReachabilityHandler.d.ts +6 -0
  51. package/dist/api/handlers/ReachabilityHandler.js +25 -6
  52. package/dist/api/network/NetworkEnvironmentConfigurationStore.d.ts +6 -1
  53. package/dist/api/network/NetworkEnvironmentConfigurationStore.js +72 -16
  54. package/dist/api/runtime.d.ts +18 -0
  55. package/dist/api/runtime.js +28 -2
  56. package/dist/api/service/AiClientConfigurationService.d.ts +1 -1
  57. package/dist/api/service/AiClientConfigurationService.js +1 -1
  58. package/dist/cli/commands/start.d.ts +26 -1
  59. package/dist/cli/commands/start.js +69 -5
  60. package/dist/components/components.jsonld +1 -1
  61. package/dist/components/context.jsonld +35 -42
  62. package/dist/edge/EdgeNodeAgent.d.ts +16 -0
  63. package/dist/edge/EdgeNodeAgent.js +56 -1
  64. package/dist/edge/EdgeNodeAgent.jsonld +8 -0
  65. package/dist/edge/EdgeNodeAgentInitializer.d.ts +2 -0
  66. package/dist/edge/EdgeNodeAgentInitializer.js +1 -0
  67. package/dist/edge/EdgeNodeAgentInitializer.jsonld +19 -0
  68. package/dist/edge/EdgeNodeDnsCoordinator.d.ts +11 -1
  69. package/dist/edge/EdgeNodeDnsCoordinator.js +12 -2
  70. package/dist/edge/EdgeNodeHealthProbeService.d.ts +15 -0
  71. package/dist/edge/EdgeNodeHealthProbeService.js +44 -12
  72. package/dist/edge/EdgeNodeHealthProbeService.jsonld +77 -0
  73. package/dist/edge/ProbeTargetGuard.d.ts +35 -0
  74. package/dist/edge/ProbeTargetGuard.js +142 -0
  75. package/dist/edge/reachability/NodeAccessResolver.d.ts +16 -0
  76. package/dist/edge/reachability/NodeAccessResolver.js +30 -0
  77. package/dist/edge/reachability/ReachabilitySessionService.js +4 -1
  78. package/dist/edge/reachability/RouteSetBuilder.d.ts +18 -1
  79. package/dist/edge/reachability/RouteSetBuilder.js +47 -0
  80. package/dist/edge/reachability/RouteSetBuilder.jsonld +29 -0
  81. package/dist/edge/reachability/types.d.ts +8 -2
  82. package/dist/http/SubgraphSparqlHttpHandler.d.ts +1 -25
  83. package/dist/http/SubgraphSparqlHttpHandler.js +0 -100
  84. package/dist/http/SubgraphSparqlHttpHandler.jsonld +0 -8
  85. package/dist/identity/drizzle/PodInterfaceKeyRepository.d.ts +33 -0
  86. package/dist/identity/drizzle/PodInterfaceKeyRepository.js +78 -0
  87. package/dist/identity/drizzle/db.d.ts +7 -0
  88. package/dist/identity/drizzle/db.js +30 -0
  89. package/dist/identity/drizzle/schema.pg.d.ts +9 -0
  90. package/dist/identity/drizzle/schema.pg.js +16 -1
  91. package/dist/identity/drizzle/schema.sqlite.d.ts +106 -0
  92. package/dist/identity/drizzle/schema.sqlite.js +16 -1
  93. package/dist/index.d.ts +3 -2
  94. package/dist/index.js +9 -5
  95. package/dist/main.js +7 -0
  96. package/dist/runtime/GatewayAdminProxyAuth.d.ts +1 -16
  97. package/dist/runtime/GatewayAdminProxyAuth.js +2 -71
  98. package/dist/runtime/Proxy.d.ts +32 -1
  99. package/dist/runtime/Proxy.js +125 -31
  100. package/dist/runtime/bootstrap.d.ts +21 -0
  101. package/dist/runtime/bootstrap.js +45 -1
  102. package/dist/runtime/css-process.d.ts +1 -0
  103. package/dist/runtime/css-process.js +1 -0
  104. package/dist/runtime/host/node/NodeRuntimeHost.js +6 -1
  105. package/dist/runtime/host/types.d.ts +6 -0
  106. package/dist/runtime/index.d.ts +1 -1
  107. package/dist/runtime/index.js +4 -1
  108. package/dist/runtime/js-runtime.js +10 -3
  109. package/dist/runtime/lifecycle.js +6 -4
  110. package/dist/runtime/port-finder.d.ts +26 -0
  111. package/dist/runtime/port-finder.js +64 -0
  112. package/dist/runtime/runner/node/NodeGatewayRuntimeRunner.js +1 -0
  113. package/dist/runtime/runner/types.d.ts +5 -0
  114. package/dist/runtime/runtime-types.d.ts +1 -0
  115. package/dist/test-utils/local-managed-client-p2p-e2e-smoke.js +1 -1
  116. package/dist/tunnel/AutoTunnelProvider.d.ts +56 -0
  117. package/dist/tunnel/AutoTunnelProvider.js +181 -0
  118. package/dist/tunnel/LocalTunnelProvider.d.ts +15 -0
  119. package/dist/tunnel/LocalTunnelProvider.js +87 -18
  120. package/dist/tunnel/LocalTunnelProvider.jsonld +27 -0
  121. package/dist/tunnel/NgrokTunnelProvider.d.ts +4 -0
  122. package/dist/tunnel/NgrokTunnelProvider.js +117 -43
  123. package/dist/tunnel/NgrokTunnelProvider.jsonld +4 -0
  124. package/dist/tunnel/SakuraFrpTunnelProvider.d.ts +65 -3
  125. package/dist/tunnel/SakuraFrpTunnelProvider.js +268 -25
  126. package/dist/tunnel/TunnelLifecycle.d.ts +14 -0
  127. package/dist/tunnel/TunnelLifecycle.js +34 -0
  128. package/dist/tunnel/TunnelProfiles.d.ts +33 -3
  129. package/dist/tunnel/TunnelProfiles.js +105 -78
  130. package/dist/tunnel/TunnelProvider.d.ts +15 -2
  131. package/dist/tunnel/TunnelProvider.jsonld +8 -0
  132. package/dist/tunnel/TunnelProviderCatalog.d.ts +62 -0
  133. package/dist/tunnel/TunnelProviderCatalog.js +130 -0
  134. package/dist/tunnel/index.d.ts +1 -0
  135. package/dist/tunnel/index.js +3 -1
  136. package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.d.ts +1 -1
  137. package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.js +1 -1
  138. package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.d.ts +1 -1
  139. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.d.ts +1 -1
  140. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.js +1 -1
  141. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectDialog.d.ts +1 -1
  142. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.d.ts +1 -1
  143. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.d.ts +1 -1
  144. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialRow.d.ts +1 -1
  145. package/node_modules/@undefineds.co/ai-connections/dist/AiCustomProviderDialog.d.ts +1 -1
  146. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.d.ts +1 -1
  147. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.d.ts +1 -1
  148. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.d.ts +1 -1
  149. package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.d.ts +1 -1
  150. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.d.ts +1 -1
  151. package/node_modules/@undefineds.co/ai-connections/dist/AiQuotaCard.d.ts +1 -1
  152. package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.d.ts +1 -1
  153. package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.d.ts +1 -1
  154. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.d.ts +1 -1
  155. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.js +3 -3
  156. package/node_modules/@undefineds.co/ai-connections/dist/collections.d.ts +1 -1
  157. package/node_modules/@undefineds.co/ai-connections/dist/collections.js +3 -3
  158. package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/ai-connections-client.d.ts +1 -1
  159. package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/ai-connections-client.js +1 -1
  160. package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/index.cjs +8 -8
  161. package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/index.d.ts +1 -1
  162. package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/index.js +1 -1
  163. package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/provider-catalog.cjs +3 -3
  164. package/node_modules/@undefineds.co/ai-connections/dist/controller.d.ts +1 -1
  165. package/node_modules/@undefineds.co/ai-connections/dist/controller.js +1 -1
  166. package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.d.ts +1 -1
  167. package/node_modules/@undefineds.co/ai-connections/dist/display-wording.d.ts +1 -1
  168. package/node_modules/@undefineds.co/ai-connections/dist/error-wording.d.ts +1 -1
  169. package/node_modules/@undefineds.co/ai-connections/dist/error-wording.js +8 -3
  170. package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.js +1 -1
  171. package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.d.ts +1 -1
  172. package/node_modules/@undefineds.co/ai-connections/dist/offering-label.d.ts +1 -1
  173. package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.d.ts +1 -1
  174. package/node_modules/@undefineds.co/ai-connections/dist/service-access.js +1 -1
  175. package/node_modules/@undefineds.co/ai-connections/dist/useAiConnectDialog.d.ts +1 -1
  176. package/node_modules/@undefineds.co/ai-connections/package.json +31 -1
  177. package/node_modules/@undefineds.co/solid-sdk/dist/access-route.cjs +230 -0
  178. package/node_modules/@undefineds.co/solid-sdk/dist/access-route.d.ts +76 -0
  179. package/node_modules/@undefineds.co/solid-sdk/dist/access-route.js +115 -0
  180. package/node_modules/@undefineds.co/solid-sdk/dist/index.cjs +89 -0
  181. package/node_modules/@undefineds.co/solid-sdk/dist/index.d.ts +1 -0
  182. package/node_modules/@undefineds.co/solid-sdk/dist/index.js +1 -0
  183. package/node_modules/@undefineds.co/solid-sdk/package.json +6 -1
  184. package/package.json +5 -6
  185. package/static/app/assets/inrupt-smoke.js +23 -23
  186. package/static/app/assets/main.css +1 -1
  187. package/static/auth-callback/assets/{AiConfigContext-DlFyEWy9.js → AiConfigContext-Bx0HCAW5.js} +1 -1
  188. package/static/auth-callback/assets/{AiConfigPage-CkYk-SFW.js → AiConfigPage-ChQImMbm.js} +1 -1
  189. package/static/auth-callback/assets/{DocumentProcessingPanel-CqIr3JqN.js → DocumentProcessingPanel-D830H4SH.js} +1 -1
  190. package/static/auth-callback/assets/{IndexLifecyclePanel-C1GKV3Vx.js → IndexLifecyclePanel-CnlkjMF8.js} +1 -1
  191. package/static/auth-callback/assets/{IndexSubjectPanel-ro9lC6XW.js → IndexSubjectPanel-CdEfg_CO.js} +1 -1
  192. package/static/auth-callback/assets/{ModelAssignmentsPanel-DxNdyKRJ.js → ModelAssignmentsPanel-D-8A8dZx.js} +1 -1
  193. package/static/auth-callback/assets/{ModelsPage-BVtWSPBU.js → ModelsPage-Cim7cubp.js} +3 -3
  194. package/static/auth-callback/assets/NetworkPage-CfK3x-pb.js +2 -0
  195. package/static/auth-callback/assets/{PaneListHeader-ByKw8ada.js → PaneListHeader-Bf_kEd4U.js} +1 -1
  196. package/static/auth-callback/assets/{SearchIndexingPanel-CulBKcYT.js → SearchIndexingPanel-4kD4RBEQ.js} +1 -1
  197. package/static/auth-callback/assets/{StatusSubjectPanel-VOcfrt8o.js → StatusSubjectPanel-Bw9AiTSf.js} +1 -1
  198. package/static/auth-callback/assets/{StatusWorkspace-Jsz6hAdE.js → StatusWorkspace-C-301H-0.js} +1 -1
  199. package/static/auth-callback/assets/{SystemSettingsPage-BFNvGAle.js → SystemSettingsPage-BbWn-eG6.js} +1 -1
  200. package/static/auth-callback/assets/{SystemSettingsSubjectPanel-DFRdrSfK.js → SystemSettingsSubjectPanel-DA4wvNSm.js} +1 -1
  201. package/static/auth-callback/assets/{XpodAiConnectionsPodStore-C6KpvHVg.js → XpodAiConnectionsPodStore-CohdyLoX.js} +1 -1
  202. package/static/auth-callback/assets/{activity-DnTlb9iM.js → activity-CCsb9Oam.js} +1 -1
  203. package/static/auth-callback/assets/ai-connections-DexTPyfC.js +1 -0
  204. package/static/auth-callback/assets/{auth-callback-D2UkK5Xj.js → auth-callback-Ds-c62W3.js} +5 -5
  205. package/static/auth-callback/assets/auth-callback-rk080mvG.css +1 -0
  206. package/static/auth-callback/assets/{badge-D7IJuuTM.js → badge-CQm5OyzR.js} +1 -1
  207. package/static/auth-callback/assets/{collection-runtime-wT1n4GS2.js → collection-runtime-DlAuU5TW.js} +1 -1
  208. package/static/auth-callback/assets/{dialog-DickLu5z.js → dialog-CnGzg5Ff.js} +1 -1
  209. package/static/auth-callback/assets/{download-kn8WnRu3.js → download-DwMONJvm.js} +1 -1
  210. package/static/auth-callback/assets/{external-link-B6B8jfSn.js → external-link-Bu5AGqCO.js} +1 -1
  211. package/static/auth-callback/assets/{index-DHF97YLP.js → index-B0T-1YO8.js} +1 -1
  212. package/static/auth-callback/assets/{index-Dz83EEHD.js → index-C8QZf_4W.js} +1 -1
  213. package/static/auth-callback/assets/index-DwIlrIDG.js +4 -0
  214. package/static/auth-callback/assets/{index-browser-CSghinyi.js → index-browser-lRsMcP_7.js} +1 -1
  215. package/static/auth-callback/assets/{key-round-ChkOx3E1.js → key-round-BDMtU57P.js} +1 -1
  216. package/static/auth-callback/assets/{rotate-ccw-B3hE-nyd.js → rotate-ccw-CoKIGCsQ.js} +1 -1
  217. package/static/auth-callback/assets/{skeleton-kEqR7tpI.js → skeleton-CPoSWHDr.js} +1 -1
  218. package/static/auth-callback/assets/{waypoints-D6Jo-SZa.js → waypoints-BeYHxqHv.js} +1 -1
  219. package/static/auth-callback/assets/{workspace-layout-BHwT_cHd.js → workspace-layout-xA5YxiK3.js} +1 -1
  220. package/static/auth-callback/auth-callback.html +2 -2
  221. package/static/dashboard/assets/{AiConfigContext-BfC3v-x2.js → AiConfigContext-rWx4TyiH.js} +1 -1
  222. package/static/dashboard/assets/{AiConfigPage-QNS3u7Ff.js → AiConfigPage-StVJpDFT.js} +1 -1
  223. package/static/dashboard/assets/{DocumentProcessingPanel-Dr4XLeT4.js → DocumentProcessingPanel-DJ5yul2O.js} +1 -1
  224. package/static/dashboard/assets/{IndexLifecyclePanel-KtM_gpeO.js → IndexLifecyclePanel-CpjtgezK.js} +1 -1
  225. package/static/dashboard/assets/{IndexSubjectPanel-DLaiKdLc.js → IndexSubjectPanel-BVKcot1_.js} +1 -1
  226. package/static/dashboard/assets/{ModelAssignmentsPanel-Bk7TvQRq.js → ModelAssignmentsPanel-BxVgWZPc.js} +1 -1
  227. package/static/dashboard/assets/{ModelsPage-Cci3vlos.js → ModelsPage-CECBwmeO.js} +3 -3
  228. package/static/dashboard/assets/NetworkPage-zQgFscEW.js +2 -0
  229. package/static/dashboard/assets/{PaneListHeader-qHME_s08.js → PaneListHeader-DIPe8pS6.js} +1 -1
  230. package/static/dashboard/assets/{SearchIndexingPanel-HZPKj8H9.js → SearchIndexingPanel-lalFJ3c8.js} +1 -1
  231. package/static/dashboard/assets/{StatusSubjectPanel-ij7IpI8d.js → StatusSubjectPanel-CpY_KU-G.js} +1 -1
  232. package/static/dashboard/assets/{StatusWorkspace-Cp02JcaN.js → StatusWorkspace-BwWCii3A.js} +1 -1
  233. package/static/dashboard/assets/{SystemSettingsPage-BSeuvb8X.js → SystemSettingsPage-BKZxX-_n.js} +1 -1
  234. package/static/dashboard/assets/{SystemSettingsSubjectPanel-CP4_luGS.js → SystemSettingsSubjectPanel-BZrqb2C5.js} +1 -1
  235. package/static/dashboard/assets/{XpodAiConnectionsPodStore-urO6zaHL.js → XpodAiConnectionsPodStore-Bbpx9dTN.js} +1 -1
  236. package/static/dashboard/assets/{activity-DxjgQNvr.js → activity-BJ15TLVP.js} +1 -1
  237. package/static/dashboard/assets/ai-connections-GG6qkTJt.js +1 -0
  238. package/static/dashboard/assets/{badge-53qCrRbl.js → badge-BBX5FlaB.js} +1 -1
  239. package/static/dashboard/assets/{collection-runtime-BPAmHG46.js → collection-runtime-UBbHBzdf.js} +1 -1
  240. package/static/dashboard/assets/{dashboard-BcT2ByXw.js → dashboard-7Y6BHyV9.js} +62 -62
  241. package/static/dashboard/assets/dashboard-rk080mvG.css +1 -0
  242. package/static/dashboard/assets/{dialog-B28YtNhS.js → dialog-QrOJ-hB0.js} +1 -1
  243. package/static/dashboard/assets/{download-DkLNceJ4.js → download-DK9x-VOP.js} +1 -1
  244. package/static/dashboard/assets/{external-link-D3TXnlo3.js → external-link-Cnkn87mJ.js} +1 -1
  245. package/static/dashboard/assets/index-B1z84it5.js +4 -0
  246. package/static/dashboard/assets/{index-CIiBu9mr.js → index-DzjauX3N.js} +1 -1
  247. package/static/dashboard/assets/{index-CFIenkeK.js → index-cIa8_efI.js} +1 -1
  248. package/static/dashboard/assets/{key-round-B5ccp6nx.js → key-round-BoS6UqKz.js} +1 -1
  249. package/static/dashboard/assets/{rotate-ccw-DUpfkNnk.js → rotate-ccw-BeWV76i0.js} +1 -1
  250. package/static/dashboard/assets/{skeleton-BRe19fO0.js → skeleton-CypcJL07.js} +1 -1
  251. package/static/dashboard/assets/{waypoints-BKDMxEvu.js → waypoints-zHOOqfhi.js} +1 -1
  252. package/static/dashboard/assets/{workspace-layout-ZTF7C16h.js → workspace-layout-DZ9JuxnM.js} +1 -1
  253. package/static/dashboard/dashboard.html +2 -2
  254. package/static/settings/assets/{AiConfigContext-DsyWgu2i.js → AiConfigContext-D3b1l_Kw.js} +1 -1
  255. package/static/settings/assets/{AiConfigPage-CSCBckKo.js → AiConfigPage-DYKw-atP.js} +1 -1
  256. package/static/settings/assets/{DocumentProcessingPanel-w9yQDbBe.js → DocumentProcessingPanel-DguRfsIV.js} +1 -1
  257. package/static/settings/assets/{IndexLifecyclePanel-CUUXI8mP.js → IndexLifecyclePanel-B85qJJA4.js} +1 -1
  258. package/static/settings/assets/{IndexSubjectPanel-BypAU5TJ.js → IndexSubjectPanel-CsN7IxaV.js} +1 -1
  259. package/static/settings/assets/{ModelAssignmentsPanel-BetgXw1G.js → ModelAssignmentsPanel-DEp9byI6.js} +1 -1
  260. package/static/settings/assets/{ModelsPage-DZpTlTZ3.js → ModelsPage-CzTnPs_G.js} +3 -3
  261. package/static/settings/assets/NetworkPage-BDVnmUU0.js +2 -0
  262. package/static/settings/assets/{PaneListHeader-BGOqGec4.js → PaneListHeader-Cpe39N76.js} +1 -1
  263. package/static/settings/assets/{SearchIndexingPanel-DYAbpZ_9.js → SearchIndexingPanel-DA9w8lLL.js} +1 -1
  264. package/static/settings/assets/{StatusSubjectPanel-CFgzeQ8Q.js → StatusSubjectPanel-BU0Aq0CS.js} +1 -1
  265. package/static/settings/assets/{StatusWorkspace-4Z6g4Jvv.js → StatusWorkspace-D1AC1i5N.js} +1 -1
  266. package/static/settings/assets/{SystemSettingsPage-C1tlrgvI.js → SystemSettingsPage-ChKvOioO.js} +1 -1
  267. package/static/settings/assets/{SystemSettingsSubjectPanel-CcURI-1L.js → SystemSettingsSubjectPanel-DyTpOnD2.js} +1 -1
  268. package/static/settings/assets/{XpodAiConnectionsPodStore-owBQc5nY.js → XpodAiConnectionsPodStore-VU5Bsz1a.js} +1 -1
  269. package/static/settings/assets/{activity-CtBc9cNy.js → activity-DGpLfsQB.js} +1 -1
  270. package/static/settings/assets/ai-connections-DexTPyfC.js +1 -0
  271. package/static/settings/assets/{badge--r-FDIhU.js → badge-_hCrrWRP.js} +1 -1
  272. package/static/settings/assets/{collection-runtime-CnhPmwAM.js → collection-runtime-E40TZ8Cl.js} +1 -1
  273. package/static/settings/assets/{dialog-B7ZRsjN7.js → dialog-DTr2JkHn.js} +1 -1
  274. package/static/settings/assets/{download-DgQ1F8QR.js → download-B_D21DDX.js} +1 -1
  275. package/static/settings/assets/{external-link-Bz7NckNO.js → external-link-BATYaM13.js} +1 -1
  276. package/static/settings/assets/index-BAlAVi-J.js +4 -0
  277. package/static/settings/assets/{index-CkGda_Pg.js → index-Ckh4h9jj.js} +1 -1
  278. package/static/settings/assets/{index-Vv-8Vslg.js → index-DOiwLF4B.js} +1 -1
  279. package/static/settings/assets/{index-browser-Dq7omlpY.js → index-browser-DFFWN3Kr.js} +1 -1
  280. package/static/settings/assets/{key-round-CvuhloKV.js → key-round-ZTVU_1O1.js} +1 -1
  281. package/static/settings/assets/{rotate-ccw-DgFKDaz7.js → rotate-ccw-DDdw8PTU.js} +1 -1
  282. package/static/settings/assets/{settings-BvqY7K96.js → settings-CyLnISOv.js} +62 -62
  283. package/static/settings/assets/settings-rk080mvG.css +1 -0
  284. package/static/settings/assets/{skeleton-D3OeFDF6.js → skeleton-DEzA3hc2.js} +1 -1
  285. package/static/settings/assets/{waypoints-C4WbspTb.js → waypoints-BSdfNvEb.js} +1 -1
  286. package/static/settings/assets/{workspace-layout-B9H1Tqrk.js → workspace-layout-BOQnl_3d.js} +1 -1
  287. package/static/settings/settings.html +2 -2
  288. package/dist/api/ai-gateway/pod/HostedPodDataAccess.d.ts +0 -31
  289. package/dist/api/ai-gateway/pod/HostedPodDataAccess.js +0 -330
  290. package/dist/http/InternalPodDataHttpHandler.d.ts +0 -57
  291. package/dist/http/InternalPodDataHttpHandler.js +0 -551
  292. package/dist/http/InternalPodDataHttpHandler.jsonld +0 -243
  293. package/node_modules/@undefineds.co/ai-connections-core/package.json +0 -61
  294. package/static/auth-callback/assets/NetworkPage-cEvxRMAl.js +0 -2
  295. package/static/auth-callback/assets/ai-connections-C6yaE6WQ.js +0 -1
  296. package/static/auth-callback/assets/auth-callback-Cx9D_1qj.css +0 -1
  297. package/static/auth-callback/assets/index-Cu0EguPo.js +0 -4
  298. package/static/dashboard/assets/NetworkPage-Ot4G2dX5.js +0 -2
  299. package/static/dashboard/assets/ai-connections-CXp5gd1J.js +0 -1
  300. package/static/dashboard/assets/dashboard-Cx9D_1qj.css +0 -1
  301. package/static/dashboard/assets/index-Gp3cLolR.js +0 -4
  302. package/static/settings/assets/NetworkPage-BVkasFGM.js +0 -2
  303. package/static/settings/assets/ai-connections-C6yaE6WQ.js +0 -1
  304. package/static/settings/assets/index-BdXwm8nh.js +0 -4
  305. package/static/settings/assets/settings-Cx9D_1qj.css +0 -1
  306. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client/normalize.d.ts +0 -0
  307. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client/normalize.js +0 -0
  308. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client/request.d.ts +0 -0
  309. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client/request.js +0 -0
  310. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client/types.d.ts +0 -0
  311. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client/types.js +0 -0
  312. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/base-adapter.d.ts +0 -0
  313. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/base-adapter.js +0 -0
  314. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/codex.d.ts +0 -0
  315. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/codex.js +0 -0
  316. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/index.d.ts +0 -0
  317. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/index.js +0 -0
  318. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/json-env-adapter.d.ts +0 -0
  319. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/json-env-adapter.js +0 -0
  320. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/pi.d.ts +0 -0
  321. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/pi.js +0 -0
  322. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/transaction.d.ts +0 -0
  323. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/transaction.js +0 -0
  324. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/types.d.ts +0 -0
  325. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/client-config/types.js +0 -0
  326. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/credential-storage.d.ts +0 -0
  327. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/credential-storage.js +0 -0
  328. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/endpoint-urls.d.ts +0 -0
  329. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/endpoint-urls.js +0 -0
  330. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/provider-catalog.d.ts +0 -0
  331. /package/node_modules/@undefineds.co/{ai-connections-core/dist → ai-connections/dist/contract}/provider-catalog.js +0 -0
@@ -1,551 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InternalPodDataHttpHandler = void 0;
4
- const node_crypto_1 = require("node:crypto");
5
- const promises_1 = require("node:stream/promises");
6
- const global_logger_factory_1 = require("global-logger-factory");
7
- const sparqljs_1 = require("sparqljs");
8
- const community_server_1 = require("@solid/community-server");
9
- const AiConnectionsServiceAccess_1 = require("../api/ai-gateway/service-access/AiConnectionsServiceAccess");
10
- const AiConfigServiceAccess_1 = require("../api/ai-gateway/service-access/AiConfigServiceAccess");
11
- const GatewayAdminProxyAuth_1 = require("../runtime/GatewayAdminProxyAuth");
12
- const ResourceReadContext_1 = require("../storage/ResourceReadContext");
13
- const ALLOWED_METHODS = new Set(['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE']);
14
- const DEFAULT_NONCE_TTL_MS = 120_000;
15
- const DEFAULT_NONCE_MAX_ENTRIES = 10_000;
16
- const MODEL_QUERY_MAX_BODY_BYTES = 256 * 1024;
17
- class InternalPodDataHttpHandler extends community_server_1.HttpHandler {
18
- constructor(options) {
19
- super();
20
- this.logger = (0, global_logger_factory_1.getLoggerFor)(this);
21
- this.eTagHandler = new community_server_1.BasicETagHandler();
22
- this.conditionsParser = new community_server_1.BasicConditionsParser(this.eTagHandler);
23
- this.resourceStore = options.resourceStore;
24
- this.gatewayAdminProxyAuthSecret = options.gatewayAdminProxyAuthSecret ?? process.env.XPOD_GATEWAY_ADMIN_PROXY_AUTH_SECRET;
25
- this.patchBodyParser = options.patchBodyParser;
26
- this.sparqlHandler = options.sparqlHandler;
27
- this.deploymentBaseUrl = this.parseOptionalUrl(options.baseUrl ?? process.env.CSS_BASE_URL);
28
- this.basePath = options.basePath ?? '/.internal/pod-data';
29
- const nonceOptions = options;
30
- this.seenNonces = new BoundedTtlNonceCache({
31
- ttlMs: nonceOptions.nonceTtlMs ?? DEFAULT_NONCE_TTL_MS,
32
- maxEntries: nonceOptions.nonceMaxEntries ?? DEFAULT_NONCE_MAX_ENTRIES,
33
- now: nonceOptions.now,
34
- });
35
- }
36
- async canHandle({ request }) {
37
- if (this.requestPathname(request) !== this.basePath) {
38
- throw new community_server_1.NotImplementedHttpError('Not an internal Pod data request.');
39
- }
40
- }
41
- async handle({ request, response }) {
42
- if (this.requestPathname(request) !== this.basePath) {
43
- throw new community_server_1.NotImplementedHttpError('Not an internal Pod data request.');
44
- }
45
- const intent = this.verifyRequest(request);
46
- if (!intent) {
47
- this.writeNotFound(response);
48
- return;
49
- }
50
- try {
51
- await (0, ResourceReadContext_1.withDirectDataRead)(() => this.delegate(request, response, intent));
52
- }
53
- catch (error) {
54
- if (isHttpNotFound(error)) {
55
- if (intent.method === 'GET' && !isGatewayAccessKeySecretResource(intent)) {
56
- this.writeEmptyGraph(response);
57
- }
58
- else {
59
- this.writeNotFound(response);
60
- }
61
- return;
62
- }
63
- throw error;
64
- }
65
- }
66
- verifyRequest(request) {
67
- const method = request.method?.toUpperCase();
68
- if (!ALLOWED_METHODS.has(method ?? '')) {
69
- this.logRejectedRequest('method_not_allowed');
70
- return undefined;
71
- }
72
- if (!(0, GatewayAdminProxyAuth_1.isLoopbackRemoteAddress)(request.socket.remoteAddress)) {
73
- this.logRejectedRequest('non_loopback_transport');
74
- return undefined;
75
- }
76
- const verification = (0, GatewayAdminProxyAuth_1.verifyGatewayAdminProxyHeaders)({
77
- headers: request.headers,
78
- secret: this.gatewayAdminProxyAuthSecret,
79
- method,
80
- url: request.url,
81
- });
82
- if (!verification.valid || !verification.originalClientLoopback || !verification.intent || !verification.nonce) {
83
- this.logRejectedRequest(verification.reason ?? 'invalid_runtime_marker');
84
- return undefined;
85
- }
86
- if (!this.intentMatchesRequest(verification.intent, method)) {
87
- this.logRejectedRequest('intent_mismatch');
88
- return undefined;
89
- }
90
- if (!this.isHostedOwnerResource(verification.intent)) {
91
- this.logRejectedRequest('owner_resource_outside_deployment');
92
- return undefined;
93
- }
94
- if (!this.isAllowedAiConnectionResource(verification.intent)) {
95
- this.logRejectedRequest('resource_not_allowed');
96
- return undefined;
97
- }
98
- if (!this.seenNonces.consume(verification.nonce)) {
99
- this.logRejectedRequest('nonce_rejected');
100
- return undefined;
101
- }
102
- return verification.intent;
103
- }
104
- logRejectedRequest(reason) {
105
- this.logger.warn(`Rejected internal Pod data request: ${reason}`);
106
- }
107
- intentMatchesRequest(intent, method) {
108
- if (intent.method !== method) {
109
- return false;
110
- }
111
- if (intent.scopes.length === 0) {
112
- return false;
113
- }
114
- if (intent.principalKind === 'gateway-key-verifier') {
115
- return intent.scopes.length === 1 && ((intent.scopes[0] === 'ai:gateway-key:verify' && (method === 'GET' || method === 'HEAD' || method === 'POST'))
116
- || (intent.scopes[0] === 'ai:gateway-key:touch' && (method === 'GET' || method === 'HEAD' || method === 'PATCH')));
117
- }
118
- if (method === 'POST') {
119
- const endpointKind = trustedSparqlEndpointKind(resourceOwnerWebId(intent), intent.resourceUrl);
120
- if (endpointKind === 'settings') {
121
- return intentHasScope(intent, 'ai:credentials:read') || intentHasScope(intent, 'ai:credentials:write');
122
- }
123
- if (endpointKind === 'models') {
124
- return intentHasScope(intent, 'ai:credentials:read');
125
- }
126
- if (endpointKind === 'gatewayAccessKeys') {
127
- return intentHasScope(intent, 'ai:credentials:read');
128
- }
129
- }
130
- return intentHasScope(intent, method === 'GET' || method === 'HEAD' ? 'ai:credentials:read' : 'ai:credentials:write');
131
- }
132
- isHostedOwnerResource(intent) {
133
- if (!this.deploymentBaseUrl) {
134
- return false;
135
- }
136
- let resourceUrl;
137
- try {
138
- resourceUrl = new URL(intent.resourceUrl);
139
- }
140
- catch {
141
- return false;
142
- }
143
- const podRoot = podRootFromIntent(intent);
144
- if (!podRoot || !this.isInsideDeployment(podRoot) || !this.isInsideDeployment(resourceUrl)) {
145
- return false;
146
- }
147
- return resourceUrl.origin === podRoot.origin &&
148
- resourceUrl.pathname.startsWith(podRoot.pathname);
149
- }
150
- isAllowedAiConnectionResource(intent) {
151
- let resourceUrl;
152
- try {
153
- resourceUrl = new URL(intent.resourceUrl);
154
- }
155
- catch {
156
- return false;
157
- }
158
- if (intent.principalKind === 'gateway-key-verifier') {
159
- return isAllowedGatewayKeyVerifierResource(intent, resourceUrl);
160
- }
161
- const resourceOwner = resourceOwnerWebId(intent);
162
- const sparqlQuery = trustedSparqlQueryForOwner(resourceOwner, resourceUrl);
163
- if (sparqlQuery !== undefined) {
164
- return intent.method === 'GET';
165
- }
166
- if (trustedSparqlEndpointKind(resourceOwner, intent.resourceUrl) !== undefined) {
167
- return intent.method === 'POST' && !resourceUrl.search && !resourceUrl.hash;
168
- }
169
- if (resourceUrl.hash || resourceUrl.search) {
170
- return false;
171
- }
172
- const allowed = (0, AiConnectionsServiceAccess_1.createAiConnectionsServiceAccess)({
173
- ownerWebId: resourceOwner,
174
- serviceWebId: intent.ownerWebId,
175
- }).resources.map((resource) => resource.url);
176
- allowed.push(...(0, AiConfigServiceAccess_1.createAiConfigResourceUrls)(resourceOwner));
177
- return allowed.includes(resourceUrl.href);
178
- }
179
- async delegate(request, response, intent) {
180
- const resourceUrl = new URL(intent.resourceUrl);
181
- const sparqlOperation = await trustedSparqlOperationForRequest(request, resourceOwnerWebId(intent), resourceUrl, intent.method);
182
- if (sparqlOperation !== undefined) {
183
- if (!this.sparqlHandler) {
184
- throw new community_server_1.NotImplementedHttpError('Internal settings SPARQL delegation is not configured.');
185
- }
186
- if (!intentAllowsSparqlOperation(intent, sparqlOperation.kind)) {
187
- this.logRejectedRequest(`sparql_scope_mismatch:${sparqlOperation.kind}`);
188
- this.writeNotFound(response);
189
- return;
190
- }
191
- if (intent.method === 'POST' && intent.bodyDigest !== sparqlOperation.bodyDigest) {
192
- this.logRejectedRequest(`sparql_body_digest_mismatch:${intent.bodyDigest?.slice(0, 12) ?? 'missing'}:${sparqlOperation.bodyDigest?.slice(0, 12) ?? 'missing'}`);
193
- this.writeNotFound(response);
194
- return;
195
- }
196
- const input = {
197
- ownerWebId: resourceOwnerWebId(intent),
198
- endpointUrl: intent.resourceUrl,
199
- query: sparqlOperation.sparql,
200
- request,
201
- response,
202
- };
203
- if (sparqlOperation.kind === 'query') {
204
- await this.sparqlHandler.handleTrustedInternalSelect(input);
205
- }
206
- else {
207
- await this.sparqlHandler.handleTrustedInternalUpdate(input);
208
- }
209
- return;
210
- }
211
- if (trustedSparqlEndpointKind(resourceOwnerWebId(intent), intent.resourceUrl) !== undefined) {
212
- this.logRejectedRequest(`sparql_operation_unsupported:${firstHeader(request.headers['content-type']) ?? 'missing-content-type'}`);
213
- this.writeNotFound(response);
214
- return;
215
- }
216
- const identifier = { path: intent.resourceUrl };
217
- switch (intent.method) {
218
- case 'GET': {
219
- const representation = await this.resourceStore.getRepresentation(identifier, resourceReadPreferences(intent));
220
- response.statusCode = 200;
221
- response.setHeader('Content-Type', representation.metadata.contentType ?? 'text/turtle');
222
- this.writeETag(representation, response);
223
- await this.pipeRepresentation(representation, response);
224
- return;
225
- }
226
- case 'HEAD': {
227
- const representation = await this.resourceStore.getRepresentation(identifier, resourceReadPreferences(intent));
228
- response.statusCode = 200;
229
- response.setHeader('Content-Type', representation.metadata.contentType ?? 'text/turtle');
230
- this.writeETag(representation, response);
231
- representation.data.destroy();
232
- response.end();
233
- return;
234
- }
235
- case 'PUT': {
236
- const conditions = await this.conditionsParser.handleSafe(request);
237
- await this.resourceStore.setRepresentation(identifier, this.createRepresentation(request, intent.resourceUrl), conditions);
238
- response.statusCode = 204;
239
- response.end();
240
- return;
241
- }
242
- case 'PATCH': {
243
- await this.resourceStore.modifyResource(identifier, await this.createPatch(request, intent.resourceUrl));
244
- response.statusCode = 204;
245
- response.end();
246
- return;
247
- }
248
- case 'DELETE': {
249
- await this.resourceStore.deleteResource(identifier);
250
- response.statusCode = 204;
251
- response.end();
252
- }
253
- }
254
- }
255
- createRepresentation(request, resourceUrl) {
256
- const contentType = firstHeader(request.headers['content-type']) ?? 'text/turtle';
257
- return new community_server_1.BasicRepresentation(request, new community_server_1.RepresentationMetadata({ path: resourceUrl }, contentType));
258
- }
259
- writeETag(representation, response) {
260
- const eTag = this.eTagHandler.getETag(representation.metadata);
261
- if (eTag) {
262
- response.setHeader('ETag', eTag);
263
- }
264
- }
265
- async createPatch(request, resourceUrl) {
266
- if (!this.patchBodyParser) {
267
- throw new community_server_1.NotImplementedHttpError('Internal Pod data PATCH requires a PatchBodyParser.');
268
- }
269
- const contentType = firstHeader(request.headers['content-type']) ?? 'application/sparql-update';
270
- const metadata = new community_server_1.RepresentationMetadata({ path: resourceUrl }, contentType);
271
- return this.patchBodyParser.handleSafe({ request, metadata });
272
- }
273
- async pipeRepresentation(representation, response) {
274
- await (0, promises_1.pipeline)(representation.data, response);
275
- }
276
- writeNotFound(response) {
277
- response.statusCode = 404;
278
- response.setHeader('Cache-Control', 'no-store');
279
- response.end('Not Found');
280
- }
281
- writeEmptyGraph(response) {
282
- response.statusCode = 200;
283
- response.setHeader('Content-Type', 'text/turtle');
284
- response.setHeader('Cache-Control', 'no-store');
285
- response.end();
286
- }
287
- requestPathname(request) {
288
- const requestUrl = request.url ?? '/';
289
- try {
290
- // Route ownership is path-based. Do not let an untrusted or proxy-shaped
291
- // Host header make URL parsing throw and silently skip this first handler.
292
- return requestUrl.startsWith('/')
293
- ? new URL(requestUrl, 'http://xpod.internal').pathname
294
- : new URL(requestUrl).pathname;
295
- }
296
- catch {
297
- return undefined;
298
- }
299
- }
300
- parseOptionalUrl(value) {
301
- if (!value) {
302
- return undefined;
303
- }
304
- try {
305
- return new URL(ensureTrailingSlash(value));
306
- }
307
- catch {
308
- return undefined;
309
- }
310
- }
311
- isInsideDeployment(url) {
312
- return this.deploymentBaseUrl !== undefined &&
313
- url.origin === this.deploymentBaseUrl.origin &&
314
- url.pathname.startsWith(this.deploymentBaseUrl.pathname);
315
- }
316
- }
317
- exports.InternalPodDataHttpHandler = InternalPodDataHttpHandler;
318
- function isHttpNotFound(error) {
319
- return typeof error === 'object' &&
320
- error !== null &&
321
- ('statusCode' in error ? error.statusCode === 404 : error.name === 'NotFoundHttpError');
322
- }
323
- function firstHeader(value) {
324
- return Array.isArray(value) ? value[0] : value;
325
- }
326
- function hostedPodRootFromOwner(ownerUrl) {
327
- if (ownerUrl.hash !== '#me') {
328
- return undefined;
329
- }
330
- if (!ownerUrl.pathname.endsWith('/profile/card')) {
331
- return undefined;
332
- }
333
- const podPath = ownerUrl.pathname.slice(0, -'profile/card'.length);
334
- if (!podPath || !podPath.endsWith('/')) {
335
- return undefined;
336
- }
337
- return new URL(podPath, ownerUrl.origin);
338
- }
339
- function podRootFromIntent(intent) {
340
- if (!intent.podBaseUrl) {
341
- try {
342
- return hostedPodRootFromOwner(new URL(intent.ownerWebId));
343
- }
344
- catch {
345
- return undefined;
346
- }
347
- }
348
- try {
349
- const root = new URL(intent.podBaseUrl);
350
- root.search = '';
351
- root.hash = '';
352
- root.pathname = ensureTrailingSlash(root.pathname);
353
- return root;
354
- }
355
- catch {
356
- return undefined;
357
- }
358
- }
359
- function resourceOwnerWebId(intent) {
360
- const podRoot = podRootFromIntent(intent);
361
- return podRoot ? new URL('profile/card#me', podRoot).href : intent.ownerWebId;
362
- }
363
- function resourceReadPreferences(intent) {
364
- return isGatewayAccessKeySecretResource(intent)
365
- ? { type: { 'application/json': 1, '*/*': 0.1 } }
366
- : { type: { 'text/turtle': 1, '*/*': 0.1 } };
367
- }
368
- function isGatewayAccessKeySecretResource(intent) {
369
- try {
370
- const resource = new URL(intent.resourceUrl);
371
- const expected = new URL((0, AiConnectionsServiceAccess_1.resolveGatewayAccessKeySecretResourceUrl)(resourceOwnerWebId(intent)));
372
- return resource.href === expected.href;
373
- }
374
- catch {
375
- return false;
376
- }
377
- }
378
- async function trustedSparqlOperationForRequest(request, ownerWebId, resourceUrl, method) {
379
- const queryFromUrl = trustedSparqlQueryForOwner(ownerWebId, resourceUrl);
380
- if (queryFromUrl !== undefined) {
381
- return method === 'GET' ? { kind: 'query', sparql: queryFromUrl } : undefined;
382
- }
383
- const endpointKind = trustedSparqlEndpointKind(ownerWebId, resourceUrl);
384
- if (method !== 'POST' || !endpointKind || resourceUrl.search || resourceUrl.hash) {
385
- return undefined;
386
- }
387
- const body = await readRequestBody(request);
388
- if (!body) {
389
- return undefined;
390
- }
391
- const contentType = firstHeader(request.headers['content-type'])?.split(';', 1)[0].trim().toLowerCase();
392
- let declaredKind;
393
- let sparql;
394
- if (contentType === 'application/sparql-query') {
395
- declaredKind = 'query';
396
- sparql = body.toString('utf8').trim();
397
- }
398
- else if (contentType === 'application/sparql-update') {
399
- declaredKind = 'update';
400
- sparql = body.toString('utf8').trim();
401
- }
402
- else if (contentType === 'application/x-www-form-urlencoded') {
403
- const params = new URLSearchParams(body.toString('utf8'));
404
- const keys = Array.from(params.keys());
405
- const operation = keys.length === 1 && (keys[0] === 'query' || keys[0] === 'update')
406
- ? keys[0]
407
- : undefined;
408
- if (operation) {
409
- declaredKind = operation;
410
- sparql = params.get(operation)?.trim();
411
- }
412
- }
413
- const parsedKind = sparql ? parseSparqlKind(sparql) : undefined;
414
- if (!declaredKind || !sparql || parsedKind !== declaredKind ||
415
- (endpointKind !== 'settings' && parsedKind !== 'query')) {
416
- return undefined;
417
- }
418
- return {
419
- kind: parsedKind,
420
- sparql,
421
- bodyDigest: (0, node_crypto_1.createHash)('sha256').update(body).digest('hex'),
422
- };
423
- }
424
- function trustedSparqlQueryForOwner(ownerWebId, resourceUrl) {
425
- if (!trustedSparqlEndpointKind(ownerWebId, resourceUrl) || resourceUrl.hash) {
426
- return undefined;
427
- }
428
- const keys = Array.from(resourceUrl.searchParams.keys());
429
- if (keys.length !== 1 || keys[0] !== 'query') {
430
- return undefined;
431
- }
432
- const query = resourceUrl.searchParams.get('query')?.trim();
433
- return query && parseSparqlKind(query) === 'query' ? query : undefined;
434
- }
435
- function trustedSparqlEndpointKind(ownerWebId, resourceUrlValue) {
436
- let ownerUrl;
437
- let resourceUrl;
438
- try {
439
- ownerUrl = new URL(ownerWebId);
440
- resourceUrl = typeof resourceUrlValue === 'string' ? new URL(resourceUrlValue) : resourceUrlValue;
441
- }
442
- catch {
443
- return undefined;
444
- }
445
- const podRoot = hostedPodRootFromOwner(ownerUrl);
446
- if (!podRoot || resourceUrl.origin !== podRoot.origin) {
447
- return undefined;
448
- }
449
- if (resourceUrl.pathname === `${podRoot.pathname}settings/providers/-/sparql`) {
450
- return 'models';
451
- }
452
- if ((0, AiConnectionsServiceAccess_1.isGatewayAccessKeySparqlEndpoint)(ownerWebId, resourceUrl)) {
453
- return 'gatewayAccessKeys';
454
- }
455
- return resourceUrl.pathname === `${podRoot.pathname}settings/-/sparql` ? 'settings' : undefined;
456
- }
457
- function isAllowedGatewayKeyVerifierResource(intent, resourceUrl) {
458
- const ownerWebId = resourceOwnerWebId(intent);
459
- let documentUrl;
460
- try {
461
- documentUrl = new URL((0, AiConnectionsServiceAccess_1.resolveGatewayAccessKeyResourceUrl)(ownerWebId));
462
- }
463
- catch {
464
- return false;
465
- }
466
- const exactDocument = resourceUrl.href === documentUrl.href;
467
- if (intent.scopes[0] === 'ai:gateway-key:touch') {
468
- return exactDocument && (intent.method === 'GET' || intent.method === 'HEAD' || intent.method === 'PATCH');
469
- }
470
- if (intent.scopes[0] !== 'ai:gateway-key:verify') {
471
- return false;
472
- }
473
- if (exactDocument) {
474
- return intent.method === 'GET' || intent.method === 'HEAD';
475
- }
476
- if (!(0, AiConnectionsServiceAccess_1.isGatewayAccessKeySparqlEndpoint)(ownerWebId, resourceUrl)) {
477
- return false;
478
- }
479
- if (intent.method === 'GET') {
480
- return trustedSparqlQueryForOwner(ownerWebId, resourceUrl) !== undefined;
481
- }
482
- return intent.method === 'POST' && !resourceUrl.search && !resourceUrl.hash;
483
- }
484
- function parseSparqlKind(value) {
485
- try {
486
- const parsed = new sparqljs_1.Parser({ baseIRI: 'urn:xpod:internal-sparql:' }).parse(value);
487
- return parsed.type === 'update' ? 'update' : parsed.type === 'query' ? 'query' : undefined;
488
- }
489
- catch {
490
- return undefined;
491
- }
492
- }
493
- function intentHasScope(intent, requiredScope) {
494
- return intent.scopes.some((scope) => scope === requiredScope || scope === 'ai:credentials:*' || scope === 'ai:*');
495
- }
496
- function intentAllowsSparqlOperation(intent, operation) {
497
- if (intent.principalKind === 'gateway-key-verifier') {
498
- return operation === 'query'
499
- && intent.scopes.length === 1
500
- && intent.scopes[0] === 'ai:gateway-key:verify';
501
- }
502
- return intentHasScope(intent, operation === 'query' ? 'ai:credentials:read' : 'ai:credentials:write');
503
- }
504
- async function readRequestBody(request) {
505
- const chunks = [];
506
- let size = 0;
507
- for await (const chunk of request) {
508
- const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
509
- size += buffer.byteLength;
510
- if (size > MODEL_QUERY_MAX_BODY_BYTES) {
511
- return undefined;
512
- }
513
- chunks.push(buffer);
514
- }
515
- if (size === 0) {
516
- return undefined;
517
- }
518
- return Buffer.concat(chunks, size);
519
- }
520
- function ensureTrailingSlash(value) {
521
- return value.endsWith('/') ? value : `${value}/`;
522
- }
523
- class BoundedTtlNonceCache {
524
- constructor(options) {
525
- this.entries = new Map();
526
- this.ttlMs = Math.max(1, options.ttlMs);
527
- this.maxEntries = Math.max(1, options.maxEntries);
528
- this.now = options.now ?? Date.now;
529
- }
530
- consume(nonce) {
531
- const now = this.now();
532
- this.pruneExpired(now);
533
- if (this.entries.has(nonce)) {
534
- return false;
535
- }
536
- if (this.entries.size >= this.maxEntries) {
537
- return false;
538
- }
539
- this.entries.set(nonce, now + this.ttlMs);
540
- return true;
541
- }
542
- pruneExpired(now) {
543
- for (const [nonce, expiresAt] of this.entries) {
544
- if (expiresAt > now) {
545
- continue;
546
- }
547
- this.entries.delete(nonce);
548
- }
549
- }
550
- }
551
- //# sourceMappingURL=InternalPodDataHttpHandler.js.map