@vividcodeai/embeddedcowork 0.0.8 → 0.0.10
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/bin/cli.js +56 -0
- package/package.json +10 -3
- package/dist/api-types.js +0 -1
- package/dist/auth/auth-store.js +0 -134
- package/dist/auth/http-auth.js +0 -37
- package/dist/auth/manager.js +0 -140
- package/dist/auth/password-hash.js +0 -32
- package/dist/auth/session-manager.js +0 -17
- package/dist/auth/token-manager.js +0 -27
- package/dist/background-processes/manager.js +0 -576
- package/dist/bin.js +0 -24
- package/dist/clients/connection-manager.js +0 -93
- package/dist/config/location.js +0 -57
- package/dist/config/schema.js +0 -72
- package/dist/events/bus.js +0 -47
- package/dist/filesystem/__tests__/search-cache.test.js +0 -40
- package/dist/filesystem/browser.js +0 -292
- package/dist/filesystem/search-cache.js +0 -43
- package/dist/filesystem/search.js +0 -135
- package/dist/index.js +0 -496
- package/dist/launcher.js +0 -149
- package/dist/loader.js +0 -21
- package/dist/logger.js +0 -109
- package/dist/opencode-config/README.md +0 -32
- package/dist/opencode-config/opencode.jsonc +0 -35
- package/dist/opencode-config/package.json +0 -9
- package/dist/opencode-config/plugin/embeddedcowork.ts +0 -62
- package/dist/opencode-config/plugin/lib/background-process.ts +0 -265
- package/dist/opencode-config/plugin/lib/client.ts +0 -133
- package/dist/opencode-config/plugin/lib/request.ts +0 -214
- package/dist/opencode-config.js +0 -15
- package/dist/opencode-downloader.js +0 -295
- package/dist/opencode-paths.js +0 -167
- package/dist/plugins/channel.js +0 -40
- package/dist/plugins/handlers.js +0 -17
- package/dist/plugins/voice-mode.js +0 -78
- package/dist/releases/dev-release-monitor.js +0 -75
- package/dist/releases/release-monitor.js +0 -107
- package/dist/runtime-paths.js +0 -67
- package/dist/server/__tests__/network-addresses.test.js +0 -68
- package/dist/server/__tests__/remote-proxy.test.js +0 -204
- package/dist/server/http-server.js +0 -998
- package/dist/server/network-addresses.js +0 -114
- package/dist/server/remote-proxy.js +0 -466
- package/dist/server/routes/auth-pages/login.html +0 -135
- package/dist/server/routes/auth-pages/token.html +0 -93
- package/dist/server/routes/auth.js +0 -149
- package/dist/server/routes/background-processes.js +0 -78
- package/dist/server/routes/events.js +0 -66
- package/dist/server/routes/filesystem.js +0 -43
- package/dist/server/routes/meta.js +0 -44
- package/dist/server/routes/opencode-status.js +0 -10
- package/dist/server/routes/plugin.js +0 -70
- package/dist/server/routes/remote-proxy.js +0 -42
- package/dist/server/routes/remote-servers.js +0 -142
- package/dist/server/routes/settings.js +0 -69
- package/dist/server/routes/sidecars.js +0 -46
- package/dist/server/routes/speech.js +0 -63
- package/dist/server/routes/storage.js +0 -52
- package/dist/server/routes/workspaces.js +0 -221
- package/dist/server/routes/worktrees.js +0 -156
- package/dist/server/tls.js +0 -224
- package/dist/settings/binaries.js +0 -37
- package/dist/settings/merge-patch.js +0 -33
- package/dist/settings/migrate.js +0 -238
- package/dist/settings/public-config.js +0 -33
- package/dist/settings/service.js +0 -101
- package/dist/settings/yaml-doc-store.js +0 -96
- package/dist/sidecars/manager.js +0 -193
- package/dist/speech/providers/openai-compatible.js +0 -189
- package/dist/speech/service.js +0 -58
- package/dist/storage/instance-store.js +0 -56
- package/dist/ui/__tests__/remote-ui.test.js +0 -67
- package/dist/ui/remote-ui.js +0 -462
- package/dist/workspaces/__tests__/spawn.test.js +0 -139
- package/dist/workspaces/git-mutations.js +0 -98
- package/dist/workspaces/git-status.js +0 -323
- package/dist/workspaces/git-worktrees.js +0 -216
- package/dist/workspaces/instance-events.js +0 -180
- package/dist/workspaces/manager.js +0 -432
- package/dist/workspaces/opencode-auth.js +0 -16
- package/dist/workspaces/runtime.js +0 -366
- package/dist/workspaces/spawn.js +0 -219
- package/dist/workspaces/worktree-directory.js +0 -74
- package/dist/workspaces/worktree-map.js +0 -116
- package/public/apple-touch-icon-180x180.png +0 -0
- package/public/assets/ChangesTab-C4_zdV74.js +0 -2
- package/public/assets/DiffToolbar-BsUPigM5.js +0 -1
- package/public/assets/EmbeddedCowork-Icon-DSw5nKk7.png +0 -0
- package/public/assets/FilesTab-Drvo30nM.js +0 -2
- package/public/assets/GitChangesTab-BhV6qTfP.js +0 -2
- package/public/assets/SplitFilePanel-BBrs329I.js +0 -1
- package/public/assets/StatusTab-DfYWlTSX.js +0 -1
- package/public/assets/abap-BdImnpbu.js +0 -1
- package/public/assets/actionscript-3-CfeIJUat.js +0 -1
- package/public/assets/ada-bCR0ucgS.js +0 -1
- package/public/assets/andromeeda-C-Jbm3Hp.js +0 -1
- package/public/assets/angular-html-CU67Zn6k.js +0 -1
- package/public/assets/angular-ts-BwZT4LLn.js +0 -1
- package/public/assets/apache-Pmp26Uib.js +0 -1
- package/public/assets/apex-DhZLUxFE.js +0 -1
- package/public/assets/apl-dKokRX4l.js +0 -1
- package/public/assets/applescript-Co6uUVPk.js +0 -1
- package/public/assets/ara-BRHolxvo.js +0 -1
- package/public/assets/asciidoc-Dv7Oe6Be.js +0 -1
- package/public/assets/asm-D_Q5rh1f.js +0 -1
- package/public/assets/astro-CbQHKStN.js +0 -1
- package/public/assets/aurora-x-D-2ljcwZ.js +0 -1
- package/public/assets/awk-DMzUqQB5.js +0 -1
- package/public/assets/ayu-dark-Cv9koXgw.js +0 -1
- package/public/assets/ballerina-BFfxhgS-.js +0 -1
- package/public/assets/bat-BkioyH1T.js +0 -1
- package/public/assets/beancount-k_qm7-4y.js +0 -1
- package/public/assets/berry-D08WgyRC.js +0 -1
- package/public/assets/bibtex-CHM0blh-.js +0 -1
- package/public/assets/bicep-Bmn6On1c.js +0 -1
- package/public/assets/blade-DVc8C-J4.js +0 -1
- package/public/assets/bsl-BO_Y6i37.js +0 -1
- package/public/assets/bundle-full-CAZqmV2E.js +0 -13
- package/public/assets/c-BIGW1oBm.js +0 -1
- package/public/assets/cadence-Bv_4Rxtq.js +0 -1
- package/public/assets/cairo-KRGpt6FW.js +0 -1
- package/public/assets/catppuccin-frappe-DFWUc33u.js +0 -1
- package/public/assets/catppuccin-latte-C9dUb6Cb.js +0 -1
- package/public/assets/catppuccin-macchiato-DQyhUUbL.js +0 -1
- package/public/assets/catppuccin-mocha-D87Tk5Gz.js +0 -1
- package/public/assets/clarity-D53aC0YG.js +0 -1
- package/public/assets/clojure-P80f7IUj.js +0 -1
- package/public/assets/cmake-D1j8_8rp.js +0 -1
- package/public/assets/cobol-nwyudZeR.js +0 -1
- package/public/assets/codeowners-Bp6g37R7.js +0 -1
- package/public/assets/codeql-DsOJ9woJ.js +0 -1
- package/public/assets/coffee-Ch7k5sss.js +0 -1
- package/public/assets/common-lisp-Cg-RD9OK.js +0 -1
- package/public/assets/coq-DkFqJrB1.js +0 -1
- package/public/assets/core-DhEqZVGG.js +0 -1
- package/public/assets/cpp-CofmeUqb.js +0 -1
- package/public/assets/crystal-tKQVLTB8.js +0 -1
- package/public/assets/csharp-CX12Zw3r.js +0 -1
- package/public/assets/css-DPfMkruS.js +0 -1
- package/public/assets/csv-fuZLfV_i.js +0 -1
- package/public/assets/cue-D82EKSYY.js +0 -1
- package/public/assets/cypher-COkxafJQ.js +0 -1
- package/public/assets/d-85-TOEBH.js +0 -1
- package/public/assets/dark-plus-eOWES_5F.js +0 -1
- package/public/assets/dart-CF10PKvl.js +0 -1
- package/public/assets/dax-CEL-wOlO.js +0 -1
- package/public/assets/desktop-BmXAJ9_W.js +0 -1
- package/public/assets/diff-D97Zzqfu.js +0 -1
- package/public/assets/diff-viewer--UIZ5GEn.js +0 -1
- package/public/assets/docker-BcOcwvcX.js +0 -1
- package/public/assets/dotenv-Da5cRb03.js +0 -1
- package/public/assets/dracula-BzJJZx-M.js +0 -1
- package/public/assets/dracula-soft-BXkSAIEj.js +0 -1
- package/public/assets/dream-maker-BtqSS_iP.js +0 -1
- package/public/assets/edge-BkV0erSs.js +0 -1
- package/public/assets/elixir-CDX3lj18.js +0 -1
- package/public/assets/elm-DbKCFpqz.js +0 -1
- package/public/assets/emacs-lisp-C9XAeP06.js +0 -1
- package/public/assets/erb-BOJIQeun.js +0 -1
- package/public/assets/erlang-DsQrWhSR.js +0 -1
- package/public/assets/event-DjZVAIBO.js +0 -1
- package/public/assets/everforest-dark-BgDCqdQA.js +0 -1
- package/public/assets/everforest-light-C8M2exoo.js +0 -1
- package/public/assets/fast-diff-vendor-DgdwVvTQ.js +0 -1
- package/public/assets/fennel-BYunw83y.js +0 -1
- package/public/assets/fish-BvzEVeQv.js +0 -1
- package/public/assets/fluent-C4IJs8-o.js +0 -1
- package/public/assets/fortran-fixed-form-BZjJHVRy.js +0 -1
- package/public/assets/fortran-free-form-D22FLkUw.js +0 -1
- package/public/assets/fsharp-CXgrBDvD.js +0 -1
- package/public/assets/gdresource-B7Tvp0Sc.js +0 -1
- package/public/assets/gdscript-DTMYz4Jt.js +0 -1
- package/public/assets/gdshader-DkwncUOv.js +0 -1
- package/public/assets/genie-D0YGMca9.js +0 -1
- package/public/assets/gherkin-DyxjwDmM.js +0 -1
- package/public/assets/git-commit-F4YmCXRG.js +0 -1
- package/public/assets/git-diff-vendor-CSgooKT_.js +0 -52
- package/public/assets/git-diff-vendor-HAZkIolJ.css +0 -19
- package/public/assets/git-rebase-r7XF79zn.js +0 -1
- package/public/assets/github-dark-DHJKELXO.js +0 -1
- package/public/assets/github-dark-default-Cuk6v7N8.js +0 -1
- package/public/assets/github-dark-dimmed-DH5Ifo-i.js +0 -1
- package/public/assets/github-dark-high-contrast-E3gJ1_iC.js +0 -1
- package/public/assets/github-light-DAi9KRSo.js +0 -1
- package/public/assets/github-light-default-D7oLnXFd.js +0 -1
- package/public/assets/github-light-high-contrast-BfjtVDDH.js +0 -1
- package/public/assets/gleam-BspZqrRM.js +0 -1
- package/public/assets/glimmer-js-Rg0-pVw9.js +0 -1
- package/public/assets/glimmer-ts-U6CK756n.js +0 -1
- package/public/assets/glsl-DplSGwfg.js +0 -1
- package/public/assets/gnuplot-DdkO51Og.js +0 -1
- package/public/assets/go-Dn2_MT6a.js +0 -1
- package/public/assets/graphql-ChdNCCLP.js +0 -1
- package/public/assets/groovy-gcz8RCvz.js +0 -1
- package/public/assets/gruvbox-dark-hard-CFHQjOhq.js +0 -1
- package/public/assets/gruvbox-dark-medium-GsRaNv29.js +0 -1
- package/public/assets/gruvbox-dark-soft-CVdnzihN.js +0 -1
- package/public/assets/gruvbox-light-hard-CH1njM8p.js +0 -1
- package/public/assets/gruvbox-light-medium-DRw_LuNl.js +0 -1
- package/public/assets/gruvbox-light-soft-hJgmCMqR.js +0 -1
- package/public/assets/hack-CaT9iCJl.js +0 -1
- package/public/assets/haml-B8DHNrY2.js +0 -1
- package/public/assets/handlebars-BL8al0AC.js +0 -1
- package/public/assets/haskell-Df6bDoY_.js +0 -1
- package/public/assets/haxe-CzTSHFRz.js +0 -1
- package/public/assets/hcl-BWvSN4gD.js +0 -1
- package/public/assets/highlight-vendor-8FKMu9os.js +0 -10
- package/public/assets/hjson-D5-asLiD.js +0 -1
- package/public/assets/hlsl-D3lLCCz7.js +0 -1
- package/public/assets/houston-DnULxvSX.js +0 -1
- package/public/assets/html-GMplVEZG.js +0 -1
- package/public/assets/html-derivative-BFtXZ54Q.js +0 -1
- package/public/assets/http-jrhK8wxY.js +0 -1
- package/public/assets/hurl-irOxFIW8.js +0 -1
- package/public/assets/hxml-Bvhsp5Yf.js +0 -1
- package/public/assets/hy-DFXneXwc.js +0 -1
- package/public/assets/imba-DGztddWO.js +0 -1
- package/public/assets/index--0EL0_Tu.js +0 -2
- package/public/assets/index-BKMyzTSR.js +0 -1
- package/public/assets/index-BLouhjer.js +0 -1
- package/public/assets/index-CLSJ4cO9.js +0 -1
- package/public/assets/index-CgjnEdBS.js +0 -1
- package/public/assets/index-ChCPoe9m.js +0 -1
- package/public/assets/index-Co-dJ-Xs.js +0 -1
- package/public/assets/index-Ctcq8Rhl.css +0 -1
- package/public/assets/index-Da0V-sLI.js +0 -1
- package/public/assets/index-hOT6sqTO.js +0 -1
- package/public/assets/ini-BEwlwnbL.js +0 -1
- package/public/assets/java-CylS5w8V.js +0 -1
- package/public/assets/javascript-wDzz0qaB.js +0 -1
- package/public/assets/jinja-4LBKfQ-Z.js +0 -1
- package/public/assets/jison-wvAkD_A8.js +0 -1
- package/public/assets/json-Cp-IABpG.js +0 -1
- package/public/assets/json5-C9tS-k6U.js +0 -1
- package/public/assets/jsonc-Des-eS-w.js +0 -1
- package/public/assets/jsonl-DcaNXYhu.js +0 -1
- package/public/assets/jsonnet-DFQXde-d.js +0 -1
- package/public/assets/jssm-C2t-YnRu.js +0 -1
- package/public/assets/jsx-g9-lgVsj.js +0 -1
- package/public/assets/julia-C8NyazO9.js +0 -1
- package/public/assets/kanagawa-dragon-CkXjmgJE.js +0 -1
- package/public/assets/kanagawa-lotus-CfQXZHmo.js +0 -1
- package/public/assets/kanagawa-wave-DWedfzmr.js +0 -1
- package/public/assets/kdl-DV7GczEv.js +0 -1
- package/public/assets/kotlin-BdnUsdx6.js +0 -1
- package/public/assets/kusto-BvAqAH-y.js +0 -1
- package/public/assets/laserwave-DUszq2jm.js +0 -1
- package/public/assets/latex-BUKiar2Z.js +0 -1
- package/public/assets/lean-DP1Csr6i.js +0 -1
- package/public/assets/less-B1dDrJ26.js +0 -1
- package/public/assets/light-plus-B7mTdjB0.js +0 -1
- package/public/assets/liquid-DYVedYrR.js +0 -1
- package/public/assets/llvm-BtvRca6l.js +0 -1
- package/public/assets/loading-CugGjKDZ.css +0 -1
- package/public/assets/loading-CvW03p4Z.js +0 -2
- package/public/assets/log-2UxHyX5q.js +0 -1
- package/public/assets/logo-BtOb2qkB.js +0 -1
- package/public/assets/lua-BbnMAYS6.js +0 -1
- package/public/assets/luau-CXu1NL6O.js +0 -1
- package/public/assets/main-ByuKWHRz.js +0 -53
- package/public/assets/make-CHLpvVh8.js +0 -1
- package/public/assets/markdown-BBFC6uy4.js +0 -58
- package/public/assets/markdown-Cvjx9yec.js +0 -1
- package/public/assets/marko-CPi9NSCl.js +0 -1
- package/public/assets/material-theme-D5KoaKCx.js +0 -1
- package/public/assets/material-theme-darker-BfHTSMKl.js +0 -1
- package/public/assets/material-theme-lighter-B0m2ddpp.js +0 -1
- package/public/assets/material-theme-ocean-CyktbL80.js +0 -1
- package/public/assets/material-theme-palenight-Csfq5Kiy.js +0 -1
- package/public/assets/matlab-D7o27uSR.js +0 -1
- package/public/assets/mdc-DUICxH0z.js +0 -1
- package/public/assets/mdx-Cmh6b_Ma.js +0 -1
- package/public/assets/mermaid-DKYwYmdq.js +0 -1
- package/public/assets/min-dark-CafNBF8u.js +0 -1
- package/public/assets/min-light-CTRr51gU.js +0 -1
- package/public/assets/mipsasm-CKIfxQSi.js +0 -1
- package/public/assets/mojo-1DNp92w6.js +0 -1
- package/public/assets/monaco-viewer-DnczYBfh.js +0 -26
- package/public/assets/monokai-D4h5O-jR.js +0 -1
- package/public/assets/move-Bu9oaDYs.js +0 -1
- package/public/assets/narrat-DRg8JJMk.js +0 -1
- package/public/assets/nextflow-CUEJCptM.js +0 -1
- package/public/assets/nginx-DknmC5AR.js +0 -1
- package/public/assets/night-owl-C39BiMTA.js +0 -1
- package/public/assets/nim-CVrawwO9.js +0 -1
- package/public/assets/nix-BbRYJGeE.js +0 -1
- package/public/assets/nord-Ddv68eIx.js +0 -1
- package/public/assets/nushell-C-sUppwS.js +0 -1
- package/public/assets/objective-c-DXmwc3jG.js +0 -1
- package/public/assets/objective-cpp-CLxacb5B.js +0 -1
- package/public/assets/ocaml-C0hk2d4L.js +0 -1
- package/public/assets/one-dark-pro-DVMEJ2y_.js +0 -1
- package/public/assets/one-light-PoHY5YXO.js +0 -1
- package/public/assets/pascal-D93ZcfNL.js +0 -1
- package/public/assets/perl-C0TMdlhV.js +0 -1
- package/public/assets/php-CDn_0X-4.js +0 -1
- package/public/assets/pkl-u5AG7uiY.js +0 -1
- package/public/assets/plastic-3e1v2bzS.js +0 -1
- package/public/assets/plsql-ChMvpjG-.js +0 -1
- package/public/assets/po-BTJTHyun.js +0 -1
- package/public/assets/poimandres-CS3Unz2-.js +0 -1
- package/public/assets/polar-C0HS_06l.js +0 -1
- package/public/assets/postcss-CXtECtnM.js +0 -1
- package/public/assets/powerquery-CEu0bR-o.js +0 -1
- package/public/assets/powershell-Dpen1YoG.js +0 -1
- package/public/assets/prisma-Dd19v3D-.js +0 -1
- package/public/assets/prolog-CbFg5uaA.js +0 -1
- package/public/assets/proto-DyJlTyXw.js +0 -1
- package/public/assets/pug-CGlum2m_.js +0 -1
- package/public/assets/puppet-BMWR74SV.js +0 -1
- package/public/assets/purescript-CklMAg4u.js +0 -1
- package/public/assets/python-B6aJPvgy.js +0 -1
- package/public/assets/qml-3beO22l8.js +0 -1
- package/public/assets/qmldir-C8lEn-DE.js +0 -1
- package/public/assets/qss-IeuSbFQv.js +0 -1
- package/public/assets/r-DiinP2Uv.js +0 -1
- package/public/assets/racket-BqYA7rlc.js +0 -1
- package/public/assets/raku-DXvB9xmW.js +0 -1
- package/public/assets/razor-WgofotgN.js +0 -1
- package/public/assets/red-bN70gL4F.js +0 -1
- package/public/assets/reg-C-SQnVFl.js +0 -1
- package/public/assets/regexp-CDVJQ6XC.js +0 -1
- package/public/assets/rel-C3B-1QV4.js +0 -1
- package/public/assets/riscv-BM1_JUlF.js +0 -1
- package/public/assets/rose-pine-BHrmToEH.js +0 -1
- package/public/assets/rose-pine-dawn-CnK8MTSM.js +0 -1
- package/public/assets/rose-pine-moon-NleAzG8P.js +0 -1
- package/public/assets/rosmsg-BJDFO7_C.js +0 -1
- package/public/assets/rst-B0xPkSld.js +0 -1
- package/public/assets/ruby-BvKwtOVI.js +0 -1
- package/public/assets/rust-B1yitclQ.js +0 -1
- package/public/assets/sas-cz2c8ADy.js +0 -1
- package/public/assets/sass-Cj5Yp3dK.js +0 -1
- package/public/assets/scala-C151Ov-r.js +0 -1
- package/public/assets/scheme-C98Dy4si.js +0 -1
- package/public/assets/scss-OYdSNvt2.js +0 -1
- package/public/assets/sdbl-DVxCFoDh.js +0 -1
- package/public/assets/shaderlab-Dg9Lc6iA.js +0 -1
- package/public/assets/shellscript-Yzrsuije.js +0 -1
- package/public/assets/shellsession-BADoaaVG.js +0 -1
- package/public/assets/slack-dark-BthQWCQV.js +0 -1
- package/public/assets/slack-ochin-DqwNpetd.js +0 -1
- package/public/assets/smalltalk-BERRCDM3.js +0 -1
- package/public/assets/snazzy-light-Bw305WKR.js +0 -1
- package/public/assets/solarized-dark-DXbdFlpD.js +0 -1
- package/public/assets/solarized-light-L9t79GZl.js +0 -1
- package/public/assets/solidity-BbcW6ACK.js +0 -1
- package/public/assets/soy-Brmx7dQM.js +0 -1
- package/public/assets/sparql-rVzFXLq3.js +0 -1
- package/public/assets/splunk-BtCnVYZw.js +0 -1
- package/public/assets/sql-BLtJtn59.js +0 -1
- package/public/assets/ssh-config-_ykCGR6B.js +0 -1
- package/public/assets/stata-BH5u7GGu.js +0 -1
- package/public/assets/stylus-BEDo0Tqx.js +0 -1
- package/public/assets/svelte-3Dk4HxPD.js +0 -1
- package/public/assets/swift-Dg5xB15N.js +0 -1
- package/public/assets/synthwave-84-CbfX1IO0.js +0 -1
- package/public/assets/system-verilog-CnnmHF94.js +0 -1
- package/public/assets/systemd-4A_iFExJ.js +0 -1
- package/public/assets/talonscript-CkByrt1z.js +0 -1
- package/public/assets/tasl-QIJgUcNo.js +0 -1
- package/public/assets/tcl-dwOrl1Do.js +0 -1
- package/public/assets/templ-W15q3VgB.js +0 -1
- package/public/assets/terraform-BETggiCN.js +0 -1
- package/public/assets/tex-Cppo0RY3.js +0 -1
- package/public/assets/todo-BLpUqy61.js +0 -1
- package/public/assets/tokyo-night-hegEt444.js +0 -1
- package/public/assets/toml-vGWfd6FD.js +0 -1
- package/public/assets/tool-call-B4Xz6FbC.js +0 -60
- package/public/assets/ts-tags-zn1MmPIZ.js +0 -1
- package/public/assets/tsv-B_m7g4N7.js +0 -1
- package/public/assets/tsx-COt5Ahok.js +0 -1
- package/public/assets/turtle-BsS91CYL.js +0 -1
- package/public/assets/twig-CO9l9SDP.js +0 -1
- package/public/assets/typescript-BPQ3VLAy.js +0 -1
- package/public/assets/typespec-Df68jz8_.js +0 -1
- package/public/assets/typst-DHCkPAjA.js +0 -1
- package/public/assets/unified-picker-BrzM_sH6.js +0 -1
- package/public/assets/v-BcVCzyr7.js +0 -1
- package/public/assets/vala-CsfeWuGM.js +0 -1
- package/public/assets/vb-D17OF-Vu.js +0 -1
- package/public/assets/verilog-BQ8w6xss.js +0 -1
- package/public/assets/vesper-DU1UobuO.js +0 -1
- package/public/assets/vhdl-CeAyd5Ju.js +0 -1
- package/public/assets/viml-CJc9bBzg.js +0 -1
- package/public/assets/vitesse-black-Bkuqu6BP.js +0 -1
- package/public/assets/vitesse-dark-D0r3Knsf.js +0 -1
- package/public/assets/vitesse-light-CVO1_9PV.js +0 -1
- package/public/assets/vue-CCoi5OLL.js +0 -1
- package/public/assets/vue-html-DAAvJJDi.js +0 -1
- package/public/assets/vue-vine-_Ih-lPRR.js +0 -1
- package/public/assets/vyper-CDx5xZoG.js +0 -1
- package/public/assets/wasm-CG6Dc4jp.js +0 -1
- package/public/assets/wasm-MzD3tlZU.js +0 -1
- package/public/assets/wenyan-BV7otONQ.js +0 -1
- package/public/assets/wgsl-Dx-B1_4e.js +0 -1
- package/public/assets/wikitext-BhOHFoWU.js +0 -1
- package/public/assets/wit-5i3qLPDT.js +0 -1
- package/public/assets/wolfram-lXgVvXCa.js +0 -1
- package/public/assets/wrap-text-B1i7zgLk.js +0 -1
- package/public/assets/xml-sdJ4AIDG.js +0 -1
- package/public/assets/xsl-CtQFsRM5.js +0 -1
- package/public/assets/yaml-Buea-lGh.js +0 -1
- package/public/assets/zenscript-DVFEvuxE.js +0 -1
- package/public/assets/zig-VOosw3JB.js +0 -1
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -44
- package/public/loading.html +0 -33
- package/public/logo.png +0 -0
- package/public/manifest.webmanifest +0 -1
- package/public/maskable-icon-512x512.png +0 -0
- package/public/monaco/vs/base/browser/ui/codicons/codicon/codicon.ttf +0 -0
- package/public/monaco/vs/base/worker/workerMain.js +0 -31
- package/public/monaco/vs/basic-languages/cpp/cpp.js +0 -10
- package/public/monaco/vs/basic-languages/kotlin/kotlin.js +0 -10
- package/public/monaco/vs/basic-languages/markdown/markdown.js +0 -10
- package/public/monaco/vs/basic-languages/python/python.js +0 -10
- package/public/monaco/vs/editor/editor.main.css +0 -8
- package/public/monaco/vs/editor/editor.main.js +0 -798
- package/public/monaco/vs/language/css/cssMode.js +0 -13
- package/public/monaco/vs/language/css/cssWorker.js +0 -77
- package/public/monaco/vs/language/html/htmlMode.js +0 -13
- package/public/monaco/vs/language/html/htmlWorker.js +0 -454
- package/public/monaco/vs/language/json/jsonMode.js +0 -19
- package/public/monaco/vs/language/json/jsonWorker.js +0 -42
- package/public/monaco/vs/language/typescript/tsMode.js +0 -20
- package/public/monaco/vs/language/typescript/tsWorker.js +0 -51328
- package/public/monaco/vs/loader.js +0 -11
- package/public/monaco.worker.js +0 -7
- package/public/pwa-192x192.png +0 -0
- package/public/pwa-512x512.png +0 -0
- package/public/pwa-64x64.png +0 -0
- package/public/registerSW.js +0 -1
- package/public/sw.js +0 -1
- package/public/ui-version.json +0 -3
- package/public/workbox-60d14903.js +0 -1
package/bin/cli.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require("child_process")
|
|
3
|
+
const path = require("path")
|
|
4
|
+
const fs = require("fs")
|
|
5
|
+
|
|
6
|
+
const platformMap = {
|
|
7
|
+
"darwin-x64": "@vividcodeai/embeddedcowork-darwin-x64",
|
|
8
|
+
"darwin-arm64": "@vividcodeai/embeddedcowork-darwin-arm64",
|
|
9
|
+
"win32-x64": "@vividcodeai/embeddedcowork-win32-x64",
|
|
10
|
+
"linux-x64": "@vividcodeai/embeddedcowork-linux-x64",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const key = `${process.platform}-${process.arch}`
|
|
14
|
+
const pkgName = platformMap[key]
|
|
15
|
+
|
|
16
|
+
if (!pkgName) {
|
|
17
|
+
console.error(`Unsupported platform: ${key}`)
|
|
18
|
+
console.error("Supported platforms: darwin-x64, darwin-arm64, win32-x64, linux-x64")
|
|
19
|
+
process.exit(1)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const binaryName = process.platform === "win32" ? "embeddedcowork-server.exe" : "embeddedcowork-server"
|
|
23
|
+
|
|
24
|
+
function findBinary(startDir) {
|
|
25
|
+
let current = startDir
|
|
26
|
+
for (;;) {
|
|
27
|
+
const modules = path.join(current, "node_modules")
|
|
28
|
+
if (fs.existsSync(modules)) {
|
|
29
|
+
const candidate = path.join(modules, pkgName, "bin", binaryName)
|
|
30
|
+
if (fs.existsSync(candidate)) return candidate
|
|
31
|
+
}
|
|
32
|
+
const parent = path.dirname(current)
|
|
33
|
+
if (parent === current) return null
|
|
34
|
+
current = parent
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const scriptDir = path.dirname(fs.realpathSync(__filename))
|
|
39
|
+
const binPath = findBinary(scriptDir)
|
|
40
|
+
|
|
41
|
+
if (!binPath) {
|
|
42
|
+
console.error(
|
|
43
|
+
`Failed to find binary for platform ${key}. Try reinstalling: npm install @vividcodeai/embeddedcowork`
|
|
44
|
+
)
|
|
45
|
+
process.exit(1)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const child = spawn(binPath, process.argv.slice(2), { stdio: "inherit" })
|
|
49
|
+
child.on("exit", (code, signal) => {
|
|
50
|
+
if (signal === "SIGTERM" && code === null) {
|
|
51
|
+
process.exit(0)
|
|
52
|
+
}
|
|
53
|
+
process.exit(code ?? 1)
|
|
54
|
+
})
|
|
55
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"))
|
|
56
|
+
process.on("SIGINT", () => child.kill("SIGINT"))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vividcodeai/embeddedcowork",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "EmbeddedCowork Server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -17,19 +17,26 @@
|
|
|
17
17
|
"url": "https://github.com/vividcode-ai/EmbeddedCowork.git"
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
|
-
"main": "dist/index.js",
|
|
21
20
|
"bin": {
|
|
22
|
-
"embeddedCowork": "
|
|
21
|
+
"embeddedCowork": "bin/cli.js",
|
|
22
|
+
"embcowork": "bin/cli.js"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "npm run build:ui && npm run prepare-ui && tsc -p tsconfig.json && node ./scripts/copy-auth-pages.mjs && npm run prepare-config",
|
|
26
26
|
"build:standalone": "node ./scripts/build-standalone.mjs",
|
|
27
|
+
"build:platforms": "node ./scripts/build-platforms.mjs",
|
|
27
28
|
"build:ui": "npm run build --prefix ../ui",
|
|
28
29
|
"prepare-ui": "node ./scripts/copy-ui-dist.mjs",
|
|
29
30
|
"prepare-config": "node ./scripts/copy-opencode-config.mjs",
|
|
30
31
|
"dev": "cross-env EMBEDDEDCOWORK_DEV=1 EMBEDDEDCOWORK_SERVER_PASSWORD=embeddedcowork-dev CLI_UI_DEV_SERVER=http://localhost:3000 CLI_HTTPS=false CLI_HTTP=true tsx src/index.ts",
|
|
31
32
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
32
33
|
},
|
|
34
|
+
"optionalDependencies": {
|
|
35
|
+
"@vividcodeai/embeddedcowork-darwin-x64": "0.0.8",
|
|
36
|
+
"@vividcodeai/embeddedcowork-darwin-arm64": "0.0.8",
|
|
37
|
+
"@vividcodeai/embeddedcowork-win32-x64": "0.0.8",
|
|
38
|
+
"@vividcodeai/embeddedcowork-linux-x64": "0.0.8"
|
|
39
|
+
},
|
|
33
40
|
"dependencies": {
|
|
34
41
|
"@fastify/cors": "^11.2.0",
|
|
35
42
|
"@fastify/reply-from": "^12.6.2",
|
package/dist/api-types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const WINDOWS_DRIVES_ROOT = "__drives__";
|
package/dist/auth/auth-store.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { hashPassword, verifyPassword } from "./password-hash";
|
|
4
|
-
export class AuthStore {
|
|
5
|
-
constructor(authFilePath, logger) {
|
|
6
|
-
this.authFilePath = authFilePath;
|
|
7
|
-
this.logger = logger;
|
|
8
|
-
this.cachedFile = null;
|
|
9
|
-
this.overrideAuth = null;
|
|
10
|
-
this.bootstrapUsername = null;
|
|
11
|
-
}
|
|
12
|
-
getAuthFilePath() {
|
|
13
|
-
return this.authFilePath;
|
|
14
|
-
}
|
|
15
|
-
load() {
|
|
16
|
-
if (this.overrideAuth) {
|
|
17
|
-
return this.overrideAuth;
|
|
18
|
-
}
|
|
19
|
-
if (this.cachedFile) {
|
|
20
|
-
return this.cachedFile;
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
if (!fs.existsSync(this.authFilePath)) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
const raw = fs.readFileSync(this.authFilePath, "utf-8");
|
|
27
|
-
const parsed = JSON.parse(raw);
|
|
28
|
-
if (!parsed || parsed.version !== 1) {
|
|
29
|
-
this.logger.warn({ authFilePath: this.authFilePath }, "Auth file has unsupported version");
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
this.cachedFile = parsed;
|
|
33
|
-
return parsed;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
this.logger.warn({ err: error, authFilePath: this.authFilePath }, "Failed to load auth file");
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
ensureInitialized(params) {
|
|
41
|
-
const password = params.password?.trim();
|
|
42
|
-
if (password) {
|
|
43
|
-
const now = new Date().toISOString();
|
|
44
|
-
const runtime = {
|
|
45
|
-
version: 1,
|
|
46
|
-
username: params.username,
|
|
47
|
-
password: hashPassword(password),
|
|
48
|
-
userProvided: true,
|
|
49
|
-
updatedAt: now,
|
|
50
|
-
};
|
|
51
|
-
this.overrideAuth = runtime;
|
|
52
|
-
this.cachedFile = null;
|
|
53
|
-
this.bootstrapUsername = null;
|
|
54
|
-
this.logger.debug({ authFilePath: this.authFilePath }, "Using runtime auth password override; ignoring auth file");
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const existing = this.load();
|
|
58
|
-
if (existing) {
|
|
59
|
-
if (existing.username !== params.username) {
|
|
60
|
-
// Keep existing username unless explicitly overridden later.
|
|
61
|
-
this.logger.debug({ existing: existing.username, requested: params.username }, "Auth username differs from requested");
|
|
62
|
-
}
|
|
63
|
-
this.bootstrapUsername = null;
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (params.allowBootstrapWithoutPassword) {
|
|
67
|
-
this.bootstrapUsername = params.username;
|
|
68
|
-
this.logger.debug({ authFilePath: this.authFilePath }, "No auth file present; bootstrap-only mode enabled");
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
throw new Error(`No server password configured. Create ${this.authFilePath} or start with --password / EMBEDDEDCOWORK_SERVER_PASSWORD.`);
|
|
72
|
-
}
|
|
73
|
-
validateCredentials(username, password) {
|
|
74
|
-
const auth = this.load();
|
|
75
|
-
if (!auth) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
if (username !== auth.username) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
return verifyPassword(password, auth.password);
|
|
82
|
-
}
|
|
83
|
-
setPassword(params) {
|
|
84
|
-
if (this.overrideAuth) {
|
|
85
|
-
throw new Error("Server password is provided via CLI/env and cannot be changed while running. Restart without --password / EMBEDDEDCOWORK_SERVER_PASSWORD to use auth.json.");
|
|
86
|
-
}
|
|
87
|
-
const current = this.load();
|
|
88
|
-
if (!current) {
|
|
89
|
-
if (!this.bootstrapUsername) {
|
|
90
|
-
throw new Error("Auth is not initialized");
|
|
91
|
-
}
|
|
92
|
-
const created = {
|
|
93
|
-
version: 1,
|
|
94
|
-
username: this.bootstrapUsername,
|
|
95
|
-
password: hashPassword(params.password),
|
|
96
|
-
userProvided: params.markUserProvided,
|
|
97
|
-
updatedAt: new Date().toISOString(),
|
|
98
|
-
};
|
|
99
|
-
this.persist(created);
|
|
100
|
-
this.bootstrapUsername = null;
|
|
101
|
-
return { username: created.username, passwordUserProvided: created.userProvided };
|
|
102
|
-
}
|
|
103
|
-
const next = {
|
|
104
|
-
...current,
|
|
105
|
-
password: hashPassword(params.password),
|
|
106
|
-
userProvided: params.markUserProvided,
|
|
107
|
-
updatedAt: new Date().toISOString(),
|
|
108
|
-
};
|
|
109
|
-
this.persist(next);
|
|
110
|
-
return { username: next.username, passwordUserProvided: next.userProvided };
|
|
111
|
-
}
|
|
112
|
-
getStatus() {
|
|
113
|
-
const current = this.load();
|
|
114
|
-
if (current) {
|
|
115
|
-
return { username: current.username, passwordUserProvided: current.userProvided };
|
|
116
|
-
}
|
|
117
|
-
if (this.bootstrapUsername) {
|
|
118
|
-
return { username: this.bootstrapUsername, passwordUserProvided: false };
|
|
119
|
-
}
|
|
120
|
-
throw new Error("Auth is not initialized");
|
|
121
|
-
}
|
|
122
|
-
persist(auth) {
|
|
123
|
-
try {
|
|
124
|
-
fs.mkdirSync(path.dirname(this.authFilePath), { recursive: true });
|
|
125
|
-
fs.writeFileSync(this.authFilePath, JSON.stringify(auth, null, 2), "utf-8");
|
|
126
|
-
this.cachedFile = auth;
|
|
127
|
-
this.logger.debug({ authFilePath: this.authFilePath }, "Persisted auth file");
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
this.logger.error({ err: error, authFilePath: this.authFilePath }, "Failed to persist auth file");
|
|
131
|
-
throw error;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
package/dist/auth/http-auth.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export function parseCookies(header) {
|
|
2
|
-
const result = {};
|
|
3
|
-
if (!header)
|
|
4
|
-
return result;
|
|
5
|
-
const parts = header.split(";");
|
|
6
|
-
for (const part of parts) {
|
|
7
|
-
const index = part.indexOf("=");
|
|
8
|
-
if (index < 0)
|
|
9
|
-
continue;
|
|
10
|
-
const key = part.slice(0, index).trim();
|
|
11
|
-
const value = part.slice(index + 1).trim();
|
|
12
|
-
if (!key)
|
|
13
|
-
continue;
|
|
14
|
-
result[key] = decodeURIComponent(value);
|
|
15
|
-
}
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
export function isLoopbackAddress(remoteAddress) {
|
|
19
|
-
if (!remoteAddress)
|
|
20
|
-
return false;
|
|
21
|
-
if (remoteAddress === "127.0.0.1" || remoteAddress === "::1")
|
|
22
|
-
return true;
|
|
23
|
-
if (remoteAddress === "::ffff:127.0.0.1")
|
|
24
|
-
return true;
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
export function wantsHtml(request) {
|
|
28
|
-
const accept = (request.headers["accept"] ?? "").toString().toLowerCase();
|
|
29
|
-
return accept.includes("text/html") || accept.includes("application/xhtml");
|
|
30
|
-
}
|
|
31
|
-
export function sendUnauthorized(request, reply) {
|
|
32
|
-
if (request.method === "GET" && !request.url.startsWith("/api/") && wantsHtml(request)) {
|
|
33
|
-
reply.redirect("/login");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
reply.code(401).send({ error: "Unauthorized" });
|
|
37
|
-
}
|
package/dist/auth/manager.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { AuthStore } from "./auth-store";
|
|
3
|
-
import { TokenManager } from "./token-manager";
|
|
4
|
-
import { SessionManager } from "./session-manager";
|
|
5
|
-
import { isLoopbackAddress, parseCookies } from "./http-auth";
|
|
6
|
-
export const BOOTSTRAP_TOKEN_STDOUT_PREFIX = "EMBEDDEDCOWORK_BOOTSTRAP_TOKEN:";
|
|
7
|
-
export const DEFAULT_AUTH_USERNAME = "embeddedcowork";
|
|
8
|
-
export const DEFAULT_AUTH_COOKIE_NAME = "embeddedcowork_session";
|
|
9
|
-
export class AuthManager {
|
|
10
|
-
constructor(init, logger) {
|
|
11
|
-
this.init = init;
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
this.sessionManager = new SessionManager();
|
|
14
|
-
this.cookieName = sanitizeCookieName(init.cookieName);
|
|
15
|
-
this.authEnabled = !Boolean(init.dangerouslySkipAuth);
|
|
16
|
-
if (!this.authEnabled) {
|
|
17
|
-
this.authStore = null;
|
|
18
|
-
this.tokenManager = null;
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const authFilePath = resolveAuthFilePath(init.configPath);
|
|
22
|
-
this.authStore = new AuthStore(authFilePath, logger.child({ component: "auth" }));
|
|
23
|
-
// Startup: password comes from CLI/env, auth.json, or bootstrap-only mode.
|
|
24
|
-
this.authStore.ensureInitialized({
|
|
25
|
-
username: init.username,
|
|
26
|
-
password: init.password,
|
|
27
|
-
allowBootstrapWithoutPassword: init.generateToken,
|
|
28
|
-
});
|
|
29
|
-
this.tokenManager = init.generateToken ? new TokenManager(60000) : null;
|
|
30
|
-
}
|
|
31
|
-
isAuthEnabled() {
|
|
32
|
-
return this.authEnabled;
|
|
33
|
-
}
|
|
34
|
-
getCookieName() {
|
|
35
|
-
return this.cookieName;
|
|
36
|
-
}
|
|
37
|
-
isTokenBootstrapEnabled() {
|
|
38
|
-
return Boolean(this.tokenManager);
|
|
39
|
-
}
|
|
40
|
-
issueBootstrapToken() {
|
|
41
|
-
if (!this.tokenManager)
|
|
42
|
-
return null;
|
|
43
|
-
return this.tokenManager.generate();
|
|
44
|
-
}
|
|
45
|
-
consumeBootstrapToken(token) {
|
|
46
|
-
if (!this.tokenManager)
|
|
47
|
-
return false;
|
|
48
|
-
return this.tokenManager.consume(token);
|
|
49
|
-
}
|
|
50
|
-
validateLogin(username, password) {
|
|
51
|
-
if (!this.authEnabled) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return this.requireAuthStore().validateCredentials(username, password);
|
|
55
|
-
}
|
|
56
|
-
createSession(username) {
|
|
57
|
-
if (!this.authEnabled) {
|
|
58
|
-
return { id: "auth-disabled", createdAt: Date.now(), username: this.init.username };
|
|
59
|
-
}
|
|
60
|
-
return this.sessionManager.createSession(username);
|
|
61
|
-
}
|
|
62
|
-
getStatus() {
|
|
63
|
-
if (!this.authEnabled) {
|
|
64
|
-
return { username: this.init.username, passwordUserProvided: false };
|
|
65
|
-
}
|
|
66
|
-
return this.requireAuthStore().getStatus();
|
|
67
|
-
}
|
|
68
|
-
setPassword(password) {
|
|
69
|
-
if (!this.authEnabled) {
|
|
70
|
-
throw new Error("Internal authentication is disabled");
|
|
71
|
-
}
|
|
72
|
-
return this.requireAuthStore().setPassword({ password, markUserProvided: true });
|
|
73
|
-
}
|
|
74
|
-
isLoopbackRequest(request) {
|
|
75
|
-
return isLoopbackAddress(request.socket.remoteAddress);
|
|
76
|
-
}
|
|
77
|
-
getSessionFromRequest(request) {
|
|
78
|
-
return this.getSessionFromHeaders(request.headers);
|
|
79
|
-
}
|
|
80
|
-
getSessionFromHeaders(headers) {
|
|
81
|
-
if (!this.authEnabled) {
|
|
82
|
-
// When auth is disabled, treat all requests as authenticated.
|
|
83
|
-
// We still return a stable username so callers can display it.
|
|
84
|
-
return { username: this.init.username, sessionId: "auth-disabled" };
|
|
85
|
-
}
|
|
86
|
-
const cookieHeader = Array.isArray(headers.cookie) ? headers.cookie.join("; ") : headers.cookie;
|
|
87
|
-
const cookies = parseCookies(cookieHeader);
|
|
88
|
-
const sessionId = cookies[this.cookieName];
|
|
89
|
-
const session = this.sessionManager.getSession(sessionId);
|
|
90
|
-
if (!session)
|
|
91
|
-
return null;
|
|
92
|
-
return { username: session.username, sessionId: session.id };
|
|
93
|
-
}
|
|
94
|
-
setSessionCookie(reply, sessionId) {
|
|
95
|
-
reply.header("Set-Cookie", buildSessionCookie(this.cookieName, sessionId));
|
|
96
|
-
}
|
|
97
|
-
setSessionCookieWithOptions(reply, sessionId, options) {
|
|
98
|
-
reply.header("Set-Cookie", buildSessionCookie(this.cookieName, sessionId, options));
|
|
99
|
-
}
|
|
100
|
-
clearSessionCookie(reply) {
|
|
101
|
-
reply.header("Set-Cookie", buildSessionCookie(this.cookieName, "", { maxAgeSeconds: 0 }));
|
|
102
|
-
}
|
|
103
|
-
clearSessionCookieWithOptions(reply, options) {
|
|
104
|
-
reply.header("Set-Cookie", buildSessionCookie(this.cookieName, "", { maxAgeSeconds: 0, ...options }));
|
|
105
|
-
}
|
|
106
|
-
requireAuthStore() {
|
|
107
|
-
if (!this.authStore) {
|
|
108
|
-
throw new Error("Auth store is unavailable");
|
|
109
|
-
}
|
|
110
|
-
return this.authStore;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function sanitizeCookieName(value) {
|
|
114
|
-
const trimmed = value?.trim();
|
|
115
|
-
if (!trimmed) {
|
|
116
|
-
return DEFAULT_AUTH_COOKIE_NAME;
|
|
117
|
-
}
|
|
118
|
-
const sanitized = trimmed.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
119
|
-
return sanitized.length > 0 ? sanitized : DEFAULT_AUTH_COOKIE_NAME;
|
|
120
|
-
}
|
|
121
|
-
function resolveAuthFilePath(configPath) {
|
|
122
|
-
const resolvedConfigPath = resolvePath(configPath);
|
|
123
|
-
return path.join(path.dirname(resolvedConfigPath), "auth.json");
|
|
124
|
-
}
|
|
125
|
-
function resolvePath(filePath) {
|
|
126
|
-
if (filePath.startsWith("~/")) {
|
|
127
|
-
return path.join(process.env.HOME ?? "", filePath.slice(2));
|
|
128
|
-
}
|
|
129
|
-
return path.resolve(filePath);
|
|
130
|
-
}
|
|
131
|
-
function buildSessionCookie(name, value, options) {
|
|
132
|
-
const parts = [`${name}=${encodeURIComponent(value)}`, "HttpOnly", "Path=/", "SameSite=Lax"];
|
|
133
|
-
if (options?.secure) {
|
|
134
|
-
parts.push("Secure");
|
|
135
|
-
}
|
|
136
|
-
if (options?.maxAgeSeconds !== undefined) {
|
|
137
|
-
parts.push(`Max-Age=${Math.max(0, Math.floor(options.maxAgeSeconds))}`);
|
|
138
|
-
}
|
|
139
|
-
return parts.join("; ");
|
|
140
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
|
-
const DEFAULT_SCRYPT_PARAMS = {
|
|
3
|
-
N: 16384,
|
|
4
|
-
r: 8,
|
|
5
|
-
p: 1,
|
|
6
|
-
maxmem: 32 * 1024 * 1024,
|
|
7
|
-
};
|
|
8
|
-
export function hashPassword(password) {
|
|
9
|
-
const salt = crypto.randomBytes(16);
|
|
10
|
-
const params = DEFAULT_SCRYPT_PARAMS;
|
|
11
|
-
const keyLength = 64;
|
|
12
|
-
const derived = crypto.scryptSync(password, salt, keyLength, params);
|
|
13
|
-
return {
|
|
14
|
-
algorithm: "scrypt",
|
|
15
|
-
saltBase64: salt.toString("base64"),
|
|
16
|
-
hashBase64: Buffer.from(derived).toString("base64"),
|
|
17
|
-
keyLength,
|
|
18
|
-
params,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export function verifyPassword(password, record) {
|
|
22
|
-
if (record.algorithm !== "scrypt") {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const salt = Buffer.from(record.saltBase64, "base64");
|
|
26
|
-
const expected = Buffer.from(record.hashBase64, "base64");
|
|
27
|
-
const derived = crypto.scryptSync(password, salt, record.keyLength, record.params);
|
|
28
|
-
if (expected.length !== derived.length) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
return crypto.timingSafeEqual(expected, Buffer.from(derived));
|
|
32
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
|
-
export class SessionManager {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.sessions = new Map();
|
|
5
|
-
}
|
|
6
|
-
createSession(username) {
|
|
7
|
-
const id = crypto.randomBytes(32).toString("base64url");
|
|
8
|
-
const info = { id, createdAt: Date.now(), username };
|
|
9
|
-
this.sessions.set(id, info);
|
|
10
|
-
return info;
|
|
11
|
-
}
|
|
12
|
-
getSession(id) {
|
|
13
|
-
if (!id)
|
|
14
|
-
return undefined;
|
|
15
|
-
return this.sessions.get(id);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import crypto from "crypto";
|
|
2
|
-
export class TokenManager {
|
|
3
|
-
constructor(ttlMs) {
|
|
4
|
-
this.ttlMs = ttlMs;
|
|
5
|
-
this.token = null;
|
|
6
|
-
}
|
|
7
|
-
generate() {
|
|
8
|
-
const token = crypto.randomBytes(32).toString("base64url");
|
|
9
|
-
this.token = { token, createdAt: Date.now(), consumed: false };
|
|
10
|
-
return token;
|
|
11
|
-
}
|
|
12
|
-
consume(token) {
|
|
13
|
-
if (!this.token)
|
|
14
|
-
return false;
|
|
15
|
-
if (this.token.consumed)
|
|
16
|
-
return false;
|
|
17
|
-
if (Date.now() - this.token.createdAt > this.ttlMs)
|
|
18
|
-
return false;
|
|
19
|
-
if (token !== this.token.token)
|
|
20
|
-
return false;
|
|
21
|
-
this.token.consumed = true;
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
peek() {
|
|
25
|
-
return this.token?.token ?? null;
|
|
26
|
-
}
|
|
27
|
-
}
|