@geekmidas/constructs 10.0.0-alpha.16 → 10.0.0-alpha.160

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-D6Y7BBt3.d.mts} +15 -8
  11. package/dist/Cron-D6Y7BBt3.d.mts.map +1 -0
  12. package/dist/{Cron-zsoSAwZo.d.cts → Cron-D_sfaMGz.d.cts} +14 -7
  13. package/dist/Cron-D_sfaMGz.d.cts.map +1 -0
  14. package/dist/CronBuilder-4BZhkChG.d.mts +47 -0
  15. package/dist/CronBuilder-4BZhkChG.d.mts.map +1 -0
  16. package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
  17. package/dist/CronBuilder-BJ5LoadF.mjs.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-C91MVLSr.d.cts +47 -0
  21. package/dist/CronBuilder-C91MVLSr.d.cts.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-BUoDD96P.d.mts} +104 -23
  25. package/dist/Endpoint-BUoDD96P.d.mts.map +1 -0
  26. package/dist/{Endpoint-DBflWAe4.d.cts → Endpoint-YYwjqtS1.d.cts} +101 -20
  27. package/dist/Endpoint-YYwjqtS1.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/{index-Cc4kKPag.d.mts → EndpointFactory-BbVOeryo.d.mts} +189 -106
  31. package/dist/EndpointFactory-BbVOeryo.d.mts.map +1 -0
  32. package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
  33. package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
  34. package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
  35. package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
  36. package/dist/{index-C1ZwNOOk.d.cts → EndpointFactory-Hh1r6J_C.d.cts} +187 -104
  37. package/dist/EndpointFactory-Hh1r6J_C.d.cts.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-DfzXQEKW.d.mts +129 -0
  47. package/dist/ObjectSubscriberBuilder-DfzXQEKW.d.mts.map +1 -0
  48. package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts +129 -0
  49. package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts.map +1 -0
  50. package/dist/ProcessorBuilder-D4oYvZeG.d.mts +216 -0
  51. package/dist/ProcessorBuilder-D4oYvZeG.d.mts.map +1 -0
  52. package/dist/ProcessorBuilder-_jdZlbfW.d.cts +216 -0
  53. package/dist/ProcessorBuilder-_jdZlbfW.d.cts.map +1 -0
  54. package/dist/{Queue-D9X6OoON.d.mts → Queue-B8HGg439.d.mts} +42 -41
  55. package/dist/Queue-B8HGg439.d.mts.map +1 -0
  56. package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
  57. package/dist/Queue-C4rijiM7.d.cts.map +1 -0
  58. package/dist/Queue-D4Iaidrs.cjs +109 -0
  59. package/dist/Queue-D4Iaidrs.cjs.map +1 -0
  60. package/dist/Queue-u8w8_HpE.mjs +104 -0
  61. package/dist/Queue-u8w8_HpE.mjs.map +1 -0
  62. package/dist/QueueBuilder-2wP5lEC8.mjs +118 -0
  63. package/dist/QueueBuilder-2wP5lEC8.mjs.map +1 -0
  64. package/dist/QueueBuilder-BxsZ9o5z.cjs +135 -0
  65. package/dist/QueueBuilder-BxsZ9o5z.cjs.map +1 -0
  66. package/dist/QueueBuilder-CVS_qPuo.d.mts +75 -0
  67. package/dist/QueueBuilder-CVS_qPuo.d.mts.map +1 -0
  68. package/dist/QueueBuilder-SQli59An.d.cts +75 -0
  69. package/dist/QueueBuilder-SQli59An.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-DN2gYJ-p.mjs +99 -0
  79. package/dist/Topic-DN2gYJ-p.mjs.map +1 -0
  80. package/dist/Topic-Dp9Q7Lj2.cjs +104 -0
  81. package/dist/Topic-Dp9Q7Lj2.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-BqWz2JxC.d.cts +274 -0
  113. package/dist/auth-BqWz2JxC.d.cts.map +1 -0
  114. package/dist/auth-DnB9H9KL.d.mts +274 -0
  115. package/dist/auth-DnB9H9KL.d.mts.map +1 -0
  116. package/dist/auth.cjs +308 -23
  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 +304 -25
  121. package/dist/auth.mjs.map +1 -1
  122. package/dist/cache-CCHcO9Oo.d.mts +44 -0
  123. package/dist/cache-CCHcO9Oo.d.mts.map +1 -0
  124. package/dist/cache-CQjMNPrC.d.cts +44 -0
  125. package/dist/cache-CQjMNPrC.d.cts.map +1 -0
  126. package/dist/cache.cjs +3 -19
  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 +2 -18
  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-CSA9VeWM.d.mts} +47 -8
  141. package/dist/construct-interface-CSA9VeWM.d.mts.map +1 -0
  142. package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-DugP0E5q.d.cts} +47 -8
  143. package/dist/construct-interface-DugP0E5q.d.cts.map +1 -0
  144. package/dist/construct-interface.cjs +38 -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 +37 -5
  149. package/dist/construct-interface.mjs.map +1 -1
  150. package/dist/credential-DYymbp_7.cjs +257 -0
  151. package/dist/credential-DYymbp_7.cjs.map +1 -0
  152. package/dist/credential-DfSAOOdY.mjs +222 -0
  153. package/dist/credential-DfSAOOdY.mjs.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 +4 -16
  171. package/dist/email.cjs.map +1 -1
  172. package/dist/email.d.cts +1 -1
  173. package/dist/email.d.cts.map +1 -1
  174. package/dist/email.d.mts +2 -2
  175. package/dist/email.d.mts.map +1 -1
  176. package/dist/email.mjs +2 -14
  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/expire-CieftS01.cjs +67 -0
  205. package/dist/expire-CieftS01.cjs.map +1 -0
  206. package/dist/expire-CpzUAfr9.mjs +50 -0
  207. package/dist/expire-CpzUAfr9.mjs.map +1 -0
  208. package/dist/external-api.cjs +106 -0
  209. package/dist/external-api.cjs.map +1 -0
  210. package/dist/external-api.d.cts +2 -0
  211. package/dist/external-api.d.mts +2 -0
  212. package/dist/external-api.mjs +103 -0
  213. package/dist/external-api.mjs.map +1 -0
  214. package/dist/fake-BqhP8RRQ.d.mts +201 -0
  215. package/dist/fake-BqhP8RRQ.d.mts.map +1 -0
  216. package/dist/fake-DqieDYYA.d.cts +201 -0
  217. package/dist/fake-DqieDYYA.d.cts.map +1 -0
  218. package/dist/file-server.cjs +123 -30
  219. package/dist/file-server.cjs.map +1 -1
  220. package/dist/file-server.d.cts +115 -1
  221. package/dist/file-server.d.cts.map +1 -1
  222. package/dist/file-server.d.mts +115 -1
  223. package/dist/file-server.d.mts.map +1 -1
  224. package/dist/file-server.mjs +122 -32
  225. package/dist/file-server.mjs.map +1 -1
  226. package/dist/functions/index.cjs +1 -1
  227. package/dist/functions/index.d.cts +2 -1
  228. package/dist/functions/index.d.mts +2 -1
  229. package/dist/functions/index.mjs +1 -1
  230. package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
  231. package/dist/functions-BvIDQKAA.mjs.map +1 -0
  232. package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
  233. package/dist/functions-DLF6-IK8.cjs.map +1 -0
  234. package/dist/inbox-CR3L1fOI.d.cts +195 -0
  235. package/dist/inbox-CR3L1fOI.d.cts.map +1 -0
  236. package/dist/inbox-YOdxlyfj.d.mts +195 -0
  237. package/dist/inbox-YOdxlyfj.d.mts.map +1 -0
  238. package/dist/inbox.cjs +291 -0
  239. package/dist/inbox.cjs.map +1 -0
  240. package/dist/inbox.d.cts +2 -0
  241. package/dist/inbox.d.mts +2 -0
  242. package/dist/inbox.mjs +283 -0
  243. package/dist/inbox.mjs.map +1 -0
  244. package/dist/index-BoQ3-M-K.d.mts +115 -0
  245. package/dist/index-BoQ3-M-K.d.mts.map +1 -0
  246. package/dist/index-DPTHa6Ud.d.cts +115 -0
  247. package/dist/index-DPTHa6Ud.d.cts.map +1 -0
  248. package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
  249. package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
  250. package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
  251. package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
  252. package/dist/index.cjs +4 -1
  253. package/dist/index.d.cts +26 -3
  254. package/dist/index.d.cts.map +1 -0
  255. package/dist/index.d.mts +26 -3
  256. package/dist/index.d.mts.map +1 -0
  257. package/dist/index.mjs +3 -2
  258. package/dist/kysely-CebjCWTl.d.cts +216 -0
  259. package/dist/kysely-CebjCWTl.d.cts.map +1 -0
  260. package/dist/kysely-Cs4uPO8k.mjs +371 -0
  261. package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
  262. package/dist/kysely-CukArHJ0.cjs +384 -0
  263. package/dist/kysely-CukArHJ0.cjs.map +1 -0
  264. package/dist/kysely-De5rAC-E.d.mts +216 -0
  265. package/dist/kysely-De5rAC-E.d.mts.map +1 -0
  266. package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
  267. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  268. package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
  269. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  270. package/dist/mobile-app.cjs +74 -0
  271. package/dist/mobile-app.cjs.map +1 -0
  272. package/dist/mobile-app.d.cts +73 -0
  273. package/dist/mobile-app.d.cts.map +1 -0
  274. package/dist/mobile-app.d.mts +73 -0
  275. package/dist/mobile-app.d.mts.map +1 -0
  276. package/dist/mobile-app.mjs +73 -0
  277. package/dist/mobile-app.mjs.map +1 -0
  278. package/dist/object-storage.cjs +8 -1
  279. package/dist/object-storage.cjs.map +1 -1
  280. package/dist/object-storage.d.cts +10 -1
  281. package/dist/object-storage.d.cts.map +1 -1
  282. package/dist/object-storage.d.mts +10 -1
  283. package/dist/object-storage.d.mts.map +1 -1
  284. package/dist/object-storage.mjs +7 -2
  285. package/dist/object-storage.mjs.map +1 -1
  286. package/dist/optionalPeers-D7Wt6dnF.mjs +140 -0
  287. package/dist/optionalPeers-D7Wt6dnF.mjs.map +1 -0
  288. package/dist/optionalPeers-DuNQXXe1.cjs +223 -0
  289. package/dist/optionalPeers-DuNQXXe1.cjs.map +1 -0
  290. package/dist/origins-BjxYht13.cjs +96 -0
  291. package/dist/origins-BjxYht13.cjs.map +1 -0
  292. package/dist/origins-Boc9qbo-.mjs +73 -0
  293. package/dist/origins-Boc9qbo-.mjs.map +1 -0
  294. package/dist/pattern-C1CEcglD.mjs +241 -0
  295. package/dist/pattern-C1CEcglD.mjs.map +1 -0
  296. package/dist/pattern-QFaUIr77.cjs +288 -0
  297. package/dist/pattern-QFaUIr77.cjs.map +1 -0
  298. package/dist/privateAddress-Bg5fUsbp.mjs +21 -0
  299. package/dist/privateAddress-Bg5fUsbp.mjs.map +1 -0
  300. package/dist/privateAddress-CqGyuFHn.cjs +26 -0
  301. package/dist/privateAddress-CqGyuFHn.cjs.map +1 -0
  302. package/dist/processors/index.cjs +214 -0
  303. package/dist/processors/index.cjs.map +1 -0
  304. package/dist/processors/index.d.cts +78 -0
  305. package/dist/processors/index.d.cts.map +1 -0
  306. package/dist/processors/index.d.mts +78 -0
  307. package/dist/processors/index.d.mts.map +1 -0
  308. package/dist/processors/index.mjs +193 -0
  309. package/dist/processors/index.mjs.map +1 -0
  310. package/dist/queue/index.cjs +5 -192
  311. package/dist/queue/index.d.cts +3 -53
  312. package/dist/queue/index.d.mts +3 -53
  313. package/dist/queue/index.mjs +3 -190
  314. package/dist/random-password.cjs +86 -0
  315. package/dist/random-password.cjs.map +1 -0
  316. package/dist/random-password.d.cts +30 -0
  317. package/dist/random-password.d.cts.map +1 -0
  318. package/dist/random-password.d.mts +30 -0
  319. package/dist/random-password.d.mts.map +1 -0
  320. package/dist/random-password.mjs +84 -0
  321. package/dist/random-password.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 +85 -70
  331. package/dist/rest-api.cjs.map +1 -1
  332. package/dist/rest-api.d.cts +77 -59
  333. package/dist/rest-api.d.cts.map +1 -1
  334. package/dist/rest-api.d.mts +77 -59
  335. package/dist/rest-api.d.mts.map +1 -1
  336. package/dist/rest-api.mjs +87 -72
  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 +104 -8
  347. package/dist/site.cjs.map +1 -1
  348. package/dist/site.d.cts +132 -2
  349. package/dist/site.d.cts.map +1 -1
  350. package/dist/site.d.mts +132 -2
  351. package/dist/site.d.mts.map +1 -1
  352. package/dist/site.mjs +102 -11
  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-C1oqncFY.d.cts +40 -0
  367. package/dist/telemetry-C1oqncFY.d.cts.map +1 -0
  368. package/dist/telemetry-CObow3Dn.d.mts +40 -0
  369. package/dist/telemetry-CObow3Dn.d.mts.map +1 -0
  370. package/dist/telemetry.cjs +56 -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 +55 -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-Bg9SowJ5.mjs +1710 -0
  385. package/dist/websocket-api-Bg9SowJ5.mjs.map +1 -0
  386. package/dist/websocket-api-CPEzJyDt.d.mts +1201 -0
  387. package/dist/websocket-api-CPEzJyDt.d.mts.map +1 -0
  388. package/dist/websocket-api-DkF8Hva-.d.cts +1201 -0
  389. package/dist/websocket-api-DkF8Hva-.d.cts.map +1 -0
  390. package/dist/websocket-api-czxhekGG.cjs +1889 -0
  391. package/dist/websocket-api-czxhekGG.cjs.map +1 -0
  392. package/dist/websocket-api.cjs +35 -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/auth.d.cts CHANGED
