@mcp-use/inspector 20.0.0-beta.16 → 20.0.0-beta.18

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 (467) hide show
  1. package/README.md +25 -58
  2. package/dist/app/inspector.css.gz +0 -0
  3. package/dist/app/inspector.js.gz +0 -0
  4. package/dist/app/providers/anthropic.png +0 -0
  5. package/dist/app/providers/google.png +0 -0
  6. package/dist/app/providers/openai.png +0 -0
  7. package/dist/cli.js +14 -1440
  8. package/dist/client/index.d.ts +1399 -50
  9. package/dist/client/index.js +170 -24320
  10. package/dist/server/index.d.ts +79 -7
  11. package/dist/server/index.js +99 -23
  12. package/package.json +76 -33
  13. package/dist/cdn/inspector.css +0 -2
  14. package/dist/cdn/inspector.js +0 -92126
  15. package/dist/cdn/providers/anthropic.png +0 -0
  16. package/dist/cdn/providers/google.png +0 -0
  17. package/dist/cdn/providers/openai.png +0 -0
  18. package/dist/client/auth/manufact-auth.d.ts +0 -32
  19. package/dist/client/auth/manufact-auth.d.ts.map +0 -1
  20. package/dist/client/chat-history/ChatHistoryHeader.d.ts +0 -4
  21. package/dist/client/chat-history/ChatHistoryHeader.d.ts.map +0 -1
  22. package/dist/client/chat-history/ChatHistoryPanel.d.ts +0 -28
  23. package/dist/client/chat-history/ChatHistoryPanel.d.ts.map +0 -1
  24. package/dist/client/chat-history/ChatHistoryRail.d.ts +0 -5
  25. package/dist/client/chat-history/ChatHistoryRail.d.ts.map +0 -1
  26. package/dist/client/chat-history/ChatList.d.ts +0 -18
  27. package/dist/client/chat-history/ChatList.d.ts.map +0 -1
  28. package/dist/client/chat-history/ChatTitleReveal.d.ts +0 -10
  29. package/dist/client/chat-history/ChatTitleReveal.d.ts.map +0 -1
  30. package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts +0 -13
  31. package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts.map +0 -1
  32. package/dist/client/chat-history/chat-title.d.ts +0 -10
  33. package/dist/client/chat-history/chat-title.d.ts.map +0 -1
  34. package/dist/client/chat-history/providers/local-storage.d.ts +0 -21
  35. package/dist/client/chat-history/providers/local-storage.d.ts.map +0 -1
  36. package/dist/client/chat-history/types.d.ts +0 -39
  37. package/dist/client/chat-history/types.d.ts.map +0 -1
  38. package/dist/client/chat-history/useChatHistory.d.ts +0 -20
  39. package/dist/client/chat-history/useChatHistory.d.ts.map +0 -1
  40. package/dist/client/chat-history/useChatTitleGeneration.d.ts +0 -17
  41. package/dist/client/chat-history/useChatTitleGeneration.d.ts.map +0 -1
  42. package/dist/client/components/AddToClientDropdown.d.ts +0 -52
  43. package/dist/client/components/AddToClientDropdown.d.ts.map +0 -1
  44. package/dist/client/components/ChatTab.d.ts +0 -98
  45. package/dist/client/components/ChatTab.d.ts.map +0 -1
  46. package/dist/client/components/IframeConsole.d.ts +0 -7
  47. package/dist/client/components/IframeConsole.d.ts.map +0 -1
  48. package/dist/client/components/MCPAppsDebugControls.d.ts +0 -19
  49. package/dist/client/components/MCPAppsDebugControls.d.ts.map +0 -1
  50. package/dist/client/components/PromptsTab.d.ts +0 -34
  51. package/dist/client/components/PromptsTab.d.ts.map +0 -1
  52. package/dist/client/components/ResourcesTab.d.ts +0 -31
  53. package/dist/client/components/ResourcesTab.d.ts.map +0 -1
  54. package/dist/client/components/ToolsTab.d.ts +0 -39
  55. package/dist/client/components/ToolsTab.d.ts.map +0 -1
  56. package/dist/client/components/chat/AssistantMessage.d.ts +0 -10
  57. package/dist/client/components/chat/AssistantMessage.d.ts.map +0 -1
  58. package/dist/client/components/chat/ChatHeader.d.ts +0 -70
  59. package/dist/client/components/chat/ChatHeader.d.ts.map +0 -1
  60. package/dist/client/components/chat/ChatInput.d.ts +0 -29
  61. package/dist/client/components/chat/ChatInput.d.ts.map +0 -1
  62. package/dist/client/components/chat/ChatInputArea.d.ts +0 -65
  63. package/dist/client/components/chat/ChatInputArea.d.ts.map +0 -1
  64. package/dist/client/components/chat/ChatLandingForm.d.ts +0 -15
  65. package/dist/client/components/chat/ChatLandingForm.d.ts.map +0 -1
  66. package/dist/client/components/chat/ChatManagedNotice.d.ts +0 -10
  67. package/dist/client/components/chat/ChatManagedNotice.d.ts.map +0 -1
  68. package/dist/client/components/chat/ChatScrollToBottomButton.d.ts +0 -7
  69. package/dist/client/components/chat/ChatScrollToBottomButton.d.ts.map +0 -1
  70. package/dist/client/components/chat/ChatScrollTopFade.d.ts +0 -7
  71. package/dist/client/components/chat/ChatScrollTopFade.d.ts.map +0 -1
  72. package/dist/client/components/chat/ChatTraceView.d.ts +0 -7
  73. package/dist/client/components/chat/ChatTraceView.d.ts.map +0 -1
  74. package/dist/client/components/chat/ConfigurationDialog.d.ts +0 -42
  75. package/dist/client/components/chat/ConfigurationDialog.d.ts.map +0 -1
  76. package/dist/client/components/chat/ConfigureEmptyState.d.ts +0 -6
  77. package/dist/client/components/chat/ConfigureEmptyState.d.ts.map +0 -1
  78. package/dist/client/components/chat/CopyButton.d.ts +0 -10
  79. package/dist/client/components/chat/CopyButton.d.ts.map +0 -1
  80. package/dist/client/components/chat/FloatingChatElicitation.d.ts +0 -10
  81. package/dist/client/components/chat/FloatingChatElicitation.d.ts.map +0 -1
  82. package/dist/client/components/chat/McpReconnectBanner.d.ts +0 -10
  83. package/dist/client/components/chat/McpReconnectBanner.d.ts.map +0 -1
  84. package/dist/client/components/chat/MessageList.d.ts +0 -48
  85. package/dist/client/components/chat/MessageList.d.ts.map +0 -1
  86. package/dist/client/components/chat/MessageMetaActions.d.ts +0 -7
  87. package/dist/client/components/chat/MessageMetaActions.d.ts.map +0 -1
  88. package/dist/client/components/chat/PromptResultsList.d.ts +0 -8
  89. package/dist/client/components/chat/PromptResultsList.d.ts.map +0 -1
  90. package/dist/client/components/chat/PromptsDropdown.d.ts +0 -11
  91. package/dist/client/components/chat/PromptsDropdown.d.ts.map +0 -1
  92. package/dist/client/components/chat/StreamingAssistantContent.d.ts +0 -7
  93. package/dist/client/components/chat/StreamingAssistantContent.d.ts.map +0 -1
  94. package/dist/client/components/chat/SystemPromptButton.d.ts +0 -11
  95. package/dist/client/components/chat/SystemPromptButton.d.ts.map +0 -1
  96. package/dist/client/components/chat/ToolCallDisplay.d.ts +0 -10
  97. package/dist/client/components/chat/ToolCallDisplay.d.ts.map +0 -1
  98. package/dist/client/components/chat/ToolResultRenderer.d.ts +0 -15
  99. package/dist/client/components/chat/ToolResultRenderer.d.ts.map +0 -1
  100. package/dist/client/components/chat/ToolSelector.d.ts +0 -13
  101. package/dist/client/components/chat/ToolSelector.d.ts.map +0 -1
  102. package/dist/client/components/chat/UserMessage.d.ts +0 -10
  103. package/dist/client/components/chat/UserMessage.d.ts.map +0 -1
  104. package/dist/client/components/chat/chat-bar-styles.d.ts +0 -6
  105. package/dist/client/components/chat/chat-bar-styles.d.ts.map +0 -1
  106. package/dist/client/components/chat/chatModeStorage.d.ts +0 -11
  107. package/dist/client/components/chat/chatModeStorage.d.ts.map +0 -1
  108. package/dist/client/components/chat/conversion.d.ts +0 -19
  109. package/dist/client/components/chat/conversion.d.ts.map +0 -1
  110. package/dist/client/components/chat/freeTier.d.ts +0 -32
  111. package/dist/client/components/chat/freeTier.d.ts.map +0 -1
  112. package/dist/client/components/chat/managedChatNotice.d.ts +0 -16
  113. package/dist/client/components/chat/managedChatNotice.d.ts.map +0 -1
  114. package/dist/client/components/chat/partialToolArgs.d.ts +0 -10
  115. package/dist/client/components/chat/partialToolArgs.d.ts.map +0 -1
  116. package/dist/client/components/chat/providerMeta.d.ts +0 -27
  117. package/dist/client/components/chat/providerMeta.d.ts.map +0 -1
  118. package/dist/client/components/chat/system-prompt/local-storage.d.ts +0 -5
  119. package/dist/client/components/chat/system-prompt/local-storage.d.ts.map +0 -1
  120. package/dist/client/components/chat/system-prompt/types.d.ts +0 -8
  121. package/dist/client/components/chat/system-prompt/types.d.ts.map +0 -1
  122. package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts +0 -3
  123. package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts.map +0 -1
  124. package/dist/client/components/chat/system-prompt-default.d.ts +0 -2
  125. package/dist/client/components/chat/system-prompt-default.d.ts.map +0 -1
  126. package/dist/client/components/chat/trace.d.ts +0 -84
  127. package/dist/client/components/chat/trace.d.ts.map +0 -1
  128. package/dist/client/components/chat/types.d.ts +0 -76
  129. package/dist/client/components/chat/types.d.ts.map +0 -1
  130. package/dist/client/components/chat/useChatMessages.d.ts +0 -76
  131. package/dist/client/components/chat/useChatMessages.d.ts.map +0 -1
  132. package/dist/client/components/chat/useChatMessagesClientSide.d.ts +0 -43
  133. package/dist/client/components/chat/useChatMessagesClientSide.d.ts.map +0 -1
  134. package/dist/client/components/chat/useChatScrollToBottom.d.ts +0 -14
  135. package/dist/client/components/chat/useChatScrollToBottom.d.ts.map +0 -1
  136. package/dist/client/components/chat/useConfig.d.ts +0 -24
  137. package/dist/client/components/chat/useConfig.d.ts.map +0 -1
  138. package/dist/client/components/chat/useHostedChatMode.d.ts +0 -14
  139. package/dist/client/components/chat/useHostedChatMode.d.ts.map +0 -1
  140. package/dist/client/components/chat/useManagedCloudModel.d.ts +0 -14
  141. package/dist/client/components/chat/useManagedCloudModel.d.ts.map +0 -1
  142. package/dist/client/components/chat/utils.d.ts +0 -11
  143. package/dist/client/components/chat/utils.d.ts.map +0 -1
  144. package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts +0 -12
  145. package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts.map +0 -1
  146. package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts +0 -9
  147. package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts.map +0 -1
  148. package/dist/client/components/elicitation/shared/schemaHelpers.d.ts +0 -8
  149. package/dist/client/components/elicitation/shared/schemaHelpers.d.ts.map +0 -1
  150. package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts +0 -29
  151. package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts.map +0 -1
  152. package/dist/client/components/prompts/PromptExecutionPanel.d.ts +0 -13
  153. package/dist/client/components/prompts/PromptExecutionPanel.d.ts.map +0 -1
  154. package/dist/client/components/prompts/PromptInputForm.d.ts +0 -9
  155. package/dist/client/components/prompts/PromptInputForm.d.ts.map +0 -1
  156. package/dist/client/components/prompts/PromptMessageCard.d.ts +0 -29
  157. package/dist/client/components/prompts/PromptMessageCard.d.ts.map +0 -1
  158. package/dist/client/components/prompts/PromptResultDisplay.d.ts +0 -34
  159. package/dist/client/components/prompts/PromptResultDisplay.d.ts.map +0 -1
  160. package/dist/client/components/prompts/PromptsList.d.ts +0 -10
  161. package/dist/client/components/prompts/PromptsList.d.ts.map +0 -1
  162. package/dist/client/components/prompts/SavedPromptsList.d.ts +0 -19
  163. package/dist/client/components/prompts/SavedPromptsList.d.ts.map +0 -1
  164. package/dist/client/components/resources/PropsConfigDialog.d.ts +0 -16
  165. package/dist/client/components/resources/PropsConfigDialog.d.ts.map +0 -1
  166. package/dist/client/components/resources/ResourceResultDisplay.d.ts +0 -30
  167. package/dist/client/components/resources/ResourceResultDisplay.d.ts.map +0 -1
  168. package/dist/client/components/resources/ResourcesList.d.ts +0 -10
  169. package/dist/client/components/resources/ResourcesList.d.ts.map +0 -1
  170. package/dist/client/components/shared/CollapsibleJSON.d.ts +0 -6
  171. package/dist/client/components/shared/CollapsibleJSON.d.ts.map +0 -1
  172. package/dist/client/components/shared/InspectorScrollArea.d.ts +0 -9
  173. package/dist/client/components/shared/InspectorScrollArea.d.ts.map +0 -1
  174. package/dist/client/components/shared/JSONDisplay.d.ts +0 -12
  175. package/dist/client/components/shared/JSONDisplay.d.ts.map +0 -1
  176. package/dist/client/components/shared/ListItem.d.ts +0 -24
  177. package/dist/client/components/shared/ListItem.d.ts.map +0 -1
  178. package/dist/client/components/shared/ListTabHeader.d.ts +0 -47
  179. package/dist/client/components/shared/ListTabHeader.d.ts.map +0 -1
  180. package/dist/client/components/shared/MarkdownRenderer.d.ts +0 -15
  181. package/dist/client/components/shared/MarkdownRenderer.d.ts.map +0 -1
  182. package/dist/client/components/shared/SchemaFormField.d.ts +0 -12
  183. package/dist/client/components/shared/SchemaFormField.d.ts.map +0 -1
  184. package/dist/client/components/shared/SearchTabHeader.d.ts +0 -28
  185. package/dist/client/components/shared/SearchTabHeader.d.ts.map +0 -1
  186. package/dist/client/components/shared/StatusIcon.d.ts +0 -12
  187. package/dist/client/components/shared/StatusIcon.d.ts.map +0 -1
  188. package/dist/client/components/shared/index.d.ts +0 -7
  189. package/dist/client/components/shared/index.d.ts.map +0 -1
  190. package/dist/client/components/tools/SaveRequestDialog.d.ts +0 -11
  191. package/dist/client/components/tools/SaveRequestDialog.d.ts.map +0 -1
  192. package/dist/client/components/tools/SavedRequestsList.d.ts +0 -19
  193. package/dist/client/components/tools/SavedRequestsList.d.ts.map +0 -1
  194. package/dist/client/components/tools/ToolExecutionPanel.d.ts +0 -20
  195. package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +0 -1
  196. package/dist/client/components/tools/ToolInputForm.d.ts +0 -14
  197. package/dist/client/components/tools/ToolInputForm.d.ts.map +0 -1
  198. package/dist/client/components/tools/ToolResultDisplay.d.ts +0 -25
  199. package/dist/client/components/tools/ToolResultDisplay.d.ts.map +0 -1
  200. package/dist/client/components/tools/ToolsList.d.ts +0 -10
  201. package/dist/client/components/tools/ToolsList.d.ts.map +0 -1
  202. package/dist/client/components/tools/schema-utils.d.ts +0 -13
  203. package/dist/client/components/tools/schema-utils.d.ts.map +0 -1
  204. package/dist/client/components/tools/useToolExecution.d.ts +0 -26
  205. package/dist/client/components/tools/useToolExecution.d.ts.map +0 -1
  206. package/dist/client/components/tools/useToolsTabNavigation.d.ts +0 -35
  207. package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +0 -1
  208. package/dist/client/components/ui/MeshGradientCanvas.d.ts +0 -13
  209. package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +0 -1
  210. package/dist/client/components/ui/WidgetWrapper.d.ts +0 -12
  211. package/dist/client/components/ui/WidgetWrapper.d.ts.map +0 -1
  212. package/dist/client/components/ui/alert-dialog.d.ts +0 -15
  213. package/dist/client/components/ui/alert-dialog.d.ts.map +0 -1
  214. package/dist/client/components/ui/ask-user-questions.d.ts +0 -80
  215. package/dist/client/components/ui/ask-user-questions.d.ts.map +0 -1
  216. package/dist/client/components/ui/badge.d.ts +0 -34
  217. package/dist/client/components/ui/badge.d.ts.map +0 -1
  218. package/dist/client/components/ui/blur-fade.d.ts +0 -25
  219. package/dist/client/components/ui/blur-fade.d.ts.map +0 -1
  220. package/dist/client/components/ui/button.d.ts +0 -34
  221. package/dist/client/components/ui/button.d.ts.map +0 -1
  222. package/dist/client/components/ui/chat-message.d.ts +0 -23
  223. package/dist/client/components/ui/chat-message.d.ts.map +0 -1
  224. package/dist/client/components/ui/checkbox.d.ts +0 -4
  225. package/dist/client/components/ui/checkbox.d.ts.map +0 -1
  226. package/dist/client/components/ui/client-icons.d.ts +0 -20
  227. package/dist/client/components/ui/client-icons.d.ts.map +0 -1
  228. package/dist/client/components/ui/command.d.ts +0 -17
  229. package/dist/client/components/ui/command.d.ts.map +0 -1
  230. package/dist/client/components/ui/dialog.d.ts +0 -37
  231. package/dist/client/components/ui/dialog.d.ts.map +0 -1
  232. package/dist/client/components/ui/dropdown-menu.d.ts +0 -25
  233. package/dist/client/components/ui/dropdown-menu.d.ts.map +0 -1
  234. package/dist/client/components/ui/dropdown.d.ts +0 -30
  235. package/dist/client/components/ui/dropdown.d.ts.map +0 -1
  236. package/dist/client/components/ui/file-thumbnail.d.ts +0 -9
  237. package/dist/client/components/ui/file-thumbnail.d.ts.map +0 -1
  238. package/dist/client/components/ui/input.d.ts +0 -4
  239. package/dist/client/components/ui/input.d.ts.map +0 -1
  240. package/dist/client/components/ui/kbd.d.ts +0 -3
  241. package/dist/client/components/ui/kbd.d.ts.map +0 -1
  242. package/dist/client/components/ui/label.d.ts +0 -4
  243. package/dist/client/components/ui/label.d.ts.map +0 -1
  244. package/dist/client/components/ui/menu-item.d.ts +0 -52
  245. package/dist/client/components/ui/menu-item.d.ts.map +0 -1
  246. package/dist/client/components/ui/mesh-animation-pause.d.ts +0 -14
  247. package/dist/client/components/ui/mesh-animation-pause.d.ts.map +0 -1
  248. package/dist/client/components/ui/mesh-gradient-colors.d.ts +0 -6
  249. package/dist/client/components/ui/mesh-gradient-colors.d.ts.map +0 -1
  250. package/dist/client/components/ui/mesh-tab-background.d.ts +0 -12
  251. package/dist/client/components/ui/mesh-tab-background.d.ts.map +0 -1
  252. package/dist/client/components/ui/not-found.d.ts +0 -9
  253. package/dist/client/components/ui/not-found.d.ts.map +0 -1
  254. package/dist/client/components/ui/popover.d.ts +0 -6
  255. package/dist/client/components/ui/popover.d.ts.map +0 -1
  256. package/dist/client/components/ui/resizable.d.ts +0 -10
  257. package/dist/client/components/ui/resizable.d.ts.map +0 -1
  258. package/dist/client/components/ui/scroll-area.d.ts +0 -4
  259. package/dist/client/components/ui/scroll-area.d.ts.map +0 -1
  260. package/dist/client/components/ui/select.d.ts +0 -52
  261. package/dist/client/components/ui/select.d.ts.map +0 -1
  262. package/dist/client/components/ui/sheet.d.ts +0 -14
  263. package/dist/client/components/ui/sheet.d.ts.map +0 -1
  264. package/dist/client/components/ui/skeleton.d.ts +0 -4
  265. package/dist/client/components/ui/skeleton.d.ts.map +0 -1
  266. package/dist/client/components/ui/spinner.d.ts +0 -3
  267. package/dist/client/components/ui/spinner.d.ts.map +0 -1
  268. package/dist/client/components/ui/switch.d.ts +0 -22
  269. package/dist/client/components/ui/switch.d.ts.map +0 -1
  270. package/dist/client/components/ui/table.d.ts +0 -9
  271. package/dist/client/components/ui/table.d.ts.map +0 -1
  272. package/dist/client/components/ui/tabs-subtle.d.ts +0 -25
  273. package/dist/client/components/ui/tabs-subtle.d.ts.map +0 -1
  274. package/dist/client/components/ui/text-shimmer.d.ts +0 -11
  275. package/dist/client/components/ui/text-shimmer.d.ts.map +0 -1
  276. package/dist/client/components/ui/textarea.d.ts +0 -4
  277. package/dist/client/components/ui/textarea.d.ts.map +0 -1
  278. package/dist/client/components/ui/tooltip.d.ts +0 -43
  279. package/dist/client/components/ui/tooltip.d.ts.map +0 -1
  280. package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts +0 -19
  281. package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts.map +0 -1
  282. package/dist/client/console-log-bus.d.ts +0 -24
  283. package/dist/client/console-log-bus.d.ts.map +0 -1
  284. package/dist/client/constants/debug-options.d.ts +0 -16
  285. package/dist/client/constants/debug-options.d.ts.map +0 -1
  286. package/dist/client/context/InspectorContext.d.ts +0 -134
  287. package/dist/client/context/InspectorContext.d.ts.map +0 -1
  288. package/dist/client/context/ThemeContext.d.ts +0 -17
  289. package/dist/client/context/ThemeContext.d.ts.map +0 -1
  290. package/dist/client/context/WidgetDebugContext.d.ts +0 -111
  291. package/dist/client/context/WidgetDebugContext.d.ts.map +0 -1
  292. package/dist/client/hooks/use-merge-split.d.ts +0 -36
  293. package/dist/client/hooks/use-merge-split.d.ts.map +0 -1
  294. package/dist/client/hooks/use-proximity-hover-index.d.ts +0 -27
  295. package/dist/client/hooks/use-proximity-hover-index.d.ts.map +0 -1
  296. package/dist/client/hooks/use-proximity-hover.d.ts +0 -26
  297. package/dist/client/hooks/use-proximity-hover.d.ts.map +0 -1
  298. package/dist/client/hooks/use-touch-primary.d.ts +0 -2
  299. package/dist/client/hooks/use-touch-primary.d.ts.map +0 -1
  300. package/dist/client/hooks/useDeviceViewport.d.ts +0 -14
  301. package/dist/client/hooks/useDeviceViewport.d.ts.map +0 -1
  302. package/dist/client/hooks/useHostedSession.d.ts +0 -9
  303. package/dist/client/hooks/useHostedSession.d.ts.map +0 -1
  304. package/dist/client/hooks/useIframeConsole.d.ts +0 -24
  305. package/dist/client/hooks/useIframeConsole.d.ts.map +0 -1
  306. package/dist/client/hooks/useKeyboardShortcuts.d.ts +0 -28
  307. package/dist/client/hooks/useKeyboardShortcuts.d.ts.map +0 -1
  308. package/dist/client/hooks/useMCPPrompts.d.ts +0 -94
  309. package/dist/client/hooks/useMCPPrompts.d.ts.map +0 -1
  310. package/dist/client/hooks/useMcpAppsHostContext.d.ts +0 -27
  311. package/dist/client/hooks/useMcpAppsHostContext.d.ts.map +0 -1
  312. package/dist/client/hooks/usePropsLLM.d.ts +0 -20
  313. package/dist/client/hooks/usePropsLLM.d.ts.map +0 -1
  314. package/dist/client/hooks/useResourceProps.d.ts +0 -14
  315. package/dist/client/hooks/useResourceProps.d.ts.map +0 -1
  316. package/dist/client/hooks/useSavedRequests.d.ts +0 -6
  317. package/dist/client/hooks/useSavedRequests.d.ts.map +0 -1
  318. package/dist/client/hooks/useViewHostProps.d.ts +0 -19
  319. package/dist/client/hooks/useViewHostProps.d.ts.map +0 -1
  320. package/dist/client/index.d.ts.map +0 -1
  321. package/dist/client/lib/elevated.d.ts +0 -28
  322. package/dist/client/lib/elevated.d.ts.map +0 -1
  323. package/dist/client/lib/font-weight.d.ts +0 -10
  324. package/dist/client/lib/font-weight.d.ts.map +0 -1
  325. package/dist/client/lib/icon-context.d.ts +0 -15
  326. package/dist/client/lib/icon-context.d.ts.map +0 -1
  327. package/dist/client/lib/shape-context.d.ts +0 -21
  328. package/dist/client/lib/shape-context.d.ts.map +0 -1
  329. package/dist/client/lib/springs.d.ts +0 -32
  330. package/dist/client/lib/springs.d.ts.map +0 -1
  331. package/dist/client/lib/surface-classes.d.ts +0 -2
  332. package/dist/client/lib/surface-classes.d.ts.map +0 -1
  333. package/dist/client/lib/surface-context.d.ts +0 -7
  334. package/dist/client/lib/surface-context.d.ts.map +0 -1
  335. package/dist/client/lib/utils.d.ts +0 -3
  336. package/dist/client/lib/utils.d.ts.map +0 -1
  337. package/dist/client/mcp-apps/csp.d.ts +0 -26
  338. package/dist/client/mcp-apps/csp.d.ts.map +0 -1
  339. package/dist/client/mcp-apps/debug/csp-suggestions.d.ts +0 -17
  340. package/dist/client/mcp-apps/debug/csp-suggestions.d.ts.map +0 -1
  341. package/dist/client/mcp-apps/logging-transport.d.ts +0 -13
  342. package/dist/client/mcp-apps/logging-transport.d.ts.map +0 -1
  343. package/dist/client/rpc-traffic-coalesce.d.ts +0 -7
  344. package/dist/client/rpc-traffic-coalesce.d.ts.map +0 -1
  345. package/dist/client/rpc-traffic-store.d.ts +0 -37
  346. package/dist/client/rpc-traffic-store.d.ts.map +0 -1
  347. package/dist/client/telemetry/capture.d.ts +0 -7
  348. package/dist/client/telemetry/capture.d.ts.map +0 -1
  349. package/dist/client/telemetry/events.d.ts +0 -168
  350. package/dist/client/telemetry/events.d.ts.map +0 -1
  351. package/dist/client/telemetry/index.d.ts +0 -5
  352. package/dist/client/telemetry/index.d.ts.map +0 -1
  353. package/dist/client/telemetry/init.d.ts +0 -2
  354. package/dist/client/telemetry/init.d.ts.map +0 -1
  355. package/dist/client/telemetry/utils.d.ts +0 -7
  356. package/dist/client/telemetry/utils.d.ts.map +0 -1
  357. package/dist/client/types/message-content-block.d.ts +0 -19
  358. package/dist/client/types/message-content-block.d.ts.map +0 -1
  359. package/dist/client/types/pending-requests.d.ts +0 -17
  360. package/dist/client/types/pending-requests.d.ts.map +0 -1
  361. package/dist/client/utils/basePath.d.ts +0 -34
  362. package/dist/client/utils/basePath.d.ts.map +0 -1
  363. package/dist/client/utils/browser.d.ts +0 -5
  364. package/dist/client/utils/browser.d.ts.map +0 -1
  365. package/dist/client/utils/format.d.ts +0 -4
  366. package/dist/client/utils/format.d.ts.map +0 -1
  367. package/dist/client/utils/highlightJson.d.ts +0 -11
  368. package/dist/client/utils/highlightJson.d.ts.map +0 -1
  369. package/dist/client/utils/jsonUtils.d.ts +0 -24
  370. package/dist/client/utils/jsonUtils.d.ts.map +0 -1
  371. package/dist/client/utils/mcpClientUtils.d.ts +0 -131
  372. package/dist/client/utils/mcpClientUtils.d.ts.map +0 -1
  373. package/dist/client/utils/servers.d.ts +0 -19
  374. package/dist/client/utils/servers.d.ts.map +0 -1
  375. package/dist/server/asset-urls.d.ts +0 -15
  376. package/dist/server/asset-urls.d.ts.map +0 -1
  377. package/dist/server/asset-urls.js +0 -13
  378. package/dist/server/cdn-shell.d.ts +0 -18
  379. package/dist/server/cdn-shell.d.ts.map +0 -1
  380. package/dist/server/cdn-shell.js +0 -12
  381. package/dist/server/chunk-FHC5ZGMM.js +0 -253
  382. package/dist/server/chunk-IKTZUWSX.js +0 -0
  383. package/dist/server/chunk-J4FNYLBF.js +0 -54
  384. package/dist/server/chunk-JZT7N2BJ.js +0 -58
  385. package/dist/server/chunk-K2F2AJOI.js +0 -619
  386. package/dist/server/chunk-KD7K27XK.js +0 -77
  387. package/dist/server/chunk-M5TZA42I.js +0 -54
  388. package/dist/server/chunk-OWR2BIBW.js +0 -40
  389. package/dist/server/chunk-PKBMQBKP.js +0 -7
  390. package/dist/server/chunk-QXOCY5ZE.js +0 -72
  391. package/dist/server/chunk-R5ZEVRE5.js +0 -154
  392. package/dist/server/chunk-UJLXHNQP.js +0 -43
  393. package/dist/server/chunk-WFT4JHYI.js +0 -24
  394. package/dist/server/chunk-XCNS5CIW.js +0 -199
  395. package/dist/server/cli.d.ts +0 -3
  396. package/dist/server/cli.d.ts.map +0 -1
  397. package/dist/server/cli.js +0 -141
  398. package/dist/server/create-dev-api-app.d.ts +0 -4
  399. package/dist/server/create-dev-api-app.d.ts.map +0 -1
  400. package/dist/server/create-dev-api-app.js +0 -11
  401. package/dist/server/dev-callback-redirect.d.ts +0 -3
  402. package/dist/server/dev-callback-redirect.d.ts.map +0 -1
  403. package/dist/server/dev-callback-redirect.js +0 -18
  404. package/dist/server/favicon-links.d.ts +0 -12
  405. package/dist/server/favicon-links.d.ts.map +0 -1
  406. package/dist/server/favicon-links.js +0 -11
  407. package/dist/server/favicon-static.d.ts +0 -4
  408. package/dist/server/favicon-static.d.ts.map +0 -1
  409. package/dist/server/favicon-static.js +0 -8
  410. package/dist/server/index.d.ts.map +0 -1
  411. package/dist/server/middleware.d.ts +0 -40
  412. package/dist/server/middleware.d.ts.map +0 -1
  413. package/dist/server/middleware.js +0 -17
  414. package/dist/server/proxy/index.d.ts +0 -3
  415. package/dist/server/proxy/index.d.ts.map +0 -1
  416. package/dist/server/proxy/index.js +0 -12
  417. package/dist/server/proxy/mcp-proxy.d.ts +0 -101
  418. package/dist/server/proxy/mcp-proxy.d.ts.map +0 -1
  419. package/dist/server/proxy/mcp-proxy.js +0 -10
  420. package/dist/server/proxy/oauth-proxy.d.ts +0 -26
  421. package/dist/server/proxy/oauth-proxy.d.ts.map +0 -1
  422. package/dist/server/proxy/oauth-proxy.js +0 -9
  423. package/dist/server/proxy-routes.d.ts +0 -16
  424. package/dist/server/proxy-routes.d.ts.map +0 -1
  425. package/dist/server/proxy-routes.js +0 -10
  426. package/dist/server/rpc-log-bus.d.ts +0 -17
  427. package/dist/server/rpc-log-bus.d.ts.map +0 -1
  428. package/dist/server/rpc-log-bus.js +0 -77
  429. package/dist/server/server.d.ts +0 -15
  430. package/dist/server/server.d.ts.map +0 -1
  431. package/dist/server/server.js +0 -66
  432. package/dist/server/static-assets.d.ts +0 -5
  433. package/dist/server/static-assets.d.ts.map +0 -1
  434. package/dist/server/static-assets.js +0 -9
  435. package/dist/server/utils.d.ts +0 -33
  436. package/dist/server/utils.d.ts.map +0 -1
  437. package/dist/server/utils.js +0 -17
  438. package/dist/server/version.d.ts +0 -7
  439. package/dist/server/version.d.ts.map +0 -1
  440. package/dist/server/version.js +0 -9
  441. package/dist/server/vite-dev-api-plugin.d.ts +0 -4
  442. package/dist/server/vite-dev-api-plugin.d.ts.map +0 -1
  443. package/dist/server/vite-dev-api-plugin.js +0 -30
  444. package/dist/web/apple-touch-icon.png +0 -0
  445. package/dist/web/assets/index-BgHcVJO3.js +0 -643
  446. package/dist/web/assets/index-bCIH1Sdx.css +0 -1
  447. package/dist/web/favicon-96x96.png +0 -0
  448. package/dist/web/favicon-black.svg +0 -5
  449. package/dist/web/favicon-white.svg +0 -5
  450. package/dist/web/favicon.ico +0 -0
  451. package/dist/web/favicon.svg +0 -5
  452. package/dist/web/index.html +0 -81
  453. package/dist/web/providers/anthropic.png +0 -0
  454. package/dist/web/providers/google.png +0 -0
  455. package/dist/web/providers/openai.png +0 -0
  456. package/dist/web/site.webmanifest +0 -21
  457. package/dist/web/web-app-manifest-192x192.png +0 -0
  458. package/dist/web/web-app-manifest-512x512.png +0 -0
  459. /package/dist/{cdn → app}/apple-touch-icon.png +0 -0
  460. /package/dist/{cdn → app}/favicon-96x96.png +0 -0
  461. /package/dist/{cdn → app}/favicon-black.svg +0 -0
  462. /package/dist/{cdn → app}/favicon-white.svg +0 -0
  463. /package/dist/{cdn → app}/favicon.ico +0 -0
  464. /package/dist/{cdn → app}/favicon.svg +0 -0
  465. /package/dist/{cdn → app}/site.webmanifest +0 -0
  466. /package/dist/{cdn → app}/web-app-manifest-192x192.png +0 -0
  467. /package/dist/{cdn → app}/web-app-manifest-512x512.png +0 -0
