@softistx/alxia-react-router 0.0.0-stage → 0.83.1

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 (609) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2085 -2
  3. package/dist/api-keys/api-keys.d.ts +93 -0
  4. package/dist/api-keys/api-keys.d.ts.map +1 -0
  5. package/dist/api-keys/index.d.ts +9 -0
  6. package/dist/api-keys/index.d.ts.map +1 -0
  7. package/dist/api-keys/index.js +66 -0
  8. package/dist/api-keys/index.js.map +10 -0
  9. package/dist/assets.d.ts +14 -0
  10. package/dist/assets.d.ts.map +1 -0
  11. package/dist/chunks/index-0786n4qe.js +25 -0
  12. package/dist/chunks/index-0786n4qe.js.map +10 -0
  13. package/dist/chunks/index-1nw5yeek.js +169 -0
  14. package/dist/chunks/index-1nw5yeek.js.map +11 -0
  15. package/dist/chunks/index-59vhfj6n.js +10 -0
  16. package/dist/chunks/index-59vhfj6n.js.map +10 -0
  17. package/dist/chunks/index-5gqcpyyg.js +34 -0
  18. package/dist/chunks/index-5gqcpyyg.js.map +10 -0
  19. package/dist/chunks/index-6jf7zpxz.js +119 -0
  20. package/dist/chunks/index-6jf7zpxz.js.map +11 -0
  21. package/dist/chunks/index-8as4j8m3.js +340 -0
  22. package/dist/chunks/index-8as4j8m3.js.map +16 -0
  23. package/dist/chunks/index-9xv2a8et.js +108 -0
  24. package/dist/chunks/index-9xv2a8et.js.map +11 -0
  25. package/dist/chunks/index-ajtvyq35.js +16 -0
  26. package/dist/chunks/index-ajtvyq35.js.map +10 -0
  27. package/dist/chunks/index-c55hxgr5.js +124 -0
  28. package/dist/chunks/index-c55hxgr5.js.map +14 -0
  29. package/dist/chunks/index-d42p3mdp.js +19 -0
  30. package/dist/chunks/index-d42p3mdp.js.map +10 -0
  31. package/dist/chunks/index-gac44rs5.js +42 -0
  32. package/dist/chunks/index-gac44rs5.js.map +11 -0
  33. package/dist/chunks/index-j4ktpcke.js +62 -0
  34. package/dist/chunks/index-j4ktpcke.js.map +10 -0
  35. package/dist/chunks/index-mscfme4r.js +12 -0
  36. package/dist/chunks/index-mscfme4r.js.map +10 -0
  37. package/dist/chunks/index-pghmb2dm.js +30 -0
  38. package/dist/chunks/index-pghmb2dm.js.map +10 -0
  39. package/dist/chunks/index-rfr02vg4.js +40 -0
  40. package/dist/chunks/index-rfr02vg4.js.map +10 -0
  41. package/dist/chunks/index-sfhshxqz.js +31 -0
  42. package/dist/chunks/index-sfhshxqz.js.map +10 -0
  43. package/dist/chunks/index-skwypsjz.js +357 -0
  44. package/dist/chunks/index-skwypsjz.js.map +12 -0
  45. package/dist/chunks/index-sxh06ged.js +118 -0
  46. package/dist/chunks/index-sxh06ged.js.map +11 -0
  47. package/dist/chunks/index-t2ph23wk.js +96 -0
  48. package/dist/chunks/index-t2ph23wk.js.map +13 -0
  49. package/dist/chunks/index-thyabr5n.js +19 -0
  50. package/dist/chunks/index-thyabr5n.js.map +10 -0
  51. package/dist/chunks/index-tx36swjx.js +134 -0
  52. package/dist/chunks/index-tx36swjx.js.map +11 -0
  53. package/dist/chunks/index-v2z5k640.js +54 -0
  54. package/dist/chunks/index-v2z5k640.js.map +11 -0
  55. package/dist/chunks/index-vr82typq.js +23 -0
  56. package/dist/chunks/index-vr82typq.js.map +11 -0
  57. package/dist/chunks/index-whj6h5eg.js +9 -0
  58. package/dist/chunks/index-whj6h5eg.js.map +10 -0
  59. package/dist/chunks/index-wyypkfdv.js +130 -0
  60. package/dist/chunks/index-wyypkfdv.js.map +13 -0
  61. package/dist/chunks/index-xd5aqy3g.js +90 -0
  62. package/dist/chunks/index-xd5aqy3g.js.map +10 -0
  63. package/dist/chunks/index-zdbqzcjp.js +97 -0
  64. package/dist/chunks/index-zdbqzcjp.js.map +12 -0
  65. package/dist/chunks/index-zyg8amjc.js +23 -0
  66. package/dist/chunks/index-zyg8amjc.js.map +10 -0
  67. package/dist/cli/index.d.ts +3 -0
  68. package/dist/cli/index.d.ts.map +1 -0
  69. package/dist/cli/index.js +215 -0
  70. package/dist/cli/index.js.map +13 -0
  71. package/dist/cli/main.d.ts +13 -0
  72. package/dist/cli/main.d.ts.map +1 -0
  73. package/dist/cli/reveal.d.ts +18 -0
  74. package/dist/cli/reveal.d.ts.map +1 -0
  75. package/dist/cli/template.d.ts +8 -0
  76. package/dist/cli/template.d.ts.map +1 -0
  77. package/dist/context.d.ts +104 -0
  78. package/dist/context.d.ts.map +1 -0
  79. package/dist/document/index.d.ts +11 -0
  80. package/dist/document/index.d.ts.map +1 -0
  81. package/dist/document/index.js +19 -0
  82. package/dist/document/index.js.map +9 -0
  83. package/dist/document/inline-script.d.ts +27 -0
  84. package/dist/document/inline-script.d.ts.map +1 -0
  85. package/dist/document/language-store.d.ts +8 -0
  86. package/dist/document/language-store.d.ts.map +1 -0
  87. package/dist/document/nonce.d.ts +34 -0
  88. package/dist/document/nonce.d.ts.map +1 -0
  89. package/dist/document/page-language.d.ts +39 -0
  90. package/dist/document/page-language.d.ts.map +1 -0
  91. package/dist/document/text-direction.d.ts +10 -0
  92. package/dist/document/text-direction.d.ts.map +1 -0
  93. package/dist/entry/abort.d.ts +21 -0
  94. package/dist/entry/abort.d.ts.map +1 -0
  95. package/dist/entry/create-entry.d.ts +41 -0
  96. package/dist/entry/create-entry.d.ts.map +1 -0
  97. package/dist/entry/index.d.ts +8 -0
  98. package/dist/entry/index.d.ts.map +1 -0
  99. package/dist/entry/index.js +154 -0
  100. package/dist/entry/index.js.map +13 -0
  101. package/dist/entry/root-data.d.ts +27 -0
  102. package/dist/entry/root-data.d.ts.map +1 -0
  103. package/dist/entry/whole-page.d.ts +10 -0
  104. package/dist/entry/whole-page.d.ts.map +1 -0
  105. package/dist/errors/api-error.d.ts +117 -0
  106. package/dist/errors/api-error.d.ts.map +1 -0
  107. package/dist/errors/api-errors.d.ts +122 -0
  108. package/dist/errors/api-errors.d.ts.map +1 -0
  109. package/dist/errors/call-failure.d.ts +45 -0
  110. package/dist/errors/call-failure.d.ts.map +1 -0
  111. package/dist/errors/catalogue-check.d.ts +24 -0
  112. package/dist/errors/catalogue-check.d.ts.map +1 -0
  113. package/dist/errors/catalogue-read.d.ts +33 -0
  114. package/dist/errors/catalogue-read.d.ts.map +1 -0
  115. package/dist/errors/catalogue.d.ts +59 -0
  116. package/dist/errors/catalogue.d.ts.map +1 -0
  117. package/dist/errors/code-resolver.d.ts +44 -0
  118. package/dist/errors/code-resolver.d.ts.map +1 -0
  119. package/dist/errors/cross-site.d.ts +8 -0
  120. package/dist/errors/cross-site.d.ts.map +1 -0
  121. package/dist/errors/describe-refusal.d.ts +6 -0
  122. package/dist/errors/describe-refusal.d.ts.map +1 -0
  123. package/dist/errors/describe.d.ts +3 -0
  124. package/dist/errors/describe.d.ts.map +1 -0
  125. package/dist/errors/fetcher-result.d.ts +33 -0
  126. package/dist/errors/fetcher-result.d.ts.map +1 -0
  127. package/dist/errors/field-placement.d.ts +12 -0
  128. package/dist/errors/field-placement.d.ts.map +1 -0
  129. package/dist/errors/form-errors.d.ts +8 -0
  130. package/dist/errors/form-errors.d.ts.map +1 -0
  131. package/dist/errors/form-refusal.d.ts +25 -0
  132. package/dist/errors/form-refusal.d.ts.map +1 -0
  133. package/dist/errors/index.d.ts +21 -0
  134. package/dist/errors/index.d.ts.map +1 -0
  135. package/dist/errors/index.js +588 -0
  136. package/dist/errors/index.js.map +26 -0
  137. package/dist/errors/json-actions.d.ts +38 -0
  138. package/dist/errors/json-actions.d.ts.map +1 -0
  139. package/dist/errors/log.d.ts +8 -0
  140. package/dist/errors/log.d.ts.map +1 -0
  141. package/dist/errors/message-values.d.ts +11 -0
  142. package/dist/errors/message-values.d.ts.map +1 -0
  143. package/dist/errors/messages.d.ts +63 -0
  144. package/dist/errors/messages.d.ts.map +1 -0
  145. package/dist/errors/page-path.d.ts +9 -0
  146. package/dist/errors/page-path.d.ts.map +1 -0
  147. package/dist/errors/problem-error.d.ts +50 -0
  148. package/dist/errors/problem-error.d.ts.map +1 -0
  149. package/dist/errors/provider.d.ts +20 -0
  150. package/dist/errors/provider.d.ts.map +1 -0
  151. package/dist/errors/request-id.d.ts +5 -0
  152. package/dist/errors/request-id.d.ts.map +1 -0
  153. package/dist/errors/route-error.d.ts +33 -0
  154. package/dist/errors/route-error.d.ts.map +1 -0
  155. package/dist/errors/route-refusal.d.ts +20 -0
  156. package/dist/errors/route-refusal.d.ts.map +1 -0
  157. package/dist/errors/same-site.d.ts +49 -0
  158. package/dist/errors/same-site.d.ts.map +1 -0
  159. package/dist/errors/section-action.d.ts +46 -0
  160. package/dist/errors/section-action.d.ts.map +1 -0
  161. package/dist/errors/standard-schema.d.ts +34 -0
  162. package/dist/errors/standard-schema.d.ts.map +1 -0
  163. package/dist/errors/submit-form.d.ts +16 -0
  164. package/dist/errors/submit-form.d.ts.map +1 -0
  165. package/dist/errors/upstream-headers.d.ts +18 -0
  166. package/dist/errors/upstream-headers.d.ts.map +1 -0
  167. package/dist/errors/use-json-fetcher.d.ts +18 -0
  168. package/dist/errors/use-json-fetcher.d.ts.map +1 -0
  169. package/dist/fetcher/auth-refusal.d.ts +29 -0
  170. package/dist/fetcher/auth-refusal.d.ts.map +1 -0
  171. package/dist/fetcher/index.d.ts +20 -0
  172. package/dist/fetcher/index.d.ts.map +1 -0
  173. package/dist/fetcher/index.js +392 -0
  174. package/dist/fetcher/index.js.map +21 -0
  175. package/dist/fetcher/section-form.d.ts +24 -0
  176. package/dist/fetcher/section-form.d.ts.map +1 -0
  177. package/dist/fetcher/section-reload.d.ts +17 -0
  178. package/dist/fetcher/section-reload.d.ts.map +1 -0
  179. package/dist/fetcher/section-save.d.ts +29 -0
  180. package/dist/fetcher/section-save.d.ts.map +1 -0
  181. package/dist/fetcher/use-debounced-fetcher.d.ts +57 -0
  182. package/dist/fetcher/use-debounced-fetcher.d.ts.map +1 -0
  183. package/dist/fetcher/use-fetcher-answer.d.ts +16 -0
  184. package/dist/fetcher/use-fetcher-answer.d.ts.map +1 -0
  185. package/dist/fetcher/use-fetcher-done.d.ts +15 -0
  186. package/dist/fetcher/use-fetcher-done.d.ts.map +1 -0
  187. package/dist/fetcher/use-fetcher-promise.d.ts +48 -0
  188. package/dist/fetcher/use-fetcher-promise.d.ts.map +1 -0
  189. package/dist/fetcher/use-form-refusal.d.ts +20 -0
  190. package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
  191. package/dist/fetcher/use-revalidate-on-focus.d.ts +20 -0
  192. package/dist/fetcher/use-revalidate-on-focus.d.ts.map +1 -0
  193. package/dist/fetcher/use-row-save.d.ts +32 -0
  194. package/dist/fetcher/use-row-save.d.ts.map +1 -0
  195. package/dist/fetcher/use-section-save.d.ts +46 -0
  196. package/dist/fetcher/use-section-save.d.ts.map +1 -0
  197. package/dist/fetcher/use-visible-interval.d.ts +24 -0
  198. package/dist/fetcher/use-visible-interval.d.ts.map +1 -0
  199. package/dist/fetcher/use-visible-revalidation.d.ts +10 -0
  200. package/dist/fetcher/use-visible-revalidation.d.ts.map +1 -0
  201. package/dist/health.d.ts +21 -0
  202. package/dist/health.d.ts.map +1 -0
  203. package/dist/help/check/check.d.ts +35 -0
  204. package/dist/help/check/check.d.ts.map +1 -0
  205. package/dist/help/check/index.d.ts +8 -0
  206. package/dist/help/check/index.d.ts.map +1 -0
  207. package/dist/help/check/index.js +17 -0
  208. package/dist/help/check/index.js.map +9 -0
  209. package/dist/help/check/routes.d.ts +22 -0
  210. package/dist/help/check/routes.d.ts.map +1 -0
  211. package/dist/help/guide.d.ts +33 -0
  212. package/dist/help/guide.d.ts.map +1 -0
  213. package/dist/help/index.d.ts +16 -0
  214. package/dist/help/index.d.ts.map +1 -0
  215. package/dist/help/index.js +192 -0
  216. package/dist/help/index.js.map +14 -0
  217. package/dist/help/load.d.ts +39 -0
  218. package/dist/help/load.d.ts.map +1 -0
  219. package/dist/help/panel.d.ts +69 -0
  220. package/dist/help/panel.d.ts.map +1 -0
  221. package/dist/help/parse-flow.d.ts +27 -0
  222. package/dist/help/parse-flow.d.ts.map +1 -0
  223. package/dist/help/react.d.ts +12 -0
  224. package/dist/help/react.d.ts.map +1 -0
  225. package/dist/help/resolve.d.ts +24 -0
  226. package/dist/help/resolve.d.ts.map +1 -0
  227. package/dist/help/types.d.ts +50 -0
  228. package/dist/help/types.d.ts.map +1 -0
  229. package/dist/help/yaml.d.ts +18 -0
  230. package/dist/help/yaml.d.ts.map +1 -0
  231. package/dist/index.d.ts +7 -0
  232. package/dist/index.d.ts.map +1 -0
  233. package/dist/index.js +197 -0
  234. package/dist/index.js.map +14 -0
  235. package/dist/link/index.d.ts +7 -0
  236. package/dist/link/index.d.ts.map +1 -0
  237. package/dist/link/index.js +16 -0
  238. package/dist/link/index.js.map +10 -0
  239. package/dist/link/router-link.d.ts +27 -0
  240. package/dist/link/router-link.d.ts.map +1 -0
  241. package/dist/lists/connection-page.d.ts +50 -0
  242. package/dist/lists/connection-page.d.ts.map +1 -0
  243. package/dist/lists/index.d.ts +13 -0
  244. package/dist/lists/index.d.ts.map +1 -0
  245. package/dist/lists/index.js +205 -0
  246. package/dist/lists/index.js.map +15 -0
  247. package/dist/lists/newest-first.d.ts +5 -0
  248. package/dist/lists/newest-first.d.ts.map +1 -0
  249. package/dist/lists/nodes-of.d.ts +21 -0
  250. package/dist/lists/nodes-of.d.ts.map +1 -0
  251. package/dist/lists/or-failed.d.ts +19 -0
  252. package/dist/lists/or-failed.d.ts.map +1 -0
  253. package/dist/lists/use-paged-rows.d.ts +40 -0
  254. package/dist/lists/use-paged-rows.d.ts.map +1 -0
  255. package/dist/lists/use-same-route-loading.d.ts +8 -0
  256. package/dist/lists/use-same-route-loading.d.ts.map +1 -0
  257. package/dist/lists/use-search-change.d.ts +20 -0
  258. package/dist/lists/use-search-change.d.ts.map +1 -0
  259. package/dist/mcp/index.d.ts +8 -0
  260. package/dist/mcp/index.d.ts.map +1 -0
  261. package/dist/mcp/index.js +105 -0
  262. package/dist/mcp/index.js.map +11 -0
  263. package/dist/mcp/mcp-relay.d.ts +58 -0
  264. package/dist/mcp/mcp-relay.d.ts.map +1 -0
  265. package/dist/mcp/relay.d.ts +38 -0
  266. package/dist/mcp/relay.d.ts.map +1 -0
  267. package/dist/media/client/error.d.ts +29 -0
  268. package/dist/media/client/error.d.ts.map +1 -0
  269. package/dist/media/client/index.d.ts +8 -0
  270. package/dist/media/client/index.d.ts.map +1 -0
  271. package/dist/media/client/index.js +133 -0
  272. package/dist/media/client/index.js.map +11 -0
  273. package/dist/media/client/upload.d.ts +32 -0
  274. package/dist/media/client/upload.d.ts.map +1 -0
  275. package/dist/media/forward.d.ts +14 -0
  276. package/dist/media/forward.d.ts.map +1 -0
  277. package/dist/media/headers.d.ts +11 -0
  278. package/dist/media/headers.d.ts.map +1 -0
  279. package/dist/media/index.d.ts +9 -0
  280. package/dist/media/index.d.ts.map +1 -0
  281. package/dist/media/index.js +396 -0
  282. package/dist/media/index.js.map +16 -0
  283. package/dist/media/options.d.ts +114 -0
  284. package/dist/media/options.d.ts.map +1 -0
  285. package/dist/media/path.d.ts +12 -0
  286. package/dist/media/path.d.ts.map +1 -0
  287. package/dist/media/read.d.ts +11 -0
  288. package/dist/media/read.d.ts.map +1 -0
  289. package/dist/media/refusal.d.ts +11 -0
  290. package/dist/media/refusal.d.ts.map +1 -0
  291. package/dist/media/respond.d.ts +8 -0
  292. package/dist/media/respond.d.ts.map +1 -0
  293. package/dist/media/write.d.ts +13 -0
  294. package/dist/media/write.d.ts.map +1 -0
  295. package/dist/navigation/index.d.ts +9 -0
  296. package/dist/navigation/index.d.ts.map +1 -0
  297. package/dist/navigation/index.js +48 -0
  298. package/dist/navigation/index.js.map +11 -0
  299. package/dist/navigation/use-focus-on-navigate.d.ts +16 -0
  300. package/dist/navigation/use-focus-on-navigate.d.ts.map +1 -0
  301. package/dist/navigation/use-route-transition.d.ts +19 -0
  302. package/dist/navigation/use-route-transition.d.ts.map +1 -0
  303. package/dist/nonce.d.ts +16 -0
  304. package/dist/nonce.d.ts.map +1 -0
  305. package/dist/oauth/answer.d.ts +33 -0
  306. package/dist/oauth/answer.d.ts.map +1 -0
  307. package/dist/oauth/binding.d.ts +43 -0
  308. package/dist/oauth/binding.d.ts.map +1 -0
  309. package/dist/oauth/consent.d.ts +134 -0
  310. package/dist/oauth/consent.d.ts.map +1 -0
  311. package/dist/oauth/grants.d.ts +88 -0
  312. package/dist/oauth/grants.d.ts.map +1 -0
  313. package/dist/oauth/index.d.ts +16 -0
  314. package/dist/oauth/index.d.ts.map +1 -0
  315. package/dist/oauth/index.js +207 -0
  316. package/dist/oauth/index.js.map +12 -0
  317. package/dist/oauth/model.d.ts +13 -0
  318. package/dist/oauth/model.d.ts.map +1 -0
  319. package/dist/oauth/react/index.d.ts +7 -0
  320. package/dist/oauth/react/index.d.ts.map +1 -0
  321. package/dist/oauth/react/index.js +99 -0
  322. package/dist/oauth/react/index.js.map +10 -0
  323. package/dist/oauth/react/use-consent.d.ts +52 -0
  324. package/dist/oauth/react/use-consent.d.ts.map +1 -0
  325. package/dist/oidc/dpop.d.ts +80 -0
  326. package/dist/oidc/dpop.d.ts.map +1 -0
  327. package/dist/oidc/errors.d.ts +16 -0
  328. package/dist/oidc/errors.d.ts.map +1 -0
  329. package/dist/oidc/flow.d.ts +59 -0
  330. package/dist/oidc/flow.d.ts.map +1 -0
  331. package/dist/oidc/index.d.ts +11 -0
  332. package/dist/oidc/index.d.ts.map +1 -0
  333. package/dist/oidc/index.js +742 -0
  334. package/dist/oidc/index.js.map +15 -0
  335. package/dist/oidc/oidc.d.ts +132 -0
  336. package/dist/oidc/oidc.d.ts.map +1 -0
  337. package/dist/oidc/revoke.d.ts +28 -0
  338. package/dist/oidc/revoke.d.ts.map +1 -0
  339. package/dist/oidc/seal.d.ts +20 -0
  340. package/dist/oidc/seal.d.ts.map +1 -0
  341. package/dist/pwa/build/build-worker.d.ts +41 -0
  342. package/dist/pwa/build/build-worker.d.ts.map +1 -0
  343. package/dist/pwa/build/index.d.ts +9 -0
  344. package/dist/pwa/build/index.d.ts.map +1 -0
  345. package/dist/pwa/build/index.js +9 -0
  346. package/dist/pwa/build/index.js.map +9 -0
  347. package/dist/pwa/build/precache.d.ts +17 -0
  348. package/dist/pwa/build/precache.d.ts.map +1 -0
  349. package/dist/pwa/index.d.ts +16 -0
  350. package/dist/pwa/index.d.ts.map +1 -0
  351. package/dist/pwa/index.js +110 -0
  352. package/dist/pwa/index.js.map +12 -0
  353. package/dist/pwa/model/caching.d.ts +46 -0
  354. package/dist/pwa/model/caching.d.ts.map +1 -0
  355. package/dist/pwa/model/clear-app-caches.d.ts +9 -0
  356. package/dist/pwa/model/clear-app-caches.d.ts.map +1 -0
  357. package/dist/pwa/model/font-precache.d.ts +15 -0
  358. package/dist/pwa/model/font-precache.d.ts.map +1 -0
  359. package/dist/pwa/model/manifest.d.ts +80 -0
  360. package/dist/pwa/model/manifest.d.ts.map +1 -0
  361. package/dist/pwa/model/precache-list.d.ts +40 -0
  362. package/dist/pwa/model/precache-list.d.ts.map +1 -0
  363. package/dist/pwa/model/registration.d.ts +39 -0
  364. package/dist/pwa/model/registration.d.ts.map +1 -0
  365. package/dist/pwa/model/start-service-worker.d.ts +24 -0
  366. package/dist/pwa/model/start-service-worker.d.ts.map +1 -0
  367. package/dist/pwa/model/storable.d.ts +8 -0
  368. package/dist/pwa/model/storable.d.ts.map +1 -0
  369. package/dist/pwa/model/theme-color.d.ts +20 -0
  370. package/dist/pwa/model/theme-color.d.ts.map +1 -0
  371. package/dist/pwa/model/update-notice.d.ts +38 -0
  372. package/dist/pwa/model/update-notice.d.ts.map +1 -0
  373. package/dist/pwa/model/worker-contract.d.ts +61 -0
  374. package/dist/pwa/model/worker-contract.d.ts.map +1 -0
  375. package/dist/pwa/react/index.d.ts +9 -0
  376. package/dist/pwa/react/index.d.ts.map +1 -0
  377. package/dist/pwa/react/index.js +75 -0
  378. package/dist/pwa/react/index.js.map +13 -0
  379. package/dist/pwa/react/use-online.d.ts +6 -0
  380. package/dist/pwa/react/use-online.d.ts.map +1 -0
  381. package/dist/pwa/react/use-service-worker.d.ts +33 -0
  382. package/dist/pwa/react/use-service-worker.d.ts.map +1 -0
  383. package/dist/pwa/react/use-update-notice.d.ts +14 -0
  384. package/dist/pwa/react/use-update-notice.d.ts.map +1 -0
  385. package/dist/pwa/server/index.d.ts +7 -0
  386. package/dist/pwa/server/index.d.ts.map +1 -0
  387. package/dist/pwa/server/index.js +18 -0
  388. package/dist/pwa/server/index.js.map +10 -0
  389. package/dist/pwa/server/no-cache.d.ts +22 -0
  390. package/dist/pwa/server/no-cache.d.ts.map +1 -0
  391. package/dist/pwa/worker/index.d.ts +9 -0
  392. package/dist/pwa/worker/index.d.ts.map +1 -0
  393. package/dist/pwa/worker/index.js +144 -0
  394. package/dist/pwa/worker/index.js.map +12 -0
  395. package/dist/pwa/worker/injected.d.ts +15 -0
  396. package/dist/pwa/worker/injected.d.ts.map +1 -0
  397. package/dist/pwa/worker/plan.d.ts +65 -0
  398. package/dist/pwa/worker/plan.d.ts.map +1 -0
  399. package/dist/pwa/worker/scope.d.ts +18 -0
  400. package/dist/pwa/worker/scope.d.ts.map +1 -0
  401. package/dist/pwa/worker/start-worker.d.ts +17 -0
  402. package/dist/pwa/worker/start-worker.d.ts.map +1 -0
  403. package/dist/react-router.d.ts +68 -0
  404. package/dist/react-router.d.ts.map +1 -0
  405. package/dist/server.d.ts +127 -0
  406. package/dist/server.d.ts.map +1 -0
  407. package/dist/session/codes.d.ts +9 -0
  408. package/dist/session/codes.d.ts.map +1 -0
  409. package/dist/session/cookies.d.ts +128 -0
  410. package/dist/session/cookies.d.ts.map +1 -0
  411. package/dist/session/flow-types.d.ts +235 -0
  412. package/dist/session/flow-types.d.ts.map +1 -0
  413. package/dist/session/guard.d.ts +10 -0
  414. package/dist/session/guard.d.ts.map +1 -0
  415. package/dist/session/index.d.ts +22 -0
  416. package/dist/session/index.d.ts.map +1 -0
  417. package/dist/session/index.js +1090 -0
  418. package/dist/session/index.js.map +27 -0
  419. package/dist/session/land.d.ts +28 -0
  420. package/dist/session/land.d.ts.map +1 -0
  421. package/dist/session/link-json.d.ts +22 -0
  422. package/dist/session/link-json.d.ts.map +1 -0
  423. package/dist/session/link-land.d.ts +20 -0
  424. package/dist/session/link-land.d.ts.map +1 -0
  425. package/dist/session/link-token.d.ts +24 -0
  426. package/dist/session/link-token.d.ts.map +1 -0
  427. package/dist/session/link-types.d.ts +142 -0
  428. package/dist/session/link-types.d.ts.map +1 -0
  429. package/dist/session/links.d.ts +14 -0
  430. package/dist/session/links.d.ts.map +1 -0
  431. package/dist/session/model/index.d.ts +8 -0
  432. package/dist/session/model/index.d.ts.map +1 -0
  433. package/dist/session/model/index.js +35 -0
  434. package/dist/session/model/index.js.map +9 -0
  435. package/dist/session/model/link-post.d.ts +35 -0
  436. package/dist/session/model/link-post.d.ts.map +1 -0
  437. package/dist/session/model/paths.d.ts +24 -0
  438. package/dist/session/model/paths.d.ts.map +1 -0
  439. package/dist/session/model/safe-next.d.ts +15 -0
  440. package/dist/session/model/safe-next.d.ts.map +1 -0
  441. package/dist/session/model/second-factor.d.ts +16 -0
  442. package/dist/session/model/second-factor.d.ts.map +1 -0
  443. package/dist/session/model/site-path.d.ts +10 -0
  444. package/dist/session/model/site-path.d.ts.map +1 -0
  445. package/dist/session/model/step-up-answers.d.ts +45 -0
  446. package/dist/session/model/step-up-answers.d.ts.map +1 -0
  447. package/dist/session/model/step-up-props.d.ts +22 -0
  448. package/dist/session/model/step-up-props.d.ts.map +1 -0
  449. package/dist/session/model/step-up.d.ts +48 -0
  450. package/dist/session/model/step-up.d.ts.map +1 -0
  451. package/dist/session/react/index.d.ts +13 -0
  452. package/dist/session/react/index.d.ts.map +1 -0
  453. package/dist/session/react/index.js +196 -0
  454. package/dist/session/react/index.js.map +14 -0
  455. package/dist/session/react/step-up/answers.d.ts +9 -0
  456. package/dist/session/react/step-up/answers.d.ts.map +1 -0
  457. package/dist/session/react/step-up/dialog-props.d.ts +27 -0
  458. package/dist/session/react/step-up/dialog-props.d.ts.map +1 -0
  459. package/dist/session/react/step-up/index.d.ts +7 -0
  460. package/dist/session/react/step-up/index.d.ts.map +1 -0
  461. package/dist/session/react/step-up/pending-runs.d.ts +21 -0
  462. package/dist/session/react/step-up/pending-runs.d.ts.map +1 -0
  463. package/dist/session/react/step-up/phase.d.ts +8 -0
  464. package/dist/session/react/step-up/phase.d.ts.map +1 -0
  465. package/dist/session/react/step-up/use-step-up-replay.d.ts +59 -0
  466. package/dist/session/react/step-up/use-step-up-replay.d.ts.map +1 -0
  467. package/dist/session/react/step-up/use-step-up-runner.d.ts +70 -0
  468. package/dist/session/react/step-up/use-step-up-runner.d.ts.map +1 -0
  469. package/dist/session/react/step-up/use-step-up.d.ts +51 -0
  470. package/dist/session/react/step-up/use-step-up.d.ts.map +1 -0
  471. package/dist/session/react/use-code-field.d.ts +37 -0
  472. package/dist/session/react/use-code-field.d.ts.map +1 -0
  473. package/dist/session/react/use-link-fragment.d.ts +22 -0
  474. package/dist/session/react/use-link-fragment.d.ts.map +1 -0
  475. package/dist/session/react/use-link-param.d.ts +26 -0
  476. package/dist/session/react/use-link-param.d.ts.map +1 -0
  477. package/dist/session/react/use-link-post.d.ts +39 -0
  478. package/dist/session/react/use-link-post.d.ts.map +1 -0
  479. package/dist/session/react/use-sign-out.d.ts +46 -0
  480. package/dist/session/react/use-sign-out.d.ts.map +1 -0
  481. package/dist/session/second-factor.d.ts +22 -0
  482. package/dist/session/second-factor.d.ts.map +1 -0
  483. package/dist/session/serialize.d.ts +42 -0
  484. package/dist/session/serialize.d.ts.map +1 -0
  485. package/dist/session/sign-in.d.ts +19 -0
  486. package/dist/session/sign-in.d.ts.map +1 -0
  487. package/dist/session/signed.d.ts +44 -0
  488. package/dist/session/signed.d.ts.map +1 -0
  489. package/dist/session/social-flow.d.ts +22 -0
  490. package/dist/session/social-flow.d.ts.map +1 -0
  491. package/dist/session/social-land.d.ts +31 -0
  492. package/dist/session/social-land.d.ts.map +1 -0
  493. package/dist/session/social-types.d.ts +136 -0
  494. package/dist/session/social-types.d.ts.map +1 -0
  495. package/dist/session/social.d.ts +32 -0
  496. package/dist/session/social.d.ts.map +1 -0
  497. package/dist/session/step-up-codes.d.ts +9 -0
  498. package/dist/session/step-up-codes.d.ts.map +1 -0
  499. package/dist/session/step-up-signed-out.d.ts +21 -0
  500. package/dist/session/step-up-signed-out.d.ts.map +1 -0
  501. package/dist/session/step-up-types.d.ts +127 -0
  502. package/dist/session/step-up-types.d.ts.map +1 -0
  503. package/dist/session/step-up.d.ts +17 -0
  504. package/dist/session/step-up.d.ts.map +1 -0
  505. package/dist/session/step.d.ts +22 -0
  506. package/dist/session/step.d.ts.map +1 -0
  507. package/dist/session/throttle.d.ts +73 -0
  508. package/dist/session/throttle.d.ts.map +1 -0
  509. package/dist/session/timed-wait.d.ts +4 -0
  510. package/dist/session/timed-wait.d.ts.map +1 -0
  511. package/dist/session/viewer.d.ts +34 -0
  512. package/dist/session/viewer.d.ts.map +1 -0
  513. package/dist/subscription/documents.d.ts +3 -0
  514. package/dist/subscription/documents.d.ts.map +1 -0
  515. package/dist/subscription/index.d.ts +7 -0
  516. package/dist/subscription/index.d.ts.map +1 -0
  517. package/dist/subscription/index.js +359 -0
  518. package/dist/subscription/index.js.map +14 -0
  519. package/dist/subscription/proxy.d.ts +54 -0
  520. package/dist/subscription/proxy.d.ts.map +1 -0
  521. package/dist/subscription/react/backoff.d.ts +8 -0
  522. package/dist/subscription/react/backoff.d.ts.map +1 -0
  523. package/dist/subscription/react/classify.d.ts +15 -0
  524. package/dist/subscription/react/classify.d.ts.map +1 -0
  525. package/dist/subscription/react/controller.d.ts +40 -0
  526. package/dist/subscription/react/controller.d.ts.map +1 -0
  527. package/dist/subscription/react/fake-timers.d.ts +8 -0
  528. package/dist/subscription/react/fake-timers.d.ts.map +1 -0
  529. package/dist/subscription/react/index.d.ts +15 -0
  530. package/dist/subscription/react/index.d.ts.map +1 -0
  531. package/dist/subscription/react/index.js +227 -0
  532. package/dist/subscription/react/index.js.map +17 -0
  533. package/dist/subscription/react/reconnect.d.ts +9 -0
  534. package/dist/subscription/react/reconnect.d.ts.map +1 -0
  535. package/dist/subscription/react/scheduler.d.ts +13 -0
  536. package/dist/subscription/react/scheduler.d.ts.map +1 -0
  537. package/dist/subscription/react/timers.d.ts +7 -0
  538. package/dist/subscription/react/timers.d.ts.map +1 -0
  539. package/dist/subscription/react/use-live-subscription.d.ts +36 -0
  540. package/dist/subscription/react/use-live-subscription.d.ts.map +1 -0
  541. package/dist/subscription/react/versions.d.ts +6 -0
  542. package/dist/subscription/react/versions.d.ts.map +1 -0
  543. package/dist/subscription/read.d.ts +17 -0
  544. package/dist/subscription/read.d.ts.map +1 -0
  545. package/dist/subscription/refusal.d.ts +11 -0
  546. package/dist/subscription/refusal.d.ts.map +1 -0
  547. package/dist/subscription/relay.d.ts +16 -0
  548. package/dist/subscription/relay.d.ts.map +1 -0
  549. package/dist/vite/bun.d.ts +21 -0
  550. package/dist/vite/bun.d.ts.map +1 -0
  551. package/dist/vite/bundle.d.ts +33 -0
  552. package/dist/vite/bundle.d.ts.map +1 -0
  553. package/dist/vite/compress.d.ts +18 -0
  554. package/dist/vite/compress.d.ts.map +1 -0
  555. package/dist/vite/config.d.ts +33 -0
  556. package/dist/vite/config.d.ts.map +1 -0
  557. package/dist/vite/dev.d.ts +28 -0
  558. package/dist/vite/dev.d.ts.map +1 -0
  559. package/dist/vite/entry.d.ts +20 -0
  560. package/dist/vite/entry.d.ts.map +1 -0
  561. package/dist/vite/hosts.d.ts +16 -0
  562. package/dist/vite/hosts.d.ts.map +1 -0
  563. package/dist/vite/index.d.ts +68 -0
  564. package/dist/vite/index.d.ts.map +1 -0
  565. package/dist/vite/index.js +635 -0
  566. package/dist/vite/index.js.map +22 -0
  567. package/dist/vite/inline.d.ts +18 -0
  568. package/dist/vite/inline.d.ts.map +1 -0
  569. package/dist/vite/node.d.ts +16 -0
  570. package/dist/vite/node.d.ts.map +1 -0
  571. package/dist/vite/preview.d.ts +8 -0
  572. package/dist/vite/preview.d.ts.map +1 -0
  573. package/dist/vite/runtime.d.ts +8 -0
  574. package/dist/vite/runtime.d.ts.map +1 -0
  575. package/dist/vite/socket.d.ts +75 -0
  576. package/dist/vite/socket.d.ts.map +1 -0
  577. package/dist/vite/worker.d.ts +16 -0
  578. package/dist/vite/worker.d.ts.map +1 -0
  579. package/dist/with-alxia.d.ts +36 -0
  580. package/dist/with-alxia.d.ts.map +1 -0
  581. package/docs/README.md +42 -0
  582. package/docs/guide/api-keys.md +216 -0
  583. package/docs/guide/beside-the-pages.md +201 -0
  584. package/docs/guide/csp-nonce.md +166 -0
  585. package/docs/guide/customising-the-server.md +324 -0
  586. package/docs/guide/deploying.md +102 -0
  587. package/docs/guide/document.md +334 -0
  588. package/docs/guide/errors.md +1147 -0
  589. package/docs/guide/fetcher.md +355 -0
  590. package/docs/guide/getting-started.md +112 -0
  591. package/docs/guide/help.md +325 -0
  592. package/docs/guide/how-it-works.md +274 -0
  593. package/docs/guide/link.md +32 -0
  594. package/docs/guide/lists.md +225 -0
  595. package/docs/guide/mcp.md +173 -0
  596. package/docs/guide/media.md +273 -0
  597. package/docs/guide/navigation.md +52 -0
  598. package/docs/guide/oauth.md +342 -0
  599. package/docs/guide/oidc.md +262 -0
  600. package/docs/guide/openapi.md +51 -0
  601. package/docs/guide/pwa.md +670 -0
  602. package/docs/guide/session.md +2105 -0
  603. package/docs/guide/subscriptions.md +211 -0
  604. package/docs/guide/testing.md +42 -0
  605. package/docs/guide/typing-the-loaders.md +311 -0
  606. package/docs/guide.md +82 -0
  607. package/docs/roadmap.md +474 -0
  608. package/docs/troubleshooting.md +3837 -0
  609. package/package.json +301 -5
