@artenx/dshb 0.1.38 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/lib/auth/gate.d.ts +9 -1
  3. package/lib/auth/gate.js +12 -5
  4. package/lib/auth/gate.js.map +1 -1
  5. package/lib/auth/index.js +42 -9
  6. package/lib/auth/index.js.map +1 -1
  7. package/lib/auth/reset-cli.js +0 -0
  8. package/lib/catalog-B3pDDoR4.js +119 -0
  9. package/lib/catalog-B3pDDoR4.js.map +1 -0
  10. package/lib/client.js +1014 -45
  11. package/lib/client.js.map +1 -1
  12. package/lib/core/index.js +477 -4
  13. package/lib/core/index.js.map +1 -1
  14. package/lib/core/routes.d.ts +1 -1
  15. package/lib/core/sync/coordinator.d.ts +5 -5
  16. package/lib/core/sync/coordinator.js +47 -6
  17. package/lib/core/sync/coordinator.js.map +1 -1
  18. package/lib/core/sync/host-key.d.ts +1 -1
  19. package/lib/core/sync/internal-routes.d.ts +3 -3
  20. package/lib/core/sync/internal-routes.js +36 -3
  21. package/lib/core/sync/internal-routes.js.map +1 -1
  22. package/lib/core/sync/model.d.ts +2 -2
  23. package/lib/core/sync/model.js +62 -1
  24. package/lib/core/sync/model.js.map +1 -1
  25. package/lib/core/sync/node-sync.d.ts +1 -1
  26. package/lib/core/sync/offline-archive.d.ts +6 -4
  27. package/lib/core/sync/offline-archive.js +31 -8
  28. package/lib/core/sync/offline-archive.js.map +1 -1
  29. package/lib/core/sync/offline-routes.js +29 -3
  30. package/lib/core/sync/offline-routes.js.map +1 -1
  31. package/lib/core/sync/peer-manager.d.ts +2 -2
  32. package/lib/core/sync/peer-manager.js +2 -0
  33. package/lib/core/sync/peer-manager.js.map +1 -1
  34. package/lib/core/sync/protocol.d.ts +2 -2
  35. package/lib/core/sync/protocol.js +2 -1
  36. package/lib/core/sync/protocol.js.map +1 -1
  37. package/lib/core/sync/remote-helper.js +4 -2
  38. package/lib/core/sync/remote-helper.js.map +1 -1
  39. package/lib/core/sync/routes.d.ts +3 -2
  40. package/lib/core/sync/routes.js +43 -2
  41. package/lib/core/sync/routes.js.map +1 -1
  42. package/lib/core/sync/session-journal.d.ts +1 -1
  43. package/lib/core/sync/session-routes.d.ts +1 -1
  44. package/lib/core/sync/session-routes.js +25 -1
  45. package/lib/core/sync/session-routes.js.map +1 -1
  46. package/lib/core/sync/session-sync.d.ts +1 -1
  47. package/lib/core/sync/session-sync.js +1 -1
  48. package/lib/core/sync/ssh-transport.d.ts +1 -1
  49. package/lib/core/sync/ssh-transport.js +73 -3
  50. package/lib/core/sync/ssh-transport.js.map +1 -1
  51. package/lib/core/sync/stores.d.ts +1 -1
  52. package/lib/core/sync/stores.js +27 -5
  53. package/lib/core/sync/stores.js.map +1 -1
  54. package/lib/core/workspaces.d.ts +1 -1
  55. package/lib/{host-key-CSnpIrjq.d.ts → host-key-Dh2YTRX7.d.ts} +2 -2
  56. package/lib/{model-CKTBf-Pl.d.ts → model-D1T078kt.d.ts} +74 -6
  57. package/lib/{node-sync-C3Ym-HDu.d.ts → node-sync-WdEv-ek7.d.ts} +3 -3
  58. package/lib/{protocol-DJ0zyVlB.d.ts → protocol-DyPDIJWa.d.ts} +3 -2
  59. package/lib/selection-BABQH1Rt.js +48 -0
  60. package/lib/selection-BABQH1Rt.js.map +1 -0
  61. package/lib/{session-journal-VE_1tA2-.d.ts → session-journal-CTblFLJg.d.ts} +2 -2
  62. package/lib/{session-sync-BBCm_ou2.js → session-sync-BZSp_o4n.js} +81 -1
  63. package/lib/session-sync-BZSp_o4n.js.map +1 -0
  64. package/lib/{session-sync-Bw0cZ4oa.d.ts → session-sync-flNnd2JQ.d.ts} +14 -5
  65. package/lib/{ssh-transport-COZe0BDr.d.ts → ssh-transport-DQPMNwh1.d.ts} +25 -6
  66. package/lib/{stores-puyTC075.d.ts → stores-CUY_YFD-.d.ts} +2 -2
  67. package/package.json +9 -7
  68. package/lib/session-sync-BBCm_ou2.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DSH-HoneyBee Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -2,6 +2,14 @@ import { CredentialStore } from "./credentials.js";
2
2
  import { IncomingMessage } from "node:http";
3
3
  //#region src/auth/gate.d.ts
4
4
  type GateDecision = 'allow' | 'exempt' | 'redirect-login' | 'reject' | 'forbidden';
