@earendil-works/chord 1.4.0 → 1.5.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 (820) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +79 -14
  3. package/dist/cell.d.ts +7 -7
  4. package/dist/cell.d.ts.map +1 -1
  5. package/dist/cell.js.map +1 -1
  6. package/dist/context/index.d.ts +1 -1
  7. package/dist/context/index.d.ts.map +1 -1
  8. package/dist/context/index.js +1 -1
  9. package/dist/context/index.js.map +1 -1
  10. package/dist/contract.d.ts +51 -52
  11. package/dist/contract.d.ts.map +1 -1
  12. package/dist/contract.js +19 -24
  13. package/dist/contract.js.map +1 -1
  14. package/dist/delta/apply-immutable-trusted.js +3 -4
  15. package/dist/delta/apply-immutable-trusted.js.map +1 -1
  16. package/dist/delta/diff.d.ts.map +1 -1
  17. package/dist/delta/diff.js +5 -3
  18. package/dist/delta/diff.js.map +1 -1
  19. package/dist/delta/index.d.ts +9 -1
  20. package/dist/delta/index.d.ts.map +1 -1
  21. package/dist/delta/index.js +15 -11
  22. package/dist/delta/index.js.map +1 -1
  23. package/dist/delta/pending.d.ts +36 -0
  24. package/dist/delta/pending.d.ts.map +1 -0
  25. package/dist/delta/pending.js +143 -0
  26. package/dist/delta/pending.js.map +1 -0
  27. package/dist/delta/tracker.d.ts +12 -0
  28. package/dist/delta/tracker.d.ts.map +1 -1
  29. package/dist/delta/tracker.js +109 -39
  30. package/dist/delta/tracker.js.map +1 -1
  31. package/dist/host.d.ts.map +1 -1
  32. package/dist/host.js +9 -7
  33. package/dist/host.js.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/next/contracts/accepts.d.ts +81 -0
  39. package/dist/next/contracts/accepts.d.ts.map +1 -0
  40. package/dist/next/contracts/accepts.js +123 -0
  41. package/dist/next/contracts/accepts.js.map +1 -0
  42. package/dist/next/contracts/contract.d.ts +121 -0
  43. package/dist/next/contracts/contract.d.ts.map +1 -0
  44. package/dist/next/contracts/contract.js +50 -0
  45. package/dist/next/contracts/contract.js.map +1 -0
  46. package/dist/next/contracts/declare.d.ts +107 -0
  47. package/dist/next/contracts/declare.d.ts.map +1 -0
  48. package/dist/next/contracts/declare.js +136 -0
  49. package/dist/next/contracts/declare.js.map +1 -0
  50. package/dist/next/contracts/evolve.d.ts +92 -0
  51. package/dist/next/contracts/evolve.d.ts.map +1 -0
  52. package/dist/next/contracts/evolve.js +179 -0
  53. package/dist/next/contracts/evolve.js.map +1 -0
  54. package/dist/next/contracts/fingerprint.d.ts +16 -0
  55. package/dist/next/contracts/fingerprint.d.ts.map +1 -0
  56. package/dist/next/contracts/fingerprint.js +50 -0
  57. package/dist/next/contracts/fingerprint.js.map +1 -0
  58. package/dist/next/contracts/history.d.ts +71 -0
  59. package/dist/next/contracts/history.d.ts.map +1 -0
  60. package/dist/next/contracts/history.js +3 -0
  61. package/dist/next/contracts/history.js.map +1 -0
  62. package/dist/next/contracts/host-kind.d.ts +40 -0
  63. package/dist/next/contracts/host-kind.d.ts.map +1 -0
  64. package/dist/next/contracts/host-kind.js +37 -0
  65. package/dist/next/contracts/host-kind.js.map +1 -0
  66. package/dist/next/contracts/index.d.ts +7 -0
  67. package/dist/next/contracts/index.d.ts.map +1 -0
  68. package/dist/next/contracts/index.js +6 -0
  69. package/dist/next/contracts/index.js.map +1 -0
  70. package/dist/next/contracts/internal.d.ts +10 -0
  71. package/dist/next/contracts/internal.d.ts.map +1 -0
  72. package/dist/next/contracts/internal.js +9 -0
  73. package/dist/next/contracts/internal.js.map +1 -0
  74. package/dist/next/contracts/names.d.ts +3 -0
  75. package/dist/next/contracts/names.d.ts.map +1 -0
  76. package/dist/next/contracts/names.js +13 -0
  77. package/dist/next/contracts/names.js.map +1 -0
  78. package/dist/next/contracts/params.d.ts +28 -0
  79. package/dist/next/contracts/params.d.ts.map +1 -0
  80. package/dist/next/contracts/params.js +50 -0
  81. package/dist/next/contracts/params.js.map +1 -0
  82. package/dist/next/contracts/schema.d.ts +102 -0
  83. package/dist/next/contracts/schema.d.ts.map +1 -0
  84. package/dist/next/contracts/schema.js +103 -0
  85. package/dist/next/contracts/schema.js.map +1 -0
  86. package/dist/next/contracts/snapshot.d.ts +16 -0
  87. package/dist/next/contracts/snapshot.d.ts.map +1 -0
  88. package/dist/next/contracts/snapshot.js +167 -0
  89. package/dist/next/contracts/snapshot.js.map +1 -0
  90. package/dist/next/data/args.d.ts +50 -0
  91. package/dist/next/data/args.d.ts.map +1 -0
  92. package/dist/next/data/args.js +83 -0
  93. package/dist/next/data/args.js.map +1 -0
  94. package/dist/next/data/errors.d.ts +73 -0
  95. package/dist/next/data/errors.d.ts.map +1 -0
  96. package/dist/next/data/errors.js +107 -0
  97. package/dist/next/data/errors.js.map +1 -0
  98. package/dist/next/data/failure.d.ts +26 -0
  99. package/dist/next/data/failure.d.ts.map +1 -0
  100. package/dist/next/data/failure.js +72 -0
  101. package/dist/next/data/failure.js.map +1 -0
  102. package/dist/next/data/index.d.ts +4 -0
  103. package/dist/next/data/index.d.ts.map +1 -0
  104. package/dist/next/data/index.js +4 -0
  105. package/dist/next/data/index.js.map +1 -0
  106. package/dist/next/data/internal.d.ts +7 -0
  107. package/dist/next/data/internal.d.ts.map +1 -0
  108. package/dist/next/data/internal.js +8 -0
  109. package/dist/next/data/internal.js.map +1 -0
  110. package/dist/next/data/params.d.ts +20 -0
  111. package/dist/next/data/params.d.ts.map +1 -0
  112. package/dist/next/data/params.js +31 -0
  113. package/dist/next/data/params.js.map +1 -0
  114. package/dist/next/data/principal.d.ts +17 -0
  115. package/dist/next/data/principal.d.ts.map +1 -0
  116. package/dist/next/data/principal.js +41 -0
  117. package/dist/next/data/principal.js.map +1 -0
  118. package/dist/next/data/validator.d.ts +12 -0
  119. package/dist/next/data/validator.d.ts.map +1 -0
  120. package/dist/next/data/validator.js +34 -0
  121. package/dist/next/data/validator.js.map +1 -0
  122. package/dist/next/documents/address-source.d.ts +20 -0
  123. package/dist/next/documents/address-source.d.ts.map +1 -0
  124. package/dist/next/documents/address-source.js +44 -0
  125. package/dist/next/documents/address-source.js.map +1 -0
  126. package/dist/next/documents/definition.d.ts +84 -0
  127. package/dist/next/documents/definition.d.ts.map +1 -0
  128. package/dist/next/documents/definition.js +73 -0
  129. package/dist/next/documents/definition.js.map +1 -0
  130. package/dist/next/documents/documents.d.ts +106 -0
  131. package/dist/next/documents/documents.d.ts.map +1 -0
  132. package/dist/next/documents/documents.js +224 -0
  133. package/dist/next/documents/documents.js.map +1 -0
  134. package/dist/next/documents/fence.d.ts +9 -0
  135. package/dist/next/documents/fence.d.ts.map +1 -0
  136. package/dist/next/documents/fence.js +15 -0
  137. package/dist/next/documents/fence.js.map +1 -0
  138. package/dist/next/documents/handles.d.ts +76 -0
  139. package/dist/next/documents/handles.d.ts.map +1 -0
  140. package/dist/next/documents/handles.js +66 -0
  141. package/dist/next/documents/handles.js.map +1 -0
  142. package/dist/next/documents/index.d.ts +4 -0
  143. package/dist/next/documents/index.d.ts.map +1 -0
  144. package/dist/next/documents/index.js +3 -0
  145. package/dist/next/documents/index.js.map +1 -0
  146. package/dist/next/documents/internal.d.ts +9 -0
  147. package/dist/next/documents/internal.d.ts.map +1 -0
  148. package/dist/next/documents/internal.js +9 -0
  149. package/dist/next/documents/internal.js.map +1 -0
  150. package/dist/next/documents/keyed-slot.d.ts +103 -0
  151. package/dist/next/documents/keyed-slot.d.ts.map +1 -0
  152. package/dist/next/documents/keyed-slot.js +395 -0
  153. package/dist/next/documents/keyed-slot.js.map +1 -0
  154. package/dist/next/documents/line.d.ts +7 -0
  155. package/dist/next/documents/line.d.ts.map +1 -0
  156. package/dist/next/documents/line.js +14 -0
  157. package/dist/next/documents/line.js.map +1 -0
  158. package/dist/next/documents/persistence.d.ts +104 -0
  159. package/dist/next/documents/persistence.d.ts.map +1 -0
  160. package/dist/next/documents/persistence.js +128 -0
  161. package/dist/next/documents/persistence.js.map +1 -0
  162. package/dist/next/documents/residency.d.ts +31 -0
  163. package/dist/next/documents/residency.d.ts.map +1 -0
  164. package/dist/next/documents/residency.js +93 -0
  165. package/dist/next/documents/residency.js.map +1 -0
  166. package/dist/next/documents/slot.d.ts +109 -0
  167. package/dist/next/documents/slot.d.ts.map +1 -0
  168. package/dist/next/documents/slot.js +181 -0
  169. package/dist/next/documents/slot.js.map +1 -0
  170. package/dist/next/documents/transaction.d.ts +133 -0
  171. package/dist/next/documents/transaction.d.ts.map +1 -0
  172. package/dist/next/documents/transaction.js +409 -0
  173. package/dist/next/documents/transaction.js.map +1 -0
  174. package/dist/next/host/activity.d.ts +31 -0
  175. package/dist/next/host/activity.d.ts.map +1 -0
  176. package/dist/next/host/activity.js +40 -0
  177. package/dist/next/host/activity.js.map +1 -0
  178. package/dist/next/host/adapted.d.ts +49 -0
  179. package/dist/next/host/adapted.d.ts.map +1 -0
  180. package/dist/next/host/adapted.js +214 -0
  181. package/dist/next/host/adapted.js.map +1 -0
  182. package/dist/next/host/attempt.d.ts +278 -0
  183. package/dist/next/host/attempt.d.ts.map +1 -0
  184. package/dist/next/host/attempt.js +1072 -0
  185. package/dist/next/host/attempt.js.map +1 -0
  186. package/dist/next/host/backoff.d.ts +29 -0
  187. package/dist/next/host/backoff.d.ts.map +1 -0
  188. package/dist/next/host/backoff.js +69 -0
  189. package/dist/next/host/backoff.js.map +1 -0
  190. package/dist/next/host/ctx.d.ts +47 -0
  191. package/dist/next/host/ctx.d.ts.map +1 -0
  192. package/dist/next/host/ctx.js +108 -0
  193. package/dist/next/host/ctx.js.map +1 -0
  194. package/dist/next/host/deadline.d.ts +12 -0
  195. package/dist/next/host/deadline.d.ts.map +1 -0
  196. package/dist/next/host/deadline.js +40 -0
  197. package/dist/next/host/deadline.js.map +1 -0
  198. package/dist/next/host/dependencies.d.ts +65 -0
  199. package/dist/next/host/dependencies.d.ts.map +1 -0
  200. package/dist/next/host/dependencies.js +115 -0
  201. package/dist/next/host/dependencies.js.map +1 -0
  202. package/dist/next/host/destination.d.ts +48 -0
  203. package/dist/next/host/destination.d.ts.map +1 -0
  204. package/dist/next/host/destination.js +101 -0
  205. package/dist/next/host/destination.js.map +1 -0
  206. package/dist/next/host/facet.d.ts +79 -0
  207. package/dist/next/host/facet.d.ts.map +1 -0
  208. package/dist/next/host/facet.js +55 -0
  209. package/dist/next/host/facet.js.map +1 -0
  210. package/dist/next/host/follow.d.ts +52 -0
  211. package/dist/next/host/follow.d.ts.map +1 -0
  212. package/dist/next/host/follow.js +207 -0
  213. package/dist/next/host/follow.js.map +1 -0
  214. package/dist/next/host/host.d.ts +495 -0
  215. package/dist/next/host/host.d.ts.map +1 -0
  216. package/dist/next/host/host.js +1075 -0
  217. package/dist/next/host/host.js.map +1 -0
  218. package/dist/next/host/index.d.ts +17 -0
  219. package/dist/next/host/index.d.ts.map +1 -0
  220. package/dist/next/host/index.js +6 -0
  221. package/dist/next/host/index.js.map +1 -0
  222. package/dist/next/host/internal.d.ts +10 -0
  223. package/dist/next/host/internal.d.ts.map +1 -0
  224. package/dist/next/host/internal.js +8 -0
  225. package/dist/next/host/internal.js.map +1 -0
  226. package/dist/next/host/members.d.ts +50 -0
  227. package/dist/next/host/members.d.ts.map +1 -0
  228. package/dist/next/host/members.js +107 -0
  229. package/dist/next/host/members.js.map +1 -0
  230. package/dist/next/host/native.d.ts +55 -0
  231. package/dist/next/host/native.d.ts.map +1 -0
  232. package/dist/next/host/native.js +92 -0
  233. package/dist/next/host/native.js.map +1 -0
  234. package/dist/next/host/object.d.ts +290 -0
  235. package/dist/next/host/object.d.ts.map +1 -0
  236. package/dist/next/host/object.js +1127 -0
  237. package/dist/next/host/object.js.map +1 -0
  238. package/dist/next/host/parked.d.ts +23 -0
  239. package/dist/next/host/parked.d.ts.map +1 -0
  240. package/dist/next/host/parked.js +79 -0
  241. package/dist/next/host/parked.js.map +1 -0
  242. package/dist/next/host/presence.d.ts +34 -0
  243. package/dist/next/host/presence.d.ts.map +1 -0
  244. package/dist/next/host/presence.js +117 -0
  245. package/dist/next/host/presence.js.map +1 -0
  246. package/dist/next/host/ref-state.d.ts +53 -0
  247. package/dist/next/host/ref-state.d.ts.map +1 -0
  248. package/dist/next/host/ref-state.js +83 -0
  249. package/dist/next/host/ref-state.js.map +1 -0
  250. package/dist/next/host/reference-keys.d.ts +36 -0
  251. package/dist/next/host/reference-keys.d.ts.map +1 -0
  252. package/dist/next/host/reference-keys.js +168 -0
  253. package/dist/next/host/reference-keys.js.map +1 -0
  254. package/dist/next/host/reference-source.d.ts +65 -0
  255. package/dist/next/host/reference-source.d.ts.map +1 -0
  256. package/dist/next/host/reference-source.js +285 -0
  257. package/dist/next/host/reference-source.js.map +1 -0
  258. package/dist/next/host/reference.d.ts +308 -0
  259. package/dist/next/host/reference.d.ts.map +1 -0
  260. package/dist/next/host/reference.js +775 -0
  261. package/dist/next/host/reference.js.map +1 -0
  262. package/dist/next/host/retry-on.d.ts +28 -0
  263. package/dist/next/host/retry-on.d.ts.map +1 -0
  264. package/dist/next/host/retry-on.js +52 -0
  265. package/dist/next/host/retry-on.js.map +1 -0
  266. package/dist/next/host/revocation.d.ts +16 -0
  267. package/dist/next/host/revocation.d.ts.map +1 -0
  268. package/dist/next/host/revocation.js +27 -0
  269. package/dist/next/host/revocation.js.map +1 -0
  270. package/dist/next/host/root.d.ts +27 -0
  271. package/dist/next/host/root.d.ts.map +1 -0
  272. package/dist/next/host/root.js +68 -0
  273. package/dist/next/host/root.js.map +1 -0
  274. package/dist/next/host/route.d.ts +64 -0
  275. package/dist/next/host/route.d.ts.map +1 -0
  276. package/dist/next/host/route.js +190 -0
  277. package/dist/next/host/route.js.map +1 -0
  278. package/dist/next/host/routines.d.ts +76 -0
  279. package/dist/next/host/routines.d.ts.map +1 -0
  280. package/dist/next/host/routines.js +350 -0
  281. package/dist/next/host/routines.js.map +1 -0
  282. package/dist/next/host/sleep.d.ts +9 -0
  283. package/dist/next/host/sleep.d.ts.map +1 -0
  284. package/dist/next/host/sleep.js +40 -0
  285. package/dist/next/host/sleep.js.map +1 -0
  286. package/dist/next/host/staging.d.ts +94 -0
  287. package/dist/next/host/staging.d.ts.map +1 -0
  288. package/dist/next/host/staging.js +302 -0
  289. package/dist/next/host/staging.js.map +1 -0
  290. package/dist/next/host/unbound.d.ts +30 -0
  291. package/dist/next/host/unbound.d.ts.map +1 -0
  292. package/dist/next/host/unbound.js +67 -0
  293. package/dist/next/host/unbound.js.map +1 -0
  294. package/dist/next/host/uuid.d.ts +3 -0
  295. package/dist/next/host/uuid.d.ts.map +1 -0
  296. package/dist/next/host/uuid.js +38 -0
  297. package/dist/next/host/uuid.js.map +1 -0
  298. package/dist/next/index.d.ts +28 -0
  299. package/dist/next/index.d.ts.map +1 -0
  300. package/dist/next/index.js +18 -0
  301. package/dist/next/index.js.map +1 -0
  302. package/dist/next/jobs/definition.d.ts +96 -0
  303. package/dist/next/jobs/definition.d.ts.map +1 -0
  304. package/dist/next/jobs/definition.js +83 -0
  305. package/dist/next/jobs/definition.js.map +1 -0
  306. package/dist/next/jobs/index.d.ts +5 -0
  307. package/dist/next/jobs/index.d.ts.map +1 -0
  308. package/dist/next/jobs/index.js +3 -0
  309. package/dist/next/jobs/index.js.map +1 -0
  310. package/dist/next/jobs/internal.d.ts +3 -0
  311. package/dist/next/jobs/internal.d.ts.map +1 -0
  312. package/dist/next/jobs/internal.js +4 -0
  313. package/dist/next/jobs/internal.js.map +1 -0
  314. package/dist/next/jobs/job.d.ts +152 -0
  315. package/dist/next/jobs/job.d.ts.map +1 -0
  316. package/dist/next/jobs/job.js +320 -0
  317. package/dist/next/jobs/job.js.map +1 -0
  318. package/dist/next/jobs/persisted.d.ts +38 -0
  319. package/dist/next/jobs/persisted.d.ts.map +1 -0
  320. package/dist/next/jobs/persisted.js +95 -0
  321. package/dist/next/jobs/persisted.js.map +1 -0
  322. package/dist/next/jobs/records.d.ts +231 -0
  323. package/dist/next/jobs/records.d.ts.map +1 -0
  324. package/dist/next/jobs/records.js +869 -0
  325. package/dist/next/jobs/records.js.map +1 -0
  326. package/dist/next/jobs/run-states.d.ts +69 -0
  327. package/dist/next/jobs/run-states.d.ts.map +1 -0
  328. package/dist/next/jobs/run-states.js +228 -0
  329. package/dist/next/jobs/run-states.js.map +1 -0
  330. package/dist/next/jobs/run.d.ts +113 -0
  331. package/dist/next/jobs/run.d.ts.map +1 -0
  332. package/dist/next/jobs/run.js +200 -0
  333. package/dist/next/jobs/run.js.map +1 -0
  334. package/dist/next/jobs/running.d.ts +44 -0
  335. package/dist/next/jobs/running.d.ts.map +1 -0
  336. package/dist/next/jobs/running.js +117 -0
  337. package/dist/next/jobs/running.js.map +1 -0
  338. package/dist/next/jobs/stored.d.ts +63 -0
  339. package/dist/next/jobs/stored.d.ts.map +1 -0
  340. package/dist/next/jobs/stored.js +55 -0
  341. package/dist/next/jobs/stored.js.map +1 -0
  342. package/dist/next/link/binary.d.ts +4 -0
  343. package/dist/next/link/binary.d.ts.map +1 -0
  344. package/dist/next/link/binary.js +534 -0
  345. package/dist/next/link/binary.js.map +1 -0
  346. package/dist/next/link/channel.d.ts +63 -0
  347. package/dist/next/link/channel.d.ts.map +1 -0
  348. package/dist/next/link/channel.js +202 -0
  349. package/dist/next/link/channel.js.map +1 -0
  350. package/dist/next/link/errors.d.ts +7 -0
  351. package/dist/next/link/errors.d.ts.map +1 -0
  352. package/dist/next/link/errors.js +21 -0
  353. package/dist/next/link/errors.js.map +1 -0
  354. package/dist/next/link/index.d.ts +8 -0
  355. package/dist/next/link/index.d.ts.map +1 -0
  356. package/dist/next/link/index.js +8 -0
  357. package/dist/next/link/index.js.map +1 -0
  358. package/dist/next/link/internal.d.ts +9 -0
  359. package/dist/next/link/internal.d.ts.map +1 -0
  360. package/dist/next/link/internal.js +10 -0
  361. package/dist/next/link/internal.js.map +1 -0
  362. package/dist/next/link/ipc.d.ts +22 -0
  363. package/dist/next/link/ipc.d.ts.map +1 -0
  364. package/dist/next/link/ipc.js +64 -0
  365. package/dist/next/link/ipc.js.map +1 -0
  366. package/dist/next/link/link.d.ts +34 -0
  367. package/dist/next/link/link.d.ts.map +1 -0
  368. package/dist/next/link/link.js +87 -0
  369. package/dist/next/link/link.js.map +1 -0
  370. package/dist/next/link/message.d.ts +249 -0
  371. package/dist/next/link/message.d.ts.map +1 -0
  372. package/dist/next/link/message.js +123 -0
  373. package/dist/next/link/message.js.map +1 -0
  374. package/dist/next/link/part.d.ts +80 -0
  375. package/dist/next/link/part.d.ts.map +1 -0
  376. package/dist/next/link/part.js +164 -0
  377. package/dist/next/link/part.js.map +1 -0
  378. package/dist/next/link/text.d.ts +6 -0
  379. package/dist/next/link/text.d.ts.map +1 -0
  380. package/dist/next/link/text.js +335 -0
  381. package/dist/next/link/text.js.map +1 -0
  382. package/dist/next/link/values.d.ts +40 -0
  383. package/dist/next/link/values.d.ts.map +1 -0
  384. package/dist/next/link/values.js +117 -0
  385. package/dist/next/link/values.js.map +1 -0
  386. package/dist/next/link/websocket.d.ts +26 -0
  387. package/dist/next/link/websocket.d.ts.map +1 -0
  388. package/dist/next/link/websocket.js +91 -0
  389. package/dist/next/link/websocket.js.map +1 -0
  390. package/dist/next/registries/contribution.d.ts +50 -0
  391. package/dist/next/registries/contribution.d.ts.map +1 -0
  392. package/dist/next/registries/contribution.js +129 -0
  393. package/dist/next/registries/contribution.js.map +1 -0
  394. package/dist/next/registries/entries.d.ts +18 -0
  395. package/dist/next/registries/entries.d.ts.map +1 -0
  396. package/dist/next/registries/entries.js +42 -0
  397. package/dist/next/registries/entries.js.map +1 -0
  398. package/dist/next/registries/index.d.ts +3 -0
  399. package/dist/next/registries/index.d.ts.map +1 -0
  400. package/dist/next/registries/index.js +5 -0
  401. package/dist/next/registries/index.js.map +1 -0
  402. package/dist/next/registries/internal.d.ts +4 -0
  403. package/dist/next/registries/internal.d.ts.map +1 -0
  404. package/dist/next/registries/internal.js +5 -0
  405. package/dist/next/registries/internal.js.map +1 -0
  406. package/dist/next/registries/record.d.ts +94 -0
  407. package/dist/next/registries/record.d.ts.map +1 -0
  408. package/dist/next/registries/record.js +253 -0
  409. package/dist/next/registries/record.js.map +1 -0
  410. package/dist/next/registries/registry.d.ts +74 -0
  411. package/dist/next/registries/registry.d.ts.map +1 -0
  412. package/dist/next/registries/registry.js +14 -0
  413. package/dist/next/registries/registry.js.map +1 -0
  414. package/dist/next/registries/value.d.ts +48 -0
  415. package/dist/next/registries/value.d.ts.map +1 -0
  416. package/dist/next/registries/value.js +199 -0
  417. package/dist/next/registries/value.js.map +1 -0
  418. package/dist/next/remote/calls.d.ts +25 -0
  419. package/dist/next/remote/calls.d.ts.map +1 -0
  420. package/dist/next/remote/calls.js +62 -0
  421. package/dist/next/remote/calls.js.map +1 -0
  422. package/dist/next/remote/consumer.d.ts +42 -0
  423. package/dist/next/remote/consumer.d.ts.map +1 -0
  424. package/dist/next/remote/consumer.js +343 -0
  425. package/dist/next/remote/consumer.js.map +1 -0
  426. package/dist/next/remote/hold.d.ts +130 -0
  427. package/dist/next/remote/hold.d.ts.map +1 -0
  428. package/dist/next/remote/hold.js +537 -0
  429. package/dist/next/remote/hold.js.map +1 -0
  430. package/dist/next/remote/host-link.d.ts +77 -0
  431. package/dist/next/remote/host-link.d.ts.map +1 -0
  432. package/dist/next/remote/host-link.js +182 -0
  433. package/dist/next/remote/host-link.js.map +1 -0
  434. package/dist/next/remote/internal.d.ts +6 -0
  435. package/dist/next/remote/internal.d.ts.map +1 -0
  436. package/dist/next/remote/internal.js +6 -0
  437. package/dist/next/remote/internal.js.map +1 -0
  438. package/dist/next/remote/path.d.ts +46 -0
  439. package/dist/next/remote/path.d.ts.map +1 -0
  440. package/dist/next/remote/path.js +73 -0
  441. package/dist/next/remote/path.js.map +1 -0
  442. package/dist/next/remote/provider.d.ts +76 -0
  443. package/dist/next/remote/provider.d.ts.map +1 -0
  444. package/dist/next/remote/provider.js +506 -0
  445. package/dist/next/remote/provider.js.map +1 -0
  446. package/dist/next/remote/relay.d.ts +58 -0
  447. package/dist/next/remote/relay.d.ts.map +1 -0
  448. package/dist/next/remote/relay.js +117 -0
  449. package/dist/next/remote/relay.js.map +1 -0
  450. package/dist/next/remote/remote-object.d.ts +133 -0
  451. package/dist/next/remote/remote-object.d.ts.map +1 -0
  452. package/dist/next/remote/remote-object.js +411 -0
  453. package/dist/next/remote/remote-object.js.map +1 -0
  454. package/dist/next/remote/replica.d.ts +59 -0
  455. package/dist/next/remote/replica.d.ts.map +1 -0
  456. package/dist/next/remote/replica.js +125 -0
  457. package/dist/next/remote/replica.js.map +1 -0
  458. package/dist/next/state/batch.d.ts +64 -0
  459. package/dist/next/state/batch.d.ts.map +1 -0
  460. package/dist/next/state/batch.js +163 -0
  461. package/dist/next/state/batch.js.map +1 -0
  462. package/dist/next/state/derive.d.ts +52 -0
  463. package/dist/next/state/derive.d.ts.map +1 -0
  464. package/dist/next/state/derive.js +182 -0
  465. package/dist/next/state/derive.js.map +1 -0
  466. package/dist/next/state/index.d.ts +6 -0
  467. package/dist/next/state/index.d.ts.map +1 -0
  468. package/dist/next/state/index.js +4 -0
  469. package/dist/next/state/index.js.map +1 -0
  470. package/dist/next/state/internal.d.ts +6 -0
  471. package/dist/next/state/internal.d.ts.map +1 -0
  472. package/dist/next/state/internal.js +8 -0
  473. package/dist/next/state/internal.js.map +1 -0
  474. package/dist/next/state/native-source.d.ts +106 -0
  475. package/dist/next/state/native-source.d.ts.map +1 -0
  476. package/dist/next/state/native-source.js +240 -0
  477. package/dist/next/state/native-source.js.map +1 -0
  478. package/dist/next/state/watchable.d.ts +114 -0
  479. package/dist/next/state/watchable.d.ts.map +1 -0
  480. package/dist/next/state/watchable.js +156 -0
  481. package/dist/next/state/watchable.js.map +1 -0
  482. package/dist/next/state/writable.d.ts +32 -0
  483. package/dist/next/state/writable.d.ts.map +1 -0
  484. package/dist/next/state/writable.js +49 -0
  485. package/dist/next/state/writable.js.map +1 -0
  486. package/dist/next/store/adapter.d.ts +67 -0
  487. package/dist/next/store/adapter.d.ts.map +1 -0
  488. package/dist/next/store/adapter.js +118 -0
  489. package/dist/next/store/adapter.js.map +1 -0
  490. package/dist/next/store/allocator.d.ts +17 -0
  491. package/dist/next/store/allocator.d.ts.map +1 -0
  492. package/dist/next/store/allocator.js +30 -0
  493. package/dist/next/store/allocator.js.map +1 -0
  494. package/dist/next/store/applier.d.ts +8 -0
  495. package/dist/next/store/applier.d.ts.map +1 -0
  496. package/dist/next/store/applier.js +375 -0
  497. package/dist/next/store/applier.js.map +1 -0
  498. package/dist/next/store/apply-batch.d.ts +12 -0
  499. package/dist/next/store/apply-batch.d.ts.map +1 -0
  500. package/dist/next/store/apply-batch.js +83 -0
  501. package/dist/next/store/apply-batch.js.map +1 -0
  502. package/dist/next/store/archive.d.ts +32 -0
  503. package/dist/next/store/archive.d.ts.map +1 -0
  504. package/dist/next/store/archive.js +129 -0
  505. package/dist/next/store/archive.js.map +1 -0
  506. package/dist/next/store/backend.d.ts +10 -0
  507. package/dist/next/store/backend.d.ts.map +1 -0
  508. package/dist/next/store/backend.js +15 -0
  509. package/dist/next/store/backend.js.map +1 -0
  510. package/dist/next/store/catalog.d.ts +24 -0
  511. package/dist/next/store/catalog.d.ts.map +1 -0
  512. package/dist/next/store/catalog.js +17 -0
  513. package/dist/next/store/catalog.js.map +1 -0
  514. package/dist/next/store/claims.d.ts +23 -0
  515. package/dist/next/store/claims.d.ts.map +1 -0
  516. package/dist/next/store/claims.js +65 -0
  517. package/dist/next/store/claims.js.map +1 -0
  518. package/dist/next/store/columns.d.ts +77 -0
  519. package/dist/next/store/columns.d.ts.map +1 -0
  520. package/dist/next/store/columns.js +77 -0
  521. package/dist/next/store/columns.js.map +1 -0
  522. package/dist/next/store/engine.d.ts +176 -0
  523. package/dist/next/store/engine.d.ts.map +1 -0
  524. package/dist/next/store/engine.js +283 -0
  525. package/dist/next/store/engine.js.map +1 -0
  526. package/dist/next/store/evaluate.d.ts +17 -0
  527. package/dist/next/store/evaluate.d.ts.map +1 -0
  528. package/dist/next/store/evaluate.js +128 -0
  529. package/dist/next/store/evaluate.js.map +1 -0
  530. package/dist/next/store/export.d.ts +17 -0
  531. package/dist/next/store/export.d.ts.map +1 -0
  532. package/dist/next/store/export.js +200 -0
  533. package/dist/next/store/export.js.map +1 -0
  534. package/dist/next/store/expression.d.ts +150 -0
  535. package/dist/next/store/expression.d.ts.map +1 -0
  536. package/dist/next/store/expression.js +268 -0
  537. package/dist/next/store/expression.js.map +1 -0
  538. package/dist/next/store/import.d.ts +10 -0
  539. package/dist/next/store/import.d.ts.map +1 -0
  540. package/dist/next/store/import.js +276 -0
  541. package/dist/next/store/import.js.map +1 -0
  542. package/dist/next/store/index.d.ts +16 -0
  543. package/dist/next/store/index.d.ts.map +1 -0
  544. package/dist/next/store/index.js +13 -0
  545. package/dist/next/store/index.js.map +1 -0
  546. package/dist/next/store/json-column.d.ts +33 -0
  547. package/dist/next/store/json-column.d.ts.map +1 -0
  548. package/dist/next/store/json-column.js +61 -0
  549. package/dist/next/store/json-column.js.map +1 -0
  550. package/dist/next/store/jsonl.d.ts +9 -0
  551. package/dist/next/store/jsonl.d.ts.map +1 -0
  552. package/dist/next/store/jsonl.js +61 -0
  553. package/dist/next/store/jsonl.js.map +1 -0
  554. package/dist/next/store/outbox.d.ts +26 -0
  555. package/dist/next/store/outbox.d.ts.map +1 -0
  556. package/dist/next/store/outbox.js +80 -0
  557. package/dist/next/store/outbox.js.map +1 -0
  558. package/dist/next/store/query.d.ts +39 -0
  559. package/dist/next/store/query.d.ts.map +1 -0
  560. package/dist/next/store/query.js +97 -0
  561. package/dist/next/store/query.js.map +1 -0
  562. package/dist/next/store/refusal.d.ts +15 -0
  563. package/dist/next/store/refusal.d.ts.map +1 -0
  564. package/dist/next/store/refusal.js +36 -0
  565. package/dist/next/store/refusal.js.map +1 -0
  566. package/dist/next/store/rows.d.ts +80 -0
  567. package/dist/next/store/rows.d.ts.map +1 -0
  568. package/dist/next/store/rows.js +183 -0
  569. package/dist/next/store/rows.js.map +1 -0
  570. package/dist/next/store/schema.d.ts +25 -0
  571. package/dist/next/store/schema.d.ts.map +1 -0
  572. package/dist/next/store/schema.js +115 -0
  573. package/dist/next/store/schema.js.map +1 -0
  574. package/dist/next/store/sql.d.ts +73 -0
  575. package/dist/next/store/sql.d.ts.map +1 -0
  576. package/dist/next/store/sql.js +234 -0
  577. package/dist/next/store/sql.js.map +1 -0
  578. package/dist/next/store/step.d.ts +48 -0
  579. package/dist/next/store/step.d.ts.map +1 -0
  580. package/dist/next/store/step.js +50 -0
  581. package/dist/next/store/step.js.map +1 -0
  582. package/dist/next/store/store.d.ts +161 -0
  583. package/dist/next/store/store.d.ts.map +1 -0
  584. package/dist/next/store/store.js +627 -0
  585. package/dist/next/store/store.js.map +1 -0
  586. package/dist/next/store/table-changes.d.ts +29 -0
  587. package/dist/next/store/table-changes.d.ts.map +1 -0
  588. package/dist/next/store/table-changes.js +102 -0
  589. package/dist/next/store/table-changes.js.map +1 -0
  590. package/dist/next/store/table-evolve.d.ts +74 -0
  591. package/dist/next/store/table-evolve.d.ts.map +1 -0
  592. package/dist/next/store/table-evolve.js +201 -0
  593. package/dist/next/store/table-evolve.js.map +1 -0
  594. package/dist/next/store/table-handle.d.ts +67 -0
  595. package/dist/next/store/table-handle.d.ts.map +1 -0
  596. package/dist/next/store/table-handle.js +101 -0
  597. package/dist/next/store/table-handle.js.map +1 -0
  598. package/dist/next/store/table-history.d.ts +75 -0
  599. package/dist/next/store/table-history.d.ts.map +1 -0
  600. package/dist/next/store/table-history.js +42 -0
  601. package/dist/next/store/table-history.js.map +1 -0
  602. package/dist/next/store/table-migration.d.ts +16 -0
  603. package/dist/next/store/table-migration.d.ts.map +1 -0
  604. package/dist/next/store/table-migration.js +202 -0
  605. package/dist/next/store/table-migration.js.map +1 -0
  606. package/dist/next/store/table-writes.d.ts +125 -0
  607. package/dist/next/store/table-writes.d.ts.map +1 -0
  608. package/dist/next/store/table-writes.js +165 -0
  609. package/dist/next/store/table-writes.js.map +1 -0
  610. package/dist/next/store/table.d.ts +80 -0
  611. package/dist/next/store/table.d.ts.map +1 -0
  612. package/dist/next/store/table.js +103 -0
  613. package/dist/next/store/table.js.map +1 -0
  614. package/dist/next/store/text.d.ts +14 -0
  615. package/dist/next/store/text.d.ts.map +1 -0
  616. package/dist/next/store/text.js +51 -0
  617. package/dist/next/store/text.js.map +1 -0
  618. package/dist/next/store/writes.d.ts +5 -0
  619. package/dist/next/store/writes.d.ts.map +1 -0
  620. package/dist/next/store/writes.js +4 -0
  621. package/dist/next/store/writes.js.map +1 -0
  622. package/dist/next-node/compression.d.ts +7 -0
  623. package/dist/next-node/compression.d.ts.map +1 -0
  624. package/dist/next-node/compression.js +24 -0
  625. package/dist/next-node/compression.js.map +1 -0
  626. package/dist/next-node/http/admission.d.ts +63 -0
  627. package/dist/next-node/http/admission.d.ts.map +1 -0
  628. package/dist/next-node/http/admission.js +134 -0
  629. package/dist/next-node/http/admission.js.map +1 -0
  630. package/dist/next-node/http/authenticate.d.ts +21 -0
  631. package/dist/next-node/http/authenticate.d.ts.map +1 -0
  632. package/dist/next-node/http/authenticate.js +34 -0
  633. package/dist/next-node/http/authenticate.js.map +1 -0
  634. package/dist/next-node/http/cookies.d.ts +24 -0
  635. package/dist/next-node/http/cookies.d.ts.map +1 -0
  636. package/dist/next-node/http/cookies.js +62 -0
  637. package/dist/next-node/http/cookies.js.map +1 -0
  638. package/dist/next-node/http/file.d.ts +23 -0
  639. package/dist/next-node/http/file.d.ts.map +1 -0
  640. package/dist/next-node/http/file.js +94 -0
  641. package/dist/next-node/http/file.js.map +1 -0
  642. package/dist/next-node/http/headers.d.ts +37 -0
  643. package/dist/next-node/http/headers.d.ts.map +1 -0
  644. package/dist/next-node/http/headers.js +129 -0
  645. package/dist/next-node/http/headers.js.map +1 -0
  646. package/dist/next-node/http/http.d.ts +100 -0
  647. package/dist/next-node/http/http.d.ts.map +1 -0
  648. package/dist/next-node/http/http.js +462 -0
  649. package/dist/next-node/http/http.js.map +1 -0
  650. package/dist/next-node/http/incoming.d.ts +19 -0
  651. package/dist/next-node/http/incoming.d.ts.map +1 -0
  652. package/dist/next-node/http/incoming.js +31 -0
  653. package/dist/next-node/http/incoming.js.map +1 -0
  654. package/dist/next-node/http/index.d.ts +11 -0
  655. package/dist/next-node/http/index.d.ts.map +1 -0
  656. package/dist/next-node/http/index.js +12 -0
  657. package/dist/next-node/http/index.js.map +1 -0
  658. package/dist/next-node/http/node.d.ts +78 -0
  659. package/dist/next-node/http/node.d.ts.map +1 -0
  660. package/dist/next-node/http/node.js +291 -0
  661. package/dist/next-node/http/node.js.map +1 -0
  662. package/dist/next-node/http/request.d.ts +54 -0
  663. package/dist/next-node/http/request.d.ts.map +1 -0
  664. package/dist/next-node/http/request.js +116 -0
  665. package/dist/next-node/http/request.js.map +1 -0
  666. package/dist/next-node/http/response.d.ts +63 -0
  667. package/dist/next-node/http/response.d.ts.map +1 -0
  668. package/dist/next-node/http/response.js +202 -0
  669. package/dist/next-node/http/response.js.map +1 -0
  670. package/dist/next-node/http/router.d.ts +114 -0
  671. package/dist/next-node/http/router.d.ts.map +1 -0
  672. package/dist/next-node/http/router.js +261 -0
  673. package/dist/next-node/http/router.js.map +1 -0
  674. package/dist/next-node/http/upgrades.d.ts +58 -0
  675. package/dist/next-node/http/upgrades.d.ts.map +1 -0
  676. package/dist/next-node/http/upgrades.js +184 -0
  677. package/dist/next-node/http/upgrades.js.map +1 -0
  678. package/dist/next-node/plugins/build.d.ts +57 -0
  679. package/dist/next-node/plugins/build.d.ts.map +1 -0
  680. package/dist/next-node/plugins/build.js +334 -0
  681. package/dist/next-node/plugins/build.js.map +1 -0
  682. package/dist/next-node/plugins/discover.d.ts +36 -0
  683. package/dist/next-node/plugins/discover.d.ts.map +1 -0
  684. package/dist/next-node/plugins/discover.js +91 -0
  685. package/dist/next-node/plugins/discover.js.map +1 -0
  686. package/dist/next-node/plugins/evaluate.d.ts +33 -0
  687. package/dist/next-node/plugins/evaluate.d.ts.map +1 -0
  688. package/dist/next-node/plugins/evaluate.js +98 -0
  689. package/dist/next-node/plugins/evaluate.js.map +1 -0
  690. package/dist/next-node/plugins/index.d.ts +9 -0
  691. package/dist/next-node/plugins/index.d.ts.map +1 -0
  692. package/dist/next-node/plugins/index.js +11 -0
  693. package/dist/next-node/plugins/index.js.map +1 -0
  694. package/dist/next-node/plugins/install.d.ts +13 -0
  695. package/dist/next-node/plugins/install.d.ts.map +1 -0
  696. package/dist/next-node/plugins/install.js +37 -0
  697. package/dist/next-node/plugins/install.js.map +1 -0
  698. package/dist/next-node/plugins/plugins.d.ts +135 -0
  699. package/dist/next-node/plugins/plugins.d.ts.map +1 -0
  700. package/dist/next-node/plugins/plugins.js +206 -0
  701. package/dist/next-node/plugins/plugins.js.map +1 -0
  702. package/dist/next-node/plugins/runtime.d.ts +41 -0
  703. package/dist/next-node/plugins/runtime.d.ts.map +1 -0
  704. package/dist/next-node/plugins/runtime.js +136 -0
  705. package/dist/next-node/plugins/runtime.js.map +1 -0
  706. package/dist/next-node/plugins/stack.d.ts +16 -0
  707. package/dist/next-node/plugins/stack.d.ts.map +1 -0
  708. package/dist/next-node/plugins/stack.js +61 -0
  709. package/dist/next-node/plugins/stack.js.map +1 -0
  710. package/dist/next-node/plugins/watcher.d.ts +58 -0
  711. package/dist/next-node/plugins/watcher.d.ts.map +1 -0
  712. package/dist/next-node/plugins/watcher.js +281 -0
  713. package/dist/next-node/plugins/watcher.js.map +1 -0
  714. package/dist/next-node/workers/control.d.ts +83 -0
  715. package/dist/next-node/workers/control.d.ts.map +1 -0
  716. package/dist/next-node/workers/control.js +77 -0
  717. package/dist/next-node/workers/control.js.map +1 -0
  718. package/dist/next-node/workers/index.d.ts +5 -0
  719. package/dist/next-node/workers/index.d.ts.map +1 -0
  720. package/dist/next-node/workers/index.js +7 -0
  721. package/dist/next-node/workers/index.js.map +1 -0
  722. package/dist/next-node/workers/lock.d.ts +21 -0
  723. package/dist/next-node/workers/lock.d.ts.map +1 -0
  724. package/dist/next-node/workers/lock.js +137 -0
  725. package/dist/next-node/workers/lock.js.map +1 -0
  726. package/dist/next-node/workers/main.d.ts +46 -0
  727. package/dist/next-node/workers/main.d.ts.map +1 -0
  728. package/dist/next-node/workers/main.js +230 -0
  729. package/dist/next-node/workers/main.js.map +1 -0
  730. package/dist/next-node/workers/process.d.ts +42 -0
  731. package/dist/next-node/workers/process.d.ts.map +1 -0
  732. package/dist/next-node/workers/process.js +125 -0
  733. package/dist/next-node/workers/process.js.map +1 -0
  734. package/dist/next-node/workers/workers.d.ts +80 -0
  735. package/dist/next-node/workers/workers.d.ts.map +1 -0
  736. package/dist/next-node/workers/workers.js +572 -0
  737. package/dist/next-node/workers/workers.js.map +1 -0
  738. package/dist/object.d.ts +4 -4
  739. package/dist/object.d.ts.map +1 -1
  740. package/dist/object.js +3 -4
  741. package/dist/object.js.map +1 -1
  742. package/dist/output.d.ts +1 -1
  743. package/dist/output.d.ts.map +1 -1
  744. package/dist/output.js +4 -2
  745. package/dist/output.js.map +1 -1
  746. package/dist/remote.d.ts.map +1 -1
  747. package/dist/remote.js +2 -2
  748. package/dist/remote.js.map +1 -1
  749. package/dist/schema.d.ts +8 -4
  750. package/dist/schema.d.ts.map +1 -1
  751. package/dist/schema.js +180 -5
  752. package/dist/schema.js.map +1 -1
  753. package/dist/sqlite/cloudflare.d.ts +2 -0
  754. package/dist/sqlite/cloudflare.d.ts.map +1 -1
  755. package/dist/sqlite/cloudflare.js +10 -0
  756. package/dist/sqlite/cloudflare.js.map +1 -1
  757. package/dist/sqlite/database.d.ts +5 -2
  758. package/dist/sqlite/database.d.ts.map +1 -1
  759. package/dist/sqlite/database.js.map +1 -1
  760. package/dist/sqlite/node.d.ts +4 -1
  761. package/dist/sqlite/node.d.ts.map +1 -1
  762. package/dist/sqlite/node.js +22 -5
  763. package/dist/sqlite/node.js.map +1 -1
  764. package/dist/watch.d.ts +194 -0
  765. package/dist/watch.d.ts.map +1 -0
  766. package/dist/watch.js +383 -0
  767. package/dist/watch.js.map +1 -0
  768. package/dist/wire.d.ts +174 -193
  769. package/dist/wire.d.ts.map +1 -1
  770. package/dist/wire.js +81 -80
  771. package/dist/wire.js.map +1 -1
  772. package/docs/guide.md +15 -15
  773. package/docs/next/benchmarks.md +959 -0
  774. package/docs/next/decisions.md +2957 -0
  775. package/docs/next/dependencies/book.md +1671 -0
  776. package/docs/next/dependencies/index.html +2641 -0
  777. package/docs/next/dependencies/model.md +330 -0
  778. package/docs/next/design.md +2554 -0
  779. package/docs/next/durable-observers/book.md +432 -0
  780. package/docs/next/durable-observers/index.html +517 -0
  781. package/docs/next/flow-control/book.md +333 -0
  782. package/docs/next/flow-control/fold/index.html +265 -0
  783. package/docs/next/flow-control/index.html +548 -0
  784. package/docs/next/flow-control/window/index.html +228 -0
  785. package/docs/next/guide-plugins-hosts/book.md +607 -0
  786. package/docs/next/guide-plugins-hosts/index.html +652 -0
  787. package/docs/next/http-workers/book.md +378 -0
  788. package/docs/next/http-workers/index.html +515 -0
  789. package/docs/next/layer-1.md +311 -0
  790. package/docs/next/layer-2.md +216 -0
  791. package/docs/next/plugin-model/book.md +186 -0
  792. package/docs/next/plugin-model/index.html +310 -0
  793. package/docs/next/plugin-primer/book.md +273 -0
  794. package/docs/next/plugin-primer/index.html +430 -0
  795. package/docs/next/slice-1.md +236 -0
  796. package/docs/next/slice-10.md +285 -0
  797. package/docs/next/slice-11.md +93 -0
  798. package/docs/next/slice-2.md +174 -0
  799. package/docs/next/slice-3a.md +296 -0
  800. package/docs/next/slice-3b.md +197 -0
  801. package/docs/next/slice-4.md +146 -0
  802. package/docs/next/slice-4a.md +418 -0
  803. package/docs/next/slice-4b.md +208 -0
  804. package/docs/next/slice-5.md +281 -0
  805. package/docs/next/slice-6a.md +676 -0
  806. package/docs/next/slice-6b.md +332 -0
  807. package/docs/next/slice-7a.md +130 -0
  808. package/docs/next/slice-7b/book.md +608 -0
  809. package/docs/next/slice-7b/index.html +842 -0
  810. package/docs/next/slice-7b.md +255 -0
  811. package/docs/next/slice-7c.md +165 -0
  812. package/docs/next/slice-8.md +194 -0
  813. package/docs/next/slices.md +230 -0
  814. package/docs/next/store/book.md +665 -0
  815. package/docs/next/store/index.html +861 -0
  816. package/docs/next/store/walkthrough.md +193 -0
  817. package/docs/spec.md +9 -9
  818. package/docs/tutorial.md +26 -25
  819. package/package.json +22 -6
  820. package/src/delta/README.md +69 -0
