@fougere/core 0.5.0-alpha.1 → 0.7.0-alpha.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 (519) hide show
  1. package/README.md +1 -1
  2. package/dist/boot/Emissions.d.ts +14 -91
  3. package/dist/boot/Emissions.d.ts.map +1 -1
  4. package/dist/boot/Emissions.js +21 -118
  5. package/dist/boot/Emissions.js.map +1 -1
  6. package/dist/boot/ambient-port.d.ts +3 -24
  7. package/dist/boot/ambient-port.d.ts.map +1 -1
  8. package/dist/boot/ambient.als.d.ts.map +1 -1
  9. package/dist/boot/ambient.als.js +7 -12
  10. package/dist/boot/ambient.als.js.map +1 -1
  11. package/dist/boot/ambient.queue.d.ts +2 -5
  12. package/dist/boot/ambient.queue.d.ts.map +1 -1
  13. package/dist/boot/ambient.queue.js.map +1 -1
  14. package/dist/boot/apply.d.ts +1 -13
  15. package/dist/boot/apply.d.ts.map +1 -1
  16. package/dist/boot/apply.js +3 -15
  17. package/dist/boot/apply.js.map +1 -1
  18. package/dist/boot/auth.d.ts +6 -16
  19. package/dist/boot/auth.d.ts.map +1 -1
  20. package/dist/boot/boot.d.ts +5 -18
  21. package/dist/boot/boot.d.ts.map +1 -1
  22. package/dist/boot/boot.js +4 -11
  23. package/dist/boot/boot.js.map +1 -1
  24. package/dist/boot/bootstrap.d.ts.map +1 -1
  25. package/dist/boot/bootstrap.js +106 -163
  26. package/dist/boot/bootstrap.js.map +1 -1
  27. package/dist/boot/card.d.ts +5 -0
  28. package/dist/boot/card.d.ts.map +1 -0
  29. package/dist/boot/card.js +71 -0
  30. package/dist/boot/card.js.map +1 -0
  31. package/dist/boot/frame.d.ts +8 -32
  32. package/dist/boot/frame.d.ts.map +1 -1
  33. package/dist/boot/frame.js +23 -57
  34. package/dist/boot/frame.js.map +1 -1
  35. package/dist/boot/hosted.d.ts +3 -19
  36. package/dist/boot/hosted.d.ts.map +1 -1
  37. package/dist/boot/hosted.js +12 -17
  38. package/dist/boot/hosted.js.map +1 -1
  39. package/dist/boot/ownership.d.ts +5 -36
  40. package/dist/boot/ownership.d.ts.map +1 -1
  41. package/dist/boot/ownership.js +9 -49
  42. package/dist/boot/ownership.js.map +1 -1
  43. package/dist/boot/ports.d.ts +2 -15
  44. package/dist/boot/ports.d.ts.map +1 -1
  45. package/dist/boot/ports.js +1 -14
  46. package/dist/boot/ports.js.map +1 -1
  47. package/dist/boot/remote.d.ts +5 -38
  48. package/dist/boot/remote.d.ts.map +1 -1
  49. package/dist/boot/remote.js +8 -41
  50. package/dist/boot/remote.js.map +1 -1
  51. package/dist/boot/runner.d.ts +11 -0
  52. package/dist/boot/runner.d.ts.map +1 -0
  53. package/dist/boot/runner.js +13 -0
  54. package/dist/boot/runner.js.map +1 -0
  55. package/dist/boot/seed.d.ts +5 -32
  56. package/dist/boot/seed.d.ts.map +1 -1
  57. package/dist/boot/seed.js +10 -41
  58. package/dist/boot/seed.js.map +1 -1
  59. package/dist/boot/statement-drift.d.ts +4 -22
  60. package/dist/boot/statement-drift.d.ts.map +1 -1
  61. package/dist/boot/statement-drift.js +4 -9
  62. package/dist/boot/statement-drift.js.map +1 -1
  63. package/dist/boot/together.d.ts +8 -12
  64. package/dist/boot/together.d.ts.map +1 -1
  65. package/dist/boot/together.js +28 -65
  66. package/dist/boot/together.js.map +1 -1
  67. package/dist/boot/types.d.ts +36 -180
  68. package/dist/boot/types.d.ts.map +1 -1
  69. package/dist/builtin/config.d.ts +7 -0
  70. package/dist/builtin/config.d.ts.map +1 -0
  71. package/dist/builtin/config.js +15 -0
  72. package/dist/builtin/config.js.map +1 -0
  73. package/dist/{builtins → builtin}/logger.d.ts +4 -25
  74. package/dist/builtin/logger.d.ts.map +1 -0
  75. package/dist/{builtins → builtin}/logger.js +5 -32
  76. package/dist/builtin/logger.js.map +1 -0
  77. package/dist/config-loader.d.ts +9 -67
  78. package/dist/config-loader.d.ts.map +1 -1
  79. package/dist/config-loader.js +5 -18
  80. package/dist/config-loader.js.map +1 -1
  81. package/dist/contract.d.ts +13 -31
  82. package/dist/contract.d.ts.map +1 -1
  83. package/dist/contract.js +10 -26
  84. package/dist/contract.js.map +1 -1
  85. package/dist/crypto/encoding.d.ts +2 -15
  86. package/dist/crypto/encoding.d.ts.map +1 -1
  87. package/dist/crypto/encoding.js +2 -15
  88. package/dist/crypto/encoding.js.map +1 -1
  89. package/dist/crypto/node.d.ts.map +1 -1
  90. package/dist/crypto/node.js +1 -7
  91. package/dist/crypto/node.js.map +1 -1
  92. package/dist/crypto/port.d.ts +2 -18
  93. package/dist/crypto/port.d.ts.map +1 -1
  94. package/dist/crypto/port.js +1 -17
  95. package/dist/crypto/port.js.map +1 -1
  96. package/dist/crypto/webcrypto.d.ts.map +1 -1
  97. package/dist/crypto/webcrypto.js +1 -12
  98. package/dist/crypto/webcrypto.js.map +1 -1
  99. package/dist/declare.d.ts +41 -0
  100. package/dist/declare.d.ts.map +1 -0
  101. package/dist/{scan/declare.js → declare.js} +6 -31
  102. package/dist/declare.js.map +1 -0
  103. package/dist/define.d.ts +2 -3
  104. package/dist/define.d.ts.map +1 -1
  105. package/dist/define.js +2 -3
  106. package/dist/define.js.map +1 -1
  107. package/dist/descriptor/Fronds.d.ts +19 -0
  108. package/dist/descriptor/Fronds.d.ts.map +1 -0
  109. package/dist/descriptor/Fronds.js +40 -0
  110. package/dist/descriptor/Fronds.js.map +1 -0
  111. package/dist/descriptor/frond.d.ts +135 -0
  112. package/dist/descriptor/frond.d.ts.map +1 -0
  113. package/dist/{scan → descriptor}/frond.js.map +1 -1
  114. package/dist/dispatch/ArgumentResolver.d.ts +6 -3
  115. package/dist/dispatch/ArgumentResolver.d.ts.map +1 -1
  116. package/dist/dispatch/ArgumentResolver.js +48 -3
  117. package/dist/dispatch/ArgumentResolver.js.map +1 -1
  118. package/dist/dispatch/DispatchEvent.d.ts +2 -2
  119. package/dist/dispatch/DispatchEvent.d.ts.map +1 -1
  120. package/dist/dispatch/DispatchLifecycle.d.ts +1 -7
  121. package/dist/dispatch/DispatchLifecycle.d.ts.map +1 -1
  122. package/dist/dispatch/DispatchLifecycle.js +1 -7
  123. package/dist/dispatch/DispatchLifecycle.js.map +1 -1
  124. package/dist/dispatch/DispatchPort.d.ts +1 -1
  125. package/dist/dispatch/DispatchPort.d.ts.map +1 -1
  126. package/dist/dispatch/Dispatcher.d.ts +1 -1
  127. package/dist/dispatch/Dispatcher.d.ts.map +1 -1
  128. package/dist/dispatch/Dispatcher.js +2 -2
  129. package/dist/dispatch/Dispatcher.js.map +1 -1
  130. package/dist/{boot → dispatch}/HandlerFacade.d.ts +25 -38
  131. package/dist/dispatch/HandlerFacade.d.ts.map +1 -0
  132. package/dist/{boot → dispatch}/HandlerFacade.js +65 -74
  133. package/dist/dispatch/HandlerFacade.js.map +1 -0
  134. package/dist/dispatch/LocalRoutePolicy.d.ts +1 -1
  135. package/dist/dispatch/LocalRoutePolicy.d.ts.map +1 -1
  136. package/dist/dispatch/LocalRoutePolicy.js +4 -4
  137. package/dist/dispatch/LocalRoutePolicy.js.map +1 -1
  138. package/dist/dispatch/OperationRoute.d.ts +2 -2
  139. package/dist/dispatch/OperationRoute.d.ts.map +1 -1
  140. package/dist/dispatch/OutputView.d.ts +3 -2
  141. package/dist/dispatch/OutputView.d.ts.map +1 -1
  142. package/dist/dispatch/OutputView.js +19 -1
  143. package/dist/dispatch/OutputView.js.map +1 -1
  144. package/dist/dispatch/Route.d.ts +2 -3
  145. package/dist/dispatch/Route.d.ts.map +1 -1
  146. package/dist/dispatch/RoutePolicy.d.ts +1 -1
  147. package/dist/dispatch/RoutePolicy.d.ts.map +1 -1
  148. package/dist/dispatch/RouteRegistry.d.ts +1 -1
  149. package/dist/dispatch/RouteRegistry.d.ts.map +1 -1
  150. package/dist/dispatch/RouteRegistry.js +2 -2
  151. package/dist/dispatch/RouteRegistry.js.map +1 -1
  152. package/dist/dispatch/RouteResolver.d.ts +2 -4
  153. package/dist/dispatch/RouteResolver.d.ts.map +1 -1
  154. package/dist/dispatch/StorageGuard.d.ts +9 -8
  155. package/dist/dispatch/StorageGuard.d.ts.map +1 -1
  156. package/dist/dispatch/StorageGuard.js +66 -23
  157. package/dist/dispatch/StorageGuard.js.map +1 -1
  158. package/dist/dispatch/presenterArguments.d.ts +7 -0
  159. package/dist/dispatch/presenterArguments.d.ts.map +1 -0
  160. package/dist/dispatch/presenterArguments.js +12 -0
  161. package/dist/dispatch/presenterArguments.js.map +1 -0
  162. package/dist/dispatch/remoteRoutes.d.ts +7 -0
  163. package/dist/dispatch/remoteRoutes.d.ts.map +1 -0
  164. package/dist/dispatch/{RemoteRouteResolver.js → remoteRoutes.js} +6 -10
  165. package/dist/dispatch/remoteRoutes.js.map +1 -0
  166. package/dist/dispatch/routeNotFound.d.ts +9 -0
  167. package/dist/dispatch/routeNotFound.d.ts.map +1 -0
  168. package/dist/dispatch/routeNotFound.js +21 -0
  169. package/dist/dispatch/routeNotFound.js.map +1 -0
  170. package/dist/dispatch/validateInput.d.ts +5 -0
  171. package/dist/dispatch/validateInput.d.ts.map +1 -0
  172. package/dist/dispatch/validateInput.js +20 -0
  173. package/dist/dispatch/validateInput.js.map +1 -0
  174. package/dist/effective-operation.d.ts +6 -3
  175. package/dist/effective-operation.d.ts.map +1 -1
  176. package/dist/effective-operation.js +49 -27
  177. package/dist/effective-operation.js.map +1 -1
  178. package/dist/emit.d.ts +4 -42
  179. package/dist/emit.d.ts.map +1 -1
  180. package/dist/emit.js +3 -39
  181. package/dist/emit.js.map +1 -1
  182. package/dist/entry/facade.d.ts +8 -0
  183. package/dist/entry/facade.d.ts.map +1 -0
  184. package/dist/entry/facade.js +28 -0
  185. package/dist/entry/facade.js.map +1 -0
  186. package/dist/entry/transport.d.ts +5 -0
  187. package/dist/entry/transport.d.ts.map +1 -0
  188. package/dist/entry/transport.js +11 -0
  189. package/dist/entry/transport.js.map +1 -0
  190. package/dist/frond-config.d.ts +8 -71
  191. package/dist/frond-config.d.ts.map +1 -1
  192. package/dist/frond-config.js +1 -9
  193. package/dist/frond-config.js.map +1 -1
  194. package/dist/graph.d.ts +1 -1
  195. package/dist/graph.d.ts.map +1 -1
  196. package/dist/identity-keys.d.ts +2 -5
  197. package/dist/identity-keys.d.ts.map +1 -1
  198. package/dist/identity-keys.js +3 -16
  199. package/dist/identity-keys.js.map +1 -1
  200. package/dist/identity.d.ts +4 -30
  201. package/dist/identity.d.ts.map +1 -1
  202. package/dist/identity.js +11 -73
  203. package/dist/identity.js.map +1 -1
  204. package/dist/imports.d.ts +2 -8
  205. package/dist/imports.d.ts.map +1 -1
  206. package/dist/imports.js +1 -7
  207. package/dist/imports.js.map +1 -1
  208. package/dist/index.d.ts +28 -30
  209. package/dist/index.d.ts.map +1 -1
  210. package/dist/index.js +17 -22
  211. package/dist/index.js.map +1 -1
  212. package/dist/loader.d.ts +1 -8
  213. package/dist/loader.d.ts.map +1 -1
  214. package/dist/loader.js +1 -8
  215. package/dist/loader.js.map +1 -1
  216. package/dist/node.d.ts +2 -11
  217. package/dist/node.d.ts.map +1 -1
  218. package/dist/node.js +2 -11
  219. package/dist/node.js.map +1 -1
  220. package/dist/prefab/collector.d.ts +1 -22
  221. package/dist/prefab/collector.d.ts.map +1 -1
  222. package/dist/prefab/collector.js +1 -22
  223. package/dist/prefab/collector.js.map +1 -1
  224. package/dist/prefab/crud.d.ts +19 -35
  225. package/dist/prefab/crud.d.ts.map +1 -1
  226. package/dist/prefab/crud.js +39 -66
  227. package/dist/prefab/crud.js.map +1 -1
  228. package/dist/prefab/mirror.d.ts +5 -27
  229. package/dist/prefab/mirror.d.ts.map +1 -1
  230. package/dist/prefab/mirror.js +6 -24
  231. package/dist/prefab/mirror.js.map +1 -1
  232. package/dist/prefab/prefab.d.ts +1 -7
  233. package/dist/prefab/prefab.d.ts.map +1 -1
  234. package/dist/prefab/prefab.js +1 -7
  235. package/dist/prefab/prefab.js.map +1 -1
  236. package/dist/prefab/presenter.d.ts +2 -36
  237. package/dist/prefab/presenter.d.ts.map +1 -1
  238. package/dist/prefab/presenter.js +2 -36
  239. package/dist/prefab/presenter.js.map +1 -1
  240. package/dist/prefab/repository.d.ts +12 -80
  241. package/dist/prefab/repository.d.ts.map +1 -1
  242. package/dist/prefab/repository.js +22 -35
  243. package/dist/prefab/repository.js.map +1 -1
  244. package/dist/scan/adapters.d.ts +3 -0
  245. package/dist/scan/adapters.d.ts.map +1 -0
  246. package/dist/scan/adapters.js +25 -0
  247. package/dist/scan/adapters.js.map +1 -0
  248. package/dist/scan/bundling.d.ts +1 -12
  249. package/dist/scan/bundling.d.ts.map +1 -1
  250. package/dist/scan/bundling.js +1 -12
  251. package/dist/scan/bundling.js.map +1 -1
  252. package/dist/scan/conventions.d.ts +6 -40
  253. package/dist/scan/conventions.d.ts.map +1 -1
  254. package/dist/scan/conventions.js +5 -34
  255. package/dist/scan/conventions.js.map +1 -1
  256. package/dist/scan/emit.d.ts +2 -6
  257. package/dist/scan/emit.d.ts.map +1 -1
  258. package/dist/scan/emit.js +5 -39
  259. package/dist/scan/emit.js.map +1 -1
  260. package/dist/scan/handler-parser.d.ts +9 -76
  261. package/dist/scan/handler-parser.d.ts.map +1 -1
  262. package/dist/scan/handler-parser.js +28 -85
  263. package/dist/scan/handler-parser.js.map +1 -1
  264. package/dist/scan/result.d.ts +28 -0
  265. package/dist/scan/result.d.ts.map +1 -0
  266. package/dist/scan/result.js +2 -0
  267. package/dist/scan/result.js.map +1 -0
  268. package/dist/scan/scanner.d.ts +3 -28
  269. package/dist/scan/scanner.d.ts.map +1 -1
  270. package/dist/scan/scanner.js +36 -135
  271. package/dist/scan/scanner.js.map +1 -1
  272. package/dist/scan/statement.d.ts +1 -1
  273. package/dist/scan/statement.d.ts.map +1 -1
  274. package/dist/scan/statement.js +4 -30
  275. package/dist/scan/statement.js.map +1 -1
  276. package/dist/source.d.ts +41 -0
  277. package/dist/source.d.ts.map +1 -0
  278. package/dist/source.js +10 -0
  279. package/dist/source.js.map +1 -0
  280. package/dist/storage.d.ts +92 -0
  281. package/dist/storage.d.ts.map +1 -0
  282. package/dist/storage.js +50 -0
  283. package/dist/storage.js.map +1 -0
  284. package/dist/store.d.ts +18 -0
  285. package/dist/store.d.ts.map +1 -0
  286. package/dist/store.js +146 -0
  287. package/dist/store.js.map +1 -0
  288. package/dist/verify.d.ts +6 -39
  289. package/dist/verify.d.ts.map +1 -1
  290. package/dist/verify.js +19 -39
  291. package/dist/verify.js.map +1 -1
  292. package/dist/wire/CallLog.d.ts +32 -0
  293. package/dist/wire/CallLog.d.ts.map +1 -0
  294. package/dist/{contract → wire}/CallLog.js.map +1 -1
  295. package/dist/wire/Invocation.d.ts +32 -0
  296. package/dist/wire/Invocation.d.ts.map +1 -0
  297. package/dist/wire/Invocation.js +66 -0
  298. package/dist/wire/Invocation.js.map +1 -0
  299. package/dist/wire/RouteAddress.d.ts +24 -0
  300. package/dist/wire/RouteAddress.d.ts.map +1 -0
  301. package/dist/{contract → wire}/RouteAddress.js +7 -0
  302. package/dist/wire/RouteAddress.js.map +1 -0
  303. package/dist/wire/binding.d.ts +36 -0
  304. package/dist/wire/binding.d.ts.map +1 -0
  305. package/dist/{boot → wire}/binding.js +5 -62
  306. package/dist/wire/binding.js.map +1 -0
  307. package/dist/wire/call.d.ts +25 -172
  308. package/dist/wire/call.d.ts.map +1 -1
  309. package/dist/wire/call.js +15 -166
  310. package/dist/wire/call.js.map +1 -1
  311. package/dist/wire/drift.d.ts +3 -28
  312. package/dist/wire/drift.d.ts.map +1 -1
  313. package/dist/wire/drift.js +4 -23
  314. package/dist/wire/drift.js.map +1 -1
  315. package/dist/wire/errors.d.ts +4 -24
  316. package/dist/wire/errors.d.ts.map +1 -1
  317. package/dist/wire/errors.js +4 -24
  318. package/dist/wire/errors.js.map +1 -1
  319. package/dist/wire/http-error.d.ts +2 -13
  320. package/dist/wire/http-error.d.ts.map +1 -1
  321. package/dist/wire/http-error.js +5 -19
  322. package/dist/wire/http-error.js.map +1 -1
  323. package/dist/wire/loggerMiddleware.d.ts +2 -8
  324. package/dist/wire/loggerMiddleware.d.ts.map +1 -1
  325. package/dist/wire/loggerMiddleware.js +1 -7
  326. package/dist/wire/loggerMiddleware.js.map +1 -1
  327. package/dist/wire/middleware.d.ts +3 -7
  328. package/dist/wire/middleware.d.ts.map +1 -1
  329. package/dist/wire/middleware.js +1 -5
  330. package/dist/wire/middleware.js.map +1 -1
  331. package/dist/wire/operation.d.ts +12 -74
  332. package/dist/wire/operation.d.ts.map +1 -1
  333. package/dist/wire/operation.js +4 -66
  334. package/dist/wire/operation.js.map +1 -1
  335. package/dist/wire/signature.d.ts +37 -0
  336. package/dist/wire/signature.d.ts.map +1 -0
  337. package/dist/wire/signature.js +2 -0
  338. package/dist/wire/signature.js.map +1 -0
  339. package/package.json +3 -3
  340. package/src/boot/Emissions.ts +22 -119
  341. package/src/boot/ambient-port.ts +3 -24
  342. package/src/boot/ambient.als.ts +7 -12
  343. package/src/boot/ambient.queue.ts +2 -5
  344. package/src/boot/apply.ts +3 -15
  345. package/src/boot/auth.ts +6 -16
  346. package/src/boot/boot.ts +8 -23
  347. package/src/boot/bootstrap.ts +117 -173
  348. package/src/boot/card.ts +84 -0
  349. package/src/boot/frame.ts +31 -65
  350. package/src/boot/hosted.ts +15 -40
  351. package/src/boot/ownership.ts +14 -49
  352. package/src/boot/ports.ts +2 -15
  353. package/src/boot/remote.ts +11 -58
  354. package/src/boot/runner.ts +17 -0
  355. package/src/boot/seed.ts +11 -42
  356. package/src/boot/statement-drift.ts +10 -28
  357. package/src/boot/together.ts +38 -72
  358. package/src/boot/types.ts +36 -180
  359. package/src/{builtins → builtin}/config.ts +1 -7
  360. package/src/{builtins → builtin}/logger.ts +6 -39
  361. package/src/config-loader.ts +12 -71
  362. package/src/contract.ts +15 -39
  363. package/src/crypto/encoding.ts +2 -15
  364. package/src/crypto/node.ts +1 -7
  365. package/src/crypto/port.ts +2 -18
  366. package/src/crypto/webcrypto.ts +1 -12
  367. package/src/{scan/declare.ts → declare.ts} +11 -42
  368. package/src/define.ts +2 -3
  369. package/src/descriptor/Fronds.ts +47 -0
  370. package/src/descriptor/frond.ts +145 -0
  371. package/src/dispatch/ArgumentResolver.ts +54 -8
  372. package/src/dispatch/DispatchEvent.ts +2 -2
  373. package/src/dispatch/DispatchLifecycle.ts +1 -7
  374. package/src/dispatch/DispatchPort.ts +1 -1
  375. package/src/dispatch/Dispatcher.ts +3 -3
  376. package/src/dispatch/HandlerFacade.ts +231 -0
  377. package/src/dispatch/LocalRoutePolicy.ts +4 -4
  378. package/src/dispatch/OperationRoute.ts +2 -2
  379. package/src/dispatch/OutputView.ts +24 -2
  380. package/src/dispatch/Route.ts +2 -4
  381. package/src/dispatch/RoutePolicy.ts +1 -1
  382. package/src/dispatch/RouteRegistry.ts +2 -2
  383. package/src/dispatch/RouteResolver.ts +2 -4
  384. package/src/dispatch/StorageGuard.ts +75 -23
  385. package/src/dispatch/presenterArguments.ts +25 -0
  386. package/src/dispatch/{RemoteRouteResolver.ts → remoteRoutes.ts} +7 -9
  387. package/src/dispatch/routeNotFound.ts +33 -0
  388. package/src/dispatch/validateInput.ts +28 -0
  389. package/src/effective-operation.ts +60 -37
  390. package/src/emit.ts +5 -63
  391. package/src/entry/facade.ts +44 -0
  392. package/src/entry/transport.ts +16 -0
  393. package/src/frond-config.ts +8 -71
  394. package/src/graph.ts +1 -1
  395. package/src/identity-keys.ts +3 -16
  396. package/src/identity.ts +12 -80
  397. package/src/imports.ts +3 -32
  398. package/src/index.ts +28 -33
  399. package/src/loader.ts +2 -16
  400. package/src/node.ts +2 -11
  401. package/src/prefab/collector.ts +1 -22
  402. package/src/prefab/crud.ts +51 -90
  403. package/src/prefab/mirror.ts +9 -49
  404. package/src/prefab/prefab.ts +2 -21
  405. package/src/prefab/presenter.ts +2 -36
  406. package/src/prefab/repository.ts +32 -108
  407. package/src/scan/adapters.ts +32 -0
  408. package/src/scan/bundling.ts +1 -12
  409. package/src/scan/conventions.ts +6 -40
  410. package/src/scan/emit.ts +7 -43
  411. package/src/scan/handler-parser.ts +41 -163
  412. package/src/scan/result.ts +29 -0
  413. package/src/scan/scanner.ts +40 -138
  414. package/src/scan/statement.ts +6 -31
  415. package/src/source.ts +44 -0
  416. package/src/storage.ts +141 -0
  417. package/src/store.ts +152 -0
  418. package/src/verify.ts +19 -60
  419. package/src/wire/CallLog.ts +30 -0
  420. package/src/{contract → wire}/Invocation.ts +24 -17
  421. package/src/{contract → wire}/RouteAddress.ts +10 -0
  422. package/src/wire/binding.ts +102 -0
  423. package/src/wire/call.ts +30 -261
  424. package/src/wire/drift.ts +5 -30
  425. package/src/wire/errors.ts +4 -24
  426. package/src/wire/http-error.ts +5 -19
  427. package/src/wire/loggerMiddleware.ts +2 -8
  428. package/src/wire/middleware.ts +3 -7
  429. package/src/wire/operation.ts +13 -110
  430. package/src/wire/signature.ts +38 -0
  431. package/dist/boot/HandlerFacade.d.ts.map +0 -1
  432. package/dist/boot/HandlerFacade.js.map +0 -1
  433. package/dist/boot/binding.d.ts +0 -60
  434. package/dist/boot/binding.d.ts.map +0 -1
  435. package/dist/boot/binding.js.map +0 -1
  436. package/dist/builtins/config.d.ts +0 -13
  437. package/dist/builtins/config.d.ts.map +0 -1
  438. package/dist/builtins/config.js +0 -21
  439. package/dist/builtins/config.js.map +0 -1
  440. package/dist/builtins/logger.d.ts.map +0 -1
  441. package/dist/builtins/logger.js.map +0 -1
  442. package/dist/contract/Call.d.ts +0 -10
  443. package/dist/contract/Call.d.ts.map +0 -1
  444. package/dist/contract/Call.js +0 -15
  445. package/dist/contract/Call.js.map +0 -1
  446. package/dist/contract/CallLog.d.ts +0 -57
  447. package/dist/contract/CallLog.d.ts.map +0 -1
  448. package/dist/contract/Invocation.d.ts +0 -27
  449. package/dist/contract/Invocation.d.ts.map +0 -1
  450. package/dist/contract/Invocation.js +0 -59
  451. package/dist/contract/Invocation.js.map +0 -1
  452. package/dist/contract/RouteAddress.d.ts +0 -17
  453. package/dist/contract/RouteAddress.d.ts.map +0 -1
  454. package/dist/contract/RouteAddress.js.map +0 -1
  455. package/dist/dispatch/InputValidator.d.ts +0 -7
  456. package/dist/dispatch/InputValidator.d.ts.map +0 -1
  457. package/dist/dispatch/InputValidator.js +0 -22
  458. package/dist/dispatch/InputValidator.js.map +0 -1
  459. package/dist/dispatch/OperationExecutor.d.ts +0 -25
  460. package/dist/dispatch/OperationExecutor.d.ts.map +0 -1
  461. package/dist/dispatch/OperationExecutor.js +0 -32
  462. package/dist/dispatch/OperationExecutor.js.map +0 -1
  463. package/dist/dispatch/OutputProjector.d.ts +0 -12
  464. package/dist/dispatch/OutputProjector.d.ts.map +0 -1
  465. package/dist/dispatch/OutputProjector.js +0 -30
  466. package/dist/dispatch/OutputProjector.js.map +0 -1
  467. package/dist/dispatch/PresenterArgumentResolver.d.ts +0 -12
  468. package/dist/dispatch/PresenterArgumentResolver.d.ts.map +0 -1
  469. package/dist/dispatch/PresenterArgumentResolver.js +0 -20
  470. package/dist/dispatch/PresenterArgumentResolver.js.map +0 -1
  471. package/dist/dispatch/RemoteRouteResolver.d.ts +0 -13
  472. package/dist/dispatch/RemoteRouteResolver.d.ts.map +0 -1
  473. package/dist/dispatch/RemoteRouteResolver.js.map +0 -1
  474. package/dist/dispatch/RouteNotFoundError.d.ts +0 -10
  475. package/dist/dispatch/RouteNotFoundError.d.ts.map +0 -1
  476. package/dist/dispatch/RouteNotFoundError.js +0 -24
  477. package/dist/dispatch/RouteNotFoundError.js.map +0 -1
  478. package/dist/entry/DynamicFacade.d.ts +0 -10
  479. package/dist/entry/DynamicFacade.d.ts.map +0 -1
  480. package/dist/entry/DynamicFacade.js +0 -27
  481. package/dist/entry/DynamicFacade.js.map +0 -1
  482. package/dist/entry/FacadeEntry.d.ts +0 -11
  483. package/dist/entry/FacadeEntry.d.ts.map +0 -1
  484. package/dist/entry/FacadeEntry.js +0 -26
  485. package/dist/entry/FacadeEntry.js.map +0 -1
  486. package/dist/entry/TransportEntry.d.ts +0 -13
  487. package/dist/entry/TransportEntry.d.ts.map +0 -1
  488. package/dist/entry/TransportEntry.js +0 -24
  489. package/dist/entry/TransportEntry.js.map +0 -1
  490. package/dist/orm.d.ts +0 -207
  491. package/dist/orm.d.ts.map +0 -1
  492. package/dist/orm.js +0 -66
  493. package/dist/orm.js.map +0 -1
  494. package/dist/scan/Fronds.d.ts +0 -45
  495. package/dist/scan/Fronds.d.ts.map +0 -1
  496. package/dist/scan/Fronds.js +0 -66
  497. package/dist/scan/Fronds.js.map +0 -1
  498. package/dist/scan/declare.d.ts +0 -71
  499. package/dist/scan/declare.d.ts.map +0 -1
  500. package/dist/scan/declare.js.map +0 -1
  501. package/dist/scan/frond.d.ts +0 -224
  502. package/dist/scan/frond.d.ts.map +0 -1
  503. package/src/boot/HandlerFacade.ts +0 -242
  504. package/src/boot/binding.ts +0 -182
  505. package/src/contract/Call.ts +0 -18
  506. package/src/contract/CallLog.ts +0 -55
  507. package/src/dispatch/InputValidator.ts +0 -28
  508. package/src/dispatch/OperationExecutor.ts +0 -60
  509. package/src/dispatch/OutputProjector.ts +0 -32
  510. package/src/dispatch/PresenterArgumentResolver.ts +0 -25
  511. package/src/dispatch/RouteNotFoundError.ts +0 -29
  512. package/src/entry/DynamicFacade.ts +0 -28
  513. package/src/entry/FacadeEntry.ts +0 -32
  514. package/src/entry/TransportEntry.ts +0 -30
  515. package/src/orm.ts +0 -252
  516. package/src/scan/Fronds.ts +0 -73
  517. package/src/scan/frond.ts +0 -235
  518. /package/dist/{scan → descriptor}/frond.js +0 -0
  519. /package/dist/{contract → wire}/CallLog.js +0 -0
