@geekmidas/constructs 10.0.0-alpha.6 → 10.0.0-alpha.60

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 (405) hide show
  1. package/README.md +223 -158
  2. package/dist/{Construct-BD5neF7w.mjs → Construct-BO1X-kt9.mjs} +32 -33
  3. package/dist/Construct-BO1X-kt9.mjs.map +1 -0
  4. package/dist/Construct-BQALFCh2.d.cts +230 -0
  5. package/dist/Construct-BQALFCh2.d.cts.map +1 -0
  6. package/dist/{Construct-CyS3RpTL.cjs → Construct-DmvXceVY.cjs} +52 -47
  7. package/dist/Construct-DmvXceVY.cjs.map +1 -0
  8. package/dist/Construct-QXnl3VqT.d.mts +230 -0
  9. package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
  10. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DI3nKoic.d.cts} +15 -9
  11. package/dist/Cron-DI3nKoic.d.cts.map +1 -0
  12. package/dist/{Cron-dh4rUgib.d.mts → Cron-uYAHPnp7.d.mts} +15 -9
  13. package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
  14. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BoHzlWU_.cjs} +47 -31
  15. package/dist/CronBuilder-BoHzlWU_.cjs.map +1 -0
  16. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-CCgt0wCE.mjs} +37 -21
  17. package/dist/CronBuilder-CCgt0wCE.mjs.map +1 -0
  18. package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
  19. package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
  20. package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
  21. package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
  22. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-Bm9HjTPc.d.cts} +70 -93
  23. package/dist/Endpoint-Bm9HjTPc.d.cts.map +1 -0
  24. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-CQ9RJ7p2.mjs} +130 -109
  25. package/dist/Endpoint-CQ9RJ7p2.mjs.map +1 -0
  26. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-DOi8c_Gy.cjs} +158 -131
  27. package/dist/Endpoint-DOi8c_Gy.cjs.map +1 -0
  28. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-KyMeR-B-.d.mts} +71 -94
  29. package/dist/Endpoint-KyMeR-B-.d.mts.map +1 -0
  30. package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-B6eZ3RDd.d.cts} +62 -132
  31. package/dist/EndpointFactory-B6eZ3RDd.d.cts.map +1 -0
  32. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-Bo9lkMqB.cjs} +75 -110
  33. package/dist/EndpointFactory-Bo9lkMqB.cjs.map +1 -0
  34. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-DR1rebok.mjs} +39 -74
  35. package/dist/EndpointFactory-DR1rebok.mjs.map +1 -0
  36. package/dist/{index-lAO9egTb.d.mts → EndpointFactory-GYkAuG3u.d.mts} +63 -133
  37. package/dist/EndpointFactory-GYkAuG3u.d.mts.map +1 -0
  38. package/dist/Function-DuqGcbOI.d.mts +76 -0
  39. package/dist/Function-DuqGcbOI.d.mts.map +1 -0
  40. package/dist/Function-Pu-1kKZz.d.cts +76 -0
  41. package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-XyxwoFnE.cjs} +52 -54
  43. package/dist/HonoEndpointAdaptor-XyxwoFnE.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-ja49poBI.mjs} +42 -47
  45. package/dist/HonoEndpointAdaptor-ja49poBI.mjs.map +1 -0
  46. package/dist/Queue-D5jcw0mu.cjs +109 -0
  47. package/dist/Queue-D5jcw0mu.cjs.map +1 -0
  48. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
  49. package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
  50. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
  51. package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
  52. package/dist/Queue-hwPN-t31.mjs +104 -0
  53. package/dist/Queue-hwPN-t31.mjs.map +1 -0
  54. package/dist/QueueBuilder-BFQn3OzZ.cjs +135 -0
  55. package/dist/QueueBuilder-BFQn3OzZ.cjs.map +1 -0
  56. package/dist/QueueBuilder-DCuYdjMw.mjs +118 -0
  57. package/dist/QueueBuilder-DCuYdjMw.mjs.map +1 -0
  58. package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
  59. package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
  60. package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
  61. package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
  62. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
  63. package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
  64. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
  65. package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
  66. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2PwqwIl.cjs} +61 -36
  67. package/dist/SubscriberBuilder-C2PwqwIl.cjs.map +1 -0
  68. package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
  69. package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
  70. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DMFk_Ap1.mjs} +50 -24
  71. package/dist/SubscriberBuilder-DMFk_Ap1.mjs.map +1 -0
  72. package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
  73. package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
  74. package/dist/Topic-CkxOTrMv.cjs +104 -0
  75. package/dist/Topic-CkxOTrMv.cjs.map +1 -0
  76. package/dist/Topic-hPffOsot.mjs +99 -0
  77. package/dist/Topic-hPffOsot.mjs.map +1 -0
  78. package/dist/adaptors/aws.cjs +118 -216
  79. package/dist/adaptors/aws.cjs.map +1 -1
  80. package/dist/adaptors/aws.d.cts +34 -53
  81. package/dist/adaptors/aws.d.cts.map +1 -1
  82. package/dist/adaptors/aws.d.mts +35 -54
  83. package/dist/adaptors/aws.d.mts.map +1 -1
  84. package/dist/adaptors/aws.mjs +91 -191
  85. package/dist/adaptors/aws.mjs.map +1 -1
  86. package/dist/adaptors/hono.cjs +3 -10
  87. package/dist/adaptors/hono.d.cts +7 -16
  88. package/dist/adaptors/hono.d.cts.map +1 -1
  89. package/dist/adaptors/hono.d.mts +8 -17
  90. package/dist/adaptors/hono.d.mts.map +1 -1
  91. package/dist/adaptors/hono.mjs +2 -10
  92. package/dist/adaptors/testing.cjs +711 -89
  93. package/dist/adaptors/testing.cjs.map +1 -1
  94. package/dist/adaptors/testing.d.cts +325 -54
  95. package/dist/adaptors/testing.d.cts.map +1 -1
  96. package/dist/adaptors/testing.d.mts +325 -54
  97. package/dist/adaptors/testing.d.mts.map +1 -1
  98. package/dist/adaptors/testing.mjs +676 -70
  99. package/dist/adaptors/testing.mjs.map +1 -1
  100. package/dist/auth-CIFXNuDk.d.cts +194 -0
  101. package/dist/auth-CIFXNuDk.d.cts.map +1 -0
  102. package/dist/auth-CJ9Ff6Lu.d.mts +194 -0
  103. package/dist/auth-CJ9Ff6Lu.d.mts.map +1 -0
  104. package/dist/auth.cjs +172 -31
  105. package/dist/auth.cjs.map +1 -1
  106. package/dist/auth.d.cts +2 -108
  107. package/dist/auth.d.mts +2 -108
  108. package/dist/auth.mjs +161 -24
  109. package/dist/auth.mjs.map +1 -1
  110. package/dist/{cache-BrRz3fEB.d.mts → cache-CXh6GIgb.d.mts} +3 -6
  111. package/dist/cache-CXh6GIgb.d.mts.map +1 -0
  112. package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
  113. package/dist/cache-DnGDGly3.d.cts.map +1 -0
  114. package/dist/cache.cjs +68 -2
  115. package/dist/cache.cjs.map +1 -0
  116. package/dist/cache.d.cts +1 -2
  117. package/dist/cache.d.mts +1 -2
  118. package/dist/cache.mjs +67 -2
  119. package/dist/cache.mjs.map +1 -0
  120. package/dist/cipher-C1lEFX63.mjs +225 -0
  121. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  122. package/dist/cipher-CVxfwLjk.cjs +332 -0
  123. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  124. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  125. package/dist/clone-EKNovYHu.mjs.map +1 -0
  126. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  127. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  128. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
  129. package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
  130. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DluK3_da.d.mts} +42 -11
  131. package/dist/construct-interface-DluK3_da.d.mts.map +1 -0
  132. package/dist/construct-interface.cjs +113 -7
  133. package/dist/construct-interface.cjs.map +1 -0
  134. package/dist/construct-interface.d.cts +2 -2
  135. package/dist/construct-interface.d.mts +2 -2
  136. package/dist/construct-interface.mjs +106 -2
  137. package/dist/construct-interface.mjs.map +1 -0
  138. package/dist/credential.cjs +63 -16
  139. package/dist/credential.cjs.map +1 -1
  140. package/dist/credential.d.cts +16 -9
  141. package/dist/credential.d.cts.map +1 -1
  142. package/dist/credential.d.mts +16 -9
  143. package/dist/credential.d.mts.map +1 -1
  144. package/dist/credential.mjs +58 -12
  145. package/dist/credential.mjs.map +1 -1
  146. package/dist/crons/index.cjs +105 -7
  147. package/dist/crons/index.cjs.map +1 -1
  148. package/dist/crons/index.d.cts +40 -11
  149. package/dist/crons/index.d.cts.map +1 -1
  150. package/dist/crons/index.d.mts +40 -11
  151. package/dist/crons/index.d.mts.map +1 -1
  152. package/dist/crons/index.mjs +103 -8
  153. package/dist/crons/index.mjs.map +1 -1
  154. package/dist/database/kysely.cjs +4 -181
  155. package/dist/database/kysely.d.cts +2 -152
  156. package/dist/database/kysely.d.mts +2 -152
  157. package/dist/database/kysely.mjs +2 -180
  158. package/dist/email.cjs +25 -12
  159. package/dist/email.cjs.map +1 -1
  160. package/dist/email.d.cts +3 -7
  161. package/dist/email.d.cts.map +1 -1
  162. package/dist/email.d.mts +3 -7
  163. package/dist/email.d.mts.map +1 -1
  164. package/dist/email.mjs +16 -3
  165. package/dist/email.mjs.map +1 -1
  166. package/dist/encryption.cjs +96 -0
  167. package/dist/encryption.cjs.map +1 -0
  168. package/dist/encryption.d.cts +117 -0
  169. package/dist/encryption.d.cts.map +1 -0
  170. package/dist/encryption.d.mts +117 -0
  171. package/dist/encryption.d.mts.map +1 -0
  172. package/dist/encryption.mjs +83 -0
  173. package/dist/encryption.mjs.map +1 -0
  174. package/dist/endpoints/index.cjs +8 -10
  175. package/dist/endpoints/index.d.cts +51 -7
  176. package/dist/endpoints/index.d.cts.map +1 -0
  177. package/dist/endpoints/index.d.mts +51 -7
  178. package/dist/endpoints/index.d.mts.map +1 -0
  179. package/dist/endpoints/index.mjs +6 -10
  180. package/dist/external-api-CWY9orcO.d.mts +86 -0
  181. package/dist/external-api-CWY9orcO.d.mts.map +1 -0
  182. package/dist/external-api-D-5WB-sr.d.cts +86 -0
  183. package/dist/external-api-D-5WB-sr.d.cts.map +1 -0
  184. package/dist/external-api.cjs +124 -0
  185. package/dist/external-api.cjs.map +1 -0
  186. package/dist/external-api.d.cts +2 -0
  187. package/dist/external-api.d.mts +2 -0
  188. package/dist/external-api.mjs +121 -0
  189. package/dist/external-api.mjs.map +1 -0
  190. package/dist/file-server.cjs +42 -10
  191. package/dist/file-server.cjs.map +1 -1
  192. package/dist/file-server.d.cts +6 -10
  193. package/dist/file-server.d.cts.map +1 -1
  194. package/dist/file-server.d.mts +6 -10
  195. package/dist/file-server.d.mts.map +1 -1
  196. package/dist/file-server.mjs +34 -2
  197. package/dist/file-server.mjs.map +1 -1
  198. package/dist/functions/index.cjs +3 -6
  199. package/dist/functions/index.d.cts +3 -4
  200. package/dist/functions/index.d.mts +3 -4
  201. package/dist/functions/index.mjs +2 -6
  202. package/dist/{functions-i_la-N5r.cjs → functions-CbP5ZKma.cjs} +414 -264
  203. package/dist/functions-CbP5ZKma.cjs.map +1 -0
  204. package/dist/{functions-14lpEFL4.mjs → functions-Di6n5ltG.mjs} +376 -238
  205. package/dist/{functions-14lpEFL4.mjs.map → functions-Di6n5ltG.mjs.map} +1 -1
  206. package/dist/index-BuzRvKOQ.d.cts +115 -0
  207. package/dist/index-BuzRvKOQ.d.cts.map +1 -0
  208. package/dist/index-CTkKOer4.d.mts +115 -0
  209. package/dist/index-CTkKOer4.d.mts.map +1 -0
  210. package/dist/index-CeEtxDmK.d.cts +79 -0
  211. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  212. package/dist/index-CeEtxDmK.d.mts +79 -0
  213. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  214. package/dist/index.cjs +6 -3
  215. package/dist/index.d.cts +26 -4
  216. package/dist/index.d.cts.map +1 -0
  217. package/dist/index.d.mts +26 -4
  218. package/dist/index.d.mts.map +1 -0
  219. package/dist/index.mjs +3 -3
  220. package/dist/kms-B-Hm3d5r.cjs +85 -0
  221. package/dist/kms-B-Hm3d5r.cjs.map +1 -0
  222. package/dist/kms-BdUlMJEZ.mjs +85 -0
  223. package/dist/kms-BdUlMJEZ.mjs.map +1 -0
  224. package/dist/kysely-BEm5sDlU.d.cts +173 -0
  225. package/dist/kysely-BEm5sDlU.d.cts.map +1 -0
  226. package/dist/kysely-BRzzawr2.cjs +301 -0
  227. package/dist/kysely-BRzzawr2.cjs.map +1 -0
  228. package/dist/kysely-BYfM6Zby.mjs +288 -0
  229. package/dist/kysely-BYfM6Zby.mjs.map +1 -0
  230. package/dist/kysely-CjuvdXEV.d.mts +173 -0
  231. package/dist/kysely-CjuvdXEV.d.mts.map +1 -0
  232. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
  233. package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
  234. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
  235. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
  236. package/dist/mobile-app.cjs +73 -0
  237. package/dist/mobile-app.cjs.map +1 -0
  238. package/dist/mobile-app.d.cts +61 -0
  239. package/dist/mobile-app.d.cts.map +1 -0
  240. package/dist/mobile-app.d.mts +61 -0
  241. package/dist/mobile-app.d.mts.map +1 -0
  242. package/dist/mobile-app.mjs +72 -0
  243. package/dist/mobile-app.mjs.map +1 -0
  244. package/dist/object-storage.cjs +18 -10
  245. package/dist/object-storage.cjs.map +1 -1
  246. package/dist/object-storage.d.cts +3 -7
  247. package/dist/object-storage.d.cts.map +1 -1
  248. package/dist/object-storage.d.mts +3 -7
  249. package/dist/object-storage.d.mts.map +1 -1
  250. package/dist/object-storage.mjs +11 -3
  251. package/dist/object-storage.mjs.map +1 -1
  252. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  253. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  254. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  255. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  256. package/dist/queue/index.cjs +6 -189
  257. package/dist/queue/index.d.cts +3 -60
  258. package/dist/queue/index.d.mts +3 -60
  259. package/dist/queue/index.mjs +3 -186
  260. package/dist/rest-api.cjs +88 -63
  261. package/dist/rest-api.cjs.map +1 -1
  262. package/dist/rest-api.d.cts +68 -61
  263. package/dist/rest-api.d.cts.map +1 -1
  264. package/dist/rest-api.d.mts +68 -61
  265. package/dist/rest-api.d.mts.map +1 -1
  266. package/dist/rest-api.mjs +80 -55
  267. package/dist/rest-api.mjs.map +1 -1
  268. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  269. package/dist/runSubscriber-BRp9a_qi.cjs +126 -0
  270. package/dist/runSubscriber-BRp9a_qi.cjs.map +1 -0
  271. package/dist/runSubscriber-BYEY_bfA.mjs +109 -0
  272. package/dist/runSubscriber-BYEY_bfA.mjs.map +1 -0
  273. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  274. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  275. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  276. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  277. package/dist/site.cjs +34 -9
  278. package/dist/site.cjs.map +1 -1
  279. package/dist/site.d.cts +17 -22
  280. package/dist/site.d.cts.map +1 -1
  281. package/dist/site.d.mts +17 -22
  282. package/dist/site.d.mts.map +1 -1
  283. package/dist/site.mjs +30 -5
  284. package/dist/site.mjs.map +1 -1
  285. package/dist/subscribers/index.cjs +111 -6
  286. package/dist/subscribers/index.cjs.map +1 -0
  287. package/dist/subscribers/index.d.cts +50 -6
  288. package/dist/subscribers/index.d.cts.map +1 -0
  289. package/dist/subscribers/index.d.mts +50 -6
  290. package/dist/subscribers/index.d.mts.map +1 -0
  291. package/dist/subscribers/index.mjs +108 -5
  292. package/dist/subscribers/index.mjs.map +1 -0
  293. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  294. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  295. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  296. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  297. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  298. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  299. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  300. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  301. package/dist/topic/index.cjs +3 -137
  302. package/dist/topic/index.d.cts +2 -4
  303. package/dist/topic/index.d.mts +2 -4
  304. package/dist/topic/index.mjs +2 -134
  305. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  306. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  307. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  308. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  309. package/dist/types.d.cts +1 -1
  310. package/dist/types.d.mts +1 -1
  311. package/dist/types.mjs +1 -0
  312. package/dist/worker.cjs +58 -34
  313. package/dist/worker.cjs.map +1 -1
  314. package/dist/worker.d.cts +63 -45
  315. package/dist/worker.d.cts.map +1 -1
  316. package/dist/worker.d.mts +63 -44
  317. package/dist/worker.d.mts.map +1 -1
  318. package/dist/worker.mjs +53 -29
  319. package/dist/worker.mjs.map +1 -1
  320. package/package.json +82 -41
  321. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  322. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  323. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  324. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  325. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  326. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  327. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  328. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  329. package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
  330. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  331. package/dist/CronBuilder-CGgY2080.d.mts +0 -44
  332. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  333. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  334. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  335. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  336. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  337. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  338. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  339. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  340. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  341. package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
  342. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  343. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  344. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  345. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  346. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  347. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  348. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  349. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  350. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  351. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  352. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  353. package/dist/Topic-19QeHBIR.d.cts +0 -91
  354. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  355. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  356. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  357. package/dist/auth.d.cts.map +0 -1
  358. package/dist/auth.d.mts.map +0 -1
  359. package/dist/cache-0ANvRQnD.mjs +0 -51
  360. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  361. package/dist/cache-3WSvAulx.cjs +0 -57
  362. package/dist/cache-3WSvAulx.cjs.map +0 -1
  363. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  364. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  365. package/dist/clone-DblgEZZa.mjs.map +0 -1
  366. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  367. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  368. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  369. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  370. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  371. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  372. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  373. package/dist/database/kysely.cjs.map +0 -1
  374. package/dist/database/kysely.d.cts.map +0 -1
  375. package/dist/database/kysely.d.mts.map +0 -1
  376. package/dist/database/kysely.mjs.map +0 -1
  377. package/dist/functions-i_la-N5r.cjs.map +0 -1
  378. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  379. package/dist/index-BknhM6Ux.d.mts +0 -31
  380. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  381. package/dist/index-CBSfrowv.d.cts +0 -31
  382. package/dist/index-CBSfrowv.d.cts.map +0 -1
  383. package/dist/index-D24Xm79M.d.cts +0 -171
  384. package/dist/index-D24Xm79M.d.cts.map +0 -1
  385. package/dist/index-_ajboYxK.d.mts +0 -171
  386. package/dist/index-_ajboYxK.d.mts.map +0 -1
  387. package/dist/index-lAO9egTb.d.mts.map +0 -1
  388. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  389. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  390. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  391. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  392. package/dist/queue/index.cjs.map +0 -1
  393. package/dist/queue/index.d.cts.map +0 -1
  394. package/dist/queue/index.d.mts.map +0 -1
  395. package/dist/queue/index.mjs.map +0 -1
  396. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  397. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  398. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  399. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  400. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  401. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  402. package/dist/topic/index.cjs.map +0 -1
  403. package/dist/topic/index.mjs.map +0 -1
  404. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  405. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -0,0 +1,332 @@