@@ -1,104 +1,2 @@
1
- import { n as Consumable, t as Construct } from "./construct-interface-DgXTJcOD.cjs";
2
- import { Service, ServiceRegisterOptions } from "@geekmidas/services";
3
- import { ConstructName, Declaration } from "@geekmidas/manifest";
4
- import { Hono } from "hono";
5
- import { betterAuth } from "better-auth";
6
- //#region src/auth.d.ts
7
- /** The server better-auth hands back. */
8
- export type AuthServer = ReturnType<typeof betterAuth>;
9
- /** Everything better-auth takes, minus what the construct owns. */
10
- export type BetterAuthOptions = Omit<Parameters<typeof betterAuth>[0], 'database' | 'secret' | 'basePath' | 'baseURL'>;
11
- export interface BetterAuthConfig<TDatabase extends Consumable> {
12
- /**
13
- * The schema tenant its tables live in.
14
- *
15
- * A construct rather than a URL: the tenant already declares its schema and
16
- * its role, and taking the declaration is what puts the edge in the graph
17
- * instead of a connection string in two places.
18
- */
19
- database: TDatabase;
20
- /**
21
- * The app that serves this auth server, relative to the workspace root —
22
- * `'apps/auth'`.
23
- *
24
- * Required, for the reason `RestApi.path` is. Not to be confused with
25
- * `basePath`, which is where its routes are mounted in a URL.
26
- */
27
- path: string;
28
- /**
29
- * Where the auth routes are mounted, e.g. `/api/auth`.
30
- *
31
- * Structural — it is part of the URL every client calls, so it cannot differ
32
- * between stages the way the host can.
33
- */
34
- basePath?: string;
35
- /**
36
- * The rest of better-auth's options: providers, plugins, email settings.
37
- *
38
- * A function when they need another construct — a magic-link plugin has to
39
- * *send* the link, and the thing that sends mail is a construct whose client
40
- * has to be registered. It is handed the same `ServiceRegisterOptions` this
41
- * construct was, so the env parser flows through the graph rather than being
42
- * imported out of application config.
43
- */
44
- options?: BetterAuthOptions | ((options: ServiceRegisterOptions) => BetterAuthOptions | Promise<BetterAuthOptions>);
45
- }
46
- export declare class BetterAuth<TName extends string = string, TDatabase extends Consumable = Consumable> implements Construct<TName, AuthServer> {
47
- private readonly config;
48
- readonly id: TName;
49
- readonly service: Service<Uncapitalize<TName>, AuthServer>;
50
- readonly basePath: string;
51
- /**
52
- * Declared once and read by both `declare()` and `connect()`, so the keys the
53
- * target publishes and the keys the server reads cannot drift.
54
- */
55
- private readonly keys;
56
- constructor(id: ConstructName<TName>, config: BetterAuthConfig<TDatabase>);
57
- /**
58
- * A signing secret and a surface.
59
- *
60
- * The database is *not* declared here — the tenant that was passed in
61
- * declares it, and declaring it twice is the duplication the whole model
62
- * removes. What is declared is what this construct owns: the key it signs
63
- * with, and the routes it answers on.
64
- *
65
- * One endpoint, wildcarded. Better Auth routes internally and the set of
66
- * paths depends on which capabilities are enabled, so enumerating them here
67
- * would be a copy of its router that goes stale on its next release. The
68
- * surface's job is to send everything under `basePath` to one handler, which
69
- * is exactly what the declaration says.
70
- */
71
- declare(): Declaration[];
72
- /**
73
- * Better Auth's own migrations, for the app's migrate step.
74
- *
75
- * It brings its own schema — users, sessions, accounts, verifications — so
76
- * the app never writes those tables and never gets to drift from them.
77
- */
78
- migrations(options: ServiceRegisterOptions): Promise<() => Promise<void>>;
79
- /**
80
- * The server this surface runs as, built from its own declaration.
81
- *
82
- * A surface is a deploy unit, so something has to serve it, and the thing
83
- * that knows how is the construct — not a generator writing a mount into
84
- * somebody else's entry point. That is how the auth server came to be
85
- * mounted by a hook in the application it was supposed to be separate from,
86
- * and then to be served by nothing at all when the hook was deleted.
87
- *
88
- * The routes come from {@link declare}: one wildcard under `basePath`, read
89
- * off the same declaration the manifest carries, so the surface the graph
90
- * describes and the surface that answers requests cannot disagree.
91
- *
92
- * ```ts
93
- * // .gkm/server/app.ts — the whole generated entry
94
- * import { auth } from '@acme/constructs/auth.js';
95
- * export const { app } = await auth.server({ envParser });
96
- * ```
97
- */
98
- server(options: ServiceRegisterOptions): Promise<{
99
- app: Hono;
100
- }>;
101
- private connect;
102
- }
103
- //#endregion
104
- //# sourceMappingURL=auth.d.cts.map
1
+ import { a as BetterAuth, c as BetterAuthOptionsContext, d as deviceLink, f as idempotent, i as AuthSession, l as ExpoPluginRequired, n as AuthServer, o as BetterAuthConfig, p as withTrustedClientIp, r as AuthServerUnreachable, s as BetterAuthOptions, t as AuthClient, u as SessionCheckFailed } from "./auth-BqWz2JxC.cjs";
2
+ export { AuthClient, AuthServer, AuthServerUnreachable, AuthSession, BetterAuth, BetterAuthConfig, BetterAuthOptions, BetterAuthOptionsContext, ExpoPluginRequired, SessionCheckFailed, deviceLink, idempotent, withTrustedClientIp };
package/dist/auth.d.mts CHANGED
@@ -1,104 +1,2 @@
1
- import { n as Consumable, t as Construct } from "./construct-interface-DPlxfpoS.mjs";
2
- import { ConstructName, Declaration } from "@geekmidas/manifest";
3
- import { betterAuth } from "better-auth";
4
- import { Service, ServiceRegisterOptions } from "@geekmidas/services";
5
- import { Hono } from "hono";
6
- //#region src/auth.d.ts
7
- /** The server better-auth hands back. */
8
- export type AuthServer = ReturnType<typeof betterAuth>;
9
- /** Everything better-auth takes, minus what the construct owns. */
10
- export type BetterAuthOptions = Omit<Parameters<typeof betterAuth>[0], 'database' | 'secret' | 'basePath' | 'baseURL'>;
11
- export interface BetterAuthConfig<TDatabase extends Consumable> {
12
- /**
13
- * The schema tenant its tables live in.
14
- *
15
- * A construct rather than a URL: the tenant already declares its schema and
16
- * its role, and taking the declaration is what puts the edge in the graph
17
- * instead of a connection string in two places.
18
- */
19
- database: TDatabase;
20
- /**
21
- * The app that serves this auth server, relative to the workspace root —
22
- * `'apps/auth'`.
23
- *
24
- * Required, for the reason `RestApi.path` is. Not to be confused with
25
- * `basePath`, which is where its routes are mounted in a URL.
26
- */
27
- path: string;
28
- /**
29
- * Where the auth routes are mounted, e.g. `/api/auth`.
30
- *
31
- * Structural — it is part of the URL every client calls, so it cannot differ
32
- * between stages the way the host can.
33
- */
34
- basePath?: string;
35
- /**
36
- * The rest of better-auth's options: providers, plugins, email settings.
37
- *
38
- * A function when they need another construct — a magic-link plugin has to
39
- * *send* the link, and the thing that sends mail is a construct whose client
40
- * has to be registered. It is handed the same `ServiceRegisterOptions` this
41
- * construct was, so the env parser flows through the graph rather than being
42
- * imported out of application config.
43
- */
44
- options?: BetterAuthOptions | ((options: ServiceRegisterOptions) => BetterAuthOptions | Promise<BetterAuthOptions>);
45
- }
46
- export declare class BetterAuth<TName extends string = string, TDatabase extends Consumable = Consumable> implements Construct<TName, AuthServer> {
47
- private readonly config;
48
- readonly id: TName;
49
- readonly service: Service<Uncapitalize<TName>, AuthServer>;
50
- readonly basePath: string;
51
- /**
52
- * Declared once and read by both `declare()` and `connect()`, so the keys the
53
- * target publishes and the keys the server reads cannot drift.
54
- */
55
- private readonly keys;
56
- constructor(id: ConstructName<TName>, config: BetterAuthConfig<TDatabase>);
57
- /**
58
- * A signing secret and a surface.
59
- *
60
- * The database is *not* declared here — the tenant that was passed in
61
- * declares it, and declaring it twice is the duplication the whole model
62
- * removes. What is declared is what this construct owns: the key it signs
63
- * with, and the routes it answers on.
64
- *
65
- * One endpoint, wildcarded. Better Auth routes internally and the set of
66
- * paths depends on which capabilities are enabled, so enumerating them here
67
- * would be a copy of its router that goes stale on its next release. The
68
- * surface's job is to send everything under `basePath` to one handler, which
69
- * is exactly what the declaration says.
70
- */
71
- declare(): Declaration[];
72
- /**
73
- * Better Auth's own migrations, for the app's migrate step.
74
- *
75
- * It brings its own schema — users, sessions, accounts, verifications — so
76
- * the app never writes those tables and never gets to drift from them.
77
- */
78
- migrations(options: ServiceRegisterOptions): Promise<() => Promise<void>>;
79
- /**
80
- * The server this surface runs as, built from its own declaration.
81
- *
82
- * A surface is a deploy unit, so something has to serve it, and the thing
83
- * that knows how is the construct — not a generator writing a mount into
84
- * somebody else's entry point. That is how the auth server came to be
85
- * mounted by a hook in the application it was supposed to be separate from,
86
- * and then to be served by nothing at all when the hook was deleted.
87
- *
88
- * The routes come from {@link declare}: one wildcard under `basePath`, read
89
- * off the same declaration the manifest carries, so the surface the graph
90
- * describes and the surface that answers requests cannot disagree.
91
- *
92
- * ```ts
93
- * // .gkm/server/app.ts — the whole generated entry
94
- * import { auth } from '@acme/constructs/auth.js';
95
- * export const { app } = await auth.server({ envParser });
96
- * ```
97
- */
98
- server(options: ServiceRegisterOptions): Promise<{
99
- app: Hono;
100
- }>;
101
- private connect;
102
- }
103
- //#endregion
104
- //# sourceMappingURL=auth.d.mts.map
1
+ import { a as BetterAuth, c as BetterAuthOptionsContext, d as deviceLink, f as idempotent, i as AuthSession, l as ExpoPluginRequired, n as AuthServer, o as BetterAuthConfig, p as withTrustedClientIp, r as AuthServerUnreachable, s as BetterAuthOptions, t as AuthClient, u as SessionCheckFailed } from "./auth-DnB9H9KL.mjs";
2
+ export { AuthClient, AuthServer, AuthServerUnreachable, AuthSession, BetterAuth, BetterAuthConfig, BetterAuthOptions, BetterAuthOptionsContext, ExpoPluginRequired, SessionCheckFailed, deviceLink, idempotent, withTrustedClientIp };
package/dist/auth.mjs CHANGED
@@ -1,6 +1,9 @@
1
1
  import { edgeTo } from "./construct-interface.mjs";