@@ -0,0 +1,93 @@
1
+ import { data } from 'react-router';
2
+ import { type ApiErrorLike } from '../errors/api-error';
3
+ import type { ApiErrors } from '../errors/api-errors';
4
+ /** The least an API key must have: its id and when it was made. */
5
+ export interface ApiKeyLike {
6
+ readonly id: string;
7
+ readonly createdAt: string;
8
+ }
9
+ /** What the API answers a creation: the key, and its secret, shown this once. */
10
+ export interface CreatedApiKey<K extends ApiKeyLike> {
11
+ readonly secret: string;
12
+ readonly apiKey: K;
13
+ }
14
+ /** What `create` answers the page's fetcher (inside `data()`, `no-store`). */
15
+ export type CreateKeyAnswer<K extends ApiKeyLike> = {
16
+ readonly ok: true;
17
+ readonly intent: 'create-key';
18
+ /** The key's secret: the API shows it this once. */
19
+ readonly secret: string;
20
+ readonly apiKey: K;
21
+ } | {
22
+ readonly ok: false;
23
+ readonly intent: 'create-key';
24
+ /** The session is not confirmed lately: the page steps up and posts again. */
25
+ readonly stepUp: boolean;
26
+ /** The worded refusal; empty for `stepUp`. */
27
+ readonly error: string;
28
+ };
29
+ /** What `revoke` answers the page's fetcher. */
30
+ export type RevokeKeyAnswer = {
31
+ readonly ok: true;
32
+ readonly intent: 'revoke-key';
33
+ readonly id: string;
34
+ /** The API no longer knew the key: what the user wanted is done. */
35
+ readonly alreadyRevoked: boolean;
36
+ } | {
37
+ readonly ok: false;
38
+ readonly intent: 'revoke-key';
39
+ readonly id: string;
40
+ /** The session is not confirmed lately: the page steps up and posts again. */
41
+ readonly stepUp: boolean;
42
+ /** The worded refusal; empty for `stepUp`. */
43
+ readonly error: string;
44
+ };
45
+ export interface ApiKeysOptions<L extends string, Ctx, K extends ApiKeyLike, Input> {
46
+ /** The app's `createApiErrors()`: words the refusals. */
47
+ readonly errors: Pick<ApiErrors<L>, 'apiRefusal'>;
48
+ /** The keys the caller may see (`apiKeys`), in any order. */
49
+ list(ctx: Ctx): Promise<readonly K[]>;
50
+ /** `createApiKey(input)`: the key and its secret. */
51
+ create(ctx: Ctx, input: Input): Promise<CreatedApiKey<K>>;
52
+ /** `revokeApiKey(id)`. */
53
+ revoke(ctx: Ctx, id: string): Promise<unknown>;
54
+ /**
55
+ * Whether a refusal of `revoke` means the key is unknown (revoked
56
+ * elsewhere, expired and purged). Default: a 404.
57
+ */
58
+ notFound?(error: ApiErrorLike): boolean;
59
+ /** The API's step-up code. Default `STEP_UP_REQUIRED`. */
60
+ readonly stepUpRequired?: string;
61
+ }
62
+ export interface ApiKeysRoute<L extends string, Ctx, K extends ApiKeyLike, Input> {
63
+ /** The keys, newest first by `createdAt`, for a loader. */
64
+ list(ctx: Ctx): Promise<K[]>;
65
+ /**
66
+ * Creates a key, for an action: the answer holds the secret and is marked
67
+ * `Cache-Control: no-store`; a session not confirmed lately is `stepUp`.
68
+ */
69
+ create(ctx: Ctx, input: Input, language: L): Promise<ReturnType<typeof data<CreateKeyAnswer<K>>>>;
70
+ /** Revokes a key, for an action: revoking one the API no longer knows is done, not an error. */
71
+ revoke(ctx: Ctx, id: string, language: L): Promise<ReturnType<typeof data<RevokeKeyAnswer>>>;
72
+ }
73
+ /**
74
+ * The server side of a user's API keys (an MCP client's credential): a
75
+ * sorted list for a loader, and a create and a revoke step for an action,
76
+ * over the app's own GraphQL calls. `Ctx` is whatever those need (a
77
+ * caller); `Input` is what the app's creation takes (a name, a lifetime, a
78
+ * scope, what the key is bound to).
79
+ *
80
+ * A creation the API refuses for a session not confirmed lately answers
81
+ * `stepUp: true`: the page opens the shared step-up and posts the same
82
+ * creation again (`useStepUpReplay` of `/session/react`). The secret is in
83
+ * the answer of that POST alone, marked `no-store`: the page shows it from
84
+ * its fetcher and resets the fetcher once it is copied.
85
+ *
86
+ * @example
87
+ * const keys = apiKeys({ errors, list: (c) => listKeys(c), create: (c, i) => createKey(c, i), revoke: (c, id) => revokeKey(c, id) });
88
+ * export const loader = async ({ request }) => ({ keys: await keys.list(caller(request)) });
89
+ * const { readJson } = jsonActions(); // `/errors`: the same-site check first
90
+ * export const action = async ({ request }) => keys.create(caller(request), await readJson(request), language);
91
+ */
92
+ export declare function apiKeys<L extends string, Ctx, K extends ApiKeyLike, Input>(options: ApiKeysOptions<L, Ctx, K, Input>): ApiKeysRoute<L, Ctx, K, Input>;
93
+ //# sourceMappingURL=api-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.d.ts","sourceRoot":"","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O,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,gGAAgG;IAChG,MAAM,CACL,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,GACT,OAAO,CAAC,UAAU,CAAC,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;CACrD;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS,UAAU,EAAE,KAAK,EACzE,OAAO,EAAE,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,GACvC,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CA4DhC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `@softistx/alxia-react-router/api-keys`: the server side of a user's API keys
3
+ * (the credential an MCP client sends): `apiKeys`' list, create and revoke
4
+ * over the app's own GraphQL calls. It may import `react-router`, `/errors`'
5
+ * files and `/session`'s step-up code, nothing else. The page's step-up is
6
+ * `useStepUpReplay` of `/session/react`.
7
+ */
8
+ export { type ApiKeyLike, type ApiKeysOptions, type ApiKeysRoute, apiKeys, type CreatedApiKey, type CreateKeyAnswer, type RevokeKeyAnswer, } from './api-keys';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api-keys/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACN,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,GACpB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,66 @@
1
+ import {
2
+ isApiErrorLike2
3
+ } from "../chunks/index-wyypkfdv.js";
4
+ import {
5
+ fetcherRefusal
6
+ } from "../chunks/index-pghmb2dm.js";
7
+ import {
8
+ STEP_UP_REQUIRED2
9
+ } from "../chunks/index-vr82typq.js";
10
+ import {
11
+ newestFirst
12
+ } from "../chunks/index-whj6h5eg.js";
13
+
14
+ // src/api-keys/api-keys.ts
15
+ import { data } from "react-router";
16
+ var NO_STORE = { "Cache-Control": "no-store" };
17
+ function apiKeys(options) {
18
+ const notFound = options.notFound ?? ((error) => error.status === 404);
19
+ const stepUpCode = options.stepUpRequired ?? STEP_UP_REQUIRED2;
20
+ function refused(error, language) {
21
+ const stepUp = isApiErrorLike2(error) && error.code === stepUpCode;
22
+ const { message, status } = fetcherRefusal(options.errors, error, language);
23
+ return { stepUp, error: stepUp ? "" : message, status };
24
+ }
25
+ async function list(ctx) {
26
+ return newestFirst(await options.list(ctx));
27
+ }
28
+ async function create(ctx, input, language) {
29
+ const intent = "create-key";
30
+ try {
31
+ const { secret, apiKey } = await options.create(ctx, input);
32
+ return data({ ok: true, intent, secret, apiKey }, { headers: NO_STORE });
33
+ } catch (error) {
34
+ const { stepUp, error: message, status } = refused(error, language);
35
+ return data({ ok: false, intent, stepUp, error: message }, { status, headers: NO_STORE });
36
+ }
37
+ }
38
+ async function revoke(ctx, id, language) {
39
+ const about = { intent: "revoke-key", id };
40
+ try {
41
+ await options.revoke(ctx, id);
42
+ return data({
43
+ ok: true,
44
+ ...about,
45
+ alreadyRevoked: false
46
+ });
47
+ } catch (error) {
48
+ const stepUp = isApiErrorLike2(error) && error.code === stepUpCode;
49
+ if (!stepUp && isApiErrorLike2(error) && notFound(error))
50
+ return data({
51
+ ok: true,
52
+ ...about,
53
+ alreadyRevoked: true
54
+ });
55
+ const { error: message, status } = refused(error, language);
56
+ return data({ ok: false, ...about, stepUp, error: message }, { status });
57
+ }
58
+ }
59
+ return { list, create, revoke };
60
+ }
61
+ export {
62
+ apiKeys
63
+ };
64
+
65
+ //# debugId=AF00071392B6059964756E2164756E21
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/api-keys/api-keys.ts"],
4
+ "sourcesContent": [
5
+ "import { data } from 'react-router';\nimport { type ApiErrorLike, isApiErrorLike } from '../errors/api-error';\nimport type { ApiErrors } from '../errors/api-errors';\nimport { fetcherRefusal } from '../errors/fetcher-result';\nimport { newestFirst } from '../lists/newest-first';\nimport { STEP_UP_REQUIRED } from '../session/step-up-codes';\n\n/** The least an API key must have: its id and when it was made. */\nexport interface ApiKeyLike {\n\treadonly id: string;\n\treadonly createdAt: string;\n}\n\n/** What the API answers a creation: the key, and its secret, shown this once. */\nexport interface CreatedApiKey<K extends ApiKeyLike> {\n\treadonly secret: string;\n\treadonly apiKey: K;\n}\n\n/** What `create` answers the page's fetcher (inside `data()`, `no-store`). */\nexport type CreateKeyAnswer<K extends ApiKeyLike> =\n\t| {\n\t\t\treadonly ok: true;\n\t\t\treadonly intent: 'create-key';\n\t\t\t/** The key's secret: the API shows it this once. */\n\t\t\treadonly secret: string;\n\t\t\treadonly apiKey: K;\n\t }\n\t| {\n\t\t\treadonly ok: false;\n\t\t\treadonly intent: 'create-key';\n\t\t\t/** The session is not confirmed lately: the page steps up and posts again. */\n\t\t\treadonly stepUp: boolean;\n\t\t\t/** The worded refusal; empty for `stepUp`. */\n\t\t\treadonly error: string;\n\t };\n\n/** What `revoke` answers the page's fetcher. */\nexport type RevokeKeyAnswer =\n\t| {\n\t\t\treadonly ok: true;\n\t\t\treadonly intent: 'revoke-key';\n\t\t\treadonly id: string;\n\t\t\t/** The API no longer knew the key: what the user wanted is done. */\n\t\t\treadonly alreadyRevoked: boolean;\n\t }\n\t| {\n\t\t\treadonly ok: false;\n\t\t\treadonly intent: 'revoke-key';\n\t\t\treadonly id: string;\n\t\t\t/** The session is not confirmed lately: the page steps up and posts again. */\n\t\t\treadonly stepUp: boolean;\n\t\t\t/** The worded refusal; empty for `stepUp`. */\n\t\t\treadonly error: string;\n\t };\n\nexport interface ApiKeysOptions<\n\tL extends string,\n\tCtx,\n\tK extends ApiKeyLike,\n\tInput,\n> {\n\t/** The app's `createApiErrors()`: words the refusals. */\n\treadonly errors: Pick<ApiErrors<L>, 'apiRefusal'>;\n\t/** The keys the caller may see (`apiKeys`), in any order. */\n\tlist(ctx: Ctx): Promise<readonly K[]>;\n\t/** `createApiKey(input)`: the key and its secret. */\n\tcreate(ctx: Ctx, input: Input): Promise<CreatedApiKey<K>>;\n\t/** `revokeApiKey(id)`. */\n\trevoke(ctx: Ctx, id: string): Promise<unknown>;\n\t/**\n\t * Whether a refusal of `revoke` means the key is unknown (revoked\n\t * elsewhere, expired and purged). Default: a 404.\n\t */\n\tnotFound?(error: ApiErrorLike): boolean;\n\t/** The API's step-up code. Default `STEP_UP_REQUIRED`. */\n\treadonly stepUpRequired?: string;\n}\n\nexport interface ApiKeysRoute<\n\tL extends string,\n\tCtx,\n\tK extends ApiKeyLike,\n\tInput,\n> {\n\t/** The keys, newest first by `createdAt`, for a loader. */\n\tlist(ctx: Ctx): Promise<K[]>;\n\t/**\n\t * Creates a key, for an action: the answer holds the secret and is marked\n\t * `Cache-Control: no-store`; a session not confirmed lately is `stepUp`.\n\t */\n\tcreate(\n\t\tctx: Ctx,\n\t\tinput: Input,\n\t\tlanguage: L,\n\t): Promise<ReturnType<typeof data<CreateKeyAnswer<K>>>>;\n\t/** Revokes a key, for an action: revoking one the API no longer knows is done, not an error. */\n\trevoke(\n\t\tctx: Ctx,\n\t\tid: string,\n\t\tlanguage: L,\n\t): Promise<ReturnType<typeof data<RevokeKeyAnswer>>>;\n}\n\nconst NO_STORE = { 'Cache-Control': 'no-store' } as const;\n\n/**\n * The server side of a user's API keys (an MCP client's credential): a\n * sorted list for a loader, and a create and a revoke step for an action,\n * over the app's own GraphQL calls. `Ctx` is whatever those need (a\n * caller); `Input` is what the app's creation takes (a name, a lifetime, a\n * scope, what the key is bound to).\n *\n * A creation the API refuses for a session not confirmed lately answers\n * `stepUp: true`: the page opens the shared step-up and posts the same\n * creation again (`useStepUpReplay` of `/session/react`). The secret is in\n * the answer of that POST alone, marked `no-store`: the page shows it from\n * its fetcher and resets the fetcher once it is copied.\n *\n * @example\n * const keys = apiKeys({ errors, list: (c) => listKeys(c), create: (c, i) => createKey(c, i), revoke: (c, id) => revokeKey(c, id) });\n * export const loader = async ({ request }) => ({ keys: await keys.list(caller(request)) });\n * const { readJson } = jsonActions(); // `/errors`: the same-site check first\n * export const action = async ({ request }) => keys.create(caller(request), await readJson(request), language);\n */\nexport function apiKeys<L extends string, Ctx, K extends ApiKeyLike, Input>(\n\toptions: ApiKeysOptions<L, Ctx, K, Input>,\n): ApiKeysRoute<L, Ctx, K, Input> {\n\tconst notFound =\n\t\toptions.notFound ?? ((error: ApiErrorLike) => error.status === 404);\n\tconst stepUpCode = options.stepUpRequired ?? STEP_UP_REQUIRED;\n\n\t/** A refusal of the API, worded for the page: `stepUp` with no message for the step-up code. */\n\tfunction refused(error: unknown, language: L) {\n\t\tconst stepUp = isApiErrorLike(error) && error.code === stepUpCode;\n\t\tconst { message, status } = fetcherRefusal(options.errors, error, language);\n\t\treturn { stepUp, error: stepUp ? '' : message, status };\n\t}\n\n\tasync function list(ctx: Ctx) {\n\t\treturn newestFirst(await options.list(ctx));\n\t}\n\n\tasync function create(ctx: Ctx, input: Input, language: L) {\n\t\tconst intent = 'create-key' as const;\n\t\ttry {\n\t\t\tconst { secret, apiKey } = await options.create(ctx, input);\n\t\t\treturn data<CreateKeyAnswer<K>>(\n\t\t\t\t{ ok: true, intent, secret, apiKey },\n\t\t\t\t{ headers: NO_STORE },\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconst { stepUp, error: message, status } = refused(error, language);\n\t\t\treturn data<CreateKeyAnswer<K>>(\n\t\t\t\t{ ok: false, intent, stepUp, error: message },\n\t\t\t\t{ status, headers: NO_STORE },\n\t\t\t);\n\t\t}\n\t}\n\n\tasync function revoke(ctx: Ctx, id: string, language: L) {\n\t\tconst about = { intent: 'revoke-key' as const, id };\n\t\ttry {\n\t\t\tawait options.revoke(ctx, id);\n\t\t\treturn data<RevokeKeyAnswer>({\n\t\t\t\tok: true,\n\t\t\t\t...about,\n\t\t\t\talreadyRevoked: false,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t// step-up, then notFound, before the refusal is worded (as `oauthGrants` does)\n\t\t\tconst stepUp = isApiErrorLike(error) && error.code === stepUpCode;\n\t\t\tif (!stepUp && isApiErrorLike(error) && notFound(error))\n\t\t\t\treturn data<RevokeKeyAnswer>({\n\t\t\t\t\tok: true,\n\t\t\t\t\t...about,\n\t\t\t\t\talreadyRevoked: true,\n\t\t\t\t});\n\t\t\tconst { error: message, status } = refused(error, language);\n\t\t\treturn data<RevokeKeyAnswer>(\n\t\t\t\t{ ok: false, ...about, stepUp, error: message },\n\t\t\t\t{ status },\n\t\t\t);\n\t\t}\n\t}\n\n\treturn { list, create, revoke };\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAwGA,IAAM,WAAW,EAAE,iBAAiB,WAAW;AAqBxC,SAAS,OAA2D,CAC1E,SACiC;AAAA,EACjC,MAAM,WACL,QAAQ,aAAa,CAAC,UAAwB,MAAM,WAAW;AAAA,EAChE,MAAM,aAAa,QAAQ,kBAAkB;AAAA,EAG7C,SAAS,OAAO,CAAC,OAAgB,UAAa;AAAA,IAC7C,MAAM,SAAS,gBAAe,KAAK,KAAK,MAAM,SAAS;AAAA,IACvD,QAAQ,SAAS,WAAW,eAAe,QAAQ,QAAQ,OAAO,QAAQ;AAAA,IAC1E,OAAO,EAAE,QAAQ,OAAO,SAAS,KAAK,SAAS,OAAO;AAAA;AAAA,EAGvD,eAAe,IAAI,CAAC,KAAU;AAAA,IAC7B,OAAO,YAAY,MAAM,QAAQ,KAAK,GAAG,CAAC;AAAA;AAAA,EAG3C,eAAe,MAAM,CAAC,KAAU,OAAc,UAAa;AAAA,IAC1D,MAAM,SAAS;AAAA,IACf,IAAI;AAAA,MACH,QAAQ,QAAQ,WAAW,MAAM,QAAQ,OAAO,KAAK,KAAK;AAAA,MAC1D,OAAO,KACN,EAAE,IAAI,MAAM,QAAQ,QAAQ,OAAO,GACnC,EAAE,SAAS,SAAS,CACrB;AAAA,MACC,OAAO,OAAO;AAAA,MACf,QAAQ,QAAQ,OAAO,SAAS,WAAW,QAAQ,OAAO,QAAQ;AAAA,MAClE,OAAO,KACN,EAAE,IAAI,OAAO,QAAQ,QAAQ,OAAO,QAAQ,GAC5C,EAAE,QAAQ,SAAS,SAAS,CAC7B;AAAA;AAAA;AAAA,EAIF,eAAe,MAAM,CAAC,KAAU,IAAY,UAAa;AAAA,IACxD,MAAM,QAAQ,EAAE,QAAQ,cAAuB,GAAG;AAAA,IAClD,IAAI;AAAA,MACH,MAAM,QAAQ,OAAO,KAAK,EAAE;AAAA,MAC5B,OAAO,KAAsB;AAAA,QAC5B,IAAI;AAAA,WACD;AAAA,QACH,gBAAgB;AAAA,MACjB,CAAC;AAAA,MACA,OAAO,OAAO;AAAA,MAEf,MAAM,SAAS,gBAAe,KAAK,KAAK,MAAM,SAAS;AAAA,MACvD,IAAI,CAAC,UAAU,gBAAe,KAAK,KAAK,SAAS,KAAK;AAAA,QACrD,OAAO,KAAsB;AAAA,UAC5B,IAAI;AAAA,aACD;AAAA,UACH,gBAAgB;AAAA,QACjB,CAAC;AAAA,MACF,QAAQ,OAAO,SAAS,WAAW,QAAQ,OAAO,QAAQ;AAAA,MAC1D,OAAO,KACN,EAAE,IAAI,UAAU,OAAO,QAAQ,OAAO,QAAQ,GAC9C,EAAE,OAAO,CACV;AAAA;AAAA;AAAA,EAIF,OAAO,EAAE,MAAM,QAAQ,OAAO;AAAA;",
8
+ "debugId": "AF00071392B6059964756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,14 @@
1
+ /** A hashed asset never changes under its name. */
2
+ export declare const IMMUTABLE = "public, max-age=31536000, immutable";
3
+ /** A public file keeps its name across builds: revalidated after an hour. */
4
+ export declare const AN_HOUR = "public, max-age=3600";
5
+ interface Serving {
6
+ static(path: string, source: string, options: object): unknown;
7
+ file(path: string, file: string, options: object): unknown;
8
+ }
9
+ /** Declares the client build's routes on `app`. */
10
+ export declare function serveClient(app: Serving, client: string, options?: {
11
+ readonly precompressed?: boolean;
12
+ }): void;
13
+ export {};
14
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAQA,mDAAmD;AACnD,eAAO,MAAM,SAAS,wCAAwC,CAAC;AAC/D,6EAA6E;AAC7E,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAK9C,UAAU,OAAO;IAChB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/D,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3D;AAED,mDAAmD;AACnD,wBAAgB,WAAW,CAC1B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GAChD,IAAI,CAyBN"}
@@ -0,0 +1,25 @@
1
+ // src/session/model/safe-next.ts
2
+ var HOME2 = "/";
3
+ var BASE = "http://next.invalid";
4
+ function safeNext2(value) {
5
+ if (!value || value.length > 2000)
6
+ return HOME2;
7
+ if (!value.startsWith("/") || value.startsWith("//"))
8
+ return HOME2;
9
+ if (/[\\\p{Cc}\s]/u.test(value))
10
+ return HOME2;
11
+ try {
12
+ const url = new URL(value, BASE);
13
+ const path = `${url.pathname}${url.search}${url.hash}`;
14
+ if (url.origin !== BASE || path.startsWith("//"))
15
+ return HOME2;
16
+ return path;
17
+ } catch {
18
+ return HOME2;
19
+ }
20
+ }
21
+
22
+ export { HOME2, safeNext2 };
23
+
24
+ //# debugId=DC9B9B90F989919264756E2164756E21
25
+ //# sourceMappingURL=index-0786n4qe.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/session/model/safe-next.ts"],
4
+ "sourcesContent": [
5
+ "/** Where a sign-in lands when `next` is missing or unsafe. */\nexport const HOME = '/';\n\n/** The base a `next` is resolved against; `.invalid` never resolves. */\nconst BASE = 'http://next.invalid';\n\n/**\n * The `next` a sign-in may redirect to: a path of this site only. Anything\n * that could leave it (`//host`, `/\\host`, `https://…`, `javascript:…`, a\n * control character a browser would strip, a value over 2000 characters)\n * falls back to `/`. The path is read after normalisation, so `/a/..//host`\n * is refused too.\n *\n * @example\n * safeNext('/orders?page=2'); // '/orders?page=2'\n * safeNext('//evil.test'); // '/'\n */\nexport function safeNext(value: string | null | undefined): string {\n\tif (!value || value.length > 2000) return HOME;\n\tif (!value.startsWith('/') || value.startsWith('//')) return HOME;\n\t// Browsers read `\\` as `/` and drop tabs and newlines in URLs.\n\tif (/[\\\\\\p{Cc}\\s]/u.test(value)) return HOME;\n\ttry {\n\t\tconst url = new URL(value, BASE);\n\t\tconst path = `${url.pathname}${url.search}${url.hash}`;\n\t\t// Dot segments can collapse into `//host` again: check what is answered.\n\t\tif (url.origin !== BASE || path.startsWith('//')) return HOME;\n\t\treturn path;\n\t} catch {\n\t\treturn HOME;\n\t}\n}\n"
6
+ ],
7
+ "mappings": ";AACO,IAAM,QAAO;AAGpB,IAAM,OAAO;AAaN,SAAS,SAAQ,CAAC,OAA0C;AAAA,EAClE,IAAI,CAAC,SAAS,MAAM,SAAS;AAAA,IAAM,OAAO;AAAA,EAC1C,IAAI,CAAC,MAAM,WAAW,GAAG,KAAK,MAAM,WAAW,IAAI;AAAA,IAAG,OAAO;AAAA,EAE7D,IAAI,gBAAgB,KAAK,KAAK;AAAA,IAAG,OAAO;AAAA,EACxC,IAAI;AAAA,IACH,MAAM,MAAM,IAAI,IAAI,OAAO,IAAI;AAAA,IAC/B,MAAM,OAAO,GAAG,IAAI,WAAW,IAAI,SAAS,IAAI;AAAA,IAEhD,IAAI,IAAI,WAAW,QAAQ,KAAK,WAAW,IAAI;AAAA,MAAG,OAAO;AAAA,IACzD,OAAO;AAAA,IACN,MAAM;AAAA,IACP,OAAO;AAAA;AAAA;",
8
+ "debugId": "DC9B9B90F989919264756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,169 @@
1
+ // src/session/serialize.ts
2
+ var SAME_SITE = { lax: "Lax", strict: "Strict", none: "None" };
3
+ function checkSameSite(caller, sameSite, secure) {
4
+ if (!Object.hasOwn(SAME_SITE, sameSite)) {
5
+ throw new TypeError(`${caller}: sameSite must be "lax", "strict" or "none"; got ${JSON.stringify(sameSite)}.`);
6
+ }
7
+ if (sameSite === "none" && !secure) {
8
+ throw new TypeError(`${caller}: sameSite "none" needs secure: true, since a browser drops a SameSite=None cookie without Secure.`);
9
+ }
10
+ }
11
+ var TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
12
+ var PATH = /^\/[^;\x00-\x1f\x7f]*$/;
13
+ var isCookieName = (name) => TOKEN.test(name);
14
+ var isCookiePath = (path) => PATH.test(path);
15
+ function serializeCookie2(name, value, { maxAge, path = "/", secure, sameSite = "lax" }) {
16
+ if (!isCookieName(name)) {
17
+ throw new TypeError(`serializeCookie(): the name ${JSON.stringify(name)} is not a cookie name (an RFC 6265 token).`);
18
+ }
19
+ if (!isCookiePath(path)) {
20
+ throw new TypeError(`serializeCookie(): the path ${JSON.stringify(path)} is not a cookie path: it must start with "/" and hold no ";" or control character.`);
21
+ }
22
+ checkSameSite("serializeCookie():", sameSite, secure);
23
+ return [
24
+ `${name}=${encodeURIComponent(value)}`,
25
+ `Max-Age=${Number.isFinite(maxAge) ? Math.max(0, Math.floor(maxAge)) : 0}`,
26
+ `Path=${path}`,
27
+ "HttpOnly",
28
+ ...secure ? ["Secure"] : [],
29
+ `SameSite=${SAME_SITE[sameSite]}`
30
+ ].join("; ");
31
+ }
32
+ function* rawValues(request, name) {
33
+ for (const pair of request.headers.get("cookie")?.split(";") ?? []) {
34
+ const index = pair.indexOf("=");
35
+ if (index >= 0 && pair.slice(0, index).trim() === name) {
36
+ yield pair.slice(index + 1).trim();
37
+ }
38
+ }
39
+ }
40
+ function readCookie2(request, name) {
41
+ for (const raw of rawValues(request, name)) {
42
+ if (!raw)
43
+ continue;
44
+ try {
45
+ return decodeURIComponent(raw);
46
+ } catch {
47
+ return null;
48
+ }
49
+ }
50
+ return null;
51
+ }
52
+ function hasCookie(request, name) {
53
+ return !rawValues(request, name).next().done;
54
+ }
55
+ function millisOf(at) {
56
+ const time = typeof at === "string" ? Date.parse(at) : at.getTime();
57
+ return Number.isNaN(time) ? 0 : time;
58
+ }
59
+ function secondsUntil2(expiresAt, now = Date.now()) {
60
+ const end = millisOf(expiresAt);
61
+ return end === 0 ? 0 : Math.max(0, (end - now) / 1000);
62
+ }
63
+
64
+ // src/session/cookies.ts
65
+ var PREFIX = /^__(?:Host|Secure)-/;
66
+ function checkName(label, name) {
67
+ if (!isCookieName(name)) {
68
+ throw new TypeError(`sessionCookies(): the ${label} name ${JSON.stringify(name)} is not a cookie name (an RFC 6265 token: letters, digits and ! # $ % & ' * + - . ^ _ \` | ~). Pass a name such as "my-app_${label}".`);
69
+ }
70
+ if (PREFIX.test(name)) {
71
+ throw new TypeError(`sessionCookies(): the ${label} name ${JSON.stringify(name)} already carries a prefix. Pass the base name: the package adds __Host- (session) or __Secure- (challenge) when secure is true.`);
72
+ }
73
+ }
74
+ function sessionCookies2(options) {
75
+ const {
76
+ secure,
77
+ sameSite = "lax",
78
+ challengePath = "/sign-in",
79
+ challengeHostPrefix = false,
80
+ challengeSeconds = 5 * 60
81
+ } = options;
82
+ checkSameSite("sessionCookies():", sameSite, secure);
83
+ checkName("session", options.session);
84
+ if (options.challenge !== undefined)
85
+ checkName("challenge", options.challenge);
86
+ if (!Number.isInteger(challengeSeconds) || challengeSeconds <= 0) {
87
+ throw new TypeError(`sessionCookies(): challengeSeconds must be a positive integer; got ${String(challengeSeconds)}.`);
88
+ }
89
+ if (!isCookiePath(challengePath)) {
90
+ throw new TypeError(`sessionCookies(): challengePath must start with "/" and hold no ";" or control character; got ${JSON.stringify(challengePath)}.`);
91
+ }
92
+ if (challengeHostPrefix && options.challenge !== undefined) {
93
+ if (options.challengePath !== "/") {
94
+ throw new TypeError(`sessionCookies(): challengeHostPrefix needs challengePath: "/" (a __Host- cookie must have Path=/); got ${JSON.stringify(options.challengePath)}.`);
95
+ }
96
+ }
97
+ const session = secure ? `__Host-${options.session}` : options.session;
98
+ const challengeName = options.challenge === undefined ? undefined : secure ? `${challengeHostPrefix ? "__Host-" : "__Secure-"}${options.challenge}` : options.challenge;
99
+ const clear = (name, path) => serializeCookie2(name, "", {
100
+ maxAge: 0,
101
+ secure,
102
+ sameSite,
103
+ ...path && { path }
104
+ });
105
+ const read = (request) => {
106
+ const value = readCookie2(request, session);
107
+ const dot = value?.indexOf(".") ?? -1;
108
+ if (!value || dot < 1)
109
+ return null;
110
+ const digits = value.slice(0, dot);
111
+ const expiresAt = Number(digits);
112
+ const token = value.slice(dot + 1);
113
+ return token && /^\d+$/.test(digits) && Number.isSafeInteger(expiresAt) ? { token, expiresAt } : null;
114
+ };
115
+ const commit = (token, expiresAt, now) => serializeCookie2(session, `${millisOf(expiresAt)}.${token}`, {
116
+ maxAge: secondsUntil2(expiresAt, now),
117
+ secure,
118
+ sameSite
119
+ });
120
+ const base = {
121
+ names: { session },
122
+ read,
123
+ token: (request) => read(request)?.token ?? null,
124
+ present: (request) => hasCookie(request, session),
125
+ commit,
126
+ destroy: () => clear(session),
127
+ refreshed(current, expiresAt) {
128
+ const end = expiresAt ? millisOf(expiresAt) : 0;
129
+ if (!expiresAt || end === 0 || end === current.expiresAt)
130
+ return {};
131
+ return { "Set-Cookie": commit(current.token, expiresAt) };
132
+ },
133
+ signInPageHeaders(deadSession) {
134
+ const headers = new Headers;
135
+ if (challengeName) {
136
+ headers.append("Set-Cookie", clear(challengeName, challengePath));
137
+ }
138
+ if (deadSession)
139
+ headers.append("Set-Cookie", clear(session));
140
+ return headers;
141
+ }
142
+ };
143
+ if (challengeName === undefined)
144
+ return base;
145
+ const challengeCookies = {
146
+ names: { challenge: challengeName },
147
+ challengeOf: (request) => readCookie2(request, challengeName),
148
+ commitChallenge: (value, expiresAt, now) => serializeCookie2(challengeName, value, {
149
+ maxAge: Math.min(challengeSeconds, expiresAt ? secondsUntil2(expiresAt, now) : challengeSeconds),
150
+ path: challengePath,
151
+ secure,
152
+ sameSite
153
+ }),
154
+ destroyChallenge: () => clear(challengeName, challengePath)
155
+ };
156
+ return {
157
+ ...base,
158
+ ...challengeCookies,
159
+ names: { session, challenge: challengeName }
160
+ };
161
+ }
162
+ function challengeCleared(cookies) {
163
+ return cookies.destroyChallenge ? [cookies.destroyChallenge()] : [];
164
+ }
165
+
166
+ export { checkSameSite, isCookieName, serializeCookie2, readCookie2, millisOf, secondsUntil2, sessionCookies2, challengeCleared };
167
+
168
+ //# debugId=F84AF96789A0E01964756E2164756E21
169
+ //# sourceMappingURL=index-1nw5yeek.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/session/serialize.ts", "../src/session/cookies.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The bytes of a cookie, and the reading of one: `Name=v; Max-Age=n; Path=/;\n * HttpOnly[; Secure]; SameSite=Lax`, in this order, so a session set by an\n * app before it adopted this package is still read after, and the other way\n * round.\n */\n\nexport interface SerializeOptions {\n\t/** Seconds; floored, and never below 0 (0 removes the cookie, and so does a value that is not finite). */\n\treadonly maxAge: number;\n\t/** `/` by default. */\n\treadonly path?: string | undefined;\n\t/** Adds `Secure`. Required: it is never read from the environment. */\n\treadonly secure: boolean;\n\t/** `'lax'` by default. `'none'` needs `secure`. */\n\treadonly sameSite?: SameSite | undefined;\n}\n\n/** The `SameSite` attribute of a cookie. */\nexport type SameSite = 'lax' | 'strict' | 'none';\n\nconst SAME_SITE = { lax: 'Lax', strict: 'Strict', none: 'None' } as const;\n\n/** Throws a `TypeError` for a `SameSite` the package does not write, or `none` without `Secure`. */\nexport function checkSameSite(\n\tcaller: string,\n\tsameSite: string,\n\tsecure: boolean,\n): asserts sameSite is SameSite {\n\tif (!Object.hasOwn(SAME_SITE, sameSite)) {\n\t\tthrow new TypeError(\n\t\t\t`${caller}: sameSite must be \"lax\", \"strict\" or \"none\"; got ${JSON.stringify(sameSite)}.`,\n\t\t);\n\t}\n\tif (sameSite === 'none' && !secure) {\n\t\tthrow new TypeError(\n\t\t\t`${caller}: sameSite \"none\" needs secure: true, since a browser drops a SameSite=None cookie without Secure.`,\n\t\t);\n\t}\n}\n\n// RFC 6265 `token`: what a cookie name may be made of.\nconst TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/;\n// A path of the site: no `;` to open another attribute, no control character.\n// biome-ignore lint/suspicious/noControlCharactersInRegex: that is the point\nconst PATH = /^\\/[^;\\x00-\\x1f\\x7f]*$/;\n\n/** Whether `name` can name a cookie (an RFC 6265 token). */\nexport const isCookieName = (name: string): boolean => TOKEN.test(name);\n/** Whether `path` can be a cookie's `Path`: absolute, no `;`, no control character. */\nexport const isCookiePath = (path: string): boolean => PATH.test(path);\n\n/**\n * A `Set-Cookie` value: always `HttpOnly`, `SameSite=Lax` unless `sameSite`\n * says otherwise, `Secure` when asked. A name or a path that could open another attribute throws a\n * `TypeError`; a `maxAge` that is not finite is 0.\n */\nexport function serializeCookie(\n\tname: string,\n\tvalue: string,\n\t{ maxAge, path = '/', secure, sameSite = 'lax' }: SerializeOptions,\n): string {\n\tif (!isCookieName(name)) {\n\t\tthrow new TypeError(\n\t\t\t`serializeCookie(): the name ${JSON.stringify(name)} is not a cookie name (an RFC 6265 token).`,\n\t\t);\n\t}\n\tif (!isCookiePath(path)) {\n\t\tthrow new TypeError(\n\t\t\t`serializeCookie(): the path ${JSON.stringify(path)} is not a cookie path: it must start with \"/\" and hold no \";\" or control character.`,\n\t\t);\n\t}\n\tcheckSameSite('serializeCookie():', sameSite, secure);\n\treturn [\n\t\t`${name}=${encodeURIComponent(value)}`,\n\t\t`Max-Age=${Number.isFinite(maxAge) ? Math.max(0, Math.floor(maxAge)) : 0}`,\n\t\t`Path=${path}`,\n\t\t'HttpOnly',\n\t\t...(secure ? ['Secure'] : []),\n\t\t`SameSite=${SAME_SITE[sameSite]}`,\n\t].join('; ');\n}\n\n/** The raw values of the request's cookies named `name`, in order, trimmed. */\nfunction* rawValues(request: Request, name: string): Generator<string> {\n\tfor (const pair of request.headers.get('cookie')?.split(';') ?? []) {\n\t\tconst index = pair.indexOf('=');\n\t\tif (index >= 0 && pair.slice(0, index).trim() === name) {\n\t\t\tyield pair.slice(index + 1).trim();\n\t\t}\n\t}\n}\n\n/**\n * A cookie of the request: the first one of that name that is not empty,\n * decoded; `null` when there is none, or when it is not valid percent-encoding.\n */\nexport function readCookie(request: Request, name: string): string | null {\n\tfor (const raw of rawValues(request, name)) {\n\t\tif (!raw) continue;\n\t\ttry {\n\t\t\treturn decodeURIComponent(raw);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\treturn null;\n}\n\n/** Whether the request has a cookie named `name`, whatever its value. */\nexport function hasCookie(request: Request, name: string): boolean {\n\treturn !rawValues(request, name).next().done;\n}\n\n/** An instant as milliseconds; 0 when it is not a date. */\nexport function millisOf(at: string | Date): number {\n\tconst time = typeof at === 'string' ? Date.parse(at) : at.getTime();\n\treturn Number.isNaN(time) ? 0 : time;\n}\n\n/** Seconds from `now` until `expiresAt`: 0 when past or unreadable. */\nexport function secondsUntil(\n\texpiresAt: string | Date,\n\tnow: number = Date.now(),\n): number {\n\tconst end = millisOf(expiresAt);\n\treturn end === 0 ? 0 : Math.max(0, (end - now) / 1000);\n}\n",
6
+ "import {\n\tcheckSameSite,\n\thasCookie,\n\tisCookieName,\n\tisCookiePath,\n\tmillisOf,\n\treadCookie,\n\ttype SameSite,\n\tsecondsUntil,\n\tserializeCookie,\n} from './serialize';\n\n/** What every `sessionCookies` call takes, with or without a second factor. */\nexport interface SessionCookiesBaseOptions {\n\t/**\n\t * The base name of the session cookie, e.g. `'my-app_session'`. With\n\t * `secure`, the cookie is named `__Host-my-app_session`.\n\t */\n\treadonly session: string;\n\t/**\n\t * The app is served over HTTPS. Required, and never read from the\n\t * environment: pass `!import.meta.env.DEV`. `false` drops `Secure` and the\n\t * prefixes (Safari drops a `Secure` cookie over `http://localhost`).\n\t */\n\treadonly secure: boolean;\n\t/**\n\t * The `SameSite` attribute of every cookie written. `'lax'` by default;\n\t * `'strict'` for an app no other site links into signed in; `'none'`\n\t * needs `secure`.\n\t */\n\treadonly sameSite?: SameSite | undefined;\n}\n\n/** The options of an app with no second factor: no challenge cookie. */\nexport interface SessionCookiesWithoutChallengeOptions\n\textends SessionCookiesBaseOptions {\n\treadonly challenge?: undefined;\n\treadonly challengePath?: undefined;\n\treadonly challengeHostPrefix?: undefined;\n\treadonly challengeSeconds?: undefined;\n}\n\n/** The options of an app with a second factor: the challenge cookie's name is given. */\nexport interface SessionCookiesOptions extends SessionCookiesBaseOptions {\n\t/**\n\t * The base name of the second-factor challenge's cookie. With `secure`, it\n\t * is named `__Secure-<name>`.\n\t */\n\treadonly challenge: string;\n\t/** Where the browser sends the challenge. `'/sign-in'` by default. */\n\treadonly challengePath?: string | undefined;\n\t/**\n\t * Name the challenge cookie `__Host-<name>` instead of `__Secure-<name>`\n\t * (with `secure`). `__Host-` also forbids a `Domain`, so a sibling\n\t * subdomain cannot plant a cookie of the same name: pick it for an app on\n\t * per-tenant subdomains. It needs `Path=/`, so `challengePath: '/'` must\n\t * be passed too, else a `TypeError`. `false` by default.\n\t */\n\treadonly challengeHostPrefix?: boolean | undefined;\n\t/** The most the challenge lives. 300, `@softistx/janus`'s lifetime, by default. */\n\treadonly challengeSeconds?: number | undefined;\n}\n\n/** What the session cookie holds: the token, and the expiry (ms) it was last set to. */\nexport interface CookieSession {\n\treadonly token: string;\n\treadonly expiresAt: number;\n}\n\n/** The cookies every BFF has: the session's. */\nexport interface SessionCookiesBase {\n\t/** The names as sent, prefixes included. */\n\treadonly names: { readonly session: string };\n\t/** The session cookie of the request; `null` when absent or not `<ms>.<token>`. */\n\tread(request: Request): CookieSession | null;\n\t/** The session token of the request, or `null`. */\n\ttoken(request: Request): string | null;\n\t/**\n\t * Whether the request carries the session cookie at all, readable or not: a\n\t * guest page clears an unreadable one with `destroy()`.\n\t */\n\tpresent(request: Request): boolean;\n\t/** A `Set-Cookie` value keeping `token` until `expiresAt`. */\n\tcommit(token: string, expiresAt: string | Date, now?: number): string;\n\t/** A `Set-Cookie` value removing the session cookie. */\n\tdestroy(): string;\n\t/** The `Set-Cookie` header that keeps the cookie as long as the session lives; empty when the expiry did not move, or is absent or not a date. */\n\trefreshed(\n\t\tsession: CookieSession,\n\t\texpiresAt: string | Date | null,\n\t): HeadersInit;\n\t/**\n\t * What a signed-out visit of the sign-in page sets: a dead session's\n\t * cookie when `deadSession` (and, with a second factor, the challenge\n\t * cleared blind: a client navigation fetches `/sign-in.data`, which the\n\t * cookie's path does not match, so the request never shows it).\n\t */\n\tsignInPageHeaders(deadSession: boolean): Headers;\n}\n\n/** The challenge cookie's helpers, present when `challenge` was given. */\nexport interface ChallengeCookies {\n\treadonly names: { readonly challenge: string };\n\t/** The challenge cookie of the request, or `null`. */\n\tchallengeOf(request: Request): string | null;\n\t/** A `Set-Cookie` value keeping the challenge for the code page. */\n\tcommitChallenge(\n\t\tchallenge: string,\n\t\texpiresAt?: string | Date | null,\n\t\tnow?: number,\n\t): string;\n\t/** A `Set-Cookie` value removing the challenge. */\n\tdestroyChallenge(): string;\n}\n\n/**\n * The cookies `sessionCookies` returns: with the challenge helpers (the\n * default) when `challenge` was given, `SessionCookies<false>` without.\n */\nexport type SessionCookies<WithChallenge extends boolean = true> =\n\tWithChallenge extends true\n\t\t? SessionCookiesBase & ChallengeCookies\n\t\t: SessionCookiesBase & NoChallengeCookies;\n\n/**\n * What `SessionCookies<false>` says of the challenge helpers: they are\n * absent. Declared as `undefined` so that a set with a challenge is not\n * assignable to it (a flow with no second factor refuses one at compile time).\n */\nexport interface NoChallengeCookies {\n\treadonly challengeOf?: undefined;\n\treadonly commitChallenge?: undefined;\n\treadonly destroyChallenge?: undefined;\n}\n\nconst PREFIX = /^__(?:Host|Secure)-/;\n\nfunction checkName(label: string, name: string): void {\n\tif (!isCookieName(name)) {\n\t\tthrow new TypeError(\n\t\t\t`sessionCookies(): the ${label} name ${JSON.stringify(name)} is not a cookie name (an RFC 6265 token: letters, digits and ! # $ % & ' * + - . ^ _ \\` | ~). Pass a name such as \"my-app_${label}\".`,\n\t\t);\n\t}\n\tif (PREFIX.test(name)) {\n\t\tthrow new TypeError(\n\t\t\t`sessionCookies(): the ${label} name ${JSON.stringify(name)} already carries a prefix. Pass the base name: the package adds __Host- (session) or __Secure- (challenge) when secure is true.`,\n\t\t);\n\t}\n}\n\n/**\n * The cookies of a BFF's session and, when `challenge` is given, of its\n * second-factor challenge. Without `challenge`, the result has no challenge\n * helpers and the type says so.\n *\n * @example\n * const cookies = sessionCookies({ session: 'my-app_session', secure: true });\n */\nexport function sessionCookies(\n\toptions: SessionCookiesOptions,\n): SessionCookies<true>;\nexport function sessionCookies(\n\toptions: SessionCookiesWithoutChallengeOptions,\n): SessionCookies<false>;\nexport function sessionCookies(\n\toptions: SessionCookiesBaseOptions & {\n\t\treadonly challenge?: string | undefined;\n\t\treadonly challengePath?: string | undefined;\n\t\treadonly challengeHostPrefix?: boolean | undefined;\n\t\treadonly challengeSeconds?: number | undefined;\n\t},\n): SessionCookies<boolean>;\nexport function sessionCookies(\n\toptions: SessionCookiesBaseOptions & {\n\t\treadonly challenge?: string | undefined;\n\t\treadonly challengePath?: string | undefined;\n\t\treadonly challengeHostPrefix?: boolean | undefined;\n\t\treadonly challengeSeconds?: number | undefined;\n\t},\n): SessionCookies<boolean> {\n\tconst {\n\t\tsecure,\n\t\tsameSite = 'lax',\n\t\tchallengePath = '/sign-in',\n\t\tchallengeHostPrefix = false,\n\t\tchallengeSeconds = 5 * 60,\n\t} = options;\n\tcheckSameSite('sessionCookies():', sameSite, secure);\n\tcheckName('session', options.session);\n\tif (options.challenge !== undefined)\n\t\tcheckName('challenge', options.challenge);\n\tif (!Number.isInteger(challengeSeconds) || challengeSeconds <= 0) {\n\t\tthrow new TypeError(\n\t\t\t`sessionCookies(): challengeSeconds must be a positive integer; got ${String(challengeSeconds)}.`,\n\t\t);\n\t}\n\tif (!isCookiePath(challengePath)) {\n\t\tthrow new TypeError(\n\t\t\t`sessionCookies(): challengePath must start with \"/\" and hold no \";\" or control character; got ${JSON.stringify(challengePath)}.`,\n\t\t);\n\t}\n\tif (challengeHostPrefix && options.challenge !== undefined) {\n\t\tif (options.challengePath !== '/') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`sessionCookies(): challengeHostPrefix needs challengePath: \"/\" (a __Host- cookie must have Path=/); got ${JSON.stringify(options.challengePath)}.`,\n\t\t\t);\n\t\t}\n\t}\n\t// `__Host-` holds only with `Path=/` and no `Domain`: the session cookie\n\t// sets neither option.\n\tconst session = secure ? `__Host-${options.session}` : options.session;\n\tconst challengeName =\n\t\toptions.challenge === undefined\n\t\t\t? undefined\n\t\t\t: secure\n\t\t\t\t? `${challengeHostPrefix ? '__Host-' : '__Secure-'}${options.challenge}`\n\t\t\t\t: options.challenge;\n\tconst clear = (name: string, path?: string) =>\n\t\tserializeCookie(name, '', {\n\t\t\tmaxAge: 0,\n\t\t\tsecure,\n\t\t\tsameSite,\n\t\t\t...(path && { path }),\n\t\t});\n\n\tconst read = (request: Request): CookieSession | null => {\n\t\tconst value = readCookie(request, session);\n\t\tconst dot = value?.indexOf('.') ?? -1;\n\t\tif (!value || dot < 1) return null;\n\t\tconst digits = value.slice(0, dot);\n\t\tconst expiresAt = Number(digits);\n\t\tconst token = value.slice(dot + 1);\n\t\treturn token && /^\\d+$/.test(digits) && Number.isSafeInteger(expiresAt)\n\t\t\t? { token, expiresAt }\n\t\t\t: null;\n\t};\n\t// The value is `<expiry ms>.<token>`: the expiry only tells a later request\n\t// whether the API moved it, so the cookie is set again then. It is never\n\t// trusted: the API alone decides whether a session is valid.\n\tconst commit = (token: string, expiresAt: string | Date, now?: number) =>\n\t\tserializeCookie(session, `${millisOf(expiresAt)}.${token}`, {\n\t\t\tmaxAge: secondsUntil(expiresAt, now),\n\t\t\tsecure,\n\t\t\tsameSite,\n\t\t});\n\n\tconst base: SessionCookiesBase = {\n\t\tnames: { session },\n\t\tread,\n\t\ttoken: (request) => read(request)?.token ?? null,\n\t\tpresent: (request) => hasCookie(request, session),\n\t\tcommit,\n\t\tdestroy: () => clear(session),\n\t\trefreshed(current, expiresAt) {\n\t\t\t// An expiry that is not a date is garbage, not an end: keep the cookie.\n\t\t\tconst end = expiresAt ? millisOf(expiresAt) : 0;\n\t\t\tif (!expiresAt || end === 0 || end === current.expiresAt) return {};\n\t\t\treturn { 'Set-Cookie': commit(current.token, expiresAt) };\n\t\t},\n\t\tsignInPageHeaders(deadSession) {\n\t\t\tconst headers = new Headers();\n\t\t\tif (challengeName) {\n\t\t\t\theaders.append('Set-Cookie', clear(challengeName, challengePath));\n\t\t\t}\n\t\t\tif (deadSession) headers.append('Set-Cookie', clear(session));\n\t\t\treturn headers;\n\t\t},\n\t};\n\tif (challengeName === undefined) return base;\n\tconst challengeCookies: ChallengeCookies = {\n\t\tnames: { challenge: challengeName },\n\t\tchallengeOf: (request) => readCookie(request, challengeName),\n\t\tcommitChallenge: (value, expiresAt, now) =>\n\t\t\tserializeCookie(challengeName, value, {\n\t\t\t\tmaxAge: Math.min(\n\t\t\t\t\tchallengeSeconds,\n\t\t\t\t\texpiresAt ? secondsUntil(expiresAt, now) : challengeSeconds,\n\t\t\t\t),\n\t\t\t\tpath: challengePath,\n\t\t\t\tsecure,\n\t\t\t\tsameSite,\n\t\t\t}),\n\t\tdestroyChallenge: () => clear(challengeName, challengePath),\n\t};\n\treturn {\n\t\t...base,\n\t\t...challengeCookies,\n\t\tnames: { session, challenge: challengeName },\n\t};\n}\n\n/** The `Set-Cookie` values that clear the challenge: none without a second factor. */\nexport function challengeCleared(cookies: SessionCookies<boolean>): string[] {\n\treturn cookies.destroyChallenge ? [cookies.destroyChallenge()] : [];\n}\n"
7
+ ],
8
+ "mappings": ";AAqBA,IAAM,YAAY,EAAE,KAAK,OAAO,QAAQ,UAAU,MAAM,OAAO;AAGxD,SAAS,aAAa,CAC5B,QACA,UACA,QAC+B;AAAA,EAC/B,IAAI,CAAC,OAAO,OAAO,WAAW,QAAQ,GAAG;AAAA,IACxC,MAAM,IAAI,UACT,GAAG,2DAA2D,KAAK,UAAU,QAAQ,IACtF;AAAA,EACD;AAAA,EACA,IAAI,aAAa,UAAU,CAAC,QAAQ;AAAA,IACnC,MAAM,IAAI,UACT,GAAG,0GACJ;AAAA,EACD;AAAA;AAID,IAAM,QAAQ;AAGd,IAAM,OAAO;AAGN,IAAM,eAAe,CAAC,SAA0B,MAAM,KAAK,IAAI;AAE/D,IAAM,eAAe,CAAC,SAA0B,KAAK,KAAK,IAAI;AAO9D,SAAS,gBAAe,CAC9B,MACA,SACE,QAAQ,OAAO,KAAK,QAAQ,WAAW,SAChC;AAAA,EACT,IAAI,CAAC,aAAa,IAAI,GAAG;AAAA,IACxB,MAAM,IAAI,UACT,+BAA+B,KAAK,UAAU,IAAI,6CACnD;AAAA,EACD;AAAA,EACA,IAAI,CAAC,aAAa,IAAI,GAAG;AAAA,IACxB,MAAM,IAAI,UACT,+BAA+B,KAAK,UAAU,IAAI,sFACnD;AAAA,EACD;AAAA,EACA,cAAc,sBAAsB,UAAU,MAAM;AAAA,EACpD,OAAO;AAAA,IACN,GAAG,QAAQ,mBAAmB,KAAK;AAAA,IACnC,WAAW,OAAO,SAAS,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,MAAM,CAAC,IAAI;AAAA,IACvE,QAAQ;AAAA,IACR;A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,MACA,IAAI;AAAA,QAAa,QAAQ,OAAO,cAAc,MAAM,OAAO,CAAC;AAAA,MAC5D,OAAO;AAAA;AAAA,EAET;AAAA,EACA,IAAI,kBAAkB;AAAA,IAAW,OAAO;AAAA,EACxC,MAAM,mBAAqC;AAAA,IAC1C,OAAO,EAAE,WAAW,cAAc;AAAA,IAClC,aAAa,CAAC,YAAY,YAAW,SAAS,aAAa;AAAA,IAC3D,iBAAiB,CAAC,OAAO,WAAW,QACnC,iBAAgB,eAAe,OAAO;AAAA,MACrC,QAAQ,KAAK,IACZ,kBACA,YAAY,cAAa,WAAW,GAAG,IAAI,gBAC5C;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACD,CAAC;AAAA,IACF,kBAAkB,MAAM,MAAM,eAAe,aAAa;AAAA,EAC3D;AAAA,EACA,OAAO;AAAA,OACH;AAAA,OACA;AAAA,IACH,OAAO,EAAE,SAAS,WAAW,cAAc;AAAA,EAC5C;AAAA;AAIM,SAAS,gBAAgB,CAAC,SAA4C;AAAA,EAC5E,OAAO,QAAQ,mBAAmB,CAAC,QAAQ,iBAAiB,CAAC,IAAI,CAAC;AAAA;",
9
+ "debugId": "F84AF96789A0E01964756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,10 @@
1
+ // src/pwa/worker/injected.ts
2
+ var PRECACHE_DEFINE = "globalThis.__ALXIA_PRECACHE__";
3
+ function injectedPrecache() {
4
+ return globalThis.__ALXIA_PRECACHE__;
5
+ }
6
+
7
+ export { PRECACHE_DEFINE, injectedPrecache };
8
+
9
+ //# debugId=CA917CBC5F688F4264756E2164756E21
10
+ //# sourceMappingURL=index-59vhfj6n.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/pwa/worker/injected.ts"],
4
+ "sourcesContent": [
5
+ "/** The define key the build sets: the worker's precache list, as JSON. */\nexport const PRECACHE_DEFINE = 'globalThis.__ALXIA_PRECACHE__';\n\n/** One file the worker precaches: its URL and a revision (`null` when hashed in the name). */\ntype Entry = { readonly url: string; readonly revision: string | null };\n\n/**\n * The precache list the build wrote into this worker, or `undefined` when the\n * worker did not go through the build. Read through `globalThis`, so a missing\n * define is `undefined`, never a `ReferenceError`.\n */\nexport function injectedPrecache(): readonly Entry[] | undefined {\n\treturn (globalThis as { __ALXIA_PRECACHE__?: readonly Entry[] })\n\t\t.__ALXIA_PRECACHE__;\n}\n"
6
+ ],
7
+ "mappings": ";AACO,IAAM,kBAAkB;AAUxB,SAAS,gBAAgB,GAAiC;AAAA,EAChE,OAAQ,WACN;AAAA;",
8
+ "debugId": "CA917CBC5F688F4264756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,34 @@
1
+ // src/pwa/model/precache-list.ts
2
+ var HASHED_ASSET = /^\/assets\/[^/]+-[\w-]{8}\.(?:js|css)$/;
3
+ function parseBrowserManifest2(source) {
4
+ const start = source.indexOf("{");
5
+ const end = source.lastIndexOf("}");
6
+ if (start < 0 || end < start) {
7
+ throw new Error("parseBrowserManifest(): not React Router's browser manifest (build/client/assets/manifest-*.js).");
8
+ }
9
+ return JSON.parse(source.slice(start, end + 1));
10
+ }
11
+ function precacheList2(manifest) {
12
+ const urls = new Set([manifest.url]);
13
+ for (const part of [manifest.entry, ...Object.values(manifest.routes)]) {
14
+ for (const url of [
15
+ ...part.module ? [part.module] : [],
16
+ ...part.imports ?? [],
17
+ ...part.css ?? []
18
+ ]) {
19
+ urls.add(url);
20
+ }
21
+ }
22
+ return [...urls].filter((url) => HASHED_ASSET.test(url)).map((url) => ({ url, revision: null }));
23
+ }
24
+ function assetPrecache2(assetFiles, include, base = "/assets/") {
25
+ return assetFiles.filter((file) => {
26
+ include.lastIndex = 0;
27
+ return include.test(file);
28
+ }).sort().map((file) => ({ url: `${base}${file}`, revision: null }));
29
+ }
30
+
31
+ export { parseBrowserManifest2, precacheList2, assetPrecache2 };
32
+
33
+ //# debugId=812DDA9793A6A64B64756E2164756E21
34
+ //# sourceMappingURL=index-5gqcpyyg.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/pwa/model/precache-list.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * What the service worker precaches, read from a build: every script and\n * stylesheet React Router's manifest names (the client entry and each\n * route's module, imports and CSS), and the manifest itself, so a client\n * navigation offline to a route never visited still finds its code. Only\n * hashed `/assets/` files: a new build names new files, so each precaches\n * under its own URL, revision `null`. Chunks only a component loads on\n * demand stay out: a cache-first route stores them the first time they load.\n *\n * Dependency-free: a build script runs it at build time.\n */\n\n/** A route or the entry, as `window.__reactRouterManifest` lists it. */\ntype ManifestModule = { module?: string; imports?: string[]; css?: string[] };\n\n/** The parts of React Router's browser manifest the list reads. */\nexport type BrowserManifest = {\n\turl: string;\n\tentry: ManifestModule;\n\troutes: Record<string, ManifestModule>;\n};\n\n/** A Workbox precache entry: a hashed URL needs no revision. */\nexport type PrecacheEntry = { url: string; revision: string | null };\n\n/** A Vite-hashed file under `/assets/`: `name-<8 hash chars>.js|css`. */\nconst HASHED_ASSET = /^\\/assets\\/[^/]+-[\\w-]{8}\\.(?:js|css)$/;\n\n/** Reads `window.__reactRouterManifest={…};` (build/client/assets/manifest-*.js). */\nexport function parseBrowserManifest(source: string): BrowserManifest {\n\tconst start = source.indexOf('{');\n\tconst end = source.lastIndexOf('}');\n\tif (start < 0 || end < start) {\n\t\tthrow new Error(\n\t\t\t\"parseBrowserManifest(): not React Router's browser manifest (build/client/assets/manifest-*.js).\",\n\t\t);\n\t}\n\treturn JSON.parse(source.slice(start, end + 1)) as BrowserManifest;\n}\n\n/** The hashed scripts and stylesheets every route needs, the manifest's own file first. */\nexport function precacheList(manifest: BrowserManifest): PrecacheEntry[] {\n\tconst urls = new Set<string>([manifest.url]);\n\tfor (const part of [manifest.entry, ...Object.values(manifest.routes)]) {\n\t\tfor (const url of [\n\t\t\t...(part.module ? [part.module] : []),\n\t\t\t...(part.imports ?? []),\n\t\t\t...(part.css ?? []),\n\t\t]) {\n\t\t\turls.add(url);\n\t\t}\n\t}\n\treturn [...urls]\n\t\t.filter((url) => HASHED_ASSET.test(url))\n\t\t.map((url) => ({ url, revision: null }));\n}\n\n/**\n * The precache entries of the files among `assetFiles` (the names in\n * build/client/assets) that `include` matches, sorted, under `base`: fonts\n * an app keeps offline, say. The regex is the app's.\n */\nexport function assetPrecache(\n\tassetFiles: readonly string[],\n\tinclude: RegExp,\n\tbase = '/assets/',\n): PrecacheEntry[] {\n\treturn assetFiles\n\t\t.filter((file) => {\n\t\t\tinclude.lastIndex = 0; // a /g or /y regex remembers its last match\n\t\t\treturn include.test(file);\n\t\t})\n\t\t.sort()\n\t\t.map((file) => ({ url: `${base}${file}`, revision: null }));\n}\n"
6
+ ],
7
+ "mappings": ";AA0BA,IAAM,eAAe;AAGd,SAAS,qBAAoB,CAAC,QAAiC;AAAA,EACrE,MAAM,QAAQ,OAAO,QAAQ,GAAG;AAAA,EAChC,MAAM,MAAM,OAAO,YAAY,GAAG;AAAA,EAClC,IAAI,QAAQ,KAAK,MAAM,OAAO;AAAA,IAC7B,MAAM,IAAI,MACT,kGACD;AAAA,EACD;AAAA,EACA,OAAO,KAAK,MAAM,OAAO,MAAM,OAAO,MAAM,CAAC,CAAC;AAAA;AAIxC,SAAS,aAAY,CAAC,UAA4C;AAAA,EACxE,MAAM,OAAO,IAAI,IAAY,CAAC,SAAS,GAAG,CAAC;AAAA,EAC3C,WAAW,QAAQ,CAAC,SAAS,OAAO,GAAG,OAAO,OAAO,SAAS,MAAM,CAAC,GAAG;AAAA,IACvE,WAAW,OAAO;AAAA,MACjB,GAAI,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC;AAAA,MACnC,GAAI,KAAK,WAAW,CAAC;AAAA,MACrB,GAAI,KAAK,OAAO,CAAC;AAAA,IAClB,GAAG;AAAA,MACF,KAAK,IAAI,GAAG;AAAA,IACb;AAAA,EACD;AAAA,EACA,OAAO,CAAC,GAAG,IAAI,EACb,OAAO,CAAC,Q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