1
+ let node_crypto = require("node:crypto");
2
+ //#region src/encryption/cipher.ts
3
+ /**
4
+ * The cipher behind an `Encryption` construct, and the format it writes.
5
+ *
6
+ * Every ciphertext names the key that wrote it — `gkm1.<keyId>.<payload>` — so
7
+ * `decrypt` never has to guess, a rotated key still opens what it wrote, and
8
+ * retiring a key is a decision made against data rather than a hope. The
9
+ * format version leads, so the day it has to change, both can be read.
10
+ *
11
+ * Two backends, picked by the scheme of the construct's URL, the way a queue's
12
+ * connection string picks its broker:
13
+ *
14
+ * - `aes256gcm://` — a keyring this process holds: AES-256-GCM with the newest
15
+ * key, HMAC-SHA256 for the blind index. Local, test and server stages.
16
+ * - `kms://` — envelope encryption under an AWS KMS key, and a KMS HMAC key for
17
+ * the index. The key material never leaves KMS. See `./kms`.
18
+ */
19
+ /** The format every ciphertext leads with. */
20
+ const CIPHERTEXT_VERSION = "gkm1";
21
+ /** AES-256-GCM's nonce and tag, in bytes. */
22
+ const IV_BYTES = 12;
23
+ const KEY_BYTES = 32;
24
+ const LOCAL_SCHEME = "aes256gcm:";
25
+ var EncryptionUrlInvalid = class extends Error {
26
+ construct;
27
+ reason;
28
+ constructor(construct, reason) {
29
+ super(`${construct}'s encryption URL is not usable: ${reason}. gkm composes it — derived locally, generated into a server stage's secrets on its first deploy, provisioned on AWS — so it should not be set by hand.`);
30
+ this.construct = construct;
31
+ this.reason = reason;
32
+ this.name = "EncryptionUrlInvalid";
33
+ }
34
+ };
35
+ var UnknownEncryptionScheme = class extends Error {
36
+ construct;
37
+ scheme;
38
+ constructor(construct, scheme) {
39
+ super(`${construct}'s encryption URL uses '${scheme}', which no cipher handles. Expected 'aes256gcm:' (a local keyring) or 'kms:' (AWS KMS).`);
40
+ this.construct = construct;
41
+ this.scheme = scheme;
42
+ this.name = "UnknownEncryptionScheme";
43
+ }
44
+ };
45
+ var CiphertextMalformed = class extends Error {
46
+ construct;
47
+ constructor(construct) {
48
+ super(`${construct} was asked to decrypt something it did not write: a ciphertext starts '${CIPHERTEXT_VERSION}.<key>.'. Check the column holds what \`encrypt\` returned, untrimmed.`);
49
+ this.construct = construct;
50
+ this.name = "CiphertextMalformed";
51
+ }
52
+ };
53
+ var EncryptionKeyRetired = class extends Error {
54
+ construct;
55
+ keyId;
56
+ constructor(construct, keyId) {
57
+ super(`${construct} has no key '${keyId}' any more, so a value it wrote cannot be read. It was retired before every value was re-encrypted; restore it from the stage's secrets history, run the sweep, then retire it again.`);
58
+ this.construct = construct;
59
+ this.keyId = keyId;
60
+ this.name = "EncryptionKeyRetired";
61
+ }
62
+ };
63
+ var CiphertextNotAuthentic = class extends Error {
64
+ construct;
65
+ constructor(construct) {
66
+ super(`${construct} could not authenticate a ciphertext: it was altered, or written by a different Encryption construct. Ciphertexts are bound to the construct that wrote them.`);
67
+ this.construct = construct;
68
+ this.name = "CiphertextNotAuthentic";
69
+ }
70
+ };
71
+ var CurrentKeyCannotRetire = class extends Error {
72
+ construct;
73
+ keyId;
74
+ constructor(construct, keyId) {
75
+ super(`'${keyId}' is ${construct}'s current key — everything new is written with it. Rotate first, sweep, then retire '${keyId}'.`);
76
+ this.construct = construct;
77
+ this.keyId = keyId;
78
+ this.name = "CurrentKeyCannotRetire";
79
+ }
80
+ };
81
+ /** A ciphertext's three parts. */
82
+ function parseCiphertext(construct, ciphertext) {
83
+ const [version, keyId, payload, ...rest] = ciphertext.split(".");
84
+ if (version !== "gkm1" || !keyId || !payload || rest.length) throw new CiphertextMalformed(construct);
85
+ return {
86
+ keyId,
87
+ payload: Buffer.from(payload, "base64url")
88
+ };
89
+ }
90
+ function formatCiphertext(keyId, payload) {
91
+ return `${CIPHERTEXT_VERSION}.${keyId}.${payload.toString("base64url")}`;
92
+ }
93
+ /**
94
+ * What the cipher authenticates alongside the data: the construct and the key.
95
+ *
96
+ * Binding the construct means a value copied from one `Encryption` into
97
+ * another's column fails instead of decrypting under the wrong policy.
98
+ */
99
+ function associatedData(construct, keyId) {
100
+ return Buffer.from(`${CIPHERTEXT_VERSION}:${construct}:${keyId}`);
101
+ }
102
+ /** `iv | tag | ciphertext`, under one AES-256-GCM key. */
103
+ function seal(key, plaintext, aad) {
104
+ const iv = (0, node_crypto.randomBytes)(IV_BYTES);
105
+ const cipher = (0, node_crypto.createCipheriv)("aes-256-gcm", key, iv);
106
+ cipher.setAAD(aad);
107
+ const body = Buffer.concat([cipher.update(plaintext), cipher.final()]);
108
+ return Buffer.concat([
109
+ iv,
110
+ cipher.getAuthTag(),
111
+ body
112
+ ]);
113
+ }
114
+ /** The inverse of {@link seal}; `undefined` when it does not authenticate. */
115
+ function open(key, sealed, aad) {
116
+ if (sealed.length < 28) return void 0;
117
+ const decipher = (0, node_crypto.createDecipheriv)("aes-256-gcm", key, sealed.subarray(0, IV_BYTES));
118
+ decipher.setAAD(aad);
119
+ decipher.setAuthTag(sealed.subarray(IV_BYTES, 28));
120
+ try {
121
+ return Buffer.concat([decipher.update(sealed.subarray(28)), decipher.final()]);
122
+ } catch {
123
+ return;
124
+ }
125
+ }
126
+ /** Parse `aes256gcm://local?keys=k2.<key>,k1.<key>&index=<key>`. */
127
+ function parseKeyring(construct, url) {
128
+ let parsed;
129
+ try {
130
+ parsed = new URL(url);
131
+ } catch {
132
+ throw new EncryptionUrlInvalid(construct, "it is not a URL");
133
+ }
134
+ const keys = (parsed.searchParams.get("keys") ?? "").split(",").filter(Boolean).map((entry) => {
135
+ const [id, encoded] = entry.split(".");
136
+ const key = Buffer.from(encoded ?? "", "base64url");
137
+ if (!id || key.length !== KEY_BYTES) throw new EncryptionUrlInvalid(construct, `'${id ?? entry}' is not a 256-bit key`);
138
+ return {
139
+ id,
140
+ key
141
+ };
142
+ });
143
+ if (keys.length === 0) throw new EncryptionUrlInvalid(construct, "it holds no keys");
144
+ const index = Buffer.from(parsed.searchParams.get("index") ?? "", "base64url");
145
+ if (index.length !== KEY_BYTES) throw new EncryptionUrlInvalid(construct, "its index key is missing");
146
+ return {
147
+ keys,
148
+ index
149
+ };
150
+ }
151
+ function formatKeyring(keyring) {
152
+ const keys = keyring.keys.map(({ id, key }) => `${id}.${key.toString("base64url")}`).join(",");
153
+ return `${LOCAL_SCHEME}//local?keys=${keys}&index=${keyring.index.toString("base64url")}`;
154
+ }
155
+ /** A keyring with one fresh key, `k1`, and a fresh index key. */
156
+ function generateKeyring() {
157
+ return formatKeyring({
158
+ keys: [{
159
+ id: "k1",
160
+ key: (0, node_crypto.randomBytes)(KEY_BYTES)
161
+ }],
162
+ index: (0, node_crypto.randomBytes)(KEY_BYTES)
163
+ });
164
+ }
165
+ /**
166
+ * The keyring with a new current key in front, and every older one kept.
167
+ *
168
+ * Nothing is dropped: what the old keys wrote still has to open until a sweep
169
+ * has re-encrypted it — see {@link retireKey}.
170
+ */
171
+ function rotateKeyring(construct, url) {
172
+ const keyring = parseKeyring(construct, url);
173
+ const next = Math.max(...keyring.keys.map(({ id }) => Number(id.slice(1)) || 0)) + 1;
174
+ return formatKeyring({
175
+ ...keyring,
176
+ keys: [{
177
+ id: `k${next}`,
178
+ key: (0, node_crypto.randomBytes)(KEY_BYTES)
179
+ }, ...keyring.keys]
180
+ });
181
+ }
182
+ /** The keyring without `keyId`, which must not be the current key. */
183
+ function retireKey(construct, url, keyId) {
184
+ const keyring = parseKeyring(construct, url);
185
+ if (keyring.keys[0]?.id === keyId) throw new CurrentKeyCannotRetire(construct, keyId);
186
+ if (!keyring.keys.some(({ id }) => id === keyId)) throw new EncryptionKeyRetired(construct, keyId);
187
+ return formatKeyring({
188
+ ...keyring,
189
+ keys: keyring.keys.filter(({ id }) => id !== keyId)
190
+ });
191
+ }
192
+ /** The `aes256gcm://` cipher: a keyring held in process. */
193
+ function keyringCipher(construct, url, onStaleKey = () => {}) {
194
+ const keyring = parseKeyring(construct, url);
195
+ const current = keyring.keys[0];
196
+ const byId = new Map(keyring.keys.map(({ id, key }) => [id, key]));
197
+ const reported = /* @__PURE__ */ new Set();
198
+ const decrypt = async (ciphertext) => {
199
+ const { keyId, payload } = parseCiphertext(construct, ciphertext);
200
+ const key = byId.get(keyId);
201
+ if (!key) throw new EncryptionKeyRetired(construct, keyId);
202
+ const plaintext = open(key, payload, associatedData(construct, keyId));
203
+ if (!plaintext) throw new CiphertextNotAuthentic(construct);
204
+ if (keyId !== current.id && !reported.has(keyId)) {
205
+ reported.add(keyId);
206
+ onStaleKey(keyId, current.id);
207
+ }
208
+ return plaintext.toString("utf8");
209
+ };
210
+ const encrypt = async (plaintext) => formatCiphertext(current.id, seal(current.key, Buffer.from(plaintext, "utf8"), associatedData(construct, current.id)));
211
+ return {
212
+ encrypt,
213
+ decrypt,
214
+ index: async (value) => (0, node_crypto.createHmac)("sha256", keyring.index).update(value, "utf8").digest("base64url"),
215
+ reencrypt: async (ciphertext) => {
216
+ const { keyId } = parseCiphertext(construct, ciphertext);
217
+ if (keyId === current.id) return ciphertext;
218
+ return encrypt(await decrypt(ciphertext));
219
+ }
220
+ };
221
+ }
222
+ //#endregion
223
+ Object.defineProperty(exports, "CiphertextMalformed", {
224
+ enumerable: true,
225
+ get: function() {
226
+ return CiphertextMalformed;
227
+ }
228
+ });
229
+ Object.defineProperty(exports, "CiphertextNotAuthentic", {
230
+ enumerable: true,
231
+ get: function() {
232
+ return CiphertextNotAuthentic;
233
+ }
234
+ });
235
+ Object.defineProperty(exports, "CurrentKeyCannotRetire", {
236
+ enumerable: true,
237
+ get: function() {
238
+ return CurrentKeyCannotRetire;
239
+ }
240
+ });
241
+ Object.defineProperty(exports, "EncryptionKeyRetired", {
242
+ enumerable: true,
243
+ get: function() {
244
+ return EncryptionKeyRetired;
245
+ }
246
+ });
247
+ Object.defineProperty(exports, "EncryptionUrlInvalid", {
248
+ enumerable: true,
249
+ get: function() {
250
+ return EncryptionUrlInvalid;
251
+ }
252
+ });
253
+ Object.defineProperty(exports, "LOCAL_SCHEME", {
254
+ enumerable: true,
255
+ get: function() {
256
+ return LOCAL_SCHEME;
257
+ }
258
+ });
259
+ Object.defineProperty(exports, "UnknownEncryptionScheme", {
260
+ enumerable: true,
261
+ get: function() {
262
+ return UnknownEncryptionScheme;
263
+ }
264
+ });
265
+ Object.defineProperty(exports, "associatedData", {
266
+ enumerable: true,
267
+ get: function() {
268
+ return associatedData;
269
+ }
270
+ });
271
+ Object.defineProperty(exports, "formatCiphertext", {
272
+ enumerable: true,
273
+ get: function() {
274
+ return formatCiphertext;
275
+ }
276
+ });
277
+ Object.defineProperty(exports, "formatKeyring", {
278
+ enumerable: true,
279
+ get: function() {
280
+ return formatKeyring;
281
+ }
282
+ });
283
+ Object.defineProperty(exports, "generateKeyring", {
284
+ enumerable: true,
285
+ get: function() {
286
+ return generateKeyring;
287
+ }
288
+ });
289
+ Object.defineProperty(exports, "keyringCipher", {
290
+ enumerable: true,
291
+ get: function() {
292
+ return keyringCipher;
293
+ }
294
+ });
295
+ Object.defineProperty(exports, "open", {
296
+ enumerable: true,
297
+ get: function() {
298
+ return open;
299
+ }
300
+ });
301
+ Object.defineProperty(exports, "parseCiphertext", {
302
+ enumerable: true,
303
+ get: function() {
304
+ return parseCiphertext;
305
+ }
306
+ });
307
+ Object.defineProperty(exports, "parseKeyring", {
308
+ enumerable: true,
309
+ get: function() {
310
+ return parseKeyring;
311
+ }
312
+ });
313
+ Object.defineProperty(exports, "retireKey", {
314
+ enumerable: true,
315
+ get: function() {
316
+ return retireKey;
317
+ }
318
+ });
319
+ Object.defineProperty(exports, "rotateKeyring", {
320
+ enumerable: true,
321
+ get: function() {
322
+ return rotateKeyring;
323
+ }
324
+ });
325
+ Object.defineProperty(exports, "seal", {
326
+ enumerable: true,
327
+ get: function() {
328
+ return seal;
329
+ }
330
+ });
331
+
332
+ //# sourceMappingURL=cipher-CVxfwLjk.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cipher-CVxfwLjk.cjs","names":["randomBytes","createCipheriv","createDecipheriv","createHmac"],"sources":["../src/encryption/cipher.ts"],"sourcesContent":["/**\n * The cipher behind an `Encryption` construct, and the format it writes.\n *\n * Every ciphertext names the key that wrote it — `gkm1.<keyId>.<payload>` — so\n * `decrypt` never has to guess, a rotated key still opens what it wrote, and\n * retiring a key is a decision made against data rather than a hope. The\n * format version leads, so the day it has to change, both can be read.\n *\n * Two backends, picked by the scheme of the construct's URL, the way a queue's\n * connection string picks its broker:\n *\n * - `aes256gcm://` — a keyring this process holds: AES-256-GCM with the newest\n * key, HMAC-SHA256 for the blind index. Local, test and server stages.\n * - `kms://` — envelope encryption under an AWS KMS key, and a KMS HMAC key for\n * the index. The key material never leaves KMS. See `./kms`.\n */\n\nimport {\n\tcreateCipheriv,\n\tcreateDecipheriv,\n\tcreateHmac,\n\trandomBytes,\n} from 'node:crypto';\n\n/** What a handler is given: `services.pii.encrypt(…)` and the rest. */\nexport interface Cipher {\n\t/** Plaintext in, a self-describing ciphertext string out. */\n\tencrypt(plaintext: string): Promise<string>;\n\t/** Opens any ciphertext this construct wrote, under whichever key wrote it. */\n\tdecrypt(ciphertext: string): Promise<string>;\n\t/**\n\t * A blind index: the same value always gives the same string, so an\n\t * encrypted column can still be looked up by an indexed column beside it.\n\t *\n\t * Deterministic on purpose, which is also why its key never rotates — a\n\t * rotated index key would make every stored index miss.\n\t */\n\tindex(value: string): Promise<string>;\n\t/**\n\t * The same plaintext under the current key — what a sweep runs over a\n\t * column before an old key is retired. Unchanged when it is already current.\n\t */\n\treencrypt(ciphertext: string): Promise<string>;\n}\n\n/** The format every ciphertext leads with. */\nexport const CIPHERTEXT_VERSION = 'gkm1';\n\n/** AES-256-GCM's nonce and tag, in bytes. */\nconst IV_BYTES = 12;\nconst TAG_BYTES = 16;\nconst KEY_BYTES = 32;\n\nexport const LOCAL_SCHEME = 'aes256gcm:';\n\nexport class EncryptionUrlInvalid extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}'s encryption URL is not usable: ${reason}. gkm composes it — derived locally, generated into a server stage's secrets on its first deploy, provisioned on AWS — so it should not be set by hand.`,\n\t\t);\n\t\tthis.name = 'EncryptionUrlInvalid';\n\t}\n}\n\nexport class UnknownEncryptionScheme extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly scheme: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct}'s encryption URL uses '${scheme}', which no cipher handles. Expected 'aes256gcm:' (a local keyring) or 'kms:' (AWS KMS).`,\n\t\t);\n\t\tthis.name = 'UnknownEncryptionScheme';\n\t}\n}\n\nexport class CiphertextMalformed extends Error {\n\tconstructor(readonly construct: string) {\n\t\tsuper(\n\t\t\t`${construct} was asked to decrypt something it did not write: a ciphertext starts '${CIPHERTEXT_VERSION}.<key>.'. Check the column holds what \\`encrypt\\` returned, untrimmed.`,\n\t\t);\n\t\tthis.name = 'CiphertextMalformed';\n\t}\n}\n\nexport class EncryptionKeyRetired extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly keyId: string,\n\t) {\n\t\tsuper(\n\t\t\t`${construct} has no key '${keyId}' any more, so a value it wrote cannot be read. It was retired before every value was re-encrypted; restore it from the stage's secrets history, run the sweep, then retire it again.`,\n\t\t);\n\t\tthis.name = 'EncryptionKeyRetired';\n\t}\n}\n\nexport class CiphertextNotAuthentic extends Error {\n\tconstructor(readonly construct: string) {\n\t\tsuper(\n\t\t\t`${construct} could not authenticate a ciphertext: it was altered, or written by a different Encryption construct. Ciphertexts are bound to the construct that wrote them.`,\n\t\t);\n\t\tthis.name = 'CiphertextNotAuthentic';\n\t}\n}\n\nexport class CurrentKeyCannotRetire extends Error {\n\tconstructor(\n\t\treadonly construct: string,\n\t\treadonly keyId: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${keyId}' is ${construct}'s current key — everything new is written with it. Rotate first, sweep, then retire '${keyId}'.`,\n\t\t);\n\t\tthis.name = 'CurrentKeyCannotRetire';\n\t}\n}\n\n/** A ciphertext's three parts. */\nexport function parseCiphertext(\n\tconstruct: string,\n\tciphertext: string,\n): { keyId: string; payload: Buffer } {\n\tconst [version, keyId, payload, ...rest] = ciphertext.split('.');\n\tif (version !== CIPHERTEXT_VERSION || !keyId || !payload || rest.length) {\n\t\tthrow new CiphertextMalformed(construct);\n\t}\n\treturn { keyId, payload: Buffer.from(payload, 'base64url') };\n}\n\nexport function formatCiphertext(keyId: string, payload: Buffer): string {\n\treturn `${CIPHERTEXT_VERSION}.${keyId}.${payload.toString('base64url')}`;\n}\n\n/**\n * What the cipher authenticates alongside the data: the construct and the key.\n *\n * Binding the construct means a value copied from one `Encryption` into\n * another's column fails instead of decrypting under the wrong policy.\n */\nexport function associatedData(construct: string, keyId: string): Buffer {\n\treturn Buffer.from(`${CIPHERTEXT_VERSION}:${construct}:${keyId}`);\n}\n\n/** `iv | tag | ciphertext`, under one AES-256-GCM key. */\nexport function seal(key: Buffer, plaintext: Buffer, aad: Buffer): Buffer {\n\tconst iv = randomBytes(IV_BYTES);\n\tconst cipher = createCipheriv('aes-256-gcm', key, iv);\n\tcipher.setAAD(aad);\n\tconst body = Buffer.concat([cipher.update(plaintext), cipher.final()]);\n\treturn Buffer.concat([iv, cipher.getAuthTag(), body]);\n}\n\n/** The inverse of {@link seal}; `undefined` when it does not authenticate. */\nexport function open(\n\tkey: Buffer,\n\tsealed: Buffer,\n\taad: Buffer,\n): Buffer | undefined {\n\tif (sealed.length < IV_BYTES + TAG_BYTES) return undefined;\n\n\tconst decipher = createDecipheriv(\n\t\t'aes-256-gcm',\n\t\tkey,\n\t\tsealed.subarray(0, IV_BYTES),\n\t);\n\tdecipher.setAAD(aad);\n\tdecipher.setAuthTag(sealed.subarray(IV_BYTES, IV_BYTES + TAG_BYTES));\n\n\ttry {\n\t\treturn Buffer.concat([\n\t\t\tdecipher.update(sealed.subarray(IV_BYTES + TAG_BYTES)),\n\t\t\tdecipher.final(),\n\t\t]);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** A local keyring: newest key first, and the index key that never rotates. */\nexport interface Keyring {\n\tkeys: { id: string; key: Buffer }[];\n\tindex: Buffer;\n}\n\n/** Parse `aes256gcm://local?keys=k2.<key>,k1.<key>&index=<key>`. */\nexport function parseKeyring(construct: string, url: string): Keyring {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch {\n\t\tthrow new EncryptionUrlInvalid(construct, 'it is not a URL');\n\t}\n\n\tconst keys = (parsed.searchParams.get('keys') ?? '')\n\t\t.split(',')\n\t\t.filter(Boolean)\n\t\t.map((entry) => {\n\t\t\tconst [id, encoded] = entry.split('.');\n\t\t\tconst key = Buffer.from(encoded ?? '', 'base64url');\n\t\t\tif (!id || key.length !== KEY_BYTES) {\n\t\t\t\tthrow new EncryptionUrlInvalid(\n\t\t\t\t\tconstruct,\n\t\t\t\t\t`'${id ?? entry}' is not a 256-bit key`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn { id, key };\n\t\t});\n\tif (keys.length === 0) {\n\t\tthrow new EncryptionUrlInvalid(construct, 'it holds no keys');\n\t}\n\n\tconst index = Buffer.from(\n\t\tparsed.searchParams.get('index') ?? '',\n\t\t'base64url',\n\t);\n\tif (index.length !== KEY_BYTES) {\n\t\tthrow new EncryptionUrlInvalid(construct, 'its index key is missing');\n\t}\n\n\treturn { keys, index };\n}\n\nexport function formatKeyring(keyring: Keyring): string {\n\tconst keys = keyring.keys\n\t\t.map(({ id, key }) => `${id}.${key.toString('base64url')}`)\n\t\t.join(',');\n\treturn `${LOCAL_SCHEME}//local?keys=${keys}&index=${keyring.index.toString('base64url')}`;\n}\n\n/** A keyring with one fresh key, `k1`, and a fresh index key. */\nexport function generateKeyring(): string {\n\treturn formatKeyring({\n\t\tkeys: [{ id: 'k1', key: randomBytes(KEY_BYTES) }],\n\t\tindex: randomBytes(KEY_BYTES),\n\t});\n}\n\n/**\n * The keyring with a new current key in front, and every older one kept.\n *\n * Nothing is dropped: what the old keys wrote still has to open until a sweep\n * has re-encrypted it — see {@link retireKey}.\n */\nexport function rotateKeyring(construct: string, url: string): string {\n\tconst keyring = parseKeyring(construct, url);\n\tconst next =\n\t\tMath.max(...keyring.keys.map(({ id }) => Number(id.slice(1)) || 0)) + 1;\n\n\treturn formatKeyring({\n\t\t...keyring,\n\t\tkeys: [{ id: `k${next}`, key: randomBytes(KEY_BYTES) }, ...keyring.keys],\n\t});\n}\n\n/** The keyring without `keyId`, which must not be the current key. */\nexport function retireKey(\n\tconstruct: string,\n\turl: string,\n\tkeyId: string,\n): string {\n\tconst keyring = parseKeyring(construct, url);\n\tif (keyring.keys[0]?.id === keyId) {\n\t\tthrow new CurrentKeyCannotRetire(construct, keyId);\n\t}\n\tif (!keyring.keys.some(({ id }) => id === keyId)) {\n\t\tthrow new EncryptionKeyRetired(construct, keyId);\n\t}\n\n\treturn formatKeyring({\n\t\t...keyring,\n\t\tkeys: keyring.keys.filter(({ id }) => id !== keyId),\n\t});\n}\n\n/** Says, once per key per process, that a value is still under an old key. */\nexport type StaleKeyReporter = (keyId: string, current: string) => void;\n\n/** The `aes256gcm://` cipher: a keyring held in process. */\nexport function keyringCipher(\n\tconstruct: string,\n\turl: string,\n\tonStaleKey: StaleKeyReporter = () => {},\n): Cipher {\n\tconst keyring = parseKeyring(construct, url);\n\tconst current = keyring.keys[0]!;\n\tconst byId = new Map(keyring.keys.map(({ id, key }) => [id, key]));\n\tconst reported = new Set<string>();\n\n\tconst decrypt = async (ciphertext: string) => {\n\t\tconst { keyId, payload } = parseCiphertext(construct, ciphertext);\n\t\tconst key = byId.get(keyId);\n\t\tif (!key) throw new EncryptionKeyRetired(construct, keyId);\n\n\t\tconst plaintext = open(key, payload, associatedData(construct, keyId));\n\t\tif (!plaintext) throw new CiphertextNotAuthentic(construct);\n\n\t\tif (keyId !== current.id && !reported.has(keyId)) {\n\t\t\treported.add(keyId);\n\t\t\tonStaleKey(keyId, current.id);\n\t\t}\n\n\t\treturn plaintext.toString('utf8');\n\t};\n\n\tconst encrypt = async (plaintext: string) =>\n\t\tformatCiphertext(\n\t\t\tcurrent.id,\n\t\t\tseal(\n\t\t\t\tcurrent.key,\n\t\t\t\tBuffer.from(plaintext, 'utf8'),\n\t\t\t\tassociatedData(construct, current.id),\n\t\t\t),\n\t\t);\n\n\treturn {\n\t\tencrypt,\n\t\tdecrypt,\n\t\tindex: async (value) =>\n\t\t\tcreateHmac('sha256', keyring.index)\n\t\t\t\t.update(value, 'utf8')\n\t\t\t\t.digest('base64url'),\n\t\treencrypt: async (ciphertext) => {\n\t\t\tconst { keyId } = parseCiphertext(construct, ciphertext);\n\t\t\tif (keyId === current.id) return ciphertext;\n\t\t\treturn encrypt(await decrypt(ciphertext));\n\t\t},\n\t};\n}\n"],"mappings":"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"}
@@ -33,7 +33,7 @@ function cloneWith(instance, delta) {
33
33
  const next = Object.create(Object.getPrototypeOf(instance));
34
34
  return Object.assign(next, instance, delta);
35
35
  }
