@geekmidas/constructs 10.0.0-alpha.9 → 10.0.0-alpha.91

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 (425) hide show
  1. package/README.md +222 -158
  2. package/dist/{Construct-BD5neF7w.mjs → Construct-B1vGBPme.mjs} +33 -34
  3. package/dist/Construct-B1vGBPme.mjs.map +1 -0
  4. package/dist/Construct-BQALFCh2.d.cts +230 -0
  5. package/dist/Construct-BQALFCh2.d.cts.map +1 -0
  6. package/dist/{Construct-CyS3RpTL.cjs → Construct-DUSXuTHP.cjs} +53 -48
  7. package/dist/Construct-DUSXuTHP.cjs.map +1 -0
  8. package/dist/Construct-QXnl3VqT.d.mts +230 -0
  9. package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
  10. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DI3nKoic.d.cts} +15 -9
  11. package/dist/Cron-DI3nKoic.d.cts.map +1 -0
  12. package/dist/{Cron-dh4rUgib.d.mts → Cron-uYAHPnp7.d.mts} +15 -9
  13. package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
  14. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-C0Ek1-RA.cjs} +47 -31
  15. package/dist/CronBuilder-C0Ek1-RA.cjs.map +1 -0
  16. package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
  17. package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
  18. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-Dmix_Pen.mjs} +37 -21
  19. package/dist/CronBuilder-Dmix_Pen.mjs.map +1 -0
  20. package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
  21. package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
  22. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-BG4UJ9oA.mjs} +146 -109
  23. package/dist/Endpoint-BG4UJ9oA.mjs.map +1 -0
  24. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-BoUg8ocM.cjs} +174 -131
  25. package/dist/Endpoint-BoUg8ocM.cjs.map +1 -0
  26. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-Du-NwPX2.d.mts} +83 -91
  27. package/dist/Endpoint-Du-NwPX2.d.mts.map +1 -0
  28. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-aCvBMPoH.d.cts} +82 -90
  29. package/dist/Endpoint-aCvBMPoH.d.cts.map +1 -0
  30. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-BDtsrEvJ.mjs} +57 -76
  31. package/dist/EndpointFactory-BDtsrEvJ.mjs.map +1 -0
  32. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-DJ7gXLpR.cjs} +93 -112
  33. package/dist/EndpointFactory-DJ7gXLpR.cjs.map +1 -0
  34. package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-DMYdJCOj.d.mts} +78 -134
  35. package/dist/EndpointFactory-DMYdJCOj.d.mts.map +1 -0
  36. package/dist/{index-lAO9egTb.d.mts → EndpointFactory-I7s1co3Y.d.cts} +79 -135
  37. package/dist/EndpointFactory-I7s1co3Y.d.cts.map +1 -0
  38. package/dist/Function-DuqGcbOI.d.mts +76 -0
  39. package/dist/Function-DuqGcbOI.d.mts.map +1 -0
  40. package/dist/Function-Pu-1kKZz.d.cts +76 -0
  41. package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-PtPlbeKY.mjs} +75 -56
  43. package/dist/HonoEndpointAdaptor-PtPlbeKY.mjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-zVzVLJEO.cjs} +83 -61
  45. package/dist/HonoEndpointAdaptor-zVzVLJEO.cjs.map +1 -0
  46. package/dist/Queue-A3wfD0it.cjs +109 -0
  47. package/dist/Queue-A3wfD0it.cjs.map +1 -0
  48. package/dist/Queue-D6USGS4q.mjs +104 -0
  49. package/dist/Queue-D6USGS4q.mjs.map +1 -0
  50. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
  51. package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
  52. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
  53. package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
  54. package/dist/QueueBuilder-BjuF0UBl.cjs +135 -0
  55. package/dist/QueueBuilder-BjuF0UBl.cjs.map +1 -0
  56. package/dist/QueueBuilder-Cue73M4t.mjs +118 -0
  57. package/dist/QueueBuilder-Cue73M4t.mjs.map +1 -0
  58. package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
  59. package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
  60. package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
  61. package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
  62. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
  63. package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
  64. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
  65. package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
  66. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-CDy4nHCz.mjs} +50 -24
  67. package/dist/SubscriberBuilder-CDy4nHCz.mjs.map +1 -0
  68. package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
  69. package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
  70. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-D_owVoHo.cjs} +61 -36
  71. package/dist/SubscriberBuilder-D_owVoHo.cjs.map +1 -0
  72. package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
  73. package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
  74. package/dist/Topic-D74b5cgs.mjs +99 -0
  75. package/dist/Topic-D74b5cgs.mjs.map +1 -0
  76. package/dist/Topic-GHxcU8AG.cjs +104 -0
  77. package/dist/Topic-GHxcU8AG.cjs.map +1 -0
  78. package/dist/adaptors/aws.cjs +131 -220
  79. package/dist/adaptors/aws.cjs.map +1 -1
  80. package/dist/adaptors/aws.d.cts +34 -53
  81. package/dist/adaptors/aws.d.cts.map +1 -1
  82. package/dist/adaptors/aws.d.mts +34 -53
  83. package/dist/adaptors/aws.d.mts.map +1 -1
  84. package/dist/adaptors/aws.mjs +102 -193
  85. package/dist/adaptors/aws.mjs.map +1 -1
  86. package/dist/adaptors/hono.cjs +3 -10
  87. package/dist/adaptors/hono.d.cts +7 -16
  88. package/dist/adaptors/hono.d.cts.map +1 -1
  89. package/dist/adaptors/hono.d.mts +8 -17
  90. package/dist/adaptors/hono.d.mts.map +1 -1
  91. package/dist/adaptors/hono.mjs +2 -10
  92. package/dist/adaptors/testing.cjs +743 -89
  93. package/dist/adaptors/testing.cjs.map +1 -1
  94. package/dist/adaptors/testing.d.cts +351 -54
  95. package/dist/adaptors/testing.d.cts.map +1 -1
  96. package/dist/adaptors/testing.d.mts +351 -54
  97. package/dist/adaptors/testing.d.mts.map +1 -1
  98. package/dist/adaptors/testing.mjs +706 -70
  99. package/dist/adaptors/testing.mjs.map +1 -1
  100. package/dist/auth-BMCJN30Y.d.cts +268 -0
  101. package/dist/auth-BMCJN30Y.d.cts.map +1 -0
  102. package/dist/auth-CcuceLYo.d.mts +268 -0
  103. package/dist/auth-CcuceLYo.d.mts.map +1 -0
  104. package/dist/auth.cjs +301 -33
  105. package/dist/auth.cjs.map +1 -1
  106. package/dist/auth.d.cts +2 -108
  107. package/dist/auth.d.mts +2 -108
  108. package/dist/auth.mjs +289 -27
  109. package/dist/auth.mjs.map +1 -1
  110. package/dist/{cache-BrRz3fEB.d.mts → cache-CXh6GIgb.d.mts} +3 -6
  111. package/dist/cache-CXh6GIgb.d.mts.map +1 -0
  112. package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
  113. package/dist/cache-DnGDGly3.d.cts.map +1 -0
  114. package/dist/cache.cjs +68 -2
  115. package/dist/cache.cjs.map +1 -0
  116. package/dist/cache.d.cts +1 -2
  117. package/dist/cache.d.mts +1 -2
  118. package/dist/cache.mjs +67 -2
  119. package/dist/cache.mjs.map +1 -0
  120. package/dist/cipher-C1lEFX63.mjs +225 -0
  121. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  122. package/dist/cipher-CVxfwLjk.cjs +332 -0
  123. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  124. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  125. package/dist/clone-EKNovYHu.mjs.map +1 -0
  126. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  127. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  128. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
  129. package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
  130. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DluK3_da.d.mts} +42 -11
  131. package/dist/construct-interface-DluK3_da.d.mts.map +1 -0
  132. package/dist/construct-interface.cjs +113 -7
  133. package/dist/construct-interface.cjs.map +1 -0
  134. package/dist/construct-interface.d.cts +2 -2
  135. package/dist/construct-interface.d.mts +2 -2
  136. package/dist/construct-interface.mjs +106 -2
  137. package/dist/construct-interface.mjs.map +1 -0
  138. package/dist/credential.cjs +77 -17
  139. package/dist/credential.cjs.map +1 -1
  140. package/dist/credential.d.cts +34 -9
  141. package/dist/credential.d.cts.map +1 -1
  142. package/dist/credential.d.mts +34 -9
  143. package/dist/credential.d.mts.map +1 -1
  144. package/dist/credential.mjs +71 -13
  145. package/dist/credential.mjs.map +1 -1
  146. package/dist/crons/index.cjs +129 -7
  147. package/dist/crons/index.cjs.map +1 -1
  148. package/dist/crons/index.d.cts +45 -11
  149. package/dist/crons/index.d.cts.map +1 -1
  150. package/dist/crons/index.d.mts +45 -11
  151. package/dist/crons/index.d.mts.map +1 -1
  152. package/dist/crons/index.mjs +127 -8
  153. package/dist/crons/index.mjs.map +1 -1
  154. package/dist/database/kysely.cjs +4 -181
  155. package/dist/database/kysely.d.cts +2 -152
  156. package/dist/database/kysely.d.mts +2 -152
  157. package/dist/database/kysely.mjs +2 -180
  158. package/dist/email.cjs +25 -12
  159. package/dist/email.cjs.map +1 -1
  160. package/dist/email.d.cts +3 -7
  161. package/dist/email.d.cts.map +1 -1
  162. package/dist/email.d.mts +3 -7
  163. package/dist/email.d.mts.map +1 -1
  164. package/dist/email.mjs +16 -3
  165. package/dist/email.mjs.map +1 -1
  166. package/dist/encryption.cjs +96 -0
  167. package/dist/encryption.cjs.map +1 -0
  168. package/dist/encryption.d.cts +117 -0
  169. package/dist/encryption.d.cts.map +1 -0
  170. package/dist/encryption.d.mts +117 -0
  171. package/dist/encryption.d.mts.map +1 -0
  172. package/dist/encryption.mjs +83 -0
  173. package/dist/encryption.mjs.map +1 -0
  174. package/dist/endpoints/index.cjs +8 -10
  175. package/dist/endpoints/index.d.cts +51 -7
  176. package/dist/endpoints/index.d.cts.map +1 -0
  177. package/dist/endpoints/index.d.mts +51 -7
  178. package/dist/endpoints/index.d.mts.map +1 -0
  179. package/dist/endpoints/index.mjs +6 -10
  180. package/dist/external-api-MJ8id87V.d.mts +105 -0
  181. package/dist/external-api-MJ8id87V.d.mts.map +1 -0
  182. package/dist/external-api-O107yzZJ.d.cts +105 -0
  183. package/dist/external-api-O107yzZJ.d.cts.map +1 -0
  184. package/dist/external-api.cjs +142 -0
  185. package/dist/external-api.cjs.map +1 -0
  186. package/dist/external-api.d.cts +2 -0
  187. package/dist/external-api.d.mts +2 -0
  188. package/dist/external-api.mjs +139 -0
  189. package/dist/external-api.mjs.map +1 -0
  190. package/dist/file-server.cjs +42 -10
  191. package/dist/file-server.cjs.map +1 -1
  192. package/dist/file-server.d.cts +6 -10
  193. package/dist/file-server.d.cts.map +1 -1
  194. package/dist/file-server.d.mts +6 -10
  195. package/dist/file-server.d.mts.map +1 -1
  196. package/dist/file-server.mjs +34 -2
  197. package/dist/file-server.mjs.map +1 -1
  198. package/dist/functions/index.cjs +3 -6
  199. package/dist/functions/index.d.cts +3 -4
  200. package/dist/functions/index.d.mts +3 -4
  201. package/dist/functions/index.mjs +2 -6
  202. package/dist/{functions-14lpEFL4.mjs → functions-BFizikJU.mjs} +376 -238
  203. package/dist/{functions-14lpEFL4.mjs.map → functions-BFizikJU.mjs.map} +1 -1
  204. package/dist/{functions-i_la-N5r.cjs → functions-CfzJG9hK.cjs} +414 -264
  205. package/dist/functions-CfzJG9hK.cjs.map +1 -0
  206. package/dist/index-BuzRvKOQ.d.cts +115 -0
  207. package/dist/index-BuzRvKOQ.d.cts.map +1 -0
  208. package/dist/index-CTkKOer4.d.mts +115 -0
  209. package/dist/index-CTkKOer4.d.mts.map +1 -0
  210. package/dist/index-CeEtxDmK.d.cts +79 -0
  211. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  212. package/dist/index-CeEtxDmK.d.mts +79 -0
  213. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  214. package/dist/index.cjs +6 -3
  215. package/dist/index.d.cts +27 -4
  216. package/dist/index.d.cts.map +1 -0
  217. package/dist/index.d.mts +27 -4
  218. package/dist/index.d.mts.map +1 -0
  219. package/dist/index.mjs +3 -3
  220. package/dist/kms-B-Hm3d5r.cjs +85 -0
  221. package/dist/kms-B-Hm3d5r.cjs.map +1 -0
  222. package/dist/kms-BdUlMJEZ.mjs +85 -0
  223. package/dist/kms-BdUlMJEZ.mjs.map +1 -0
  224. package/dist/kysely-Bii4l6eP.mjs +370 -0
  225. package/dist/kysely-Bii4l6eP.mjs.map +1 -0
  226. package/dist/kysely-CO_Dk43W.cjs +383 -0
  227. package/dist/kysely-CO_Dk43W.cjs.map +1 -0
  228. package/dist/kysely-D0bpzgPs.d.cts +175 -0
  229. package/dist/kysely-D0bpzgPs.d.cts.map +1 -0
  230. package/dist/kysely-DUqC3Ie0.d.mts +175 -0
  231. package/dist/kysely-DUqC3Ie0.d.mts.map +1 -0
  232. package/dist/{telemetry-C3L0iS28.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +3 -6
  233. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  234. package/dist/{telemetry-D7bVFLGi.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +3 -6
  235. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  236. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
  237. package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
  238. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
  239. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
  240. package/dist/mobile-app.cjs +73 -0
  241. package/dist/mobile-app.cjs.map +1 -0
  242. package/dist/mobile-app.d.cts +61 -0
  243. package/dist/mobile-app.d.cts.map +1 -0
  244. package/dist/mobile-app.d.mts +61 -0
  245. package/dist/mobile-app.d.mts.map +1 -0
  246. package/dist/mobile-app.mjs +72 -0
  247. package/dist/mobile-app.mjs.map +1 -0
  248. package/dist/object-storage.cjs +18 -10
  249. package/dist/object-storage.cjs.map +1 -1
  250. package/dist/object-storage.d.cts +3 -7
  251. package/dist/object-storage.d.cts.map +1 -1
  252. package/dist/object-storage.d.mts +3 -7
  253. package/dist/object-storage.d.mts.map +1 -1
  254. package/dist/object-storage.mjs +11 -3
  255. package/dist/object-storage.mjs.map +1 -1
  256. package/dist/processAudits-BRRVVHUB.mjs +131 -0
  257. package/dist/processAudits-BRRVVHUB.mjs.map +1 -0
  258. package/dist/processAudits-DasOZjPl.cjs +154 -0
  259. package/dist/processAudits-DasOZjPl.cjs.map +1 -0
  260. package/dist/queue/index.cjs +6 -189
  261. package/dist/queue/index.d.cts +3 -60
  262. package/dist/queue/index.d.mts +3 -60
  263. package/dist/queue/index.mjs +3 -186
  264. package/dist/rest-api.cjs +90 -59
  265. package/dist/rest-api.cjs.map +1 -1
  266. package/dist/rest-api.d.cts +70 -42
  267. package/dist/rest-api.d.cts.map +1 -1
  268. package/dist/rest-api.d.mts +70 -42
  269. package/dist/rest-api.d.mts.map +1 -1
  270. package/dist/rest-api.mjs +82 -51
  271. package/dist/rest-api.mjs.map +1 -1
  272. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  273. package/dist/runSubscriber-BHvJ8POr.mjs +109 -0
  274. package/dist/runSubscriber-BHvJ8POr.mjs.map +1 -0
  275. package/dist/runSubscriber-D8nLXIv1.cjs +126 -0
  276. package/dist/runSubscriber-D8nLXIv1.cjs.map +1 -0
  277. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  278. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  279. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  280. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  281. package/dist/site.cjs +33 -7
  282. package/dist/site.cjs.map +1 -1
  283. package/dist/site.d.cts +17 -7
  284. package/dist/site.d.cts.map +1 -1
  285. package/dist/site.d.mts +17 -7
  286. package/dist/site.d.mts.map +1 -1
  287. package/dist/site.mjs +29 -3
  288. package/dist/site.mjs.map +1 -1
  289. package/dist/stages-BSCF19o2.d.cts +56 -0
  290. package/dist/stages-BSCF19o2.d.cts.map +1 -0
  291. package/dist/stages-BSCF19o2.d.mts +56 -0
  292. package/dist/stages-BSCF19o2.d.mts.map +1 -0
  293. package/dist/subscribers/index.cjs +118 -6
  294. package/dist/subscribers/index.cjs.map +1 -0
  295. package/dist/subscribers/index.d.cts +51 -6
  296. package/dist/subscribers/index.d.cts.map +1 -0
  297. package/dist/subscribers/index.d.mts +51 -6
  298. package/dist/subscribers/index.d.mts.map +1 -0
  299. package/dist/subscribers/index.mjs +115 -5
  300. package/dist/subscribers/index.mjs.map +1 -0
  301. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  302. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  303. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  304. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  305. package/dist/telemetry-B48RLjyk.d.cts +40 -0
  306. package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
  307. package/dist/telemetry-DRtT1_0A.d.mts +40 -0
  308. package/dist/telemetry-DRtT1_0A.d.mts.map +1 -0
  309. package/dist/telemetry.cjs +56 -0
  310. package/dist/telemetry.cjs.map +1 -0
  311. package/dist/telemetry.d.cts +2 -0
  312. package/dist/telemetry.d.mts +2 -0
  313. package/dist/telemetry.mjs +55 -0
  314. package/dist/telemetry.mjs.map +1 -0
  315. package/dist/topic/index.cjs +3 -137
  316. package/dist/topic/index.d.cts +2 -4
  317. package/dist/topic/index.d.mts +2 -4
  318. package/dist/topic/index.mjs +2 -134
  319. package/dist/tracing-CxaZ98IB.mjs +110 -0
  320. package/dist/tracing-CxaZ98IB.mjs.map +1 -0
  321. package/dist/tracing-DPMidF_r.cjs +127 -0
  322. package/dist/tracing-DPMidF_r.cjs.map +1 -0
  323. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  324. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  325. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  326. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  327. package/dist/types.d.cts +1 -1
  328. package/dist/types.d.mts +1 -1
  329. package/dist/types.mjs +1 -0
  330. package/dist/worker.cjs +59 -34
  331. package/dist/worker.cjs.map +1 -1
  332. package/dist/worker.d.cts +70 -45
  333. package/dist/worker.d.cts.map +1 -1
  334. package/dist/worker.d.mts +70 -44
  335. package/dist/worker.d.mts.map +1 -1
  336. package/dist/worker.mjs +54 -29
  337. package/dist/worker.mjs.map +1 -1
  338. package/package.json +96 -42
  339. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  340. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  341. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  342. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  343. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  344. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  345. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  346. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  347. package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
  348. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  349. package/dist/CronBuilder-CGgY2080.d.mts +0 -44
  350. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  351. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  352. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  353. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  354. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  355. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  356. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  357. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  358. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  359. package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
  360. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  361. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  362. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  363. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  364. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  365. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  366. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  367. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  368. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  369. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  370. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  371. package/dist/Topic-19QeHBIR.d.cts +0 -91
  372. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  373. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  374. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  375. package/dist/auth.d.cts.map +0 -1
  376. package/dist/auth.d.mts.map +0 -1
  377. package/dist/cache-0ANvRQnD.mjs +0 -51
  378. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  379. package/dist/cache-3WSvAulx.cjs +0 -57
  380. package/dist/cache-3WSvAulx.cjs.map +0 -1
  381. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  382. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  383. package/dist/clone-DblgEZZa.mjs.map +0 -1
  384. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  385. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  386. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  387. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  388. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  389. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  390. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  391. package/dist/database/kysely.cjs.map +0 -1
  392. package/dist/database/kysely.d.cts.map +0 -1
  393. package/dist/database/kysely.d.mts.map +0 -1
  394. package/dist/database/kysely.mjs.map +0 -1
  395. package/dist/functions-i_la-N5r.cjs.map +0 -1
  396. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  397. package/dist/index-BknhM6Ux.d.mts +0 -31
  398. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  399. package/dist/index-CBSfrowv.d.cts +0 -31
  400. package/dist/index-CBSfrowv.d.cts.map +0 -1
  401. package/dist/index-D24Xm79M.d.cts +0 -171
  402. package/dist/index-D24Xm79M.d.cts.map +0 -1
  403. package/dist/index-_ajboYxK.d.mts +0 -171
  404. package/dist/index-_ajboYxK.d.mts.map +0 -1
  405. package/dist/index-lAO9egTb.d.mts.map +0 -1
  406. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  407. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  408. package/dist/processAudits-CGqttuXm.cjs +0 -92
  409. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  410. package/dist/processAudits-Dmts9H_b.mjs +0 -80
  411. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  412. package/dist/queue/index.cjs.map +0 -1
  413. package/dist/queue/index.d.cts.map +0 -1
  414. package/dist/queue/index.d.mts.map +0 -1
  415. package/dist/queue/index.mjs.map +0 -1
  416. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  417. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  418. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  419. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  420. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  421. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  422. package/dist/topic/index.cjs.map +0 -1
  423. package/dist/topic/index.mjs.map +0 -1
  424. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  425. package/dist/types-aKksMEWL.d.mts.map +0 -1
package/dist/auth.d.cts CHANGED
@@ -1,108 +1,2 @@
1
- import { Construct, Consumable } from "./construct-interface-D9d4Gm4p.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
-
7
- //#region src/auth.d.ts
8
-
9
- /** The server better-auth hands back. */
10
- type AuthServer = ReturnType<typeof betterAuth>;
11
- /** Everything better-auth takes, minus what the construct owns. */
12
- type BetterAuthOptions = Omit<Parameters<typeof betterAuth>[0], 'database' | 'secret' | 'basePath' | 'baseURL'>;
13
- interface BetterAuthConfig<TDatabase extends Consumable> {
14
- /**
15
- * The schema tenant its tables live in.
16
- *
17
- * A construct rather than a URL: the tenant already declares its schema and
18
- * its role, and taking the declaration is what puts the edge in the graph
19
- * instead of a connection string in two places.
20
- */
21
- database: TDatabase;
22
- /**
23
- * The app that serves this auth server, relative to the workspace root —
24
- * `'apps/auth'`.
25
- *
26
- * Required, for the reason `RestApi.path` is. Not to be confused with
27
- * `basePath`, which is where its routes are mounted in a URL.
28
- */
29
- path: string;
30
- /**
31
- * Where the auth routes are mounted, e.g. `/api/auth`.
32
- *
33
- * Structural — it is part of the URL every client calls, so it cannot differ
34
- * between stages the way the host can.
35
- */
36
- basePath?: string;
37
- /**
38
- * The rest of better-auth's options: providers, plugins, email settings.
39
- *
40
- * A function when they need another construct — a magic-link plugin has to
41
- * *send* the link, and the thing that sends mail is a construct whose client
42
- * has to be registered. It is handed the same `ServiceRegisterOptions` this
43
- * construct was, so the env parser flows through the graph rather than being
44
- * imported out of application config.
45
- */
46
- options?: BetterAuthOptions | ((options: ServiceRegisterOptions) => BetterAuthOptions | Promise<BetterAuthOptions>);
47
- }
48
- declare class BetterAuth<TName extends string = string, TDatabase extends Consumable = Consumable> implements Construct<TName, AuthServer> {
49
- private readonly config;
50
- readonly id: TName;
51
- readonly service: Service<Uncapitalize<TName>, AuthServer>;
52
- readonly basePath: string;
53
- /**
54
- * Declared once and read by both `declare()` and `connect()`, so the keys the
55
- * target publishes and the keys the server reads cannot drift.
56
- */
57
- private readonly keys;
58
- constructor(id: ConstructName<TName>, config: BetterAuthConfig<TDatabase>);
59
- /**
60
- * A signing secret and a surface.
61
- *
62
- * The database is *not* declared here — the tenant that was passed in
63
- * declares it, and declaring it twice is the duplication the whole model
64
- * removes. What is declared is what this construct owns: the key it signs
65
- * with, and the routes it answers on.
66
- *
67
- * One endpoint, wildcarded. Better Auth routes internally and the set of
68
- * paths depends on which capabilities are enabled, so enumerating them here
69
- * would be a copy of its router that goes stale on its next release. The
70
- * surface's job is to send everything under `basePath` to one handler, which
71
- * is exactly what the declaration says.
72
- */
73
- declare(): Declaration[];
74
- /**
75
- * Better Auth's own migrations, for the app's migrate step.
76
- *
77
- * It brings its own schema — users, sessions, accounts, verifications — so
78
- * the app never writes those tables and never gets to drift from them.
79
- */
80
- migrations(options: ServiceRegisterOptions): Promise<() => Promise<void>>;
81
- /**
82
- * The server this surface runs as, built from its own declaration.
83
- *
84
- * A surface is a deploy unit, so something has to serve it, and the thing
85
- * that knows how is the construct — not a generator writing a mount into
86
- * somebody else's entry point. That is how the auth server came to be
87
- * mounted by a hook in the application it was supposed to be separate from,
88
- * and then to be served by nothing at all when the hook was deleted.
89
- *
90
- * The routes come from {@link declare}: one wildcard under `basePath`, read
91
- * off the same declaration the manifest carries, so the surface the graph
92
- * describes and the surface that answers requests cannot disagree.
93
- *
94
- * ```ts
95
- * // .gkm/server/app.ts — the whole generated entry
96
- * import { auth } from '@acme/constructs/auth.js';
97
- * export const { app } = await auth.server({ envParser });
98
- * ```
99
- */
100
- server(options: ServiceRegisterOptions): Promise<{
101
- app: Hono;
102
- }>;
103
- private connect;
104
- }
105
- //# sourceMappingURL=auth.d.ts.map
106
- //#endregion
107
- export { AuthServer, BetterAuth, BetterAuthConfig, BetterAuthOptions };
108
- //# 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-BMCJN30Y.cjs";
2
+ export { AuthClient, AuthServer, AuthServerUnreachable, AuthSession, BetterAuth, BetterAuthConfig, BetterAuthOptions, BetterAuthOptionsContext, ExpoPluginRequired, SessionCheckFailed, deviceLink, idempotent, withTrustedClientIp };
package/dist/auth.d.mts CHANGED
@@ -1,108 +1,2 @@
1
- import { Construct, Consumable } from "./construct-interface-g5GM5pwR.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
-
7
- //#region src/auth.d.ts
8
-
9
- /** The server better-auth hands back. */
10
- type AuthServer = ReturnType<typeof betterAuth>;
11
- /** Everything better-auth takes, minus what the construct owns. */
12
- type BetterAuthOptions = Omit<Parameters<typeof betterAuth>[0], 'database' | 'secret' | 'basePath' | 'baseURL'>;
13
- interface BetterAuthConfig<TDatabase extends Consumable> {
14
- /**
15
- * The schema tenant its tables live in.
16
- *
17
- * A construct rather than a URL: the tenant already declares its schema and
18
- * its role, and taking the declaration is what puts the edge in the graph
19
- * instead of a connection string in two places.
20
- */
21
- database: TDatabase;
22
- /**
23
- * The app that serves this auth server, relative to the workspace root —
24
- * `'apps/auth'`.
25
- *
26
- * Required, for the reason `RestApi.path` is. Not to be confused with
27
- * `basePath`, which is where its routes are mounted in a URL.
28
- */
29
- path: string;
30
- /**
31
- * Where the auth routes are mounted, e.g. `/api/auth`.
32
- *
33
- * Structural — it is part of the URL every client calls, so it cannot differ
34
- * between stages the way the host can.
35
- */
36
- basePath?: string;
37
- /**
38
- * The rest of better-auth's options: providers, plugins, email settings.
39
- *
40
- * A function when they need another construct — a magic-link plugin has to
41
- * *send* the link, and the thing that sends mail is a construct whose client
42
- * has to be registered. It is handed the same `ServiceRegisterOptions` this
43
- * construct was, so the env parser flows through the graph rather than being
44
- * imported out of application config.
45
- */
46
- options?: BetterAuthOptions | ((options: ServiceRegisterOptions) => BetterAuthOptions | Promise<BetterAuthOptions>);
47
- }
48
- declare class BetterAuth<TName extends string = string, TDatabase extends Consumable = Consumable> implements Construct<TName, AuthServer> {
49
- private readonly config;
50
- readonly id: TName;
51
- readonly service: Service<Uncapitalize<TName>, AuthServer>;
52
- readonly basePath: string;
53
- /**
54
- * Declared once and read by both `declare()` and `connect()`, so the keys the
55
- * target publishes and the keys the server reads cannot drift.
56
- */
57
- private readonly keys;
58
- constructor(id: ConstructName<TName>, config: BetterAuthConfig<TDatabase>);
59
- /**
60
- * A signing secret and a surface.
61
- *
62
- * The database is *not* declared here — the tenant that was passed in
63
- * declares it, and declaring it twice is the duplication the whole model
64
- * removes. What is declared is what this construct owns: the key it signs
65
- * with, and the routes it answers on.
66
- *
67
- * One endpoint, wildcarded. Better Auth routes internally and the set of
68
- * paths depends on which capabilities are enabled, so enumerating them here
69
- * would be a copy of its router that goes stale on its next release. The
70
- * surface's job is to send everything under `basePath` to one handler, which
71
- * is exactly what the declaration says.
72
- */
73
- declare(): Declaration[];
74
- /**
75
- * Better Auth's own migrations, for the app's migrate step.
76
- *
77
- * It brings its own schema — users, sessions, accounts, verifications — so
78
- * the app never writes those tables and never gets to drift from them.
79
- */
80
- migrations(options: ServiceRegisterOptions): Promise<() => Promise<void>>;
81
- /**
82
- * The server this surface runs as, built from its own declaration.
83
- *
84
- * A surface is a deploy unit, so something has to serve it, and the thing
85
- * that knows how is the construct — not a generator writing a mount into
86
- * somebody else's entry point. That is how the auth server came to be
87
- * mounted by a hook in the application it was supposed to be separate from,
88
- * and then to be served by nothing at all when the hook was deleted.
89
- *
90
- * The routes come from {@link declare}: one wildcard under `basePath`, read
91
- * off the same declaration the manifest carries, so the surface the graph
92
- * describes and the surface that answers requests cannot disagree.
93
- *
94
- * ```ts
95
- * // .gkm/server/app.ts — the whole generated entry
96
- * import { auth } from '@acme/constructs/auth.js';
97
- * export const { app } = await auth.server({ envParser });
98
- * ```
99
- */
100
- server(options: ServiceRegisterOptions): Promise<{
101
- app: Hono;
102
- }>;
103
- private connect;
104
- }
105
- //# sourceMappingURL=auth.d.ts.map
106
- //#endregion
107
- export { AuthServer, BetterAuth, BetterAuthConfig, BetterAuthOptions };
108
- //# 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-CcuceLYo.mjs";
2
+ export { AuthClient, AuthServer, AuthServerUnreachable, AuthSession, BetterAuth, BetterAuthConfig, BetterAuthOptions, BetterAuthOptionsContext, ExpoPluginRequired, SessionCheckFailed, deviceLink, idempotent, withTrustedClientIp };
package/dist/auth.mjs CHANGED
@@ -1,11 +1,22 @@
1
- import { edgeTo } from "./construct-interface-Z4CpS8tK.mjs";
2
- import { canonicalId, environmentCase, provideKey, serviceKey } from "@geekmidas/manifest";
3
- import { betterAuth } from "better-auth";
4
-
1
+ import { edgeTo } from "./construct-interface.mjs";
2
+ import { t as injectTraceContext } from "./tracing-CxaZ98IB.mjs";
3
+ import { CLIENT_IP_HEADER, canonicalId, environmentCase, isWebOrigin, provideKey, serviceKey } from "@geekmidas/manifest";
5
4
  //#region src/auth.ts
6
5
  const DEFAULT_BASE_PATH = "/api/auth";
7
6
  var BetterAuth = class {
7
+ config;
8
8
  id;
9
+ /**
10
+ * What `.dependsOn([auth])` injects: an {@link AuthClient}, never the server.
11
+ *
12
+ * Which of the two a process holds is decided by how it reaches the
13
+ * construct, not by asking where it is running. The auth app's process is
14
+ * its generated entry, which calls {@link server} and nothing else — a
15
+ * self-serving surface has no endpoints of its own for a `dependsOn` to sit
16
+ * on. Every other process reaches it through this. So the API, a worker, a
17
+ * test's in-process endpoints all get the client, and none of them needs
18
+ * the signing secret, the auth tenant's URL or the mailer to start.
19
+ */
9
20
  service;
10
21
  basePath;
11
22
  /**
@@ -28,7 +39,7 @@ var BetterAuth = class {
28
39
  };
29
40
  this.service = {
30
41
  serviceName: serviceKey(canonical),
31
- register: (options) => this.connect(options)
42
+ register: (options) => this.client(options.envParser)
32
43
  };
33
44
  }
34
45
  /**
@@ -54,6 +65,8 @@ var BetterAuth = class {
54
65
  kind: "rest-api",
55
66
  id: this.id,
56
67
  path: this.config.path,
68
+ ...this.config.subdomain ? { subdomain: this.config.subdomain } : {},
69
+ ...this.config.telemetry ? { telemetry: this.config.telemetry.id } : {},
57
70
  provides: [
58
71
  this.keys.url,
59
72
  this.keys.trustedOrigins,
@@ -64,22 +77,63 @@ var BetterAuth = class {
64
77
  handler: `${this.id}.handler`,
65
78
  method: "ANY",
66
79
  path: `${this.basePath}/*`,
67
- dependencies: [edgeTo(this.config.database)],
80
+ dependencies: [edgeTo(this.config.database), ...(this.config.dependsOn ?? []).map(edgeTo)],
68
81
  requires: [this.keys.secret]
69
82
  }]
70
83
  }];
71
84
  }
72
85
  /**
73
- * Better Auth's own migrations, for the app's migrate step.
86
+ * Whose request this is: the session for these headers, or `null`.
87
+ *
88
+ * Asked of the auth server over HTTP, at the URL the `.auth()` edge injects —
89
+ * so it is the same call whether the server runs in this process, beside
90
+ * it, or behind MSW in a test. The same call {@link AuthClient} makes.
91
+ */
92
+ async verify(headers, envParser) {
93
+ return this.client(envParser).api.getSession({ headers });
94
+ }
95
+ /**
96
+ * The client a caller of this server holds: its URL and nothing else.
97
+ *
98
+ * `<ID>_URL` is the one key a consumer is given for an edge to a surface —
99
+ * the compose network's address between containers, the public one where
100
+ * that is all there is — so this is everything it can know.
101
+ */
102
+ client(envParser) {
103
+ const { url } = envParser.create((get) => ({ url: get(this.keys.url).string() })).parse();
104
+ const endpoint = `${url.replace(/\/$/, "")}${this.basePath}`;
105
+ return { api: { getSession: ({ headers }) => fetchSession(this.id, endpoint, new Headers(headers)) } };
106
+ }
107
+ /**
108
+ * The tenant this server keeps its tables in — whose migrations folder,
109
+ * `db/<tenant>/`, Better Auth's schema is written into.
110
+ */
111
+ get databaseId() {
112
+ return this.config.database.id;
113
+ }
114
+ /**
115
+ * The SQL that brings the tenant up to Better Auth's schema, or `undefined`
116
+ * when it already matches.
117
+ *
118
+ * What `gkm migration` writes as the tenant's next migration, so Better
119
+ * Auth's tables are committed, reviewed and applied like any other — rather
120
+ * than diffed against the database at runtime, where a change nobody wrote
121
+ * down happens on whichever machine migrates first.
74
122
  *
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.
123
+ * Compared as the owner, against the tenant `gkm migrate` has already brought
124
+ * up to date: what comes back is only what the committed files are missing.
77
125
  */
78
- async migrations(options) {
79
- const auth = await this.connect(options, { owner: true });
80
- const { getMigrations } = await import("better-auth/db/migration");
81
- const { runMigrations } = await getMigrations(auth.options);
82
- return runMigrations;
126
+ async pendingMigration(options) {
127
+ const resolved = await this.optionsFor(options, { owner: true });
128
+ const db = resolved.database.db;
129
+ try {
130
+ const { getMigrations } = await import("better-auth/db/migration");
131
+ const { toBeCreated, toBeAdded, toBeAddedIndexes, compileMigrations } = await getMigrations(resolved);
132
+ if (toBeCreated.length === 0 && toBeAdded.length === 0 && toBeAddedIndexes.length === 0) return;
133
+ return idempotent(await compileMigrations());
134
+ } finally {
135
+ await db.destroy();
136
+ }
83
137
  }
84
138
  /**
85
139
  * The server this surface runs as, built from its own declaration.
@@ -99,6 +153,11 @@ var BetterAuth = class {
99
153
  * import { auth } from '@acme/constructs/auth.js';
100
154
  * export const { app } = await auth.server({ envParser });
101
155
  * ```
156
+ *
157
+ * The only way to the server: it is what reads the signing secret, opens
158
+ * the tenant and builds the mailer, so it is built here, in the auth app's
159
+ * own process, and `.dependsOn([auth])` everywhere else gets
160
+ * {@link AuthClient}. `auth` is the better-auth instance behind the app.
102
161
  */
103
162
  async server(options) {
104
163
  const { Hono } = await import("hono");
@@ -121,23 +180,60 @@ var BetterAuth = class {
121
180
  "DELETE",
122
181
  "OPTIONS"
123
182
  ] : [endpoint.method];
124
- app.on([...methods], endpoint.path, (c) => server.handler(c.req.raw));
183
+ app.on([...methods], endpoint.path, (c) => server.handler(withTrustedClientIp(c.req.raw, remoteAddressOf(c))));
125
184
  }
126
- return { app };
185
+ return {
186
+ app,
187
+ auth: server
188
+ };
189
+ }
190
+ /**
191
+ * The ids of the better-auth plugins this server runs — what a client has
192
+ * to pair its own plugins with (`magic-link` with `magicLinkClient`).
193
+ * Resolved the way the server resolves them, options callback included.
194
+ */
195
+ async pluginIds(options) {
196
+ const { plugins = [] } = await this.configured(options);
197
+ return plugins.map(({ id }) => id);
198
+ }
199
+ /** Better-auth's options as given — a value, or a callback of the environment. */
200
+ async configured(options) {
201
+ const configure = this.config.options;
202
+ if (typeof configure !== "function") return configure ?? {};
203
+ const services = {};
204
+ for (const construct of this.config.dependsOn ?? []) services[construct.service.serviceName] = await construct.service.register(options);
205
+ return configure({
206
+ ...options,
207
+ services
208
+ });
127
209
  }
128
210
  async connect(options, as = {}) {
129
- const { secret, baseUrl, trustedOrigins, cookieDomain } = options.envParser.create((get) => ({
211
+ const { betterAuth } = await import("better-auth");
212
+ return betterAuth(await this.optionsFor(options, as));
213
+ }
214
+ /**
215
+ * Everything better-auth is given: the app's options, and what the construct
216
+ * owns — its secret, its URL, its tenant's connection, the origins and cookie
217
+ * domain its graph derives. One place, so the server and its migrations are
218
+ * built from the same options.
219
+ */
220
+ async optionsFor(options, as = {}) {
221
+ const { secret, baseUrl, trustedOrigins, cookieDomain, deviceUrl } = options.envParser.create((get) => ({
130
222
  secret: get(this.keys.secret).string(),
131
223
  baseUrl: get(this.keys.url).string(),
132
224
  trustedOrigins: get(this.keys.trustedOrigins).string().default("").transform((value) => value.split(",").map((origin) => origin.trim()).filter(Boolean)),
133
- cookieDomain: get(this.keys.cookieDomain).string().optional()
225
+ cookieDomain: get(this.keys.cookieDomain).string().optional(),
226
+ deviceUrl: get(provideKey(this.id, "deviceUrl")).string().optional()
134
227
  })).parse();
135
228
  const tenant = this.config.database;
136
- const source = as.owner && tenant.owner ? tenant.owner : tenant.service;
137
- const db = await source.register(options);
138
- const configure = this.config.options;
139
- const configured = typeof configure === "function" ? await configure(options) : configure ?? {};
140
- return betterAuth({
229
+ const db = await (as.owner && tenant.owner ? tenant.owner : tenant.service).register(options);
230
+ const configured = await this.configured(options);
231
+ const origins = [...trustedOrigins, ...configured.trustedOrigins && Array.isArray(configured.trustedOrigins) ? configured.trustedOrigins : []];
232
+ const plugins = [...configured.plugins ?? []];
233
+ const mobile = trustedOrigins.filter((origin) => !isWebOrigin(origin));
234
+ if (mobile.length > 0 && !plugins.some((plugin) => plugin.id === "expo")) throw new ExpoPluginRequired(this.id, mobile);
235
+ if (deviceUrl) for (const plugin of plugins) reachableFromDevice(plugin, deviceUrl);
236
+ return {
141
237
  ...configured,
142
238
  secret,
143
239
  baseURL: baseUrl,
@@ -146,19 +242,185 @@ var BetterAuth = class {
146
242
  db,
147
243
  type: "postgres"
148
244
  },
149
- trustedOrigins: [...trustedOrigins, ...configured.trustedOrigins && Array.isArray(configured.trustedOrigins) ? configured.trustedOrigins : []],
245
+ plugins,
246
+ trustedOrigins: origins,
150
247
  advanced: {
151
248
  ...configured.advanced,
249
+ ipAddress: {
250
+ ...configured.advanced?.ipAddress,
251
+ ipAddressHeaders: [CLIENT_IP_HEADER, ...(configured.advanced?.ipAddress?.ipAddressHeaders ?? ["x-forwarded-for"]).filter((name) => name.toLowerCase() !== CLIENT_IP_HEADER)]
252
+ },
152
253
  ...cookieDomain ? { crossSubDomainCookies: {
153
254
  enabled: true,
154
255
  domain: cookieDomain,
155
256
  ...configured.advanced?.crossSubDomainCookies
156
257
  } } : {}
157
258
  }
158
- });
259
+ };
159
260
  }
160
261
  };
161
-
262
+ /** Links already rewritten — an `options` object is reused across builds. */
263
+ const rewritten = /* @__PURE__ */ new WeakSet();
264
+ /**
265
+ * Build the magic links an app asked for on the address a phone reaches.
266
+ *
267
+ * An app's link carries its scheme as the `callbackURL` (`shop://…`)
268
+ * where a browser's carries a path or an `http(s)` URL — which is how the two
269
+ * are told apart. A browser's link is left alone: it is opened on this
270
+ * machine, where the server's own hostname resolves.
271
+ *
272
+ * Better Auth's magic-link plugin calls `sendMagicLink` through the options
273
+ * object it returns, so wrapping it there is wrapping the call.
274
+ */
275
+ function reachableFromDevice(plugin, deviceUrl) {
276
+ if (plugin.id !== "magic-link") return;
277
+ const options = plugin.options;
278
+ if (!options?.sendMagicLink || rewritten.has(options)) return;
279
+ rewritten.add(options);
280
+ const send = options.sendMagicLink;
281
+ options.sendMagicLink = (data, ...rest) => send({
282
+ ...data,
283
+ url: deviceLink(data.url, deviceUrl)
284
+ }, ...rest);
285
+ }
286
+ /** A magic link moved to the device address when an app is its destination. */
287
+ function deviceLink(url, deviceUrl) {
288
+ try {
289
+ const link = new URL(url);
290
+ const callback = link.searchParams.get("callbackURL") ?? "/";
291
+ if (callback.startsWith("/") || isWebOrigin(callback)) return url;
292
+ return new URL(`${link.pathname}${link.search}`, deviceUrl).toString();
293
+ } catch {
294
+ return url;
295
+ }
296
+ }
297
+ /** A mobile app depends on this auth server, which has no Expo plugin. */
298
+ var ExpoPluginRequired = class extends Error {
299
+ server;
300
+ origins;
301
+ constructor(server, origins) {
302
+ 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.`);
303
+ this.server = server;
304
+ this.origins = origins;
305
+ this.name = "ExpoPluginRequired";
306
+ }
307
+ };
308
+ /** What is forwarded to the auth server: the headers a session travels in. */
309
+ const SESSION_HEADERS = ["cookie", "authorization"];
310
+ /**
311
+ * `GET <basePath>/get-session`, read the way Better Auth answers it.
312
+ *
313
+ * Whose request it is travels in {@link CLIENT_IP_HEADER} — the server
314
+ * rate-limits `/get-session` by the client's address, so without it every
315
+ * caller shares the API's one bucket — and never as `X-Forwarded-For`. A
316
+ * forwarding header is what marks a request as outside traffic, so the auth
317
+ * server would start its span in a trace of its own rather than continue the
318
+ * API's. Without one, this is an internal caller's request, and the trace
319
+ * context it carries is continued.
320
+ */
321
+ async function fetchSession(authenticator, endpoint, given) {
322
+ const headers = new Headers();
323
+ for (const name of SESSION_HEADERS) {
324
+ const value = given.get(name);
325
+ if (value) headers.set(name, value);
326
+ }
327
+ const client = given.get("x-forwarded-for");
328
+ if (client) headers.set(CLIENT_IP_HEADER, client);
329
+ injectTraceContext(headers);
330
+ const url = `${endpoint}/get-session`;
331
+ let response;
332
+ try {
333
+ response = await fetch(url, { headers });
334
+ } catch (cause) {
335
+ throw new AuthServerUnreachable(authenticator, url, cause);
336
+ }
337
+ if (response.status === 401) return null;
338
+ if (!response.ok) throw new SessionCheckFailed(authenticator, response.status);
339
+ return await response.json();
340
+ }
341
+ /** The auth server answered a session check with a failure. */
342
+ var SessionCheckFailed = class extends Error {
343
+ authenticator;
344
+ status;
345
+ constructor(authenticator, status) {
346
+ 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.`);
347
+ this.authenticator = authenticator;
348
+ this.status = status;
349
+ this.name = "SessionCheckFailed";
350
+ }
351
+ };
352
+ /** A session check never reached the auth server. */
353
+ var AuthServerUnreachable = class extends Error {
354
+ authenticator;
355
+ url;
356
+ constructor(authenticator, url, cause) {
357
+ 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 });
358
+ this.authenticator = authenticator;
359
+ this.url = url;
360
+ this.name = "AuthServerUnreachable";
361
+ }
362
+ };
363
+ /**
364
+ * Better Auth's DDL, safe to run where its tables already exist.
365
+ *
366
+ * Its SQL is Kysely's, so its shape is known: `create table "…"`, `create index
367
+ * "…"`, `alter table "…" add column "…"`. A database that has been running
368
+ * already has those — Better Auth used to create them at runtime — and the
369
+ * first committed migration would fail on them rather than recording that they
370
+ * are there.
371
+ */
372
+ function idempotent(statements) {
373
+ 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 \"");
374
+ }
375
+ /** Headers a reverse proxy or CDN adds on the way in. */
376
+ const FORWARDING_HEADERS = [
377
+ "forwarded",
378
+ "x-forwarded-for",
379
+ "x-forwarded-host",
380
+ "x-real-ip",
381
+ "cf-connecting-ip",
382
+ "true-client-ip",
383
+ "fastly-client-ip",
384
+ "x-client-ip"
385
+ ];
386
+ /**
387
+ * `request`, without {@link CLIENT_IP_HEADER} unless an internal caller sent
388
+ * it — no `Origin`, no forwarding header, a loopback or private peer: the
389
+ * rule a request's span continues a trace by (`@geekmidas/telescope`'s
390
+ * `isInternalCaller`).
391
+ *
392
+ * The stack's own edges strip the header already. This holds wherever one
393
+ * does not — a platform's proxy, a port published straight to the internet —
394
+ * so a stranger cannot pick the address Better Auth rate-limits them by.
395
+ */
396
+ function withTrustedClientIp(request, remoteAddress) {
397
+ if (!request.headers.has(CLIENT_IP_HEADER)) return request;
398
+ if (!request.headers.has("origin") && !FORWARDING_HEADERS.some((name) => request.headers.has(name)) && isPrivateAddress(remoteAddress)) return request;
399
+ const headers = new Headers(request.headers);
400
+ headers.delete(CLIENT_IP_HEADER);
401
+ return new Request(request, { headers });
402
+ }
403
+ /** The TCP peer of a request served by `@hono/node-server`, when there is one. */
404
+ function remoteAddressOf(c) {
405
+ return c.env?.incoming?.socket?.remoteAddress;
406
+ }
407
+ /**
408
+ * Whether `address` is loopback or private: 127/8, 10/8, 172.16/12,
409
+ * 192.168/16, 169.254/16, `::1`, `fc00::/7`, `fe80::/10`, and an IPv4 one
410
+ * mapped into IPv6.
411
+ */
412
+ function isPrivateAddress(address) {
413
+ if (!address) return false;
414
+ const ip = address.toLowerCase().replace(/^::ffff:/, "");
415
+ const v4 = ip.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
416
+ if (v4) {
417
+ const [a, b] = [Number(v4[1]), Number(v4[2])];
418
+ return a === 127 || a === 10 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 169 && b === 254;
419
+ }
420
+ if (ip === "::1") return true;
421
+ return /^f[cd][0-9a-f]{2}:/.test(ip) || /^fe[89ab][0-9a-f]:/.test(ip);
422
+ }
162
423
  //#endregion
163
- export { BetterAuth };
424
+ export { AuthServerUnreachable, BetterAuth, ExpoPluginRequired, SessionCheckFailed, deviceLink, idempotent, withTrustedClientIp };
425
+
164
426
  //# sourceMappingURL=auth.mjs.map