@wonderwhy-er/desktop-commander 0.2.38 → 0.2.39
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 +53 -2
- package/dist/handlers/filesystem-handlers.d.ts +5 -0
- package/dist/handlers/filesystem-handlers.js +14 -2
- package/dist/remote-device/desktop-commander-integration.js +1 -1
- package/dist/search-manager.js +31 -38
- package/dist/server.js +8 -3
- package/dist/terminal-manager.js +4 -2
- package/dist/tools/edit.js +34 -1
- package/dist/tools/filesystem.js +91 -3
- package/dist/tools/improved-process-tools.js +2 -1
- package/dist/ui/config-editor/app.js +840 -0
- package/dist/ui/config-editor/array-modal.d.ts +19 -0
- package/dist/ui/config-editor/array-modal.js +185 -0
- package/dist/ui/config-editor/config-editor-runtime.js +65 -14096
- package/dist/ui/config-editor/main.js +2 -0
- package/dist/ui/config-editor/src/App.d.ts +43 -0
- package/dist/ui/config-editor/src/components/layout.d.ts +4 -0
- package/dist/ui/config-editor/src/components/layout.js +83 -0
- package/dist/ui/config-editor/src/components/toolbar.d.ts +1 -0
- package/dist/ui/config-editor/src/components/toolbar.js +21 -0
- package/dist/ui/config-editor/src/config-values.d.ts +6 -0
- package/dist/ui/config-editor/src/config-values.js +61 -0
- package/dist/ui/config-editor/src/contracts.d.ts +14 -0
- package/dist/ui/config-editor/src/contracts.js +3 -0
- package/dist/ui/config-editor/src/directory-browser.d.ts +6 -0
- package/dist/ui/config-editor/src/directory-browser.js +71 -0
- package/dist/ui/config-editor/src/layout.d.ts +5 -0
- package/dist/ui/config-editor/src/layout.js +90 -0
- package/dist/ui/config-editor/src/parsing.d.ts +5 -0
- package/dist/ui/config-editor/src/parsing.js +50 -0
- package/dist/ui/config-editor/src/toolbar.d.ts +1 -0
- package/dist/ui/config-editor/src/toolbar.js +18 -0
- package/dist/ui/config-editor/src/types.d.ts +17 -0
- package/dist/ui/config-editor/src/types.js +3 -0
- package/dist/ui/config-editor/src/utils/config-values.d.ts +9 -0
- package/dist/ui/config-editor/src/utils/config-values.js +61 -0
- package/dist/ui/config-editor/src/utils/directory-browser.d.ts +31 -0
- package/dist/ui/config-editor/src/utils/directory-browser.js +201 -0
- package/dist/ui/config-editor/src/utils/parsing.d.ts +8 -0
- package/dist/ui/config-editor/src/utils/parsing.js +50 -0
- package/dist/ui/config-editor/styles.css +2 -1
- package/dist/ui/file-preview/{src/app.d.ts → app.d.ts} +1 -1
- package/dist/ui/file-preview/app.js +2020 -0
- package/dist/ui/file-preview/components/code-viewer.d.ts +6 -0
- package/dist/ui/file-preview/components/code-viewer.js +73 -0
- package/dist/ui/file-preview/components/highlighting.d.ts +2 -0
- package/dist/ui/file-preview/components/highlighting.js +54 -0
- package/dist/ui/file-preview/components/html-renderer.d.ts +5 -0
- package/dist/ui/file-preview/components/html-renderer.js +47 -0
- package/dist/ui/file-preview/components/markdown-renderer.d.ts +1 -0
- package/dist/ui/file-preview/components/markdown-renderer.js +67 -0
- package/dist/ui/file-preview/components/toolbar.d.ts +6 -0
- package/dist/ui/file-preview/components/toolbar.js +75 -0
- package/dist/ui/file-preview/image-preview.d.ts +3 -0
- package/dist/ui/file-preview/image-preview.js +21 -0
- package/dist/ui/file-preview/main.js +5 -0
- package/dist/ui/file-preview/markdown/editor.d.ts +36 -0
- package/dist/ui/file-preview/markdown/editor.js +643 -0
- package/dist/ui/file-preview/markdown/linking.d.ts +9 -0
- package/dist/ui/file-preview/markdown/linking.js +210 -0
- package/dist/ui/file-preview/markdown/outline.d.ts +7 -0
- package/dist/ui/file-preview/markdown/outline.js +40 -0
- package/dist/ui/file-preview/markdown/preview.d.ts +8 -0
- package/dist/ui/file-preview/markdown/preview.js +33 -0
- package/dist/ui/file-preview/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/markdown/toc.d.ts +11 -0
- package/dist/ui/file-preview/markdown/toc.js +75 -0
- package/dist/ui/file-preview/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/markdown/utils.js +15 -0
- package/dist/ui/file-preview/markdown/workspace-controller.d.ts +25 -0
- package/dist/ui/file-preview/markdown/workspace-controller.js +40 -0
- package/dist/ui/file-preview/preview-runtime.js +384 -26533
- package/dist/ui/file-preview/shared/preview-file-types.d.ts +1 -1
- package/dist/ui/file-preview/src/App.d.ts +4 -0
- package/dist/ui/file-preview/src/App.js +564 -0
- package/dist/ui/file-preview/src/components/CodeViewer.d.ts +6 -0
- package/dist/ui/file-preview/src/components/CodeViewer.js +60 -0
- package/dist/ui/file-preview/src/components/HtmlRenderer.d.ts +8 -0
- package/dist/ui/file-preview/src/components/HtmlRenderer.js +45 -0
- package/dist/ui/file-preview/src/components/MarkdownRenderer.d.ts +1 -0
- package/dist/ui/file-preview/src/components/MarkdownRenderer.js +15 -0
- package/dist/ui/file-preview/src/components/editor-toolbar.d.ts +15 -0
- package/dist/ui/file-preview/src/components/editor-toolbar.js +384 -0
- package/dist/ui/file-preview/src/components/markdown-editor.d.ts +29 -0
- package/dist/ui/file-preview/src/components/markdown-editor.js +535 -0
- package/dist/ui/file-preview/src/components/markdown-renderer.js +47 -9
- package/dist/ui/file-preview/src/directory-controller.d.ts +8 -0
- package/dist/ui/file-preview/src/directory-controller.js +233 -0
- package/dist/ui/file-preview/src/document-layout.d.ts +20 -0
- package/dist/ui/file-preview/src/document-layout.js +109 -0
- package/dist/ui/file-preview/src/document-outline.d.ts +17 -0
- package/dist/ui/file-preview/src/document-outline.js +97 -0
- package/dist/ui/file-preview/src/document-workspace.d.ts +19 -0
- package/dist/ui/file-preview/src/document-workspace.js +33 -0
- package/dist/ui/file-preview/src/file-type-handlers.d.ts +10 -0
- package/dist/ui/file-preview/src/file-type-handlers.js +98 -0
- package/dist/ui/file-preview/src/host/external-actions.d.ts +19 -0
- package/dist/ui/file-preview/src/host/external-actions.js +94 -0
- package/dist/ui/file-preview/src/host/selection-context.d.ts +9 -0
- package/dist/ui/file-preview/src/host/selection-context.js +106 -0
- package/dist/ui/file-preview/src/markdown/block-merge.d.ts +25 -0
- package/dist/ui/file-preview/src/markdown/block-merge.js +86 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.d.ts +40 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js +163 -0
- package/dist/ui/file-preview/src/markdown/controller.d.ts +38 -0
- package/dist/ui/file-preview/src/markdown/controller.js +921 -0
- package/dist/ui/file-preview/src/markdown/editor.d.ts +35 -0
- package/dist/ui/file-preview/src/markdown/editor.js +691 -0
- package/dist/ui/file-preview/src/markdown/link-modal.d.ts +13 -0
- package/dist/ui/file-preview/src/markdown/link-modal.js +213 -0
- package/dist/ui/file-preview/src/markdown/linking.d.ts +16 -0
- package/dist/ui/file-preview/src/markdown/linking.js +228 -0
- package/dist/ui/file-preview/src/markdown/outline.d.ts +2 -0
- package/dist/ui/file-preview/src/markdown/outline.js +16 -0
- package/dist/ui/file-preview/src/markdown/parser.d.ts +30 -0
- package/dist/ui/file-preview/src/markdown/parser.js +38 -0
- package/dist/ui/file-preview/src/markdown/preview.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/preview.js +20 -0
- package/dist/ui/file-preview/src/markdown/raw-editor.d.ts +8 -0
- package/dist/ui/file-preview/src/markdown/raw-editor.js +61 -0
- package/dist/ui/file-preview/src/markdown/selection-toolbar.d.ts +14 -0
- package/dist/ui/file-preview/src/markdown/selection-toolbar.js +128 -0
- package/dist/ui/file-preview/src/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown/toc.d.ts +11 -0
- package/dist/ui/file-preview/src/markdown/toc.js +75 -0
- package/dist/ui/file-preview/src/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/utils.js +15 -0
- package/dist/ui/file-preview/src/markdown-workspace/editor.d.ts +36 -0
- package/dist/ui/file-preview/src/markdown-workspace/editor.js +643 -0
- package/dist/ui/file-preview/src/markdown-workspace/linking.d.ts +9 -0
- package/dist/ui/file-preview/src/markdown-workspace/linking.js +210 -0
- package/dist/ui/file-preview/src/markdown-workspace/outline.d.ts +7 -0
- package/dist/ui/file-preview/src/markdown-workspace/outline.js +40 -0
- package/dist/ui/file-preview/src/markdown-workspace/preview.d.ts +8 -0
- package/dist/ui/file-preview/src/markdown-workspace/preview.js +33 -0
- package/dist/ui/file-preview/src/markdown-workspace/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown-workspace/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown-workspace/toc.d.ts +11 -0
- package/dist/ui/file-preview/src/markdown-workspace/toc.js +75 -0
- package/dist/ui/file-preview/src/markdown-workspace/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown-workspace/utils.js +15 -0
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.d.ts +25 -0
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.js +40 -0
- package/dist/ui/file-preview/src/model.d.ts +34 -0
- package/dist/ui/file-preview/src/panel-actions.d.ts +17 -0
- package/dist/ui/file-preview/src/panel-actions.js +182 -0
- package/dist/ui/file-preview/src/path-utils.d.ts +6 -0
- package/dist/ui/file-preview/src/path-utils.js +64 -0
- package/dist/ui/file-preview/src/payload-utils.d.ts +11 -0
- package/dist/ui/file-preview/src/payload-utils.js +94 -0
- package/dist/ui/file-preview/styles.css +1066 -233
- package/dist/ui/file-preview/types.d.ts +1 -0
- package/dist/ui/server-integration.d.ts +13 -0
- package/dist/ui/server-integration.js +31 -0
- package/dist/ui/shared/ToolHeader.d.ts +9 -0
- package/dist/ui/shared/ToolHeader.js +29 -0
- package/dist/ui/shared/app-bootstrap.d.ts +9 -0
- package/dist/ui/shared/app-bootstrap.js +15 -0
- package/dist/ui/shared/guards.d.ts +1 -0
- package/dist/ui/shared/guards.js +3 -0
- package/dist/ui/shared/host-lifecycle.d.ts +1 -0
- package/dist/ui/shared/host-lifecycle.js +8 -2
- package/dist/ui/shared/widget-state.d.ts +6 -1
- package/dist/ui/shared/widget-state.js +102 -4
- package/dist/utils/files/base.d.ts +2 -0
- package/dist/utils/open-browser.js +1 -1
- package/dist/utils/ui-call-context.d.ts +8 -0
- package/dist/utils/ui-call-context.js +72 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
- package/dist/data/spec-kit-prompts.json +0 -123
- package/dist/handlers/macos-control-handlers.d.ts +0 -16
- package/dist/handlers/macos-control-handlers.js +0 -81
- package/dist/handlers/node-handlers.d.ts +0 -6
- package/dist/handlers/node-handlers.js +0 -73
- package/dist/handlers/test-crash-handler.d.ts +0 -11
- package/dist/handlers/test-crash-handler.js +0 -26
- package/dist/http-index.d.ts +0 -45
- package/dist/http-index.js +0 -51
- package/dist/http-server-auto-tunnel.js +0 -667
- package/dist/http-server-named-tunnel.d.ts +0 -2
- package/dist/http-server-named-tunnel.js +0 -167
- package/dist/http-server-tunnel.d.ts +0 -2
- package/dist/http-server-tunnel.js +0 -111
- package/dist/http-server.d.ts +0 -2
- package/dist/http-server.js +0 -270
- package/dist/index-oauth.d.ts +0 -2
- package/dist/index-oauth.js +0 -201
- package/dist/lib.d.ts +0 -10
- package/dist/lib.js +0 -10
- package/dist/oauth/auth-middleware.d.ts +0 -20
- package/dist/oauth/auth-middleware.js +0 -62
- package/dist/oauth/index.d.ts +0 -3
- package/dist/oauth/index.js +0 -3
- package/dist/oauth/oauth-manager.d.ts +0 -80
- package/dist/oauth/oauth-manager.js +0 -179
- package/dist/oauth/oauth-routes.d.ts +0 -3
- package/dist/oauth/oauth-routes.js +0 -377
- package/dist/oauth/provider.d.ts +0 -22
- package/dist/oauth/provider.js +0 -124
- package/dist/oauth/server.d.ts +0 -18
- package/dist/oauth/server.js +0 -160
- package/dist/oauth/types.d.ts +0 -54
- package/dist/oauth/types.js +0 -2
- package/dist/remote-device/templates/auth-success.d.ts +0 -1
- package/dist/remote-device/templates/auth-success.js +0 -30
- package/dist/setup.log +0 -275
- package/dist/test-setup.js +0 -14
- package/dist/tools/docx/builders/html-builder.d.ts +0 -17
- package/dist/tools/docx/builders/html-builder.js +0 -92
- package/dist/tools/docx/builders/image.d.ts +0 -14
- package/dist/tools/docx/builders/image.js +0 -84
- package/dist/tools/docx/builders/index.d.ts +0 -11
- package/dist/tools/docx/builders/index.js +0 -11
- package/dist/tools/docx/builders/markdown-builder.d.ts +0 -2
- package/dist/tools/docx/builders/markdown-builder.js +0 -260
- package/dist/tools/docx/builders/paragraph.d.ts +0 -12
- package/dist/tools/docx/builders/paragraph.js +0 -29
- package/dist/tools/docx/builders/table.d.ts +0 -10
- package/dist/tools/docx/builders/table.js +0 -138
- package/dist/tools/docx/builders/utils.d.ts +0 -5
- package/dist/tools/docx/builders/utils.js +0 -18
- package/dist/tools/docx/constants.d.ts +0 -32
- package/dist/tools/docx/constants.js +0 -61
- package/dist/tools/docx/converters/markdown-to-html.d.ts +0 -17
- package/dist/tools/docx/converters/markdown-to-html.js +0 -111
- package/dist/tools/docx/create.d.ts +0 -21
- package/dist/tools/docx/create.js +0 -386
- package/dist/tools/docx/dom.d.ts +0 -139
- package/dist/tools/docx/dom.js +0 -448
- package/dist/tools/docx/errors.d.ts +0 -28
- package/dist/tools/docx/errors.js +0 -48
- package/dist/tools/docx/extractors/images.d.ts +0 -14
- package/dist/tools/docx/extractors/images.js +0 -40
- package/dist/tools/docx/extractors/metadata.d.ts +0 -14
- package/dist/tools/docx/extractors/metadata.js +0 -64
- package/dist/tools/docx/extractors/sections.d.ts +0 -14
- package/dist/tools/docx/extractors/sections.js +0 -61
- package/dist/tools/docx/html.d.ts +0 -17
- package/dist/tools/docx/html.js +0 -111
- package/dist/tools/docx/index.d.ts +0 -10
- package/dist/tools/docx/index.js +0 -10
- package/dist/tools/docx/markdown.d.ts +0 -84
- package/dist/tools/docx/markdown.js +0 -507
- package/dist/tools/docx/modify.d.ts +0 -28
- package/dist/tools/docx/modify.js +0 -271
- package/dist/tools/docx/operations/handlers/index.d.ts +0 -39
- package/dist/tools/docx/operations/handlers/index.js +0 -152
- package/dist/tools/docx/operations/html-manipulator.d.ts +0 -24
- package/dist/tools/docx/operations/html-manipulator.js +0 -352
- package/dist/tools/docx/operations/index.d.ts +0 -14
- package/dist/tools/docx/operations/index.js +0 -61
- package/dist/tools/docx/operations/operation-handlers.d.ts +0 -3
- package/dist/tools/docx/operations/operation-handlers.js +0 -67
- package/dist/tools/docx/operations/preprocessor.d.ts +0 -14
- package/dist/tools/docx/operations/preprocessor.js +0 -44
- package/dist/tools/docx/operations/xml-replacer.d.ts +0 -9
- package/dist/tools/docx/operations/xml-replacer.js +0 -35
- package/dist/tools/docx/operations.d.ts +0 -13
- package/dist/tools/docx/operations.js +0 -13
- package/dist/tools/docx/ops/delete-paragraph-at-body-index.d.ts +0 -11
- package/dist/tools/docx/ops/delete-paragraph-at-body-index.js +0 -23
- package/dist/tools/docx/ops/header-replace-text-exact.d.ts +0 -13
- package/dist/tools/docx/ops/header-replace-text-exact.js +0 -55
- package/dist/tools/docx/ops/index.d.ts +0 -17
- package/dist/tools/docx/ops/index.js +0 -70
- package/dist/tools/docx/ops/insert-image-after-text.d.ts +0 -24
- package/dist/tools/docx/ops/insert-image-after-text.js +0 -128
- package/dist/tools/docx/ops/insert-paragraph-after-text.d.ts +0 -12
- package/dist/tools/docx/ops/insert-paragraph-after-text.js +0 -74
- package/dist/tools/docx/ops/insert-table-after-text.d.ts +0 -19
- package/dist/tools/docx/ops/insert-table-after-text.js +0 -57
- package/dist/tools/docx/ops/replace-hyperlink-url.d.ts +0 -12
- package/dist/tools/docx/ops/replace-hyperlink-url.js +0 -37
- package/dist/tools/docx/ops/replace-paragraph-at-body-index.d.ts +0 -9
- package/dist/tools/docx/ops/replace-paragraph-at-body-index.js +0 -25
- package/dist/tools/docx/ops/replace-paragraph-text-exact.d.ts +0 -21
- package/dist/tools/docx/ops/replace-paragraph-text-exact.js +0 -36
- package/dist/tools/docx/ops/replace-table-cell-text.d.ts +0 -25
- package/dist/tools/docx/ops/replace-table-cell-text.js +0 -85
- package/dist/tools/docx/ops/set-color-for-paragraph-exact.d.ts +0 -9
- package/dist/tools/docx/ops/set-color-for-paragraph-exact.js +0 -24
- package/dist/tools/docx/ops/set-color-for-style.d.ts +0 -13
- package/dist/tools/docx/ops/set-color-for-style.js +0 -31
- package/dist/tools/docx/ops/set-paragraph-style-at-body-index.d.ts +0 -8
- package/dist/tools/docx/ops/set-paragraph-style-at-body-index.js +0 -57
- package/dist/tools/docx/ops/table-set-cell-text.d.ts +0 -9
- package/dist/tools/docx/ops/table-set-cell-text.js +0 -40
- package/dist/tools/docx/parsers/image-extractor.d.ts +0 -18
- package/dist/tools/docx/parsers/image-extractor.js +0 -61
- package/dist/tools/docx/parsers/index.d.ts +0 -9
- package/dist/tools/docx/parsers/index.js +0 -9
- package/dist/tools/docx/parsers/paragraph-parser.d.ts +0 -2
- package/dist/tools/docx/parsers/paragraph-parser.js +0 -88
- package/dist/tools/docx/parsers/table-parser.d.ts +0 -9
- package/dist/tools/docx/parsers/table-parser.js +0 -72
- package/dist/tools/docx/parsers/xml-parser.d.ts +0 -25
- package/dist/tools/docx/parsers/xml-parser.js +0 -71
- package/dist/tools/docx/parsers/zip-reader.d.ts +0 -23
- package/dist/tools/docx/parsers/zip-reader.js +0 -52
- package/dist/tools/docx/read.d.ts +0 -27
- package/dist/tools/docx/read.js +0 -308
- package/dist/tools/docx/relationships.d.ts +0 -22
- package/dist/tools/docx/relationships.js +0 -76
- package/dist/tools/docx/structure.d.ts +0 -25
- package/dist/tools/docx/structure.js +0 -102
- package/dist/tools/docx/styled-html-parser.d.ts +0 -23
- package/dist/tools/docx/styled-html-parser.js +0 -1262
- package/dist/tools/docx/types.d.ts +0 -213
- package/dist/tools/docx/types.js +0 -5
- package/dist/tools/docx/utils/escaping.d.ts +0 -13
- package/dist/tools/docx/utils/escaping.js +0 -26
- package/dist/tools/docx/utils/images.d.ts +0 -9
- package/dist/tools/docx/utils/images.js +0 -26
- package/dist/tools/docx/utils/index.d.ts +0 -12
- package/dist/tools/docx/utils/index.js +0 -17
- package/dist/tools/docx/utils/markdown.d.ts +0 -13
- package/dist/tools/docx/utils/markdown.js +0 -32
- package/dist/tools/docx/utils/paths.d.ts +0 -15
- package/dist/tools/docx/utils/paths.js +0 -27
- package/dist/tools/docx/utils/versioning.d.ts +0 -25
- package/dist/tools/docx/utils/versioning.js +0 -55
- package/dist/tools/docx/utils.d.ts +0 -101
- package/dist/tools/docx/utils.js +0 -299
- package/dist/tools/docx/validate.d.ts +0 -33
- package/dist/tools/docx/validate.js +0 -49
- package/dist/tools/docx/validators.d.ts +0 -13
- package/dist/tools/docx/validators.js +0 -40
- package/dist/tools/docx/write.d.ts +0 -17
- package/dist/tools/docx/write.js +0 -88
- package/dist/tools/docx/xml-view-test.js +0 -63
- package/dist/tools/docx/xml-view.d.ts +0 -56
- package/dist/tools/docx/xml-view.js +0 -169
- package/dist/tools/docx/zip.d.ts +0 -21
- package/dist/tools/docx/zip.js +0 -35
- package/dist/tools/macos-control/ax-adapter.d.ts +0 -55
- package/dist/tools/macos-control/ax-adapter.js +0 -438
- package/dist/tools/macos-control/cdp-adapter.d.ts +0 -23
- package/dist/tools/macos-control/cdp-adapter.js +0 -402
- package/dist/tools/macos-control/orchestrator.d.ts +0 -77
- package/dist/tools/macos-control/orchestrator.js +0 -136
- package/dist/tools/macos-control/role-aliases.d.ts +0 -5
- package/dist/tools/macos-control/role-aliases.js +0 -34
- package/dist/tools/macos-control/types.d.ts +0 -129
- package/dist/tools/pdf-processor.d.ts +0 -1
- package/dist/tools/pdf-processor.js +0 -3
- package/dist/tools/search.d.ts +0 -32
- package/dist/tools/search.js +0 -202
- package/dist/ui/file-preview/src/app.js +0 -714
- package/dist/utils/crash-logger.d.ts +0 -18
- package/dist/utils/crash-logger.js +0 -44
- package/dist/utils/dedent.d.ts +0 -8
- package/dist/utils/dedent.js +0 -38
- /package/dist/ui/config-editor/{src/app.d.ts → app.d.ts} +0 -0
- /package/dist/{http-server-auto-tunnel.d.ts → ui/config-editor/main.d.ts} +0 -0
- /package/dist/ui/config-editor/src/{app.js → App.js} +0 -0
- /package/dist/{test-docx.d.ts → ui/file-preview/main.d.ts} +0 -0
- /package/dist/ui/file-preview/src/components/{toolbar.d.ts → Toolbar.d.ts} +0 -0
- /package/dist/ui/file-preview/src/components/{toolbar.js → Toolbar.js} +0 -0
- /package/dist/{tools/docx/xml-view-test.d.ts → ui/file-preview/src/model.js} +0 -0
- /package/dist/{tools/macos-control → ui/file-preview}/types.js +0 -0
package/dist/index-oauth.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { FilteredStdioServerTransport } from './custom-stdio.js';
|
|
3
|
-
import { server } from './server.js';
|
|
4
|
-
import { configManager } from './config-manager.js';
|
|
5
|
-
import { runSetup } from './npm-scripts/setup.js';
|
|
6
|
-
import { runUninstall } from './npm-scripts/uninstall.js';
|
|
7
|
-
import { capture } from './utils/capture.js';
|
|
8
|
-
import { logToStderr, logger } from './utils/logger.js';
|
|
9
|
-
import { OAuthHttpServer } from './oauth/server.js';
|
|
10
|
-
async function runServer() {
|
|
11
|
-
try {
|
|
12
|
-
// Check if first argument is "setup"
|
|
13
|
-
if (process.argv[2] === 'setup') {
|
|
14
|
-
await runSetup();
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
// Check if first argument is "remove"
|
|
18
|
-
if (process.argv[2] === 'remove') {
|
|
19
|
-
await runUninstall();
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
// Check for HTTP mode with OAuth
|
|
23
|
-
const httpMode = process.argv.includes('--http') || process.argv.includes('--oauth');
|
|
24
|
-
const port = getPortFromArgs() || 8000;
|
|
25
|
-
if (httpMode) {
|
|
26
|
-
await runHttpServer(port);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
await runStdioServer();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
logger.error('Failed to start server:', error);
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async function runStdioServer() {
|
|
38
|
-
logger.info('Loading server.ts');
|
|
39
|
-
logger.info('Setting up request handlers...');
|
|
40
|
-
try {
|
|
41
|
-
logger.info('Loading configuration...');
|
|
42
|
-
await configManager.loadConfig();
|
|
43
|
-
logger.info('Configuration loaded successfully');
|
|
44
|
-
const transport = new FilteredStdioServerTransport();
|
|
45
|
-
logger.info('Enhanced FilteredStdioServerTransport initialized');
|
|
46
|
-
logger.info('Connecting server...');
|
|
47
|
-
await server.connect(transport);
|
|
48
|
-
logger.info('Server connected successfully');
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
await capture('error_start_stdio_server', { error });
|
|
52
|
-
logToStderr('error', `Failed to start stdio server: ${error}`);
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async function runHttpServer(port) {
|
|
57
|
-
logger.info(`Starting HTTP server with OAuth on port ${port}`);
|
|
58
|
-
try {
|
|
59
|
-
logger.info('Loading configuration...');
|
|
60
|
-
await configManager.loadConfig();
|
|
61
|
-
logger.info('Configuration loaded successfully');
|
|
62
|
-
// OAuth configuration
|
|
63
|
-
const baseUrl = `http://localhost:${port}`;
|
|
64
|
-
const oauthConfig = {
|
|
65
|
-
enabled: true,
|
|
66
|
-
clientId: 'desktop-commander-mcp',
|
|
67
|
-
clientSecret: 'dc-secret-' + Math.random().toString(36).substring(7),
|
|
68
|
-
redirectUri: `${baseUrl}/callback`,
|
|
69
|
-
authorizationUrl: `${baseUrl}/authorize`,
|
|
70
|
-
tokenUrl: `${baseUrl}/token`,
|
|
71
|
-
scope: 'mcp:access mcp:tools mcp:resources',
|
|
72
|
-
issuer: baseUrl
|
|
73
|
-
};
|
|
74
|
-
// Create MCP handler for HTTP requests
|
|
75
|
-
const mcpHandler = createMcpHttpHandler();
|
|
76
|
-
// Create OAuth HTTP server
|
|
77
|
-
const oauthServer = new OAuthHttpServer(oauthConfig, mcpHandler);
|
|
78
|
-
oauthServer.listen(port, () => {
|
|
79
|
-
logger.info(`HTTP server running on port ${port}`);
|
|
80
|
-
logger.info(`Authorization Server Metadata: ${baseUrl}/.well-known/oauth-authorization-server`);
|
|
81
|
-
logger.info(`MCP Endpoint: ${baseUrl}/mcp`);
|
|
82
|
-
logger.info(`SSE Endpoint: ${baseUrl}/sse`);
|
|
83
|
-
console.log(`\n🚀 DesktopCommanderMCP HTTP Server Started!`);
|
|
84
|
-
console.log(`📍 Server URL: ${baseUrl}`);
|
|
85
|
-
console.log(`🔐 OAuth Metadata: ${baseUrl}/.well-known/oauth-authorization-server`);
|
|
86
|
-
console.log(`🔧 MCP Endpoint: ${baseUrl}/mcp`);
|
|
87
|
-
console.log(`⚡ SSE Endpoint: ${baseUrl}/sse`);
|
|
88
|
-
console.log(`\n📝 For Claude Custom Connectors:`);
|
|
89
|
-
console.log(` URL: ${baseUrl}/sse`);
|
|
90
|
-
console.log(` Authentication: OAuth`);
|
|
91
|
-
});
|
|
92
|
-
// Graceful shutdown
|
|
93
|
-
process.on('SIGINT', () => {
|
|
94
|
-
logger.info('Received SIGINT, shutting down gracefully...');
|
|
95
|
-
oauthServer.close(() => {
|
|
96
|
-
process.exit(0);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
await capture('error_start_http_server', { error });
|
|
102
|
-
logToStderr('error', `Failed to start HTTP server: ${error}`);
|
|
103
|
-
throw error;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function createMcpHttpHandler() {
|
|
107
|
-
return (req, res) => {
|
|
108
|
-
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
109
|
-
// Handle SSE endpoint for MCP clients
|
|
110
|
-
if (url.pathname === '/sse') {
|
|
111
|
-
handleSSE(req, res);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// Handle Streamable HTTP endpoint
|
|
115
|
-
if (url.pathname === '/mcp') {
|
|
116
|
-
handleStreamableHttp(req, res);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
// Health check
|
|
120
|
-
if (url.pathname === '/health') {
|
|
121
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
122
|
-
res.end(JSON.stringify({ status: 'ok', service: 'DesktopCommanderMCP' }));
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
// 404 for other paths
|
|
126
|
-
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
127
|
-
res.end(JSON.stringify({ error: 'Not found' }));
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function handleSSE(req, res) {
|
|
131
|
-
// Set SSE headers
|
|
132
|
-
res.writeHead(200, {
|
|
133
|
-
'Content-Type': 'text/event-stream',
|
|
134
|
-
'Cache-Control': 'no-cache',
|
|
135
|
-
'Connection': 'keep-alive',
|
|
136
|
-
'Access-Control-Allow-Origin': '*',
|
|
137
|
-
'Access-Control-Allow-Headers': 'Cache-Control'
|
|
138
|
-
});
|
|
139
|
-
// SSE implementation would go here
|
|
140
|
-
// For now, just indicate that SSE is available
|
|
141
|
-
res.write('event: connected\n');
|
|
142
|
-
res.write('data: {"type":"connected","message":"DesktopCommanderMCP SSE endpoint"}\n\n');
|
|
143
|
-
// Keep connection alive
|
|
144
|
-
const heartbeat = setInterval(() => {
|
|
145
|
-
res.write('event: heartbeat\n');
|
|
146
|
-
res.write('data: {"type":"heartbeat","timestamp":' + Date.now() + '}\n\n');
|
|
147
|
-
}, 30000);
|
|
148
|
-
req.on('close', () => {
|
|
149
|
-
clearInterval(heartbeat);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
function handleStreamableHttp(req, res) {
|
|
153
|
-
// Handle Streamable HTTP for MCP
|
|
154
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
155
|
-
if (req.method === 'GET') {
|
|
156
|
-
// Return server info
|
|
157
|
-
res.end(JSON.stringify({
|
|
158
|
-
name: 'DesktopCommanderMCP',
|
|
159
|
-
version: '0.2.13',
|
|
160
|
-
transport: 'streamable-http',
|
|
161
|
-
authenticated: !!req.user
|
|
162
|
-
}));
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
// Handle MCP protocol messages
|
|
166
|
-
if (req.method === 'POST') {
|
|
167
|
-
let body = '';
|
|
168
|
-
req.on('data', chunk => body += chunk.toString());
|
|
169
|
-
req.on('end', () => {
|
|
170
|
-
try {
|
|
171
|
-
const message = JSON.parse(body);
|
|
172
|
-
// Process MCP message through the server
|
|
173
|
-
// This would need to be integrated with the existing MCP server
|
|
174
|
-
res.end(JSON.stringify({
|
|
175
|
-
jsonrpc: '2.0',
|
|
176
|
-
id: message.id,
|
|
177
|
-
result: { message: 'MCP message received' }
|
|
178
|
-
}));
|
|
179
|
-
}
|
|
180
|
-
catch (error) {
|
|
181
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
182
|
-
res.end(JSON.stringify({ error: 'Invalid JSON' }));
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
res.writeHead(405, { 'Content-Type': 'application/json' });
|
|
188
|
-
res.end(JSON.stringify({ error: 'Method not allowed' }));
|
|
189
|
-
}
|
|
190
|
-
function getPortFromArgs() {
|
|
191
|
-
const portIndex = process.argv.findIndex(arg => arg === '--port');
|
|
192
|
-
if (portIndex !== -1 && process.argv[portIndex + 1]) {
|
|
193
|
-
return parseInt(process.argv[portIndex + 1], 10);
|
|
194
|
-
}
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
// Run the server
|
|
198
|
-
runServer().catch(error => {
|
|
199
|
-
console.error('Fatal error:', error);
|
|
200
|
-
process.exit(1);
|
|
201
|
-
});
|
package/dist/lib.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Library entry point for the DC Electron app worker thread.
|
|
3
|
-
* Exports server, configManager, and MCP SDK classes so the worker
|
|
4
|
-
* can import everything from a single bundled file instead of
|
|
5
|
-
* hundreds of individual module files.
|
|
6
|
-
*/
|
|
7
|
-
export { server } from './server.js';
|
|
8
|
-
export { configManager } from './config-manager.js';
|
|
9
|
-
export { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
10
|
-
export { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
package/dist/lib.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Library entry point for the DC Electron app worker thread.
|
|
3
|
-
* Exports server, configManager, and MCP SDK classes so the worker
|
|
4
|
-
* can import everything from a single bundled file instead of
|
|
5
|
-
* hundreds of individual module files.
|
|
6
|
-
*/
|
|
7
|
-
export { server } from './server.js';
|
|
8
|
-
export { configManager } from './config-manager.js';
|
|
9
|
-
export { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
10
|
-
export { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Request, Response, NextFunction } from 'express';
|
|
2
|
-
import { OAuthManager } from './oauth-manager.js';
|
|
3
|
-
declare global {
|
|
4
|
-
namespace Express {
|
|
5
|
-
interface Request {
|
|
6
|
-
auth?: {
|
|
7
|
-
username: string;
|
|
8
|
-
client_id: string;
|
|
9
|
-
scope: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Create authentication middleware for MCP endpoints
|
|
16
|
-
*
|
|
17
|
-
* ChatGPT Workaround: Allow unauthenticated tools/list and initialize requests
|
|
18
|
-
* but require auth for actual tool calls
|
|
19
|
-
*/
|
|
20
|
-
export declare function createAuthMiddleware(oauthManager: OAuthManager | null, baseUrl: string, requireAuth: boolean): (req: Request, res: Response, next: NextFunction) => Promise<void | Response<any, Record<string, any>>>;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create authentication middleware for MCP endpoints
|
|
3
|
-
*
|
|
4
|
-
* ChatGPT Workaround: Allow unauthenticated tools/list and initialize requests
|
|
5
|
-
* but require auth for actual tool calls
|
|
6
|
-
*/
|
|
7
|
-
export function createAuthMiddleware(oauthManager, baseUrl, requireAuth) {
|
|
8
|
-
return async (req, res, next) => {
|
|
9
|
-
// Skip auth if disabled
|
|
10
|
-
if (!requireAuth || !oauthManager) {
|
|
11
|
-
return next();
|
|
12
|
-
}
|
|
13
|
-
// CHATGPT WORKAROUND: Allow unauthenticated discovery requests
|
|
14
|
-
// ChatGPT needs to see tools before authenticating
|
|
15
|
-
const method = req.body?.method;
|
|
16
|
-
if (method === 'initialize' || method === 'tools/list') {
|
|
17
|
-
console.log(`⚠️ Allowing unauthenticated ${method} for ChatGPT compatibility`);
|
|
18
|
-
return next();
|
|
19
|
-
}
|
|
20
|
-
const auth = req.headers.authorization;
|
|
21
|
-
// Check for Bearer token
|
|
22
|
-
if (!auth || !auth.startsWith('Bearer ')) {
|
|
23
|
-
console.log(`❌ Auth failed: No Bearer token provided for ${method}`);
|
|
24
|
-
return res.status(401)
|
|
25
|
-
.set('WWW-Authenticate', `Bearer resource_metadata="${baseUrl}/.well-known/oauth-protected-resource"`)
|
|
26
|
-
.json({
|
|
27
|
-
jsonrpc: '2.0',
|
|
28
|
-
error: {
|
|
29
|
-
code: -32001,
|
|
30
|
-
message: 'Authorization required',
|
|
31
|
-
data: 'Bearer token must be provided in Authorization header'
|
|
32
|
-
},
|
|
33
|
-
id: null
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
// Extract token
|
|
37
|
-
const token = auth.substring(7); // Remove "Bearer " prefix
|
|
38
|
-
// Validate token
|
|
39
|
-
const validation = oauthManager.validateToken(token);
|
|
40
|
-
if (!validation.valid) {
|
|
41
|
-
console.log(`❌ Auth failed: ${validation.error}`);
|
|
42
|
-
return res.status(401).json({
|
|
43
|
-
jsonrpc: '2.0',
|
|
44
|
-
error: {
|
|
45
|
-
code: -32001,
|
|
46
|
-
message: 'Invalid or expired token',
|
|
47
|
-
data: validation.error
|
|
48
|
-
},
|
|
49
|
-
id: null
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
// Attach user info to request
|
|
53
|
-
req.auth = {
|
|
54
|
-
username: validation.username,
|
|
55
|
-
client_id: validation.client_id,
|
|
56
|
-
scope: validation.scope
|
|
57
|
-
};
|
|
58
|
-
// Log authenticated request
|
|
59
|
-
console.log(`✅ Authenticated: ${req.auth.username} (${req.auth.client_id})`);
|
|
60
|
-
next();
|
|
61
|
-
};
|
|
62
|
-
}
|
package/dist/oauth/index.d.ts
DELETED
package/dist/oauth/index.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
interface JWTPayload {
|
|
2
|
-
sub: string;
|
|
3
|
-
client_id: string;
|
|
4
|
-
scope: string;
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
}
|
|
7
|
-
interface TokenValidation {
|
|
8
|
-
valid: boolean;
|
|
9
|
-
username?: string;
|
|
10
|
-
client_id?: string;
|
|
11
|
-
scope?: string;
|
|
12
|
-
error?: string;
|
|
13
|
-
}
|
|
14
|
-
interface ClientData {
|
|
15
|
-
client_id: string;
|
|
16
|
-
client_name: string;
|
|
17
|
-
redirect_uris: string[];
|
|
18
|
-
grant_types: string[];
|
|
19
|
-
response_types: string[];
|
|
20
|
-
}
|
|
21
|
-
interface AuthCodeData {
|
|
22
|
-
username: string;
|
|
23
|
-
client_id: string;
|
|
24
|
-
redirect_uri: string;
|
|
25
|
-
code_challenge?: string;
|
|
26
|
-
code_challenge_method?: string;
|
|
27
|
-
scope: string;
|
|
28
|
-
expiresAt: number;
|
|
29
|
-
}
|
|
30
|
-
export declare class OAuthManager {
|
|
31
|
-
private users;
|
|
32
|
-
private codes;
|
|
33
|
-
private clients;
|
|
34
|
-
private privateKey;
|
|
35
|
-
private publicKey;
|
|
36
|
-
private baseUrl;
|
|
37
|
-
constructor(baseUrl: string);
|
|
38
|
-
/**
|
|
39
|
-
* Pre-register well-known OAuth clients with fixed IDs
|
|
40
|
-
* This prevents issues when server restarts and clients still have cached IDs
|
|
41
|
-
*/
|
|
42
|
-
private preRegisterWellKnownClients;
|
|
43
|
-
/**
|
|
44
|
-
* Create a JWT token with the given payload
|
|
45
|
-
*/
|
|
46
|
-
createJWT(payload: JWTPayload): string;
|
|
47
|
-
/**
|
|
48
|
-
* Validate a JWT token
|
|
49
|
-
*/
|
|
50
|
-
validateToken(token: string): TokenValidation;
|
|
51
|
-
/**
|
|
52
|
-
* Register a new OAuth client
|
|
53
|
-
*/
|
|
54
|
-
registerClient(redirect_uris: string[], client_name?: string): ClientData;
|
|
55
|
-
/**
|
|
56
|
-
* Get a client by ID
|
|
57
|
-
*/
|
|
58
|
-
getClient(clientId: string): ClientData | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* List all registered client IDs (for debugging)
|
|
61
|
-
*/
|
|
62
|
-
listClients(): string;
|
|
63
|
-
/**
|
|
64
|
-
* Validate user credentials
|
|
65
|
-
*/
|
|
66
|
-
validateUser(username: string, password: string): boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Create an authorization code
|
|
69
|
-
*/
|
|
70
|
-
createAuthCode(data: Omit<AuthCodeData, 'expiresAt'>): string;
|
|
71
|
-
/**
|
|
72
|
-
* Validate and consume an authorization code
|
|
73
|
-
*/
|
|
74
|
-
validateAuthCode(code: string, client_id: string, redirect_uri: string, code_verifier?: string): {
|
|
75
|
-
valid: boolean;
|
|
76
|
-
data?: AuthCodeData;
|
|
77
|
-
error?: string;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
export {};
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
export class OAuthManager {
|
|
3
|
-
constructor(baseUrl) {
|
|
4
|
-
this.users = new Map([['admin', 'password123']]);
|
|
5
|
-
this.codes = new Map();
|
|
6
|
-
this.clients = new Map();
|
|
7
|
-
this.baseUrl = baseUrl;
|
|
8
|
-
// Generate RSA keys for JWT signing
|
|
9
|
-
const keys = crypto.generateKeyPairSync('rsa', {
|
|
10
|
-
modulusLength: 2048,
|
|
11
|
-
publicKeyEncoding: { type: 'spki', format: 'pem' },
|
|
12
|
-
privateKeyEncoding: { type: 'pkcs8', format: 'pem' }
|
|
13
|
-
});
|
|
14
|
-
this.privateKey = keys.privateKey;
|
|
15
|
-
this.publicKey = keys.publicKey;
|
|
16
|
-
console.log('🔐 OAuth Manager: JWT Keys generated');
|
|
17
|
-
// Pre-register well-known clients for common AI tools
|
|
18
|
-
// This survives server restarts as they use fixed IDs
|
|
19
|
-
this.preRegisterWellKnownClients();
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Pre-register well-known OAuth clients with fixed IDs
|
|
23
|
-
* This prevents issues when server restarts and clients still have cached IDs
|
|
24
|
-
*/
|
|
25
|
-
preRegisterWellKnownClients() {
|
|
26
|
-
// ChatGPT client
|
|
27
|
-
const chatgptClient = {
|
|
28
|
-
client_id: 'chatgpt-fixed-client-id',
|
|
29
|
-
client_name: 'ChatGPT',
|
|
30
|
-
redirect_uris: [
|
|
31
|
-
'https://chatgpt.com/connector_platform_oauth_redirect',
|
|
32
|
-
'https://chat.openai.com/connector_platform_oauth_redirect'
|
|
33
|
-
],
|
|
34
|
-
grant_types: ['authorization_code'],
|
|
35
|
-
response_types: ['code']
|
|
36
|
-
};
|
|
37
|
-
this.clients.set(chatgptClient.client_id, chatgptClient);
|
|
38
|
-
console.log(`🔐 Pre-registered: ${chatgptClient.client_name} (${chatgptClient.client_id})`);
|
|
39
|
-
// Claude client
|
|
40
|
-
const claudeClient = {
|
|
41
|
-
client_id: 'claude-fixed-client-id',
|
|
42
|
-
client_name: 'Claude',
|
|
43
|
-
redirect_uris: [
|
|
44
|
-
'https://claude.ai/oauth/callback',
|
|
45
|
-
'http://localhost:3000/callback'
|
|
46
|
-
],
|
|
47
|
-
grant_types: ['authorization_code'],
|
|
48
|
-
response_types: ['code']
|
|
49
|
-
};
|
|
50
|
-
this.clients.set(claudeClient.client_id, claudeClient);
|
|
51
|
-
console.log(`🔐 Pre-registered: ${claudeClient.client_name} (${claudeClient.client_id})`);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Create a JWT token with the given payload
|
|
55
|
-
*/
|
|
56
|
-
createJWT(payload) {
|
|
57
|
-
const header = { alg: 'RS256', typ: 'JWT', kid: 'key-1' };
|
|
58
|
-
const now = Math.floor(Date.now() / 1000);
|
|
59
|
-
const claims = {
|
|
60
|
-
...payload,
|
|
61
|
-
iat: now,
|
|
62
|
-
exp: now + 3600, // 1 hour expiration
|
|
63
|
-
iss: this.baseUrl,
|
|
64
|
-
aud: this.baseUrl
|
|
65
|
-
};
|
|
66
|
-
const encodedHeader = Buffer.from(JSON.stringify(header)).toString('base64url');
|
|
67
|
-
const encodedPayload = Buffer.from(JSON.stringify(claims)).toString('base64url');
|
|
68
|
-
const signature = crypto.sign('sha256', Buffer.from(`${encodedHeader}.${encodedPayload}`), this.privateKey);
|
|
69
|
-
return `${encodedHeader}.${encodedPayload}.${signature.toString('base64url')}`;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Validate a JWT token
|
|
73
|
-
*/
|
|
74
|
-
validateToken(token) {
|
|
75
|
-
try {
|
|
76
|
-
const parts = token.split('.');
|
|
77
|
-
if (parts.length !== 3) {
|
|
78
|
-
return { valid: false, error: 'Invalid token format' };
|
|
79
|
-
}
|
|
80
|
-
const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString());
|
|
81
|
-
// Check expiration
|
|
82
|
-
if (payload.exp < Math.floor(Date.now() / 1000)) {
|
|
83
|
-
return { valid: false, error: 'Token expired' };
|
|
84
|
-
}
|
|
85
|
-
// Verify signature
|
|
86
|
-
const signature = parts[2];
|
|
87
|
-
const data = `${parts[0]}.${parts[1]}`;
|
|
88
|
-
const valid = crypto.verify('sha256', Buffer.from(data), this.publicKey, Buffer.from(signature, 'base64url'));
|
|
89
|
-
if (!valid) {
|
|
90
|
-
return { valid: false, error: 'Invalid signature' };
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
valid: true,
|
|
94
|
-
username: payload.sub,
|
|
95
|
-
client_id: payload.client_id,
|
|
96
|
-
scope: payload.scope
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
catch (err) {
|
|
100
|
-
return { valid: false, error: err instanceof Error ? err.message : 'Unknown error' };
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Register a new OAuth client
|
|
105
|
-
*/
|
|
106
|
-
registerClient(redirect_uris, client_name) {
|
|
107
|
-
const clientId = crypto.randomUUID();
|
|
108
|
-
const client = {
|
|
109
|
-
client_id: clientId,
|
|
110
|
-
client_name: client_name || 'MCP Client',
|
|
111
|
-
redirect_uris,
|
|
112
|
-
grant_types: ['authorization_code'],
|
|
113
|
-
response_types: ['code']
|
|
114
|
-
};
|
|
115
|
-
this.clients.set(clientId, client);
|
|
116
|
-
console.log(`🔐 OAuth Manager: Registered client ${clientId} (${client.client_name})`);
|
|
117
|
-
return client;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get a client by ID
|
|
121
|
-
*/
|
|
122
|
-
getClient(clientId) {
|
|
123
|
-
return this.clients.get(clientId);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* List all registered client IDs (for debugging)
|
|
127
|
-
*/
|
|
128
|
-
listClients() {
|
|
129
|
-
const ids = Array.from(this.clients.keys());
|
|
130
|
-
return ids.length > 0 ? ids.join(', ') : 'none';
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Validate user credentials
|
|
134
|
-
*/
|
|
135
|
-
validateUser(username, password) {
|
|
136
|
-
return this.users.get(username) === password;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Create an authorization code
|
|
140
|
-
*/
|
|
141
|
-
createAuthCode(data) {
|
|
142
|
-
const code = crypto.randomBytes(32).toString('base64url');
|
|
143
|
-
this.codes.set(code, {
|
|
144
|
-
...data,
|
|
145
|
-
expiresAt: Date.now() + 600000 // 10 minutes
|
|
146
|
-
});
|
|
147
|
-
console.log(`🔐 OAuth Manager: Created auth code for user ${data.username}`);
|
|
148
|
-
return code;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Validate and consume an authorization code
|
|
152
|
-
*/
|
|
153
|
-
validateAuthCode(code, client_id, redirect_uri, code_verifier) {
|
|
154
|
-
const codeData = this.codes.get(code);
|
|
155
|
-
if (!codeData) {
|
|
156
|
-
return { valid: false, error: 'Invalid or expired code' };
|
|
157
|
-
}
|
|
158
|
-
if (codeData.expiresAt < Date.now()) {
|
|
159
|
-
this.codes.delete(code);
|
|
160
|
-
return { valid: false, error: 'Code expired' };
|
|
161
|
-
}
|
|
162
|
-
if (codeData.client_id !== client_id || codeData.redirect_uri !== redirect_uri) {
|
|
163
|
-
return { valid: false, error: 'Client ID or redirect URI mismatch' };
|
|
164
|
-
}
|
|
165
|
-
// PKCE verification
|
|
166
|
-
if (codeData.code_challenge) {
|
|
167
|
-
if (!code_verifier) {
|
|
168
|
-
return { valid: false, error: 'code_verifier required' };
|
|
169
|
-
}
|
|
170
|
-
const hash = crypto.createHash('sha256').update(code_verifier).digest('base64url');
|
|
171
|
-
if (hash !== codeData.code_challenge) {
|
|
172
|
-
return { valid: false, error: 'Invalid code_verifier' };
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
// Delete code after use (one-time use)
|
|
176
|
-
this.codes.delete(code);
|
|
177
|
-
return { valid: true, data: codeData };
|
|
178
|
-
}
|
|
179
|
-
}
|