36
-
37
36
  //#endregion
38
- export { cloneWith };
39
- //# sourceMappingURL=clone-DblgEZZa.mjs.map
37
+ export { cloneWith as t };
38
+
39
+ //# sourceMappingURL=clone-EKNovYHu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone-EKNovYHu.mjs","names":[],"sources":["../src/clone.ts"],"sourcesContent":["/**\n * Cloning a builder, without enumerating its fields.\n *\n * The builders were mutable singletons that reset themselves by listing every\n * field at the end of `.handle()`. Two things followed from that, and both were\n * real:\n *\n * A configured base could not be reused. `const fn = f.logger(log)` handed back\n * `f` itself, and the first `.handle()` reset `_logger` to the default — so the\n * second handler built from that base silently logged somewhere else. Every\n * field in the reset block behaved the same way, which made\n * `f.logger(l).timeout(60_000)` a base that worked exactly once.\n *\n * And a field left out of the reset list leaked into the next handler instead.\n * `_constructs` was left out, so a function was granted a bucket a *previous*\n * function had declared — an over-grant in the field a deploy reads to size an\n * IAM policy.\n *\n * Both are the same defect: a hand-maintained list of fields that has to be\n * edited every time a field is added, and is silent when it isn't. So this\n * copies whatever the instance actually has, and the list stops existing. The\n * prototype is carried over, so `instanceof` and every method still resolve,\n * and the constructor is deliberately not re-run — this copies state rather\n * than initialising it.\n *\n * Fields must be replaced rather than mutated in place: a clone and its parent\n * share whatever array a field points at, so `_events.push(…)` would be seen by\n * both. Every builder assigns a fresh array instead, which is what makes\n * sharing the reference safe.\n */\nexport function cloneWith<T extends object>(\n\tinstance: T,\n\tdelta: Record<string, unknown>,\n): T {\n\tconst next = Object.create(Object.getPrototypeOf(instance)) as T;\n\n\treturn Object.assign(next, instance, delta);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,UACf,UACA,OACI;CACJ,MAAM,OAAO,OAAO,OAAO,OAAO,eAAe,QAAQ,CAAC;CAE1D,OAAO,OAAO,OAAO,MAAM,UAAU,KAAK;AAC3C"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/clone.ts
3
2
  /**
4
3
  * Cloning a builder, without enumerating its fields.
@@ -34,12 +33,12 @@ function cloneWith(instance, delta) {
34
33
  const next = Object.create(Object.getPrototypeOf(instance));
35
34
  return Object.assign(next, instance, delta);
36
35
  }
37
-
38
36
  //#endregion
39
- Object.defineProperty(exports, 'cloneWith', {
40
- enumerable: true,
41
- get: function () {
42
- return cloneWith;
43
- }
37
+ Object.defineProperty(exports, "cloneWith", {
38
+ enumerable: true,
39
+ get: function() {
40
+ return cloneWith;
41
+ }
44
42
  });
45
- //# sourceMappingURL=clone-Dy0cR2SZ.cjs.map
43
+
44
+ //# sourceMappingURL=clone-UGJpvQnL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone-UGJpvQnL.cjs","names":[],"sources":["../src/clone.ts"],"sourcesContent":["/**\n * Cloning a builder, without enumerating its fields.\n *\n * The builders were mutable singletons that reset themselves by listing every\n * field at the end of `.handle()`. Two things followed from that, and both were\n * real:\n *\n * A configured base could not be reused. `const fn = f.logger(log)` handed back\n * `f` itself, and the first `.handle()` reset `_logger` to the default — so the\n * second handler built from that base silently logged somewhere else. Every\n * field in the reset block behaved the same way, which made\n * `f.logger(l).timeout(60_000)` a base that worked exactly once.\n *\n * And a field left out of the reset list leaked into the next handler instead.\n * `_constructs` was left out, so a function was granted a bucket a *previous*\n * function had declared — an over-grant in the field a deploy reads to size an\n * IAM policy.\n *\n * Both are the same defect: a hand-maintained list of fields that has to be\n * edited every time a field is added, and is silent when it isn't. So this\n * copies whatever the instance actually has, and the list stops existing. The\n * prototype is carried over, so `instanceof` and every method still resolve,\n * and the constructor is deliberately not re-run — this copies state rather\n * than initialising it.\n *\n * Fields must be replaced rather than mutated in place: a clone and its parent\n * share whatever array a field points at, so `_events.push(…)` would be seen by\n * both. Every builder assigns a fresh array instead, which is what makes\n * sharing the reference safe.\n */\nexport function cloneWith<T extends object>(\n\tinstance: T,\n\tdelta: Record<string, unknown>,\n): T {\n\tconst next = Object.create(Object.getPrototypeOf(instance)) as T;\n\n\treturn Object.assign(next, instance, delta);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,UACf,UACA,OACI;CACJ,MAAM,OAAO,OAAO,OAAO,OAAO,eAAe,QAAQ,CAAC;CAE1D,OAAO,OAAO,OAAO,MAAM,UAAU,KAAK;AAC3C"}
@@ -1,8 +1,7 @@
1
+ import { EnvironmentParser } from "@geekmidas/envkit";
1
2
  import { Service } from "@geekmidas/services";
2
3
  import { Declaration, Dependency } from "@geekmidas/manifest";
3
-
4
4
  //#region src/construct-interface.d.ts
5
-
6
5
  /**
7
6
  * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a
8
7
  * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript
@@ -27,8 +26,8 @@ interface Construct<TName extends string = string, TClient = never> {
27
26
  * The consumable face — the address this construct owns, as a client.
28
27
  *
29
28
  * A field assigned once rather than a getter. `Construct.getEnvironment`
30
- * caches by service *object*, and `Topic.publisher` returns a fresh literal
31
- * on every access, so that cache never hits for topics or queues today.
29
+ * and `ServiceDiscovery` cache by service *object*, so a getter returning a
30
+ * fresh literal on every access would never hit either cache.
32
31
  */
33
32
  readonly service: [TClient] extends [never] ? never : Service<Uncapitalize<TName>, TClient>;
34
33
  }
