@celljs/ta-host 4.8.0 → 4.9.1

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