@@ -0,0 +1,462 @@
1
+ // The HTTP component (slice 10 §2; decisions "The HTTP core is a fetch handler", "The HTTP server is a native object",
2
+ // "The HTTP component's security baseline", "Settings are arguments, extensions are registries"): `createHttp` takes
3
+ // the app's settings (where to listen, the links endpoint, the close bound) and builds one Web-standard handler,
4
+ // `fetch`, from the registries its facet serves (`Http`, `Authenticators`), an upgrade adapter for Node (`upgrade`), and
5
+ // the facet, whose host-lifetime listener object is Chord's own Node server. Every request is admitted (provenance), routed,
6
+ // checked for foreign origins, authenticated unless foreign, and served in one `host.root` scope with its principal
7
+ // that lasts until its body is delivered; every answer carries the default headers.
8
+ import { awaitWithContext, withAbortSignal, withoutAbortSignal } from "../../context/index.js";
9
+ import { local } from "../../next/contracts/index.js";
10
+ import { isChordError } from "../../next/data/index.js";
11
+ import { defineFacet } from "../../next/host/index.js";
12
+ import { admit, isForeign, isNavigation, originAccepted, refused, } from "./admission.js";
13
+ import { Authenticators, authenticate, composeAuthenticators } from "./authenticate.js";
14
+ import { DefaultHeaders, Nonces } from "./headers.js";
15
+ import { webIncoming } from "./incoming.js";
16
+ import { connectionOf, NodeIncoming, NodeListener } from "./node.js";
17
+ import { HttpFailure, WebRequest } from "./request.js";
18
+ import { answerOf, errorAnswer, webResponse } from "./response.js";
19
+ import { composeRouter, Http } from "./router.js";
20
+ import { Upgrades } from "./upgrades.js";
21
+ /** Builds the HTTP component on `host` (a request's scope is a `host.root` with its principal). */
22
+ export function createHttp(host, options, context) {
23
+ return new Component(host, options, context);
24
+ }
25
+ /** The listener: a host-lifetime object of plugin `chord.http` whose native is Chord's own Node server. */
26
+ export const HttpListener = local("chord.http.listener", { version: 1, params: {}, members: {} });
27
+ /** `close`'s bound unless `closeTimeout` says otherwise: 30 s. */
28
+ const CLOSE_TIMEOUT = 30_000;
29
+ /** Who threw out of a route itself (no wrap). */
30
+ const ROUTE = { kind: "route" };
31
+ class Component {
32
+ facet;
33
+ upgrade;
34
+ #host;
35
+ #options;
36
+ #onError;
37
+ #context;
38
+ /** The component's context without its cancellation: each request's scope adds its own signal. */
39
+ #base;
40
+ #defaults = new DefaultHeaders();
41
+ #nonces = new Nonces();
42
+ #upgrades = new Upgrades();
43
+ #running = new Set();
44
+ /** The registries while they resolve (once; again after a failed try), then the values themselves. */
45
+ #resolving;
46
+ #registries;
47
+ /** Aborted at `close`: the router's watch. */
48
+ #closing = new AbortController();
49
+ #closed;
50
+ #listening = Promise.withResolvers();
51
+ constructor(host, options, context) {
52
+ this.#host = host;
53
+ this.#options = options;
54
+ this.#onError = options.onError;
55
+ this.#context = context;
56
+ this.#base = withoutAbortSignal(context);
57
+ this.#listening.promise.catch(() => { });
58
+ this.upgrade = (message, socket, head) => {
59
+ socket.on("error", () => socket.destroy());
60
+ void this.#upgrade(message, socket, head).catch(() => socket.destroy());
61
+ };
62
+ const { listen } = options;
63
+ this.facet = defineFacet((facet) => {
64
+ facet.serve(Http, { compose: composeRouter });
65
+ facet.serve(Authenticators, { compose: composeAuthenticators });
66
+ if (listen === undefined)
67
+ return;
68
+ facet.serve(HttpListener, (_params, self) => {
69
+ self.open((opening) => this.#listen(listen, opening), async (listener, _reason, closing) => {
70
+ listener.stop();
71
+ await this.close(closing);
72
+ await listener.closed();
73
+ });
74
+ return {};
75
+ });
76
+ });
77
+ }
78
+ async fetch(request, connection = {}) {
79
+ const { answer, finished } = await this.serve(webIncoming(request), connection);
80
+ // A whole body is out of the component's hands once its `Response` is; a pulled one ends when it is read.
81
+ if (answer.body instanceof ReadableStream)
82
+ return webResponse({ ...answer, body: tracked(answer.body, finished) });
83
+ finished();
84
+ return webResponse(answer);
85
+ }
86
+ listening(context) {
87
+ return awaitWithContext(this.#listening.promise, context);
88
+ }
89
+ close(context) {
90
+ this.#closed ??= this.#close(context);
91
+ return this.#closed;
92
+ }
93
+ /**
94
+ * Serves `request`: its answer, and what its consumer calls once the body is written or abandoned. Never throws:
95
+ * whatever fails answers (503 before the publication or while closing, 403, 404, 500 reported).
96
+ */
97
+ async serve(request, connection) {
98
+ const controller = new AbortController();
99
+ const finished = Promise.withResolvers();
100
+ const running = { controller, done: finished.promise };
101
+ this.#running.add(running);
102
+ request.cancelled((reason) => controller.abort(reason));
103
+ let answer;
104
+ try {
105
+ const served = await this.#serve(request, connection, controller, finished.promise);
106
+ answer = served.answer;
107
+ // The request is over once its consumer finished and its scope (if it got one) ended.
108
+ if (served.scope !== undefined)
109
+ running.done = Promise.all([finished.promise, served.scope]);
110
+ }
111
+ catch {
112
+ answer = this.refusal(500);
113
+ }
114
+ void running.done.then(() => this.#running.delete(running));
115
+ return { answer, finished: () => finished.resolve() };
116
+ }
117
+ /** The answer for a refused or failed request, outside any scope, with the default headers. */
118
+ refusal(status, admitted, router, head = false) {
119
+ return errorAnswer(status, this.#defaults.of(admitted, router, this.#nonces.next()), undefined, head);
120
+ }
121
+ /** The steps of `serve`: closing, the registries, admission, the route, origins, the principal, then the scope. */
122
+ async #serve(request, connection, controller, finished) {
123
+ const head = request.method === "HEAD";
124
+ if (this.#closing.signal.aborted)
125
+ return { answer: this.refusal(503, undefined, undefined, head) };
126
+ let registries;
127
+ try {
128
+ registries = this.#registries ?? (await this.#resolve());
129
+ }
130
+ catch {
131
+ return { answer: this.refusal(503, undefined, undefined, head) };
132
+ }
133
+ if (this.#closing.signal.aborted)
134
+ return { answer: this.refusal(503, undefined, undefined, head) };
135
+ const router = registries.router.value;
136
+ const admission = admit(request, connection, router.hosts, router.relays);
137
+ if (refused(admission)) {
138
+ if (admission.failed !== undefined)
139
+ this.#hookFailed("relay", admission.failed.relay, admission.failed.error);
140
+ return { answer: this.refusal(403, undefined, router, head) };
141
+ }
142
+ // A fresh script nonce per response (decision "A CSP nonce per response").
143
+ const webRequest = new WebRequest(request, admission, this.#nonces.next());
144
+ const match = router.route(request.method, webRequest.path);
145
+ if (match === "bad_path" || match === undefined) {
146
+ return { answer: this.refusal(match === undefined ? 404 : 400, admission, router, head) };
147
+ }
148
+ webRequest.params = match.params;
149
+ const foreign = isForeign(request);
150
+ if (!match.crossSite && !originAccepted(request.method, request, admission.origin)) {
151
+ return { answer: this.refusal(403, admission, router, head) };
152
+ }
153
+ let principal;
154
+ // Foreign requests are never authenticated but a top-level navigation to a page; a cross-site route never is.
155
+ const authenticators = registries.authenticators.value;
156
+ if (authenticators.length > 0 &&
157
+ !match.crossSite &&
158
+ (!foreign || (match.page && isNavigation(request.method, request)))) {
159
+ principal = await this.#principal(registries, webRequest, controller.signal);
160
+ if (this.#closing.signal.aborted || controller.signal.aborted) {
161
+ return { answer: this.refusal(503, admission, router, head) };
162
+ }
163
+ }
164
+ const answered = Promise.withResolvers();
165
+ const scope = this.#host
166
+ .root(async (ctx) => {
167
+ answered.resolve(await this.#run(request, webRequest, match, admission, router, foreign, ctx));
168
+ // The scope lasts until the body is written or abandoned (a `bytes` body reads in it).
169
+ await finished;
170
+ }, withAbortSignal(controller.signal, this.#base), { principal })
171
+ .catch(() => {
172
+ // The scope was sealed (a disconnect, `close`) before it answered: the request is over.
173
+ answered.resolve(this.refusal(503, admission, router, head));
174
+ });
175
+ return { answer: await answered.promise, scope };
176
+ }
177
+ /** Runs the wraps and the route in the request's scope `ctx`, and makes its answer (a failure: a reported 500). */
178
+ async #run(incoming, request, match, admitted, router, foreign, ctx) {
179
+ let response;
180
+ try {
181
+ response = await chainOf(match, ctx)(request);
182
+ }
183
+ catch (error) {
184
+ response = this.#failure(error, match);
185
+ }
186
+ // Downloads are never another site's to take (rule 6).
187
+ if (response.kind === "bytes" && foreign)
188
+ response = { kind: "error", status: 403 };
189
+ const failed = (error) => this.#onError({ kind: "response_failed", pattern: match.pattern, error });
190
+ try {
191
+ return answerOf(response, incoming, this.#defaults.of(admitted, router, request.nonce), ctx, failed);
192
+ }
193
+ catch (error) {
194
+ failed(error);
195
+ return this.refusal(500, admitted, router, request.method === "HEAD");
196
+ }
197
+ }
198
+ /** What an error escaping the chain answers: its `HttpFailure`'s status, else a reported 500 without its message. */
199
+ #failure(error, match) {
200
+ const thrown = error instanceof Thrown ? error : new Thrown(ROUTE, match.plugin, error);
201
+ if (thrown.cause instanceof HttpFailure)
202
+ return { kind: "error", status: thrown.cause.status };
203
+ // Chord refused the caller (an anonymous scope's remote object, a route's `authorize`): no failure of the route.
204
+ if (isChordError(thrown.cause, "forbidden"))
205
+ return { kind: "error", status: 403 };
206
+ if (thrown.by.kind === "route") {
207
+ this.#onError({ kind: "route_failed", pattern: match.pattern, plugin: thrown.plugin, error: thrown.cause });
208
+ }
209
+ else {
210
+ this.#onError({ kind: "wrap_failed", name: thrown.by.name, plugin: thrown.plugin, error: thrown.cause });
211
+ }
212
+ return { kind: "error", status: 500 };
213
+ }
214
+ /**
215
+ * The principal the authenticators give `request`; one that throws is reported and skipped. Raced against `signal`
216
+ * (a disconnect, `close`'s seal): an authenticator ignoring it no longer holds the request; the caller sees the
217
+ * abort and answers 503.
218
+ */
219
+ async #principal(registries, request, signal) {
220
+ const failed = (plugin, error) => this.#hookFailed("authenticate", plugin, error);
221
+ const context = withAbortSignal(signal, this.#base);
222
+ const authenticating = authenticate(registries.authenticators.value, request, failed, context);
223
+ // The registry's values are typed by no principal type: an app's authenticators return its principals.
224
+ return (await awaitWithContext(authenticating, context).catch(() => undefined));
225
+ }
226
+ #hookFailed(hook, plugin, error) {
227
+ this.#onError({ kind: "hook_failed", hook, ...(plugin === undefined ? {} : { plugin }), error });
228
+ }
229
+ /** The registries: resolved once, waiting for the publication; a failed try is tried again later. */
230
+ #resolve() {
231
+ this.#resolving ??= Promise.all([
232
+ this.#host.registry(Http, this.#context),
233
+ this.#host.registry(Authenticators, this.#context),
234
+ ]).then(([router, authenticators]) => {
235
+ this.#registries = { router, authenticators };
236
+ // A close may come first: nothing to follow then (Astra's recheck R4: the stopped watch threw unhandled).
237
+ this.#follow(router).catch(() => { });
238
+ return this.#registries;
239
+ }, (error) => {
240
+ this.#resolving = undefined;
241
+ throw error;
242
+ });
243
+ return this.#resolving;
244
+ }
245
+ /** Follows the router until `close`: connections its changes no longer admit are terminated. */
246
+ async #follow(router) {
247
+ if (this.#closing.signal.aborted)
248
+ return;
249
+ const watch = await router.watch(withAbortSignal(this.#closing.signal, this.#base));
250
+ if (this.#closing.signal.aborted)
251
+ return;
252
+ watch.start(async (call) => {
253
+ if (call.kind === "value")
254
+ this.#upgrades.revoke(call.value);
255
+ });
256
+ }
257
+ /** One upgrade, tracked from its arrival: refused while closing, else admitted and checked, then handed out. */
258
+ async #upgrade(message, stream, head) {
259
+ const controller = new AbortController();
260
+ // A client gone while its upgrade authenticates aborts that work (Astra's recheck R1, Sol's N5).
261
+ const gone = () => controller.abort(new Error("http: the client disconnected"));
262
+ if (stream.destroyed)
263
+ gone();
264
+ else {
265
+ // A clean disconnect (FIN) is seen only by reading: nothing reads a detached upgrade socket, so start it
266
+ // (Fable's second recheck: `end()` while authenticating went unnoticed).
267
+ stream.once("close", gone);
268
+ stream.once("end", gone);
269
+ stream.read(0);
270
+ }
271
+ const running = { controller, done: Promise.resolve() };
272
+ const work = this.#upgradeSteps(message, stream, head, controller.signal);
273
+ running.done = work;
274
+ this.#running.add(running);
275
+ try {
276
+ await work;
277
+ }
278
+ finally {
279
+ stream.removeListener("close", gone);
280
+ stream.removeListener("end", gone);
281
+ this.#running.delete(running);
282
+ }
283
+ }
284
+ /** The steps of an upgrade (the same rules as a request's; a socket needs a principal), checked again at hand-out. */
285
+ async #upgradeSteps(message, stream, head, signal) {
286
+ if (this.#closing.signal.aborted)
287
+ return refuse(stream, 503);
288
+ const request = NodeIncoming.of(message);
289
+ if (!(request instanceof NodeIncoming))
290
+ return refuse(stream, request.status);
291
+ let registries;
292
+ try {
293
+ registries = this.#registries ?? (await this.#resolve());
294
+ }
295
+ catch {
296
+ return refuse(stream, 503);
297
+ }
298
+ if (this.#closing.signal.aborted || signal.aborted)
299
+ return refuse(stream, 503);
300
+ const before = registries.router.value;
301
+ const admission = admit(request, connectionOf(message), before.hosts, before.relays);
302
+ if (refused(admission)) {
303
+ if (admission.failed !== undefined)
304
+ this.#hookFailed("relay", admission.failed.relay, admission.failed.error);
305
+ return refuse(stream, 403);
306
+ }
307
+ const sent = request.header("origin");
308
+ if (isForeign(request) || (sent !== null && sent !== admission.origin))
309
+ return refuse(stream, 403);
310
+ const webRequest = new WebRequest(request, admission, this.#nonces.next());
311
+ const principal = await this.#principal(registries, webRequest, signal);
312
+ if (this.#closing.signal.aborted || signal.aborted)
313
+ return refuse(stream, 503);
314
+ if (principal === undefined)
315
+ return refuse(stream, 403);
316
+ // The router now: a host, a relay or a socket removed while authenticating refuses the upgrade.
317
+ const router = registries.router.value;
318
+ const { allowed, relay } = admission;
319
+ if ((allowed !== undefined && !router.hosts.has(allowed)) ||
320
+ (relay !== undefined && !router.relays.includes(relay))) {
321
+ return refuse(stream, 403);
322
+ }
323
+ const { links } = this.#options;
324
+ if (links !== undefined && webRequest.path === links.path) {
325
+ let options;
326
+ try {
327
+ options =
328
+ (typeof links.options === "function" ? links.options(webRequest, principal) : links.options) ?? {};
329
+ }
330
+ catch (error) {
331
+ this.#hookFailed("links.options", undefined, error);
332
+ return refuse(stream, 403);
333
+ }
334
+ const admitted = { allowed, relay, principal, ...options };
335
+ return this.#upgrades.link(message, stream, head, admitted, this.#host, this.#context);
336
+ }
337
+ const match = router.socket(webRequest.path);
338
+ if (match === "bad_path")
339
+ return refuse(stream, 400);
340
+ if (match === undefined)
341
+ return refuse(stream, 404);
342
+ webRequest.params = match.params;
343
+ const fail = ({ pattern, plugin, error }) => this.#onError({ kind: "socket_failed", pattern, plugin, error });
344
+ const admitted = { allowed, relay, principal, match, request: webRequest };
345
+ this.#upgrades.socket(message, stream, head, admitted, this.#host, this.#context, fail);
346
+ }
347
+ /** The listener's open: Chord's own Node server listening at `listen`. */
348
+ async #listen(listen, context) {
349
+ const listener = await NodeListener.listen(this, listen, context);
350
+ this.#listening.resolve(listener.address);
351
+ return listener;
352
+ }
353
+ /** `close`: refuses from now on, then waits for sockets and running requests until the deadline, then seals. */
354
+ async #close(context) {
355
+ this.#closing.abort();
356
+ this.#listening.reject(new Error("http: closed"));
357
+ const timeout = this.#options.closeTimeout ?? CLOSE_TIMEOUT;
358
+ const signal = context.abortSignal;
359
+ let timer;
360
+ let aborted;
361
+ const deadline = new Promise((resolve) => {
362
+ // Already aborted: no wait at all (Sol's recheck N9).
363
+ if (signal?.aborted)
364
+ return resolve();
365
+ timer = setTimeout(resolve, timeout);
366
+ aborted = () => resolve();
367
+ signal?.addEventListener("abort", aborted, { once: true });
368
+ });
369
+ const running = Promise.all([...this.#running].map(({ done }) => done));
370
+ await Promise.race([Promise.all([this.#upgrades.close(deadline), running]), deadline]);
371
+ clearTimeout(timer);
372
+ if (aborted !== undefined)
373
+ signal?.removeEventListener("abort", aborted);
374
+ for (const { controller } of this.#running)
375
+ controller.abort(new Error("http: closed"));
376
+ }
377
+ }
378
+ /**
379
+ * `stream` as read by its consumer, `finished` called once it is read to its end, failed or cancelled (a mounted
380
+ * handler's `bytes` body: the request's scope lasts until then).
381
+ */
382
+ function tracked(stream, finished) {
383
+ const reader = stream.getReader();
384
+ // The owned stream ending (read whole, or errored by the scope's seal) ends the request too, whether or not its
385
+ // consumer pulls again (Sol's second recheck B: an aborted `Response` nobody touched kept its request and scope).
386
+ reader.closed.then(finished, finished);
387
+ return new ReadableStream({
388
+ pull: async (controller) => {
389
+ try {
390
+ const next = await reader.read();
391
+ if (next.done) {
392
+ controller.close();
393
+ finished();
394
+ }
395
+ else {
396
+ controller.enqueue(next.value);
397
+ }
398
+ }
399
+ catch (error) {
400
+ controller.error(error);
401
+ finished();
402
+ }
403
+ },
404
+ cancel: async (reason) => {
405
+ finished();
406
+ await reader.cancel(reason);
407
+ },
408
+ }, { highWaterMark: 0 });
409
+ }
410
+ /** Refuses an upgrade with `status` and closes its connection. */
411
+ function refuse(stream, status) {
412
+ stream.end(`HTTP/1.1 ${status} ${STATUS[status] ?? ""}\r\nConnection: close\r\nContent-Length: 0\r\n\r\n`);
413
+ }
414
+ /** The reason phrases of the statuses an upgrade is refused with. */
415
+ const STATUS = {
416
+ 400: "Bad Request",
417
+ 403: "Forbidden",
418
+ 404: "Not Found",
419
+ 501: "Not Implemented",
420
+ 503: "Service Unavailable",
421
+ };
422
+ /** Who threw out of a request's chain: the route, or a wrap (by name), with its plugin. */
423
+ class Thrown extends Error {
424
+ by;
425
+ plugin;
426
+ constructor(by, plugin, cause) {
427
+ super("thrown", { cause });
428
+ this.by = by;
429
+ this.plugin = plugin;
430
+ }
431
+ }
432
+ /** The route of `match` inside its wraps (outermost first), each throw tagged with who threw it. */
433
+ function chainOf(match, ctx) {
434
+ let next = tagged(match.handler, match.plugin, ctx);
435
+ for (let index = match.wraps.length - 1; index >= 0; index--) {
436
+ const { wrap, plugin } = match.wraps[index];
437
+ const inner = next;
438
+ next = async (request) => {
439
+ try {
440
+ return await wrap.wrap(request, inner, ctx);
441
+ }
442
+ catch (error) {
443
+ if (error instanceof Thrown)
444
+ throw error;
445
+ throw new Thrown({ kind: "wrap", name: wrap.name }, plugin, error);
446
+ }
447
+ };
448
+ }
449
+ return next;
450
+ }
451
+ /** `route` with its throws tagged as the route's. */
452
+ function tagged(route, plugin, ctx) {
453
+ return async (request) => {
454
+ try {
455
+ return await route(request, ctx);
456
+ }
457
+ catch (error) {
458
+ throw new Thrown(ROUTE, plugin, error);
459
+ }
460
+ };
461
+ }
462
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/next-node/http/http.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,qHAAqH;AACrH,iHAAiH;AACjH,yHAAyH;AACzH,6HAA6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gBACzC,MAAM,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;YACpE,CAAC;QACF,CAAC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,qDAAqD;AACrD,SAAS,MAAM,CAAC,KAAgB,EAAE,MAAc,EAAE,GAAQ;IACzD,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,IAAI,CAAC;YACJ,OAAO,MAAM,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;IACF,CAAC,CAAC;AACH,CAAC","sourcesContent":["// The HTTP component (slice 10 §2; decisions \"The HTTP core is a fetch handler\", \"The HTTP server is a native object\",\n// \"The HTTP component's security baseline\", \"Settings are arguments, extensions are registries\"): `createHttp` takes\n// the app's settings (where to listen, the links endpoint, the close bound) and builds one Web-standard handler,\n// `fetch`, from the registries its facet serves (`Http`, `Authenticators`), an upgrade adapter for Node (`upgrade`), and\n// the facet, whose host-lifetime listener object is Chord's own Node server. Every request is admitted (provenance), routed,\n// checked for foreign origins, authenticated unless foreign, and served in one `host.root` scope with its principal\n// that lasts until its body is delivered; every answer carries the default headers.\n\nimport type { IncomingMessage } from \"node:http\";\nimport type { Duplex } from \"node:stream\";\nimport { awaitWithContext, type Context, withAbortSignal, withoutAbortSignal } from \"../../context/index.ts\";\nimport { local } from \"../../next/contracts/index.ts\";\nimport { isChordError, type Principal } from \"../../next/data/index.ts\";\nimport { type Ctx, defineFacet, type Facet, type Host } from \"../../next/host/index.ts\";\nimport type { RegistryValue } from \"../../next/registries/index.ts\";\nimport {\n\ttype Admitted,\n\tadmit,\n\ttype Connection,\n\tisForeign,\n\tisNavigation,\n\toriginAccepted,\n\trefused,\n} from \"./admission.ts\";\nimport { type AuthenticatorEntry, Authenticators, authenticate, composeAuthenticators } from \"./authenticate.ts\";\nimport { DefaultHeaders, Nonces } from \"./headers.ts\";\nimport { type Incoming, webIncoming } from \"./incoming.ts\";\nimport { connectionOf, type Handler, type ListenAddress, NodeIncoming, NodeListener, type Served } from \"./node.ts\";\nimport { HttpFailure, type HttpRequest, WebRequest } from \"./request.ts\";\nimport { type Answer, answerOf, errorAnswer, type HttpResponse, webResponse } from \"./response.ts\";\nimport { composeRouter, Http, type HttpRoute, type RouteMatch, type Router } from \"./router.ts\";\nimport { type LinkOptions, Upgrades } from \"./upgrades.ts\";\n\n/** What `createHttp` takes: the app's settings, fixed for the component's life (changing one is a restart). */\nexport type HttpOptions = {\n\t/** Where Chord's own listener listens; none: no listener (an app mounting `fetch`). Port 0 picks one. */\n\treadonly listen?: ListenAddress;\n\t/** The links endpoint: its path, and each socket's options, a value or per request and principal. */\n\treadonly links?: LinksOptions;\n\t/** How long `close` waits for running requests and closing sockets: 30 s by default. */\n\treadonly closeTimeout?: number;\n\treadonly onError: (error: HttpError) => void;\n};\n\n/** The links endpoint's path and what it gives each socket (`maxPayload` 1 MiB by default). */\nexport type LinksOptions = {\n\treadonly path: string;\n\treadonly options?: LinkOptions | ((request: HttpRequest, principal: Principal) => LinkOptions);\n};\n\n/** What the component reports. */\nexport type HttpError =\n\t| { readonly kind: \"route_failed\"; readonly pattern: string; readonly plugin: string; readonly error: unknown }\n\t| { readonly kind: \"wrap_failed\"; readonly name: string; readonly plugin: string; readonly error: unknown }\n\t| { readonly kind: \"socket_failed\"; readonly pattern: string; readonly plugin: string; readonly error: unknown }\n\t/** A response that could not be made (an invalid header, no JSON) or read whole (a `bytes` read that threw). */\n\t| { readonly kind: \"response_failed\"; readonly pattern: string; readonly error: unknown }\n\t/** A contributed hook threw (`plugin`), or the app's `links.options` (no plugin). */\n\t| { readonly kind: \"hook_failed\"; readonly hook: HookName; readonly plugin?: string; readonly error: unknown };\n\n/** The hooks the component calls. */\nexport type HookName = \"authenticate\" | \"relay\" | \"links.options\";\n\n/** The running component. */\nexport interface HttpComponent<P extends Principal> {\n\t/**\n\t * Its facet (plugin `chord.http`): serves `Http` and `Authenticators`, and with `listen` the listener, a\n\t * host-lifetime object. The app loads it among its core facets, the same object at every reload.\n\t */\n\treadonly facet: Facet<P>;\n\t/**\n\t * Answers a Web `Request` (an app's own server mounts it: `hono.all(\"/*\", (c) => http.fetch(c.req.raw, …))`);\n\t * `connection` is what the server knows of the socket: without `localAddress` and `localPort` no request is local.\n\t * Requests before the publication wait for it (503 past the host's `readyTimeout`).\n\t */\n\tfetch(request: Request, connection?: Connection): Promise<Response>;\n\t/** Node's upgrade adapter (`server.on(\"upgrade\", http.upgrade)`): the links endpoint and plugin sockets. */\n\treadonly upgrade: (message: IncomingMessage, socket: Duplex, head: Buffer) => void;\n\t/** Where the listener listens, once it does (the real port when `listen.port` was 0). */\n\tlistening(context: Context): Promise<ListenAddress>;\n\t/**\n\t * Refuses new requests and upgrades (503), closes sockets and links (1001, terminated at `closeTimeout`), waits for\n\t * running requests up to `closeTimeout` (an aborted `context`: not at all), then seals them. Run it before\n\t * `host.close`, which seals every request's scope at once (the listener's close runs it then, too late to drain).\n\t */\n\tclose(context: Context): Promise<void>;\n}\n\n/** Builds the HTTP component on `host` (a request's scope is a `host.root` with its principal). */\nexport function createHttp<P extends Principal>(\n\thost: Host<P>,\n\toptions: HttpOptions,\n\tcontext: Context,\n): HttpComponent<P> {\n\treturn new Component(host, options, context);\n}\n\n/** The listener: a host-lifetime object of plugin `chord.http` whose native is Chord's own Node server. */\nexport const HttpListener = local(\"chord.http.listener\", { version: 1, params: {}, members: {} });\n\n/** The registries a request reads, resolved once. */\ntype Registries = {\n\treadonly router: RegistryValue<Router>;\n\treadonly authenticators: RegistryValue<readonly AuthenticatorEntry[]>;\n};\n\n/** A request or an upgrade from its arrival to its end: what `close` waits for, then seals. */\ntype Running = { readonly controller: AbortController; done: Promise<unknown> };\n\n/** `close`'s bound unless `closeTimeout` says otherwise: 30 s. */\nconst CLOSE_TIMEOUT = 30_000;\n\n/** Who threw out of a route itself (no wrap). */\nconst ROUTE = { kind: \"route\" } as const;\n\nclass Component<P extends Principal> implements HttpComponent<P>, Handler {\n\treadonly facet: Facet<P>;\n\treadonly upgrade: (message: IncomingMessage, socket: Duplex, head: Buffer) => void;\n\treadonly #host: Host<P>;\n\treadonly #options: HttpOptions;\n\treadonly #onError: (error: HttpError) => void;\n\treadonly #context: Context;\n\t/** The component's context without its cancellation: each request's scope adds its own signal. */\n\treadonly #base: Context;\n\treadonly #defaults = new DefaultHeaders();\n\treadonly #nonces = new Nonces();\n\treadonly #upgrades = new Upgrades();\n\treadonly #running = new Set<Running>();\n\t/** The registries while they resolve (once; again after a failed try), then the values themselves. */\n\t#resolving: Promise<Registries> | undefined;\n\t#registries: Registries | undefined;\n\t/** Aborted at `close`: the router's watch. */\n\treadonly #closing = new AbortController();\n\t#closed: Promise<void> | undefined;\n\treadonly #listening = Promise.withResolvers<ListenAddress>();\n\n\tconstructor(host: Host<P>, options: HttpOptions, context: Context) {\n\t\tthis.#host = host;\n\t\tthis.#options = options;\n\t\tthis.#onError = options.onError;\n\t\tthis.#context = context;\n\t\tthis.#base = withoutAbortSignal(context);\n\t\tthis.#listening.promise.catch(() => {});\n\t\tthis.upgrade = (message, socket, head) => {\n\t\t\tsocket.on(\"error\", () => socket.destroy());\n\t\t\tvoid this.#upgrade(message, socket, head).catch(() => socket.destroy());\n\t\t};\n\t\tconst { listen } = options;\n\t\tthis.facet = defineFacet<P>((facet) => {\n\t\t\tfacet.serve(Http, { compose: composeRouter });\n\t\t\tfacet.serve(Authenticators, { compose: composeAuthenticators });\n\t\t\tif (listen === undefined) return;\n\t\t\tfacet.serve(HttpListener, (_params, self) => {\n\t\t\t\tself.open(\n\t\t\t\t\t(opening) => this.#listen(listen, opening),\n\t\t\t\t\tasync (listener, _reason, closing) => {\n\t\t\t\t\t\tlistener.stop();\n\t\t\t\t\t\tawait this.close(closing);\n\t\t\t\t\t\tawait listener.closed();\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn {};\n\t\t\t});\n\t\t});\n\t}\n\n\tasync fetch(request: Request, connection: Connection = {}): Promise<Response> {\n\t\tconst { answer, finished } = await this.serve(webIncoming(request), connection);\n\t\t// A whole body is out of the component's hands once its `Response` is; a pulled one ends when it is read.\n\t\tif (answer.body instanceof ReadableStream)\n\t\t\treturn webResponse({ ...answer, body: tracked(answer.body, finished) });\n\t\tfinished();\n\t\treturn webResponse(answer);\n\t}\n\n\tlistening(context: Context): Promise<ListenAddress> {\n\t\treturn awaitWithContext(this.#listening.promise, context);\n\t}\n\n\tclose(context: Context): Promise<void> {\n\t\tthis.#closed ??= this.#close(context);\n\t\treturn this.#closed;\n\t}\n\n\t/**\n\t * Serves `request`: its answer, and what its consumer calls once the body is written or abandoned. Never throws:\n\t * whatever fails answers (503 before the publication or while closing, 403, 404, 500 reported).\n\t */\n\tasync serve(request: Incoming, connection: Connection): Promise<Served> {\n\t\tconst controller = new AbortController();\n\t\tconst finished = Promise.withResolvers<void>();\n\t\tconst running: Running = { controller, done: finished.promise };\n\t\tthis.#running.add(running);\n\t\trequest.cancelled((reason) => controller.abort(reason));\n\t\tlet answer: Answer;\n\t\ttry {\n\t\t\tconst served = await this.#serve(request, connection, controller, finished.promise);\n\t\t\tanswer = served.answer;\n\t\t\t// The request is over once its consumer finished and its scope (if it got one) ended.\n\t\t\tif (served.scope !== undefined) running.done = Promise.all([finished.promise, served.scope]);\n\t\t} catch {\n\t\t\tanswer = this.refusal(500);\n\t\t}\n\t\tvoid running.done.then(() => this.#running.delete(running));\n\t\treturn { answer, finished: () => finished.resolve() };\n\t}\n\n\t/** The answer for a refused or failed request, outside any scope, with the default headers. */\n\trefusal(status: number, admitted?: Admitted, router?: Router, head = false): Answer {\n\t\treturn errorAnswer(status, this.#defaults.of(admitted, router, this.#nonces.next()), undefined, head);\n\t}\n\n\t/** The steps of `serve`: closing, the registries, admission, the route, origins, the principal, then the scope. */\n\tasync #serve(\n\t\trequest: Incoming,\n\t\tconnection: Connection,\n\t\tcontroller: AbortController,\n\t\tfinished: Promise<void>,\n\t): Promise<{ readonly answer: Answer; readonly scope?: Promise<void> }> {\n\t\tconst head = request.method === \"HEAD\";\n\t\tif (this.#closing.signal.aborted) return { answer: this.refusal(503, undefined, undefined, head) };\n\t\tlet registries: Registries;\n\t\ttry {\n\t\t\tregistries = this.#registries ?? (await this.#resolve());\n\t\t} catch {\n\t\t\treturn { answer: this.refusal(503, undefined, undefined, head) };\n\t\t}\n\t\tif (this.#closing.signal.aborted) return { answer: this.refusal(503, undefined, undefined, head) };\n\t\tconst router = registries.router.value;\n\t\tconst admission = admit(request, connection, router.hosts, router.relays);\n\t\tif (refused(admission)) {\n\t\t\tif (admission.failed !== undefined) this.#hookFailed(\"relay\", admission.failed.relay, admission.failed.error);\n\t\t\treturn { answer: this.refusal(403, undefined, router, head) };\n\t\t}\n\t\t// A fresh script nonce per response (decision \"A CSP nonce per response\").\n\t\tconst webRequest = new WebRequest(request, admission, this.#nonces.next());\n\t\tconst match = router.route(request.method, webRequest.path);\n\t\tif (match === \"bad_path\" || match === undefined) {\n\t\t\treturn { answer: this.refusal(match === undefined ? 404 : 400, admission, router, head) };\n\t\t}\n\t\twebRequest.params = match.params;\n\t\tconst foreign = isForeign(request);\n\t\tif (!match.crossSite && !originAccepted(request.method, request, admission.origin)) {\n\t\t\treturn { answer: this.refusal(403, admission, router, head) };\n\t\t}\n\t\tlet principal: P | undefined;\n\t\t// Foreign requests are never authenticated but a top-level navigation to a page; a cross-site route never is.\n\t\tconst authenticators = registries.authenticators.value;\n\t\tif (\n\t\t\tauthenticators.length > 0 &&\n\t\t\t!match.crossSite &&\n\t\t\t(!foreign || (match.page && isNavigation(request.method, request)))\n\t\t) {\n\t\t\tprincipal = await this.#principal(registries, webRequest, controller.signal);\n\t\t\tif (this.#closing.signal.aborted || controller.signal.aborted) {\n\t\t\t\treturn { answer: this.refusal(503, admission, router, head) };\n\t\t\t}\n\t\t}\n\t\tconst answered = Promise.withResolvers<Answer>();\n\t\tconst scope = this.#host\n\t\t\t.root(\n\t\t\t\tasync (ctx) => {\n\t\t\t\t\tanswered.resolve(await this.#run(request, webRequest, match, admission, router, foreign, ctx));\n\t\t\t\t\t// The scope lasts until the body is written or abandoned (a `bytes` body reads in it).\n\t\t\t\t\tawait finished;\n\t\t\t\t},\n\t\t\t\twithAbortSignal(controller.signal, this.#base),\n\t\t\t\t{ principal },\n\t\t\t)\n\t\t\t.catch(() => {\n\t\t\t\t// The scope was sealed (a disconnect, `close`) before it answered: the request is over.\n\t\t\t\tanswered.resolve(this.refusal(503, admission, router, head));\n\t\t\t});\n\t\treturn { answer: await answered.promise, scope };\n\t}\n\n\t/** Runs the wraps and the route in the request's scope `ctx`, and makes its answer (a failure: a reported 500). */\n\tasync #run(\n\t\tincoming: Incoming,\n\t\trequest: WebRequest,\n\t\tmatch: RouteMatch,\n\t\tadmitted: Admitted,\n\t\trouter: Router,\n\t\tforeign: boolean,\n\t\tctx: Ctx<P>,\n\t): Promise<Answer> {\n\t\tlet response: HttpResponse;\n\t\ttry {\n\t\t\tresponse = await chainOf(match, ctx)(request);\n\t\t} catch (error) {\n\t\t\tresponse = this.#failure(error, match);\n\t\t}\n\t\t// Downloads are never another site's to take (rule 6).\n\t\tif (response.kind === \"bytes\" && foreign) response = { kind: \"error\", status: 403 };\n\t\tconst failed = (error: unknown): void =>\n\t\t\tthis.#onError({ kind: \"response_failed\", pattern: match.pattern, error });\n\t\ttry {\n\t\t\treturn answerOf(response, incoming, this.#defaults.of(admitted, router, request.nonce), ctx, failed);\n\t\t} catch (error) {\n\t\t\tfailed(error);\n\t\t\treturn this.refusal(500, admitted, router, request.method === \"HEAD\");\n\t\t}\n\t}\n\n\t/** What an error escaping the chain answers: its `HttpFailure`'s status, else a reported 500 without its message. */\n\t#failure(error: unknown, match: RouteMatch): HttpResponse {\n\t\tconst thrown = error instanceof Thrown ? error : new Thrown(ROUTE, match.plugin, error);\n\t\tif (thrown.cause instanceof HttpFailure) return { kind: \"error\", status: thrown.cause.status };\n\t\t// Chord refused the caller (an anonymous scope's remote object, a route's `authorize`): no failure of the route.\n\t\tif (isChordError(thrown.cause, \"forbidden\")) return { kind: \"error\", status: 403 };\n\t\tif (thrown.by.kind === \"route\") {\n\t\t\tthis.#onError({ kind: \"route_failed\", pattern: match.pattern, plugin: thrown.plugin, error: thrown.cause });\n\t\t} else {\n\t\t\tthis.#onError({ kind: \"wrap_failed\", name: thrown.by.name, plugin: thrown.plugin, error: thrown.cause });\n\t\t}\n\t\treturn { kind: \"error\", status: 500 };\n\t}\n\n\t/**\n\t * The principal the authenticators give `request`; one that throws is reported and skipped. Raced against `signal`\n\t * (a disconnect, `close`'s seal): an authenticator ignoring it no longer holds the request; the caller sees the\n\t * abort and answers 503.\n\t */\n\tasync #principal(registries: Registries, request: HttpRequest, signal: AbortSignal): Promise<P | undefined> {\n\t\tconst failed = (plugin: string, error: unknown): void => this.#hookFailed(\"authenticate\", plugin, error);\n\t\tconst context = withAbortSignal(signal, this.#base);\n\t\tconst authenticating = authenticate(registries.authenticators.value, request, failed, context);\n\t\t// The registry's values are typed by no principal type: an app's authenticators return its principals.\n\t\treturn (await awaitWithContext(authenticating, context).catch(() => undefined)) as P | undefined;\n\t}\n\n\t#hookFailed(hook: HookName, plugin: string | undefined, error: unknown): void {\n\t\tthis.#onError({ kind: \"hook_failed\", hook, ...(plugin === undefined ? {} : { plugin }), error });\n\t}\n\n\t/** The registries: resolved once, waiting for the publication; a failed try is tried again later. */\n\t#resolve(): Promise<Registries> {\n\t\tthis.#resolving ??= Promise.all([\n\t\t\tthis.#host.registry(Http, this.#context),\n\t\t\tthis.#host.registry(Authenticators, this.#context),\n\t\t]).then(\n\t\t\t([router, authenticators]) => {\n\t\t\t\tthis.#registries = { router, authenticators };\n\t\t\t\t// A close may come first: nothing to follow then (Astra's recheck R4: the stopped watch threw unhandled).\n\t\t\t\tthis.#follow(router).catch(() => {});\n\t\t\t\treturn this.#registries;\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tthis.#resolving = undefined;\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\treturn this.#resolving;\n\t}\n\n\t/** Follows the router until `close`: connections its changes no longer admit are terminated. */\n\tasync #follow(router: RegistryValue<Router>): Promise<void> {\n\t\tif (this.#closing.signal.aborted) return;\n\t\tconst watch = await router.watch(withAbortSignal(this.#closing.signal, this.#base));\n\t\tif (this.#closing.signal.aborted) return;\n\t\twatch.start(async (call) => {\n\t\t\tif (call.kind === \"value\") this.#upgrades.revoke(call.value);\n\t\t});\n\t}\n\n\t/** One upgrade, tracked from its arrival: refused while closing, else admitted and checked, then handed out. */\n\tasync #upgrade(message: IncomingMessage, stream: Duplex, head: Buffer): Promise<void> {\n\t\tconst controller = new AbortController();\n\t\t// A client gone while its upgrade authenticates aborts that work (Astra's recheck R1, Sol's N5).\n\t\tconst gone = (): void => controller.abort(new Error(\"http: the client disconnected\"));\n\t\tif (stream.destroyed) gone();\n\t\telse {\n\t\t\t// A clean disconnect (FIN) is seen only by reading: nothing reads a detached upgrade socket, so start it\n\t\t\t// (Fable's second recheck: `end()` while authenticating went unnoticed).\n\t\t\tstream.once(\"close\", gone);\n\t\t\tstream.once(\"end\", gone);\n\t\t\tstream.read(0);\n\t\t}\n\t\tconst running: Running = { controller, done: Promise.resolve() };\n\t\tconst work = this.#upgradeSteps(message, stream, head, controller.signal);\n\t\trunning.done = work;\n\t\tthis.#running.add(running);\n\t\ttry {\n\t\t\tawait work;\n\t\t} finally {\n\t\t\tstream.removeListener(\"close\", gone);\n\t\t\tstream.removeListener(\"end\", gone);\n\t\t\tthis.#running.delete(running);\n\t\t}\n\t}\n\n\t/** The steps of an upgrade (the same rules as a request's; a socket needs a principal), checked again at hand-out. */\n\tasync #upgradeSteps(message: IncomingMessage, stream: Duplex, head: Buffer, signal: AbortSignal): Promise<void> {\n\t\tif (this.#closing.signal.aborted) return refuse(stream, 503);\n\t\tconst request = NodeIncoming.of(message);\n\t\tif (!(request instanceof NodeIncoming)) return refuse(stream, request.status);\n\t\tlet registries: Registries;\n\t\ttry {\n\t\t\tregistries = this.#registries ?? (await this.#resolve());\n\t\t} catch {\n\t\t\treturn refuse(stream, 503);\n\t\t}\n\t\tif (this.#closing.signal.aborted || signal.aborted) return refuse(stream, 503);\n\t\tconst before = registries.router.value;\n\t\tconst admission = admit(request, connectionOf(message), before.hosts, before.relays);\n\t\tif (refused(admission)) {\n\t\t\tif (admission.failed !== undefined) this.#hookFailed(\"relay\", admission.failed.relay, admission.failed.error);\n\t\t\treturn refuse(stream, 403);\n\t\t}\n\t\tconst sent = request.header(\"origin\");\n\t\tif (isForeign(request) || (sent !== null && sent !== admission.origin)) return refuse(stream, 403);\n\t\tconst webRequest = new WebRequest(request, admission, this.#nonces.next());\n\t\tconst principal = await this.#principal(registries, webRequest, signal);\n\t\tif (this.#closing.signal.aborted || signal.aborted) return refuse(stream, 503);\n\t\tif (principal === undefined) return refuse(stream, 403);\n\t\t// The router now: a host, a relay or a socket removed while authenticating refuses the upgrade.\n\t\tconst router = registries.router.value;\n\t\tconst { allowed, relay } = admission;\n\t\tif (\n\t\t\t(allowed !== undefined && !router.hosts.has(allowed)) ||\n\t\t\t(relay !== undefined && !router.relays.includes(relay))\n\t\t) {\n\t\t\treturn refuse(stream, 403);\n\t\t}\n\t\tconst { links } = this.#options;\n\t\tif (links !== undefined && webRequest.path === links.path) {\n\t\t\tlet options: LinkOptions;\n\t\t\ttry {\n\t\t\t\toptions =\n\t\t\t\t\t(typeof links.options === \"function\" ? links.options(webRequest, principal) : links.options) ?? {};\n\t\t\t} catch (error) {\n\t\t\t\tthis.#hookFailed(\"links.options\", undefined, error);\n\t\t\t\treturn refuse(stream, 403);\n\t\t\t}\n\t\t\tconst admitted = { allowed, relay, principal, ...options };\n\t\t\treturn this.#upgrades.link(message, stream, head, admitted, this.#host, this.#context);\n\t\t}\n\t\tconst match = router.socket(webRequest.path);\n\t\tif (match === \"bad_path\") return refuse(stream, 400);\n\t\tif (match === undefined) return refuse(stream, 404);\n\t\twebRequest.params = match.params;\n\t\tconst fail = ({ pattern, plugin, error }: { pattern: string; plugin: string; error: unknown }) =>\n\t\t\tthis.#onError({ kind: \"socket_failed\", pattern, plugin, error });\n\t\tconst admitted = { allowed, relay, principal, match, request: webRequest };\n\t\tthis.#upgrades.socket(message, stream, head, admitted, this.#host, this.#context, fail);\n\t}\n\n\t/** The listener's open: Chord's own Node server listening at `listen`. */\n\tasync #listen(listen: ListenAddress, context: Context): Promise<NodeListener> {\n\t\tconst listener = await NodeListener.listen(this, listen, context);\n\t\tthis.#listening.resolve(listener.address);\n\t\treturn listener;\n\t}\n\n\t/** `close`: refuses from now on, then waits for sockets and running requests until the deadline, then seals. */\n\tasync #close(context: Context): Promise<void> {\n\t\tthis.#closing.abort();\n\t\tthis.#listening.reject(new Error(\"http: closed\"));\n\t\tconst timeout = this.#options.closeTimeout ?? CLOSE_TIMEOUT;\n\t\tconst signal = context.abortSignal;\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\tlet aborted: (() => void) | undefined;\n\t\tconst deadline = new Promise<void>((resolve) => {\n\t\t\t// Already aborted: no wait at all (Sol's recheck N9).\n\t\t\tif (signal?.aborted) return resolve();\n\t\t\ttimer = setTimeout(resolve, timeout);\n\t\t\taborted = () => resolve();\n\t\t\tsignal?.addEventListener(\"abort\", aborted, { once: true });\n\t\t});\n\t\tconst running = Promise.all([...this.#running].map(({ done }) => done));\n\t\tawait Promise.race([Promise.all([this.#upgrades.close(deadline), running]), deadline]);\n\t\tclearTimeout(timer);\n\t\tif (aborted !== undefined) signal?.removeEventListener(\"abort\", aborted);\n\t\tfor (const { controller } of this.#running) controller.abort(new Error(\"http: closed\"));\n\t}\n}\n\n/**\n * `stream` as read by its consumer, `finished` called once it is read to its end, failed or cancelled (a mounted\n * handler's `bytes` body: the request's scope lasts until then).\n */\nfunction tracked(stream: ReadableStream<Uint8Array>, finished: () => void): ReadableStream<Uint8Array> {\n\tconst reader = stream.getReader();\n\t// The owned stream ending (read whole, or errored by the scope's seal) ends the request too, whether or not its\n\t// consumer pulls again (Sol's second recheck B: an aborted `Response` nobody touched kept its request and scope).\n\treader.closed.then(finished, finished);\n\treturn new ReadableStream<Uint8Array>(\n\t\t{\n\t\t\tpull: async (controller) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst next = await reader.read();\n\t\t\t\t\tif (next.done) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\tfinished();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontroller.enqueue(next.value);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tcontroller.error(error);\n\t\t\t\t\tfinished();\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancel: async (reason) => {\n\t\t\t\tfinished();\n\t\t\t\tawait reader.cancel(reason);\n\t\t\t},\n\t\t},\n\t\t{ highWaterMark: 0 },\n\t);\n}\n\n/** Refuses an upgrade with `status` and closes its connection. */\nfunction refuse(stream: Duplex, status: number): void {\n\tstream.end(`HTTP/1.1 ${status} ${STATUS[status] ?? \"\"}\\r\\nConnection: close\\r\\nContent-Length: 0\\r\\n\\r\\n`);\n}\n\n/** The reason phrases of the statuses an upgrade is refused with. */\nconst STATUS: Readonly<Record<number, string>> = {\n\t400: \"Bad Request\",\n\t403: \"Forbidden\",\n\t404: \"Not Found\",\n\t501: \"Not Implemented\",\n\t503: \"Service Unavailable\",\n};\n\n/** Who threw out of a request's chain: the route, or a wrap (by name), with its plugin. */\nclass Thrown extends Error {\n\treadonly by: { readonly kind: \"route\" } | { readonly kind: \"wrap\"; readonly name: string };\n\treadonly plugin: string;\n\n\tconstructor(by: Thrown[\"by\"], plugin: string, cause: unknown) {\n\t\tsuper(\"thrown\", { cause });\n\t\tthis.by = by;\n\t\tthis.plugin = plugin;\n\t}\n}\n\n/** The route of `match` inside its wraps (outermost first), each throw tagged with who threw it. */\nfunction chainOf(match: RouteMatch, ctx: Ctx): (request: HttpRequest) => Promise<HttpResponse> {\n\tlet next: (request: HttpRequest) => Promise<HttpResponse> = tagged(match.handler, match.plugin, ctx);\n\tfor (let index = match.wraps.length - 1; index >= 0; index--) {\n\t\tconst { wrap, plugin } = match.wraps[index]!;\n\t\tconst inner = next;\n\t\tnext = async (request) => {\n\t\t\ttry {\n\t\t\t\treturn await wrap.wrap(request, inner, ctx);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Thrown) throw error;\n\t\t\t\tthrow new Thrown({ kind: \"wrap\", name: wrap.name }, plugin, error);\n\t\t\t}\n\t\t};\n\t}\n\treturn next;\n}\n\n/** `route` with its throws tagged as the route's. */\nfunction tagged(route: HttpRoute, plugin: string, ctx: Ctx): (request: HttpRequest) => Promise<HttpResponse> {\n\treturn async (request) => {\n\t\ttry {\n\t\t\treturn await route(request, ctx);\n\t\t} catch (error) {\n\t\t\tthrow new Thrown(ROUTE, plugin, error);\n\t\t}\n\t};\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /** A request as the component reads it. */
2
+ export interface Incoming {
3
+ readonly method: string;
4
+ /** The URL as the URL parser serialized it (dot segments resolved, `\` as `/`). */
5
+ readonly url: string;
6
+ /** A header's value, several of one name joined with `", "` (as `Headers.get`); `null` without it. */
7
+ header(name: string): string | null;
8
+ /** Whether a proxy forwarded it: a `Forwarded` or `X-Forwarded-*` header. */
9
+ forwarded(): boolean;
10
+ /** Calls `abort` once when the client goes away before its answer is written (at once when it has). */
11
+ cancelled(abort: (reason: unknown) => void): void;
12
+ /** The Web `Request`, made at the first call on the Node side. */
13
+ request(): Request;
14
+ }
15
+ /** `request` as the component reads it. */
16
+ export declare function webIncoming(request: Request): Incoming;
17
+ /** Whether a (lowercased) header name says a proxy forwarded the request. */
18
+ export declare function isForwarding(name: string): boolean;
19
+ //# sourceMappingURL=incoming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incoming.d.ts","sourceRoot":"","sources":["../../../src/next-node/http/incoming.ts"],"names":[],"mappings":"AAKA,2CAA2C;AAC3C,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,sGAAsG;IACtG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,6EAA6E;IAC7E,SAAS,IAAI,OAAO,CAAC;IACrB,uGAAuG;IACvG,SAAS,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;IAClD,kEAAkE;IAClE,OAAO,IAAI,OAAO,CAAC;CACnB;AAED,2CAA2C;AAC3C,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAgBtD;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD"}
@@ -0,0 +1,31 @@
1
+ // What the component reads of a request (decision "The HTTP core is a fetch handler"): one shape for a Web `Request`
2
+ // (`fetch`) and for Chord's own Node server, so admission, routing and the baseline have one implementation. The Node
3
+ // side reads Node's own parsed headers and builds a Web `Request` only when something asks for it (a route's
4
+ // `headers` or body, a relay's `verify`).
5
+ /** `request` as the component reads it. */
6
+ export function webIncoming(request) {
7
+ return {
8
+ method: request.method,
9
+ url: request.url,
10
+ header: (name) => request.headers.get(name),
11
+ forwarded: () => {
12
+ for (const name of request.headers.keys())
13
+ if (isForwarding(name))
14
+ return true;
15
+ return false;
16
+ },
17
+ cancelled: (abort) => {
18
+ const { signal } = request;
19
+ if (signal.aborted)
20
+ abort(signal.reason);
21
+ else
22
+ signal.addEventListener("abort", () => abort(signal.reason), { once: true });
23
+ },
24
+ request: () => request,
25
+ };
26
+ }
27
+ /** Whether a (lowercased) header name says a proxy forwarded the request. */
28
+ export function isForwarding(name) {
29
+ return name === "forwarded" || name.startsWith("x-forwarded-");
30
+ }
31
+ //# sourceMappingURL=incoming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incoming.js","sourceRoot":"","sources":["../../../src/next-node/http/incoming.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,sHAAsH;AACtH,6GAA6G;AAC7G,0CAA0C;AAiB1C,2CAA2C;AAC3C,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC3C,OAAO;QACN,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QAC3C,SAAS,EAAE,GAAG,EAAE;YACf,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE;gBAAE,IAAI,YAAY,CAAC,IAAI,CAAC;oBAAE,OAAO,IAAI,CAAC;YAC/E,OAAO,KAAK,CAAC;QACd,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACpB,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;YAC3B,IAAI,MAAM,CAAC,OAAO;gBAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;gBACpC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;KACtB,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAChE,CAAC","sourcesContent":["// What the component reads of a request (decision \"The HTTP core is a fetch handler\"): one shape for a Web `Request`\n// (`fetch`) and for Chord's own Node server, so admission, routing and the baseline have one implementation. The Node\n// side reads Node's own parsed headers and builds a Web `Request` only when something asks for it (a route's\n// `headers` or body, a relay's `verify`).\n\n/** A request as the component reads it. */\nexport interface Incoming {\n\treadonly method: string;\n\t/** The URL as the URL parser serialized it (dot segments resolved, `\\` as `/`). */\n\treadonly url: string;\n\t/** A header's value, several of one name joined with `\", \"` (as `Headers.get`); `null` without it. */\n\theader(name: string): string | null;\n\t/** Whether a proxy forwarded it: a `Forwarded` or `X-Forwarded-*` header. */\n\tforwarded(): boolean;\n\t/** Calls `abort` once when the client goes away before its answer is written (at once when it has). */\n\tcancelled(abort: (reason: unknown) => void): void;\n\t/** The Web `Request`, made at the first call on the Node side. */\n\trequest(): Request;\n}\n\n/** `request` as the component reads it. */\nexport function webIncoming(request: Request): Incoming {\n\treturn {\n\t\tmethod: request.method,\n\t\turl: request.url,\n\t\theader: (name) => request.headers.get(name),\n\t\tforwarded: () => {\n\t\t\tfor (const name of request.headers.keys()) if (isForwarding(name)) return true;\n\t\t\treturn false;\n\t\t},\n\t\tcancelled: (abort) => {\n\t\t\tconst { signal } = request;\n\t\t\tif (signal.aborted) abort(signal.reason);\n\t\t\telse signal.addEventListener(\"abort\", () => abort(signal.reason), { once: true });\n\t\t},\n\t\trequest: () => request,\n\t};\n}\n\n/** Whether a (lowercased) header name says a proxy forwarded the request. */\nexport function isForwarding(name: string): boolean {\n\treturn name === \"forwarded\" || name.startsWith(\"x-forwarded-\");\n}\n"]}
@@ -0,0 +1,11 @@
1
+ export type { Connection, Provenance } from "./admission.ts";
2
+ export { type Authenticator, Authenticators } from "./authenticate.ts";
3
+ export { type CookieOptions, cookie, readCookie } from "./cookies.ts";
4
+ export { type FileResponseOptions, fileResponse } from "./file.ts";
5
+ export { createHttp, type HookName, type HttpComponent, type HttpError, HttpListener, type HttpOptions, type LinksOptions, } from "./http.ts";
6
+ export { type ListenAddress, type NodeRequest, nodeRequest } from "./node.ts";
7
+ export { HttpFailure, type HttpRequest } from "./request.ts";
8
+ export type { HttpResponse } from "./response.ts";
9
+ export { Http, type HttpContribution, type HttpRelay, type HttpRoute, type HttpRouteOptions, type HttpSocket, type HttpWrap, type Router, type WebSocketHandle, type WrapPhase, } from "./router.ts";
10
+ export type { LinkOptions } from "./upgrades.ts";
11
+ //# sourceMappingURL=index.d.ts.map