2
- import { canonicalId, environmentCase, provideKey, serviceKey } from "@geekmidas/manifest";
3
- import { betterAuth } from "better-auth";
2
+ import { a as loadBetterAuthMigration, c as loadHono, i as loadBetterAuth, l as loadHonoCors } from "./optionalPeers-D7Wt6dnF.mjs";
3
+ import { n as injectTraceContext } from "./tracing-Bbj1uoFJ.mjs";
4
+ import { t as isPrivateAddress } from "./privateAddress-Bg5fUsbp.mjs";
5
+ import { CLIENT_IP_HEADER, EDGE_TOKEN_HEADER, EDGE_TOKEN_KEY, canonicalId, environmentCase, isWebOrigin, provideKey, serviceKey } from "@geekmidas/manifest";
6
+ import { timingSafeEqual } from "node:crypto";
4
7
  //#region src/auth.ts
5
8
  /**
6
9
  * `BetterAuth` — a declared auth server.
@@ -32,6 +35,17 @@ const DEFAULT_BASE_PATH = "/api/auth";
32
35
  var BetterAuth = class {
33
36
  config;
34
37
  id;
38
+ /**
39
+ * What `.dependsOn([auth])` injects: an {@link AuthClient}, never the server.
40
+ *
41
+ * Which of the two a process holds is decided by how it reaches the
42
+ * construct, not by asking where it is running. The auth app's process is
43
+ * its generated entry, which calls {@link server} and nothing else — a
44
+ * self-serving surface has no endpoints of its own for a `dependsOn` to sit
45
+ * on. Every other process reaches it through this. So the API, a worker, a
46
+ * test's in-process endpoints all get the client, and none of them needs
47
+ * the signing secret, the auth tenant's URL or the mailer to start.
48
+ */
35
49
  service;