@@ -45,6 +44,17 @@ interface Declarable<TName extends string = string> {
45
44
  readonly id: TName;
46
45
  declare(): Declaration[];
47
46
  }
47
+ /**
48
+ * A construct that authenticates requests — what `RestApi.auth()` takes.
49
+ *
50
+ * `verify` is the one thing every provider shares: given a request's headers,
51
+ * whose request is it — the session, or `null` when there is none. Whether the
52
+ * provider is a server mounted beside the API, deployed elsewhere, or an issuer
53
+ * somebody else runs is its own business; a surface only ever asks this.
54
+ */
55
+ interface Authenticator<TSession = unknown> extends Declarable {
56
+ verify(headers: Headers, envParser: EnvironmentParser<{}>): Promise<TSession | null>;
57
+ }
48
58
  /**
49
59
  * The edge that points at a construct.
50
60
  *
@@ -85,7 +95,7 @@ interface Consumable<TName extends string = string, TClient = unknown> {
85
95
  * both keys — the same machinery `.services()` already uses, which is why
86
96
  * `dependsOn` needs no type plumbing of its own.
87
97
  */
88
- type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service'] };
98
+ type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service']; };
89
99
  /**
90
100
  * The services of a list of constructs, at runtime.
91
101
  *
@@ -104,6 +114,28 @@ declare function servicesOf<const T extends readonly Consumable[]>(constructs: T
104
114
  * calls accumulate the way `.services()` already does.
105
115
  */