@@ -1,58 +0,0 @@
1
- // src/server/asset-urls.ts
2
- var JSDELIVR_INSPECTOR_TAG = "beta";
3
- var DEFAULT_REMOTE_ASSETS_URL = `https://cdn.jsdelivr.net/npm/@mcp-use/inspector@${JSDELIVR_INSPECTOR_TAG}/dist/cdn/inspector.js`;
4
- function inspectorStylesUrl(assetsUrl) {
5
- return assetsUrl.replace(/\.js(?=$|[?#])/, ".css");
6
- }
7
- function resolveInspectorAssetUrls(inspectorMode, basePath) {
8
- const envUrl = process.env.INSPECTOR_ASSETS_URL ?? process.env.MCP_USE_INSPECTOR_ASSETS_URL;
9
- if (envUrl) {
10
- return {
11
- jsUrl: envUrl,
12
- cssUrl: inspectorStylesUrl(envUrl),
13
- useLocal: false,
14
- resolveLatest: false
15
- };
16
- }
17
- const legacyBase = process.env.INSPECTOR_CDN_BASE;
18
- if (legacyBase) {
19
- const base = legacyBase.replace(/\/$/, "");
20
- if (/\.js(?:$|[?#])/.test(base)) {
21
- return {
22
- jsUrl: base,
23
- cssUrl: inspectorStylesUrl(base),
24
- useLocal: false,
25
- resolveLatest: false
26
- };
27
- }
28
- return {
29
- jsUrl: `${base}/inspector.js`,
30
- cssUrl: `${base}/inspector.css`,
31
- useLocal: false,
32
- resolveLatest: false
33
- };
34
- }
35
- if (inspectorMode === "standalone") {
36
- const prefix = basePath;
37
- return {
38
- jsUrl: `${prefix}/dist/cdn/inspector.js`,
39
- cssUrl: `${prefix}/dist/cdn/inspector.css`,
40
- useLocal: true,
41
- resolveLatest: false
42
- };
43
- }
44
- const jsUrl = DEFAULT_REMOTE_ASSETS_URL;
45
- return {
46
- jsUrl,
47
- cssUrl: inspectorStylesUrl(jsUrl),
48
- useLocal: false,
49
- resolveLatest: true
50
- };
51
- }
52
-
53
- export {
54
- JSDELIVR_INSPECTOR_TAG,
55
- DEFAULT_REMOTE_ASSETS_URL,
56
- inspectorStylesUrl,
57
- resolveInspectorAssetUrls
58
- };
@@ -1,619 +0,0 @@
1
- // src/server/proxy/oauth-proxy.ts
2
- import { lookup } from "dns/promises";
3
- import { isIP } from "net";
4
- var SAFE_REQUEST_HEADERS = /* @__PURE__ */ new Set([
5
- "accept",
6
- "authorization",
7
- "content-type",
8
- "dpop"
9
- ]);
10
- var SAFE_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
11
- "cache-control",
12
- "content-type",
13
- "dpop-nonce",
14
- "expires",
15
- "pragma",
16
- "retry-after",
17
- "www-authenticate"
18
- ]);
19
- var ENDPOINT_FIELDS = [
20
- ["registration_endpoint", "registration"],
21
- ["token_endpoint", "token"],
22
- ["revocation_endpoint", "revocation"],
23
- ["introspection_endpoint", "introspection"]
24
- ];
25
- var BINDING_TTL_MS = 10 * 60 * 1e3;
26
- var MAX_BINDINGS = 100;
27
- function mountOAuthProxy(app, options = {}) {
28
- const {
29
- basePath = "/oauth",
30
- allowedOrigins = [],
31
- allowLoopback = false,
32
- timeoutMs = 1e4,
33
- maxRequestBodyBytes = 64 * 1024,
34
- maxResponseBodyBytes = 1024 * 1024,
35
- enableLogging = true,
36
- authenticate,
37
- validateServerUrl
38
- } = options;
39
- const origins = new Set(allowedOrigins.map(normalizeOrigin));
40
- const bindings = /* @__PURE__ */ new Map();
41
- app.use(`${basePath}/*`, async (c, next) => {
42
- const origin = c.req.header("Origin");
43
- if (origin && !isAllowedOrigin(origin, c.req.url, origins)) {
44
- return c.json({ error: "Origin not allowed" }, 403);
45
- }
46
- if (c.req.method === "OPTIONS") {
47
- return corsResponse(origin);
48
- }
49
- await next();
50
- if (origin) setCorsHeaders(c.res.headers, origin);
51
- });
52
- app.get(`${basePath}/metadata`, async (c) => {
53
- if (!await isAuthenticated(c, authenticate)) {
54
- return c.json({ error: "Unauthorized" }, 401);
55
- }
56
- const serverUrlResult = await validateUrl(
57
- c.req.query("serverUrl"),
58
- allowLoopback
59
- );
60
- if ("error" in serverUrlResult) {
61
- return c.json({ error: serverUrlResult.error }, 400);
62
- }
63
- const serverUrl = serverUrlResult.url;
64
- if (validateServerUrl && !await validateServerUrl(serverUrl.toString(), c)) {
65
- return c.json({ error: "MCP server URL not allowed" }, 403);
66
- }
67
- const targetResult = await validateUrl(c.req.query("url"), allowLoopback);
68
- if ("error" in targetResult) {
69
- return c.json({ error: targetResult.error }, 400);
70
- }
71
- const target = targetResult.url;
72
- const key = canonicalUrl(serverUrl);
73
- const binding = getBinding(bindings, key);
74
- let metadataKind = classifyMetadataTarget(serverUrl, target, binding);
75
- if (!metadataKind && binding.authorizationServers.size === 0) {
76
- try {
77
- await hydrateBinding(
78
- serverUrl,
79
- binding,
80
- allowLoopback,
81
- timeoutMs,
82
- maxResponseBodyBytes
83
- );
84
- bindings.set(key, binding);
85
- metadataKind = classifyMetadataTarget(serverUrl, target, binding);
86
- } catch {
87
- }
88
- }
89
- if (!metadataKind) {
90
- return c.json(
91
- { error: "Metadata target is not bound to this MCP server" },
92
- 403
93
- );
94
- }
95
- try {
96
- log(enableLogging, `GET ${target}`);
97
- const upstream = await safeFetch(target, {
98
- method: "GET",
99
- headers: { Accept: "application/json" },
100
- redirect: "manual",
101
- signal: AbortSignal.timeout(timeoutMs)
102
- });
103
- if (isRedirect(upstream.status)) {
104
- return c.json(
105
- { error: "OAuth metadata redirects are not allowed" },
106
- 502
107
- );
108
- }
109
- const raw = await readCapped(upstream, maxResponseBodyBytes);
110
- if (!upstream.ok) {
111
- return c.body(raw, upstream.status, {
112
- "Content-Type": upstream.headers.get("content-type") ?? "application/json"
113
- });
114
- }
115
- const metadata = parseObject(raw);
116
- if (metadataKind.type === "protected-resource") {
117
- await bindProtectedResource(
118
- metadata,
119
- serverUrl,
120
- binding,
121
- allowLoopback
122
- );
123
- } else {
124
- await bindAuthorizationServer(
125
- metadata,
126
- metadataKind.issuer,
127
- binding,
128
- allowLoopback
129
- );
130
- }
131
- binding.updatedAt = Date.now();
132
- bindings.set(key, binding);
133
- pruneBindings(bindings);
134
- return c.body(raw, 200, {
135
- "Content-Type": upstream.headers.get("content-type") ?? "application/json"
136
- });
137
- } catch (error) {
138
- return proxyError(c, error, enableLogging);
139
- }
140
- });
141
- app.post(`${basePath}/proxy`, async (c) => {
142
- if (!await isAuthenticated(c, authenticate)) {
143
- return c.json({ error: "Unauthorized" }, 401);
144
- }
145
- let request;
146
- try {
147
- request = JSON.parse(
148
- await readRequestCapped(c.req.raw, maxRequestBodyBytes)
149
- );
150
- } catch (error) {
151
- return c.json(
152
- {
153
- error: error instanceof BodyTooLargeError ? "Request body too large" : "Invalid JSON request body"
154
- },
155
- error instanceof BodyTooLargeError ? 413 : 400
156
- );
157
- }
158
- const serverUrlResult = await validateUrl(request.serverUrl, allowLoopback);
159
- if ("error" in serverUrlResult) {
160
- return c.json({ error: serverUrlResult.error }, 400);
161
- }
162
- const serverUrl = serverUrlResult.url;
163
- if (validateServerUrl && !await validateServerUrl(serverUrl.toString(), c)) {
164
- return c.json({ error: "MCP server URL not allowed" }, 403);
165
- }
166
- const targetResult = await validateUrl(request.url, allowLoopback);
167
- if ("error" in targetResult) {
168
- return c.json({ error: targetResult.error }, 400);
169
- }
170
- const target = targetResult.url;
171
- if (request.method !== void 0 && request.method !== "POST") {
172
- return c.json({ error: "Only OAuth endpoint POST is allowed" }, 405);
173
- }
174
- const bindingKey = canonicalUrl(serverUrl);
175
- const binding = getBinding(bindings, bindingKey);
176
- if (binding.endpoints.size === 0) {
177
- try {
178
- await hydrateBinding(
179
- serverUrl,
180
- binding,
181
- allowLoopback,
182
- timeoutMs,
183
- maxResponseBodyBytes
184
- );
185
- bindings.set(bindingKey, binding);
186
- pruneBindings(bindings);
187
- } catch (error) {
188
- return proxyError(c, error, enableLogging);
189
- }
190
- }
191
- const endpointKind = binding.endpoints.get(canonicalUrl(target));
192
- if (!endpointKind) {
193
- return c.json(
194
- { error: "OAuth endpoint is not bound to this MCP server" },
195
- 403
196
- );
197
- }
198
- try {
199
- const headers = filterRequestHeaders(request.headers);
200
- const body = serializeBody(request.body, headers);
201
- if (new TextEncoder().encode(body ?? "").byteLength > maxRequestBodyBytes) {
202
- return c.json({ error: "OAuth request body too large" }, 413);
203
- }
204
- log(enableLogging, `POST ${endpointKind} ${target}`);
205
- const upstream = await safeFetch(target, {
206
- method: "POST",
207
- headers,
208
- body,
209
- redirect: "manual",
210
- signal: AbortSignal.timeout(timeoutMs)
211
- });
212
- if (isRedirect(upstream.status)) {
213
- return c.json(
214
- { error: "OAuth endpoint redirects are not allowed" },
215
- 502
216
- );
217
- }
218
- const raw = await readCapped(upstream, maxResponseBodyBytes);
219
- const responseHeaders = filterResponseHeaders(upstream.headers);
220
- const contentType = upstream.headers.get("content-type") ?? "";
221
- let responseBody = raw;
222
- if (contentType.includes("json")) {
223
- try {
224
- responseBody = JSON.parse(raw);
225
- } catch {
226
- }
227
- }
228
- return c.json({
229
- status: upstream.status,
230
- statusText: upstream.statusText,
231
- headers: responseHeaders,
232
- body: responseBody
233
- });
234
- } catch (error) {
235
- return proxyError(c, error, enableLogging);
236
- }
237
- });
238
- log(enableLogging, `Mounted at ${basePath}/metadata and ${basePath}/proxy`);
239
- }
240
- async function validateUrl(value, allowLoopback) {
241
- if (typeof value !== "string" || !value) {
242
- return { error: "Missing or invalid URL" };
243
- }
244
- let url;
245
- try {
246
- url = new URL(value);
247
- } catch {
248
- return { error: "Invalid URL" };
249
- }
250
- if (url.username || url.password || url.hash) {
251
- return { error: "URL credentials and fragments are not allowed" };
252
- }
253
- const loopback = isLoopbackHostname(url.hostname);
254
- if (url.protocol !== "https:") {
255
- if (!(allowLoopback && loopback && url.protocol === "http:")) {
256
- return { error: "HTTPS is required" };
257
- }
258
- }
259
- if (loopback) {
260
- return allowLoopback ? { url } : { error: "Loopback URL not allowed" };
261
- }
262
- if (isLocalHostname(url.hostname)) {
263
- return { error: "Local network URL not allowed" };
264
- }
265
- try {
266
- const addresses = isIP(url.hostname) ? [url.hostname] : (await lookup(url.hostname, { all: true, verbatim: true })).map(
267
- ({ address }) => address
268
- );
269
- if (addresses.length === 0 || addresses.some((address) => !isPublicAddress(address))) {
270
- return { error: "Private or non-routable URL not allowed" };
271
- }
272
- } catch {
273
- return { error: "URL hostname could not be resolved" };
274
- }
275
- return { url };
276
- }
277
- async function isSafeProxyTarget(value, allowLoopback = false) {
278
- return !("error" in await validateUrl(value, allowLoopback));
279
- }
280
- function classifyMetadataTarget(serverUrl, target, binding) {
281
- const targetUrl = canonicalUrl(target);
282
- if (protectedResourceMetadataUrls(serverUrl).some(
283
- (candidate) => canonicalUrl(candidate) === targetUrl
284
- )) {
285
- return { type: "protected-resource" };
286
- }
287
- for (const issuer of binding.authorizationServers) {
288
- if (authorizationServerMetadataUrls(new URL(issuer)).some(
289
- (candidate) => canonicalUrl(candidate) === targetUrl
290
- )) {
291
- return { type: "authorization-server", issuer };
292
- }
293
- }
294
- return void 0;
295
- }
296
- function protectedResourceMetadataUrls(serverUrl) {
297
- const path = serverUrl.pathname === "/" ? "" : serverUrl.pathname;
298
- return [
299
- new URL(`/.well-known/oauth-protected-resource${path}`, serverUrl.origin),
300
- new URL("/.well-known/oauth-protected-resource", serverUrl.origin)
301
- ];
302
- }
303
- function authorizationServerMetadataUrls(issuer) {
304
- const path = issuer.pathname === "/" ? "" : issuer.pathname;
305
- return [
306
- new URL(`/.well-known/oauth-authorization-server${path}`, issuer.origin),
307
- new URL(`/.well-known/openid-configuration${path}`, issuer.origin),
308
- new URL(`${path || ""}/.well-known/openid-configuration`, issuer.origin)
309
- ];
310
- }
311
- async function bindProtectedResource(metadata, serverUrl, binding, allowLoopback) {
312
- if (typeof metadata.resource !== "string" || canonicalUrl(new URL(metadata.resource)) !== canonicalUrl(serverUrl)) {
313
- throw new InvalidUpstreamError(
314
- "Protected-resource metadata does not match serverUrl"
315
- );
316
- }
317
- if (!Array.isArray(metadata.authorization_servers) || metadata.authorization_servers.length === 0) {
318
- throw new InvalidUpstreamError(
319
- "Protected-resource metadata has no authorization servers"
320
- );
321
- }
322
- const issuers = /* @__PURE__ */ new Set();
323
- for (const value of metadata.authorization_servers) {
324
- const result = await validateUrl(value, allowLoopback);
325
- if ("error" in result) {
326
- throw new InvalidUpstreamError(
327
- `Unsafe authorization server: ${result.error}`
328
- );
329
- }
330
- issuers.add(canonicalUrl(result.url));
331
- }
332
- binding.authorizationServers = issuers;
333
- binding.endpoints.clear();
334
- }
335
- async function bindAuthorizationServer(metadata, expectedIssuer, binding, allowLoopback) {
336
- if (typeof metadata.issuer !== "string" || canonicalUrl(new URL(metadata.issuer)) !== expectedIssuer) {
337
- throw new InvalidUpstreamError(
338
- "Authorization-server metadata issuer mismatch"
339
- );
340
- }
341
- binding.endpoints.clear();
342
- for (const [field, kind] of ENDPOINT_FIELDS) {
343
- const value = metadata[field];
344
- if (value === void 0) continue;
345
- const result = await validateUrl(value, allowLoopback);
346
- if ("error" in result) {
347
- throw new InvalidUpstreamError(`Unsafe ${field}: ${result.error}`);
348
- }
349
- binding.endpoints.set(canonicalUrl(result.url), kind);
350
- }
351
- }
352
- async function hydrateBinding(serverUrl, binding, allowLoopback, timeoutMs, maxResponseBodyBytes) {
353
- for (const metadataUrl of protectedResourceMetadataUrls(serverUrl)) {
354
- const response = await safeFetch(metadataUrl, {
355
- method: "GET",
356
- headers: { Accept: "application/json" },
357
- redirect: "manual",
358
- signal: AbortSignal.timeout(timeoutMs)
359
- });
360
- if (isRedirect(response.status)) {
361
- throw new InvalidUpstreamError(
362
- "OAuth metadata redirects are not allowed"
363
- );
364
- }
365
- if (!response.ok) continue;
366
- await bindProtectedResource(
367
- parseObject(await readCapped(response, maxResponseBodyBytes)),
368
- serverUrl,
369
- binding,
370
- allowLoopback
371
- );
372
- break;
373
- }
374
- if (binding.authorizationServers.size === 0) {
375
- throw new InvalidUpstreamError(
376
- "Protected-resource metadata could not be discovered"
377
- );
378
- }
379
- for (const issuer of binding.authorizationServers) {
380
- let bound = false;
381
- for (const metadataUrl of authorizationServerMetadataUrls(
382
- new URL(issuer)
383
- )) {
384
- const response = await safeFetch(metadataUrl, {
385
- method: "GET",
386
- headers: { Accept: "application/json" },
387
- redirect: "manual",
388
- signal: AbortSignal.timeout(timeoutMs)
389
- });
390
- if (isRedirect(response.status)) {
391
- throw new InvalidUpstreamError(
392
- "OAuth metadata redirects are not allowed"
393
- );
394
- }
395
- if (!response.ok) continue;
396
- await bindAuthorizationServer(
397
- parseObject(await readCapped(response, maxResponseBodyBytes)),
398
- issuer,
399
- binding,
400
- allowLoopback
401
- );
402
- bound = true;
403
- break;
404
- }
405
- if (bound) break;
406
- }
407
- if (binding.endpoints.size === 0) {
408
- throw new InvalidUpstreamError(
409
- "Authorization-server metadata could not be discovered"
410
- );
411
- }
412
- binding.updatedAt = Date.now();
413
- }
414
- async function safeFetch(url, init) {
415
- return fetch(url, init);
416
- }
417
- function filterRequestHeaders(value) {
418
- const result = new Headers();
419
- if (!value || typeof value !== "object" || Array.isArray(value))
420
- return result;
421
- for (const [name, rawValue] of Object.entries(value)) {
422
- const lower = name.toLowerCase();
423
- if (SAFE_REQUEST_HEADERS.has(lower) && typeof rawValue === "string") {
424
- result.set(lower, rawValue);
425
- }
426
- }
427
- return result;
428
- }
429
- function filterResponseHeaders(headers) {
430
- const result = {};
431
- headers.forEach((value, name) => {
432
- if (SAFE_RESPONSE_HEADERS.has(name.toLowerCase())) result[name] = value;
433
- });
434
- return result;
435
- }
436
- function serializeBody(body, headers) {
437
- if (body === void 0 || body === null) return void 0;
438
- if (typeof body === "string") return body;
439
- const contentType = headers.get("content-type") ?? "";
440
- if (contentType.includes("application/x-www-form-urlencoded") && typeof body === "object" && !Array.isArray(body)) {
441
- const params = new URLSearchParams();
442
- for (const [key, value] of Object.entries(
443
- body
444
- )) {
445
- params.append(key, String(value));
446
- }
447
- return params.toString();
448
- }
449
- if (!headers.has("content-type")) {
450
- headers.set("content-type", "application/json");
451
- }
452
- return JSON.stringify(body);
453
- }
454
- async function readRequestCapped(request, maxBytes) {
455
- const declared = Number(request.headers.get("content-length"));
456
- if (Number.isFinite(declared) && declared > maxBytes) {
457
- throw new BodyTooLargeError();
458
- }
459
- return readStreamCapped(request.body, maxBytes);
460
- }
461
- async function readCapped(response, maxBytes) {
462
- const declared = Number(response.headers.get("content-length"));
463
- if (Number.isFinite(declared) && declared > maxBytes) {
464
- await response.body?.cancel();
465
- throw new BodyTooLargeError();
466
- }
467
- return readStreamCapped(response.body, maxBytes);
468
- }
469
- async function readStreamCapped(stream, maxBytes) {
470
- if (!stream) return "";
471
- const reader = stream.getReader();
472
- const chunks = [];
473
- let size = 0;
474
- while (true) {
475
- const { done, value } = await reader.read();
476
- if (done) break;
477
- size += value.byteLength;
478
- if (size > maxBytes) {
479
- await reader.cancel();
480
- throw new BodyTooLargeError();
481
- }
482
- chunks.push(value);
483
- }
484
- const bytes = new Uint8Array(size);
485
- let offset = 0;
486
- for (const chunk of chunks) {
487
- bytes.set(chunk, offset);
488
- offset += chunk.byteLength;
489
- }
490
- return new TextDecoder().decode(bytes);
491
- }
492
- function parseObject(value) {
493
- let parsed;
494
- try {
495
- parsed = JSON.parse(value);
496
- } catch {
497
- throw new InvalidUpstreamError("OAuth metadata is not valid JSON");
498
- }
499
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
500
- throw new InvalidUpstreamError("OAuth metadata is not an object");
501
- }
502
- return parsed;
503
- }
504
- function getBinding(bindings, key) {
505
- const existing = bindings.get(key);
506
- if (existing && Date.now() - existing.updatedAt <= BINDING_TTL_MS) {
507
- return existing;
508
- }
509
- bindings.delete(key);
510
- return {
511
- authorizationServers: /* @__PURE__ */ new Set(),
512
- endpoints: /* @__PURE__ */ new Map(),
513
- updatedAt: Date.now()
514
- };
515
- }
516
- function pruneBindings(bindings) {
517
- const now = Date.now();
518
- for (const [key, binding] of bindings) {
519
- if (now - binding.updatedAt > BINDING_TTL_MS) bindings.delete(key);
520
- }
521
- while (bindings.size > MAX_BINDINGS) {
522
- const oldest = bindings.keys().next().value;
523
- if (!oldest) break;
524
- bindings.delete(oldest);
525
- }
526
- }
527
- function canonicalUrl(url) {
528
- const copy = new URL(url);
529
- copy.hash = "";
530
- if (copy.protocol === "https:" && copy.port === "443" || copy.protocol === "http:" && copy.port === "80") {
531
- copy.port = "";
532
- }
533
- return copy.toString().replace(/\/$/, "");
534
- }
535
- function normalizeOrigin(origin) {
536
- const url = new URL(origin);
537
- if (url.pathname !== "/" || url.search || url.hash) {
538
- throw new Error(`OAuth proxy allowed origin must be an origin: ${origin}`);
539
- }
540
- return url.origin;
541
- }
542
- function isAllowedOrigin(origin, requestUrl, allowed) {
543
- try {
544
- const normalized = normalizeOrigin(origin);
545
- return normalized === new URL(requestUrl).origin || allowed.has(normalized);
546
- } catch {
547
- return false;
548
- }
549
- }
550
- function corsResponse(origin) {
551
- const headers = new Headers();
552
- if (origin) setCorsHeaders(headers, origin);
553
- headers.set("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
554
- headers.set(
555
- "Access-Control-Allow-Headers",
556
- "Accept, Authorization, Content-Type"
557
- );
558
- headers.set("Access-Control-Max-Age", "600");
559
- return new Response(null, { status: 204, headers });
560
- }
561
- function setCorsHeaders(headers, origin) {
562
- headers.set("Access-Control-Allow-Origin", origin);
563
- headers.append("Vary", "Origin");
564
- }
565
- async function isAuthenticated(c, authenticate) {
566
- return authenticate ? authenticate(c) : true;
567
- }
568
- function isRedirect(status) {
569
- return status >= 300 && status < 400;
570
- }
571
- function isLoopbackHostname(hostname) {
572
- const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, "");
573
- return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "::1" || normalized.startsWith("127.");
574
- }
575
- function isLocalHostname(hostname) {
576
- const normalized = hostname.toLowerCase();
577
- return normalized.endsWith(".local") || normalized.endsWith(".internal") || normalized.endsWith(".home.arpa");
578
- }
579
- function isPublicAddress(address) {
580
- if (address.includes(":")) {
581
- const lower = address.toLowerCase();
582
- if (lower.startsWith("::ffff:")) {
583
- return isPublicAddress(lower.slice(7));
584
- }
585
- return !(lower === "::" || lower === "::1" || lower.startsWith("fc") || lower.startsWith("fd") || /^fe[89ab]/.test(lower) || lower.startsWith("ff") || lower.startsWith("2001:db8:"));
586
- }
587
- const parts = address.split(".").map(Number);
588
- if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part))) {
589
- return false;
590
- }
591
- const [a, b, c] = parts;
592
- return !(a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 0 && c === 0 || a === 192 && b === 0 && c === 2 || a === 192 && b === 168 || a === 198 && (b === 18 || b === 19) || a === 198 && b === 51 && c === 100 || a === 203 && b === 0 && c === 113 || a >= 224);
593
- }
594
- function log(enabled, message) {
595
- if (enabled) console.log(`[OAuth BFF] ${message}`);
596
- }
597
- function proxyError(c, error, logging) {
598
- const message = error instanceof Error ? error.message : "Unknown error";
599
- if (logging) console.error("[OAuth BFF]", message);
600
- if (error instanceof BodyTooLargeError) {
601
- return c.json({ error: "Upstream response too large" }, 502);
602
- }
603
- if (error instanceof InvalidUpstreamError) {
604
- return c.json({ error: error.message }, 502);
605
- }
606
- if (error instanceof DOMException && error.name === "TimeoutError") {
607
- return c.json({ error: "OAuth upstream timed out" }, 504);
608
- }
609
- return c.json({ error: "OAuth upstream request failed" }, 502);
610
- }
611
- var BodyTooLargeError = class extends Error {
612
- };
613
- var InvalidUpstreamError = class extends Error {
614
- };
615
-
616
- export {
617
- mountOAuthProxy,
618
- isSafeProxyTarget
619
- };