package/dist/emit.d.ts CHANGED
@@ -1,50 +1,12 @@
1
- /**
2
- * What an emitter injects. Resolved by type, like `EntityOrm<Post>` and `Facade<T>`.
3
- *
4
- * The returned promise settles when the fact has been **dispatched**, never when it has
5
- * been handled: a subscriber's failure is its own. The `EventBus` this replaces did
6
- * `await Promise.all(handlers)` and handed their rejections back, which made a publication
7
- * hostage to its own indexer.
8
- */
1
+ /** What an emitter injects. */
9
2
  export type Emit<T> = (fact: T) => Promise<void>;
10
- /**
11
- * What a subscriber accepts — and what it PROMISES about itself.
12
- *
13
- * Not merely "I subscribe". Push is the strict mode and pull is a special case of it: an
14
- * op written for push is correct when called directly, the reverse is false. So this
15
- * wrapper commits the operation to three things its author must honour, because no type
16
- * can check them:
17
- *
18
- * 1. **replayable** — delivery is at-least-once the day a broker sits underneath;
19
- * 2. **no reader for its return** — nobody receives what it hands back;
20
- * 3. **owner of its failures** — they reach a log, never the emitter.
21
- *
22
- * It is the identity at runtime. The scan reads the written name, which is the whole
23
- * mechanism: `binding.ts` sees `Fact<X>` and binds the parameter as a fact instead of
24
- * letting it fall through to "everything else — body".
25
- */
3
+ /** What a subscriber accepts — and what it PROMISES about itself. */
26
4
  export type Fact<T> = T;