36
50
  basePath;
37
51
  /**
@@ -54,7 +68,7 @@ var BetterAuth = class {
54
68
  };
55
69
  this.service = {
56
70
  serviceName: serviceKey(canonical),
57
- register: (options) => this.connect(options)
71
+ register: (options) => this.client(options.envParser)
58
72
  };
59
73
  }
60
74
  /**
@@ -80,32 +94,79 @@ var BetterAuth = class {
80
94
  kind: "rest-api",
81
95
  id: this.id,
82
96
  path: this.config.path,
97
+ ...this.config.subdomain ? { subdomain: this.config.subdomain } : {},
98
+ ...this.config.telemetry ? { telemetry: this.config.telemetry.id } : {},
83
99
  provides: [
84
100
  this.keys.url,
85
101
  this.keys.trustedOrigins,
86
102
  this.keys.cookieDomain
87
103
  ],
104
+ servesItself: true,
88
105
  endpoints: [{
89
106
  id: `${this.id}Handler`,
90
107
  handler: `${this.id}.handler`,
91
108
  method: "ANY",
92
109
  path: `${this.basePath}/*`,
93
- dependencies: [edgeTo(this.config.database)],
110
+ dependencies: [edgeTo(this.config.database), ...(this.config.dependsOn ?? []).map(edgeTo)],
94
111
  requires: [this.keys.secret]
95
112
  }]
96
113
  }];
97
114
  }
98
115
  /**
99
- * Better Auth's own migrations, for the app's migrate step.
116
+ * Whose request this is: the session for these headers, or `null`.
117
+ *
118
+ * Asked of the auth server over HTTP, at the URL the `.auth()` edge injects —
119
+ * so it is the same call whether the server runs in this process, beside
120
+ * it, or behind MSW in a test. The same call {@link AuthClient} makes.
121
+ */
122
+ async verify(headers, envParser) {
123
+ return this.client(envParser).api.getSession({ headers });
124
+ }
125
+ /**
126
+ * The client a caller of this server holds: its URL and nothing else.
100
127
  *
101
- * It brings its own schema — users, sessions, accounts, verifications — so
102
- * the app never writes those tables and never gets to drift from them.
128
+ * `<ID>_URL` is the one key a consumer is given for an edge to a surface —
129
+ * the compose network's address between containers, the public one where
130
+ * that is all there is — so this is everything it can know.
103
131
  */
