@celljs/ta-host 4.7.0 → 4.9.0

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 (466) hide show
  1. package/README.en.md +34 -4
  2. package/README.md +33 -3
  3. package/cell.schema.json +4 -0
  4. package/cell.yml +2 -0
  5. package/esm/node/auth-server-impl.d.ts +2 -0
  6. package/esm/node/auth-server-impl.js +7 -0
  7. package/esm/node/client-tool-broker.d.ts +11 -3
  8. package/esm/node/client-tool-broker.js +23 -3
  9. package/esm/node/extension-providers.d.ts +22 -0
  10. package/esm/node/extension-providers.js +52 -0
  11. package/esm/node/host-protocol.d.ts +22 -1
  12. package/esm/node/host-protocol.js +1 -0
  13. package/esm/node/index.d.ts +6 -0
  14. package/esm/node/index.js +6 -0
  15. package/esm/node/live-run.d.ts +22 -0
  16. package/esm/node/live-run.js +58 -0
  17. package/esm/node/message-page.d.ts +17 -0
  18. package/esm/node/message-page.js +71 -0
  19. package/esm/node/package-host-extension.d.ts +4 -2
  20. package/esm/node/package-host-extension.js +4 -3
  21. package/esm/node/package-hosts.d.ts +2 -2
  22. package/esm/node/package-hosts.js +2 -0
  23. package/esm/node/package-server-impl.d.ts +9 -1
  24. package/esm/node/package-server-impl.js +16 -1
  25. package/esm/node/relay-bridge.d.ts +9 -1
  26. package/esm/node/relay-bridge.js +44 -4
  27. package/esm/node/remote-ui-context.d.ts +6 -1
  28. package/esm/node/remote-ui-context.js +31 -3
  29. package/esm/node/session-catalog.d.ts +69 -0
  30. package/esm/node/session-catalog.js +211 -0
  31. package/esm/node/session-files.d.ts +18 -0
  32. package/esm/node/session-files.js +32 -0
  33. package/esm/node/session-info-util.d.ts +4 -1
  34. package/esm/node/session-info-util.js +8 -3
  35. package/esm/node/settings-server-impl.d.ts +1 -0
  36. package/esm/node/settings-server-impl.js +8 -0
  37. package/esm/node/settings-store.d.ts +3 -1
  38. package/esm/node/settings-store.js +25 -3
  39. package/esm/node/sign-in/access-server-impl.d.ts +19 -0
  40. package/esm/node/sign-in/access-server-impl.js +82 -0
  41. package/esm/node/sign-in/access-store.d.ts +65 -0
  42. package/esm/node/sign-in/access-store.js +175 -0
  43. package/esm/node/sign-in/index.d.ts +7 -0
  44. package/esm/node/sign-in/index.js +8 -0
  45. package/esm/node/sign-in/sign-in-flow.d.ts +58 -0
  46. package/esm/node/sign-in/sign-in-flow.js +104 -0
  47. package/esm/node/sign-in/sign-in-middleware.d.ts +10 -0
  48. package/esm/node/sign-in/sign-in-middleware.js +48 -0
  49. package/esm/node/sign-in/sign-in-pages.d.ts +31 -0
  50. package/esm/node/sign-in/sign-in-pages.js +118 -0
  51. package/esm/node/sign-in/sign-in-provider.d.ts +135 -0
  52. package/esm/node/sign-in/sign-in-provider.js +225 -0
  53. package/esm/node/sign-in/ta-sign-in.d.ts +10 -0
  54. package/esm/node/sign-in/ta-sign-in.js +32 -0
  55. package/esm/node/ta-access.d.ts +7 -0
  56. package/esm/node/ta-access.js +30 -1
  57. package/esm/node/ta-server-impl.d.ts +8 -3
  58. package/esm/node/ta-server-impl.js +25 -6
  59. package/esm/node/ta-session-factory.d.ts +4 -1
  60. package/esm/node/ta-session-factory.js +30 -7
  61. package/esm/node/ta-session-registry.d.ts +2 -0
  62. package/esm/node/ta-session-registry.js +23 -3
  63. package/esm/node/ta-session.d.ts +24 -2
  64. package/esm/node/ta-session.js +84 -6
  65. package/esm/node/temporary-packages.d.ts +46 -0
  66. package/esm/node/temporary-packages.js +114 -0
  67. package/esm/node/temporary-purge.d.ts +13 -0
  68. package/esm/node/temporary-purge.js +51 -0
  69. package/esm/node/terminal-service.d.ts +18 -2
  70. package/esm/node/terminal-service.js +45 -9
  71. package/esm/node/terminal-util.d.ts +14 -0
  72. package/esm/node/terminal-util.js +30 -1
  73. package/esm/node/web-extension-catalog.d.ts +28 -1
  74. package/esm/node/web-extension-catalog.js +173 -5
  75. package/esm/node/web-extension-util.d.ts +5 -1
  76. package/esm/node/web-extension-util.js +36 -5
  77. package/esm/node/workspace-protocol.d.ts +2 -0
  78. package/esm/node/workspace-server-impl.d.ts +2 -1
  79. package/esm/node/workspace-server-impl.js +13 -1
  80. package/esm/node/workspace-service.d.ts +1 -0
  81. package/esm/node/workspace-service.js +13 -1
  82. package/lib/node/auth-server-impl.d.ts +2 -0
  83. package/lib/node/auth-server-impl.js +7 -0
  84. package/lib/node/client-tool-broker.d.ts +11 -3
  85. package/lib/node/client-tool-broker.js +23 -3
  86. package/lib/node/extension-providers.d.ts +23 -0
  87. package/lib/node/extension-providers.js +55 -0
  88. package/lib/node/host-protocol.d.ts +22 -1
  89. package/lib/node/host-protocol.js +2 -1
  90. package/lib/node/index.d.ts +6 -0
  91. package/lib/node/index.js +6 -0
  92. package/lib/node/live-run.d.ts +23 -0
  93. package/lib/node/live-run.js +62 -0
  94. package/lib/node/message-page.d.ts +18 -0
  95. package/lib/node/message-page.js +74 -0
  96. package/lib/node/package-host-extension.d.ts +4 -2
  97. package/lib/node/package-host-extension.js +4 -3
  98. package/lib/node/package-hosts.d.ts +2 -2
  99. package/lib/node/package-hosts.js +2 -0
  100. package/lib/node/package-server-impl.d.ts +9 -1
  101. package/lib/node/package-server-impl.js +15 -0
  102. package/lib/node/relay-bridge.d.ts +9 -1
  103. package/lib/node/relay-bridge.js +43 -3
  104. package/lib/node/remote-ui-context.d.ts +6 -1
  105. package/lib/node/remote-ui-context.js +31 -3
  106. package/lib/node/session-catalog.d.ts +70 -0
  107. package/lib/node/session-catalog.js +214 -0
  108. package/lib/node/session-files.d.ts +19 -0
  109. package/lib/node/session-files.js +36 -0
  110. package/lib/node/session-info-util.d.ts +4 -1
  111. package/lib/node/session-info-util.js +7 -2
  112. package/lib/node/settings-server-impl.d.ts +1 -0
  113. package/lib/node/settings-server-impl.js +8 -0
  114. package/lib/node/settings-store.d.ts +3 -1
  115. package/lib/node/settings-store.js +25 -3
  116. package/lib/node/sign-in/access-server-impl.d.ts +20 -0
  117. package/lib/node/sign-in/access-server-impl.js +85 -0
  118. package/lib/node/sign-in/access-store.d.ts +66 -0
  119. package/lib/node/sign-in/access-store.js +179 -0
  120. package/lib/node/sign-in/index.d.ts +8 -0
  121. package/lib/node/sign-in/index.js +24 -0
  122. package/lib/node/sign-in/sign-in-flow.d.ts +59 -0
  123. package/lib/node/sign-in/sign-in-flow.js +108 -0
  124. package/lib/node/sign-in/sign-in-middleware.d.ts +11 -0
  125. package/lib/node/sign-in/sign-in-middleware.js +51 -0
  126. package/lib/node/sign-in/sign-in-pages.d.ts +32 -0
  127. package/lib/node/sign-in/sign-in-pages.js +121 -0
  128. package/lib/node/sign-in/sign-in-provider.d.ts +136 -0
  129. package/lib/node/sign-in/sign-in-provider.js +232 -0
  130. package/lib/node/sign-in/ta-sign-in.d.ts +11 -0
  131. package/lib/node/sign-in/ta-sign-in.js +35 -0
  132. package/lib/node/ta-access.d.ts +7 -0
  133. package/lib/node/ta-access.js +30 -1
  134. package/lib/node/ta-server-impl.d.ts +8 -3
  135. package/lib/node/ta-server-impl.js +24 -5
  136. package/lib/node/ta-session-factory.d.ts +4 -1
  137. package/lib/node/ta-session-factory.js +30 -7
  138. package/lib/node/ta-session-registry.d.ts +2 -0
  139. package/lib/node/ta-session-registry.js +23 -3
  140. package/lib/node/ta-session.d.ts +24 -2
  141. package/lib/node/ta-session.js +84 -6
  142. package/lib/node/temporary-packages.d.ts +47 -0
  143. package/lib/node/temporary-packages.js +118 -0
  144. package/lib/node/temporary-purge.d.ts +14 -0
  145. package/lib/node/temporary-purge.js +54 -0
  146. package/lib/node/terminal-service.d.ts +18 -2
  147. package/lib/node/terminal-service.js +44 -8
  148. package/lib/node/terminal-util.d.ts +14 -0
  149. package/lib/node/terminal-util.js +30 -1
  150. package/lib/node/web-extension-catalog.d.ts +28 -1
  151. package/lib/node/web-extension-catalog.js +172 -4
  152. package/lib/node/web-extension-util.d.ts +5 -1
  153. package/lib/node/web-extension-util.js +36 -5
  154. package/lib/node/workspace-protocol.d.ts +2 -0
  155. package/lib/node/workspace-server-impl.d.ts +2 -1
  156. package/lib/node/workspace-server-impl.js +12 -0
  157. package/lib/node/workspace-service.d.ts +1 -0
  158. package/lib/node/workspace-service.js +13 -1
  159. package/package.json +17 -12
  160. package/esm/node/auth-server-impl.js.map +0 -1
  161. package/esm/node/client-channel.js.map +0 -1
  162. package/esm/node/client-tool-broker.js.map +0 -1
  163. package/esm/node/event-log.js.map +0 -1
  164. package/esm/node/exec-environment-factory.js.map +0 -1
  165. package/esm/node/extension-data-notifier.js.map +0 -1
  166. package/esm/node/extension-data.js.map +0 -1
  167. package/esm/node/host-protocol.js.map +0 -1
  168. package/esm/node/index.js.map +0 -1
  169. package/esm/node/module.js.map +0 -1
  170. package/esm/node/package-host-extension.js.map +0 -1
  171. package/esm/node/package-hosts.js.map +0 -1
  172. package/esm/node/package-server-impl.js.map +0 -1
  173. package/esm/node/package-switch.js.map +0 -1
  174. package/esm/node/receipt-book.js.map +0 -1
  175. package/esm/node/relay-bridge.js.map +0 -1
  176. package/esm/node/remote/index.js.map +0 -1
  177. package/esm/node/remote/pi-directories.js.map +0 -1
  178. package/esm/node/remote/port-forwards.js.map +0 -1
  179. package/esm/node/remote/remote-hosts.js.map +0 -1
  180. package/esm/node/remote/remote-protocol.js.map +0 -1
  181. package/esm/node/remote/remote-server-impl.js.map +0 -1
  182. package/esm/node/remote-ui-context.js.map +0 -1
  183. package/esm/node/session-info-util.js.map +0 -1
  184. package/esm/node/session-storage/file-session-storage.js.map +0 -1
  185. package/esm/node/session-storage/index.js.map +0 -1
  186. package/esm/node/session-storage/session-storage-protocol.js.map +0 -1
  187. package/esm/node/session-storage/stored-session.js.map +0 -1
  188. package/esm/node/settings-server-impl.js.map +0 -1
  189. package/esm/node/settings-store.js.map +0 -1
  190. package/esm/node/ta-access.js.map +0 -1
  191. package/esm/node/ta-errors.js.map +0 -1
  192. package/esm/node/ta-event-util.js.map +0 -1
  193. package/esm/node/ta-server-impl.js.map +0 -1
  194. package/esm/node/ta-session-factory.js.map +0 -1
  195. package/esm/node/ta-session-registry.js.map +0 -1
  196. package/esm/node/ta-session.js.map +0 -1
  197. package/esm/node/terminal-protocol.js.map +0 -1
  198. package/esm/node/terminal-service.js.map +0 -1
  199. package/esm/node/terminal-util.js.map +0 -1
  200. package/esm/node/web-extension-catalog.js.map +0 -1
  201. package/esm/node/web-extension-util.js.map +0 -1
  202. package/esm/node/working-directory.js.map +0 -1
  203. package/esm/node/workspace-files.js.map +0 -1
  204. package/esm/node/workspace-protocol.js.map +0 -1
  205. package/esm/node/workspace-server-impl.js.map +0 -1
  206. package/esm/node/workspace-service.js.map +0 -1
  207. package/esm/node/workspace-util.js.map +0 -1
  208. package/lib/node/auth-server-impl.d.ts.map +0 -1
  209. package/lib/node/auth-server-impl.js.map +0 -1
  210. package/lib/node/auth-server-impl.spec.d.ts +0 -2
  211. package/lib/node/auth-server-impl.spec.d.ts.map +0 -1
  212. package/lib/node/auth-server-impl.spec.js +0 -47
  213. package/lib/node/auth-server-impl.spec.js.map +0 -1
  214. package/lib/node/client-channel.d.ts.map +0 -1
  215. package/lib/node/client-channel.js.map +0 -1
  216. package/lib/node/client-channel.spec.d.ts +0 -2
  217. package/lib/node/client-channel.spec.d.ts.map +0 -1
  218. package/lib/node/client-channel.spec.js +0 -106
  219. package/lib/node/client-channel.spec.js.map +0 -1
  220. package/lib/node/client-tool-broker.d.ts.map +0 -1
  221. package/lib/node/client-tool-broker.js.map +0 -1
  222. package/lib/node/client-tool-broker.spec.d.ts +0 -2
  223. package/lib/node/client-tool-broker.spec.d.ts.map +0 -1
  224. package/lib/node/client-tool-broker.spec.js +0 -49
  225. package/lib/node/client-tool-broker.spec.js.map +0 -1
  226. package/lib/node/event-log.d.ts.map +0 -1
  227. package/lib/node/event-log.js.map +0 -1
  228. package/lib/node/event-log.spec.d.ts +0 -2
  229. package/lib/node/event-log.spec.d.ts.map +0 -1
  230. package/lib/node/event-log.spec.js +0 -48
  231. package/lib/node/event-log.spec.js.map +0 -1
  232. package/lib/node/exec-environment-factory.d.ts.map +0 -1
  233. package/lib/node/exec-environment-factory.js.map +0 -1
  234. package/lib/node/extension-data-notifier.d.ts.map +0 -1
  235. package/lib/node/extension-data-notifier.js.map +0 -1
  236. package/lib/node/extension-data-notifier.spec.d.ts +0 -2
  237. package/lib/node/extension-data-notifier.spec.d.ts.map +0 -1
  238. package/lib/node/extension-data-notifier.spec.js +0 -35
  239. package/lib/node/extension-data-notifier.spec.js.map +0 -1
  240. package/lib/node/extension-data.d.ts.map +0 -1
  241. package/lib/node/extension-data.js.map +0 -1
  242. package/lib/node/extension-data.spec.d.ts +0 -2
  243. package/lib/node/extension-data.spec.d.ts.map +0 -1
  244. package/lib/node/extension-data.spec.js +0 -99
  245. package/lib/node/extension-data.spec.js.map +0 -1
  246. package/lib/node/host-protocol.d.ts.map +0 -1
  247. package/lib/node/host-protocol.js.map +0 -1
  248. package/lib/node/index.d.ts.map +0 -1
  249. package/lib/node/index.js.map +0 -1
  250. package/lib/node/module.d.ts.map +0 -1
  251. package/lib/node/module.js.map +0 -1
  252. package/lib/node/package-host-extension.d.ts.map +0 -1
  253. package/lib/node/package-host-extension.js.map +0 -1
  254. package/lib/node/package-hosts.d.ts.map +0 -1
  255. package/lib/node/package-hosts.js.map +0 -1
  256. package/lib/node/package-hosts.spec.d.ts +0 -2
  257. package/lib/node/package-hosts.spec.d.ts.map +0 -1
  258. package/lib/node/package-hosts.spec.js +0 -53
  259. package/lib/node/package-hosts.spec.js.map +0 -1
  260. package/lib/node/package-server-impl.d.ts.map +0 -1
  261. package/lib/node/package-server-impl.js.map +0 -1
  262. package/lib/node/package-switch.d.ts.map +0 -1
  263. package/lib/node/package-switch.js.map +0 -1
  264. package/lib/node/receipt-book.d.ts.map +0 -1
  265. package/lib/node/receipt-book.js.map +0 -1
  266. package/lib/node/receipt-book.spec.d.ts +0 -2
  267. package/lib/node/receipt-book.spec.d.ts.map +0 -1
  268. package/lib/node/receipt-book.spec.js +0 -39
  269. package/lib/node/receipt-book.spec.js.map +0 -1
  270. package/lib/node/relay-bridge.d.ts.map +0 -1
  271. package/lib/node/relay-bridge.js.map +0 -1
  272. package/lib/node/remote/index.d.ts.map +0 -1
  273. package/lib/node/remote/index.js.map +0 -1
  274. package/lib/node/remote/pi-directories.d.ts.map +0 -1
  275. package/lib/node/remote/pi-directories.js.map +0 -1
  276. package/lib/node/remote/port-forwards.d.ts.map +0 -1
  277. package/lib/node/remote/port-forwards.js.map +0 -1
  278. package/lib/node/remote/remote-hosts.d.ts.map +0 -1
  279. package/lib/node/remote/remote-hosts.js.map +0 -1
  280. package/lib/node/remote/remote-protocol.d.ts.map +0 -1
  281. package/lib/node/remote/remote-protocol.js.map +0 -1
  282. package/lib/node/remote/remote-server-impl.d.ts.map +0 -1
  283. package/lib/node/remote/remote-server-impl.js.map +0 -1
  284. package/lib/node/remote/remote.spec.d.ts +0 -2
  285. package/lib/node/remote/remote.spec.d.ts.map +0 -1
  286. package/lib/node/remote/remote.spec.js +0 -130
  287. package/lib/node/remote/remote.spec.js.map +0 -1
  288. package/lib/node/remote-ui-context.d.ts.map +0 -1
  289. package/lib/node/remote-ui-context.js.map +0 -1
  290. package/lib/node/remote-ui-context.spec.d.ts +0 -2
  291. package/lib/node/remote-ui-context.spec.d.ts.map +0 -1
  292. package/lib/node/remote-ui-context.spec.js +0 -62
  293. package/lib/node/remote-ui-context.spec.js.map +0 -1
  294. package/lib/node/session-info-util.d.ts.map +0 -1
  295. package/lib/node/session-info-util.js.map +0 -1
  296. package/lib/node/session-info-util.spec.d.ts +0 -2
  297. package/lib/node/session-info-util.spec.d.ts.map +0 -1
  298. package/lib/node/session-info-util.spec.js +0 -22
  299. package/lib/node/session-info-util.spec.js.map +0 -1
  300. package/lib/node/session-storage/file-session-storage.d.ts.map +0 -1
  301. package/lib/node/session-storage/file-session-storage.js.map +0 -1
  302. package/lib/node/session-storage/file-session-storage.spec.d.ts +0 -2
  303. package/lib/node/session-storage/file-session-storage.spec.d.ts.map +0 -1
  304. package/lib/node/session-storage/file-session-storage.spec.js +0 -70
  305. package/lib/node/session-storage/file-session-storage.spec.js.map +0 -1
  306. package/lib/node/session-storage/index.d.ts.map +0 -1
  307. package/lib/node/session-storage/index.js.map +0 -1
  308. package/lib/node/session-storage/session-storage-protocol.d.ts.map +0 -1
  309. package/lib/node/session-storage/session-storage-protocol.js.map +0 -1
  310. package/lib/node/session-storage/stored-session.d.ts.map +0 -1
  311. package/lib/node/session-storage/stored-session.js.map +0 -1
  312. package/lib/node/session-storage/stored-session.spec.d.ts +0 -2
  313. package/lib/node/session-storage/stored-session.spec.d.ts.map +0 -1
  314. package/lib/node/session-storage/stored-session.spec.js +0 -73
  315. package/lib/node/session-storage/stored-session.spec.js.map +0 -1
  316. package/lib/node/settings-server-impl.d.ts.map +0 -1
  317. package/lib/node/settings-server-impl.js.map +0 -1
  318. package/lib/node/settings-store.d.ts.map +0 -1
  319. package/lib/node/settings-store.js.map +0 -1
  320. package/lib/node/settings-store.spec.d.ts +0 -2
  321. package/lib/node/settings-store.spec.d.ts.map +0 -1
  322. package/lib/node/settings-store.spec.js +0 -146
  323. package/lib/node/settings-store.spec.js.map +0 -1
  324. package/lib/node/ta-access.d.ts.map +0 -1
  325. package/lib/node/ta-access.js.map +0 -1
  326. package/lib/node/ta-access.spec.d.ts +0 -2
  327. package/lib/node/ta-access.spec.d.ts.map +0 -1
  328. package/lib/node/ta-access.spec.js +0 -33
  329. package/lib/node/ta-access.spec.js.map +0 -1
  330. package/lib/node/ta-errors.d.ts.map +0 -1
  331. package/lib/node/ta-errors.js.map +0 -1
  332. package/lib/node/ta-errors.spec.d.ts +0 -2
  333. package/lib/node/ta-errors.spec.d.ts.map +0 -1
  334. package/lib/node/ta-errors.spec.js +0 -25
  335. package/lib/node/ta-errors.spec.js.map +0 -1
  336. package/lib/node/ta-event-util.d.ts.map +0 -1
  337. package/lib/node/ta-event-util.js.map +0 -1
  338. package/lib/node/ta-event-util.spec.d.ts +0 -2
  339. package/lib/node/ta-event-util.spec.d.ts.map +0 -1
  340. package/lib/node/ta-event-util.spec.js +0 -28
  341. package/lib/node/ta-event-util.spec.js.map +0 -1
  342. package/lib/node/ta-server-impl.d.ts.map +0 -1
  343. package/lib/node/ta-server-impl.js.map +0 -1
  344. package/lib/node/ta-session-factory.d.ts.map +0 -1
  345. package/lib/node/ta-session-factory.js.map +0 -1
  346. package/lib/node/ta-session-registry.d.ts.map +0 -1
  347. package/lib/node/ta-session-registry.js.map +0 -1
  348. package/lib/node/ta-session.d.ts.map +0 -1
  349. package/lib/node/ta-session.js.map +0 -1
  350. package/lib/node/terminal-protocol.d.ts.map +0 -1
  351. package/lib/node/terminal-protocol.js.map +0 -1
  352. package/lib/node/terminal-service.d.ts.map +0 -1
  353. package/lib/node/terminal-service.js.map +0 -1
  354. package/lib/node/terminal-service.spec.d.ts +0 -2
  355. package/lib/node/terminal-service.spec.d.ts.map +0 -1
  356. package/lib/node/terminal-service.spec.js +0 -79
  357. package/lib/node/terminal-service.spec.js.map +0 -1
  358. package/lib/node/terminal-util.d.ts.map +0 -1
  359. package/lib/node/terminal-util.js.map +0 -1
  360. package/lib/node/terminal-util.spec.d.ts +0 -2
  361. package/lib/node/terminal-util.spec.d.ts.map +0 -1
  362. package/lib/node/terminal-util.spec.js +0 -71
  363. package/lib/node/terminal-util.spec.js.map +0 -1
  364. package/lib/node/web-extension-catalog.d.ts.map +0 -1
  365. package/lib/node/web-extension-catalog.js.map +0 -1
  366. package/lib/node/web-extension-catalog.spec.d.ts +0 -2
  367. package/lib/node/web-extension-catalog.spec.d.ts.map +0 -1
  368. package/lib/node/web-extension-catalog.spec.js +0 -157
  369. package/lib/node/web-extension-catalog.spec.js.map +0 -1
  370. package/lib/node/web-extension-util.d.ts.map +0 -1
  371. package/lib/node/web-extension-util.js.map +0 -1
  372. package/lib/node/working-directory.d.ts.map +0 -1
  373. package/lib/node/working-directory.js.map +0 -1
  374. package/lib/node/workspace-files.d.ts.map +0 -1
  375. package/lib/node/workspace-files.js.map +0 -1
  376. package/lib/node/workspace-files.spec.d.ts +0 -2
  377. package/lib/node/workspace-files.spec.d.ts.map +0 -1
  378. package/lib/node/workspace-files.spec.js +0 -133
  379. package/lib/node/workspace-files.spec.js.map +0 -1
  380. package/lib/node/workspace-protocol.d.ts.map +0 -1
  381. package/lib/node/workspace-protocol.js.map +0 -1
  382. package/lib/node/workspace-server-impl.d.ts.map +0 -1
  383. package/lib/node/workspace-server-impl.js.map +0 -1
  384. package/lib/node/workspace-service.d.ts.map +0 -1
  385. package/lib/node/workspace-service.js.map +0 -1
  386. package/lib/node/workspace-service.spec.d.ts +0 -2
  387. package/lib/node/workspace-service.spec.d.ts.map +0 -1
  388. package/lib/node/workspace-service.spec.js +0 -104
  389. package/lib/node/workspace-service.spec.js.map +0 -1
  390. package/lib/node/workspace-util.d.ts.map +0 -1
  391. package/lib/node/workspace-util.js.map +0 -1
  392. package/lib/node/workspace-util.spec.d.ts +0 -2
  393. package/lib/node/workspace-util.spec.d.ts.map +0 -1
  394. package/lib/node/workspace-util.spec.js +0 -44
  395. package/lib/node/workspace-util.spec.js.map +0 -1
  396. package/src/node/auth-server-impl.spec.ts +0 -49
  397. package/src/node/auth-server-impl.ts +0 -252
  398. package/src/node/client-channel.spec.ts +0 -117
  399. package/src/node/client-channel.ts +0 -94
  400. package/src/node/client-tool-broker.spec.ts +0 -53
  401. package/src/node/client-tool-broker.ts +0 -106
  402. package/src/node/event-log.spec.ts +0 -52
  403. package/src/node/event-log.ts +0 -59
  404. package/src/node/exec-environment-factory.ts +0 -66
  405. package/src/node/extension-data-notifier.spec.ts +0 -34
  406. package/src/node/extension-data-notifier.ts +0 -124
  407. package/src/node/extension-data.spec.ts +0 -105
  408. package/src/node/extension-data.ts +0 -180
  409. package/src/node/host-protocol.ts +0 -62
  410. package/src/node/index.ts +0 -37
  411. package/src/node/module.ts +0 -4
  412. package/src/node/package-host-extension.ts +0 -20
  413. package/src/node/package-hosts.spec.ts +0 -54
  414. package/src/node/package-hosts.ts +0 -202
  415. package/src/node/package-server-impl.ts +0 -87
  416. package/src/node/package-switch.ts +0 -80
  417. package/src/node/receipt-book.spec.ts +0 -41
  418. package/src/node/receipt-book.ts +0 -40
  419. package/src/node/relay-bridge.ts +0 -94
  420. package/src/node/remote/index.ts +0 -5
  421. package/src/node/remote/pi-directories.ts +0 -49
  422. package/src/node/remote/port-forwards.ts +0 -148
  423. package/src/node/remote/remote-hosts.ts +0 -170
  424. package/src/node/remote/remote-protocol.ts +0 -57
  425. package/src/node/remote/remote-server-impl.ts +0 -60
  426. package/src/node/remote/remote.spec.ts +0 -142
  427. package/src/node/remote-ui-context.spec.ts +0 -68
  428. package/src/node/remote-ui-context.ts +0 -168
  429. package/src/node/session-info-util.spec.ts +0 -23
  430. package/src/node/session-info-util.ts +0 -55
  431. package/src/node/session-storage/file-session-storage.spec.ts +0 -72
  432. package/src/node/session-storage/file-session-storage.ts +0 -145
  433. package/src/node/session-storage/index.ts +0 -3
  434. package/src/node/session-storage/session-storage-protocol.ts +0 -81
  435. package/src/node/session-storage/stored-session.spec.ts +0 -80
  436. package/src/node/session-storage/stored-session.ts +0 -149
  437. package/src/node/settings-server-impl.ts +0 -33
  438. package/src/node/settings-store.spec.ts +0 -156
  439. package/src/node/settings-store.ts +0 -314
  440. package/src/node/ta-access.spec.ts +0 -36
  441. package/src/node/ta-access.ts +0 -156
  442. package/src/node/ta-errors.spec.ts +0 -25
  443. package/src/node/ta-errors.ts +0 -75
  444. package/src/node/ta-event-util.spec.ts +0 -29
  445. package/src/node/ta-event-util.ts +0 -23
  446. package/src/node/ta-server-impl.ts +0 -341
  447. package/src/node/ta-session-factory.ts +0 -203
  448. package/src/node/ta-session-registry.ts +0 -75
  449. package/src/node/ta-session.ts +0 -240
  450. package/src/node/terminal-protocol.ts +0 -18
  451. package/src/node/terminal-service.spec.ts +0 -84
  452. package/src/node/terminal-service.ts +0 -259
  453. package/src/node/terminal-util.spec.ts +0 -78
  454. package/src/node/terminal-util.ts +0 -166
  455. package/src/node/web-extension-catalog.spec.ts +0 -172
  456. package/src/node/web-extension-catalog.ts +0 -177
  457. package/src/node/web-extension-util.ts +0 -144
  458. package/src/node/working-directory.ts +0 -71
  459. package/src/node/workspace-files.spec.ts +0 -145
  460. package/src/node/workspace-files.ts +0 -256
  461. package/src/node/workspace-protocol.ts +0 -22
  462. package/src/node/workspace-server-impl.ts +0 -90
  463. package/src/node/workspace-service.spec.ts +0 -113
  464. package/src/node/workspace-service.ts +0 -223
  465. package/src/node/workspace-util.spec.ts +0 -47
  466. package/src/node/workspace-util.ts +0 -103