106
116
  declare function idsOf(constructs: readonly Consumable[], existing?: readonly string[]): string[];
117
+ /**
118
+ * The edges after `.database(source)` names a builder's database.
119
+ *
120
+ * A database replaces the one before it — a worker's default, overridden by a
121
+ * runnable that names its own — so the edge the previous one added goes with
122
+ * it. Left behind, a Lambda built from a queue that moved to another database
123
+ * would still be granted the worker's.
124
+ *
125
+ * Only an edge `.database()` added is removed, which is why it is returned as
126
+ * `_databaseEdge` for the next call to read — and not even that one when
127
+ * `.dependsOn()` has since named the same construct, since the handler still
128
+ * reaches it through `services`.
129
+ */
130
+ declare function databaseEdges(current: {
131
+ constructs: readonly string[];
132
+ edge: string | undefined;
133
+ service: Service | undefined;
134
+ services: readonly Service[];
135
+ }, source: unknown): {
136
+ _constructs: string[];
137
+ _databaseEdge: string | undefined;
138
+ };
107
139
  /** Something that is not a construct was passed to `.dependsOn()`. */
108
140
  declare class NotAConstruct extends Error {
109
141
  readonly value: unknown;
@@ -120,12 +152,11 @@ declare function isConsumable(value: unknown): value is Consumable;
120
152
  /**
121
153
  * The service behind either face.
122
154
  *
123
- * `.database()` and the publisher slots take a construct now; they took a
124
- * `Service` before and still do, because a hand-written one is exactly what
125
- * `Construct.fromService` exists to lift and not everything has been lifted.
155
+ * `.database()` and the auditor slot take a construct now; they took a
156
+ * `Service` before and still do, because not every hand-written service has a
157
+ * construct to stand for it.
126
158
  */
127
159
  declare function serviceOf<TName extends string, TClient>(source: Consumable<TName, TClient> | Service<TName, TClient>): Service<TName, TClient>;
128
- //# sourceMappingURL=construct-interface.d.ts.map
129
160
  //#endregion
130
- export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
131
- //# sourceMappingURL=construct-interface-D9d4Gm4p.d.cts.map
161
+ export { Infer as a, ServicesOf as c, idsOf as d, isConsumable as f, Declarable as i, databaseEdges as l, servicesOf as m, Construct as n, NameOf as o, serviceOf as p, Consumable as r, NotAConstruct as s, Authenticator as t, edgeTo as u };
162
+ //# sourceMappingURL=construct-interface-B1AfqRl4.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"construct-interface-B1AfqRl4.d.cts","names":[],"sources":["../src/construct-interface.ts"],"mappings":";;;;;;;;;;;;;UA8BiB,UAAU,+BAA+B;;WAEhD,IAAI;;;;;;;;EASb,WAAW;;;;;;;;WASF,UAAU,mCAEhB,QAAQ,aAAa,QAAQ;;;;;;;;;;;UAYhB,WAAW;WAClB,IAAI;EACb,WAAW;;;;;;;;;;UAWK,cAAc,4BAA4B;EAC1D,OACC,SAAS,SACT,WAAW,wBACT,QAAQ;;;;;;;;;;;;;;iBAeI,OAAO,WAAW,aAAa;;KAWnC,MAAM,KACjB,UAAU,wBAAwB,WAAW;;KAGlC,OAAO,KAClB,UAAU,gBAAgB,kBAAkB;;;;;;;;;;;UAY5B,WAAW,+BAA+B;WACjD,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;EAC/C,WAAW;;;;;;;;;;KAWA,WAAW,mBAAmB,mBACxC,WAAW,IAAI,EAAE;;;;;;;;iBAUH,iBAAiB,mBAAmB,cACnD,YAAY,IACV,WAAW;;;;;;;;;;iBAiBE,MACf,qBAAqB,cACrB;;;;;;;;;;;;;;iBAkBe,cACf;EACC;EACA;EACA,SAAS;EACT,mBAAmB;GAEpB;EACI;EAAuB;;;cAgBf,sBAAsB;WACb;EAArB,YAAqB;;;;;;;;;iBAqBN,aAAa,iBAAiB,SAAS;;;;;;;;iBAmBvC,UAAU,sBAAsB,SAC/C,QAAQ,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO"}
@@ -1,8 +1,7 @@
1
1
  import { Declaration, Dependency } from "@geekmidas/manifest";
2
+ import { EnvironmentParser } from "@geekmidas/envkit";
2
3
  import { Service } from "@geekmidas/services";
3
-
4
4
  //#region src/construct-interface.d.ts
5
-
6
5
  /**
7
6
  * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a
8
7
  * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript
@@ -27,8 +26,8 @@ interface Construct<TName extends string = string, TClient = never> {
27
26
  * The consumable face — the address this construct owns, as a client.
28
27
  *
29
28
  * A field assigned once rather than a getter. `Construct.getEnvironment`
30
- * caches by service *object*, and `Topic.publisher` returns a fresh literal
31
- * on every access, so that cache never hits for topics or queues today.
29
+ * and `ServiceDiscovery` cache by service *object*, so a getter returning a
30
+ * fresh literal on every access would never hit either cache.
32
31
  */
33
32
  readonly service: [TClient] extends [never] ? never : Service<Uncapitalize<TName>, TClient>;
34
33
  }