104
- async migrations(options) {
105
- const auth = await this.connect(options, { owner: true });
106
- const { getMigrations } = await import("better-auth/db/migration");
107
- const { runMigrations } = await getMigrations(auth.options);
108
- return runMigrations;
132
+ client(envParser) {
133
+ const { url, edgeToken } = envParser.create((get) => ({
134
+ url: get(this.keys.url).string(),
135
+ edgeToken: get(EDGE_TOKEN_KEY).string().optional()
136
+ })).parse();
137
+ const endpoint = `${url.replace(/\/$/, "")}${this.basePath}`;
138
+ return { api: { getSession: ({ headers }) => fetchSession(this.id, endpoint, new Headers(headers), edgeToken) } };
139
+ }
140
+ /**
141
+ * The tenant this server keeps its tables in — whose migrations folder,
142
+ * `db/<tenant>/`, Better Auth's schema is written into.
143
+ */
144
+ get databaseId() {
145
+ return this.config.database.id;
146
+ }
147
+ /**
148
+ * The SQL that brings the tenant up to Better Auth's schema, or `undefined`
149
+ * when it already matches.
150
+ *
151
+ * What `gkm migration` writes as the tenant's next migration, so Better
152
+ * Auth's tables are committed, reviewed and applied like any other — rather
153
+ * than diffed against the database at runtime, where a change nobody wrote
154
+ * down happens on whichever machine migrates first.
155
+ *
156
+ * Compared as the owner, against the tenant `gkm migrate` has already brought
157
+ * up to date: what comes back is only what the committed files are missing.
158
+ */
159
+ async pendingMigration(options) {
160
+ const resolved = await this.optionsFor(options, { owner: true });
161
+ const db = resolved.database.db;
162
+ try {
163
+ const { getMigrations } = await loadBetterAuthMigration();
164
+ const { toBeCreated, toBeAdded, toBeAddedIndexes, compileMigrations } = await getMigrations(resolved);
165
+ if (toBeCreated.length === 0 && toBeAdded.length === 0 && toBeAddedIndexes.length === 0) return;
166
+ return idempotent(await compileMigrations());
167
+ } finally {
168
+ await db.destroy();
169
+ }
109
170
  }
110
171
  /**
111
172
  * The server this surface runs as, built from its own declaration.
@@ -125,13 +186,21 @@ var BetterAuth = class {
125
186
  * import { auth } from '@acme/constructs/auth.js';
126
187
  * export const { app } = await auth.server({ envParser });
127
188
  * ```
189
+ *
190
+ * The only way to the server: it is what reads the signing secret, opens
191
+ * the tenant and builds the mailer, so it is built here, in the auth app's
192
+ * own process, and `.dependsOn([auth])` everywhere else gets
193
+ * {@link AuthClient}. `auth` is the better-auth instance behind the app.
128
194
  */
129
195
  async server(options) {
130
- const { Hono } = await import("hono");
131
- const { cors } = await import("hono/cors");
196
+ const { Hono } = await loadHono("An Auth");
197
+ const { cors } = await loadHonoCors("An Auth");
132
198
  const app = new Hono();
133
199
  const server = await this.connect(options);
134
- const { origins } = options.envParser.create((get) => ({ origins: get(this.keys.trustedOrigins).string().default("").transform((value) => value.split(",").map((origin) => origin.trim()).filter(Boolean)) })).parse();
200
+ const { origins, edgeToken } = options.envParser.create((get) => ({
201
+ edgeToken: get(EDGE_TOKEN_KEY).string().optional(),
202
+ origins: get(this.keys.trustedOrigins).string().default("").transform((value) => value.split(",").map((origin) => origin.trim()).filter(Boolean))
203
+ })).parse();
135
204
  app.use("*", cors({
136
205
  origin: origins,
137
206
  credentials: true,
@@ -147,22 +216,60 @@ var BetterAuth = class {
147
216
  "DELETE",
148
217
  "OPTIONS"
149
218
  ] : [endpoint.method];
150
- app.on([...methods], endpoint.path, (c) => server.handler(c.req.raw));
219
+ app.on([...methods], endpoint.path, (c) => server.handler(withTrustedClientIp(c.req.raw, remoteAddressOf(c), edgeToken)));
151
220
  }
152
- return { app };
221
+ return {
222
+ app,
223
+ auth: server
224
+ };
225
+ }
226
+ /**
227
+ * The ids of the better-auth plugins this server runs — what a client has
228
+ * to pair its own plugins with (`magic-link` with `magicLinkClient`).
229
+ * Resolved the way the server resolves them, options callback included.
230
+ */
231
+ async pluginIds(options) {
232
+ const { plugins = [] } = await this.configured(options);
233
+ return plugins.map(({ id }) => id);
234
+ }
235
+ /** Better-auth's options as given — a value, or a callback of the environment. */
236
+ async configured(options) {
237
+ const configure = this.config.options;
238
+ if (typeof configure !== "function") return configure ?? {};
239
+ const services = {};
240
+ for (const construct of this.config.dependsOn ?? []) services[construct.service.serviceName] = await construct.service.register(options);
241
+ return configure({
242
+ ...options,
243
+ services
244
+ });
153
245
  }
154
246
  async connect(options, as = {}) {
155
- const { secret, baseUrl, trustedOrigins, cookieDomain } = options.envParser.create((get) => ({
247
+ const { betterAuth } = await loadBetterAuth();
248
+ return betterAuth(await this.optionsFor(options, as));
249
+ }
250
+ /**
251
+ * Everything better-auth is given: the app's options, and what the construct
252
+ * owns — its secret, its URL, its tenant's connection, the origins and cookie
253
+ * domain its graph derives. One place, so the server and its migrations are
254
+ * built from the same options.
255
+ */
256
+ async optionsFor(options, as = {}) {
257
+ const { secret, baseUrl, trustedOrigins, cookieDomain, deviceUrl } = options.envParser.create((get) => ({
156
258
  secret: get(this.keys.secret).string(),
157
259
  baseUrl: get(this.keys.url).string(),
158
260
  trustedOrigins: get(this.keys.trustedOrigins).string().default("").transform((value) => value.split(",").map((origin) => origin.trim()).filter(Boolean)),
159
- cookieDomain: get(this.keys.cookieDomain).string().optional()
261
+ cookieDomain: get(this.keys.cookieDomain).string().optional(),
262
+ deviceUrl: get(provideKey(this.id, "deviceUrl")).string().optional()
160
263
  })).parse();
161
264
  const tenant = this.config.database;
162
265
  const db = await (as.owner && tenant.owner ? tenant.owner : tenant.service).register(options);
163
- const configure = this.config.options;
164
- const configured = typeof configure === "function" ? await configure(options) : configure ?? {};
165
- return betterAuth({
266
+ const configured = await this.configured(options);
267
+ const origins = [...trustedOrigins, ...configured.trustedOrigins && Array.isArray(configured.trustedOrigins) ? configured.trustedOrigins : []];
268
+ const plugins = [...configured.plugins ?? []];
269
+ const mobile = trustedOrigins.filter((origin) => !isWebOrigin(origin));
270
+ if (mobile.length > 0 && !plugins.some((plugin) => plugin.id === "expo")) throw new ExpoPluginRequired(this.id, mobile);
271
+ if (deviceUrl) for (const plugin of plugins) reachableFromDevice(plugin, deviceUrl);
272
+ return {
166
273
  ...configured,
167
274
  secret,
168
275
  baseURL: baseUrl,
@@ -171,19 +278,191 @@ var BetterAuth = class {
171
278
  db,
172
279
  type: "postgres"
173
280
  },
174
- trustedOrigins: [...trustedOrigins, ...configured.trustedOrigins && Array.isArray(configured.trustedOrigins) ? configured.trustedOrigins : []],
281
+ plugins,
282
+ trustedOrigins: origins,
175
283
  advanced: {
176
284
  ...configured.advanced,
285
+ ipAddress: {
286
+ ...configured.advanced?.ipAddress,
287
+ ipAddressHeaders: [CLIENT_IP_HEADER, ...(configured.advanced?.ipAddress?.ipAddressHeaders ?? ["x-forwarded-for"]).filter((name) => name.toLowerCase() !== CLIENT_IP_HEADER)]
288
+ },
177
289
  ...cookieDomain ? { crossSubDomainCookies: {
178
290
  enabled: true,
179
291
  domain: cookieDomain,
180
292
  ...configured.advanced?.crossSubDomainCookies
181
293
  } } : {}
182
294
  }
183
- });
295
+ };
296
+ }
297
+ };
298
+ /** Links already rewritten — an `options` object is reused across builds. */
299
+ const rewritten = /* @__PURE__ */ new WeakSet();
300
+ /**
301
+ * Build the magic links an app asked for on the address a phone reaches.
302
+ *
303
+ * An app's link carries its scheme as the `callbackURL` (`shop://…`)
304
+ * where a browser's carries a path or an `http(s)` URL — which is how the two
305
+ * are told apart. A browser's link is left alone: it is opened on this
306
+ * machine, where the server's own hostname resolves.
307
+ *
308
+ * Better Auth's magic-link plugin calls `sendMagicLink` through the options
309
+ * object it returns, so wrapping it there is wrapping the call.
310
+ */
311
+ function reachableFromDevice(plugin, deviceUrl) {
312
+ if (plugin.id !== "magic-link") return;
313
+ const options = plugin.options;
314
+ if (!options?.sendMagicLink || rewritten.has(options)) return;
315
+ rewritten.add(options);
316
+ const send = options.sendMagicLink;
317
+ options.sendMagicLink = (data, ...rest) => send({
318
+ ...data,
319
+ url: deviceLink(data.url, deviceUrl)
320
+ }, ...rest);
321
+ }
322
+ /** A magic link moved to the device address when an app is its destination. */
323
+ function deviceLink(url, deviceUrl) {
324
+ try {
325
+ const link = new URL(url);
326
+ const callback = link.searchParams.get("callbackURL") ?? "/";
327
+ if (callback.startsWith("/") || isWebOrigin(callback)) return url;
328
+ return new URL(`${link.pathname}${link.search}`, deviceUrl).toString();
329
+ } catch {
330
+ return url;
331
+ }
332
+ }
333
+ /** A mobile app depends on this auth server, which has no Expo plugin. */
334
+ var ExpoPluginRequired = class extends Error {
335
+ server;
336
+ origins;
337
+ constructor(server, origins) {
338
+ super(`'${server}' is called by a mobile app (${origins[0]}), and a mobile app signs in through Better Auth's Expo plugin: add expo() from '@better-auth/expo' to this auth server's plugins.`);
339
+ this.server = server;
340
+ this.origins = origins;
341
+ this.name = "ExpoPluginRequired";
342
+ }
343
+ };
344
+ /**
345
+ * What is forwarded to the auth server: the headers a session travels in, and
346
+ * the origin the request came from. The API calls the auth server at its
347
+ * public address, through the edge, which marks the call as outside traffic;
348
+ * the origin is what lets the auth server continue the trace exactly when
349
+ * the API did — for a request from one of the sites both trust.
350
+ */
351
+ const SESSION_HEADERS = [
352
+ "cookie",
353
+ "authorization",
354
+ "origin"
355
+ ];
356
+ /**
357
+ * `GET <basePath>/get-session`, read the way Better Auth answers it.
358
+ *
359
+ * Whose request it is travels in {@link CLIENT_IP_HEADER} — the server
360
+ * rate-limits `/get-session` by the client's address, so without it every
361
+ * caller shares the API's one bucket — and never as `X-Forwarded-For`, which
362
+ * marks a request as outside traffic. The call goes to the auth server's
363
+ * public address, through the stack's edge, so the stack's token goes with
364
+ * it ({@link EDGE_TOKEN_HEADER}): the edge keeps gkm's header only on a
365
+ * request carrying it, and the auth server honours it from one. The
366
+ * request's `Origin` is passed on so the trace is continued for a site both
367
+ * trust.
368
+ */
369
+ async function fetchSession(authenticator, endpoint, given, edgeToken) {
370
+ const headers = new Headers();
371
+ for (const name of SESSION_HEADERS) {
372
+ const value = given.get(name);
373
+ if (value) headers.set(name, value);
374
+ }
375
+ const client = given.get("x-forwarded-for");
376
+ if (client) {
377
+ headers.set(CLIENT_IP_HEADER, client);
378
+ if (edgeToken) headers.set(EDGE_TOKEN_HEADER, edgeToken);
379
+ }
380
+ injectTraceContext(headers);
381
+ const url = `${endpoint}/get-session`;
382
+ let response;
383
+ try {
384
+ response = await fetch(url, { headers });
385
+ } catch (cause) {
386
+ throw new AuthServerUnreachable(authenticator, url, cause);
387
+ }
388
+ if (response.status === 401) return null;
389
+ if (!response.ok) throw new SessionCheckFailed(authenticator, response.status);
390
+ return await response.json();
391
+ }
392
+ /** The auth server answered a session check with a failure. */
393
+ var SessionCheckFailed = class extends Error {
394
+ authenticator;
395
+ status;
396
+ constructor(authenticator, status) {
397
+ super(`'${authenticator}' answered a session check with ${status}. A request with no session gets 200 and null, or 401; this is the server failing — check its logs, and that it is running at its URL.`);
398
+ this.authenticator = authenticator;
399
+ this.status = status;
400
+ this.name = "SessionCheckFailed";
401
+ }
402
+ };
403
+ /** A session check never reached the auth server. */
404
+ var AuthServerUnreachable = class extends Error {
405
+ authenticator;
406
+ url;
407
+ constructor(authenticator, url, cause) {
408
+ super(`'${authenticator}' could not be reached at ${url} to check a session. Check that the auth app is running and that this app's ${provideKey(authenticator, "url")} points at it.`, { cause });
409
+ this.authenticator = authenticator;
410
+ this.url = url;
411
+ this.name = "AuthServerUnreachable";
184
412
  }
185
413
  };
414
+ /**
415
+ * Better Auth's DDL, safe to run where its tables already exist.
416
+ *
417
+ * Its SQL is Kysely's, so its shape is known: `create table "…"`, `create index
418
+ * "…"`, `alter table "…" add column "…"`. A database that has been running
419
+ * already has those — Better Auth used to create them at runtime — and the
420
+ * first committed migration would fail on them rather than recording that they
421
+ * are there.
422
+ */
423
+ function idempotent(statements) {
424
+ return statements.replace(/\bcreate table "/gi, "create table if not exists \"").replace(/\bcreate (unique )?index "/gi, (_, unique = "") => `create ${unique}index if not exists "`).replace(/\badd column "/gi, "add column if not exists \"");
425
+ }
426
+ /** Headers a reverse proxy or CDN adds on the way in. */
427
+ const FORWARDING_HEADERS = [
428
+ "forwarded",
429
+ "x-forwarded-for",
430
+ "x-forwarded-host",
431
+ "x-real-ip",
432
+ "cf-connecting-ip",
433
+ "true-client-ip",
434
+ "fastly-client-ip",
435
+ "x-client-ip"
436
+ ];
437
+ /**
438
+ * `request`, without {@link CLIENT_IP_HEADER} unless an internal caller sent
439
+ * it — no `Origin`, no forwarding header, a loopback or private peer: the
440
+ * rule a request's span continues a trace by (`@geekmidas/telescope`'s
441
+ * `isInternalCaller`).
442
+ *
443
+ * The stack's own edges strip the header already. This holds wherever one
444
+ * does not — a platform's proxy, a port published straight to the internet —
445
+ * so a stranger cannot pick the address Better Auth rate-limits them by.
446
+ */
447
+ function withTrustedClientIp(request, remoteAddress, edgeToken) {
448
+ if (!request.headers.has(CLIENT_IP_HEADER)) return request;
449
+ if (!request.headers.has("origin") && !FORWARDING_HEADERS.some((name) => request.headers.has(name)) && isPrivateAddress(remoteAddress) || sameToken(request.headers.get(EDGE_TOKEN_HEADER), edgeToken)) return request;
450
+ const headers = new Headers(request.headers);
451
+ headers.delete(CLIENT_IP_HEADER);
452
+ return new Request(request, { headers });
453
+ }
454
+ /** Whether a request's token is the stack's, compared in constant time. */
455
+ function sameToken(sent, expected) {
456
+ if (!sent || !expected) return false;
457
+ const a = Buffer.from(sent);
458
+ const b = Buffer.from(expected);
459
+ return a.length === b.length && timingSafeEqual(a, b);
460
+ }
461
+ /** The TCP peer of a request served by `@hono/node-server`, when there is one. */
462
+ function remoteAddressOf(c) {
463
+ return c.env?.incoming?.socket?.remoteAddress;
464
+ }
186
465
  //#endregion
187
- export { BetterAuth };
466
+ export { AuthServerUnreachable, BetterAuth, ExpoPluginRequired, SessionCheckFailed, deviceLink, idempotent, withTrustedClientIp };
188
467
 
189
468
  //# sourceMappingURL=auth.mjs.map