@@ -0,0 +1,175 @@
1
+ import { createHash, randomBytes } from 'node:crypto';
2
+ import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
3
+ import { dirname } from 'node:path';
4
+ /** Requests kept, the latest first, and for how long. */
5
+ const MAX_REQUESTS = 20;
6
+ const REQUEST_TTL_MS = 7 * 24 * 3600 * 1000;
7
+ /** How often a sign-in in use writes when it was last used. */
8
+ const TOUCH_INTERVAL_MS = 3600 * 1000;
9
+ export var AccessUtil;
10
+ (function (AccessUtil) {
11
+ /** Logins and addresses are the same whatever their case; the ids of WeChat and `sub`s are not. */
12
+ function normalize(account) {
13
+ const value = account.trim();
14
+ return value.startsWith('github:') || value.includes('@') ? value.toLowerCase() : value;
15
+ }
16
+ AccessUtil.normalize = normalize;
17
+ /** `google:*@corp.com` lets in every address of the domain; anything else, one account. */
18
+ function matches(pattern, account) {
19
+ const [want, have] = [normalize(pattern), normalize(account)];
20
+ const star = want.indexOf(':*@');
21
+ if (star > 0) {
22
+ return have.startsWith(want.slice(0, star + 1)) && have.endsWith(want.slice(star + 2));
23
+ }
24
+ return want === have;
25
+ }
26
+ AccessUtil.matches = matches;
27
+ /** TA_ALLOWED_USERS: accounts separated by commas, spaces or new lines. */
28
+ function parseList(list) {
29
+ return (list !== null && list !== void 0 ? list : '')
30
+ .split(/[\s,]+/)
31
+ .map(entry => entry.trim())
32
+ .filter(entry => /^[a-z][a-z0-9-]*:.+/.test(entry));
33
+ }
34
+ AccessUtil.parseList = parseList;
35
+ function hash(token) {
36
+ return createHash('sha256').update(token).digest('base64url');
37
+ }
38
+ AccessUtil.hash = hash;
39
+ })(AccessUtil || (AccessUtil = {}));
40
+ /**
41
+ * Who may sign in with an account, and the browsers signed in: `access.json` of the agent directory, which
42
+ * only this user reads, beside the accounts of TA_ALLOWED_USERS. A sign-in lets its browser in while its
43
+ * account is let in: removing the account signs its browsers out.
44
+ */
45
+ export class AccessStore {
46
+ constructor(file, fromEnv = []) {
47
+ this.file = file;
48
+ this.fromEnv = fromEnv;
49
+ this.touched = new Map();
50
+ }
51
+ /** Whether the account is let in, by TA_ALLOWED_USERS or here. */
52
+ allows(account) {
53
+ return this.fromEnv.some(pattern => AccessUtil.matches(pattern, account)) || this.read().accounts.some(added => AccessUtil.matches(added.id, account));
54
+ }
55
+ /** Anyone let in at all: otherwise an account that signs in can only ask. */
56
+ get open() {
57
+ return this.fromEnv.length > 0 || this.read().accounts.length > 0;
58
+ }
59
+ /** A new sign-in of an account let in: the token for its browser, which only it keeps. */
60
+ signIn(account, device, now = Date.now()) {
61
+ const token = randomBytes(32).toString('base64url');
62
+ const data = this.read();
63
+ data.signIns.push({
64
+ id: randomBytes(9).toString('base64url'),
65
+ hash: AccessUtil.hash(token),
66
+ account: account.id,
67
+ name: account.name,
68
+ avatar: account.avatar,
69
+ createdAt: now,
70
+ lastUsedAt: now,
71
+ device: device === null || device === void 0 ? void 0 : device.slice(0, 300),
72
+ });
73
+ data.requests = data.requests.filter(request => request.id !== account.id);
74
+ this.write();
75
+ return token;
76
+ }
77
+ /** The sign-in of a token, while its account is let in. */
78
+ check(token, now = Date.now()) {
79
+ var _a;
80
+ const hash = AccessUtil.hash(token);
81
+ const signIn = this.read().signIns.find(one => one.hash === hash);
82
+ if (!signIn || !this.allows(signIn.account)) {
83
+ return undefined;
84
+ }
85
+ signIn.lastUsedAt = now;
86
+ if (now - ((_a = this.touched.get(signIn.id)) !== null && _a !== void 0 ? _a : signIn.createdAt) >= TOUCH_INTERVAL_MS) {
87
+ this.touched.set(signIn.id, now);
88
+ this.write();
89
+ }
90
+ return signIn;
91
+ }
92
+ /** Someone not let in signed in: the owner sees it, and lets them in with a tap. */
93
+ request(account, now = Date.now()) {
94
+ const data = this.read();
95
+ const others = data.requests.filter(request => request.id !== account.id && now - request.at < REQUEST_TTL_MS);
96
+ data.requests = [{ id: account.id, name: account.name, avatar: account.avatar, at: now }, ...others].slice(0, MAX_REQUESTS);
97
+ this.write();
98
+ }
99
+ allow(account, name, now = Date.now()) {
100
+ const id = AccessUtil.normalize(account);
101
+ const data = this.read();
102
+ const request = data.requests.find(one => one.id === id);
103
+ data.requests = data.requests.filter(one => one.id !== id);
104
+ if (!data.accounts.some(added => added.id === id)) {
105
+ data.accounts.push({ id, name: name !== null && name !== void 0 ? name : request === null || request === void 0 ? void 0 : request.name, avatar: request === null || request === void 0 ? void 0 : request.avatar, addedAt: now });
106
+ }
107
+ this.write();
108
+ }
109
+ dismiss(account) {
110
+ const data = this.read();
111
+ data.requests = data.requests.filter(one => one.id !== AccessUtil.normalize(account));
112
+ this.write();
113
+ }
114
+ /** An account added here no longer lets in; its sign-ins go too, unless TA_ALLOWED_USERS lets it in. */
115
+ disallow(account) {
116
+ const id = AccessUtil.normalize(account);
117
+ const data = this.read();
118
+ data.accounts = data.accounts.filter(added => added.id !== id);
119
+ data.signIns = data.signIns.filter(signIn => this.allows(signIn.account));
120
+ this.write();
121
+ }
122
+ signOut(signInId) {
123
+ const data = this.read();
124
+ data.signIns = data.signIns.filter(signIn => signIn.id !== signInId);
125
+ this.write();
126
+ }
127
+ info(currentToken, now = Date.now()) {
128
+ const data = this.read();
129
+ const current = currentToken && AccessUtil.hash(currentToken);
130
+ const accounts = [
131
+ ...this.fromEnv.map(id => ({ id, source: 'env' })),
132
+ ...data.accounts.map(({ id, name, avatar, addedAt }) => ({ id, name, avatar, addedAt, source: 'added' })),
133
+ ];
134
+ return {
135
+ accounts,
136
+ requests: data.requests.filter(request => now - request.at < REQUEST_TTL_MS && !this.allows(request.id)),
137
+ signIns: data.signIns
138
+ .filter(signIn => this.allows(signIn.account))
139
+ .map(({ id, account, name, createdAt, lastUsedAt, device, hash }) => ({
140
+ id,
141
+ account,
142
+ name,
143
+ createdAt,
144
+ lastUsedAt,
145
+ device,
146
+ current: hash === current,
147
+ })),
148
+ };
149
+ }
150
+ read() {
151
+ if (!this.data) {
152
+ try {
153
+ const parsed = JSON.parse(readFileSync(this.file, 'utf8'));
154
+ this.data = {
155
+ accounts: Array.isArray(parsed.accounts) ? parsed.accounts : [],
156
+ requests: Array.isArray(parsed.requests) ? parsed.requests : [],
157
+ signIns: Array.isArray(parsed.signIns) ? parsed.signIns : [],
158
+ };
159
+ }
160
+ catch (_a) {
161
+ this.data = { accounts: [], requests: [], signIns: [] };
162
+ }
163
+ }
164
+ return this.data;
165
+ }
166
+ /** Whole or not at all: a new file put in the place of the old. */
167
+ write() {
168
+ mkdirSync(dirname(this.file), { recursive: true });
169
+ const temporary = `${this.file}.${process.pid}.tmp`;
170
+ writeFileSync(temporary, JSON.stringify(this.data, undefined, 2), { mode: 0o600 });
171
+ chmodSync(temporary, 0o600);
172
+ renameSync(temporary, this.file);
173
+ }
174
+ }
175
+ //# sourceMappingURL=access-store.js.map
@@ -0,0 +1,7 @@
1
+ export * from './access-server-impl.js';
2
+ export * from './access-store.js';
3
+ export * from './sign-in-flow.js';
4
+ export * from './sign-in-middleware.js';
5
+ export * from './sign-in-pages.js';
6
+ export * from './sign-in-provider.js';
7
+ export * from './ta-sign-in.js';
@@ -0,0 +1,8 @@
1
+ export * from './access-server-impl.js';
2
+ export * from './access-store.js';
3
+ export * from './sign-in-flow.js';
4
+ export * from './sign-in-middleware.js';
5
+ export * from './sign-in-pages.js';
6
+ export * from './sign-in-provider.js';
7
+ export * from './ta-sign-in.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,58 @@
1
+ import type { IncomingMessage } from 'node:http';
2
+ import type { AccessStore } from './access-store.js';
3
+ import { type SignInAccount, type SignInProvider } from './sign-in-provider.js';
4
+ interface Pending {
5
+ provider: string;
6
+ verifier: string;
7
+ redirectUri: string;
8
+ /** Lets the account in: started by someone already in. */
9
+ bind: boolean;
10
+ at: number;
11
+ }
12
+ export type SignInResult = {
13
+ token: string;
14
+ account: SignInAccount;
15
+ } | {
16
+ denied: SignInAccount;
17
+ };
18
+ export declare namespace SignInUtil {
19
+ /**
20
+ * Where the browser reaches ta serve: TA_PUBLIC_URL, otherwise what the request says, behind a proxy
21
+ * its `X-Forwarded-*`. A provider only sends the browser back to an address registered with it.
22
+ */
23
+ function origin(request: IncomingMessage, publicUrl?: string): string;
24
+ function redirectUri(origin: string, provider: string): string;
25
+ /** PKCE's pair: the verifier stays here, the challenge goes to the provider. */
26
+ function pkce(): {
27
+ verifier: string;
28
+ challenge: string;
29
+ };
30
+ }
31
+ /**
32
+ * Signing in with an account (GitHub, Google, WeChat, an OpenID Connect provider): OAuth 2.0's authorization
33
+ * code, with PKCE, the account let in or not by `store`. Plain, without Cell: ta serve (TaSignIn) and the
34
+ * gateway (`ta gateway`) use it alike.
35
+ */
36
+ export declare class SignInFlow {
37
+ readonly providers: SignInProvider[];
38
+ readonly store: AccessStore;
39
+ readonly publicUrl?: string | undefined;
40
+ constructor(providers: SignInProvider[], store: AccessStore, publicUrl?: string | undefined);
41
+ protected readonly pending: Map<string, Pending>;
42
+ protected readonly binds: Map<string, {
43
+ provider: string;
44
+ at: number;
45
+ }>;
46
+ provider(id: string): SignInProvider | undefined;
47
+ /** A link, used once, that signs in with `provider` and lets the account in. */
48
+ bindUrl(provider: string, now?: number): string;
49
+ /** Where the browser goes, and the state that comes back with it. */
50
+ start(providerId: string, origin: string, bind?: string, now?: number): Promise<{
51
+ url: string;
52
+ state: string;
53
+ }>;
54
+ /** The browser came back from the provider with a code: in with a token of its own, or told to wait. */
55
+ finish(providerId: string, state: string, code: string, device?: string, now?: number): Promise<SignInResult>;
56
+ protected prune(now: number): void;
57
+ }
58
+ export {};
@@ -0,0 +1,104 @@
1
+ import { createHash, randomBytes } from 'node:crypto';
2
+ import { TA_SIGN_IN_PATH } from '@celljs/ta-protocol';
3
+ import { SignInError } from './sign-in-provider.js';
4
+ /** How long the browser has with the provider, and a link of {@link SignInFlow.bindUrl}. */
5
+ const PENDING_TTL_MS = 10 * 60 * 1000;
6
+ const BIND_TTL_MS = 5 * 60 * 1000;
7
+ export var SignInUtil;
8
+ (function (SignInUtil) {
9
+ /**
10
+ * Where the browser reaches ta serve: TA_PUBLIC_URL, otherwise what the request says, behind a proxy
11
+ * its `X-Forwarded-*`. A provider only sends the browser back to an address registered with it.
12
+ */
13
+ function origin(request, publicUrl) {
14
+ var _a;
15
+ if (publicUrl) {
16
+ return publicUrl;
17
+ }
18
+ const first = (value) => { var _a; return (_a = (Array.isArray(value) ? value[0] : value)) === null || _a === void 0 ? void 0 : _a.split(',')[0].trim(); };
19
+ const proto = first(request.headers['x-forwarded-proto']) || (((_a = request.socket) === null || _a === void 0 ? void 0 : _a.encrypted) ? 'https' : 'http');
20
+ return `${proto}://${first(request.headers['x-forwarded-host']) || request.headers.host}`;
21
+ }
22
+ SignInUtil.origin = origin;
23
+ function redirectUri(origin, provider) {
24
+ return `${origin}${TA_SIGN_IN_PATH}/${provider}/callback`;
25
+ }
26
+ SignInUtil.redirectUri = redirectUri;
27
+ /** PKCE's pair: the verifier stays here, the challenge goes to the provider. */
28
+ function pkce() {
29
+ const verifier = randomBytes(32).toString('base64url');
30
+ return { verifier, challenge: createHash('sha256').update(verifier).digest('base64url') };
31
+ }
32
+ SignInUtil.pkce = pkce;
33
+ })(SignInUtil || (SignInUtil = {}));
34
+ /**
35
+ * Signing in with an account (GitHub, Google, WeChat, an OpenID Connect provider): OAuth 2.0's authorization
36
+ * code, with PKCE, the account let in or not by `store`. Plain, without Cell: ta serve (TaSignIn) and the
37
+ * gateway (`ta gateway`) use it alike.
38
+ */
39
+ export class SignInFlow {
40
+ constructor(providers, store, publicUrl) {
41
+ this.providers = providers;
42
+ this.store = store;
43
+ this.publicUrl = publicUrl;
44
+ this.pending = new Map();
45
+ this.binds = new Map();
46
+ }
47
+ provider(id) {
48
+ return this.providers.find(provider => provider.id === id);
49
+ }
50
+ /** A link, used once, that signs in with `provider` and lets the account in. */
51
+ bindUrl(provider, now = Date.now()) {
52
+ const nonce = randomBytes(18).toString('base64url');
53
+ this.binds.set(nonce, { provider, at: now });
54
+ return `${TA_SIGN_IN_PATH}/${provider}?bind=${nonce}`;
55
+ }
56
+ /** Where the browser goes, and the state that comes back with it. */
57
+ async start(providerId, origin, bind, now = Date.now()) {
58
+ const provider = this.provider(providerId);
59
+ if (!provider) {
60
+ throw new SignInError(`No provider ${providerId}`);
61
+ }
62
+ this.prune(now);
63
+ const binding = bind ? this.binds.get(bind) : undefined;
64
+ if (bind) {
65
+ this.binds.delete(bind);
66
+ }
67
+ const state = randomBytes(18).toString('base64url');
68
+ const { verifier, challenge } = SignInUtil.pkce();
69
+ const redirectUri = SignInUtil.redirectUri(origin, provider.id);
70
+ this.pending.set(state, { provider: provider.id, verifier, redirectUri, bind: (binding === null || binding === void 0 ? void 0 : binding.provider) === provider.id, at: now });
71
+ return { url: await provider.authorizeUrl({ redirectUri, state, challenge }), state };
72
+ }
73
+ /** The browser came back from the provider with a code: in with a token of its own, or told to wait. */
74
+ async finish(providerId, state, code, device, now = Date.now()) {
75
+ const pending = this.pending.get(state);
76
+ this.pending.delete(state);
77
+ const provider = this.provider(providerId);
78
+ if (!pending || !provider || pending.provider !== providerId || now - pending.at > PENDING_TTL_MS) {
79
+ throw new SignInError('The sign-in expired or was not started here');
80
+ }
81
+ const account = await provider.account({ code, redirectUri: pending.redirectUri, verifier: pending.verifier });
82
+ if (pending.bind) {
83
+ this.store.allow(account.id, account.name, now);
84
+ }
85
+ if (!this.store.allows(account.id)) {
86
+ this.store.request(account, now);
87
+ return { denied: account };
88
+ }
89
+ return { token: this.store.signIn(account, device, now), account };
90
+ }
91
+ prune(now) {
92
+ for (const [state, pending] of this.pending) {
93
+ if (now - pending.at > PENDING_TTL_MS) {
94
+ this.pending.delete(state);
95
+ }
96
+ }
97
+ for (const [nonce, bind] of this.binds) {
98
+ if (now - bind.at > BIND_TTL_MS) {
99
+ this.binds.delete(nonce);
100
+ }
101
+ }
102
+ }
103
+ }
104
+ //# sourceMappingURL=sign-in-flow.js.map
@@ -0,0 +1,10 @@
1
+ import { type Context, Middleware } from '@celljs/web/lib/node';
2
+ import { type TaSignIn } from './ta-sign-in.js';
3
+ /** The pages of signing in with an account (SignInPages) in ta serve. */
4
+ export declare class SignInMiddleware implements Middleware {
5
+ /** Before TaAccess, which needs a token for what it does not know. */
6
+ readonly priority: number;
7
+ protected readonly signIn: TaSignIn;
8
+ protected readonly host?: string;
9
+ handle(ctx: Context, next: () => Promise<void>): Promise<void>;
10
+ }
@@ -0,0 +1,48 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Autowired, Component, Value } from '@celljs/core';
11
+ import { Middleware } from '@celljs/web/lib/node';
12
+ import { ACCESS_MIDDLEWARE_PRIORITY, TaAccessUtil } from '../ta-access.js';
13
+ import { SignInPages, SignInPageUtil } from './sign-in-pages.js';
14
+ import { TA_SIGN_IN } from './ta-sign-in.js';
15
+ /** The pages of signing in with an account (SignInPages) in ta serve. */
16
+ let SignInMiddleware = class SignInMiddleware {
17
+ constructor() {
18
+ /** Before TaAccess, which needs a token for what it does not know. */
19
+ this.priority = ACCESS_MIDDLEWARE_PRIORITY + 1;
20
+ }
21
+ async handle(ctx, next) {
22
+ const request = ctx.request;
23
+ if (!SignInPages.matches(request)) {
24
+ await next();
25
+ return;
26
+ }
27
+ const response = ctx.response;
28
+ // A page that rebinds its domain to a ta serve of 127.0.0.1 gets nothing, as from TaAccess.
29
+ if (TaAccessUtil.isLoopbackHost(this.host) && !TaAccessUtil.isLoopbackHost(request.headers.host)) {
30
+ SignInPageUtil.end(response, 404);
31
+ return;
32
+ }
33
+ await SignInPages.handle(request, response, this.signIn, { name: 'ta serve' });
34
+ }
35
+ };
36
+ __decorate([
37
+ Autowired(TA_SIGN_IN),
38
+ __metadata("design:type", Function)
39
+ ], SignInMiddleware.prototype, "signIn", void 0);
40
+ __decorate([
41
+ Value('server.host'),
42
+ __metadata("design:type", String)
43
+ ], SignInMiddleware.prototype, "host", void 0);
44
+ SignInMiddleware = __decorate([
45
+ Component(Middleware)
46
+ ], SignInMiddleware);
47
+ export { SignInMiddleware };
48
+ //# sourceMappingURL=sign-in-middleware.js.map
@@ -0,0 +1,31 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ import { type TaSignInOutcome } from '@celljs/ta-protocol';
3
+ import { type SignInFlow } from './sign-in-flow.js';
4
+ import type { SignInAccount } from './sign-in-provider.js';
5
+ export declare namespace SignInPageUtil {
6
+ function cookie(header: string | undefined, name: string): string | undefined;
7
+ /** The page of the web client, told how the sign-in went in its fragment, which no server sees. */
8
+ function back(fragment: {
9
+ token: string;
10
+ } | {
11
+ outcome: TaSignInOutcome;
12
+ account?: string;
13
+ }): string;
14
+ function redirect(response: ServerResponse, location: string): void;
15
+ function end(response: ServerResponse, status: number, body?: string): void;
16
+ }
17
+ export interface SignInPagesOptions {
18
+ /** Who writes to the log: `ta serve`, `ta gateway`. */
19
+ name: string;
20
+ /** A browser signed in, before it goes back to the web client: the gateway sets a cookie of it. */
21
+ onSignedIn?(response: ServerResponse, token: string, account: SignInAccount, origin: string): void | Promise<void>;
22
+ }
23
+ /**
24
+ * The pages of TA_SIGN_IN_PATH, which the browser goes to without a token: the ways to sign in, the way to
25
+ * a provider, and back from it to the web client with a token of its own (`/#token=`, as `ta serve --web`).
26
+ * False for a request of another path.
27
+ */
28
+ export declare namespace SignInPages {
29
+ function matches(request: IncomingMessage): boolean;
30
+ function handle(request: IncomingMessage, response: ServerResponse, flow: SignInFlow, options: SignInPagesOptions): Promise<void>;
31
+ }
@@ -0,0 +1,118 @@
1
+ import { TA_SIGN_IN_PATH } from '@celljs/ta-protocol';
2
+ import { SignInUtil } from './sign-in-flow.js';
3
+ /** Ties the browser that comes back from the provider to the one that went: login CSRF. */
4
+ const STATE_COOKIE = 'ta_sign_in';
5
+ export var SignInPageUtil;
6
+ (function (SignInPageUtil) {
7
+ function cookie(header, name) {
8
+ for (const part of (header !== null && header !== void 0 ? header : '').split(';')) {
9
+ const [key, ...value] = part.trim().split('=');
10
+ if (key === name) {
11
+ return decodeURIComponent(value.join('='));
12
+ }
13
+ }
14
+ return undefined;
15
+ }
16
+ SignInPageUtil.cookie = cookie;
17
+ /** The page of the web client, told how the sign-in went in its fragment, which no server sees. */
18
+ function back(fragment) {
19
+ const params = new URLSearchParams('token' in fragment ? { token: fragment.token } : { 'sign-in': fragment.outcome, ...(fragment.account ? { account: fragment.account } : {}) });
20
+ return `/#${params.toString()}`;
21
+ }
22
+ SignInPageUtil.back = back;
23
+ function redirect(response, location) {
24
+ response.statusCode = 302;
25
+ response.setHeader('Location', location);
26
+ response.end();
27
+ }
28
+ SignInPageUtil.redirect = redirect;
29
+ function end(response, status, body = '') {
30
+ response.statusCode = status;
31
+ response.end(body);
32
+ }
33
+ SignInPageUtil.end = end;
34
+ })(SignInPageUtil || (SignInPageUtil = {}));
35
+ /**
36
+ * The pages of TA_SIGN_IN_PATH, which the browser goes to without a token: the ways to sign in, the way to
37
+ * a provider, and back from it to the web client with a token of its own (`/#token=`, as `ta serve --web`).
38
+ * False for a request of another path.
39
+ */
40
+ export var SignInPages;
41
+ (function (SignInPages) {
42
+ function matches(request) {
43
+ var _a;
44
+ const path = ((_a = request.url) !== null && _a !== void 0 ? _a : '/').split('?')[0];
45
+ return path === TA_SIGN_IN_PATH || path.startsWith(`${TA_SIGN_IN_PATH}/`);
46
+ }
47
+ SignInPages.matches = matches;
48
+ async function handle(request, response, flow, options) {
49
+ var _a, _b;
50
+ const url = new URL((_a = request.url) !== null && _a !== void 0 ? _a : '/', 'http://localhost');
51
+ response.setHeader('Cache-Control', 'no-store');
52
+ response.setHeader('Referrer-Policy', 'no-referrer');
53
+ if (request.method !== 'GET' && request.method !== 'HEAD') {
54
+ response.setHeader('Allow', 'GET, HEAD');
55
+ SignInPageUtil.end(response, 405);
56
+ return;
57
+ }
58
+ const [providerId, step, ...rest] = url.pathname.slice(TA_SIGN_IN_PATH.length + 1).split('/');
59
+ if (!providerId) {
60
+ const ways = { providers: flow.providers.map(({ id, name }) => ({ id, name })) };
61
+ response.setHeader('Content-Type', 'application/json');
62
+ SignInPageUtil.end(response, 200, JSON.stringify(ways));
63
+ return;
64
+ }
65
+ if (!flow.provider(providerId) || rest.length > 0 || (step && step !== 'callback')) {
66
+ SignInPageUtil.end(response, 404);
67
+ return;
68
+ }
69
+ if (!step) {
70
+ await go(request, response, flow, providerId, (_b = url.searchParams.get('bind')) !== null && _b !== void 0 ? _b : undefined, options);
71
+ return;
72
+ }
73
+ await back(request, response, flow, providerId, url.searchParams, options);
74
+ }
75
+ SignInPages.handle = handle;
76
+ async function go(request, response, flow, providerId, bind, options) {
77
+ const origin = SignInUtil.origin(request, flow.publicUrl);
78
+ try {
79
+ const { url, state } = await flow.start(providerId, origin, bind);
80
+ const secure = origin.startsWith('https:') ? '; Secure' : '';
81
+ response.setHeader('Set-Cookie', `${STATE_COOKIE}=${state}; Path=${TA_SIGN_IN_PATH}; Max-Age=600; HttpOnly; SameSite=Lax${secure}`);
82
+ SignInPageUtil.redirect(response, url);
83
+ }
84
+ catch (error) {
85
+ console.warn(`${options.name}: signing in with ${providerId} failed: ${error instanceof Error ? error.message : error}`);
86
+ SignInPageUtil.redirect(response, SignInPageUtil.back({ outcome: 'failed' }));
87
+ }
88
+ }
89
+ async function back(request, response, flow, providerId, params, options) {
90
+ var _a;
91
+ var _b;
92
+ const state = (_b = params.get('state')) !== null && _b !== void 0 ? _b : '';
93
+ const code = params.get('code');
94
+ response.setHeader('Set-Cookie', `${STATE_COOKIE}=; Path=${TA_SIGN_IN_PATH}; Max-Age=0; HttpOnly; SameSite=Lax`);
95
+ if (!code || !state || SignInPageUtil.cookie(request.headers.cookie, STATE_COOKIE) !== state) {
96
+ // Cancelled at the provider (`error`), or a link that did not start in this browser.
97
+ SignInPageUtil.redirect(response, SignInPageUtil.back({ outcome: 'failed' }));
98
+ return;
99
+ }
100
+ try {
101
+ const result = await flow.finish(providerId, state, code, request.headers['user-agent']);
102
+ if ('token' in result) {
103
+ console.log(`${options.name}: ${result.account.id} signed in`);
104
+ await ((_a = options.onSignedIn) === null || _a === void 0 ? void 0 : _a.call(options, response, result.token, result.account, SignInUtil.origin(request, flow.publicUrl)));
105
+ SignInPageUtil.redirect(response, SignInPageUtil.back({ token: result.token }));
106
+ }
107
+ else {
108
+ console.log(`${options.name}: ${result.denied.id} signed in and waits to be let in`);
109
+ SignInPageUtil.redirect(response, SignInPageUtil.back({ outcome: 'denied', account: result.denied.id }));
110
+ }
111
+ }
112
+ catch (error) {
113
+ console.warn(`${options.name}: signing in with ${providerId} failed: ${error instanceof Error ? error.message : error}`);
114
+ SignInPageUtil.redirect(response, SignInPageUtil.back({ outcome: 'failed' }));
115
+ }
116
+ }
117
+ })(SignInPages || (SignInPages = {}));
118
+ //# sourceMappingURL=sign-in-pages.js.map