@@ -45,6 +44,17 @@ interface Declarable<TName extends string = string> {
45
44
  readonly id: TName;
46
45
  declare(): Declaration[];
47
46
  }
47
+ /**
48
+ * A construct that authenticates requests — what `RestApi.auth()` takes.
49
+ *
50
+ * `verify` is the one thing every provider shares: given a request's headers,
51
+ * whose request is it — the session, or `null` when there is none. Whether the
52
+ * provider is a server mounted beside the API, deployed elsewhere, or an issuer
53
+ * somebody else runs is its own business; a surface only ever asks this.
54
+ */
55
+ interface Authenticator<TSession = unknown> extends Declarable {
56
+ verify(headers: Headers, envParser: EnvironmentParser<{}>): Promise<TSession | null>;
57
+ }
48
58
  /**
49
59
  * The edge that points at a construct.
50
60
  *
@@ -85,7 +95,7 @@ interface Consumable<TName extends string = string, TClient = unknown> {
85
95
  * both keys — the same machinery `.services()` already uses, which is why
86
96
  * `dependsOn` needs no type plumbing of its own.
87
97
  */
88
- type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service'] };
98
+ type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service']; };
89
99
  /**
90
100
  * The services of a list of constructs, at runtime.
91
101
  *
@@ -104,6 +114,28 @@ declare function servicesOf<const T extends readonly Consumable[]>(constructs: T
104
114
  * calls accumulate the way `.services()` already does.
105
115
  */
