autodev-cli 1.4.0 → 1.4.3

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 (237) hide show
  1. package/bin/autodev.js +0 -0
  2. package/out/agentBackup/archive.d.ts +44 -0
  3. package/out/agentBackup/archive.js +131 -0
  4. package/out/agentBackup/archive.js.map +1 -0
  5. package/out/agentBackup/export.d.ts +18 -0
  6. package/out/agentBackup/export.js +92 -0
  7. package/out/agentBackup/export.js.map +1 -0
  8. package/out/agentBackup/import.d.ts +21 -0
  9. package/out/agentBackup/import.js +40 -0
  10. package/out/agentBackup/import.js.map +1 -0
  11. package/out/agentBackup/index.d.ts +6 -0
  12. package/out/agentBackup/index.js +11 -0
  13. package/out/agentBackup/index.js.map +1 -0
  14. package/out/agentBackup/layout.d.ts +30 -0
  15. package/out/agentBackup/layout.js +126 -0
  16. package/out/agentBackup/layout.js.map +1 -0
  17. package/out/agentBackup/manifest.d.ts +24 -0
  18. package/out/agentBackup/manifest.js +70 -0
  19. package/out/agentBackup/manifest.js.map +1 -0
  20. package/out/agentBackup/opencodeDb.d.ts +20 -0
  21. package/out/agentBackup/opencodeDb.js +213 -0
  22. package/out/agentBackup/opencodeDb.js.map +1 -0
  23. package/out/agentBackup/sessionProviders.d.ts +35 -0
  24. package/out/agentBackup/sessionProviders.js +263 -0
  25. package/out/agentBackup/sessionProviders.js.map +1 -0
  26. package/out/agentBackup/upload.d.ts +9 -0
  27. package/out/agentBackup/upload.js +121 -0
  28. package/out/agentBackup/upload.js.map +1 -0
  29. package/out/cli.d.ts +1 -0
  30. package/out/cli.js +8 -0
  31. package/out/cli.js.map +1 -1
  32. package/out/cliExit.d.ts +34 -0
  33. package/out/cliExit.js +159 -0
  34. package/out/cliExit.js.map +1 -0
  35. package/out/commands/config.d.ts +2 -0
  36. package/out/commands/config.js +7 -7
  37. package/out/commands/config.js.map +1 -1
  38. package/out/commands/connect.d.ts +2 -0
  39. package/out/commands/connect.js +11 -0
  40. package/out/commands/connect.js.map +1 -1
  41. package/out/commands/export.d.ts +2 -0
  42. package/out/commands/export.js +79 -0
  43. package/out/commands/export.js.map +1 -0
  44. package/out/commands/import.d.ts +2 -0
  45. package/out/commands/import.js +92 -0
  46. package/out/commands/import.js.map +1 -0
  47. package/out/commands/init.d.ts +16 -0
  48. package/out/commands/init.js +9 -5
  49. package/out/commands/init.js.map +1 -1
  50. package/out/commands/resume.d.ts +2 -0
  51. package/out/commands/resume.js +65 -0
  52. package/out/commands/resume.js.map +1 -0
  53. package/out/commands/sessions.d.ts +2 -0
  54. package/out/commands/sessions.js +64 -0
  55. package/out/commands/sessions.js.map +1 -0
  56. package/out/commands/start.d.ts +2 -0
  57. package/out/commands/start.js +40 -7
  58. package/out/commands/start.js.map +1 -1
  59. package/out/commands/status.d.ts +2 -0
  60. package/out/commands/status.js +3 -3
  61. package/out/commands/status.js.map +1 -1
  62. package/out/commands/tailOutput.d.ts +12 -0
  63. package/out/commands/up.d.ts +3 -0
  64. package/out/configManager.d.ts +42 -0
  65. package/out/configManager.js +430 -0
  66. package/out/configManager.js.map +1 -0
  67. package/out/connect.d.ts +4 -0
  68. package/out/connect.js +7 -7
  69. package/out/connect.js.map +1 -1
  70. package/out/core/adapters.d.ts +34 -0
  71. package/out/core/adapters.js +84 -0
  72. package/out/core/adapters.js.map +1 -0
  73. package/out/core/commandHelpers.d.ts +12 -0
  74. package/out/core/commandHelpers.js +96 -0
  75. package/out/core/commandHelpers.js.map +1 -0
  76. package/out/core/projectMcp.d.ts +25 -0
  77. package/out/core/projectMcp.js +144 -0
  78. package/out/core/projectMcp.js.map +1 -0
  79. package/out/core/provider/BaseProvider.d.ts +14 -0
  80. package/out/core/provider/BaseProvider.js +25 -0
  81. package/out/core/provider/BaseProvider.js.map +1 -0
  82. package/out/core/provider/ProviderRegistry.d.ts +12 -0
  83. package/out/core/provider/ProviderRegistry.js +40 -0
  84. package/out/core/provider/ProviderRegistry.js.map +1 -0
  85. package/out/core/provider/contract.d.ts +62 -0
  86. package/out/core/provider/contract.js +9 -0
  87. package/out/core/provider/contract.js.map +1 -0
  88. package/out/core/provider/implementations.d.ts +54 -0
  89. package/out/core/provider/implementations.js +147 -0
  90. package/out/core/provider/implementations.js.map +1 -0
  91. package/out/core/settingsLoader.d.ts +221 -0
  92. package/out/core/settingsLoader.js +176 -0
  93. package/out/core/settingsLoader.js.map +1 -0
  94. package/out/discordGateway.d.ts +26 -0
  95. package/out/discordGateway.js +230 -0
  96. package/out/discordGateway.js.map +1 -0
  97. package/out/discordPoller.d.ts +28 -0
  98. package/out/discordPoller.js +247 -0
  99. package/out/discordPoller.js.map +1 -0
  100. package/out/dispatcher.d.ts +12 -0
  101. package/out/dispatcher.js +214 -0
  102. package/out/dispatcher.js.map +1 -0
  103. package/out/emailPoller.d.ts +42 -0
  104. package/out/emailPoller.js +221 -0
  105. package/out/emailPoller.js.map +1 -0
  106. package/out/git/gitService.d.ts +36 -0
  107. package/out/git/gitService.js +165 -0
  108. package/out/git/gitService.js.map +1 -0
  109. package/out/hookEventNormalizer.d.ts +39 -0
  110. package/out/hookEventNormalizer.js +397 -0
  111. package/out/hookEventNormalizer.js.map +1 -0
  112. package/out/hooksManager.d.ts +25 -0
  113. package/out/hooksManager.js +471 -0
  114. package/out/hooksManager.js.map +1 -0
  115. package/out/launchIde.d.ts +14 -0
  116. package/out/logger.d.ts +12 -0
  117. package/out/mcpEmailTest.d.ts +29 -0
  118. package/out/mcpEmailTest.js +245 -0
  119. package/out/mcpEmailTest.js.map +1 -0
  120. package/out/mcpInstallCheck.d.ts +23 -0
  121. package/out/mcpInstallCheck.js +219 -0
  122. package/out/mcpInstallCheck.js.map +1 -0
  123. package/out/mcpManager.d.ts +35 -0
  124. package/out/mcpManager.js +371 -0
  125. package/out/mcpManager.js.map +1 -0
  126. package/out/messageBuilder.d.ts +54 -0
  127. package/out/messageBuilder.js +373 -0
  128. package/out/messageBuilder.js.map +1 -0
  129. package/out/openCodeHooksManager.d.ts +23 -0
  130. package/out/openCodeHooksManager.js +511 -0
  131. package/out/openCodeHooksManager.js.map +1 -0
  132. package/out/periodicActions.d.ts +63 -0
  133. package/out/periodicActions.js +237 -0
  134. package/out/periodicActions.js.map +1 -0
  135. package/out/profileBuilder.d.ts +29 -0
  136. package/out/profileBuilder.js +366 -0
  137. package/out/profileBuilder.js.map +1 -0
  138. package/out/prompt.d.ts +12 -0
  139. package/out/prompt.js +18 -0
  140. package/out/prompt.js.map +1 -0
  141. package/out/protocolSections.d.ts +26 -0
  142. package/out/protocolSections.js +209 -0
  143. package/out/protocolSections.js.map +1 -0
  144. package/out/providers/claudeCliProvider.d.ts +71 -0
  145. package/out/providers/claudeCliProvider.js +425 -0
  146. package/out/providers/claudeCliProvider.js.map +1 -0
  147. package/out/providers/claudeTuiProvider.d.ts +23 -0
  148. package/out/providers/claudeTuiProvider.js +296 -0
  149. package/out/providers/claudeTuiProvider.js.map +1 -0
  150. package/out/providers/copilotCliProvider.d.ts +16 -0
  151. package/out/providers/copilotCliProvider.js +44 -0
  152. package/out/providers/copilotCliProvider.js.map +1 -0
  153. package/out/providers/copilotSdkProvider.d.ts +12 -0
  154. package/out/providers/copilotSdkProvider.js +445 -0
  155. package/out/providers/copilotSdkProvider.js.map +1 -0
  156. package/out/providers/grokTuiProvider.d.ts +14 -0
  157. package/out/providers/grokTuiProvider.js +271 -0
  158. package/out/providers/grokTuiProvider.js.map +1 -0
  159. package/out/providers/opencodeCliProvider.d.ts +29 -0
  160. package/out/providers/opencodeCliProvider.js +199 -0
  161. package/out/providers/opencodeCliProvider.js.map +1 -0
  162. package/out/providers/opencodeSdkProvider.d.ts +22 -0
  163. package/out/providers/opencodeSdkProvider.js +557 -0
  164. package/out/providers/opencodeSdkProvider.js.map +1 -0
  165. package/out/providers.d.ts +9 -0
  166. package/out/providers.js +44 -0
  167. package/out/providers.js.map +1 -0
  168. package/out/rateLimit.d.ts +18 -0
  169. package/out/rateLimit.js +90 -0
  170. package/out/rateLimit.js.map +1 -0
  171. package/out/rdp/auth.d.ts +55 -0
  172. package/out/rdp/auth.js +197 -0
  173. package/out/rdp/auth.js.map +1 -0
  174. package/out/rdp/bridge.d.ts +86 -0
  175. package/out/rdp/bridge.js +1398 -0
  176. package/out/rdp/bridge.js.map +1 -0
  177. package/out/rdp/constants.d.ts +86 -0
  178. package/out/rdp/constants.js +182 -0
  179. package/out/rdp/constants.js.map +1 -0
  180. package/out/rdp/index.d.ts +7 -0
  181. package/out/rdp/index.js +14 -0
  182. package/out/rdp/index.js.map +1 -0
  183. package/out/rdp/session.d.ts +30 -0
  184. package/out/rdp/session.js +196 -0
  185. package/out/rdp/session.js.map +1 -0
  186. package/out/rdp/types.d.ts +27 -0
  187. package/out/rdp/types.js +6 -0
  188. package/out/rdp/types.js.map +1 -0
  189. package/out/sdk/index.d.ts +22 -0
  190. package/out/sdk/index.js +81 -0
  191. package/out/sdk/index.js.map +1 -0
  192. package/out/sessionState.d.ts +54 -0
  193. package/out/sessionState.js +284 -0
  194. package/out/sessionState.js.map +1 -0
  195. package/out/sessions.d.ts +11 -0
  196. package/out/sessions.js +32 -0
  197. package/out/sessions.js.map +1 -0
  198. package/out/taskLoop.d.ts +152 -0
  199. package/out/taskLoop.js +2505 -0
  200. package/out/taskLoop.js.map +1 -0
  201. package/out/todo.d.ts +42 -0
  202. package/out/todo.js +311 -0
  203. package/out/todo.js.map +1 -0
  204. package/out/todoWriteManager.d.ts +26 -0
  205. package/out/todoWriteManager.js +44 -0
  206. package/out/todoWriteManager.js.map +1 -0
  207. package/out/vnc/auth.d.ts +52 -0
  208. package/out/vnc/auth.js +181 -0
  209. package/out/vnc/auth.js.map +1 -0
  210. package/out/vnc/bridge.d.ts +40 -0
  211. package/out/vnc/bridge.js +540 -0
  212. package/out/vnc/bridge.js.map +1 -0
  213. package/out/vnc/constants.d.ts +8 -0
  214. package/out/vnc/constants.js +34 -0
  215. package/out/vnc/constants.js.map +1 -0
  216. package/out/vnc/des.d.ts +6 -0
  217. package/out/vnc/des.js +93 -0
  218. package/out/vnc/des.js.map +1 -0
  219. package/out/vnc/index.d.ts +7 -0
  220. package/out/vnc/index.js +13 -0
  221. package/out/vnc/index.js.map +1 -0
  222. package/out/vnc/session.d.ts +18 -0
  223. package/out/vnc/session.js +193 -0
  224. package/out/vnc/session.js.map +1 -0
  225. package/out/vnc/types.d.ts +16 -0
  226. package/out/vnc/types.js +6 -0
  227. package/out/vnc/types.js.map +1 -0
  228. package/out/webSocketPoller.d.ts +95 -0
  229. package/out/webSocketPoller.js +986 -0
  230. package/out/webSocketPoller.js.map +1 -0
  231. package/out/webhook.d.ts +37 -0
  232. package/out/webhook.js +265 -0
  233. package/out/webhook.js.map +1 -0
  234. package/out/webhookPoller.d.ts +40 -0
  235. package/out/webhookPoller.js +378 -0
  236. package/out/webhookPoller.js.map +1 -0
  237. package/package.json +54 -41
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.todoWriter = void 0;
4
+ const todo_1 = require("./todo");
5
+ /**
6
+ * Serialises all mutating TODO.md operations so concurrent callers
7
+ * (email poller, webhook poller, discord poller, sidebar "Add task", task loop)
8
+ * never overwrite each other's changes.
9
+ *
10
+ * Each write operation is queued per file path and executes only after all
11
+ * previously enqueued operations for that path have settled (resolved or
12
+ * rejected). The queue is purely in-process — it does not use file locks,
13
+ * which is sufficient because all writes originate from within this extension.
14
+ */
15
+ class TodoWriteManager {
16
+ _tails = new Map();
17
+ _enqueue(filePath, op) {
18
+ const tail = this._tails.get(filePath) ?? Promise.resolve();
19
+ // Use two-arg .then so the queue keeps draining even if a prior op threw.
20
+ const result = tail.then(() => op(), () => op());
21
+ // Store a never-rejecting tail so subsequent ops always get a chance to run.
22
+ this._tails.set(filePath, result.then(() => undefined, () => undefined));
23
+ return result;
24
+ }
25
+ /** Append a new task to the Todo section and return its generated task ID. */
26
+ append(filePath, text, id) {
27
+ return this._enqueue(filePath, () => (0, todo_1.appendTask)(filePath, text, id));
28
+ }
29
+ /** Reset a single [~] in-progress task back to [ ]. */
30
+ resetToTodo(filePath, task) {
31
+ return this._enqueue(filePath, () => (0, todo_1.resetToTodo)(filePath, task));
32
+ }
33
+ /** Reset ALL [~] in-progress tasks back to [ ]. */
34
+ resetAllInProgress(filePath) {
35
+ return this._enqueue(filePath, () => (0, todo_1.resetAllInProgress)(filePath));
36
+ }
37
+ /** Mark a task as [x] done in TODO.md. */
38
+ markDone(filePath, task) {
39
+ return this._enqueue(filePath, () => (0, todo_1.markDone)(filePath, task));
40
+ }
41
+ }
42
+ /** Singleton — import this everywhere instead of calling todo.ts write functions directly. */
43
+ exports.todoWriter = new TodoWriteManager();
44
+ //# sourceMappingURL=todoWriteManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"todoWriteManager.js","sourceRoot":"","sources":["../src/todoWriteManager.ts"],"names":[],"mappings":";;;AAAA,iCAAqF;AAErF;;;;;;;;;GASG;AACH,MAAM,gBAAgB;IACD,MAAM,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEtD,QAAQ,CAAI,QAAgB,EAAE,EAAW;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5D,0EAA0E;QAC1E,MAAM,MAAM,GAAgB,IAAsB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAChF,6EAA6E;QAC7E,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,8EAA8E;IAC9E,MAAM,CAAC,QAAgB,EAAE,IAAY,EAAE,EAAW;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,iBAAU,EAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,uDAAuD;IACvD,WAAW,CAAC,QAAgB,EAAE,IAAU;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAW,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,mDAAmD;IACnD,kBAAkB,CAAC,QAAgB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,yBAAkB,EAAC,QAAQ,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,0CAA0C;IAC1C,QAAQ,CAAC,QAAgB,EAAE,IAAU;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,eAAQ,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IACnE,CAAC;CACJ;AAED,8FAA8F;AACjF,QAAA,UAAU,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * RFB authentication algorithms.
3
+ *
4
+ * Supported security types:
5
+ * 1 — None (no auth required)
6
+ * 2 — VNC Authentication (DES challenge-response)
7
+ * 18 — TLS (opportunistic — we accept the server cert without validation;
8
+ * used as a wrapper; inner auth type negotiated separately)
9
+ * 19 — VeNCrypt (TLS variants; we handle plain + VNC sub-types)
10
+ *
11
+ * RFB 3.3 only ever sends a single auth type as a 4-byte uint.
12
+ * RFB 3.7 / 3.8 send a length-prefixed list; the client picks one.
13
+ */
14
+ import * as tls from 'tls';
15
+ import * as net from 'net';
16
+ export declare const AUTH_NONE = 1;
17
+ export declare const AUTH_VNC = 2;
18
+ export declare const AUTH_TIGHT = 16;
19
+ export declare const AUTH_VENCRYPT = 19;
20
+ export declare const VENCRYPT_PLAIN = 256;
21
+ export declare const VENCRYPT_TLSNONE = 257;
22
+ export declare const VENCRYPT_TLSVNC = 258;
23
+ export declare const VENCRYPT_TLSPLAIN = 259;
24
+ export declare const VENCRYPT_X509NONE = 260;
25
+ export declare const VENCRYPT_X509VNC = 261;
26
+ export declare const VENCRYPT_X509PLAIN = 262;
27
+ /**
28
+ * VNC challenge-response: DES-encrypt the 16-byte challenge with the
29
+ * bit-reversed password key.
30
+ */
31
+ export declare function vncDesResponse(challenge: Buffer, password: string): Buffer;
32
+ /**
33
+ * Sorted list of auth types we can handle, in preference order.
34
+ * The bridge uses this when negotiating RFB 3.7/3.8 security type lists.
35
+ */
36
+ export declare const SUPPORTED_AUTH_TYPES: number[];
37
+ /**
38
+ * Pick the best supported auth type from a server-provided list.
39
+ * Returns undefined if none are supported.
40
+ */
41
+ export declare function pickAuthType(serverTypes: number[]): number | undefined;
42
+ /**
43
+ * Negotiate VeNCrypt on a raw socket. On success, returns the upgraded stream
44
+ * (plain socket or TLS socket) plus the chosen sub-type so the caller knows
45
+ * which inner auth to perform next.
46
+ *
47
+ * Throws on failure.
48
+ */
49
+ export declare function negotiateVeNCrypt(sock: net.Socket, readBytes: (n: number) => Promise<Buffer>, password: string | undefined, username: string | undefined): Promise<{
50
+ stream: net.Socket | tls.TLSSocket;
51
+ subType: number;
52
+ }>;
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ /**
3
+ * RFB authentication algorithms.
4
+ *
5
+ * Supported security types:
6
+ * 1 — None (no auth required)
7
+ * 2 — VNC Authentication (DES challenge-response)
8
+ * 18 — TLS (opportunistic — we accept the server cert without validation;
9
+ * used as a wrapper; inner auth type negotiated separately)
10
+ * 19 — VeNCrypt (TLS variants; we handle plain + VNC sub-types)
11
+ *
12
+ * RFB 3.3 only ever sends a single auth type as a 4-byte uint.
13
+ * RFB 3.7 / 3.8 send a length-prefixed list; the client picks one.
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || (function () {
32
+ var ownKeys = function(o) {
33
+ ownKeys = Object.getOwnPropertyNames || function (o) {
34
+ var ar = [];
35
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
36
+ return ar;
37
+ };
38
+ return ownKeys(o);
39
+ };
40
+ return function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
47
+ })();
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.SUPPORTED_AUTH_TYPES = exports.VENCRYPT_X509PLAIN = exports.VENCRYPT_X509VNC = exports.VENCRYPT_X509NONE = exports.VENCRYPT_TLSPLAIN = exports.VENCRYPT_TLSVNC = exports.VENCRYPT_TLSNONE = exports.VENCRYPT_PLAIN = exports.AUTH_VENCRYPT = exports.AUTH_TIGHT = exports.AUTH_VNC = exports.AUTH_NONE = void 0;
50
+ exports.vncDesResponse = vncDesResponse;
51
+ exports.pickAuthType = pickAuthType;
52
+ exports.negotiateVeNCrypt = negotiateVeNCrypt;
53
+ const des_1 = require("./des");
54
+ const tls = __importStar(require("tls"));
55
+ // ── Security type constants ────────────────────────────────────────────────
56
+ exports.AUTH_NONE = 1;
57
+ exports.AUTH_VNC = 2;
58
+ exports.AUTH_TIGHT = 16;
59
+ exports.AUTH_VENCRYPT = 19;
60
+ // VeNCrypt sub-types we support (plain TCP variants only — no TLS cert)
61
+ exports.VENCRYPT_PLAIN = 256; // plain username+password
62
+ exports.VENCRYPT_TLSNONE = 257; // TLS with no inner auth
63
+ exports.VENCRYPT_TLSVNC = 258; // TLS + VNC auth
64
+ exports.VENCRYPT_TLSPLAIN = 259; // TLS + plain auth
65
+ exports.VENCRYPT_X509NONE = 260; // X.509 TLS with no inner auth
66
+ exports.VENCRYPT_X509VNC = 261; // X.509 TLS + VNC auth
67
+ exports.VENCRYPT_X509PLAIN = 262; // X.509 TLS + plain auth
68
+ // ── Helpers ────────────────────────────────────────────────────────────────
69
+ function reverseBits(b) {
70
+ let r = 0;
71
+ for (let i = 0; i < 8; i++) {
72
+ r = (r << 1) | (b & 1);
73
+ b >>= 1;
74
+ }
75
+ return r;
76
+ }
77
+ /**
78
+ * VNC challenge-response: DES-encrypt the 16-byte challenge with the
79
+ * bit-reversed password key.
80
+ */
81
+ function vncDesResponse(challenge, password) {
82
+ const pw = password.padEnd(8, '\0').slice(0, 8);
83
+ const key = Buffer.alloc(8);
84
+ for (let i = 0; i < 8; i++)
85
+ key[i] = reverseBits(pw.charCodeAt(i));
86
+ const result = Buffer.alloc(16);
87
+ (0, des_1.desEncrypt)(challenge.slice(0, 8), key).copy(result, 0);
88
+ (0, des_1.desEncrypt)(challenge.slice(8, 16), key).copy(result, 8);
89
+ return result;
90
+ }
91
+ // ── Auth negotiation helpers used by VncBridge ─────────────────────────────
92
+ /**
93
+ * Sorted list of auth types we can handle, in preference order.
94
+ * The bridge uses this when negotiating RFB 3.7/3.8 security type lists.
95
+ */
96
+ exports.SUPPORTED_AUTH_TYPES = [exports.AUTH_NONE, exports.AUTH_VNC, exports.AUTH_VENCRYPT];
97
+ /**
98
+ * Pick the best supported auth type from a server-provided list.
99
+ * Returns undefined if none are supported.
100
+ */
101
+ function pickAuthType(serverTypes) {
102
+ for (const preferred of exports.SUPPORTED_AUTH_TYPES) {
103
+ if (serverTypes.includes(preferred))
104
+ return preferred;
105
+ }
106
+ return undefined;
107
+ }
108
+ // ── VeNCrypt negotiation ───────────────────────────────────────────────────
109
+ /** VeNCrypt sub-types we can handle, in preference order. */
110
+ const SUPPORTED_VENCRYPT_SUBTYPES = [
111
+ exports.VENCRYPT_TLSNONE,
112
+ exports.VENCRYPT_TLSVNC,
113
+ exports.VENCRYPT_TLSPLAIN,
114
+ exports.VENCRYPT_X509NONE,
115
+ exports.VENCRYPT_X509VNC,
116
+ exports.VENCRYPT_X509PLAIN,
117
+ exports.VENCRYPT_PLAIN,
118
+ ];
119
+ /**
120
+ * Negotiate VeNCrypt on a raw socket. On success, returns the upgraded stream
121
+ * (plain socket or TLS socket) plus the chosen sub-type so the caller knows
122
+ * which inner auth to perform next.
123
+ *
124
+ * Throws on failure.
125
+ */
126
+ async function negotiateVeNCrypt(sock, readBytes, password, username) {
127
+ // Send VeNCrypt version 0.2
128
+ sock.write(Buffer.from([0, 2]));
129
+ const serverVer = await readBytes(2);
130
+ if (serverVer[0] !== 0 || serverVer[1] !== 2) {
131
+ throw new Error(`Unsupported VeNCrypt version: ${serverVer[0]}.${serverVer[1]}`);
132
+ }
133
+ // ACK version
134
+ sock.write(Buffer.from([0]));
135
+ // Read sub-type list
136
+ const countBuf = await readBytes(1);
137
+ const count = countBuf[0];
138
+ const typesBuf = await readBytes(count * 4);
139
+ const serverSubTypes = [];
140
+ for (let i = 0; i < count; i++)
141
+ serverSubTypes.push(typesBuf.readUInt32BE(i * 4));
142
+ const chosen = SUPPORTED_VENCRYPT_SUBTYPES.find(t => serverSubTypes.includes(t));
143
+ if (!chosen) {
144
+ throw new Error(`No supported VeNCrypt sub-type (server offers: ${serverSubTypes.join(', ')})`);
145
+ }
146
+ // Send chosen sub-type
147
+ const choiceBuf = Buffer.alloc(4);
148
+ choiceBuf.writeUInt32BE(chosen, 0);
149
+ sock.write(choiceBuf);
150
+ // Server ACK (1 byte, must be 1)
151
+ const ack = await readBytes(1);
152
+ if (ack[0] !== 1)
153
+ throw new Error('VeNCrypt: server rejected sub-type selection');
154
+ // ── Upgrade to TLS if needed ─────────────────────────────────────────────
155
+ let stream = sock;
156
+ if (chosen !== exports.VENCRYPT_PLAIN) {
157
+ stream = await new Promise((resolve, reject) => {
158
+ const tlsSock = tls.connect({
159
+ socket: sock,
160
+ rejectUnauthorized: false, // VNC servers use self-signed certs
161
+ });
162
+ tlsSock.once('secureConnect', () => resolve(tlsSock));
163
+ tlsSock.once('error', (e) => reject(e));
164
+ });
165
+ }
166
+ // ── Inner auth ───────────────────────────────────────────────────────────
167
+ if (chosen === exports.VENCRYPT_PLAIN || chosen === exports.VENCRYPT_TLSPLAIN || chosen === exports.VENCRYPT_X509PLAIN) {
168
+ if (!username || !password)
169
+ throw new Error('VeNCrypt plain auth requires username and password');
170
+ const userBuf = Buffer.from(username, 'utf8');
171
+ const passBuf = Buffer.from(password, 'utf8');
172
+ const lenBuf = Buffer.alloc(8);
173
+ lenBuf.writeUInt32BE(userBuf.length, 0);
174
+ lenBuf.writeUInt32BE(passBuf.length, 4);
175
+ stream.write(Buffer.concat([lenBuf, userBuf, passBuf]));
176
+ }
177
+ // TLSNONE / X509NONE: no inner auth data to send
178
+ // TLSVNC / X509VNC : VNC challenge-response is handled by bridge after this returns
179
+ return { stream, subType: chosen };
180
+ }
181
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/vnc/auth.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,wCAQC;AAcD,oCAKC;AAsBD,8CAgEC;AAjJD,+BAAmC;AACnC,yCAA2B;AAG3B,8EAA8E;AAEjE,QAAA,SAAS,GAAY,CAAC,CAAC;AACvB,QAAA,QAA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AAC,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,iDAAiD;IACjD,qFAAqF;IAErF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * VncBridge — TCP connection to a local VNC server.
3
+ *
4
+ * Handles RFB protocol version negotiation (3.3 / 3.7 / 3.8) and
5
+ * security types: None (1), VNC auth/DES (2), VeNCrypt (19).
6
+ *
7
+ * Emits:
8
+ * 'frame' (rect: VncRect) — one decoded framebuffer rectangle
9
+ * 'error' (err: Error) — unrecoverable error (connection closed)
10
+ * 'close' () — TCP connection closed
11
+ */
12
+ import { EventEmitter } from 'events';
13
+ import type { VncInfo } from './types';
14
+ export declare class VncBridge extends EventEmitter {
15
+ private _sock;
16
+ private _width;
17
+ private _height;
18
+ private _bypp;
19
+ private _recvBuf;
20
+ private _closed;
21
+ get width(): number;
22
+ get height(): number;
23
+ /** Connect to a VNC server at 127.0.0.1:port. Resolves once handshake is done. */
24
+ connect(port: number, password?: string, username?: string): Promise<VncInfo>;
25
+ /** Request a framebuffer update. */
26
+ requestUpdate(x?: number, y?: number, w?: number, h?: number, incremental?: number): void;
27
+ /** Send a key event. */
28
+ sendKey(keysym: number, down: boolean): void;
29
+ /** Send a ClientCutText message (push local clipboard to remote). */
30
+ sendClientCutText(text: string): void;
31
+ /** Send a pointer (mouse) event. */
32
+ sendMouse(x: number, y: number, buttonMask: number): void;
33
+ close(): void;
34
+ private _handleVeNCrypt;
35
+ private _runRunning;
36
+ private _sendSetPixelFormat;
37
+ private _sendSetEncodings;
38
+ private _parseServerMessage;
39
+ private _parseFBU;
40
+ }