@geekmidas/constructs 10.0.0-alpha.18 → 10.0.0-alpha.181

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 (485) hide show
  1. package/README.md +246 -158
  2. package/dist/Construct-127M7yrl.d.cts +231 -0
  3. package/dist/Construct-127M7yrl.d.cts.map +1 -0
  4. package/dist/Construct-BMk_CRSD.d.mts +231 -0
  5. package/dist/Construct-BMk_CRSD.d.mts.map +1 -0
  6. package/dist/{Construct-BeYVu_QF.mjs → Construct-CGuc_Ijk.mjs} +8 -9
  7. package/dist/Construct-CGuc_Ijk.mjs.map +1 -0
  8. package/dist/{Construct-DqdlARxq.cjs → Construct-DorKS0Ua.cjs} +8 -9
  9. package/dist/Construct-DorKS0Ua.cjs.map +1 -0
  10. package/dist/{Cron-l4Wlz6G9.d.mts → Cron-BcA8F0S-.d.cts} +16 -9
  11. package/dist/Cron-BcA8F0S-.d.cts.map +1 -0
  12. package/dist/{Cron-zsoSAwZo.d.cts → Cron-z2CiuQT_.d.mts} +15 -8
  13. package/dist/Cron-z2CiuQT_.d.mts.map +1 -0
  14. package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
  15. package/dist/CronBuilder-BJ5LoadF.mjs.map +1 -0
  16. package/dist/CronBuilder-BZvo34X2.d.cts +47 -0
  17. package/dist/CronBuilder-BZvo34X2.d.cts.map +1 -0
  18. package/dist/{CronBuilder-BdnI6lxF.cjs → CronBuilder-B_NSP-Y5.cjs} +27 -10
  19. package/dist/CronBuilder-B_NSP-Y5.cjs.map +1 -0
  20. package/dist/CronBuilder-BbgKo8OI.d.mts +47 -0
  21. package/dist/CronBuilder-BbgKo8OI.d.mts.map +1 -0
  22. package/dist/Endpoint-52z1P0Ue.cjs +581 -0
  23. package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
  24. package/dist/{Endpoint-oS-Fe3d_.d.mts → Endpoint-CIDUreMW.d.mts} +104 -23
  25. package/dist/Endpoint-CIDUreMW.d.mts.map +1 -0
  26. package/dist/{Endpoint-DBflWAe4.d.cts → Endpoint-COisi9jw.d.cts} +101 -20
  27. package/dist/Endpoint-COisi9jw.d.cts.map +1 -0
  28. package/dist/Endpoint-sUOU7uLx.mjs +552 -0
  29. package/dist/Endpoint-sUOU7uLx.mjs.map +1 -0
  30. package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
  31. package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
  32. package/dist/{index-Cc4kKPag.d.mts → EndpointFactory-CIM80WIK.d.mts} +189 -106
  33. package/dist/EndpointFactory-CIM80WIK.d.mts.map +1 -0
  34. package/dist/{index-C1ZwNOOk.d.cts → EndpointFactory-CfBg6jJE.d.cts} +187 -104
  35. package/dist/EndpointFactory-CfBg6jJE.d.cts.map +1 -0
  36. package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
  37. package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
  38. package/dist/Function-BIEsY0Hm.d.cts +76 -0
  39. package/dist/Function-BIEsY0Hm.d.cts.map +1 -0
  40. package/dist/Function-BKReud5p.d.mts +76 -0
  41. package/dist/Function-BKReud5p.d.mts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-92zavCsV.cjs → HonoEndpointAdaptor-BTbqfSaa.cjs} +115 -41
  43. package/dist/HonoEndpointAdaptor-BTbqfSaa.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-CBVey2cY.mjs} +112 -38
  45. package/dist/HonoEndpointAdaptor-CBVey2cY.mjs.map +1 -0
  46. package/dist/ObjectSubscriberBuilder-Ci_Cc-WZ.d.mts +129 -0
  47. package/dist/ObjectSubscriberBuilder-Ci_Cc-WZ.d.mts.map +1 -0
  48. package/dist/ObjectSubscriberBuilder-DWtLxfAJ.d.cts +129 -0
  49. package/dist/ObjectSubscriberBuilder-DWtLxfAJ.d.cts.map +1 -0
  50. package/dist/ProcessorBuilder-CdLwJK4k.d.mts +216 -0
  51. package/dist/ProcessorBuilder-CdLwJK4k.d.mts.map +1 -0
  52. package/dist/ProcessorBuilder-ClD7tmEe.d.cts +216 -0
  53. package/dist/ProcessorBuilder-ClD7tmEe.d.cts.map +1 -0
  54. package/dist/Queue-9Hh20ZCk.mjs +104 -0
  55. package/dist/Queue-9Hh20ZCk.mjs.map +1 -0
  56. package/dist/{Queue-D9X6OoON.d.mts → Queue-B8HGg439.d.mts} +42 -41
  57. package/dist/Queue-B8HGg439.d.mts.map +1 -0
  58. package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
  59. package/dist/Queue-C4rijiM7.d.cts.map +1 -0
  60. package/dist/Queue-W1wueijP.cjs +109 -0
  61. package/dist/Queue-W1wueijP.cjs.map +1 -0
  62. package/dist/QueueBuilder-BDcv9B71.cjs +135 -0
  63. package/dist/QueueBuilder-BDcv9B71.cjs.map +1 -0
  64. package/dist/QueueBuilder-CjULiiDN.d.mts +75 -0
  65. package/dist/QueueBuilder-CjULiiDN.d.mts.map +1 -0
  66. package/dist/QueueBuilder-CrZL8HHs.mjs +118 -0
  67. package/dist/QueueBuilder-CrZL8HHs.mjs.map +1 -0
  68. package/dist/QueueBuilder-Dacm9qAv.d.cts +75 -0
  69. package/dist/QueueBuilder-Dacm9qAv.d.cts.map +1 -0
  70. package/dist/Subscriber-5rCX1Nph.d.cts +83 -0
  71. package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
  72. package/dist/Subscriber-CtQXhcL7.d.mts +83 -0
  73. package/dist/Subscriber-CtQXhcL7.d.mts.map +1 -0
  74. package/dist/SubscriberBuilder-CpFhShTJ.mjs +238 -0
  75. package/dist/SubscriberBuilder-CpFhShTJ.mjs.map +1 -0
  76. package/dist/SubscriberBuilder-DJEvNRdD.cjs +261 -0
  77. package/dist/SubscriberBuilder-DJEvNRdD.cjs.map +1 -0
  78. package/dist/Topic-BGoOeCT6.mjs +99 -0
  79. package/dist/Topic-BGoOeCT6.mjs.map +1 -0
  80. package/dist/Topic-DLCZBNwK.cjs +104 -0
  81. package/dist/Topic-DLCZBNwK.cjs.map +1 -0
  82. package/dist/adaptors/aws.cjs +147 -168
  83. package/dist/adaptors/aws.cjs.map +1 -1
  84. package/dist/adaptors/aws.d.cts +57 -48
  85. package/dist/adaptors/aws.d.cts.map +1 -1
  86. package/dist/adaptors/aws.d.mts +58 -49
  87. package/dist/adaptors/aws.d.mts.map +1 -1
  88. package/dist/adaptors/aws.mjs +142 -164
  89. package/dist/adaptors/aws.mjs.map +1 -1
  90. package/dist/adaptors/awsWebsocket.cjs +354 -0
  91. package/dist/adaptors/awsWebsocket.cjs.map +1 -0
  92. package/dist/adaptors/awsWebsocket.d.cts +156 -0
  93. package/dist/adaptors/awsWebsocket.d.cts.map +1 -0
  94. package/dist/adaptors/awsWebsocket.d.mts +156 -0
  95. package/dist/adaptors/awsWebsocket.d.mts.map +1 -0
  96. package/dist/adaptors/awsWebsocket.mjs +347 -0
  97. package/dist/adaptors/awsWebsocket.mjs.map +1 -0
  98. package/dist/adaptors/hono.cjs +1 -1
  99. package/dist/adaptors/hono.d.cts +8 -7
  100. package/dist/adaptors/hono.d.cts.map +1 -1
  101. package/dist/adaptors/hono.d.mts +10 -9
  102. package/dist/adaptors/hono.d.mts.map +1 -1
  103. package/dist/adaptors/hono.mjs +1 -1
  104. package/dist/adaptors/testing.cjs +1174 -41
  105. package/dist/adaptors/testing.cjs.map +1 -1
  106. package/dist/adaptors/testing.d.cts +517 -40
  107. package/dist/adaptors/testing.d.cts.map +1 -1
  108. package/dist/adaptors/testing.d.mts +517 -40
  109. package/dist/adaptors/testing.d.mts.map +1 -1
  110. package/dist/adaptors/testing.mjs +1140 -36
  111. package/dist/adaptors/testing.mjs.map +1 -1
  112. package/dist/auth-CutSfNlr.d.mts +274 -0
  113. package/dist/auth-CutSfNlr.d.mts.map +1 -0
  114. package/dist/auth-b9ADezz9.d.cts +274 -0
  115. package/dist/auth-b9ADezz9.d.cts.map +1 -0
  116. package/dist/auth.cjs +311 -26
  117. package/dist/auth.cjs.map +1 -1
  118. package/dist/auth.d.cts +2 -104
  119. package/dist/auth.d.mts +2 -104
  120. package/dist/auth.mjs +307 -28
  121. package/dist/auth.mjs.map +1 -1
  122. package/dist/cache-9wLNSy3O.d.cts +44 -0
  123. package/dist/cache-9wLNSy3O.d.cts.map +1 -0
  124. package/dist/cache-BFPs_CGs.d.mts +44 -0
  125. package/dist/cache-BFPs_CGs.d.mts.map +1 -0
  126. package/dist/cache.cjs +4 -20
  127. package/dist/cache.cjs.map +1 -1
  128. package/dist/cache.d.cts +2 -43
  129. package/dist/cache.d.mts +2 -43
  130. package/dist/cache.mjs +4 -20
  131. package/dist/cache.mjs.map +1 -1
  132. package/dist/cipher-C1lEFX63.mjs +225 -0
  133. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  134. package/dist/cipher-CVxfwLjk.cjs +332 -0
  135. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  136. package/dist/cipher-DSDxPRIp.d.cts +106 -0
  137. package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
  138. package/dist/cipher-DSDxPRIp.d.mts +106 -0
  139. package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
  140. package/dist/{construct-interface-DPlxfpoS.d.mts → construct-interface-CVoejIpo.d.cts} +79 -8
  141. package/dist/construct-interface-CVoejIpo.d.cts.map +1 -0
  142. package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-Nw5Dt9AC.d.mts} +79 -8
  143. package/dist/construct-interface-Nw5Dt9AC.d.mts.map +1 -0
  144. package/dist/construct-interface.cjs +62 -4
  145. package/dist/construct-interface.cjs.map +1 -1
  146. package/dist/construct-interface.d.cts +2 -2
  147. package/dist/construct-interface.d.mts +2 -2
  148. package/dist/construct-interface.mjs +59 -5
  149. package/dist/construct-interface.mjs.map +1 -1
  150. package/dist/credential-B80mOxwT.mjs +222 -0
  151. package/dist/credential-B80mOxwT.mjs.map +1 -0
  152. package/dist/credential-RlgbzZAc.cjs +257 -0
  153. package/dist/credential-RlgbzZAc.cjs.map +1 -0
  154. package/dist/credential.cjs +7 -129
  155. package/dist/credential.d.cts +2 -58
  156. package/dist/credential.d.mts +2 -58
  157. package/dist/credential.mjs +2 -128
  158. package/dist/crons/index.cjs +127 -1
  159. package/dist/crons/index.cjs.map +1 -1
  160. package/dist/crons/index.d.cts +43 -3
  161. package/dist/crons/index.d.cts.map +1 -1
  162. package/dist/crons/index.d.mts +43 -3
  163. package/dist/crons/index.d.mts.map +1 -1
  164. package/dist/crons/index.mjs +126 -2
  165. package/dist/crons/index.mjs.map +1 -1
  166. package/dist/database/kysely.cjs +3 -194
  167. package/dist/database/kysely.d.cts +2 -149
  168. package/dist/database/kysely.d.mts +2 -149
  169. package/dist/database/kysely.mjs +2 -192
  170. package/dist/email.cjs +24 -17
  171. package/dist/email.cjs.map +1 -1
  172. package/dist/email.d.cts +15 -5
  173. package/dist/email.d.cts.map +1 -1
  174. package/dist/email.d.mts +16 -6
  175. package/dist/email.d.mts.map +1 -1
  176. package/dist/email.mjs +23 -17
  177. package/dist/email.mjs.map +1 -1
  178. package/dist/encryption/kms.cjs +95 -0
  179. package/dist/encryption/kms.cjs.map +1 -0
  180. package/dist/encryption/kms.d.cts +7 -0
  181. package/dist/encryption/kms.d.cts.map +1 -0
  182. package/dist/encryption/kms.d.mts +7 -0
  183. package/dist/encryption/kms.d.mts.map +1 -0
  184. package/dist/encryption/kms.mjs +93 -0
  185. package/dist/encryption/kms.mjs.map +1 -0
  186. package/dist/encryption.cjs +116 -0
  187. package/dist/encryption.cjs.map +1 -0
  188. package/dist/encryption.d.cts +37 -0
  189. package/dist/encryption.d.cts.map +1 -0
  190. package/dist/encryption.d.mts +37 -0
  191. package/dist/encryption.d.mts.map +1 -0
  192. package/dist/encryption.mjs +101 -0
  193. package/dist/encryption.mjs.map +1 -0
  194. package/dist/endpoints/index.cjs +32 -10
  195. package/dist/endpoints/index.d.cts +106 -3
  196. package/dist/endpoints/index.d.cts.map +1 -0
  197. package/dist/endpoints/index.d.mts +106 -3
  198. package/dist/endpoints/index.d.mts.map +1 -0
  199. package/dist/endpoints/index.mjs +6 -4
  200. package/dist/expire-C586zznE.d.cts +38 -0
  201. package/dist/expire-C586zznE.d.cts.map +1 -0
  202. package/dist/expire-C586zznE.d.mts +38 -0
  203. package/dist/expire-C586zznE.d.mts.map +1 -0
  204. package/dist/external-api.cjs +106 -0
  205. package/dist/external-api.cjs.map +1 -0
  206. package/dist/external-api.d.cts +2 -0
  207. package/dist/external-api.d.mts +2 -0
  208. package/dist/external-api.mjs +103 -0
  209. package/dist/external-api.mjs.map +1 -0
  210. package/dist/fake-JI5uN1SF.d.cts +201 -0
  211. package/dist/fake-JI5uN1SF.d.cts.map +1 -0
  212. package/dist/fake-zpuXpBmY.d.mts +201 -0
  213. package/dist/fake-zpuXpBmY.d.mts.map +1 -0
  214. package/dist/file-server.cjs +170 -49
  215. package/dist/file-server.cjs.map +1 -1
  216. package/dist/file-server.d.cts +148 -16
  217. package/dist/file-server.d.cts.map +1 -1
  218. package/dist/file-server.d.mts +148 -16
  219. package/dist/file-server.d.mts.map +1 -1
  220. package/dist/file-server.mjs +168 -51
  221. package/dist/file-server.mjs.map +1 -1
  222. package/dist/functions/index.cjs +1 -1
  223. package/dist/functions/index.d.cts +2 -1
  224. package/dist/functions/index.d.mts +2 -1
  225. package/dist/functions/index.mjs +1 -1
  226. package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
  227. package/dist/functions-BvIDQKAA.mjs.map +1 -0
  228. package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
  229. package/dist/functions-DLF6-IK8.cjs.map +1 -0
  230. package/dist/inbox-CXLU7h_8.d.cts +195 -0
  231. package/dist/inbox-CXLU7h_8.d.cts.map +1 -0
  232. package/dist/inbox-DYFsLd9A.d.mts +195 -0
  233. package/dist/inbox-DYFsLd9A.d.mts.map +1 -0
  234. package/dist/inbox.cjs +291 -0
  235. package/dist/inbox.cjs.map +1 -0
  236. package/dist/inbox.d.cts +2 -0
  237. package/dist/inbox.d.mts +2 -0
  238. package/dist/inbox.mjs +283 -0
  239. package/dist/inbox.mjs.map +1 -0
  240. package/dist/index-BpE9_6l5.d.mts +115 -0
  241. package/dist/index-BpE9_6l5.d.mts.map +1 -0
  242. package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
  243. package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
  244. package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
  245. package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
  246. package/dist/index-zRChehJ9.d.cts +115 -0
  247. package/dist/index-zRChehJ9.d.cts.map +1 -0
  248. package/dist/index.cjs +4 -1
  249. package/dist/index.d.cts +26 -3
  250. package/dist/index.d.cts.map +1 -0
  251. package/dist/index.d.mts +26 -3
  252. package/dist/index.d.mts.map +1 -0
  253. package/dist/index.mjs +3 -2
  254. package/dist/kysely-5PAqFBzo.d.mts +216 -0
  255. package/dist/kysely-5PAqFBzo.d.mts.map +1 -0
  256. package/dist/kysely-Bc9xzaik.mjs +371 -0
  257. package/dist/kysely-Bc9xzaik.mjs.map +1 -0
  258. package/dist/kysely-D7f6J2lh.cjs +384 -0
  259. package/dist/kysely-D7f6J2lh.cjs.map +1 -0
  260. package/dist/kysely-lxNUBSTP.d.cts +216 -0
  261. package/dist/kysely-lxNUBSTP.d.cts.map +1 -0
  262. package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
  263. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  264. package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
  265. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  266. package/dist/mobile-app.cjs +79 -0
  267. package/dist/mobile-app.cjs.map +1 -0
  268. package/dist/mobile-app.d.cts +78 -0
  269. package/dist/mobile-app.d.cts.map +1 -0
  270. package/dist/mobile-app.d.mts +78 -0
  271. package/dist/mobile-app.d.mts.map +1 -0
  272. package/dist/mobile-app.mjs +78 -0
  273. package/dist/mobile-app.mjs.map +1 -0
  274. package/dist/object-storage.cjs +50 -7
  275. package/dist/object-storage.cjs.map +1 -1
  276. package/dist/object-storage.d.cts +37 -3
  277. package/dist/object-storage.d.cts.map +1 -1
  278. package/dist/object-storage.d.mts +37 -3
  279. package/dist/object-storage.d.mts.map +1 -1
  280. package/dist/object-storage.mjs +49 -9
  281. package/dist/object-storage.mjs.map +1 -1
  282. package/dist/optionalPeers-D7Wt6dnF.mjs +140 -0
  283. package/dist/optionalPeers-D7Wt6dnF.mjs.map +1 -0
  284. package/dist/optionalPeers-DuNQXXe1.cjs +223 -0
  285. package/dist/optionalPeers-DuNQXXe1.cjs.map +1 -0
  286. package/dist/origins-BjxYht13.cjs +96 -0
  287. package/dist/origins-BjxYht13.cjs.map +1 -0
  288. package/dist/origins-Boc9qbo-.mjs +73 -0
  289. package/dist/origins-Boc9qbo-.mjs.map +1 -0
  290. package/dist/pattern-C1CEcglD.mjs +241 -0
  291. package/dist/pattern-C1CEcglD.mjs.map +1 -0
  292. package/dist/pattern-QFaUIr77.cjs +288 -0
  293. package/dist/pattern-QFaUIr77.cjs.map +1 -0
  294. package/dist/privateAddress-Bg5fUsbp.mjs +21 -0
  295. package/dist/privateAddress-Bg5fUsbp.mjs.map +1 -0
  296. package/dist/privateAddress-CqGyuFHn.cjs +26 -0
  297. package/dist/privateAddress-CqGyuFHn.cjs.map +1 -0
  298. package/dist/processors/index.cjs +214 -0
  299. package/dist/processors/index.cjs.map +1 -0
  300. package/dist/processors/index.d.cts +78 -0
  301. package/dist/processors/index.d.cts.map +1 -0
  302. package/dist/processors/index.d.mts +78 -0
  303. package/dist/processors/index.d.mts.map +1 -0
  304. package/dist/processors/index.mjs +193 -0
  305. package/dist/processors/index.mjs.map +1 -0
  306. package/dist/queue/index.cjs +5 -192
  307. package/dist/queue/index.d.cts +3 -53
  308. package/dist/queue/index.d.mts +3 -53
  309. package/dist/queue/index.mjs +3 -190
  310. package/dist/random-password.cjs +86 -0
  311. package/dist/random-password.cjs.map +1 -0
  312. package/dist/random-password.d.cts +30 -0
  313. package/dist/random-password.d.cts.map +1 -0
  314. package/dist/random-password.d.mts +30 -0
  315. package/dist/random-password.d.mts.map +1 -0
  316. package/dist/random-password.mjs +84 -0
  317. package/dist/random-password.mjs.map +1 -0
  318. package/dist/readOnlyStorage-C7bCe-z5.cjs +101 -0
  319. package/dist/readOnlyStorage-C7bCe-z5.cjs.map +1 -0
  320. package/dist/readOnlyStorage-DMCeLuS2.mjs +78 -0
  321. package/dist/readOnlyStorage-DMCeLuS2.mjs.map +1 -0
  322. package/dist/readRequestBody-BmKnPl0a.mjs +293 -0
  323. package/dist/readRequestBody-BmKnPl0a.mjs.map +1 -0
  324. package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-CN9GVdeE.cjs} +141 -47
  325. package/dist/readRequestBody-CN9GVdeE.cjs.map +1 -0
  326. package/dist/{processAudits-D_2W5x8k.cjs → requestLogger-CnoYd-Ah.cjs} +63 -3
  327. package/dist/requestLogger-CnoYd-Ah.cjs.map +1 -0
  328. package/dist/{processAudits-BpRlPQMW.mjs → requestLogger-D2JS7pPM.mjs} +51 -3
  329. package/dist/requestLogger-D2JS7pPM.mjs.map +1 -0
  330. package/dist/rest-api.cjs +100 -73
  331. package/dist/rest-api.cjs.map +1 -1
  332. package/dist/rest-api.d.cts +83 -59
  333. package/dist/rest-api.d.cts.map +1 -1
  334. package/dist/rest-api.d.mts +83 -59
  335. package/dist/rest-api.d.mts.map +1 -1
  336. package/dist/rest-api.mjs +97 -76
  337. package/dist/rest-api.mjs.map +1 -1
  338. package/dist/runSubscriber-HEqXkin1.mjs +117 -0
  339. package/dist/runSubscriber-HEqXkin1.mjs.map +1 -0
  340. package/dist/runSubscriber-sVJfLA0-.cjs +134 -0
  341. package/dist/runSubscriber-sVJfLA0-.cjs.map +1 -0
  342. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  343. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  344. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  345. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  346. package/dist/site.cjs +140 -10
  347. package/dist/site.cjs.map +1 -1
  348. package/dist/site.d.cts +156 -3
  349. package/dist/site.d.cts.map +1 -1
  350. package/dist/site.d.mts +156 -3
  351. package/dist/site.d.mts.map +1 -1
  352. package/dist/site.mjs +120 -13
  353. package/dist/site.mjs.map +1 -1
  354. package/dist/stages-DaTaoQei.d.cts +73 -0
  355. package/dist/stages-DaTaoQei.d.cts.map +1 -0
  356. package/dist/stages-DaTaoQei.d.mts +73 -0
  357. package/dist/stages-DaTaoQei.d.mts.map +1 -0
  358. package/dist/subscribers/index.cjs +134 -1
  359. package/dist/subscribers/index.cjs.map +1 -0
  360. package/dist/subscribers/index.d.cts +74 -3
  361. package/dist/subscribers/index.d.cts.map +1 -0
  362. package/dist/subscribers/index.d.mts +74 -3
  363. package/dist/subscribers/index.d.mts.map +1 -0
  364. package/dist/subscribers/index.mjs +132 -2
  365. package/dist/subscribers/index.mjs.map +1 -0
  366. package/dist/telemetry-BbLyS7ln.d.cts +57 -0
  367. package/dist/telemetry-BbLyS7ln.d.cts.map +1 -0
  368. package/dist/telemetry-DWX-qKUh.d.mts +57 -0
  369. package/dist/telemetry-DWX-qKUh.d.mts.map +1 -0
  370. package/dist/telemetry.cjs +64 -0
  371. package/dist/telemetry.cjs.map +1 -0
  372. package/dist/telemetry.d.cts +2 -0
  373. package/dist/telemetry.d.mts +2 -0
  374. package/dist/telemetry.mjs +63 -0
  375. package/dist/telemetry.mjs.map +1 -0
  376. package/dist/topic/index.cjs +2 -134
  377. package/dist/topic/index.d.cts +2 -3
  378. package/dist/topic/index.d.mts +2 -3
  379. package/dist/topic/index.mjs +2 -132
  380. package/dist/tracing-Bbj1uoFJ.mjs +127 -0
  381. package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
  382. package/dist/tracing-C0ooU0V2.cjs +150 -0
  383. package/dist/tracing-C0ooU0V2.cjs.map +1 -0
  384. package/dist/websocket-api-9ndLBolx.d.cts +1207 -0
  385. package/dist/websocket-api-9ndLBolx.d.cts.map +1 -0
  386. package/dist/websocket-api-BPPXF79i.d.mts +1207 -0
  387. package/dist/websocket-api-BPPXF79i.d.mts.map +1 -0
  388. package/dist/websocket-api-C6LGg9-D.mjs +1716 -0
  389. package/dist/websocket-api-C6LGg9-D.mjs.map +1 -0
  390. package/dist/websocket-api-CoKPJJRl.cjs +1895 -0
  391. package/dist/websocket-api-CoKPJJRl.cjs.map +1 -0
  392. package/dist/websocket-api.cjs +42 -0
  393. package/dist/websocket-api.d.cts +2 -0
  394. package/dist/websocket-api.d.mts +2 -0
  395. package/dist/websocket-api.mjs +3 -0
  396. package/dist/worker.cjs +174 -32
  397. package/dist/worker.cjs.map +1 -1
  398. package/dist/worker.d.cts +147 -47
  399. package/dist/worker.d.cts.map +1 -1
  400. package/dist/worker.d.mts +147 -47
  401. package/dist/worker.d.mts.map +1 -1
  402. package/dist/worker.mjs +175 -33
  403. package/dist/worker.mjs.map +1 -1
  404. package/package.json +180 -43
  405. package/dist/Construct-BeYVu_QF.mjs.map +0 -1
  406. package/dist/Construct-DfbwIntp.d.cts +0 -115
  407. package/dist/Construct-DfbwIntp.d.cts.map +0 -1
  408. package/dist/Construct-DqdlARxq.cjs.map +0 -1
  409. package/dist/Construct-l5aOn_jv.d.mts +0 -115
  410. package/dist/Construct-l5aOn_jv.d.mts.map +0 -1
  411. package/dist/Cron-l4Wlz6G9.d.mts.map +0 -1
  412. package/dist/Cron-zsoSAwZo.d.cts.map +0 -1
  413. package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
  414. package/dist/CronBuilder-CyT71Nzg.d.cts +0 -41
  415. package/dist/CronBuilder-CyT71Nzg.d.cts.map +0 -1
  416. package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
  417. package/dist/CronBuilder-UoNgFe8S.d.mts +0 -41
  418. package/dist/CronBuilder-UoNgFe8S.d.mts.map +0 -1
  419. package/dist/Endpoint-BpZHtJ2W.cjs +0 -1689
  420. package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
  421. package/dist/Endpoint-DBflWAe4.d.cts.map +0 -1
  422. package/dist/Endpoint-ONsly_dq.mjs +0 -1671
  423. package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
  424. package/dist/Endpoint-oS-Fe3d_.d.mts.map +0 -1
  425. package/dist/EndpointFactory-Bm3aKRdV.mjs.map +0 -1
  426. package/dist/EndpointFactory-CLvWuHyt.cjs.map +0 -1
  427. package/dist/HonoEndpointAdaptor-92zavCsV.cjs.map +0 -1
  428. package/dist/HonoEndpointAdaptor-yYaU7jVJ.mjs.map +0 -1
  429. package/dist/Queue-D9X6OoON.d.mts.map +0 -1
  430. package/dist/Queue-DYPB2KWL.d.cts.map +0 -1
  431. package/dist/Subscriber-C4heaAyO.d.mts +0 -51
  432. package/dist/Subscriber-C4heaAyO.d.mts.map +0 -1
  433. package/dist/Subscriber-CotDUELC.d.cts +0 -51
  434. package/dist/Subscriber-CotDUELC.d.cts.map +0 -1
  435. package/dist/SubscriberBuilder-BEv0eoHy.d.cts +0 -59
  436. package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +0 -1
  437. package/dist/SubscriberBuilder-C0ZEtGDI.cjs +0 -125
  438. package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +0 -1
  439. package/dist/SubscriberBuilder-h7B_cHMr.mjs +0 -114
  440. package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +0 -1
  441. package/dist/SubscriberBuilder-tyH5yTk5.d.mts +0 -59
  442. package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +0 -1
  443. package/dist/Topic-DEVGo0Dm.d.cts +0 -89
  444. package/dist/Topic-DEVGo0Dm.d.cts.map +0 -1
  445. package/dist/Topic-zk_6Gthr.d.mts +0 -89
  446. package/dist/Topic-zk_6Gthr.d.mts.map +0 -1
  447. package/dist/auth.d.cts.map +0 -1
  448. package/dist/auth.d.mts.map +0 -1
  449. package/dist/cache.d.cts.map +0 -1
  450. package/dist/cache.d.mts.map +0 -1
  451. package/dist/construct-interface-DPlxfpoS.d.mts.map +0 -1
  452. package/dist/construct-interface-DgXTJcOD.d.cts.map +0 -1
  453. package/dist/credential.cjs.map +0 -1
  454. package/dist/credential.d.cts.map +0 -1
  455. package/dist/credential.d.mts.map +0 -1
  456. package/dist/credential.mjs.map +0 -1
  457. package/dist/database/kysely.cjs.map +0 -1
  458. package/dist/database/kysely.d.cts.map +0 -1
  459. package/dist/database/kysely.d.mts.map +0 -1
  460. package/dist/database/kysely.mjs.map +0 -1
  461. package/dist/functions-B6qCvfmy.cjs.map +0 -1
  462. package/dist/functions-C53GW2eQ.mjs.map +0 -1
  463. package/dist/index-B2urf3YI.d.cts +0 -26
  464. package/dist/index-B2urf3YI.d.cts.map +0 -1
  465. package/dist/index-C1ZwNOOk.d.cts.map +0 -1
  466. package/dist/index-Cc4kKPag.d.mts.map +0 -1
  467. package/dist/index-DMCDvnsM.d.mts +0 -26
  468. package/dist/index-DMCDvnsM.d.mts.map +0 -1
  469. package/dist/index-D_frT6MP.d.cts +0 -165
  470. package/dist/index-D_frT6MP.d.cts.map +0 -1
  471. package/dist/index-DcyIYbDS.d.mts +0 -165
  472. package/dist/index-DcyIYbDS.d.mts.map +0 -1
  473. package/dist/lazyAccessors-BHtcqgz2.mjs +0 -211
  474. package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
  475. package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
  476. package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
  477. package/dist/processAudits-D_2W5x8k.cjs.map +0 -1
  478. package/dist/queue/index.cjs.map +0 -1
  479. package/dist/queue/index.d.cts.map +0 -1
  480. package/dist/queue/index.d.mts.map +0 -1
  481. package/dist/queue/index.mjs.map +0 -1
  482. package/dist/telemetry-DGcFlVpB.d.cts.map +0 -1
  483. package/dist/telemetry-DGcFlVpB.d.mts.map +0 -1
  484. package/dist/topic/index.cjs.map +0 -1
  485. package/dist/topic/index.mjs.map +0 -1