106
116
  declare function idsOf(constructs: readonly Consumable[], existing?: readonly string[]): string[];
117
+ /**
118
+ * The edges after `.database(source)` names a builder's database.
119
+ *
120
+ * A database replaces the one before it — a worker's default, overridden by a
121
+ * runnable that names its own — so the edge the previous one added goes with
122
+ * it. Left behind, a Lambda built from a queue that moved to another database
123
+ * would still be granted the worker's.
124
+ *
125
+ * Only an edge `.database()` added is removed, which is why it is returned as
126
+ * `_databaseEdge` for the next call to read — and not even that one when
127
+ * `.dependsOn()` has since named the same construct, since the handler still
128
+ * reaches it through `services`.
129
+ */
130
+ declare function databaseEdges(current: {
131
+ constructs: readonly string[];
132
+ edge: string | undefined;
133
+ service: Service | undefined;
134
+ services: readonly Service[];
135
+ }, source: unknown): {
136
+ _constructs: string[];
137
+ _databaseEdge: string | undefined;
138
+ };
107
139
  /** Something that is not a construct was passed to `.dependsOn()`. */
108
140
  declare class NotAConstruct extends Error {
109
141
  readonly value: unknown;
@@ -120,12 +152,11 @@ declare function isConsumable(value: unknown): value is Consumable;
120
152
  /**
121
153
  * The service behind either face.
122
154
  *
123
- * `.database()` and the publisher slots take a construct now; they took a
124
- * `Service` before and still do, because a hand-written one is exactly what
125
- * `Construct.fromService` exists to lift and not everything has been lifted.
155
+ * `.database()` and the auditor slot take a construct now; they took a
156
+ * `Service` before and still do, because not every hand-written service has a
157
+ * construct to stand for it.
126
158
  */
127
159
  declare function serviceOf<TName extends string, TClient>(source: Consumable<TName, TClient> | Service<TName, TClient>): Service<TName, TClient>;
128
- //# sourceMappingURL=construct-interface.d.ts.map
129
160
  //#endregion
130
- export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
131
- //# sourceMappingURL=construct-interface-g5GM5pwR.d.mts.map
161
+ export { Infer as a, ServicesOf as c, idsOf as d, isConsumable as f, Declarable as i, databaseEdges as l, servicesOf as m, Construct as n, NameOf as o, serviceOf as p, Consumable as r, NotAConstruct as s, Authenticator as t, edgeTo as u };
162
+ //# sourceMappingURL=construct-interface-DluK3_da.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"construct-interface-DluK3_da.d.mts","names":[],"sources":["../src/construct-interface.ts"],"mappings":";;;;;;;;;;;;;UA8BiB,UAAU,+BAA+B;;WAEhD,IAAI;;;;;;;;EASb,WAAW;;;;;;;;WASF,UAAU,mCAEhB,QAAQ,aAAa,QAAQ;;;;;;;;;;;UAYhB,WAAW;WAClB,IAAI;EACb,WAAW;;;;;;;;;;UAWK,cAAc,4BAA4B;EAC1D,OACC,SAAS,SACT,WAAW,wBACT,QAAQ;;;;;;;;;;;;;;iBAeI,OAAO,WAAW,aAAa;;KAWnC,MAAM,KACjB,UAAU,wBAAwB,WAAW;;KAGlC,OAAO,KAClB,UAAU,gBAAgB,kBAAkB;;;;;;;;;;;UAY5B,WAAW,+BAA+B;WACjD,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;EAC/C,WAAW;;;;;;;;;;KAWA,WAAW,mBAAmB,mBACxC,WAAW,IAAI,EAAE;;;;;;;;iBAUH,iBAAiB,mBAAmB,cACnD,YAAY,IACV,WAAW;;;;;;;;;;iBAiBE,MACf,qBAAqB,cACrB;;;;;;;;;;;;;;iBAkBe,cACf;EACC;EACA;EACA,SAAS;EACT,mBAAmB;GAEpB;EACI;EAAuB;;;cAgBf,sBAAsB;WACb;EAArB,YAAqB;;;;;;;;;iBAqBN,aAAa,iBAAiB,SAAS;;;;;;;;iBAmBvC,UAAU,sBAAsB,SAC/C,QAAQ,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO"}