5
+ /**
6
+ * 认证路由(登录/状态)的可信来源判定。
7
+ * - remoteAddress 必须回环:直连本机,或经可信反代(部署方边界)转发。
8
+ * - 跨站浏览器请求一律拒绝(sec-fetch-site / Origin 与 Host 一致性)。
9
+ * Host 头允许外部域名:预览反代会保留原始 Host,回环校验由
10
+ * remoteAddress 与反代信任承担,登录后再经 rewriteToLoopback 归一。
11
+ */
12
+ declare function isTrustedAuthRequest(req: IncomingMessage): boolean;
5
13
  declare class AuthGate {
6
14
  private readonly store;
7
15
  private isTrustedAuthRequest;
@@ -12,5 +20,5 @@ declare class AuthGate {
12
20
  }
13
21
  declare function rewriteToLoopback(req: IncomingMessage, port?: number): void;
14
22
  //#endregion
15
- export { AuthGate, GateDecision, rewriteToLoopback };
23
+ export { AuthGate, GateDecision, isTrustedAuthRequest, rewriteToLoopback };
16
24
  //# sourceMappingURL=gate.d.ts.map
package/lib/auth/gate.js CHANGED
@@ -1,8 +1,15 @@
1
- import { isLoopbackRequest } from "./loopback.js";
1
+ import { isLoopbackAddress, isLoopbackRequest } from "./loopback.js";
2
2
  import { SESSION_COOKIE, readCookie, verifySession } from "./session.js";
3
3
  //#region src/auth/gate.ts
4
- function isTrustedLoopbackAuthRequest(req) {
5
- if (!isLoopbackRequest(req.socket.remoteAddress, req.headers.host)) return false;
4
+ /**
5
+ * 认证路由(登录/状态)的可信来源判定。
6
+ * - remoteAddress 必须回环:直连本机,或经可信反代(部署方边界)转发。
7
+ * - 跨站浏览器请求一律拒绝(sec-fetch-site / Origin 与 Host 一致性)。
8
+ * Host 头允许外部域名:预览反代会保留原始 Host,回环校验由
9
+ * remoteAddress 与反代信任承担,登录后再经 rewriteToLoopback 归一。
10
+ */
11
+ function isTrustedAuthRequest(req) {
12
+ if (!isLoopbackAddress(req.socket.remoteAddress)) return false;
6
13
  if (req.headers["sec-fetch-site"] === "cross-site") return false;
7
14
  const origin = req.headers.origin;
8
15
  if (origin === void 0) return true;
@@ -25,7 +32,7 @@ var AuthGate = class {
25
32
  decide(req) {
26
33
  const path = new URL(req.url ?? "/", "http://x").pathname;
27
34
  if (path === "/login") return "exempt";
28
- if (path === "/api/auth" || path.startsWith("/api/auth/")) return (this.isTrustedAuthRequest ? this.isTrustedAuthRequest(req) : isTrustedLoopbackAuthRequest(req)) ? "exempt" : "forbidden";
35
+ if (path === "/api/auth" || path.startsWith("/api/auth/")) return (this.isTrustedAuthRequest ? this.isTrustedAuthRequest(req) : isTrustedAuthRequest(req)) ? "exempt" : "forbidden";
29
36
  if (isLoopbackRequest(req.socket.remoteAddress, req.headers.host)) return "allow";
30
37
  const secret = this.store.sessionSecret;
31
38
  const username = this.store.username;
@@ -59,6 +66,6 @@ function rewriteToLoopback(req, port) {
59
66
  }
60
67
  }
61
68
  //#endregion
62
- export { AuthGate, rewriteToLoopback };
69
+ export { AuthGate, isTrustedAuthRequest, rewriteToLoopback };
63
70
 
64
71
  //# sourceMappingURL=gate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gate.js","names":[],"sources":["../../src/auth/gate.ts"],"sourcesContent":["import type { IncomingMessage } from 'node:http'\nimport { isLoopbackRequest } from './loopback.js'\nimport { readCookie, SESSION_COOKIE, verifySession } from './session.js'\nimport type { CredentialStore } from './credentials.js'\n\nexport type GateDecision = 'allow' | 'exempt' | 'redirect-login' | 'reject' | 'forbidden'\n\nfunction isTrustedLoopbackAuthRequest(req: IncomingMessage): boolean {\n if (!isLoopbackRequest(req.socket.remoteAddress, req.headers.host)) return false\n if (req.headers['sec-fetch-site'] === 'cross-site') return false\n const origin = req.headers.origin\n if (origin === undefined) return true\n if (typeof origin !== 'string' || !req.headers.host) return false\n try {\n return new URL(origin).host === new URL(`http://${req.headers.host}`).host\n } catch {\n return false\n }\n}\n\nexport class AuthGate {\n private isTrustedAuthRequest: ((req: IncomingMessage) => boolean) | undefined\n\n constructor(private readonly store: CredentialStore) {}\n\n setAuthRequestTrustCheck(check: (req: IncomingMessage) => boolean): void {\n this.isTrustedAuthRequest = check\n }\n\n decide(req: IncomingMessage): GateDecision {\n const path = new URL(req.url ?? '/', 'http://x').pathname\n if (path === '/login') return 'exempt'\n if (path === '/api/auth' || path.startsWith('/api/auth/')) {\n const trusted = this.isTrustedAuthRequest\n ? this.isTrustedAuthRequest(req)\n : isTrustedLoopbackAuthRequest(req)\n return trusted ? 'exempt' : 'forbidden'\n }\n if (isLoopbackRequest(req.socket.remoteAddress, req.headers.host)) return 'allow'\n const secret = this.store.sessionSecret\n const username = this.store.username\n if (secret && username) {\n const value = readCookie(req.headers.cookie, SESSION_COOKIE)\n if (verifySession(value, secret, username)) return 'allow'\n }\n if (this.isPageRequest(req)) return 'redirect-login'\n return 'reject'\n }\n\n private isPageRequest(req: IncomingMessage): boolean {\n if (req.method !== 'GET' && req.method !== 'HEAD') return false\n const path = new URL(req.url ?? '/', 'http://x').pathname\n if (path.startsWith('/api/')) return false\n const accept = req.headers.accept ?? ''\n return accept.includes('text/html') || accept.includes('*/*')\n }\n}\n\nexport function rewriteToLoopback(req: IncomingMessage, port?: number): void {\n const localPort = port ?? req.socket.localPort\n if (typeof localPort !== 'number') return\n const authority = `127.0.0.1:${localPort}`\n req.headers.host = authority\n for (const name of ['origin', 'referer'] as const) {\n const value = req.headers[name]\n if (typeof value !== 'string') continue\n try {\n const url = new URL(value)\n url.host = authority\n req.headers[name] = url.toString()\n } catch {}\n }\n}\n"],"mappings":";;;AAOA,SAAS,6BAA6B,KAA+B;CACnE,IAAI,CAAC,kBAAkB,IAAI,OAAO,eAAe,IAAI,QAAQ,IAAI,GAAG,OAAO;CAC3E,IAAI,IAAI,QAAQ,sBAAsB,cAAc,OAAO;CAC3D,MAAM,SAAS,IAAI,QAAQ;CAC3B,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI,OAAO,WAAW,YAAY,CAAC,IAAI,QAAQ,MAAM,OAAO;CAC5D,IAAI;EACF,OAAO,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,UAAU,IAAI,QAAQ,MAAM,CAAC,CAAC;CACxE,QAAQ;EACN,OAAO;CACT;AACF;AAEA,IAAa,WAAb,MAAsB;CAGS;CAF7B;CAEA,YAAY,OAAyC;EAAxB,KAAA,QAAA;CAAyB;CAEtD,yBAAyB,OAAgD;EACvE,KAAK,uBAAuB;CAC9B;CAEA,OAAO,KAAoC;EACzC,MAAM,OAAO,IAAI,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC;EACjD,IAAI,SAAS,UAAU,OAAO;EAC9B,IAAI,SAAS,eAAe,KAAK,WAAW,YAAY,GAItD,QAHgB,KAAK,uBACjB,KAAK,qBAAqB,GAAG,IAC7B,6BAA6B,GAAG,KACnB,WAAW;EAE9B,IAAI,kBAAkB,IAAI,OAAO,eAAe,IAAI,QAAQ,IAAI,GAAG,OAAO;EAC1E,MAAM,SAAS,KAAK,MAAM;EAC1B,MAAM,WAAW,KAAK,MAAM;EAC5B,IAAI,UAAU,UAAU;GACtB,MAAM,QAAQ,WAAW,IAAI,QAAQ,QAAQ,cAAc;GAC3D,IAAI,cAAc,OAAO,QAAQ,QAAQ,GAAG,OAAO;EACrD;EACA,IAAI,KAAK,cAAc,GAAG,GAAG,OAAO;EACpC,OAAO;CACT;CAEA,cAAsB,KAA+B;EACnD,IAAI,IAAI,WAAW,SAAS,IAAI,WAAW,QAAQ,OAAO;EAE1D,IADa,IAAI,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,SACxC,WAAW,OAAO,GAAG,OAAO;EACrC,MAAM,SAAS,IAAI,QAAQ,UAAU;EACrC,OAAO,OAAO,SAAS,WAAW,KAAK,OAAO,SAAS,KAAK;CAC9D;AACF;AAEA,SAAgB,kBAAkB,KAAsB,MAAqB;CAC3E,MAAM,YAAY,QAAQ,IAAI,OAAO;CACrC,IAAI,OAAO,cAAc,UAAU;CACnC,MAAM,YAAY,aAAa;CAC/B,IAAI,QAAQ,OAAO;CACnB,KAAK,MAAM,QAAQ,CAAC,UAAU,SAAS,GAAY;EACjD,MAAM,QAAQ,IAAI,QAAQ;EAC1B,IAAI,OAAO,UAAU,UAAU;EAC/B,IAAI;GACF,MAAM,MAAM,IAAI,IAAI,KAAK;GACzB,IAAI,OAAO;GACX,IAAI,QAAQ,QAAQ,IAAI,SAAS;EACnC,QAAQ,CAAC;CACX;AACF"}
1
+ {"version":3,"file":"gate.js","names":[],"sources":["../../src/auth/gate.ts"],"sourcesContent":["import type { IncomingMessage } from 'node:http'\nimport { isLoopbackAddress, isLoopbackRequest } from './loopback.js'\nimport { readCookie, SESSION_COOKIE, verifySession } from './session.js'\nimport type { CredentialStore } from './credentials.js'\n\nexport type GateDecision = 'allow' | 'exempt' | 'redirect-login' | 'reject' | 'forbidden'\n\n/**\n * 认证路由(登录/状态)的可信来源判定。\n * - remoteAddress 必须回环:直连本机,或经可信反代(部署方边界)转发。\n * - 跨站浏览器请求一律拒绝(sec-fetch-site / Origin 与 Host 一致性)。\n * Host 头允许外部域名:预览反代会保留原始 Host,回环校验由\n * remoteAddress 与反代信任承担,登录后再经 rewriteToLoopback 归一。\n */\nexport function isTrustedAuthRequest(req: IncomingMessage): boolean {\n if (!isLoopbackAddress(req.socket.remoteAddress)) return false\n if (req.headers['sec-fetch-site'] === 'cross-site') return false\n const origin = req.headers.origin\n if (origin === undefined) return true\n if (typeof origin !== 'string' || !req.headers.host) return false\n try {\n return new URL(origin).host === new URL(`http://${req.headers.host}`).host\n } catch {\n return false\n }\n}\n\nexport class AuthGate {\n private isTrustedAuthRequest: ((req: IncomingMessage) => boolean) | undefined\n\n constructor(private readonly store: CredentialStore) {}\n\n setAuthRequestTrustCheck(check: (req: IncomingMessage) => boolean): void {\n this.isTrustedAuthRequest = check\n }\n\n decide(req: IncomingMessage): GateDecision {\n const path = new URL(req.url ?? '/', 'http://x').pathname\n if (path === '/login') return 'exempt'\n if (path === '/api/auth' || path.startsWith('/api/auth/')) {\n const trusted = this.isTrustedAuthRequest\n ? this.isTrustedAuthRequest(req)\n : isTrustedAuthRequest(req)\n return trusted ? 'exempt' : 'forbidden'\n }\n if (isLoopbackRequest(req.socket.remoteAddress, req.headers.host)) return 'allow'\n const secret = this.store.sessionSecret\n const username = this.store.username\n if (secret && username) {\n const value = readCookie(req.headers.cookie, SESSION_COOKIE)\n if (verifySession(value, secret, username)) return 'allow'\n }\n if (this.isPageRequest(req)) return 'redirect-login'\n return 'reject'\n }\n\n private isPageRequest(req: IncomingMessage): boolean {\n if (req.method !== 'GET' && req.method !== 'HEAD') return false\n const path = new URL(req.url ?? '/', 'http://x').pathname\n if (path.startsWith('/api/')) return false\n const accept = req.headers.accept ?? ''\n return accept.includes('text/html') || accept.includes('*/*')\n }\n}\n\nexport function rewriteToLoopback(req: IncomingMessage, port?: number): void {\n const localPort = port ?? req.socket.localPort\n if (typeof localPort !== 'number') return\n const authority = `127.0.0.1:${localPort}`\n req.headers.host = authority\n for (const name of ['origin', 'referer'] as const) {\n const value = req.headers[name]\n if (typeof value !== 'string') continue\n try {\n const url = new URL(value)\n url.host = authority\n req.headers[name] = url.toString()\n } catch {}\n }\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,qBAAqB,KAA+B;CAClE,IAAI,CAAC,kBAAkB,IAAI,OAAO,aAAa,GAAG,OAAO;CACzD,IAAI,IAAI,QAAQ,sBAAsB,cAAc,OAAO;CAC3D,MAAM,SAAS,IAAI,QAAQ;CAC3B,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI,OAAO,WAAW,YAAY,CAAC,IAAI,QAAQ,MAAM,OAAO;CAC5D,IAAI;EACF,OAAO,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,UAAU,IAAI,QAAQ,MAAM,CAAC,CAAC;CACxE,QAAQ;EACN,OAAO;CACT;AACF;AAEA,IAAa,WAAb,MAAsB;CAGS;CAF7B;CAEA,YAAY,OAAyC;EAAxB,KAAA,QAAA;CAAyB;CAEtD,yBAAyB,OAAgD;EACvE,KAAK,uBAAuB;CAC9B;CAEA,OAAO,KAAoC;EACzC,MAAM,OAAO,IAAI,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC;EACjD,IAAI,SAAS,UAAU,OAAO;EAC9B,IAAI,SAAS,eAAe,KAAK,WAAW,YAAY,GAItD,QAHgB,KAAK,uBACjB,KAAK,qBAAqB,GAAG,IAC7B,qBAAqB,GAAG,KACX,WAAW;EAE9B,IAAI,kBAAkB,IAAI,OAAO,eAAe,IAAI,QAAQ,IAAI,GAAG,OAAO;EAC1E,MAAM,SAAS,KAAK,MAAM;EAC1B,MAAM,WAAW,KAAK,MAAM;EAC5B,IAAI,UAAU,UAAU;GACtB,MAAM,QAAQ,WAAW,IAAI,QAAQ,QAAQ,cAAc;GAC3D,IAAI,cAAc,OAAO,QAAQ,QAAQ,GAAG,OAAO;EACrD;EACA,IAAI,KAAK,cAAc,GAAG,GAAG,OAAO;EACpC,OAAO;CACT;CAEA,cAAsB,KAA+B;EACnD,IAAI,IAAI,WAAW,SAAS,IAAI,WAAW,QAAQ,OAAO;EAE1D,IADa,IAAI,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,SACxC,WAAW,OAAO,GAAG,OAAO;EACrC,MAAM,SAAS,IAAI,QAAQ,UAAU;EACrC,OAAO,OAAO,SAAS,WAAW,KAAK,OAAO,SAAS,KAAK;CAC9D;AACF;AAEA,SAAgB,kBAAkB,KAAsB,MAAqB;CAC3E,MAAM,YAAY,QAAQ,IAAI,OAAO;CACrC,IAAI,OAAO,cAAc,UAAU;CACnC,MAAM,YAAY,aAAa;CAC/B,IAAI,QAAQ,OAAO;CACnB,KAAK,MAAM,QAAQ,CAAC,UAAU,SAAS,GAAY;EACjD,MAAM,QAAQ,IAAI,QAAQ;EAC1B,IAAI,OAAO,UAAU,UAAU;EAC/B,IAAI;GACF,MAAM,MAAM,IAAI,IAAI,KAAK;GACzB,IAAI,OAAO;GACX,IAAI,QAAQ,QAAQ,IAAI,SAAS;EACnC,QAAQ,CAAC;CACX;AACF"}
package/lib/auth/index.js CHANGED
@@ -1,25 +1,57 @@
1
1
  import { sharedCredentialStore } from "./credentials.js";
2
- import { AuthGate } from "./gate.js";
2
+ import { AuthGate, isTrustedAuthRequest } from "./gate.js";
3
3
  import { decorateWebServer } from "./decorate-webserver.js";
4
4
  import { installLoopbackCompat } from "./loopback-compat.js";
5
5
  import { LoginRateLimiter } from "./ratelimit.js";
6
6
  import { registerAuthRoutes } from "./routes.js";
7
7
  import { createRequire } from "node:module";
8
- import { readFileSync, readdirSync } from "node:fs";
8
+ import { readFileSync, readdirSync, realpathSync } from "node:fs";
9
9
  import { basename, dirname, join } from "node:path";
10
+ import { fileURLToPath } from "node:url";
10
11
  //#region src/auth/index.ts
11
12
  const name = "dshb-auth";
12
13
  const inject = ["webServer"];
14
+ /**
15
+ * 定位 dshb 实际安装所在 profile 的 node_modules。
16
+ * link 安装(开发预览)下 ESM 真实路径解析会把 import.meta.url 指向仓库源码,
17
+ * 由此向上 resolve 会命中仓库工作区的 @deepseek-ai/dsh-web-app 副本;服务器
18
+ * 实际服务的却是 profile 内那份。通过 DSH_HOME/profiles 扫描 realpath 匹配
19
+ * 找回安装位置;常规安装(真实文件就在 profile 内)时现有解析本就正确。
20
+ */
21
+ function profileNodeModulesFor(realSelfPath) {
22
+ const home = process.env.DSH_HOME;
23
+ if (!home) return void 0;
24
+ const profilesDir = join(home, "profiles");
25
+ let names;
26
+ try {
27
+ names = readdirSync(profilesDir);
28
+ } catch {
29
+ return;
30
+ }
31
+ for (const name of names) {
32
+ const installed = join(profilesDir, name, "node_modules", "@artenx", "dshb");
33
+ try {
34
+ const realInstalled = realpathSync(installed);
35
+ if (realInstalled === realSelfPath || realSelfPath.startsWith(`${realInstalled}/`)) return join(profilesDir, name, "node_modules");
36
+ } catch {}
37
+ }
38
+ }
13
39
  function registerFrontendBootRaceWorkaround(ctx) {
14
40
  try {
15
41
  const resolver = createRequire(import.meta.url);
42
+ const profileModules = profileNodeModulesFor(realpathSync(fileURLToPath(import.meta.url)));
43
+ const webAppResolvers = [];
44
+ if (profileModules) webAppResolvers.push(() => resolver.resolve("@deepseek-ai/dsh-web-app/package.json", { paths: [profileModules] }));
45
+ if (process.argv[1]) webAppResolvers.push(() => createRequire(realpathSync(process.argv[1])).resolve("@deepseek-ai/dsh-web-app/package.json"));
46
+ webAppResolvers.push(() => resolver.resolve("@deepseek-ai/dsh-web-app/package.json"));
47
+ let webAppManifest;
48
+ for (const resolveWebApp of webAppResolvers) try {
49
+ webAppManifest = resolveWebApp();
50
+ break;
51
+ } catch {}
16
52
  let manifestPath;
17
- try {
18
- const webAppManifest = resolver.resolve("@deepseek-ai/dsh-web-app/package.json");
19
- manifestPath = createRequire(webAppManifest).resolve("@deepseek-ai/dsh-web-frontend/package.json");
20
- } catch {
21
- manifestPath = resolver.resolve("@deepseek-ai/dsh-web-frontend/package.json", { paths: [process.cwd()] });
22
- }
53
+ if (webAppManifest) manifestPath = createRequire(webAppManifest).resolve("@deepseek-ai/dsh-web-frontend/package.json");
54
+ else manifestPath = resolver.resolve("@deepseek-ai/dsh-web-frontend/package.json", { paths: [process.cwd()] });
23
55
  const assetDir = join(dirname(manifestPath), "dist", "assets");
24
56
  const assetName = readdirSync(assetDir).find((name) => /^index-.*\.js$/.test(name));
25
57
  if (!assetName) return;
@@ -62,7 +94,8 @@ function apply(ctx) {
62
94
  }
63
95
  if (conn && typeof conn.requestRejection === "function") gate.setAuthRequestTrustCheck((req) => {
64
96
  const rejection = conn.requestRejection(req);
65
- return rejection === void 0 || rejection === 401;
97
+ if (rejection === void 0 || rejection === 401) return true;
98
+ return isTrustedAuthRequest(req);
66
99
  });
67
100
  return () => {
68
101
  if (!auth || !installedNeutralizer) return;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/auth/index.ts"],"sourcesContent":["import { readFileSync, readdirSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { basename, dirname, join } from 'node:path'\nimport type { IncomingMessage } from 'node:http'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { sharedCredentialStore } from './credentials.js'\nimport { decorateWebServer } from './decorate-webserver.js'\nimport { AuthGate } from './gate.js'\nimport { installLoopbackCompat } from './loopback-compat.js'\nimport { LoginRateLimiter } from './ratelimit.js'\nimport { registerAuthRoutes } from './routes.js'\n\nexport const name = 'dshb-auth'\n\nexport const inject = ['webServer']\n\nfunction registerFrontendBootRaceWorkaround(ctx: Context): void {\n try {\n // Resolve the frontend through the same `dsh-web-app` bundle the webserver\n // loads, so the patched hashed asset is the one the static fallback serves.\n // `process.cwd()` may hold a different installation whose asset filename\n // the server never requests, leaving the served bundle unpatched.\n const resolver = createRequire(import.meta.url)\n let manifestPath: string\n try {\n const webAppManifest = resolver.resolve('@deepseek-ai/dsh-web-app/package.json')\n manifestPath = createRequire(webAppManifest).resolve('@deepseek-ai/dsh-web-frontend/package.json')\n } catch {\n manifestPath = resolver.resolve('@deepseek-ai/dsh-web-frontend/package.json', {\n paths: [process.cwd()],\n })\n }\n const assetDir = join(dirname(manifestPath), 'dist', 'assets')\n const assetName = readdirSync(assetDir).find((name) => /^index-.*\\.js$/.test(name))\n if (!assetName) return\n\n const assetPath = join(assetDir, assetName)\n const source = readFileSync(assetPath, 'utf8')\n // DSH asserts before api-remotes' dynamic remote namespace fibers settle.\n // Delay the assertion so mountApp sees the complete client graph; real\n // activation failures still throw after the bounded wait. The minified\n // identifiers vary between builds, and 0.1.7 moved the assertion into nE.\n const legacyPatch = source.replace(\n /await ([A-Za-z_$][\\w$]*)\\.await\\(\\),this\\.assertEntriesActive\\(([A-Za-z_$][\\w$]*)\\)/,\n 'await $1.await(),await new Promise(r=>setTimeout(r,8000)),this.assertEntriesActive($2)',\n )\n const patched = legacyPatch !== source\n ? legacyPatch\n : source.replace(\n /await ([A-Za-z_$][\\w$]*)\\.await\\(\\),([A-Za-z_$][\\w$]*)\\(([A-Za-z_$][\\w$]*),([A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*)\\)/,\n 'await $1.await(),await new Promise(r=>setTimeout(r,8000)),$2($3,$4)',\n )\n if (patched === source) return\n\n ctx.effect(() =>\n ctx.webServer.register({\n kind: 'exact',\n path: `/assets/${basename(assetPath)}`,\n handler: (_req, res) => {\n res.writeHead(200, {\n 'cache-control': 'no-store',\n 'content-type': 'application/javascript; charset=utf-8',\n })\n res.end(patched)\n },\n }),\n )\n } catch {\n // Upstream assets are optional from DSHB's perspective. A missing or changed\n // frontend layout simply skips this version-specific workaround.\n }\n}\n\nexport function apply(ctx: Context): void {\n const store = sharedCredentialStore()\n const gate = new AuthGate(store)\n ctx.effect(() => decorateWebServer(ctx.webServer, store, gate))\n registerFrontendBootRaceWorkaround(ctx)\n ctx.effect(() => ctx.webServer.tapIndex(installLoopbackCompat))\n registerAuthRoutes(ctx, store, new LoginRateLimiter())\n\n // DSH 0.1.5 introduced a browser-auth fence on the connection package: the SPA\n // fallback calls connection.authorizeIndex() on \"/\" (mints/checks DSH's own\n // launch-token cookie), and /api routes run requestRejection() which 401s when\n // that DSH cookie is absent. DSHB uses its own session cookie and must stay the\n // sole auth gate (DSH 0.1.1 had no such connection fence, so DSHB worked there).\n // Neutralize the connection's browserAuth.isAuthenticated check so DSH's fence\n // never rejects a DSHB-authenticated (or loopback) request; DSHB's gate still\n // rejects unauthenticated access to gated routes. Property is read at request\n // time, so installing it once after connection is ready suffices.\n ctx.inject(['connection'], (connCtx: Context) => {\n connCtx.effect(() => {\n const conn = (connCtx as unknown as {\n connection?: {\n browserAuth?: { isAuthenticated?: (...a: unknown[]) => unknown; __dshbNeutralized?: true }\n requestRejection?: (request: IncomingMessage) => number | undefined\n }\n }).connection\n const auth = conn?.browserAuth\n const originalIsAuthenticated = auth?.isAuthenticated\n const neutralizedIsAuthenticated = () => true\n let installedNeutralizer = false\n if (auth && typeof originalIsAuthenticated === 'function' && !auth.__dshbNeutralized) {\n auth.isAuthenticated = neutralizedIsAuthenticated\n auth.__dshbNeutralized = true\n installedNeutralizer = true\n }\n if (conn && typeof conn.requestRejection === 'function') {\n gate.setAuthRequestTrustCheck((req) => {\n const rejection = conn.requestRejection!(req)\n // DSH 401 is its browser-cookie gate; DSHB owns that check for these routes.\n return rejection === undefined || rejection === 401\n })\n }\n return () => {\n if (!auth || !installedNeutralizer) return\n if (auth.isAuthenticated === neutralizedIsAuthenticated && originalIsAuthenticated) {\n auth.isAuthenticated = originalIsAuthenticated\n }\n delete auth.__dshbNeutralized\n }\n })\n })\n}\n"],"mappings":";;;;;;;;;;AAYA,MAAa,OAAO;AAE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AAqB;EAC/C,QAAQ,aAAa;GACnB,MAAM,OAAQ,QAKX;GACH,MAAM,OAAO,MAAM;GACnB,MAAM,0BAA0B,MAAM;GACtC,MAAM,mCAAmC;GACzC,IAAI,uBAAuB;GAC3B,IAAI,QAAQ,OAAO,4BAA4B,cAAc,CAAC,KAAK,mBAAmB;IACpF,KAAK,kBAAkB;IACvB,KAAK,oBAAoB;IACzB,uBAAuB;GACzB;GACA,IAAI,QAAQ,OAAO,KAAK,qBAAqB,YAC3C,KAAK,0BAA0B,QAAQ;IACrC,MAAM,YAAY,KAAK,iBAAkB,GAAG;IAE5C,OAAO,cAAc,KAAA,KAAa,cAAc;GAClD,CAAC;GAEH,aAAa;IACX,IAAI,CAAC,QAAQ,CAAC,sBAAsB;IACpC,IAAI,KAAK,oBAAoB,8BAA8B,yBACzD,KAAK,kBAAkB;IAEzB,OAAO,KAAK;GACd;EACF,CAAC;CACH,CAAC;AACH"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/auth/index.ts"],"sourcesContent":["import { readFileSync, readdirSync, realpathSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { basename, dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { IncomingMessage } from 'node:http'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { sharedCredentialStore } from './credentials.js'\nimport { decorateWebServer } from './decorate-webserver.js'\nimport { AuthGate, isTrustedAuthRequest } from './gate.js'\nimport { installLoopbackCompat } from './loopback-compat.js'\nimport { LoginRateLimiter } from './ratelimit.js'\nimport { registerAuthRoutes } from './routes.js'\n\nexport const name = 'dshb-auth'\n\nexport const inject = ['webServer']\n\n/**\n * 定位 dshb 实际安装所在 profile 的 node_modules。\n * link 安装(开发预览)下 ESM 真实路径解析会把 import.meta.url 指向仓库源码,\n * 由此向上 resolve 会命中仓库工作区的 @deepseek-ai/dsh-web-app 副本;服务器\n * 实际服务的却是 profile 内那份。通过 DSH_HOME/profiles 扫描 realpath 匹配\n * 找回安装位置;常规安装(真实文件就在 profile 内)时现有解析本就正确。\n */\nfunction profileNodeModulesFor(realSelfPath: string): string | undefined {\n const home = process.env.DSH_HOME\n if (!home) return undefined\n const profilesDir = join(home, 'profiles')\n let names: string[]\n try {\n names = readdirSync(profilesDir)\n } catch {\n return undefined\n }\n for (const name of names) {\n const installed = join(profilesDir, name, 'node_modules', '@artenx', 'dshb')\n try {\n const realInstalled = realpathSync(installed)\n if (realInstalled === realSelfPath || realSelfPath.startsWith(`${realInstalled}/`)) {\n return join(profilesDir, name, 'node_modules')\n }\n } catch {\n /* profile without this package */\n }\n }\n return undefined\n}\n\nfunction registerFrontendBootRaceWorkaround(ctx: Context): void {\n try {\n // Resolve the frontend through the same runtime package tree the webserver\n // loads, so the patched hashed asset is the one the static fallback serves.\n // A linked plugin profile may contain only @artenx/dshb; its DSH executable\n // supplies the actual @deepseek-ai bundle tree.\n const resolver = createRequire(import.meta.url)\n const realSelf = realpathSync(fileURLToPath(import.meta.url))\n const profileModules = profileNodeModulesFor(realSelf)\n const webAppResolvers: Array<() => string> = []\n if (profileModules) {\n webAppResolvers.push(() => resolver.resolve('@deepseek-ai/dsh-web-app/package.json', { paths: [profileModules] }))\n }\n if (process.argv[1]) {\n webAppResolvers.push(() => createRequire(realpathSync(process.argv[1]!)).resolve('@deepseek-ai/dsh-web-app/package.json'))\n }\n webAppResolvers.push(() => resolver.resolve('@deepseek-ai/dsh-web-app/package.json'))\n let webAppManifest: string | undefined\n for (const resolveWebApp of webAppResolvers) {\n try {\n webAppManifest = resolveWebApp()\n break\n } catch {\n // Try the next runtime-owned package tree.\n }\n }\n let manifestPath: string\n if (webAppManifest) {\n manifestPath = createRequire(webAppManifest).resolve('@deepseek-ai/dsh-web-frontend/package.json')\n } else {\n manifestPath = resolver.resolve('@deepseek-ai/dsh-web-frontend/package.json', {\n paths: [process.cwd()],\n })\n }\n const assetDir = join(dirname(manifestPath), 'dist', 'assets')\n const assetName = readdirSync(assetDir).find((name) => /^index-.*\\.js$/.test(name))\n if (!assetName) return\n\n const assetPath = join(assetDir, assetName)\n const source = readFileSync(assetPath, 'utf8')\n // DSH asserts before api-remotes' dynamic remote namespace fibers settle.\n // Delay the assertion so mountApp sees the complete client graph; real\n // activation failures still throw after the bounded wait. The minified\n // identifiers vary between builds, and 0.1.7 moved the assertion into nE.\n const legacyPatch = source.replace(\n /await ([A-Za-z_$][\\w$]*)\\.await\\(\\),this\\.assertEntriesActive\\(([A-Za-z_$][\\w$]*)\\)/,\n 'await $1.await(),await new Promise(r=>setTimeout(r,8000)),this.assertEntriesActive($2)',\n )\n const patched = legacyPatch !== source\n ? legacyPatch\n : source.replace(\n /await ([A-Za-z_$][\\w$]*)\\.await\\(\\),([A-Za-z_$][\\w$]*)\\(([A-Za-z_$][\\w$]*),([A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*)\\)/,\n 'await $1.await(),await new Promise(r=>setTimeout(r,8000)),$2($3,$4)',\n )\n if (patched === source) return\n\n ctx.effect(() =>\n ctx.webServer.register({\n kind: 'exact',\n path: `/assets/${basename(assetPath)}`,\n handler: (_req, res) => {\n res.writeHead(200, {\n 'cache-control': 'no-store',\n 'content-type': 'application/javascript; charset=utf-8',\n })\n res.end(patched)\n },\n }),\n )\n } catch {\n // Upstream assets are optional from DSHB's perspective. A missing or changed\n // frontend layout simply skips this version-specific workaround.\n }\n}\n\nexport function apply(ctx: Context): void {\n const store = sharedCredentialStore()\n const gate = new AuthGate(store)\n ctx.effect(() => decorateWebServer(ctx.webServer, store, gate))\n registerFrontendBootRaceWorkaround(ctx)\n ctx.effect(() => ctx.webServer.tapIndex(installLoopbackCompat))\n registerAuthRoutes(ctx, store, new LoginRateLimiter())\n\n // DSH 0.1.5 introduced a browser-auth fence on the connection package: the SPA\n // fallback calls connection.authorizeIndex() on \"/\" (mints/checks DSH's own\n // launch-token cookie), and /api routes run requestRejection() which 401s when\n // that DSH cookie is absent. DSHB uses its own session cookie and must stay the\n // sole auth gate (DSH 0.1.1 had no such connection fence, so DSHB worked there).\n // Neutralize the connection's browserAuth.isAuthenticated check so DSH's fence\n // never rejects a DSHB-authenticated (or loopback) request; DSHB's gate still\n // rejects unauthenticated access to gated routes. Property is read at request\n // time, so installing it once after connection is ready suffices.\n ctx.inject(['connection'], (connCtx: Context) => {\n connCtx.effect(() => {\n const conn = (connCtx as unknown as {\n connection?: {\n browserAuth?: { isAuthenticated?: (...a: unknown[]) => unknown; __dshbNeutralized?: true }\n requestRejection?: (request: IncomingMessage) => number | undefined\n }\n }).connection\n const auth = conn?.browserAuth\n const originalIsAuthenticated = auth?.isAuthenticated\n const neutralizedIsAuthenticated = () => true\n let installedNeutralizer = false\n if (auth && typeof originalIsAuthenticated === 'function' && !auth.__dshbNeutralized) {\n auth.isAuthenticated = neutralizedIsAuthenticated\n auth.__dshbNeutralized = true\n installedNeutralizer = true\n }\n if (conn && typeof conn.requestRejection === 'function') {\n gate.setAuthRequestTrustCheck((req) => {\n const rejection = conn.requestRejection!(req)\n // DSH 401 is its browser-cookie gate; DSHB owns that check for these routes.\n if (rejection === undefined || rejection === 401) return true\n // DSH fence rejects non-loopback authorities (403). Preview reverse\n // proxies keep the external Host header, so DSHB falls back to its own\n // source checks (loopback peer address + cross-site protection); the\n // session gate still owns every authenticated route after login.\n return isTrustedAuthRequest(req)\n })\n }\n return () => {\n if (!auth || !installedNeutralizer) return\n if (auth.isAuthenticated === neutralizedIsAuthenticated && originalIsAuthenticated) {\n auth.isAuthenticated = originalIsAuthenticated\n }\n delete auth.__dshbNeutralized\n }\n })\n })\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,OAAO;AAEpB,MAAa,SAAS,CAAC,WAAW;;;;;;;;AASlC,SAAS,sBAAsB,cAA0C;CACvE,MAAM,OAAO,QAAQ,IAAI;CACzB,IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,MAAM,cAAc,KAAK,MAAM,UAAU;CACzC,IAAI;CACJ,IAAI;EACF,QAAQ,YAAY,WAAW;CACjC,QA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CAAC;CACH,CAAC;AACH"}
File without changes
@@ -0,0 +1,119 @@
1
+ import { isNonNegativeSafeInteger, isRecord } from "./core/sync/model.js";
2
+ import "./core/sync/protocol.js";
3
+ import { posix } from "node:path";
4
+ //#region src/core/sync/catalog.ts
5
+ const MAX_CATALOG_ITEMS = 1e4;
6
+ function parseOrigin(value) {
7
+ if (!isRecord(value) || Object.keys(value).some((key) => key !== "originInstanceId" && key !== "originEntityId") || typeof value.originInstanceId !== "string" || value.originInstanceId.length === 0 || value.originInstanceId.length > 512 || typeof value.originEntityId !== "string" || value.originEntityId.length === 0 || value.originEntityId.length > 512 || /[\u0000-\u001f\u007f]/.test(value.originInstanceId) || /[\u0000-\u001f\u007f]/.test(value.originEntityId)) throw new Error("sync catalog origin is invalid");
8
+ return {
9
+ originInstanceId: value.originInstanceId,
10
+ originEntityId: value.originEntityId
11
+ };
12
+ }
13
+ function validateCatalogNode(value) {
14
+ if (!isRecord(value) || Object.keys(value).some((key) => ![
15
+ "origin",
16
+ "name",
17
+ "type"
18
+ ].includes(key)) || typeof value.name !== "string" || !value.name.trim() || value.name.length > 128 || value.type !== "remote-ssh" && value.type !== "remote-docker") throw new Error("sync catalog node is invalid");
19
+ return {
20
+ origin: parseOrigin(value.origin),
21
+ name: value.name,
22
+ type: value.type
23
+ };
24
+ }
25
+ function validateCatalogWorkspace(value) {
26
+ if (!isRecord(value) || Object.keys(value).some((key) => ![
27
+ "origin",
28
+ "nodeOrigin",
29
+ "remotePath",
30
+ "title"
31
+ ].includes(key)) || typeof value.remotePath !== "string" || value.remotePath.length > 4096 || !posix.isAbsolute(value.remotePath) || posix.normalize(value.remotePath) !== value.remotePath || typeof value.title !== "string" || value.title.length > 512) throw new Error("sync catalog workspace is invalid");
32
+ return {
33
+ origin: parseOrigin(value.origin),
34
+ nodeOrigin: parseOrigin(value.nodeOrigin),
35
+ remotePath: value.remotePath,
36
+ title: value.title
37
+ };
38
+ }
39
+ function validateCatalogSession(value) {
40
+ if (!isRecord(value) || Object.keys(value).some((key) => ![
41
+ "origin",
42
+ "workspaceOrigin",
43
+ "workspaceRemotePath",
44
+ "nodeOrigin",
45
+ "sessionId",
46
+ "sizeBytes",
47
+ "branchId",
48
+ "deleted"
49
+ ].includes(key)) || typeof value.sessionId !== "string" || !value.sessionId || value.sessionId.length > 512 || value.workspaceRemotePath !== void 0 && (typeof value.workspaceRemotePath !== "string" || value.workspaceRemotePath.length > 4096 || !posix.isAbsolute(value.workspaceRemotePath) || posix.normalize(value.workspaceRemotePath) !== value.workspaceRemotePath) || value.sizeBytes !== void 0 && !isNonNegativeSafeInteger(value.sizeBytes) || value.branchId !== void 0 && (typeof value.branchId !== "string" || !/^b-[a-f0-9]{32}$/.test(value.branchId)) || value.deleted !== void 0 && typeof value.deleted !== "boolean") throw new Error("sync catalog session is invalid");
50
+ return {
51
+ origin: parseOrigin(value.origin),
52
+ ...value.workspaceOrigin === void 0 ? {} : { workspaceOrigin: parseOrigin(value.workspaceOrigin) },
53
+ ...value.workspaceRemotePath === void 0 ? {} : { workspaceRemotePath: value.workspaceRemotePath },
54
+ ...value.nodeOrigin === void 0 ? {} : { nodeOrigin: parseOrigin(value.nodeOrigin) },
55
+ sessionId: value.sessionId,
56
+ ...value.sizeBytes === void 0 ? {} : { sizeBytes: value.sizeBytes },
57
+ ...value.branchId === void 0 ? {} : { branchId: value.branchId },
58
+ ...value.deleted === void 0 ? {} : { deleted: value.deleted }
59
+ };
60
+ }
61
+ function validateSyncCatalog(value) {
62
+ if (!isRecord(value) || value.protocolVersion !== 1 || typeof value.instanceId !== "string" || !/^i-[a-f0-9]{32}$/.test(value.instanceId) || !Array.isArray(value.nodes) || !Array.isArray(value.workspaces) || !Array.isArray(value.sessions) || value.nodes.length > MAX_CATALOG_ITEMS || value.workspaces.length > MAX_CATALOG_ITEMS || value.sessions.length > MAX_CATALOG_ITEMS || Object.keys(value).some((key) => ![
63
+ "protocolVersion",
64
+ "instanceId",
65
+ "nodes",
66
+ "workspaces",
67
+ "sessions"
68
+ ].includes(key))) throw new Error("sync catalog is invalid");
69
+ const catalog = {
70
+ protocolVersion: 1,
71
+ instanceId: value.instanceId,
72
+ nodes: value.nodes.map(validateCatalogNode),
73
+ workspaces: value.workspaces.map(validateCatalogWorkspace),
74
+ sessions: value.sessions.map(validateCatalogSession)
75
+ };
76
+ const keys = [
77
+ ...catalog.nodes.map((item) => JSON.stringify([
78
+ "node",
79
+ item.origin.originInstanceId,
80
+ item.origin.originEntityId
81
+ ])),
82
+ ...catalog.workspaces.map((item) => JSON.stringify([
83
+ "workspace",
84
+ item.origin.originInstanceId,
85
+ item.origin.originEntityId,
86
+ item.remotePath
87
+ ])),
88
+ ...catalog.sessions.map((item) => JSON.stringify([
89
+ "session",
90
+ item.branchId ?? item.origin.originEntityId,
91
+ item.origin.originInstanceId
92
+ ]))
93
+ ];
94
+ if (new Set(keys).size !== keys.length) throw new Error("sync catalog contains duplicate records");
95
+ if (Buffer.byteLength(JSON.stringify(catalog), "utf8") > 134217728) throw new Error("sync catalog exceeds the transfer limit");
96
+ return catalog;
97
+ }
98
+ async function exportSyncCatalog(nodes, sessions) {
99
+ const manifest = await nodes.exportManifest();
100
+ const sessionCatalog = await sessions.exportCatalog();
101
+ return validateSyncCatalog({
102
+ protocolVersion: 1,
103
+ instanceId: manifest.instanceId,
104
+ nodes: manifest.records.flatMap((entry) => entry.profile && !entry.metadata.deleted ? [{
105
+ origin: {
106
+ originInstanceId: entry.metadata.originInstanceId,
107
+ originEntityId: entry.metadata.originEntityId
108
+ },
109
+ name: entry.profile.name,
110
+ type: entry.profile.type
111
+ }] : []),
112
+ workspaces: sessionCatalog.workspaces,
113
+ sessions: sessionCatalog.sessions
114
+ });
115
+ }
116
+ //#endregion
117
+ export { validateSyncCatalog as n, exportSyncCatalog as t };
118
+
119
+ //# sourceMappingURL=catalog-B3pDDoR4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-B3pDDoR4.js","names":[],"sources":["../src/core/sync/catalog.ts"],"sourcesContent":["import { posix } from 'node:path'\nimport type { SyncCatalog, SyncCatalogNode, SyncCatalogSession, SyncCatalogWorkspace, SyncOrigin } from './model.js'\nimport { isNonNegativeSafeInteger, isRecord } from './model.js'\nimport type { SyncNodeService } from './node-sync.js'\nimport type { SyncSessionService } from './session-sync.js'\nimport { MAX_SYNC_TRANSFER_BYTES } from './protocol.js'\n\nconst MAX_CATALOG_ITEMS = 10_000\n\nfunction parseOrigin(value: unknown): SyncOrigin {\n if (!isRecord(value) || Object.keys(value).some((key) => key !== 'originInstanceId' && key !== 'originEntityId') ||\n typeof value.originInstanceId !== 'string' || value.originInstanceId.length === 0 || value.originInstanceId.length > 512 ||\n typeof value.originEntityId !== 'string' || value.originEntityId.length === 0 || value.originEntityId.length > 512 ||\n /[\\u0000-\\u001f\\u007f]/.test(value.originInstanceId) || /[\\u0000-\\u001f\\u007f]/.test(value.originEntityId)) {\n throw new Error('sync catalog origin is invalid')\n }\n return { originInstanceId: value.originInstanceId, originEntityId: value.originEntityId }\n}\n\nfunction validateCatalogNode(value: unknown): SyncCatalogNode {\n if (!isRecord(value) || Object.keys(value).some((key) => !['origin', 'name', 'type'].includes(key)) ||\n typeof value.name !== 'string' || !value.name.trim() || value.name.length > 128 ||\n (value.type !== 'remote-ssh' && value.type !== 'remote-docker')) {\n throw new Error('sync catalog node is invalid')\n }\n return { origin: parseOrigin(value.origin), name: value.name, type: value.type }\n}\n\nfunction validateCatalogWorkspace(value: unknown): SyncCatalogWorkspace {\n if (!isRecord(value) || Object.keys(value).some((key) => !['origin', 'nodeOrigin', 'remotePath', 'title'].includes(key)) ||\n typeof value.remotePath !== 'string' || value.remotePath.length > 4096 || !posix.isAbsolute(value.remotePath) || posix.normalize(value.remotePath) !== value.remotePath ||\n typeof value.title !== 'string' || value.title.length > 512) {\n throw new Error('sync catalog workspace is invalid')\n }\n return {\n origin: parseOrigin(value.origin),\n nodeOrigin: parseOrigin(value.nodeOrigin),\n remotePath: value.remotePath,\n title: value.title,\n }\n}\n\nfunction validateCatalogSession(value: unknown): SyncCatalogSession {\n if (!isRecord(value) || Object.keys(value).some((key) => ![\n 'origin', 'workspaceOrigin', 'workspaceRemotePath', 'nodeOrigin', 'sessionId', 'sizeBytes', 'branchId', 'deleted',\n ].includes(key)) || typeof value.sessionId !== 'string' || !value.sessionId || value.sessionId.length > 512 ||\n (value.workspaceRemotePath !== undefined && (typeof value.workspaceRemotePath !== 'string' || value.workspaceRemotePath.length > 4096 ||\n !posix.isAbsolute(value.workspaceRemotePath) || posix.normalize(value.workspaceRemotePath) !== value.workspaceRemotePath)) ||\n (value.sizeBytes !== undefined && !isNonNegativeSafeInteger(value.sizeBytes)) ||\n (value.branchId !== undefined && (typeof value.branchId !== 'string' || !/^b-[a-f0-9]{32}$/.test(value.branchId))) ||\n (value.deleted !== undefined && typeof value.deleted !== 'boolean')) {\n throw new Error('sync catalog session is invalid')\n }\n return {\n origin: parseOrigin(value.origin),\n ...(value.workspaceOrigin === undefined ? {} : { workspaceOrigin: parseOrigin(value.workspaceOrigin) }),\n ...(value.workspaceRemotePath === undefined ? {} : { workspaceRemotePath: value.workspaceRemotePath as string }),\n ...(value.nodeOrigin === undefined ? {} : { nodeOrigin: parseOrigin(value.nodeOrigin) }),\n sessionId: value.sessionId,\n ...(value.sizeBytes === undefined ? {} : { sizeBytes: value.sizeBytes as number }),\n ...(value.branchId === undefined ? {} : { branchId: value.branchId }),\n ...(value.deleted === undefined ? {} : { deleted: value.deleted }),\n }\n}\n\nexport function validateSyncCatalog(value: unknown): SyncCatalog {\n if (!isRecord(value) || value.protocolVersion !== 1 || typeof value.instanceId !== 'string' ||\n !/^i-[a-f0-9]{32}$/.test(value.instanceId) || !Array.isArray(value.nodes) ||\n !Array.isArray(value.workspaces) || !Array.isArray(value.sessions) ||\n value.nodes.length > MAX_CATALOG_ITEMS || value.workspaces.length > MAX_CATALOG_ITEMS ||\n value.sessions.length > MAX_CATALOG_ITEMS || Object.keys(value).some((key) =>\n !['protocolVersion', 'instanceId', 'nodes', 'workspaces', 'sessions'].includes(key))) {\n throw new Error('sync catalog is invalid')\n }\n const catalog: SyncCatalog = {\n protocolVersion: 1,\n instanceId: value.instanceId,\n nodes: value.nodes.map(validateCatalogNode),\n workspaces: value.workspaces.map(validateCatalogWorkspace),\n sessions: value.sessions.map(validateCatalogSession),\n }\n const keys = [\n ...catalog.nodes.map((item) => JSON.stringify(['node', item.origin.originInstanceId, item.origin.originEntityId])),\n ...catalog.workspaces.map((item) => JSON.stringify(['workspace', item.origin.originInstanceId, item.origin.originEntityId, item.remotePath])),\n ...catalog.sessions.map((item) => JSON.stringify(['session', item.branchId ?? item.origin.originEntityId, item.origin.originInstanceId])),\n ]\n if (new Set(keys).size !== keys.length) throw new Error('sync catalog contains duplicate records')\n if (Buffer.byteLength(JSON.stringify(catalog), 'utf8') > MAX_SYNC_TRANSFER_BYTES) throw new Error('sync catalog exceeds the transfer limit')\n return catalog\n}\n\nexport async function exportSyncCatalog(nodes: SyncNodeService, sessions: SyncSessionService): Promise<SyncCatalog> {\n const manifest = await nodes.exportManifest()\n const sessionCatalog = await sessions.exportCatalog()\n return validateSyncCatalog({\n protocolVersion: 1,\n instanceId: manifest.instanceId,\n nodes: manifest.records.flatMap((entry) => entry.profile && !entry.metadata.deleted\n ? [{\n origin: { originInstanceId: entry.metadata.originInstanceId, originEntityId: entry.metadata.originEntityId },\n name: entry.profile.name,\n type: entry.profile.type,\n }]\n : []),\n workspaces: sessionCatalog.workspaces,\n sessions: sessionCatalog.sessions,\n })\n}\n"],"mappings":";;;;AAOA,MAAM,oBAAoB;AAE1B,SAAS,YAAY,OAA4B;CAC/C,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,KAAK,KAAK,CAAC,CAAC,MAAM,QAAQ,QAAQ,sBAAsB,QAAQ,gBAAgB,KAC7G,OAAO,MAAM,qBAAqB,YAAY,MAAM,iBAAiB,WAAW,KAAK,MAAM,iBAAiB,SAAS,OACrH,OAAO,MAAM,mBAAmB,YAAY,M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