package/dist/email.cjs CHANGED
@@ -1,20 +1,23 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_optionalPeers = require("./optionalPeers-DuNQXXe1.cjs");
2
3
  let _geekmidas_manifest = require("@geekmidas/manifest");
3
- let _geekmidas_emailkit = require("@geekmidas/emailkit");
4
4
  //#region src/email.ts
5
5
  /**
6
- * `Email` — declared outbound mail.
7
- *
8
- * The same three-package meeting point as `ObjectStorage`: it implements the
9
- * construct contract, derives its env key through `@geekmidas/manifest`, and
10
- * hands back an `@geekmidas/emailkit` client. It names no provider — locally the
11
- * injected URL points at Mailpit, deployed it points at SES or whichever service
12
- * config selected.
13
- *
14
- * Where object storage needs a driver per provider, this needs none: mail is
15
- * delivered over SMTP whoever delivers it, so there is one client and one URL
16
- * shape, and the provider survives only as a host and a credential.
6
+ * The address-shaped characters a local part may hold: the dot-atom of RFC
7
+ * 5322, which is every sender anyone sends from.
17
8
  */
9
+ const LOCAL_PART = /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*$/;
10
+ /** An `Email`'s `from` that is not a bare local part. */
11
+ var EmailFromNotALocalPart = class extends Error {
12
+ id;
13
+ from;
14
+ constructor(id, from) {
15
+ super(from.includes("@") ? `Email '${id}' has from: '${from}', a whole address. 'from' is the local part only — from: '${from.slice(0, from.lastIndexOf("@"))}' sends as that @ the stage's domain. A whole address for one stage is deploy.email.<stage>.from.` : `Email '${id}' has from: '${from}', which is not a mail local part. Set it to what goes before the @, like 'info' or 'noreply'.`);
16
+ this.id = id;
17
+ this.from = from;
18
+ this.name = "EmailFromNotALocalPart";
19
+ }
20
+ };
18
21
  var Email = class {
19
22
  options;
20
23
  id;
@@ -27,10 +30,11 @@ var Email = class {
27
30
  constructor(id, options) {
28
31
  this.options = options;
29
32
  const canonical = (0, _geekmidas_manifest.canonicalId)(id);
33
+ if (options.from !== void 0 && !LOCAL_PART.test(options.from)) throw new EmailFromNotALocalPart(canonical, options.from);
30
34
  this.id = canonical;
31
35
  this.keys = {
32
- url: (0, _geekmidas_manifest.provideKey)(canonical, "url"),
33
- from: (0, _geekmidas_manifest.provideKey)(canonical, "from")
36
+ url: (0, _geekmidas_manifest.providedKeyFor)(canonical, "email", "url"),
37
+ from: (0, _geekmidas_manifest.providedKeyFor)(canonical, "email", "from")
34
38
  };
35
39
  this.service = {
36
40
  serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
@@ -41,7 +45,8 @@ var Email = class {
41
45
  return [{
42
46
  kind: "email",
43
47
  id: this.id,
44
- provides: [this.keys.url, this.keys.from]
48
+ provides: [this.keys.url, this.keys.from],
49
+ ...this.options.from ? { from: this.options.from } : {}
45
50
  }];
46
51
  }
47
52
  /**
@@ -56,8 +61,9 @@ var Email = class {
56
61
  url: get(this.keys.url).string(),
57
62
  from: get(this.keys.from).string()
58
63
  })).parse();
59
- return (0, _geekmidas_emailkit.createEmailClient)({
60
- smtp: (0, _geekmidas_emailkit.parseEmailUrl)(url),
64
+ const { createEmailClient, parseEmailUrl } = await require_optionalPeers.loadEmailkit();
65
+ return createEmailClient({
66
+ smtp: parseEmailUrl(url),
61
67
  templates: this.options.templates,
62
68
  defaults: {
63
69
  from,
@@ -68,5 +74,6 @@ var Email = class {
68
74
  };
69
75
  //#endregion
70
76
  exports.Email = Email;
77
+ exports.EmailFromNotALocalPart = EmailFromNotALocalPart;
71
78
 
72
79
  //# sourceMappingURL=email.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"email.cjs","names":["canonicalId","provideKey","serviceKey","createEmailClient","parseEmailUrl"],"sources":["../src/email.ts"],"sourcesContent":["/**\n * `Email` — declared outbound mail.\n *\n * The same three-package meeting point as `ObjectStorage`: it implements the\n * construct contract, derives its env key through `@geekmidas/manifest`, and\n * hands back an `@geekmidas/emailkit` client. It names no provider — locally the\n * injected URL points at Mailpit, deployed it points at SES or whichever service\n * config selected.\n *\n * Where object storage needs a driver per provider, this needs none: mail is\n * delivered over SMTP whoever delivers it, so there is one client and one URL\n * shape, and the provider survives only as a host and a credential.\n */\n\nimport {\n\tcreateEmailClient,\n\ttype EmailClient,\n\tparseEmailUrl,\n\ttype TemplateRecord,\n} from '@geekmidas/emailkit';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\n\nexport interface EmailOptions<TTemplates extends TemplateRecord> {\n\t/**\n\t * The React templates this app can send.\n\t *\n\t * Structural — they are code, they ship with the handler, and which ones\n\t * exist cannot differ between stages. They are also what types\n\t * `sendTemplate`, so passing them here is what makes the client's call sites\n\t * checkable.\n\t */\n\ttemplates: TTemplates;\n\t/**\n\t * A reply-to address for every send.\n\t *\n\t * `from` is deliberately absent: it belongs to the verified sending domain,\n\t * which is `myapp.test` locally and the real domain deployed, so it arrives\n\t * as stage config rather than being written here.\n\t */\n\treplyTo?: string;\n}\n\nexport class Email<\n\tTName extends string = string,\n\tTTemplates extends TemplateRecord = TemplateRecord,\n> implements Construct<TName, EmailClient<TTemplates>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, EmailClient<TTemplates>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { url: string; from: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: EmailOptions<TTemplates>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\t// The sending identity travels with the URL rather than being a second\n\t\t\t// construct option, for the same reason the URL does: it is the one\n\t\t\t// thing about mail that differs per stage.\n\t\t\tfrom: provideKey(canonical, 'from'),\n\t\t};\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'email',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url, this.keys.from],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the URL the adapter supplied.\n\t *\n\t * No provider branch and no driver lookup — `parseEmailUrl` turns any of\n\t * Mailpit, SES, or Resend into the same transport config, which is the whole\n\t * reason the scheme is always `smtp://`.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<EmailClient<TTemplates>> {\n\t\tconst { url, from } = envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.keys.url).string(),\n\t\t\t\tfrom: get(this.keys.from).string(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\treturn createEmailClient({\n\t\t\tsmtp: parseEmailUrl(url),\n\t\t\ttemplates: this.options.templates,\n\t\t\tdefaults: {\n\t\t\t\tfrom,\n\t\t\t\t...(this.options.replyTo ? { replyTo: this.options.replyTo } : {}),\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkDA,IAAa,QAAb,MAIA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO;GACX,MAAA,GAAKC,oBAAAA,WAAAA,CAAW,WAAW,KAAK;GAIhC,OAAA,GAAMA,oBAAAA,WAAAA,CAAW,WAAW,MAAM;EACnC;EAGA,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI;EACzC,CACD;CACD;;;;;;;;CASA,MAAc,QAAQ,EACrB,aAC4D;EAC5D,MAAM,EAAE,KAAK,SAAS,UACpB,QAAQ,SAAS;GACjB,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,OAAO;GAC/B,MAAM,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,OAAO;EAClC,EAAE,CAAC,CACF,MAAM;EAER,QAAA,GAAOC,oBAAAA,kBAAAA,CAAkB;GACxB,OAAA,GAAMC,oBAAAA,cAAAA,CAAc,GAAG;GACvB,WAAW,KAAK,QAAQ;GACxB,UAAU;IACT;IACA,GAAI,KAAK,QAAQ,UAAU,EAAE,SAAS,KAAK,QAAQ,QAAQ,IAAI,CAAC;GACjE;EACD,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"email.cjs","names":["canonicalId","providedKeyFor","serviceKey","loadEmailkit"],"sources":["../src/email.ts"],"sourcesContent":["/**\n * `Email` — declared outbound mail.\n *\n * The same three-package meeting point as `ObjectStorage`: it implements the\n * construct contract, derives its env key through `@geekmidas/manifest`, and\n * hands back an `@geekmidas/emailkit` client. It names no provider — locally the\n * injected URL points at Mailpit, deployed it points at SES or whichever service\n * config selected.\n *\n * Where object storage needs a driver per provider, this needs none: mail is\n * delivered over SMTP whoever delivers it, so there is one client and one URL\n * shape, and the provider survives only as a host and a credential.\n */\n\nimport type { EmailClient, TemplateRecord } from '@geekmidas/emailkit';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\nimport { loadEmailkit } from './optionalPeers';\n\nexport interface EmailOptions<TTemplates extends TemplateRecord> {\n\t/**\n\t * The React templates this app can send.\n\t *\n\t * Structural — they are code, they ship with the handler, and which ones\n\t * exist cannot differ between stages. They are also what types\n\t * `sendTemplate`, so passing them here is what makes the client's call sites\n\t * checkable.\n\t */\n\ttemplates: TTemplates;\n\t/**\n\t * The local part mail is sent from — `'info'` sends as `info@` the stage's\n\t * domain (`info@localhost` under `gkm dev`). Defaults to `noreply`.\n\t *\n\t * Only the local part: it is structural, the same on every stage, and the\n\t * templates' copy is written for it. The domain is the stage's, so a stage\n\t * whose domain changes sends from the new one. A whole address for one\n\t * stage is `deploy.email.<stage>.from`, which wins over this.\n\t */\n\tfrom?: string;\n\t/** A reply-to address for every send. */\n\treplyTo?: string;\n}\n\n/**\n * The address-shaped characters a local part may hold: the dot-atom of RFC\n * 5322, which is every sender anyone sends from.\n */\nconst LOCAL_PART =\n\t/^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*$/;\n\n/** An `Email`'s `from` that is not a bare local part. */\nexport class EmailFromNotALocalPart extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly from: string,\n\t) {\n\t\tsuper(\n\t\t\tfrom.includes('@')\n\t\t\t\t? `Email '${id}' has from: '${from}', a whole address. 'from' is the local part only — from: '${from.slice(0, from.lastIndexOf('@'))}' sends as that @ the stage's domain. A whole address for one stage is deploy.email.<stage>.from.`\n\t\t\t\t: `Email '${id}' has from: '${from}', which is not a mail local part. Set it to what goes before the @, like 'info' or 'noreply'.`,\n\t\t);\n\t\tthis.name = 'EmailFromNotALocalPart';\n\t}\n}\n\nexport class Email<\n\tTName extends string = string,\n\tTTemplates extends TemplateRecord = TemplateRecord,\n> implements Construct<TName, EmailClient<TTemplates>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, EmailClient<TTemplates>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { url: string; from: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: EmailOptions<TTemplates>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\t\tif (options.from !== undefined && !LOCAL_PART.test(options.from)) {\n\t\t\tthrow new EmailFromNotALocalPart(canonical, options.from);\n\t\t}\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: providedKeyFor(canonical, 'email', 'url'),\n\t\t\t// The whole address arrives with the URL: its domain is the stage's,\n\t\t\t// so only the local part (`options.from`) is written here.\n\t\t\tfrom: providedKeyFor(canonical, 'email', 'from'),\n\t\t};\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'email',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url, this.keys.from],\n\t\t\t\t...(this.options.from ? { from: this.options.from } : {}),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the URL the adapter supplied.\n\t *\n\t * No provider branch and no driver lookup — `parseEmailUrl` turns any of\n\t * Mailpit, SES, or Resend into the same transport config, which is the whole\n\t * reason the scheme is always `smtp://`.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<EmailClient<TTemplates>> {\n\t\tconst { url, from } = envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.keys.url).string(),\n\t\t\t\tfrom: get(this.keys.from).string(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\t// Loaded here, not at the top: the test harness names this construct in\n\t\t// every app, and an app that sends no mail does not install emailkit.\n\t\tconst { createEmailClient, parseEmailUrl } = await loadEmailkit();\n\t\treturn createEmailClient({\n\t\t\tsmtp: parseEmailUrl(url),\n\t\t\ttemplates: this.options.templates,\n\t\t\tdefaults: {\n\t\t\t\tfrom,\n\t\t\t\t...(this.options.replyTo ? { replyTo: this.options.replyTo } : {}),\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;AAsDA,MAAM,aACL;;AAGD,IAAa,yBAAb,cAA4C,MAAM;CAEvC;CACA;CAFV,YACC,IACA,MACC;EACD,MACC,KAAK,SAAS,GAAG,IACd,UAAU,GAAG,eAAe,KAAK,6DAA6D,KAAK,MAAM,GAAG,KAAK,YAAY,GAAG,CAAC,EAAE,qGACnI,UAAU,GAAG,eAAe,KAAK,+FACrC;EAPS,KAAA,KAAA;EACA,KAAA,OAAA;EAOT,KAAK,OAAO;CACb;AACD;AAEA,IAAa,QAAb,MAIA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,aAAA,GAAYA,oBAAAA,YAAAA,CAAY,EAAY;EAC1C,IAAI,QAAQ,SAAS,KAAA,KAAa,CAAC,WAAW,KAAK,QAAQ,IAAI,GAC9D,MAAM,IAAI,uBAAuB,WAAW,QAAQ,IAAI;EAGzD,KAAK,KAAK;EACV,KAAK,OAAO;GACX,MAAA,GAAKC,oBAAAA,eAAAA,CAAe,WAAW,SAAS,KAAK;GAG7C,OAAA,GAAMA,oBAAAA,eAAAA,CAAe,WAAW,SAAS,MAAM;EAChD;EAGA,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI;GACxC,GAAI,KAAK,QAAQ,OAAO,EAAE,MAAM,KAAK,QAAQ,KAAK,IAAI,CAAC;EACxD,CACD;CACD;;;;;;;;CASA,MAAc,QAAQ,EACrB,aAC4D;EAC5D,MAAM,EAAE,KAAK,SAAS,UACpB,QAAQ,SAAS;GACjB,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,OAAO;GAC/B,MAAM,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,OAAO;EAClC,EAAE,CAAC,CACF,MAAM;EAIR,MAAM,EAAE,mBAAmB,kBAAkB,MAAMC,sBAAAA,aAAa;EAChE,OAAO,kBAAkB;GACxB,MAAM,cAAc,GAAG;GACvB,WAAW,KAAK,QAAQ;GACxB,UAAU;IACT;IACA,GAAI,KAAK,QAAQ,UAAU,EAAE,SAAS,KAAK,QAAQ,QAAQ,IAAI,CAAC;GACjE;EACD,CAAC;CACF;AACD"}
package/dist/email.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Construct } from "./construct-interface-DgXTJcOD.cjs";
1
+ import { n as Construct } from "./construct-interface-CVoejIpo.cjs";
2
2
  import { Service } from "@geekmidas/services";
3
3
  import { ConstructName, Declaration } from "@geekmidas/manifest";
4
4
  import { EmailClient, TemplateRecord } from "@geekmidas/emailkit";
@@ -14,14 +14,24 @@ export interface EmailOptions<TTemplates extends TemplateRecord> {
14
14
  */
15
15
  templates: TTemplates;
16
16
  /**
17
- * A reply-to address for every send.
17
+ * The local part mail is sent from — `'info'` sends as `info@` the stage's
18
+ * domain (`info@localhost` under `gkm dev`). Defaults to `noreply`.
18
19
  *
19
- * `from` is deliberately absent: it belongs to the verified sending domain,
20
- * which is `myapp.test` locally and the real domain deployed, so it arrives
21
- * as stage config rather than being written here.
20
+ * Only the local part: it is structural, the same on every stage, and the
21
+ * templates' copy is written for it. The domain is the stage's, so a stage
22
+ * whose domain changes sends from the new one. A whole address for one
23
+ * stage is `deploy.email.<stage>.from`, which wins over this.
22
24
  */
25
+ from?: string;
26
+ /** A reply-to address for every send. */
23
27
  replyTo?: string;
24
28
  }
29
+ /** An `Email`'s `from` that is not a bare local part. */
30
+ export declare class EmailFromNotALocalPart extends Error {
31
+ readonly id: string;
32
+ readonly from: string;
33
+ constructor(id: string, from: string);
34
+ }
25
35
  export declare class Email<TName extends string = string, TTemplates extends TemplateRecord = TemplateRecord> implements Construct<TName, EmailClient<TTemplates>> {
26
36
  private readonly options;
27
37
  readonly id: TName;
@@ -1 +1 @@
1
- {"version":3,"file":"email.d.cts","names":[],"sources":["../src/email.ts"],"mappings":";;;;;iBA8BiB,aAAa,mBAAmB;;;;;;;;;EAShD,WAAW;;;;;;;;EAQX;;qBAGY,MACZ,+BACA,mBAAmB,iBAAiB,2BACxB,UAAU,OAAO,YAAY;mBAavB;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,YAAY;;;;;mBAM1C;EAEjB,YACC,IAAI,cAAc,QACD,SAAS,aAAa;EAoBxC,WAAW;;;;;;;;UAiBG"}
1
+ {"version":3,"file":"email.d.cts","names":[],"sources":["../src/email.ts"],"mappings":";;;;;iBA0BiB,aAAa,mBAAmB;;;;;;;;;EAShD,WAAW;;;;;;;;;;EAUX;;EAEA;;;qBAWY,+BAA+B;WAEjC;WACA;EAFV,YACU,YACA;;qBAWE,MACZ,+BACA,mBAAmB,iBAAiB,2BACxB,UAAU,OAAO,YAAY;mBAavB;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,YAAY;;;;;mBAM1C;EAEjB,YACC,IAAI,cAAc,QACD,SAAS,aAAa;EAsBxC,WAAW;;;;;;;;UAkBG"}
package/dist/email.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { t as Construct } from "./construct-interface-DPlxfpoS.mjs";
1
+ import { n as Construct } from "./construct-interface-Nw5Dt9AC.mjs";
2
2
  import { ConstructName, Declaration } from "@geekmidas/manifest";
3
- import { EmailClient, TemplateRecord } from "@geekmidas/emailkit";
4
3
  import { Service } from "@geekmidas/services";
4
+ import { EmailClient, TemplateRecord } from "@geekmidas/emailkit";
5
5
  //#region src/email.d.ts
6
6
  export interface EmailOptions<TTemplates extends TemplateRecord> {
7
7
  /**
@@ -14,14 +14,24 @@ export interface EmailOptions<TTemplates extends TemplateRecord> {
14
14
  */
15
15
  templates: TTemplates;
16
16
  /**
17
- * A reply-to address for every send.
17
+ * The local part mail is sent from — `'info'` sends as `info@` the stage's
18
+ * domain (`info@localhost` under `gkm dev`). Defaults to `noreply`.
18
19
  *
19
- * `from` is deliberately absent: it belongs to the verified sending domain,
20
- * which is `myapp.test` locally and the real domain deployed, so it arrives
21
- * as stage config rather than being written here.
20
+ * Only the local part: it is structural, the same on every stage, and the
21
+ * templates' copy is written for it. The domain is the stage's, so a stage
22
+ * whose domain changes sends from the new one. A whole address for one
23
+ * stage is `deploy.email.<stage>.from`, which wins over this.
22
24
  */
25
+ from?: string;
26
+ /** A reply-to address for every send. */
23
27
  replyTo?: string;
24
28
  }
29
+ /** An `Email`'s `from` that is not a bare local part. */
30
+ export declare class EmailFromNotALocalPart extends Error {
31
+ readonly id: string;
32
+ readonly from: string;
33
+ constructor(id: string, from: string);
34
+ }
25
35
  export declare class Email<TName extends string = string, TTemplates extends TemplateRecord = TemplateRecord> implements Construct<TName, EmailClient<TTemplates>> {
26
36
  private readonly options;
27
37
  readonly id: TName;
@@ -1 +1 @@
1
- {"version":3,"file":"email.d.mts","names":[],"sources":["../src/email.ts"],"mappings":";;;;;iBA8BiB,aAAa,mBAAmB;;;;;;;;;EAShD,WAAW;;;;;;;;EAQX;;qBAGY,MACZ,+BACA,mBAAmB,iBAAiB,2BACxB,UAAU,OAAO,YAAY;mBAavB;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,YAAY;;;;;mBAM1C;EAEjB,YACC,IAAI,cAAc,QACD,SAAS,aAAa;EAoBxC,WAAW;;;;;;;;UAiBG"}
1
+ {"version":3,"file":"email.d.mts","names":[],"sources":["../src/email.ts"],"mappings":";;;;;iBA0BiB,aAAa,mBAAmB;;;;;;;;;EAShD,WAAW;;;;;;;;;;EAUX;;EAEA;;;qBAWY,+BAA+B;WAEjC;WACA;EAFV,YACU,YACA;;qBAWE,MACZ,+BACA,mBAAmB,iBAAiB,2BACxB,UAAU,OAAO,YAAY;mBAavB;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,YAAY;;;;;mBAM1C;EAEjB,YACC,IAAI,cAAc,QACD,SAAS,aAAa;EAsBxC,WAAW;;;;;;;;UAkBG"}
package/dist/email.mjs CHANGED
@@ -1,19 +1,22 @@
1
- import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
2
- import { createEmailClient, parseEmailUrl } from "@geekmidas/emailkit";
1
+ import { s as loadEmailkit } from "./optionalPeers-D7Wt6dnF.mjs";
2
+ import { canonicalId, providedKeyFor, serviceKey } from "@geekmidas/manifest";
3
3
  //#region src/email.ts
4
4
  /**
5
- * `Email` — declared outbound mail.
6
- *
7
- * The same three-package meeting point as `ObjectStorage`: it implements the
8
- * construct contract, derives its env key through `@geekmidas/manifest`, and
9
- * hands back an `@geekmidas/emailkit` client. It names no provider — locally the
10
- * injected URL points at Mailpit, deployed it points at SES or whichever service
11
- * config selected.
12
- *
13
- * Where object storage needs a driver per provider, this needs none: mail is
14
- * delivered over SMTP whoever delivers it, so there is one client and one URL
15
- * shape, and the provider survives only as a host and a credential.
5
+ * The address-shaped characters a local part may hold: the dot-atom of RFC
6
+ * 5322, which is every sender anyone sends from.
16
7
  */
8
+ const LOCAL_PART = /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*$/;
9
+ /** An `Email`'s `from` that is not a bare local part. */
10
+ var EmailFromNotALocalPart = class extends Error {
11
+ id;
12
+ from;
13
+ constructor(id, from) {
14
+ super(from.includes("@") ? `Email '${id}' has from: '${from}', a whole address. 'from' is the local part only — from: '${from.slice(0, from.lastIndexOf("@"))}' sends as that @ the stage's domain. A whole address for one stage is deploy.email.<stage>.from.` : `Email '${id}' has from: '${from}', which is not a mail local part. Set it to what goes before the @, like 'info' or 'noreply'.`);
15
+ this.id = id;
16
+ this.from = from;
17
+ this.name = "EmailFromNotALocalPart";
18
+ }
19
+ };
17
20
  var Email = class {
18
21
  options;
19
22
  id;
@@ -26,10 +29,11 @@ var Email = class {
26
29
  constructor(id, options) {
27
30
  this.options = options;
28
31
  const canonical = canonicalId(id);
32
+ if (options.from !== void 0 && !LOCAL_PART.test(options.from)) throw new EmailFromNotALocalPart(canonical, options.from);
29
33
  this.id = canonical;
30
34
  this.keys = {
31
- url: provideKey(canonical, "url"),
32
- from: provideKey(canonical, "from")
35
+ url: providedKeyFor(canonical, "email", "url"),
36
+ from: providedKeyFor(canonical, "email", "from")
33
37
  };
34
38
  this.service = {
35
39
  serviceName: serviceKey(canonical),
@@ -40,7 +44,8 @@ var Email = class {
40
44
  return [{
41
45
  kind: "email",
42
46
  id: this.id,
43
- provides: [this.keys.url, this.keys.from]
47
+ provides: [this.keys.url, this.keys.from],
48
+ ...this.options.from ? { from: this.options.from } : {}
44
49
  }];
45
50
  }
46
51
  /**
@@ -55,6 +60,7 @@ var Email = class {
55
60
  url: get(this.keys.url).string(),
56
61
  from: get(this.keys.from).string()
57
62
  })).parse();
63
+ const { createEmailClient, parseEmailUrl } = await loadEmailkit();
58
64
  return createEmailClient({
59
65
  smtp: parseEmailUrl(url),
60
66
  templates: this.options.templates,
@@ -66,6 +72,6 @@ var Email = class {
66
72
  }
67
73
  };
68
74
  //#endregion
69
- export { Email };
75
+ export { Email, EmailFromNotALocalPart };
70
76
 
71
77
  //# sourceMappingURL=email.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"email.mjs","names":[],"sources":["../src/email.ts"],"sourcesContent":["/**\n * `Email` — declared outbound mail.\n *\n * The same three-package meeting point as `ObjectStorage`: it implements the\n * construct contract, derives its env key through `@geekmidas/manifest`, and\n * hands back an `@geekmidas/emailkit` client. It names no provider — locally the\n * injected URL points at Mailpit, deployed it points at SES or whichever service\n * config selected.\n *\n * Where object storage needs a driver per provider, this needs none: mail is\n * delivered over SMTP whoever delivers it, so there is one client and one URL\n * shape, and the provider survives only as a host and a credential.\n */\n\nimport {\n\tcreateEmailClient,\n\ttype EmailClient,\n\tparseEmailUrl,\n\ttype TemplateRecord,\n} from '@geekmidas/emailkit';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\n\nexport interface EmailOptions<TTemplates extends TemplateRecord> {\n\t/**\n\t * The React templates this app can send.\n\t *\n\t * Structural — they are code, they ship with the handler, and which ones\n\t * exist cannot differ between stages. They are also what types\n\t * `sendTemplate`, so passing them here is what makes the client's call sites\n\t * checkable.\n\t */\n\ttemplates: TTemplates;\n\t/**\n\t * A reply-to address for every send.\n\t *\n\t * `from` is deliberately absent: it belongs to the verified sending domain,\n\t * which is `myapp.test` locally and the real domain deployed, so it arrives\n\t * as stage config rather than being written here.\n\t */\n\treplyTo?: string;\n}\n\nexport class Email<\n\tTName extends string = string,\n\tTTemplates extends TemplateRecord = TemplateRecord,\n> implements Construct<TName, EmailClient<TTemplates>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, EmailClient<TTemplates>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { url: string; from: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: EmailOptions<TTemplates>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\t// The sending identity travels with the URL rather than being a second\n\t\t\t// construct option, for the same reason the URL does: it is the one\n\t\t\t// thing about mail that differs per stage.\n\t\t\tfrom: provideKey(canonical, 'from'),\n\t\t};\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'email',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url, this.keys.from],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the URL the adapter supplied.\n\t *\n\t * No provider branch and no driver lookup — `parseEmailUrl` turns any of\n\t * Mailpit, SES, or Resend into the same transport config, which is the whole\n\t * reason the scheme is always `smtp://`.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<EmailClient<TTemplates>> {\n\t\tconst { url, from } = envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.keys.url).string(),\n\t\t\t\tfrom: get(this.keys.from).string(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\treturn createEmailClient({\n\t\t\tsmtp: parseEmailUrl(url),\n\t\t\ttemplates: this.options.templates,\n\t\t\tdefaults: {\n\t\t\t\tfrom,\n\t\t\t\t...(this.options.replyTo ? { replyTo: this.options.replyTo } : {}),\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkDA,IAAa,QAAb,MAIA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO;GACX,KAAK,WAAW,WAAW,KAAK;GAIhC,MAAM,WAAW,WAAW,MAAM;EACnC;EAGA,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI;EACzC,CACD;CACD;;;;;;;;CASA,MAAc,QAAQ,EACrB,aAC4D;EAC5D,MAAM,EAAE,KAAK,SAAS,UACpB,QAAQ,SAAS;GACjB,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,OAAO;GAC/B,MAAM,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,OAAO;EAClC,EAAE,CAAC,CACF,MAAM;EAER,OAAO,kBAAkB;GACxB,MAAM,cAAc,GAAG;GACvB,WAAW,KAAK,QAAQ;GACxB,UAAU;IACT;IACA,GAAI,KAAK,QAAQ,UAAU,EAAE,SAAS,KAAK,QAAQ,QAAQ,IAAI,CAAC;GACjE;EACD,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"email.mjs","names":[],"sources":["../src/email.ts"],"sourcesContent":["/**\n * `Email` — declared outbound mail.\n *\n * The same three-package meeting point as `ObjectStorage`: it implements the\n * construct contract, derives its env key through `@geekmidas/manifest`, and\n * hands back an `@geekmidas/emailkit` client. It names no provider — locally the\n * injected URL points at Mailpit, deployed it points at SES or whichever service\n * config selected.\n *\n * Where object storage needs a driver per provider, this needs none: mail is\n * delivered over SMTP whoever delivers it, so there is one client and one URL\n * shape, and the provider survives only as a host and a credential.\n */\n\nimport type { EmailClient, TemplateRecord } from '@geekmidas/emailkit';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovidedKeyFor,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport type { Construct } from './construct-interface';\nimport { loadEmailkit } from './optionalPeers';\n\nexport interface EmailOptions<TTemplates extends TemplateRecord> {\n\t/**\n\t * The React templates this app can send.\n\t *\n\t * Structural — they are code, they ship with the handler, and which ones\n\t * exist cannot differ between stages. They are also what types\n\t * `sendTemplate`, so passing them here is what makes the client's call sites\n\t * checkable.\n\t */\n\ttemplates: TTemplates;\n\t/**\n\t * The local part mail is sent from — `'info'` sends as `info@` the stage's\n\t * domain (`info@localhost` under `gkm dev`). Defaults to `noreply`.\n\t *\n\t * Only the local part: it is structural, the same on every stage, and the\n\t * templates' copy is written for it. The domain is the stage's, so a stage\n\t * whose domain changes sends from the new one. A whole address for one\n\t * stage is `deploy.email.<stage>.from`, which wins over this.\n\t */\n\tfrom?: string;\n\t/** A reply-to address for every send. */\n\treplyTo?: string;\n}\n\n/**\n * The address-shaped characters a local part may hold: the dot-atom of RFC\n * 5322, which is every sender anyone sends from.\n */\nconst LOCAL_PART =\n\t/^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*$/;\n\n/** An `Email`'s `from` that is not a bare local part. */\nexport class EmailFromNotALocalPart extends Error {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly from: string,\n\t) {\n\t\tsuper(\n\t\t\tfrom.includes('@')\n\t\t\t\t? `Email '${id}' has from: '${from}', a whole address. 'from' is the local part only — from: '${from.slice(0, from.lastIndexOf('@'))}' sends as that @ the stage's domain. A whole address for one stage is deploy.email.<stage>.from.`\n\t\t\t\t: `Email '${id}' has from: '${from}', which is not a mail local part. Set it to what goes before the @, like 'info' or 'noreply'.`,\n\t\t);\n\t\tthis.name = 'EmailFromNotALocalPart';\n\t}\n}\n\nexport class Email<\n\tTName extends string = string,\n\tTTemplates extends TemplateRecord = TemplateRecord,\n> implements Construct<TName, EmailClient<TTemplates>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, EmailClient<TTemplates>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly keys: { url: string; from: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: EmailOptions<TTemplates>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\t\tif (options.from !== undefined && !LOCAL_PART.test(options.from)) {\n\t\t\tthrow new EmailFromNotALocalPart(canonical, options.from);\n\t\t}\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = {\n\t\t\turl: providedKeyFor(canonical, 'email', 'url'),\n\t\t\t// The whole address arrives with the URL: its domain is the stage's,\n\t\t\t// so only the local part (`options.from`) is written here.\n\t\t\tfrom: providedKeyFor(canonical, 'email', 'from'),\n\t\t};\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'email',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url, this.keys.from],\n\t\t\t\t...(this.options.from ? { from: this.options.from } : {}),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the URL the adapter supplied.\n\t *\n\t * No provider branch and no driver lookup — `parseEmailUrl` turns any of\n\t * Mailpit, SES, or Resend into the same transport config, which is the whole\n\t * reason the scheme is always `smtp://`.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<EmailClient<TTemplates>> {\n\t\tconst { url, from } = envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.keys.url).string(),\n\t\t\t\tfrom: get(this.keys.from).string(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\t// Loaded here, not at the top: the test harness names this construct in\n\t\t// every app, and an app that sends no mail does not install emailkit.\n\t\tconst { createEmailClient, parseEmailUrl } = await loadEmailkit();\n\t\treturn createEmailClient({\n\t\t\tsmtp: parseEmailUrl(url),\n\t\t\ttemplates: this.options.templates,\n\t\t\tdefaults: {\n\t\t\t\tfrom,\n\t\t\t\t...(this.options.replyTo ? { replyTo: this.options.replyTo } : {}),\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;AAsDA,MAAM,aACL;;AAGD,IAAa,yBAAb,cAA4C,MAAM;CAEvC;CACA;CAFV,YACC,IACA,MACC;EACD,MACC,KAAK,SAAS,GAAG,IACd,UAAU,GAAG,eAAe,KAAK,6DAA6D,KAAK,MAAM,GAAG,KAAK,YAAY,GAAG,CAAC,EAAE,qGACnI,UAAU,GAAG,eAAe,KAAK,+FACrC;EAPS,KAAA,KAAA;EACA,KAAA,OAAA;EAOT,KAAK,OAAO;CACb;AACD;AAEA,IAAa,QAAb,MAIA;CAYmB;CAXlB;CACA;;;;;CAMA;CAEA,YACC,IACA,SACC;EADgB,KAAA,UAAA;EAEjB,MAAM,YAAY,YAAY,EAAY;EAC1C,IAAI,QAAQ,SAAS,KAAA,KAAa,CAAC,WAAW,KAAK,QAAQ,IAAI,GAC9D,MAAM,IAAI,uBAAuB,WAAW,QAAQ,IAAI;EAGzD,KAAK,KAAK;EACV,KAAK,OAAO;GACX,KAAK,eAAe,WAAW,SAAS,KAAK;GAG7C,MAAM,eAAe,WAAW,SAAS,MAAM;EAChD;EAGA,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI;GACxC,GAAI,KAAK,QAAQ,OAAO,EAAE,MAAM,KAAK,QAAQ,KAAK,IAAI,CAAC;EACxD,CACD;CACD;;;;;;;;CASA,MAAc,QAAQ,EACrB,aAC4D;EAC5D,MAAM,EAAE,KAAK,SAAS,UACpB,QAAQ,SAAS;GACjB,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,OAAO;GAC/B,MAAM,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,OAAO;EAClC,EAAE,CAAC,CACF,MAAM;EAIR,MAAM,EAAE,mBAAmB,kBAAkB,MAAM,aAAa;EAChE,OAAO,kBAAkB;GACxB,MAAM,cAAc,GAAG;GACvB,WAAW,KAAK,QAAQ;GACxB,UAAU;IACT;IACA,GAAI,KAAK,QAAQ,UAAU,EAAE,SAAS,KAAK,QAAQ,QAAQ,IAAI,CAAC;GACjE;EACD,CAAC;CACF;AACD"}
@@ -0,0 +1,95 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_cipher = require("../cipher-CVxfwLjk.cjs");
3
+ let _geekmidas_manifest = require("@geekmidas/manifest");
4
+ let _aws_sdk_client_kms = require("@aws-sdk/client-kms");
5
+ //#region src/encryption/kms.ts
6
+ /**
7
+ * The `kms://` cipher: envelope encryption under an AWS KMS key.
8
+ *
9
+ * Each `encrypt` asks KMS for a fresh data key, seals the plaintext with it
10
+ * locally, and stores the data key *as KMS encrypted it* beside the data. The
11
+ * plaintext data key is used once and dropped, and the master key never leaves
12
+ * KMS — every decrypt is a KMS call IAM can refuse and CloudTrail records.
13
+ *
14
+ * Rotation is KMS's: it keeps every backing version of the key, and the
15
+ * encrypted data key names the one that wrapped it, so nothing here tracks a
16
+ * version and `reencrypt` has nothing to move. The ciphertext's key field is
17
+ * `kms` for that reason.
18
+ *
19
+ * The blind index is a KMS HMAC key's `GenerateMac`: deterministic, and the
20
+ * key is as unextractable as the encryption key.
21
+ *
22
+ * In its own entry, `@geekmidas/constructs/encryption/kms`, which only an
23
+ * AWS build's generated entry imports — to register {@link kmsCipherDriver}
24
+ * — so a project that never deploys to AWS never needs
25
+ * `@aws-sdk/client-kms` installed, and its bundle never mentions it.
26
+ */
27
+ /** The ciphertext's key field: the version lives inside KMS's own blob. */
28
+ const KMS_KEY_ID = "kms";
29
+ function kmsCipher(construct, url) {
30
+ const parsed = new URL(url);
31
+ const region = parsed.hostname;
32
+ const keyId = parsed.searchParams.get("key");
33
+ const indexKeyId = parsed.searchParams.get("index");
34
+ if (!region || !keyId || !indexKeyId) throw new require_cipher.EncryptionUrlInvalid(construct, "a kms:// URL names a region, a key and an index key");
35
+ const endpoint = parsed.searchParams.get("endpoint");
36
+ const kms = new _aws_sdk_client_kms.KMSClient({
37
+ region,
38
+ ...endpoint ? { endpoint } : {}
39
+ });
40
+ const context = { construct };
41
+ const aad = require_cipher.associatedData(construct, KMS_KEY_ID);
42
+ return {
43
+ async encrypt(plaintext) {
44
+ const dataKey = await kms.send(new _aws_sdk_client_kms.GenerateDataKeyCommand({
45
+ KeyId: keyId,
46
+ KeySpec: "AES_256",
47
+ EncryptionContext: context
48
+ }));
49
+ const wrapped = Buffer.from(dataKey.CiphertextBlob);
50
+ const sealed = require_cipher.seal(Buffer.from(dataKey.Plaintext), Buffer.from(plaintext, "utf8"), aad);
51
+ const length = Buffer.alloc(2);
52
+ length.writeUInt16BE(wrapped.length);
53
+ return require_cipher.formatCiphertext(KMS_KEY_ID, Buffer.concat([
54
+ length,
55
+ wrapped,
56
+ sealed
57
+ ]));
58
+ },
59
+ async decrypt(ciphertext) {
60
+ const { payload } = require_cipher.parseCiphertext(construct, ciphertext);
61
+ const length = payload.length >= 2 ? payload.readUInt16BE(0) : 0;
62
+ const wrapped = payload.subarray(2, 2 + length);
63
+ if (!length || wrapped.length !== length) throw new require_cipher.CiphertextNotAuthentic(construct);
64
+ const dataKey = await kms.send(new _aws_sdk_client_kms.DecryptCommand({
65
+ CiphertextBlob: wrapped,
66
+ EncryptionContext: context
67
+ }));
68
+ const plaintext = require_cipher.open(Buffer.from(dataKey.Plaintext), payload.subarray(2 + length), aad);
69
+ if (!plaintext) throw new require_cipher.CiphertextNotAuthentic(construct);
70
+ return plaintext.toString("utf8");
71
+ },
72
+ async index(value) {
73
+ const { Mac } = await kms.send(new _aws_sdk_client_kms.GenerateMacCommand({
74
+ KeyId: indexKeyId,
75
+ MacAlgorithm: "HMAC_SHA_256",
76
+ Message: Buffer.from(value, "utf8")
77
+ }));
78
+ return Buffer.from(Mac).toString("base64url");
79
+ },
80
+ async reencrypt(ciphertext) {
81
+ require_cipher.parseCiphertext(construct, ciphertext);
82
+ return ciphertext;
83
+ }
84
+ };
85
+ }
86
+ /** The `kms:` cipher, as an AWS build's entry registers it. */
87
+ const kmsCipherDriver = {
88
+ scheme: _geekmidas_manifest.KMS_SCHEME,
89
+ open: kmsCipher
90
+ };
91
+ //#endregion
92
+ exports.kmsCipher = kmsCipher;
93
+ exports.kmsCipherDriver = kmsCipherDriver;
94
+
95
+ //# sourceMappingURL=kms.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kms.cjs","names":["EncryptionUrlInvalid","KMSClient","associatedData","GenerateDataKeyCommand","seal","formatCiphertext","parseCiphertext","CiphertextNotAuthentic","DecryptCommand","open","GenerateMacCommand","KMS_SCHEME"],"sources":["../../src/encryption/kms.ts"],"sourcesContent":["/**\n * The `kms://` cipher: envelope encryption under an AWS KMS key.\n *\n * Each `encrypt` asks KMS for a fresh data key, seals the plaintext with it\n * locally, and stores the data key *as KMS encrypted it* beside the data. The\n * plaintext data key is used once and dropped, and the master key never leaves\n * KMS — every decrypt is a KMS call IAM can refuse and CloudTrail records.\n *\n * Rotation is KMS's: it keeps every backing version of the key, and the\n * encrypted data key names the one that wrapped it, so nothing here tracks a\n * version and `reencrypt` has nothing to move. The ciphertext's key field is\n * `kms` for that reason.\n *\n * The blind index is a KMS HMAC key's `GenerateMac`: deterministic, and the\n * key is as unextractable as the encryption key.\n *\n * In its own entry, `@geekmidas/constructs/encryption/kms`, which only an\n * AWS build's generated entry imports — to register {@link kmsCipherDriver}\n * — so a project that never deploys to AWS never needs\n * `@aws-sdk/client-kms` installed, and its bundle never mentions it.\n */\n\nimport {\n\tDecryptCommand,\n\tGenerateDataKeyCommand,\n\tGenerateMacCommand,\n\tKMSClient,\n} from '@aws-sdk/client-kms';\nimport { KMS_SCHEME } from '@geekmidas/manifest';\nimport {\n\tassociatedData,\n\ttype Cipher,\n\ttype CipherDriver,\n\tCiphertextNotAuthentic,\n\tEncryptionUrlInvalid,\n\tformatCiphertext,\n\topen,\n\tparseCiphertext,\n\tseal,\n} from './cipher';\n\n/** The ciphertext's key field: the version lives inside KMS's own blob. */\nconst KMS_KEY_ID = 'kms';\n\nexport function kmsCipher(construct: string, url: string): Cipher {\n\tconst parsed = new URL(url);\n\tconst region = parsed.hostname;\n\tconst keyId = parsed.searchParams.get('key');\n\tconst indexKeyId = parsed.searchParams.get('index');\n\tif (!region || !keyId || !indexKeyId) {\n\t\tthrow new EncryptionUrlInvalid(\n\t\t\tconstruct,\n\t\t\t'a kms:// URL names a region, a key and an index key',\n\t\t);\n\t}\n\n\tconst endpoint = parsed.searchParams.get('endpoint');\n\t// Credentials are not part of the address: the default chain — a Lambda's\n\t// role deployed, the environment against an emulator.\n\tconst kms = new KMSClient({ region, ...(endpoint ? { endpoint } : {}) });\n\t// What KMS checks on every decrypt, and what CloudTrail shows each call was\n\t// for — a data key minted for one construct will not open for another.\n\tconst context = { construct };\n\tconst aad = associatedData(construct, KMS_KEY_ID);\n\n\treturn {\n\t\tasync encrypt(plaintext) {\n\t\t\tconst dataKey = await kms.send(\n\t\t\t\tnew GenerateDataKeyCommand({\n\t\t\t\t\tKeyId: keyId,\n\t\t\t\t\tKeySpec: 'AES_256',\n\t\t\t\t\tEncryptionContext: context,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst wrapped = Buffer.from(dataKey.CiphertextBlob!);\n\t\t\tconst sealed = seal(\n\t\t\t\tBuffer.from(dataKey.Plaintext!),\n\t\t\t\tBuffer.from(plaintext, 'utf8'),\n\t\t\t\taad,\n\t\t\t);\n\n\t\t\tconst length = Buffer.alloc(2);\n\t\t\tlength.writeUInt16BE(wrapped.length);\n\t\t\treturn formatCiphertext(\n\t\t\t\tKMS_KEY_ID,\n\t\t\t\tBuffer.concat([length, wrapped, sealed]),\n\t\t\t);\n\t\t},\n\n\t\tasync decrypt(ciphertext) {\n\t\t\tconst { payload } = parseCiphertext(construct, ciphertext);\n\t\t\tconst length = payload.length >= 2 ? payload.readUInt16BE(0) : 0;\n\t\t\tconst wrapped = payload.subarray(2, 2 + length);\n\t\t\tif (!length || wrapped.length !== length) {\n\t\t\t\tthrow new CiphertextNotAuthentic(construct);\n\t\t\t}\n\n\t\t\tconst dataKey = await kms.send(\n\t\t\t\tnew DecryptCommand({\n\t\t\t\t\tCiphertextBlob: wrapped,\n\t\t\t\t\tEncryptionContext: context,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst plaintext = open(\n\t\t\t\tBuffer.from(dataKey.Plaintext!),\n\t\t\t\tpayload.subarray(2 + length),\n\t\t\t\taad,\n\t\t\t);\n\t\t\tif (!plaintext) throw new CiphertextNotAuthentic(construct);\n\n\t\t\treturn plaintext.toString('utf8');\n\t\t},\n\n\t\tasync index(value) {\n\t\t\tconst { Mac } = await kms.send(\n\t\t\t\tnew GenerateMacCommand({\n\t\t\t\t\tKeyId: indexKeyId,\n\t\t\t\t\tMacAlgorithm: 'HMAC_SHA_256',\n\t\t\t\t\tMessage: Buffer.from(value, 'utf8'),\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn Buffer.from(Mac!).toString('base64url');\n\t\t},\n\n\t\t// KMS keeps every version it rotated through, so a value is never under\n\t\t// a key that could be retired from under it.\n\t\tasync reencrypt(ciphertext) {\n\t\t\tparseCiphertext(construct, ciphertext);\n\t\t\treturn ciphertext;\n\t\t},\n\t};\n}\n\n/** The `kms:` cipher, as an AWS build's entry registers it. */\nexport const kmsCipherDriver: CipherDriver = {\n\tscheme: KMS_SCHEME,\n\topen: kmsCipher,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,aAAa;AAEnB,SAAgB,UAAU,WAAmB,KAAqB;CACjE,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,SAAS,OAAO;CACtB,MAAM,QAAQ,OAAO,aAAa,IAAI,KAAK;CAC3C,MAAM,aAAa,OAAO,aAAa,IAAI,OAAO;CAClD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YACzB,MAAM,IAAIA,eAAAA,qBACT,WACA,qDACD;CAGD,MAAM,WAAW,OAAO,aAAa,IAAI,UAAU;CAGnD,MAAM,MAAM,IAAIC,oBAAAA,UAAU;EAAE;EAAQ,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CAAG,CAAC;CAGvE,MAAM,UAAU,EAAE,UAAU;CAC5B,MAAM,MAAMC,eAAAA,eAAe,WAAW,UAAU;CAEhD,OAAO;EACN,MAAM,QAAQ,WAAW;GACxB,MAAM,UAAU,MAAM,IAAI,KACzB,IAAIC,oBAAAA,uBAAuB;IAC1B,OAAO;IACP,SAAS;IACT,mBAAmB;GACpB,CAAC,CACF;GACA,MAAM,UAAU,OAAO,KAAK,QAAQ,cAAe;GACnD,MAAM,SAASC,eAAAA,KACd,OAAO,KAAK,QAAQ,SAAU,GAC9B,OAAO,KAAK,WAAW,MAAM,GAC7B,GACD;GAEA,MAAM,SAAS,OAAO,MAAM,CAAC;GAC7B,OAAO,cAAc,QAAQ,MAAM;GACnC,OAAOC,eAAAA,iBACN,YACA,OAAO,OAAO;IAAC;IAAQ;IAAS;GAAM,CAAC,CACxC;EACD;EAEA,MAAM,QAAQ,YAAY;GACzB,MAAM,EAAE,YAAYC,eAAAA,gBAAgB,WAAW,UAAU;GACzD,MAAM,SAAS,QAAQ,UAAU,IAAI,QAAQ,aAAa,CAAC,IAAI;GAC/D,MAAM,UAAU,QAAQ,SAAS,GAAG,IAAI,MAAM;GAC9C,IAAI,CAAC,UAAU,QAAQ,WAAW,QACjC,MAAM,IAAIC,eAAAA,uBAAuB,SAAS;GAG3C,MAAM,UAAU,MAAM,IAAI,KACzB,IAAIC,oBAAAA,eAAe;IAClB,gBAAgB;IAChB,mBAAmB;GACpB,CAAC,CACF;GACA,MAAM,YAAYC,eAAAA,KACjB,OAAO,KAAK,QAAQ,SAAU,GAC9B,QAAQ,SAAS,IAAI,MAAM,GAC3B,GACD;GACA,IAAI,CAAC,WAAW,MAAM,IAAIF,eAAAA,uBAAuB,SAAS;GAE1D,OAAO,UAAU,SAAS,MAAM;EACjC;EAEA,MAAM,MAAM,OAAO;GAClB,MAAM,EAAE,QAAQ,MAAM,IAAI,KACzB,IAAIG,oBAAAA,mBAAmB;IACtB,OAAO;IACP,cAAc;IACd,SAAS,OAAO,KAAK,OAAO,MAAM;GACnC,CAAC,CACF;GACA,OAAO,OAAO,KAAK,GAAI,CAAC,CAAC,SAAS,WAAW;EAC9C;EAIA,MAAM,UAAU,YAAY;GAC3B,eAAA,gBAAgB,WAAW,UAAU;GACrC,OAAO;EACR;CACD;AACD;;AAGA,MAAa,kBAAgC;CAC5C,QAAQC,oBAAAA;CACR,MAAM;AACP"}
@@ -0,0 +1,7 @@
1
+ import { n as CipherDriver, t as Cipher } from "../cipher-DSDxPRIp.cjs";
2
+ //#region src/encryption/kms.d.ts
3
+ export declare function kmsCipher(construct: string, url: string): Cipher;
4
+ /** The `kms:` cipher, as an AWS build's entry registers it. */
5
+ export declare const kmsCipherDriver: CipherDriver;
6
+ //#endregion
7
+ //# sourceMappingURL=kms.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kms.d.cts","names":[],"sources":["../../src/encryption/kms.ts"],"mappings":";;wBA4CgB,UAAU,mBAAmB,cAAc;;qBA0F9C,iBAAiB"}
@@ -0,0 +1,7 @@
1
+ import { n as CipherDriver, t as Cipher } from "../cipher-DSDxPRIp.mjs";
2
+ //#region src/encryption/kms.d.ts
3
+ export declare function kmsCipher(construct: string, url: string): Cipher;
4
+ /** The `kms:` cipher, as an AWS build's entry registers it. */
5
+ export declare const kmsCipherDriver: CipherDriver;
6
+ //#endregion
7
+ //# sourceMappingURL=kms.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kms.d.mts","names":[],"sources":["../../src/encryption/kms.ts"],"mappings":";;wBA4CgB,UAAU,mBAAmB,cAAc;;qBA0F9C,iBAAiB"}
@@ -0,0 +1,93 @@
1
+ import { a as EncryptionUrlInvalid, c as associatedData, l as formatCiphertext, m as parseCiphertext, n as CiphertextNotAuthentic, p as open, v as seal } from "../cipher-C1lEFX63.mjs";
2
+ import { KMS_SCHEME } from "@geekmidas/manifest";
3
+ import { DecryptCommand, GenerateDataKeyCommand, GenerateMacCommand, KMSClient } from "@aws-sdk/client-kms";
4
+ //#region src/encryption/kms.ts
5
+ /**
6
+ * The `kms://` cipher: envelope encryption under an AWS KMS key.
7
+ *
8
+ * Each `encrypt` asks KMS for a fresh data key, seals the plaintext with it
9
+ * locally, and stores the data key *as KMS encrypted it* beside the data. The
10
+ * plaintext data key is used once and dropped, and the master key never leaves
11
+ * KMS — every decrypt is a KMS call IAM can refuse and CloudTrail records.
12
+ *
13
+ * Rotation is KMS's: it keeps every backing version of the key, and the
14
+ * encrypted data key names the one that wrapped it, so nothing here tracks a
15
+ * version and `reencrypt` has nothing to move. The ciphertext's key field is
16
+ * `kms` for that reason.
17
+ *
18
+ * The blind index is a KMS HMAC key's `GenerateMac`: deterministic, and the
19
+ * key is as unextractable as the encryption key.
20
+ *
21
+ * In its own entry, `@geekmidas/constructs/encryption/kms`, which only an
22
+ * AWS build's generated entry imports — to register {@link kmsCipherDriver}
23
+ * — so a project that never deploys to AWS never needs
24
+ * `@aws-sdk/client-kms` installed, and its bundle never mentions it.
25
+ */
26
+ /** The ciphertext's key field: the version lives inside KMS's own blob. */
27
+ const KMS_KEY_ID = "kms";
28
+ function kmsCipher(construct, url) {
29
+ const parsed = new URL(url);
30
+ const region = parsed.hostname;
31
+ const keyId = parsed.searchParams.get("key");
32
+ const indexKeyId = parsed.searchParams.get("index");
33
+ if (!region || !keyId || !indexKeyId) throw new EncryptionUrlInvalid(construct, "a kms:// URL names a region, a key and an index key");
34
+ const endpoint = parsed.searchParams.get("endpoint");
35
+ const kms = new KMSClient({
36
+ region,
37
+ ...endpoint ? { endpoint } : {}
38
+ });
39
+ const context = { construct };
40
+ const aad = associatedData(construct, KMS_KEY_ID);
41
+ return {
42
+ async encrypt(plaintext) {
43
+ const dataKey = await kms.send(new GenerateDataKeyCommand({
44
+ KeyId: keyId,
45
+ KeySpec: "AES_256",
46
+ EncryptionContext: context
47
+ }));
48
+ const wrapped = Buffer.from(dataKey.CiphertextBlob);
49
+ const sealed = seal(Buffer.from(dataKey.Plaintext), Buffer.from(plaintext, "utf8"), aad);
50
+ const length = Buffer.alloc(2);
51
+ length.writeUInt16BE(wrapped.length);
52
+ return formatCiphertext(KMS_KEY_ID, Buffer.concat([
53
+ length,
54
+ wrapped,
55
+ sealed
56
+ ]));
57
+ },
58
+ async decrypt(ciphertext) {
59
+ const { payload } = parseCiphertext(construct, ciphertext);
60
+ const length = payload.length >= 2 ? payload.readUInt16BE(0) : 0;
61
+ const wrapped = payload.subarray(2, 2 + length);
62
+ if (!length || wrapped.length !== length) throw new CiphertextNotAuthentic(construct);
63
+ const dataKey = await kms.send(new DecryptCommand({
64
+ CiphertextBlob: wrapped,
65
+ EncryptionContext: context
66
+ }));
67
+ const plaintext = open(Buffer.from(dataKey.Plaintext), payload.subarray(2 + length), aad);
68
+ if (!plaintext) throw new CiphertextNotAuthentic(construct);
69
+ return plaintext.toString("utf8");
70
+ },
71
+ async index(value) {
72
+ const { Mac } = await kms.send(new GenerateMacCommand({
73
+ KeyId: indexKeyId,
74
+ MacAlgorithm: "HMAC_SHA_256",
75
+ Message: Buffer.from(value, "utf8")
76
+ }));
77
+ return Buffer.from(Mac).toString("base64url");
78
+ },
79
+ async reencrypt(ciphertext) {
80
+ parseCiphertext(construct, ciphertext);
81
+ return ciphertext;
82
+ }
83
+ };
84
+ }
85
+ /** The `kms:` cipher, as an AWS build's entry registers it. */
86
+ const kmsCipherDriver = {
87
+ scheme: KMS_SCHEME,
88
+ open: kmsCipher
89
+ };
90
+ //#endregion
91
+ export { kmsCipher, kmsCipherDriver };
92
+
93
+ //# sourceMappingURL=kms.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kms.mjs","names":[],"sources":["../../src/encryption/kms.ts"],"sourcesContent":["/**\n * The `kms://` cipher: envelope encryption under an AWS KMS key.\n *\n * Each `encrypt` asks KMS for a fresh data key, seals the plaintext with it\n * locally, and stores the data key *as KMS encrypted it* beside the data. The\n * plaintext data key is used once and dropped, and the master key never leaves\n * KMS — every decrypt is a KMS call IAM can refuse and CloudTrail records.\n *\n * Rotation is KMS's: it keeps every backing version of the key, and the\n * encrypted data key names the one that wrapped it, so nothing here tracks a\n * version and `reencrypt` has nothing to move. The ciphertext's key field is\n * `kms` for that reason.\n *\n * The blind index is a KMS HMAC key's `GenerateMac`: deterministic, and the\n * key is as unextractable as the encryption key.\n *\n * In its own entry, `@geekmidas/constructs/encryption/kms`, which only an\n * AWS build's generated entry imports — to register {@link kmsCipherDriver}\n * — so a project that never deploys to AWS never needs\n * `@aws-sdk/client-kms` installed, and its bundle never mentions it.\n */\n\nimport {\n\tDecryptCommand,\n\tGenerateDataKeyCommand,\n\tGenerateMacCommand,\n\tKMSClient,\n} from '@aws-sdk/client-kms';\nimport { KMS_SCHEME } from '@geekmidas/manifest';\nimport {\n\tassociatedData,\n\ttype Cipher,\n\ttype CipherDriver,\n\tCiphertextNotAuthentic,\n\tEncryptionUrlInvalid,\n\tformatCiphertext,\n\topen,\n\tparseCiphertext,\n\tseal,\n} from './cipher';\n\n/** The ciphertext's key field: the version lives inside KMS's own blob. */\nconst KMS_KEY_ID = 'kms';\n\nexport function kmsCipher(construct: string, url: string): Cipher {\n\tconst parsed = new URL(url);\n\tconst region = parsed.hostname;\n\tconst keyId = parsed.searchParams.get('key');\n\tconst indexKeyId = parsed.searchParams.get('index');\n\tif (!region || !keyId || !indexKeyId) {\n\t\tthrow new EncryptionUrlInvalid(\n\t\t\tconstruct,\n\t\t\t'a kms:// URL names a region, a key and an index key',\n\t\t);\n\t}\n\n\tconst endpoint = parsed.searchParams.get('endpoint');\n\t// Credentials are not part of the address: the default chain — a Lambda's\n\t// role deployed, the environment against an emulator.\n\tconst kms = new KMSClient({ region, ...(endpoint ? { endpoint } : {}) });\n\t// What KMS checks on every decrypt, and what CloudTrail shows each call was\n\t// for — a data key minted for one construct will not open for another.\n\tconst context = { construct };\n\tconst aad = associatedData(construct, KMS_KEY_ID);\n\n\treturn {\n\t\tasync encrypt(plaintext) {\n\t\t\tconst dataKey = await kms.send(\n\t\t\t\tnew GenerateDataKeyCommand({\n\t\t\t\t\tKeyId: keyId,\n\t\t\t\t\tKeySpec: 'AES_256',\n\t\t\t\t\tEncryptionContext: context,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst wrapped = Buffer.from(dataKey.CiphertextBlob!);\n\t\t\tconst sealed = seal(\n\t\t\t\tBuffer.from(dataKey.Plaintext!),\n\t\t\t\tBuffer.from(plaintext, 'utf8'),\n\t\t\t\taad,\n\t\t\t);\n\n\t\t\tconst length = Buffer.alloc(2);\n\t\t\tlength.writeUInt16BE(wrapped.length);\n\t\t\treturn formatCiphertext(\n\t\t\t\tKMS_KEY_ID,\n\t\t\t\tBuffer.concat([length, wrapped, sealed]),\n\t\t\t);\n\t\t},\n\n\t\tasync decrypt(ciphertext) {\n\t\t\tconst { payload } = parseCiphertext(construct, ciphertext);\n\t\t\tconst length = payload.length >= 2 ? payload.readUInt16BE(0) : 0;\n\t\t\tconst wrapped = payload.subarray(2, 2 + length);\n\t\t\tif (!length || wrapped.length !== length) {\n\t\t\t\tthrow new CiphertextNotAuthentic(construct);\n\t\t\t}\n\n\t\t\tconst dataKey = await kms.send(\n\t\t\t\tnew DecryptCommand({\n\t\t\t\t\tCiphertextBlob: wrapped,\n\t\t\t\t\tEncryptionContext: context,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst plaintext = open(\n\t\t\t\tBuffer.from(dataKey.Plaintext!),\n\t\t\t\tpayload.subarray(2 + length),\n\t\t\t\taad,\n\t\t\t);\n\t\t\tif (!plaintext) throw new CiphertextNotAuthentic(construct);\n\n\t\t\treturn plaintext.toString('utf8');\n\t\t},\n\n\t\tasync index(value) {\n\t\t\tconst { Mac } = await kms.send(\n\t\t\t\tnew GenerateMacCommand({\n\t\t\t\t\tKeyId: indexKeyId,\n\t\t\t\t\tMacAlgorithm: 'HMAC_SHA_256',\n\t\t\t\t\tMessage: Buffer.from(value, 'utf8'),\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn Buffer.from(Mac!).toString('base64url');\n\t\t},\n\n\t\t// KMS keeps every version it rotated through, so a value is never under\n\t\t// a key that could be retired from under it.\n\t\tasync reencrypt(ciphertext) {\n\t\t\tparseCiphertext(construct, ciphertext);\n\t\t\treturn ciphertext;\n\t\t},\n\t};\n}\n\n/** The `kms:` cipher, as an AWS build's entry registers it. */\nexport const kmsCipherDriver: CipherDriver = {\n\tscheme: KMS_SCHEME,\n\topen: kmsCipher,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,aAAa;AAEnB,SAAgB,UAAU,WAAmB,KAAqB;CACjE,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,SAAS,OAAO;CACtB,MAAM,QAAQ,OAAO,aAAa,IAAI,KAAK;CAC3C,MAAM,aAAa,OAAO,aAAa,IAAI,OAAO;CAClD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YACzB,MAAM,IAAI,qBACT,WACA,qDACD;CAGD,MAAM,WAAW,OAAO,aAAa,IAAI,UAAU;CAGnD,MAAM,MAAM,IAAI,UAAU;EAAE;EAAQ,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;CAAG,CAAC;CAGvE,MAAM,UAAU,EAAE,UAAU;CAC5B,MAAM,MAAM,eAAe,WAAW,UAAU;CAEhD,OAAO;EACN,MAAM,QAAQ,WAAW;GACxB,MAAM,UAAU,MAAM,IAAI,KACzB,IAAI,uBAAuB;IAC1B,OAAO;IACP,SAAS;IACT,mBAAmB;GACpB,CAAC,CACF;GACA,MAAM,UAAU,OAAO,KAAK,QAAQ,cAAe;GACnD,MAAM,SAAS,KACd,OAAO,KAAK,QAAQ,SAAU,GAC9B,OAAO,KAAK,WAAW,MAAM,GAC7B,GACD;GAEA,MAAM,SAAS,OAAO,MAAM,CAAC;GAC7B,OAAO,cAAc,QAAQ,MAAM;GACnC,OAAO,iBACN,YACA,OAAO,OAAO;IAAC;IAAQ;IAAS;GAAM,CAAC,CACxC;EACD;EAEA,MAAM,QAAQ,YAAY;GACzB,MAAM,EAAE,YAAY,gBAAgB,WAAW,UAAU;GACzD,MAAM,SAAS,QAAQ,UAAU,IAAI,QAAQ,aAAa,CAAC,IAAI;GAC/D,MAAM,UAAU,QAAQ,SAAS,GAAG,IAAI,MAAM;GAC9C,IAAI,CAAC,UAAU,QAAQ,WAAW,QACjC,MAAM,IAAI,uBAAuB,SAAS;GAG3C,MAAM,UAAU,MAAM,IAAI,KACzB,IAAI,eAAe;IAClB,gBAAgB;IAChB,mBAAmB;GACpB,CAAC,CACF;GACA,MAAM,YAAY,KACjB,OAAO,KAAK,QAAQ,SAAU,GAC9B,QAAQ,SAAS,IAAI,MAAM,GAC3B,GACD;GACA,IAAI,CAAC,WAAW,MAAM,IAAI,uBAAuB,SAAS;GAE1D,OAAO,UAAU,SAAS,MAAM;EACjC;EAEA,MAAM,MAAM,OAAO;GAClB,MAAM,EAAE,QAAQ,MAAM,IAAI,KACzB,IAAI,mBAAmB;IACtB,OAAO;IACP,cAAc;IACd,SAAS,OAAO,KAAK,OAAO,MAAM;GACnC,CAAC,CACF;GACA,OAAO,OAAO,KAAK,GAAI,CAAC,CAAC,SAAS,WAAW;EAC9C;EAIA,MAAM,UAAU,YAAY;GAC3B,gBAAgB,WAAW,UAAU;GACrC,OAAO;EACR;CACD;AACD;;AAGA,MAAa,kBAAgC;CAC5C,QAAQ;CACR,MAAM;AACP"}