27
- /**
28
- * The container key of an emission — THE one place that spells the format.
29
- *
30
- * Its dual is right below, because the boot reads the fact back out of a handler's `deps`
31
- * to know which emissions to register. A key and the way to undo it belong together: the
32
- * pair that is split is the pair that drifts.
33
- */
5
+ /** The container key of an emission — THE one place that spells the format. */
34
6
  export declare function emitKeyOf(fact: string): string;
35
7
  /** The fact behind an emission key, or `undefined` when the key is not one. */
36
8
  export declare function factOfEmitKey(key: string): string | undefined;
37
- /**
38
- * What a set of handlers ANNOUNCES — `Emit<T>` read back out of their dependencies.
39
- *
40
- * Two readers, which is exactly why it is a function and not a line: the boot registers one
41
- * emission value per name, and the identity card publishes the same set. Spelled twice they
42
- * would drift the day an emission stops being a constructor dependency.
43
- *
44
- * The dual — what a handler ACCEPTS — is not here, because it is not read the same way: a
45
- * `Fact<T>` parameter is a fact about one operation, and `computeBindingPlan` has already
46
- * written it into the plan (`app.listensTo()`).
47
- */
9
+ /** What a set of handlers ANNOUNCES — `Emit<T>` read back out of their dependencies. */
48
10
  export declare function factsAnnouncedBy(handlers: readonly {
49
11
  deps: readonly string[];
50
12
  }[]): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAuBA;;;;;;;GAOG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAExB;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAID,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS;IAAE,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,GAAG,MAAM,EAAE,CAO3F"}
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAGA,+BAA+B;AAC/B,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjD,qEAAqE;AACrE,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAExB,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAID,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI7D;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS;IAAE,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,GAAG,MAAM,EAAE,CAO3F"}
package/dist/emit.js CHANGED
@@ -1,32 +1,6 @@
1
- /**
2
- * Announcing a fact — the half of the topology `remotes:` never covered.
3
- *
4
- * Every other call in Fougere names **one** recipient: `remotes` names one address per
5
- * frond, `Facade<T>` resolves one door. `Emit<T>` names a **subject** instead, and the
6
- * number of readers is not the emitter's business.
7
- *
8
- * ```ts
9
- * constructor(private published: Emit<PostPublished>) {}
10
- * await this.published({ id, title }); // I say it happened. I do not know who cares.
11
- *
12
- * async reindex(fact: Fact<PostPublished>) {} // any handler, any frond. Nothing to register.
13
- * ```
14
- *
15
- * **It is a resolver, not a channel.** A bus moves messages — it has a queue, an envelope
16
- * format, a delivery semantic. This has none of that: it answers *who*, then hands over to
17
- * the call path that already exists. It is `resolve` returning N things instead of one.
18
- * That is also why temporal decoupling stays out of reach: a resolver holds nothing. The
19
- * day at-least-once is wanted, a real channel goes UNDER this, in the transport — the
20
- * dispatch line becomes a publish and a consumer calls the same door on the far side.
21
- */
1
+ /** Announcing a fact — the half of the topology `remotes:` never covered. */
22
2
  import { lowerFirst } from '@fougere/schema';
