@mcp-use/inspector 20.0.0-beta.5 → 20.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -78
- package/dist/app/inspector.css.gz +0 -0
- package/dist/app/inspector.js.gz +0 -0
- package/dist/app/providers/anthropic.png +0 -0
- package/dist/app/providers/google.png +0 -0
- package/dist/app/providers/openai.png +0 -0
- package/dist/cli.js +332 -1384
- package/dist/client/index.d.ts +1405 -50
- package/dist/client/index.js +165 -24019
- package/dist/server/index.d.ts +79 -7
- package/dist/server/index.js +370 -22
- package/package.json +77 -35
- package/dist/cdn/AnimatePresence-Dcw-FOy8.js +0 -393
- package/dist/cdn/ChatTab-B255lH5i.js +0 -6744
- package/dist/cdn/CheckboxIndicator-Bt4IICtv.js +0 -251
- package/dist/cdn/ConnectionSettingsForm-DF-NS58d.js +0 -929
- package/dist/cdn/ConnectionSettingsTab-dI-Cqe79.js +0 -150
- package/dist/cdn/ElicitationTab-CL1KJ0bz.js +0 -654
- package/dist/cdn/FormContext-tmgN_Vdr.js +0 -135
- package/dist/cdn/InspectorContext-UjtEbNod.js +0 -123
- package/dist/cdn/JSONDisplay-BFxf5oEu.js +0 -324
- package/dist/cdn/ListTabHeader-Cv-GmtGF.js +0 -88
- package/dist/cdn/ManufactOAuthCallback-B98kSYCj.js +0 -31
- package/dist/cdn/MarkdownRenderer-Ba7nA4Ie.js +0 -3610
- package/dist/cdn/NotificationsTab-CeImSrhx.js +0 -290
- package/dist/cdn/OAuthCallback-Blc2Asxc.js +0 -58
- package/dist/cdn/PromptsTab-BYKnY7Rp.js +0 -901
- package/dist/cdn/ResourcesTab-BGualKW-.js +0 -564
- package/dist/cdn/SamplingTab-BeZBUeni.js +0 -658
- package/dist/cdn/ServerMetadataTab-CvrKX8fz.js +0 -244
- package/dist/cdn/StatusIcon-D0-ARyOh.js +0 -66
- package/dist/cdn/ToolsTab-j6n4O_3s.js +0 -2033
- package/dist/cdn/ViewPreview-DihyG6Qd.js +0 -238
- package/dist/cdn/WidgetDebugContext-D4usL_MA.js +0 -324
- package/dist/cdn/WidgetWrapper-B4H3Fek7.js +0 -2210
- package/dist/cdn/basePath-B8HuhIMu.js +0 -25
- package/dist/cdn/bell-CGjAO_0s.js +0 -10
- package/dist/cdn/browser-CbQIH4w2.js +0 -42
- package/dist/cdn/brush-B_mKhyxG.js +0 -17
- package/dist/cdn/card-DgiYnSg-.js +0 -41
- package/dist/cdn/cfWorker-Bxcs9rNe.js +0 -10799
- package/dist/cdn/checkbox-By0FklhG.js +0 -20
- package/dist/cdn/chunk-QUQL4437-XnDcYQEx.js +0 -1508
- package/dist/cdn/clock-CmUbSx_B.js +0 -12
- package/dist/cdn/code-V_0nf5rg.js +0 -10
- package/dist/cdn/createLucideIcon-C5fZZ6oB.js +0 -38
- package/dist/cdn/dialog-BsDpuJd3.js +0 -1028
- package/dist/cdn/dist-DaMB0Su9.js +0 -616
- package/dist/cdn/dist-DbX5yidW.js +0 -2306
- package/dist/cdn/external-link-CjmfT6rW.js +0 -17
- package/dist/cdn/eye-B7H96av8.js +0 -29
- package/dist/cdn/folder-open-B3lu2rG_.js +0 -7
- package/dist/cdn/hash-BVQnWi7q.js +0 -33
- package/dist/cdn/history-Csw4rb44.js +0 -17
- package/dist/cdn/index-browser-DkQOzkvX.js +0 -1934
- package/dist/cdn/info-CNiOwqkf.js +0 -19
- package/dist/cdn/input-C2OBd4PJ.js +0 -12160
- package/dist/cdn/inspector-settings-layout-0VDsjeqb.js +0 -4
- package/dist/cdn/inspector.css +0 -2
- package/dist/cdn/inspector.js +0 -24523
- package/dist/cdn/jsx-runtime-CIxvMpEo.js +0 -180
- package/dist/cdn/label-B9Jmm9be.js +0 -60
- package/dist/cdn/loader-circle-BLy9A_pp.js +0 -7
- package/dist/cdn/manufact-auth-BQMHhbLV.js +0 -423
- package/dist/cdn/maximize-2-CH5Lq90B.js +0 -21
- package/dist/cdn/maximize-BALCV_ep.js +0 -21
- package/dist/cdn/message-square-BnxdpJxZ.js +0 -7
- package/dist/cdn/not-found-DEtSM_Wd.js +0 -34
- package/dist/cdn/play-vuZ5PLnI.js +0 -7
- package/dist/cdn/providerMeta-BQIfHuNL.js +0 -379
- package/dist/cdn/providers/anthropic.png +0 -0
- package/dist/cdn/providers/google.png +0 -0
- package/dist/cdn/providers/openai.png +0 -0
- package/dist/cdn/react-BIs9pQ3H.js +0 -926
- package/dist/cdn/react-BajV-X4P.js +0 -5425
- package/dist/cdn/refresh-cw-BXY-Pa0U.js +0 -21
- package/dist/cdn/save-Tgil_AJZ.js +0 -34
- package/dist/cdn/schemaHelpers-DTV38jGq.js +0 -16
- package/dist/cdn/select-DDdiIPR2.js +0 -2594
- package/dist/cdn/servers-Dm72iTpY.js +0 -26
- package/dist/cdn/shared-DaILIQPP.js +0 -1700
- package/dist/cdn/sheet-Br_l2kry.js +0 -2077
- package/dist/cdn/sparkles-BntO2rDR.js +0 -23
- package/dist/cdn/spinner-jQtC7EBj.js +0 -15
- package/dist/cdn/square-check-big-BvwQ17Bl.js +0 -10
- package/dist/cdn/switch-C3IyQuid.js +0 -664
- package/dist/cdn/tabs-subtle-CkdI6Mac.js +0 -787
- package/dist/cdn/telemetry-DabTAQ8x.js +0 -240
- package/dist/cdn/textarea-DSbwcFVt.js +0 -14
- package/dist/cdn/trash-2-RwpJY5SL.js +0 -25
- package/dist/cdn/useAriaLabelledBy-DqAdnppm.js +0 -29
- package/dist/cdn/useCompositeItem-BRqEzYh-.js +0 -26
- package/dist/cdn/useConfig-Btmh8wjJ.js +0 -235
- package/dist/cdn/useSavedRequests-Ci2I919u.js +0 -51
- package/dist/cdn/useViewHostProps-B6SKeeH9.js +0 -349
- package/dist/cdn/wrench-DzGmCfnb.js +0 -7
- package/dist/cdn/x-C3vRQIYu.js +0 -10
- package/dist/cdn/zap-Mb-pbw2X.js +0 -10
- package/dist/client/auth/manufact-auth.d.ts +0 -32
- package/dist/client/auth/manufact-auth.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryHeader.d.ts +0 -4
- package/dist/client/chat-history/ChatHistoryHeader.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryPanel.d.ts +0 -28
- package/dist/client/chat-history/ChatHistoryPanel.d.ts.map +0 -1
- package/dist/client/chat-history/ChatHistoryRail.d.ts +0 -5
- package/dist/client/chat-history/ChatHistoryRail.d.ts.map +0 -1
- package/dist/client/chat-history/ChatList.d.ts +0 -18
- package/dist/client/chat-history/ChatList.d.ts.map +0 -1
- package/dist/client/chat-history/ChatTitleReveal.d.ts +0 -10
- package/dist/client/chat-history/ChatTitleReveal.d.ts.map +0 -1
- package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts +0 -13
- package/dist/client/chat-history/chat-events-to-inspector-messages.d.ts.map +0 -1
- package/dist/client/chat-history/chat-title.d.ts +0 -10
- package/dist/client/chat-history/chat-title.d.ts.map +0 -1
- package/dist/client/chat-history/providers/local-storage.d.ts +0 -21
- package/dist/client/chat-history/providers/local-storage.d.ts.map +0 -1
- package/dist/client/chat-history/types.d.ts +0 -39
- package/dist/client/chat-history/types.d.ts.map +0 -1
- package/dist/client/chat-history/useChatHistory.d.ts +0 -20
- package/dist/client/chat-history/useChatHistory.d.ts.map +0 -1
- package/dist/client/chat-history/useChatTitleGeneration.d.ts +0 -17
- package/dist/client/chat-history/useChatTitleGeneration.d.ts.map +0 -1
- package/dist/client/components/AddToClientDropdown.d.ts +0 -52
- package/dist/client/components/AddToClientDropdown.d.ts.map +0 -1
- package/dist/client/components/ChatTab.d.ts +0 -98
- package/dist/client/components/ChatTab.d.ts.map +0 -1
- package/dist/client/components/IframeConsole.d.ts +0 -7
- package/dist/client/components/IframeConsole.d.ts.map +0 -1
- package/dist/client/components/MCPAppsDebugControls.d.ts +0 -19
- package/dist/client/components/MCPAppsDebugControls.d.ts.map +0 -1
- package/dist/client/components/PromptsTab.d.ts +0 -34
- package/dist/client/components/PromptsTab.d.ts.map +0 -1
- package/dist/client/components/ResourcesTab.d.ts +0 -31
- package/dist/client/components/ResourcesTab.d.ts.map +0 -1
- package/dist/client/components/ToolsTab.d.ts +0 -39
- package/dist/client/components/ToolsTab.d.ts.map +0 -1
- package/dist/client/components/chat/AssistantMessage.d.ts +0 -10
- package/dist/client/components/chat/AssistantMessage.d.ts.map +0 -1
- package/dist/client/components/chat/ChatHeader.d.ts +0 -70
- package/dist/client/components/chat/ChatHeader.d.ts.map +0 -1
- package/dist/client/components/chat/ChatInput.d.ts +0 -29
- package/dist/client/components/chat/ChatInput.d.ts.map +0 -1
- package/dist/client/components/chat/ChatInputArea.d.ts +0 -65
- package/dist/client/components/chat/ChatInputArea.d.ts.map +0 -1
- package/dist/client/components/chat/ChatLandingForm.d.ts +0 -15
- package/dist/client/components/chat/ChatLandingForm.d.ts.map +0 -1
- package/dist/client/components/chat/ChatManagedNotice.d.ts +0 -10
- package/dist/client/components/chat/ChatManagedNotice.d.ts.map +0 -1
- package/dist/client/components/chat/ChatScrollToBottomButton.d.ts +0 -7
- package/dist/client/components/chat/ChatScrollToBottomButton.d.ts.map +0 -1
- package/dist/client/components/chat/ChatScrollTopFade.d.ts +0 -7
- package/dist/client/components/chat/ChatScrollTopFade.d.ts.map +0 -1
- package/dist/client/components/chat/ChatTraceView.d.ts +0 -7
- package/dist/client/components/chat/ChatTraceView.d.ts.map +0 -1
- package/dist/client/components/chat/ConfigurationDialog.d.ts +0 -42
- package/dist/client/components/chat/ConfigurationDialog.d.ts.map +0 -1
- package/dist/client/components/chat/ConfigureEmptyState.d.ts +0 -6
- package/dist/client/components/chat/ConfigureEmptyState.d.ts.map +0 -1
- package/dist/client/components/chat/CopyButton.d.ts +0 -10
- package/dist/client/components/chat/CopyButton.d.ts.map +0 -1
- package/dist/client/components/chat/FloatingChatElicitation.d.ts +0 -10
- package/dist/client/components/chat/FloatingChatElicitation.d.ts.map +0 -1
- package/dist/client/components/chat/McpReconnectBanner.d.ts +0 -10
- package/dist/client/components/chat/McpReconnectBanner.d.ts.map +0 -1
- package/dist/client/components/chat/MessageList.d.ts +0 -47
- package/dist/client/components/chat/MessageList.d.ts.map +0 -1
- package/dist/client/components/chat/MessageMetaActions.d.ts +0 -7
- package/dist/client/components/chat/MessageMetaActions.d.ts.map +0 -1
- package/dist/client/components/chat/PromptResultsList.d.ts +0 -8
- package/dist/client/components/chat/PromptResultsList.d.ts.map +0 -1
- package/dist/client/components/chat/PromptsDropdown.d.ts +0 -11
- package/dist/client/components/chat/PromptsDropdown.d.ts.map +0 -1
- package/dist/client/components/chat/StreamingAssistantContent.d.ts +0 -7
- package/dist/client/components/chat/StreamingAssistantContent.d.ts.map +0 -1
- package/dist/client/components/chat/SystemPromptButton.d.ts +0 -11
- package/dist/client/components/chat/SystemPromptButton.d.ts.map +0 -1
- package/dist/client/components/chat/ToolCallDisplay.d.ts +0 -10
- package/dist/client/components/chat/ToolCallDisplay.d.ts.map +0 -1
- package/dist/client/components/chat/ToolResultRenderer.d.ts +0 -15
- package/dist/client/components/chat/ToolResultRenderer.d.ts.map +0 -1
- package/dist/client/components/chat/ToolSelector.d.ts +0 -13
- package/dist/client/components/chat/ToolSelector.d.ts.map +0 -1
- package/dist/client/components/chat/UserMessage.d.ts +0 -10
- package/dist/client/components/chat/UserMessage.d.ts.map +0 -1
- package/dist/client/components/chat/chat-bar-styles.d.ts +0 -6
- package/dist/client/components/chat/chat-bar-styles.d.ts.map +0 -1
- package/dist/client/components/chat/chatModeStorage.d.ts +0 -11
- package/dist/client/components/chat/chatModeStorage.d.ts.map +0 -1
- package/dist/client/components/chat/conversion.d.ts +0 -19
- package/dist/client/components/chat/conversion.d.ts.map +0 -1
- package/dist/client/components/chat/freeTier.d.ts +0 -32
- package/dist/client/components/chat/freeTier.d.ts.map +0 -1
- package/dist/client/components/chat/managedChatNotice.d.ts +0 -16
- package/dist/client/components/chat/managedChatNotice.d.ts.map +0 -1
- package/dist/client/components/chat/providerMeta.d.ts +0 -27
- package/dist/client/components/chat/providerMeta.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/local-storage.d.ts +0 -5
- package/dist/client/components/chat/system-prompt/local-storage.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/types.d.ts +0 -8
- package/dist/client/components/chat/system-prompt/types.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts +0 -3
- package/dist/client/components/chat/system-prompt/useLocalSystemPrompt.d.ts.map +0 -1
- package/dist/client/components/chat/system-prompt-default.d.ts +0 -2
- package/dist/client/components/chat/system-prompt-default.d.ts.map +0 -1
- package/dist/client/components/chat/trace.d.ts +0 -84
- package/dist/client/components/chat/trace.d.ts.map +0 -1
- package/dist/client/components/chat/types.d.ts +0 -75
- package/dist/client/components/chat/types.d.ts.map +0 -1
- package/dist/client/components/chat/useChatMessages.d.ts +0 -76
- package/dist/client/components/chat/useChatMessages.d.ts.map +0 -1
- package/dist/client/components/chat/useChatMessagesClientSide.d.ts +0 -43
- package/dist/client/components/chat/useChatMessagesClientSide.d.ts.map +0 -1
- package/dist/client/components/chat/useChatScrollToBottom.d.ts +0 -14
- package/dist/client/components/chat/useChatScrollToBottom.d.ts.map +0 -1
- package/dist/client/components/chat/useConfig.d.ts +0 -24
- package/dist/client/components/chat/useConfig.d.ts.map +0 -1
- package/dist/client/components/chat/useHostedChatMode.d.ts +0 -14
- package/dist/client/components/chat/useHostedChatMode.d.ts.map +0 -1
- package/dist/client/components/chat/useManagedCloudModel.d.ts +0 -14
- package/dist/client/components/chat/useManagedCloudModel.d.ts.map +0 -1
- package/dist/client/components/chat/utils.d.ts +0 -11
- package/dist/client/components/chat/utils.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts +0 -12
- package/dist/client/components/elicitation/shared/ElicitationAskUserPanel.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts +0 -9
- package/dist/client/components/elicitation/shared/elicitationToAskUserQuestions.d.ts.map +0 -1
- package/dist/client/components/elicitation/shared/schemaHelpers.d.ts +0 -8
- package/dist/client/components/elicitation/shared/schemaHelpers.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptExecutionPanel.d.ts +0 -13
- package/dist/client/components/prompts/PromptExecutionPanel.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptInputForm.d.ts +0 -9
- package/dist/client/components/prompts/PromptInputForm.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptMessageCard.d.ts +0 -29
- package/dist/client/components/prompts/PromptMessageCard.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptResultDisplay.d.ts +0 -34
- package/dist/client/components/prompts/PromptResultDisplay.d.ts.map +0 -1
- package/dist/client/components/prompts/PromptsList.d.ts +0 -10
- package/dist/client/components/prompts/PromptsList.d.ts.map +0 -1
- package/dist/client/components/prompts/SavedPromptsList.d.ts +0 -19
- package/dist/client/components/prompts/SavedPromptsList.d.ts.map +0 -1
- package/dist/client/components/resources/PropsConfigDialog.d.ts +0 -16
- package/dist/client/components/resources/PropsConfigDialog.d.ts.map +0 -1
- package/dist/client/components/resources/ResourceResultDisplay.d.ts +0 -30
- package/dist/client/components/resources/ResourceResultDisplay.d.ts.map +0 -1
- package/dist/client/components/resources/ResourcesList.d.ts +0 -10
- package/dist/client/components/resources/ResourcesList.d.ts.map +0 -1
- package/dist/client/components/shared/CollapsibleJSON.d.ts +0 -6
- package/dist/client/components/shared/CollapsibleJSON.d.ts.map +0 -1
- package/dist/client/components/shared/InspectorScrollArea.d.ts +0 -9
- package/dist/client/components/shared/InspectorScrollArea.d.ts.map +0 -1
- package/dist/client/components/shared/JSONDisplay.d.ts +0 -12
- package/dist/client/components/shared/JSONDisplay.d.ts.map +0 -1
- package/dist/client/components/shared/ListItem.d.ts +0 -24
- package/dist/client/components/shared/ListItem.d.ts.map +0 -1
- package/dist/client/components/shared/ListTabHeader.d.ts +0 -47
- package/dist/client/components/shared/ListTabHeader.d.ts.map +0 -1
- package/dist/client/components/shared/MarkdownRenderer.d.ts +0 -15
- package/dist/client/components/shared/MarkdownRenderer.d.ts.map +0 -1
- package/dist/client/components/shared/SchemaFormField.d.ts +0 -12
- package/dist/client/components/shared/SchemaFormField.d.ts.map +0 -1
- package/dist/client/components/shared/SearchTabHeader.d.ts +0 -28
- package/dist/client/components/shared/SearchTabHeader.d.ts.map +0 -1
- package/dist/client/components/shared/StatusIcon.d.ts +0 -12
- package/dist/client/components/shared/StatusIcon.d.ts.map +0 -1
- package/dist/client/components/shared/index.d.ts +0 -7
- package/dist/client/components/shared/index.d.ts.map +0 -1
- package/dist/client/components/tools/SaveRequestDialog.d.ts +0 -11
- package/dist/client/components/tools/SaveRequestDialog.d.ts.map +0 -1
- package/dist/client/components/tools/SavedRequestsList.d.ts +0 -19
- package/dist/client/components/tools/SavedRequestsList.d.ts.map +0 -1
- package/dist/client/components/tools/ToolExecutionPanel.d.ts +0 -20
- package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +0 -1
- package/dist/client/components/tools/ToolInputForm.d.ts +0 -14
- package/dist/client/components/tools/ToolInputForm.d.ts.map +0 -1
- package/dist/client/components/tools/ToolResultDisplay.d.ts +0 -24
- package/dist/client/components/tools/ToolResultDisplay.d.ts.map +0 -1
- package/dist/client/components/tools/ToolsList.d.ts +0 -10
- package/dist/client/components/tools/ToolsList.d.ts.map +0 -1
- package/dist/client/components/tools/schema-utils.d.ts +0 -13
- package/dist/client/components/tools/schema-utils.d.ts.map +0 -1
- package/dist/client/components/tools/useToolExecution.d.ts +0 -26
- package/dist/client/components/tools/useToolExecution.d.ts.map +0 -1
- package/dist/client/components/tools/useToolsTabNavigation.d.ts +0 -35
- package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +0 -1
- package/dist/client/components/ui/MeshGradientCanvas.d.ts +0 -13
- package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +0 -1
- package/dist/client/components/ui/WidgetWrapper.d.ts +0 -12
- package/dist/client/components/ui/WidgetWrapper.d.ts.map +0 -1
- package/dist/client/components/ui/alert-dialog.d.ts +0 -15
- package/dist/client/components/ui/alert-dialog.d.ts.map +0 -1
- package/dist/client/components/ui/ask-user-questions.d.ts +0 -80
- package/dist/client/components/ui/ask-user-questions.d.ts.map +0 -1
- package/dist/client/components/ui/badge.d.ts +0 -34
- package/dist/client/components/ui/badge.d.ts.map +0 -1
- package/dist/client/components/ui/blur-fade.d.ts +0 -25
- package/dist/client/components/ui/blur-fade.d.ts.map +0 -1
- package/dist/client/components/ui/button.d.ts +0 -34
- package/dist/client/components/ui/button.d.ts.map +0 -1
- package/dist/client/components/ui/chat-message.d.ts +0 -23
- package/dist/client/components/ui/chat-message.d.ts.map +0 -1
- package/dist/client/components/ui/checkbox.d.ts +0 -4
- package/dist/client/components/ui/checkbox.d.ts.map +0 -1
- package/dist/client/components/ui/client-icons.d.ts +0 -20
- package/dist/client/components/ui/client-icons.d.ts.map +0 -1
- package/dist/client/components/ui/command.d.ts +0 -17
- package/dist/client/components/ui/command.d.ts.map +0 -1
- package/dist/client/components/ui/dialog.d.ts +0 -37
- package/dist/client/components/ui/dialog.d.ts.map +0 -1
- package/dist/client/components/ui/dropdown-menu.d.ts +0 -25
- package/dist/client/components/ui/dropdown-menu.d.ts.map +0 -1
- package/dist/client/components/ui/dropdown.d.ts +0 -30
- package/dist/client/components/ui/dropdown.d.ts.map +0 -1
- package/dist/client/components/ui/file-thumbnail.d.ts +0 -9
- package/dist/client/components/ui/file-thumbnail.d.ts.map +0 -1
- package/dist/client/components/ui/input.d.ts +0 -4
- package/dist/client/components/ui/input.d.ts.map +0 -1
- package/dist/client/components/ui/kbd.d.ts +0 -3
- package/dist/client/components/ui/kbd.d.ts.map +0 -1
- package/dist/client/components/ui/label.d.ts +0 -4
- package/dist/client/components/ui/label.d.ts.map +0 -1
- package/dist/client/components/ui/menu-item.d.ts +0 -52
- package/dist/client/components/ui/menu-item.d.ts.map +0 -1
- package/dist/client/components/ui/mesh-tab-background.d.ts +0 -12
- package/dist/client/components/ui/mesh-tab-background.d.ts.map +0 -1
- package/dist/client/components/ui/not-found.d.ts +0 -9
- package/dist/client/components/ui/not-found.d.ts.map +0 -1
- package/dist/client/components/ui/popover.d.ts +0 -6
- package/dist/client/components/ui/popover.d.ts.map +0 -1
- package/dist/client/components/ui/resizable.d.ts +0 -10
- package/dist/client/components/ui/resizable.d.ts.map +0 -1
- package/dist/client/components/ui/scroll-area.d.ts +0 -4
- package/dist/client/components/ui/scroll-area.d.ts.map +0 -1
- package/dist/client/components/ui/select.d.ts +0 -52
- package/dist/client/components/ui/select.d.ts.map +0 -1
- package/dist/client/components/ui/sheet.d.ts +0 -14
- package/dist/client/components/ui/sheet.d.ts.map +0 -1
- package/dist/client/components/ui/skeleton.d.ts +0 -4
- package/dist/client/components/ui/skeleton.d.ts.map +0 -1
- package/dist/client/components/ui/spinner.d.ts +0 -3
- package/dist/client/components/ui/spinner.d.ts.map +0 -1
- package/dist/client/components/ui/switch.d.ts +0 -22
- package/dist/client/components/ui/switch.d.ts.map +0 -1
- package/dist/client/components/ui/table.d.ts +0 -9
- package/dist/client/components/ui/table.d.ts.map +0 -1
- package/dist/client/components/ui/tabs-subtle.d.ts +0 -25
- package/dist/client/components/ui/tabs-subtle.d.ts.map +0 -1
- package/dist/client/components/ui/text-shimmer.d.ts +0 -11
- package/dist/client/components/ui/text-shimmer.d.ts.map +0 -1
- package/dist/client/components/ui/textarea.d.ts +0 -4
- package/dist/client/components/ui/textarea.d.ts.map +0 -1
- package/dist/client/components/ui/tooltip.d.ts +0 -43
- package/dist/client/components/ui/tooltip.d.ts.map +0 -1
- package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts +0 -19
- package/dist/client/components/ui-playground/shared/SafeAreaInsetsEditor.d.ts.map +0 -1
- package/dist/client/console-log-bus.d.ts +0 -24
- package/dist/client/console-log-bus.d.ts.map +0 -1
- package/dist/client/constants/debug-options.d.ts +0 -16
- package/dist/client/constants/debug-options.d.ts.map +0 -1
- package/dist/client/context/InspectorContext.d.ts +0 -134
- package/dist/client/context/InspectorContext.d.ts.map +0 -1
- package/dist/client/context/ThemeContext.d.ts +0 -17
- package/dist/client/context/ThemeContext.d.ts.map +0 -1
- package/dist/client/context/WidgetDebugContext.d.ts +0 -121
- package/dist/client/context/WidgetDebugContext.d.ts.map +0 -1
- package/dist/client/hooks/use-merge-split.d.ts +0 -36
- package/dist/client/hooks/use-merge-split.d.ts.map +0 -1
- package/dist/client/hooks/use-proximity-hover-index.d.ts +0 -27
- package/dist/client/hooks/use-proximity-hover-index.d.ts.map +0 -1
- package/dist/client/hooks/use-proximity-hover.d.ts +0 -26
- package/dist/client/hooks/use-proximity-hover.d.ts.map +0 -1
- package/dist/client/hooks/use-touch-primary.d.ts +0 -2
- package/dist/client/hooks/use-touch-primary.d.ts.map +0 -1
- package/dist/client/hooks/useDeviceViewport.d.ts +0 -18
- package/dist/client/hooks/useDeviceViewport.d.ts.map +0 -1
- package/dist/client/hooks/useHostedSession.d.ts +0 -9
- package/dist/client/hooks/useHostedSession.d.ts.map +0 -1
- package/dist/client/hooks/useIframeConsole.d.ts +0 -24
- package/dist/client/hooks/useIframeConsole.d.ts.map +0 -1
- package/dist/client/hooks/useKeyboardShortcuts.d.ts +0 -28
- package/dist/client/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/dist/client/hooks/useMCPPrompts.d.ts +0 -94
- package/dist/client/hooks/useMCPPrompts.d.ts.map +0 -1
- package/dist/client/hooks/useMcpAppsHostContext.d.ts +0 -27
- package/dist/client/hooks/useMcpAppsHostContext.d.ts.map +0 -1
- package/dist/client/hooks/usePropsLLM.d.ts +0 -20
- package/dist/client/hooks/usePropsLLM.d.ts.map +0 -1
- package/dist/client/hooks/useResourceProps.d.ts +0 -14
- package/dist/client/hooks/useResourceProps.d.ts.map +0 -1
- package/dist/client/hooks/useSavedRequests.d.ts +0 -6
- package/dist/client/hooks/useSavedRequests.d.ts.map +0 -1
- package/dist/client/hooks/useViewHostProps.d.ts +0 -19
- package/dist/client/hooks/useViewHostProps.d.ts.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/lib/elevated.d.ts +0 -28
- package/dist/client/lib/elevated.d.ts.map +0 -1
- package/dist/client/lib/font-weight.d.ts +0 -10
- package/dist/client/lib/font-weight.d.ts.map +0 -1
- package/dist/client/lib/icon-context.d.ts +0 -15
- package/dist/client/lib/icon-context.d.ts.map +0 -1
- package/dist/client/lib/shape-context.d.ts +0 -21
- package/dist/client/lib/shape-context.d.ts.map +0 -1
- package/dist/client/lib/springs.d.ts +0 -32
- package/dist/client/lib/springs.d.ts.map +0 -1
- package/dist/client/lib/surface-classes.d.ts +0 -2
- package/dist/client/lib/surface-classes.d.ts.map +0 -1
- package/dist/client/lib/surface-context.d.ts +0 -7
- package/dist/client/lib/surface-context.d.ts.map +0 -1
- package/dist/client/lib/utils.d.ts +0 -3
- package/dist/client/lib/utils.d.ts.map +0 -1
- package/dist/client/mcp-apps/csp.d.ts +0 -26
- package/dist/client/mcp-apps/csp.d.ts.map +0 -1
- package/dist/client/mcp-apps/debug/csp-suggestions.d.ts +0 -17
- package/dist/client/mcp-apps/debug/csp-suggestions.d.ts.map +0 -1
- package/dist/client/mcp-apps/logging-transport.d.ts +0 -13
- package/dist/client/mcp-apps/logging-transport.d.ts.map +0 -1
- package/dist/client/rpc-traffic-coalesce.d.ts +0 -7
- package/dist/client/rpc-traffic-coalesce.d.ts.map +0 -1
- package/dist/client/rpc-traffic-store.d.ts +0 -37
- package/dist/client/rpc-traffic-store.d.ts.map +0 -1
- package/dist/client/telemetry/capture.d.ts +0 -7
- package/dist/client/telemetry/capture.d.ts.map +0 -1
- package/dist/client/telemetry/events.d.ts +0 -168
- package/dist/client/telemetry/events.d.ts.map +0 -1
- package/dist/client/telemetry/index.d.ts +0 -5
- package/dist/client/telemetry/index.d.ts.map +0 -1
- package/dist/client/telemetry/init.d.ts +0 -2
- package/dist/client/telemetry/init.d.ts.map +0 -1
- package/dist/client/telemetry/utils.d.ts +0 -7
- package/dist/client/telemetry/utils.d.ts.map +0 -1
- package/dist/client/types/message-content-block.d.ts +0 -19
- package/dist/client/types/message-content-block.d.ts.map +0 -1
- package/dist/client/types/pending-requests.d.ts +0 -17
- package/dist/client/types/pending-requests.d.ts.map +0 -1
- package/dist/client/utils/basePath.d.ts +0 -34
- package/dist/client/utils/basePath.d.ts.map +0 -1
- package/dist/client/utils/browser.d.ts +0 -5
- package/dist/client/utils/browser.d.ts.map +0 -1
- package/dist/client/utils/format.d.ts +0 -4
- package/dist/client/utils/format.d.ts.map +0 -1
- package/dist/client/utils/highlightJson.d.ts +0 -11
- package/dist/client/utils/highlightJson.d.ts.map +0 -1
- package/dist/client/utils/jsonUtils.d.ts +0 -24
- package/dist/client/utils/jsonUtils.d.ts.map +0 -1
- package/dist/client/utils/mcpClientUtils.d.ts +0 -131
- package/dist/client/utils/mcpClientUtils.d.ts.map +0 -1
- package/dist/client/utils/servers.d.ts +0 -14
- package/dist/client/utils/servers.d.ts.map +0 -1
- package/dist/server/asset-urls.d.ts +0 -18
- package/dist/server/asset-urls.d.ts.map +0 -1
- package/dist/server/asset-urls.js +0 -17
- package/dist/server/cdn-shell.d.ts +0 -18
- package/dist/server/cdn-shell.d.ts.map +0 -1
- package/dist/server/cdn-shell.js +0 -12
- package/dist/server/chunk-DSTNUYWX.js +0 -148
- package/dist/server/chunk-H6ZCIKBS.js +0 -63
- package/dist/server/chunk-IKTZUWSX.js +0 -0
- package/dist/server/chunk-J4FNYLBF.js +0 -54
- package/dist/server/chunk-K2F2AJOI.js +0 -619
- package/dist/server/chunk-KD7K27XK.js +0 -77
- package/dist/server/chunk-M5TZA42I.js +0 -54
- package/dist/server/chunk-OWR2BIBW.js +0 -40
- package/dist/server/chunk-PKBMQBKP.js +0 -7
- package/dist/server/chunk-SQ4XNMLT.js +0 -72
- package/dist/server/chunk-UJLXHNQP.js +0 -43
- package/dist/server/chunk-WFT4JHYI.js +0 -24
- package/dist/server/chunk-XCNS5CIW.js +0 -199
- package/dist/server/chunk-ZCGLU5T7.js +0 -156
- package/dist/server/cli.d.ts +0 -3
- package/dist/server/cli.d.ts.map +0 -1
- package/dist/server/cli.js +0 -141
- package/dist/server/create-dev-api-app.d.ts +0 -4
- package/dist/server/create-dev-api-app.d.ts.map +0 -1
- package/dist/server/create-dev-api-app.js +0 -11
- package/dist/server/dev-callback-redirect.d.ts +0 -3
- package/dist/server/dev-callback-redirect.d.ts.map +0 -1
- package/dist/server/dev-callback-redirect.js +0 -18
- package/dist/server/favicon-links.d.ts +0 -12
- package/dist/server/favicon-links.d.ts.map +0 -1
- package/dist/server/favicon-links.js +0 -11
- package/dist/server/favicon-static.d.ts +0 -4
- package/dist/server/favicon-static.d.ts.map +0 -1
- package/dist/server/favicon-static.js +0 -8
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/middleware.d.ts +0 -40
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/middleware.js +0 -17
- package/dist/server/proxy/index.d.ts +0 -3
- package/dist/server/proxy/index.d.ts.map +0 -1
- package/dist/server/proxy/index.js +0 -12
- package/dist/server/proxy/mcp-proxy.d.ts +0 -101
- package/dist/server/proxy/mcp-proxy.d.ts.map +0 -1
- package/dist/server/proxy/mcp-proxy.js +0 -10
- package/dist/server/proxy/oauth-proxy.d.ts +0 -26
- package/dist/server/proxy/oauth-proxy.d.ts.map +0 -1
- package/dist/server/proxy/oauth-proxy.js +0 -9
- package/dist/server/proxy-routes.d.ts +0 -16
- package/dist/server/proxy-routes.d.ts.map +0 -1
- package/dist/server/proxy-routes.js +0 -10
- package/dist/server/rpc-log-bus.d.ts +0 -17
- package/dist/server/rpc-log-bus.d.ts.map +0 -1
- package/dist/server/rpc-log-bus.js +0 -77
- package/dist/server/server.d.ts +0 -15
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/server.js +0 -66
- package/dist/server/static-assets.d.ts +0 -5
- package/dist/server/static-assets.d.ts.map +0 -1
- package/dist/server/static-assets.js +0 -9
- package/dist/server/utils.d.ts +0 -33
- package/dist/server/utils.d.ts.map +0 -1
- package/dist/server/utils.js +0 -17
- package/dist/server/version.d.ts +0 -7
- package/dist/server/version.d.ts.map +0 -1
- package/dist/server/version.js +0 -9
- package/dist/server/vite-dev-api-plugin.d.ts +0 -4
- package/dist/server/vite-dev-api-plugin.d.ts.map +0 -1
- package/dist/server/vite-dev-api-plugin.js +0 -30
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/AnimatePresence-C5p0yiY1.js +0 -9
- package/dist/web/assets/ChatTab-BCobuZDc.js +0 -18
- package/dist/web/assets/ConnectionSettingsTab-BjGkLwVu.js +0 -1
- package/dist/web/assets/ElicitationTab-D3ZUKHND.js +0 -1
- package/dist/web/assets/FormContext-DH2caWKO.js +0 -1
- package/dist/web/assets/ListTabHeader-R17w_JsB.js +0 -1
- package/dist/web/assets/ManufactOAuthCallback-CS3ydSZg.js +0 -1
- package/dist/web/assets/MarkdownRenderer-BeeBfQhv.js +0 -47
- package/dist/web/assets/NotificationsTab-Uj0_DrmK.js +0 -1
- package/dist/web/assets/OAuthCallback-C0ljgCiw.js +0 -1
- package/dist/web/assets/PromptsTab-Bns2u0G-.js +0 -15
- package/dist/web/assets/ResourcesTab-CO24312V.js +0 -2
- package/dist/web/assets/SamplingTab-7gtN7FwU.js +0 -1
- package/dist/web/assets/ServerMetadataTab-CQwqYSjL.js +0 -1
- package/dist/web/assets/ToolsTab-bDdRxI1b.js +0 -8
- package/dist/web/assets/ViewPreview-Ba1Ec5uA.js +0 -1
- package/dist/web/assets/WidgetWrapper-CYHfzrtb.js +0 -34
- package/dist/web/assets/brush--0LobUi4.js +0 -1
- package/dist/web/assets/checkbox-CzBkaNKa.js +0 -1
- package/dist/web/assets/code-tME-5H6D.js +0 -1
- package/dist/web/assets/createLucideIcon-B3b8EU0b.js +0 -1
- package/dist/web/assets/dist-C5JjLJN9.js +0 -21
- package/dist/web/assets/index-TQ5V7cM9.js +0 -492
- package/dist/web/assets/index-fBX3akc8.css +0 -1
- package/dist/web/assets/input-CLYhA7PK.js +0 -1
- package/dist/web/assets/inspector-settings-layout-yjKRJDai.js +0 -1
- package/dist/web/assets/jsx-runtime-Cjj9sGSy.js +0 -1
- package/dist/web/assets/label-Cdim77Jw.js +0 -1
- package/dist/web/assets/maximize-2-BTT9QQU9.js +0 -1
- package/dist/web/assets/maximize-_O55kFcr.js +0 -1
- package/dist/web/assets/react-CU_d2d5K.js +0 -1
- package/dist/web/assets/refresh-cw-C9wQl8_d.js +0 -1
- package/dist/web/assets/save-B-MsgxX9.js +0 -1
- package/dist/web/assets/schemaHelpers-DLNTQr_6.js +0 -1
- package/dist/web/assets/select-CJ57-Bor.js +0 -1
- package/dist/web/assets/shared-BF0rJNdE.js +0 -1
- package/dist/web/assets/sparkles-2OAsc1aP.js +0 -1
- package/dist/web/assets/tabs-subtle-6D79T1xd.js +0 -1
- package/dist/web/assets/textarea-DLAmNVf_.js +0 -1
- package/dist/web/assets/useConfig-BAgALiZg.js +0 -1
- package/dist/web/assets/useViewHostProps-BYitt_6K.js +0 -1
- package/dist/web/assets/zap-Du2Uc5pa.js +0 -1
- package/dist/web/favicon-96x96.png +0 -0
- package/dist/web/favicon-black.svg +0 -5
- package/dist/web/favicon-white.svg +0 -5
- package/dist/web/favicon.ico +0 -0
- package/dist/web/favicon.svg +0 -5
- package/dist/web/index.html +0 -89
- package/dist/web/providers/anthropic.png +0 -0
- package/dist/web/providers/google.png +0 -0
- package/dist/web/providers/openai.png +0 -0
- package/dist/web/site.webmanifest +0 -21
- package/dist/web/web-app-manifest-192x192.png +0 -0
- package/dist/web/web-app-manifest-512x512.png +0 -0
- /package/dist/{cdn → app}/apple-touch-icon.png +0 -0
- /package/dist/{cdn → app}/favicon-96x96.png +0 -0
- /package/dist/{cdn → app}/favicon-black.svg +0 -0
- /package/dist/{cdn → app}/favicon-white.svg +0 -0
- /package/dist/{cdn → app}/favicon.ico +0 -0
- /package/dist/{cdn → app}/favicon.svg +0 -0
- /package/dist/{cdn → app}/site.webmanifest +0 -0
- /package/dist/{cdn → app}/web-app-manifest-192x192.png +0 -0
- /package/dist/{cdn → app}/web-app-manifest-512x512.png +0 -0
|
@@ -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
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// src/server/utils.ts
|
|
2
|
-
function isValidUrl(urlString) {
|
|
3
|
-
try {
|
|
4
|
-
const url = new URL(urlString);
|
|
5
|
-
return url.protocol === "http:" || url.protocol === "https:";
|
|
6
|
-
} catch {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
async function findAvailablePort(startPort = 8080, maxAttempts = 100) {
|
|
11
|
-
const net = await import("net");
|
|
12
|
-
for (let port = startPort; port < startPort + maxAttempts; port++) {
|
|
13
|
-
try {
|
|
14
|
-
await new Promise((resolve, reject) => {
|
|
15
|
-
const server = net.createServer();
|
|
16
|
-
server.listen(port, () => {
|
|
17
|
-
server.close(() => resolve());
|
|
18
|
-
});
|
|
19
|
-
server.on("error", (err) => reject(err));
|
|
20
|
-
});
|
|
21
|
-
return port;
|
|
22
|
-
} catch {
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
throw new Error(
|
|
27
|
-
`No available port found after trying ${maxAttempts} ports starting from ${startPort}`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
async function isPortAvailable(port) {
|
|
31
|
-
const net = await import("net");
|
|
32
|
-
return new Promise((resolve) => {
|
|
33
|
-
const server = net.createServer();
|
|
34
|
-
server.listen(port, () => {
|
|
35
|
-
server.close(() => resolve(true));
|
|
36
|
-
});
|
|
37
|
-
server.on("error", () => resolve(false));
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function parsePortFromArgs() {
|
|
41
|
-
const portArgIndex = process.argv.indexOf("--port");
|
|
42
|
-
if (portArgIndex !== -1 && portArgIndex + 1 < process.argv.length) {
|
|
43
|
-
const portValue = Number.parseInt(process.argv[portArgIndex + 1], 10);
|
|
44
|
-
if (!Number.isNaN(portValue) && portValue >= 1 && portValue <= 65535) {
|
|
45
|
-
return portValue;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
function hasNoOpenFlag() {
|
|
51
|
-
return process.argv.includes("--no-open");
|
|
52
|
-
}
|
|
53
|
-
function formatErrorResponse(error, context) {
|
|
54
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
55
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
56
|
-
const errorStack = error instanceof Error ? error.stack : void 0;
|
|
57
|
-
console.error(`[${timestamp}] Error in ${context}:`, {
|
|
58
|
-
message: errorMessage,
|
|
59
|
-
stack: errorStack
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
error: errorMessage,
|
|
63
|
-
context,
|
|
64
|
-
timestamp,
|
|
65
|
-
// Only include stack in development mode
|
|
66
|
-
...process.env.NODE_ENV === "development" && errorStack ? { stack: errorStack } : {}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export {
|
|
71
|
-
isValidUrl,
|
|
72
|
-
findAvailablePort,
|
|
73
|
-
isPortAvailable,
|
|
74
|
-
parsePortFromArgs,
|
|
75
|
-
hasNoOpenFlag,
|
|
76
|
-
formatErrorResponse
|
|
77
|
-
};
|