23
- /**
24
- * The container key of an emission — THE one place that spells the format.
25
- *
26
- * Its dual is right below, because the boot reads the fact back out of a handler's `deps`
27
- * to know which emissions to register. A key and the way to undo it belong together: the
28
- * pair that is split is the pair that drifts.
29
- */
3
+ /** The container key of an emission — THE one place that spells the format. */
30
4
  export function emitKeyOf(fact) {
31
5
  return `${lowerFirst(fact)}Emit`;
32
6
  }
@@ -37,17 +11,7 @@ export function factOfEmitKey(key) {
37
11
  ? key.slice(0, -SUFFIX.length)
38
12
  : undefined;
39
13
  }
40
- /**
41
- * What a set of handlers ANNOUNCES — `Emit<T>` read back out of their dependencies.
42
- *
43
- * Two readers, which is exactly why it is a function and not a line: the boot registers one
44
- * emission value per name, and the identity card publishes the same set. Spelled twice they
45
- * would drift the day an emission stops being a constructor dependency.
46
- *
47
- * The dual — what a handler ACCEPTS — is not here, because it is not read the same way: a
48
- * `Fact<T>` parameter is a fact about one operation, and `computeBindingPlan` has already
49
- * written it into the plan (`app.listensTo()`).
50
- */
14
+ /** What a set of handlers ANNOUNCES — `Emit<T>` read back out of their dependencies. */
51
15
  export function factsAnnouncedBy(handlers) {
52
16
  return [...new Set(handlers
53
17
  .flatMap((handler) => handler.deps)
package/dist/emit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"emit.js","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA8B7C;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;AACnC,CAAC;AAED,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB,+EAA+E;AAC/E,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;QACvD,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgD;IAC/E,OAAO,CAAC,GAAG,IAAI,GAAG,CAChB,QAAQ;aACL,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;aAClC,GAAG,CAAC,aAAa,CAAC;aAClB,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CACxD,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"emit.js","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQ7C,+EAA+E;AAC/E,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;AACnC,CAAC;AAED,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB,+EAA+E;AAC/E,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;QACvD,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,gBAAgB,CAAC,QAAgD;IAC/E,OAAO,CAAC,GAAG,IAAI,GAAG,CAChB,QAAQ;aACL,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;aAClC,GAAG,CAAC,aAAa,CAAC;aAClB,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CACxD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { DispatchPort } from '../dispatch/DispatchPort.js';
2
+ type Operation = (...args: any[]) => unknown;
3
+ /** Facade for a contract whose operation names are only known at discovery. */
4
+ export declare function dynamicOperations(operation: (name: string) => Operation): Record<string, Operation>;
5
+ /** Turns facade method calls into canonical dispatches. */
6
+ export declare function facadeOperations(dispatcher: DispatchPort, entity: string, operationNames?: Iterable<string>, surface?: string): Record<string, Operation>;
7
+ export {};
8
+ //# sourceMappingURL=facade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["../../src/entry/facade.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,KAAK,SAAS,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;AAE7C,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAcnG;AAED,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,YAAY,EACxB,MAAM,EAAE,MAAM,EACd,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,EACjC,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAa3B"}
@@ -0,0 +1,28 @@
1
+ import { Call } from '../wire/call.js';
2
+ import { RouteAddress } from '../wire/RouteAddress.js';
3
+ /** Facade for a contract whose operation names are only known at discovery. */
4
+ export function dynamicOperations(operation) {
5
+ const isOperationName = (name) => typeof name === 'string'
6
+ && name !== 'then'
7
+ && name !== 'toJSON'
8
+ && !Object.hasOwn(Object.prototype, name);
9
+ return new Proxy({}, {
10
+ get: (_target, name) => (isOperationName(name) ? operation(name) : undefined),
11
+ has: (_target, name) => isOperationName(name),
12
+ getOwnPropertyDescriptor: (_target, name) => (isOperationName(name)
13
+ ? { value: operation(name), writable: false, enumerable: true, configurable: true }
14
+ : undefined),
15
+ });
16
+ }
17
+ /** Turns facade method calls into canonical dispatches. */
18
+ export function facadeOperations(dispatcher, entity, operationNames, surface) {
19
+ const operation = (name) => (invocation) => dispatcher.dispatch(new Call(new RouteAddress({
20
+ entity,
21
+ operation: name,
22
+ ...(surface !== undefined ? { surface } : {}),
23
+ }), invocation));
24
+ return operationNames
25
+ ? Object.fromEntries([...operationNames].map((name) => [name, operation(name)]))
26
+ : dynamicOperations(operation);
27
+ }
28
+ //# sourceMappingURL=facade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facade.js","sourceRoot":"","sources":["../../src/entry/facade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAAC,SAA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,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChF,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { DispatchPort } from '../dispatch/DispatchPort.js';
2
+ import type { Transport } from '../wire/call.js';
3
+ /** Adapts the historical transport signature to the canonical dispatch port. */
4
+ export declare function createTransportEntry(dispatcher: DispatchPort, surface?: string): Transport;
5
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/entry/transport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,gFAAgF;AAChF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAS1F"}
@@ -0,0 +1,11 @@
1
+ import { Call } from '../wire/call.js';
2
+ import { RouteAddress } from '../wire/RouteAddress.js';
3
+ /** Adapts the historical transport signature to the canonical dispatch port. */
4
+ export function createTransportEntry(dispatcher, surface) {
5
+ return (legacy, invocation) => dispatcher.dispatch(new Call(new RouteAddress({
6
+ entity: legacy.entity,
7
+ operation: legacy.op,
8
+ ...(surface !== undefined ? { surface } : {}),
9
+ }), invocation));
10
+ }
11
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/entry/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD,gFAAgF;AAChF,MAAM,UAAU,oBAAoB,CAAC,UAAwB,EAAE,OAAgB;IAC7E,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,IAAI,CACzD,IAAI,YAAY,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,EAAE;QACpB,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC,EACF,UAAU,CACX,CAAC,CAAC;AACL,CAAC"}
@@ -1,44 +1,10 @@
1
1
  import type { EntityConstructor, SchemaView } from '@fougere/schema';
2
- import type { BindingPlan } from './boot/binding.js';
3
- /**
4
- * Per-operation override. Config takes precedence over conventions (isReadOp, facade lookup).
5
- *
6
- * Two families of keys, and they act at different depths:
7
- *
8
- * - **Resolution** (`kind`, `handler`, `method`) — intent and implementation, resolved
9
- * once into core's `EffectiveOperation`; every local or remote door consumes it.
10
- * - **Projection** (`graphql`) — protocol vocabulary, read only by that adapter.
11
- * - **Contract** (`input`, `output`, `binding`) — what the op IS. Read by the façade,
12
- * and this is the third producer of an {@link OperationContract}: a prefab DECLARES its
13
- * ops (`Crud.__ops`), the scan DERIVES them from source, config STATES them outright.
14
- * The façade cannot tell the three apart.
15
- *
16
- * Stating a contract here makes the scan optional rather than load-bearing. Two cases it
17
- * answers that nothing else does:
18
- * - a method inherited from an **installed** base class — the scan resolves nothing there
19
- * (workspace-only heritage) and says nothing, so the op silently misses the façade;
20
- * - an operation inherited from a declaration unavailable to the project's type checker.
21
- *
22
- * Config wins over both other producers — it is the most explicit statement, made by
23
- * whoever assembles the app. Precedence: CLI > frond config > fougere config > scan >
24
- * conventions.
25
- */
2
+ import type { BindingPlan } from './wire/binding.js';
3
+ /** Per-operation override. */
26
4
  export interface OperationOverride {
27
- /**
28
- * Force operation kind, over the naming convention (`isReadOp`).
29
- *
30
- * The convention reads the NAME, which is a weak signal — an app naming its reads in
31
- * domain terms (`ofBook`, `roots`, `bySlug`) matches no prefix and every one of them is
32
- * published as a mutation and a POST. This is the only place that fixes it.
33
- */
5
+ /** Force operation kind, over the naming convention (`isReadOp`). */
34
6
  kind?: 'query' | 'command';
35
- /**
36
- * The GraphQL root field this op answers to. Defaults to the method name.
37
- *
38
- * A GraphQL root is flat, so two handlers naming a method `ofBook` claim one field and
39
- * the build is refused, naming both. Nothing is renamed for you: the root vocabulary is
40
- * the app's, and a derived name would move the day a distant frond gained an entity.
41
- */
7
+ /** The GraphQL root field this op answers to. */
42
8
  graphql?: string;
43
9
  /**
44
10
  * Handler class to delegate to (overrides the default `{Entity}Handler` lookup).
@@ -47,19 +13,9 @@ export interface OperationOverride {
47
13
  handler?: EntityConstructor;
48
14
  /** Method name on `handler` (defaults to the operation name). */
49
15
  method?: string;
50
- /**
51
- * CASL ability check (e.g. 'archive Post'). **Declared, not implemented** — no
52
- * reader interprets it today, in any adapter. Kept as the named slot for the
53
- * question rather than silently dropped, but do not rely on it: a config that
54
- * states a policy is not enforced anywhere.
55
- *
56
- * Wiring it means adopting a rules engine, which is precisely what the design
57
- * turns down: an identity-dependent right is judged INSIDE the operation
58
- * (`publish` reads `post.authorId !== user.id`), and a door-dependent one is a
59
- * surface. Neither needs a second vocabulary evaluated by a second engine.
60
- */
16
+ /** CASL ability check (e.g. */
61
17
  policy?: string;
62
- /** What judges the input. The view carries its own mode (`partial()` → patch). */
18
+ /** What validates the input. The view carries its own mode (`partial()` → patch). */
63
19
  input?: SchemaView;
64
20
  /**
65
21
  * Where each argument is read from — states what the scan would otherwise derive
@@ -72,18 +28,7 @@ export interface OperationOverride {
72
28
  export interface FrondConfig {
73
29
  /** Class names exposed as the frond's public contract (all surfaces). */
74
30
  expose?: string[];
75
- /**
76
- * The entities this frond may read ACROSS sources, by name.
77
- *
78
- * It is not a permission checked after the fact: the list IS the environment a
79
- * cross-source query runs in — a source holding none of these is never opened, so
80
- * its tables do not exist in that connection. `facadeFor` excludes an entity with no
81
- * door on purpose ("it would publish the auth tables to anyone who asks"), and a SQL
82
- * door at app scope would hand them over; this is what keeps it shut.
83
- *
84
- * Declaring it is what makes `Sources` injectable here. A frond that declares none
85
- * asks for none, and nothing is attached on its behalf.
86
- */
31
+ /** The entities this frond may read ACROSS sources, by name. */
87
32
  reads?: string[];
88
33
  /** Per-surface entity lists. Overrides default deduction for each named surface. */
89
34
  surfaces?: Record<string, string[]>;
@@ -92,15 +37,7 @@ export interface FrondConfig {
92
37
  /** Per-operation overrides. Key = operation name (method name on a handler). */
93
38
  operations?: Record<string, OperationOverride>;
94
39
  }
95
- /**
96
- * Define a frond configuration (typed identity helper).
97
- *
98
- * ```ts
99
- * // fronds/auth/frond.config.ts
100
- * import { defineFrond } from '@fougere/core'
101
- * export default defineFrond({ expose: ['User', 'AuthHandler'] })
102
- * ```
103
- */
40
+ /** Define a frond configuration (typed identity helper). */
104
41
  export declare function defineFrond(config: FrondConfig): FrondConfig;
105
42
  /**
106
43
  * Load a frond's `frond.config.{ts,js,mjs}` from the given frond directory.
@@ -1 +1 @@
1
- {"version":3,"file":"frond-config.d.ts","sourceRoot":"","sources":["../src/frond-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;OA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AC,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,qFAAqF;IACrF,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACpC,wFAAwF;IACxF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAChD;AAID,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAE5D;AAMD;;;GAGG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CASzF"}
@@ -1,15 +1,7 @@
1
1
  import { resolve } from 'node:path';
2
2
  import { existsSync } from 'node:fs';
3
3
  // ── Helper ───────────────────────────────────────
4
- /**
5
- * Define a frond configuration (typed identity helper).
6
- *
7
- * ```ts
8
- * // fronds/auth/frond.config.ts
9
- * import { defineFrond } from '@fougere/core'
10
- * export default defineFrond({ expose: ['User', 'AuthHandler'] })
11
- * ```
12
- */
4
+ /** Define a frond configuration (typed identity helper). */
13
5
  export function defineFrond(config) {
14
6
  return config;
15
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"frond-config.js","sourceRoot":"","sources":["../src/frond-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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AC;QACtC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/dist/graph.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Entity dependency graph — analyzes ref() links between entities
3
3
  * to suggest domain boundaries for splitting fronds.
4
4
  */
5
- import type { FrondDescriptor } from './scan/frond.js';
5
+ import type { FrondDescriptor } from './descriptor/frond.js';
6
6
  export interface EntityNode {
7
7
  name: string;
8
8
  frond: string;
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClE;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CA6B7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,aAAa,EAAE,CAwC/E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAC9B,cAAc,SAAI,GACjB,aAAa,EAAE,CAmDjB"}
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClE;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CA6B7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,aAAa,EAAE,CAwC/E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAC9B,cAAc,SAAI,GACjB,aAAa,EAAE,CAmDjB"}
@@ -4,11 +4,8 @@ export declare function generateKeyPair(): {
4
4
  publicKey: string;
5
5
  };
6
6
  /**
7
- * Bind a name to a public key, signed by the root — the whole of what a receiver
8
- * needs to recognize a frond it has never seen.
9
- *
10
- * `ttlDays` bounds the damage of a leaked frond key without a revocation list:
11
- * re-issuing is a deployment, which is the same gesture that leaked it.
7
+ * Bind a name to a public key, signed by the root — the whole of what a receiver needs to
8
+ * recognize a frond it has never seen.
12
9
  */
13
10
  export declare function issueGrant(rootPrivateKey: string, name: string, frondPublicKey: string, ttlDays?: number): string;
14
11
  //# sourceMappingURL=identity-keys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity-keys.d.ts","sourceRoot":"","sources":["../src/identity-keys.ts"],"names":[],"mappings":"AAcA,uFAAuF;AACvF,wBAAgB,eAAe,IAAI;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAM3E;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,OAAO,SAAK,GACX,MAAM,CAOR"}
1
+ {"version":3,"file":"identity-keys.d.ts","sourceRoot":"","sources":["../src/identity-keys.ts"],"names":[],"mappings":"AAIA,uFAAuF;AACvF,wBAAgB,eAAe,IAAI;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAM3E;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,OAAO,SAAK,GACX,MAAM,CAOR"}
@@ -1,14 +1,4 @@
1
- /**
2
- * Making keys and issuing grants — the half of identity that runs at a DEPLOYMENT.
3
- *
4
- * It sits on the Node entry because it is the CLI speaking: `fougere keys` generates a
5
- * pair, `fougere grant` binds a name to one, and both happen once, on a machine with a
6
- * filesystem. Neither is reachable from a request path, so nothing here is on any hot
7
- * path and `generateKeyPairSync` — the one gesture WebCrypto could not replace without
8
- * changing what a key IS — never has to leave `node:crypto`.
9
- *
10
- * The verifying half is elsewhere (`identity.ts`) because it runs per call, everywhere.
11
- */
1
+ /** Making keys and issuing grants — the half of identity that runs at a DEPLOYMENT. */
12
2
  import { createPrivateKey, createPublicKey, generateKeyPairSync, sign } from 'node:crypto';
13
3
  import { b64url } from './crypto/encoding.js';
14
4
  /** A fresh Ed25519 pair, PEM both ways. The root's and a frond's are the same kind. */
@@ -20,11 +10,8 @@ export function generateKeyPair() {
20
10
  };
21
11
  }
22
12
  /**
23
- * Bind a name to a public key, signed by the root — the whole of what a receiver
24
- * needs to recognize a frond it has never seen.
25
- *
26
- * `ttlDays` bounds the damage of a leaked frond key without a revocation list:
27
- * re-issuing is a deployment, which is the same gesture that leaked it.
13
+ * Bind a name to a public key, signed by the root — the whole of what a receiver needs to
14
+ * recognize a frond it has never seen.
28
15
  */
29
16
  export function issueGrant(rootPrivateKey, name, frondPublicKey, ttlDays = 90) {
30
17
  const jwk = createPublicKey(frondPublicKey).export({ format: 'jwk' });
@@ -1 +1 @@
1
- {"version":3,"file":"identity-keys.js","sourceRoot":"","sources":["../src/identity-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,uFAAuF;AACvF,MAAM,UAAU,eAAe;IAC7B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACjE,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE;QAC1E,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE;KACxE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,cAAsB,EACtB,IAAY,EACZ,cAAsB,EACtB,OAAO,GAAG,EAAE;IAEZ,MAAM,GAAG,G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S,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE;KACxE,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,cAAsB,EACtB,IAAY,EACZ,cAAsB,EACtB,OAAO,GAAG,EAAE;IAEZ,MAAM,GAAG,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IACtE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;IAC9E,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC;IACtG,MAAM,YAAY,GAAG,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC;IAC5C,OAAO,GAAG,YAAY,IAAI,MAAM,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9H,CAAC"}
@@ -14,45 +14,19 @@ export interface VerifiedCall {
14
14
  /** The state it asserted, now proven to come from `caller`. */
15
15
  state: Record<string, unknown>;
16
16
  }
17
- /**
18
- * Sign one call, whole: who is asking, what is asked, and on whose behalf.
19
- *
20
- * The private key is parsed on every call here, which is the convenience form. A process
21
- * that signs in a request path builds its signer once — `identityFromEnv` does exactly
22
- * that, and `sign` on the value it returns holds the parsed key.
23
- */
17
+ /** Sign one call, whole. */
24
18
  export declare function signEnvelope(identity: FrondIdentity, call: SignedCall): Promise<string>;
25
- /**
26
- * Establish the caller, or throw. Order matters: the grant is checked against the ROOT
27
- * first, and only the key it carries verifies the envelope — reading the envelope's own
28
- * claim of who it is before that would be believing the thing under examination.
29
- */
19
+ /** Establish the caller, or throw. */
30
20
  export declare function verifyEnvelope(token: string, rootPublicKey: string, presented: SignedCall): Promise<VerifiedCall>;
31
21
  /** The two halves a boot needs, and the environment they come from. */
32
22
  export interface CallIdentity {
33
- /**
34
- * Signs an outgoing call, whole. Absent when this process holds no key — it only answers.
35
- *
36
- * A promise because WebCrypto has no synchronous form. On Node the work stays
37
- * synchronous inside and only the answer is wrapped: measured at 14.28 µs awaited
38
- * against 14.30 µs called directly, while WebCrypto on the same curve costs 22.72.
39
- */
23
+ /** Signs an outgoing call, whole. */
40
24
  sign?: (call: SignedCall) => Promise<string>;
41
25
  /** Establishes an incoming caller, against the call that actually arrived. */
42
26
  verify?: (identity: string, presented: SignedCall) => Promise<VerifiedCall>;
43
27
  /** Refuse an unsigned call. True exactly when a root is trusted. */
44
28
  requireIdentity: boolean;
45
29
  }
46
- /**
47
- * What the deployment injected, read once at boot.
48
- *
49
- * Three variables, no config key: a private key never belongs in a committed file, and
50
- * `fougere keys` prints exactly these. A process may hold either half or both — a frond
51
- * that only answers has no key, one that only calls trusts no root, one in the middle
52
- * does both.
53
- *
54
- * Trusting a root IS asking to refuse: there is no separate flag, because a deployment
55
- * that names an authority and then accepts unsigned calls has said two things at once.
56
- */
30
+ /** What the deployment injected, read once at boot. */
57
31
  export declare function identityFromEnv(env?: Record<string, string | undefined>): Promise<CallIdentity>;
58
32
  //# sourceMappingURL=identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,YAAY,EAAE,UAAU,E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gBAAgB,CAAC;AAOjD,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;CACf;AAuBD,2EAA2E;AAC3E,MAAM,WAAW,YAAY;IAC3B,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AA8BD,4BAA4B;AAC5B,wBAAsB,YAAY,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7F;AAaD,sCAAsC;AACtC,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAEvH;AA+BD,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,qCAAqC;IACrC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAC5E,oEAAoE;IACpE,eAAe,EAAE,OAAO,CAAC;CAC1B;AAOD,uDAAuD;AACvD,wBAAsB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAgBrH"}
package/dist/identity.js CHANGED
@@ -1,48 +1,17 @@
1
- /**
2
- * Who is calling — the proof, not the claim.
3
- *
4
- * `InvocationContext.state` is what a caller SAYS about itself, and a split receiver
5
- * used to believe it: identity read straight off the wire, so a reader could post
6
- * `{ state: { user: { role: 'admin' } } }` and be one. This module is what turns that
7
- * sack into something a receiver establishes instead of accepts.
8
- *
9
- * Two signatures, one public key to distribute:
10
- *
11
- * GRANT the root says "this key is `blog`" — issued once, at deployment
12
- * ENVELOPE `blog` says "here is my whole call" — signed per call
13
- *
14
- * The envelope binds the CALL and not only its state: address, params, query, a digest
15
- * of the body. Signing the state alone proved WHO without proving WHAT, so anyone on the
16
- * wire could replay a captured envelope against another operation for as long as it
17
- * stayed valid — `post.list` re-sent as `post.delete`, same signature, still good.
18
- *
19
- * A receiver holds the root's public key and nothing else: it validates any frond it
20
- * has never seen, which is what a per-caller list could not do. The private root key
21
- * signs grants and never leaves the machine that issued them.
22
- *
23
- * Ed25519 and a JWS-shaped grant rather than X.509: node can PARSE a certificate but
24
- * not ISSUE one, so a real chain would mean openssl or a library. The grant says the
25
- * same thing — a name bound to a public key, signed by the root — with no dependency.
26
- *
27
- * The Ed25519 itself comes through `#crypto`, which has two realizations: `node:crypto`
28
- * everywhere, WebCrypto under `workerd`. Everything here is therefore async — WebCrypto
29
- * has no synchronous form — and a key is parsed ONCE, into a `Signer` or a `Verifier`,
30
- * never per call. Making the keys and issuing grants happen at a deployment and live in
31
- * `identity-keys.ts`, on the Node entry.
32
- */
1
+ /** Who is calling — the proof, not the claim. */
33
2
  import { crypto } from '#crypto';
34
3
  import { b64url, unb64url, bytesOf, textOf, unb64 } from './crypto/encoding.js';
35
4
  /** How long a call envelope stays valid. A signed call is not a session. */
36
5
  const ENVELOPE_TTL_MS = 60_000;
37
6
  /** Clock skew tolerated on both sides of a validity window. */
38
7
  const SKEW_MS = 30_000;
39
- /** The body's fingerprint. Absence and explicit null are different signed calls. */
40
- async function digestOf(body) {
8
+ /** The input's fingerprint. Absence and explicit null are different signed calls. */
9
+ async function digestOf(input) {
41
10
  // The tag is outside the caller value, so no user object can collide with it. JSON's
42
11
  // own omission rule still applies inside `value`, matching what crosses the wire.
43
- const canonical = body === undefined
12
+ const canonical = input === undefined
44
13
  ? { kind: 'undefined' }
45
- : { kind: 'value', value: body };
14
+ : { kind: 'value', value: input };
46
15
  return b64url(await crypto.sha256(bytesOf(JSON.stringify(canonical))));
47
16
  }
48
17
  /** What the envelope pins, as one comparable value. */
@@ -52,7 +21,7 @@ async function boundTo(call) {
52
21
  op: call.op,
53
22
  params: call.params ?? {},
54
23
  query: call.query ?? {},
55
- body: await digestOf(call.body),
24
+ input: await digestOf(call.input),
56
25
  };
57
26
  }
58
27
  /** A JWS compact serialization, signed with Ed25519. */
@@ -60,11 +29,7 @@ async function signJws(header, payload, signer) {
60
29
  const signingInput = `${b64url(JSON.stringify(header))}.${b64url(JSON.stringify(payload))}`;
61
30
  return `${signingInput}.${b64url(await signer.sign(bytesOf(signingInput)))}`;
62
31
  }
63
- /**
64
- * The payload, once the signature holds. Throws rather than returning a falsy value:
65
- * every caller here is deciding whether to admit a call, and an unverified payload
66
- * must never be reachable by forgetting a check.
67
- */
32
+ /** The payload, once the signature holds. */
68
33
  async function verifyJws(token, verifier, what) {
69
34
  const parts = token.split('.');
70
35
  if (parts.length !== 3)
@@ -88,13 +53,7 @@ function headerOf(token) {
88
53
  throw new Error('Malformed envelope');
89
54
  return JSON.parse(textOf(unb64url(encodedHeader)));
90
55
  }
91
- /**
92
- * Sign one call, whole: who is asking, what is asked, and on whose behalf.
93
- *
94
- * The private key is parsed on every call here, which is the convenience form. A process
95
- * that signs in a request path builds its signer once — `identityFromEnv` does exactly
96
- * that, and `sign` on the value it returns holds the parsed key.
97
- */
56
+ /** Sign one call, whole. */
98
57
  export async function signEnvelope(identity, call) {
99
58
  return sealWith(await crypto.signerOf(identity.privateKey), identity.grant, call);
100
59
  }
@@ -104,11 +63,7 @@ async function sealWith(signer, grant, call) {
104
63
  const { sub } = JSON.parse(textOf(unb64url(grant.split('.')[1])));
105
64
  return signJws({ alg: 'EdDSA', typ: 'fougere-call', grant }, { iss: sub, state: call.state ?? {}, bound: await boundTo(call), iat: now, exp: now + ENVELOPE_TTL_MS }, signer);
106
65
  }
107
- /**
108
- * Establish the caller, or throw. Order matters: the grant is checked against the ROOT
109
- * first, and only the key it carries verifies the envelope — reading the envelope's own
110
- * claim of who it is before that would be believing the thing under examination.
111
- */
66
+ /** Establish the caller, or throw. */
112
67
  export async function verifyEnvelope(token, rootPublicKey, presented) {
113
68
  return openWith(await crypto.verifierOf(rootPublicKey), token, presented);
114
69
  }
@@ -137,28 +92,11 @@ async function openWith(root, token, presented) {
137
92
  state: payload.state ?? {},
138
93
  };
139
94
  }
140
- /**
141
- * A PEM, however the deployment chose to carry it.
142
- *
143
- * A PEM is multi-line and an environment variable that spans lines survives poorly —
144
- * docker-compose, systemd and CI secret stores each mangle it differently — so
145
- * `fougere keys` prints base64. Both forms are read here rather than one being decreed:
146
- * a human pasting a real PEM is not making a mistake.
147
- */
95
+ /** A PEM, however the deployment chose to carry it. */
148
96
  function pemOf(value) {
149
97
  return value.trimStart().startsWith('-----') ? value : textOf(unb64(value));
150
98
  }
151
- /**
152
- * What the deployment injected, read once at boot.
153
- *
154
- * Three variables, no config key: a private key never belongs in a committed file, and
155
- * `fougere keys` prints exactly these. A process may hold either half or both — a frond
156
- * that only answers has no key, one that only calls trusts no root, one in the middle
157
- * does both.
158
- *
159
- * Trusting a root IS asking to refuse: there is no separate flag, because a deployment
160
- * that names an authority and then accepts unsigned calls has said two things at once.
161
- */
99
+ /** What the deployment injected, read once at boot. */
162
100
  export async function identityFromEnv(env = envOfProcess()) {
163
101
  const root = env.FOUGERE_ROOT_KEY ? pemOf(env.FOUGERE_ROOT_KEY) : undefined;
164
102
  const privateKey = env.FOUGERE_KEY ? pemOf(env.FOUGERE_KEY) : undefined;